1 | ! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt |
---|
2 | ! SPDX-License-Identifier: GPL-3.0-or-later |
---|
3 | |
---|
4 | subroutine ohreaction(itime,ltsample,loutnext) |
---|
5 | ! i i i |
---|
6 | !***************************************************************************** |
---|
7 | ! * |
---|
8 | ! * |
---|
9 | ! Author: R.L. Thompson * |
---|
10 | ! * |
---|
11 | ! Nov 2014 * |
---|
12 | ! * |
---|
13 | ! * |
---|
14 | !***************************************************************************** |
---|
15 | ! Variables: * |
---|
16 | ! ix,jy indices of output grid cell for each particle * |
---|
17 | ! itime [s] actual simulation time [s] * |
---|
18 | ! jpart particle index * |
---|
19 | ! ldeltat [s] interval since radioactive decay was computed * |
---|
20 | ! loutnext [s] time for which gridded deposition is next output * |
---|
21 | ! loutstep [s] interval at which gridded deposition is output * |
---|
22 | ! oh_average [molecule/cm^3] OH Concentration * |
---|
23 | ! ltsample [s] interval over which mass is deposited * |
---|
24 | ! * |
---|
25 | !***************************************************************************** |
---|
26 | |
---|
27 | use oh_mod |
---|
28 | use par_mod |
---|
29 | use com_mod |
---|
30 | |
---|
31 | implicit none |
---|
32 | |
---|
33 | integer :: jpart,itime,ltsample,loutnext,ldeltat,j,k,ix,jy!,ijx,jjy |
---|
34 | integer :: ngrid,interp_time,n,m,h,indz,i!,ia,il |
---|
35 | integer :: jjjjmmdd,hhmmss,OHx,OHy,OHz |
---|
36 | real, dimension(nzOH) :: altOHtop |
---|
37 | real :: xlon,ylat |
---|
38 | real :: xtn,ytn |
---|
39 | real :: restmass,ohreacted,oh_average |
---|
40 | real :: ohrate,temp |
---|
41 | real, parameter :: smallnum = tiny(0.0) ! smallest number that can be handled |
---|
42 | real(kind=dp) :: jul |
---|
43 | |
---|
44 | ! Compute interval since radioactive decay of deposited mass was computed |
---|
45 | !************************************************************************ |
---|
46 | |
---|
47 | if (itime.le.loutnext) then |
---|
48 | ldeltat=itime-(loutnext-loutstep) |
---|
49 | else ! first half of next interval |
---|
50 | ldeltat=itime-loutnext |
---|
51 | endif |
---|
52 | |
---|
53 | jul=bdate+real(itime,kind=dp)/86400. |
---|
54 | call caldate(jul,jjjjmmdd,hhmmss) |
---|
55 | m=(jjjjmmdd-(jjjjmmdd/10000)*10000)/100 |
---|
56 | h=hhmmss/10000 |
---|
57 | |
---|
58 | ! Loop over particles |
---|
59 | !***************************************** |
---|
60 | |
---|
61 | do jpart=1,numpart |
---|
62 | |
---|
63 | ! Determine which nesting level to be used |
---|
64 | ngrid=0 |
---|
65 | do j=numbnests,1,-1 |
---|
66 | if ((xtra1(jpart).gt.xln(j)).and.(xtra1(jpart).lt.xrn(j)).and. & |
---|
67 | (ytra1(jpart).gt.yln(j)).and.(ytra1(jpart).lt.yrn(j))) then |
---|
68 | ngrid=j |
---|
69 | goto 23 |
---|
70 | endif |
---|
71 | end do |
---|
72 | 23 continue |
---|
73 | |
---|
74 | ! Determine nested grid coordinates |
---|
75 | if (ngrid.gt.0) then |
---|
76 | xtn=(xtra1(jpart)-xln(ngrid))*xresoln(ngrid) |
---|
77 | ytn=(ytra1(jpart)-yln(ngrid))*yresoln(ngrid) |
---|
78 | ix=int(xtn) |
---|
79 | jy=int(ytn) |
---|
80 | else |
---|
81 | ix=int(xtra1(jpart)) |
---|
82 | jy=int(ytra1(jpart)) |
---|
83 | endif |
---|
84 | |
---|
85 | interp_time=nint(itime-0.5*ltsample) |
---|
86 | n=2 |
---|
87 | if(abs(memtime(1)-interp_time).lt.abs(memtime(2)-interp_time)) n=1 |
---|
88 | |
---|
89 | do i=2,nz |
---|
90 | if (height(i).gt.ztra1(jpart)) then |
---|
91 | indz=i-1 |
---|
92 | goto 6 |
---|
93 | endif |
---|
94 | end do |
---|
95 | 6 continue |
---|
96 | |
---|
97 | ! Get OH from nearest grid-cell and specific month |
---|
98 | !************************************************* |
---|
99 | |
---|
100 | ! world coordinates |
---|
101 | xlon=xtra1(jpart)*dx+xlon0 |
---|
102 | if (xlon.gt.180) then |
---|
103 | xlon=xlon-360 |
---|
104 | endif |
---|
105 | ylat=ytra1(jpart)*dy+ylat0 |
---|
106 | |
---|
107 | ! get position in the OH field |
---|
108 | OHx=minloc(abs(lonOH-xlon),dim=1,mask=abs(lonOH-xlon).eq.minval(abs(lonOH-xlon))) |
---|
109 | OHy=minloc(abs(latOH-ylat),dim=1,mask=abs(latOH-ylat).eq.minval(abs(latOH-ylat))) |
---|
110 | |
---|
111 | ! get the level of the OH field for the particle |
---|
112 | ! ztra1 is the z-coord of the trajectory above model orography in metres |
---|
113 | ! altOH is the height of the centre of the level in the OH field above orography |
---|
114 | do i=2,nzOH |
---|
115 | altOHtop(i-1)=altOH(i)+0.5*(altOH(i)-altOH(i-1)) |
---|
116 | end do |
---|
117 | altOHtop(nzOH)=altOH(nzOH)+0.5*(altOH(nzOH)-altOH(nzOH-1)) |
---|
118 | OHz=minloc(abs(altOHtop-ztra1(jpart)),dim=1,mask=abs(altOHtop-ztra1(jpart))& |
---|
119 | &.eq.minval(abs(altOHtop-ztra1(jpart)))) |
---|
120 | |
---|
121 | ! Interpolate between hourly OH fields to current time |
---|
122 | !***************************************************** |
---|
123 | |
---|
124 | oh_average=OH_hourly(OHx,OHy,OHz,1)+& |
---|
125 | &(OH_hourly(OHx,OHy,OHz,2)-OH_hourly(OHx,OHy,OHz,1))*& |
---|
126 | &(itime-memOHtime(1))/(memOHtime(2)-memOHtime(1)) |
---|
127 | |
---|
128 | if (oh_average.gt.smallnum) then |
---|
129 | |
---|
130 | ! Computation of the OH reaction |
---|
131 | !********************************************************** |
---|
132 | |
---|
133 | temp=tt(ix,jy,indz,n) |
---|
134 | |
---|
135 | do k=1,nspec |
---|
136 | if (ohcconst(k).gt.0.) then |
---|
137 | ohrate=ohcconst(k)*temp**ohnconst(k)*exp(-ohdconst(k)/temp)*oh_average |
---|
138 | ! new particle mass |
---|
139 | restmass = xmass1(jpart,k)*exp(-1*ohrate*abs(ltsample)) |
---|
140 | if (restmass .gt. smallnum) then |
---|
141 | xmass1(jpart,k)=restmass |
---|
142 | else |
---|
143 | xmass1(jpart,k)=0. |
---|
144 | endif |
---|
145 | ohreacted=xmass1(jpart,k)*(1-exp(-1*ohrate*abs(ltsample))) |
---|
146 | else |
---|
147 | ohreacted=0. |
---|
148 | endif |
---|
149 | end do |
---|
150 | |
---|
151 | endif ! oh_average.gt.smallnum |
---|
152 | |
---|
153 | end do !continue loop over all particles |
---|
154 | |
---|
155 | |
---|
156 | end subroutine ohreaction |
---|
157 | |
---|