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

axis_utils unit tests #1

Open
wants to merge 32 commits into
base: axis_utils2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c89ba7
Unit tests for axis_utils
Feb 16, 2023
4c12ec1
Axis utils tests: More descriptive messages
Feb 16, 2023
29c187d
Various improvements to axis_utils tests
Feb 21, 2023
267c7cd
Implement `get_axis_cart` unit test
Feb 23, 2023
b55faec
Use explicit kind for all real constants
Feb 27, 2023
8b6259c
Merge `string` branch
Mar 7, 2023
56b7954
Remove `PRETTY()` macro
Mar 7, 2023
2dc3ed2
Make `C(x)` macro work on all compilers
Mar 7, 2023
ce93ff5
Revise comments
Mar 7, 2023
ba095ea
Break lines longer than 110 characters
Mar 7, 2023
0a24637
Trailing underscore at end of macro name
Mar 8, 2023
682924f
Comment to explain macro overload for kind strings
Mar 8, 2023
17a5359
Update mixedmode to main (#1143)
mlee03 Mar 8, 2023
9cfefee
Replace `C(x)` macro with global `k` parameter
Mar 9, 2023
42c2d1c
Merge updated `fms_string_utils_mod` from main
Mar 10, 2023
24760ee
update the mixedmode branch to main (#1153)
mlee03 Mar 15, 2023
4e1434f
Use `k` parameter more extensively
Mar 20, 2023
31deacf
Merge branch 'mixedmode' into axis_utils2
Mar 22, 2023
d39f88b
`CALC_FRAC_INDEX` -> `CALC_FRAC_INDEX_`
Mar 23, 2023
26430c0
Fix merge issue
Mar 23, 2023
9ab2164
Additional `lon_in_range` tests
Mar 23, 2023
f404ee9
Comment out the tests that fail
Mar 23, 2023
326f580
Edit comments for tests that fail
Mar 23, 2023
c5af210
Fix `CMakeLists.txt`
Mar 29, 2023
8376481
update mixedmode to main (#1171)
mlee03 Mar 29, 2023
2edc3dc
feat: mixed precision axis_utils2 (#1104)
mcallic2 Mar 29, 2023
6b3855a
feat: mixed precision fms_mod (#1147)
J-Lentz Mar 29, 2023
cdabf07
feat: horiz interp mixed precision (#1067)
rem1776 Mar 29, 2023
7b3906c
mixed precision sat_vapor_pressure (#1095)
mlee03 Mar 29, 2023
9a3a673
Merge mixedmode branch
Mar 29, 2023
08330a4
Update `CMakeLists.txt` from `mixedmode`
Mar 29, 2023
b970f35
Merge 'mixedmode' branch
Mar 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ list(APPEND fms_fortran_src_files
diag_manager/diag_output.F90
diag_manager/diag_table.F90
diag_manager/diag_util.F90
diag_manager/fms_diag_time_reduction.F90
diag_manager/fms_diag_outfield.F90
diag_manager/fms_diag_elem_weight_procs.F90
diag_manager/fms_diag_fieldbuff_update.F90
diag_manager/fms_diag_bbox.F90
drifters/cloud_interpolator.F90
drifters/drifters.F90
drifters/drifters_comm.F90
Expand Down Expand Up @@ -288,12 +293,16 @@ foreach(kind ${kinds})

target_include_directories(${libTgt}_f PRIVATE include
fms
fms/include
fms2_io/include
string_utils/include
mpp/include
sat_vapor_pres/include
horiz_interp/include
diag_manager/include
constants4
constants
axis_utils/include)

target_compile_definitions(${libTgt}_f PRIVATE "${fms_defs}")
target_compile_definitions(${libTgt}_f PRIVATE "${${kind}_defs}")

Expand Down Expand Up @@ -327,9 +336,13 @@ foreach(kind ${kinds})
target_include_directories(${libTgt} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fms>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fms/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fms2_io/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/sat_vapor_pres/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/horiz_interp/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/string_utils/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mpp/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/axis_utils/include>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/diag_manager/include>)

target_include_directories(${libTgt} INTERFACE
$<BUILD_INTERFACE:${moduleDir}>
Expand Down
12 changes: 6 additions & 6 deletions amip_interp/include/amip_interp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ end interface
type amip_interp_type
private
type (horiz_interp_type) :: Hintrp, Hintrp2 ! add by JHC
real, pointer :: data1(:,:) =>NULL(), &
data2(:,:) =>NULL()
real, allocatable :: data1(:,:), data2(:,:)
type (date_type) :: Date1, Date2
logical :: use_climo, use_annual
logical :: I_am_initialized=.false.
Expand Down Expand Up @@ -1003,8 +1002,8 @@ endif
!! when calling get_amip_sst and get_amip_ice.
subroutine amip_interp_del (Interp)
type (amip_interp_type), intent(inout) :: Interp
if(associated(Interp%data1)) deallocate(Interp%data1)
if(associated(Interp%data2)) deallocate(Interp%data2)
if(allocated(Interp%data1)) deallocate(Interp%data1)
if(allocated(Interp%data2)) deallocate(Interp%data2)
if(allocated(lon_bnd)) deallocate(lon_bnd)
if(allocated(lat_bnd)) deallocate(lat_bnd)
call horiz_interp_del ( Interp%Hintrp )
Expand Down Expand Up @@ -1536,8 +1535,9 @@ subroutine amip_interp_type_eq(amip_interp_out, amip_interp_in)
endif

amip_interp_out%Hintrp = amip_interp_in%Hintrp
amip_interp_out%data1 => amip_interp_in%data1
amip_interp_out%data2 => amip_interp_in%data2
amip_interp_out%Hintrp2 = amip_interp_in%Hintrp2 !< missing assignment statement; added by GPP
amip_interp_out%data1 = amip_interp_in%data1
amip_interp_out%data2 = amip_interp_in%data2
amip_interp_out%Date1 = amip_interp_in%Date1
amip_interp_out%Date2 = amip_interp_in%Date2
amip_interp_out%Date1 = amip_interp_in%Date1
Expand Down
2 changes: 1 addition & 1 deletion axis_utils/axis_utils2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module axis_utils2_mod
private

integer, parameter :: maxatts = 100
real(r8_kind), parameter :: epsln = real(1.d-10, kind=r8_kind)
real(r8_kind), parameter :: epsln = 1.e-10_r8_kind
real(r8_kind), parameter :: fp5 = 0.5_r8_kind, f360 = 360.0_r8_kind

!> @}
Expand Down
58 changes: 12 additions & 46 deletions axis_utils/include/axis_utils2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
edge_data(i) = r_var(i-1) + 0.5_lkind*(r_var(i) - r_var(i-1))
enddo
edge_data(1) = r_var(1) - 0.5_lkind*(r_var(2) - r_var(1))
if (abs(edge_data(1)) .lt. real(1.d-10, FMS_AU_KIND_)) then
if (abs(edge_data(1)) .lt. 1.e-10_lkind) then
edge_data(1) = 0.0_lkind
endif
edge_data(n+1) = r_var(n) + 0.5_lkind*(r_var(n) - r_var(n-1))
Expand All @@ -143,12 +143,12 @@
LON_IN_RANGE_ = lon
l_end = l_strt + 360.0_lkind

if (abs(LON_IN_RANGE_ - l_strt) < real(1.d-4, FMS_AU_KIND_)) then
if (abs(LON_IN_RANGE_ - l_strt) < 1.e-4_lkind) then
LON_IN_RANGE_ = l_strt
return
endif

if (abs(LON_IN_RANGE_ - l_end) < real(1.d-4, FMS_AU_KIND_)) then
if (abs(LON_IN_RANGE_ - l_end) < 1.e-4_lkind) then
LON_IN_RANGE_ = l_strt
return
endif
Expand Down Expand Up @@ -223,41 +223,6 @@
return
end subroutine TRANLON_

!> nearest_index = index of nearest data point within "array" corresponding to
!! "value".
!!
!! inputs:
!!
!! value = arbitrary data...same units as elements in "array"
!! array = array of data points (must be monotonically increasing)
!!
!! output:
!!
!! nearest_index = index of nearest data point to "value"
!! if "value" is outside the domain of "array" then nearest_index = 1
!! or "ia" depending on whether array(1) or array(ia) is
!! closest to "value"
!!
!! note: if "array" is dimensioned array(0:ia) in the calling
!! program, then the returned index should be reduced
!! by one to account for the zero base.
!!
!! example:
!!
!! let model depths be defined by the following:
!! parameter (km=5)
!! dimension z(km)
!! data z /5.0, 10.0, 50.0, 100.0, 250.0/
!!
!! k1 = nearest_index (12.5, z, km)
!! k2 = nearest_index (0.0, z, km)
!!
!! k1 would be set to 2, and k2 would be set to 1 so that
!! z(k1) would be the nearest data point to 12.5 and z(k2) would
!! be the nearest data point to 0.0
!!
!! @return real frac_index


function FRAC_INDEX_(value, array)

Expand Down Expand Up @@ -293,8 +258,7 @@
do while (i <= ia .and. keep_going)
i = i+1
if (value <= array(i)) then
FRAC_INDEX_ = real((i-1), FMS_AU_KIND_) + (real(value-array(i-1), FMS_AU_KIND_)) &
/(real(array(i), FMS_AU_KIND_)-real(array(i-1), FMS_AU_KIND_))
FRAC_INDEX_ = real((i-1), lkind) + (value-array(i-1)) / (array(i) - array(i-1))
keep_going = .false.
endif
enddo
Expand Down Expand Up @@ -455,7 +419,7 @@
if (grid1(1) > grid2(1) ) call mpp_error(FATAL, 'grid2 lies outside grid1')
if (grid1(n) < grid2(m) ) call mpp_error(FATAL, 'grid2 lies outside grid1')

if (yp1>real(0.99d30, FMS_AU_KIND_)) then
if (yp1>0.99e30_lkind) then
y2(1) = 0.0_lkind
u(1) = 0.0_lkind
else
Expand All @@ -471,7 +435,7 @@ if (yp1>real(0.99d30, FMS_AU_KIND_)) then
/(grid1(i)-grid1(i-1)))/(grid1(i+1)-grid1(i-1))-sig*u(i-1))/p
enddo

if (ypn>real(.99d30, FMS_AU_KIND_)) then
if (ypn>0.99e30_lkind) then
qn = 0.0_lkind
un = 0.0_lkind
else
Expand Down Expand Up @@ -520,15 +484,16 @@ if (yp1>real(0.99d30, FMS_AU_KIND_)) then
real(kind=FMS_AU_KIND_) :: y1, y2
character(len=32) :: interp_method
integer :: k2, ks, ke
integer, parameter :: lkind = FMS_AU_KIND_

k2 = size(grid2(:))

interp_method = "linear"
if(present(method)) interp_method = method
y1 = real(1.0d30, FMS_AU_KIND_)
y1 = 1.0e30_lkind

if(present(yp1)) y1 = yp1
y2 = real(1.0d30, FMS_AU_KIND_)
y2 = 1.0e30_lkind

if(present(yp2)) y2 = yp2
call find_index(grid1, grid2(1), grid2(k2), ks, ke)
Expand Down Expand Up @@ -583,6 +548,7 @@ if (yp1>real(0.99d30, FMS_AU_KIND_)) then
real(kind=FMS_AU_KIND_) :: y1, y2
character(len=32) :: interp_method
integer :: ks, ke
integer, parameter :: lkind = FMS_AU_KIND_

n1 = size(grid1,1)
n2 = size(grid2,1)
Expand All @@ -592,10 +558,10 @@ if (yp1>real(0.99d30, FMS_AU_KIND_)) then

interp_method = "linear"
if(present(method)) interp_method = method
y1 = real(1.0d30, FMS_AU_KIND_)
y1 = 1.0e30_lkind

if(present(yp1)) y1 = yp1
y2 = real(1.0d30, FMS_AU_KIND_)
y2 = 1.0e30_lkind
if(present(yp2)) y2 = yp2

if (n1 /= n2 .or. m1 /= m2) call mpp_error(FATAL,'grid size mismatch')
Expand Down
38 changes: 32 additions & 6 deletions diag_manager/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Ed Hartnett 2/22/19

# Include .h and .mod files.
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/diag_manager/include -I$(top_srcdir)/diag_manager
AM_FCFLAGS = $(FC_MODINC). $(FC_MODOUT)$(MODDIR)

# Build these uninstalled convenience libraries.
Expand All @@ -37,15 +37,33 @@ libdiag_manager_la_SOURCES = \
diag_manager.F90 \
diag_output.F90 \
diag_table.F90 \
diag_util.F90
diag_util.F90 \
fms_diag_time_reduction.F90 \
fms_diag_outfield.F90 \
fms_diag_elem_weight_procs.F90 \
fms_diag_fieldbuff_update.F90 \
fms_diag_bbox.F90 \
include/fms_diag_fieldbuff_update.inc \
include/fms_diag_fieldbuff_update.fh

# Some mods are dependant on other mods in this dir.
diag_data_mod.$(FC_MODEXT): fms_diag_bbox_mod.$(FC_MODEXT)
diag_axis_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
diag_output_mod.$(FC_MODEXT): diag_axis_mod.$(FC_MODEXT) diag_data_mod.$(FC_MODEXT)
diag_util_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) diag_output_mod.$(FC_MODEXT) diag_grid_mod.$(FC_MODEXT)
diag_util_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) diag_output_mod.$(FC_MODEXT) \
diag_grid_mod.$(FC_MODEXT) fms_diag_bbox_mod.$(FC_MODEXT)
diag_table_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT)
fms_diag_axis_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT)
fms_diag_time_reduction_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
fms_diag_elem_weight_procs_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
fms_diag_outfield_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_elem_weight_procs_mod.$(FC_MODEXT)
fms_diag_fieldbuff_update_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_elem_weight_procs_mod.$(FC_MODEXT) fms_diag_bbox_mod.$(FC_MODEXT)
diag_manager_mod.$(FC_MODEXT): diag_axis_mod.$(FC_MODEXT) diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT) \
diag_output_mod.$(FC_MODEXT) diag_grid_mod.$(FC_MODEXT) diag_table_mod.$(FC_MODEXT)
diag_output_mod.$(FC_MODEXT) diag_grid_mod.$(FC_MODEXT) diag_table_mod.$(FC_MODEXT) \
fms_diag_time_reduction_mod.$(FC_MODEXT) fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT)


