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

Add testing of relative time axis for NetCDF.

parent 12268648
No related branches found
No related tags found
No related merge requests found
......@@ -263,7 +263,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
vlistDefVarDatatype(vlistID, varDesc[varIdx].id, setup.datatype);
}
taxisID = taxisCreate ( TAXIS_ABSOLUTE );
taxisID = taxisCreate ( setup.taxistype );
vlistDefTaxis ( vlistID, taxisID );
for ( tfID = 0; tfID < ntfiles; tfID++ )
......
#! @SHELL@
pio_write_args="-f nc4 -w 3"
pio_write_args="-f nc4 -w 3 -qtaxis-type=relative"
mpi_task_num=7
LOG=pio_cksum_cdf.log
suffix=nc4
......
......@@ -32,11 +32,15 @@
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, "grb"};
PIO_WRITE_CONFIG_CHECKSUM_FLAG,
TAXIS_ABSOLUTE, -1,
"grb"};
#else
= { .nlon = 12, .nts = 3, .nlat = 6, .nvars = 5,
.filetype = CDI_FILETYPE_GRB, .datatype = CDI_DATATYPE_PACK24,
.flags = PIO_WRITE_CONFIG_CHECKSUM_FLAG,
.taxistype = TAXIS_ABSOLUTE,
.taxisunit = -1,
.suffix = "grb",
.max_nlev = 5,
};
......@@ -129,12 +133,44 @@ parseBooleanLongOption(size_t optionStrSize, const char *optionStr,
return result;
}
struct string2int
{
const char *key;
int val;
};
static bool
parseLongOptionArgStringToInt(const char *str,
size_t optionStrLen, const char *optionStr,
size_t mapSize, const struct string2int *map,
int argc, char *argv[], int *out)
{
if (!strncmp(str, optionStr, optionStrLen))
{
const char *optargArg;
if (str[optionStrLen] == '=')
optargArg = str + optionStrLen+1;
else if (str[sizeof (optionStr) - 1] == 0 && optind < argc)
optargArg = argv[optind++];
else
invalidOptionDie("missing argument to -q%s", optionStr);
for (size_t i = 0; i < mapSize; ++i)
if (!strcmp(optargArg, map[i].key))
{
*out = map[i].val;
return true;
}
invalidOptionDie("unknown argument \"%s\" to -q%s",
optargArg, optionStr);
}
return false;
}
static void
parse_long_option(struct model_config *restrict setup,
int pioConfHandle, pioRoleFunc *pioRoleAssign,
const char *str)
const char *str, int argc, char *argv[])
{
#ifndef USE_MPI
(void)pioConfHandle;
......@@ -144,7 +180,31 @@ parse_long_option(struct model_config *restrict setup,
pioRoleSchemeOptionStr[] = "pio-role-scheme",
curvilinearGridOptionStr[] = "no-create-curvilinear-grid",
uuidCreateOptionStr[] = "no-create-uuid",
useDistGridOptionStr[] = "no-use-dist-grid";
useDistGridOptionStr[] = "no-use-dist-grid",
taxistypeOptionStr[] = "taxis-type",
taxisunitOptionStr[] = "taxis-unit";
static const struct string2int taxistypeArgMap[]
= { { "absolute", TAXIS_ABSOLUTE },
{ "relative", TAXIS_RELATIVE },
{ "forecast", TAXIS_FORECAST },
};
static const struct string2int taxisunitArgMap[]
= { { "second", TUNIT_SECOND },
{ "minute", TUNIT_MINUTE },
{ "quarter", TUNIT_QUARTER },
{ "30minutes", TUNIT_30MINUTES },
{ "hour", TUNIT_HOUR },
{ "3hours", TUNIT_3HOURS },
{ "6hours", TUNIT_6HOURS },
{ "12hours", TUNIT_12HOURS },
{ "day", TUNIT_DAY },
{ "month", TUNIT_MONTH },
{ "year", TUNIT_YEAR },
};
enum {
taxistypeArgMapSize = sizeof(taxistypeArgMap) / sizeof(taxistypeArgMap[0]),
taxisunitArgMapSize = sizeof(taxisunitArgMap) / sizeof(taxisunitArgMap[0]),
};
struct boolOptionParse bop;
if ((bop = parseBooleanLongOption(sizeof (cacheRedistStr), cacheRedistStr,
str)).matched)
......@@ -156,6 +216,16 @@ parse_long_option(struct model_config *restrict setup,
cacheRedistStr + (bop.invert ? 0 : 3));
#endif
}
else if (parseLongOptionArgStringToInt(str, sizeof (taxistypeOptionStr) - 1,
taxistypeOptionStr,
taxistypeArgMapSize, taxistypeArgMap,
argc, argv, &setup->taxistype))
;
else if (parseLongOptionArgStringToInt(str, sizeof (taxisunitOptionStr) - 1,
taxisunitOptionStr,
taxisunitArgMapSize, taxisunitArgMap,
argc, argv, &setup->taxisunit))
;
else if (!strncmp(str, pioRoleSchemeOptionStr,
sizeof (pioRoleSchemeOptionStr) - 1))
{
......@@ -290,7 +360,8 @@ int main(int argc, char *argv[])
break;
#endif
case 'q':
parse_long_option(&setup, pioConfHandle, &pioRoleAssign, optarg);
parse_long_option(&setup, pioConfHandle, &pioRoleAssign,
optarg, argc, argv);
break;
case 'f':
{
......
......@@ -31,6 +31,7 @@ struct model_config
int nlon, nlat, nts, max_nlev, nvars;
int filetype, datatype;
int flags;
int taxistype, taxisunit;
const char *suffix;
};
......
......@@ -186,7 +186,9 @@ modelRun(struct model_config setup, MPI_Comm comm)
vlistDefVarDatatype(vlistID, varDesc[varIdx].id, setup.datatype);
}
taxisID = taxisCreate ( TAXIS_ABSOLUTE );
taxisID = taxisCreate ( setup.taxistype );
if ( setup.taxisunit != -1 )
taxisDefTunit(taxisID, setup.taxisunit);
vlistDefTaxis ( vlistID, taxisID );
for ( tfID = 0; tfID < ntfiles; tfID++ )
......
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