Skip to content
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_location followed by get_location does not necessarily return the same value #621

Open
hkershaw-brown opened this issue Jan 12, 2024 · 0 comments

Comments

@hkershaw-brown
Copy link
Member

This was a Jira issue DART-12

see example program below:

program bitwise_creep

use types_mod,    only : r8
use location_mod, only : location_type, VERTISLEVEL, set_location, get_location
use utilities_mod, only : initialize_utilities

implicit none

real(r8) :: lon, lat, lev
real(r8) :: lon_lat_lev(3)
type(location_type) :: location
integer :: i


call initialize_utilities()

lon = -91.868560791015625_r8
lat =  16.901844024658203_r8
lev = 1.0_r8


! dart expects longitude [0,360]
do while (lon <   0.0_r8)
   lon = lon + 360.0_r8
end do
do while (lon > 360.0_r8)
   lon = lon - 360.0_r8
end do

do i = 1, 10
print*, 'lon, lat', lon, lat

location = set_location(lon, lat, lev, VERTISLEVEL)
lon_lat_lev = get_location(location)

print*, 'lon, lat', lon_lat_lev(1), lon_lat_lev(2)
enddo

end program bitwise_creep
hkershaw@cisl-fisher work (main) $ ./bitwise-creep 

 --------------------------------------
 Starting ... at YYYY MM DD HH MM SS = 
                 2024  1 12 10  9  1
 --------------------------------------

  set_nml_output Echo NML values to log file only
 lon, lat   268.13143920898438        16.901844024658203     
  location_mod: using code with optimized cutoffs
  location_mod: Including vertical separation when computing distances:
  location_mod:        # pascals ~ 1 horiz radian:     6666666.70000
  location_mod:         # meters ~ 1 horiz radian:     5000000.00000
  location_mod:   # model levels ~ 1 horiz radian:        2666.70000
  location_mod:  # scale heights ~ 1 horiz radian:          10.00000
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
 lon, lat   268.13143920898438        16.901844024658203     
 lon, lat   268.13143920898443        16.901844024658203     
hkershaw-brown added a commit that referenced this issue Jan 12, 2024
bitwise with original code
see #621 for difference between set_veritical and set_location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant