From e47052ad2e178fdd9712e4a397b4a4dcfad60942 Mon Sep 17 00:00:00 2001 From: Bill Skamarock Date: Fri, 10 Dec 2021 17:11:08 -0700 Subject: [PATCH 01/24] Added coefficient arrays used to compute the horizontal gradients of cell-centered variables to the input and restart streams for the MPAS dynamical core. --- .../mpas/driver/cam_mpas_subdriver.F90 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index 39eeb1ecf4..17f59f6b08 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -963,6 +963,7 @@ subroutine cam_mpas_read_static(fh_ini, endrun) type (field3DReal), pointer :: zb, zb3, deriv_two, cellTangentPlane, coeffs_reconstruct type (field2DReal), pointer :: edgeNormalVectors, localVerticalUnitVectors, defc_a, defc_b + type (field2DReal), pointer :: cell_gradient_coef_x, cell_gradient_coef_y type (MPAS_Stream_type) :: mesh_stream @@ -1046,6 +1047,8 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call mpas_pool_get_field(meshPool, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(meshPool, 'defc_a', defc_a) call mpas_pool_get_field(meshPool, 'defc_b', defc_b) + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) ierr_total = 0 @@ -1178,6 +1181,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(mesh_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 if (ierr_total > 0) then write(errString, '(a,i0,a)') subname//': FATAL: Failed to add ', ierr_total, ' fields to static input stream.' @@ -1259,6 +1266,8 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call MPAS_dmpar_exch_halo_field(localVerticalUnitVectors) call MPAS_dmpar_exch_halo_field(defc_a) call MPAS_dmpar_exch_halo_field(defc_b) + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_x) + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_y) ! ! Re-index from global index space to local index space @@ -1342,6 +1351,7 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) type (field3DReal), pointer :: zb, zb3, deriv_two, cellTangentPlane, coeffs_reconstruct type (field2DReal), pointer :: edgeNormalVectors, localVerticalUnitVectors, defc_a, defc_b + type (field2DReal), pointer :: cell_gradient_coef_x, cell_gradient_coef_y type (field0DChar), pointer :: initial_time type (field0DChar), pointer :: xtime @@ -1461,6 +1471,8 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) call mpas_pool_get_field(allFields, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(allFields, 'defc_a', defc_a) call mpas_pool_get_field(allFields, 'defc_b', defc_b) + call mpas_pool_get_field(allFields, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(allFields, 'cell_gradient_coef_y', cell_gradient_coef_y) call mpas_pool_get_field(allFields, 'initial_time', initial_time, timeLevel=1) call mpas_pool_get_field(allFields, 'xtime', xtime, timeLevel=1) @@ -1631,6 +1643,10 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(restart_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(restart_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, initial_time, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 @@ -1841,6 +1857,8 @@ subroutine cam_mpas_read_restart(restart_stream, endrun) call cam_mpas_update_halo('localVerticalUnitVectors', endrun) call cam_mpas_update_halo('defc_a', endrun) call cam_mpas_update_halo('defc_b', endrun) + call cam_mpas_update_halo('cell_gradient_coef_x', endrun) + call cam_mpas_update_halo('cell_gradient_coef_y', endrun) call cam_mpas_update_halo('u', endrun) call cam_mpas_update_halo('w', endrun) From 28bc86407223c6b9b4516b2c893ea83c26b2c4b8 Mon Sep 17 00:00:00 2001 From: Bill Skamarock Date: Mon, 13 Dec 2021 15:24:24 -0700 Subject: [PATCH 02/24] Added MPAS mesh information and coefficients for computing the frontogenesis function to the dynamics export state for use in d_p_coupling (where the frontogenesis function and angle are computed). --- src/dynamics/mpas/dyn_comp.F90 | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index 347f795b4d..ba7c2e0da4 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -131,7 +131,6 @@ module dyn_comp ! of the sphere [dimensionless] (3,ncol) integer, dimension(:,:), pointer :: cellsOnEdge ! Indices of cells separated by an edge (2,nedge) - ! ! State that may be directly derived from dycore prognostic state ! @@ -198,6 +197,19 @@ module dyn_comp real(r8), dimension(:), pointer :: fzp ! Interp weight from k-1 layer midpoint to k ! layer interface [dimensionless] (nver) + ! + ! Invariant -- needed for computing the frontogenesis function + ! + real(r8), dimension(:,:), pointer :: defc_a + real(r8), dimension(:,:), pointer :: defc_b + real(r8), dimension(:,:), pointer :: cell_gradient_coef_x + real(r8), dimension(:,:), pointer :: cell_gradient_coef_y + real(r8), dimension(:,:), pointer :: edgesOnCell_sign + real(r8), dimension(:), pointer :: dvEdge + + integer, dimension(:,:), pointer :: edgesOnCell + integer, dimension(:), pointer :: nEdgesOnCell + ! ! State that may be directly derived from dycore prognostic state ! @@ -488,6 +500,19 @@ subroutine dyn_init(dyn_in, dyn_out) dyn_out % ux => dyn_in % ux dyn_out % uy => dyn_in % uy + ! components only needed in output, no time level index + + call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) + call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + call mpas_pool_get_array(mesh_pool, 'edgesOnCell_sign', dyn_out % edgesOnCell_sign) + call mpas_pool_get_array(mesh_pool, 'dvEdge', dyn_out % dvEdge) + call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) + call mpas_pool_get_array(mesh_pool, 'nEdgesOnCell', dyn_out % nEdgesOnCell) + + ! cam-required hydrostatic pressures + allocate(dyn_out % pmiddry(nVertLevels, nCells), stat=ierr) if( ierr /= 0 ) call endrun(subname//': failed to allocate dyn_out%pmiddry array') From 4eb8978d6d7b0e98ed02e928a8dc96306bb6d0a4 Mon Sep 17 00:00:00 2001 From: Bill Skamarock Date: Thu, 23 Dec 2021 12:14:24 -0700 Subject: [PATCH 03/24] Added the option to compute the frontogenesis function and the angle of del(theta) needed by the gravity-wave drag parameterization. --- src/dynamics/mpas/dp_coupling.F90 | 211 +++++++++++++++++++++++++++++- src/dynamics/mpas/dyn_comp.F90 | 27 +++- 2 files changed, 234 insertions(+), 4 deletions(-) diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 7dbb17071c..8ba9cdeab9 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -44,8 +44,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) ! Convert the dynamics output state into the physics input state. ! Note that all pressures and tracer mixing ratios coming from the dycore are based on ! dry air mass. - use cam_history, only : hist_fld_active - use mpas_constants, only : Rv_over_Rd => rvord + use cam_history, only: hist_fld_active + use dyn_comp, only: frontgf_idx, frontga_idx + use mpas_constants, only: Rv_over_Rd => rvord + use phys_control, only: use_gw_front, use_gw_front_igw ! arguments type(physics_state), intent(inout) :: phys_state(begchunk:endchunk) @@ -70,6 +72,36 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) real(r8), pointer :: theta_m(:,:) real(r8), pointer :: tracers(:,:,:) + ! + ! mesh information and coefficients needed for + ! frontogenesis function calculation + ! + real(r8), dimension(:,:), pointer :: defc_a + real(r8), dimension(:,:), pointer :: defc_b + real(r8), dimension(:,:), pointer :: cell_gradient_coef_x + real(r8), dimension(:,:), pointer :: cell_gradient_coef_y + real(r8), dimension(:,:), pointer :: edgesOnCell_sign + real(r8), dimension(:), pointer :: dvEdge + real(r8), dimension(:), pointer :: areaCell + + integer, dimension(:,:), pointer :: cellsOnEdge + integer, dimension(:,:), pointer :: edgesOnCell + integer, dimension(:), pointer :: nEdgesOnCell + + real(r8), dimension(:,:), pointer :: uperp + real(r8), dimension(:,:), pointer :: utangential + + ! + ! local storage for frontogenesis function and angle + ! + real(r8), dimension(:,:), pointer :: frontogenesisFunction + real(r8), dimension(:,:), pointer :: frontogenesisAngle + real(r8), dimension(:,:), pointer :: pbuf_frontgf + real(r8), dimension(:,:), pointer :: pbuf_frontga + real(r8), allocatable :: frontgf_phys(:,:,:) + real(r8), allocatable :: frontga_phys(:,:,:) + + type(physics_buffer_desc), pointer :: pbuf_chnk(:) integer :: lchnk, icol, icol_p, k, kk ! indices over chunks, columns, physics columns and layers integer :: i, m, ncols, blockid @@ -129,6 +161,45 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) nCellsSolve, plev, zz, zint, rho_zz, theta_m, tracers(index_qv,:,:),& pmiddry, pintdry, pmid) + if (use_gw_front .or. use_gw_front_igw) then + nullify(pbuf_chnk) + nullify(pbuf_frontgf) + nullify(pbuf_frontga) + ! + ! compute frontogenesis function and angle for gravity wave scheme + ! + defc_a => dyn_out % defc_a + defc_b => dyn_out % defc_b + cell_gradient_coef_x => dyn_out % cell_gradient_coef_x + cell_gradient_coef_y => dyn_out % cell_gradient_coef_y + edgesOnCell_sign => dyn_out % edgesOnCell_sign + dvEdge => dyn_out % dvEdge + areaCell => dyn_out % areaCell + cellsOnEdge => dyn_out % cellsOnEdge + edgesOnCell => dyn_out % edgesOnCell + nEdgesOnCell => dyn_out % nEdgesOnCell + uperp => dyn_out % uperp + utangential => dyn_out % utangential + + allocate(frontogenesisFunction(plev, nCellsSolve), stat=ierr) + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisFunction array') + allocate(frontogenesisAngle(plev, nCellsSolve), stat=ierr) + + allocate(frontgf_phys(pcols, pver, begchunk:endchunk)) + allocate(frontga_phys(pcols, pver, begchunk:endchunk)) + + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisAngle array') + + call calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & + theta_m, tracers(index_qv,:,:), & + uperp, utangential, defc_a, defc_b, & + cell_gradient_coef_x, cell_gradient_coef_y, & + areaCell, dvEdge, cellsOnEdge, edgesOnCell, & + nEdgesOnCell, edgesOnCell_sign, & + plev, nCellsSolve ) + + end if + call t_startf('dpcopy') ncols = columns_on_task @@ -154,6 +225,11 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) phys_state(lchnk)%omega(icol_p,k) = -rho_zz(kk,i)*zz(kk,i)*gravit*0.5_r8*(w(kk,i)+w(kk+1,i)) ! omega phys_state(lchnk)%pmiddry(icol_p,k) = pmiddry(kk,i) phys_state(lchnk)%pmid(icol_p,k) = pmid(kk,i) + + if (use_gw_front .or. use_gw_front_igw) then + frontgf_phys(icol_p, k, lchnk) = frontogenesisFunction(kk, i) + frontga_phys(icol_p, k, lchnk) = frontogenesisAngle(kk, i) + end if end do do k = 1, pverp @@ -169,6 +245,25 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) end do end do + if (use_gw_front .or. use_gw_front_igw) then + + !$omp parallel do private (lchnk, ncols, icol, k, pbuf_chnk, pbuf_frontgf, pbuf_frontga) + do lchnk = begchunk, endchunk + ncols = get_ncols_p(lchnk) + pbuf_chnk => pbuf_get_chunk(pbuf2d, lchnk) + call pbuf_get_field(pbuf_chnk, frontgf_idx, pbuf_frontgf) + call pbuf_get_field(pbuf_chnk, frontga_idx, pbuf_frontga) + do icol = 1, ncols + do k = 1, pver + pbuf_frontgf(icol, k) = frontgf_phys(icol, k, lchnk) + pbuf_frontga(icol, k) = frontga_phys(icol, k, lchnk) + end do + end do + end do + deallocate(frontgf_phys) + deallocate(frontga_phys) + end if + call t_stopf('dpcopy') call t_startf('derived_phys') @@ -177,6 +272,8 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) deallocate(pmid,pintdry,pmiddry) + if (use_gw_front .or. use_gw_front_igw) deallocate(frontogenesisFunction, frontogenesisAngle) + end subroutine d_p_coupling !========================================================================================= @@ -875,4 +972,114 @@ subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, t end if end subroutine tot_energy + subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & + theta_m, qv, u,v, defc_a, defc_b, cell_gradient_coef_x, cell_gradient_coef_y, & + areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & + nVertLevels, nCellsSolve ) + + use mpas_constants, only : rvord + + implicit none + + ! inputs + + integer, intent(in) :: nVertLevels, nCellsSolve + real(r8), dimension(:,:), intent(in) :: theta_m, qv + real(r8), dimension(:,:), intent(in) :: u, v + real(r8), dimension(:,:), intent(in) :: defc_a + real(r8), dimension(:,:), intent(in) :: defc_b + real(r8), dimension(:,:), intent(in) :: cell_gradient_coef_x + real(r8), dimension(:,:), intent(in) :: cell_gradient_coef_y + real(r8), dimension(:,:), intent(in) :: edgesOnCell_sign + real(r8), dimension(:), intent(in) :: dvEdge + real(r8), dimension(:), intent(in) :: areaCell + integer, dimension(:,:), intent(in) :: cellsOnEdge + integer, dimension(:,:), intent(in) :: edgesOnCell + integer, dimension(:), intent(in) :: nEdgesOnCell + + ! outputs + + real(r8), dimension(:,:), intent(out) :: frontogenesisFunction + real(r8), dimension(:,:), intent(out) :: frontogenesisAngle + + ! local storage + + integer :: iCell, iEdge, k, cell1, cell2 + integer :: CellStart, CellEnd + real(r8), dimension(nVertLevels) :: d_diag, d_off_diag, divh, theta_x, theta_y + real(r8) :: edge_sign, thetaEdge + + ! + ! for each column, compute frontogenesis function and del(theta) angle + ! + CellStart = 1 + CellEnd = nCellsSolve + + do iCell = cellStart,cellEnd + + d_diag(1:nVertLevels) = 0.0 + d_off_diag(1:nVertLevels) = 0.0 + divh(1:nVertLevels) = 0.0 + theta_x(1:nVertLevels) = 0.0 + theta_y(1:nVertLevels) = 0.0 + + ! + ! Integrate over edges to compute cell-averaged divergence, deformation, + ! d(theta)/dx, and d(theta)/dy. (x,y) are aligned with (lon,lat) at the + ! cell center in the 2D tangent-plane approximation used here. This alignment + ! is set in the initialization routine for the coefficients + ! defc_a, defc_b, cell_gradient_coef_x and cell_gradient_coef_y that is + ! part of the MPAS mesh initialization. The horizontal divergence is calculated + ! as it is in the MPAS solver, i.e. on the sphere as opposed to on the tangent plane. + ! + do iEdge=1,nEdgesOnCell(iCell) + + edge_sign = edgesOnCell_sign(iEdge,iCell) * dvEdge(edgesOnCell(iEdge,iCell)) / areaCell(iCell) + cell1 = cellsOnEdge(1,edgesOnCell(iEdge,iCell)) + cell2 = cellsOnEdge(2,edgesOnCell(iEdge,iCell)) + + do k=1,nVertLevels + + d_diag(k) = d_diag(k) + defc_a(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & + - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + d_off_diag(k) = d_off_diag(k) + defc_b(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & + + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + divh(k) = divh(k) + edge_sign * u(k,EdgesOnCell(iEdge,iCell)) + thetaEdge = 0.5*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & + +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) + theta_x(k) = theta_x(k) + cell_gradient_coef_x(iEdge,iCell)*thetaEdge + theta_y(k) = theta_y(k) + cell_gradient_coef_y(iEdge,iCell)*thetaEdge + + end do + + end do + + ! + ! compute the frontogenesis function: + ! 1/2 |del(theta)/dt)| = 1/2 ( + ! - Div * |del(theta)|^2 + ! - E (d(theta)/dx)^2 + ! - 2F (d(theta)/dx)*(d(theta)/dy) + ! + E (d(theta)/dy) ) + ! where + ! Div = u_x + v_y (horizontal velocity divergence) + ! E = u_x - v_y (stretching deformation) + ! F = v_x + u_y (shearing deformation) + ! + !DIR$ IVDEP + do k=1, nVertLevels + + frontogenesisFunction(k,iCell) = 0.5*( & + -divh(k)*(theta_x(k)**2 + theta_y(k)**2) & + -d_diag(k)*theta_x(k)**2 & + -2.0*d_off_diag(k)*theta_x(k)*theta_y(k) & + +d_diag(k)*theta_y(k)**2 ) + frontogenesisAngle(k,iCell) = atan2(theta_y(k),theta_x(k)) + + end do + + end do + +end subroutine calc_frontogenesis + end module dp_coupling diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index ba7c2e0da4..f07a2fb811 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -206,10 +206,15 @@ module dyn_comp real(r8), dimension(:,:), pointer :: cell_gradient_coef_y real(r8), dimension(:,:), pointer :: edgesOnCell_sign real(r8), dimension(:), pointer :: dvEdge + real(r8), dimension(:), pointer :: areaCell ! cell area (m^2) integer, dimension(:,:), pointer :: edgesOnCell + integer, dimension(:,:), pointer :: cellsOnEdge integer, dimension(:), pointer :: nEdgesOnCell + real(r8), dimension(:,:), pointer :: utangential ! velocity tangent to cell edge, + ! diagnosed by mpas + ! ! State that may be directly derived from dycore prognostic state ! @@ -235,6 +240,10 @@ module dyn_comp ixh = -1, & ixh2 = -1 +! Frontogenesis indices +integer, public :: frontgf_idx = -1 +integer, public :: frontga_idx = -1 + real(r8), parameter :: rad2deg = 180.0_r8 / pi real(r8), parameter :: deg2rad = pi / 180.0_r8 @@ -313,8 +322,17 @@ subroutine dyn_register() use physics_buffer, only: pbuf_add_field, dtype_r8 use ppgrid, only: pcols, pver - !---------------------------------------------------------------------------- + use phys_control, only: use_gw_front, use_gw_front_igw + ! These fields are computed by the dycore and passed to the physics via the + ! physics buffer. + + if (use_gw_front .or. use_gw_front_igw) then + call pbuf_add_field("FRONTGF", "global", dtype_r8, (/pcols,pver/), frontgf_idx) + call pbuf_add_field("FRONTGA", "global", dtype_r8, (/pcols,pver/), frontga_idx) + end if + + !---------------------------------------------------------------------------- end subroutine dyn_register @@ -500,7 +518,10 @@ subroutine dyn_init(dyn_in, dyn_out) dyn_out % ux => dyn_in % ux dyn_out % uy => dyn_in % uy - ! components only needed in output, no time level index + ! components needed in output, no time level index + + dyn_out % areaCell => dyn_in % areaCell + dyn_out % cellsOnEdge => dyn_in % cellsOnEdge call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) @@ -511,6 +532,8 @@ subroutine dyn_init(dyn_in, dyn_out) call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) call mpas_pool_get_array(mesh_pool, 'nEdgesOnCell', dyn_out % nEdgesOnCell) + call mpas_pool_get_array(diag_pool, 'v', dyn_out % utangential) + ! cam-required hydrostatic pressures allocate(dyn_out % pmiddry(nVertLevels, nCells), stat=ierr) From ca65b5feb79242b5139c40891aad03c85cabf122 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Wed, 17 Aug 2022 06:56:19 -0600 Subject: [PATCH 04/24] read cell_gradient_coefs from IC file only if front GWs are turn on; cold start CLM in mpasa480 test; clean up modified: cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands modified: src/dynamics/mpas/dp_coupling.F90 modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 --- .../cam/outfrq9s_mpasa480/shell_commands | 1 + src/dynamics/mpas/dp_coupling.F90 | 30 +++++---- .../mpas/driver/cam_mpas_subdriver.F90 | 61 +++++++++++-------- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands index 52f64de9ce..593ae0b036 100644 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands @@ -1,3 +1,4 @@ ./xmlchange ROF_NCPL=\$ATM_NCPL ./xmlchange GLC_NCPL=\$ATM_NCPL ./xmlchange LND_DOMAIN_FILE="domain.lnd.mpasa480_gx1v7.201001.nc" +./xmlchange CLM_FORCE_COLDSTART=on diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 98d7244929..64c30c8e6f 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -73,7 +73,7 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) real(r8), pointer :: tracers(:,:,:) ! - ! mesh information and coefficients needed for + ! mesh information and coefficients needed for ! frontogenesis function calculation ! real(r8), dimension(:,:), pointer :: defc_a @@ -823,11 +823,11 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, end do do k = nVertLevels, 1, -1 - !hydrostatic mid-level pressure - MPAS full pressure is (rhok*rgas*thetavk*kap1)**kap2 - pmid (k,iCell) = 0.5_r8*(pint(k+1)+pint(k)) - !hydrostatic dry mid-level dry pressure - + !hydrostatic mid-level pressure - MPAS full pressure is (rhok*rgas*thetavk*kap1)**kap2 + pmid (k,iCell) = 0.5_r8*(pint(k+1)+pint(k)) + !hydrostatic dry mid-level dry pressure - !MPAS non-hydrostatic dry pressure is pmiddry(k,iCell) = (rhodryk*rgas*theta*kap1)**kap2 - pmiddry(k,iCell) = 0.5_r8*(pintdry(k+1,iCell)+pintdry(k,iCell)) + pmiddry(k,iCell) = 0.5_r8*(pintdry(k+1,iCell)+pintdry(k,iCell)) end do end do end subroutine hydrostatic_pressure @@ -935,15 +935,13 @@ subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, t end if end subroutine tot_energy - subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & - theta_m, qv, u,v, defc_a, defc_b, cell_gradient_coef_x, cell_gradient_coef_y, & - areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & - nVertLevels, nCellsSolve ) + subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & + theta_m, qv, u,v, defc_a, defc_b, cell_gradient_coef_x, cell_gradient_coef_y, & + areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & + nVertLevels, nCellsSolve ) use mpas_constants, only : rvord - implicit none - ! inputs integer, intent(in) :: nVertLevels, nCellsSolve @@ -958,10 +956,10 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, real(r8), dimension(:), intent(in) :: areaCell integer, dimension(:,:), intent(in) :: cellsOnEdge integer, dimension(:,:), intent(in) :: edgesOnCell - integer, dimension(:), intent(in) :: nEdgesOnCell + integer, dimension(:), intent(in) :: nEdgesOnCell ! outputs - + real(r8), dimension(:,:), intent(out) :: frontogenesisFunction real(r8), dimension(:,:), intent(out) :: frontogenesisAngle @@ -1004,9 +1002,9 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, do k=1,nVertLevels d_diag(k) = d_diag(k) + defc_a(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & - - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) d_off_diag(k) = d_off_diag(k) + defc_b(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & - + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) divh(k) = divh(k) + edge_sign * u(k,EdgesOnCell(iEdge,iCell)) thetaEdge = 0.5*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) @@ -1043,6 +1041,6 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, end do -end subroutine calc_frontogenesis + end subroutine calc_frontogenesis end module dp_coupling diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index d6a27c6bb6..a74d3a98f3 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -12,6 +12,7 @@ module cam_mpas_subdriver use cam_abortutils, only: endrun use mpas_derived_types, only : core_type, dm_info, domain_type, MPAS_Clock_type + use phys_control, only: use_gw_front, use_gw_front_igw implicit none @@ -382,7 +383,7 @@ subroutine cam_mpas_init_phase4(endrun) if ( ierr /= 0 ) then call endrun(subname//': failed to get MPAS_START_TIME') end if - call mpas_get_time(startTime, dateTimeString=startTimeStamp) + call mpas_get_time(startTime, dateTimeString=startTimeStamp) call mpas_pool_get_subpool(domain_ptr % blocklist % structs, 'state', state) @@ -438,7 +439,7 @@ end subroutine cam_mpas_init_phase4 !> to reorder the constituents; to allow for mapping of indices between CAM !> physics and the MPAS-A dycore, this routine returns index mapping arrays !> mpas_from_cam_cnst and cam_from_mpas_cnst. - !> + !> ! !----------------------------------------------------------------------- subroutine cam_mpas_define_scalars(block, mpas_from_cam_cnst, cam_from_mpas_cnst, ierr) @@ -770,7 +771,7 @@ subroutine cam_mpas_get_global_coords(latCellGlobal, lonCellGlobal, areaCellGlob allocate(temp(nCellsGlobal), stat=ierr) if( ierr /= 0 ) call endrun(subname//':failed to allocate temp array') - + ! ! latCellGlobal ! @@ -1047,8 +1048,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call mpas_pool_get_field(meshPool, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(meshPool, 'defc_a', defc_a) call mpas_pool_get_field(meshPool, 'defc_b', defc_b) - call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) - call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) + if (use_gw_front .or. use_gw_front_igw) then + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) + endif ierr_total = 0 @@ -1181,10 +1184,12 @@ subroutine cam_mpas_read_static(fh_ini, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(mesh_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(mesh_stream, cell_gradient_coef_x, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(mesh_stream, cell_gradient_coef_y, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + if (use_gw_front .or. use_gw_front_igw) then + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + endif if (ierr_total > 0) then write(errString, '(a,i0,a)') subname//': FATAL: Failed to add ', ierr_total, ' fields to static input stream.' @@ -1266,9 +1271,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call MPAS_dmpar_exch_halo_field(localVerticalUnitVectors) call MPAS_dmpar_exch_halo_field(defc_a) call MPAS_dmpar_exch_halo_field(defc_b) - call MPAS_dmpar_exch_halo_field(cell_gradient_coef_x) - call MPAS_dmpar_exch_halo_field(cell_gradient_coef_y) - + if (use_gw_front .or. use_gw_front_igw) then + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_x) + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_y) + endif ! ! Re-index from global index space to local index space ! @@ -1471,9 +1477,10 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) call mpas_pool_get_field(allFields, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(allFields, 'defc_a', defc_a) call mpas_pool_get_field(allFields, 'defc_b', defc_b) - call mpas_pool_get_field(allFields, 'cell_gradient_coef_x', cell_gradient_coef_x) - call mpas_pool_get_field(allFields, 'cell_gradient_coef_y', cell_gradient_coef_y) - + if (use_gw_front .or. use_gw_front_igw) then + call mpas_pool_get_field(allFields, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(allFields, 'cell_gradient_coef_y', cell_gradient_coef_y) + endif call mpas_pool_get_field(allFields, 'initial_time', initial_time, timeLevel=1) call mpas_pool_get_field(allFields, 'xtime', xtime, timeLevel=1) call mpas_pool_get_field(allFields, 'u', u, timeLevel=1) @@ -1643,11 +1650,12 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(restart_stream, cell_gradient_coef_x, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(restart_stream, cell_gradient_coef_y, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - + if (use_gw_front .or. use_gw_front_igw) then + call MPAS_streamAddField(restart_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(restart_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + endif call MPAS_streamAddField(restart_stream, initial_time, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, xtime, ierr=ierr) @@ -1857,9 +1865,10 @@ subroutine cam_mpas_read_restart(restart_stream, endrun) call cam_mpas_update_halo('localVerticalUnitVectors', endrun) call cam_mpas_update_halo('defc_a', endrun) call cam_mpas_update_halo('defc_b', endrun) - call cam_mpas_update_halo('cell_gradient_coef_x', endrun) - call cam_mpas_update_halo('cell_gradient_coef_y', endrun) - + if (use_gw_front .or. use_gw_front_igw) then + call cam_mpas_update_halo('cell_gradient_coef_x', endrun) + call cam_mpas_update_halo('cell_gradient_coef_y', endrun) + endif call cam_mpas_update_halo('u', endrun) call cam_mpas_update_halo('w', endrun) call cam_mpas_update_halo('rho_zz', endrun) @@ -2273,17 +2282,17 @@ subroutine cam_mpas_run(integrationLength) runUntilTime = currTime + integrationLength do while (currTime < runUntilTime) - call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr) + call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr) call mpas_log_write('Dynamics timestep beginning at '//trim(timeStamp)) call mpas_timer_start('time integration') call atm_do_timestep(domain_ptr, dt, itimestep) - call mpas_timer_stop('time integration') + call mpas_timer_stop('time integration') ! Move time level 2 fields back into time level 1 for next time step call mpas_pool_get_subpool(domain_ptr % blocklist % structs, 'state', state) call mpas_pool_shift_time_levels(state) - + ! Advance clock before writing output itimestep = itimestep + 1 call mpas_advance_clock(clock) From 8cc55751fa18d7d76686295100c04990bd3ea784 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 18 Aug 2022 13:34:58 -0600 Subject: [PATCH 05/24] Turn on frontogenesis GWs in WACCM-SC; add cheyenne tests modified: Externals_CAM.cfg modified: bld/namelist_files/namelist_defaults_cam.xml modified: cime_config/config_pes.xml modified: cime_config/testdefs/testlist_cam.xml modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 modified: src/dynamics/mpas/dyn_comp.F90 --- Externals_CAM.cfg | 4 ++-- bld/namelist_files/namelist_defaults_cam.xml | 13 +++++++++++ cime_config/config_pes.xml | 22 +++++++++++++++++++ cime_config/testdefs/testlist_cam.xml | 19 ++++++++++++++++ .../mpas/driver/cam_mpas_subdriver.F90 | 5 +++++ src/dynamics/mpas/dyn_comp.F90 | 9 +++++--- 6 files changed, 67 insertions(+), 5 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 9a2754171f..7301213d8b 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -64,9 +64,9 @@ required = True [mpas] local_path = src/dynamics/mpas/dycore protocol = git -repo_url = https://github.com/MPAS-Dev/MPAS-Model.git +repo_url = https://github.com/fvitt/MPAS-Model.git sparse = ../.mpas_sparse_checkout -hash = ff76a231 +branch = cell_grad_ff76a231 required = True [externals_description] diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 033fe8019a..13e0786394 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -246,6 +246,8 @@ atm/waccm/ic/FW2000_CONUS_30x8_L70_01-01-0001_c200602.nc +atm/waccm/ic/mpasa120km.waccm_fulltopo_c220818.nc + atm/cam/inic/mpas/cami_01-01-2000_00Z_mpasa120_L32_CFSR_c210426.nc atm/cam/inic/mpas/cami_01-01-2000_00Z_mpasa480_L32_CFSR_c211013.nc @@ -2970,6 +2972,17 @@ .false. .false. + 600.D0 + 4 + 120000.D0 + 80000.0D0 + 0.2D0 + 0.2D0 + 0.5D0 + 0.0D0 + .true. + 5.D0 + diff --git a/cime_config/config_pes.xml b/cime_config/config_pes.xml index f4b145ebdc..35e1347797 100644 --- a/cime_config/config_pes.xml +++ b/cime_config/config_pes.xml @@ -257,6 +257,28 @@ + + + + + 360 + 360 + 360 + 360 + 360 + 360 + + + 1 + 1 + 1 + 1 + 1 + 1 + + + + diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index fffe69590c..bda04b0432 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -1861,6 +1861,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index a74d3a98f3..16a9c4c176 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -968,6 +968,9 @@ subroutine cam_mpas_read_static(fh_ini, endrun) type (MPAS_Stream_type) :: mesh_stream + nullify(cell_gradient_coef_x) + nullify(cell_gradient_coef_y) + call MPAS_createStream(mesh_stream, domain_ptr % ioContext, 'not_used', MPAS_IO_NETCDF, MPAS_IO_READ, & pio_file_desc=fh_ini, ierr=ierr) @@ -1046,8 +1049,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call mpas_pool_get_field(meshPool, 'edgeNormalVectors', edgeNormalVectors) call mpas_pool_get_field(meshPool, 'localVerticalUnitVectors', localVerticalUnitVectors) + call mpas_pool_get_field(meshPool, 'defc_a', defc_a) call mpas_pool_get_field(meshPool, 'defc_b', defc_b) + if (use_gw_front .or. use_gw_front_igw) then call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index 689cfa51a8..a3a043c0ce 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -42,6 +42,8 @@ module dyn_comp use cam_mpas_subdriver, only: cam_mpas_global_sum_real +use phys_control, only: use_gw_front, use_gw_front_igw + implicit none private save @@ -322,7 +324,6 @@ subroutine dyn_register() use physics_buffer, only: pbuf_add_field, dtype_r8 use ppgrid, only: pcols, pver - use phys_control, only: use_gw_front, use_gw_front_igw ! These fields are computed by the dycore and passed to the physics via the ! physics buffer. @@ -524,8 +525,10 @@ subroutine dyn_init(dyn_in, dyn_out) call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) - call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) - call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + if (use_gw_front .or. use_gw_front_igw) then + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + endif call mpas_pool_get_array(mesh_pool, 'edgesOnCell_sign', dyn_out % edgesOnCell_sign) call mpas_pool_get_array(mesh_pool, 'dvEdge', dyn_out % dvEdge) call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) From ce145c9061287616117b072afe64324105224875 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 18 Aug 2022 21:45:06 -0600 Subject: [PATCH 06/24] fix restarts by haloing tracers; append constants with _r8 kind modified: src/dynamics/mpas/dp_coupling.F90 --- src/dynamics/mpas/dp_coupling.F90 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 64c30c8e6f..87fa728e94 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -40,6 +40,7 @@ module dp_coupling !========================================================================================= subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) + use cam_mpas_subdriver, only : cam_mpas_update_halo ! Convert the dynamics output state into the physics input state. ! Note that all pressures and tracer mixing ratios coming from the dycore are based on @@ -162,6 +163,7 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) pmiddry, pintdry, pmid) if (use_gw_front .or. use_gw_front_igw) then + call cam_mpas_update_halo('scalars', endrun) ! scalars is the name of tracers in the MPAS state pool nullify(pbuf_chnk) nullify(pbuf_frontgf) nullify(pbuf_frontga) @@ -978,11 +980,11 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, do iCell = cellStart,cellEnd - d_diag(1:nVertLevels) = 0.0 - d_off_diag(1:nVertLevels) = 0.0 - divh(1:nVertLevels) = 0.0 - theta_x(1:nVertLevels) = 0.0 - theta_y(1:nVertLevels) = 0.0 + d_diag(1:nVertLevels) = 0.0_r8 + d_off_diag(1:nVertLevels) = 0.0_r8 + divh(1:nVertLevels) = 0.0_r8 + theta_x(1:nVertLevels) = 0.0_r8 + theta_y(1:nVertLevels) = 0.0_r8 ! ! Integrate over edges to compute cell-averaged divergence, deformation, @@ -1006,8 +1008,8 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, d_off_diag(k) = d_off_diag(k) + defc_b(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) divh(k) = divh(k) + edge_sign * u(k,EdgesOnCell(iEdge,iCell)) - thetaEdge = 0.5*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & - +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) + thetaEdge = 0.5_r8*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & + +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) theta_x(k) = theta_x(k) + cell_gradient_coef_x(iEdge,iCell)*thetaEdge theta_y(k) = theta_y(k) + cell_gradient_coef_y(iEdge,iCell)*thetaEdge @@ -1030,10 +1032,10 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, !DIR$ IVDEP do k=1, nVertLevels - frontogenesisFunction(k,iCell) = 0.5*( & + frontogenesisFunction(k,iCell) = 0.5_r8*( & -divh(k)*(theta_x(k)**2 + theta_y(k)**2) & -d_diag(k)*theta_x(k)**2 & - -2.0*d_off_diag(k)*theta_x(k)*theta_y(k) & + -2.0_r8*d_off_diag(k)*theta_x(k)*theta_y(k) & +d_diag(k)*theta_y(k)**2 ) frontogenesisAngle(k,iCell) = atan2(theta_y(k),theta_x(k)) From 977dafe2b60b4b7497eb2a0f19a3b7e703beff68 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 1 Sep 2022 10:40:48 -0600 Subject: [PATCH 07/24] some code clean up modified: src/dynamics/mpas/dp_coupling.F90 modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 modified: src/dynamics/mpas/dyn_comp.F90 modified: src/dynamics/mpas/dyn_grid.F90 --- src/dynamics/mpas/dp_coupling.F90 | 51 +++++------------ .../mpas/driver/cam_mpas_subdriver.F90 | 57 +++---------------- src/dynamics/mpas/dyn_comp.F90 | 26 +++------ src/dynamics/mpas/dyn_grid.F90 | 2 +- 4 files changed, 30 insertions(+), 106 deletions(-) diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 87fa728e94..9ecd4dfd01 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -8,23 +8,18 @@ module dp_coupling use pmgrid, only: plev use ppgrid, only: begchunk, endchunk, pcols, pver, pverp use constituents, only: pcnst, cnst_type -use physconst, only: gravit, cpairv, cappa, rairv, rh2o, zvir - -use spmd_dyn, only: local_dp_map, block_buf_nrecs, chunk_buf_nrecs -use spmd_utils, only: mpicom, iam, masterproc - +use physconst, only: gravit, cpairv, cappa, zvir use dyn_comp, only: dyn_export_t, dyn_import_t - use physics_types, only: physics_state, physics_tend, physics_cnst_limit -use phys_grid, only: get_dyn_col_p, get_chunk_info_p, get_ncols_p, get_gcol_all_p +use phys_grid, only: get_dyn_col_p, get_chunk_info_p, get_ncols_p use phys_grid, only: columns_on_task use physics_buffer, only: physics_buffer_desc, pbuf_get_chunk, pbuf_get_field -use cam_logfile, only: iulog -use perf_mod, only: t_startf, t_stopf, t_barrierf +use perf_mod, only: t_startf, t_stopf use cam_abortutils, only: endrun -use physconst, only: thermodynamic_active_species_num,thermodynamic_active_species_idx,thermodynamic_active_species_idx_dycore +use physconst, only: thermodynamic_active_species_num,thermodynamic_active_species_idx, & + thermodynamic_active_species_idx_dycore implicit none private save @@ -105,15 +100,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) type(physics_buffer_desc), pointer :: pbuf_chnk(:) integer :: lchnk, icol, icol_p, k, kk ! indices over chunks, columns, physics columns and layers - integer :: i, m, ncols, blockid + integer :: i, m, ncols integer :: block_index integer, dimension(:), pointer :: block_offset - integer :: pgcols(pcols) - integer :: tsize ! amount of data per grid point passed to physics - integer, allocatable :: bpter(:,:) ! offsets into block buffer for packing data - integer, allocatable :: cpter(:,:) ! offsets into chunk buffer for unpacking data - real(r8), allocatable:: pmid(:,:) !mid-level hydrostatic pressure consistent with MPAS discrete state real(r8), allocatable:: pintdry(:,:) !interface hydrostatic pressure consistent with MPAS discrete state real(r8), allocatable:: pmiddry(:,:) !mid-level hydrostatic dry pressure consistent with MPAS discrete state @@ -300,7 +290,7 @@ subroutine p_d_coupling(phys_state, phys_tend, dyn_in) ! Local variables integer :: lchnk, icol, icol_p, k, kk ! indices over chunks, columns, layers - integer :: i, m, ncols, blockid + integer :: i, m, ncols integer :: block_index integer, dimension(:), pointer :: block_offset @@ -310,7 +300,6 @@ subroutine p_d_coupling(phys_state, phys_tend, dyn_in) ! Variables from dynamics import container integer :: nCellsSolve integer :: nCells - integer :: nEdgesSolve integer :: index_qv integer, dimension(:), pointer :: mpas_from_cam_cnst @@ -324,11 +313,6 @@ subroutine p_d_coupling(phys_state, phys_tend, dyn_in) integer :: idx_phys, idx_dycore - integer :: pgcols(pcols) - integer :: tsize ! amount of data per grid point passed to dynamics - integer, allocatable :: bpter(:,:) ! offsets into block buffer for unpacking data - integer, allocatable :: cpter(:,:) ! offsets into chunk buffer for packing data - type (mpas_pool_type), pointer :: tend_physics type (field2DReal), pointer :: tend_uzonal, tend_umerid @@ -441,7 +425,7 @@ subroutine derived_phys(phys_state, phys_tend, pbuf2d) ! Local variables - integer :: i, k, lchnk, m, ncol + integer :: k, lchnk, m, ncol real(r8) :: factor(pcols,pver) real(r8) :: zvirv(pcols,pver) @@ -605,13 +589,11 @@ subroutine derived_tend(nCellsSolve, nCells, t_tend, u_tend, v_tend, q_tend, dyn real(r8), pointer :: north(:,:) integer, pointer :: cellsOnEdge(:,:) - real(r8), pointer :: theta(:,:) - real(r8), pointer :: exner(:,:) real(r8), pointer :: rho_zz(:,:) real(r8), pointer :: tracers(:,:,:) integer :: index_qv,m,idx_dycore - real(r8) :: rhok,thetavk,thetak,pk,exnerk,tempk,tempk_new,exnerk_new,thetak_new,thetak_m_new,rhodk,tknew,thetaknew + real(r8) :: thetak,exnerk,rhodk,tknew,thetaknew ! ! variables for energy diagnostics ! @@ -625,7 +607,6 @@ subroutine derived_tend(nCellsSolve, nCells, t_tend, u_tend, v_tend, q_tend, dyn real(r8) :: qk (thermodynamic_active_species_num,pver,nCellsSolve) !water species before physics (diagnostics) real(r8) :: qwv(pver,nCellsSolve) !water vapor before physics real(r8) :: facnew, facold - real(r8), allocatable :: tracers_old(:,:,:) integer :: iCell,k @@ -642,8 +623,6 @@ subroutine derived_tend(nCellsSolve, nCells, t_tend, u_tend, v_tend, q_tend, dyn normal => dyn_in % normal cellsOnEdge => dyn_in % cellsOnEdge - theta => dyn_in % theta - exner => dyn_in % exner rho_zz => dyn_in % rho_zz tracers => dyn_in % tracers index_qv = dyn_in % index_qv @@ -771,8 +750,7 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, ! The vertical dimension for 3-d arrays is innermost, and k=1 represents ! the lowest layer or level in the fields. ! - use mpas_constants, only : cp, rgas, cv, gravity, p0, Rv_over_Rd => rvord - use physconst, only: rair, cpair + use mpas_constants, only : cp, rgas, cv, gravity, p0 ! Arguments integer, intent(in) :: nCells @@ -790,8 +768,7 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, integer :: iCell, k real(r8), dimension(nVertLevels) :: dz ! Geometric layer thickness in column real(r8), dimension(nVertLevels+1) :: pint ! hydrostatic pressure at interface - real(r8) :: pi, t - real(r8) :: pk,rhok,rhodryk,theta,thetavk,kap1,kap2 + real(r8) :: pk,rhok,rhodryk,thetavk,kap1,kap2 ! ! For each column, integrate downward from model top to compute dry hydrostatic pressure at layer @@ -836,7 +813,7 @@ end subroutine hydrostatic_pressure subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, theta_m, q, ux,uy,outfld_name_suffix) - use physconst, only: rair, cpair, gravit,cappa!=R/cp (dry air) + use physconst, only: gravit use physconst, only: thermodynamic_active_species_liq_num use mpas_constants, only: p0,cv,rv,rgas,cp use cam_history, only: outfld, hist_fld_active @@ -859,9 +836,9 @@ subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, t ! Local variables integer :: iCell, k, idx - real(r8) :: rho_dz,zcell,temperature,theta,pk,ptop,exner + real(r8) :: rho_dz,zcell,temperature,theta,exner real(r8), dimension(nVertLevels, nCells) :: rhod, dz - real(r8), dimension(nCells) :: kinetic_energy,potential_energy,internal_energy,water_vapor,water_liq,water_ice + real(r8), dimension(nCells) :: kinetic_energy,potential_energy,internal_energy,water_vapor real(r8), dimension(nCells) :: liq !total column integrated liquid real(r8), dimension(nCells) :: ice !total column integrated ice diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index 16a9c4c176..39b0eb63ee 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -11,7 +11,7 @@ module cam_mpas_subdriver !------------------------------------------------------------------------------- use cam_abortutils, only: endrun - use mpas_derived_types, only : core_type, dm_info, domain_type, MPAS_Clock_type + use mpas_derived_types, only : core_type, domain_type, MPAS_Clock_type use phys_control, only: use_gw_front, use_gw_front_igw implicit none @@ -76,7 +76,6 @@ subroutine cam_mpas_init_phase1(mpicom, endrun, logUnits, realkind) use mpas_domain_routines, only : mpas_allocate_domain use mpas_framework, only : mpas_framework_init_phase1 use atm_core_interface, only : atm_setup_core, atm_setup_domain - use mpas_pool_routines, only : mpas_pool_add_config use mpas_kind_types, only : RKIND ! Dummy argument @@ -148,7 +147,6 @@ end subroutine cam_mpas_init_phase1 !----------------------------------------------------------------------- subroutine cam_mpas_init_phase2(pio_subsystem, endrun, cam_calendar) - use mpas_log, only : mpas_log_write use mpas_kind_types, only : ShortStrKIND use pio_types, only : iosystem_desc_t @@ -160,7 +158,6 @@ subroutine cam_mpas_init_phase2(pio_subsystem, endrun, cam_calendar) character(len=*), intent(in) :: cam_calendar integer :: ierr - logical :: streamsExists character(len=ShortStrKIND) :: mpas_calendar @@ -222,52 +219,19 @@ end subroutine cam_mpas_init_phase2 !> the number of constituents. ! !----------------------------------------------------------------------- - subroutine cam_mpas_init_phase3(fh_ini, num_scalars, endrun) + subroutine cam_mpas_init_phase3(fh_ini, num_scalars) - use mpas_log, only : mpas_log_write use pio, only : file_desc_t - use iso_c_binding, only : c_int, c_char, c_ptr, c_loc - - use mpas_derived_types, only : MPAS_Time_type, MPAS_TimeInterval_type - use mpas_derived_types, only : MPAS_IO_PNETCDF, MPAS_IO_PNETCDF5, MPAS_IO_NETCDF, MPAS_IO_NETCDF4 - use mpas_derived_types, only : MPAS_START_TIME - use mpas_derived_types, only : MPAS_STREAM_MGR_NOERR - use mpas_timekeeping, only : mpas_get_clock_time, mpas_get_time, mpas_expand_string, mpas_set_time, & - mpas_set_timeInterval - use mpas_stream_manager, only : MPAS_stream_mgr_init, mpas_build_stream_filename, MPAS_stream_mgr_validate_streams - use mpas_kind_types, only : StrKIND - use mpas_c_interfacing, only : mpas_c_to_f_string, mpas_f_to_c_string + use mpas_derived_types, only : MPAS_IO_NETCDF + use mpas_kind_types, only : StrKIND use mpas_bootstrapping, only : mpas_bootstrap_framework_phase1, mpas_bootstrap_framework_phase2 use mpas_pool_routines, only : mpas_pool_add_config type (file_desc_t), intent(inout) :: fh_ini integer, intent(in) :: num_scalars - procedure(halt_model) :: endrun - integer :: ierr - character(kind=c_char), dimension(StrKIND+1) :: c_filename ! StrKIND+1 for C null-termination character - integer(kind=c_int) :: c_comm - integer(kind=c_int) :: c_ierr - type (c_ptr) :: mgr_p - character(len=StrKIND) :: mesh_stream character(len=StrKIND) :: mesh_filename - character(len=StrKIND) :: mesh_filename_temp - character(len=StrKIND) :: ref_time_temp - character(len=StrKIND) :: filename_interval_temp - character(kind=c_char), dimension(StrKIND+1) :: c_mesh_stream - character(kind=c_char), dimension(StrKIND+1) :: c_mesh_filename_temp - character(kind=c_char), dimension(StrKIND+1) :: c_ref_time_temp - character(kind=c_char), dimension(StrKIND+1) :: c_filename_interval_temp - character(kind=c_char), dimension(StrKIND+1) :: c_iotype - type (MPAS_Time_type) :: start_time - type (MPAS_Time_type) :: ref_time - type (MPAS_TimeInterval_type) :: filename_interval - character(len=StrKIND) :: start_timestamp - character(len=StrKIND) :: iotype - logical :: streamsExists integer :: mesh_iotype - integer :: blockID - character(len=StrKIND) :: timeStamp character(len=*), parameter :: subname = 'cam_mpas_subdriver::cam_mpas_init_phase3' @@ -321,8 +285,6 @@ subroutine cam_mpas_init_phase4(endrun) real (kind=RKIND), pointer :: dt - character(len=StrKIND) :: timeStamp - integer :: i logical, pointer :: config_do_restart type (mpas_pool_type), pointer :: state @@ -736,7 +698,7 @@ subroutine cam_mpas_get_global_coords(latCellGlobal, lonCellGlobal, areaCellGlob use mpas_pool_routines, only : mpas_pool_get_subpool, mpas_pool_get_dimension, mpas_pool_get_array use mpas_derived_types, only : mpas_pool_type use mpas_kind_types, only : RKIND - use mpas_dmpar, only : mpas_dmpar_sum_int, mpas_dmpar_max_int, mpas_dmpar_max_real_array + use mpas_dmpar, only : mpas_dmpar_sum_int, mpas_dmpar_max_real_array real (kind=RKIND), dimension(:), intent(out) :: latCellGlobal real (kind=RKIND), dimension(:), intent(out) :: lonCellGlobal @@ -1778,8 +1740,6 @@ end subroutine cam_mpas_setup_restart !----------------------------------------------------------------------- subroutine cam_mpas_read_restart(restart_stream, endrun) - use pio, only : file_desc_t - use mpas_io_streams, only : MPAS_readStream, MPAS_closeStream use mpas_derived_types, only : MPAS_Stream_type, MPAS_pool_type, MPAS_STREAM_NOERR use mpas_pool_routines, only : MPAS_pool_create_pool, MPAS_pool_destroy_pool, MPAS_pool_add_config @@ -1943,8 +1903,6 @@ end subroutine cam_mpas_read_restart !----------------------------------------------------------------------- subroutine cam_mpas_write_restart(restart_stream, endrun) - use pio, only : file_desc_t - use mpas_io_streams, only : MPAS_writeStream, MPAS_closeStream use mpas_derived_types, only : MPAS_Stream_type, MPAS_pool_type, MPAS_STREAM_NOERR use mpas_pool_routines, only : MPAS_pool_create_pool, MPAS_pool_destroy_pool, MPAS_pool_add_config @@ -2389,11 +2347,10 @@ subroutine cam_mpas_debug_stream(domain, filename, timeLevel) use mpas_derived_types, only : MPAS_IO_WRITE, MPAS_IO_NETCDF, MPAS_STREAM_NOERR, MPAS_Stream_type, MPAS_pool_type, & field0DReal, field1DReal, field2DReal, field3DReal, field4DReal, field5DReal, & field1DInteger, field2DInteger, field3DInteger - use mpas_pool_routines, only : MPAS_pool_get_subpool, MPAS_pool_get_field, MPAS_pool_create_pool, MPAS_pool_destroy_pool, & - MPAS_pool_add_config + use mpas_pool_routines, only : MPAS_pool_get_field use mpas_derived_types, only : MPAS_Pool_iterator_type, MPAS_POOL_FIELD, MPAS_POOL_REAL, MPAS_POOL_INTEGER - use mpas_pool_routines, only : mpas_pool_begin_iteration, mpas_pool_get_next_member, mpas_pool_get_config + use mpas_pool_routines, only : mpas_pool_begin_iteration, mpas_pool_get_next_member type (domain_type), intent(inout) :: domain character(len=*), intent(in) :: filename diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index a3a043c0ce..88a556dfe8 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -3,7 +3,7 @@ module dyn_comp ! CAM component interfaces to the MPAS Dynamical Core use shr_kind_mod, only: r8=>shr_kind_r8 -use spmd_utils, only: iam, masterproc, mpicom, npes +use spmd_utils, only: masterproc, mpicom, npes use physconst, only: pi, gravit, rair, cpair use pmgrid, only: plev, plevp @@ -13,23 +13,18 @@ module dyn_comp use cam_control_mod, only: initial_run use cam_initfiles, only: initial_file_get_id, topo_file_get_id -use cam_grid_support, only: cam_grid_id, cam_grid_get_gcid, & - cam_grid_dimensions, cam_grid_get_dim_names, & - cam_grid_get_latvals, cam_grid_get_lonvals, & - max_hcoordname_len +use cam_grid_support, only: cam_grid_id, & + cam_grid_get_latvals, cam_grid_get_lonvals use cam_map_utils, only: iMap use inic_analytic, only: analytic_ic_active, dyn_set_inic_col use dyn_tests_utils, only: vcoord=>vc_height -use cam_history, only: addfld, add_default, horiz_only, register_vector_field, & - outfld, hist_fld_active -use cam_history_support, only: max_fieldname_len +use cam_history, only: addfld, horiz_only use string_utils, only: date2yyyymmdd, sec2hms, int2str use ncdio_atm, only: infld -use pio, only: file_desc_t, pio_seterrorhandling, PIO_BCAST_ERROR, & - pio_inq_dimid, pio_inq_dimlen, PIO_NOERR +use pio, only: file_desc_t use cam_pio_utils, only: clean_iodesc_list use time_manager, only: get_start_date, get_stop_date, get_run_duration, & @@ -277,11 +272,8 @@ subroutine dyn_readnl(NLFileName) character(len=*), intent(in) :: NLFileName ! Local variables - integer :: ierr integer, dimension(2) :: logUnits ! stdout and stderr for MPAS logging integer :: yr, mon, day, tod, ndate, nday, nsec - character(len=10) :: date_str - character(len=8) :: tod_str character(len=*), parameter :: subname = 'dyn_comp:dyn_readnl' !---------------------------------------------------------------------------- @@ -353,7 +345,7 @@ subroutine dyn_init(dyn_in, dyn_out) use mpas_derived_types, only : mpas_pool_type use mpas_constants, only : mpas_constants_compute_derived use dyn_tests_utils, only : vc_dycore, vc_height, string_vc, vc_str_lgth - use constituents, only : cnst_get_ind + ! arguments: type(dyn_import_t), intent(inout) :: dyn_in type(dyn_export_t), intent(inout) :: dyn_out @@ -762,7 +754,7 @@ subroutine read_inidat(dyn_in) use cam_mpas_subdriver, only : domain_ptr, cam_mpas_update_halo, cam_mpas_cell_to_edge_winds use cam_initfiles, only : scale_dry_air_mass - use mpas_pool_routines, only : mpas_pool_get_subpool, mpas_pool_get_array, mpas_pool_get_config + use mpas_pool_routines, only : mpas_pool_get_subpool, mpas_pool_get_array use mpas_derived_types, only : mpas_pool_type use mpas_vector_reconstruction, only : mpas_reconstruct use mpas_constants, only : Rv_over_Rd => rvord @@ -820,7 +812,6 @@ subroutine read_inidat(dyn_in) real(r8), allocatable :: qv(:), tm(:) - real(r8) :: dz, h logical :: readvar character(len=shr_kind_cx) :: str @@ -1314,7 +1305,7 @@ subroutine cam_mpas_namelist_read(namelistFilename, configPool) ! if no errors were encountered, all MPI ranks have valid namelists in their configPool. use spmd_utils, only: mpicom, masterproc, masterprocid, & - mpi_integer, mpi_real8, mpi_logical, mpi_character, mpi_success + mpi_integer, mpi_real8, mpi_logical, mpi_character use namelist_utils, only: find_group_name use mpas_derived_types, only: mpas_pool_type @@ -1763,7 +1754,6 @@ subroutine set_dry_mass(dyn_in, target_avg_dry_surface_pressure) real(r8) :: preliminary_avg_dry_surface_pressure, scaled_avg_dry_surface_pressure real(r8) :: scaling_ratio real(r8) :: sphere_surface_area - real(r8) :: surface_integral, test_value integer :: ixqv,ierr diff --git a/src/dynamics/mpas/dyn_grid.F90 b/src/dynamics/mpas/dyn_grid.F90 index c8efc66123..78d686283a 100644 --- a/src/dynamics/mpas/dyn_grid.F90 +++ b/src/dynamics/mpas/dyn_grid.F90 @@ -130,7 +130,7 @@ subroutine dyn_grid_init() ! MPAS-A always requires at least one scalar (qv). CAM has the same requirement ! and it is enforced by the configure script which sets the cpp macrop PCNST. - call cam_mpas_init_phase3(fh_ini, pcnst, endrun) + call cam_mpas_init_phase3(fh_ini, pcnst) ! Read or compute all time-invariant fields for the MPAS-A dycore ! Time-invariant fields are stored in the MPAS mesh pool. This call From 0cf06c6da32baf2df8677240ead5d6a7cf681a12 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Fri, 4 Nov 2022 09:00:42 -0600 Subject: [PATCH 08/24] fix bug in Z3GM diagnostic modified: src/ionosphere/waccmx/ionosphere_interface.F90 --- src/ionosphere/waccmx/ionosphere_interface.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ionosphere/waccmx/ionosphere_interface.F90 b/src/ionosphere/waccmx/ionosphere_interface.F90 index 69c28739dd..86735a8020 100644 --- a/src/ionosphere/waccmx/ionosphere_interface.F90 +++ b/src/ionosphere/waccmx/ionosphere_interface.F90 @@ -740,7 +740,7 @@ subroutine ionosphere_run2(phys_state, pbuf2d) ! Might need geometric height on midpoints for output !------------------------------------------------------------ if (hist_fld_active('Z3GM')) then - r8tmp = phys_state(lchnk)%zm(i, k) + r8tmp = phys_state(lchnk)%zm(i, k) + phis(i)/gravit tempm(i, k) = r8tmp * (1._r8 + (r8tmp * rearth_inv)) end if ! physics state fields on interfaces (but only to pver) From 049054f66731808687c2e4053462c1e78d8cfb1e Mon Sep 17 00:00:00 2001 From: Bill Skamarock Date: Fri, 10 Dec 2021 17:11:08 -0700 Subject: [PATCH 09/24] Added coefficient arrays used to compute the horizontal gradients of cell-centered variables to the input and restart streams for the MPAS dynamical core. --- .../mpas/driver/cam_mpas_subdriver.F90 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index 65a098f90e..d6a27c6bb6 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -963,6 +963,7 @@ subroutine cam_mpas_read_static(fh_ini, endrun) type (field3DReal), pointer :: zb, zb3, deriv_two, cellTangentPlane, coeffs_reconstruct type (field2DReal), pointer :: edgeNormalVectors, localVerticalUnitVectors, defc_a, defc_b + type (field2DReal), pointer :: cell_gradient_coef_x, cell_gradient_coef_y type (MPAS_Stream_type) :: mesh_stream @@ -1046,6 +1047,8 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call mpas_pool_get_field(meshPool, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(meshPool, 'defc_a', defc_a) call mpas_pool_get_field(meshPool, 'defc_b', defc_b) + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) ierr_total = 0 @@ -1178,6 +1181,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(mesh_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 if (ierr_total > 0) then write(errString, '(a,i0,a)') subname//': FATAL: Failed to add ', ierr_total, ' fields to static input stream.' @@ -1259,6 +1266,8 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call MPAS_dmpar_exch_halo_field(localVerticalUnitVectors) call MPAS_dmpar_exch_halo_field(defc_a) call MPAS_dmpar_exch_halo_field(defc_b) + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_x) + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_y) ! ! Re-index from global index space to local index space @@ -1342,6 +1351,7 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) type (field3DReal), pointer :: zb, zb3, deriv_two, cellTangentPlane, coeffs_reconstruct type (field2DReal), pointer :: edgeNormalVectors, localVerticalUnitVectors, defc_a, defc_b + type (field2DReal), pointer :: cell_gradient_coef_x, cell_gradient_coef_y type (field0DChar), pointer :: initial_time type (field0DChar), pointer :: xtime @@ -1461,6 +1471,8 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) call mpas_pool_get_field(allFields, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(allFields, 'defc_a', defc_a) call mpas_pool_get_field(allFields, 'defc_b', defc_b) + call mpas_pool_get_field(allFields, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(allFields, 'cell_gradient_coef_y', cell_gradient_coef_y) call mpas_pool_get_field(allFields, 'initial_time', initial_time, timeLevel=1) call mpas_pool_get_field(allFields, 'xtime', xtime, timeLevel=1) @@ -1631,6 +1643,10 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(restart_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(restart_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, initial_time, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 @@ -1841,6 +1857,8 @@ subroutine cam_mpas_read_restart(restart_stream, endrun) call cam_mpas_update_halo('localVerticalUnitVectors', endrun) call cam_mpas_update_halo('defc_a', endrun) call cam_mpas_update_halo('defc_b', endrun) + call cam_mpas_update_halo('cell_gradient_coef_x', endrun) + call cam_mpas_update_halo('cell_gradient_coef_y', endrun) call cam_mpas_update_halo('u', endrun) call cam_mpas_update_halo('w', endrun) From 5c655a6076899f0edd6c2a7ed344b522e223dec7 Mon Sep 17 00:00:00 2001 From: Bill Skamarock Date: Mon, 13 Dec 2021 15:24:24 -0700 Subject: [PATCH 10/24] Added MPAS mesh information and coefficients for computing the frontogenesis function to the dynamics export state for use in d_p_coupling (where the frontogenesis function and angle are computed). --- src/dynamics/mpas/dyn_comp.F90 | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index d4ff112434..6f53a32763 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -131,7 +131,6 @@ module dyn_comp ! of the sphere [dimensionless] (3,ncol) integer, dimension(:,:), pointer :: cellsOnEdge ! Indices of cells separated by an edge (2,nedge) - ! ! State that may be directly derived from dycore prognostic state ! @@ -198,6 +197,19 @@ module dyn_comp real(r8), dimension(:), pointer :: fzp ! Interp weight from k-1 layer midpoint to k ! layer interface [dimensionless] (nver) + ! + ! Invariant -- needed for computing the frontogenesis function + ! + real(r8), dimension(:,:), pointer :: defc_a + real(r8), dimension(:,:), pointer :: defc_b + real(r8), dimension(:,:), pointer :: cell_gradient_coef_x + real(r8), dimension(:,:), pointer :: cell_gradient_coef_y + real(r8), dimension(:,:), pointer :: edgesOnCell_sign + real(r8), dimension(:), pointer :: dvEdge + + integer, dimension(:,:), pointer :: edgesOnCell + integer, dimension(:), pointer :: nEdgesOnCell + ! ! State that may be directly derived from dycore prognostic state ! @@ -480,6 +492,19 @@ subroutine dyn_init(dyn_in, dyn_out) dyn_out % ux => dyn_in % ux dyn_out % uy => dyn_in % uy + ! components only needed in output, no time level index + + call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) + call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + call mpas_pool_get_array(mesh_pool, 'edgesOnCell_sign', dyn_out % edgesOnCell_sign) + call mpas_pool_get_array(mesh_pool, 'dvEdge', dyn_out % dvEdge) + call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) + call mpas_pool_get_array(mesh_pool, 'nEdgesOnCell', dyn_out % nEdgesOnCell) + + ! cam-required hydrostatic pressures + allocate(dyn_out % pmiddry(nVertLevels, nCells), stat=ierr) if( ierr /= 0 ) call endrun(subname//': failed to allocate dyn_out%pmiddry array') From 34ece99b8421ee50ea6cb87b52c92e0fecc49db7 Mon Sep 17 00:00:00 2001 From: Bill Skamarock Date: Thu, 23 Dec 2021 12:14:24 -0700 Subject: [PATCH 11/24] Added the option to compute the frontogenesis function and the angle of del(theta) needed by the gravity-wave drag parameterization. --- src/dynamics/mpas/dp_coupling.F90 | 211 +++++++++++++++++++++++++++++- src/dynamics/mpas/dyn_comp.F90 | 25 +++- 2 files changed, 233 insertions(+), 3 deletions(-) diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 2037a820cb..c27cd183ae 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -45,8 +45,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) ! Convert the dynamics output state into the physics input state. ! Note that all pressures and tracer mixing ratios coming from the dycore are based on ! dry air mass. - use cam_history, only : hist_fld_active - use mpas_constants, only : Rv_over_Rd => rvord + use cam_history, only: hist_fld_active + use dyn_comp, only: frontgf_idx, frontga_idx + use mpas_constants, only: Rv_over_Rd => rvord + use phys_control, only: use_gw_front, use_gw_front_igw ! arguments type(physics_state), intent(inout) :: phys_state(begchunk:endchunk) @@ -71,6 +73,36 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) real(r8), pointer :: theta_m(:,:) real(r8), pointer :: tracers(:,:,:) + ! + ! mesh information and coefficients needed for + ! frontogenesis function calculation + ! + real(r8), dimension(:,:), pointer :: defc_a + real(r8), dimension(:,:), pointer :: defc_b + real(r8), dimension(:,:), pointer :: cell_gradient_coef_x + real(r8), dimension(:,:), pointer :: cell_gradient_coef_y + real(r8), dimension(:,:), pointer :: edgesOnCell_sign + real(r8), dimension(:), pointer :: dvEdge + real(r8), dimension(:), pointer :: areaCell + + integer, dimension(:,:), pointer :: cellsOnEdge + integer, dimension(:,:), pointer :: edgesOnCell + integer, dimension(:), pointer :: nEdgesOnCell + + real(r8), dimension(:,:), pointer :: uperp + real(r8), dimension(:,:), pointer :: utangential + + ! + ! local storage for frontogenesis function and angle + ! + real(r8), dimension(:,:), pointer :: frontogenesisFunction + real(r8), dimension(:,:), pointer :: frontogenesisAngle + real(r8), dimension(:,:), pointer :: pbuf_frontgf + real(r8), dimension(:,:), pointer :: pbuf_frontga + real(r8), allocatable :: frontgf_phys(:,:,:) + real(r8), allocatable :: frontga_phys(:,:,:) + + type(physics_buffer_desc), pointer :: pbuf_chnk(:) integer :: lchnk, icol, icol_p, k, kk ! indices over chunks, columns, physics columns and layers integer :: i, m, ncols, blockid @@ -130,6 +162,45 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) nCellsSolve, plev, zz, zint, rho_zz, theta_m, tracers(index_qv,:,:),& pmiddry, pintdry, pmid) + if (use_gw_front .or. use_gw_front_igw) then + nullify(pbuf_chnk) + nullify(pbuf_frontgf) + nullify(pbuf_frontga) + ! + ! compute frontogenesis function and angle for gravity wave scheme + ! + defc_a => dyn_out % defc_a + defc_b => dyn_out % defc_b + cell_gradient_coef_x => dyn_out % cell_gradient_coef_x + cell_gradient_coef_y => dyn_out % cell_gradient_coef_y + edgesOnCell_sign => dyn_out % edgesOnCell_sign + dvEdge => dyn_out % dvEdge + areaCell => dyn_out % areaCell + cellsOnEdge => dyn_out % cellsOnEdge + edgesOnCell => dyn_out % edgesOnCell + nEdgesOnCell => dyn_out % nEdgesOnCell + uperp => dyn_out % uperp + utangential => dyn_out % utangential + + allocate(frontogenesisFunction(plev, nCellsSolve), stat=ierr) + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisFunction array') + allocate(frontogenesisAngle(plev, nCellsSolve), stat=ierr) + + allocate(frontgf_phys(pcols, pver, begchunk:endchunk)) + allocate(frontga_phys(pcols, pver, begchunk:endchunk)) + + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisAngle array') + + call calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & + theta_m, tracers(index_qv,:,:), & + uperp, utangential, defc_a, defc_b, & + cell_gradient_coef_x, cell_gradient_coef_y, & + areaCell, dvEdge, cellsOnEdge, edgesOnCell, & + nEdgesOnCell, edgesOnCell_sign, & + plev, nCellsSolve ) + + end if + call t_startf('dpcopy') ncols = columns_on_task @@ -155,6 +226,11 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) phys_state(lchnk)%omega(icol_p,k) = -rho_zz(kk,i)*zz(kk,i)*gravit*0.5_r8*(w(kk,i)+w(kk+1,i)) ! omega phys_state(lchnk)%pmiddry(icol_p,k) = pmiddry(kk,i) phys_state(lchnk)%pmid(icol_p,k) = pmid(kk,i) + + if (use_gw_front .or. use_gw_front_igw) then + frontgf_phys(icol_p, k, lchnk) = frontogenesisFunction(kk, i) + frontga_phys(icol_p, k, lchnk) = frontogenesisAngle(kk, i) + end if end do do k = 1, pverp @@ -170,6 +246,25 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) end do end do + if (use_gw_front .or. use_gw_front_igw) then + + !$omp parallel do private (lchnk, ncols, icol, k, pbuf_chnk, pbuf_frontgf, pbuf_frontga) + do lchnk = begchunk, endchunk + ncols = get_ncols_p(lchnk) + pbuf_chnk => pbuf_get_chunk(pbuf2d, lchnk) + call pbuf_get_field(pbuf_chnk, frontgf_idx, pbuf_frontgf) + call pbuf_get_field(pbuf_chnk, frontga_idx, pbuf_frontga) + do icol = 1, ncols + do k = 1, pver + pbuf_frontgf(icol, k) = frontgf_phys(icol, k, lchnk) + pbuf_frontga(icol, k) = frontga_phys(icol, k, lchnk) + end do + end do + end do + deallocate(frontgf_phys) + deallocate(frontga_phys) + end if + call t_stopf('dpcopy') call t_startf('derived_phys') @@ -178,6 +273,8 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) deallocate(pmid,pintdry,pmiddry) + if (use_gw_front .or. use_gw_front_igw) deallocate(frontogenesisFunction, frontogenesisAngle) + end subroutine d_p_coupling !========================================================================================= @@ -839,4 +936,114 @@ subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, t end if end subroutine tot_energy + subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & + theta_m, qv, u,v, defc_a, defc_b, cell_gradient_coef_x, cell_gradient_coef_y, & + areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & + nVertLevels, nCellsSolve ) + + use mpas_constants, only : rvord + + implicit none + + ! inputs + + integer, intent(in) :: nVertLevels, nCellsSolve + real(r8), dimension(:,:), intent(in) :: theta_m, qv + real(r8), dimension(:,:), intent(in) :: u, v + real(r8), dimension(:,:), intent(in) :: defc_a + real(r8), dimension(:,:), intent(in) :: defc_b + real(r8), dimension(:,:), intent(in) :: cell_gradient_coef_x + real(r8), dimension(:,:), intent(in) :: cell_gradient_coef_y + real(r8), dimension(:,:), intent(in) :: edgesOnCell_sign + real(r8), dimension(:), intent(in) :: dvEdge + real(r8), dimension(:), intent(in) :: areaCell + integer, dimension(:,:), intent(in) :: cellsOnEdge + integer, dimension(:,:), intent(in) :: edgesOnCell + integer, dimension(:), intent(in) :: nEdgesOnCell + + ! outputs + + real(r8), dimension(:,:), intent(out) :: frontogenesisFunction + real(r8), dimension(:,:), intent(out) :: frontogenesisAngle + + ! local storage + + integer :: iCell, iEdge, k, cell1, cell2 + integer :: CellStart, CellEnd + real(r8), dimension(nVertLevels) :: d_diag, d_off_diag, divh, theta_x, theta_y + real(r8) :: edge_sign, thetaEdge + + ! + ! for each column, compute frontogenesis function and del(theta) angle + ! + CellStart = 1 + CellEnd = nCellsSolve + + do iCell = cellStart,cellEnd + + d_diag(1:nVertLevels) = 0.0 + d_off_diag(1:nVertLevels) = 0.0 + divh(1:nVertLevels) = 0.0 + theta_x(1:nVertLevels) = 0.0 + theta_y(1:nVertLevels) = 0.0 + + ! + ! Integrate over edges to compute cell-averaged divergence, deformation, + ! d(theta)/dx, and d(theta)/dy. (x,y) are aligned with (lon,lat) at the + ! cell center in the 2D tangent-plane approximation used here. This alignment + ! is set in the initialization routine for the coefficients + ! defc_a, defc_b, cell_gradient_coef_x and cell_gradient_coef_y that is + ! part of the MPAS mesh initialization. The horizontal divergence is calculated + ! as it is in the MPAS solver, i.e. on the sphere as opposed to on the tangent plane. + ! + do iEdge=1,nEdgesOnCell(iCell) + + edge_sign = edgesOnCell_sign(iEdge,iCell) * dvEdge(edgesOnCell(iEdge,iCell)) / areaCell(iCell) + cell1 = cellsOnEdge(1,edgesOnCell(iEdge,iCell)) + cell2 = cellsOnEdge(2,edgesOnCell(iEdge,iCell)) + + do k=1,nVertLevels + + d_diag(k) = d_diag(k) + defc_a(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & + - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + d_off_diag(k) = d_off_diag(k) + defc_b(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & + + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + divh(k) = divh(k) + edge_sign * u(k,EdgesOnCell(iEdge,iCell)) + thetaEdge = 0.5*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & + +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) + theta_x(k) = theta_x(k) + cell_gradient_coef_x(iEdge,iCell)*thetaEdge + theta_y(k) = theta_y(k) + cell_gradient_coef_y(iEdge,iCell)*thetaEdge + + end do + + end do + + ! + ! compute the frontogenesis function: + ! 1/2 |del(theta)/dt)| = 1/2 ( + ! - Div * |del(theta)|^2 + ! - E (d(theta)/dx)^2 + ! - 2F (d(theta)/dx)*(d(theta)/dy) + ! + E (d(theta)/dy) ) + ! where + ! Div = u_x + v_y (horizontal velocity divergence) + ! E = u_x - v_y (stretching deformation) + ! F = v_x + u_y (shearing deformation) + ! + !DIR$ IVDEP + do k=1, nVertLevels + + frontogenesisFunction(k,iCell) = 0.5*( & + -divh(k)*(theta_x(k)**2 + theta_y(k)**2) & + -d_diag(k)*theta_x(k)**2 & + -2.0*d_off_diag(k)*theta_x(k)*theta_y(k) & + +d_diag(k)*theta_y(k)**2 ) + frontogenesisAngle(k,iCell) = atan2(theta_y(k),theta_x(k)) + + end do + + end do + +end subroutine calc_frontogenesis + end module dp_coupling diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index 6f53a32763..8492012a69 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -131,6 +131,7 @@ module dyn_comp ! of the sphere [dimensionless] (3,ncol) integer, dimension(:,:), pointer :: cellsOnEdge ! Indices of cells separated by an edge (2,nedge) + ! ! State that may be directly derived from dycore prognostic state ! @@ -206,10 +207,15 @@ module dyn_comp real(r8), dimension(:,:), pointer :: cell_gradient_coef_y real(r8), dimension(:,:), pointer :: edgesOnCell_sign real(r8), dimension(:), pointer :: dvEdge + real(r8), dimension(:), pointer :: areaCell ! cell area (m^2) integer, dimension(:,:), pointer :: edgesOnCell + integer, dimension(:,:), pointer :: cellsOnEdge integer, dimension(:), pointer :: nEdgesOnCell + real(r8), dimension(:,:), pointer :: utangential ! velocity tangent to cell edge, + ! diagnosed by mpas + ! ! State that may be directly derived from dycore prognostic state ! @@ -228,6 +234,10 @@ module dyn_comp ! (nver,ncol) end type dyn_export_t +! Frontogenesis indices +integer, public :: frontgf_idx = -1 +integer, public :: frontga_idx = -1 + real(r8), parameter :: rad2deg = 180.0_r8 / pi real(r8), parameter :: deg2rad = pi / 180.0_r8 @@ -306,8 +316,16 @@ subroutine dyn_register() use physics_buffer, only: pbuf_add_field, dtype_r8 use ppgrid, only: pcols, pver + use phys_control, only: use_gw_front, use_gw_front_igw !---------------------------------------------------------------------------- + ! These fields are computed by the dycore and passed to the physics via the + ! physics buffer. + + if (use_gw_front .or. use_gw_front_igw) then + call pbuf_add_field("FRONTGF", "global", dtype_r8, (/pcols,pver/), frontgf_idx) + call pbuf_add_field("FRONTGA", "global", dtype_r8, (/pcols,pver/), frontga_idx) + end if end subroutine dyn_register @@ -492,7 +510,10 @@ subroutine dyn_init(dyn_in, dyn_out) dyn_out % ux => dyn_in % ux dyn_out % uy => dyn_in % uy - ! components only needed in output, no time level index + ! components needed in output, no time level index + + dyn_out % areaCell => dyn_in % areaCell + dyn_out % cellsOnEdge => dyn_in % cellsOnEdge call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) @@ -503,6 +524,8 @@ subroutine dyn_init(dyn_in, dyn_out) call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) call mpas_pool_get_array(mesh_pool, 'nEdgesOnCell', dyn_out % nEdgesOnCell) + call mpas_pool_get_array(diag_pool, 'v', dyn_out % utangential) + ! cam-required hydrostatic pressures allocate(dyn_out % pmiddry(nVertLevels, nCells), stat=ierr) From 9e7f26d50eab49d44985d4f47ca24a6197531b2a Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Wed, 17 Aug 2022 06:56:19 -0600 Subject: [PATCH 12/24] read cell_gradient_coefs from IC file only if front GWs are turn on; cold start CLM in mpasa480 test; clean up modified: cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands modified: src/dynamics/mpas/dp_coupling.F90 modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 --- .../cam/outfrq9s_mpasa480/shell_commands | 1 + src/dynamics/mpas/dp_coupling.F90 | 30 +++++---- .../mpas/driver/cam_mpas_subdriver.F90 | 61 +++++++++++-------- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands index 52f64de9ce..593ae0b036 100644 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands @@ -1,3 +1,4 @@ ./xmlchange ROF_NCPL=\$ATM_NCPL ./xmlchange GLC_NCPL=\$ATM_NCPL ./xmlchange LND_DOMAIN_FILE="domain.lnd.mpasa480_gx1v7.201001.nc" +./xmlchange CLM_FORCE_COLDSTART=on diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index c27cd183ae..733a8c22a1 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -74,7 +74,7 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) real(r8), pointer :: tracers(:,:,:) ! - ! mesh information and coefficients needed for + ! mesh information and coefficients needed for ! frontogenesis function calculation ! real(r8), dimension(:,:), pointer :: defc_a @@ -825,11 +825,11 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, end do do k = nVertLevels, 1, -1 - !hydrostatic mid-level pressure - MPAS full pressure is (rhok*rgas*thetavk*kap1)**kap2 - pmid (k,iCell) = 0.5_r8*(pint(k+1)+pint(k)) - !hydrostatic dry mid-level dry pressure - + !hydrostatic mid-level pressure - MPAS full pressure is (rhok*rgas*thetavk*kap1)**kap2 + pmid (k,iCell) = 0.5_r8*(pint(k+1)+pint(k)) + !hydrostatic dry mid-level dry pressure - !MPAS non-hydrostatic dry pressure is pmiddry(k,iCell) = (rhodryk*rgas*theta*kap1)**kap2 - pmiddry(k,iCell) = 0.5_r8*(pintdry(k+1,iCell)+pintdry(k,iCell)) + pmiddry(k,iCell) = 0.5_r8*(pintdry(k+1,iCell)+pintdry(k,iCell)) end do end do end subroutine hydrostatic_pressure @@ -936,15 +936,13 @@ subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, t end if end subroutine tot_energy - subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & - theta_m, qv, u,v, defc_a, defc_b, cell_gradient_coef_x, cell_gradient_coef_y, & - areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & - nVertLevels, nCellsSolve ) + subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & + theta_m, qv, u,v, defc_a, defc_b, cell_gradient_coef_x, cell_gradient_coef_y, & + areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & + nVertLevels, nCellsSolve ) use mpas_constants, only : rvord - implicit none - ! inputs integer, intent(in) :: nVertLevels, nCellsSolve @@ -959,10 +957,10 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, real(r8), dimension(:), intent(in) :: areaCell integer, dimension(:,:), intent(in) :: cellsOnEdge integer, dimension(:,:), intent(in) :: edgesOnCell - integer, dimension(:), intent(in) :: nEdgesOnCell + integer, dimension(:), intent(in) :: nEdgesOnCell ! outputs - + real(r8), dimension(:,:), intent(out) :: frontogenesisFunction real(r8), dimension(:,:), intent(out) :: frontogenesisAngle @@ -1005,9 +1003,9 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, do k=1,nVertLevels d_diag(k) = d_diag(k) + defc_a(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & - - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) d_off_diag(k) = d_off_diag(k) + defc_b(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & - + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) + + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) divh(k) = divh(k) + edge_sign * u(k,EdgesOnCell(iEdge,iCell)) thetaEdge = 0.5*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) @@ -1044,6 +1042,6 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, end do -end subroutine calc_frontogenesis + end subroutine calc_frontogenesis end module dp_coupling diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index d6a27c6bb6..a74d3a98f3 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -12,6 +12,7 @@ module cam_mpas_subdriver use cam_abortutils, only: endrun use mpas_derived_types, only : core_type, dm_info, domain_type, MPAS_Clock_type + use phys_control, only: use_gw_front, use_gw_front_igw implicit none @@ -382,7 +383,7 @@ subroutine cam_mpas_init_phase4(endrun) if ( ierr /= 0 ) then call endrun(subname//': failed to get MPAS_START_TIME') end if - call mpas_get_time(startTime, dateTimeString=startTimeStamp) + call mpas_get_time(startTime, dateTimeString=startTimeStamp) call mpas_pool_get_subpool(domain_ptr % blocklist % structs, 'state', state) @@ -438,7 +439,7 @@ end subroutine cam_mpas_init_phase4 !> to reorder the constituents; to allow for mapping of indices between CAM !> physics and the MPAS-A dycore, this routine returns index mapping arrays !> mpas_from_cam_cnst and cam_from_mpas_cnst. - !> + !> ! !----------------------------------------------------------------------- subroutine cam_mpas_define_scalars(block, mpas_from_cam_cnst, cam_from_mpas_cnst, ierr) @@ -770,7 +771,7 @@ subroutine cam_mpas_get_global_coords(latCellGlobal, lonCellGlobal, areaCellGlob allocate(temp(nCellsGlobal), stat=ierr) if( ierr /= 0 ) call endrun(subname//':failed to allocate temp array') - + ! ! latCellGlobal ! @@ -1047,8 +1048,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call mpas_pool_get_field(meshPool, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(meshPool, 'defc_a', defc_a) call mpas_pool_get_field(meshPool, 'defc_b', defc_b) - call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) - call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) + if (use_gw_front .or. use_gw_front_igw) then + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) + endif ierr_total = 0 @@ -1181,10 +1184,12 @@ subroutine cam_mpas_read_static(fh_ini, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(mesh_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(mesh_stream, cell_gradient_coef_x, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(mesh_stream, cell_gradient_coef_y, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + if (use_gw_front .or. use_gw_front_igw) then + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(mesh_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + endif if (ierr_total > 0) then write(errString, '(a,i0,a)') subname//': FATAL: Failed to add ', ierr_total, ' fields to static input stream.' @@ -1266,9 +1271,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call MPAS_dmpar_exch_halo_field(localVerticalUnitVectors) call MPAS_dmpar_exch_halo_field(defc_a) call MPAS_dmpar_exch_halo_field(defc_b) - call MPAS_dmpar_exch_halo_field(cell_gradient_coef_x) - call MPAS_dmpar_exch_halo_field(cell_gradient_coef_y) - + if (use_gw_front .or. use_gw_front_igw) then + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_x) + call MPAS_dmpar_exch_halo_field(cell_gradient_coef_y) + endif ! ! Re-index from global index space to local index space ! @@ -1471,9 +1477,10 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) call mpas_pool_get_field(allFields, 'localVerticalUnitVectors', localVerticalUnitVectors) call mpas_pool_get_field(allFields, 'defc_a', defc_a) call mpas_pool_get_field(allFields, 'defc_b', defc_b) - call mpas_pool_get_field(allFields, 'cell_gradient_coef_x', cell_gradient_coef_x) - call mpas_pool_get_field(allFields, 'cell_gradient_coef_y', cell_gradient_coef_y) - + if (use_gw_front .or. use_gw_front_igw) then + call mpas_pool_get_field(allFields, 'cell_gradient_coef_x', cell_gradient_coef_x) + call mpas_pool_get_field(allFields, 'cell_gradient_coef_y', cell_gradient_coef_y) + endif call mpas_pool_get_field(allFields, 'initial_time', initial_time, timeLevel=1) call mpas_pool_get_field(allFields, 'xtime', xtime, timeLevel=1) call mpas_pool_get_field(allFields, 'u', u, timeLevel=1) @@ -1643,11 +1650,12 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, defc_b, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(restart_stream, cell_gradient_coef_x, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - call MPAS_streamAddField(restart_stream, cell_gradient_coef_y, ierr=ierr) - if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 - + if (use_gw_front .or. use_gw_front_igw) then + call MPAS_streamAddField(restart_stream, cell_gradient_coef_x, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + call MPAS_streamAddField(restart_stream, cell_gradient_coef_y, ierr=ierr) + if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 + endif call MPAS_streamAddField(restart_stream, initial_time, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) ierr_total = ierr_total + 1 call MPAS_streamAddField(restart_stream, xtime, ierr=ierr) @@ -1857,9 +1865,10 @@ subroutine cam_mpas_read_restart(restart_stream, endrun) call cam_mpas_update_halo('localVerticalUnitVectors', endrun) call cam_mpas_update_halo('defc_a', endrun) call cam_mpas_update_halo('defc_b', endrun) - call cam_mpas_update_halo('cell_gradient_coef_x', endrun) - call cam_mpas_update_halo('cell_gradient_coef_y', endrun) - + if (use_gw_front .or. use_gw_front_igw) then + call cam_mpas_update_halo('cell_gradient_coef_x', endrun) + call cam_mpas_update_halo('cell_gradient_coef_y', endrun) + endif call cam_mpas_update_halo('u', endrun) call cam_mpas_update_halo('w', endrun) call cam_mpas_update_halo('rho_zz', endrun) @@ -2273,17 +2282,17 @@ subroutine cam_mpas_run(integrationLength) runUntilTime = currTime + integrationLength do while (currTime < runUntilTime) - call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr) + call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr) call mpas_log_write('Dynamics timestep beginning at '//trim(timeStamp)) call mpas_timer_start('time integration') call atm_do_timestep(domain_ptr, dt, itimestep) - call mpas_timer_stop('time integration') + call mpas_timer_stop('time integration') ! Move time level 2 fields back into time level 1 for next time step call mpas_pool_get_subpool(domain_ptr % blocklist % structs, 'state', state) call mpas_pool_shift_time_levels(state) - + ! Advance clock before writing output itimestep = itimestep + 1 call mpas_advance_clock(clock) From 4e52cded05b19c9227b973c57a151b74fc07b508 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 18 Aug 2022 13:34:58 -0600 Subject: [PATCH 13/24] Turn on frontogenesis GWs in WACCM-SC; add cheyenne tests modified: Externals_CAM.cfg modified: bld/namelist_files/namelist_defaults_cam.xml modified: cime_config/config_pes.xml modified: cime_config/testdefs/testlist_cam.xml modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 modified: src/dynamics/mpas/dyn_comp.F90 --- Externals_CAM.cfg | 4 ++-- bld/namelist_files/namelist_defaults_cam.xml | 13 +++++++++++ cime_config/config_pes.xml | 22 +++++++++++++++++++ cime_config/testdefs/testlist_cam.xml | 19 ++++++++++++++++ .../mpas/driver/cam_mpas_subdriver.F90 | 5 +++++ src/dynamics/mpas/dyn_comp.F90 | 8 +++++-- 6 files changed, 67 insertions(+), 4 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 025a017dec..1f266fe476 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -71,9 +71,9 @@ required = True [mpas] local_path = src/dynamics/mpas/dycore protocol = git -repo_url = https://github.com/MPAS-Dev/MPAS-Model.git +repo_url = https://github.com/fvitt/MPAS-Model.git sparse = ../.mpas_sparse_checkout -hash = ff76a231 +branch = cell_grad_ff76a231 required = True [externals_description] diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index b29e1e5be4..93c43d95bb 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -246,6 +246,8 @@ atm/waccm/ic/FW2000_CONUS_30x8_L70_01-01-0001_c200602.nc +atm/waccm/ic/mpasa120km.waccm_fulltopo_c220818.nc + atm/cam/inic/mpas/cami_01-01-2000_00Z_mpasa120_L32_CFSR_c210426.nc atm/cam/inic/mpas/cami_01-01-2000_00Z_mpasa480_L32_CFSR_c211013.nc @@ -2976,6 +2978,17 @@ .false. .false. + 600.D0 + 4 + 120000.D0 + 80000.0D0 + 0.2D0 + 0.2D0 + 0.5D0 + 0.0D0 + .true. + 5.D0 + diff --git a/cime_config/config_pes.xml b/cime_config/config_pes.xml index f4b145ebdc..35e1347797 100644 --- a/cime_config/config_pes.xml +++ b/cime_config/config_pes.xml @@ -257,6 +257,28 @@ + + + + + 360 + 360 + 360 + 360 + 360 + 360 + + + 1 + 1 + 1 + 1 + 1 + 1 + + + + diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index 325d04a056..6a25aead42 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -1861,6 +1861,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index a74d3a98f3..16a9c4c176 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -968,6 +968,9 @@ subroutine cam_mpas_read_static(fh_ini, endrun) type (MPAS_Stream_type) :: mesh_stream + nullify(cell_gradient_coef_x) + nullify(cell_gradient_coef_y) + call MPAS_createStream(mesh_stream, domain_ptr % ioContext, 'not_used', MPAS_IO_NETCDF, MPAS_IO_READ, & pio_file_desc=fh_ini, ierr=ierr) @@ -1046,8 +1049,10 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call mpas_pool_get_field(meshPool, 'edgeNormalVectors', edgeNormalVectors) call mpas_pool_get_field(meshPool, 'localVerticalUnitVectors', localVerticalUnitVectors) + call mpas_pool_get_field(meshPool, 'defc_a', defc_a) call mpas_pool_get_field(meshPool, 'defc_b', defc_b) + if (use_gw_front .or. use_gw_front_igw) then call mpas_pool_get_field(meshPool, 'cell_gradient_coef_x', cell_gradient_coef_x) call mpas_pool_get_field(meshPool, 'cell_gradient_coef_y', cell_gradient_coef_y) diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index 8492012a69..ac6a0b13a7 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -42,6 +42,8 @@ module dyn_comp use cam_mpas_subdriver, only: cam_mpas_global_sum_real +use phys_control, only: use_gw_front, use_gw_front_igw + implicit none private save @@ -517,8 +519,10 @@ subroutine dyn_init(dyn_in, dyn_out) call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) - call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) - call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + if (use_gw_front .or. use_gw_front_igw) then + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + endif call mpas_pool_get_array(mesh_pool, 'edgesOnCell_sign', dyn_out % edgesOnCell_sign) call mpas_pool_get_array(mesh_pool, 'dvEdge', dyn_out % dvEdge) call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) From bdb4024082d7db872253c997d126534f46c2752b Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 18 Aug 2022 21:45:06 -0600 Subject: [PATCH 14/24] fix restarts by haloing tracers; append constants with _r8 kind modified: src/dynamics/mpas/dp_coupling.F90 --- src/dynamics/mpas/dp_coupling.F90 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 733a8c22a1..9298cddd41 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -41,6 +41,7 @@ module dp_coupling !========================================================================================= subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) + use cam_mpas_subdriver, only : cam_mpas_update_halo ! Convert the dynamics output state into the physics input state. ! Note that all pressures and tracer mixing ratios coming from the dycore are based on @@ -163,6 +164,7 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) pmiddry, pintdry, pmid) if (use_gw_front .or. use_gw_front_igw) then + call cam_mpas_update_halo('scalars', endrun) ! scalars is the name of tracers in the MPAS state pool nullify(pbuf_chnk) nullify(pbuf_frontgf) nullify(pbuf_frontga) @@ -979,11 +981,11 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, do iCell = cellStart,cellEnd - d_diag(1:nVertLevels) = 0.0 - d_off_diag(1:nVertLevels) = 0.0 - divh(1:nVertLevels) = 0.0 - theta_x(1:nVertLevels) = 0.0 - theta_y(1:nVertLevels) = 0.0 + d_diag(1:nVertLevels) = 0.0_r8 + d_off_diag(1:nVertLevels) = 0.0_r8 + divh(1:nVertLevels) = 0.0_r8 + theta_x(1:nVertLevels) = 0.0_r8 + theta_y(1:nVertLevels) = 0.0_r8 ! ! Integrate over edges to compute cell-averaged divergence, deformation, @@ -1007,8 +1009,8 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, d_off_diag(k) = d_off_diag(k) + defc_b(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell)) & + defc_a(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell)) divh(k) = divh(k) + edge_sign * u(k,EdgesOnCell(iEdge,iCell)) - thetaEdge = 0.5*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & - +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) + thetaEdge = 0.5_r8*( theta_m(k,cell1)/(1.0_r8 + rvord*qv(k,cell1)) & + +theta_m(k,cell2)/(1.0_r8 + rvord*qv(k,cell2)) ) theta_x(k) = theta_x(k) + cell_gradient_coef_x(iEdge,iCell)*thetaEdge theta_y(k) = theta_y(k) + cell_gradient_coef_y(iEdge,iCell)*thetaEdge @@ -1031,10 +1033,10 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, !DIR$ IVDEP do k=1, nVertLevels - frontogenesisFunction(k,iCell) = 0.5*( & + frontogenesisFunction(k,iCell) = 0.5_r8*( & -divh(k)*(theta_x(k)**2 + theta_y(k)**2) & -d_diag(k)*theta_x(k)**2 & - -2.0*d_off_diag(k)*theta_x(k)*theta_y(k) & + -2.0_r8*d_off_diag(k)*theta_x(k)*theta_y(k) & +d_diag(k)*theta_y(k)**2 ) frontogenesisAngle(k,iCell) = atan2(theta_y(k),theta_x(k)) From 1375fc58105ae269a926cd9acf5ff0dcb4aa5bc2 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 1 Sep 2022 10:40:48 -0600 Subject: [PATCH 15/24] some code clean up modified: src/dynamics/mpas/dp_coupling.F90 modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 modified: src/dynamics/mpas/dyn_comp.F90 modified: src/dynamics/mpas/dyn_grid.F90 --- src/dynamics/mpas/dp_coupling.F90 | 54 ++++++------------ .../mpas/driver/cam_mpas_subdriver.F90 | 57 +++---------------- src/dynamics/mpas/dyn_comp.F90 | 26 +++------ src/dynamics/mpas/dyn_grid.F90 | 2 +- 4 files changed, 32 insertions(+), 107 deletions(-) diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 9298cddd41..1fb6a5c053 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -8,24 +8,20 @@ module dp_coupling use pmgrid, only: plev use ppgrid, only: begchunk, endchunk, pcols, pver, pverp use constituents, only: pcnst, cnst_type -use physconst, only: gravit, cappa, rh2o, zvir -use air_composition,only: cpairv, rairv - -use spmd_dyn, only: local_dp_map, block_buf_nrecs, chunk_buf_nrecs -use spmd_utils, only: mpicom, iam, masterproc - +use physconst, only: gravit, cappa, zvir +use air_composition,only: cpairv use dyn_comp, only: dyn_export_t, dyn_import_t - use physics_types, only: physics_state, physics_tend, physics_cnst_limit -use phys_grid, only: get_dyn_col_p, get_chunk_info_p, get_ncols_p, get_gcol_all_p +use phys_grid, only: get_dyn_col_p, get_chunk_info_p, get_ncols_p use phys_grid, only: columns_on_task use physics_buffer, only: physics_buffer_desc, pbuf_get_chunk, pbuf_get_field -use cam_logfile, only: iulog -use perf_mod, only: t_startf, t_stopf, t_barrierf +use perf_mod, only: t_startf, t_stopf use cam_abortutils, only: endrun -use air_composition,only: thermodynamic_active_species_num,thermodynamic_active_species_idx,thermodynamic_active_species_idx_dycore +use air_composition,only: thermodynamic_active_species_num,thermodynamic_active_species_idx, & + thermodynamic_active_species_idx_dycore + implicit none private save @@ -106,15 +102,10 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) type(physics_buffer_desc), pointer :: pbuf_chnk(:) integer :: lchnk, icol, icol_p, k, kk ! indices over chunks, columns, physics columns and layers - integer :: i, m, ncols, blockid + integer :: i, m, ncols integer :: block_index integer, dimension(:), pointer :: block_offset - integer :: pgcols(pcols) - integer :: tsize ! amount of data per grid point passed to physics - integer, allocatable :: bpter(:,:) ! offsets into block buffer for packing data - integer, allocatable :: cpter(:,:) ! offsets into chunk buffer for unpacking data - real(r8), allocatable:: pmid(:,:) !mid-level hydrostatic pressure consistent with MPAS discrete state real(r8), allocatable:: pintdry(:,:) !interface hydrostatic pressure consistent with MPAS discrete state real(r8), allocatable:: pmiddry(:,:) !mid-level hydrostatic dry pressure consistent with MPAS discrete state @@ -301,7 +292,7 @@ subroutine p_d_coupling(phys_state, phys_tend, dyn_in) ! Local variables integer :: lchnk, icol, icol_p, k, kk ! indices over chunks, columns, layers - integer :: i, m, ncols, blockid + integer :: i, m, ncols integer :: block_index integer, dimension(:), pointer :: block_offset @@ -311,7 +302,6 @@ subroutine p_d_coupling(phys_state, phys_tend, dyn_in) ! Variables from dynamics import container integer :: nCellsSolve integer :: nCells - integer :: nEdgesSolve integer :: index_qv integer, dimension(:), pointer :: mpas_from_cam_cnst @@ -325,11 +315,6 @@ subroutine p_d_coupling(phys_state, phys_tend, dyn_in) integer :: idx_phys, idx_dycore - integer :: pgcols(pcols) - integer :: tsize ! amount of data per grid point passed to dynamics - integer, allocatable :: bpter(:,:) ! offsets into block buffer for unpacking data - integer, allocatable :: cpter(:,:) ! offsets into chunk buffer for packing data - type (mpas_pool_type), pointer :: tend_physics type (field2DReal), pointer :: tend_uzonal, tend_umerid @@ -443,7 +428,7 @@ subroutine derived_phys(phys_state, phys_tend, pbuf2d) ! Local variables - integer :: i, k, lchnk, m, ncol + integer :: k, lchnk, m, ncol real(r8) :: factor(pcols,pver) real(r8) :: zvirv(pcols,pver) @@ -607,13 +592,11 @@ subroutine derived_tend(nCellsSolve, nCells, t_tend, u_tend, v_tend, q_tend, dyn real(r8), pointer :: north(:,:) integer, pointer :: cellsOnEdge(:,:) - real(r8), pointer :: theta(:,:) - real(r8), pointer :: exner(:,:) real(r8), pointer :: rho_zz(:,:) real(r8), pointer :: tracers(:,:,:) integer :: index_qv,m,idx_dycore - real(r8) :: rhok,thetavk,thetak,pk,exnerk,tempk,tempk_new,exnerk_new,thetak_new,thetak_m_new,rhodk,tknew,thetaknew + real(r8) :: thetak,exnerk,rhodk,tknew,thetaknew ! ! variables for energy diagnostics ! @@ -627,7 +610,6 @@ subroutine derived_tend(nCellsSolve, nCells, t_tend, u_tend, v_tend, q_tend, dyn real(r8) :: qk (thermodynamic_active_species_num,pver,nCellsSolve) !water species before physics (diagnostics) real(r8) :: qwv(pver,nCellsSolve) !water vapor before physics real(r8) :: facnew, facold - real(r8), allocatable :: tracers_old(:,:,:) integer :: iCell,k @@ -644,8 +626,6 @@ subroutine derived_tend(nCellsSolve, nCells, t_tend, u_tend, v_tend, q_tend, dyn normal => dyn_in % normal cellsOnEdge => dyn_in % cellsOnEdge - theta => dyn_in % theta - exner => dyn_in % exner rho_zz => dyn_in % rho_zz tracers => dyn_in % tracers index_qv = dyn_in % index_qv @@ -773,8 +753,7 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, ! The vertical dimension for 3-d arrays is innermost, and k=1 represents ! the lowest layer or level in the fields. ! - use mpas_constants, only : cp, rgas, cv, gravity, p0, Rv_over_Rd => rvord - use physconst, only: rair, cpair + use mpas_constants, only : cp, rgas, cv, gravity, p0 ! Arguments integer, intent(in) :: nCells @@ -792,8 +771,7 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, integer :: iCell, k real(r8), dimension(nVertLevels) :: dz ! Geometric layer thickness in column real(r8), dimension(nVertLevels+1) :: pint ! hydrostatic pressure at interface - real(r8) :: pi, t - real(r8) :: pk,rhok,rhodryk,theta,thetavk,kap1,kap2 + real(r8) :: pk,rhok,rhodryk,thetavk,kap1,kap2 ! ! For each column, integrate downward from model top to compute dry hydrostatic pressure at layer @@ -838,12 +816,12 @@ end subroutine hydrostatic_pressure subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, theta_m, q, ux,uy,outfld_name_suffix) - use physconst, only: rair, cpair, gravit,cappa!=R/cp (dry air) use mpas_constants, only: p0,cv,rv,rgas,cp use cam_history, only: outfld, hist_fld_active use mpas_constants, only: Rv_over_Rd => rvord use air_composition, only: thermodynamic_active_species_ice_idx_dycore,thermodynamic_active_species_liq_idx_dycore use air_composition, only: thermodynamic_active_species_ice_num,thermodynamic_active_species_liq_num + ! Arguments integer, intent(in) :: nCells integer, intent(in) :: nVertLevels @@ -860,9 +838,9 @@ subroutine tot_energy(nCells, nVertLevels, qsize, index_qv, zz, zgrid, rho_zz, t ! Local variables integer :: iCell, k, idx - real(r8) :: rho_dz,zcell,temperature,theta,pk,ptop,exner + real(r8) :: rho_dz,zcell,temperature,theta,exner real(r8), dimension(nVertLevels, nCells) :: rhod, dz - real(r8), dimension(nCells) :: kinetic_energy,potential_energy,internal_energy,water_vapor,water_liq,water_ice + real(r8), dimension(nCells) :: kinetic_energy,potential_energy,internal_energy,water_vapor real(r8), dimension(nCells) :: liq !total column integrated liquid real(r8), dimension(nCells) :: ice !total column integrated ice diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index 16a9c4c176..39b0eb63ee 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -11,7 +11,7 @@ module cam_mpas_subdriver !------------------------------------------------------------------------------- use cam_abortutils, only: endrun - use mpas_derived_types, only : core_type, dm_info, domain_type, MPAS_Clock_type + use mpas_derived_types, only : core_type, domain_type, MPAS_Clock_type use phys_control, only: use_gw_front, use_gw_front_igw implicit none @@ -76,7 +76,6 @@ subroutine cam_mpas_init_phase1(mpicom, endrun, logUnits, realkind) use mpas_domain_routines, only : mpas_allocate_domain use mpas_framework, only : mpas_framework_init_phase1 use atm_core_interface, only : atm_setup_core, atm_setup_domain - use mpas_pool_routines, only : mpas_pool_add_config use mpas_kind_types, only : RKIND ! Dummy argument @@ -148,7 +147,6 @@ end subroutine cam_mpas_init_phase1 !----------------------------------------------------------------------- subroutine cam_mpas_init_phase2(pio_subsystem, endrun, cam_calendar) - use mpas_log, only : mpas_log_write use mpas_kind_types, only : ShortStrKIND use pio_types, only : iosystem_desc_t @@ -160,7 +158,6 @@ subroutine cam_mpas_init_phase2(pio_subsystem, endrun, cam_calendar) character(len=*), intent(in) :: cam_calendar integer :: ierr - logical :: streamsExists character(len=ShortStrKIND) :: mpas_calendar @@ -222,52 +219,19 @@ end subroutine cam_mpas_init_phase2 !> the number of constituents. ! !----------------------------------------------------------------------- - subroutine cam_mpas_init_phase3(fh_ini, num_scalars, endrun) + subroutine cam_mpas_init_phase3(fh_ini, num_scalars) - use mpas_log, only : mpas_log_write use pio, only : file_desc_t - use iso_c_binding, only : c_int, c_char, c_ptr, c_loc - - use mpas_derived_types, only : MPAS_Time_type, MPAS_TimeInterval_type - use mpas_derived_types, only : MPAS_IO_PNETCDF, MPAS_IO_PNETCDF5, MPAS_IO_NETCDF, MPAS_IO_NETCDF4 - use mpas_derived_types, only : MPAS_START_TIME - use mpas_derived_types, only : MPAS_STREAM_MGR_NOERR - use mpas_timekeeping, only : mpas_get_clock_time, mpas_get_time, mpas_expand_string, mpas_set_time, & - mpas_set_timeInterval - use mpas_stream_manager, only : MPAS_stream_mgr_init, mpas_build_stream_filename, MPAS_stream_mgr_validate_streams - use mpas_kind_types, only : StrKIND - use mpas_c_interfacing, only : mpas_c_to_f_string, mpas_f_to_c_string + use mpas_derived_types, only : MPAS_IO_NETCDF + use mpas_kind_types, only : StrKIND use mpas_bootstrapping, only : mpas_bootstrap_framework_phase1, mpas_bootstrap_framework_phase2 use mpas_pool_routines, only : mpas_pool_add_config type (file_desc_t), intent(inout) :: fh_ini integer, intent(in) :: num_scalars - procedure(halt_model) :: endrun - integer :: ierr - character(kind=c_char), dimension(StrKIND+1) :: c_filename ! StrKIND+1 for C null-termination character - integer(kind=c_int) :: c_comm - integer(kind=c_int) :: c_ierr - type (c_ptr) :: mgr_p - character(len=StrKIND) :: mesh_stream character(len=StrKIND) :: mesh_filename - character(len=StrKIND) :: mesh_filename_temp - character(len=StrKIND) :: ref_time_temp - character(len=StrKIND) :: filename_interval_temp - character(kind=c_char), dimension(StrKIND+1) :: c_mesh_stream - character(kind=c_char), dimension(StrKIND+1) :: c_mesh_filename_temp - character(kind=c_char), dimension(StrKIND+1) :: c_ref_time_temp - character(kind=c_char), dimension(StrKIND+1) :: c_filename_interval_temp - character(kind=c_char), dimension(StrKIND+1) :: c_iotype - type (MPAS_Time_type) :: start_time - type (MPAS_Time_type) :: ref_time - type (MPAS_TimeInterval_type) :: filename_interval - character(len=StrKIND) :: start_timestamp - character(len=StrKIND) :: iotype - logical :: streamsExists integer :: mesh_iotype - integer :: blockID - character(len=StrKIND) :: timeStamp character(len=*), parameter :: subname = 'cam_mpas_subdriver::cam_mpas_init_phase3' @@ -321,8 +285,6 @@ subroutine cam_mpas_init_phase4(endrun) real (kind=RKIND), pointer :: dt - character(len=StrKIND) :: timeStamp - integer :: i logical, pointer :: config_do_restart type (mpas_pool_type), pointer :: state @@ -736,7 +698,7 @@ subroutine cam_mpas_get_global_coords(latCellGlobal, lonCellGlobal, areaCellGlob use mpas_pool_routines, only : mpas_pool_get_subpool, mpas_pool_get_dimension, mpas_pool_get_array use mpas_derived_types, only : mpas_pool_type use mpas_kind_types, only : RKIND - use mpas_dmpar, only : mpas_dmpar_sum_int, mpas_dmpar_max_int, mpas_dmpar_max_real_array + use mpas_dmpar, only : mpas_dmpar_sum_int, mpas_dmpar_max_real_array real (kind=RKIND), dimension(:), intent(out) :: latCellGlobal real (kind=RKIND), dimension(:), intent(out) :: lonCellGlobal @@ -1778,8 +1740,6 @@ end subroutine cam_mpas_setup_restart !----------------------------------------------------------------------- subroutine cam_mpas_read_restart(restart_stream, endrun) - use pio, only : file_desc_t - use mpas_io_streams, only : MPAS_readStream, MPAS_closeStream use mpas_derived_types, only : MPAS_Stream_type, MPAS_pool_type, MPAS_STREAM_NOERR use mpas_pool_routines, only : MPAS_pool_create_pool, MPAS_pool_destroy_pool, MPAS_pool_add_config @@ -1943,8 +1903,6 @@ end subroutine cam_mpas_read_restart !----------------------------------------------------------------------- subroutine cam_mpas_write_restart(restart_stream, endrun) - use pio, only : file_desc_t - use mpas_io_streams, only : MPAS_writeStream, MPAS_closeStream use mpas_derived_types, only : MPAS_Stream_type, MPAS_pool_type, MPAS_STREAM_NOERR use mpas_pool_routines, only : MPAS_pool_create_pool, MPAS_pool_destroy_pool, MPAS_pool_add_config @@ -2389,11 +2347,10 @@ subroutine cam_mpas_debug_stream(domain, filename, timeLevel) use mpas_derived_types, only : MPAS_IO_WRITE, MPAS_IO_NETCDF, MPAS_STREAM_NOERR, MPAS_Stream_type, MPAS_pool_type, & field0DReal, field1DReal, field2DReal, field3DReal, field4DReal, field5DReal, & field1DInteger, field2DInteger, field3DInteger - use mpas_pool_routines, only : MPAS_pool_get_subpool, MPAS_pool_get_field, MPAS_pool_create_pool, MPAS_pool_destroy_pool, & - MPAS_pool_add_config + use mpas_pool_routines, only : MPAS_pool_get_field use mpas_derived_types, only : MPAS_Pool_iterator_type, MPAS_POOL_FIELD, MPAS_POOL_REAL, MPAS_POOL_INTEGER - use mpas_pool_routines, only : mpas_pool_begin_iteration, mpas_pool_get_next_member, mpas_pool_get_config + use mpas_pool_routines, only : mpas_pool_begin_iteration, mpas_pool_get_next_member type (domain_type), intent(inout) :: domain character(len=*), intent(in) :: filename diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index ac6a0b13a7..b429096f59 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -3,7 +3,7 @@ module dyn_comp ! CAM component interfaces to the MPAS Dynamical Core use shr_kind_mod, only: r8=>shr_kind_r8 -use spmd_utils, only: iam, masterproc, mpicom, npes +use spmd_utils, only: masterproc, mpicom, npes use physconst, only: pi, gravit, rair, cpair use pmgrid, only: plev, plevp @@ -13,23 +13,18 @@ module dyn_comp use cam_control_mod, only: initial_run use cam_initfiles, only: initial_file_get_id, topo_file_get_id -use cam_grid_support, only: cam_grid_id, cam_grid_get_gcid, & - cam_grid_dimensions, cam_grid_get_dim_names, & - cam_grid_get_latvals, cam_grid_get_lonvals, & - max_hcoordname_len +use cam_grid_support, only: cam_grid_id, & + cam_grid_get_latvals, cam_grid_get_lonvals use cam_map_utils, only: iMap use inic_analytic, only: analytic_ic_active, dyn_set_inic_col use dyn_tests_utils, only: vcoord=>vc_height -use cam_history, only: addfld, add_default, horiz_only, register_vector_field, & - outfld, hist_fld_active -use cam_history_support, only: max_fieldname_len +use cam_history, only: addfld, horiz_only use string_utils, only: date2yyyymmdd, sec2hms, int2str use ncdio_atm, only: infld -use pio, only: file_desc_t, pio_seterrorhandling, PIO_BCAST_ERROR, & - pio_inq_dimid, pio_inq_dimlen, PIO_NOERR +use pio, only: file_desc_t use cam_pio_utils, only: clean_iodesc_list use time_manager, only: get_start_date, get_stop_date, get_run_duration, & @@ -271,11 +266,8 @@ subroutine dyn_readnl(NLFileName) character(len=*), intent(in) :: NLFileName ! Local variables - integer :: ierr integer, dimension(2) :: logUnits ! stdout and stderr for MPAS logging integer :: yr, mon, day, tod, ndate, nday, nsec - character(len=10) :: date_str - character(len=8) :: tod_str character(len=*), parameter :: subname = 'dyn_comp:dyn_readnl' !---------------------------------------------------------------------------- @@ -347,7 +339,7 @@ subroutine dyn_init(dyn_in, dyn_out) use mpas_derived_types, only : mpas_pool_type use mpas_constants, only : mpas_constants_compute_derived use dyn_tests_utils, only : vc_dycore, vc_height, string_vc, vc_str_lgth - use constituents, only : cnst_get_ind + ! arguments: type(dyn_import_t), intent(inout) :: dyn_in type(dyn_export_t), intent(inout) :: dyn_out @@ -756,7 +748,7 @@ subroutine read_inidat(dyn_in) use cam_mpas_subdriver, only : domain_ptr, cam_mpas_update_halo, cam_mpas_cell_to_edge_winds use cam_initfiles, only : scale_dry_air_mass - use mpas_pool_routines, only : mpas_pool_get_subpool, mpas_pool_get_array, mpas_pool_get_config + use mpas_pool_routines, only : mpas_pool_get_subpool, mpas_pool_get_array use mpas_derived_types, only : mpas_pool_type use mpas_vector_reconstruction, only : mpas_reconstruct use mpas_constants, only : Rv_over_Rd => rvord @@ -814,7 +806,6 @@ subroutine read_inidat(dyn_in) real(r8), allocatable :: qv(:), tm(:) - real(r8) :: dz, h logical :: readvar character(len=shr_kind_cx) :: str @@ -1308,7 +1299,7 @@ subroutine cam_mpas_namelist_read(namelistFilename, configPool) ! if no errors were encountered, all MPI ranks have valid namelists in their configPool. use spmd_utils, only: mpicom, masterproc, masterprocid, & - mpi_integer, mpi_real8, mpi_logical, mpi_character, mpi_success + mpi_integer, mpi_real8, mpi_logical, mpi_character use namelist_utils, only: find_group_name use mpas_derived_types, only: mpas_pool_type @@ -1757,7 +1748,6 @@ subroutine set_dry_mass(dyn_in, target_avg_dry_surface_pressure) real(r8) :: preliminary_avg_dry_surface_pressure, scaled_avg_dry_surface_pressure real(r8) :: scaling_ratio real(r8) :: sphere_surface_area - real(r8) :: surface_integral, test_value integer :: ixqv,ierr diff --git a/src/dynamics/mpas/dyn_grid.F90 b/src/dynamics/mpas/dyn_grid.F90 index c8efc66123..78d686283a 100644 --- a/src/dynamics/mpas/dyn_grid.F90 +++ b/src/dynamics/mpas/dyn_grid.F90 @@ -130,7 +130,7 @@ subroutine dyn_grid_init() ! MPAS-A always requires at least one scalar (qv). CAM has the same requirement ! and it is enforced by the configure script which sets the cpp macrop PCNST. - call cam_mpas_init_phase3(fh_ini, pcnst, endrun) + call cam_mpas_init_phase3(fh_ini, pcnst) ! Read or compute all time-invariant fields for the MPAS-A dycore ! Time-invariant fields are stored in the MPAS mesh pool. This call From 1aabd83c067ae76c672c478f3ad0dc6d077ca02f Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Fri, 4 Nov 2022 09:00:42 -0600 Subject: [PATCH 16/24] fix bug in Z3GM diagnostic modified: src/ionosphere/waccmx/ionosphere_interface.F90 --- src/ionosphere/waccmx/ionosphere_interface.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ionosphere/waccmx/ionosphere_interface.F90 b/src/ionosphere/waccmx/ionosphere_interface.F90 index 69c28739dd..86735a8020 100644 --- a/src/ionosphere/waccmx/ionosphere_interface.F90 +++ b/src/ionosphere/waccmx/ionosphere_interface.F90 @@ -740,7 +740,7 @@ subroutine ionosphere_run2(phys_state, pbuf2d) ! Might need geometric height on midpoints for output !------------------------------------------------------------ if (hist_fld_active('Z3GM')) then - r8tmp = phys_state(lchnk)%zm(i, k) + r8tmp = phys_state(lchnk)%zm(i, k) + phis(i)/gravit tempm(i, k) = r8tmp * (1._r8 + (r8tmp * rearth_inv)) end if ! physics state fields on interfaces (but only to pver) From 7a0fb78f5b6faa7fdb3990738f496f9bbdb5600d Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Tue, 31 Jan 2023 10:11:09 -0700 Subject: [PATCH 17/24] adjust regression test list; minor code changes modified: cime_config/testdefs/testlist_cam.xml modified: cime_config/testdefs/testmods_dirs/cam/outfrq1d_physgrid_tem_mpasa120_wcmsc/user_nl_cam modified: cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands modified: src/dynamics/mpas/dp_coupling.F90 modified: src/dynamics/mpas/dyn_comp.F90 --- cime_config/testdefs/testlist_cam.xml | 13 +++++----- .../user_nl_cam | 12 --------- .../cam/outfrq9s_mpasa480/shell_commands | 1 - src/dynamics/mpas/dp_coupling.F90 | 1 - src/dynamics/mpas/dyn_comp.F90 | 26 +++++++++---------- 5 files changed, 19 insertions(+), 34 deletions(-) diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index b797f57a1f..603eb7c045 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -752,15 +752,16 @@ - + + - + @@ -1989,8 +1990,8 @@ - - + + @@ -1998,8 +1999,8 @@ - - + + diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq1d_physgrid_tem_mpasa120_wcmsc/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq1d_physgrid_tem_mpasa120_wcmsc/user_nl_cam index 1212d35edd..f642ec7233 100644 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq1d_physgrid_tem_mpasa120_wcmsc/user_nl_cam +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq1d_physgrid_tem_mpasa120_wcmsc/user_nl_cam @@ -1,15 +1,3 @@ -ncdata = '$DIN_LOC_ROOT/atm/waccm/ic/mpasa120km.waccm_fulltopo_c220818.nc' - -mpas_cam_coef = 0.2D0 -mpas_rayleigh_damp_u_timescale_days = 5.D0 -mpas_zd = 80000.0D0 -mpas_apvm_upwinding = 0.0D0 -mpas_dt = 600.D0 -mpas_dynamics_split_steps = 4 -mpas_epssm = 0.5D0 - -use_gw_front = .false. - phys_grid_ctem_nfreq = -12 phys_grid_ctem_zm_nbas = 120 phys_grid_ctem_za_nlat = 90 diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands index 593ae0b036..52f64de9ce 100644 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mpasa480/shell_commands @@ -1,4 +1,3 @@ ./xmlchange ROF_NCPL=\$ATM_NCPL ./xmlchange GLC_NCPL=\$ATM_NCPL ./xmlchange LND_DOMAIN_FILE="domain.lnd.mpasa480_gx1v7.201001.nc" -./xmlchange CLM_FORCE_COLDSTART=on diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 1fb6a5c053..5033085774 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -1008,7 +1008,6 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, ! E = u_x - v_y (stretching deformation) ! F = v_x + u_y (shearing deformation) ! - !DIR$ IVDEP do k=1, nVertLevels frontogenesisFunction(k,iCell) = 0.5_r8*( & diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 index b429096f59..4ee202fa1e 100644 --- a/src/dynamics/mpas/dyn_comp.F90 +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -504,23 +504,21 @@ subroutine dyn_init(dyn_in, dyn_out) dyn_out % ux => dyn_in % ux dyn_out % uy => dyn_in % uy - ! components needed in output, no time level index + ! for frontogenesis calc - dyn_out % areaCell => dyn_in % areaCell - dyn_out % cellsOnEdge => dyn_in % cellsOnEdge - - call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) - call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) if (use_gw_front .or. use_gw_front_igw) then - call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) - call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + dyn_out % areaCell => dyn_in % areaCell + dyn_out % cellsOnEdge => dyn_in % cellsOnEdge + call mpas_pool_get_array(mesh_pool, 'defc_a', dyn_out % defc_a) + call mpas_pool_get_array(mesh_pool, 'defc_b', dyn_out % defc_b) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_x', dyn_out % cell_gradient_coef_x) + call mpas_pool_get_array(mesh_pool, 'cell_gradient_coef_y', dyn_out % cell_gradient_coef_y) + call mpas_pool_get_array(mesh_pool, 'edgesOnCell_sign', dyn_out % edgesOnCell_sign) + call mpas_pool_get_array(mesh_pool, 'dvEdge', dyn_out % dvEdge) + call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) + call mpas_pool_get_array(mesh_pool, 'nEdgesOnCell', dyn_out % nEdgesOnCell) + call mpas_pool_get_array(diag_pool, 'v', dyn_out % utangential) endif - call mpas_pool_get_array(mesh_pool, 'edgesOnCell_sign', dyn_out % edgesOnCell_sign) - call mpas_pool_get_array(mesh_pool, 'dvEdge', dyn_out % dvEdge) - call mpas_pool_get_array(mesh_pool, 'edgesOnCell', dyn_out % edgesOnCell) - call mpas_pool_get_array(mesh_pool, 'nEdgesOnCell', dyn_out % nEdgesOnCell) - - call mpas_pool_get_array(diag_pool, 'v', dyn_out % utangential) ! cam-required hydrostatic pressures From 514772f90e4cf3571adb14c14169b00d6e0443c1 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Tue, 31 Jan 2023 15:16:06 -0700 Subject: [PATCH 18/24] fix issue #690 modified: bld/namelist_files/namelist_definition.xml --- bld/namelist_files/namelist_definition.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 6608541143..14b9c6bb96 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -3545,7 +3545,7 @@ Include effects of precip evaporation on turbulent moments Switch for CLUBB_ADV parameter that turns on advection of CLUBB pdf moments by -the dynamics core. Very experimental. +the dynamics core. Very experimental. @@ -3894,7 +3894,7 @@ xpyp only. -Flag to apply a locally calculated ustar to momentum surface fluxes in the +Flag to apply a locally calculated ustar to momentum surface fluxes in the clubb interface. @@ -3960,8 +3960,8 @@ Flag to turn on the clubb monotonic flux limiter for vm (meridional momemtum). -Flag to use an "upwind" discretization rather than a centered discretization -for the portion of the wp3 turbulent advection term for ADG1 that is linearized +Flag to use an "upwind" discretization rather than a centered discretization +for the portion of the wp3 turbulent advection term for ADG1 that is linearized in terms of wp3(t+1). (Requires ADG1 PDF and l_standard_term_ta=true). @@ -3988,7 +3988,7 @@ Flag to use smooth Heaviside 'Peskin' in computation of invrs_tau. -Use the standard discretization for the turbulent advection terms. Setting to +Use the standard discretization for the turbulent advection terms. Setting to .false. means that a_1 and a_3 are pulled outside of the derivative in advance_wp2_wp3_module.F90 and in advance_xp2_xpyp_module.F90. @@ -4070,7 +4070,7 @@ production) term. -Flag used to calculate convective velocity using a variable estimate of layer +Flag used to calculate convective velocity using a variable estimate of layer depth based on the depth over which wpthlp is positive near the ground when true @@ -7678,7 +7678,7 @@ If < 0, se_sponge_del4_nu_fac is automatically set based on model top locatio Default: Set by build-namelist. - Divergence damping hyperviscosity coefficient se_nu_div [m^4/s] for u,v is increased to se_nu_p*se_sponge_del4_nu_div_fac following a hyperbolic tangent function @@ -7692,7 +7692,7 @@ If < 0, se_sponge_del4_nu_div_fac is automatically set based on model top loc Default: Set by build-namelist. - Level index around which increased del4 damping is centered. From 5d4ef724b6ba4ec76b724a52c84ee5faa58049c4 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Fri, 31 Mar 2023 12:56:44 -0600 Subject: [PATCH 19/24] reviewers misc change requests modified: bld/namelist_files/namelist_defaults_cam.xml modified: src/dynamics/mpas/dp_coupling.F90 modified: src/dynamics/mpas/driver/cam_mpas_subdriver.F90 modified: src/ionosphere/waccmx/ionosphere_interface.F90 --- bld/namelist_files/namelist_defaults_cam.xml | 4 -- src/dynamics/mpas/dp_coupling.F90 | 63 +++++++++---------- .../mpas/driver/cam_mpas_subdriver.F90 | 3 +- .../waccmx/ionosphere_interface.F90 | 4 +- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 5ac45dc6db..d9f934468f 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -3000,14 +3000,10 @@ 600.D0 4 - 120000.D0 80000.0D0 - 0.2D0 0.2D0 0.5D0 0.0D0 - .true. - 5.D0 diff --git a/src/dynamics/mpas/dp_coupling.F90 b/src/dynamics/mpas/dp_coupling.F90 index 5033085774..84f7abef83 100644 --- a/src/dynamics/mpas/dp_coupling.F90 +++ b/src/dynamics/mpas/dp_coupling.F90 @@ -37,7 +37,7 @@ module dp_coupling !========================================================================================= subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) - use cam_mpas_subdriver, only : cam_mpas_update_halo + use cam_mpas_subdriver, only: cam_mpas_update_halo ! Convert the dynamics output state into the physics input state. ! Note that all pressures and tracer mixing ratios coming from the dycore are based on @@ -74,28 +74,28 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) ! mesh information and coefficients needed for ! frontogenesis function calculation ! - real(r8), dimension(:,:), pointer :: defc_a - real(r8), dimension(:,:), pointer :: defc_b - real(r8), dimension(:,:), pointer :: cell_gradient_coef_x - real(r8), dimension(:,:), pointer :: cell_gradient_coef_y - real(r8), dimension(:,:), pointer :: edgesOnCell_sign - real(r8), dimension(:), pointer :: dvEdge - real(r8), dimension(:), pointer :: areaCell + real(r8), pointer :: defc_a(:,:) + real(r8), pointer :: defc_b(:,:) + real(r8), pointer :: cell_gradient_coef_x(:,:) + real(r8), pointer :: cell_gradient_coef_y(:,:) + real(r8), pointer :: edgesOnCell_sign(:,:) + real(r8), pointer :: dvEdge(:) + real(r8), pointer :: areaCell(:) - integer, dimension(:,:), pointer :: cellsOnEdge - integer, dimension(:,:), pointer :: edgesOnCell - integer, dimension(:), pointer :: nEdgesOnCell + integer, pointer :: cellsOnEdge(:,:) + integer, pointer :: edgesOnCell(:,:) + integer, pointer :: nEdgesOnCell(:) - real(r8), dimension(:,:), pointer :: uperp - real(r8), dimension(:,:), pointer :: utangential + real(r8), pointer :: uperp(:,:) + real(r8), pointer :: utangential(:,:) ! ! local storage for frontogenesis function and angle ! - real(r8), dimension(:,:), pointer :: frontogenesisFunction - real(r8), dimension(:,:), pointer :: frontogenesisAngle - real(r8), dimension(:,:), pointer :: pbuf_frontgf - real(r8), dimension(:,:), pointer :: pbuf_frontga + real(r8), pointer :: frontogenesisFunction(:,:) + real(r8), pointer :: frontogenesisAngle(:,:) + real(r8), pointer :: pbuf_frontgf(:,:) + real(r8), pointer :: pbuf_frontga(:,:) real(r8), allocatable :: frontgf_phys(:,:,:) real(r8), allocatable :: frontga_phys(:,:,:) @@ -178,11 +178,13 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) allocate(frontogenesisFunction(plev, nCellsSolve), stat=ierr) if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisFunction array') allocate(frontogenesisAngle(plev, nCellsSolve), stat=ierr) + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisAngle array') - allocate(frontgf_phys(pcols, pver, begchunk:endchunk)) - allocate(frontga_phys(pcols, pver, begchunk:endchunk)) + allocate(frontgf_phys(pcols, pver, begchunk:endchunk), stat=ierr) + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontgf_phys array') + allocate(frontga_phys(pcols, pver, begchunk:endchunk), stat=ierr) + if( ierr /= 0 ) call endrun(subname//':failed to allocate frontga_phys array') - if( ierr /= 0 ) call endrun(subname//':failed to allocate frontogenesisAngle array') call calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, & theta_m, tracers(index_qv,:,:), & @@ -247,8 +249,8 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) pbuf_chnk => pbuf_get_chunk(pbuf2d, lchnk) call pbuf_get_field(pbuf_chnk, frontgf_idx, pbuf_frontgf) call pbuf_get_field(pbuf_chnk, frontga_idx, pbuf_frontga) - do icol = 1, ncols - do k = 1, pver + do k = 1, pver + do icol = 1, ncols pbuf_frontgf(icol, k) = frontgf_phys(icol, k, lchnk) pbuf_frontga(icol, k) = frontga_phys(icol, k, lchnk) end do @@ -256,6 +258,8 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) end do deallocate(frontgf_phys) deallocate(frontga_phys) + deallocate(frontogenesisFunction) + deallocate(frontogenesisAngle) end if call t_stopf('dpcopy') @@ -266,8 +270,6 @@ subroutine d_p_coupling(phys_state, phys_tend, pbuf2d, dyn_out) deallocate(pmid,pintdry,pmiddry) - if (use_gw_front .or. use_gw_front_igw) deallocate(frontogenesisFunction, frontogenesisAngle) - end subroutine d_p_coupling !========================================================================================= @@ -753,7 +755,7 @@ subroutine hydrostatic_pressure(nCells, nVertLevels, zz, zgrid, rho_zz, theta_m, ! The vertical dimension for 3-d arrays is innermost, and k=1 represents ! the lowest layer or level in the fields. ! - use mpas_constants, only : cp, rgas, cv, gravity, p0 + use mpas_constants, only: cp, rgas, cv, gravity, p0 ! Arguments integer, intent(in) :: nCells @@ -921,7 +923,7 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, areaCell, dvEdge, cellsOnEdge, edgesOnCell, nEdgesOnCell, edgesOnCell_sign, & nVertLevels, nCellsSolve ) - use mpas_constants, only : rvord + use mpas_constants, only: rvord ! inputs @@ -941,23 +943,20 @@ subroutine calc_frontogenesis( frontogenesisFunction, frontogenesisAngle, ! outputs - real(r8), dimension(:,:), intent(out) :: frontogenesisFunction - real(r8), dimension(:,:), intent(out) :: frontogenesisAngle + real(r8), dimension(:,:), intent(out) :: frontogenesisFunction(:,:) + real(r8), dimension(:,:), intent(out) :: frontogenesisAngle(:,:) ! local storage integer :: iCell, iEdge, k, cell1, cell2 - integer :: CellStart, CellEnd real(r8), dimension(nVertLevels) :: d_diag, d_off_diag, divh, theta_x, theta_y real(r8) :: edge_sign, thetaEdge ! ! for each column, compute frontogenesis function and del(theta) angle ! - CellStart = 1 - CellEnd = nCellsSolve - do iCell = cellStart,cellEnd + do iCell = 1,nCellsSolve d_diag(1:nVertLevels) = 0.0_r8 d_off_diag(1:nVertLevels) = 0.0_r8 diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index 39b0eb63ee..cc6ac75114 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -933,7 +933,6 @@ subroutine cam_mpas_read_static(fh_ini, endrun) nullify(cell_gradient_coef_x) nullify(cell_gradient_coef_y) - call MPAS_createStream(mesh_stream, domain_ptr % ioContext, 'not_used', MPAS_IO_NETCDF, MPAS_IO_READ, & pio_file_desc=fh_ini, ierr=ierr) if (ierr /= MPAS_STREAM_NOERR) then @@ -1364,6 +1363,8 @@ subroutine cam_mpas_setup_restart(fh_rst, restart_stream, direction, endrun) type (field1DReal), pointer :: u_init type (field1DReal), pointer :: qv_init + nullify(cell_gradient_coef_x) + nullify(cell_gradient_coef_y) call MPAS_createStream(restart_stream, domain_ptr % ioContext, 'not_used', MPAS_IO_NETCDF, & direction, pio_file_desc=fh_rst, ierr=ierr) diff --git a/src/ionosphere/waccmx/ionosphere_interface.F90 b/src/ionosphere/waccmx/ionosphere_interface.F90 index 86735a8020..a63082ed33 100644 --- a/src/ionosphere/waccmx/ionosphere_interface.F90 +++ b/src/ionosphere/waccmx/ionosphere_interface.F90 @@ -14,7 +14,7 @@ module ionosphere_interface use physics_buffer, only: pbuf_get_index use constituents, only: cnst_get_ind, cnst_mw - use physconst, only: gravit + use physconst, only: gravit,rga use oplus, only: oplus_init use edyn_init, only: edynamo_init use pio, only: var_desc_t @@ -740,7 +740,7 @@ subroutine ionosphere_run2(phys_state, pbuf2d) ! Might need geometric height on midpoints for output !------------------------------------------------------------ if (hist_fld_active('Z3GM')) then - r8tmp = phys_state(lchnk)%zm(i, k) + phis(i)/gravit + r8tmp = phys_state(lchnk)%zm(i, k) + phis(i)*rga tempm(i, k) = r8tmp * (1._r8 + (r8tmp * rearth_inv)) end if ! physics state fields on interfaces (but only to pver) From 8b2c82451b36598276c18c493ecb27c4edc175a0 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 17 Aug 2023 10:23:19 -0600 Subject: [PATCH 20/24] group default namelist vars by name modified: bld/namelist_files/namelist_defaults_cam.xml --- bld/namelist_files/namelist_defaults_cam.xml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index d9f934468f..f117fc171d 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2942,10 +2942,12 @@ 2 1800.0D0 900.0D0 + 600.D0 .true. 2 3 + 4 0.0D0 0.0D0 0.0D0 @@ -2973,12 +2975,16 @@ 0.125D0 .true. 0.1D0 + 0.5D0 0.1D0 0.5D0 + 0.0D0 .true. 22000.0D0 + 80000.0D0 0.2D0 0.0D0 + 0.2D0 .true. 5.0 5 @@ -2998,13 +3004,6 @@ .false. .false. - 600.D0 - 4 - 80000.0D0 - 0.2D0 - 0.5D0 - 0.0D0 - From e6325feddbcf19c0dcf24f4141a95c8d5fc0c9a5 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 30 Nov 2023 10:33:29 -0700 Subject: [PATCH 21/24] derecho tests and pe layout modified: cime_config/config_pes.xml modified: cime_config/testdefs/testlist_cam.xml --- cime_config/config_pes.xml | 20 ++++++++++++++++++++ cime_config/testdefs/testlist_cam.xml | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cime_config/config_pes.xml b/cime_config/config_pes.xml index a312afec0d..7f0f268fe8 100644 --- a/cime_config/config_pes.xml +++ b/cime_config/config_pes.xml @@ -278,6 +278,26 @@ + + + + -4 + -4 + -4 + -4 + -4 + -4 + + + 1 + 1 + 1 + 1 + 1 + 1 + + + diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index 80d1342111..987f4dbc47 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -726,12 +726,13 @@ - + + @@ -2138,6 +2139,7 @@ + @@ -2147,6 +2149,7 @@ + From 03f8695318b3c925cc7168fcdc4ac8c94e748ab1 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 30 Nov 2023 12:58:07 -0700 Subject: [PATCH 22/24] remove derecho tests; ChangeLog draft --- cime_config/testdefs/testlist_cam.xml | 3 - doc/ChangeLog | 89 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index 987f4dbc47..b3673cc7c4 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -732,7 +732,6 @@ - @@ -2139,7 +2138,6 @@ - @@ -2149,7 +2147,6 @@ - diff --git a/doc/ChangeLog b/doc/ChangeLog index bc5b36c08f..7dc836c477 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,93 @@ +=============================================================== + +Tag name: cam6_3_138 +Originator(s): fvitt, skamaroc +Date: +One-line Summary: Frontogenesis gravity waves with MPAS dyncamical core +Github PR URL: https://github.com/ESCOMP/CAM/pull/688 + +Purpose of changes (include the issue number and title text for each relevant GitHub issue): + +Describe any changes made to build system: + +Describe any changes made to the namelist: + +List any changes to the defaults for the boundary datasets: + +Describe any substantial timing or memory changes: + +Code reviewed by: + +List all files eliminated: + +List all files added and what they do: +List all existing files that have been modified, and describe the changes: +M bld/namelist_files/namelist_defaults_cam.xml + - default namelist settings for waccm on mpasa120 grid + +M cime_config/config_pes.xml + - working cheyenne and derecho PE layouts for waccm on mpasa120 grid + +M cime_config/testdefs/testlist_cam.xml + - tests for waccm-sc on mpasa120 grid + +M cime_config/testdefs/testmods_dirs/cam/outfrq1d_physgrid_tem_mpasa120_wcmsc/user_nl_cam + - mpas namelist setting moved to namelist_defaults_cam.xml + +M src/dynamics/mpas/dp_coupling.F90 + - implement function for front generated gravity wave forcings + - code cleanup + +M src/dynamics/mpas/driver/cam_mpas_subdriver.F90 + - add MPAS stream fields for cell gradient coeffecients + - code cleanup + +M src/dynamics/mpas/dyn_comp.F90 + - set dyn_out pointers for frontogenesis calculations + - code cleanup + +M src/dynamics/mpas/dyn_grid.F90 + - minor code cleanup + +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. + +cheyenne/intel/aux_cam: + +derecho/intel/aux_cam: + +izumi/nag/aux_cam: + +izumi/gnu/aux_cam: + +CAM tag used for the baseline comparison tests if different than previous +tag: + +Summarize any changes to answers, i.e., +- what code configurations: +- what platforms/compilers: +- nature of change (roundoff; larger than roundoff but same climate; new + climate): + +If bitwise differences were observed, how did you show they were no worse +than roundoff? + +If this tag changes climate describe the run(s) done to evaluate the new +climate in enough detail that it(they) could be reproduced, i.e., +- source tag (all code used must be in the repository): +- platform/compilers: +- configure commandline: +- build-namelist command (or complete namelist): +- MSS location of output: + +MSS location of control simulations used to validate new climate: + +URL for AMWG diagnostics output used to validate new climate: + +=============================================================== =============================================================== Tag name: cam6_3_137 From 791855a117a2791d5985f20df8bc5d52833ff5a0 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 30 Nov 2023 13:13:22 -0700 Subject: [PATCH 23/24] ChangeLog update --- doc/ChangeLog | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 7dc836c477..a3f4c9df90 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -8,19 +8,22 @@ Github PR URL: https://github.com/ESCOMP/CAM/pull/688 Purpose of changes (include the issue number and title text for each relevant GitHub issue): -Describe any changes made to build system: + Add the capability to generate frontal gravity wave forcings when the MPAS dynamical core + is used. See github issue #400. -Describe any changes made to the namelist: +Describe any changes made to build system: N/A -List any changes to the defaults for the boundary datasets: +Describe any changes made to the namelist: N/A -Describe any substantial timing or memory changes: +List any changes to the defaults for the boundary datasets: N/A -Code reviewed by: +Describe any substantial timing or memory changes: N/A -List all files eliminated: +Code reviewed by: cacraigucar brian-eaton jtruesdal nusbaume -List all files added and what they do: +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 bld/namelist_files/namelist_defaults_cam.xml From b84b58f2484ee22c9d6cc85001ea35f7470c2f7c Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Fri, 1 Dec 2023 06:14:04 -0700 Subject: [PATCH 24/24] ChangeLog update --- doc/ChangeLog | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index a3f4c9df90..5428fcaed0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,8 +2,8 @@ Tag name: cam6_3_138 Originator(s): fvitt, skamaroc -Date: -One-line Summary: Frontogenesis gravity waves with MPAS dyncamical core +Date: 1 Dec 2023 +One-line Summary: Frontogenesis gravity waves with MPAS dynamical core Github PR URL: https://github.com/ESCOMP/CAM/pull/688 Purpose of changes (include the issue number and title text for each relevant GitHub issue): @@ -59,36 +59,32 @@ then copy the lines from the td.*.status files for the failed tests to the appropriate machine below. All failed tests must be justified. cheyenne/intel/aux_cam: + ERP_Ln9_Vnuopc.C96_C96_mg17.F2000climo.cheyenne_intel.cam-outfrq9s_mg3 (Overall: FAIL) details: + FAIL ERP_Ln9_Vnuopc.C96_C96_mg17.F2000climo.cheyenne_intel.cam-outfrq9s_mg3 MODEL_BUILD time=2 + ERP_Ln9_Vnuopc.f09_f09_mg17.FCSD_HCO.cheyenne_intel.cam-outfrq9s (Overall: FAIL) details: + FAIL ERP_Ln9_Vnuopc.f09_f09_mg17.FCSD_HCO.cheyenne_intel.cam-outfrq9s COMPARE_base_rest + FAIL ERP_Ln9_Vnuopc.f09_f09_mg17.FCSD_HCO.cheyenne_intel.cam-outfrq9s BASELINE /glade/p/cesm/amwg/cesm_baselines/cam6_3_137: DIFF + - pre-existing failures derecho/intel/aux_cam: + ERP_Ln9_Vnuopc.C96_C96_mg17.F2000climo.derecho_intel.cam-outfrq9s_mg3 (Overall: PEND) details: + PEND ERP_Ln9_Vnuopc.C96_C96_mg17.F2000climo.derecho_intel.cam-outfrq9s_mg3 SHAREDLIB_BUILD RERUN + ERP_Ln9_Vnuopc.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL) details: + FAIL ERP_Ln9_Vnuopc.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s COMPARE_base_rest + ERP_Ln9_Vnuopc.ne30pg3_ne30pg3_mg17.FW2000climo.derecho_intel.cam-outfrq9s_wcm_ne30 (Overall: PEND) details: + PEND ERP_Ln9_Vnuopc.ne30pg3_ne30pg3_mg17.FW2000climo.derecho_intel.cam-outfrq9s_wcm_ne30 RUN + PEND ERP_Ln9_Vnuopc.ne30pg3_ne30pg3_mg17.FW2000climo.derecho_intel.cam-outfrq9s_wcm_ne30 COMPARE_base_rest + - pre-existing failures izumi/nag/aux_cam: + DAE_Vnuopc.f45_f45_mg37.FHS94.izumi_nag.cam-dae (Overall: FAIL) details: + FAIL DAE_Vnuopc.f45_f45_mg37.FHS94.izumi_nag.cam-dae RUN time=10 + PEND DAE_Vnuopc.f45_f45_mg37.FHS94.izumi_nag.cam-dae COMPARE_base_da + - pre-existing failure -izumi/gnu/aux_cam: - -CAM tag used for the baseline comparison tests if different than previous -tag: - -Summarize any changes to answers, i.e., -- what code configurations: -- what platforms/compilers: -- nature of change (roundoff; larger than roundoff but same climate; new - climate): - -If bitwise differences were observed, how did you show they were no worse -than roundoff? - -If this tag changes climate describe the run(s) done to evaluate the new -climate in enough detail that it(they) could be reproduced, i.e., -- source tag (all code used must be in the repository): -- platform/compilers: -- configure commandline: -- build-namelist command (or complete namelist): -- MSS location of output: - -MSS location of control simulations used to validate new climate: +izumi/gnu/aux_cam: All PASS -URL for AMWG diagnostics output used to validate new climate: +Summarize any changes to answers: bit-for-bit unchanged =============================================================== ===============================================================