[1682] | 1 | !> @file lpm_write_restart_file.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 | ! |
---|
[3655] | 17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[849] | 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[1360] | 22 | ! |
---|
[2001] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: lpm_write_restart_file.f90 3655 2019-01-07 16:51:22Z eckhard $ |
---|
[3560] | 27 | ! time_prel replaced by last_particle_release_time |
---|
| 28 | ! |
---|
| 29 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 30 | ! Corrected "Former revisions" section |
---|
| 31 | ! |
---|
| 32 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 33 | ! Change in file header (GPL part) |
---|
| 34 | ! |
---|
| 35 | ! 2265 2017-06-08 16:58:28Z schwenkel |
---|
[2265] | 36 | ! Unused variables removed. |
---|
| 37 | ! |
---|
| 38 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
[1321] | 39 | ! |
---|
[2001] | 40 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 41 | ! Forced header and separation lines into 80 columns |
---|
| 42 | ! |
---|
[1823] | 43 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 44 | ! Tails removed. Unused variables removed. |
---|
| 45 | ! |
---|
[1683] | 46 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 47 | ! Code annotations made doxygen readable |
---|
| 48 | ! |
---|
[1360] | 49 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 50 | ! New particle structure integrated. |
---|
| 51 | ! |
---|
[1321] | 52 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 53 | ! ONLY-attribute added to USE-statements, |
---|
| 54 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 55 | ! kinds are defined in new module kinds, |
---|
| 56 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 57 | ! all variable declaration statements |
---|
[849] | 58 | ! |
---|
[1037] | 59 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 60 | ! code put under GPL (PALM 3.9) |
---|
| 61 | ! |
---|
[850] | 62 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 63 | ! initial revision (former part of advec_particles) |
---|
[849] | 64 | ! |
---|
[850] | 65 | ! |
---|
[849] | 66 | ! Description: |
---|
| 67 | ! ------------ |
---|
[1682] | 68 | !> Write particle data in FORTRAN binary format on restart file |
---|
[849] | 69 | !------------------------------------------------------------------------------! |
---|
[1682] | 70 | SUBROUTINE lpm_write_restart_file |
---|
[849] | 71 | |
---|
[1320] | 72 | |
---|
[1359] | 73 | USE indices, & |
---|
| 74 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
| 75 | |
---|
[1320] | 76 | USE kinds |
---|
| 77 | |
---|
| 78 | USE particle_attributes, & |
---|
[1359] | 79 | ONLY: bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, grid_particles, & |
---|
[3560] | 80 | last_particle_release_time, number_of_particles, & |
---|
| 81 | number_of_particle_groups, particles, particle_groups, & |
---|
| 82 | prt_count, time_write_particle_data |
---|
[1320] | 83 | |
---|
[849] | 84 | USE pegrid |
---|
| 85 | |
---|
| 86 | IMPLICIT NONE |
---|
| 87 | |
---|
[1682] | 88 | CHARACTER (LEN=10) :: particle_binary_version !< |
---|
[1359] | 89 | |
---|
[1682] | 90 | INTEGER(iwp) :: ip !< |
---|
| 91 | INTEGER(iwp) :: jp !< |
---|
| 92 | INTEGER(iwp) :: kp !< |
---|
[849] | 93 | |
---|
| 94 | ! |
---|
| 95 | !-- First open the output unit. |
---|
| 96 | IF ( myid_char == '' ) THEN |
---|
| 97 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT'//myid_char, & |
---|
| 98 | FORM='UNFORMATTED') |
---|
| 99 | ELSE |
---|
| 100 | IF ( myid == 0 ) CALL local_system( 'mkdir PARTICLE_RESTART_DATA_OUT' ) |
---|
| 101 | #if defined( __parallel ) |
---|
| 102 | ! |
---|
| 103 | !-- Set a barrier in order to allow that thereafter all other processors |
---|
| 104 | !-- in the directory created by PE0 can open their file |
---|
| 105 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 106 | #endif |
---|
| 107 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT/'//myid_char, & |
---|
| 108 | FORM='UNFORMATTED' ) |
---|
| 109 | ENDIF |
---|
| 110 | |
---|
| 111 | ! |
---|
[1822] | 112 | !-- Write the version number of the binary format. |
---|
| 113 | !-- Attention: After changes to the following output commands the version |
---|
| 114 | !-- --------- number of the variable particle_binary_version must be |
---|
| 115 | !-- changed! Also, the version number and the list of arrays |
---|
| 116 | !-- to be read in lpm_read_restart_file must be adjusted |
---|
| 117 | !-- accordingly. |
---|
| 118 | particle_binary_version = '4.0' |
---|
| 119 | WRITE ( 90 ) particle_binary_version |
---|
[849] | 120 | |
---|
| 121 | ! |
---|
[1822] | 122 | !-- Write some particle parameters, the size of the particle arrays as |
---|
| 123 | !-- well as other dvrp-plot variables. |
---|
[3560] | 124 | WRITE ( 90 ) bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, & |
---|
| 125 | last_particle_release_time, number_of_particle_groups, & |
---|
| 126 | particle_groups, time_write_particle_data |
---|
[849] | 127 | |
---|
[1822] | 128 | WRITE ( 90 ) prt_count |
---|
[1359] | 129 | |
---|
[1822] | 130 | DO ip = nxl, nxr |
---|
| 131 | DO jp = nys, nyn |
---|
| 132 | DO kp = nzb+1, nzt |
---|
| 133 | number_of_particles = prt_count(kp,jp,ip) |
---|
| 134 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
| 135 | IF ( number_of_particles <= 0 ) CYCLE |
---|
| 136 | WRITE ( 90 ) particles |
---|
[1359] | 137 | ENDDO |
---|
[1822] | 138 | ENDDO |
---|
| 139 | ENDDO |
---|
[849] | 140 | |
---|
[1822] | 141 | CLOSE ( 90 ) |
---|
[849] | 142 | |
---|
| 143 | #if defined( __parallel ) |
---|
| 144 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 145 | #endif |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | END SUBROUTINE lpm_write_restart_file |
---|