-
Notifications
You must be signed in to change notification settings - Fork 0
/
TR_GridCompMod.F90
5457 lines (4151 loc) · 215 KB
/
TR_GridCompMod.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
#include "MAPL_Generic.h"
!-------------------------------------------------------------------------
! NASA/GSFC, Global Modeling and Assimilation Office, Code 910.1 !
! and !
! Atmospheric Chemistry and Dynamics Lab, Code 614 !
!-------------------------------------------------------------------------
!BOP
!
! !MODULE: TR_GridCompMod - Implements Passive Tracers
!
! !INTERFACE:
!
MODULE TR_GridCompMod
!
! !USES:
!
USE ESMF
USE MAPL
USE Chem_Mod ! Chemistry Base Class
USE Chem_ArrayMod
USE Runtime_RegistryMod
USE Chem_UtilMod ! I/O
USE OVP, ONLY: OVP_init, OVP_end_of_timestep_hms, OVP_mask, OVP_apply_mask
USE m_inpak90 ! Resource file management
USE m_die, ONLY: die
USE DryDepositionGmiMod, ONLY: TR_GMI_DryDeposition ! in this dir
USE WetRemovalGmiMod, ONLY: TR_GMI_WetRemoval ! in this dir
USE TR_GravSetMod, ONLY: TR_GMI_GravitationalSettling ! in this dir
USE WetRemovalMod, ONLY: WetRemovalGOCART ! in Chem_Shared
USE ConvectionMod, ONLY: convection, set_vud ! in Chem_Shared
USE Chem_SettlingMod, ONLY: Chem_Settling ! in Chem_Shared
USE DryDepositionMod, ONLY: DryDepositionGOCART ! in Chem_Shared
USE VegLaiMod, ONLY: Decode_Land_Types, Decode_XLAI ! in Chem_Shared
IMPLICIT NONE
PRIVATE
INTEGER, SAVE, ALLOCATABLE :: MASK_10AM(:,:)
INTEGER, SAVE, ALLOCATABLE :: MASK_2PM(:,:)
INTEGER, SAVE :: OVP_FIRST_HMS ! End of the first timestep in each 24-hr period
INTEGER, SAVE :: OVP_RUN_DT ! Heartbeat timestep
INTEGER, SAVE :: OVP_GC_DT ! TR GridComp timestep
INTEGER, SAVE :: OVP_MASK_DT
!
! !PUBLIC MEMBER FUNCTIONS:
PUBLIC SetServices
!
! !DESCRIPTION:
!
! {\tt TR\_GridComp} is an ESMF gridded component implementing
! passive tracers.
!
! Developed for GEOS-5 release Ganymed 4 beta 11 and later.
!
! !REVISION HISTORY:
!
! 06Dec2009 da Silva Created the MATRIX skeleton.
! 20May2014 Manyin Initial version of TR in Ganymed, similar to MAMchem_GridCompMod.F90
! 19aug2014 Manyin Added WetDep, DryDep, Emissions constraints; traded I90 for ESMF calls.
! 7jul2015 Manyin Added run_order to replace spaghetti.
! 27may2016 Manyin ExtData is now used for 2D and 3D source files, veg/lai files, and masks.
! 26nov2018 Oman Renumbered QQK values for GMI, to match the new mechanism.
! 18may2020 Manyin Diagnostics for GMI wet and dry removal now assume VMR wrt moist air
! Diagnostics for PR and DK, when units=VMR, now assume wrt moist air
! Diagnostic for 3D emissions is now kg/m2/s instead of kg/m2
! Fixed memory leak (VMR_to_MMR and MMR_to_VMR)
!
!EOP
!-------------------------------------------------------------------------
! For use in the run_order CASE statement:
#define NO_PHASE 0
#define SOURCE_PHASE 1
#define SINK_PHASE 2
! For unit_type
INTEGER, PARAMETER :: MMR_UNITS = 1
INTEGER, PARAMETER :: VMR_UNITS = 2
INTEGER, PARAMETER :: TIME_UNITS = 3
INTEGER, PARAMETER :: OTHER_UNITS = 0
REAL, PARAMETER :: MW_UNDEFINED = 0.5
! A set of values common to all passive tracers
! ---------------------------------------------
TYPE TR_TracerKit
INTEGER :: tr_count ! number of passive tracers
INTEGER :: im,jm,km ! global max values
INTEGER :: i1,i2,j1,j2 ! local index bounds
REAL*8, POINTER, DIMENSION(:,:) :: lats => NULL() ! Latitudes in degrees
REAL*8, POINTER, DIMENSION(:,:) :: lons => NULL() ! Longitudes in degrees, 0 to 360
REAL :: ptop ! top pressure in Pa
! Only if needed for Dry Deposition:
INTEGER, POINTER, DIMENSION(:,:) :: ireg => NULL() ! Land type counts
INTEGER, POINTER, DIMENSION(:,:,:) :: iland => NULL() ! Land types
INTEGER, POINTER, DIMENSION(:,:,:) :: iuse => NULL() ! Land type percentages
REAL*8, POINTER, DIMENSION(:,:,:) :: xlai => NULL() ! Land type LeafAreaIndex vals
LOGICAL :: veg_fraction_done ! Veg fraction only to be read once
TYPE(ESMF_Grid) :: grid_esmf ! Grid
END TYPE TR_TracerKit
! Parameters for a 2D (surface) constraint
! ----------------------------------------
TYPE TR_SurfaceConstraintSpec
CHARACTER(LEN=20) :: mode ! set or scale
LOGICAL :: use_regions
CHARACTER(LEN=255) :: regions_str ! one or more indices
LOGICAL :: use_bool
LOGICAL :: use_expr
CHARACTER(LEN=255) :: bool_FIELD ! field name
CHARACTER(LEN=10 ) :: bool_OP ! (LT, GT, EQ, NE, LE, GE)
REAL*4 :: bool_SCALAR
CHARACTER(LEN=255) :: expr ! expression involving scalars and fields
LOGICAL, POINTER, DIMENSION(:,:) :: bool_array => NULL() ! set or scale where TRUE
! region list and bool expr determine this
LOGICAL, POINTER, DIMENSION(:,:) :: bool_aux => NULL() ! scratch space
REAL*4, POINTER, DIMENSION(:,:) :: value_array => NULL() ! set or scale w/ these values
! value or expr determine this
END TYPE TR_SurfaceConstraintSpec
! Parameters to specify a single tracer
! -------------------------------------
TYPE TR_TracerSpec
CHARACTER(LEN=255) :: name ! name of the tracer
CHARACTER(LEN=255) :: units ! units for the tracer
INTEGER :: unit_type ! GMI assumes vmr, GOCART assumes mmr, etc
CHARACTER(LEN=255) :: iname ! instance name
CHARACTER(LEN=255) :: rcfilen ! resource file name
CHARACTER(LEN=255) :: regions_ExtData_entry ! Dataset that divides the globe into regions
REAL, POINTER :: regions_array(:,:) => NULL() ! Fill with GetPointer
CHARACTER(LEN=255) :: regionsString ! Comma-delimited string of regions
CHARACTER(LEN=255) :: emisFileName ! TRACER emission file name
INTEGER :: instance ! instance number
REAL*8 :: decayConstant ! Decay constant, inverse seconds -- very small for Be10!
REAL :: emission ! kg m^{-2} s^{-1}
CHARACTER(LEN=255) :: decays_to ! Name of the Passive Tracer produced by the decay
CHARACTER(LEN=255) :: src_species ! Name of the Passive Tracer that decays to current one
CHARACTER(LEN=255) :: loss_species ! Chemical loss rate of this GMI species will be the sink
REAL, POINTER :: regionMask(:,:) => NULL() ! regional mask - TO USE, alloc same as TRsfcFlux
!MEM
REAL , POINTER :: TRsfcFlux(:,:) => NULL() ! TR surface flux kg m^-2 s^-1
REAL , POINTER :: TRvolFlux(:,:,:) => NULL() ! TR 3D volume flux mixrat/sec, or kg m^-2 s^-1
!I dont see why we need R*8
! REAL*8, POINTER :: TRsfcFlux(:,:) => NULL() ! TR surface flux kg m^-2 s^-1
! REAL*8, POINTER :: TRvolFlux(:,:,:) => NULL() ! TR 3D volume flux mixrat/sec, or kg m^-2 s^-1
REAL, POINTER :: tropp_prev(:,:) => NULL() ! Tropopause pressure from previous timestep
INTEGER :: run_order(2) ! order to do SOURCE_PHASE and SINK_PHASE
LOGICAL :: src_add ! T- add values; F- replace values
CHARACTER(LEN=255) :: src_mode ! Source mode of tracer
REAL :: src_value ! Source constant, parts per part
REAL :: src_amplitude ! Source constant, CORBE 07/18/16
REAL :: src_phase_shift ! Source phase shift, CORBE 07/18/16
CHARACTER(LEN=255) :: src_horiz ! Horizontal spec of tracer source
LOGICAL, POINTER :: src_mask_horiz(:,:) => NULL() ! regional mask
CHARACTER(LEN=255) :: src_vert ! Vertical spec of tracer source
INTEGER :: src_lev1, src_lev2 ! Level bounds for tracer source
REAL :: src_press1, src_press2 ! Pressure bounds for tracer source
CHARACTER(LEN=255) :: src_field_name ! Field to copy from, as source
CHARACTER(LEN=255) :: snk_mode ! Sink mode of tracer
REAL :: snk_value ! Sink constant, parts per part
CHARACTER(LEN=255) :: snk_horiz ! Horizontal spec of tracer sink
LOGICAL, POINTER :: snk_mask_horiz(:,:) => NULL() ! regional mask
CHARACTER(LEN=255) :: snk_vert ! Vertical spec of tracer sink
INTEGER :: snk_lev1, snk_lev2 ! Level bounds for tracer sink
REAL :: snk_press1, snk_press2 ! Pressure bounds for tracer sink
!MEM
REAL :: mw ! molecular weight
! REAL*8 :: mw ! molecular weight
! GMI Dry Dep
LOGICAL :: GMI_dry_deposition ! when true, do Gravitational Settling and Dry Deposition a la GMI
REAL :: GMI_aero_density ! see examples in gmi_aerosol.h
REAL :: GMI_aero_eff_radius ! see examples in gmi_aerosol.h
REAL :: GMI_aero_c(1:4) ! see examples in gmi_aerosol.h
REAL :: GMI_hstar_dry ! a parameter for computing Henry's law constant
REAL :: GMI_delH_298_over_R_dry ! a parameter for computing Henry's law constant
REAL :: GMI_f0 ! reactivity factor for oxidation of biological substances
! GMI Wet Dep
LOGICAL :: GMI_wet_removal ! when true, do rainout, washout & wet deposition a la GMI
REAL :: GMI_rel_scav_eff ! scavenging efficiency relative to sulfate (unitless)
REAL :: GMI_retention_eff ! retention efficiency
LOGICAL :: GMI_h2o2_flag ! if the species should be treated as H2O2
LOGICAL :: GMI_hno3_flag ! if the species should be treated as HNO3
REAL :: GMI_hstar_wet ! a parameter for computing Henry's law constant
REAL :: GMI_delH_298_over_R_wet ! a parameter for computing Henry's law constant
! Dry & Wet Dep
LOGICAL :: GMI_aero_flag ! treat as an aerosol for the purposes of washout and reevaporation
! GOCART Wet Removal
LOGICAL :: GOCART_wet_removal ! when true, apply GOCART's wet removal scheme
CHARACTER(LEN=255) :: GOCART_species ! GOCART routines are species-specific
LOGICAL :: GOCART_aero_flag ! true / false
REAL :: GOCART_fscav ! scavenging efficiency in convective updrafts [km-1]
REAL :: GOCART_fwet ! large-scale wet removal efficiency [fraction]
! GOCART Convection
LOGICAL :: GOCART_convection ! when true, apply GOCART's convection scheme
! GOCART Settling
LOGICAL :: GOCART_settling ! when true, apply GOCART's settling scheme
REAL :: GOCART_radius ! radius for settling [m]
REAL :: GOCART_rho_p ! density for setting [kg m-3]
INTEGER :: GOCART_rh_effect ! Flag for RH effects
! 0 - no moisture effect
! 1 - Fitzgerald 1975 parameterization
! 2 - Gerber 1985 parameterization
! 3 - Gerber parameterization for Ammonium Sulfate
! 4 - Petters and Kreidenweis (ACP2007) parameterization
! GOCART Dry Deposition
LOGICAL :: GOCART_dry_deposition ! when true, apply GOCART's dry deposition scheme
INTEGER :: surface_constraint_count = 0 ! constraints on SRC
TYPE(TR_SurfaceConstraintSpec), POINTER, DIMENSION(:) :: constraints => NULL()
! REAL, POINTER :: src_3d_array(:,:,:) => NULL() ! For reading 3D file, or if VERT depends on P
!MEM
REAL , POINTER :: tracer_decay(:,:,:) => NULL() ! Amount of tracer lost, for others to use
! REAL*8, POINTER :: tracer_decay(:,:,:) => NULL() ! Amount of tracer lost, for others to use
! e.g. Rn222 loss -> Pb210 with strat-only source
END TYPE TR_TracerSpec
! Legacy state
! ------------
TYPE TR_State
PRIVATE
type(ESMF_Config) :: CF ! Private Config
type(ESMF_Grid) :: grid ! Grid
type(Runtime_Registry), pointer :: registry => NULL()
type(MAPL_SimpleBundle) :: qa ! Passive tracers
real :: dt ! Model time step
type(TR_TracerKit), pointer :: kit => NULL() ! Set of values common to all tracers
type(TR_TracerSpec), pointer :: spec(:) => NULL() ! Tracer specific values
! integer :: model ! MAM7 or MAM3
! type(MAM_MetaSpec) :: meta ! MAM meta data
! real :: femisSS ! Seasalt emission tuning parameter
! real :: femisDU ! Dust emission tuning parameter
! logical :: dry_removal ! turn on/off dry removal processes
! logical :: wet_removal ! turn on/off wet removal processes
! logical :: nucleation ! turn on/off nucleation process
! logical :: condensation ! turn on/off condensation process
! logical :: coagulation ! turn on/off coagulation process
logical :: verbose ! turn on/off more verbose messages
integer :: pet ! ID of the persistent execution thread
LOGICAL :: strict_tracer_timing ! Call a barrier before and after each tracer is run
! Only use this to test timings, not operationally
END TYPE TR_State
! Hook for the ESMF
! -----------------
TYPE TR_Wrap
TYPE (TR_State), pointer :: PTR => null()
END TYPE TR_Wrap
INTEGER, PARAMETER :: DBL = KIND(0.00D+00)
! Constant string
#define NO_DECAY '<no_specific_species>'
#define NULL_REGION_MASK '<no_mask>'
CONTAINS
!-------------------------------------------------------------------------
! NASA/GSFC, Atmospheric Chemistry and Dynamics Lab, Code 614 !
!-------------------------------------------------------------------------
!BOP
!
! !IROUTINE: SetServices --- Sets IRF services for the TR Grid Component
!
! !INTERFACE:
SUBROUTINE SetServices ( GC, RC )
! !ARGUMENTS:
type(ESMF_GridComp), intent(INOUT) :: GC ! gridded component
integer, optional :: RC ! return code
! !DESCRIPTION: Sets Initialize, Run and Finalize services.
!
! !REVISION HISTORY:
!
! 20May2014 Manyin First crack.
!
!EOP
!-------------------------------------------------------------------------
__Iam__('SetServices')
! Local derived type aliases
! --------------------------
type (TR_State), pointer :: myState ! internal state
type (TR_Wrap) :: wrap
type (Runtime_Registry), pointer :: r
TYPE (ESMF_VM) :: vm
character(len=ESMF_MAXSTR) :: comp_name
! Local variables
! --------------------------
! logical :: flagMAM7, flagMAM3
integer :: n
integer :: petID
character(len=ESMF_MAXSTR) :: rcfilen
character(len=ESMF_MAXSTR) :: src_mode
character(len=ESMF_MAXSTR) :: snk_mode
character(len=ESMF_MAXSTR) :: loss_species
character(len=ESMF_MAXSTR) :: regions_ExtData_entry
character(len=ESMF_MAXSTR) :: friend_list
logical :: dry_dep
logical :: wet_removal
logical :: gocart_conv
logical :: lai_needed
logical :: stOX_loss_needed
type (ESMF_Config) :: myCF
character(len=ESMF_MAXSTR), allocatable :: str_array(:) ! to hold unique ExtData entries
integer :: s_count ! number of entries in str_array
! ------------
! Get my name and set-up traceback handle
! ---------------------------------------
call ESMF_GridCompGet( GC, name=comp_name, __RC__ )
Iam = TRIM(comp_name) // '::' // trim(Iam)
! if (MAPL_AM_I_ROOT()) then
! print *, trim(Iam)//': setting up...'
! print *, ''
! end if
! Wrap internal state for storing in GC; rename legacyState
! -------------------------------------
allocate ( myState, __STAT__ )
wrap%ptr => myState
! Identify the PET (persistent execution thread) ID
! -------------------------------------------------
call ESMF_VMGetCurrent(vm, __RC__ )
call ESMF_VMGet(vm, localPet=petID, __RC__ )
myState%pet = petID
allocate ( myState%kit, __STAT__ )
! Start by loading the Chem Registry.
! This duplicates the approach in GMI and GOCART.
! It might be better to break off the Passive Tracers into a
! separate file, but for now use the Chem Registry. (MeM 5.27.14)
! ----------------------------------
allocate ( myState%registry, __STAT__ )
myState%registry = Runtime_RegistryCreate ( 'TR_Registry.rc', 'TR_table::', STATUS )
VERIFY_(STATUS)
r => myState%registry ! short-hand
! Load private Config Attributes
! ------------------------------
myState%CF = ESMF_ConfigCreate(__RC__)
! CAN WE USE esmf ROUTINES HERE? OR i90 ROUTINES???
! call ESMF_ConfigLoadFile ( myState%CF, 'MAMchem_GridComp.rc', __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%verbose, Label='verbose:', default=.false., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, flagMAM7, Label='doing_MAM7:', default=.true. , __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, flagMAM3, Label='doing_MAM3:', default=.false., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%dry_removal, Label='dry_removal:', default=.true., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%wet_removal, Label='wet_removal:', default=.true., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%nucleation, Label='nucleation:', default=.true., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%condensation, Label='condensation:', default=.true., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%coagulation, Label='coagulation:', default=.true., __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%femisSS, Label='seasalt_femis:', default=1.0, __RC__ )
! call ESMF_ConfigGetAttribute ( myState%CF, myState%femisDU, Label='dust_femis:', default=1.0, __RC__ )
! _ASSERT(flagMAM3 /= flagMAM7,'needs informative message')
! if (flagMAM7) then
! myState%model = MAM7_MODEL
! else
! myState%model = MAM3_MODEL
! end if
! ------------------------
! ESMF Functional Services
! ------------------------
! Set the Initialize, Run, Finalize entry points
! ----------------------------------------------
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_INITIALIZE, Initialize_, __RC__ )
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, Run_, __RC__ )
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_FINALIZE, Finalize_, __RC__ )
! Store internal state in GC
! --------------------------
call ESMF_UserCompSetInternalState ( GC, 'TR_STATE', wrap, STATUS )
VERIFY_(STATUS)
! Read resource settings
! ----------------------
myCF = ESMF_ConfigCreate(__RC__)
call ESMF_ConfigLoadFile (myCF, 'TR_GridComp.rc', __RC__ )
call ESMF_ConfigGetAttribute(myCF, myState%strict_tracer_timing, Default=.FALSE., Label="strict_tracer_timing:", __RC__ )
call ESMF_ConfigDestroy (myCF, __RC__)
IF(MAPL_AM_I_ROOT()) PRINT *, TRIM(Iam)//": strict_tracer_timing =", myState%strict_tracer_timing
! ------------------
! MAPL Data Services
! ------------------
!BOS
!
! These .h files are generated from a Registry, by acg.pl
!
! !IMPORT STATE:
! #include "MAMchem_ImportSpec___.h"
!! The TR version could include calls like these:
!! (these are copied from GOCART_GridCompMod.F90)
! IMPORT variables computed AFTER RUN Method of TR_GridCompMod.F90
! Therefore, variables are included on RESTART
! --------------------------------------------
! CLDTT - Connectivity from RAD to CHEM
! -------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CLDTT', &
LONG_NAME = 'total_cloud_area_fraction', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
__RC__ )
! IMPORT variables computed BEFORE RUN Method of TR_GridCompMod.F90
! Therefore, variables are skipped on RESTART
! -------------------------------------------
! TROPP - Connectivity from SDYN to PHYS is TROPP_BLENDED to TROPP
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'TROPP', &
LONG_NAME = 'tropopause_pressure_based_on_blended_estimate', &
UNITS = 'Pa', &
! DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! PLE - Pressure at the edges
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PLE', &
LONG_NAME = 'air_pressure', &
UNITS = 'Pa', &
! DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! ZLE - Height at the edges
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'ZLE', &
LONG_NAME = 'geopotential_height', &
UNITS = 'm', &
! DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! T - Air Temperature
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'T', &
LONG_NAME = 'air_temperature', &
UNITS = 'K', &
! DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! DELP - Pressure difference between top and bottom edges
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'DELP', &
LONG_NAME = 'pressure_thickness', &
UNITS = 'Pa', &
!ALT DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, __RC__ )
! AIRDENS - Air density
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'AIRDENS', &
LONG_NAME = 'air_density', &
UNITS = 'kg m-3', &
!ALT DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! AIRDENS_DRYP - Dry air density
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'AIRDENS_DRYP', &
LONG_NAME = 'partial_dry_air_density', &
UNITS = 'kg dry m-3 tot', &
!ALT DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! AREA - Cell area
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'AREA', &
LONG_NAME = 'agrid_cell_area', &
UNITS = 'm+2', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! Q - Specific Humidity
! ----------------------------------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'Q', &
LONG_NAME = 'specific_humidity', &
UNITS = 'kg kg-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'LWI', &
LONG_NAME = 'land-ocean-ice_mask', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'T2M', &
LONG_NAME = '2-meter_air_temperature', &
UNITS = 'K', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'Z0H', &
LONG_NAME = 'surface_roughness_for_heat', &
UNITS = 'm', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'SWNDSRF', &
LONG_NAME = 'surface_net_downward_shortwave_flux',&
UNITS = 'W m-2', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'USTAR', &
LONG_NAME = 'surface_velocity_scale', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! FRLAKE
! ------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FRLAKE', &
LONG_NAME = 'fraction_of_lake', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! FROCEAN
! -------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FROCEAN', &
LONG_NAME = 'fraction_of_ocean', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! FRACI
! -----
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FRACI', &
LONG_NAME = 'ice_covered_fraction_of_tile', &
UNITS = '1', &
!ALT DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! TSOIL1, from SURFACE
! --------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'TSOIL1', &
LONG_NAME = 'soil_temperatures_layer_1', &
UNITS = 'K', &
!ALT DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'DQDT', &
LONG_NAME = 'specific_humidity_tendency_due_to_moist', &
UNITS = 's-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PFL_CN', &
LONG_NAME = '3D_flux_of_liquid_convective_precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PFL_LSAN', &
LONG_NAME = '3D_flux_of_liquid_nonconvective_precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PFI_LSAN', &
LONG_NAME = '3D_flux_of_ice_nonconvective_precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'SNOWDP', &
LONG_NAME = 'snow_depth', &
UNITS = 'm', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FRLANDICE', &
LONG_NAME = 'fraction_of_land_ice', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CN_PRCP', &
LONG_NAME = 'Surface Conv. rain flux needed by land', &
UNITS = 'kg m-2 s-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'NCN_PRCP', &
LONG_NAME = 'Non-convective precipitation', &
UNITS = 'kg m-2 s-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CNV_MFD', &
LONG_NAME = 'detraining_mass_flux', &
UNITS = 'kg m-2 s-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CNV_MFC', &
LONG_NAME = 'cumulative_mass_flux', &
UNITS = 'kg m-2 s-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'QLCN', &
LONG_NAME = 'mass_fraction_of_convective_cloud_liquid_water', &
UNITS = 'kg kg-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'QICN', &
LONG_NAME = 'mass_fraction_of_convective_cloud_ice_water', &
UNITS = 'kg kg-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__)
! RH: is between 0 and 1
! ----------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'RH2', &
LONG_NAME = 'Rel_Hum_after_moist', &
UNITS = '1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__)
! PBL
! ---
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'ZPBL', &
LONG_NAME = 'Planetary boundary layer height', &
UNITS = 'm', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
! PPBL
! ----
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PPBL', &
LONG_NAME = 'pbltop_pressure', &
UNITS = '1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
! SHFX (pos is up)
! ----------------------------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'SH', &
LONG_NAME = 'sensible_heat_flux_from_turbulence', &
UNITS = 'W m-2', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
!! --------------------------------------
!! Some Chemical Species will need to be IMPORTED here...
!! To really do this correctly we will parse the .rc files, and
!! keep a list of unique names of imports; long name and units will get filler values?
! Got this from GMICHEM_InternalSpec___.h
! We no longer use Chem_Registry, so we don't know if GMI is running
! Add these entries to ExtData.rc
! IF ( r%doing_GMI ) THEN
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'OX_TR', &
LONG_NAME = 'Ozone', &
UNITS = 'mol mol-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! Only do this conditionally, because GMI needs to run all the QQJ & QQK
! in order to provide it:
!
! call MAPL_AddImportSpec(GC, &
! SHORT_NAME = 'stOX_loss', &
! LONG_NAME = 'loss to apply to strat OX tracer', &
! UNITS = 'mole m-3 s-1', &
! DIMS = MAPL_DimsHorzVert, &
! VLOCATION = MAPL_VLocationCenter, &
! RESTART = MAPL_RestartSkip, &
! __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'DD_OX', &
LONG_NAME = 'dry_deposition_of_OX', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! END IF
!! --------------------------------------
!EOS
!!
!! Add IMPORT specs for tracers that rely on 2D or 3D files
!! Add IMPORT specs for unique ExtData region masks
!! Conditionally add IMPORT specs for VEG and LAI fractions
!!
!! Add EXPORT (EM) specs for tracers that rely on 2D or 3D files
!! Add EXPORT (DK) specs for tracers with e-folding or halflife loss
!! Add EXPORT (PR) specs for tracers that are produced by the decay of another tracer
!! Add EXPORT (ST,STvsum,DD) specs for tracers subject to Dry Dep
!! Add EXPORT (WR,WRvsum) specs for tracers subject to Wet Removal
!!
lai_needed = .FALSE.
stOX_loss_needed = .FALSE.
allocate ( str_array( r%nq ), __STAT__ )
s_count = 0
do n = 1, r%nq
rcfilen = 'TR_GridComp---' // TRIM(r%vname(n)) // '.rc'
call ESMF_ConfigLoadFile ( myState%CF, TRIM(rcfilen), __RC__ )
call ESMF_ConfigGetAttribute ( myState%CF, label='src_mode:', value=src_mode, default='NO_SRC', __RC__ )
IF( TRIM(src_mode) == "file2d" ) THEN
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'SRC_2D_'//TRIM(r%vname(n)), &
LONG_NAME = 'source_values_for_'//TRIM(r%vname(n)), &
! UNITS = 'units', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! EM_ values are positive
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'EM_'//TRIM(r%vname(n)), &
LONG_NAME = 'Emissions (2D) of '//TRIM(r%vtitle(n)), &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
__RC__ )
END IF
IF( TRIM(src_mode) == "file3d" ) THEN
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'SRC_3D_'//TRIM(r%vname(n)), &
LONG_NAME = 'source_values_for_'//TRIM(r%vname(n)), &
! UNITS = 'units', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! EM_ values are positive
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'EM_'//TRIM(r%vname(n)), &
LONG_NAME = 'Emissions (3D) of '//TRIM(r%vtitle(n)), &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
__RC__ )
END IF
IF( TRIM(src_mode) == "decay_of_another_species" ) THEN
! PRtend_ values are only guarateed positive when src_add == TRUE
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'PRtend_'//TRIM(r%vname(n)), &
LONG_NAME = 'Production of '//TRIM(r%vtitle(n)), &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
__RC__ )
END IF
call ESMF_ConfigGetAttribute ( myState%CF, label='GMI_dry_deposition:', value=dry_dep, default=.FALSE., __RC__ )
!MEM
! IF ( dry_dep ) THEN
! Settling from level A to level B will result in a negative tendency at level A and
! a positive tendency at level B. Compute the cumulative effect at all levels.
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'STtend_'//TRIM(r%vname(n)), &
LONG_NAME = 'Tendency of '//TRIM(r%vtitle(n))//' due to Settling', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
__RC__ )
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'STtendVsum_'//TRIM(r%vname(n)), &
LONG_NAME = 'Tendency of '//TRIM(r%vtitle(n))//' due to Settling, column total', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
__RC__ )
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'DDtend_'//TRIM(r%vname(n)), &
LONG_NAME = 'Tendency of '//TRIM(r%vtitle(n))//' due to Dry Deposition', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, &
__RC__ )
lai_needed = .TRUE.
! END IF
call ESMF_ConfigGetAttribute ( myState%CF, label='GMI_wet_removal:', value=wet_removal, default=.FALSE., __RC__ )
!MEM
! IF ( wet_removal ) THEN
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'WRtend_'//TRIM(r%vname(n)), &
LONG_NAME = 'Tendency of '//TRIM(r%vtitle(n))//' due to Large-Scale Wet Removal', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
__RC__ )
call MAPL_AddExportSpec(GC, &