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