Last active
December 9, 2020 17:50
-
-
Save MiCurry/a237abff4ec5596ec4c754e38e0f4a99 to your computer and use it in GitHub Desktop.
Supersample
This file contains hidden or 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
program supersample_fac | |
implicit none | |
integer :: i, j, ii, jj | |
integer :: supersample | |
integer :: tile_nx, tile_ny | |
integer :: tile_bdr | |
real :: lat, lon, latp, lonp | |
real :: known_lat | |
real :: dx | |
tile_nx = 1200 | |
tile_ny = 1200 | |
supersample = 3 | |
tile_bdr = 3 | |
do j = supersample * tile_bdr + 1, supersample * (tile_ny + tile_bdr), 1 | |
do i = supersample * tile_bdr + 1, supersample * (tile_nx + tile_bdr), 1 | |
ii = (i - 1) / supersample + 1 | |
jj = (j - 1) / supersample + 1 | |
call tile_to_latlon(j, i, lat, lon, 3) | |
call tile_to_latlon(jj, ii, latp, lonp, 1) | |
if (lat /= latp .or. lon /= lonp) then | |
write(0,*) 'Not equal!' | |
write(0,*) 'First: ', i, j, lat, lon | |
write(0,*) 'Second: ', ii, jj, latp, lonp | |
stop | |
endif | |
enddo | |
enddo | |
contains | |
subroutine tile_to_latlon(j, i, lat, lon, supersample) | |
implicit none | |
integer, intent(in) :: j, i | |
real, intent(out) :: lat, lon | |
integer, intent(in) :: supersample | |
integer :: tile_x, tile_y ! Start of tile | |
real :: known_lat, known_lon | |
real :: dx, dy | |
tile_x = 1 | |
tile_y = 1201 | |
known_lat = 89.975 | |
known_lon = -179.975 | |
dx = 0.05 | |
dy = 0.05 | |
lon = known_lon + real(i - (supersample * tile_bdr + 1) + (supersample * (tile_x - 1))) * dx / supersample | |
lat = known_lat + real(j - (supersample * tile_bdr + 1) + (supersample * (tile_y - 1))) * dy / supersample | |
end subroutine tile_to_latlon | |
end program supersample_fac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment