diff --git a/components/mpas-ocean/src/mode_init/Registry_global_ocean.xml b/components/mpas-ocean/src/mode_init/Registry_global_ocean.xml index 682146ec002d..0ef1ff95245f 100644 --- a/components/mpas-ocean/src/mode_init/Registry_global_ocean.xml +++ b/components/mpas-ocean/src/mode_init/Registry_global_ocean.xml @@ -136,7 +136,7 @@ possible_values="Any real positive number." /> domain % blocklist - do while(associated(block_ptr)) - - call mpas_pool_get_subpool(block_ptr % structs, 'mesh', meshPool) - call mpas_pool_get_subpool(block_ptr % structs, 'landIceInit', landIceInitPool) - call mpas_pool_get_dimension(meshPool, 'nCells', nCells) - - call mpas_pool_get_array(meshPool, 'latCell', latCell) - call mpas_pool_get_array(meshPool, 'lonCell', lonCell) - call mpas_pool_get_array(landIceInitPool, 'landIceDraftObserved', landIceDraftObserved) - call mpas_pool_get_array(landIceInitPool, 'landIceThkObserved', landIceThkObserved) - call mpas_pool_get_array(landIceInitPool, 'landIceFracObserved', landIceFracObserved) - call mpas_pool_get_array(landIceInitPool, 'landIceGroundedFracObserved', landIceGroundedFracObserved) - - if (config_global_ocean_topography_method .eq. "nearest_neighbor") then - - call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & - landIceThkIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceThkObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) - - call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & - landIceDraftIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceDraftObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) - - call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & - landIceFracIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + if (config_global_ocean_topography_source == "latlon_file") then + block_ptr => domain % blocklist + do while(associated(block_ptr)) - call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & - groundedFracIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceGroundedFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + call mpas_pool_get_subpool(block_ptr % structs, 'mesh', meshPool) + call mpas_pool_get_subpool(block_ptr % structs, 'landIceInit', landIceInitPool) + call mpas_pool_get_dimension(meshPool, 'nCells', nCells) - 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) + call mpas_pool_get_array(meshPool, 'latCell', latCell) + call mpas_pool_get_array(meshPool, 'lonCell', lonCell) + call mpas_pool_get_array(landIceInitPool, 'landIceDraftObserved', landIceDraftObserved) + call mpas_pool_get_array(landIceInitPool, 'landIceThkObserved', landIceThkObserved) + call mpas_pool_get_array(landIceInitPool, 'landIceFracObserved', landIceFracObserved) + call mpas_pool_get_array(landIceInitPool, 'landIceGroundedFracObserved', landIceGroundedFracObserved) + + if (config_global_ocean_topography_method .eq. "nearest_neighbor") then + + call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & + landIceThkIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceThkObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) + + call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & + landIceDraftIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceDraftObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) + + call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & + landIceFracIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceFracObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) + + call ocn_init_interpolation_nearest_horiz(landIceThkLon % array, landIceThkLat % array, & + groundedFracIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceGroundedFracObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) + + 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) - call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & - landIceDraftIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceDraftObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & + landIceDraftIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceDraftObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) - call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & - landIceFracIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & + landIceFracIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceFracObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) - call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & - groundedFracIC % array, nLonLandIceThk, nLatLandIceThk, & - lonCell, latCell, landIceGroundedFracObserved, nCells, & - inXPeriod = 2.0_RKIND * pii) + call ocn_init_interpolation_bilinear_horiz(landIceThkLon % array, landIceThkLat % array, & + groundedFracIC % array, nLonLandIceThk, nLatLandIceThk, & + lonCell, latCell, landIceGroundedFracObserved, nCells, & + inXPeriod = 2.0_RKIND * pii) - else - call mpas_log_write( 'Invalid choice of config_global_ocean_topography_method.', MPAS_LOG_CRIT) - iErr = 1 - call mpas_dmpar_finalize(domain % dminfo) - endif + else + call mpas_log_write( 'Invalid choice of config_global_ocean_topography_method.', MPAS_LOG_CRIT) + iErr = 1 + call mpas_dmpar_finalize(domain % dminfo) + endif - block_ptr => block_ptr % next - end do + block_ptr => block_ptr % next + end do + end if ! Iteratively smooth landIceDraftObserved, landIceThkObserved, landIceFracObserved, @@ -2803,6 +2809,7 @@ subroutine ocn_init_validate_global_ocean(configPool, packagePool, iocontext, iE type (mpas_io_context_type), pointer :: iocontext_ptr type (MPAS_IO_Handle_type) :: inputFile character (len=StrKIND), pointer :: config_init_configuration, & + config_global_ocean_topography_source, & config_global_ocean_depth_file, & config_global_ocean_depth_dimname, & config_global_ocean_temperature_file, & @@ -2842,6 +2849,8 @@ subroutine ocn_init_validate_global_ocean(configPool, packagePool, iocontext, iE call mpas_pool_get_config(configPool, 'config_vert_levels', config_vert_levels) + call mpas_pool_get_config(configPool, 'config_global_ocean_topography_source', & + config_global_ocean_topography_source) call mpas_pool_get_config(configPool, 'config_global_ocean_depth_file', & config_global_ocean_depth_file) call mpas_pool_get_config(configPool, 'config_global_ocean_depth_dimname', & @@ -2975,23 +2984,34 @@ subroutine ocn_init_validate_global_ocean(configPool, packagePool, iocontext, iE call MPAS_io_close(inputFile, iErr) - if (trim(config_global_ocean_topography_file) == 'none') then - call mpas_log_write( 'Validation failed for global ocean. ' & - // 'Invalid filename for config_global_ocean_topography_file', MPAS_LOG_CRIT) + if (config_global_ocean_topography_source /= 'latlon_file' .and. & + config_global_ocean_topography_source /= 'mpas_variable') then + call mpas_log_write( 'Unexpected value for config_global_ocean_topography_source: ' & + // trim(config_global_ocean_topography_source), MPAS_LOG_CRIT) iErr = 1 return end if - inputFile = MPAS_io_open(config_global_ocean_topography_file, MPAS_IO_READ, MPAS_IO_NETCDF, iocontext_ptr, ierr=iErr) - if (iErr .ne. 0) then - call mpas_log_write( 'could not open file '// trim(config_global_ocean_topography_file), MPAS_LOG_CRIT) + if (config_global_ocean_topography_file == 'none' .and. & + config_global_ocean_topography_source == 'latlon_file') then + call mpas_log_write( 'Validation failed for global ocean. ' & + // 'Invalid filename for config_global_ocean_topography_file', MPAS_LOG_CRIT) + iErr = 1 return end if - call MPAS_io_inq_dim(inputFile, config_global_ocean_topography_nlat_dimname, nLatTopo, iErr) - call MPAS_io_inq_dim(inputFile, config_global_ocean_topography_nlon_dimname, nLonTopo, iErr) + if (config_global_ocean_topography_source == 'latlon_file') then + inputFile = MPAS_io_open(config_global_ocean_topography_file, MPAS_IO_READ, MPAS_IO_NETCDF, iocontext_ptr, ierr=iErr) + if (iErr /= 0) then + call mpas_log_write( 'could not open file '// trim(config_global_ocean_topography_file), MPAS_LOG_CRIT) + return + end if + + call MPAS_io_inq_dim(inputFile, config_global_ocean_topography_nlat_dimname, nLatTopo, iErr) + call MPAS_io_inq_dim(inputFile, config_global_ocean_topography_nlon_dimname, nLonTopo, iErr) - call MPAS_io_close(inputFile, iErr) + call MPAS_io_close(inputFile, iErr) + end if inputFile = MPAS_io_open(config_global_ocean_windstress_file, MPAS_IO_READ, MPAS_IO_NETCDF, iocontext_ptr, ierr=iErr) if (iErr .ne. 0) then @@ -3039,23 +3059,26 @@ subroutine ocn_init_validate_global_ocean(configPool, packagePool, iocontext, iE end if if (config_global_ocean_depress_by_land_ice) then - if (trim(config_global_ocean_land_ice_topo_file) == 'none') then + if (config_global_ocean_land_ice_topo_file == 'none' .and. & + config_global_ocean_topography_source == 'latlon_file') then call mpas_log_write( 'Validation failed for global ocean. '// & 'Invalid filename for config_global_ocean_land_ice_topo_file', MPAS_LOG_CRIT) iErr = 1 return end if - inputFile = MPAS_io_open(config_global_ocean_land_ice_topo_file, MPAS_IO_READ, MPAS_IO_NETCDF, iocontext_ptr, ierr=iErr) - if (iErr .ne. 0) then - call mpas_log_write( 'could not open file '// trim(config_global_ocean_land_ice_topo_file), MPAS_LOG_CRIT) - return - end if + if(config_global_ocean_topography_source == 'latlon_file') then + inputFile = MPAS_io_open(config_global_ocean_land_ice_topo_file, MPAS_IO_READ, MPAS_IO_NETCDF, iocontext_ptr, ierr=iErr) + if (iErr /= 0) then + call mpas_log_write( 'could not open file '// trim(config_global_ocean_land_ice_topo_file), MPAS_LOG_CRIT) + return + end if - call MPAS_io_inq_dim(inputFile, config_global_ocean_land_ice_topo_nlat_dimname, nLatLandIceThk, iErr) - call MPAS_io_inq_dim(inputFile, config_global_ocean_land_ice_topo_nlon_dimname, nLonLandIceThk, iErr) + call MPAS_io_inq_dim(inputFile, config_global_ocean_land_ice_topo_nlat_dimname, nLatLandIceThk, iErr) + call MPAS_io_inq_dim(inputFile, config_global_ocean_land_ice_topo_nlon_dimname, nLonLandIceThk, iErr) - call MPAS_io_close(inputFile, iErr) + call MPAS_io_close(inputFile, iErr) + end if end if !--------------------------------------------------------------------