Skip to content

Commit

Permalink
Merge pull request #1922 from GEOS-ESM/bugfix/mathomp4/1888-identity-…
Browse files Browse the repository at this point in the history
…method-fix

Fixes #1888. Set regrid_method to identity for native collections
  • Loading branch information
mathomp4 committed Jan 13, 2023
2 parents 5a21ae9 + cafef07 commit ed0b8dd
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Apps/Regrid_Util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ subroutine process_command_line(this,rc)
if (.not.allocated(this%tripolar_file_out)) then
this%tripolar_file_out = "empty"
end if
this%regridMethod = get_regrid_method(regridMth)
this%regridMethod = regrid_method_string_to_int(regridMth)
_ASSERT(this%regridMethod/=UNSPECIFIED_REGRID_METHOD,"improper regrid method chosen")

this%filenames = split_string(cfilenames,',')
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Renamed `get_regrid_method` and `translate_regrid_method` to `regrid_method_string_to_int` and `regrid_method_int_to_string`
respectively in `RegridMethods.F90`. This was done so we could add `get_regrid_method` to the AbstractRegridder. The new names
more accurately reflect what the RegridMethods functions do.
- Changed call to `MAPL_SunOrbitCreate()` inside `MAPL_Generic.F90` to call to new function
`MAPL_SunOrbitCreateFromConfig()`, the latter which get the orbital parameters from the MAPL
state's Config. In this way no default orbital parameter values need appear in `MAPL_Generic.F90`.
Expand All @@ -27,8 +30,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Added the correct values to halo corner of LatLon grid
- Added the correct values to halo corner of LatLon grid
- Fixed range in halo of LatLonGridFactory
- Corrected issue with native output having metadata saying it was bilinearly regridded. Now sets these files to have
`regrid_method: identity`
- Fix bug in `mapl_acg.cmake` that caused unnecessary rebuilds

### Removed
Expand Down
80 changes: 43 additions & 37 deletions base/MAPL_AbstractRegridder.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module MAPL_AbstractRegridderMod
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64
implicit none
private

public :: AbstractRegridder

type, abstract :: AbstractRegridder
Expand All @@ -29,7 +29,7 @@ module MAPL_AbstractRegridderMod
procedure :: get_spec
procedure :: set_spec
procedure :: isTranspose

procedure :: regrid_scalar_2d_real32
procedure :: regrid_scalar_2d_real64
procedure :: regrid_scalar_3d_real32
Expand All @@ -44,7 +44,7 @@ module MAPL_AbstractRegridderMod
! interfaces.
procedure :: regrid_esmf_fields_scalar
procedure :: regrid_esmf_fields_vector

! Generic overload
generic :: regrid => regrid_esmf_fields_scalar
generic :: regrid => regrid_esmf_fields_vector
Expand Down Expand Up @@ -90,6 +90,7 @@ module MAPL_AbstractRegridderMod
procedure :: get_undef_value
procedure :: clear_undef_value
procedure :: has_undef_value
procedure :: get_regrid_method

end type AbstractRegridder

Expand All @@ -105,7 +106,7 @@ subroutine initialize_subclass(this, unusable, rc)
class (KeywordEnforcer), optional, intent(in) :: unusable
integer, optional, intent(out) :: rc
end subroutine initialize_subclass

end interface

character(len=*), parameter :: MOD_NAME = 'MAPL_AbstractRegridder::'
Expand Down Expand Up @@ -272,7 +273,7 @@ subroutine regrid_esmf_fields_scalar(this, f_in, f_out, rc)
type (ESMF_Field), intent(in) :: f_in
type (ESMF_Field), intent(in) :: f_out
integer, optional, intent(out) :: rc

character(len=*), parameter :: Iam = MOD_NAME//'regrid_esmf_fields'
integer :: rank_in
type (ESMF_TypeKind_Flag) :: typekind_in
Expand All @@ -298,7 +299,7 @@ subroutine regrid_esmf_fields_scalar(this, f_in, f_out, rc)

block
real(REAL32), pointer :: q_in(:,:), q_out(:,:)

call ESMF_FieldGet(f_in , 0, q_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_out , 0, q_out, rc=status)
Expand All @@ -311,7 +312,7 @@ subroutine regrid_esmf_fields_scalar(this, f_in, f_out, rc)

block
real(REAL64), pointer :: q_in(:,:), q_out(:,:)

