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