diff --git a/sorc/chgres_cube.fd/CMakeLists.txt b/sorc/chgres_cube.fd/CMakeLists.txt index c148cfb8c..7ed7d156d 100644 --- a/sorc/chgres_cube.fd/CMakeLists.txt +++ b/sorc/chgres_cube.fd/CMakeLists.txt @@ -5,12 +5,14 @@ set(lib_src atmosphere.F90 + atmosphere_target_data.F90 grib2_util.F90 input_data.F90 model_grid.F90 program_setup.F90 search_util.F90 static_data.F90 + surface_target_data.F90 surface.F90 thompson_mp_climo_data.F90 wam_climo_data.f90 diff --git a/sorc/chgres_cube.fd/atmosphere.F90 b/sorc/chgres_cube.fd/atmosphere.F90 index e00568a8a..12d117fd4 100644 --- a/sorc/chgres_cube.fd/atmosphere.F90 +++ b/sorc/chgres_cube.fd/atmosphere.F90 @@ -20,6 +20,15 @@ module atmosphere use esmf + use atmosphere_target_data, only : lev_target, levp1_target, nvcoord_target, & + vcoord_target, delp_target_grid, & + dzdt_target_grid, ps_target_grid, & + temp_target_grid, tracers_target_grid, & + u_s_target_grid, v_s_target_grid, & + u_w_target_grid, v_w_target_grid, & + zh_target_grid, qnwfa_climo_target_grid, & + qnifa_climo_target_grid + use input_data, only : lev_input, & levp1_input, & tracers_input_grid, & @@ -56,50 +65,32 @@ module atmosphere thomp_pres_climo_input_grid, & lev_thomp_mp_climo + use write_data, only : write_fv3_atm_header_netcdf, & + write_fv3_atm_bndy_data_netcdf, & + write_fv3_atm_data_netcdf + implicit none private - integer, public :: lev_target !< num vertical levels - integer, public :: levp1_target !< num levels plus 1 - integer, public :: nvcoord_target !< num vertical coordinate variables - - real(esmf_kind_r8), allocatable, public :: vcoord_target(:,:) !< vertical coordinate - - type(esmf_field), public :: delp_target_grid !< pressure thickness - type(esmf_field), public :: dzdt_target_grid !< vertical velocity type(esmf_field) :: dzdt_b4adj_target_grid !< vertical vel before vert adj - type(esmf_field), allocatable, public :: tracers_target_grid(:) !< tracers type(esmf_field), allocatable :: tracers_b4adj_target_grid(:) !< tracers before vert adj - type(esmf_field), public :: ps_target_grid !< surface pressure type(esmf_field) :: ps_b4adj_target_grid !< sfc pres before terrain adj type(esmf_field) :: pres_target_grid !< 3-d pressure type(esmf_field) :: pres_b4adj_target_grid !< 3-d pres before terrain adj - type(esmf_field), public :: temp_target_grid !< temperautre type(esmf_field) :: temp_b4adj_target_grid !< temp before vert adj type(esmf_field) :: terrain_interp_to_target_grid !< Input grid terrain interpolated to target grid. - type(esmf_field), public :: u_s_target_grid !< u-wind, 'south' edge - type(esmf_field), public :: v_s_target_grid !< v-wind, 'south' edge type(esmf_field) :: wind_target_grid !< 3-d wind, grid box center type(esmf_field) :: wind_b4adj_target_grid !< 3-d wind before vert adj type(esmf_field) :: wind_s_target_grid !< 3-d wind, 'south' edge - type(esmf_field), public :: u_w_target_grid !< u-wind, 'west' edge - type(esmf_field), public :: v_w_target_grid !< v-wind, 'west' edge type(esmf_field) :: wind_w_target_grid !< 3-d wind, 'west' edge - type(esmf_field), public :: zh_target_grid !< 3-d height ! Fields associated with thompson microphysics climatological tracers. type(esmf_field) :: qnifa_climo_b4adj_target_grid !< number concentration of ice !! friendly aerosols before vert adj - type(esmf_field), public :: qnifa_climo_target_grid !< number concentration of ice - !! friendly aerosols on target - !! horiz/vert grid. type(esmf_field) :: qnwfa_climo_b4adj_target_grid !< number concentration of water !! friendly aerosols before vert adj - type(esmf_field), public :: qnwfa_climo_target_grid !< number concentration of water - !! friendly aerosols on target - !! horiz/vert grid. type(esmf_field) :: thomp_pres_climo_b4adj_target_grid !< pressure of each level on !! target grid @@ -429,7 +420,7 @@ subroutine atmosphere_driver(localpet) ! Free up memory. !----------------------------------------------------------------------------------- - call cleanup_target_atm_data + call cleanup_all_target_atm_data end subroutine atmosphere_driver @@ -2189,42 +2180,23 @@ end subroutine cleanup_target_atm_b4adj_data !> Cleanup target grid atmospheric field objects. !! @author George Gayno - subroutine cleanup_target_atm_data + subroutine cleanup_all_target_atm_data + + use atmosphere_target_data, only : cleanup_atmosphere_target_data implicit none - integer :: i, rc + integer :: rc - print*,"- DESTROY TARGET GRID ATMOSPHERIC FIELDS." + print*,"- DESTROY LOCAL TARGET GRID ATMOSPHERIC FIELDS." - call ESMF_FieldDestroy(delp_target_grid, rc=rc) - call ESMF_FieldDestroy(dzdt_target_grid, rc=rc) - call ESMF_FieldDestroy(ps_target_grid, rc=rc) - call ESMF_FieldDestroy(pres_target_grid, rc=rc) - call ESMF_FieldDestroy(temp_target_grid, rc=rc) - call ESMF_FieldDestroy(u_s_target_grid, rc=rc) - call ESMF_FieldDestroy(v_s_target_grid, rc=rc) call ESMF_FieldDestroy(wind_target_grid, rc=rc) call ESMF_FieldDestroy(wind_s_target_grid, rc=rc) call ESMF_FieldDestroy(wind_w_target_grid, rc=rc) - call ESMF_FieldDestroy(u_w_target_grid, rc=rc) - call ESMF_FieldDestroy(v_w_target_grid, rc=rc) - call ESMF_FieldDestroy(zh_target_grid, rc=rc) - - do i = 1, num_tracers - call ESMF_FieldDestroy(tracers_target_grid(i), rc=rc) - enddo - - deallocate(tracers_target_grid) - - if (ESMF_FieldIsCreated(qnifa_climo_target_grid)) then - call ESMF_FieldDestroy(qnifa_climo_target_grid, rc=rc) - endif + call ESMF_FieldDestroy(pres_target_grid, rc=rc) - if (ESMF_FieldIsCreated(qnwfa_climo_target_grid)) then - call ESMF_FieldDestroy(qnwfa_climo_target_grid, rc=rc) - endif + call cleanup_atmosphere_target_data - end subroutine cleanup_target_atm_data + end subroutine cleanup_all_target_atm_data end module atmosphere diff --git a/sorc/chgres_cube.fd/atmosphere_target_data.F90 b/sorc/chgres_cube.fd/atmosphere_target_data.F90 new file mode 100644 index 000000000..0e4d9cd64 --- /dev/null +++ b/sorc/chgres_cube.fd/atmosphere_target_data.F90 @@ -0,0 +1,83 @@ +!> @file +!! @brief Define atmospheric target data variables. +!! @author George Gayno NCEP/EMC + +!> Module to hold variables and ESMF fields associated +!! with the target grid atmospheric data. +!! +!! @author George Gayno NCEP/EMC + module atmosphere_target_data + + use esmf + + implicit none + + private + + integer, public :: lev_target !< Number of vertical levels. + integer, public :: levp1_target !< Number of vertical levels plus 1. + integer, public :: nvcoord_target !< Number of vertical coordinate variables. + + real(esmf_kind_r8), allocatable, public :: vcoord_target(:,:) !< Vertical coordinate. + + type(esmf_field), public :: delp_target_grid !< Pressure thickness. + type(esmf_field), public :: dzdt_target_grid !< Vertical velocity. + type(esmf_field), public :: ps_target_grid !< Surface pressure. + type(esmf_field), public :: temp_target_grid !< Temperautre. + type(esmf_field), allocatable, public :: tracers_target_grid(:) !< Tracers. + type(esmf_field), public :: u_s_target_grid !< U-wind, 'south' edge of grid cell. + type(esmf_field), public :: v_s_target_grid !< V-wind, 'south' edge of grid cell. + type(esmf_field), public :: u_w_target_grid !< U-wind, 'west' edge of grid cell. + type(esmf_field), public :: v_w_target_grid !< V-wind, 'west' edge of grid cell. + type(esmf_field), public :: zh_target_grid !< 3-d height. + type(esmf_field), public :: qnifa_climo_target_grid !< Number concentration of ice + !! friendly aerosols. + type(esmf_field), public :: qnwfa_climo_target_grid !< Number concentration of water + !! friendly aerosols. + + public :: cleanup_atmosphere_target_data + + contains + +!> Free up memory for fields and variables in this module. +!! +!! @author George.Gayno NOAA/EMC + subroutine cleanup_atmosphere_target_data + + use program_setup, only : num_tracers + + implicit none + + integer :: i, rc + + print*,"- DESTROY TARGET GRID ATMOSPHERIC FIELDS." + + if (ESMF_FieldIsCreated(delp_target_grid)) call ESMF_FieldDestroy(delp_target_grid, rc=rc) + if (ESMF_FieldIsCreated(dzdt_target_grid)) call ESMF_FieldDestroy(dzdt_target_grid, rc=rc) + if (ESMF_FieldIsCreated(ps_target_grid)) call ESMF_FieldDestroy(ps_target_grid, rc=rc) + if (ESMF_FieldIsCreated(temp_target_grid)) call ESMF_FieldDestroy(temp_target_grid, rc=rc) + if (ESMF_FieldIsCreated(u_s_target_grid)) call ESMF_FieldDestroy(u_s_target_grid, rc=rc) + if (ESMF_FieldIsCreated(v_s_target_grid)) call ESMF_FieldDestroy(v_s_target_grid, rc=rc) + if (ESMF_FieldIsCreated(u_w_target_grid)) call ESMF_FieldDestroy(u_w_target_grid, rc=rc) + if (ESMF_FieldIsCreated(v_w_target_grid)) call ESMF_FieldDestroy(v_w_target_grid, rc=rc) + if (ESMF_FieldIsCreated(zh_target_grid)) call ESMF_FieldDestroy(zh_target_grid, rc=rc) + + do i = 1, num_tracers + if (ESMF_FieldIsCreated(tracers_target_grid(i))) call ESMF_FieldDestroy(tracers_target_grid(i), rc=rc) + enddo + + if (allocated (tracers_target_grid)) deallocate(tracers_target_grid) + + if (ESMF_FieldIsCreated(qnifa_climo_target_grid)) then + call ESMF_FieldDestroy(qnifa_climo_target_grid, rc=rc) + endif + + if (ESMF_FieldIsCreated(qnwfa_climo_target_grid)) then + call ESMF_FieldDestroy(qnwfa_climo_target_grid, rc=rc) + endif + + if (allocated (vcoord_target)) deallocate(vcoord_target) + + end subroutine cleanup_atmosphere_target_data + + end module atmosphere_target_data diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index c8cc2961a..7df645cfa 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -22,6 +22,28 @@ module surface use esmf + use surface_target_data, only : canopy_mc_target_grid, t2m_target_grid, & + q2m_target_grid, tprcp_target_grid, & + f10m_target_grid, seaice_fract_target_grid, & + ffmm_target_grid, ustar_target_grid, & + srflag_target_grid, soil_temp_target_grid, & + seaice_depth_target_grid, snow_liq_equiv_target_grid, & + seaice_skin_temp_target_grid, skin_temp_target_grid, & + snow_depth_target_grid, z0_target_grid, & + c_d_target_grid, c_0_target_grid, & + d_conv_target_grid, dt_cool_target_grid, & + ifd_target_grid, qrain_target_grid, & + tref_target_grid, w_d_target_grid, & + w_0_target_grid, xs_target_grid, & + xt_target_grid, xu_target_grid, & + xv_target_grid, xz_target_grid, & + xtts_target_grid, xzts_target_grid, & + z_c_target_grid, zm_target_grid, & + soilm_tot_target_grid, lai_target_grid, & + soilm_liq_target_grid + + use write_data, only : write_fv3_sfc_data_netcdf + implicit none private @@ -32,91 +54,6 @@ module surface !< The Noah LSM land ice physics !< are applied at these points. -! surface fields (not including nst) - type(esmf_field), public :: canopy_mc_target_grid - !< canopy moisture content - type(esmf_field), public :: f10m_target_grid - !< log((z0+10)*1/z0) - !< See sfc_diff.f for details - type(esmf_field), public :: ffmm_target_grid - !< log((z0+z1)*1/z0) - !< See sfc_diff.f for details - type(esmf_field), public :: q2m_target_grid - !< 2-m specific humidity - type(esmf_field), public :: seaice_depth_target_grid - !< sea ice depth - type(esmf_field), public :: seaice_fract_target_grid - !< sea ice fraction - type(esmf_field), public :: seaice_skin_temp_target_grid - !< sea ice skin temperature - type(esmf_field), public :: skin_temp_target_grid - !< skin temperature/sst - type(esmf_field), public :: srflag_target_grid - !< snow/rain flag - type(esmf_field), public :: snow_liq_equiv_target_grid - !< liquid equiv snow depth - type(esmf_field), public :: snow_depth_target_grid - !< physical snow depth - type(esmf_field), public :: soil_temp_target_grid - !< 3-d soil temperature - type(esmf_field), public :: soilm_liq_target_grid - !< 3-d liquid soil moisture - type(esmf_field), public :: soilm_tot_target_grid - !< 3-d total soil moisture - type(esmf_field), public :: t2m_target_grid - !< 2-m temperatrure - type(esmf_field), public :: tprcp_target_grid - !< precip - type(esmf_field), public :: ustar_target_grid - !< friction velocity - type(esmf_field), public :: z0_target_grid - !< roughness length - type(esmf_field), public :: lai_target_grid - !< leaf area index - -! nst fields - type(esmf_field), public :: c_d_target_grid - !< Coefficient 2 to calculate d(tz)/d(ts) - type(esmf_field), public :: c_0_target_grid - !< Coefficient 1 to calculate d(tz)/d(ts) - type(esmf_field), public :: d_conv_target_grid - !< Thickness of free convection layer - type(esmf_field), public :: dt_cool_target_grid - !< Sub-layer cooling amount - type(esmf_field), public :: ifd_target_grid - !< Model mode index. 0-diurnal model not - !< started; 1-diurnal model started. - type(esmf_field), public :: qrain_target_grid - !< Sensible heat flux due to rainfall - type(esmf_field), public :: tref_target_grid - !< reference temperature - type(esmf_field), public :: w_d_target_grid - !< Coefficient 4 to calculate d(tz)/d(ts) - type(esmf_field), public :: w_0_target_grid - !< Coefficient 3 to calculate d(tz)/d(ts) - type(esmf_field), public :: xs_target_grid - !< Salinity content in diurnal - !< thermocline layer - type(esmf_field), public :: xt_target_grid - !< Heat content in diurnal thermocline - !< layer - type(esmf_field), public :: xu_target_grid - !< u-current content in diurnal - !< thermocline layer - type(esmf_field), public :: xv_target_grid - !< v-current content in diurnal - !< thermocline layer - type(esmf_field), public :: xz_target_grid - !< Diurnal thermocline layer thickness - type(esmf_field), public :: xtts_target_grid - !< d(xt)/d(ts) - type(esmf_field), public :: xzts_target_grid - !< d(xz)/d(ts) - type(esmf_field), public :: z_c_target_grid - !< Sub-layer cooling thickness - type(esmf_field), public :: zm_target_grid - !< Oceanic mixed layer depth - type(esmf_field) :: soil_type_from_input_grid !< soil type interpolated from !< input grid @@ -154,9 +91,7 @@ module surface public :: create_nst_esmf_fields public :: interp public :: create_surface_esmf_fields - public :: cleanup_target_sfc_data public :: nst_land_fill - public :: cleanup_target_nst_data public :: regrid_many public :: search_many @@ -180,6 +115,8 @@ subroutine surface_driver(localpet) use static_data, only : get_static_fields, & cleanup_static_fields + use surface_target_data, only : cleanup_target_nst_data + implicit none integer, intent(in) :: localpet @@ -289,7 +226,7 @@ subroutine surface_driver(localpet) if (convert_nst) call cleanup_target_nst_data - call cleanup_target_sfc_data + call cleanup_all_target_sfc_data call cleanup_static_fields @@ -3464,70 +3401,22 @@ end subroutine search_many !! no longer needed. !! !! @author George Gayno NOAA/EMC - subroutine cleanup_target_sfc_data + subroutine cleanup_all_target_sfc_data + + use surface_target_data, only : cleanup_target_sfc_data implicit none integer :: rc - print*,"- DESTROY TARGET GRID SURFACE FIELDS." - - call ESMF_FieldDestroy(t2m_target_grid, rc=rc) - call ESMF_FieldDestroy(q2m_target_grid, rc=rc) - call ESMF_FieldDestroy(tprcp_target_grid, rc=rc) - call ESMF_FieldDestroy(f10m_target_grid, rc=rc) - call ESMF_FieldDestroy(ffmm_target_grid, rc=rc) - call ESMF_FieldDestroy(ustar_target_grid, rc=rc) - call ESMF_FieldDestroy(snow_liq_equiv_target_grid, rc=rc) - call ESMF_FieldDestroy(snow_depth_target_grid, rc=rc) - call ESMF_FieldDestroy(seaice_fract_target_grid, rc=rc) - call ESMF_FieldDestroy(seaice_depth_target_grid, rc=rc) - call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) - call ESMF_FieldDestroy(srflag_target_grid, rc=rc) - call ESMF_FieldDestroy(skin_temp_target_grid, rc=rc) - call ESMF_FieldDestroy(canopy_mc_target_grid, rc=rc) - call ESMF_FieldDestroy(lai_target_grid,rc=rc) - call ESMF_FieldDestroy(z0_target_grid, rc=rc) + print*,"- DESTROY LOCAL TARGET GRID SURFACE FIELDS." + call ESMF_FieldDestroy(terrain_from_input_grid, rc=rc) call ESMF_FieldDestroy(terrain_from_input_grid_land, rc=rc) call ESMF_FieldDestroy(soil_type_from_input_grid, rc=rc) - call ESMF_FieldDestroy(soil_temp_target_grid, rc=rc) - call ESMF_FieldDestroy(soilm_tot_target_grid, rc=rc) - call ESMF_FieldDestroy(soilm_liq_target_grid, rc=rc) - - end subroutine cleanup_target_sfc_data -!> Free up memory once the target grid nst fields are -!! no longer needed. -!! -!! @author George Gayno NOAA/EMC - subroutine cleanup_target_nst_data - - implicit none + call cleanup_target_sfc_data - integer :: rc - - print*,"- DESTROY TARGET GRID NST DATA." - - call ESMF_FieldDestroy(c_d_target_grid, rc=rc) - call ESMF_FieldDestroy(c_0_target_grid, rc=rc) - call ESMF_FieldDestroy(d_conv_target_grid, rc=rc) - call ESMF_FieldDestroy(dt_cool_target_grid, rc=rc) - call ESMF_FieldDestroy(ifd_target_grid, rc=rc) - call ESMF_FieldDestroy(qrain_target_grid, rc=rc) - call ESMF_FieldDestroy(tref_target_grid, rc=rc) - call ESMF_FieldDestroy(w_d_target_grid, rc=rc) - call ESMF_FieldDestroy(w_0_target_grid, rc=rc) - call ESMF_FieldDestroy(xs_target_grid, rc=rc) - call ESMF_FieldDestroy(xt_target_grid, rc=rc) - call ESMF_FieldDestroy(xu_target_grid, rc=rc) - call ESMF_FieldDestroy(xv_target_grid, rc=rc) - call ESMF_FieldDestroy(xz_target_grid, rc=rc) - call ESMF_FieldDestroy(xtts_target_grid, rc=rc) - call ESMF_FieldDestroy(xzts_target_grid, rc=rc) - call ESMF_FieldDestroy(z_c_target_grid, rc=rc) - call ESMF_FieldDestroy(zm_target_grid, rc=rc) - - end subroutine cleanup_target_nst_data + end subroutine cleanup_all_target_sfc_data end module surface diff --git a/sorc/chgres_cube.fd/surface_target_data.F90 b/sorc/chgres_cube.fd/surface_target_data.F90 new file mode 100644 index 000000000..c9011f8b1 --- /dev/null +++ b/sorc/chgres_cube.fd/surface_target_data.F90 @@ -0,0 +1,173 @@ +!> @file +!! @brief Define target grid surface data variables. +!! @author George Gayno NCEP/EMC + +!> Module to hold ESMF fields associated +!! with the target grid surface data. +!! +!! @author George Gayno NCEP/EMC + module surface_target_data + + use esmf + + implicit none + + private + +! surface fields (not including nst) + type(esmf_field), public :: canopy_mc_target_grid + !< Canopy moisture content. + type(esmf_field), public :: f10m_target_grid + !< log((z0+10)*1/z0) + !< See sfc_diff.f for details. + type(esmf_field), public :: ffmm_target_grid + !< log((z0+z1)*1/z0) + !< See sfc_diff.f for details. + type(esmf_field), public :: q2m_target_grid + !< 2-m specific humidity. + type(esmf_field), public :: seaice_depth_target_grid + !< Sea ice depth. + type(esmf_field), public :: seaice_fract_target_grid + !< Sea ice fraction. + type(esmf_field), public :: seaice_skin_temp_target_grid + !< Sea ice skin temperature. + type(esmf_field), public :: skin_temp_target_grid + !< Skin temperature/sst. + type(esmf_field), public :: srflag_target_grid + !< Snow/rain flag. + type(esmf_field), public :: snow_liq_equiv_target_grid + !< Liquid equivalent snow depth. + type(esmf_field), public :: snow_depth_target_grid + !< Physical snow depth. + type(esmf_field), public :: soil_temp_target_grid + !< 3-d soil temperature. + type(esmf_field), public :: soilm_liq_target_grid + !< 3-d liquid soil moisture. + type(esmf_field), public :: soilm_tot_target_grid + !< 3-d total soil moisture. + type(esmf_field), public :: t2m_target_grid + !< 2-m temperatrure. + type(esmf_field), public :: tprcp_target_grid + !< Precipitation. + type(esmf_field), public :: ustar_target_grid + !< Friction velocity. + type(esmf_field), public :: z0_target_grid + !< Roughness length. + type(esmf_field), public :: lai_target_grid + !< Leaf area index. + +! nst fields + type(esmf_field), public :: c_d_target_grid + !< Coefficient 2 to calculate d(tz)/d(ts). + type(esmf_field), public :: c_0_target_grid + !< Coefficient 1 to calculate d(tz)/d(ts). + type(esmf_field), public :: d_conv_target_grid + !< Thickness of free convection layer. + type(esmf_field), public :: dt_cool_target_grid + !< Sub-layer cooling amount. + type(esmf_field), public :: ifd_target_grid + !< Model mode index. 0-diurnal model not + !< started; 1-diurnal model started. + type(esmf_field), public :: qrain_target_grid + !< Sensible heat flux due to rainfall. + type(esmf_field), public :: tref_target_grid + !< Reference temperature. + type(esmf_field), public :: w_d_target_grid + !< Coefficient 4 to calculate d(tz)/d(ts). + type(esmf_field), public :: w_0_target_grid + !< Coefficient 3 to calculate d(tz)/d(ts). + type(esmf_field), public :: xs_target_grid + !< Salinity content in diurnal + !< thermocline layer. + type(esmf_field), public :: xt_target_grid + !< Heat content in diurnal thermocline + !< layer. + type(esmf_field), public :: xu_target_grid + !< u-current content in diurnal + !< thermocline layer. + type(esmf_field), public :: xv_target_grid + !< v-current content in diurnal + !< thermocline layer. + type(esmf_field), public :: xz_target_grid + !< Diurnal thermocline layer thickness. + type(esmf_field), public :: xtts_target_grid + !< d(xt)/d(ts). + type(esmf_field), public :: xzts_target_grid + !< d(xz)/d(ts). + type(esmf_field), public :: z_c_target_grid + !< Sub-layer cooling thickness. + type(esmf_field), public :: zm_target_grid + !< Oceanic mixed layer depth. + + public :: cleanup_target_nst_data + public :: cleanup_target_sfc_data + + contains + +!> Free up memory once the target grid surface fields are +!! no longer needed. +!! +!! @author George Gayno NOAA/EMC + subroutine cleanup_target_sfc_data + + implicit none + + integer :: rc + + print*,"- DESTROY TARGET GRID SURFACE FIELDS." + call ESMF_FieldDestroy(t2m_target_grid, rc=rc) + call ESMF_FieldDestroy(q2m_target_grid, rc=rc) + call ESMF_FieldDestroy(tprcp_target_grid, rc=rc) + call ESMF_FieldDestroy(f10m_target_grid, rc=rc) + call ESMF_FieldDestroy(ffmm_target_grid, rc=rc) + call ESMF_FieldDestroy(ustar_target_grid, rc=rc) + call ESMF_FieldDestroy(snow_liq_equiv_target_grid, rc=rc) + call ESMF_FieldDestroy(snow_depth_target_grid, rc=rc) + call ESMF_FieldDestroy(seaice_fract_target_grid, rc=rc) + call ESMF_FieldDestroy(seaice_depth_target_grid, rc=rc) + call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) + call ESMF_FieldDestroy(srflag_target_grid, rc=rc) + call ESMF_FieldDestroy(skin_temp_target_grid, rc=rc) + call ESMF_FieldDestroy(canopy_mc_target_grid, rc=rc) + call ESMF_FieldDestroy(lai_target_grid,rc=rc) + call ESMF_FieldDestroy(z0_target_grid, rc=rc) + call ESMF_FieldDestroy(soil_temp_target_grid, rc=rc) + call ESMF_FieldDestroy(soilm_tot_target_grid, rc=rc) + call ESMF_FieldDestroy(soilm_liq_target_grid, rc=rc) + + end subroutine cleanup_target_sfc_data + +!> Free up memory once the target grid nst fields are +!! no longer needed. +!! +!! @author George Gayno NOAA/EMC + subroutine cleanup_target_nst_data + + implicit none + + integer :: rc + + print*,"- DESTROY TARGET GRID NST DATA." + + call ESMF_FieldDestroy(c_d_target_grid, rc=rc) + call ESMF_FieldDestroy(c_0_target_grid, rc=rc) + call ESMF_FieldDestroy(d_conv_target_grid, rc=rc) + call ESMF_FieldDestroy(dt_cool_target_grid, rc=rc) + call ESMF_FieldDestroy(ifd_target_grid, rc=rc) + call ESMF_FieldDestroy(qrain_target_grid, rc=rc) + call ESMF_FieldDestroy(tref_target_grid, rc=rc) + call ESMF_FieldDestroy(w_d_target_grid, rc=rc) + call ESMF_FieldDestroy(w_0_target_grid, rc=rc) + call ESMF_FieldDestroy(xs_target_grid, rc=rc) + call ESMF_FieldDestroy(xt_target_grid, rc=rc) + call ESMF_FieldDestroy(xu_target_grid, rc=rc) + call ESMF_FieldDestroy(xv_target_grid, rc=rc) + call ESMF_FieldDestroy(xz_target_grid, rc=rc) + call ESMF_FieldDestroy(xtts_target_grid, rc=rc) + call ESMF_FieldDestroy(xzts_target_grid, rc=rc) + call ESMF_FieldDestroy(z_c_target_grid, rc=rc) + call ESMF_FieldDestroy(zm_target_grid, rc=rc) + + end subroutine cleanup_target_nst_data + + end module surface_target_data diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 2788654a1..498f6c798 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1,3 +1,14 @@ + module write_data + + private + + public :: write_fv3_atm_header_netcdf + public :: write_fv3_atm_bndy_data_netcdf + public :: write_fv3_atm_data_netcdf + public :: write_fv3_sfc_data_netcdf + + contains + !> @file !! @brief Writes the tiled and header files expected by the forecast !! model. @@ -18,9 +29,9 @@ subroutine write_fv3_atm_header_netcdf(localpet) use netcdf - use atmosphere, only : nvcoord_target, & - vcoord_target, & - levp1_target + use atmosphere_target_data, only : nvcoord_target, & + vcoord_target, & + levp1_target use program_setup, only : num_tracers, use_thomp_mp_climo @@ -105,18 +116,12 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet) use esmf use netcdf - use atmosphere, only : lev_target, levp1_target, & - dzdt_target_grid, & - ps_target_grid, & - tracers_target_grid, & - u_s_target_grid, & - v_s_target_grid, & - u_w_target_grid, & - v_w_target_grid, & - temp_target_grid, & - zh_target_grid, & - qnifa_climo_target_grid, & - qnwfa_climo_target_grid + use atmosphere_target_data, only : lev_target, levp1_target, & + ps_target_grid, zh_target_grid, & + tracers_target_grid, dzdt_target_grid, & + temp_target_grid, qnifa_climo_target_grid, & + qnwfa_climo_target_grid, u_s_target_grid, & + v_s_target_grid, u_w_target_grid, v_w_target_grid use model_grid, only : i_target, ip1_target, j_target, jp1_target @@ -1201,20 +1206,13 @@ subroutine write_fv3_atm_data_netcdf(localpet) use_thomp_mp_climo, & regional - use atmosphere, only : lev_target, & - levp1_target, & - ps_target_grid, & - zh_target_grid, & - dzdt_target_grid, & - qnifa_climo_target_grid, & - qnwfa_climo_target_grid, & - tracers_target_grid, & - temp_target_grid, & - delp_target_grid, & - u_s_target_grid, & - v_s_target_grid, & - u_w_target_grid, & - v_w_target_grid + use atmosphere_target_data, only : lev_target, levp1_target, & + ps_target_grid, zh_target_grid, & + dzdt_target_grid, delp_target_grid, & + temp_target_grid, tracers_target_grid, & + qnifa_climo_target_grid, qnwfa_climo_target_grid, & + u_s_target_grid, v_s_target_grid, & + u_w_target_grid, v_w_target_grid use model_grid, only : num_tiles_target_grid, & i_target, j_target, & @@ -1819,7 +1817,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) use program_setup, only : convert_nst, halo=>halo_bndy, & regional, lai_from_climo - use surface, only : canopy_mc_target_grid, & + use surface_target_data, only : canopy_mc_target_grid, & f10m_target_grid, & ffmm_target_grid, & q2m_target_grid, & @@ -3157,3 +3155,5 @@ subroutine write_fv3_sfc_data_netcdf(localpet) return end subroutine write_fv3_sfc_data_netcdf + + end module write_data diff --git a/tests/chgres_cube/ftst_read_vcoord.F90 b/tests/chgres_cube/ftst_read_vcoord.F90 index cfff79454..9dc535f80 100644 --- a/tests/chgres_cube/ftst_read_vcoord.F90 +++ b/tests/chgres_cube/ftst_read_vcoord.F90 @@ -18,11 +18,12 @@ program vcoord ! ! @author George Gayno - use atmosphere, only : read_vcoord_info, & - vcoord_target, & - nvcoord_target, & - lev_target, & - levp1_target + use atmosphere_target_data, only : vcoord_target, & + nvcoord_target, & + lev_target, & + levp1_target + + use atmosphere, only : read_vcoord_info use program_setup, only : vcoord_file_target_grid diff --git a/tests/chgres_cube/ftst_surface_nst_landfill.F90 b/tests/chgres_cube/ftst_surface_nst_landfill.F90 index 4bf7e3ef9..00d801478 100644 --- a/tests/chgres_cube/ftst_surface_nst_landfill.F90 +++ b/tests/chgres_cube/ftst_surface_nst_landfill.F90 @@ -11,10 +11,10 @@ program surface_nst_landfill target_grid, num_tiles_target_grid, & landmask_target_grid - use surface, only : skin_temp_target_grid, & - nst_land_fill, & - create_nst_esmf_fields, & - cleanup_target_nst_data, & + use surface, only : nst_land_fill, & + create_nst_esmf_fields + + use surface_target_data, only : skin_temp_target_grid, & c_d_target_grid, & c_0_target_grid, & d_conv_target_grid, & @@ -32,9 +32,9 @@ program surface_nst_landfill xtts_target_grid, & xzts_target_grid, & z_c_target_grid, & - zm_target_grid - - + zm_target_grid, & + cleanup_target_nst_data + implicit none integer, parameter :: IPTS_TARGET=4 diff --git a/tests/chgres_cube/ftst_surface_regrid_many.F90 b/tests/chgres_cube/ftst_surface_regrid_many.F90 index 9fac01bef..34619d7b6 100644 --- a/tests/chgres_cube/ftst_surface_regrid_many.F90 +++ b/tests/chgres_cube/ftst_surface_regrid_many.F90 @@ -20,10 +20,10 @@ program surface_interp use input_data, only: t2m_input_grid, & q2m_input_grid - use surface, only : regrid_many, & - t2m_target_grid, & - q2m_target_grid + use surface, only : regrid_many + use surface_target_data, only : t2m_target_grid, & + q2m_target_grid implicit none