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