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

Last change on this file since 2066 was 2001, checked in by knoop, 8 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 4.5 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
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.
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-2016 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_write_restart_file.f90 2001 2016-08-20 18:41:22Z maronga $
27!
28! 2000 2016-08-20 18:09:15Z knoop
29! Forced header and separation lines into 80 columns
30!
31! 1822 2016-04-07 07:49:42Z hoffmann
32! Tails removed. Unused variables removed.
33!
34! 1682 2015-10-07 23:56:08Z knoop
35! Code annotations made doxygen readable
36!
37! 1359 2014-04-11 17:15:14Z hoffmann
38! New particle structure integrated.
39!
40! 1320 2014-03-20 08:40:49Z raasch
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
46!
47! 1036 2012-10-22 13:43:42Z raasch
48! code put under GPL (PALM 3.9)
49!
50! 849 2012-03-15 10:35:09Z raasch
51! initial revision (former part of advec_particles)
52!
53!
54! Description:
55! ------------
56!> Write particle data in FORTRAN binary format on restart file
57!------------------------------------------------------------------------------!
58 SUBROUTINE lpm_write_restart_file
59
60
61    USE indices,                                                               &
62        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
63
64    USE kinds
65
66    USE particle_attributes,                                                   &
67        ONLY:  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, grid_particles,       &
68               number_of_particles, number_of_particle_groups,                 &
69               particles, particle_groups, prt_count, time_prel,               &
70               time_write_particle_data, uniform_particles
71
72    USE pegrid
73
74    IMPLICIT NONE
75
76    CHARACTER (LEN=10) ::  particle_binary_version   !<
77
78    INTEGER(iwp) ::  ip                              !<
79    INTEGER(iwp) ::  jp                              !<
80    INTEGER(iwp) ::  kp                              !<
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!
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
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                  number_of_particle_groups, particle_groups, time_prel, &
114                  time_write_particle_data, uniform_particles
115
116    WRITE ( 90 )  prt_count
117         
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
125          ENDDO
126       ENDDO
127    ENDDO
128
129    CLOSE ( 90 )
130
131#if defined( __parallel )
132       CALL MPI_BARRIER( comm2d, ierr )
133#endif
134
135
136 END SUBROUTINE lpm_write_restart_file
Note: See TracBrowser for help on using the repository browser.