-
Notifications
You must be signed in to change notification settings - Fork 10
/
FV_StateMod.F90
5229 lines (4713 loc) · 217 KB
/
FV_StateMod.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"
module FV_StateMod
!BOP
!
! !MODULE: FV_StateMod --- GEOS5/CAM Cubed-Sphere fvcore state variables/init/run/finalize
!
! !USES:
#if defined( MAPL_MODE )
use ESMF ! ESMF base class
use MAPL ! MAPL base class
#endif
use MAPL_ConstantsMod, only: MAPL_CP, MAPL_RGAS, MAPL_RVAP, MAPL_GRAV, MAPL_RADIUS, &
MAPL_KAPPA, MAPL_PI_R8, MAPL_ALHL, MAPL_PSDRY
use fv_mp_mod, only: start_group_halo_update, complete_group_halo_update
use fv_mp_mod, only: group_halo_update_type
use fms_mod, only: fms_init, set_domain, nullify_domain
use mpp_domains_mod, only: mpp_update_domains, CGRID_NE, DGRID_NE, mpp_get_boundary
use mpp_parameter_mod, only: AGRID_PARAM=>AGRID, CORNER
use fv_timing_mod, only: timing_on, timing_off, timing_init, timing_prt
use mpp_mod, only: mpp_pe, mpp_root_pe
use mpp_domains_mod, only: domain2d
use fv_grid_utils_mod, only: inner_prod, mid_pt_sphere, cubed_to_latlon, &
ptop_min, g_sum
use fv_grid_tools_mod, only: get_unit_vector
use fv_control_mod, only: fv_init1, fv_init2
use fv_arrays_mod , only: fv_atmos_type, FVPRC, REAL4, REAL8
use init_hydro_mod, only: p_var
use fv_dynamics_mod, only: fv_dynamics
use fv_update_phys_mod, only: fv_update_phys
use sw_core_mod, only: d2a2c_vect
use fv_sg_mod, only: fv_subgrid_z
use gfdl_lin_cloud_microphys_mod, only: gfdl_cloud_microphys_init
use fv_diagnostics_mod, only: prt_maxmin, prt_minmax, range_check, &
get_vorticity, updraft_helicity, bunkers_vector, helicity_relative_CAPS
#ifdef RUN_GTFV3
use ieee_exceptions, only: ieee_get_halting_mode, ieee_set_halting_mode, ieee_all
use geos_gtfv3_interface_mod, only: geos_gtfv3_interface_f
use geos_gtfv3_interface_mod, only: geos_gtfv3_interface_f_init, geos_gtfv3_interface_f_finalize
#endif
implicit none
private
#include "mpif.h"
real(REAL8), save :: elapsed_time = 0
real(REAL8), save :: massD0
real(REAL8), save :: massADDED = 0.0
real(FVPRC), parameter :: tiny_number=1.e-15
real(FVPRC), parameter :: huge_number=1.e+15
! !PUBLIC DATA MEMBERS:
logical :: FV_OFF = .false.
integer :: INT_FV_OFF = 0
logical :: ADJUST_DT = .false.
logical :: DEBUG = .false.
logical :: COLDSTART = .false.
logical :: SW_DYNAMICS = .false.
integer :: INT_ADIABATIC = 0
logical :: ADIABATIC = .false.
logical :: FV_HYDROSTATIC = .true.
integer :: INT_check_mass = 0
logical :: check_mass = .false.
integer :: INT_fix_mass = 1
logical :: fix_mass = .true.
integer :: CASE_ID = 11
integer :: AdvCore_Advection = 0
character(LEN=ESMF_MAXSTR) :: FV3_CONFIG
public FV_Atm
public FV_Setup, FV_InitState, FV_Run, FV_Finalize, FV_DA_Incs
public FV_HYDROSTATIC, ADIABATIC, DEBUG, COLDSTART, CASE_ID, SW_DYNAMICS, AdvCore_Advection
public FV_RESET_CONSTANTS
public FV_To_State, State_To_FV
public T_TRACERS, T_FVDYCORE_VARS, T_FVDYCORE_GRID, T_FVDYCORE_STATE
public fv_fillMassFluxes
public fv_computeMassFluxes
public fv_getVerticalMassFlux
public fv_getPK
public fv_getOmega
public fv_getVorticity
public fv_getDivergence
public fv_getUpdraftHelicity
public fv_getEPV
public fv_getDELZ
public fv_getPKZ
public fv_getQ
public debug_fv_state
public fv_getAllWinds
public INTERP_AGRID_TO_DGRID
interface fv_computeMassFluxes
module procedure fv_computeMassFluxes_r4
module procedure fv_computeMassFluxes_r8
end interface
INTERFACE fv_getAllWinds
MODULE PROCEDURE fv_getAllWinds_3D_R4
MODULE PROCEDURE fv_getAllWinds_3D
MODULE PROCEDURE fv_getAllWinds_2D
END INTERFACE
INTERFACE INTERP_AGRID_TO_DGRID
MODULE PROCEDURE a2d3d ! 2d to 3d
MODULE PROCEDURE a2d2d ! 2d to 2d
END INTERFACE
logical, save :: Init_FV_Domain = .true.
type(fv_atmos_type), allocatable, save :: FV_Atm(:)
logical, allocatable, save :: grids_on_this_pe(:)
type T_TRACERS
logical :: is_r4
real(REAL8), dimension(:,:,: ), pointer :: content
real(REAL4), dimension(:,:,: ), pointer :: content_r4
character(LEN=ESMF_MAXSTR) :: tname
end type T_TRACERS
! T_FVDYCORE_VARS contains the prognostic variables for FVdycore
type T_FVDYCORE_VARS
real(REAL8), dimension(:,:,: ), pointer :: U => NULL() ! U winds (D-grid)
real(REAL8), dimension(:,:,: ), pointer :: V => NULL() ! V winds (D-grid)
real(REAL8), dimension(:,:,: ), pointer :: PT => NULL() ! scaled virtual pot. temp.
real(REAL8), dimension(:,:,: ), pointer :: PE => NULL() ! Pressure at layer edges
real(REAL8), dimension(:,:,: ), pointer :: PKZ => NULL() ! P^kappa mean
real(REAL8), dimension(:,:,: ), pointer :: DZ => NULL() ! Height Thickness
real(REAL8), dimension(:,:,: ), pointer :: W => NULL() ! Vertical Velocity
type(T_TRACERS), dimension(:), pointer :: tracer => NULL() ! Tracers
integer :: nwat ! Number of water species
end type T_FVDYCORE_VARS
! T_FVDYCORE_GRID contains information about the horizontal and vertical
! discretization, unlike in ARIES where these data are split into HORZ_GRID
! and VERT_GRID. The reason for this: currently all of this information is
! initialized in one call to FVCAM dynamics_init.
type T_FVDYCORE_GRID
!
#if defined( MAPL_MODE )
type (MAPL_MetaComp), pointer :: FVgenstate
type (ESMF_Grid) :: GRID ! The 'horizontal' grid (2D decomp only)
#endif
integer :: NG ! Ghosting
!
integer :: IS ! Start X-index (exclusive, unghosted)
integer :: IE ! End X-index (exclusive, unghosted)
integer :: JS ! Start Y-index (exclusive, unghosted)
integer :: JE ! End Y-index (exclusive, unghosted)
!
integer :: ISD ! Start X-index (exclusive, ghosted)
integer :: IED ! End X-index (exclusive, ghosted)
integer :: JSD ! Start Y-index (exclusive, ghosted)
integer :: JED ! End Y-index (exclusive, ghosted)
!
integer :: NPX ! Full X- dim
integer :: NPY ! Full Y- dim
integer :: NPZ ! Numer of levels
integer :: NPZ_P1 ! NPZ+1 (?)
integer :: NTILES ! How many log-rectangular tiles does my grid Have
! lat-lon = 1
! cubed-sphere = 6
real(REAL8), allocatable :: DXC(:,:) ! local C-Grid DeltaX
real(REAL8), allocatable :: DYC(:,:) ! local C-Grid DeltaY
real(REAL8), allocatable :: AREA(:,:) ! local cell area
real(REAL8) :: GLOBALAREA ! global area
integer :: KS ! Number of true pressure levels (out of NPZ+1)
real(REAL8) :: PTOP ! pressure at top (ak(1))
real(REAL8) :: PINT ! initial pressure (ak(npz+1))
real(REAL8), dimension(:), pointer :: AK => NULL() ! Sigma mapping
real(REAL8), dimension(:), pointer :: BK => NULL() ! Sigma mapping
real(REAL8) :: f_coriolis_angle = 0
!
! Tracers
!
integer :: NQ ! Number of advected tracers
end type T_FVDYCORE_GRID
integer, parameter :: NUM_FVDYCORE_ALARMS = 3
integer, parameter :: NUM_TIMES = 8
integer, parameter :: TIME_TO_RUN = 1
type T_FVDYCORE_STATE
!!! private
type (T_FVDYCORE_VARS) :: VARS
type (T_FVDYCORE_GRID ) :: GRID
#if defined( MAPL_MODE )
type (ESMF_Clock), pointer :: CLOCK
type (ESMF_Alarm) :: ALARMS(NUM_FVDYCORE_ALARMS)
#endif
integer(kind=8) :: RUN_TIMES(4,NUM_TIMES)
logical :: DOTIME, DODYN
real(REAL8) :: DT ! Large time step
integer :: KSPLIT
integer :: NSPLIT
integer :: NUM_CALLS
end type T_FVDYCORE_STATE
! Constants used by fvcore
real(REAL8) :: pi
real(REAL8) :: omega ! angular velocity of earth's rotation
real(FVPRC) :: cp ! heat capacity of air at constant pressure
real(REAL8) :: radius ! radius of the earth (m)
real(REAL8) :: rgas ! Gas constant of the air
real(REAL8) :: rvap ! Gas constant of vapor
real(FVPRC) :: kappa ! kappa
real(REAL8) :: grav ! Gravity
real(REAL8) :: hlv ! latent heat of evaporation
real(FVPRC) :: zvir ! RWV/RAIR-1
real(kind=4), pointer :: phis(:,:), varflt(:,:)
logical :: fv_first_run = .true.
integer :: ntracers=11
type (ESMF_Alarm) :: MASSALARM
type (ESMF_TimeInterval) :: MassAlarmInt
logical :: first_mass_fix = .true.
!
! !DESCRIPTION:
!
! This module provides variables which are specific to the Lin-Rood
! dynamical core. Most of them were previously SAVE variables in
! different routines and were set with an "if (first)" statement.
!
! \begin{tabular}{|l|l|} \hline \hline
! lr\_init & Initialize the Lin-Rood variables \\ \hline
! lr\_clean & Deallocate all internal data structures \\ \hline
! \hline
! \end{tabular}
!
! !REVISION HISTORY:
! 2007.07.17 Putman Created from lat-lon core
!
!EOP
!-----------------------------------------------------------------------
real(REAL8), parameter :: D0_0 = 0.0
real(REAL8), parameter :: D0_5 = 0.5
real(REAL8), parameter :: D1_0 = 1.0
real(REAL8), parameter :: D2_0 = 2.0
real(REAL8), parameter :: D4_0 = 4.0
real(REAL8), parameter :: D180_0 = 180.0
real(REAL8), parameter :: ratmax = 0.81
#ifdef RUN_GTFV3
integer :: run_gtfv3 = 0
#endif
contains
!-----------------------------------------------------------------------
!
! !INTERFACE:
subroutine FV_RESET_CONSTANTS(FV_PI, FV_OMEGA, FV_CP, FV_RADIUS, FV_RGAS, &
FV_RVAP, FV_KAPPA, FV_GRAV, FV_HLV, FV_ZVIR)
real (REAL8), optional, intent(IN) :: FV_PI
real (REAL8), optional, intent(IN) :: FV_OMEGA
real (REAL8), optional, intent(IN) :: FV_CP
real (REAL8), optional, intent(IN) :: FV_RADIUS
real (REAL8), optional, intent(IN) :: FV_RGAS
real (REAL8), optional, intent(IN) :: FV_RVAP
real (REAL8), optional, intent(IN) :: FV_KAPPA
real (REAL8), optional, intent(IN) :: FV_GRAV
real (REAL8), optional, intent(IN) :: FV_HLV
real (REAL8), optional, intent(IN) :: FV_ZVIR
if (present(FV_PI)) then
pi = FV_PI
endif
if (present(FV_OMEGA)) then
omega = FV_OMEGA
endif
if (present(FV_CP)) then
cp = FV_CP
endif
if (present(FV_RADIUS)) then
radius = FV_RADIUS
endif
if (present(FV_RGAS)) then
rgas = FV_RGAS
endif
if (present(FV_RVAP)) then
rvap = FV_RVAP
endif
if (present(FV_KAPPA)) then
kappa = FV_KAPPA
endif
if (present(FV_GRAV)) then
grav = FV_GRAV
endif
if (present(FV_HLV)) then
hlv = FV_HLV
endif
if (present(FV_ZVIR)) then
zvir = FV_ZVIR
endif
end subroutine FV_RESET_CONSTANTS
!
!-----------------------------------------------------------------------
subroutine FV_Setup(GC,LAYOUT_FILE, RC)
use test_cases_mod, only : test_case
type (ESMF_GridComp) , intent(INOUT) :: GC
character(LEN=*) , intent(IN ) :: LAYOUT_FILE
integer, optional , intent(OUT ) :: RC
! Local
character(len=ESMF_MAXSTR) :: IAm='FV_StateMod:FV_Setup'
! Local variables
type (ESMF_Config) :: cf
type (ESMF_VM) :: VM
integer :: status
real(FVPRC) :: DT
integer :: ndt,nx,ny
type (MAPL_MetaComp), pointer :: MAPL => NULL()
integer :: comm
integer :: p_split=1
real :: temp_real
! BEGIN
call ESMF_VMGetCurrent(VM, rc=STATUS)
VERIFY_(STATUS)
call MAPL_MemUtilsWrite(VM, trim(IAm), RC=STATUS )
VERIFY_(STATUS)
! Retrieve the pointer to the state
! ---------------------------------
call MAPL_GetObjectFromGC (GC, MAPL, RC=STATUS )
VERIFY_(STATUS)
call MAPL_TimerOn(MAPL,"--FMS_INIT")
call ESMF_VMGet(VM,mpiCommunicator=comm,rc=status)
VERIFY_(STATUS)
call fms_init(comm)
call MAPL_TimerOff(MAPL,"--FMS_INIT")
call MAPL_MemUtilsWrite(VM, 'FV_StateMod: FMS_INIT', RC=STATUS )
VERIFY_(STATUS)
! Start up FV
call MAPL_TimerOn(MAPL,"--FV_INIT")
call fv_init1(FV_Atm, DT, grids_on_this_pe, p_split)
call MAPL_TimerOff(MAPL,"--FV_INIT")
call MAPL_MemUtilsWrite(VM, 'FV_StateMod: FV_INIT', RC=STATUS )
VERIFY_(STATUS)
! FV grid dimensions setup from MAPL
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npx, 'AGCM_IM:', default= 32, RC=STATUS )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npy, 'AGCM_JM:', default=192, RC=STATUS )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npz, 'AGCM_LM:', default= 72, RC=STATUS )
VERIFY_(STATUS)
if (FV_Atm(1)%flagstruct%npz == 1) SW_DYNAMICS = .true.
! stretch_fac is kind(R_GRID) in FV, so to prevent a MAPL failure on RC check, we pull
! AGCM.STRETCH_FACTOR: as a REAL32 and then cast it to REAL64. This is because
! FV_Atm(1)%flagstruct%stretch_fac is R_GRID => REAL64, and the MAPL_GetResource call
! is getting a REAL32
call MAPL_GetResource( MAPL, temp_real, 'AGCM.STRETCH_FACTOR:', default=1.0, RC=STATUS )
VERIFY_(STATUS)
FV_Atm(1)%flagstruct%stretch_fac = temp_real
! FV likes npx;npy in terms of cell vertices
if (FV_Atm(1)%flagstruct%npy == 6*FV_Atm(1)%flagstruct%npx) then
FV_Atm(1)%flagstruct%ntiles = 6
FV_Atm(1)%flagstruct%npy = FV_Atm(1)%flagstruct%npx+1
FV_Atm(1)%flagstruct%npx = FV_Atm(1)%flagstruct%npx+1
else
FV_Atm(1)%flagstruct%ntiles = 1
FV_Atm(1)%flagstruct%npy = FV_Atm(1)%flagstruct%npy+1
FV_Atm(1)%flagstruct%npx = FV_Atm(1)%flagstruct%npx+1
endif
! Check for Doubly Periodic Domain Info
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%deglat, label='FIXED_LATS:', default=FV_Atm(1)%flagstruct%deglat, rc=status )
VERIFY_(STATUS)
! MPI decomp setup
call MAPL_GetResource( MAPL, nx, 'NX:', default=0, RC=STATUS )
VERIFY_(STATUS)
FV_Atm(1)%layout(1) = nx
call MAPL_GetResource( MAPL, ny, 'NY:', default=0, RC=STATUS )
VERIFY_(STATUS)
if (FV_Atm(1)%flagstruct%grid_type == 4) then
FV_Atm(1)%layout(2) = ny
else
FV_Atm(1)%layout(2) = ny / 6
end if
! Get other scalars
! -----------------
call MAPL_GetResource( MAPL, ndt, 'RUN_DT:', default=0, RC=STATUS )
VERIFY_(STATUS)
DT = ndt
! Advect tracers within DynCore(AdvCore_Advection=.false.)
! or within AdvCore(AdvCore_Advection=.true.)
call MAPL_GetResource( MAPL, AdvCore_Advection, label='AdvCore_Advection:', default=AdvCore_Advection, rc=status )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, ADJUST_DT, label='ADJUST_DT:' , default=ADJUST_DT, rc=status )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, INT_fix_mass, label='fix_mass:' , default=INT_fix_mass, rc=status )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, INT_check_mass, label='check_mass:' , default=INT_check_mass, rc=status )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, INT_ADIABATIC, label='ADIABATIC:' , default=INT_adiabatic, rc=status )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, INT_FV_OFF, label='FV_OFF:' , default=INT_FV_OFF, rc=status )
VERIFY_(STATUS)
! option to enable MERRA-2 configurations for FV3
call MAPL_GetResource( MAPL, FV3_CONFIG, label='FV3_CONFIG:', default='STOCK', rc=status )
VERIFY_(STATUS)
! MAT The Fortran Standard, and thus gfortran, *does not allow* the use
! of if (integer). So, we must convert integer resources to logicals
if (INT_fix_mass == 0) then
fix_mass = .FALSE.
else
fix_mass = .TRUE.
end if
if (INT_check_mass == 0) then
check_mass = .FALSE.
else
check_mass = .TRUE.
end if
if (INT_ADIABATIC == 0) then
ADIABATIC = .FALSE.
else
ADIABATIC = .TRUE.
end if
if (INT_FV_OFF == 0) then
FV_OFF = .FALSE.
else
FV_OFF = .TRUE.
end if
! Constants
!
pi = MAPL_PI_R8
omega = MAPL_OMEGA ! angular velocity of earth's rotation
cp = MAPL_CP ! heat capacity of air at constant pressure
radius = MAPL_RADIUS ! radius of the earth (m)
rgas = MAPL_RGAS ! Gas constant of the air
rvap = MAPL_RVAP ! Gas constant of vapor
kappa = MAPL_KAPPA ! kappa
grav = MAPL_GRAV ! Gravity
hlv = MAPL_ALHL ! latent heat of evaporation
zvir = MAPL_RVAP/MAPL_RGAS - 1. ! RWV/RAIR-1
!
! Create some resolution dependent defaults for FV3 in GEOS...
! These can be overrided in fv_core_nml in fvcore_layout.rc linked to input.nml
!-------------------------------------------------------------
! Number of water species for FV3 determined later
! when reading the tracer bundle in fv_first_run
FV_Atm(1)%flagstruct%nwat = 0
! Trigger to enable autoconversion/cloud processes on the fv_mapz step
FV_Atm(1)%flagstruct%do_sat_adj = .false.
! Veritical resolution dependencies
FV_Atm(1)%flagstruct%external_eta = .true.
if (FV_Atm(1)%flagstruct%npz >= 70) then
FV_Atm(1)%flagstruct%n_sponge = 9 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 18 ! ~10mb
endif
if (FV_Atm(1)%flagstruct%npz >= 72) then
FV_Atm(1)%flagstruct%n_sponge = 9 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 25 ! ~10mb
endif
if (FV_Atm(1)%flagstruct%npz >= 90) then
FV_Atm(1)%flagstruct%n_sponge = 9 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 25 ! ~10mb
endif
if (FV_Atm(1)%flagstruct%npz >= 126) then
FV_Atm(1)%flagstruct%n_sponge = 9 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 23 ! ~10mb
endif
if (FV_Atm(1)%flagstruct%npz >= 132) then
FV_Atm(1)%flagstruct%n_sponge = 9 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 30 ! ~10mb
endif
if (FV_Atm(1)%flagstruct%npz >= 136) then
FV_Atm(1)%flagstruct%n_sponge = 9 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 30 ! ~10mb
endif
if (FV_Atm(1)%flagstruct%npz >= 180) then
FV_Atm(1)%flagstruct%n_sponge = 18 ! ~0.2mb
FV_Atm(1)%flagstruct%n_zfilter = 50 ! ~10mb
endif
FV_Atm(1)%flagstruct%remap_option = 0 ! Remap T in LogP
if (FV_Atm(1)%flagstruct%npz == 72) then
FV_Atm(1)%flagstruct%gmao_remap = 0 ! GFDL Schemes
else
FV_Atm(1)%flagstruct%gmao_remap = 0 ! (0 for GFDL Schemes) (3 for GMAO Cubic)
endif
FV_Atm(1)%flagstruct%kord_tm = 9
FV_Atm(1)%flagstruct%kord_mt = 9
FV_Atm(1)%flagstruct%kord_wz = 9
FV_Atm(1)%flagstruct%kord_tr = 9
FV_Atm(1)%flagstruct%z_tracer = .true.
! Some default horizontal flags
FV_Atm(1)%flagstruct%adjust_dry_mass = fix_mass
FV_Atm(1)%flagstruct%consv_am = .false.
FV_Atm(1)%flagstruct%fill = .true.
FV_Atm(1)%flagstruct%dwind_2d = .false.
FV_Atm(1)%flagstruct%delt_max = 0.002
FV_Atm(1)%flagstruct%ke_bg = 0.0
! Rayleigh & Divergence Damping
if (index(FV3_CONFIG,"HWT") > 0) then
FV_Atm(1)%flagstruct%fv_sg_adj = -1
FV_Atm(1)%flagstruct%n_zfilter = -1
FV_Atm(1)%flagstruct%do_sat_adj = .false. ! only valid when nwat >= 6
FV_Atm(1)%flagstruct%dz_min = 6.0
FV_Atm(1)%flagstruct%RF_fast = .true.
FV_Atm(1)%flagstruct%tau = 2.0
FV_Atm(1)%flagstruct%rf_cutoff = 0.35e2
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 1440) then
! 6th order default damping options
FV_Atm(1)%flagstruct%nord = 3
FV_Atm(1)%flagstruct%dddmp = 0.2
FV_Atm(1)%flagstruct%d4_bg = 0.12
FV_Atm(1)%flagstruct%d2_bg = 0.0
FV_Atm(1)%flagstruct%d_ext = 0.0
else
! 4th order default damping options
FV_Atm(1)%flagstruct%nord = 2
FV_Atm(1)%flagstruct%dddmp = 0.2
FV_Atm(1)%flagstruct%d4_bg = 0.12
FV_Atm(1)%flagstruct%d2_bg = 0.0
FV_Atm(1)%flagstruct%d_ext = 0.0
endif
! Sponge damping and TE conservation
FV_Atm(1)%flagstruct%n_sponge = 0
FV_Atm(1)%flagstruct%d2_bg_k1 = 0.20
FV_Atm(1)%flagstruct%d2_bg_k2 = 0.15
FV_Atm(1)%flagstruct%consv_te = 1.0
else
FV_Atm(1)%flagstruct%fv_sg_adj = DT
FV_Atm(1)%flagstruct%RF_fast = .false.
FV_Atm(1)%flagstruct%tau = 0.0
FV_Atm(1)%flagstruct%rf_cutoff = 0.35e2
! 4th order default damping options
FV_Atm(1)%flagstruct%nord = 2
FV_Atm(1)%flagstruct%dddmp = 0.2
FV_Atm(1)%flagstruct%d4_bg = 0.12
FV_Atm(1)%flagstruct%d2_bg = 0.0
FV_Atm(1)%flagstruct%d_ext = 0.0
FV_Atm(1)%flagstruct%d2_bg_k1 = 0.20
FV_Atm(1)%flagstruct%d2_bg_k2 = 0.06
FV_Atm(1)%flagstruct%consv_te = 1.0
endif
! Some default time-splitting options
FV_Atm(1)%flagstruct%n_split = 0
FV_Atm(1)%flagstruct%k_split = 1
! default NonHydrostatic settings (irrelavent to Hydrostatic)
FV_Atm(1)%flagstruct%beta = 0.0
FV_Atm(1)%flagstruct%a_imp = 1.0
FV_Atm(1)%flagstruct%p_fac = 0.05
! Cubed-Sphere Global Resolution Specific adjustments
if (FV_Atm(1)%flagstruct%ntiles == 6) then
! Cubed-sphere grid resolution and DT dependence
! based on ideal remapping DT
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 12) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/1800.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 24) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/1800.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 48) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/1800.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 90) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 900.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 180) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 600.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 360) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 300.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 720) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 150.0 )
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 150.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 1440) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 75.0 )
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 75.0 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 2880) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 37.5 )
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 37.5 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 4320) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 28.125)
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 18.75 )
endif
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 5760) then
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 18.75)
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 18.75)
endif
FV_Atm(1)%flagstruct%k_split = MAX(FV_Atm(1)%flagstruct%k_split,1)
! Monotonic Hydrostatic defaults
FV_Atm(1)%flagstruct%hydrostatic = .false.
FV_Atm(1)%flagstruct%make_nh = .false.
! This is the best/fastest option for tracers
FV_Atm(1)%flagstruct%hord_tr = 8
if (index(FV3_CONFIG,"MONOTONIC") > 0) then
! Monotonic advection schemes
FV_Atm(1)%flagstruct%hord_mt = 10
FV_Atm(1)%flagstruct%hord_vt = 10
FV_Atm(1)%flagstruct%hord_tm = 10
FV_Atm(1)%flagstruct%hord_dp = 10
! disable vorticity damping
FV_Atm(1)%flagstruct%vtdm4 = 0.0
FV_Atm(1)%flagstruct%do_vort_damp = .false.
FV_Atm(1)%flagstruct%d_con = 0.
else
! Non-Monotonic advection
if (index(FV3_CONFIG,"HWT") > 0) then
FV_Atm(1)%flagstruct%hord_mt = 6
FV_Atm(1)%flagstruct%hord_vt = 6
FV_Atm(1)%flagstruct%hord_tm = 6
FV_Atm(1)%flagstruct%hord_dp = -6
else
FV_Atm(1)%flagstruct%hord_mt = 5
FV_Atm(1)%flagstruct%hord_vt = 6
FV_Atm(1)%flagstruct%hord_tm = 6
FV_Atm(1)%flagstruct%hord_dp = -6
endif
! Must now include explicit vorticity damping
FV_Atm(1)%flagstruct%d_con = 1.
FV_Atm(1)%flagstruct%do_vort_damp = .true.
FV_Atm(1)%flagstruct%vtdm4 = 0.01
! continue to adjust vorticity damping with
! increasing resolution
if (FV_Atm(1)%flagstruct%npx*(FV_Atm(1)%flagstruct%stretch_fac) >= 180) then
FV_Atm(1)%flagstruct%vtdm4 = 0.01
endif
if (FV_Atm(1)%flagstruct%npx*(FV_Atm(1)%flagstruct%stretch_fac) >= 360) then
FV_Atm(1)%flagstruct%vtdm4 = 0.02
endif
if (FV_Atm(1)%flagstruct%npx*(FV_Atm(1)%flagstruct%stretch_fac) >= 720) then
FV_Atm(1)%flagstruct%vtdm4 = 0.03
endif
if (FV_Atm(1)%flagstruct%npx*(FV_Atm(1)%flagstruct%stretch_fac) >= 1440) then
FV_Atm(1)%flagstruct%vtdm4 = 0.04
endif
if (FV_Atm(1)%flagstruct%npx*(FV_Atm(1)%flagstruct%stretch_fac) >= 2880) then
FV_Atm(1)%flagstruct%vtdm4 = 0.05
endif
if (FV_Atm(1)%flagstruct%npx*(FV_Atm(1)%flagstruct%stretch_fac) >= 5760) then
FV_Atm(1)%flagstruct%vtdm4 = 0.06
endif
endif
if (index(FV3_CONFIG,"MERRA-2") > 0) then
! Override FV3 defaults with MERRA-2 hydrostatic configuration
FV_Atm(1)%flagstruct%hydrostatic = .true.
! disable subgrid dz adjustment
FV_Atm(1)%flagstruct%fv_sg_adj = -1
! Monotonic advection schemes
FV_Atm(1)%flagstruct%hord_mt = 10
FV_Atm(1)%flagstruct%hord_vt = 10
FV_Atm(1)%flagstruct%hord_tm = 10
FV_Atm(1)%flagstruct%hord_dp = 10
! 2nd order damping
FV_Atm(1)%flagstruct%nord = 0
FV_Atm(1)%flagstruct%dddmp = 0.2
FV_Atm(1)%flagstruct%d4_bg = 0.0
FV_Atm(1)%flagstruct%d2_bg = 0.0075
FV_Atm(1)%flagstruct%d_ext = 0.02
! disable vorticity damping
FV_Atm(1)%flagstruct%vtdm4 = 0.0
FV_Atm(1)%flagstruct%do_vort_damp = .false.
FV_Atm(1)%flagstruct%d_con = 0.
! Use GMAO cubic remapping for TE
FV_Atm(1)%flagstruct%remap_option = 2 ! Remap TE in LogP
FV_Atm(1)%flagstruct%gmao_remap = 3 ! GMAO Cubic
! do TE conservation just in the GMAO cubic remap
FV_Atm(1)%flagstruct%consv_te = 0.0
endif
endif
!! Start up FV
call MAPL_TimerOn(MAPL,"--FV_INIT")
call fv_init2(FV_Atm, DT, grids_on_this_pe, p_split)
call MAPL_TimerOff(MAPL,"--FV_INIT")
call MAPL_MemUtilsWrite(VM, 'FV_StateMod: FV_INIT', RC=STATUS )
VERIFY_(STATUS)
!! Force compatibility of gmao_remap and n_zfilter
if (FV_Atm(1)%flagstruct%gmao_remap > 0) then
FV_Atm(1)%flagstruct%n_zfilter = 0
endif
!! Setup GFDL microphysics module
if (FV_Atm(1)%flagstruct%do_sat_adj) then
call gfdl_cloud_microphys_init()
endif
_ASSERT(DT > 0.0, 'DT must be greater than zero')
call WRITE_PARALLEL("Dynamics PE Layout ")
call WRITE_PARALLEL(FV_Atm(1)%layout(1) ,format='("NPES_X : ",( I3))')
call WRITE_PARALLEL(FV_Atm(1)%layout(2) ,format='("NPES_Y : ",( I3))')
call WRITE_PARALLEL((/FV_Atm(1)%flagstruct%npx,FV_Atm(1)%flagstruct%npy,FV_Atm(1)%flagstruct%npz/) , &
format='("Resolution of dynamics restart =",3I5)' )
call WRITE_PARALLEL((/FV_Atm(1)%flagstruct%stretch_fac/) , &
format='(" stretch_fac =",F10.4)' )
FV_HYDROSTATIC = FV_Atm(1)%flagstruct%hydrostatic
DEBUG = FV_Atm(1)%flagstruct%fv_debug
prt_minmax = FV_Atm(1)%flagstruct%fv_debug
call MAPL_MemUtilsWrite(VM, trim(Iam), RC=STATUS )
VERIFY_(STATUS)
#ifdef RUN_GTFV3
call MAPL_GetResource(MAPL, run_gtfv3, 'RUN_GTFV3:', default=0, RC=STATUS)
VERIFY_(STATUS)
#endif
RETURN_(ESMF_SUCCESS)
contains
end subroutine FV_Setup
subroutine FV_InitState (STATE, CLOCK, INTERNAL, IMPORT, GC, RC)
use test_cases_mod, only : test_case, init_double_periodic
type (T_FVDYCORE_STATE),pointer :: STATE
type (ESMF_Clock), target, intent(INOUT) :: CLOCK
type (ESMF_GridComp) , intent(INOUT) :: GC
type (ESMF_State) , intent(INOUT) :: INTERNAL
type (ESMF_State) , intent(INOUT) :: IMPORT
integer, optional , intent(OUT ) :: RC
! Local variables
! Pointers to geography info in the MAPL MetaComp
real(REAL4), pointer :: LATS (:,:)
real(REAL4), pointer :: LONS (:,:)
type (ESMF_TimeInterval) :: Time2Run
type (ESMF_VM) :: VM
type (T_FVDYCORE_GRID) , pointer :: GRID
integer :: status
real(REAL8) :: DT
integer :: is ,ie , js ,je ! Local dims
integer :: isc,iec, jsc,jec ! Local dims
integer :: isd,ied, jsd,jed ! Local dims
integer :: k ! Vertical loop index
integer :: ng
integer :: ndt
integer :: i,j
type (ESMF_Time) :: fv_time
integer :: days, seconds
character(len=ESMF_MAXSTR) :: IAm='FV:FV_InitState'
real(REAL8), pointer :: AK(:) => NULL()
real(REAL8), pointer :: BK(:) => NULL()
real(REAL8), dimension(:,:,:), pointer :: U => NULL()
real(REAL8), dimension(:,:,:), pointer :: V => NULL()
real(REAL8), dimension(:,:,:), pointer :: PT => NULL()
real(REAL8), dimension(:,:,:), pointer :: PE => NULL()
real(REAL8), dimension(:,:,:), pointer :: PKZ => NULL()
real(REAL8), dimension(:,:,:), pointer :: DZ => NULL()
real(REAL8), dimension(:,:,:), pointer :: W => NULL()
type (MAPL_MetaComp), pointer :: mapl => NULL()
real(REAL8), ALLOCATABLE :: UA(:,:,:)
real(REAL8), ALLOCATABLE :: VA(:,:,:)
real(REAL8), ALLOCATABLE :: UD(:,:,:)
real(REAL8), ALLOCATABLE :: VD(:,:,:)
logical :: hybrid
integer :: tile_in
integer :: gid, masterproc
#ifdef RUN_GTFV3
logical :: halting_mode(5)
integer :: comm
#endif
! BEGIN
! Retrieve the pointer to the state
! ---------------------------------
call MAPL_GetObjectFromGC (GC, MAPL, RC=STATUS )
VERIFY_(STATUS)
call MAPL_GetResource( MAPL, ndt, 'RUN_DT:', default=0, RC=STATUS )
VERIFY_(STATUS)
DT = ndt
STATE%GRID%FVgenstate => MAPL
GRID => STATE%GRID ! For convenience
STATE%DOTIME= .TRUE.
STATE%DT = DT
STATE%KSPLIT = FV_Atm(1)%flagstruct%K_SPLIT
STATE%NSPLIT = FV_Atm(1)%flagstruct%N_SPLIT
GRID%NG = 3 ; ng = 3
GRID%NPX = FV_Atm(1)%flagstruct%NPX-1
GRID%NPY = FV_Atm(1)%flagstruct%NPY-1
GRID%NPZ = FV_Atm(1)%flagstruct%NPZ
GRID%NPZ_P1 = FV_Atm(1)%flagstruct%NPZ+1
GRID%NTILES = 6
GRID%NQ = MAX(1,FV_Atm(1)%flagstruct%ncnst)
masterproc = mpp_root_pe()
gid = mpp_pe()
call ESMF_GridCompGet(gc, grid=GRID%GRID, VM=VM, rc=STATUS)
VERIFY_(STATUS)
call WRITE_PARALLEL(' ')
call WRITE_PARALLEL(STATE%DT,format='("Dynamics time step : ",(F10.4))')
call WRITE_PARALLEL(' ')
! Get pointers to internal state vars
call MAPL_GetPointer(internal, ak, "AK",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, bk, "BK",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, u, "U",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, v, "V",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, pt, "PT",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, pe, "PE",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, pkz, "PKZ",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, dz, "DZ",rc=status)
VERIFY_(STATUS)
call MAPL_GetPointer(internal, w, "W",rc=status)
VERIFY_(STATUS)
call CREATE_VARS ( FV_Atm(1)%bd%isc, FV_Atm(1)%bd%iec, FV_Atm(1)%bd%jsc, FV_Atm(1)%bd%jec, &
1, FV_Atm(1)%flagstruct%npz, FV_Atm(1)%flagstruct%npz+1, &
U, V, PT, PE, PKZ, DZ, W, &
STATE%VARS )
call MAPL_MemUtilsWrite(VM, 'FV_StateMod: CREATE_VARS', RC=STATUS )
VERIFY_(STATUS)
GRID%IS = FV_Atm(1)%bd%isc
GRID%IE = FV_Atm(1)%bd%iec
GRID%JS = FV_Atm(1)%bd%jsc
GRID%JE = FV_Atm(1)%bd%jec
GRID%isd = FV_Atm(1)%bd%isd
GRID%ied = FV_Atm(1)%bd%ied
GRID%jsd = FV_Atm(1)%bd%jsd
GRID%jed = FV_Atm(1)%bd%jed
if(.not.associated(GRID%AK)) allocate(GRID%AK(size(ak)))
if(.not.associated(GRID%BK)) allocate(GRID%BK(size(bk)))
GRID%AK = ak
GRID%BK = bk
FV_Atm(1)%ks = count(bk == 0.0) - 1
_ASSERT(FV_Atm(1)%ks <= FV_Atm(1)%flagstruct%NPZ+1,'ks must be smaller than NPZ+1')
call WRITE_PARALLEL(FV_Atm(1)%ks, format='("Number of true pressure levels =", I5)' )
! Local Copy of dimensions
IS = FV_Atm(1)%bd%isc
IE = FV_Atm(1)%bd%iec
JS = FV_Atm(1)%bd%jsc
JE = FV_Atm(1)%bd%jec
ISC = FV_Atm(1)%bd%isc
IEC = FV_Atm(1)%bd%iec
JSC = FV_Atm(1)%bd%jsc
JEC = FV_Atm(1)%bd%jec
ISD = FV_Atm(1)%bd%isd
IED = FV_Atm(1)%bd%ied
JSD = FV_Atm(1)%bd%jsd
JED = FV_Atm(1)%bd%jed
allocate( GRID%DXC(IS:IE,JS:JE) )
GRID%DXC = fv_atm(1)%gridstruct%dxc(IS:IE,JS:JE)
allocate( GRID%DYC(IS:IE,JS:JE) )
GRID%DYC = fv_atm(1)%gridstruct%dyc(IS:IE,JS:JE)
allocate( GRID%AREA(IS:IE,JS:JE) )
GRID%AREA = fv_atm(1)%gridstruct%area(IS:IE,JS:JE)
GRID%GLOBALAREA = fv_atm(1)%gridstruct%globalarea
if (FV_Atm(1)%flagstruct%grid_type == 4) then
fv_atm(1)%gridstruct%fC(:,:) = 2.*MAPL_OMEGA*sin(FV_Atm(1)%flagstruct%deglat/180.*MAPL_PI_R8)
fv_atm(1)%gridstruct%f0(:,:) = 2.*MAPL_OMEGA*sin(FV_Atm(1)%flagstruct%deglat/180.*MAPL_PI_R8)
else
if (GRID%f_coriolis_angle == -999) then
fv_atm(1)%gridstruct%fC(:,:) = 0.0
fv_atm(1)%gridstruct%f0(:,:) = 0.0
else
do j=jsd,jed+1
do i=isd,ied+1
fv_atm(1)%gridstruct%fC(i,j) = 2.*MAPL_OMEGA*( -COS(FV_Atm(1)%gridstruct%grid(i,j,1))*COS(FV_Atm(1)%gridstruct%grid(i,j,2))*SIN(GRID%f_coriolis_angle) + &
SIN(FV_Atm(1)%gridstruct%grid(i,j,2))*COS(GRID%f_coriolis_angle) )
enddo
enddo
do j=jsd,jed
do i=isd,ied
fv_atm(1)%gridstruct%f0(i,j) = 2.*MAPL_OMEGA*( -COS(FV_Atm(1)%gridstruct%agrid(i,j,1))*COS(FV_Atm(1)%gridstruct%agrid(i,j,2))*SIN(GRID%f_coriolis_angle) + &
SIN(FV_Atm(1)%gridstruct%agrid(i,j,2))*COS(GRID%f_coriolis_angle) )
enddo
enddo
endif
endif
! Check coordinate information from MAPL_MetaComp
!--------------------------------------------
call MAPL_Get(MAPL, &
LATS = LATS, & ! These are in radians
LONS = LONS, & ! These are in radians
INTERNAL_ESMF_STATE=INTERNAL, &
RC=STATUS )
VERIFY_(STATUS)
STATE%CLOCK => CLOCK
call ESMF_TimeIntervalSet(Time2Run, &
S=nint(STATE%DT), rc=status)
VERIFY_(status)
STATE%ALARMS(TIME_TO_RUN) = ESMF_AlarmCreate(name="Time2Run", clock=clock, &
ringInterval=Time2Run, &
Enabled=.TRUE., rc=status) ; VERIFY_(status)
call ESMF_AlarmEnable(STATE%ALARMS(TIME_TO_RUN), rc=status); VERIFY_(status)
call ESMF_AlarmRingerOn(STATE%ALARMS(TIME_TO_RUN), rc=status); VERIFY_(status)
call WRITE_PARALLEL(' ')
call WRITE_PARALLEL(STATE%DT, &
format='("INITIALIZED ALARM: DYN_TIME_TO_RUN EVERY ",F9.1," secs.")')
! Clear wall clock time clocks and global budgets
STATE%RUN_TIMES = 0
STATE%NUM_CALLS = 0
call ESMF_ClockGet( CLOCK, currTime=fv_time, rc=STATUS )
VERIFY_(STATUS)
call ESMF_TimeGet( fv_time, dayOfYear=days, s=seconds, rc=STATUS )
VERIFY_(STATUS)
! ---------------------------------------
! Create alarm for dry mass fix reporting
! ---------------------------------------
! Set an interval for printing. Currently hard-coded to
! six hours, but could be a MAPL_GetResource value
call ESMF_TimeIntervalSet(MassAlarmInt, H=6, rc=STATUS)
VERIFY_(STATUS)
! Create the alarm with the above interval
MASSALARM = ESMF_AlarmCreate(CLOCK = CLOCK, &
name = trim(Iam)//"_MassAlarm", &