Skip to content

Commit

Permalink
Merge pull request #1169 from PeterHjortLauritzen/std_atm_fix_for_mpas
Browse files Browse the repository at this point in the history
cam6_4_042: Fix reference pressures for MPAS
  • Loading branch information
nusbaume authored Oct 22, 2024
2 parents 54af3ee + 191cc48 commit ddacf0f
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 31 deletions.
2 changes: 1 addition & 1 deletion cime
Submodule cime updated 55 files
+3 −2 .github/workflows/testing.yml
+7 −1 CIME/BuildTools/configure.py
+26 −54 CIME/ParamGen/paramgen.py
+4 −4 CIME/Servers/__init__.py
+3 −14 CIME/SystemTests/ers.py
+2 −1 CIME/SystemTests/funit.py
+3 −4 CIME/SystemTests/hommebaseclass.py
+4 −4 CIME/SystemTests/mvk.py
+5 −5 CIME/SystemTests/pgn.py
+1 −1 CIME/SystemTests/restart_tests.py
+71 −2 CIME/SystemTests/system_tests_common.py
+4 −4 CIME/SystemTests/tsc.py
+5 −4 CIME/Tools/Makefile
+94 −60 CIME/Tools/list_e3sm_tests
+52 −9 CIME/Tools/xmlchange
+10 −0 CIME/XML/batch.py
+1 −1 CIME/XML/component.py
+22 −0 CIME/XML/compsets.py
+1 −1 CIME/XML/entry_id.py
+65 −21 CIME/XML/env_batch.py
+12 −0 CIME/XML/env_workflow.py
+47 −21 CIME/XML/grids.py
+30 −7 CIME/XML/pes.py
+8 −3 CIME/build.py
+29 −9 CIME/case/case.py
+8 −4 CIME/case/case_cmpgen_namelists.py
+6 −2 CIME/case/case_run.py
+48 −4 CIME/case/case_setup.py
+6 −5 CIME/case/case_st_archive.py
+5 −1 CIME/case/case_submit.py
+2 −1 CIME/case/case_test.py
+9 −15 CIME/code_checker.py
+2 −1 CIME/compare_test_results.py
+0 −3 CIME/data/config/config_tests.xml
+2 −0 CIME/data/config/xml_schemas/config_workflow.xsd
+77 −0 CIME/data/templates/gitignore.template
+100 −0 CIME/gitinterface.py
+66 −47 CIME/hist_utils.py
+1 −1 CIME/non_py/cprnc
+10 −0 CIME/scripts/create_test.py
+270 −365 CIME/scripts/query_config.py
+132 −0 CIME/status.py
+30 −17 CIME/test_scheduler.py
+8 −1 CIME/test_status.py
+2 −1 CIME/tests/test_sys_cime_case.py
+1 −1 CIME/tests/test_sys_create_newcase.py
+25 −3 CIME/tests/test_sys_unittest.py
+1 −1 CIME/tests/test_unit_utils.py
+164 −0 CIME/tests/test_unit_xml_grids.py
+13 −98 CIME/utils.py
+12 −50 docker/Dockerfile
+29 −0 docker/cime.yaml
+9 −0 docker/entrypoint.sh
+3 −3 tools/mapping/gen_mapping_files/runoff_to_ocn/INSTALL
+1 −1 tools/mapping/gen_mapping_files/runoff_to_ocn/tools/makdep.c
69 changes: 69 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,74 @@
===============================================================

Tag name: cam6_4_042
Originator(s): pel, nusbaume
Date: Oct 9, 2024
One-line Summary: Fix reference pressures in MPAS
Github PR URL: https://github.com/ESCOMP/CAM/pull/1169

Purpose of changes (include the issue number and title text for each relevant GitHub issue):
- https://github.com/ESCOMP/CAM/issues/1168

Describe any changes made to build system: N/A

Describe any changes made to the namelist: N/A

List any changes to the defaults for the boundary datasets: N/A

Describe any substantial timing or memory changes: N/A

Code reviewed by: nusbaume

List all files eliminated: N/A

List all files added and what they do: N/A

List all existing files that have been modified, and describe the changes:

M src/dynamics/mpas/dyn_grid.F90
M src/utils/std_atm_profile.F90
- Use CAM reference pressure instead of standard atmosphere surface pressure.

If there were any failures reported from running test_driver.sh on any test
platform, and checkin with these failures has been OK'd by the gatekeeper,
then copy the lines from the td.*.status files for the failed tests to the
appropriate machine below. All failed tests must be justified.

derecho/intel/aux_cam:

ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL)
SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d (Overall: DIFF)
- pre-existing failure due to HEMCO not having reproducible results issues #1018 and #856

