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