source: flexpart.git/src/plumetraj.f90 @ 34f1452

univie
Last change on this file since 34f1452 was 34f1452, checked in by pesei <petra seibert at univie ac at>, 6 years ago

increase output width for time (ticket:205)

2018-09-10, Petra Seibert: increase output width for time in sec
small improvements in code layout, name big loops

  • Property mode set to 100644
File size: 9.1 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 plumetraj(itime)
23  !                       i
24  !*****************************************************************************
25  !                                                                            *
26  ! Determines a plume centroid trajectory for each release site, and manages  *
27  ! clustering of particle locations. Certain parameters (average PV,          *
28  ! tropopause height, etc., are provided along the plume trajectories.        *
29  ! At the end, output is written to file 'trajectories.txt'.                  *
30  !                                                                            *
31  !     Author: A. Stohl                                                       *
32  !                                                                            *
33  !     24 January 2002                                                        *
34  !                                                                            *
35  !     2018-09-10, Petra Seibert: increase output width for time in sec       *
36  !       small improvements in code layout, name big loops                    *
37  !                                                                            *
38  ! Variables:                                                                 *
39  ! fclust          fraction of particles belonging to each cluster            *
40  ! hmixcenter      mean mixing height for all particles                       *
41  ! ncluster        number of clusters to be used                              *
42  ! pvcenter        mean PV for all particles                                  *
43  ! pvfract         fraction of particles with PV<2pvu                         *
44  ! rms             total horizontal rms distance after clustering             *
45  ! rmsdist         total horizontal rms distance before clustering            *
46  ! rmsclust        horizontal rms distance for each individual cluster        *
47  ! topocenter      mean topography underlying all particles                   *
48  ! tropocenter     mean tropopause height at the positions of particles       *
49  ! tropofract      fraction of particles within the troposphere               *
50  ! zrms            total vertical rms distance after clustering               *
51  ! zrmsdist        total vertical rms distance before clustering              *
52  ! xclust,yclust,  Cluster centroid positions                                 *
53  ! zclust                                                                     *
54  !                                                                            *
55  !*****************************************************************************
56
57  use point_mod
58  use par_mod
59  use com_mod
60  use mean_mod
61
62  implicit none
63
64  integer :: itime,ix,jy,ixp,jyp,indexh,i,j,k,m,n,il,ind,indz,indzp
65  real :: xl(maxpart),yl(maxpart),zl(maxpart)
66  real :: xcenter,ycenter,zcenter,dist,distance,rmsdist,zrmsdist
67
68  real :: xclust(ncluster),yclust(ncluster),zclust(ncluster)
69  real :: fclust(ncluster),rms,rmsclust(ncluster),zrms
70
71  real :: dt1,dt2,dtt,ddx,ddy,rddx,rddy,p1,p2,p3,p4,dz1,dz2,dz
72  real :: topo,topocenter,hm(2),hmixi,hmixfract,hmixcenter
73  real :: pv1(2),pvprof(2),pvi,pvcenter,pvfract,tr(2),tri,tropofract
74  real :: tropocenter
75
76
77  dt1=real(itime-memtime(1))
78  dt2=real(memtime(2)-itime)
79  dtt=1./(dt1+dt2)
80
81
82  ! Loop over all release points
83  !*****************************
84
85  point_loop: do j=1,numpoint
86    if (abs(ireleasestart(j)-itime).gt.lage(nageclass)) goto 10
87    topocenter=0.
88    hmixcenter=0.
89    hmixfract=0.
90    tropocenter=0.
91    tropofract=0.
92    pvfract=0.
93    pvcenter=0.
94    rmsdist=0.
95    zrmsdist=0.
96
97    n=0
98    particle_loop: do i=1,numpart
99      if (itra1(i).ne.itime) goto 20
100      if (npoint(i).ne.j) goto 20
101      n=n+1
102      xl(n)=xlon0+xtra1(i)*dx
103      yl(n)=ylat0+ytra1(i)*dy
104      zl(n)=ztra1(i)
105
106
107  ! Interpolate PBL height, PV, and tropopause height to each
108  ! particle position in order to determine fraction of particles
109  ! within the PBL, above tropopause height, and average PV.
110  ! Interpolate topography, too, and convert to altitude asl
111  !**************************************************************
112
113      ix=int(xtra1(i))
114      jy=int(ytra1(i))
115      ixp=ix+1
116      jyp=jy+1
117      ddx=xtra1(i)-real(ix)
118      ddy=ytra1(i)-real(jy)
119      rddx=1.-ddx
120      rddy=1.-ddy
121      p1=rddx*rddy
122      p2=ddx*rddy
123      p3=rddx*ddy
124      p4=ddx*ddy
125
126  ! Topography
127  !***********
128
129      topo=p1*oro(ix ,jy) &
130         + p2*oro(ixp,jy) &
131         + p3*oro(ix ,jyp) &
132         + p4*oro(ixp,jyp)
133      topocenter=topocenter+topo
134
135  ! Potential vorticity
136  !********************
137
138      do il=2,nz
139        if (height(il).gt.zl(n)) then
140          indz=il-1
141          indzp=il
142          goto 6
143        endif
144      end do
1456     continue
146
147      dz1=zl(n)-height(indz)
148      dz2=height(indzp)-zl(n)
149      dz=1./(dz1+dz2)
150
151
152      do ind=indz,indzp
153        do m=1,2
154          indexh=memind(m)
155          pv1(m)=p1*pv(ix ,jy ,ind,indexh) &
156                +p2*pv(ixp,jy ,ind,indexh) &
157                +p3*pv(ix ,jyp,ind,indexh) &
158                +p4*pv(ixp,jyp,ind,indexh)
159        end do
160        pvprof(ind-indz+1)=(pv1(1)*dt2+pv1(2)*dt1)*dtt
161      end do
162      pvi=(dz1*pvprof(2)+dz2*pvprof(1))*dz
163      pvcenter=pvcenter+pvi
164      if (yl(n).gt.0.) then
165        if (pvi.lt.2.) pvfract=pvfract+1.
166      else
167        if (pvi.gt.-2.) pvfract=pvfract+1.
168      endif
169
170
171  ! Tropopause and PBL height
172  !**************************
173
174      do m=1,2
175        indexh=memind(m)
176
177        tr(m)=p1*tropopause(ix ,jy ,1,indexh) &
178            + p2*tropopause(ixp,jy ,1,indexh) &
179            + p3*tropopause(ix ,jyp,1,indexh) &
180            + p4*tropopause(ixp,jyp,1,indexh)
181
182        hm(m)=p1*hmix(ix ,jy ,1,indexh) &
183            + p2*hmix(ixp,jy ,1,indexh) &
184            + p3*hmix(ix ,jyp,1,indexh) &
185            + p4*hmix(ixp,jyp,1,indexh)
186      end do
187
188      hmixi=(hm(1)*dt2+hm(2)*dt1)*dtt
189      tri=(tr(1)*dt2+tr(2)*dt1)*dtt
190      if (zl(n).lt.tri) tropofract=tropofract+1.
191      tropocenter=tropocenter+tri+topo
192      if (zl(n).lt.hmixi) hmixfract=hmixfract+1.
193      zl(n)=zl(n)+topo        ! convert to height asl
194      hmixcenter=hmixcenter+hmixi
195
19620    continue
197    end do particle_loop
198
199
200  ! Make statistics for all plumes with n>0 particles
201  !**************************************************
202
203    if (n.gt.0) then
204      topocenter=topocenter/real(n)
205      hmixcenter=hmixcenter/real(n)
206      pvcenter=pvcenter/real(n)
207      tropocenter=tropocenter/real(n)
208      hmixfract=100.*hmixfract/real(n)
209      pvfract=100.*pvfract/real(n)
210      tropofract=100.*tropofract/real(n)
211
212  ! Cluster the particle positions
213  !*******************************
214
215      call clustering(xl,yl,zl,n,xclust,yclust,zclust,fclust,rms, &
216           rmsclust,zrms)
217
218
219  ! Determine center of mass position on earth and average height
220  !**************************************************************
221
222      call centerofmass(xl,yl,n,xcenter,ycenter)
223      call mean(zl,zcenter,zrmsdist,n)
224
225  ! Root mean square distance from center of mass
226  !**********************************************
227
228      do k=1,n
229        dist=distance(yl(k),xl(k),ycenter,xcenter)
230        rmsdist=rmsdist+dist*dist
231      end do
232      if (rmsdist.gt.0.) rmsdist=sqrt(rmsdist/real(n))
233      rmsdist=max(rmsdist,0.)
234
235  ! Write out results in trajectory data file
236  !******************************************
237
238      write (unitouttraj,901) j,itime-(ireleasestart(j)+ireleaseend(j))/2, &
239           xcenter,ycenter,zcenter,topocenter,hmixcenter,tropocenter, &
240           pvcenter,rmsdist,rms,zrmsdist,zrms,hmixfract,pvfract,tropofract, &
241           (xclust(k),yclust(k),zclust(k),fclust(k),rmsclust(k), k=1,ncluster)
242901   format(i5,i10,2f9.4,4f8.1,f8.2,4f8.1,3f6.1,5(2f8.3,f7.0,f6.1,f8.1))   
243    endif
244
245
24610  continue
247  end do point_loop
248
249
250end subroutine plumetraj
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG