diff --git a/doc/ChangeLog b/doc/ChangeLog index ab83bacb34..48d6f320f7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -24,8 +24,8 @@ List all files eliminated: N/A List all files added and what they do: N/A List all existing files that have been modified, and describe the changes: -M src/dynamics/mpas/driver/cam_mpas_subdriver.F90 - - Modifies cam_mpas_read_static to ensure lonCell values are in [0,2pi) range +M src/dynamics/mpas/dyn_grid.F90 + - Modifies setup_time_invariant to ensure lonCell values are in [0,2pi) range 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, diff --git a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 index 376389efef..676bacd4af 100644 --- a/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 +++ b/src/dynamics/mpas/driver/cam_mpas_subdriver.F90 @@ -884,16 +884,15 @@ subroutine cam_mpas_read_static(fh_ini, endrun) use pio, only : file_desc_t - use mpas_kind_types, only : StrKIND, RKIND + use mpas_kind_types, only : StrKIND use mpas_io_streams, only : MPAS_createStream, MPAS_closeStream, MPAS_streamAddField, MPAS_readStream use mpas_derived_types, only : MPAS_IO_READ, MPAS_IO_NETCDF, MPAS_Stream_type, MPAS_pool_type, & field0DReal, field1DReal, field2DReal, field3DReal, field1DInteger, field2DInteger, & MPAS_STREAM_NOERR 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, MPAS_pool_get_array + MPAS_pool_add_config use mpas_dmpar, only : MPAS_dmpar_exch_halo_field use mpas_stream_manager, only : postread_reindex - use mpas_constants, only : pii ! Arguments type (file_desc_t), pointer :: fh_ini @@ -930,11 +929,8 @@ subroutine cam_mpas_read_static(fh_ini, endrun) type (MPAS_Stream_type) :: mesh_stream - real(kind=RKIND), dimension(:), pointer :: lonCell_arr - nullify(cell_gradient_coef_x) nullify(cell_gradient_coef_y) - nullify(lonCell_arr) call MPAS_createStream(mesh_stream, domain_ptr % ioContext, 'not_used', MPAS_IO_NETCDF, MPAS_IO_READ, & pio_file_desc=fh_ini, ierr=ierr) @@ -1175,11 +1171,6 @@ subroutine cam_mpas_read_static(fh_ini, endrun) call endrun(subname//': FATAL: Failed to close static input stream.') end if - call mpas_pool_get_array(meshPool, 'lonCell', lonCell_arr) - - ! Ensure longitudes w/i [0, 2*pi) range - lonCell_arr(:) = lonCell_arr(:) - (2._RKIND*pii) * floor(lonCell_arr(:) / (2._RKIND*pii)) - ! ! Perform halo updates for all decomposed fields (i.e., fields with ! an outermost dimension of nCells, nVertices, or nEdges) diff --git a/src/dynamics/mpas/dyn_grid.F90 b/src/dynamics/mpas/dyn_grid.F90 index d0b53c5fa0..d289d84499 100644 --- a/src/dynamics/mpas/dyn_grid.F90 +++ b/src/dynamics/mpas/dyn_grid.F90 @@ -453,6 +453,8 @@ subroutine setup_time_invariant(fh_ini) type(mpas_pool_type), pointer :: meshPool real(r8), pointer :: rdzw(:) real(r8), allocatable :: dzw(:) + integer, pointer :: nCells + real(r8), dimension(:), pointer :: lonCell integer :: k, kk integer :: ierr @@ -473,6 +475,7 @@ subroutine setup_time_invariant(fh_ini) call mpas_pool_get_dimension(meshPool, 'nEdgesSolve', nEdgesSolve) call mpas_pool_get_dimension(meshPool, 'nVerticesSolve', nVerticesSolve) call mpas_pool_get_dimension(meshPool, 'nVertLevels', nVertLevelsSolve) ! MPAS always solves over the full column + call mpas_pool_get_dimension(meshPool, 'nCells', nCells) ! check that number of vertical layers matches MPAS grid data if (plev /= nVertLevelsSolve) then @@ -482,6 +485,16 @@ subroutine setup_time_invariant(fh_ini) ') does not match plev ('//int2str(nVertLevelsSolve)//').') end if + ! Ensure longitudes are within the [0,2*pi) range, and only remap values that + ! are outside the range. Some non-simple physics in CAM require this + ! longitude range, MPAS may have any (radian) value in lonCell + call mpas_pool_get_array(meshPool, 'lonCell', lonCell) + do k=1,nCells + if (lonCell(k) < 0._r8 .or. lonCell(k) .ge. (2._r8 * pi)) then + lonCell(k) = lonCell(k) - (2._r8 * pi) * floor(lonCell(k) / (2._r8 * pi)) + end if + end do + ! Initialize fields needed for reconstruction of cell-centered winds from edge-normal winds ! Note: This same pair of calls happens a second time later in the initialization of ! the MPAS-A dycore (in atm_mpas_init_block), but the redundant calls do no harm