# Mod files are built and then installed as headers.
MODFILES = \
Expand All @@ -55,8 +73,16 @@ MODFILES = \
diag_output_mod.$(FC_MODEXT) \
diag_util_mod.$(FC_MODEXT) \
diag_table_mod.$(FC_MODEXT) \
diag_manager_mod.$(FC_MODEXT)
nodist_include_HEADERS = $(MODFILES)
fms_diag_time_reduction_mod.$(FC_MODEXT) \
fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_bbox_mod.$(FC_MODEXT) \
fms_diag_elem_weight_procs_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT) \
diag_manager_mod.$(FC_MODEXT) \
include/fms_diag_fieldbuff_update.inc \
include/fms_diag_fieldbuff_update.fh

nodist_include_HEADERS = $(MODFILES)
BUILT_SOURCES = $(MODFILES)

include $(top_srcdir)/mkmods.mk
9 changes: 8 additions & 1 deletion diag_manager/diag_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ MODULE diag_data_mod
USE time_manager_mod, ONLY: time_type
USE mpp_domains_mod, ONLY: domain1d, domain2d, domainUG
USE fms_mod, ONLY: WARNING, write_version_number
USE fms_diag_bbox_mod, ONLY: fmsDiagIbounds_type

#ifdef use_netCDF
! NF90_FILL_REAL has value of 9.9692099683868690e+36.
USE netcdf, ONLY: NF_FILL_REAL => NF90_FILL_REAL
Expand Down Expand Up @@ -115,6 +117,8 @@ MODULE diag_data_mod
INTEGER, allocatable, DIMENSION(:) :: iatt !< INTEGER array to hold value of INTEGER attributes
END TYPE diag_atttype

