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