Skip to content

Commit

Permalink
feat: test harness for get_close_init zero maxdist
Browse files Browse the repository at this point in the history
  • Loading branch information
hkershaw-brown committed Aug 9, 2024
1 parent 75cf8dc commit 179b869
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ test_quad_irreg_interp
test_quad_reg_interp
test_table_read
test_ran_unif
test_get_close_init_zero_dist
test_get_close_init_zero_dists

# Directories to NOT IGNORE ... same as executable names
# as far as I know, these must be listed after the executables
Expand Down
20 changes: 20 additions & 0 deletions developer_tests/get_close/test_get_close_init_zero_dist.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
program test_get_close_zero_dist

use location_mod, only : get_close_init, get_close_type, location_type
use types_mod, only : r8
use utilities_mod, only : initialize_utilities, finalize_utilities

implicit none

integer, parameter :: n = 10
type(get_close_type) :: gc
type(location_type) :: locs(n)
real(r8) :: max_dist = 0.0_r8

call initialize_utilities('test_get_close')

call get_close_init(gc, n, max_dist, locs)

call finalize_utilities()

end program test_get_close_zero_dist
21 changes: 21 additions & 0 deletions developer_tests/get_close/test_get_close_init_zero_dists.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
program test_get_close_zero_dist

use location_mod, only : get_close_init, get_close_type, location_type
use types_mod, only : r8
use utilities_mod, only : initialize_utilities, finalize_utilities

implicit none

integer, parameter :: n = 10
type(get_close_type) :: gc
type(location_type) :: locs(n)
real(r8) :: max_dist = 1.0_r8
real(r8) :: max_dists(n) = 0.0_r8

call initialize_utilities('test_get_close')

call get_close_init(gc, n, max_dist, locs, max_dists)

call finalize_utilities()

end program test_get_close_zero_dist
23 changes: 23 additions & 0 deletions developer_tests/get_close/work/input.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

&location_nml
/

&preprocess_nml
overwrite_output = .true.
input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90'
output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90'
input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90'
output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90'
obs_type_files = '../../../observations/forward_operators/obs_def_reanalysis_bufr_mod.f90'
quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90'
/

&obs_kind_nml
/

&utilities_nml
TERMLEVEL = 2
module_details = .false.
logfilename = 'dart_log.out'
nmlfilename = 'dart_log.nml'
/
38 changes: 38 additions & 0 deletions developer_tests/get_close/work/quickbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

main() {

export DART=$(git rev-parse --show-toplevel)
source "$DART"/build_templates/buildfunctions.sh

MODEL="none"
EXTRA="$DART"/models/template/threed_model_mod.f90
TEST=get_close
dev_test=1
LOCATION="threed_cartesian"

programs=(
)

serial_programs=(
test_get_close_init_zero_dist
test_get_close_init_zero_dists
)

arguments "$@"

# clean the directory
\rm -f -- *.o *.mod Makefile .cppdefs

# build and run preprocess before making any other DART executables
buildpreprocess

# build DART
buildit

# clean up
\rm -f -- *.o *.mod

}

main "$@"
52 changes: 52 additions & 0 deletions developer_tests/get_close/work/runall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# DART software - Copyright UCAR. This open source software is provided
# by UCAR, "as is", without charge, subject to all terms of use at
# http://www.image.ucar.edu/DAReS/DART/DART_download

# Usage:
# ./runall.sh
# ./runall.sh | grep FAIL
# ./runall.sh | grep PASS

should_pass () {
if [[ $? -ne 0 ]]; then
echo $1: "FAIL"
else
echo $1: "PASS"
fi
}

function run_test () {
./$1 > out.$1 2>&1
grep "$2" out.$1
res=$?
return $res
}

# for three_sphere
# Use sed to replace the line (compatible with both macOS and Linux)
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/^LOCATION=".*"/LOCATION="threed_sphere"/' quickbuild.sh
else
sed -i 's/^LOCATION=".*"/LOCATION="threed_sphere"/' quickbuild.sh
fi

./quickbuild.sh

run_test test_get_close_init_zero_dist "bad maxdist value"; should_pass "3d sphere max dist <=0"
run_test test_get_close_init_zero_dists "bad maxdist_list value"; should_pass "3d sphere max dists <=0"


# for threed_cartesian
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/^LOCATION=".*"/LOCATION="threed_cartesian"/' quickbuild.sh
else
sed -i 's/^LOCATION=".*"/LOCATION="threed_cartesian"/' quickbuild.sh
fi

./quickbuild.sh

run_test test_get_close_init_zero_dist "bad maxdist value"; should_pass "3d cart max dist <=0"
run_test test_get_close_init_zero_dists "bad maxdist_list value"; should_pass "3d cart max dists <=0"

0 comments on commit 179b869

Please sign in to comment.