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