Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve memory footprint in chgres_cube #766

Merged
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9dc1a64
Replace 4-dimensional wind fields with 3-dimensional
GeorgeGayno-NOAA Feb 25, 2022
60ab187
Comment out all 4-d wind fields.
GeorgeGayno-NOAA Feb 28, 2022
f584c91
Fix bug.
GeorgeGayno-NOAA Feb 28, 2022
2f15adf
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Nov 7, 2022
e121d0d
Add variable declaration.
GeorgeGayno-NOAA Nov 7, 2022
95f3bca
Fix some bugs from the last merge.
GeorgeGayno-NOAA Nov 9, 2022
dde77c1
Update to esmf v8.4 on wcoss2.
GeorgeGayno-NOAA Nov 10, 2022
57792e3
Updates to run gdas init utility at C3072 C128.
GeorgeGayno-NOAA Nov 10, 2022
707ff4f
Removed some unused code/variables from atmosphere.F90
GeorgeGayno-NOAA Nov 10, 2022
e268f8c
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Nov 29, 2022
cbd36c4
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Dec 7, 2022
9a86354
Update the WAM vertical interpolation to use xyz wind
GeorgeGayno-NOAA Dec 9, 2022
91710f6
Interpolate winds to west edge using a field bundle.
GeorgeGayno-NOAA Dec 9, 2022
cb4498d
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Dec 13, 2022
611f777
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Dec 19, 2022
f4a5224
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Jan 13, 2023
5c1daac
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Jan 27, 2023
0a7be3f
Remove old code. Fix comments.
GeorgeGayno-NOAA Jan 30, 2023
5e6bcf8
Upgrade to esmf v8.4 on Hera.
GeorgeGayno-NOAA Jan 30, 2023
d45f3c8
Give the two convert wind routines unique names.
GeorgeGayno-NOAA Jan 30, 2023
ec27420
Remove unused variables from atmosphere.F90
GeorgeGayno-NOAA Jan 31, 2023
e4b0d27
Update to esmf 8.4 on Jet.
GeorgeGayno-NOAA Jan 31, 2023
220ca48
Update to esmf v8.4 on orion.
GeorgeGayno-NOAA Jan 31, 2023
e12ca40
Update some print statements.
GeorgeGayno-NOAA Feb 1, 2023
6cd48c0
Update more print statements.
GeorgeGayno-NOAA Feb 2, 2023
2686c9f
Revert GDAS init configuration file to the version in
GeorgeGayno-NOAA Feb 2, 2023
0b391ed
Merge branch 'develop' into bug_fix/chgres_memory
GeorgeGayno-NOAA Feb 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modulefiles/build.hera.gnu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load(pathJoin("hpc-mpich", mpich_ver))
netcdf_ver=os.getenv("netcdf_ver") or "4.7.4"
load(pathJoin("netcdf", netcdf_ver))

esmf_ver=os.getenv("esmf_ver") or "8.2.1b04"
esmf_ver=os.getenv("esmf_ver") or "8.4.0b08"
load(pathJoin("esmf", esmf_ver))

bacio_ver=os.getenv("bacio_ver") or "2.4.1"
Expand Down
2 changes: 1 addition & 1 deletion modulefiles/build.hera.intel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ load(pathJoin("netcdf", netcdf_ver))
nccmp_ver=os.getenv("nccmp_ver") or "1.8.9.0"
load(pathJoin("nccmp", nccmp_ver))

esmf_ver=os.getenv("esmf_ver") or "8.2.1b04"
esmf_ver=os.getenv("esmf_ver") or "8.4.0b08"
load(pathJoin("esmf", esmf_ver))

nco_ver=os.getenv("nco_ver") or "4.9.1"
Expand Down
2 changes: 1 addition & 1 deletion modulefiles/build.jet.intel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load(pathJoin("netcdf", netcdf_ver))
nccmp_ver=os.getenv("nccmp_ver") or "1.8.9.0"
load(pathJoin("nccmp", nccmp_ver))

esmf_ver=os.getenv("esmf_ver") or "8.2.0"
esmf_ver=os.getenv("esmf_ver") or "8.4.0b08"
load(pathJoin("esmf", esmf_ver))

w3nco_ver=os.getenv("w3nco_ver") or "2.4.1"
Expand Down
2 changes: 1 addition & 1 deletion modulefiles/build.orion.intel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ load(pathJoin("netcdf", netcdf_ver))
nccmp_ver=os.getenv("nccmp_ver") or "1.8.9.0"
load(pathJoin("nccmp", nccmp_ver))

