Skip to content

Commit 870df85

Browse files
committed
Updates for mixed-precision FMS
1 parent 345231b commit 870df85

File tree

5 files changed

+35
-26
lines changed

5 files changed

+35
-26
lines changed

CMakeLists.txt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,17 @@ if (BUILD_GEOS_GTFV3_INTERFACE)
111111
SRCS ${srcs}
112112
SUBCOMPONENTS fvdycore
113113
DEPENDENCIES ${dependencies}
114-
DEPENDENCIES ${GFDL}
114+
DEPENDENCIES FMS::fms
115115
DEPENDENCIES geos_gtfv3_interface_py) # Make the main library depend on the Python library
116116
else ()
117117
esma_add_library (${this}
118118
SRCS ${srcs}
119119
SUBCOMPONENTS fvdycore
120120
DEPENDENCIES ${dependencies}
121-
DEPENDENCIES ${GFDL})
121+
DEPENDENCIES FMS::fms)
122122
endif ()
123123

124-
if (FV_PRECISION STREQUAL R4)
125-
set (GFDL FMS::fms_r4)
126-
elseif (FV_PRECISION STREQUAL R4R8) # FV is R4 but FMS is R8
127-
get_target_property (extra_incs FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
128-
target_include_directories(${this} PRIVATE $<BUILD_INTERFACE:${extra_incs}>)
129-
set (GFDL FMS::fms_r8)
130-
elseif (FV_PRECISION STREQUAL R8)
131-
set (GFDL FMS::fms_r8)
124+
if (FV_PRECISION STREQUAL R8)
132125
string(REPLACE " " ";" tmp ${FREAL8})
133126
foreach(flag ${tmp})
134127
target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${flag}>)
@@ -137,8 +130,6 @@ endif ()
137130

138131
if (FV_PRECISION MATCHES R4)
139132
target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4)
140-
elseif (FV_PRECISION MATCHES R4R8) # FV is R4 but FMS is R8
141-
target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4)
142133
endif ()
143134

144135
message(STATUS "Building FV as ${FV_PRECISION}")

CreateTopography.F90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
PROGRAM CreateTopography
22

33
use ESMF
4-
use constants_mod, only: pi, grav
4+
#if defined (SINGLE_FV)
5+
use constantsr4_mod, only: pi, grav
6+
#else
7+
use constants_mod, only: pi, grav
8+
#endif
59

610
! Shared Utilities
711
use fms_mod, only: fms_init, fms_end

FV_StateMod.F90

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,42 +604,42 @@ subroutine FV_Setup(GC,LAYOUT_FILE, RC)
604604
FV_Atm(1)%flagstruct%RF_fast = .false.
605605
endif
606606
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 1120) then
607-
FV_Atm(1)%flagstruct%hydrostatic = .false.
607+
FV_Atm(1)%flagstruct%hydrostatic = .false.
608608
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 60.0 )
609609
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 90.0 )
610610
FV_Atm(1)%flagstruct%tau = 2.5
611611
FV_Atm(1)%flagstruct%RF_fast = .false.
612612
endif
613613
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 1440) then
614-
FV_Atm(1)%flagstruct%hydrostatic = .false.
614+
FV_Atm(1)%flagstruct%hydrostatic = .false.
615615
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 37.5 )
616616
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 60.0 )
617617
FV_Atm(1)%flagstruct%tau = 2.0
618618
FV_Atm(1)%flagstruct%RF_fast = .true.
619619
endif
620620
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 2880) then
621-
FV_Atm(1)%flagstruct%hydrostatic = .false.
621+
FV_Atm(1)%flagstruct%hydrostatic = .false.
622622
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 18.75 )
623623
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 30.0 )
624624
FV_Atm(1)%flagstruct%tau = 1.5
625625
FV_Atm(1)%flagstruct%RF_fast = .true.
626626
endif
627627
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 4320) then
628-
FV_Atm(1)%flagstruct%hydrostatic = .false.
628+
FV_Atm(1)%flagstruct%hydrostatic = .false.
629629
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 15.0 )
630630
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 15.0 )
631631
FV_Atm(1)%flagstruct%tau = 1.0
632632
FV_Atm(1)%flagstruct%RF_fast = .true.
633633
endif
634634
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 5760) then
635-
FV_Atm(1)%flagstruct%hydrostatic = .false.
635+
FV_Atm(1)%flagstruct%hydrostatic = .false.
636636
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 9.375 )
637637
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 7.5 )
638638
FV_Atm(1)%flagstruct%tau = 1.0
639639
FV_Atm(1)%flagstruct%RF_fast = .true.
640640
endif
641641
if (FV_Atm(1)%flagstruct%npx*CEILING(FV_Atm(1)%flagstruct%stretch_fac) >= 10800) then
642-
FV_Atm(1)%flagstruct%hydrostatic = .false.
642+
FV_Atm(1)%flagstruct%hydrostatic = .false.
643643
FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 4.6875 )
644644
if (FV_Atm(1)%flagstruct%stretch_fac > 1) FV_Atm(1)%flagstruct%k_split = CEILING(DT/ 3.25 )
645645
FV_Atm(1)%flagstruct%tau = 1.0
@@ -668,7 +668,7 @@ subroutine FV_Setup(GC,LAYOUT_FILE, RC)
668668
FV_Atm(1)%flagstruct%a_imp = 1.0
669669
! dz_min is a NH delta-z limiter increasing may improve stability
670670
FV_Atm(1)%flagstruct%dz_min = 2.0
671-
! p_fac is a NH pressure fraction limiter near model top (0:0.25)
671+
! p_fac is a NH pressure fraction limiter near model top (0:0.25)
672672
FV_Atm(1)%flagstruct%p_fac = 0.05
673673
! General defaults
674674
FV_Atm(1)%flagstruct%make_nh = .false.
@@ -4037,7 +4037,11 @@ subroutine fv_getDivergence(uc, vc, divg)
40374037
end subroutine fv_getDivergence
40384038

