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

Last change on this file since 203 was 198, checked in by raasch, 16 years ago

file headers updated for the next release 3.5

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