source: palm/trunk/SOURCE/palm.f90 @ 134

Last change on this file since 134 was 114, checked in by raasch, 17 years ago

preliminary updates for implementing buildings in poismg

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1 PROGRAM palm
2
3!------------------------------------------------------------------------------!
4! Actual revisions:
5! -----------------
6!
7!
8! Former revisions:
9! -----------------
10! $Id: palm.f90 114 2007-10-10 00:03:15Z letzel $
11!
12! 108 2007-08-24 15:10:38Z letzel
13! Get coupling mode from environment variable, change location of debug output
14!
15! 75 2007-03-22 09:54:05Z raasch
16! __vtk directives removed, write_particles is called only in case of particle
17! advection switched on, open unit 9 for debug output,
18! setting of palm version moved from modules to here
19!
20! RCS Log replace by Id keyword, revision history cleaned up
21!
22! Revision 1.10  2006/08/04 14:53:12  raasch
23! Distibution of run description header removed, call of header moved behind
24! init_3d_model
25!
26! Revision 1.2  2001/01/25 07:15:06  raasch
27! Program name changed to PALM, module test_variables removed.
28! Initialization of dvrp logging as well as exit of dvrp moved to new
29! subroutines init_dvrp_logging and close_dvrp (file init_dvrp.f90)
30!
31! Revision 1.1  1997/07/24 11:23:35  raasch
32! Initial revision
33!
34!
35! Description:
36! ------------
37! Large-Eddy Simulation (LES) model for the convective boundary layer,
38! optimized for use on parallel machines (implementation realized using the
39! Message Passing Interface (MPI)). The model can also be run on vector machines
40! (less well optimized) and workstations. Versions for the different types of
41! machines are controlled via cpp-directives.
42! Model runs are only feasible using the ksh-script mrun.
43!------------------------------------------------------------------------------!
44
45
46    USE arrays_3d
47    USE constants
48    USE control_parameters
49    USE cpulog
50    USE dvrp_variables
51    USE grid_variables
52    USE indices
53    USE interfaces
54    USE model_1d
55    USE particle_attributes
56    USE pegrid
57    USE spectrum
58    USE statistics
59
60    IMPLICIT NONE
61
62!
63!-- Local variables
64    CHARACTER (LEN=9) ::  time_to_string
65    CHARACTER (LEN=1) ::  cdum
66    INTEGER           ::  i, run_description_header_i(80)
67
68    version = 'PALM 3.4a'
69
70#if defined( __parallel )
71!
72!-- MPI initialisation. comm2d is preliminary set, because
73!-- it will be defined in init_pegrid but is used before in cpu_log.
74    CALL MPI_INIT( ierr )
75    CALL MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
76    comm_palm = MPI_COMM_WORLD
77    comm2d    = MPI_COMM_WORLD
78#endif
79
80#if defined( __mpi2 )
81!
82!-- Get information about the coupling mode from the environment variable
83!-- which has been set by the mpiexec command
84    CALL local_getenv( 'coupling_mode', 13, coupling_mode, i )
85    IF ( i == 0 )  coupling_mode = 'uncoupled'
86    IF ( coupling_mode == 'ocean_to_atmosphere' )  coupling_char = '_O'
87#endif
88
89!
90!-- Initialize measuring of the CPU-time remaining to the run
91    CALL local_tremain_ini
92
93!
94!-- Start of total CPU time measuring.
95    CALL cpu_log( log_point(1), 'total', 'start' )
96    CALL cpu_log( log_point(2), 'initialisation', 'start' )
97
98!
99!-- Initialize dvrp logging. Also, one PE maybe split from the global
100!-- communicator for doing the dvrp output. In that case, the number of
101!-- PEs available for PALM is reduced by one and communicator comm_palm
102!-- is changed respectively.
103#if defined( __parallel )
104    CALL MPI_COMM_RANK( comm_palm, myid, ierr )
105#endif
106
107!
108!-- Open a file for debug output
109    WRITE (myid_char,'(''_'',I4.4)')  myid
110    OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' )
111
112#if defined( __mpi2 )
113!
114!-- TEST OUTPUT (TO BE REMOVED)
115    WRITE(9,*) '*** coupling_mode = "', TRIM( coupling_mode ), '"'
116    CALL LOCAL_FLUSH( 9 )
117    print*, '*** PE', myid, '  ', TRIM( coupling_mode )
118#endif
119
120    CALL init_dvrp_logging
121
122!
123!-- Read control parameters from NAMELIST files and read environment-variables
124    CALL parin
125
126!
127!-- Determine processor topology and local array indices
128    CALL init_pegrid
129
130!
131!-- Generate grid parameters
132    CALL init_grid
133
134!
135!-- Check control parameters and deduce further quantities
136    CALL check_parameters
137
138!
139!-- Initialize all necessary variables
140    CALL init_3d_model
141
142!
143!-- Output of program header
144    IF ( myid == 0 )  CALL header
145
146    CALL cpu_log( log_point(2), 'initialisation', 'stop' )
147
148!
149!-- Set start time in format hh:mm:ss
150    simulated_time_chr = time_to_string( simulated_time )
151
152!
153!-- If required, output of initial arrays
154    IF ( do2d_at_begin )  THEN
155       CALL data_output_2d( 'xy', 0 )
156       CALL data_output_2d( 'xz', 0 )
157       CALL data_output_2d( 'yz', 0 )
158    ENDIF
159    IF ( do3d_at_begin )  THEN
160       CALL data_output_3d( 0 )
161    ENDIF
162
163!
164!-- Integration of the model equations using the leap-frog scheme
165    CALL time_integration
166
167!
168!-- If required, write binary data for model continuation runs
169    IF ( write_binary(1:4) == 'true' )  CALL write_3d_binary
170
171!
172!-- If required, write binary particle data
173    IF ( particle_advection )  CALL write_particles
174
175!
176!-- If required, repeat output of header including the required CPU-time
177    IF ( myid == 0 )  CALL header
178
179!
180!-- If required, final user-defined actions, and
181!-- last actions on the open files and close files. Unit 14 was opened
182!-- in write_3d_binary but it is closed here, to allow writing on this
183!-- unit in routine user_last_actions.
184    CALL cpu_log( log_point(4), 'last actions', 'start' )
185    CALL user_last_actions
186    IF ( write_binary(1:4) == 'true' )  CALL close_file( 14 )
187    CALL close_file( 0 )
188    CALL close_dvrp
189    CALL cpu_log( log_point(4), 'last actions', 'stop' )
190
191#if defined( __mpi2 )
192!
193!-- Test exchange via intercommunicator
194    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
195       i = 12345 + myid
196       CALL MPI_SEND( i, 1, MPI_INTEGER, myid, 11, comm_inter, ierr )
197    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
198       CALL MPI_RECV( i, 1, MPI_INTEGER, myid, 11, comm_inter, status, ierr )
199       PRINT*, '### myid: ', myid, '   received from atmosphere:  i = ', i
200    ENDIF
201#endif
202
203!
204!-- Take final CPU-time for CPU-time analysis
205    CALL cpu_log( log_point(1), 'total', 'stop' )
206    CALL cpu_statistics
207
208#if defined( __parallel )
209    CALL MPI_FINALIZE( ierr )
210#endif
211
212 END PROGRAM palm
213
Note: See TracBrowser for help on using the repository browser.