40394039
subroutine fv_getUpdraftHelicity(uh25, uh03, srh01, srh03, srh25)
4040+
#if defined (SINGLE_FV)
4041+
use constantsr4_mod, only: fms_grav=>grav
4042+
#else
40404043
use constants_mod, only: fms_grav=>grav
4044+
#endif
40414045
! made this REAL4
40424046
real(REAL4), intent(OUT) :: uh25(:,:)
40434047
real(REAL4), intent(OUT) :: uh03(:,:)

interp_restarts_bin.F90

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ program interp_restarts
2121
use fv_regridding_utils
2222
use fv_grid_utils_mod, only: ptop_min
2323
use init_hydro_mod, only: p_var
24-
use constants_mod, only: pi, omega, grav, kappa, rdgas, rvgas, cp_air
24+
#if defined (SINGLE_FV)
25+
use constantsr4_mod, &
26+
#else
27+
use constants_mod, &
28+
#endif
29+
only: pi, omega, grav, kappa, rdgas, rvgas, cp_air
2530
use fv_diagnostics_mod,only: prt_maxmin
2631
! use fv_eta_mod, only: set_eta
2732
use m_set_eta, only: set_eta

rs_scale.F90

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ program main
108108

109109
open(unit=10, file=trim(dynrst), form='unformatted')
110110
open(unit=20, file=trim(mstrst), form='unformatted')
111-
111+
112112
! **********************************************************************
113113
! **** Read dycore internal Restart ****
114114
! **********************************************************************
@@ -295,7 +295,7 @@ program main
295295
do while ( dabs( pdrydif_ave ).gt.eps .and. iter.le.20 )
296296

297297
! --------------------------------------
298-
298+
299299
do n=1,5
300300
qsum = 0.0_8
301301
do L=1,lm
@@ -506,7 +506,7 @@ program main
506506
! check if we have ncpl and ncpi
507507
if (nVarsMoist == 9) then
508508
allocate( dum4(im,jm) )
509-
509+
510510
do L=1,lm
511511
call MAPL_VarRead(InMoist,"NCPL",dum4,lev=l)
512512
call MAPL_VarWrite(OutMoist,"NCPL",dum4,lev=l)
@@ -576,7 +576,12 @@ program main
576576

577577
subroutine Get_Areas ( area,im,jm )
578578
use ESMF
579-
use constants_mod, only: cnst_radius=>radius
579+
#if defined (SINGLE_FV)
580+
use constantsr4_mod, &
581+
#else
582+
use constants_mod, &
583+
#endif
584+
only: cnst_radius=>radius
580585
use fv_grid_utils_mod, only: get_area
581586
use fv_arrays_mod, only: R_GRID
582587
implicit none
@@ -638,7 +643,7 @@ end subroutine AppCSEdgeCreateF
638643
else
639644
! Cube Area
640645
! ---------
641-
allocate(grid_lons(im+1,im+1,6))
646+
allocate(grid_lons(im+1,im+1,6))
642647
allocate(grid_lats(im+1,im+1,6))
643648
call AppCSEdgeCreateF(im,grid_lons,grid_lats)
644649
do k=1,6

0 commit comments

Comments
 (0)