call ESMF_FieldGet(f_in , 0, q_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_out , 0, q_out, rc=status)
Expand Down Expand Up @@ -356,13 +357,13 @@ subroutine regrid_esmf_fields_scalar(this, f_in, f_out, rc)
case default ! unsupported type/kind
_FAIL( 'unsupported type kind')
end select

case default ! unsupported rank
_FAIL( 'unsupported rank')
end select

_RETURN(_SUCCESS)

end subroutine regrid_esmf_fields_scalar


Expand All @@ -377,7 +378,7 @@ subroutine regrid_esmf_fields_vector(this, f_in, f_out, rc)
type (ESMF_Field), intent(in) :: f_in(NUM_DIM)
type (ESMF_Field), intent(in) :: f_out(NUM_DIM)
integer, optional, intent(out) :: rc

character(len=*), parameter :: Iam = MOD_NAME//'regrid_esmf_fields'
integer :: rank_in(NUM_DIM)
type (ESMF_TypeKind_Flag) :: typekind_in(NUM_DIM)
Expand Down Expand Up @@ -413,7 +414,7 @@ subroutine regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL32), pointer :: u_in(:,:), v_in(:,:)
real(REAL32), pointer :: u_out(:,:), v_out(:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -431,7 +432,7 @@ subroutine regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL64), pointer :: u_in(:,:), v_in(:,:)
real(REAL64), pointer :: u_out(:,:), v_out(:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -455,7 +456,7 @@ subroutine regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL32), pointer :: u_in(:,:,:), v_in(:,:,:)
real(REAL32), pointer :: u_out(:,:,:), v_out(:,:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -473,7 +474,7 @@ subroutine regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL64), pointer :: u_in(:,:,:), v_in(:,:,:)
real(REAL64), pointer :: u_out(:,:,:), v_out(:,:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -489,19 +490,19 @@ subroutine regrid_esmf_fields_vector(this, f_in, f_out, rc)
case default ! unsupported type/kind
_FAIL( 'unsupported type-kind')
end select

case default ! unsupported rank
_FAIL( 'unsupported rank')
end select

_RETURN(_SUCCESS)


end subroutine regrid_esmf_fields_vector


! Begin - transpose interfaces

subroutine transpose_regrid_scalar_2d_real32(this, q_in, q_out, rc)
class (AbstractRegridder), intent(in) :: this
real(kind=REAL32), intent(in) :: q_in(:,:)
Expand Down Expand Up @@ -531,7 +532,7 @@ subroutine transpose_regrid_scalar_2d_real64(this, q_in, q_out, rc)
_RETURN(_FAILURE)
end subroutine transpose_regrid_scalar_2d_real64


subroutine transpose_regrid_scalar_3d_real32(this, q_in, q_out, rc)
class (AbstractRegridder), intent(in) :: this
real(kind=REAL32), intent(in) :: q_in(:,:,:)
Expand Down Expand Up @@ -563,7 +564,7 @@ subroutine transpose_regrid_scalar_3d_real64(this, q_in, q_out, rc)

end subroutine transpose_regrid_scalar_3d_real64


subroutine transpose_regrid_vector_2d_real32(this, u_in, v_in, u_out, v_out, rotate, rc)
class (AbstractRegridder), intent(in) :: this
real(kind=REAL32), intent(in) :: u_in(:,:)
Expand All @@ -585,7 +586,7 @@ subroutine transpose_regrid_vector_2d_real32(this, u_in, v_in, u_out, v_out, rot
u_out = 0
v_out = 0
_RETURN(_FAILURE)

end subroutine transpose_regrid_vector_2d_real32


Expand All @@ -610,7 +611,7 @@ subroutine transpose_regrid_vector_2d_real64(this, u_in, v_in, u_out, v_out, rot
u_out = 0
v_out = 0
_RETURN(_FAILURE)

end subroutine transpose_regrid_vector_2d_real64


Expand All @@ -635,7 +636,7 @@ subroutine transpose_regrid_vector_3d_real32(this, u_in, v_in, u_out, v_out, rot
u_out = 0
v_out = 0
_RETURN(_FAILURE)

end subroutine transpose_regrid_vector_3d_real32


Expand All @@ -658,7 +659,7 @@ subroutine transpose_regrid_vector_3d_real64(this, u_in, v_in, u_out, v_out, rc)
u_out = 0
v_out = 0
_RETURN(_FAILURE)

end subroutine transpose_regrid_vector_3d_real64


Expand All @@ -672,7 +673,7 @@ subroutine transpose_regrid_esmf_fields_scalar(this, f_in, f_out, rc)
type (ESMF_Field), intent(in) :: f_in
type (ESMF_Field), intent(in) :: f_out
integer, optional, intent(out) :: rc

character(len=*), parameter :: Iam = MOD_NAME//'transpose_regrid_esmf_fields'
integer :: rank_in
type (ESMF_TypeKind_Flag) :: typekind_in
Expand All @@ -698,7 +699,7 @@ subroutine transpose_regrid_esmf_fields_scalar(this, f_in, f_out, rc)

block
real(REAL32), pointer :: q_in(:,:), q_out(:,:)

call ESMF_FieldGet(f_in , 0, q_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_out , 0, q_out, rc=status)
Expand All @@ -711,7 +712,7 @@ subroutine transpose_regrid_esmf_fields_scalar(this, f_in, f_out, rc)

block
real(REAL64), pointer :: q_in(:,:), q_out(:,:)

call ESMF_FieldGet(f_in , 0, q_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_out , 0, q_out, rc=status)
Expand Down Expand Up @@ -756,13 +757,13 @@ subroutine transpose_regrid_esmf_fields_scalar(this, f_in, f_out, rc)
case default ! unsupported type/kind
_FAIL( 'unsupported typekind')
end select

case default ! unsupported rank
_FAIL( 'unsupported rank')
end select

_RETURN(_SUCCESS)

end subroutine transpose_regrid_esmf_fields_scalar


Expand All @@ -777,7 +778,7 @@ subroutine transpose_regrid_esmf_fields_vector(this, f_in, f_out, rc)
type (ESMF_Field), intent(in) :: f_in(NUM_DIM)
type (ESMF_Field), intent(in) :: f_out(NUM_DIM)
integer, optional, intent(out) :: rc

character(len=*), parameter :: Iam = MOD_NAME//'transpose_regrid_esmf_fields'
integer :: rank_in(NUM_DIM)
type (ESMF_TypeKind_Flag) :: typekind_in(NUM_DIM)
Expand Down Expand Up @@ -813,7 +814,7 @@ subroutine transpose_regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL32), pointer :: u_in(:,:), v_in(:,:)
real(REAL32), pointer :: u_out(:,:), v_out(:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -831,7 +832,7 @@ subroutine transpose_regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL64), pointer :: u_in(:,:), v_in(:,:)
real(REAL64), pointer :: u_out(:,:), v_out(:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -855,7 +856,7 @@ subroutine transpose_regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL32), pointer :: u_in(:,:,:), v_in(:,:,:)
real(REAL32), pointer :: u_out(:,:,:), v_out(:,:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -873,7 +874,7 @@ subroutine transpose_regrid_esmf_fields_vector(this, f_in, f_out, rc)
block
real(REAL64), pointer :: u_in(:,:,:), v_in(:,:,:)
real(REAL64), pointer :: u_out(:,:,:), v_out(:,:,:)

call ESMF_FieldGet(f_in(1) , 0, u_in, rc=status)
_VERIFY(status)
call ESMF_FieldGet(f_in(2) , 0, v_in, rc=status)
Expand All @@ -889,13 +890,13 @@ subroutine transpose_regrid_esmf_fields_vector(this, f_in, f_out, rc)
case default ! unsupported type/kind
_FAIL( 'unsupported typekind')
end select

case default ! unsupported rank
_FAIL( 'unsupported rank')
end select

_RETURN(_SUCCESS)


end subroutine transpose_regrid_esmf_fields_vector

Expand Down Expand Up @@ -940,7 +941,7 @@ function get_spec(this) result(spec)
class (AbstractRegridder), intent(in) :: this
spec = this%spec
end function get_spec

subroutine set_spec(this, spec)
class(AbstractRegridder), intent(inout) :: this
type(RegridderSpec), intent(in) :: spec
Expand Down Expand Up @@ -974,7 +975,7 @@ subroutine initialize_base(this, spec, unusable, rc)
_RETURN(_SUCCESS)

end subroutine initialize_base

function clone(this)
class (AbstractRegridder), allocatable :: clone
class (AbstractRegridder), intent(in) :: this
Expand All @@ -1000,4 +1001,9 @@ logical function supports(spec, unusable, rc)

end function supports

integer function get_regrid_method(this) result(method)
class (AbstractRegridder), intent(in) :: this
method = this%spec%regrid_method
end function get_regrid_method

end module MAPL_AbstractRegridderMod
Loading

0 comments on commit ed0b8dd

Please sign in to comment.