Skip to content

Commit

Permalink
Set correct kind of coordinate arrays when constructing fcst grids
Browse files Browse the repository at this point in the history
  • Loading branch information
DusanJovic-NOAA committed May 26, 2022
1 parent ca36376 commit 058e68f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
branch = main
[submodule "ccpp/physics"]
path = ccpp/physics
url = https://github.com/SamuelTrahanNOAA/ccpp-physics
branch = sing_prec_from_main
url = https://github.com/DusanJovic-NOAA/ccpp-physics
branch = single_prec
[submodule "upp"]
path = upp
url = https://github.com/NOAA-EMC/UPP
Expand Down
23 changes: 21 additions & 2 deletions ccpp/data/GFS_typedefs.F90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GFS_typedefs

use machine, only: kind_phys, kind_dbl_prec
use machine, only: kind_phys, kind_dbl_prec, kind_sngl_prec
use physcons, only: con_cp, con_fvirt, con_g, &
con_hvap, con_hfus, con_pi, con_rd, con_rv, &
con_t0c, con_cvap, con_cliq, con_eps, con_epsq, &
Expand Down Expand Up @@ -2736,6 +2736,8 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
logical :: exists
real(kind=kind_phys) :: tem
real(kind=kind_phys) :: rinc(5)
real(kind=kind_sngl_prec) :: rinc4(5)
real(kind=kind_dbl_prec) :: rinc8(5)
real(kind=kind_phys) :: wrk(1)
real(kind=kind_phys), parameter :: con_hr = 3600.

Expand Down Expand Up @@ -3217,7 +3219,11 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
! max and min lon and lat for critical relative humidity
integer :: max_lon=5000, max_lat=2000, min_lon=192, min_lat=94
real(kind=kind_phys) :: rhcmax = 0.9999999 !< max critical rel. hum.
#ifdef SINGLE_PREC
real(kind=kind_phys) :: huge = 9.9692099683868690E30 ! NetCDF float FillValue
#else
real(kind=kind_phys) :: huge = 9.9692099683868690E36 ! NetCDF float FillValue
#endif


!--- stochastic physics control parameters
Expand Down Expand Up @@ -3245,6 +3251,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &

real(kind=kind_phys) :: radar_tten_limits(2) = (/ limit_unspecified, limit_unspecified /)
integer :: itime
integer :: w3kindreal,w3kindint

!--- END NAMELIST VARIABLES

Expand Down Expand Up @@ -4631,7 +4638,19 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
Model%cdec = -9999.
Model%clstp = -9999
rinc(1:5) = 0
call w3difdat(jdat,idat,4,rinc)
call w3kind(w3kindreal,w3kindint)
if (w3kindreal == 8) then
rinc8(1:5) = 0
call w3difdat(jdat,idat,4,rinc8)
rinc = rinc8
else if (w3kindreal == 4) then
rinc4(1:5) = 0
call w3difdat(jdat,idat,4,rinc4)
rinc = rinc4
else
write(0,*)' FATAL ERROR: Invalid w3kindreal'
call abort
endif
Model%phour = rinc(4)/con_hr
Model%fhour = (rinc(4) + Model%dtp)/con_hr
Model%zhour = mod(Model%phour,Model%fhzero)
Expand Down
11 changes: 11 additions & 0 deletions module_fcst_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module module_fcst_grid_comp
atmos_model_exchange_phase_2, &
addLsmask2grid, atmos_model_get_nth_domain_info

use GFS_typedefs, only: kind_phys, kind_sngl_prec

use constants_mod, only: constants_init
use fms_mod, only: error_mesg, fms_init, fms_end, &
write_version_number, uppercase
Expand Down Expand Up @@ -161,6 +163,7 @@ subroutine SetServicesNest(nest, rc)
integer,dimension(2,6):: decomptile !define delayout for the 6 cubed-sphere tiles
integer,dimension(2) :: regdecomp !define delayout for the nest grid
type(ESMF_Decomp_Flag):: decompflagPTile(2,6)
type(ESMF_TypeKind_Flag) :: grid_typekind
character(3) :: myGridStr
type(ESMF_DistGrid) :: distgrid
type(ESMF_Array) :: array
Expand Down Expand Up @@ -188,6 +191,12 @@ subroutine SetServicesNest(nest, rc)
call ESMF_InfoGet(info, key="layout", values=layout, rc=rc); ESMF_ERR_ABORT(rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

if (kind_phys == kind_sngl_prec) then
grid_typekind = ESMF_TYPEKIND_R4
else
grid_typekind = ESMF_TYPEKIND_R8
endif

if (trim(name)=="global") then
! global domain
call ESMF_InfoGet(info, key="tilesize", value=tilesize, rc=rc); ESMF_ERR_ABORT(rc)
Expand All @@ -200,6 +209,7 @@ subroutine SetServicesNest(nest, rc)
enddo
grid = ESMF_GridCreateCubedSphere(tileSize=tilesize, &
coordSys=ESMF_COORDSYS_SPH_RAD, &
coordTypeKind=grid_typekind, &
regDecompPTile=decomptile, &
decompflagPTile=decompflagPTile, &
name="fcst_grid", rc=rc)
Expand All @@ -215,6 +225,7 @@ subroutine SetServicesNest(nest, rc)
maxIndex=(/nx,ny/), &
gridAlign=(/-1,-1/), &
coordSys=ESMF_COORDSYS_SPH_RAD, &
coordTypeKind=grid_typekind, &
decompflag=(/ESMF_DECOMP_SYMMEDGEMAX,ESMF_DECOMP_SYMMEDGEMAX/), &
name="fcst_grid", &
indexflag=ESMF_INDEX_DELOCAL, &
Expand Down

0 comments on commit 058e68f

Please sign in to comment.