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