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

Last change on this file since 558 was 557, checked in by weinreis, 14 years ago

bugfix message string in set_mask_locations

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