-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set is_allocated in all horiz_interp_type_new routines #1538
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
154a541
set is_allocated in interp_type for every variant of the *_new routines
5f83a86
add tests
5d04cfd
rm whitespace and fix missed compile errors in time_interp
2d94c14
undo time_interp changes, and change bicubic CPP name to be more accu…
0a6317d
add doxygen comments for variables in assignment/types test
ebce5ab
rename the SPHERICA constant and remove the other interpolation metho…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,12 @@ program horiz_interp_test | |
use fms_mod, only : check_nml_error, fms_init | ||
use horiz_interp_mod, only : horiz_interp_init, horiz_interp_new, horiz_interp_del | ||
use horiz_interp_mod, only : horiz_interp, horiz_interp_type | ||
use horiz_interp_spherical_mod, only: horiz_interp_spherical_wght | ||
use horiz_interp_type_mod, only: SPHERICA | ||
use constants_mod, only : constants_init, PI | ||
use horiz_interp_bilinear_mod, only: horiz_interp_bilinear_new | ||
use horiz_interp_spherical_mod, only: horiz_interp_spherical_wght, horiz_interp_spherical_new | ||
use horiz_interp_bicubic_mod, only: horiz_interp_bicubic_new | ||
use horiz_interp_conserve_mod, only: horiz_interp_conserve_new | ||
use platform_mod | ||
|
||
implicit none | ||
|
@@ -957,6 +960,8 @@ subroutine test_horiz_interp_conserve | |
!> Tests the assignment overload for horiz_interp_type | ||
!! creates some new instances of the derived type for the different methods | ||
!! and tests equality of fields after initial weiht calculations | ||
!! Also tests creating the types via the method-specific *_new routines to ensure | ||
!! they can be created/deleted without allocation errors. | ||
subroutine test_assignment() | ||
type(horiz_interp_type) :: Interp_new1, Interp_new2, Interp_cp, intp_3 | ||
!! grid data points | ||
|
@@ -968,8 +973,8 @@ subroutine test_assignment() | |
real(HI_TEST_KIND_), allocatable, dimension(:) :: lat_out_bil, lon_out_bil | ||
real(HI_TEST_KIND_), allocatable, dimension(:,:) :: lat_in_bil, lon_in_bil | ||
!! array sizes and number of lat/lon per index | ||
real(HI_TEST_KIND_) :: nlon_in, nlat_in | ||
real(HI_TEST_KIND_) :: nlon_out, nlat_out | ||
integer :: nlon_in, nlat_in | ||
integer :: nlon_out, nlat_out | ||
real(HI_TEST_KIND_) :: dlon_src, dlat_src, dlon_dst, dlat_dst | ||
!! parameters for lon/lat setup | ||
real(HI_TEST_KIND_) :: lon_src_beg = 0._lkind, lon_src_end = 360._lkind | ||
|
@@ -979,6 +984,10 @@ subroutine test_assignment() | |
real(HI_TEST_KIND_) :: D2R = real(PI,HI_TEST_KIND_)/180._lkind | ||
real(HI_TEST_KIND_) :: R2D = 180._lkind/real(PI,HI_TEST_KIND_) | ||
real(HI_TEST_KIND_), parameter :: SMALL = 1.0e-10_lkind | ||
!! for bicubic set up | ||
real(HI_TEST_KIND_), allocatable :: lon_src_1d(:), lat_src_1d(:) | ||
real(HI_TEST_KIND_), allocatable :: lon_dst_1d(:), lat_dst_1d(:) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should have doxygen documentation instead of just a comment above |
||
|
||
|
||
! set up longitude and latitude of source/destination grid. | ||
dlon_src = (lon_src_end-lon_src_beg)/real(ni_src, lkind) | ||
|
@@ -1062,6 +1071,15 @@ subroutine test_assignment() | |
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_del(Interp_new2) | ||
call horiz_interp_del(Interp_cp) | ||
! test deletion after direct calls | ||
call horiz_interp_conserve_new(Interp_new1, lon_in_1d, lat_in_1d, lon_out_1d, lat_out_1d) | ||
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_conserve_new(Interp_new1, lon_in_1d, lat_in_1d, lon_out_2d, lat_out_2d) | ||
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_conserve_new(Interp_new1, lon_in_2d, lat_in_2d, lon_out_1d, lat_out_1d) | ||
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_conserve_new(Interp_new1, lon_in_2d, lat_in_2d, lon_out_2d, lat_out_2d) | ||
call horiz_interp_del(Interp_new1) | ||
|
||
! bicubic only works with 1d src | ||
! 1dx1d | ||
|
@@ -1084,6 +1102,28 @@ subroutine test_assignment() | |
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_del(Interp_new2) | ||
call horiz_interp_del(Interp_cp) | ||
! test deletion after direct calls | ||
! this set up is usually done within horiz_interp_new | ||
nlon_in = size(lon_in_1d(:))-1; nlat_in = size(lat_in_1d(:))-1 | ||
nlon_out = size(lon_out_1d(:))-1; nlat_out = size(lat_out_1d(:))-1 | ||
allocate(lon_src_1d(nlon_in), lat_src_1d(nlat_in)) | ||
allocate(lon_dst_1d(nlon_out), lat_dst_1d(nlat_out)) | ||
do i = 1, nlon_in | ||
lon_src_1d(i) = (lon_in_1d(i) + lon_in_1d(i+1)) * 0.5_lkind | ||
enddo | ||
do j = 1, nlat_in | ||
lat_src_1d(j) = (lat_in_1d(j) + lat_in_1d(j+1)) * 0.5_lkind | ||
enddo | ||
do i = 1, nlon_out | ||
lon_dst_1d(i) = (lon_out_1d(i) + lon_out_1d(i+1)) * 0.5_lkind | ||
enddo | ||
do j = 1, nlat_out | ||
lat_dst_1d(j) = (lat_out_1d(j) + lat_out_1d(j+1)) * 0.5_lkind | ||
enddo | ||
call horiz_interp_bicubic_new(Interp_new1, lon_src_1d, lat_src_1d, lon_out_2d, lat_out_2d) | ||
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_bicubic_new(Interp_new1, lon_src_1d, lat_src_1d, lon_dst_1d, lat_dst_1d) | ||
call horiz_interp_del(Interp_new1) | ||
|
||
deallocate(lon_out_2D, lat_out_2D, lon_in_2D, lat_in_2D) | ||
allocate(lon_out_2D(ni_dst, nj_dst), lat_out_2D(ni_dst, nj_dst)) | ||
|
@@ -1117,11 +1157,14 @@ subroutine test_assignment() | |
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_del(Interp_new2) | ||
call horiz_interp_del(Interp_cp) | ||
! check deletion after direct calls | ||
call horiz_interp_spherical_new(Interp_new1, lon_in_2d, lat_in_2d, lon_out_2d, lat_out_2d) | ||
call horiz_interp_del(Interp_new1) | ||
|
||
! bilinear | ||
! 1dx1d | ||
call horiz_interp_new(Interp_new1, lon_in_1D, lat_in_1D, lon_in_1D, lat_in_1D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new2, lon_in_1D, lat_in_1D, lon_in_1D, lat_in_1D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new1, lon_in_1D, lat_in_1D, lon_out_1D, lat_out_1D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new2, lon_in_1D, lat_in_1D, lon_out_1D, lat_out_1D, interp_method="bilinear") | ||
Interp_cp = Interp_new1 | ||
call mpp_error(NOTE,"testing horiz_interp_type assignment 1x1d bilinear") | ||
call check_type_eq(Interp_cp, Interp_new2) | ||
|
@@ -1130,8 +1173,8 @@ subroutine test_assignment() | |
call horiz_interp_del(Interp_new2) | ||
call horiz_interp_del(Interp_cp) | ||
! 1dx2d | ||
call horiz_interp_new(Interp_new1, lon_in_1D, lat_in_1D, lon_in_2D, lat_in_2D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new2, lon_in_1D, lat_in_1D, lon_in_2D, lat_in_2D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new1, lon_in_1D, lat_in_1D, lon_out_2D, lat_out_2D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new2, lon_in_1D, lat_in_1D, lon_out_2D, lat_out_2D, interp_method="bilinear") | ||
Interp_cp = Interp_new1 | ||
call mpp_error(NOTE,"testing horiz_interp_type assignment 1x2d bilinear") | ||
call check_type_eq(Interp_cp, Interp_new2) | ||
|
@@ -1160,15 +1203,20 @@ subroutine test_assignment() | |
call horiz_interp_del(Interp_new2) | ||
call horiz_interp_del(Interp_cp) | ||
! 2dx2d | ||
call horiz_interp_new(Interp_new1, lon_in_2D, lat_in_2D, lon_in_2D, lat_in_2D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new2, lon_in_2D, lat_in_2D, lon_in_2D, lat_in_2D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new1, lon_in_2D, lat_in_2D, lon_out_2D, lat_out_2D, interp_method="bilinear") | ||
call horiz_interp_new(Interp_new2, lon_in_2D, lat_in_2D, lon_out_2D, lat_out_2D, interp_method="bilinear") | ||
Interp_cp = Interp_new1 | ||
call mpp_error(NOTE,"testing horiz_interp_type assignment 1x2d bilinear") | ||
call check_type_eq(Interp_cp, Interp_new2) | ||
call check_type_eq(Interp_cp, Interp_new1) | ||
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_del(Interp_new2) | ||
call horiz_interp_del(Interp_cp) | ||
! check deletion after direct calls | ||
call horiz_interp_bilinear_new(Interp_new1, lon_in_1d, lat_in_1d, lon_out_2d, lat_out_2d) | ||
call horiz_interp_del(Interp_new1) | ||
call horiz_interp_bilinear_new(Interp_new1, lon_in_2d, lat_in_2d, lon_out_2d, lat_out_2d) | ||
call horiz_interp_del(Interp_new1) | ||
|
||
end subroutine | ||
!> helps assignment test with derived type comparisons | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we do not include the trailing
L
other than to limit the variable name to 8 characters?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No as far as I can tell that's the only reason it's cut off. I checked if there was anything else used in FMS named
spherical
but there's not.Should we update it to add the L?