Skip to content
Snippets Groups Projects
Commit bac16949 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Make test file name prefix configurable.

parent fe2a644c
No related branches found
No related tags found
No related merge requests found
......@@ -67,8 +67,6 @@ modelRegionCompute(double region[], int nlev, int nlat, int nlon,
void
modelRun(const struct model_config *setup, MPI_Comm comm)
{
static const char * const fname_prefix = "example";
struct varDesc_t
{
size_t size;
......@@ -287,7 +285,7 @@ modelRun(const struct model_config *setup, MPI_Comm comm)
for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
varDesc[varIdx].checksum_state = 0;
int streamID = composeStream(&filename, fname_prefix, tfID,
int streamID = composeStream(&filename, setup->prefix, tfID,
setup->suffix,
setup->filetype);
streamDefVlist(streamID, vlistID);
......@@ -418,7 +416,7 @@ modelRun(const struct model_config *setup, MPI_Comm comm)
if (rank == 0 && (setup->flags & PIO_WRITE_CONFIG_CHECKSUM_FLAG))
{
FILE *tablefp;
composeFilename(&filename, fname_prefix, tfID, "cksum");
composeFilename(&filename, setup->prefix, tfID, "cksum");
if (!(tablefp = fopen(filename, "w")))
{
perror("failed to open table file");
......
......@@ -31,12 +31,14 @@
#include "pio_util.h"
#endif
static const char default_fname_prefix[] = "example";
static const struct model_config default_setup
#ifdef __cplusplus
= { 12, 6, 3, 5, 5, CDI_FILETYPE_GRB, CDI_DATATYPE_PACK24,
PIO_WRITE_CONFIG_CHECKSUM_FLAG,
TAXIS_ABSOLUTE, -1,
"grb"};
"grb", default_fname_prefix };
#else
= { .nlon = 12, .nts = 3, .nlat = 6, .nvars = 5,
.filetype = CDI_FILETYPE_GRB, .datatype = CDI_DATATYPE_PACK24,
......@@ -44,6 +46,7 @@ static const struct model_config default_setup
.taxistype = TAXIS_ABSOLUTE,
.taxisunit = -1,
.suffix = "grb",
.prefix = default_fname_prefix,
.max_nlev = 5,
};
#endif
......@@ -190,6 +193,7 @@ parse_long_option(struct model_config *restrict setup,
batchedRmaOptionStr[] = "no-batch-rma",
presetDecoOptionStr[] = "no-preset-decomposition",
datatypeOptionStr[] = "datatype",
prefixOptionStr[] = "prefix",
taxistypeOptionStr[] = "taxis-type",
taxisunitOptionStr[] = "taxis-unit";
static const struct string2int datatypeArgMap[]
......@@ -313,6 +317,17 @@ parse_long_option(struct model_config *restrict setup,
pioRoleSchemeOptionStr);
#endif
}
else if (!strncmp(str, prefixOptionStr,
sizeof (prefixOptionStr) - 1))
{
if (str[sizeof (prefixOptionStr) - 1] == '=')
{
setup->prefix = str + sizeof (prefixOptionStr);
}
else
invalidOptionDie("long option %s needs argument\n",
prefixOptionStr);
}
else if ((bop = parseBooleanLongOption(sizeof (useDistGridOptionStr),
useDistGridOptionStr, str)).matched)
{
......
......@@ -35,7 +35,7 @@ struct model_config
int filetype, datatype;
int flags;
int taxistype, taxisunit;
const char *suffix;
const char *suffix, *prefix;
};
void
......
......@@ -5,8 +5,9 @@ if [ @ENABLE_GRIB@ != yes ]; then
# skip tests for unsupported formats
exit 77
fi
mpi_task_num="${mpi_task_num-4}"
suffix="${suffix-grb}"
mpi_task_num=${mpi_task_num-4}
prefix=${CDI_TEST_PREFIX-example}
suffix=${suffix-grb}
if [ "@USE_MPI@" = yes ]; then
variations="-qno-batch-rma -qcache-redists -qcreate-curvilinear-grid -qpreset-decomposition=true"
else
......@@ -15,17 +16,21 @@ fi
test_variation()
{
exec 5>&1 6>&2 >"$LOG" 2>&1
if expr "$prefix" : "[^/]*/" >/dev/null ; then
mkdir -p `echo ${prefix} | sed -e 's@/[^/]$@@'`
fi
echo "creating data with $1" >&2
variation=$1
../libtool --mode=execute \
@MPI_LAUNCH@ \
-n ${mpi_task_num} ${tool_wrap} ./pio_write ${pio_write_args} -s 7 ${variation}
echo "checking example_0.$suffix" >&2
-n ${mpi_task_num} ${tool_wrap} ./pio_write ${pio_write_args} -s 7 \
${variation} ${CDI_TEST_PREFIX+"-qprefix=${CDI_TEST_PREFIX}"}
echo "checking ${prefix}_0.$suffix" >&2
../libtool --mode=execute \
${tool_wrap} ./cksum_read example_0.${suffix} example_0.cksum
echo "checking example_1.$suffix" >&2
${tool_wrap} ./cksum_read "${prefix}_0.${suffix}" "${prefix}_0.cksum"
echo "checking ${prefix}_1.$suffix" >&2
../libtool --mode=execute \
${tool_wrap} ./cksum_read example_1.${suffix} example_1.cksum
${tool_wrap} ./cksum_read "${prefix}_1.${suffix}" "${prefix}_1.cksum"
}
exec 5>&1 6>&2 >"$LOG" 2>&1
......
......@@ -57,8 +57,6 @@ modelRegionCompute(double region[], size_t offset, size_t len,
void
modelRun(const struct model_config *setup, MPI_Comm comm)
{
static const char * const fname_prefix = "example";
struct varDesc_t
{
size_t size;
......@@ -216,7 +214,7 @@ modelRun(const struct model_config *setup, MPI_Comm comm)
for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
varDesc[varIdx].checksum_state = 0;
int streamID = composeStream(&filename, fname_prefix, tfID,
int streamID = composeStream(&filename, setup->prefix, tfID,
setup->suffix,
setup->filetype);
#ifdef USE_MPI
......@@ -330,7 +328,7 @@ modelRun(const struct model_config *setup, MPI_Comm comm)
if (rank == 0 && (setup->flags & PIO_WRITE_CONFIG_CHECKSUM_FLAG))
{
FILE *tablefp;
composeFilename(&filename, fname_prefix, tfID, "cksum");
composeFilename(&filename, setup->prefix, tfID, "cksum");
if (!(tablefp = fopen(filename, "w")))
{
perror("failed to open table file");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment