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

Last change on this file since 495 was 495, checked in by raasch, 11 years ago

Particle data for restart runs are only written if write_binary=true

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