esmf_ver=os.getenv("esmf_ver") or "8.2.0"
esmf_ver=os.getenv("esmf_ver") or "8.4.0b08"
load(pathJoin("esmf", esmf_ver))

nco_ver=os.getenv("nco_ver") or "4.9.3"
Expand Down
2 changes: 1 addition & 1 deletion modulefiles/build.wcoss2.intel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ load(pathJoin("nco", nco_ver))
setenv("HPC_OPT","/apps/ops/para/libs")
prepend_path("MODULEPATH", "/apps/ops/para/libs/modulefiles/compiler/intel/19.1.3.304")
prepend_path("MODULEPATH", "/apps/ops/para/libs/modulefiles/mpi/intel/19.1.3.304/cray-mpich/8.1.7")
esmf_ver=os.getenv("esmf_ver") or "8.2.1b04"
esmf_ver=os.getenv("esmf_ver") or "8.4.0b08"
load(pathJoin("esmf", esmf_ver))

whatis("Description: UFS_UTILS build environment")
94 changes: 65 additions & 29 deletions sorc/chgres_cube.fd/atm_input_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ module atm_input_data

type(esmf_field), public :: u_input_grid !< u/v wind at grid
type(esmf_field), public :: v_input_grid !< box center
type(esmf_field), public :: wind_input_grid !< 3-component wind
type(esmf_field), public :: xwind_input_grid !< x-component wind
type(esmf_field), public :: ywind_input_grid !< y-component wind
type(esmf_field), public :: zwind_input_grid !< z-component wind
type(esmf_field), allocatable, public :: tracers_input_grid(:) !< tracers

integer, public :: lev_input !< number of atmospheric layers
Expand All @@ -64,7 +66,7 @@ module atm_input_data

public :: read_input_atm_data
public :: cleanup_input_atm_data
public :: convert_winds
public :: convert_winds_to_xyz

contains

Expand Down Expand Up @@ -150,15 +152,6 @@ subroutine init_atm_esmf_fields

print*,"- INITIALIZE ATMOSPHERIC ESMF FIELDS."

print*,"- CALL FieldCreate FOR INPUT GRID 3-D WIND."
wind_input_grid = ESMF_FieldCreate(input_grid, &
typekind=ESMF_TYPEKIND_R8, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
ungriddedLBound=(/1,1/), &
ungriddedUBound=(/lev_input,3/), rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)

print*,"- CALL FieldCreate FOR INPUT GRID SURFACE PRESSURE."
ps_input_grid = ESMF_FieldCreate(input_grid, &
typekind=ESMF_TYPEKIND_R8, &
Expand All @@ -173,6 +166,33 @@ subroutine init_atm_esmf_fields
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)

print*,"- CALL FieldCreate FOR INPUT GRID xwind."
xwind_input_grid = ESMF_FieldCreate(input_grid, &
typekind=ESMF_TYPEKIND_R8, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
ungriddedLBound=(/1/), &
ungriddedUBound=(/lev_input/), rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)

print*,"- CALL FieldCreate FOR INPUT GRID ywind."
ywind_input_grid = ESMF_FieldCreate(input_grid, &
typekind=ESMF_TYPEKIND_R8, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
ungriddedLBound=(/1/), &
ungriddedUBound=(/lev_input/), rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)

