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