!!TODO: coord_type deserves a better name, like coord_interval_type or coord_bbox_type.
!! additionally, consider using a 2D array.
!> @brief Define the region for field output
!> @ingroup diag_data_mod
TYPE coord_type
Expand Down Expand Up @@ -240,7 +244,7 @@ MODULE diag_data_mod
TYPE(diag_grid) :: output_grid
LOGICAL :: local_output, need_compute, phys_window, written_once
LOGICAL :: reduced_k_range
INTEGER :: imin, imax, jmin, jmax, kmin, kmax
TYPE(fmsDiagIbounds_type) :: buff_bounds
TYPE(time_type) :: Time_of_prev_field_data
TYPE(diag_atttype), allocatable, dimension(:) :: attributes
INTEGER :: num_attributes
Expand Down Expand Up @@ -327,6 +331,7 @@ MODULE diag_data_mod
!! <TT>.TRUE.</TT> is only supported if the diag_manager_init
!! routine is called with the optional time_init parameter.
LOGICAL :: use_mpp_io = .false. !< false is fms2_io (default); true is mpp_io
LOGICAL :: use_refactored_send = .false. !< Namelist flag to use refactored send_data math funcitons.

! <!-- netCDF variable -->

Expand Down Expand Up @@ -384,6 +389,8 @@ SUBROUTINE diag_data_init()
call write_version_number("DIAG_DATA_MOD", version)
END SUBROUTINE diag_data_init



END MODULE diag_data_mod
!> @}
! close documentation grouping
Loading