1 | PROGRAM palm |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! Initialization of coupled runs modified for MPI-1 and moved to external |
---|
7 | ! subroutine init_coupling |
---|
8 | ! |
---|
9 | ! Former revisions: |
---|
10 | ! ----------------- |
---|
11 | ! $Id: palm.f90 215 2008-11-18 09:54:31Z letzel $ |
---|
12 | ! |
---|
13 | ! 197 2008-09-16 15:29:03Z raasch |
---|
14 | ! Workaround for getting information about the coupling mode |
---|
15 | ! |
---|
16 | ! 108 2007-08-24 15:10:38Z letzel |
---|
17 | ! Get coupling mode from environment variable, change location of debug output |
---|
18 | ! |
---|
19 | ! 75 2007-03-22 09:54:05Z raasch |
---|
20 | ! __vtk directives removed, write_particles is called only in case of particle |
---|
21 | ! advection switched on, open unit 9 for debug output, |
---|
22 | ! setting of palm version moved from modules to here |
---|
23 | ! |
---|
24 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
25 | ! |
---|
26 | ! Revision 1.10 2006/08/04 14:53:12 raasch |
---|
27 | ! Distibution of run description header removed, call of header moved behind |
---|
28 | ! init_3d_model |
---|
29 | ! |
---|
30 | ! Revision 1.2 2001/01/25 07:15:06 raasch |
---|
31 | ! Program name changed to PALM, module test_variables removed. |
---|
32 | ! Initialization of dvrp logging as well as exit of dvrp moved to new |
---|
33 | ! subroutines init_dvrp_logging and close_dvrp (file init_dvrp.f90) |
---|
34 | ! |
---|
35 | ! Revision 1.1 1997/07/24 11:23:35 raasch |
---|
36 | ! Initial revision |
---|
37 | ! |
---|
38 | ! |
---|
39 | ! Description: |
---|
40 | ! ------------ |
---|
41 | ! Large-Eddy Simulation (LES) model for the convective boundary layer, |
---|
42 | ! optimized for use on parallel machines (implementation realized using the |
---|
43 | ! Message Passing Interface (MPI)). The model can also be run on vector machines |
---|
44 | ! (less well optimized) and workstations. Versions for the different types of |
---|
45 | ! machines are controlled via cpp-directives. |
---|
46 | ! Model runs are only feasible using the ksh-script mrun. |
---|
47 | !------------------------------------------------------------------------------! |
---|
48 | |
---|
49 | |
---|
50 | USE arrays_3d |
---|
51 | USE constants |
---|
52 | USE control_parameters |
---|
53 | USE cpulog |
---|
54 | USE dvrp_variables |
---|
55 | USE grid_variables |
---|
56 | USE indices |
---|
57 | USE interfaces |
---|
58 | USE model_1d |
---|
59 | USE particle_attributes |
---|
60 | USE pegrid |
---|
61 | USE spectrum |
---|
62 | USE statistics |
---|
63 | |
---|
64 | IMPLICIT NONE |
---|
65 | |
---|
66 | ! |
---|
67 | !-- Local variables |
---|
68 | CHARACTER (LEN=9) :: time_to_string |
---|
69 | CHARACTER (LEN=1) :: cdum |
---|
70 | INTEGER :: i, run_description_header_i(80) |
---|
71 | |
---|
72 | version = 'PALM 3.5' |
---|
73 | |
---|
74 | #if defined( __parallel ) |
---|
75 | ! |
---|
76 | !-- MPI initialisation. comm2d is preliminary set, because |
---|
77 | !-- it will be defined in init_pegrid but is used before in cpu_log. |
---|
78 | CALL MPI_INIT( ierr ) |
---|
79 | CALL MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr ) |
---|
80 | CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr ) |
---|
81 | comm_palm = MPI_COMM_WORLD |
---|
82 | comm2d = MPI_COMM_WORLD |
---|
83 | |
---|
84 | ! |
---|
85 | !-- Initialize PE topology in case of coupled runs |
---|
86 | CALL init_coupling |
---|
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 | !-- Open a file for debug output |
---|
100 | WRITE (myid_char,'(''_'',I4.4)') myid |
---|
101 | OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' ) |
---|
102 | |
---|
103 | ! |
---|
104 | !-- Initialize dvrp logging. Also, one PE maybe split from the global |
---|
105 | !-- communicator for doing the dvrp output. In that case, the number of |
---|
106 | !-- PEs available for PALM is reduced by one and communicator comm_palm |
---|
107 | !-- is changed respectively. |
---|
108 | #if defined( __parallel ) |
---|
109 | CALL MPI_COMM_RANK( comm_palm, myid, ierr ) |
---|
110 | ! |
---|
111 | !-- TEST OUTPUT (TO BE REMOVED) |
---|
112 | WRITE(9,*) '*** coupling_mode = "', TRIM( coupling_mode ), '"' |
---|
113 | CALL LOCAL_FLUSH( 9 ) |
---|
114 | IF ( TRIM( coupling_mode ) /= 'uncoupled' ) THEN |
---|
115 | PRINT*, '*** PE', myid, ' Global target PE:', target_id, & |
---|
116 | TRIM( coupling_mode ) |
---|
117 | ENDIF |
---|
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 in case of a MPI-2 coupling |
---|
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 |
---|