1 | SUBROUTINE lpm_write_restart_file |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later version. |
---|
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 | ! |
---|
17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: lpm_write_restart_file.f90 1360 2014-04-11 17:20:32Z hoffmann $ |
---|
27 | ! |
---|
28 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
29 | ! New particle structure integrated. |
---|
30 | ! |
---|
31 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
32 | ! ONLY-attribute added to USE-statements, |
---|
33 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
34 | ! kinds are defined in new module kinds, |
---|
35 | ! comment fields (!:) to be used for variable explanations added to |
---|
36 | ! all variable declaration statements |
---|
37 | ! |
---|
38 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
39 | ! code put under GPL (PALM 3.9) |
---|
40 | ! |
---|
41 | ! 849 2012-03-15 10:35:09Z raasch |
---|
42 | ! initial revision (former part of advec_particles) |
---|
43 | ! |
---|
44 | ! |
---|
45 | ! Description: |
---|
46 | ! ------------ |
---|
47 | ! Write particle data in FORTRAN binary format on restart file |
---|
48 | !------------------------------------------------------------------------------! |
---|
49 | |
---|
50 | USE control_parameters, & |
---|
51 | ONLY: io_blocks, io_group |
---|
52 | |
---|
53 | USE indices, & |
---|
54 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
55 | |
---|
56 | USE kinds |
---|
57 | |
---|
58 | USE particle_attributes, & |
---|
59 | ONLY: bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, grid_particles, & |
---|
60 | maximum_number_of_tails, maximum_number_of_tailpoints, & |
---|
61 | number_of_particles, number_of_particle_groups, & |
---|
62 | number_of_tails, particles, particle_groups, & |
---|
63 | particle_tail_coordinates, prt_count, time_prel, & |
---|
64 | time_write_particle_data, uniform_particles, & |
---|
65 | use_particle_tails, zero_particle |
---|
66 | |
---|
67 | USE pegrid |
---|
68 | |
---|
69 | IMPLICIT NONE |
---|
70 | |
---|
71 | CHARACTER (LEN=10) :: particle_binary_version !: |
---|
72 | |
---|
73 | INTEGER(iwp) :: i !: |
---|
74 | INTEGER(iwp) :: ip !: |
---|
75 | INTEGER(iwp) :: jp !: |
---|
76 | INTEGER(iwp) :: kp !: |
---|
77 | |
---|
78 | ! |
---|
79 | !-- First open the output unit. |
---|
80 | IF ( myid_char == '' ) THEN |
---|
81 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT'//myid_char, & |
---|
82 | FORM='UNFORMATTED') |
---|
83 | ELSE |
---|
84 | IF ( myid == 0 ) CALL local_system( 'mkdir PARTICLE_RESTART_DATA_OUT' ) |
---|
85 | #if defined( __parallel ) |
---|
86 | ! |
---|
87 | !-- Set a barrier in order to allow that thereafter all other processors |
---|
88 | !-- in the directory created by PE0 can open their file |
---|
89 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
90 | #endif |
---|
91 | OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT/'//myid_char, & |
---|
92 | FORM='UNFORMATTED' ) |
---|
93 | ENDIF |
---|
94 | |
---|
95 | ! DO i = 0, io_blocks-1 |
---|
96 | |
---|
97 | ! IF ( i == io_group ) THEN |
---|
98 | |
---|
99 | ! |
---|
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 = '3.2' |
---|
107 | WRITE ( 90 ) particle_binary_version |
---|
108 | |
---|
109 | ! |
---|
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 | maximum_number_of_tailpoints, maximum_number_of_tails, & |
---|
114 | number_of_particle_groups, number_of_tails, & |
---|
115 | particle_groups, time_prel, time_write_particle_data, & |
---|
116 | uniform_particles |
---|
117 | |
---|
118 | WRITE ( 90 ) prt_count |
---|
119 | |
---|
120 | DO ip = nxl, nxr |
---|
121 | DO jp = nys, nyn |
---|
122 | DO kp = nzb+1, nzt |
---|
123 | number_of_particles = prt_count(kp,jp,ip) |
---|
124 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
125 | IF ( number_of_particles <= 0 ) CYCLE |
---|
126 | WRITE ( 90 ) particles |
---|
127 | ENDDO |
---|
128 | ENDDO |
---|
129 | ENDDO |
---|
130 | |
---|
131 | ! |
---|
132 | !-- particle tails currently not available |
---|
133 | ! IF ( use_particle_tails ) THEN |
---|
134 | ! WRITE ( 90 ) particle_tail_coordinates |
---|
135 | ! ENDIF |
---|
136 | |
---|
137 | CLOSE ( 90 ) |
---|
138 | |
---|
139 | ! ENDIF |
---|
140 | |
---|
141 | #if defined( __parallel ) |
---|
142 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
143 | #endif |
---|
144 | |
---|
145 | ! ENDDO |
---|
146 | |
---|
147 | |
---|
148 | END SUBROUTINE lpm_write_restart_file |
---|