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

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

Forced header and separation lines into 80 columns

  • 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! Forced header and separation lines into 80 columns
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_write_restart_file.f90 2000 2016-08-20 18:09:15Z knoop $
27!
28! 1822 2016-04-07 07:49:42Z hoffmann
29! Tails removed. Unused variables removed.
30!
31! 1682 2015-10-07 23:56:08Z knoop
32! Code annotations made doxygen readable
33!
34! 1359 2014-04-11 17:15:14Z hoffmann
35! New particle structure integrated.
36!
37! 1320 2014-03-20 08:40:49Z raasch
38! ONLY-attribute added to USE-statements,
39! kind-parameters added to all INTEGER and REAL declaration statements,
40! kinds are defined in new module kinds,
41! comment fields (!:) to be used for variable explanations added to
42! all variable declaration statements
43!
44! 1036 2012-10-22 13:43:42Z raasch
45! code put under GPL (PALM 3.9)
46!
47! 849 2012-03-15 10:35:09Z raasch
48! initial revision (former part of advec_particles)
49!
50!
51! Description:
52! ------------
53!> Write particle data in FORTRAN binary format on restart file
54!------------------------------------------------------------------------------!
55 SUBROUTINE lpm_write_restart_file
56
57
58    USE indices,                                                               &
59        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
60
61    USE kinds
62
63    USE particle_attributes,                                                   &
64        ONLY:  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, grid_particles,       &
65               number_of_particles, number_of_particle_groups,                 &
66               particles, particle_groups, prt_count, time_prel,               &
67               time_write_particle_data, uniform_particles
68
69    USE pegrid
70
71    IMPLICIT NONE
72
73    CHARACTER (LEN=10) ::  particle_binary_version   !<
74
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!
97!-- Write the version number of the binary format.
98!-- Attention: After changes to the following output commands the version
99!-- ---------  number of the variable particle_binary_version must be
100!--            changed! Also, the version number and the list of arrays
101!--            to be read in lpm_read_restart_file must be adjusted
102!--            accordingly.
103    particle_binary_version = '4.0'
104    WRITE ( 90 )  particle_binary_version
105
106!
107!-- Write some particle parameters, the size of the particle arrays as
108!-- well as other dvrp-plot variables.
109    WRITE ( 90 )  bc_par_b, bc_par_lr, bc_par_ns, bc_par_t,              &
110                  number_of_particle_groups, particle_groups, time_prel, &
111                  time_write_particle_data, uniform_particles
112
113    WRITE ( 90 )  prt_count
114         
115    DO  ip = nxl, nxr
116       DO  jp = nys, nyn
117          DO  kp = nzb+1, nzt
118             number_of_particles = prt_count(kp,jp,ip)
119             particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
120             IF ( number_of_particles <= 0 )  CYCLE
121             WRITE ( 90 )  particles
122          ENDDO
123       ENDDO
124    ENDDO
125
126    CLOSE ( 90 )
127
128#if defined( __parallel )
129       CALL MPI_BARRIER( comm2d, ierr )
130#endif
131
132
133 END SUBROUTINE lpm_write_restart_file
Note: See TracBrowser for help on using the repository browser.