source: flexpart.git/src/initial_cond_calc.f90 @ 3481cc1

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bug
Last change on this file since 3481cc1 was 3481cc1, checked in by Ignacio Pisso <ip@…>, 4 years ago

move license from headers to a different file

  • Property mode set to 100644
File size: 5.9 KB
Line 
1subroutine initial_cond_calc(itime,i)
2  !                               i   i
3  !*****************************************************************************
4  !                                                                            *
5  !     Calculation of the sensitivity to initial conditions for BW runs       *
6  !                                                                            *
7  !     Author: A. Stohl                                                       *
8  !                                                                            *
9  !     15 January 2010                                                        *
10  !                                                                            *
11  !*****************************************************************************
12
13  use unc_mod
14  use outg_mod
15  use par_mod
16  use com_mod
17
18  implicit none
19
20  integer :: itime,i,ix,jy,ixp,jyp,kz,ks
21  integer :: il,ind,indz,indzp,nrelpointer
22  real :: rddx,rddy,p1,p2,p3,p4,dz1,dz2,dz
23  real :: ddx,ddy
24  real :: rhoprof(2),rhoi,xl,yl,wx,wy,w
25  integer :: mind2
26  ! mind2        eso: pointer to 2nd windfield in memory
27
28
29  ! For forward simulations, make a loop over the number of species;
30  ! for backward simulations, make an additional loop over the release points
31  !**************************************************************************
32
33
34  if (itra1(i).ne.itime) return
35
36  ! Depending on output option, calculate air density or set it to 1
37  ! linit_cond: 1=mass unit, 2=mass mixing ratio unit
38  !*****************************************************************
39
40
41  if (linit_cond.eq.1) then     ! mass unit
42
43    ix=int(xtra1(i))
44    jy=int(ytra1(i))
45    ixp=ix+1
46    jyp=jy+1
47    ddx=xtra1(i)-real(ix)
48    ddy=ytra1(i)-real(jy)
49    rddx=1.-ddx
50    rddy=1.-ddy
51    p1=rddx*rddy
52    p2=ddx*rddy
53    p3=rddx*ddy
54    p4=ddx*ddy
55
56    do il=2,nz
57      if (height(il).gt.ztra1(i)) then
58        indz=il-1
59        indzp=il
60        goto 6
61      endif
62    end do
636   continue
64
65    dz1=ztra1(i)-height(indz)
66    dz2=height(indzp)-ztra1(i)
67    dz=1./(dz1+dz2)
68
69  ! Take density from 2nd wind field in memory (accurate enough, no time interpolation needed)
70  !*****************************************************************************
71    mind2=memind(2)
72
73    do ind=indz,indzp
74      rhoprof(ind-indz+1)=p1*rho(ix ,jy ,ind,mind2) &
75           +p2*rho(ixp,jy ,ind,mind2) &
76           +p3*rho(ix ,jyp,ind,mind2) &
77           +p4*rho(ixp,jyp,ind,mind2)
78    end do
79    rhoi=(dz1*rhoprof(2)+dz2*rhoprof(1))*dz
80  elseif (linit_cond.eq.2) then    ! mass mixing ratio unit
81    rhoi=1.
82  endif
83
84
85  !****************************************************************************
86  ! 1. Evaluate grid concentrations using a uniform kernel of bandwidths dx, dy
87  !****************************************************************************
88
89
90  ! For backward simulations, look from which release point the particle comes from
91  ! For domain-filling trajectory option, npoint contains a consecutive particle
92  ! number, not the release point information. Therefore, nrelpointer is set to 1
93  ! for the domain-filling option.
94  !*****************************************************************************
95
96  if ((ioutputforeachrelease.eq.0).or.(mdomainfill.eq.1)) then
97    nrelpointer=1
98  else
99    nrelpointer=npoint(i)
100  endif
101
102  do kz=1,numzgrid                ! determine height of cell
103    if (outheight(kz).gt.ztra1(i)) goto 21
104  end do
10521   continue
106  if (kz.le.numzgrid) then           ! inside output domain
107
108
109    xl=(xtra1(i)*dx+xoutshift)/dxout
110    yl=(ytra1(i)*dy+youtshift)/dyout
111    ix=int(xl)
112    if (xl.lt.0.) ix=ix-1
113    jy=int(yl)
114    if (yl.lt.0.) jy=jy-1
115
116
117  ! If a particle is close to the domain boundary, do not use the kernel either
118  !****************************************************************************
119
120    if ((xl.lt.0.5).or.(yl.lt.0.5).or. &
121         (xl.gt.real(numxgrid-1)-0.5).or. &
122         (yl.gt.real(numygrid-1)-0.5)) then             ! no kernel, direct attribution to grid cell
123      if ((ix.ge.0).and.(jy.ge.0).and.(ix.le.numxgrid-1).and. &
124           (jy.le.numygrid-1)) then
125        do ks=1,nspec
126          init_cond(ix,jy,kz,ks,nrelpointer)= &
127               init_cond(ix,jy,kz,ks,nrelpointer)+ &
128               xmass1(i,ks)/rhoi
129        end do
130      endif
131
132    else                                 ! attribution via uniform kernel
133
134      ddx=xl-real(ix)                   ! distance to left cell border
135      ddy=yl-real(jy)                   ! distance to lower cell border
136      if (ddx.gt.0.5) then
137        ixp=ix+1
138        wx=1.5-ddx
139      else
140        ixp=ix-1
141        wx=0.5+ddx
142      endif
143
144      if (ddy.gt.0.5) then
145        jyp=jy+1
146        wy=1.5-ddy
147      else
148        jyp=jy-1
149        wy=0.5+ddy
150      endif
151
152
153  ! Determine mass fractions for four grid points
154  !**********************************************
155
156      if ((ix.ge.0).and.(ix.le.numxgrid-1)) then
157        if ((jy.ge.0).and.(jy.le.numygrid-1)) then
158          w=wx*wy
159          do ks=1,nspec
160            init_cond(ix,jy,kz,ks,nrelpointer)= &
161                 init_cond(ix,jy,kz,ks,nrelpointer)+xmass1(i,ks)/rhoi*w
162          end do
163        endif
164
165        if ((jyp.ge.0).and.(jyp.le.numygrid-1)) then
166          w=wx*(1.-wy)
167          do ks=1,nspec
168            init_cond(ix,jyp,kz,ks,nrelpointer)= &
169                 init_cond(ix,jyp,kz,ks,nrelpointer)+xmass1(i,ks)/rhoi*w
170          end do
171        endif
172      endif
173
174
175      if ((ixp.ge.0).and.(ixp.le.numxgrid-1)) then
176        if ((jyp.ge.0).and.(jyp.le.numygrid-1)) then
177          w=(1.-wx)*(1.-wy)
178          do ks=1,nspec
179            init_cond(ixp,jyp,kz,ks,nrelpointer)= &
180                 init_cond(ixp,jyp,kz,ks,nrelpointer)+xmass1(i,ks)/rhoi*w
181          end do
182        endif
183
184        if ((jy.ge.0).and.(jy.le.numygrid-1)) then
185          w=(1.-wx)*wy
186          do ks=1,nspec
187            init_cond(ixp,jy,kz,ks,nrelpointer)= &
188                 init_cond(ixp,jy,kz,ks,nrelpointer)+xmass1(i,ks)/rhoi*w
189          end do
190        endif
191      endif
192    endif
193
194  endif
195
196end subroutine initial_cond_calc
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG