-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGEOS_ChemEnvGridComp.F90
1445 lines (1133 loc) · 64.8 KB
/
GEOS_ChemEnvGridComp.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"
!=============================================================================
!BOP
! !MODULE: GEOS_ChemEnvGridCompMod -- Prepares Environment for GEOSchem
! !INTERFACE:
module GEOS_ChemEnvGridCompMod
! !USES:
use ESMF
use MAPL
use OVP, only: OVP_init, OVP_end_of_timestep_hms, OVP_mask, OVP_apply_mask
use Lightning_mod
implicit none
private
!Derived types for the internal state
type T_ChemEnv_STATE
private
INTEGER, ALLOCATABLE :: MASK_10AM(:,:)
INTEGER, ALLOCATABLE :: MASK_2PM(:,:)
INTEGER :: OVP_FIRST_HMS
INTEGER :: OVP_RUN_DT
INTEGER :: OVP_GC_DT
INTEGER :: OVP_MASK_DT
LOGICAL :: OVP_setup_done = .FALSE.
end type T_ChemEnv_STATE
type ChemEnv_WRAP
type (T_ChemEnv_STATE), pointer :: PTR
end type ChemEnv_WRAP
integer, parameter :: r8 = 8
character(len=ESMF_MAXSTR) :: rcfilen = 'ChemEnv.rc'
! Retrieve from rc file:
integer :: flash_source_enum = FLASH_SOURCE_UNDEFINED
character(len=ESMF_MAXSTR) :: ratioGlobalFile ! only needed for FIT
real :: minDeepCloudTop ! needed for emiss_lightning
real :: lightNOampFactor ! needed for emiss_lightning
real :: numberNOperFlash ! needed for emiss_lightning
real :: MOIST_flashFactor
real :: FIT_flashFactor
real :: HEMCO_flashFactor
real :: LOPEZ_flashFactor
logical :: usePreconCape ! use CAPE, INHB and BYNCY from MOIST
! May change during the course of the run:
integer :: year_for_ratio = 0
integer :: month_for_ratio = 0
real :: ratioGlobalLight ! only needed for FIT
! !PUBLIC MEMBER FUNCTIONS:
public SetServices
! !PRIVATE MEMBER FUNCTIONS:
!
PRIVATE :: Initialize_ ! Init method
PRIVATE :: Run1 ! Run method
PRIVATE :: Run2 ! Run method
PRIVATE :: Airdens ! Compute Air Density
! !DESCRIPTION: This is a Cinderella gridded component (GC)
!EOP
contains
!BOP
! !IROUTINE: SetServices -- Sets ESMF services for this component
! !INTERFACE:
subroutine SetServices ( GC, RC )
! !ARGUMENTS:
type(ESMF_GridComp), intent(INOUT) :: GC ! gridded component
integer, intent(OUT) :: RC ! return code
! !DESCRIPTION: The SetServices for the Chemistry Env GC needs to register its
! Initialize and Run. It uses the MAPL\_Generic construct for defining
! state specs and couplings among its children. In addition, it creates the
! children GCs and runs their respective SetServices.
!EOP
!=============================================================================
!
! ErrLog Variables
character(len=ESMF_MAXSTR) :: IAm
integer :: STATUS
character(len=ESMF_MAXSTR) :: COMP_NAME
! Locals
type (ESMF_Config) :: CF
type (T_ChemEnv_STATE), pointer :: state
type (ChemEnv_WRAP) :: wrap
!=============================================================================
! Begin...
! Get my name and set-up traceback handle
! ---------------------------------------
Iam = 'ChemEnv::SetServices'
call ESMF_GridCompGet( GC, NAME=COMP_NAME, CONFIG=CF, __RC__ )
Iam = trim(COMP_NAME) // 'SetServices'
! Wrap internal state for storing in GC; rename legacyState
! -------------------------------------
allocate ( state, stat=STATUS )
VERIFY_(STATUS)
wrap%ptr => state
! Register services for this component
! ------------------------------------
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_INITIALIZE, Initialize_, __RC__ )
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, Run1, __RC__ )
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, Run2, __RC__ )
! Save pointer to the wrapped internal state in the GC
!-----------------------------------------------------
call ESMF_UserCompSetInternalState ( GC, 'ChemEnv', wrap, STATUS )
VERIFY_(STATUS)
state%OVP_setup_done = .FALSE.
!BOS
call read_flash_source ( rcfilen, flash_source_enum, __RC__ )
! !IMPORT STATE:
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PLE', &
LONG_NAME = 'air_pressure', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'TH', &
LONG_NAME = 'potential_temperature', &
UNITS = 'K', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'Q', &
LONG_NAME = 'specific_humidity', &
UNITS = 'kg kg-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
! Geopotential Height
! -------------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PHIS', &
LONG_NAME = 'Geopotential Height at Surface', &
UNITS = 'm+2 s-2', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
! Total precip
! ------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PRECTOT', &
LONG_NAME = 'total_precipitation', &
UNITS = 'kg m-2 s-1', &
DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
! Convective precip
! -----------------
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CN_PRCP', &
LONG_NAME = 'convective_precipitation', &
UNITS = 'kg m-2 s-1', &
DEFAULT = MAPL_UNDEF, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
! call MAPL_AddImportSpec(GC, &
! SHORT_NAME = 'FRLANDICE', &
! LONG_NAME = 'fraction_of_land_ice', &
! UNITS = '1', &
! DIMS = MAPL_DimsHorzOnly, &
! VLOCATION = MAPL_VLocationNone, &
! RC=STATUS )
! VERIFY_(STATUS)
!! NEEDED?:
! call MAPL_AddImportSpec(GC, &
! SHORT_NAME = 'FRACI', &
! LONG_NAME = 'ice_covered_fraction_of_tile', &
! UNITS = '1', &
! DIMS = MAPL_DimsHorzOnly, &
! VLOCATION = MAPL_VLocationNone, &
! __RC__ )
if (flash_source_enum == FLASH_SOURCE_FIT) then
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'MCOR', &
LONG_NAME = 'agrid_cell_area', &
UNITS = 'm+2', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'RATIO_LOCAL', &
LONG_NAME = 'local_ratios_lightning', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'MIDLAT_ADJ', &
LONG_NAME = 'midlat_adjustment_lightning', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
endif
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CNV_MFC', &
LONG_NAME = 'cumulative_mass_flux', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CNV_MFD', &
LONG_NAME = 'detraining_mass_flux', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PFI_CN', &
LONG_NAME = '3D_flux_of_ice_convective_precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__ )
call MAPL_AddImportSpec ( gc, &
SHORT_NAME = 'T', &
LONG_NAME = 'air_temperature', &
UNITS = 'K', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'TS', &
LONG_NAME = 'surface_skin_temperature', &
UNITS = 'K', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FROCEAN', &
LONG_NAME = 'fraction_of_ocean', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FRLAND', &
LONG_NAME = 'fraction_of_land', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'ZLE', &
LONG_NAME = 'geopotential_height', &
UNITS = 'm', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'LWI', &
LONG_NAME = 'land(1)_water(0)_ice(2)_flag', &
UNITS = '1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'ZPBL', &
LONG_NAME = 'planetary_boundary_layer_height', &
UNITS = 'm', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'AREA', &
LONG_NAME = 'agrid_cell_area', &
UNITS = 'm+2', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'CNV_QC', &
LONG_NAME = 'grid_mean_convective_condensate', &
UNITS = 'kg kg-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
call MAPL_AddImportSpec ( gc, &
SHORT_NAME = 'QLTOT', &
LONG_NAME = 'mass_fraction_of_cloud_liquid_water', &
UNITS = 'kg kg-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PS', &
LONG_NAME = 'surface_pressure', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'U10M', &
LONG_NAME = '10-meter_eastward_wind', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'V10M', &
LONG_NAME = '10-meter_northward_wind', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
! call MAPL_AddImportSpec ( gc, &
! SHORT_NAME = 'EPV', &
! LONG_NAME = 'ertels_potential_vorticity', &
! UNITS = 'K m+2 kg-1 s-1', &
! RESTART = MAPL_RestartSkip, &
! DIMS = MAPL_DimsHorzVert, &
! VLOCATION = MAPL_VLocationCenter, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'PPBL', &
LONG_NAME = 'pbltop_pressure', &
UNITS = '1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'TROPP', &
LONG_NAME = 'tropopause_pressure_based_on_blended_estimate', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME ='BYNCY', &
LONG_NAME ='buoyancy_of surface_parcel', &
UNITS ='m s-2', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME ='CAPE', &
LONG_NAME ='cape_for_surface_parcel', &
UNITS ='J kg-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME ='INHB', &
LONG_NAME ='inhibition_for_surface_parcel', &
UNITS ='J kg-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
call MAPL_AddImportSpec(GC, &
SHORT_NAME='ZLCL', &
LONG_NAME ='lifting_condensation_level', &
UNITS ='m' , &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, RC=STATUS )
VERIFY_(STATUS)
call MAPL_AddImportSpec(GC, &
SHORT_NAME='ZLFC', &
LONG_NAME ='level_of_free_convection', &
UNITS ='m' , &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, RC=STATUS )
VERIFY_(STATUS)
! !EXPORT STATE:
! AIRDENS: Provided for Children
! ------------------------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'AIRDENS', &
LONG_NAME = 'moist_air_density', &
UNITS = 'kg m-3', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
! Density of dry air
! ------------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'AIRDENS_DRYP', &
LONG_NAME = 'partial_dry_air_density', &
UNITS = 'kg dry m-3 tot', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
! DELP (This should be wired from DYN)
! ------------------------------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'DELP', &
LONG_NAME = 'pressure_thickness', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
! Total precip
! ------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'TPREC', &
LONG_NAME = 'total_precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
! Convective precip
! -----------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'CN_PRCP', &
LONG_NAME = 'Convective precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
! Non-convective precip
! ---------------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'NCN_PRCP', &
LONG_NAME = 'Non-convective precipitation', &
UNITS = 'kg m-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'LFR', &
LONG_NAME = 'lightning_flash_rate', &
UNITS = 'km-2 s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'BYNCY', &
LONG_NAME = 'buoyancy_of surface_parcel', &
UNITS = 'm s-2', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'CAPE', &
LONG_NAME = 'convective_avail_pot_energy', &
UNITS = 'J m^{-2} <check this!>', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'LIGHT_NO_PROD', &
LONG_NAME = 'lightning_NO_prod_rate', &
UNITS = 'm-3 s-1', &
DIMS = MAPL_DimsHorzVert, &
PRECISION = ESMF_KIND_R4, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
!!!! >>>>>>>>>>>>>>>> OVP
! 10am overpass AIRDENS
! ---------------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_AIRDENS', &
LONG_NAME = 'moist_air_density_10am_local', &
UNITS = 'kg m-3', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
! 2pm overpass AIRDENS
! ---------------------
call MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_AIRDENS', &
LONG_NAME = 'moist_air_density_2pm_local', &
UNITS = 'kg m-3', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_T', &
LONG_NAME = 'air_temperature_10am_local', &
UNITS = 'K', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_T', &
LONG_NAME = 'air_temperature_2pm_local', &
UNITS = 'K', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_PL', &
LONG_NAME = 'mid_level_pressure_10am_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_PL', &
LONG_NAME = 'mid_level_pressure_2pm_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_PLE', &
LONG_NAME = 'edge_pressure_10am_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_PLE', &
LONG_NAME = 'edge_pressure_2pm_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationEdge, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_QV_VMR', &
LONG_NAME = 'water_vapor_10am_local', &
UNITS = 'mol mol-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_QV_VMR', &
LONG_NAME = 'water_vapor_2pm_local', &
UNITS = 'mol mol-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_QLTOT', &
LONG_NAME = 'mass_fraction_of_cloud_liquid_water_10am_local', &
UNITS = 'kg kg-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_QLTOT', &
LONG_NAME = 'mass_fraction_of_cloud_liquid_water_2pm_local', &
UNITS = 'kg kg-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_PS', &
LONG_NAME = 'surface_pressure_10am_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_PS', &
LONG_NAME = 'surface_pressure_2pm_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_PPBL', &
LONG_NAME = 'pbltop_pressure_10am_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_PPBL', &
LONG_NAME = 'pbltop_pressure_2pm_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_TROPP', &
LONG_NAME = 'tropopause_pressure_10am_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_TROPP', &
LONG_NAME = 'tropopause_pressure_2pm_local', &
UNITS = 'Pa', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_U10M', &
LONG_NAME = 'eastward_10m_wind_speed_10am_local', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_U10M', &
LONG_NAME = 'eastward_10m_wind_speed_2pm_local', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP10_V10M', &
LONG_NAME = 'northward_10m_wind_speed_10am_local', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
CALL MAPL_AddExportSpec(GC, &
SHORT_NAME = 'OVP14_V10M', &
LONG_NAME = 'northward_10m_wind_speed_2pm_local', &
UNITS = 'm s-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__ )
! CALL MAPL_AddExportSpec(GC, &
! SHORT_NAME = 'OVP10_EPV', &
! LONG_NAME = 'ertels_potential_vorticity_10am_local', &
! UNITS = 'K m+2 kg-1 s-1', &
! DIMS = MAPL_DimsHorzVert, &
! VLOCATION = MAPL_VLocationCenter, __RC__ )
! CALL MAPL_AddExportSpec(GC, &
! SHORT_NAME = 'OVP14_EPV', &
! LONG_NAME = 'ertels_potential_vorticity_2pm_local', &
! UNITS = 'K m+2 kg-1 s-1', &
! DIMS = MAPL_DimsHorzVert, &
! VLOCATION = MAPL_VLocationCenter, __RC__ )
!!!! <<<<<<<<<<<<<<<< OVP
!EOS
! Create children's gridded components and invoke their SetServices
! -----------------------------------------------------------------
call MAPL_GenericSetServices ( GC, __RC__ )
RETURN_(ESMF_SUCCESS)
end subroutine SetServices
! !IROUTINE: Initialize_ -- Finish setting up
! !INTERFACE:
subroutine Initialize_ ( GC, impChem, expChem, clock, RC )
! !USES:
implicit NONE
! !INPUT PARAMETERS:
type(ESMF_Clock), intent(inout) :: clock ! The clock
! !OUTPUT PARAMETERS:
type(ESMF_GridComp), intent(inout) :: GC ! Grid Component
type(ESMF_State), intent(inout) :: impChem ! Import State
type(ESMF_State), intent(inout) :: expChem ! Export State
integer, intent(out) :: RC ! Error return code:
! 0 - all is well
! 1 -
! !DESCRIPTION: Read the resource file
!EOP
!=============================================================================
!
! ErrLog Variables
character(len=ESMF_MAXSTR) :: IAm
integer :: STATUS
character(len=ESMF_MAXSTR) :: COMP_NAME
! Locals
type (ESMF_Grid) :: esmfGrid
integer :: dims(3), im, jm
type (ESMF_Config) :: CF
character(len=ESMF_MAXSTR) :: rc_string
character(len=10) :: SimType ! CTM, FREE or REPLAY
!=============================================================================
! Begin...
! Get my name and set-up traceback handle
! ---------------------------------------
Iam = 'ChemEnv::Initialize_'
call ESMF_GridCompGet( GC, NAME=COMP_NAME, GRID=esmfGrid, __RC__ )
Iam = trim(COMP_NAME) // 'Initialize_'
! Call GenericInitialize (for every Child?)
! -----------------------------------------
call MAPL_GenericInitialize ( GC, impChem, expChem, clock, __RC__ )
call MAPL_GridGet ( esmfGrid, globalCellCountPerDim=dims, __RC__ )
im = dims(1)
jm = dims(2)
! SimType is added by ctm_setup
call ESMF_GridCompGet ( GC, CONFIG=CF, __RC__ )
call ESMF_ConfigGetAttribute ( CF, rc_string, Label="SimType:", Default="undefined", __RC__ )
! IF(MAPL_AM_I_ROOT()) PRINT*,'The SimType resource is '//TRIM(rc_string)
IF ( TRIM(rc_string) == "CTM" ) THEN
SimType = "CTM"
ELSE
call ESMF_ConfigGetAttribute ( CF, rc_string, Label="REPLAY_MODE:", Default="undefined", __RC__ )
! IF(MAPL_AM_I_ROOT()) PRINT*,'The REPLAY_MODE is '//TRIM(rc_string)
IF ( TRIM(rc_string) == "undefined" ) THEN
SimType = "FREE"
ELSE
SimType = "REPLAY"
END IF
END IF
! IF(MAPL_AM_I_ROOT()) PRINT*,'The SimType is '//SimType
call read_lightning_config ( im, jm, rcfilen, flash_source_enum, &
SimType, ratioGlobalFile, &
minDeepCloudTop, lightNOampFactor, &
numberNOperFlash, &
MOIST_flashFactor, FIT_flashFactor, &
HEMCO_flashFactor, LOPEZ_flashFactor, &
usePreconCape, &
__RC__ )
IF(MAPL_AM_I_ROOT()) THEN
if ( flash_source_enum == FLASH_SOURCE_MOIST ) PRINT*,'MOIST_flashFactor is ', MOIST_flashFactor
if ( flash_source_enum == FLASH_SOURCE_FIT ) PRINT*,' FIT_flashFactor is ', FIT_flashFactor
if ( flash_source_enum == FLASH_SOURCE_HEMCO ) PRINT*,'HEMCO_flashFactor is ', HEMCO_flashFactor
if ( flash_source_enum == FLASH_SOURCE_LOPEZ ) PRINT*,'LOPEZ_flashFactor is ', LOPEZ_flashFactor
PRINT*,'usePreconCape = ', usePreconCape
ENDIF
RETURN_(ESMF_SUCCESS)
end subroutine Initialize_
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !IROUTINE: Run1 -- Phase 1 run method
! !INTERFACE:
subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
! !ARGUMENTS:
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_State), intent(inout) :: IMPORT ! Import state
type(ESMF_State), intent(inout) :: EXPORT ! Export state
type(ESMF_Clock), intent(inout) :: CLOCK ! The clock
integer, optional, intent( out) :: RC ! Error code
! !DESCRIPTION: The Run1 method of the Chemistry Environment Gridded
! Component. It calculates air density used by chemistry and emissions.
!EOP
! ErrLog Variables
character(len=ESMF_MAXSTR) :: IAm
integer :: STATUS
character(len=ESMF_MAXSTR) :: COMP_NAME
type (MAPL_MetaComp), pointer :: ggState
integer :: ndt
real(r8) :: DT
real(r8), pointer :: R8D2(:,:)
real, pointer :: LONSLOCAL(:,:), LATSLOCAL(:,:)
type(ESMF_Grid) :: esmfGrid
!!!
!!!
! Imports
real, pointer, dimension(:,:,:) :: PLE => null()
real, pointer, dimension(:,:) :: RATIO_LOCAL => null()
real, pointer, dimension(:,:) :: MIDLAT_ADJ => null()
real, pointer, dimension(:,:,:) :: T => null()
real, pointer, dimension(:,:,:) :: TH => null()
real, pointer, dimension(:,:,:) :: Q => null()
real, pointer, dimension(:,:,:) :: ZLE => null()
real, pointer, dimension(:,:) :: cellArea => null()
real, pointer, dimension(:,:) :: mcor => null()
real, pointer, dimension(:,:) :: LWI => null()
real, pointer, dimension(:,:) :: PBLH => null()
real, pointer, dimension(:,:) :: ZLFC => null()
real, pointer, dimension(:,:) :: ZLCL => null()
real, pointer, dimension(:,:) :: TS => null()
real, pointer, dimension(:,:) :: FROCEAN => null()
real, pointer, dimension(:,:) :: FRLAND => null()
real, pointer, dimension(:,:) :: CN_PRCP => null()
real, pointer, dimension(:,:) :: PHIS => null()
real, pointer, dimension(:,:,:) :: CNV_MFC => null()
real, pointer, dimension(:,:,:) :: CNV_MFD => null()
real, pointer, dimension(:,:,:) :: PFI_CN => null()
real, pointer, dimension(:,:,:) :: CNV_QC => null()
real, pointer, dimension(:,:) :: CAPE_PRECON => null()
real, pointer, dimension(:,:) :: INHB_PRECON => null()
real, pointer, dimension(:,:,:) :: BYNCY_PRECON => null()
! Exports
real, pointer, dimension(:,:,:) :: delp => null()
real, pointer, dimension(:,:) :: LFR => null()
real, pointer, dimension(:,:,:) :: BYNCY => null()
real, pointer, dimension(:,:) :: CAPE => null()
real*4, pointer, dimension(:,:,:) :: LIGHT_NO_PROD => null()
!=============================================================================
integer :: k, k0
! Begin...
! Get the target components name and set-up traceback handle.
! -----------------------------------------------------------
Iam = "Run1"
call ESMF_GridCompGet ( GC, name=COMP_NAME, __RC__ )
Iam = trim(COMP_NAME) // "Run1"
call MAPL_GetObjectFromGC ( GC, ggState, __RC__ )
! Get the time-step
! -----------------------
call MAPL_GetResource( ggState, ndt, 'RUN_DT:', default=0, __RC__ )
DT = ndt
! Get the grid related information
!---------------------------------
call ESMF_GridCompGet ( GC, GRID=esmfGrid, __RC__ )
! Get the local longitudes
!---------------------------------
call ESMF_GridGetCoord(esmfGrid, localDE=0, coordDim=1, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
datacopyFlag = ESMF_DATACOPY_REFERENCE, &
farrayPtr=R8D2, __RC__ )
allocate(LONSLOCAL(size(R8D2,1),size(R8D2,2)), __STAT__ )
LONSLOCAL = R8D2*(180/MAPL_PI)
! Get the local latitudes
!---------------------------------
call ESMF_GridGetCoord(esmfGrid, localDE=0, coordDim=2, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
datacopyFlag = ESMF_DATACOPY_REFERENCE, &
farrayPtr=R8D2, __RC__ )
allocate(LATSLOCAL(size(R8D2,1),size(R8D2,2)), __STAT__ )
LATSLOCAL = R8D2*(180/MAPL_PI)
! Every time, double check that the ratio has not changed
! We pass in the year and month last used, to save reading again
! --------------------------------------------------------------
if ( flash_source_enum == FLASH_SOURCE_FIT ) then
call update_lightning_ratio( ratioGlobalFile, CLOCK, &
year_for_ratio, month_for_ratio, &
ratioGlobalLight, __RC__ )
end if
! Get the imports...
! ------------------
call MAPL_GetPointer ( IMPORT, PLE, 'PLE', __RC__ )
! Get the exports...
! ------------------
call MAPL_GetPointer ( EXPORT, delp, 'DELP', ALLOC=.TRUE., __RC__ )
! Compute moist (rho) and dry (rhoDry) air density
! ------------------------------------------------
CALL AirDens ( GC, IMPORT, EXPORT, __RC__ )
if ( associated(delp) ) then
k0 = 1-lbound(PLE,3)
do k = 1, size(delp,3)
delp(:,:,k) = PLE(:,:,k-k0+1) - PLE(:,:,k-k0)
end do
end if
!------------------------------------------------
! Flash Rate (LFR) for Lighting Parameterization
!------------------------------------------------
call MAPL_GetPointer ( EXPORT, LFR, 'LFR', ALLOC=.TRUE., __RC__ ) ! Can we get rid of ALLOC=T ?
call MAPL_GetPointer ( EXPORT, BYNCY, 'BYNCY', ALLOC=.TRUE., __RC__ )
call MAPL_GetPointer ( EXPORT, CAPE, 'CAPE', ALLOC=.TRUE., __RC__ )
call MAPL_GetPointer ( EXPORT, LIGHT_NO_PROD, 'LIGHT_NO_PROD', __RC__ ) ! If not requested, do not compute
! for FIT flashrate option
if (flash_source_enum == FLASH_SOURCE_FIT) then
call MAPL_GetPointer ( IMPORT, mcor, 'MCOR', __RC__ )
call MAPL_GetPointer ( IMPORT, RATIO_LOCAL, 'RATIO_LOCAL', __RC__ )
call MAPL_GetPointer ( IMPORT, MIDLAT_ADJ, 'MIDLAT_ADJ', __RC__ )
end if
call MAPL_GetPointer ( IMPORT, CNV_MFC, 'CNV_MFC', __RC__ )
call MAPL_GetPointer ( IMPORT, CNV_MFD, 'CNV_MFD', __RC__ )
call MAPL_GetPointer ( IMPORT, CN_PRCP, 'CN_PRCP', __RC__ )
call MAPL_GetPointer ( IMPORT, PHIS, 'PHIS', __RC__ )
call MAPL_GetPointer ( IMPORT, PFI_CN, 'PFI_CN', __RC__ )
call MAPL_GetPointer ( IMPORT, T, 'T', __RC__ )
call MAPL_GetPointer ( IMPORT, TH, 'TH', __RC__ )
call MAPL_GetPointer ( IMPORT, TS, 'TS', __RC__ )
call MAPL_GetPointer ( IMPORT, LWI, 'LWI', __RC__ )
call MAPL_GetPointer ( IMPORT, PBLH, 'ZPBL', __RC__ )
call MAPL_GetPointer ( IMPORT, FROCEAN, 'FROCEAN', __RC__ )
call MAPL_GetPointer ( IMPORT, FRLAND, 'FRLAND', __RC__ )
call MAPL_GetPointer ( IMPORT, Q, 'Q', __RC__ )
call MAPL_GetPointer ( IMPORT, ZLE, 'ZLE', __RC__ )
call MAPL_GetPointer ( IMPORT, CNV_QC, 'CNV_QC', __RC__ )
call MAPL_GetPointer ( IMPORT, cellArea, 'AREA', __RC__ )
call MAPL_GetPointer ( IMPORT, CAPE_PRECON, 'CAPE', __RC__ )
call MAPL_GetPointer ( IMPORT, INHB_PRECON, 'INHB', __RC__ )
call MAPL_GetPointer ( IMPORT, BYNCY_PRECON, 'BYNCY', __RC__ )
call MAPL_GetPointer ( IMPORT, ZLFC, 'ZLFC', __RC__ )
call MAPL_GetPointer ( IMPORT, ZLCL, 'ZLCL', __RC__ )
BYNCY(:,:,:) = real(0)
CAPE(:,:) = real(0)
LFR(:,:) = real(0)
if ( associated(LIGHT_NO_PROD) ) then
LIGHT_NO_PROD(:,:,:) = REAL(0)
end if
! print*,'ENV MOIST CN_PRCP ', MINVAL(CN_PRCP), MAXVAL(CN_PRCP)
! print*,'ENV MOIST FROCEAN ', MINVAL(FROCEAN), MAXVAL(FROCEAN)
! print*,'ENV MOIST TS ', MINVAL(TS ), MAXVAL(TS )
! print*,'ENV MOIST CNV_MFC ', MINVAL(CNV_MFC), MAXVAL(CNV_MFC)
! print*,'ENV MOIST PLE ', MINVAL(PLE ), MAXVAL(PLE )
! print*,'ENV MOIST TH ', MINVAL(TH ), MAXVAL(TH )
! print*,'ENV MOIST Q ', MINVAL(Q ), MAXVAL(Q )