[1682] | 1 | !> @file palm.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1310] | 16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1] | 20 | ! ----------------- |
---|
[1748] | 21 | ! |
---|
[1784] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: palm.f90 1784 2016-03-06 19:14:40Z raasch $ |
---|
| 26 | ! |
---|
[1784] | 27 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 28 | ! required user interface version changed |
---|
| 29 | ! |
---|
[1782] | 30 | ! 1781 2016-03-03 15:12:23Z raasch |
---|
| 31 | ! pmc initialization moved from time_integration to here |
---|
| 32 | ! |
---|
[1780] | 33 | ! 1779 2016-03-03 08:01:28Z raasch |
---|
| 34 | ! setting of nest_domain and coupling_char moved to the pmci |
---|
| 35 | ! |
---|
[1765] | 36 | ! 1764 2016-02-28 12:45:19Z raasch |
---|
| 37 | ! cpp-statements for nesting removed, communicator settings cleaned up |
---|
| 38 | ! |
---|
[1763] | 39 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 40 | ! Introduction of nested domain feature |
---|
| 41 | ! |
---|
[1748] | 42 | ! 1747 2016-02-08 12:25:53Z raasch |
---|
| 43 | ! OpenACC-adjustment for new surface layer parameterization |
---|
| 44 | ! |
---|
[1683] | 45 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 46 | ! Code annotations made doxygen readable |
---|
| 47 | ! |
---|
[1669] | 48 | ! 1668 2015-09-23 13:45:36Z raasch |
---|
| 49 | ! warning replaced by abort in case of failed user interface check |
---|
| 50 | ! |
---|
[1667] | 51 | ! 1666 2015-09-23 07:31:10Z raasch |
---|
| 52 | ! check for user's interface version added |
---|
| 53 | ! |
---|
[1483] | 54 | ! 1482 2014-10-18 12:34:45Z raasch |
---|
| 55 | ! adjustments for using CUDA-aware OpenMPI |
---|
| 56 | ! |
---|
[1469] | 57 | ! 1468 2014-09-24 14:06:57Z maronga |
---|
| 58 | ! Adapted for use on up to 6-digit processor cores |
---|
| 59 | ! |
---|
[1403] | 60 | ! 1402 2014-05-09 14:25:13Z raasch |
---|
| 61 | ! location messages added |
---|
| 62 | ! |
---|
[1375] | 63 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 64 | ! bugfix: various modules added |
---|
| 65 | ! |
---|
[1321] | 66 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 67 | ! ONLY-attribute added to USE-statements, |
---|
| 68 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 69 | ! kinds are defined in new module kinds, |
---|
| 70 | ! old module precision_kind is removed, |
---|
| 71 | ! revision history before 2012 removed, |
---|
| 72 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 73 | ! all variable declaration statements |
---|
[77] | 74 | ! |
---|
[1319] | 75 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 76 | ! module interfaces removed |
---|
| 77 | ! |
---|
[1242] | 78 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 79 | ! initialization of nuding and large scale forcing from external file |
---|
| 80 | ! |
---|
[1222] | 81 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
| 82 | ! +wall_flags_00, rflags_invers, rflags_s_inner in copyin statement |
---|
| 83 | ! |
---|
[1213] | 84 | ! 1212 2013-08-15 08:46:27Z raasch |
---|
| 85 | ! +tri in copyin statement |
---|
| 86 | ! |
---|
[1182] | 87 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 88 | ! ref_state added to copyin-list |
---|
| 89 | ! |
---|
[1114] | 90 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
| 91 | ! openACC statements modified |
---|
| 92 | ! |
---|
[1112] | 93 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
| 94 | ! openACC statements updated |
---|
| 95 | ! |
---|
[1093] | 96 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 97 | ! unused variables removed |
---|
| 98 | ! |
---|
[1037] | 99 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 100 | ! code put under GPL (PALM 3.9) |
---|
| 101 | ! |
---|
[1017] | 102 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
[863] | 103 | ! Version number changed from 3.8 to 3.8a. |
---|
[1017] | 104 | ! OpenACC statements added + code changes required for GPU optimization |
---|
[863] | 105 | ! |
---|
[850] | 106 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 107 | ! write_particles renamed lpm_write_restart_file |
---|
| 108 | ! |
---|
[1] | 109 | ! Revision 1.1 1997/07/24 11:23:35 raasch |
---|
| 110 | ! Initial revision |
---|
| 111 | ! |
---|
| 112 | ! |
---|
| 113 | ! Description: |
---|
| 114 | ! ------------ |
---|
[1682] | 115 | !> Large-Eddy Simulation (LES) model for the convective boundary layer, |
---|
| 116 | !> optimized for use on parallel machines (implementation realized using the |
---|
| 117 | !> Message Passing Interface (MPI)). The model can also be run on vector machines |
---|
| 118 | !> (less well optimized) and workstations. Versions for the different types of |
---|
| 119 | !> machines are controlled via cpp-directives. |
---|
| 120 | !> Model runs are only feasible using the ksh-script mrun. |
---|
[1] | 121 | !------------------------------------------------------------------------------! |
---|
[1682] | 122 | PROGRAM palm |
---|
| 123 | |
---|
[1] | 124 | |
---|
[1374] | 125 | USE arrays_3d |
---|
[1] | 126 | |
---|
[1320] | 127 | USE control_parameters, & |
---|
[1781] | 128 | ONLY: constant_diffusion, coupling_char, coupling_mode, & |
---|
| 129 | do2d_at_begin, do3d_at_begin, humidity, io_blocks, io_group, & |
---|
| 130 | large_scale_forcing, message_string, nest_domain, nudging, & |
---|
| 131 | passive_scalar, simulated_time, simulated_time_chr, & |
---|
[1666] | 132 | user_interface_current_revision, & |
---|
| 133 | user_interface_required_revision, version, wall_heatflux, & |
---|
| 134 | write_binary |
---|
[1320] | 135 | |
---|
| 136 | USE cpulog, & |
---|
| 137 | ONLY: cpu_log, log_point, cpu_statistics |
---|
| 138 | |
---|
[1374] | 139 | USE grid_variables, & |
---|
| 140 | ONLY: fxm, fxp, fym, fyp, fwxm, fwxp, fwym, fwyp, wall_e_x, wall_e_y, & |
---|
| 141 | wall_u, wall_v, wall_w_x, wall_w_y |
---|
| 142 | |
---|
| 143 | USE indices, & |
---|
[1781] | 144 | ONLY: nbgp, ngp_2dh, ngp_2dh_s_inner, nzb_diff_s_inner, nzb_diff_s_outer, & |
---|
[1666] | 145 | nzb_diff_u, nzb_diff_v, nzb_s_inner, nzb_s_outer, nzb_u_inner, & |
---|
| 146 | nzb_u_outer, nzb_v_inner, nzb_v_outer, nzb_w_inner, & |
---|
| 147 | nzb_w_outer, rflags_invers, rflags_s_inner, wall_flags_0, & |
---|
| 148 | wall_flags_00 |
---|
[1374] | 149 | |
---|
[1320] | 150 | USE kinds |
---|
| 151 | |
---|
| 152 | USE ls_forcing_mod, & |
---|
| 153 | ONLY: init_ls_forcing |
---|
| 154 | |
---|
| 155 | USE nudge_mod, & |
---|
| 156 | ONLY: init_nudge |
---|
| 157 | |
---|
| 158 | USE particle_attributes, & |
---|
| 159 | ONLY: particle_advection |
---|
| 160 | |
---|
[1] | 161 | USE pegrid |
---|
| 162 | |
---|
[1762] | 163 | USE pmc_interface, & |
---|
[1781] | 164 | ONLY: cpl_id, nested_run, pmci_client_initialize, pmci_init, & |
---|
| 165 | pmci_modelconfiguration, pmci_server_initialize |
---|
[1762] | 166 | |
---|
[1374] | 167 | USE statistics, & |
---|
| 168 | ONLY: hom, rmask, weight_pres, weight_substep |
---|
| 169 | |
---|
[1747] | 170 | USE surface_layer_fluxes_mod, & |
---|
| 171 | ONLY: pt1, qv1, uv_total |
---|
| 172 | |
---|
[1015] | 173 | #if defined( __openacc ) |
---|
| 174 | USE OPENACC |
---|
| 175 | #endif |
---|
| 176 | |
---|
[1] | 177 | IMPLICIT NONE |
---|
| 178 | |
---|
| 179 | ! |
---|
| 180 | !-- Local variables |
---|
[1682] | 181 | CHARACTER(LEN=9) :: time_to_string !< |
---|
| 182 | CHARACTER(LEN=10) :: env_string !< to store string of environment var |
---|
| 183 | INTEGER(iwp) :: env_stat !< to hold status of GET_ENV |
---|
| 184 | INTEGER(iwp) :: i !< |
---|
| 185 | INTEGER(iwp) :: myid_openmpi !< OpenMPI local rank for CUDA aware MPI |
---|
[1015] | 186 | #if defined( __openacc ) |
---|
[1682] | 187 | REAL(wp), DIMENSION(100) :: acc_dum !< |
---|
[1015] | 188 | #endif |
---|
[1] | 189 | |
---|
[1539] | 190 | version = 'PALM 4.0' |
---|
[1783] | 191 | user_interface_required_revision = 'r1783' |
---|
[75] | 192 | |
---|
[1] | 193 | #if defined( __parallel ) |
---|
| 194 | ! |
---|
| 195 | !-- MPI initialisation. comm2d is preliminary set, because |
---|
| 196 | !-- it will be defined in init_pegrid but is used before in cpu_log. |
---|
| 197 | CALL MPI_INIT( ierr ) |
---|
[1762] | 198 | |
---|
| 199 | ! |
---|
| 200 | !-- Initialize the coupling for nested-domain runs |
---|
[1764] | 201 | !-- comm_palm is the communicator which includes all PEs (MPI processes) |
---|
| 202 | !-- available for this (nested) model. If it is not a nested run, comm_palm |
---|
| 203 | !-- is returned as MPI_COMM_WORLD |
---|
[1762] | 204 | CALL pmci_init( comm_palm ) |
---|
| 205 | comm2d = comm_palm |
---|
[1764] | 206 | ! |
---|
| 207 | !-- Get the (preliminary) number of MPI processes and the local PE-id (in case |
---|
| 208 | !-- of a further communicator splitting in init_coupling, these numbers will |
---|
| 209 | !-- be changed in init_pegrid). |
---|
| 210 | IF ( nested_run ) THEN |
---|
[1762] | 211 | |
---|
[1764] | 212 | CALL MPI_COMM_SIZE( comm_palm, numprocs, ierr ) |
---|
| 213 | CALL MPI_COMM_RANK( comm_palm, myid, ierr ) |
---|
[1762] | 214 | |
---|
[1764] | 215 | ELSE |
---|
| 216 | |
---|
| 217 | CALL MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr ) |
---|
| 218 | CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr ) |
---|
[1] | 219 | ! |
---|
[1764] | 220 | !-- Initialize PE topology in case of coupled atmosphere-ocean runs (comm_palm |
---|
| 221 | !-- will be splitted in init_coupling) |
---|
| 222 | CALL init_coupling |
---|
| 223 | ENDIF |
---|
[102] | 224 | #endif |
---|
| 225 | |
---|
[1015] | 226 | #if defined( __openacc ) |
---|
[102] | 227 | ! |
---|
[1482] | 228 | !-- Get the local MPI rank in case of CUDA aware OpenMPI. Important, if there |
---|
| 229 | !-- is more than one accelerator board on the node |
---|
| 230 | CALL GET_ENVIRONMENT_VARIABLE('OMPI_COMM_WORLD_LOCAL_RANK', & |
---|
| 231 | VALUE=env_string, STATUS=env_stat ) |
---|
| 232 | READ( env_string, '(I1)' ) myid_openmpi |
---|
| 233 | PRINT*, '### local_rank = ', myid_openmpi, ' status=',env_stat |
---|
| 234 | ! |
---|
[1015] | 235 | !-- Get the number of accelerator boards per node and assign the MPI processes |
---|
| 236 | !-- to these boards |
---|
[1092] | 237 | PRINT*, '*** ACC_DEVICE_NVIDIA = ', ACC_DEVICE_NVIDIA |
---|
[1015] | 238 | num_acc_per_node = ACC_GET_NUM_DEVICES( ACC_DEVICE_NVIDIA ) |
---|
[1092] | 239 | IF ( numprocs == 1 .AND. num_acc_per_node > 0 ) num_acc_per_node = 1 |
---|
[1482] | 240 | PRINT*, '*** myid = ', myid_openmpi, ' num_acc_per_node = ', num_acc_per_node |
---|
| 241 | acc_rank = MOD( myid_openmpi, num_acc_per_node ) |
---|
[1015] | 242 | CALL ACC_SET_DEVICE_NUM ( acc_rank, ACC_DEVICE_NVIDIA ) |
---|
| 243 | ! |
---|
| 244 | !-- Test output (to be removed later) |
---|
[1482] | 245 | WRITE (*,'(A,I6,A,I3,A,I3,A,I3)') '*** Connect MPI-Task ', myid_openmpi, & |
---|
| 246 | ' to CPU ', acc_rank, ' Devices: ', & |
---|
| 247 | num_acc_per_node, ' connected to:', & |
---|
[1015] | 248 | ACC_GET_DEVICE_NUM( ACC_DEVICE_NVIDIA ) |
---|
| 249 | #endif |
---|
[1092] | 250 | |
---|
[1015] | 251 | ! |
---|
| 252 | !-- Ensure that OpenACC first attaches the GPU devices by copying a dummy data |
---|
| 253 | !-- region |
---|
| 254 | !$acc data copyin( acc_dum ) |
---|
| 255 | |
---|
| 256 | ! |
---|
[1] | 257 | !-- Initialize measuring of the CPU-time remaining to the run |
---|
| 258 | CALL local_tremain_ini |
---|
| 259 | |
---|
| 260 | ! |
---|
| 261 | !-- Start of total CPU time measuring. |
---|
| 262 | CALL cpu_log( log_point(1), 'total', 'start' ) |
---|
| 263 | CALL cpu_log( log_point(2), 'initialisation', 'start' ) |
---|
| 264 | |
---|
| 265 | ! |
---|
[206] | 266 | !-- Open a file for debug output |
---|
[1468] | 267 | WRITE (myid_char,'(''_'',I6.6)') myid |
---|
[206] | 268 | OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' ) |
---|
| 269 | |
---|
| 270 | ! |
---|
[1] | 271 | !-- Initialize dvrp logging. Also, one PE maybe split from the global |
---|
| 272 | !-- communicator for doing the dvrp output. In that case, the number of |
---|
| 273 | !-- PEs available for PALM is reduced by one and communicator comm_palm |
---|
| 274 | !-- is changed respectively. |
---|
| 275 | #if defined( __parallel ) |
---|
| 276 | CALL MPI_COMM_RANK( comm_palm, myid, ierr ) |
---|
| 277 | ! |
---|
[102] | 278 | !-- TEST OUTPUT (TO BE REMOVED) |
---|
| 279 | WRITE(9,*) '*** coupling_mode = "', TRIM( coupling_mode ), '"' |
---|
| 280 | CALL LOCAL_FLUSH( 9 ) |
---|
[215] | 281 | IF ( TRIM( coupling_mode ) /= 'uncoupled' ) THEN |
---|
| 282 | PRINT*, '*** PE', myid, ' Global target PE:', target_id, & |
---|
| 283 | TRIM( coupling_mode ) |
---|
| 284 | ENDIF |
---|
[102] | 285 | #endif |
---|
| 286 | |
---|
[108] | 287 | CALL init_dvrp_logging |
---|
| 288 | |
---|
[102] | 289 | ! |
---|
[108] | 290 | !-- Read control parameters from NAMELIST files and read environment-variables |
---|
| 291 | CALL parin |
---|
| 292 | |
---|
| 293 | ! |
---|
[1666] | 294 | !-- Check for the user's interface version |
---|
| 295 | IF ( user_interface_current_revision /= user_interface_required_revision ) & |
---|
| 296 | THEN |
---|
| 297 | message_string = 'current user-interface revision "' // & |
---|
| 298 | TRIM( user_interface_current_revision ) // '" does ' // & |
---|
| 299 | 'not match the required revision ' // & |
---|
| 300 | TRIM( user_interface_required_revision ) |
---|
[1668] | 301 | CALL message( 'palm', 'PA0169', 1, 2, 0, 6, 0 ) |
---|
[1666] | 302 | ENDIF |
---|
| 303 | |
---|
| 304 | ! |
---|
[108] | 305 | !-- Determine processor topology and local array indices |
---|
| 306 | CALL init_pegrid |
---|
| 307 | |
---|
| 308 | ! |
---|
[1] | 309 | !-- Generate grid parameters |
---|
| 310 | CALL init_grid |
---|
| 311 | |
---|
| 312 | ! |
---|
[1241] | 313 | !-- Initialize nudging if required |
---|
| 314 | IF ( nudging ) THEN |
---|
| 315 | CALL init_nudge |
---|
| 316 | ENDIF |
---|
| 317 | |
---|
| 318 | ! |
---|
| 319 | !-- Initialize reading of large scale forcing from external file - if required |
---|
| 320 | IF ( large_scale_forcing ) THEN |
---|
| 321 | CALL init_ls_forcing |
---|
| 322 | ENDIF |
---|
| 323 | |
---|
| 324 | ! |
---|
[1] | 325 | !-- Check control parameters and deduce further quantities |
---|
| 326 | CALL check_parameters |
---|
| 327 | |
---|
| 328 | ! |
---|
| 329 | !-- Initialize all necessary variables |
---|
| 330 | CALL init_3d_model |
---|
| 331 | |
---|
| 332 | ! |
---|
[1762] | 333 | !-- Coupling protocol setup for nested-domain runs |
---|
[1764] | 334 | IF ( nested_run ) THEN |
---|
| 335 | CALL pmci_modelconfiguration |
---|
[1781] | 336 | ! |
---|
| 337 | !-- Receive and interpolate initial data on client. |
---|
| 338 | !-- Client initialization must be made first if the model is both client and |
---|
| 339 | !-- server |
---|
| 340 | CALL pmci_client_initialize |
---|
| 341 | ! |
---|
| 342 | !-- Send initial condition data from server to client |
---|
| 343 | CALL pmci_server_initialize |
---|
| 344 | ! |
---|
| 345 | !-- Exchange_horiz is needed after the nest initialization |
---|
| 346 | IF ( nest_domain ) THEN |
---|
| 347 | CALL exchange_horiz( u, nbgp ) |
---|
| 348 | CALL exchange_horiz( v, nbgp ) |
---|
| 349 | CALL exchange_horiz( w, nbgp ) |
---|
| 350 | CALL exchange_horiz( pt, nbgp ) |
---|
| 351 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e, nbgp ) |
---|
| 352 | IF (humidity .OR. passive_scalar) THEN |
---|
| 353 | CALL exchange_horiz( q, nbgp ) |
---|
| 354 | ENDIF |
---|
| 355 | ENDIF |
---|
| 356 | |
---|
[1764] | 357 | ENDIF |
---|
[1762] | 358 | |
---|
[1781] | 359 | |
---|
[1762] | 360 | ! |
---|
[1] | 361 | !-- Output of program header |
---|
| 362 | IF ( myid == 0 ) CALL header |
---|
| 363 | |
---|
| 364 | CALL cpu_log( log_point(2), 'initialisation', 'stop' ) |
---|
| 365 | |
---|
| 366 | ! |
---|
| 367 | !-- Set start time in format hh:mm:ss |
---|
| 368 | simulated_time_chr = time_to_string( simulated_time ) |
---|
| 369 | |
---|
| 370 | ! |
---|
| 371 | !-- If required, output of initial arrays |
---|
| 372 | IF ( do2d_at_begin ) THEN |
---|
| 373 | CALL data_output_2d( 'xy', 0 ) |
---|
| 374 | CALL data_output_2d( 'xz', 0 ) |
---|
| 375 | CALL data_output_2d( 'yz', 0 ) |
---|
| 376 | ENDIF |
---|
| 377 | IF ( do3d_at_begin ) THEN |
---|
| 378 | CALL data_output_3d( 0 ) |
---|
| 379 | ENDIF |
---|
| 380 | |
---|
| 381 | ! |
---|
[1015] | 382 | !-- Declare and initialize variables in the accelerator memory with their |
---|
| 383 | !-- host values |
---|
[1113] | 384 | !$acc data copyin( d, diss, e, e_p, kh, km, p, pt, pt_p, q, ql, tend, te_m, tpt_m, tu_m, tv_m, tw_m, u, u_p, v, vpt, v_p, w, w_p ) & |
---|
[1212] | 385 | !$acc copyin( tri, tric, dzu, ddzu, ddzw, dd2zu, l_grid, l_wall, ptdf_x, ptdf_y, pt_init, rdf, rdf_sc, ref_state, ug, u_init, vg, v_init, zu, zw ) & |
---|
[1747] | 386 | !$acc copyin( hom, ol, pt1, qs, qsws, qswst, qv1, rif_wall, shf, ts, tswst, us, usws, uswst, uv_total, vsws, vswst, z0, z0h ) & |
---|
[1015] | 387 | !$acc copyin( fxm, fxp, fym, fyp, fwxm, fwxp, fwym, fwyp, nzb_diff_s_inner, nzb_diff_s_outer, nzb_diff_u ) & |
---|
| 388 | !$acc copyin( nzb_diff_v, nzb_s_inner, nzb_s_outer, nzb_u_inner ) & |
---|
| 389 | !$acc copyin( nzb_u_outer, nzb_v_inner, nzb_v_outer, nzb_w_inner ) & |
---|
[1221] | 390 | !$acc copyin( nzb_w_outer, rflags_invers, rflags_s_inner, rmask, wall_heatflux, wall_e_x, wall_e_y, wall_u, wall_v, wall_w_x, wall_w_y, wall_flags_0, wall_flags_00 ) & |
---|
| 391 | !$acc copyin( ngp_2dh, ngp_2dh_s_inner ) & |
---|
[1113] | 392 | !$acc copyin( weight_pres, weight_substep ) |
---|
[1015] | 393 | ! |
---|
[495] | 394 | !-- Integration of the model equations using timestep-scheme |
---|
[1] | 395 | CALL time_integration |
---|
| 396 | |
---|
| 397 | ! |
---|
[495] | 398 | !-- If required, write binary data for restart runs |
---|
| 399 | IF ( write_binary(1:4) == 'true' ) THEN |
---|
[759] | 400 | |
---|
| 401 | CALL cpu_log( log_point(22), 'write_3d_binary', 'start' ) |
---|
| 402 | |
---|
[1402] | 403 | CALL location_message( 'writing restart data', .FALSE. ) |
---|
| 404 | |
---|
[759] | 405 | CALL check_open( 14 ) |
---|
| 406 | |
---|
| 407 | DO i = 0, io_blocks-1 |
---|
| 408 | IF ( i == io_group ) THEN |
---|
[1] | 409 | ! |
---|
[759] | 410 | !-- Write flow field data |
---|
| 411 | CALL write_3d_binary |
---|
| 412 | ENDIF |
---|
| 413 | #if defined( __parallel ) |
---|
| 414 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 415 | #endif |
---|
| 416 | ENDDO |
---|
| 417 | |
---|
[1402] | 418 | CALL location_message( 'finished', .TRUE. ) |
---|
| 419 | |
---|
[759] | 420 | CALL cpu_log( log_point(22), 'write_3d_binary', 'stop' ) |
---|
| 421 | |
---|
[495] | 422 | ! |
---|
| 423 | !-- If required, write particle data |
---|
[849] | 424 | IF ( particle_advection ) CALL lpm_write_restart_file |
---|
[495] | 425 | ENDIF |
---|
[1] | 426 | |
---|
| 427 | ! |
---|
| 428 | !-- If required, repeat output of header including the required CPU-time |
---|
| 429 | IF ( myid == 0 ) CALL header |
---|
| 430 | ! |
---|
| 431 | !-- If required, final user-defined actions, and |
---|
| 432 | !-- last actions on the open files and close files. Unit 14 was opened |
---|
| 433 | !-- in write_3d_binary but it is closed here, to allow writing on this |
---|
| 434 | !-- unit in routine user_last_actions. |
---|
| 435 | CALL cpu_log( log_point(4), 'last actions', 'start' ) |
---|
[759] | 436 | DO i = 0, io_blocks-1 |
---|
| 437 | IF ( i == io_group ) THEN |
---|
| 438 | CALL user_last_actions |
---|
| 439 | IF ( write_binary(1:4) == 'true' ) CALL close_file( 14 ) |
---|
| 440 | ENDIF |
---|
| 441 | #if defined( __parallel ) |
---|
| 442 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 443 | #endif |
---|
| 444 | ENDDO |
---|
[1] | 445 | CALL close_file( 0 ) |
---|
| 446 | CALL close_dvrp |
---|
| 447 | CALL cpu_log( log_point(4), 'last actions', 'stop' ) |
---|
| 448 | |
---|
[102] | 449 | #if defined( __mpi2 ) |
---|
[1] | 450 | ! |
---|
[206] | 451 | !-- Test exchange via intercommunicator in case of a MPI-2 coupling |
---|
[102] | 452 | IF ( coupling_mode == 'atmosphere_to_ocean' ) THEN |
---|
| 453 | i = 12345 + myid |
---|
| 454 | CALL MPI_SEND( i, 1, MPI_INTEGER, myid, 11, comm_inter, ierr ) |
---|
| 455 | ELSEIF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
| 456 | CALL MPI_RECV( i, 1, MPI_INTEGER, myid, 11, comm_inter, status, ierr ) |
---|
| 457 | PRINT*, '### myid: ', myid, ' received from atmosphere: i = ', i |
---|
| 458 | ENDIF |
---|
| 459 | #endif |
---|
| 460 | |
---|
| 461 | ! |
---|
[1015] | 462 | !-- Close the OpenACC dummy data region |
---|
| 463 | !$acc end data |
---|
| 464 | !$acc end data |
---|
| 465 | |
---|
| 466 | ! |
---|
[1] | 467 | !-- Take final CPU-time for CPU-time analysis |
---|
| 468 | CALL cpu_log( log_point(1), 'total', 'stop' ) |
---|
| 469 | CALL cpu_statistics |
---|
| 470 | |
---|
| 471 | #if defined( __parallel ) |
---|
| 472 | CALL MPI_FINALIZE( ierr ) |
---|
| 473 | #endif |
---|
| 474 | |
---|
| 475 | END PROGRAM palm |
---|