-
Notifications
You must be signed in to change notification settings - Fork 0
/
FUTURE_NH3Emis_variation_mod.f90
361 lines (319 loc) · 13.7 KB
/
FUTURE_NH3Emis_variation_mod.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
module NH3Emis_variation_mod
use NH3variables_mod, only :I_ISO_STABLE,I_OPEN_STABLE,I_STORAGE &
,I_WINTER_CROP,I_SPRING_CROP,I_SPRING_SBEET &
,I_SPRING_GRASS,I_MANURE1,I_MANURE2,I_MANURE3 &
,I_MANURE4,I_MINERAL_SPRING,I_MINERAL_AUTUMN &
,I_GRAZ_CATTLE,I_NH3_GRASS,I_TRAFFIC &
,I_MANURE4a,NNH3,TSPERDAY
use calc_emis_potential_mod, only : lddagtemp,lNH3emis_pot, lEmis50_nh3, emnh3
use TimeDate_mod, only : nydays, current_date
use MetFields_mod, only : t2_nwp,u_ref, &
foundv10_met,ps, roa,foundws10_met,ws_10m
use Par_mod, only : LIMAX,LJMAX,me,limax,ljmax
use GridValues_mod , only : i_fdom, j_fdom, sigma_bnd, xm2
use Config_module, only : DEBUG_i, DEBUG_j, PT, DEBUG_NH3, &
KMAX_MID, MasterProc
use Io_mod, only : IO_NH3_DEB
use TimeDate_mod, only : day_of_year, nmdays
use PhysicalConstants_mod, only : T0
use EmisDef_mod, only : NH3EMIS_VAR
use PhysicalConstants_mod, only : GRAV, AVOG
implicit none
private
real, public, save, dimension(NNH3,LIMAX,LJMAX) :: tnh3_fac !timefactors.
!Need to be reset every 3 hour (metstep)
!(or really:the same timestep as used in NH3emis_potential)
public :: NH3emis_variation
public :: SetNH3
contains
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine NH3emis_variation() !only one grid cell (and later one timestep at a time, now loop)
integer :: NHOUR,TIME1 !timesteps nr since start of year
integer :: NDAYS,I,NTIMESTEPS,KKK ,NDAY
real :: T2,V10
real :: VH10HELP
real :: VENTFACT,TSTALD
real :: GEMEMIS
real :: C1, D1, PI,SQRTTWOPI
integer :: year,month,day, hour,j,lu,nlu,ilu
integer, parameter :: TSPERDAY=8
logical :: debug_flag
real, parameter :: Z10 = 10.0 ! 10m height
tnh3_fac(:,:,:)=0.0 !initialize
GEMEMIS=1.
NDAYS = nydays !day_of_year(ISTARTYEAR,12,31)!find number of days in year
NDAY =day_of_year(current_date%year,current_date%month,current_date%day) !day in year
NHOUR= (NDAY-1)*24 + current_date%hour
TIME1=NHOUR/(24/TSPERDAY) +1
if (MasterProc)then
write(6,*)'Date and nhour and ntstep in NH3Emis_variation',current_date%year,current_date%month,current_date%day,current_date%hour,NHOUR,TIME1
end if
NTIMESTEPS=NDAYS*TSPERDAY
PI=4.*ATAN(1.)
SQRTTWOPI=(PI*2.)**0.5
do j = 1,ljmax
do i = 1,limax
! - Set up debugging coordinates first. ---------------------------!
! If location matches debug i,j value, set debug_flag.
debug_flag = .false.
if ( i_fdom(i)==DEBUG_i .and. j_fdom(j)==DEBUG_j)then
debug_flag = .true.
write(6,*)'Found coords for Tange, prog, i,j, ',me,i,j
end if
T2=t2_nwp(i,j,1)-T0 ! T2 in C not in K degrees
if(foundws10_met)then
V10=ws_10m(i,j,1)
! else
! V10=u_ref(i,j) !~45m wind??
end if
if ( DEBUG_NH3 .and. debug_flag )then !write out for Tange
write(6,*) 'DEBUG 2m nwp temp for Tange NDAY, NHOUR',T2,me,i,j, NDAY,NHOUR
write(6,*) 'DEBUG 10m wind V10 foundu10_met foundv10_met ',foundws10_met,V10,me,i,j
end if
!C
!C *******************************************
!C * EMISSION VARIATION FOR ISOLATED STABLES *
!C *******************************************
!C
IF (T2.LT.0) THEN
VENTFACT=0.2
TSTALD=MAX(0.,(18.0+0.5*(T2-0.)))
ELSE IF (T2.GE.0.AND.T2.LT.12.5) THEN
TSTALD=18.
VENTFACT=(0.2+(0.38-0.2)*(MAX(0.,T2)-0.)/(12.5-0.))
ELSE
TSTALD=18.+(T2-12.5)*0.77
VENTFACT=0.38 !SAME AS ABOVE
ENDIF
tnh3_fac(I_ISO_STABLE,i,j)=&
(VENTFACT**0.26)*(TSTALD**0.89)*&
(1.0*GEMEMIS/(lNH3emis_pot(I_ISO_STABLE,i,j)))
!C ***************************************
!C * EMISSION VARIATION FOR OPEN STABLES *
!C ***************************************
!C
IF (T2.LT.1.) THEN
TSTALD=4.
ELSE
TSTALD=(T2+3.)
ENDIF
VENTFACT=0.214+&
0.014*SIN((243.*TIME1+(REAL(TIME1)))*2.*PI/(TSPERDAY*REAL(NDAYS))) ! 24 -> TSPERDAY !I->TIME1
tnh3_fac(I_OPEN_STABLE,i,j)=&
(VENTFACT**0.26)*(TSTALD**0.89)*&
(GEMEMIS/(lNH3emis_pot(I_OPEN_STABLE,i,j)))
!C
!C **********************************************
!C * EMISSION POTENTIAL FOR STORAGE FASCIITIES *
!C **********************************************
!C
IF (T2.LT.1.) THEN
TSTALD=1.
ELSE
TSTALD=T2
ENDIF
tnh3_fac(I_STORAGE,i,j)=(V10**0.26)*(TSTALD**0.89)*&
(GEMEMIS/(lNH3emis_pot(I_STORAGE,i,j)))
VH10HELP=EXP(0.0419*V10)
!C
!C ******************************************************
!C * EMISSION VARIATION FOR MANURE TYPE 1: EARLY SPRING *
!C ******************************************************
!C
C1=(lddagtemp(1,i,j))*TSPERDAY ! 24 -> TSPERDAY
D1=9.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MANURE1,i,j)=EXP(0.0223*T2)*&
VH10HELP*&
(1./(D1*SQRTTWOPI))*(GEMEMIS/(lNH3emis_pot(I_MANURE1,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C *****************************************************
!C * EMISSION VARIATION FOR MANURE TYPE 2: LATE SPRING *
!C *****************************************************
!C
C1=(lddagtemp(3,i,j))*TSPERDAY ! 24 -> TSPERDAY
D1=9.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MANURE2,i,j)=EXP(0.0223*T2)*&
VH10HELP*&
(1./(D1*SQRTTWOPI))*(GEMEMIS/(lNH3emis_pot(I_MANURE2,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ************************************************
!C * EMISSION VARIATION FOR MANURE TYPE 3: SUMMER *
!C ************************************************
!C
C1=(lddagtemp(7,i,j))*TSPERDAY ! 24 -> TSPERDAY
D1=16.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MANURE3,i,j)=EXP(0.0223*T2)*&
VH10HELP*&
(1./(D1*SQRTTWOPI))*(GEMEMIS/(lNH3emis_pot(I_MANURE3,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ************************************************
!C * EMISSION VARIATION FOR MANURE TYPE 4: AUTUMN *
!C ************************************************
!C
C1=270.*TSPERDAY ! 24 -> TSPERDAY
D1=16.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MANURE4,i,j)=EXP(0.0223*T2)*&
VH10HELP*&
(1./(D1*SQRTTWOPI))*(GEMEMIS/(lNH3emis_pot(I_MANURE4,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C *****************************************************
!C * EMISSION VARIATION FOR MANURE TYPE 4a: EMPTY TANKS *
!C *****************************************************
!C
C1=270.*TSPERDAY ! 24 -> TSPERDAY
D1=09.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MANURE4a,i,j)=EXP(0.0223*T2)*VH10HELP*&
(1./(D1*SQRTTWOPI))*(GEMEMIS/(lNH3emis_pot(I_MANURE4a,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ******************************************************************************
!C * EMISSION VARIATION FOR GRAZING CATTLE: ASSUMED TO FOLLOW THE GRASS PATTERN *
!C ******************************************************************************
!C
C1=lddagtemp(7,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=60.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_GRAZ_CATTLE,i,j)=(1./(D1*SQRTTWOPI))*&
(GEMEMIS/(lNH3emis_pot(I_GRAZ_CATTLE,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ***************************************
!C * EMISSION VARIATION FOR WINTER CROPS *
!C ***************************************
!C
C1=lddagtemp(5,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=39.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_WINTER_CROP,i,j)=(1./(D1*SQRTTWOPI))*&
(GEMEMIS/(lNH3emis_pot(I_WINTER_CROP,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ***************************************
!C * EMISSION VARIATION FOR SPRING CROPS *
!C ***************************************
!C
C1=lddagtemp(6,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=25.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_SPRING_CROP,i,j)=(1./(D1*SQRTTWOPI))*&
(GEMEMIS/(lNH3emis_pot(I_SPRING_CROP,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C *********************************************
!C * EMISSION VARIATION FOR SPRING SUGAR BEETS *
!C *********************************************
!C
C1=lddagtemp(8,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=45.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_SPRING_SBEET,i,j)=(1./(D1*SQRTTWOPI))*&
(GEMEMIS/(lNH3emis_pot(I_SPRING_SBEET,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ********************************************
!C * EMISSION VARIATION FOR GRASS IN ROTATION *
!C ********************************************
!C
C1=lddagtemp(7,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=60.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_SPRING_GRASS,i,j)=(1./(D1*SQRTTWOPI))*&
(GEMEMIS/(lNH3emis_pot(I_SPRING_GRASS,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C *****************************************************
!C * EMISSION VARIATION FOR MINERAL FERTIIZER: SPRING *
!C
C1=lddagtemp(2,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=9.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MINERAL_SPRING,i,j)=EXP(0.0223*T2)*VH10HELP*&
(1./(D1*SQRTTWOPI))*(0.9*GEMEMIS/(lNH3emis_pot(I_MINERAL_SPRING,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C *****************************************************
!C * EMISSION VARIATION FOR MINERAL FERTIIZER: SUMMER *
!C *****************************************************
!C
C1=lddagtemp(7,i,j)*TSPERDAY ! 24 -> TSPERDAY
D1=16.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_MINERAL_AUTUMN,i,j)=EXP(0.0223*T2)*VH10HELP*&
(1./(D1*SQRTTWOPI))*(0.1*GEMEMIS/(lNH3emis_pot(I_MINERAL_AUTUMN,i,j)))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ************************************************
!C * AMMONIA LOSSES FROM NH3 THREATMEANT OF GRASS *
!C ************************************************
!C
C1=(lddagtemp(4,i,j)+15)*TSPERDAY ! 24 -> TSPERDAY
D1=9.*TSPERDAY ! 24 -> TSPERDAY
tnh3_fac(I_NH3_GRASS,i,j)=GEMEMIS*(1./(D1*SQRTTWOPI))*&
EXP(-0.5*((TIME1-C1)/D1)**2.)
!C
!C ************************
!C * AMMONIA FROM TRAFFIC *
!C ************************
!C
tnh3_fac(I_TRAFFIC,i,j)=GEMEMIS/(TSPERDAY *REAL(NDAYS)) ! 24 -> TSPERDAY
!C
!C
!write out for Tange
if ( DEBUG_NH3 .and. i_fdom(i)==DEBUG_i .and. j_fdom(j)==DEBUG_j )then
! output to file
! write(IO_NH3_DEB,'(3i3,i5,18F20.10)')current_date%month,&
! current_date%day,current_date%hour,TIME1,&
! tnh3_fac(I_ISO_STABLE,i,j),tnh3_fac(I_OPEN_STABLE,i,j),&
! tnh3_fac(I_STORAGE,i,j),tnh3_fac(I_WINTER_CROP,i,j),&
! tnh3_fac(I_SPRING_CROP,i,j), tnh3_fac(I_SPRING_SBEET,i,j),&
! tnh3_fac(I_SPRING_GRASS,i,j), tnh3_fac(I_MANURE1,i,j), &
! tnh3_fac(I_MANURE2,i,j),tnh3_fac(I_MANURE3,i,j),&
! tnh3_fac(I_MANURE4,i,j),tnh3_fac(I_MANURE4a,i,j),&
! tnh3_fac(I_MINERAL_SPRING,i,j),tnh3_fac(I_MINERAL_AUTUMN,i,j),&
! tnh3_fac(I_GRAZ_CATTLE,i,j),tnh3_fac(I_NH3_GRASS,i,j), &
! tnh3_fac(I_TRAFFIC,i,j),sum(tnh3_fac(:,i,j))
print *, '-------------DEBUG VARIATIONS-------------------------'
write(6,'(3i3,3i5,F6.0,17F20.10)')current_date%month,current_date%day,current_date%hour,TIME1,&
I,J,T2,tnh3_fac(I_ISO_STABLE,i,j),&
tnh3_fac(I_OPEN_STABLE,i,j),tnh3_fac(I_STORAGE,i,j),tnh3_fac(I_WINTER_CROP,i,j),&
tnh3_fac(I_SPRING_CROP,i,j), tnh3_fac(I_SPRING_SBEET,i,j), tnh3_fac(I_SPRING_GRASS,i,j), &
tnh3_fac(I_MANURE1,i,j), tnh3_fac(I_MANURE2,i,j),&
tnh3_fac(I_MANURE3,i,j),tnh3_fac(I_MANURE4,i,j),tnh3_fac(I_MANURE4a,i,j),tnh3_fac(I_MINERAL_SPRING,i,j),&
tnh3_fac(I_MINERAL_AUTUMN,i,j),tnh3_fac(I_GRAZ_CATTLE,i,j),&
tnh3_fac(I_NH3_GRASS,i,j), tnh3_fac(I_TRAFFIC,i,j)
end if
end do !i
end do !j
end subroutine NH3emis_variation
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!hf NH3emis
!------------------------------------------------------------------------------
subroutine SetNH3()
!------------------------------------------------------------------------------
integer :: i,j,k
real :: ehlpcom,ehlpcom0
real :: NTPERYEAR
if (NH3EMIS_VAR) then
call NH3emis_variation() !set timefactors for this timestep
ehlpcom0 = GRAV* 0.001*AVOG/ (sigma_bnd(KMAX_MID+1) - sigma_bnd(KMAX_MID))
emnh3(:,:,:)=0.0
do j = 1,ljmax
do i = 1,limax
ehlpcom = ehlpcom0 * roa(i,j,KMAX_MID,1)/(ps(i,j,1)-PT)
!tnh3_fac(k,i,j) is the fraction of emissions per 3 hour(1/3h)
!Already in /s, thus we multiply tnh3_fac up to a year
NTPERYEAR=nydays*TSPERDAY
do k=1,NNH3
emnh3(k,i,j) = lEmis50_nh3(k,i,j)*ehlpcom *tnh3_fac(k,i,j) &
*NTPERYEAR *xm2(i,j)/14.0 !from kg(N)/m2/s to molecules/cm3/s
if ( DEBUG_NH3 .and. i_fdom(i)==DEBUG_i .and. j_fdom(j)==DEBUG_j)then !write out for Tange
write(6,*)'DEBUG for Tange'
write(6,*)'k and emnh3', k, emnh3(k,i,j)
write(6,*)'proc,lEmis50_nh3',me, lEmis50_nh3(k,i,j)
write(6,*)'tnh3_fac(k,i,j)', tnh3_fac(k,i,j)*NTPERYEAR
write(6,*)'NH3Emisvariation ',emnh3(k,i,j)
write(6,*)'NTPERYEAR, nydays, TSPERDAY',NTPERYEAR,nydays,TSPERDAY
end if
end do
end do ! i
end do ! j
end if ! NH3EMIS_VAR
end subroutine SetNH3
end module NH3Emis_variation_mod