-
Notifications
You must be signed in to change notification settings - Fork 3
/
bulk_chemistry.f90
2206 lines (1891 loc) · 79.4 KB
/
bulk_chemistry.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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
program bulk_model
use modchem
! USE DFLIB
implicit none
! --------------------------------------------
! Defines platform (MS Windows vs Linux/OSX)
logical :: windows = .false.
! --------------------------------------------
! From Tennekes and Driedonks,
! Boundary Layer Meteorology (1981), 515-531
!
! variables of the system
! thetam : potential temperature mixing layer value
! dtheta: potential temperature jump
! zi: boundary layer height
! -- wind ------------------------------------------
! um : initial horizontal windspeed ( x - direction)
! vm : initial horizontal windspeed ( y - direction)
! um0 : initial horizontal windspeed ( x - direction)
! vm0 : initial horizontal windspeed ( y - direction)
! ug: geostrophic wind in x-direction
! vg: geostrophic wind in y-direction
! --Specific humidity-------------------------
! qm : specific humidity mixing layer value
! dq : specific humidity jump
! zi : boundary layer height
! ws : Subsidence velocity
! prescribed value
! --Potential temperature-------------------------
! beta=-(wthetave/wthetavs) : entrainment to surface flux ratio
! wthetas : surface heat flux
! gamma: lapse rate
! --Specific humidity-------------------------
! betaq=-(wqe/wqs) : entrainment to surface flux ratio
! wq : surface humidity flux
! gammaq: lapse rate specific moisture
! -- wind ------------------------------------------
! um : initial horizontal windspeed ( x - direction)
! vm : initial horizontal windspeed ( y - direction)
!
! initial value
! --Potential temperature-------------------------
! z0: initial boundary layer height
! thetam0: initial potential temperature mixing layer value
! dtheta0: initial potential temperature jump
! --Specific humidity-------------------------
! qm0: initial specific humidity mixing layer value
! dq0: initial specific humidity jump
! --Carbon dioxide----------------------------------
! cm0: initial carbon dioxide mixing layer value
! dc0: initial carbon dioxide jump
! -- wind ------------------------------------------
! um0 : initial horizontal windspeed ( x - direction)
! vm0 : initial horizontal windspeed ( y - direction)
! ug: geostrophic wind in x-direction
! vg: geostrophic wind in y-direction
!
! constant for coding
! time = second
!
! solving using eulerien's way
!
! declaration
! dynamics
! beta=-(wthetae/wthetas) : entrainment to surface flux ratio
! wthetas : surface heat flux
! gamma: lapse rate
! --Specific humidity-------------------------
! betaq=-(wqe/wqs) : entrainment to surface flux ratio
! wq : surface humidity flux
! gammaq: lapse rate specific moisture
! gammac
!
!
! solving using eulerien's way
!
! Reaction_1 O3 + NO -> NO2 + O2 4.75E-4
! Reaction_2 HO + CO -> HO2 + CO2 6.0E-3
! Reaction_3 HO + RH -> HO2 + products 1.8
! Reaction_4 HO2 + NO -> HO + NO2 2.10E-1
! Reaction_5 HO2 + O3 -> HO + 2 O2 5.00E-5
! Reaction_6 2HO2 -> H2O2 + O2 7.25E-2
! Reaction_7 HO + NO2 -> HNO3 2.75E-1
! Reaction_8 HO + O3 -> HO2 + O2 1.75E-3
! Reaction_9 HO + HO2 -> H2O + O2 2.75
!
! Reaction_10 O3 -> 2 HO + O2 2.70E-6
! Reaction_11 NO2 -> NO + O3 8.90E-3
! declaration
! dynamics
logical :: c_ustr=.true.,c_wth=.false.,c_fluxes=.false., lencroachment=.false., ladvecFT=.false., lgamma=.false., lenhancedentrainment=.false., lfixedlapserates=.false., lfixedtroposphere=.false. !c_fluxes replaces c_wth
logical :: lradiation=.false.,lsurfacelayer=.false.,llandsurface=.false.,lrsAgs=.false., lCO2Ags=.false.
double precision :: zi(2),zi0 = 200 ,thetam(2), dtheta(2),pressure = 1013.0, wthetae
double precision temp_cbl, temp_ft
integer :: runtime,t, time=24*3600.0,tt
double precision :: beta = 0.2 ,wthetas=0.0,gamma = 0.006,thetam0 = 295,dtheta0 = 4,wthetav=0.0,dthetav
real :: dtime = 1
double precision :: z0 = 0.03, kappa, zp, alpha,z0m=0.03,z0h=0.03, hcrit = 10000, gamma2 = 0.006
!! ROUGHNESS LENGTH
!! Terrain Description ZO (m)
!! Open sea, fetch at least 5km 0.0002
!! Open flat terrain; grass, few isolated obstacles 0.03
!! Low crops, occasional large obstacles; L/h > 20 0.10
!! High crops, scattered obstacles, 15 < L/h < 20 0.25
!! Parkland, bushes, numerous obstacles, L/h < 10 0.50
!! Regular large obstacle coverage (suburb, forest) 0.50 - 1.0
!! http://www.webmet.com/met_monitoring/663.html
!!
real isec,mins,ttt, sec
integer :: day = 80
real :: hour = 0
integer ierr,iter
double precision pi
double precision :: wthetasmax = 0.0 , wqsmax = 0.0 , wcsmax = 0.0
double precision :: uws=0,vws=0,uws0 = 0.0 , vws0 = 0.0
double precision ustar
double precision :: um(2), vm(2), um0 = 0.0 , vm0 = 0.0, ueff, wstar
double precision :: ug = 0.0 , vg = 0.0
double precision du(2), dv(2)
double precision :: ws,wsls=0.0, wsubs = 0.0 !wsubs = subsiding motions (subsidence + convective mass flux compensation) affecting inversions through the lapse rates
double precision uwe,vwe
double precision :: f,gammau = 0.0 , gammav = 0.0
double precision we
double precision :: advq = 0.0 ,lsq ! large scale advection moisture (units (g/Kg)/s)!
double precision :: advtheta = 0.0 ,lstheta ! large scale advection heat (units K/s)!
double precision :: cc=0.0,Qtot=400.0,albedo=0.2 ! cloud cover and incoming energy,albedo, incoming radiation
double precision :: DeltaF = 0.0, Rdistr = 1.0 ! Radiative gradient due to aerosols and clouds (neg. = absorption, pos. = emission): amount (W/m2) and distribution (1 = top, 0 = over entire mixed layer)
double precision :: DeltaFsw=0.0, DeltaFlw=0.0 ! Shortwave component (e.g. aerosols) and longwave component (e.g. clouds)
double precision :: wf ! Resulting boundary-layer development (following the lapse rate)
double precision :: Ts !Skin temperature
double precision :: thetasurf, qsurf, thetavsurf, thetav, Rib, L, L0, fx, Lstart, Lend, fxdif
double precision :: T2m, q2m, u2m, v2m, esat2m , e2m, rh2m
double precision :: Tr,Ta,costh !Needed for radiation calculation
double precision :: Swin,Swout,Lwin,Lwout !Calculated radiations
double precision :: Cs = -1, Constm
double precision :: esatsurf,qsatsurf,cq,rs=1.e6,ra,zsl,esat,qsat,rssoil
double precision :: desatdT, dqsatdT, efinal, f1, f2, f3, f4, C1, C2, wgeq
double precision :: w2=0.42,wfc=0.491,wwilt=0.314,gD=0.0,rsmin=0, LAI = 1.0
double precision :: wsat=0.6,CLa=0.083, CLb=11.4, CLc=12.0, C1sat=0.342, C2ref=0.3
double precision :: wg=0.40,rssoilmin=0,cliq,Wlmx,Wl=0.0,Wmax=2.0e-4,cveg=1.0
double precision :: Lambda = 5.9, Tsoil=285, T2=285, Tsoiltend, Wltend, CGsat=3.6e-6
double precision :: LEveg, LEliq, LEsoil, LE, SH, GR, CG, wgtend
double precision qm(2), dq(2),wqe
double precision :: betaq,wqs=0,gammaq = 0.0 ,qm0 = 0.0,dq0 =0.0
double precision :: cm(2), dc(2), wce, CO2ags, CO2comp, CO2comp298=68.5, Q10CO2=1.5
double precision :: gm298 = 7, Ammax298 = 2.2, Q10gm = 2, T1gm = 278, T2gm = 301
double precision :: Q10Am = 2, T1Am = 281, T2Am = 311, f0 = 0.89, ad = 0.07, cfrac, co2abs, Ammax, betaw, PAR
double precision :: alpha0 = 0.017,Kx = 0.7, gmin = 2.5e-4, gm, fmin0, nuco2q=1.6, fmin, Ds, D0, ci, fstr, Am, Rdark
double precision :: alphac, tempy, An, E1, AGSa1, Dstar, gcco2,rsAgs,rsCO2, Resp, fw, wco2
double precision :: factorial
double precision :: Cw = 1.6e-3,wsmax=0.55,wsmin=0.005,R10=0.23,Eact0=53.3e3
double precision :: betac,wcs,gammac = 0.0,cm0 = 0.0,dc0 = 0.0
logical :: lsea=.false. ! sea surface fluxes switch
double precision :: sst=285.0 ! sea surface temperature
! Shallow cumulus
logical :: lscu=.false.,lrelaxdz=.false.
double precision :: tau=7200,dz=200,ca=0.5 ! if(lrelaxdz): dz relaxes as ddz/dt = 1/tau * zlcl-h
double precision :: q2=0,ac=0,wm=0,wqm=0
double precision :: Ptop,Ttop,estop,etop,qstop,qqs
double precision :: ev,tempd,templcl,zlcl,RHlcl
integer :: ii
! define variables for G/P-partitioning
logical :: lvbs=.false.
integer m, low_high_NOx
double precision :: alpha1_TERP_low, alpha2_TERP_low, alpha3_TERP_low, alpha4_TERP_low, alpha1_TERP_high, alpha2_TERP_high, alpha3_TERP_high, alpha4_TERP_high
double precision :: alpha1_ISO_low, alpha2_ISO_low, alpha3_ISO_low, alpha1_ISO_high, alpha2_ISO_high, alpha3_ISO_high
double precision :: CiTmc, CiImc, beta_iso, beta_terp
double precision :: epsi, C1Tmc, C2Tmc, C3Tmc, C4Tmc, C1_st, C2_st, C3_st, C4_st, X1, X2, X3, X4, T_hh, Coait, Coait_new, Coa, OAbgb
double precision :: C1Tlmc,C2Tlmc,C3Tlmc,C4Tlmc,C1Thmc,C2Thmc,C3Thmc,C4Thmc, C1Ilmc,C2Ilmc,C3Ilmc,C1Ihmc,C2Ihmc,C3Ihmc
double precision :: C1Tlmc_ft,C2Tlmc_ft,C3Tlmc_ft,C4Tlmc_ft,C1Thmc_ft,C2Thmc_ft,C3Thmc_ft,C4Thmc_ft, C1Ilmc_ft,C2Ilmc_ft,C3Ilmc_ft,C1Ihmc_ft,C2Ihmc_ft,C3Ihmc_ft
double precision :: C1mc, C2mc, C3mc, C4mc, C1mc_ft, C2mc_ft, C3mc_ft, C4mc_ft
double precision :: CiTmc_ft, CiImc_ft
double precision :: C1Imc, C2Imc, C3Imc, C1Imc_ft, C2Imc_ft, C3Imc_ft
double precision :: epsi_ft, C1Tmc_ft, C2Tmc_ft, C3Tmc_ft, C4Tmc_ft, C1_st_ft, C2_st_ft, C3_st_ft, C4_st_ft, X1_ft, X2_ft, X3_ft, X4_ft, T_ft, OAbgb_ft, Coait_ft, Coait_new_ft, Coa_ft
double precision :: mr2mc_OAbg, mr2mc_PRODT, mr2mc_PRODI, C10_st=1., C20_st=10., C30_st=100., C40_st=1000.
double precision :: kISORO2NO, kISORO2HO2, kTERPRO2NO, kTERPRO2HO2
real, parameter :: T0 = 298. ! temperature (K) at which the lab experiments and fitting are done, Tsimpidi'10
real, parameter :: dHvap = 30.e3 ! enthalpy of vaporization (J/mol), Lane'08
real, parameter :: PRODTmm = 180. ! molar mass terp-oxidation products (g/mol)
real, parameter :: PRODImm = 136. ! molar mass iso-oxidation products (g/mol)
real, parameter :: mmOAbg = 250. ! molar mass background OA (g/mol)
real conv_cbl,conv_ft, Rfact
! define variables for bVOC-emission
logical :: lBVOC =.false.
double precision :: BaserateISO = 0.0, BaserateTER = 0.0
double precision :: dwg = 0.06, gammaLAI, w1, gammasm
double precision :: beta_MT, Tref, gammaT_MT, gammace_MT, gamma_MT, eps_MT, rho_MT, ER_MT, mm_MT, cf_MT, F_TERP
double precision :: Thr, Tdaily, Topt, C_T1, C_T2, x, Eopt, gammaT_ISO, aa, Pac, Pdaily, Ptoa, phi, gammap, gammace_ISO, gamma_ISO, eps_ISO, rho_ISO, ER_ISO, mm_ISO, cf_ISO, F_ISO
!Define variables for the 'saturation level' program
integer :: i,a,n,aver3,sat_lev
double precision p0,epsilon,Tabs,Cp,Rd,Rv,Lv,e0,gammad,gammam
double precision np,p,lcl,lcl0
double precision z_s,T_s,qt_s,qs_s,es_s
double precision z,Tair,qt,qs,es,e_saturation,Td
double precision Tparcel_s,Tparcel
double precision sat_time,sat_height
integer :: atime = 60, aver1, itime
double precision g, Cf,eta, CT, C_m
!Define variables for vertical profiles
integer :: n_vert, atime_vert = 1800, aver2
double precision :: h_max = 3000 , eps, inf
!constants
! double precision,parameter :: rvrd = 461.5/287.04 ! Rv/Rd
real,parameter :: rvrd = 0.61 !Rd/Rv
real,parameter :: bolz = 5.67e-8 !Stefan-Boltzmann constant [-]
real,parameter :: rhow = 1000. !density of water [kg m-3]
real,parameter :: rho = 1.2 !density of air [kg m-3]
real,parameter :: Rgas = 8.3145 ! gas constant (J mol-1 k-1)
real :: S0 = 1368. !Incoming shortwave radiation [W m-2]
!chemistry
integer k
integer startdaytime,enddaytime,daylength,daystart,daytime_start,daytime_end,prevdaysec
double precision photo
real getth
real psim,psih
real factor, factor1, factor2, factor3, printhour
real a0, a1, a2
! general
character(len=25) inputchemfile
character(len=80) formatstring
character(len=40) filename
integer j
character(len=2),allocatable :: dummy(:)
character(len=25) :: outdir = 'RUN00'
!Adapted surface fluxes
!Times in s after start of run
integer starttime_wT , endtime_wT , starttime_wq, endtime_wq
integer starttime_chem, endtime_chem, starttime_adv, endtime_adv
!Offsets in standard flux units (K m s-1 & g kg-1 m s-1)
double precision offset_wT, offset_wq
!Functions of fluxes
! 0 = no flux
! 1 = constant flux
! 2 = sinoid flux from starttime to endtime
! 3 = constant flux froms tarttime to endtime
integer function_wT, function_wq
character(len=1) dirsep
character(len=5) kopie
! !!!!!!!!!!!!!!!!!!!!
! No longer used, see below declaration namelist
! BvS, nov2011
! !!!!!!!!!!!!!!!!!!!!
!DEC$ IF DEFINED (LINUX)
! character(len=1) :: dirsep ='/'
! character(len=3) :: kopie = 'cp '
!DEC$ ELSE !WINDOWS
! character(len=1) :: dirsep ='\'
! character(len=5) :: kopie = 'copy '
!DEC$ ENDIF
! general options
namelist/NAMRUN/ &
outdir, &
time, &
dtime, &
atime, &
atime_vert, &
h_max, &
latt, &
long, &
day, &
hour
! option for the dynamics
namelist/NAMDYN/ &
zi0, &
beta, &
lenhancedentrainment, &
wsls, &
lfixedlapserates, &
lfixedtroposphere, &
wthetasmax, &
c_wth, &
c_fluxes, &
gamma, &
lgamma, &
hcrit,&
gamma2,&
thetam0, &
dtheta0, &
pressure, &
wqsmax, &
gammaq, &
qm0, &
dq0, &
wcsmax, &
gammac, &
cm0, &
dc0, &
c_ustr, &
z0, &
uws0, &
vws0, &
gammau, &
gammav, &
um0, &
vm0, &
ug, &
vg, &
advq, &
advtheta, &
ladvecFT, &
lencroachment, &
lscu, &
lrelaxdz, &
tau
namelist/NAMSURFLAYER/ &
lsurfacelayer,&
z0m,&
z0h
namelist/NAMRAD/ &
lradiation,& !radiation scheme to determine Q and SW
cc,& !cloud cover
S0,& !Incoming radiation
DeltaFsw,& !Absorbed radiation by e.g. aerosols (neg. value)
DeltaFlw,& !Emitted radiation by e.g. clouds (pos. value)
Rdistr,& !Distribution of absorbing aerosols (see Barbaro et al., 2013)
albedo !Surface albedo
namelist/NAMSURFACE/ &
llandsurface,& !switch to use interactive landsurface
Qtot,& !Incoming energy
lsea,& !Using a sea surface instead of land
sst,& !Sea surface temperature
Ts,& !Initial surface temperature [K]
wwilt,& !wilting point
w2,& !Volumetric water content deeper soil layer
wg,& !Volumetric water content top soil layer
wfc,& !Volumetric water content field capacity
wsat,& !Saturated volumetric water content ECMWF config
CLa,& !Clapp and Hornberger retention curve parameter a
CLb,& !Clapp and Hornberger retention curve parameter b
CLc,& !Clapp and Hornberger retention curve parameter c
C1sat,& !Coefficient force term moisture
C2ref,& !Coefficient restore term moisture
gD,& !VPD correction factor for rs
rsmin,& !Minimum resistance of transpiration
rssoilmin,& !Minimum resistance of soiltranspiration
LAI,& !Leaf area index
cveg,& !Vegetation fraction
Tsoil,& !Temperature top soil layer
T2,& !Temperature deeper soil layer
Wl,& !Equivalent water layer depth for wet vegetation
Lambda,& !Thermal diffusivity skin layer
CGsat,& !Saturated soil conductivity for heat
lrsAgs,& !Switch to use A-gs model for surface resistances
lCO2Ags,& !Switch to use A-gs model for CO2 flux
CO2comp298,& !CO2 compensation concentration [mg m-3]
Q10CO2,& !function parameter to calculate CO2 compensation concentration [-]
gm298 ,& !mesophyill conductance at 298 K [mm s-1]
Ammax298,& !CO2 maximal primary productivity [mg m-2 s-1]
Q10gm ,& !function parameter to calculate mesophyll conductance [-]
T1gm ,& !reference temperature to calculate mesophyll conductance gm [K]
T2gm ,& !reference temperature to calculate mesophyll conductance gm [K]
Q10Am ,& !function parameter to calculate maximal primary profuctivity Ammax
T1Am ,& !reference temperature to calculate maximal primary profuctivity Ammax [K]
T2Am ,& !reference temperature to calculate maximal primary profuctivity Ammax [K]
f0 ,& !maximum value Cfrac [-]
ad ,& !regression coefficient to calculate Cfrac [kPa-1]
alpha0 ,& !initial low light conditions [mg J-1]
Kx ,& !extinction coefficient PAR [-]
gmin ,& !cuticular (minimum) conductance [m s-1]
Cw ,& !constant water stress correction (eq. 13 Jacobs et al. 2007) [-]
wsmax ,& !upper reference value soil water [-]
wsmin ,& !lower reference value soil water [-]
R10 ,& !respiration at 10 C [mg CO2 m-2 s-1]
Eact0 ,& !activation energy [53.3 kJ kmol-1]
lBVOC ,& !Enable the calculation of BVOC (isoprene, terpene) emissions
BaserateIso ,& !Base emission rate for isoprene emissions [microg m^4 h^-1]
BaserateTer !Base emission rate for terprene emissions [microg m^4 h^-1]
! option for the chemistry
namelist/NAMCHEM/ &
lchem, &
lwritepl, &
lcomplex, &
ldiuvar,&
h_ref ,&
lflux, &
fluxstart, &
fluxend, &
pressure_ft ,&
lchconst ,&
t_ref_cbl ,&
p_ref_cbl ,&
q_ref_cbl ,&
t_ref_ft ,&
p_ref_ft ,&
q_ref_ft
! options for changes in the surface fluxes
namelist/NAMFLUX/ &
starttime_wT , &
endtime_wT , &
offset_wT , &
starttime_wq , &
endtime_wq , &
offset_wq , &
starttime_chem, &
endtime_chem , &
starttime_adv , &
endtime_adv , &
function_wT , &
function_wq
! options for the gas/particle partitioning leading to SOA formation, using the Volatility Basis Set (VBS)
namelist/NAMSOA/ &
lvbs , &
low_high_NOx , &
alpha1_TERP_low , &
alpha2_TERP_low , &
alpha3_TERP_low , &
alpha4_TERP_low , &
alpha1_TERP_high , &
alpha2_TERP_high , &
alpha3_TERP_high , &
alpha4_TERP_high , &
alpha1_ISO_low , &
alpha2_ISO_low , &
alpha3_ISO_low , &
alpha1_ISO_high , &
alpha2_ISO_high , &
alpha3_ISO_high
if (windows) then
dirsep = '\'
kopie = 'copy '
else
dirsep ='/'
kopie = 'cp '
end if
! some variables
inf = 1.0e-9 ! Correction to avoid divide by 0 if z0=0
eps = 1.0e-4 ! Correction to avoid crashing with plots
! in visual BASIC
aver3 = 300 ! saturation level will be calculated every 300s
pi=acos(-1.)
Rfact= 8.314e-2 ! mbar*m3 /K*mol
lcl = 3000. !dummy value for first run
a = 0
n = 0
g = 9.81 !m/s2
Cf = 0.2 ! constants from D.Pino
CT = 4. ! J. At. Sci. Vol. 60
eta = 2. ! 1913 - 1926
C_m = 0.7 !
! Define more constants for the 'saturation level'program
p0 = 100.00 !kPa
epsilon = 0.622 !g water / g air = Rd/Rv
Tabs = 273.0 !K
Cp = 1004.67 !J/ kg K
Rd = 287.053 !J/ kg K
Rv = 461.50 !J/ kg K
Lv = 2.501*10**6 !J/kg
e0 = 0.611 !kPa
gammad = -(g/Cp) !K/m
kappa = 0.4 ! Von Karman constant
zp = 10. ! Height for the calculation of the logarithmic equation for u* (m)
! Number of vertical points
n_vert = 4
! Number of vertical levels of the saturation plot
sat_lev= 50
! Fitting function isoprene flux Gaussian
a0 = 0.653289
! a0= 0.653289 a0 = 0.8775 (sim04) a0 = 0.42458 (sim05)
a1 = 42705.1
a2 = 7999.29
!with use DFLIB NARGS() visual fortran 6 on windows
!DEC$ IF DEFINED (VISUAL_COMPILER)
! if ( NARGS ()<= 1 ) then
! inputchemfile = 'chem.inp'
! else
! call getarg(1,inputchemfile)
! endif
!DEC$ ENDIF
!New Intel compilers also take GET_COMMAND_ARGUMENT
!DEC$ IF DEFINED (INTEL_COMPILER )
! if ( iargc ()< 1 ) then
! inputchemfile = 'chem.inp'
! else
! call getarg(1,inputchemfile,n)
! endif
!DEC$ ENDIF
!GNU fortran on Windows and Linux ?
! Works both with ifort and gnu fortran, don't know about visual
! BvS, nov2011
if ( COMMAND_ARGUMENT_COUNT () > 0) then
CALL GET_COMMAND_ARGUMENT(1,inputchemfile)
else
inputchemfile = 'chem.inp'
endif
open (1, file='namoptions')
read (1,NAMRUN,iostat=ierr)
close(1)
open (1, file='namoptions')
read (1,NAMDYN,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
open (1, file='namoptions')
read (1,NAMRAD,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
pressure_ft = pressure
Ts = thetam0
z0m = z0
z0h = z0
open (1, file='namoptions')
read (1,NAMCHEM,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
open (1, file='namoptions')
read (1,NAMSURFACE,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
open (1, file='namoptions')
read (1,NAMSURFLAYER,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
open (1, file='namoptions')
read (1,NAMSOA,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
if (lfixedtroposphere) lfixedlapserates = .true.
if ( lCO2Ags ) then
lrsAgs = .true.
llandsurface = .true.
endif
if ( .not. lchem ) lvbs = .false.
if ( lrsAgs .and. (.not. llandsurface) ) then
print *,""
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,"You enabled lrsAgs without enabling llandsurface!"
print *,"Please check your namelist options."
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,""
endif
if ( lrsAgs .and. (.not. lsurfacelayer) ) then
lsurfacelayer = .true.
print *,""
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,"You enabled lrsAgs without enabling lsurfacelayer!"
print *,"lsurfacelayer is automatically enabled"
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,""
endif
if ( lrsAgs .and. (.not. lradiation) ) then
lradiation = .true.
print *,""
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,"You enabled lrsAgs without enabling lradiation!"
print *,"lradiation is automatically enabled"
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,""
endif
if (lchem .and. (dtime .gt. 2.)) then
dtime = 2.
print *,""
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,"You enabled lchem with dtime > 2 seconds!"
print *,"This might result in unstable chemistry results"
print *,"dtime set to 2 seconds"
print *,""
print *,"!!!!!!!!!!!!!!!!!!!!!"
print *,""
print *,""
endif
write(formatstring,'(a,a)')'mkdir ',trim(outdir)
call system(formatstring)
write(formatstring,'(a,a)')'mkdir ',trim(outdir)//dirsep//'PL'
call system(formatstring)
write(formatstring,'(a,a)')kopie//'namoptions '//trim(outdir)
call system(formatstring)
write(formatstring,'(a,a)')kopie//inputchemfile//trim(outdir)
call system(formatstring)
if (lcomplex) then
write(formatstring,'(a,a)')kopie//'chemicals.txt '//trim(outdir)
call system(formatstring)
endif
!estimate the daylength
daystart=0
do i=1,24*3600
thour = i/3600.
zenith = getth(1.0*day,latt,long,i/3600.)
if (cos(zenith) > 0.0 .and. daystart == 0 ) then
daystart=1
startdaytime = i
endif
if (cos(zenith) <= 0.0 .and. daystart == 1 ) then
enddaytime = i
exit
endif
enddo
daylength = enddaytime - startdaytime
write (*,*)'LCHEM=',lchem,'LDIUVAR=',ldiuvar,'LCONST=',lchconst,'LFLUX=',lflux,'LVBS=',lvbs, 'LBVOC=', lBVOC
write (*,*) ' long',long
write (*,*) 'latt',latt
write (*,*) ' day',day
write (*,*) 'hour',hour
write (*,*) 'daystart',startdaytime/3600.
write (*,*) 'dayend ',enddaytime/3600.
write (*,*) 'daylength',daylength/3600.
! DEPRECATED: USE NAMELIST NAMFLUX to set individually
! if lfux then we use startflux and endflux times
if (lflux .eqv. .true.) then
startdaytime = fluxstart * 3600
enddaytime = fluxend * 3600
daylength = enddaytime - startdaytime
write (*,*)'**** LFLUX = TRUE *****'
write (*,*) 'daystart',startdaytime/3600.
write (*,*) 'dayend ',enddaytime/3600.
write (*,*) 'daylength',daylength/3600.
endif
if ( hour*3600 > enddaytime )then !we start in previous night
prevdaysec = nint((24 - hour) * 3600)
daytime_start = nint((24 - hour) * 3600 + startdaytime) !seconds after starttime model
daytime_end = nint((24 - hour) * 3600 + enddaytime)
else
daytime_start = nint(startdaytime - hour * 3600) !seconds after starttime model
daytime_end = nint(enddaytime - hour *3600)
endif
write(*,*) 'Day time starts',daytime_start,'seconds after start model'
write(*,*) 'Day time end',daytime_end,'seconds after start model'
starttime_wT = daytime_start
endtime_wT = daytime_end
starttime_wq = daytime_start
endtime_wq = daytime_end
starttime_chem = daytime_start
endtime_chem = daytime_end
starttime_adv = daytime_start
endtime_adv = daytime_end
offset_wT = 0.0
offset_wq = 0.0
!!Function: just like chemistry functions:
!! 0 = no flux
!! 1 = constant flux
!! 2 = sinoid flux from starttime to endtime
!! 3 = constant flux froms tarttime to endtime
function_wT = 2
function_wq = 2
open (1, file='namoptions',iostat=ierr)
read (1,NAMFLUX,iostat=ierr)
if (ierr > 0) stop 'ERROR: Problem in namoptions'
close(1)
! initialisation dynamics
if (lencroachment) then
beta = 0.0
dtheta0 = 0.0
dq0 = 0.0
else
dthetav = dtheta0 + 1.e-03*rvrd*(qm0*dtheta0+thetam0*dq0+dtheta0*dq0)
if (dthetav .le. 0.0) then
write(*,*) 'Initial dthetav <= 0, but encroachment switch not activated!'
write(*,*) 'dq is set to 0.0 and dtheta to 0.01 K'
dtheta0 = 0.01
dq0 = 0.0
endif
if (beta .le. 0.0) then
write(*,*) 'WARNING: beta is set to ',beta
write(*,*) 'This could result in unrealistic situations (negative inversions)'
endif
endif
f = 2.*pi/(24.*3600.)*2.*sin(pi*latt/180.) ! Coriolis parameter
runtime=nint(time/dtime)
zi(1)=zi0
thetam(1)=thetam0
dtheta(1)=dtheta0
um(1)= um0
vm(1)= vm0
du(1)= ug-um0
dv(1)= vg-vm0
qm(1) = qm0
dq(1) = dq0
cm(1) = cm0
dc(1) = dc0
DeltaF = DeltaFsw + DeltaFlw
aver1=atime/dtime
aver2=atime_vert/dtime
! initialise chemistry
!
allocate(dummy(mrpcc))
if (lchem) then
if (lcomplex) then
call inputchem_mozart(inputchemfile,outdir,dirsep)
else
call inputchem_simple(inputchemfile,outdir,dirsep)
endif
endif
open (20, file=trim(outdir)//dirsep//'output_dyn')
write (20,'(a4)') 'TIME'
write (20,'(I4)') time/atime
write (20,'(17a14)') 'UTC(hours)','RT(hours)','zi(m)','we(m/s)', &
'thetam(K)','dtheta(K)','wte(Km/s)','wts(Km/s)', &
'beta','um(ms-1)','du(ms-1)','vm(ms-1)','dv(ms-1)','ws(ms-1)','ac(-)','wm(ms-1)','dz(m)'
open (28, file=trim(outdir)//dirsep//'t_prof')
write (28,'(a4)') 'VERT'
write (28,'(I3)') time/atime_vert
write (28,'(I2)') n_vert
write (28,'(3a14)') 'z (m)','theta (K)','wtheta'
open (29, file=trim(outdir)//dirsep//'q_prof')
write (29,'(a4)') 'VERT'
write (29,'(I3)') time/atime_vert
write (29,'(I2)') n_vert
write (29,'(3a14)') 'z (m)','q (g/kg)','wq'
open (30, file=trim(outdir)//dirsep//'c_prof')
write (30,'(a4)') 'VERT'
write (30,'(I3)') time/atime_vert
write (30,'(I2)') n_vert
write (30,'(3a14)') 'z (m)','c (ppm)','wc'
open (31, file=trim(outdir)//dirsep//'u_prof')
write (31,'(a4)') 'VERT'
write (31,'(I3)') time/atime_vert
write (31,'(I2)') n_vert
write (31,'(3a14)') 'z (m)','u (m/s)','wu'
open (32, file=trim(outdir)//dirsep//'v_prof')
write (32,'(a4)') 'VERT'
write (32,'(I3)') time/atime_vert
write (32,'(I2)') n_vert
write (32,'(3a14)') 'z (m)','v (m/s)','wv'
open (50, file=trim(outdir)//dirsep//'beta_shear')
write (50,*) 'UTC(hours) ustar uws vws uwe vwe du dv dVe '
open (60, file=trim(outdir)//dirsep//'output_sca')
write (60,'(a4)') 'TIMS'
write (60,'(I4)') time/atime
write (60,'(15a14)') &
'UTC(hours)','RT(h-ours)','zi(m)','qm(g/kg)','dq(g/kg)','wqe', &
'wqs',' betaq',' cm(ppm)','dc(ppm)', 'wce','wcs',' betac','q2','wqm'
if(llandsurface)then
open (61, file=trim(outdir)//dirsep//'output_land')
write (61,'(a4)') 'TIME'
write (61,'(I4)') time/atime
write (61,'(12a14)') 'UTC(hours)','RT(hours)','SWin(W/m2)','SWout(w/m2)', &
'Lwin(W/m2)','LWout(W/m2)','Qtot(W/m2)','SH(W/m2)','LE(W/m2)', &
'GR(W/m2)','ra(s/m)','rs(s/m)'
if(lCO2Ags)then
open (63, file=trim(outdir)//dirsep//'output_ags')
write (63,'(a4)') 'TIME'
write (63,'(I4)') time/atime
write (63,'(12a14)') 'UTC(hours)','RT(hours)','An(mgC/m2s)','Resp(mgC/m2s)'
endif
endif
if(lchem)then
write(formatstring,'(A,i2,A)')'(',nchsp+2,'A15)' !nchsp + 2 places for the 2 times
open (40, file=trim(outdir)//dirsep//'chem_conc')
write (40, '(a4)') 'CHEM'
write (40,'(I4)') time/atime
write (40,formatstring) 'UTC(hours)','RT(hours)',(PL_scheme(k)%name,k=1,nchsp)
open (41, file=trim(outdir)//dirsep//'chem_entr')
write (41, '(a4)') 'CHEM'
write (41,'(I4)') time/atime
write (41,formatstring) 'UTC(hours)','RT(hours)',(PL_scheme(k)%name,k=1,nchsp)
open (42, file=trim(outdir)//dirsep//'chem_beta')
write (42, '(a4)') 'CHEM'
write (42,'(I4)') time/atime
write (42,formatstring) 'UTC(hours)','RT(hours)',(PL_scheme(k)%name,k=1,nchsp)
if(lvbs)then
open (43, file=trim(outdir)//dirsep//'soa_part')
write (43, '(a4)') 'SOA'
write (43,'(I4)') time/atime
write (43,formatstring) 'UTC(hours)','RT(hours)','OAbgb','Coa','C1Tmc','C2Tmc','C3Tmc','C4Tmc','C1Imc','C2Imc','C3Imc','X1','X2','X3','X4', &
'mr2mc_PRODT','mr2mc_PRODI', 'beta_terp', 'beta_iso'
open (44, file=trim(outdir)//dirsep//'soa_ftr')
write (44, '(a4)') 'SOA'
write (44,'(I4)') time/atime
write (44,formatstring) 'UTC(hours)','RT(hours)','OAbgb','Coa','C1Tmc','C2Tmc','C3Tmc','C4Tmc','C1Imc','C2Imc','C3Imc','X1','X2','X3','X4'
endif
if(lBVOC)then
open (45, file=trim(outdir)//dirsep//'voc_em')
write (45, '(a4)') 'VOC'
write (45,'(I4)') time/atime
write (45,formatstring) 'UTC(hours)','RT(hours)','F_ISO', 'F_TERP','gamma_ISO', 'gammaT_ISO', 'gammap', 'gammace_ISO', &
'gamma_MT', 'gammaT_MT', 'gammace_MT', 'gammaLAI', 'gammasm'
endif
open (46, file=trim(outdir)//dirsep//'initial_chem')
write (46,*) '# name initial_c_CBL c_ft0 emission function'
do k=1,nchsp
write (46,'(2(A4),3(1X,F9.4),i5)') '# ',PL_scheme(k)%name, c_cbl(k), c_ft(k), Q_cbl(k),Q_func(k)
enddo
open (47, file=trim(outdir)//dirsep//'chem_photo')
write (47, '(a4)') 'CHEM'
write (47,'(I4)') time/atime
write (47,'(9a14)') 'UTC(hours)','RT(hours)','jo3*1000*60','jno2*60(min)','jch2o*100*60(min)',&
'photo','zenith','RH_emiss', 'angle'
open (48, file=trim(outdir)//dirsep//'chem_ftr')
write (48, '(a4)') 'CHEM'
write (48,'(I4)') time/atime
write (48,formatstring) 'UTC(hours)','RT(hours)',(PL_scheme(k)%name,k=1,nchsp)
open ( 62, file =trim(outdir)//dirsep//'keff_cbl')
write(formatstring,'(A,i3,A4)')'(',tnor+3,'A13)' !+3 id for 2 times and tem_cbl
write (62,formatstring) 'UTC(hours)','RT(hours)','Temp_cbl',(RC(k)%rname,k=1,tnor)
if (lwritepl) then
do i=1,nchsp
if((.not. lcomplex).or.(PL_scheme(i)%prin)) then
filename = PL_scheme(i)%name
filename = trim(outdir)//dirsep//'PL'//dirsep//trim(PL_scheme(i)%name)
do j=1,PL_scheme(i)%nr_PL
if (PL_scheme(i)%PL(j)%PorL == PRODUCTION ) then
dummy(j)='P_'
else
dummy(j)='L_'
endif
enddo
open(100+i,FILE=trim(filename))
write(formatstring,'(A,i3,A4)')'(',PL_scheme(i)%nr_PL+4,'A17)'
write(100+i,formatstring) 'RT(hours)','['//trim(PL_scheme(i)%name)//']',(dummy(j)//RC(PL_scheme(i)%PL(j)%r_nr)%rname,j=1,PL_scheme(i)%nr_PL),'tot_loss','tot_prod'
endif
enddo
endif !lwritepl
endif !lchem
! initialisation
! checking init
write (*,*) ' checking namrun t=0'
write (*,*) 'time',time
write (*,*) 'dtime',dtime
write (*,*) 'the following only used for the complex'
write (*,*) ' checking the initialisation dyn t=0'
write (*,*) 'entrainment_ratio_(beta)= ',beta
write (*,*) 'max surface_heat_flux_(wthetas)= ',wthetasmax
write (*,*) 'exchange_temperature_coeff._in_FT_(gamma)= ',gamma
write (*,*) 'initial_boundary_layer_height_(zi0)= ',zi0
write (*,*) 'mixing-layer_pot._temp._(thetam0)= ',thetam0
write (*,*) 'initial_pot._temp._jump_(dtheta0)= ',dtheta0
write (*,*) 'timestep_(dtime)=',dtime
write (*,*) 'uws=',uws
write (*,*) 'vws=',vws
write (*,*) 'ustar=',ustar
write (*,*) 'initial_x.-dir._windspeed_(um0)= ',um0
write (*,*) 'initial_y-dir._windspeed_(vm0)= ',vm0
write (*,*) 'du=',du
write (*,*) 'dv=',dv
write (*,*) 'uwe=',uwe
write (*,*) 'vwe=',vwe
write (*,*) ' '
write (*,*) ' checking the initialisation c_cbl c_ft0 emis at t=0'
! write (*,*) specname(i_R), c_cbl(i_R), c_ft0(i_R ),Q(i_R )
! dynamics
tt=0
! run
do t=1, runtime
tt=tt+1
sec = t * dtime !number of seconds from start
printhour=t * dtime/3600.
thour= hour+t*dtime/3600.
if ( thour > 24. ) then
thour = thour - 24 * (ceiling(thour/24)-1)
endif
zsl = 0.1*zi(1) !Height of surface layer
! Start with radiation calculation
if (lradiation) then
costh = max(0.0,cos(getth(1.0*day,latt,long,thour)))
Ta = thetam(1)*((((100*pressure)-zsl*rho*g)/(100*pressure))**(Rd/Cp))!pressure*100 to compensate for SI, 0.1 to get T at top of the SL
Tr = (0.6 + 0.2 * costh) * (1 - 0.4 * cc)
Swin = S0 * Tr * costh + DeltaFsw
Swout = albedo * Swin
Lwin = 0.8 * bolz * (Ta ** 4)
Lwout = bolz * (Ts ** 4)
Qtot = Swin - Swout + Lwin - Lwout
endif
thetav = thetam(1) * (1. + 0.61 * qm(1) * 1.e-3)
wstar = ( (g / thetav) * zi(1) * wthetav ) ** ( 1. / 3. )
ueff = sqrt(um(1)**2.+vm(1)**2.+wstar**2.)
! ueff = sqrt(um(1)**2.+vm(1)**2.)
if (lsurfacelayer) then
if(ueff .lt. 1.e-2) stop 'effective wind velocity below 1 cm/s'
if(t==1) then
thetasurf = Ts
else
thetasurf = thetam(1) + wthetas / (Cs * ueff)
endif
esatsurf = 0.611e3 * exp(17.2694 * (thetasurf - 273.16) / (thetasurf - 35.86))
qsatsurf = 0.622 * esatsurf / (pressure*100)
cq = 0.0
if(t/=1) cq = (1. + Cs * ueff * rs) ** (-1.)
if(lsea) cq = 1.0
qsurf = (1. - cq) * qm(1) + cq * qsatsurf * 1.e3 !HGO factor for qsatsurf which is in kg/kg
thetavsurf = thetasurf * (1. + 0.61 * qsurf * 1.e-3)
Rib = min(0.2,g/thetav * zsl * (thetav-thetavsurf) / (ueff ** 2.))
L = sign(dble(0.01),Rib)
L0 = sign(dble(0.1),Rib)
iter = 0
do while(.true.)
iter = iter + 1
L0 = L
fx = Rib - zsl / L * (log(zsl / z0h) - psih(zsl / L) + psih(z0h / L)) / (log(zsl / z0m) - psim(zsl / L) + psim(z0m / L)) ** 2.
Lstart = L - 0.001*L
Lend = L + 0.001*L
fxdif = ( (- zsl / Lstart * (log(zsl / z0h) - psih(zsl / Lstart) + psih(z0h / Lstart)) / (log(zsl / z0m) - psim(zsl / Lstart) + psim(z0m / Lstart)) ** 2.) &
- (-zsl / Lend * (log(zsl / z0h)- psih(zsl / Lend) + psih(z0h / Lend)) / (log(zsl / z0m) - psim(zsl / Lend) + psim(z0m / Lend)) ** 2.) ) / (Lstart - Lend)
L = L - fx / fxdif
L = sign(min(abs(L),1.e6),L)!capping L