print*,"- CALL FieldCreate FOR INPUT GRID zwind."
zwind_input_grid = ESMF_FieldCreate(input_grid, &
typekind=ESMF_TYPEKIND_R8, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
ungriddedLBound=(/1/), &
ungriddedUBound=(/lev_input/), rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldCreate", rc)

print*,"- CALL FieldCreate FOR INPUT GRID TEMPERATURE."
temp_input_grid = ESMF_FieldCreate(input_grid, &
typekind=ESMF_TYPEKIND_R8, &
Expand Down Expand Up @@ -408,7 +428,7 @@ subroutine read_input_atm_gfs_sigio_file(localpet)
! Convert from 2-d to 3-d component winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Compute 3-d pressure from 'ak' and 'bk'.
Expand Down Expand Up @@ -668,7 +688,7 @@ subroutine read_input_atm_gfs_gaussian_nemsio_file(localpet)
! Convert from 2-d to 3-d component winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Compute 3-d pressure from 'ak' and 'bk'.
Expand Down Expand Up @@ -933,7 +953,7 @@ subroutine read_input_atm_gaussian_nemsio_file(localpet)
! Convert from 2-d to 3-d component winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Compute 3-d pressure. Mid-layer and surface pressure are computed
Expand Down Expand Up @@ -1217,7 +1237,7 @@ subroutine read_input_atm_restart_file(localpet)
! Convert from 2-d to 3-d cartesian winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Compute pressures
Expand Down Expand Up @@ -1587,7 +1607,7 @@ subroutine read_input_atm_gaussian_netcdf_file(localpet)
! Convert from 2-d to 3-d cartesian winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Compute pressure.
Expand Down Expand Up @@ -1893,7 +1913,7 @@ subroutine read_input_atm_tiled_history_file(localpet)
! Convert from 2-d to 3-d cartesian winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Compute pressure.
Expand Down Expand Up @@ -2848,7 +2868,7 @@ subroutine read_input_atm_grib2_file(localpet)
! Convert from 2-d to 3-d component winds.
!---------------------------------------------------------------------------

call convert_winds
call convert_winds_to_xyz

!---------------------------------------------------------------------------
! Convert dpdt to dzdt if needed
Expand Down Expand Up @@ -3083,25 +3103,39 @@ end subroutine read_winds
!> Convert winds from 2-d to 3-d components.
!!
!! @author George Gayno NCEP/EMC
subroutine convert_winds
subroutine convert_winds_to_xyz

implicit none

integer :: clb(4), cub(4)
integer :: clb(3), cub(3)
integer :: i, j, k, rc

real(esmf_kind_r8) :: latrad, lonrad
real(esmf_kind_r8), pointer :: windptr(:,:,:,:)
real(esmf_kind_r8), pointer :: xptr(:,:,:)
real(esmf_kind_r8), pointer :: yptr(:,:,:)
real(esmf_kind_r8), pointer :: zptr(:,:,:)
real(esmf_kind_r8), pointer :: uptr(:,:,:)
real(esmf_kind_r8), pointer :: vptr(:,:,:)
real(esmf_kind_r8), pointer :: latptr(:,:)
real(esmf_kind_r8), pointer :: lonptr(:,:)

print*,"- CALL FieldGet FOR 3-D WIND."
call ESMF_FieldGet(wind_input_grid, &
print*,"- CALL FieldGet FOR xwind."
call ESMF_FieldGet(xwind_input_grid, &
computationalLBound=clb, &
computationalUBound=cub, &
farrayPtr=windptr, rc=rc)
farrayPtr=xptr, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldGet", rc)

print*,"- CALL FieldGet FOR ywind."
call ESMF_FieldGet(ywind_input_grid, &
farrayPtr=yptr, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldGet", rc)

print*,"- CALL FieldGet FOR zwind."
call ESMF_FieldGet(zwind_input_grid, &
farrayPtr=zptr, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldGet", rc)

Expand Down Expand Up @@ -3134,17 +3168,17 @@ subroutine convert_winds
latrad = latptr(i,j) * acos(-1.) / 180.0
lonrad = lonptr(i,j) * acos(-1.) / 180.0
do k = clb(3), cub(3)
windptr(i,j,k,1) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
windptr(i,j,k,2) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
windptr(i,j,k,3) = vptr(i,j,k) * cos(latrad)
xptr(i,j,k) = uptr(i,j,k) * cos(lonrad) - vptr(i,j,k) * sin(latrad) * sin(lonrad)
yptr(i,j,k) = uptr(i,j,k) * sin(lonrad) + vptr(i,j,k) * sin(latrad) * cos(lonrad)
zptr(i,j,k) = vptr(i,j,k) * cos(latrad)
enddo
enddo
enddo

call ESMF_FieldDestroy(u_input_grid, rc=rc)
call ESMF_FieldDestroy(v_input_grid, rc=rc)

end subroutine convert_winds
end subroutine convert_winds_to_xyz

!> Compute grid rotation angle for non-latlon grids.
!!
Expand Down Expand Up @@ -3251,7 +3285,9 @@ subroutine cleanup_input_atm_data
call ESMF_FieldDestroy(pres_input_grid, rc=rc)
call ESMF_FieldDestroy(dzdt_input_grid, rc=rc)
call ESMF_FieldDestroy(temp_input_grid, rc=rc)
call ESMF_FieldDestroy(wind_input_grid, rc=rc)
call ESMF_FieldDestroy(xwind_input_grid, rc=rc)
call ESMF_FieldDestroy(ywind_input_grid, rc=rc)
call ESMF_FieldDestroy(zwind_input_grid, rc=rc)
call ESMF_FieldDestroy(ps_input_grid, rc=rc)

do n = 1, num_tracers_input
Expand Down
Loading