source: palm/trunk/SOURCE/lpm_write_restart_file.f90 @ 1682

Last change on this file since 1682 was 1682, checked in by knoop, 9 years ago

Code annotations made doxygen readable

  • Property svn:keywords set to Id
File size: 5.3 KB
Line 
1!> @file lpm_write_restart_file.f90
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!
16! Copyright 1997-2014 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! ------------------
21! Code annotations made doxygen readable
22!
23! Former revisions:
24! -----------------
25! $Id: lpm_write_restart_file.f90 1682 2015-10-07 23:56:08Z knoop $
26!
27! 1359 2014-04-11 17:15:14Z hoffmann
28! New particle structure integrated.
29!
30! 1320 2014-03-20 08:40:49Z raasch
31! ONLY-attribute added to USE-statements,
32! kind-parameters added to all INTEGER and REAL declaration statements,
33! kinds are defined in new module kinds,
34! comment fields (!:) to be used for variable explanations added to
35! all variable declaration statements
36!
37! 1036 2012-10-22 13:43:42Z raasch
38! code put under GPL (PALM 3.9)
39!
40! 849 2012-03-15 10:35:09Z raasch
41! initial revision (former part of advec_particles)
42!
43!
44! Description:
45! ------------
46!> Write particle data in FORTRAN binary format on restart file
47!------------------------------------------------------------------------------!
48 SUBROUTINE lpm_write_restart_file
49 
50
51    USE control_parameters,                                                    &
52        ONLY:  io_blocks, io_group
53
54    USE indices,                                                               &
55        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
56
57    USE kinds
58
59    USE particle_attributes,                                                   &
60        ONLY:  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, grid_particles,       &
61               maximum_number_of_tails, maximum_number_of_tailpoints,          &
62               number_of_particles, number_of_particle_groups,                 &
63               number_of_tails, particles, particle_groups,                    &
64               particle_tail_coordinates, prt_count, time_prel,                &
65               time_write_particle_data, uniform_particles,                    &
66               use_particle_tails, zero_particle
67
68    USE pegrid
69
70    IMPLICIT NONE
71
72    CHARACTER (LEN=10) ::  particle_binary_version   !<
73
74    INTEGER(iwp) ::  i                               !<
75    INTEGER(iwp) ::  ip                              !<
76    INTEGER(iwp) ::  jp                              !<
77    INTEGER(iwp) ::  kp                              !<
78
79!
80!-- First open the output unit.
81    IF ( myid_char == '' )  THEN
82       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT'//myid_char, &
83                  FORM='UNFORMATTED')
84    ELSE
85       IF ( myid == 0 )  CALL local_system( 'mkdir PARTICLE_RESTART_DATA_OUT' )
86#if defined( __parallel )
87!
88!--    Set a barrier in order to allow that thereafter all other processors
89!--    in the directory created by PE0 can open their file
90       CALL MPI_BARRIER( comm2d, ierr )
91#endif
92       OPEN ( 90, FILE='PARTICLE_RESTART_DATA_OUT/'//myid_char, &
93                  FORM='UNFORMATTED' )
94    ENDIF
95
96!    DO  i = 0, io_blocks-1
97
98!       IF ( i == io_group )  THEN
99
100!
101!--       Write the version number of the binary format.
102!--       Attention: After changes to the following output commands the version
103!--       ---------  number of the variable particle_binary_version must be
104!--                  changed! Also, the version number and the list of arrays
105!--                  to be read in lpm_read_restart_file must be adjusted
106!--                  accordingly.
107          particle_binary_version = '3.2'
108          WRITE ( 90 )  particle_binary_version
109
110!
111!--       Write some particle parameters, the size of the particle arrays as
112!--       well as other dvrp-plot variables.
113          WRITE ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,              &
114                        maximum_number_of_tailpoints, maximum_number_of_tails, &
115                        number_of_particle_groups, number_of_tails,            &
116                        particle_groups, time_prel, time_write_particle_data,  &
117                        uniform_particles
118
119          WRITE ( 90 )  prt_count
120         
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
128                ENDDO
129             ENDDO
130          ENDDO
131
132!
133!--       particle tails currently not available
134!          IF ( use_particle_tails )  THEN
135!             WRITE ( 90 )  particle_tail_coordinates
136!          ENDIF
137
138          CLOSE ( 90 )
139
140!       ENDIF
141
142#if defined( __parallel )
143       CALL MPI_BARRIER( comm2d, ierr )
144#endif
145
146 !   ENDDO
147
148
149 END SUBROUTINE lpm_write_restart_file
Note: See TracBrowser for help on using the repository browser.