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