module test_gdland use fruit use windspeed_model, only : gdland_table implicit none integer :: ioper =1 common /oper/ ioper contains subroutine test_gdland_lonwrap ! Couple of predetermined distances to sanity check function ! Call same location in -180:180 and 0:360 to check unwrapping the lons INTEGER :: n, i PARAMETER (n = 4) REAL :: return_val, reldiff REAL, DIMENSION(n) :: input_lats, input_lons, expect_vals input_lats = (/ 0., 25.7, 25.7, 17.63/) input_lons = (/ 0., -80.1, 279.9, -61.77/) expect_vals = (/ 574.1, 15.5, 15.5, 0.82 /) do i=1, n call gdland_table( input_lons(i), input_lats(i), return_val) reldiff = abs((expect_vals(i) - return_val)) / expect_vals(i) ! write(6,*) 'test_gdland_lonwrap' ! write(6,*) 'Expects | Got' ! write(6,*) expect_vals(i), '|', return_val ! write(6,*) reldiff, '% difference' call assert_true(reldiff .le. 0.01) end do end subroutine test_gdland_lonwrap subroutine test_gdlandtable_at_dateline ! This tests that there is a break at the dateline in the gdland_table ! file. A previous version of the file had breakpoints at basin boundaries INTEGER :: n PARAMETER (n = 2) REAL :: east_returnval, west_returnval, difference REAL, DIMENSION(n) :: input_lats, input_lons input_lats = (/ 21, 21/) input_lons = (/ 179.9, -179.9/) call gdland_table( input_lons(1), input_lats(1), east_returnval) call gdland_table( input_lons(2), input_lats(2), west_returnval) difference = abs(east_returnval - west_returnval) ! write(6,*) 'test_gdlandtable_at_dateline' ! write(6,*) difference, '< 25' call assert_true(difference .le. 25) call assert_true(difference .ne. 0) end subroutine test_gdlandtable_at_dateline subroutine test_guam_existence ! Simple check to test the existence of guam island in the table. ! Specified location is just west of the island REAL :: dist_to_guam REAL :: input_lat, input_lon input_lat = 13.4443 input_lon = 144.5 call gdland_table( input_lon, input_lat, dist_to_guam) ! write(6,*) 'test_guam_existence' ! write(6,*) 'Guam is ',dist_to_guam, ' away' call assert_true(dist_to_guam .le. 25) call assert_true(dist_to_guam .gt. 0) end subroutine test_guam_existence subroutine test_local_lon_changed ! Check that input lon value isn't changed by function REAL :: dist_to_land REAL :: input_lat, input_lon input_lat = 13.4443 input_lon = -176.5 call gdland_table( input_lon, input_lat, dist_to_land) ! write(6,*) 'test_local_lon_changed' ! write(6,*) 'input_lon is ',input_lon ! write(6,*) 'dist_to_land is ',dist_to_land call assert_true(abs(input_lon - (-176.5)) .le. 1.e-5) call assert_true(dist_to_land .le. 2000) end subroutine test_local_lon_changed end module