Skip to content

Commit

Permalink
Merge pull request #1 from underwoo/unit_tests
Browse files Browse the repository at this point in the history
Fixes to allow tests to passed on Travis CI
  • Loading branch information
uramirez8707 authored Sep 18, 2019
2 parents a8be1e1 + 4b102f9 commit 428b0e5
Show file tree
Hide file tree
Showing 59 changed files with 565 additions and 255 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Makefile.in
/mdate-sh
/py-compile
/test-driver
/tap-driver.sh
/ylwrap
*.log
*.trs
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- pkg-config gfortran netcdf-bin libnetcdf-dev libnetcdff-dev openmpi-bin libopenmpi-dev
- pkg-config gfortran netcdf-bin libnetcdf-dev libnetcdff-dev openmpi-bin libopenmpi-dev

env:
- CPPFLAGS_ADD='' FCFLAGS_REAL_KIND='-fdefault-real-8 -fdefault-double-8'
Expand All @@ -31,9 +31,9 @@ before_script:
- export CPPFLAGS="-I/usr/include -Duse_LARGEFILE -DMAXFIELDMETHODS_=500 ${CPPFLAGS_ADD}"
- export FCFLAGS="-fcray-pointer -Waliasing -ffree-line-length-none -fno-range-check ${FCFLAGS_REAL_KIND}"
- export LDFLAGS='-L/usr/lib'
- export LOG_DRIVER_FLAGS="--comments"

script:
- autoreconf -i
- ./configure
- make -j distcheck

4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ test_fms/monin_obukhov test_fms/drifters test_fms/mosaic \
test_fms/interpolator test_fms/fms \
test_fms/mpp test_fms/mpp_io test_fms/time_interp test_fms/time_manager \
test_fms/horiz_interp \
test_fms/field_manager test_fms/fft test_fms/axis_utils
test_fms/field_manager test_fms/fft test_fms/axis_utils

EXTRA_DIST = README.md

CLEANFILES = *__genmod.mod *__genmod.f90
CLEANFILES = *__genmod.mod *__genmod.f90
21 changes: 11 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
AC_REQUIRE_AUX_FILE([tap-driver.sh])

# Keep libtool macros in an m4 directory.
AC_CONFIG_MACRO_DIR([m4])
Expand Down Expand Up @@ -106,18 +107,18 @@ AC_CONFIG_FILES([Makefile
test_fms/diag_manager/Makefile
test_fms/data_override/Makefile
test_fms/exchange/Makefile
test_fms/monin_obukhov/Makefile
test_fms/drifters/Makefile
test_fms/interpolator/Makefile
test_fms/fms/Makefile
test_fms/monin_obukhov/Makefile
test_fms/drifters/Makefile
test_fms/interpolator/Makefile
test_fms/fms/Makefile
test_fms/mpp/Makefile
test_fms/mpp_io/Makefile
test_fms/time_interp/Makefile
test_fms/time_manager/Makefile
test_fms/horiz_interp/Makefile
test_fms/field_manager/Makefile
test_fms/fft/Makefile
test_fms/time_interp/Makefile
test_fms/time_manager/Makefile
test_fms/horiz_interp/Makefile
test_fms/field_manager/Makefile
test_fms/fft/Makefile
test_fms/axis_utils/Makefile
test_fms/mosaic/Makefile
test_fms/mosaic/Makefile
])
AC_OUTPUT()
9 changes: 6 additions & 3 deletions test_fms/axis_utils/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# This is an automake file for the test_fms/data_override directory of the FMS
# package.

LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh

# Find the fms_mod.mod file.
test_axis_utils_CPPFLAGS = -I${top_srcdir}/axis_utils
test_axis_utils_CPPFLAGS += -I${top_srcdir}/fms
test_axis_utils_CPPFLAGS += -I${top_srcdir}/mpp
test_axis_utils_CPPFLAGS = -I${top_builddir}/axis_utils
test_axis_utils_CPPFLAGS += -I${top_builddir}/fms
test_axis_utils_CPPFLAGS += -I${top_builddir}/mpp

# Copy over other needed files to the srcdir
EXTRA_DIST = test_axis_utils.sh
Expand Down
7 changes: 6 additions & 1 deletion test_fms/axis_utils/test_axis_utils.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
teardown () {
# Echo the output. Will only be done on a test failure.
echo "$output"
}

