From 1aad42b32631f239b90f1e360d5eef972f16ff13 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Fri, 6 Dec 2024 13:42:57 -0700 Subject: [PATCH] add more zm feilds; some clean up new file: cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/shell_commands new file: cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_cam new file: cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_clm modified: src/utils/esmf_zm_mod.F90 modified: src/utils/zm_test_mod.F90 --- .../cam/outfrq9s_esmf_zm/shell_commands | 2 ++ .../cam/outfrq9s_esmf_zm/user_nl_cam | 8 +++++ .../cam/outfrq9s_esmf_zm/user_nl_clm | 27 +++++++++++++++ src/utils/esmf_zm_mod.F90 | 34 +++++-------------- src/utils/zm_test_mod.F90 | 32 ++++++++++------- 5 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_cam create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/shell_commands new file mode 100644 index 0000000000..eb40ad83e0 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/shell_commands @@ -0,0 +1,2 @@ +./xmlchange ROF_NCPL=\$ATM_NCPL +./xmlchange GLC_NCPL=\$ATM_NCPL diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_cam new file mode 100644 index 0000000000..6a7258cfb4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_cam @@ -0,0 +1,8 @@ +mfilt=1,1,1,1,1,1,1,1,1,1 +ndens=1,1,1,1,1,1,1,1,1,1 +nhtfrq=9,9,9,9,9,9,9,9,9,9 +write_nstep0=.true. +inithist='ENDOFRUN' + +cam_physics_mesh = '$ATM_DOMAIN_MESH' +fincl2 = 'T_emsfzm', 'U_emsfzm', 'V_emsfzm','PS_emsfzm' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_clm new file mode 100644 index 0000000000..0d83b5367b --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_esmf_zm/user_nl_clm @@ -0,0 +1,27 @@ +!---------------------------------------------------------------------------------- +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +! +! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options +! are set in the CLM_NAMELIST_OPTS env variable. +! +! EXCEPTIONS: +! Set use_cndv by the compset you use and the CLM_BLDNML_OPTS -dynamic_vegetation setting +! Set use_vichydro by the compset you use and the CLM_BLDNML_OPTS -vichydro setting +! Set use_cn by the compset you use and CLM_BLDNML_OPTS -bgc setting +! Set use_crop by the compset you use and CLM_BLDNML_OPTS -crop setting +! Set spinup_state by the CLM_BLDNML_OPTS -bgc_spinup setting +! Set irrigate by the CLM_BLDNML_OPTS -irrig setting +! Set dtime with L_NCPL option +! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options +! Set finidat with RUN_REFCASE/RUN_REFDATE/RUN_REFTOD options for hybrid or branch cases +! (includes $inst_string for multi-ensemble cases) +! Set glc_grid with CISM_GRID option +! Set glc_smb with GLC_SMB option +! Set maxpatch_glcmec with GLC_NEC option +! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable +!---------------------------------------------------------------------------------- +hist_nhtfrq = 9 +hist_mfilt = 1 +hist_ndens = 1 + diff --git a/src/utils/esmf_zm_mod.F90 b/src/utils/esmf_zm_mod.F90 index ae37f69b08..7173899fd4 100644 --- a/src/utils/esmf_zm_mod.F90 +++ b/src/utils/esmf_zm_mod.F90 @@ -460,13 +460,13 @@ function esmf_zm_calc_2d(physfld) result(zmfld) real(ESMF_KIND_R8), pointer :: physptr(:) real(ESMF_KIND_R8), pointer :: lonlatptr(:,:) - real(r8) :: lonlat_fld(lon_beg:lon_end,lat_beg:lat_end) - character(len=*), parameter :: subname = 'esmf_zm_calc_2d: ' - real(r8) :: arr(mynlons,1) + real(r8) :: arr(lon_beg:lon_end,1) real(r8) :: gsum(1) + ! regrid to lat/lon + call ESMF_FieldGet(physfld_2d, localDe=0, farrayPtr=physptr, rc=rc) call check_esmf_error(rc, subname//'ESMF_FieldGet physptr') @@ -486,21 +486,12 @@ function esmf_zm_calc_2d(physfld) result(zmfld) call ESMF_FieldGet(lonlatfld_2d, localDe=0, farrayPtr=lonlatptr, rc=rc) call check_esmf_error(rc, subname//'ESMF_FieldGet lonlatptr') - do ilat = lat_beg, lat_end - do ilon = lon_beg, lon_end - lonlat_fld(ilon,ilat) = lonlatptr(ilon,ilat) - end do - end do - ! zonal mean - zmfld = huge(1._r8) do ilat = lat_beg, lat_end - arr(1:mynlons,1) = lonlat_fld(lon_beg:lon_end,ilat) + arr(lon_beg:lon_end,1) = lonlatptr(lon_beg:lon_end,ilat) call shr_reprosum_calc(arr, gsum, mynlons, mynlons, 1, gbl_count=nlons, commid=rows_comm) - zmfld(ilat) = gsum(1)/nlons - end do end function esmf_zm_calc_2d @@ -518,7 +509,6 @@ function esmf_zm_calc_3d(physfld) result(zmfld) real(ESMF_KIND_R8), pointer :: physptr(:,:) real(ESMF_KIND_R8), pointer :: lonlatptr(:,:,:) - real(r8) :: lonlat_fld(lon_beg:lon_end,lat_beg:lat_end,1:pver) real(r8) :: arr(lon_beg:lon_end,pver) real(r8) :: gsum(pver) @@ -526,6 +516,8 @@ function esmf_zm_calc_3d(physfld) result(zmfld) integer :: k + ! regrid to lat/lon + call ESMF_FieldGet(physfld_3d, localDe=0, farrayPtr=physptr, rc=rc) call check_esmf_error(rc, subname//'ESMF_FieldGet physptr') @@ -547,22 +539,12 @@ function esmf_zm_calc_3d(physfld) result(zmfld) call ESMF_FieldGet(lonlatfld_3d, localDe=0, farrayPtr=lonlatptr, rc=rc) call check_esmf_error(rc, subname//'ESMF_FieldGet lonlatptr') - do ilat = lat_beg, lat_end - do ilon = lon_beg, lon_end - do ilev = 1,pver - lonlat_fld(ilon,ilat,ilev) = lonlatptr(ilon,ilat,ilev) - end do - end do - end do - - zmfld = -huge(1._r8) + ! zonal mean do ilat = lat_beg, lat_end - arr(lon_beg:lon_end,:) = lonlat_fld(lon_beg:lon_end,ilat,:) + arr(lon_beg:lon_end,:) = lonlatptr(lon_beg:lon_end,ilat,:) call shr_reprosum_calc(arr, gsum, mynlons, mynlons, pver, gbl_count=nlons, commid=rows_comm) - zmfld(ilat,:) = gsum(:)/nlons - end do end function esmf_zm_calc_3d diff --git a/src/utils/zm_test_mod.F90 b/src/utils/zm_test_mod.F90 index 03d5e39d85..09b45853e5 100644 --- a/src/utils/zm_test_mod.F90 +++ b/src/utils/zm_test_mod.F90 @@ -62,6 +62,8 @@ end subroutine zm_test_reg subroutine zm_test_init() call addfld ('T_emsfzm', (/'lev'/), 'A', 'K', 'Zonal-Mean temperature', gridname='esmf_zonal_mean' ) + call addfld ('U_emsfzm', (/'lev'/), 'A', 'm s-1', 'Zonal-Mean zonal wind', gridname='esmf_zonal_mean' ) + call addfld ('V_emsfzm', (/'lev'/), 'A', 'm s-1', 'Zonal-Mean meridianal wind', gridname='esmf_zonal_mean' ) call addfld ('PS_emsfzm', horiz_only, 'A','Pa', 'Zonal-Mean srf press', gridname='esmf_zonal_mean' ) end subroutine zm_test_init @@ -70,35 +72,41 @@ end subroutine zm_test_init !------------------------------------------------------------------------------ subroutine zm_test_run(phys_state) - use time_manager, only: get_nstep - type(physics_state), intent(in) :: phys_state(begchunk:endchunk) - real(r8) :: physfld(pver,pcols,begchunk:endchunk) + real(r8) :: tfld(pver,pcols,begchunk:endchunk) + real(r8) :: ufld(pver,pcols,begchunk:endchunk) + real(r8) :: vfld(pver,pcols,begchunk:endchunk) real(r8) :: psfld(pcols,begchunk:endchunk) - integer :: lchnk, ncol, icol, nstep, j + integer :: lchnk, ncol, icol - real(r8) :: temp_zm(lat_beg:lat_end,pver) + real(r8) :: t_zm(lat_beg:lat_end,pver) + real(r8) :: u_zm(lat_beg:lat_end,pver) + real(r8) :: v_zm(lat_beg:lat_end,pver) real(r8) :: ps_zm(lat_beg:lat_end) do lchnk = begchunk, endchunk ncol = get_ncols_p(lchnk) do icol = 1,ncol - physfld(:pver,icol,lchnk) = phys_state(lchnk)%t(icol,:pver) + tfld(:pver,icol,lchnk) = phys_state(lchnk)%t(icol,:pver) + ufld(:pver,icol,lchnk) = phys_state(lchnk)%u(icol,:pver) + vfld(:pver,icol,lchnk) = phys_state(lchnk)%v(icol,:pver) psfld(icol,lchnk) = phys_state(lchnk)%ps(icol) end do end do - temp_zm = esmf_zm_calc_3d(physfld) - - nstep = get_nstep() + t_zm = esmf_zm_calc_3d(tfld) + u_zm = esmf_zm_calc_3d(ufld) + v_zm = esmf_zm_calc_3d(vfld) ps_zm = esmf_zm_calc_2d(psfld) - do j = lat_beg, lat_end - call outfld('PS_emsfzm',ps_zm(j),1,j) - call outfld('T_emsfzm',temp_zm(j,:),1,j) + do icol = lat_beg, lat_end + call outfld('PS_emsfzm',ps_zm(icol),1,icol) + call outfld('T_emsfzm',t_zm(icol,:),1,icol) + call outfld('U_emsfzm',u_zm(icol,:),1,icol) + call outfld('V_emsfzm',v_zm(icol,:),1,icol) end do end subroutine zm_test_run