[0c8c7f2] | 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 | |
---|
| 22 | |
---|
| 23 | subroutine partpos_average(itime,j) |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | !********************************************************************** |
---|
| 27 | ! This subroutine averages particle quantities, to be used for particle |
---|
| 28 | ! dump (in partoutput.f90). Averaging is done over output interval. |
---|
| 29 | !********************************************************************** |
---|
| 30 | |
---|
| 31 | use par_mod |
---|
| 32 | use com_mod |
---|
| 33 | |
---|
| 34 | implicit none |
---|
| 35 | |
---|
| 36 | integer :: itime,j,ix,jy,ixp,jyp,indexh,m,il,ind,indz,indzp |
---|
| 37 | real :: xlon,ylat,x,y,z |
---|
| 38 | real :: dt1,dt2,dtt,ddx,ddy,rddx,rddy,p1,p2,p3,p4,dz1,dz2,dz |
---|
| 39 | real :: topo,hm(2),hmixi,pv1(2),pvprof(2),pvi,qv1(2),qvprof(2),qvi |
---|
| 40 | real :: tt1(2),ttprof(2),tti,rho1(2),rhoprof(2),rhoi |
---|
| 41 | real :: uu1(2),uuprof(2),uui,vv1(2),vvprof(2),vvi |
---|
| 42 | real :: tr(2),tri,energy |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | ! Some variables needed for temporal interpolation |
---|
| 47 | !************************************************* |
---|
| 48 | |
---|
| 49 | dt1=real(itime-memtime(1)) |
---|
| 50 | dt2=real(memtime(2)-itime) |
---|
| 51 | dtt=1./(dt1+dt2) |
---|
| 52 | |
---|
| 53 | xlon=xlon0+xtra1(j)*dx |
---|
| 54 | ylat=ylat0+ytra1(j)*dy |
---|
| 55 | |
---|
| 56 | !***************************************************************************** |
---|
| 57 | ! Interpolate several variables (PV, specific humidity, etc.) to particle position |
---|
| 58 | !***************************************************************************** |
---|
| 59 | |
---|
| 60 | ix=xtra1(j) |
---|
| 61 | jy=ytra1(j) |
---|
| 62 | ixp=ix+1 |
---|
| 63 | jyp=jy+1 |
---|
| 64 | ddx=xtra1(j)-real(ix) |
---|
| 65 | ddy=ytra1(j)-real(jy) |
---|
| 66 | rddx=1.-ddx |
---|
| 67 | rddy=1.-ddy |
---|
| 68 | p1=rddx*rddy |
---|
| 69 | p2=ddx*rddy |
---|
| 70 | p3=rddx*ddy |
---|
| 71 | p4=ddx*ddy |
---|
| 72 | |
---|
| 73 | ! eso: Temporary fix for particle exactly at north pole |
---|
| 74 | if (jyp >= nymax) then |
---|
| 75 | ! write(*,*) 'WARNING: conccalc.f90 jyp >= nymax' |
---|
| 76 | jyp=jyp-1 |
---|
| 77 | end if |
---|
| 78 | |
---|
| 79 | ! Topography |
---|
| 80 | !*********** |
---|
| 81 | |
---|
| 82 | topo=p1*oro(ix,jy)+p2*oro(ixp,jy)+p3*oro(ix,jyp)+p4*oro(ixp,jyp) |
---|
| 83 | |
---|
| 84 | ! Potential vorticity, specific humidity, temperature, and density |
---|
| 85 | !***************************************************************** |
---|
| 86 | |
---|
| 87 | do il=2,nz |
---|
| 88 | if (height(il).gt.ztra1(j)) then |
---|
| 89 | indz=il-1 |
---|
| 90 | indzp=il |
---|
| 91 | goto 6 |
---|
| 92 | endif |
---|
| 93 | end do |
---|
| 94 | 6 continue |
---|
| 95 | |
---|
| 96 | dz1=ztra1(j)-height(indz) |
---|
| 97 | dz2=height(indzp)-ztra1(j) |
---|
| 98 | dz=1./(dz1+dz2) |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | do ind=indz,indzp |
---|
| 102 | do m=1,2 |
---|
| 103 | indexh=memind(m) |
---|
| 104 | |
---|
| 105 | ! Potential vorticity |
---|
| 106 | pv1(m)=p1*pv(ix ,jy ,ind,indexh) & |
---|
| 107 | +p2*pv(ixp,jy ,ind,indexh) & |
---|
| 108 | +p3*pv(ix ,jyp,ind,indexh) & |
---|
| 109 | +p4*pv(ixp,jyp,ind,indexh) |
---|
| 110 | ! Specific humidity |
---|
| 111 | qv1(m)=p1*qv(ix ,jy ,ind,indexh) & |
---|
| 112 | +p2*qv(ixp,jy ,ind,indexh) & |
---|
| 113 | +p3*qv(ix ,jyp,ind,indexh) & |
---|
| 114 | +p4*qv(ixp,jyp,ind,indexh) |
---|
| 115 | ! Temperature |
---|
| 116 | tt1(m)=p1*tt(ix ,jy ,ind,indexh) & |
---|
| 117 | +p2*tt(ixp,jy ,ind,indexh) & |
---|
| 118 | +p3*tt(ix ,jyp,ind,indexh) & |
---|
| 119 | +p4*tt(ixp,jyp,ind,indexh) |
---|
| 120 | ! U wind |
---|
| 121 | uu1(m)=p1*uu(ix ,jy ,ind,indexh) & |
---|
| 122 | +p2*uu(ixp,jy ,ind,indexh) & |
---|
| 123 | +p3*uu(ix ,jyp,ind,indexh) & |
---|
| 124 | +p4*uu(ixp,jyp,ind,indexh) |
---|
| 125 | ! V wind |
---|
| 126 | vv1(m)=p1*vv(ix ,jy ,ind,indexh) & |
---|
| 127 | +p2*vv(ixp,jy ,ind,indexh) & |
---|
| 128 | +p3*vv(ix ,jyp,ind,indexh) & |
---|
| 129 | +p4*vv(ixp,jyp,ind,indexh) |
---|
| 130 | ! Density |
---|
| 131 | rho1(m)=p1*rho(ix ,jy ,ind,indexh) & |
---|
| 132 | +p2*rho(ixp,jy ,ind,indexh) & |
---|
| 133 | +p3*rho(ix ,jyp,ind,indexh) & |
---|
| 134 | +p4*rho(ixp,jyp,ind,indexh) |
---|
| 135 | end do |
---|
| 136 | pvprof(ind-indz+1)=(pv1(1)*dt2+pv1(2)*dt1)*dtt |
---|
| 137 | qvprof(ind-indz+1)=(qv1(1)*dt2+qv1(2)*dt1)*dtt |
---|
| 138 | ttprof(ind-indz+1)=(tt1(1)*dt2+tt1(2)*dt1)*dtt |
---|
| 139 | uuprof(ind-indz+1)=(uu1(1)*dt2+uu1(2)*dt1)*dtt |
---|
| 140 | vvprof(ind-indz+1)=(vv1(1)*dt2+vv1(2)*dt1)*dtt |
---|
| 141 | rhoprof(ind-indz+1)=(rho1(1)*dt2+rho1(2)*dt1)*dtt |
---|
| 142 | end do |
---|
| 143 | pvi=(dz1*pvprof(2)+dz2*pvprof(1))*dz |
---|
| 144 | qvi=(dz1*qvprof(2)+dz2*qvprof(1))*dz |
---|
| 145 | tti=(dz1*ttprof(2)+dz2*ttprof(1))*dz |
---|
| 146 | uui=(dz1*uuprof(2)+dz2*uuprof(1))*dz |
---|
| 147 | vvi=(dz1*vvprof(2)+dz2*vvprof(1))*dz |
---|
| 148 | rhoi=(dz1*rhoprof(2)+dz2*rhoprof(1))*dz |
---|
| 149 | |
---|
| 150 | ! Tropopause and PBL height |
---|
| 151 | !************************** |
---|
| 152 | |
---|
| 153 | do m=1,2 |
---|
| 154 | indexh=memind(m) |
---|
| 155 | |
---|
| 156 | ! Tropopause |
---|
| 157 | tr(m)=p1*tropopause(ix ,jy ,1,indexh) & |
---|
| 158 | + p2*tropopause(ixp,jy ,1,indexh) & |
---|
| 159 | + p3*tropopause(ix ,jyp,1,indexh) & |
---|
| 160 | + p4*tropopause(ixp,jyp,1,indexh) |
---|
| 161 | |
---|
| 162 | ! PBL height |
---|
| 163 | hm(m)=p1*hmix(ix ,jy ,1,indexh) & |
---|
| 164 | + p2*hmix(ixp,jy ,1,indexh) & |
---|
| 165 | + p3*hmix(ix ,jyp,1,indexh) & |
---|
| 166 | + p4*hmix(ixp,jyp,1,indexh) |
---|
| 167 | end do |
---|
| 168 | |
---|
| 169 | hmixi=(hm(1)*dt2+hm(2)*dt1)*dtt |
---|
| 170 | tri=(tr(1)*dt2+tr(2)*dt1)*dtt |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | energy=tti*cpa+(ztra1(j)+topo)*9.81+qvi*2501000.+(uui**2+vvi**2)/2. |
---|
| 174 | |
---|
| 175 | ! Add new values to sum and increase counter by one |
---|
| 176 | !************************************************** |
---|
| 177 | |
---|
| 178 | npart_av(j)=npart_av(j)+1 |
---|
| 179 | |
---|
| 180 | ! Calculate Cartesian 3D coordinates suitable for averaging |
---|
| 181 | !********************************************************** |
---|
| 182 | |
---|
| 183 | xlon=xlon*pi180 |
---|
| 184 | ylat=ylat*pi180 |
---|
| 185 | x = cos(ylat)*sin(xlon) |
---|
| 186 | y = -1.*cos(ylat)*cos(xlon) |
---|
| 187 | z = sin(ylat) |
---|
| 188 | |
---|
| 189 | part_av_cartx(j)=part_av_cartx(j)+x |
---|
| 190 | part_av_carty(j)=part_av_carty(j)+y |
---|
| 191 | part_av_cartz(j)=part_av_cartz(j)+z |
---|
| 192 | part_av_z(j)=part_av_z(j)+ztra1(j) |
---|
| 193 | part_av_topo(j)=part_av_topo(j)+topo |
---|
| 194 | part_av_pv(j)=part_av_pv(j)+pvi |
---|
| 195 | part_av_qv(j)=part_av_qv(j)+qvi |
---|
| 196 | part_av_tt(j)=part_av_tt(j)+tti |
---|
| 197 | part_av_uu(j)=part_av_uu(j)+uui |
---|
| 198 | part_av_vv(j)=part_av_vv(j)+vvi |
---|
| 199 | part_av_rho(j)=part_av_rho(j)+rhoi |
---|
| 200 | part_av_tro(j)=part_av_tro(j)+tri |
---|
| 201 | part_av_hmix(j)=part_av_hmix(j)+hmixi |
---|
| 202 | part_av_energy(j)=part_av_energy(j)+energy |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | return |
---|
| 206 | end subroutine partpos_average |
---|