@test "1" {
run mpirun -n 6 ./test_axis_utils
run mpirun -n 2 ./test_axis_utils
[ "$status" -eq 0 ]
}
15 changes: 9 additions & 6 deletions test_fms/data_override/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# This is an automake file for the test_fms/data_override directory of the FMS
# package.

LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh

# Find the fms_mod.mod file.
test_data_override_CPPFLAGS = -I${top_srcdir}/include
test_data_override_CPPFLAGS += -I${top_srcdir}/mpp
test_data_override_CPPFLAGS += -I${top_srcdir}/fms
test_data_override_CPPFLAGS += -I${top_srcdir}/constants
test_data_override_CPPFLAGS += -I${top_srcdir}/time_manager
test_data_override_CPPFLAGS += -I${top_srcdir}/diag_manager
test_data_override_CPPFLAGS += -I${top_srcdir}/data_override
test_data_override_CPPFLAGS += -I${top_builddir}/mpp
test_data_override_CPPFLAGS += -I${top_builddir}/fms
test_data_override_CPPFLAGS += -I${top_builddir}/constants
test_data_override_CPPFLAGS += -I${top_builddir}/time_manager
test_data_override_CPPFLAGS += -I${top_builddir}/diag_manager
test_data_override_CPPFLAGS += -I${top_builddir}/data_override

# Copy over other needed files to the srcdir
EXTRA_DIST = test_data_override.sh
Expand Down
14 changes: 9 additions & 5 deletions test_fms/data_override/test_data_override.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ setup() {
sed "s/<test_num>/${tnum}/" $srcdir/test_fms/data_override/input.nml_base > input.nml
}

teardown () {
# Echo the output. Will only be done on a test failure.
echo "$output"
}

@test "Test 1: Cubic-Grid" {
skip "The input file is missing"
skip "The input file is missing"
cp -r $srcdir/test_fms/data_override/INPUT $builddir/test_fms/data_override/INPUT
run mpirun -n 6 ./test_data_override
run mpirun -n 2 ./test_data_override
[ "$status" -eq 0 ]
}

@test "Test 2: Latlon-Grid" {
skip "The input file is missing"
run mpirun -n 6 ./test_data_override
run mpirun -n 2 ./test_data_override
[ "$status" -eq 0 ]
chmod 755 $builddir/test_fms/data_override/INPUT
chmod 755 $builddir/test_fms/data_override/INPUT
rm -rf $builddir/test_fms/data_override/INPUT
}

13 changes: 8 additions & 5 deletions test_fms/diag_manager/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This is an automake file for the test_fms/diag_manager directory of the FMS
# package.

LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh

# Build this test program.
check_PROGRAMS = test_diag_manager

Expand All @@ -10,11 +13,11 @@ test_diag_manager_LDADD = ${top_builddir}/libFMS/libFMS.la

# Find the fms_mod.mod file.
test_diag_manager_CPPFLAGS = -I${top_srcdir}/include
test_diag_manager_CPPFLAGS += -I${top_srcdir}/mpp
test_diag_manager_CPPFLAGS += -I${top_srcdir}/fms
test_diag_manager_CPPFLAGS += -I${top_srcdir}/diag_manager
test_diag_manager_CPPFLAGS += -I${top_srcdir}/time_manager
test_diag_manager_CPPFLAGS += -I${top_srcdir}/constants
test_diag_manager_CPPFLAGS += -I${top_builddir}/mpp
test_diag_manager_CPPFLAGS += -I${top_builddir}/fms
test_diag_manager_CPPFLAGS += -I${top_builddir}/diag_manager
test_diag_manager_CPPFLAGS += -I${top_builddir}/time_manager
test_diag_manager_CPPFLAGS += -I${top_builddir}/constants

# Copy over other needed files to the srcdir
EXTRA_DIST = test_diag_manager.sh
Expand Down
8 changes: 6 additions & 2 deletions test_fms/diag_manager/test_diag_manager.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ setup() {
ln -s $srcdir/test_fms/diag_manager/diagTables/diag_table_${tnum} diag_table
}

teardown () {
# Echo the output. Will only be done on a test failure.
echo "$output"
}