ERP_Ln9_P24x3.f45_f45_mg37.QPWmaC6.derecho_intel.cam-outfrq9s_mee_fluxes (Overall: PEND)
ERS_Ld3.f10_f10_mg37.F1850.derecho_intel.cam-outfrq1d_14dec_ghg_cam7 (Overall: PEND)
ERS_Ln9_P36x1.mpasa480_mpasa480.F2000climo.derecho_intel.cam-outfrq9s_mpasa480 (Overall: PEND)
SMS_Lm13.f10_f10_mg37.F2000climo.derecho_intel.cam-outfrq1m (Overall: PEND)
- pre-existing failures due to resource limits due to being switched to run in the 'develop' queue rather than 'main'

SMS_D_Ln9.f19_f19_mg17.FXHIST.derecho_intel.cam-outfrq9s_amie (Overall: PEND)
SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: PEND)
- pre-existing failures due to build-namelist error requiring CLM/CTSM external update.

ERS_Ln9_P288x1.mpasa120_mpasa120.F2000climo.derecho_intel.cam-outfrq9s_mpasa120 (Overall: DIFF)
- Expected answer change due to bug-fix in MPAS surface reference pressure.

derecho/nvhpc/aux_cam: ALL PASS

izumi/nag/aux_cam:

DAE.f45_f45_mg37.FHS94.izumi_nag.cam-dae (Overall: FAIL)
- pre-existing failure -- issue #670

ERC_D_Ln9.mpasa480z32_mpasa480.FHS94.izumi_nag.cam-outfrq3s_usecase (Overall: DIFF)
- Expected answer change due to bug-fix in MPAS surface reference pressure.

izumi/gnu/aux_cam: ALL PASS

Summarize any changes to answers: all MPAS tests will likely fail against baselines

===============================================================

Tag name: cam6_4_041
Originator(s): fvitt
Date: 16 Oct 2024
Expand Down
19 changes: 10 additions & 9 deletions src/dynamics/mpas/dyn_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ subroutine dyn_grid_init()
! coupling code requires constructing global fields for the cell center
! grid which is used by the physics parameterizations.

use hycoef, only: ps0
use ref_pres, only: ref_pres_init
use std_atm_profile, only: std_atm_pres
use time_manager, only: get_step_size
Expand Down Expand Up @@ -141,7 +142,7 @@ subroutine dyn_grid_init()
ierr = pio_get_att(fh_ini, pio_global, 'sphere_radius', sphere_radius)

! Compute reference pressures from reference heights.
call std_atm_pres(zw, pref_edge)
call std_atm_pres(zw, pref_edge, user_specified_ps=ps0)
pref_mid = (pref_edge(1:plev) + pref_edge(2:plevp)) * 0.5_r8

num_pr_lev = 0
Expand Down Expand Up @@ -173,7 +174,7 @@ subroutine dyn_grid_init()
! centered grid is used by the physics parameterizations. The physics
! decomposition of the cell centered grid is defined in phys_grid_init.
call define_cam_grids()

end subroutine dyn_grid_init

!=========================================================================================
Expand Down Expand Up @@ -380,7 +381,7 @@ integer function get_dyn_grid_parm(name) result(ival)
ival = nCells_g
else if(name == 'plev') then
ival = plev
else
else
ival = -1
end if

Expand Down Expand Up @@ -428,7 +429,7 @@ subroutine dyn_grid_get_elem_coords(ie, rlon, rlat, cdex )
! for a field on a dynamics decomposition. The code in hbuf_accum_addlcltime appears
! to also assume that the field is on the physics grid since there is no argument
! passed to specify which dynamics grid the coordinates are for.

call endrun(subname//': not implemented for the MPAS grids')

end subroutine dyn_grid_get_elem_coords
Expand Down Expand Up @@ -545,7 +546,7 @@ subroutine define_cam_grids()
use cam_grid_support, only: horiz_coord_t, horiz_coord_create, iMap
use cam_grid_support, only: cam_grid_register, cam_grid_attribute_register
use shr_const_mod, only: PI => SHR_CONST_PI

! Local variables
integer :: i, j

Expand Down Expand Up @@ -600,7 +601,7 @@ subroutine define_cam_grids()
'degrees_north', 1, nCellsSolve, latCell(1:nCellsSolve)*rad2deg, map=gidx)
lon_coord => horiz_coord_create('lonCell', 'nCells', nCells_g, 'longitude', &
'degrees_east', 1, nCellsSolve, lonCell(1:nCellsSolve)*rad2deg, map=gidx)

allocate(areaWeight(nCellsSolve), stat=ierr)
if( ierr /= 0 ) call endrun(subname//':failed to allocate area_weight :'//int2str(__LINE__))
call get_dyn_grid_info(hdim1_d, hdim2_d, num_levels, index_model_top_layer, index_surface_layer, unstructured, dyn_cols)
Expand Down Expand Up @@ -667,7 +668,7 @@ subroutine define_cam_grids()
'degrees_north', 1, nEdgesSolve, latEdge(1:nEdgesSolve)*rad2deg, map=gidx)
lon_coord => horiz_coord_create('lonEdge', 'nEdges', nEdges_g, 'longitude', &
'degrees_east', 1, nEdgesSolve, lonEdge(1:nEdgesSolve)*rad2deg, map=gidx)

