From 7867f368292f4bcacd8e9bed426e579039079a0b Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Fri, 3 May 2024 16:30:28 -0500 Subject: [PATCH] Switch global ocean in init mode to E3SM shared constants This merge also migrates the computation of the coriolis parameter to using E3SM shared constants. The unused constants module imports are removed from several init mode utilities to ensure that they don't use constants that are inconsistent with E3SM's versions. --- components/mpas-ocean/src/mode_init/Makefile | 4 +- .../mode_init/mpas_ocn_init_cell_markers.F | 3 - .../mode_init/mpas_ocn_init_global_ocean.F | 81 ++++++++++--------- .../mode_init/mpas_ocn_init_interpolation.F | 3 - .../mode_init/mpas_ocn_init_spherical_utils.F | 10 ++- .../mpas_ocn_init_ssh_and_landIcePressure.F | 2 - .../mode_init/mpas_ocn_init_vertical_grids.F | 2 - 7 files changed, 50 insertions(+), 55 deletions(-) diff --git a/components/mpas-ocean/src/mode_init/Makefile b/components/mpas-ocean/src/mode_init/Makefile index d1aba81e14f5..1890ce6c9269 100644 --- a/components/mpas-ocean/src/mode_init/Makefile +++ b/components/mpas-ocean/src/mode_init/Makefile @@ -2,7 +2,9 @@ OBJS = mpas_ocn_init_mode.o -UTILS = mpas_ocn_init_spherical_utils.o \ +UTILS = shr_kind_mod.o \ + shr_const_mod.o \ + mpas_ocn_init_spherical_utils.o \ mpas_ocn_init_vertical_grids.o \ mpas_ocn_init_cell_markers.o \ mpas_ocn_init_interpolation.o \ diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_cell_markers.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_cell_markers.F index ac2d3465757d..2aed74c10ab4 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_cell_markers.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_cell_markers.F @@ -22,11 +22,8 @@ module ocn_init_cell_markers use mpas_kind_types use mpas_derived_types use mpas_pool_routines - use mpas_constants use mpas_timer - use ocn_constants - implicit none private diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_global_ocean.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_global_ocean.F index 926400345e65..623e2db83b73 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_global_ocean.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_global_ocean.F @@ -20,18 +20,19 @@ module ocn_init_global_ocean + use shr_kind_mod, only: SHR_KIND_R8 + use shr_const_mod + use mpas_kind_types use mpas_io_units use mpas_derived_types use mpas_pool_routines - use mpas_constants use mpas_io use mpas_io_streams use mpas_stream_manager use mpas_timekeeping use mpas_dmpar - use ocn_constants use ocn_config use ocn_diagnostics_variables use ocn_init_cell_markers @@ -632,8 +633,8 @@ subroutine ocn_init_setup_global_ocean_read_topo(domain, iErr)!{{{ call MPAS_closeStream(topographyStream) if (config_global_ocean_topography_latlon_degrees) then - topoLat % array(:) = topoLat % array(:) * pii / 180.0_RKIND - topoLon % array(:) = topoLon % array(:) * pii / 180.0_RKIND + topoLat % array(:) = topoLat % array(:) * SHR_CONST_PI / 180.0_RKIND + topoLon % array(:) = topoLon % array(:) * SHR_CONST_PI / 180.0_RKIND end if end subroutine ocn_init_setup_global_ocean_read_topo!}}} @@ -753,8 +754,8 @@ subroutine ocn_init_setup_global_ocean_read_land_ice_topography(domain, iErr)!{{ call MPAS_closeStream(landIceThicknessStream) if (config_global_ocean_land_ice_topo_latlon_degrees) then - landIceThkLat % array(:) = landIceThkLat % array(:) * pii / 180.0_RKIND - landIceThkLon % array(:) = landIceThkLon % array(:) * pii / 180.0_RKIND + landIceThkLat % array(:) = landIceThkLat % array(:) * SHR_CONST_PI / 180.0_RKIND + landIceThkLon % array(:) = landIceThkLon % array(:) * SHR_CONST_PI / 180.0_RKIND end if end subroutine ocn_init_setup_global_ocean_read_land_ice_topography!}}} @@ -825,26 +826,26 @@ subroutine ocn_init_setup_global_ocean_create_model_topo(domain, iErr)!{{{ call ocn_init_interpolation_nearest_horiz(topoLon % array, topoLat % array, & topoIC % array, nLonTopo, nLatTopo, & lonCell, latCell, bottomDepthObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) if (config_global_ocean_topography_has_ocean_frac) then call ocn_init_interpolation_nearest_horiz(topoLon % array, topoLat % array, & oceanFracIC % array, nLonTopo, nLatTopo, & lonCell, latCell, oceanFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) end if elseif (config_global_ocean_topography_method == "bilinear_interpolation") then call ocn_init_interpolation_bilinear_horiz(topoLon % array, topoLat % array, & topoIC % array, nLonTopo, nLatTopo, & lonCell, latCell, bottomDepthObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) if (config_global_ocean_topography_has_ocean_frac) then call ocn_init_interpolation_bilinear_horiz(topoLon % array, topoLat % array, & oceanFracIC % array, nLonTopo, nLatTopo, & lonCell, latCell, oceanFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) end if else @@ -1108,44 +1109,44 @@ subroutine ocn_init_setup_global_ocean_interpolate_land_ice_topography(domain, i call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & landIceThkIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceThkObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & landIceDraftIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceDraftObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & landIceFracIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & groundedFracIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceGroundedFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) elseif (config_global_ocean_topography_method .eq. "bilinear_interpolation") then call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & landIceThkIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceThkObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & landIceDraftIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceDraftObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & landIceFracIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & groundedFracIC % array, nLonLandIceThk, nLatLandIceThk, & lonCell, latCell, landIceGroundedFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) else call mpas_log_write( 'Invalid choice of config_global_ocean_topography_method.', MPAS_LOG_CRIT) @@ -1641,11 +1642,11 @@ subroutine ocn_init_setup_global_ocean_read_tracer_lat_lon(domain, iErr)!{{{ if (config_global_ocean_tracer_latlon_degrees) then do iLat = 1, nLatTracer - tracerLat % array(iLat) = tracerLat % array(iLat) * pii / 180.0_RKIND + tracerLat % array(iLat) = tracerLat % array(iLat) * SHR_CONST_PI / 180.0_RKIND end do do iLon = 1, nLonTracer - tracerLon % array(iLon) = tracerLon % array(iLon) * pii / 180.0_RKIND + tracerLon % array(iLon) = tracerLon % array(iLon) * SHR_CONST_PI / 180.0_RKIND end do end if @@ -1713,11 +1714,11 @@ subroutine ocn_init_setup_global_ocean_read_swData_lat_lon(domain, iErr)!{{{ if (config_global_ocean_swData_latlon_degrees) then do iLat = 1, nLatSW - swDataLat % array(iLat) = swDataLat % array(iLat) * pii / 180.0_RKIND + swDataLat % array(iLat) = swDataLat % array(iLat) * SHR_CONST_PI / 180.0_RKIND end do do iLon = 1, nLonSW - swDataLon % array(iLon) = swDataLon % array(iLon) * pii / 180.0_RKIND + swDataLon % array(iLon) = swDataLon % array(iLon) * SHR_CONST_PI / 180.0_RKIND end do end if @@ -1800,11 +1801,11 @@ subroutine ocn_init_setup_global_ocean_read_ecosys_lat_lon(domain, iErr)!{{{ if (config_global_ocean_ecosys_latlon_degrees) then do iLat = 1, nLatEcosys - tracerLat % array(iLat) = tracerLat % array(iLat) * pii / 180.0_RKIND + tracerLat % array(iLat) = tracerLat % array(iLat) * SHR_CONST_PI / 180.0_RKIND end do do iLon = 1, nLonEcosys - tracerLon % array(iLon) = tracerLon % array(iLon) * pii / 180.0_RKIND + tracerLon % array(iLon) = tracerLon % array(iLon) * SHR_CONST_PI / 180.0_RKIND end do end if @@ -2071,13 +2072,13 @@ subroutine ocn_init_setup_global_ocean_interpolate_tracers(domain, tracerArray, call ocn_init_interpolation_nearest_horiz(tracerLon % array, tracerLat % array, & tracerIC % array, nLonTracer, nLatTracer, & lonCell, latCell, interpTracer, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) elseif (config_global_ocean_tracer_method .eq. "bilinear_interpolation") then call ocn_init_interpolation_bilinear_horiz(tracerLon % array, tracerLat % array, & tracerIC % array, nLonTracer, nLatTracer, & lonCell, latCell, interpTracer, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) else call mpas_log_write( 'Invalid choice of config_global_ocean_tracer_method.', MPAS_LOG_CRIT) @@ -2238,13 +2239,13 @@ subroutine ocn_init_setup_global_ocean_interpolate_ecosys_forcing(domain, fieldN call ocn_init_interpolation_nearest_horiz(tracerLon % array, tracerLat % array, & ecosysForcingIC % array(:,:,timeCounter), nLonEcosys, nLatEcosys, & lonCell, latCell, ecosysForcingField, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) elseif (config_global_ocean_ecosys_method .eq. "bilinear_interpolation") then call ocn_init_interpolation_bilinear_horiz(tracerLon % array, tracerLat % array, & ecosysForcingIC % array(:,:,timeCounter), nLonEcosys, nLatEcosys, & lonCell, latCell, ecosysForcingField, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) else call mpas_log_write( 'Invalid choice of config_global_ocean_ecosys_method.', MPAS_LOG_CRIT) iErr = 1 @@ -2448,33 +2449,33 @@ subroutine ocn_init_setup_global_ocean_interpolate_swData(domain, iErr)!{{{ call ocn_init_interpolation_nearest_horiz(swDataLon % array, swDataLat % array, & chlorophyllIC % array, nLonSW, nLatSW, & lonCell, latCell, chlorophyllData, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_nearest_horiz(swDataLon % array, swDataLat % array, & zenithAngleIC % array, nLonSW, nLatSW, & lonCell, latCell, zenithAngle, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_nearest_horiz(swDataLon % array, swDataLat % array, & clearSKYIC % array, nLonSW, nLatSW, & lonCell, latCell, clearSkyRadiation, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) elseif (config_global_ocean_swData_method .eq. "bilinear_interpolation") then call ocn_init_interpolation_bilinear_horiz(swDataLon % array, swDataLat % array, & chlorophyllIC % array, nLonSW, nLatSW, & lonCell, latCell, chlorophyllData, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_bilinear_horiz(swDataLon % array, swDataLat % array, & zenithAngleIC % array, nLonSW, nLatSW, & lonCell, latCell, zenithAngle, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_bilinear_horiz(swDataLon % array, swDataLat % array, & clearSKYIC % array, nLonSW, nLatSW, & lonCell, latCell, clearSkyRadiation, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) else call mpas_log_write( 'Invalid choice of config_global_ocean_swData_method.', MPAS_LOG_CRIT) iErr = 1 @@ -2602,8 +2603,8 @@ subroutine ocn_init_setup_global_ocean_read_windstress(domain, iErr)!{{{ call MPAS_closeStream(windstressStream) if (config_global_ocean_windstress_latlon_degrees) then - windLat % array(:) = windLat % array(:) * pii / 180.0_RKIND - windLon % array(:) = windLon % array(:) * pii / 180.0_RKIND + windLat % array(:) = windLat % array(:) * SHR_CONST_PI / 180.0_RKIND + windLon % array(:) = windLon % array(:) * SHR_CONST_PI / 180.0_RKIND end if end subroutine ocn_init_setup_global_ocean_read_windstress!}}} @@ -2656,23 +2657,23 @@ subroutine ocn_init_setup_global_ocean_interpolate_windstress(domain, iErr)!{{{ call ocn_init_interpolation_nearest_horiz(windLon % array, windLat % array, & zonalWindIC % array, nLonWind, nLatWind, & lonCell, latCell, windStressZonal, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) call ocn_init_interpolation_nearest_horiz(windLon % array, windLat % array, & meridionalWindIC % array, nLonWind, nLatWind, & lonCell, latCell, windStressMeridional, nCells, & - inXPeriod = 2.0_RKIND * pii) + inXPeriod = 2.0_RKIND * SHR_CONST_PI) elseif (config_global_ocean_windstress_method .eq. "bilinear_interpolation") then call ocn_init_interpolation_bilinear_horiz(windLon % array, windLat % array, & zonalWindIC % array, nLonWind, nLatWind, & lonCell, latCell, windStressZonal, nCells, & - inXPeriod = 2.0_RKIND*pii) + inXPeriod = 2.0_RKIND*SHR_CONST_PI) call ocn_init_interpolation_bilinear_horiz(windLon % array, windLat % array, & meridionalWindIC % array, nLonWind, nLatWind, & lonCell, latCell, windStressMeridional, nCells, & - inXPeriod = 2.0_RKIND*pii) + inXPeriod = 2.0_RKIND*SHR_CONST_PI) else call mpas_log_write( 'Invalid choice of config_global_ocean_windstress_method.', MPAS_LOG_CRIT) diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_interpolation.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_interpolation.F index 7510357606f4..3ff4df4b4dad 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_interpolation.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_interpolation.F @@ -22,11 +22,8 @@ module ocn_init_interpolation use mpas_kind_types use mpas_derived_types use mpas_pool_routines - use mpas_constants use mpas_timer - use ocn_constants - implicit none private save diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_spherical_utils.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_spherical_utils.F index d24c182e8c0a..4ccd920ddf9f 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_spherical_utils.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_spherical_utils.F @@ -19,11 +19,13 @@ module ocn_init_spherical_utils + use shr_kind_mod, only: SHR_KIND_R8 + use shr_const_mod + use mpas_kind_types use mpas_io_units use mpas_derived_types use mpas_pool_routines - use mpas_constants use mpas_stream_manager use ocn_config @@ -293,15 +295,15 @@ subroutine ocn_init_realistic_coriolis_parameter(domain, err)!{{{ call mpas_pool_get_array(meshPool, 'fVertex', fVertex) do iCell = 1, nCellsSolve - fCell(iCell) = 2.0_RKIND * omega * sin(latCell(iCell)) + fCell(iCell) = 2.0_RKIND * SHR_CONST_OMEGA * sin(latCell(iCell)) end do do iVertex = 1, nVerticesSolve - fVertex(iVertex) = 2.0_RKIND * omega * sin( latVertex(iVertex) ) + fVertex(iVertex) = 2.0_RKIND * SHR_CONST_OMEGA * sin( latVertex(iVertex) ) end do do iEdge = 1, nEdgesSolve - fEdge(iEdge) = 2.0_RKIND * omega * sin( latEdge(iEdge) ) + fEdge(iEdge) = 2.0_RKIND * SHR_CONST_OMEGA * sin( latEdge(iEdge) ) end do block_ptr => block_ptr % next diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_ssh_and_landIcePressure.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_ssh_and_landIcePressure.F index c85249635a7d..dfa7c6b430b6 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_ssh_and_landIcePressure.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_ssh_and_landIcePressure.F @@ -25,9 +25,7 @@ module ocn_init_ssh_and_landIcePressure use mpas_io_units use mpas_derived_types use mpas_pool_routines - use mpas_constants - use ocn_constants use ocn_config use ocn_diagnostics_variables diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F index 2fcbf507f7a3..e28cf5e97fad 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F @@ -22,11 +22,9 @@ module ocn_init_vertical_grids use mpas_kind_types use mpas_derived_types use mpas_pool_routines - use mpas_constants use mpas_timer use mpas_io - use ocn_constants use ocn_config use ocn_diagnostics_variables