@test "Test 1: Data array is too large in x and y direction" {
run mpirun -n 1 ./test_diag_manager
run mpirun -n 1 ./test_diag_manager
[ "$status" -eq 0 ]
[[ "$output" =~ "test1.1 successful:" ]]
[[ "$output" =~ "test1.2 successful" ]]
Expand Down Expand Up @@ -174,4 +179,3 @@ setup() {
run mpirun -n 1 ./test_diag_manager
[ "$status" -eq 0 ]
}

65 changes: 34 additions & 31 deletions test_fms/drifters/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
# This is an automake file for the test_fms/drifters directory of the FMS
# package.

LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh

# Find the fms_mod.mod file.
test_cloud_interpolator_CPPFLAGS = -I${top_srcdir}/drifters
test_cloud_interpolator_CPPFLAGS += -I${top_srcdir}/mpp
test_cloud_interpolator_CPPFLAGS = -I${top_builddir}/drifters
test_cloud_interpolator_CPPFLAGS += -I${top_builddir}/mpp
test_cloud_interpolator_CPPFLAGS += -I${top_srcdir}/include

test_drifters_io_CPPFLAGS = -I${top_srcdir}/drifters
test_drifters_io_CPPFLAGS += -I${top_srcdir}/mpp
test_drifters_io_CPPFLAGS += -I${top_srcdir}/include
test_drifters_io_CPPFLAGS = -I${top_builddir}/drifters
test_drifters_io_CPPFLAGS += -I${top_builddir}/mpp
test_drifters_io_CPPFLAGS += -I${top_builddir}/include

test_drifters_input_CPPFLAGS = -I${top_srcdir}/drifters
test_drifters_input_CPPFLAGS += -I${top_srcdir}/mpp
test_drifters_input_CPPFLAGS += -I${top_srcdir}/fms
test_drifters_input_CPPFLAGS += -I${top_srcdir}/include
test_drifters_input_CPPFLAGS = -I${top_builddir}/drifters
test_drifters_input_CPPFLAGS += -I${top_builddir}/mpp
test_drifters_input_CPPFLAGS += -I${top_builddir}/fms
test_drifters_input_CPPFLAGS += -I${top_builddir}/include

test_drifters_comm_CPPFLAGS = -I${top_srcdir}/drifters
test_drifters_comm_CPPFLAGS += -I${top_srcdir}/mpp
test_drifters_comm_CPPFLAGS += -I${top_srcdir}/include
test_drifters_comm_CPPFLAGS = -I${top_builddir}/drifters
test_drifters_comm_CPPFLAGS += -I${top_builddir}/mpp
test_drifters_comm_CPPFLAGS += -I${top_builddir}/include

test_drifters_core_CPPFLAGS = -I${top_srcdir}/drifters
test_drifters_core_CPPFLAGS += -I${top_srcdir}/mpp
test_drifters_core_CPPFLAGS += -I${top_srcdir}/include
test_drifters_core_CPPFLAGS += -I${top_srcdir}/fms
test_drifters_core_CPPFLAGS = -I${top_builddir}/drifters
test_drifters_core_CPPFLAGS += -I${top_builddir}/mpp
test_drifters_core_CPPFLAGS += -I${top_builddir}/include
test_drifters_core_CPPFLAGS += -I${top_builddir}/fms

test_quicksort_CPPFLAGS = -I${top_srcdir}/drifters
test_quicksort_CPPFLAGS = -I${top_builddir}/drifters

test_drifters_CPPFLAGS = -I${top_srcdir}/drifters
test_drifters_CPPFLAGS += -I${top_srcdir}/mpp
test_drifters_CPPFLAGS += -I${top_srcdir}/include
test_drifters_CPPFLAGS = -I${top_builddir}/drifters
test_drifters_CPPFLAGS += -I${top_builddir}/mpp
test_drifters_CPPFLAGS += -I${top_builddir}/include

# Copy over other needed files to the srcdir
EXTRA_DIST = input.nml
EXTRA_DIST += test_cloud_interpolator.bats
EXTRA_DIST += test_cloud_interpolator.sh
EXTRA_DIST += test_drifters_io.bats
EXTRA_DIST += test_drifters_io.sh
EXTRA_DIST += test_drifters_input.bats
EXTRA_DIST += test_drifters_input.sh
EXTRA_DIST += test_drifters_comm.bats
EXTRA_DIST += test_drifters_comm.sh
EXTRA_DIST += test_drifters_core.bats
EXTRA_DIST += test_drifters_core.sh
EXTRA_DIST += test_quicksort.bats
EXTRA_DIST += test_quicksort.sh
EXTRA_DIST += test_drifters.bats
EXTRA_DIST += test_drifters.sh
EXTRA_DIST += test_drifters_input.bats
EXTRA_DIST += test_drifters_input.sh
EXTRA_DIST += test_drifters_comm.bats
EXTRA_DIST += test_drifters_comm.sh
EXTRA_DIST += test_drifters_core.bats
EXTRA_DIST += test_drifters_core.sh
EXTRA_DIST += test_quicksort.bats
EXTRA_DIST += test_quicksort.sh
EXTRA_DIST += test_drifters.bats
EXTRA_DIST += test_drifters.sh
EXTRA_DIST += drifters_inp_test_3d.cdl

# Build this test program.
check_PROGRAMS = test_cloud_interpolator test_drifters_input test_drifters_comm test_drifters_core test_drifters_io test_quicksort test_drifters
Expand Down Expand Up @@ -80,4 +84,3 @@ TESTS_ENVIRONMENT = srcdir="$(top_srcdir)"

# Clean up
CLEANFILES = *out *__genmod.mod *__genmod.f90 input.nml *.nc

15 changes: 8 additions & 7 deletions test_fms/drifters/test_cloud_interpolator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

program test_cloud_interpolator
use cloud_interpolator_mod
use mpp_mod, only : mpp_error, FATAL, stdout, mpp_init
use mpp_mod, only : mpp_error, FATAL, stdout, mpp_init, mpp_exit

implicit none

Expand All @@ -30,9 +30,10 @@ program test_cloud_interpolator
call test_cell_search
call test_get_node_values

call mpp_exit()
CONTAINS
subroutine test_expansion_contraction

integer ie1(4), ie2(4), Ic, ier, idiff, j
ie1 = (/1,0,1,1/)
call cld_ntrp_contract_indices(ie1, Ic, ier)
Expand All @@ -49,11 +50,11 @@ subroutine test_expansion_contraction
print *,'ie1 = ', ie1
print *,'ie2 = ', ie2
print *,'Ic = ', Ic

end subroutine test_expansion_contraction

subroutine test_linear_cell_interpolation
integer, parameter :: nd = 3
integer, parameter :: nd = 3
real :: fvals(2**nd), ts(nd)
real :: fi, fx
integer ier
Expand All @@ -62,9 +63,9 @@ subroutine test_linear_cell_interpolation
ts = (/ 0.1, 0.2, 0.3 /)
fx = 1. + ts(1) + 2*ts(2) + 3*ts(3)
call cld_ntrp_linear_cell_interp(fvals, ts, fi, ier)
if(ier/=0) then
if(ier/=0) then
print *,'ERROR flag ier=', ier
call mpp_error(FATAL,'ERROR: linear cell interpolation test failed (ier/=0)')
call mpp_error(FATAL,'ERROR: linear cell interpolation test failed (ier/=0)')
endif
print *,'fi, fx = ', fi, fx
end subroutine test_linear_cell_interpolation
Expand All @@ -78,7 +79,7 @@ subroutine test_cell_search
real :: axis4(n) = (/0.4, 0.03, 0.02, 0.01, 0./)
real x
integer :: ier_tot = 0

print *,'axis1=', axis1
x = -0.0001
call cld_ntrp_locate_cell(axis1, x, index, ier)
Expand Down
7 changes: 6 additions & 1 deletion test_fms/drifters/test_cloud_interpolator.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
teardown () {
# Echo the output. Will only be done on a test failure.
echo "$output"
}

@test "1" {
run mpirun -n 6 ./test_cloud_interpolator
run mpirun -n 2 ./test_cloud_interpolator
[ "$status" -eq 0 ]
}
5 changes: 5 additions & 0 deletions test_fms/drifters/test_drifters.bats
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
teardown () {
# Echo the output. Will only be done on a test failure.
echo "$output"
}

@test "1" {
skip "The input file is missing"
run ./test_drifters
Expand Down
7 changes: 6 additions & 1 deletion test_fms/drifters/test_drifters_comm.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
teardown () {
# Echo the output. Will only be done on a test failure.
echo "$output"
}

@test "1" {
run ./test_drifters_comm
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
}
Loading

0 comments on commit 428b0e5

Please sign in to comment.