! Map for edge node grid
allocate(grid_map(3, nEdgesSolve), stat=ierr)
if( ierr /= 0 ) call endrun(subname//':failed to allocate grid_map array at line:'//int2str(__LINE__))
Expand Down Expand Up @@ -704,7 +705,7 @@ subroutine define_cam_grids()
'degrees_north', 1, nVerticesSolve, latVertex(1:nVerticesSolve)*rad2deg, map=gidx)
lon_coord => horiz_coord_create('lonVertex', 'nVertices', nVertices_g, 'longitude', &
'degrees_east', 1, nVerticesSolve, lonVertex(1:nVerticesSolve)*rad2deg, map=gidx)

! Map for vertex node grid
allocate(grid_map(3, nVerticesSolve), stat=ierr)
if( ierr /= 0 ) call endrun(subname//':failed to allocate grid_map array at line:'//int2str(__LINE__))
Expand All @@ -723,7 +724,7 @@ subroutine define_cam_grids()
nullify(grid_map)
nullify(lat_coord)
nullify(lon_coord)

end subroutine define_cam_grids

end module dyn_grid
53 changes: 32 additions & 21 deletions src/utils/std_atm_profile.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,33 @@ module std_atm_profile
real(r8), parameter :: g0 = 9.80665_r8 ! gravitational acceleration (m/s^2)
real(r8), parameter :: mw = 0.0289644_r8 ! molar mass of dry air (kg/mol)
real(r8), parameter :: c1 = g0*mw/rg

!=========================================================================================
CONTAINS
!=========================================================================================

subroutine std_atm_pres(height, pstd)
subroutine std_atm_pres(height, pstd, user_specified_ps)

! arguments
real(r8), intent(in) :: height(:) ! height above sea level in meters
real(r8), intent(out) :: pstd(:) ! std pressure in Pa

integer :: i, ii, k, nlev
real(r8), intent(in) :: height(:) ! height above sea level in meters
real(r8), intent(out) :: pstd(:) ! std pressure in Pa
real(r8), optional, intent(in) :: user_specified_ps

integer :: i, ii, k, nlev
integer :: ierr
real(r8) :: pb_local(nreg)

character(len=*), parameter :: routine = 'std_atm_pres'
!----------------------------------------------------------------------------


! Initialize local standard pressure values array
pb_local = pb

! Set new surface pressure value if provided by the caller
if (present(user_specified_ps)) then
pb_local(1) = user_specified_ps
end if

nlev = size(height)
do k = 1, nlev
if (height(k) < 0.0_r8) then
Expand All @@ -76,33 +88,32 @@ subroutine std_atm_pres(height, pstd)
end if
end do find_region
end if

if (lb(ii) /= 0._r8) then
pstd(k) = pb(ii) * ( tb(ii) / (tb(ii) + lb(ii)*(height(k) - hb(ii)) ) )**(c1/lb(ii))
pstd(k) = pb_local(ii) * ( tb(ii) / (tb(ii) + lb(ii)*(height(k) - hb(ii)) ) )**(c1/lb(ii))
else
pstd(k) = pb(ii) * exp( -c1*(height(k) - hb(ii))/tb(ii) )
pstd(k) = pb_local(ii) * exp( -c1*(height(k) - hb(ii))/tb(ii) )
end if

end do

end do
end subroutine std_atm_pres

!=========================================================================================

subroutine std_atm_height(pstd, height)

! arguments
real(r8), intent(in) :: pstd(:) ! std pressure in Pa
real(r8), intent(out) :: height(:) ! height above sea level in meters

integer :: i, ii, k, nlev
logical :: found_region
character(len=*), parameter :: routine = 'std_atm_height'
!----------------------------------------------------------------------------

nlev = size(height)
do k = 1, nlev

if (pstd(k) <= pb(nreg)) then
ii = nreg
else if (pstd(k) > pb(1)) then
Expand All @@ -129,16 +140,16 @@ end subroutine std_atm_height
!=========================================================================================

subroutine std_atm_temp(height, temp)

! arguments
real(r8), intent(in) :: height(:) ! std pressure in Pa
real(r8), intent(out) :: temp(:) ! temperature

! local vars
integer :: i, ii, k, nlev
character(len=*), parameter :: routine = 'std_atm_temp'
!----------------------------------------------------------------------------

nlev = size(height)
do k = 1, nlev
if (height(k) < 0.0_r8) then
Expand All @@ -158,7 +169,7 @@ subroutine std_atm_temp(height, temp)
else
temp(k) = tb(ii)
end if

end do

end subroutine std_atm_temp
Expand Down

0 comments on commit ddacf0f

Please sign in to comment.