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

Last change on this file since 1904 was 1823, checked in by hoffmann, 9 years ago

last commit documented

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