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