[4017] | 1 | ! !> @file palm.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 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 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[2233] | 22 | ! |
---|
[4539] | 23 | ! |
---|
[2233] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: palm.f90 4539 2020-05-18 14:05:17Z hellstea $ |
---|
[4539] | 27 | ! log point name changed |
---|
| 28 | ! |
---|
| 29 | ! 4535 2020-05-15 12:07:23Z raasch |
---|
[4535] | 30 | ! bugfix for restart data format query |
---|
| 31 | ! |
---|
| 32 | ! 4496 2020-04-15 08:37:26Z raasch |
---|
[4496] | 33 | ! bugfix: coupling character added to restart output filename |
---|
| 34 | ! |
---|
| 35 | ! 4495 2020-04-13 20:11:20Z raasch |
---|
[4495] | 36 | ! restart data handling with MPI-IO added |
---|
| 37 | ! |
---|
| 38 | ! 4457 2020-03-11 14:20:43Z raasch |
---|
[4457] | 39 | ! use statement for exchange horiz added |
---|
| 40 | ! |
---|
| 41 | ! 4444 2020-03-05 15:59:50Z raasch |
---|
[4444] | 42 | ! bugfix: cpp-directives for serial mode added |
---|
| 43 | ! |
---|
| 44 | ! 4414 2020-02-19 20:16:04Z suehring |
---|
[4414] | 45 | ! Call to module_interface_init_numerics |
---|
| 46 | ! |
---|
| 47 | ! 4400 2020-02-10 20:32:41Z suehring |
---|
[4400] | 48 | ! Add interface to initialize data output with dom |
---|
| 49 | ! |
---|
| 50 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4227] | 51 | ! implement new palm_date_time_mod |
---|
| 52 | ! |
---|
| 53 | ! 4094 2019-07-12 09:24:21Z gronemeier |
---|
[4182] | 54 | ! Corrected "Former revisions" section |
---|
| 55 | ! |
---|
| 56 | ! 4039 2019-06-18 10:32:41Z suehring |
---|
[4039] | 57 | ! Rename subroutines in module for diagnostic quantities |
---|
| 58 | ! |
---|
| 59 | ! 4017 2019-06-06 12:16:46Z schwenkel |
---|
[3994] | 60 | ! new module for calculation and output of diagnostic quantities added |
---|
| 61 | ! |
---|
| 62 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
[3885] | 63 | ! Changes related to global restructuring of location messages and introduction |
---|
| 64 | ! of additional debug messages |
---|
| 65 | ! |
---|
| 66 | ! 3761 2019-02-25 15:31:42Z raasch |
---|
[3761] | 67 | ! unused variable removed |
---|
| 68 | ! |
---|
| 69 | ! 3719 2019-02-06 13:10:18Z kanani |
---|
[3719] | 70 | ! Included cpu measurement for wall/soil spinup |
---|
| 71 | ! |
---|
| 72 | ! 3703 2019-01-29 16:43:53Z knoop |
---|
[3685] | 73 | ! Some interface calls moved to module_interface + cleanup |
---|
| 74 | ! |
---|
| 75 | ! 3648 2019-01-02 16:35:46Z suehring |
---|
[3648] | 76 | ! Rename subroutines for surface-data output |
---|
[3298] | 77 | ! |
---|
[4182] | 78 | ! Revision 1.1 1997/07/24 11:23:35 raasch |
---|
| 79 | ! Initial revision |
---|
| 80 | ! |
---|
| 81 | ! |
---|
[1] | 82 | ! Description: |
---|
| 83 | ! ------------ |
---|
[3232] | 84 | !> Large-Eddy Simulation (LES) model for atmospheric and oceanic boundary-layer |
---|
| 85 | !> flows |
---|
| 86 | !> see the PALM homepage https://palm-model.org for further information |
---|
[1] | 87 | !------------------------------------------------------------------------------! |
---|
[1682] | 88 | PROGRAM palm |
---|
| 89 | |
---|
[1] | 90 | |
---|
[1374] | 91 | USE arrays_3d |
---|
[1] | 92 | |
---|
[4444] | 93 | #if defined( __parallel ) |
---|
[3298] | 94 | USE bulk_cloud_model_mod, & |
---|
| 95 | ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert |
---|
[4444] | 96 | #endif |
---|
[3298] | 97 | |
---|
[1320] | 98 | USE control_parameters, & |
---|
[4444] | 99 | ONLY: coupling_char, do2d_at_begin, do3d_at_begin, io_blocks, & |
---|
[4495] | 100 | io_group, message_string, restart_data_format_output, runnr, simulated_time_chr, spinup, & |
---|
[3241] | 101 | time_since_reference_point, user_interface_current_revision, & |
---|
| 102 | user_interface_required_revision, version, write_binary |
---|
[1320] | 103 | |
---|
[4444] | 104 | #if defined( __parallel ) |
---|
| 105 | USE control_parameters, & |
---|
| 106 | ONLY: child_domain, constant_diffusion, humidity, & |
---|
| 107 | initializing_actions, neutral, passive_scalar |
---|
| 108 | #endif |
---|
| 109 | |
---|
[1320] | 110 | USE cpulog, & |
---|
[4444] | 111 | ONLY: cpu_log, log_point, cpu_statistics |
---|
[1320] | 112 | |
---|
[4444] | 113 | #if defined( __parallel ) |
---|
| 114 | USE cpulog, & |
---|
| 115 | ONLY: log_point_s |
---|
| 116 | #endif |
---|
| 117 | |
---|
[3994] | 118 | USE diagnostic_output_quantities_mod, & |
---|
[4039] | 119 | ONLY: doq_calculate |
---|
[3994] | 120 | |
---|
[4444] | 121 | #if defined( __parallel ) |
---|
[4457] | 122 | USE exchange_horiz_mod, & |
---|
| 123 | ONLY: exchange_horiz |
---|
| 124 | |
---|
[1374] | 125 | USE indices, & |
---|
[2232] | 126 | ONLY: nbgp |
---|
[4444] | 127 | #endif |
---|
[1374] | 128 | |
---|
[3274] | 129 | USE kinds |
---|
| 130 | |
---|
[3687] | 131 | USE module_interface, & |
---|
[4414] | 132 | ONLY: module_interface_init_numerics, & |
---|
| 133 | module_interface_init_output, & |
---|
[4400] | 134 | module_interface_last_actions |
---|
[3687] | 135 | |
---|
[4400] | 136 | |
---|
[3235] | 137 | USE multi_agent_system_mod, & |
---|
| 138 | ONLY: agents_active, mas_last_actions |
---|
| 139 | |
---|
[2696] | 140 | USE netcdf_data_input_mod, & |
---|
[3685] | 141 | ONLY: netcdf_data_input_inquire_file, netcdf_data_input_init, & |
---|
[2696] | 142 | netcdf_data_input_surface_data, netcdf_data_input_topo |
---|
| 143 | |
---|
[1] | 144 | USE pegrid |
---|
| 145 | |
---|
[4444] | 146 | #if defined( __parallel ) |
---|
[2894] | 147 | USE pmc_particle_interface, & |
---|
| 148 | ONLY: pmcp_g_alloc_win |
---|
| 149 | |
---|
[1762] | 150 | USE pmc_interface, & |
---|
[3241] | 151 | ONLY: nested_run, pmci_child_initialize, pmci_init, & |
---|
[3484] | 152 | pmci_modelconfiguration, pmci_parent_initialize |
---|
[4444] | 153 | #endif |
---|
[4414] | 154 | |
---|
[4495] | 155 | USE restart_data_mpi_io_mod, & |
---|
| 156 | ONLY: rd_mpi_io_close, rd_mpi_io_open |
---|
| 157 | |
---|
[3648] | 158 | USE surface_data_output_mod, & |
---|
| 159 | ONLY: surface_data_output_last_action |
---|
[1762] | 160 | |
---|
[2894] | 161 | USE write_restart_data_mod, & |
---|
| 162 | ONLY: wrd_global, wrd_local |
---|
[2801] | 163 | |
---|
[4444] | 164 | #if defined( __parallel ) && defined( _OPENACC ) |
---|
[3689] | 165 | USE openacc |
---|
| 166 | #endif |
---|
[1747] | 167 | |
---|
[3689] | 168 | |
---|
[1] | 169 | IMPLICIT NONE |
---|
| 170 | |
---|
| 171 | ! |
---|
| 172 | !-- Local variables |
---|
[3241] | 173 | CHARACTER(LEN=9) :: time_to_string !< |
---|
| 174 | INTEGER(iwp) :: i !< loop counter for blocked I/O |
---|
[3689] | 175 | #if defined( __parallel) && defined( _OPENACC ) |
---|
| 176 | INTEGER(iwp) :: local_comm !< local communicator (shared memory) |
---|
| 177 | INTEGER(iwp) :: local_num_procs !< local number of processes |
---|
| 178 | INTEGER(iwp) :: local_id !< local id |
---|
| 179 | INTEGER(acc_device_kind) :: device_type !< device type for OpenACC |
---|
| 180 | INTEGER(iwp) :: num_devices !< number of devices visible to OpenACC |
---|
| 181 | INTEGER(iwp) :: my_device !< device used by this process |
---|
| 182 | #endif |
---|
[1] | 183 | |
---|
[3487] | 184 | version = 'PALM 6.0' |
---|
[4495] | 185 | user_interface_required_revision = 'r4495' |
---|
[75] | 186 | |
---|
[1] | 187 | #if defined( __parallel ) |
---|
| 188 | ! |
---|
| 189 | !-- MPI initialisation. comm2d is preliminary set, because |
---|
| 190 | !-- it will be defined in init_pegrid but is used before in cpu_log. |
---|
| 191 | CALL MPI_INIT( ierr ) |
---|
[1762] | 192 | |
---|
| 193 | ! |
---|
| 194 | !-- Initialize the coupling for nested-domain runs |
---|
[1764] | 195 | !-- comm_palm is the communicator which includes all PEs (MPI processes) |
---|
| 196 | !-- available for this (nested) model. If it is not a nested run, comm_palm |
---|
| 197 | !-- is returned as MPI_COMM_WORLD |
---|
[2951] | 198 | CALL cpu_log( log_point_s(70), 'pmci_init', 'start' ) |
---|
[1762] | 199 | CALL pmci_init( comm_palm ) |
---|
[2951] | 200 | CALL cpu_log( log_point_s(70), 'pmci_init', 'stop' ) |
---|
[1762] | 201 | comm2d = comm_palm |
---|
[1764] | 202 | ! |
---|
| 203 | !-- Get the (preliminary) number of MPI processes and the local PE-id (in case |
---|
| 204 | !-- of a further communicator splitting in init_coupling, these numbers will |
---|
| 205 | !-- be changed in init_pegrid). |
---|
| 206 | IF ( nested_run ) THEN |
---|
[1762] | 207 | |
---|
[1764] | 208 | CALL MPI_COMM_SIZE( comm_palm, numprocs, ierr ) |
---|
| 209 | CALL MPI_COMM_RANK( comm_palm, myid, ierr ) |
---|
[1762] | 210 | |
---|
[1764] | 211 | ELSE |
---|
| 212 | |
---|
| 213 | CALL MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr ) |
---|
| 214 | CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr ) |
---|
[1] | 215 | ! |
---|
[1764] | 216 | !-- Initialize PE topology in case of coupled atmosphere-ocean runs (comm_palm |
---|
| 217 | !-- will be splitted in init_coupling) |
---|
| 218 | CALL init_coupling |
---|
| 219 | ENDIF |
---|
[3689] | 220 | |
---|
| 221 | #ifdef _OPENACC |
---|
| 222 | ! |
---|
| 223 | !-- Select OpenACC device to use in this process. For this find out how many |
---|
| 224 | !-- neighbors there are running on the same node and which id this process is. |
---|
| 225 | IF ( nested_run ) THEN |
---|
| 226 | CALL MPI_COMM_SPLIT_TYPE( comm_palm, MPI_COMM_TYPE_SHARED, 0, & |
---|
| 227 | MPI_INFO_NULL, local_comm, ierr ) |
---|
| 228 | ELSE |
---|
| 229 | CALL MPI_COMM_SPLIT_TYPE( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, & |
---|
| 230 | MPI_INFO_NULL, local_comm, ierr ) |
---|
| 231 | ENDIF |
---|
| 232 | CALL MPI_COMM_SIZE( local_comm, local_num_procs, ierr ) |
---|
| 233 | CALL MPI_COMM_RANK( local_comm, local_id, ierr ) |
---|
| 234 | |
---|
| 235 | ! |
---|
| 236 | !-- This loop including the barrier is a workaround for PGI compiler versions |
---|
| 237 | !-- up to and including 18.4. Later releases are able to select their GPUs in |
---|
| 238 | !-- parallel, without running into spurious errors. |
---|
| 239 | DO i = 0, local_num_procs-1 |
---|
| 240 | CALL MPI_BARRIER( local_comm, ierr ) |
---|
| 241 | |
---|
| 242 | IF ( i == local_id ) THEN |
---|
| 243 | device_type = acc_get_device_type() |
---|
| 244 | num_devices = acc_get_num_devices( device_type ) |
---|
| 245 | my_device = MOD( local_id, num_devices ) |
---|
| 246 | CALL acc_set_device_num( my_device, device_type ) |
---|
| 247 | ENDIF |
---|
| 248 | ENDDO |
---|
| 249 | |
---|
| 250 | CALL MPI_COMM_FREE( local_comm, ierr ) |
---|
[102] | 251 | #endif |
---|
[3689] | 252 | #endif |
---|
[102] | 253 | |
---|
| 254 | ! |
---|
[1] | 255 | !-- Initialize measuring of the CPU-time remaining to the run |
---|
| 256 | CALL local_tremain_ini |
---|
| 257 | |
---|
| 258 | ! |
---|
| 259 | !-- Start of total CPU time measuring. |
---|
| 260 | CALL cpu_log( log_point(1), 'total', 'start' ) |
---|
| 261 | CALL cpu_log( log_point(2), 'initialisation', 'start' ) |
---|
| 262 | |
---|
| 263 | ! |
---|
[206] | 264 | !-- Open a file for debug output |
---|
[1468] | 265 | WRITE (myid_char,'(''_'',I6.6)') myid |
---|
[206] | 266 | OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' ) |
---|
| 267 | |
---|
| 268 | ! |
---|
[1] | 269 | !-- Initialize dvrp logging. Also, one PE maybe split from the global |
---|
| 270 | !-- communicator for doing the dvrp output. In that case, the number of |
---|
| 271 | !-- PEs available for PALM is reduced by one and communicator comm_palm |
---|
| 272 | !-- is changed respectively. |
---|
| 273 | #if defined( __parallel ) |
---|
| 274 | CALL MPI_COMM_RANK( comm_palm, myid, ierr ) |
---|
[102] | 275 | #endif |
---|
| 276 | |
---|
| 277 | ! |
---|
[108] | 278 | !-- Read control parameters from NAMELIST files and read environment-variables |
---|
| 279 | CALL parin |
---|
| 280 | |
---|
| 281 | ! |
---|
[1666] | 282 | !-- Check for the user's interface version |
---|
| 283 | IF ( user_interface_current_revision /= user_interface_required_revision ) & |
---|
| 284 | THEN |
---|
| 285 | message_string = 'current user-interface revision "' // & |
---|
| 286 | TRIM( user_interface_current_revision ) // '" does ' // & |
---|
| 287 | 'not match the required revision ' // & |
---|
| 288 | TRIM( user_interface_required_revision ) |
---|
[1668] | 289 | CALL message( 'palm', 'PA0169', 1, 2, 0, 6, 0 ) |
---|
[1666] | 290 | ENDIF |
---|
| 291 | |
---|
| 292 | ! |
---|
[108] | 293 | !-- Determine processor topology and local array indices |
---|
| 294 | CALL init_pegrid |
---|
| 295 | ! |
---|
[2696] | 296 | !-- Check if input file according to input-data standard exists |
---|
| 297 | CALL netcdf_data_input_inquire_file |
---|
| 298 | ! |
---|
| 299 | !-- Read topography input data if required. This is required before the |
---|
| 300 | !-- numerical grid is finally created in init_grid |
---|
| 301 | CALL netcdf_data_input_topo |
---|
| 302 | ! |
---|
| 303 | !-- Generate grid parameters, initialize generic topography and further process |
---|
| 304 | !-- topography information if required |
---|
[1] | 305 | CALL init_grid |
---|
| 306 | ! |
---|
[4414] | 307 | !-- Initialize boundary conditions and numerics such as the multigrid solver or |
---|
| 308 | !-- the advection routine |
---|
| 309 | CALL module_interface_init_numerics |
---|
| 310 | ! |
---|
[2696] | 311 | !-- Read global attributes if available. |
---|
| 312 | CALL netcdf_data_input_init |
---|
| 313 | ! |
---|
| 314 | !-- Read surface classification data, e.g. vegetation and soil types, water |
---|
| 315 | !-- surfaces, etc., if available. Some of these data is required before |
---|
| 316 | !-- check parameters is invoked. |
---|
| 317 | CALL netcdf_data_input_surface_data |
---|
| 318 | ! |
---|
[1] | 319 | !-- Check control parameters and deduce further quantities |
---|
| 320 | CALL check_parameters |
---|
[3298] | 321 | |
---|
[1] | 322 | CALL init_3d_model |
---|
| 323 | |
---|
[4400] | 324 | CALL module_interface_init_output |
---|
| 325 | |
---|
[4444] | 326 | #if defined( __parallel ) |
---|
[1] | 327 | ! |
---|
[1762] | 328 | !-- Coupling protocol setup for nested-domain runs |
---|
[1764] | 329 | IF ( nested_run ) THEN |
---|
| 330 | CALL pmci_modelconfiguration |
---|
[1781] | 331 | ! |
---|
[1933] | 332 | !-- Receive and interpolate initial data on children. |
---|
| 333 | !-- Child initialization must be made first if the model is both child and |
---|
[2177] | 334 | !-- parent if necessary |
---|
| 335 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
| 336 | CALL pmci_child_initialize |
---|
[1781] | 337 | ! |
---|
[2177] | 338 | !-- Send initial condition data from parent to children |
---|
| 339 | CALL pmci_parent_initialize |
---|
[1781] | 340 | ! |
---|
[3232] | 341 | !-- Exchange_horiz is needed after the nest initialization |
---|
[3182] | 342 | IF ( child_domain ) THEN |
---|
[2178] | 343 | CALL exchange_horiz( u, nbgp ) |
---|
| 344 | CALL exchange_horiz( v, nbgp ) |
---|
| 345 | CALL exchange_horiz( w, nbgp ) |
---|
| 346 | IF ( .NOT. neutral ) THEN |
---|
| 347 | CALL exchange_horiz( pt, nbgp ) |
---|
| 348 | ENDIF |
---|
| 349 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e, nbgp ) |
---|
| 350 | IF ( humidity ) THEN |
---|
| 351 | CALL exchange_horiz( q, nbgp ) |
---|
[3274] | 352 | IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN |
---|
[2292] | 353 | CALL exchange_horiz( qc, nbgp ) |
---|
| 354 | CALL exchange_horiz( nc, nbgp ) |
---|
| 355 | ENDIF |
---|
[3274] | 356 | IF ( bulk_cloud_model .AND. microphysics_seifert ) THEN |
---|
[2178] | 357 | CALL exchange_horiz( qr, nbgp ) |
---|
| 358 | CALL exchange_horiz( nr, nbgp ) |
---|
| 359 | ENDIF |
---|
| 360 | ENDIF |
---|
| 361 | IF ( passive_scalar ) CALL exchange_horiz( s, nbgp ) |
---|
[1933] | 362 | ENDIF |
---|
[1781] | 363 | ENDIF |
---|
| 364 | |
---|
[2801] | 365 | CALL pmcp_g_alloc_win ! Must be called after pmci_child_initialize and pmci_parent_initialize |
---|
[1764] | 366 | ENDIF |
---|
[4444] | 367 | #endif |
---|
[1762] | 368 | |
---|
| 369 | ! |
---|
[1] | 370 | !-- Output of program header |
---|
| 371 | IF ( myid == 0 ) CALL header |
---|
| 372 | |
---|
| 373 | CALL cpu_log( log_point(2), 'initialisation', 'stop' ) |
---|
| 374 | |
---|
| 375 | ! |
---|
[2296] | 376 | !-- Integration of the non-atmospheric equations (land surface model, urban |
---|
| 377 | !-- surface model) |
---|
| 378 | IF ( spinup ) THEN |
---|
[3719] | 379 | CALL cpu_log( log_point(41), 'wall/soil spinup', 'start' ) |
---|
[2296] | 380 | CALL time_integration_spinup |
---|
[3719] | 381 | CALL cpu_log( log_point(41), 'wall/soil spinup', 'stop' ) |
---|
[2296] | 382 | ENDIF |
---|
| 383 | |
---|
| 384 | ! |
---|
[1] | 385 | !-- Set start time in format hh:mm:ss |
---|
[2977] | 386 | simulated_time_chr = time_to_string( time_since_reference_point ) |
---|
[1] | 387 | |
---|
| 388 | ! |
---|
| 389 | !-- If required, output of initial arrays |
---|
| 390 | IF ( do2d_at_begin ) THEN |
---|
[4039] | 391 | CALL doq_calculate !TODO, will be called twice |
---|
[3994] | 392 | |
---|
[1] | 393 | CALL data_output_2d( 'xy', 0 ) |
---|
| 394 | CALL data_output_2d( 'xz', 0 ) |
---|
| 395 | CALL data_output_2d( 'yz', 0 ) |
---|
| 396 | ENDIF |
---|
[1976] | 397 | |
---|
[1] | 398 | IF ( do3d_at_begin ) THEN |
---|
[4039] | 399 | CALL doq_calculate !TODO, will be called twice |
---|
[3994] | 400 | |
---|
[1] | 401 | CALL data_output_3d( 0 ) |
---|
| 402 | ENDIF |
---|
| 403 | |
---|
| 404 | ! |
---|
[495] | 405 | !-- Integration of the model equations using timestep-scheme |
---|
[1] | 406 | CALL time_integration |
---|
| 407 | |
---|
| 408 | ! |
---|
[495] | 409 | !-- If required, write binary data for restart runs |
---|
[2298] | 410 | IF ( write_binary ) THEN |
---|
[759] | 411 | |
---|
[4539] | 412 | CALL cpu_log( log_point(22), 'write-restart-data', 'start' ) |
---|
[759] | 413 | |
---|
[3885] | 414 | CALL location_message( 'writing restart data', 'start' ) |
---|
[1402] | 415 | |
---|
[4495] | 416 | IF ( TRIM( restart_data_format_output ) == 'fortran_binary' ) THEN |
---|
[2894] | 417 | |
---|
[4495] | 418 | DO i = 0, io_blocks-1 |
---|
| 419 | IF ( i == io_group ) THEN |
---|
| 420 | |
---|
[1] | 421 | ! |
---|
[4495] | 422 | !-- Open binary file |
---|
| 423 | CALL check_open( 14 ) |
---|
[2894] | 424 | ! |
---|
[4495] | 425 | !-- Write control parameters and other global variables for restart. |
---|
| 426 | IF ( myid == 0 ) CALL wrd_global |
---|
[2894] | 427 | ! |
---|
[4495] | 428 | !-- Write processor specific flow field data for restart runs |
---|
| 429 | CALL wrd_local |
---|
[2894] | 430 | ! |
---|
[4495] | 431 | !-- Close binary file |
---|
| 432 | CALL close_file( 14 ) |
---|
[2894] | 433 | |
---|
[4495] | 434 | ENDIF |
---|
[759] | 435 | #if defined( __parallel ) |
---|
[4495] | 436 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[759] | 437 | #endif |
---|
[4495] | 438 | ENDDO |
---|
[759] | 439 | |
---|
[4535] | 440 | ELSEIF ( restart_data_format_output(1:3) == 'mpi' ) THEN |
---|
[4495] | 441 | ! |
---|
| 442 | !-- Open MPI-IO restart file |
---|
[4496] | 443 | CALL rd_mpi_io_open( 'write', 'BINOUT' // TRIM( coupling_char ) ) |
---|
[4495] | 444 | ! |
---|
| 445 | !-- Write control parameters and other global variables for restart. |
---|
| 446 | CALL wrd_global |
---|
| 447 | ! |
---|
| 448 | !-- Write processor specific flow field data for restart runs |
---|
| 449 | CALL wrd_local |
---|
| 450 | ! |
---|
| 451 | !-- Close restart File |
---|
| 452 | CALL rd_mpi_io_close |
---|
| 453 | |
---|
| 454 | ENDIF |
---|
| 455 | |
---|
[3885] | 456 | CALL location_message( 'writing restart data', 'finished' ) |
---|
[1402] | 457 | |
---|
[4539] | 458 | CALL cpu_log( log_point(22), 'write-restart-data', 'stop' ) |
---|
[2007] | 459 | |
---|
[495] | 460 | ENDIF |
---|
[3494] | 461 | ! |
---|
| 462 | !-- Last actions for surface output, for instantaneous and time-averaged data |
---|
[3648] | 463 | CALL surface_data_output_last_action( 0 ) |
---|
| 464 | CALL surface_data_output_last_action( 1 ) |
---|
[1] | 465 | |
---|
| 466 | ! |
---|
| 467 | !-- If required, repeat output of header including the required CPU-time |
---|
| 468 | IF ( myid == 0 ) CALL header |
---|
| 469 | ! |
---|
[3687] | 470 | !-- Perform module specific last actions |
---|
[1] | 471 | CALL cpu_log( log_point(4), 'last actions', 'start' ) |
---|
[3235] | 472 | |
---|
[3687] | 473 | IF ( myid == 0 .AND. agents_active ) CALL mas_last_actions ! ToDo: move to module_interface |
---|
[2894] | 474 | |
---|
[3687] | 475 | CALL module_interface_last_actions |
---|
| 476 | |
---|
[1] | 477 | CALL cpu_log( log_point(4), 'last actions', 'stop' ) |
---|
| 478 | |
---|
| 479 | ! |
---|
[3687] | 480 | !-- Close files |
---|
| 481 | CALL close_file( 0 ) |
---|
| 482 | |
---|
| 483 | ! |
---|
[3232] | 484 | !-- Write run number to file (used by palmrun to create unified cycle numbers |
---|
| 485 | !-- for output files |
---|
[2261] | 486 | IF ( myid == 0 .AND. runnr > 0 ) THEN |
---|
| 487 | OPEN( 90, FILE='RUN_NUMBER', FORM='FORMATTED' ) |
---|
| 488 | WRITE( 90, '(I4)' ) runnr |
---|
| 489 | CLOSE( 90 ) |
---|
| 490 | ENDIF |
---|
| 491 | |
---|
| 492 | ! |
---|
[1] | 493 | !-- Take final CPU-time for CPU-time analysis |
---|
| 494 | CALL cpu_log( log_point(1), 'total', 'stop' ) |
---|
| 495 | CALL cpu_statistics |
---|
| 496 | |
---|
| 497 | #if defined( __parallel ) |
---|
| 498 | CALL MPI_FINALIZE( ierr ) |
---|
| 499 | #endif |
---|
| 500 | |
---|
| 501 | END PROGRAM palm |
---|