[1682] | 1 | !> @file lpm_write_restart_file.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1310] | 16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[849] | 19 | ! Current revisions: |
---|
| 20 | ! ------------------ |
---|
[1360] | 21 | ! |
---|
[1683] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: lpm_write_restart_file.f90 1683 2015-10-07 23:57:51Z maronga $ |
---|
| 26 | ! |
---|
[1683] | 27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 28 | ! Code annotations made doxygen readable |
---|
| 29 | ! |
---|
[1360] | 30 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 31 | ! New particle structure integrated. |
---|
| 32 | ! |
---|
[1321] | 33 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 34 | ! ONLY-attribute added to USE-statements, |
---|
| 35 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 36 | ! kinds are defined in new module kinds, |
---|
| 37 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 38 | ! all variable declaration statements |
---|
[849] | 39 | ! |
---|
[1037] | 40 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 41 | ! code put under GPL (PALM 3.9) |
---|
| 42 | ! |
---|
[850] | 43 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 44 | ! initial revision (former part of advec_particles) |
---|
[849] | 45 | ! |
---|
[850] | 46 | ! |
---|
[849] | 47 | ! Description: |
---|
| 48 | ! ------------ |
---|
[1682] | 49 | !> Write particle data in FORTRAN binary format on restart file |
---|
[849] | 50 | !------------------------------------------------------------------------------! |
---|
[1682] | 51 | SUBROUTINE lpm_write_restart_file |
---|
| 52 | |
---|
[849] | 53 | |
---|
[1320] | 54 | USE control_parameters, & |
---|
| 55 | ONLY: io_blocks, io_group |
---|
| 56 | |
---|
[1359] | 57 | USE indices, & |
---|
| 58 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
| 59 | |
---|
[1320] | 60 | USE kinds |
---|
| 61 | |
---|
| 62 | USE particle_attributes, & |
---|
[1359] | 63 | ONLY: bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, grid_particles, & |
---|
| 64 | maximum_number_of_tails, maximum_number_of_tailpoints, & |
---|
| 65 | number_of_particles, number_of_particle_groups, & |
---|
| 66 | number_of_tails, particles, particle_groups, & |
---|
| 67 | particle_tail_coordinates, prt_count, time_prel, & |
---|
| 68 | time_write_particle_data, uniform_particles, & |
---|
| 69 | use_particle_tails, zero_particle |
---|
[1320] | 70 | |
---|
[849] | 71 | USE pegrid |
---|
| 72 | |
---|
| 73 | IMPLICIT NONE |
---|
| 74 | |
---|
[1682] | 75 | CHARACTER (LEN=10) :: particle_binary_version !< |
---|
[1359] | 76 | |
---|
[1682] | 77 | INTEGER(iwp) :: i !< |
---|
| 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 | |
---|
[1359] | 99 | ! DO i = 0, io_blocks-1 |
---|
[849] | 100 | |
---|
[1359] | 101 | ! IF ( i == io_group ) THEN |
---|
[849] | 102 | |
---|
| 103 | ! |
---|
| 104 | !-- Write the version number of the binary format. |
---|
| 105 | !-- Attention: After changes to the following output commands the version |
---|
| 106 | !-- --------- number of the variable particle_binary_version must be |
---|
| 107 | !-- changed! Also, the version number and the list of arrays |
---|
| 108 | !-- to be read in lpm_read_restart_file must be adjusted |
---|
| 109 | !-- accordingly. |
---|
[1359] | 110 | particle_binary_version = '3.2' |
---|
[849] | 111 | WRITE ( 90 ) particle_binary_version |
---|
| 112 | |
---|
| 113 | ! |
---|
| 114 | !-- Write some particle parameters, the size of the particle arrays as |
---|
| 115 | !-- well as other dvrp-plot variables. |
---|
| 116 | WRITE ( 90 ) bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, & |
---|
| 117 | maximum_number_of_tailpoints, maximum_number_of_tails, & |
---|
| 118 | number_of_particle_groups, number_of_tails, & |
---|
| 119 | particle_groups, time_prel, time_write_particle_data, & |
---|
| 120 | uniform_particles |
---|
| 121 | |
---|
[1359] | 122 | WRITE ( 90 ) prt_count |
---|
| 123 | |
---|
| 124 | DO ip = nxl, nxr |
---|
| 125 | DO jp = nys, nyn |
---|
| 126 | DO kp = nzb+1, nzt |
---|
| 127 | number_of_particles = prt_count(kp,jp,ip) |
---|
| 128 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
| 129 | IF ( number_of_particles <= 0 ) CYCLE |
---|
| 130 | WRITE ( 90 ) particles |
---|
| 131 | ENDDO |
---|
| 132 | ENDDO |
---|
| 133 | ENDDO |
---|
[849] | 134 | |
---|
[1359] | 135 | ! |
---|
| 136 | !-- particle tails currently not available |
---|
| 137 | ! IF ( use_particle_tails ) THEN |
---|
| 138 | ! WRITE ( 90 ) particle_tail_coordinates |
---|
| 139 | ! ENDIF |
---|
[849] | 140 | |
---|
| 141 | CLOSE ( 90 ) |
---|
| 142 | |
---|
[1359] | 143 | ! ENDIF |
---|
[849] | 144 | |
---|
| 145 | #if defined( __parallel ) |
---|
| 146 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 147 | #endif |
---|
| 148 | |
---|
[1359] | 149 | ! ENDDO |
---|
[849] | 150 | |
---|
| 151 | |
---|
| 152 | END SUBROUTINE lpm_write_restart_file |
---|