subroutine MAPL_IOChangeRes(cfIn,cfOut,dimNames,dimSizes,rc)
type(FileMetadata), intent(inout) :: cfIn
type(Filemetadata), intent(inout) :: cfOut
character(len=*) :: dimNames(:)
integer, intent(in) :: dimSizes(:)
integer, intent(out), optional :: rc
integer :: status
type(StringIntegerMap) :: newDims
integer :: i
do i=1,size(dimNames)
call newDims%insert(trim(dimNames(i)),dimSizes(i))
enddo
cfOut = cfIn
call modify_grid_dimensions(rc=status)
_VERIFY(status)
call modify_coordinate_vars(rc=status)
_RETURN(ESMF_SUCCESS)
contains
subroutine modify_grid_dimensions(rc)
integer, optional, intent(out) :: rc
integer :: status
type(StringIntegerMap), pointer :: dims
type(StringIntegerMapIterator) :: iter
character(len=:), pointer :: name
integer, pointer :: newExtent => null()
dims => cfIn%get_dimensions()
iter = dims%begin()
do while (iter /= dims%end())
name => iter%key()
newExtent => newDims%at(trim(name))
if (associated(newExtent)) then
call cfOut%modify_dimension(trim(name),newExtent,rc=status)
nullify(newExtent)
end if
call iter%next()
enddo
_RETURN(ESMF_SUCCESS)
end subroutine modify_grid_dimensions
subroutine modify_coordinate_vars(rc)
integer, optional, intent(out) :: rc
integer :: status
type(StringVariableMap), pointer :: vars
type(StringVariableMapIterator) :: iter
type(CoordinateVariable), pointer :: cvar
character(len=:), pointer :: name
real(kind=REAL32) :: r32_x1,r32_x0
real(kind=REAL64) :: r64_x1,r64_x0
real(kind=REAL32), allocatable :: var32(:)
real(kind=REAL64), allocatable :: var64(:)
integer, pointer :: newExtent => null()
class(*), pointer :: dim_var_values(:)
class(*), allocatable :: coordinate_data(:)
vars => cfIn%get_variables()
iter = vars%begin()
do while (iter /= vars%end())
name => iter%key()
newExtent => newDims%at(trim(name))
if (associated(newExtent)) then
cvar => cfOut%get_coordinate_variable(trim(name),rc=status)
if (status==ESMF_SUCCESS) then
dim_var_values => cvar%get_coordinate_data()
select type(q => dim_var_values)
type is (real(REAL32))
r32_x0=1.0d0
r32_x1=dble(newExtent)
var32 = MAPL_Range(r32_x0,r32_x1,newExtent)
allocate(coordinate_data,source=var32)
call cvar%replace_coordinate_data(coordinate_data)
deallocate(coordinate_data,var32)
type is (real(REAL64))
r64_x0=1.0d0
r64_x1=dble(newExtent)
var64 = MAPL_Range(r64_x0,r64_x1,newExtent)
allocate(coordinate_data,source=var64)
call cvar%replace_coordinate_data(coordinate_data)
deallocate(coordinate_data,var64)
class default
status = ESMF_FAILURE
end select
end if
nullify(newExtent)
end if
call iter%next()
enddo
_RETURN(ESMF_SUCCESS)
end subroutine modify_coordinate_vars
end subroutine MAPL_IOChangeRes