source: branches/flexpart91_hasod/src/readpartpositions.f90 @ 7

Last change on this file since 7 was 7, checked in by hasod, 11 years ago

Initial import

  • namelist input for COMMAND
  • pathnames optionally as command line argument
  • conversion utility from COMMAND to COMMAND namelist
File size: 6.2 KB
Line 
1!**********************************************************************
2! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
3! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
4! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
5!                                                                     *
6! This file is part of FLEXPART.                                      *
7!                                                                     *
8! FLEXPART is free software: you can redistribute it and/or modify    *
9! it under the terms of the GNU General Public License as published by*
10! the Free Software Foundation, either version 3 of the License, or   *
11! (at your option) any later version.                                 *
12!                                                                     *
13! FLEXPART is distributed in the hope that it will be useful,         *
14! but WITHOUT ANY WARRANTY; without even the implied warranty of      *
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
16! GNU General Public License for more details.                        *
17!                                                                     *
18! You should have received a copy of the GNU General Public License   *
19! along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
20!**********************************************************************
21
22subroutine readpartpositions
23
24  !*****************************************************************************
25  !                                                                            *
26  !   This routine opens the particle dump file and reads all the particle     *
27  !   positions from a previous run to initialize the current run.             *
28  !                                                                            *
29  !                                                                            *
30  !     Author: A. Stohl                                                       *
31  !                                                                            *
32  !     24 March 2000                                                          *
33  !                                                                            *
34  !*****************************************************************************
35  !                                                                            *
36  ! Variables:                                                                 *
37  !                                                                            *
38  !*****************************************************************************
39
40  use par_mod
41  use com_mod
42
43  implicit none
44
45  integer :: ibdatein,ibtimein,nspecin,itimein,numpointin,i,j,ix
46  integer :: id1,id2,it1,it2
47  real :: xlonin,ylatin,ran1,topo,hmixi,pvi,qvi,rhoi,tri,tti
48  character :: specin*7
49  real(kind=dp) :: julin,julpartin,juldate
50
51  integer :: idummy = -8
52
53  numparticlecount=0
54
55  ! Open header file of dumped particle data
56  !*****************************************
57
58  open(unitpartin,file=path(2)(1:length(2))//'header', &
59       form='unformatted',err=998)
60
61  read(unitpartin) ibdatein,ibtimein
62  read(unitpartin)
63  read(unitpartin)
64
65  read(unitpartin)
66  read(unitpartin)
67  read(unitpartin) nspecin
68  nspecin=nspecin/3
69  if ((ldirect.eq.1).and.(nspec.ne.nspecin)) goto 997
70
71  do i=1,nspecin
72    read(unitpartin)
73    read(unitpartin)
74    read(unitpartin) j,specin
75    if ((ldirect.eq.1).and.(species(i)(1:7).ne.specin)) goto 996
76  end do
77
78  read(unitpartin) numpointin
79  if (numpointin.ne.numpoint) goto 995
80  do i=1,numpointin
81    read(unitpartin)
82    read(unitpartin)
83    read(unitpartin)
84    read(unitpartin)
85    do j=1,nspec
86      read(unitpartin)
87      read(unitpartin)
88      read(unitpartin)
89    end do
90  end do
91  read(unitpartin)
92  read(unitpartin)
93
94  do ix=0,numxgrid-1
95    read(unitpartin)
96  end do
97
98
99  ! Open data file of dumped particle data
100  !***************************************
101
102  close(unitpartin)
103  open(unitpartin,file=path(2)(1:length(2))//'partposit_end', &
104       form='unformatted',err=998)
105
106
107100   read(unitpartin,end=99) itimein
108    i=0
109200   i=i+1
110    read(unitpartin) npoint(i),xlonin,ylatin,ztra1(i),itramem(i), &
111         topo,pvi,qvi,rhoi,hmixi,tri,tti,(xmass1(i,j),j=1,nspec)
112
113    if (xlonin.eq.-9999.9) goto 100
114    xtra1(i)=(xlonin-xlon0)/dx
115    ytra1(i)=(ylatin-ylat0)/dy
116    numparticlecount=max(numparticlecount,npoint(i))
117    goto 200
118
11999   numpart=i-1
120
121  close(unitpartin)
122
123  julin=juldate(ibdatein,ibtimein)+real(itimein,kind=dp)/86400._dp
124  if (abs(julin-bdate).gt.1.e-5) goto 994
125  do i=1,numpart
126    julpartin=juldate(ibdatein,ibtimein)+ &
127         real(itramem(i),kind=dp)/86400._dp
128    nclass(i)=min(int(ran1(idummy)*real(nclassunc))+1, &
129         nclassunc)
130    idt(i)=mintime
131    itra1(i)=0
132    itramem(i)=nint((julpartin-bdate)*86400.)
133    itrasplit(i)=ldirect*itsplit
134  end do
135
136  return
137
138
139994   write(*,*) ' #### FLEXPART MODEL ERROR IN READPARTPOSITIONS#### '
140  write(*,*) ' #### ENDING TIME OF PREVIOUS MODEL RUN DOES   #### '
141  write(*,*) ' #### NOT AGREE WITH STARTING TIME OF THIS RUN.#### '
142  call caldate(julin,id1,it1)
143  call caldate(bdate,id2,it2)
144  write(*,*) 'julin: ',julin,id1,it1
145  write(*,*) 'bdate: ',bdate,id2,it2
146  stop
147
148995   write(*,*) ' #### FLEXPART MODEL ERROR IN READPARTPOSITIONS#### '
149  write(*,*) ' #### NUMBER OF RELEASE LOCATIONS DOES NOT     #### '
150  write(*,*) ' #### AGREE WITH CURRENT SETTINGS!             #### '
151  stop
152
153996   write(*,*) ' #### FLEXPART MODEL ERROR IN READPARTPOSITIONS#### '
154  write(*,*) ' #### SPECIES NAMES TO BE READ IN DO NOT       #### '
155  write(*,*) ' #### AGREE WITH CURRENT SETTINGS!             #### '
156  stop
157
158997   write(*,*) ' #### FLEXPART MODEL ERROR IN READPARTPOSITIONS#### '
159  write(*,*) ' #### THE NUMBER OF SPECIES TO BE READ IN DOES #### '
160  write(*,*) ' #### NOT AGREE WITH CURRENT SETTINGS!         #### '
161  stop
162
163998   write(*,*) ' #### FLEXPART MODEL ERROR!   THE FILE         #### '
164  write(*,*) ' #### '//path(2)(1:length(2))//'grid'//' #### '
165  write(*,*) ' #### CANNOT BE OPENED. IF A FILE WITH THIS    #### '
166  write(*,*) ' #### NAME ALREADY EXISTS, DELETE IT AND START #### '
167  write(*,*) ' #### THE PROGRAM AGAIN.                       #### '
168  stop
169
170end subroutine readpartpositions
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG