|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Copyright (C) 2024 Geophysical Fluid Dynamics Laboratory |
| 4 | + |
| 5 | +# This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). |
| 6 | + |
| 7 | +# FRE-NCtools is free software: you can redistribute it and/or modify it under |
| 8 | +# the terms of the GNU Lesser General Public License as published by |
| 9 | +# the Free Software Foundation, either version 3 of the License, or (at |
| 10 | +# your option) any later version. |
| 11 | + |
| 12 | +# FRE-NCtools is distributed in the hope that it will be useful, but WITHOUT |
| 13 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 | +# for more details. |
| 16 | + |
| 17 | +# You should have received a copy of the GNU Lesser General Public |
| 18 | +# License along with FRE-NCTools. If not, see |
| 19 | +# <http://www.gnu.org/licenses/>. |
| 20 | + |
| 21 | +if test "$VERBOSE" = yes |
| 22 | +then |
| 23 | + set -x |
| 24 | + command -v split_ncvars.pl --version |
| 25 | +fi |
| 26 | + |
| 27 | +. ${srcdir=.}/init.sh; path_prepend_ ../../src |
| 28 | + |
| 29 | +# Need to use the included list_ncvars.sh script. Otherwise, |
| 30 | +# split_ncvars will look for list_ncvars.sh in the installed bin |
| 31 | +# directory. |
| 32 | +export LIST_NCVARS=$(readlink -f ../../src/list_ncvars.sh) |
| 33 | + |
| 34 | +# list_ncvars.sh needs to know where to find the built list_ncvars |
| 35 | +# executable. |
| 36 | +export PKGLIBEXECDIR=$(readlink -f ../../src) |
| 37 | + |
| 38 | +# Use the test netCDF files from plevel |
| 39 | +${builddir=..}/create_plevel_test_ncfile || framework_failure_ "failed to create plevel test files" |
| 40 | +mkdir idir || framework_failure_ "failed to create idir" |
| 41 | +mv test_input.nc idir || framework_failure_ "failed to move test_input.nc to idir" |
| 42 | + |
| 43 | +# Extract a static variable whose formula_terms contains a variable that contains time. |
| 44 | +# The output file should NOT contain time. |
| 45 | +split_ncvars.pl -v pfull -i idir test_input.nc -f output.nc || fail_ split_ncvars.pl test_input.nc failed |
| 46 | + |
| 47 | +# Check that the output.nc file was created, that it has pfull in it, and does not have time in it |
| 48 | +test -f output.nc || fail_ output.nc not created |
| 49 | +if ncdump -v time output.nc |
| 50 | +then |
| 51 | + # Expected failure |
| 52 | + fail_ "output.nc incorrectly contains time" |
| 53 | +fi |
| 54 | +ncdump -v pfull output.nc || fail_ "output.nc does not contain output variable pfull" |
0 commit comments