Skip to content

Commit

Permalink
test harness for window code
Browse files Browse the repository at this point in the history
using external fortran-testanything
model_mod.f90 is in the work directory. This is a lazy move to avoid fiddling with EXTRA in quickbuild.sh

for issue #718
  • Loading branch information
hkershaw-brown committed Sep 10, 2024
1 parent a85e162 commit 9d0f897
Show file tree
Hide file tree
Showing 5 changed files with 404 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ test_quad_reg_interp
test_table_read
test_ran_unif
test_kde_dist
test_window

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

use mpi_utilities_mod, only : initialize_mpi_utilities, finalize_mpi_utilities, my_task_id, task_count, task_sync

use ensemble_manager_mod, only : init_ensemble_manager, end_ensemble_manager, ensemble_type, set_num_extra_copies
use distributed_state_mod, only : create_state_window, free_state_window, get_state
use types_mod, only : i8, r8

use test ! fortran-testanything

implicit none

integer :: num_copies = 10
integer :: real_ens_members = 3
real(r8) :: res(3)
integer(i8) :: num_vars = 201
type(ensemble_type) :: ens_handle

call initialize_mpi_utilities('test_window')

if (my_task_id() == 0 ) then
call plan(3*task_count())
endif

call init_ensemble_manager(ens_handle, num_copies, num_vars)
call set_num_extra_copies(ens_handle, num_copies - real_ens_members)

ens_handle%copies(1:real_ens_members,:) = my_task_id()
ens_handle%copies(real_ens_members+1:num_copies,:) = -100

call create_state_window(ens_handle)

! result should be index-1 mod task_count() for round robin distribution
res = get_state(1_i8, ens_handle)
call ok(res(1) == mod(1-1, task_count()))

res = get_state(27_i8, ens_handle)
call ok(res(1) == mod(27-1, task_count()))

res = get_state(198_i8, ens_handle)
call ok(res(1) == mod(198-1, task_count()))

call free_state_window(ens_handle)

call end_ensemble_manager(ens_handle)

call finalize_mpi_utilities()


end program test_window
15 changes: 15 additions & 0 deletions developer_tests/window/work/input.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
&ensemble_manager_nml
/

&utilities_nml
module_details = .false.
/

&preprocess_nml
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_gps_mod.f90'
quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90'
/
40 changes: 40 additions & 0 deletions developer_tests/window/work/quickbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env 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

main() {


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

MODEL="none"
EXTRA=/Users/hkershaw/DART/issues/fortran-testanything
dev_test=1
LOCATION="threed_sphere"
TEST="window"

programs=(
test_window
)

# quickbuild arguments
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 "$@"
Loading

0 comments on commit 9d0f897

Please sign in to comment.