Commit af9ea711 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

grib2: set stepUnits after changing the template [Bug #4500]

parent 0f5407f7
2014-02-20 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* grib2: set stepUnits after changing the template [Bug #4500]
2014-02-14 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Version 1.6.3 released
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for cdi 1.6.3.
# Generated by GNU Autoconf 2.68 for cdi 1.6.4rc1.
#
# Report bugs to <http://code.zmaw.de/projects/cdi>.
#
......@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.6.3'
PACKAGE_STRING='cdi 1.6.3'
PACKAGE_VERSION='1.6.4rc1'
PACKAGE_STRING='cdi 1.6.4rc1'
PACKAGE_BUGREPORT='http://code.zmaw.de/projects/cdi'
PACKAGE_URL=''
 
......@@ -1437,7 +1437,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdi 1.6.3 to adapt to many kinds of systems.
\`configure' configures cdi 1.6.4rc1 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
......@@ -1507,7 +1507,7 @@ fi
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.6.3:";;
short | recursive ) echo "Configuration of cdi 1.6.4rc1:";;
esac
cat <<\_ACEOF
 
......@@ -1689,7 +1689,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.6.3
cdi configure 1.6.4rc1
generated by GNU Autoconf 2.68
 
Copyright (C) 2010 Free Software Foundation, Inc.
......@@ -2450,7 +2450,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
 
It was created by cdi $as_me 1.6.3, which was
It was created by cdi $as_me 1.6.4rc1, which was
generated by GNU Autoconf 2.68. Invocation command line was
 
$ $0 $@
......@@ -3347,7 +3347,7 @@ fi
 
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.6.3'
VERSION='1.6.4rc1'
 
 
cat >>confdefs.h <<_ACEOF
......@@ -28300,7 +28300,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdi $as_me 1.6.3, which was
This file was extended by cdi $as_me 1.6.4rc1, which was
generated by GNU Autoconf 2.68. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
......@@ -28366,7 +28366,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
cdi config.status 1.6.3
cdi config.status 1.6.4rc1
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
 
......
# Process this file with autoconf to produce a configure script.
AC_INIT([cdi], [1.6.3], [http://code.zmaw.de/projects/cdi])
AC_INIT([cdi], [1.6.4rc1], [http://code.zmaw.de/projects/cdi])
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
......
......@@ -150,37 +150,15 @@ double timeunit_factor(int tu1, int tu2)
static
int gribapiGetTimeUnits(grib_handle *gh)
{
int status;
int timeunits = -1;
long unitsOfTime = -1;
int status;
// size_t len = 8;
//char stepunits[8];
//static int lprint = TRUE;
status = grib_get_long(gh, "indicatorOfUnitOfTimeRange", &unitsOfTime);
timeunits = getTimeunits(unitsOfTime);
/*
GRIB_CHECK(grib_get_string(gh, "stepUnits", stepunits, &len), 0);
len--;
GRIB_CHECK(grib_set_long(gh, "stepUnits", unitsOfTime), 0);
if ( memcmp(stepunits, "s", len) == 0 ) timeunits = TUNIT_SECOND;
else if ( memcmp(stepunits, "m", len) == 0 ) timeunits = TUNIT_MINUTE;
else if ( memcmp(stepunits, "h", len) == 0 ) timeunits = TUNIT_HOUR;
else if ( memcmp(stepunits, "3h", len) == 0 ) timeunits = TUNIT_3HOURS;
else if ( memcmp(stepunits, "6h", len) == 0 ) timeunits = TUNIT_6HOURS;
else if ( memcmp(stepunits, "12h", len) == 0 ) timeunits = TUNIT_12HOURS;
else if ( memcmp(stepunits, "D", len) == 0 ) timeunits = TUNIT_DAY;
else if ( memcmp(stepunits, "M", len) == 0 ) timeunits = TUNIT_MONTH;
else if ( memcmp(stepunits, "Y", len) == 0 ) timeunits = TUNIT_YEAR;
else if ( lprint )
{
Message("Step units >%s< unsupported!", stepunits);
lprint = FALSE;
}
*/
timeunits = getTimeunits(unitsOfTime);
return (timeunits);
}
......@@ -2081,33 +2059,47 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
}
static
int gribapiDefStepUnits(grib_handle *gh, int timeunit, int gcinit)
int getTimeunitFactor(int timeunit)
{
int factor = 1;
switch (timeunit)
{
case TUNIT_SECOND: factor = 1; break;
case TUNIT_MINUTE: factor = 60; break;
case TUNIT_HOUR: factor = 3600; break;
case TUNIT_3HOURS: factor = 10800; break;
case TUNIT_6HOURS: factor = 21600; break;
case TUNIT_12HOURS: factor = 43200; break;
case TUNIT_DAY: factor = 86400; break;
default: factor = 3600; break;
}
return (factor);
}
static
void gribapiDefStepUnits(grib_handle *gh, int timeunit, int gcinit)
{
long unitsOfTime;
char stepunits[8];
size_t len;
switch (timeunit)
{
case TUNIT_SECOND: factor = 1; unitsOfTime = 13; strcpy(stepunits, "s"); break;
case TUNIT_MINUTE: factor = 60; unitsOfTime = 0; strcpy(stepunits, "m"); break;
case TUNIT_HOUR: factor = 3600; unitsOfTime = 1; strcpy(stepunits, "h"); break;
case TUNIT_3HOURS: factor = 10800; unitsOfTime = 10; strcpy(stepunits, "3h"); break;
case TUNIT_6HOURS: factor = 21600; unitsOfTime = 11; strcpy(stepunits, "6h"); break;
case TUNIT_12HOURS: factor = 43200; unitsOfTime = 12; strcpy(stepunits, "12h"); break;
case TUNIT_DAY: factor = 86400; unitsOfTime = 2; strcpy(stepunits, "D"); break;
default: factor = 3600; unitsOfTime = 1; strcpy(stepunits, "h"); break;
case TUNIT_SECOND: unitsOfTime = 13; break;
case TUNIT_MINUTE: unitsOfTime = 0; break;
case TUNIT_HOUR: unitsOfTime = 1; break;
case TUNIT_3HOURS: unitsOfTime = 10; break;
case TUNIT_6HOURS: unitsOfTime = 11; break;
case TUNIT_12HOURS: unitsOfTime = 12; break;
case TUNIT_DAY: unitsOfTime = 2; break;
default: unitsOfTime = 1; break;
}
if ( !gcinit )
{
len = strlen(stepunits) + 1;
GRIB_CHECK(grib_set_long(gh, "stepUnits", unitsOfTime), 0);
GRIB_CHECK(grib_set_long(gh, "indicatorOfUnitOfTimeRange", unitsOfTime), 0);
GRIB_CHECK(grib_set_string(gh, "stepUnits", stepunits, &len), 0);
}
return (factor);
}
static
......@@ -2115,7 +2107,7 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int tsteptype, int gc
{
long proDefTempNum = 0;
size_t len = 64;
char stepType[64];
char stepType[len];
switch ( tsteptype )
{
......@@ -2145,24 +2137,24 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int tsteptype, int gc
static
void gribapiDefDateTimeAbs(int editionNumber, grib_handle *gh, int date, int time, int tsteptype, int gcinit)
{
(void ) gribapiDefSteptype(editionNumber, gh, tsteptype, gcinit);
if ( editionNumber > 1 ) GRIB_CHECK(grib_set_long(gh, "significanceOfReferenceTime", 0), 0);
if ( editionNumber > 1 ) GRIB_CHECK(grib_set_long(gh, "stepRange", 0), 0);
if ( date == 0 ) date = 10101;
gribapiSetDataDateTime(gh, date, time);
(void ) gribapiDefSteptype(editionNumber, gh, tsteptype, gcinit);
}
static
int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rtime, int vdate, int vtime,
int tsteptype, int factor, int calendar, int gcinit)
int tsteptype, int timeunit, int calendar, int gcinit)
{
int status = -1;
int year, month, day, hour, minute, second;
int julday1, secofday1, julday2, secofday2, days, secs;
int factor;
long startStep = 0, endStep;
long proDefTempNum = 0;
cdiDecodeDate(rdate, &year, &month, &day);
cdiDecodeTime(rtime, &hour, &minute, &second);
......@@ -2174,8 +2166,14 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
(void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
factor = getTimeunitFactor(timeunit);
if ( !(int) fmod(days*86400.0 + secs, factor) )
{
int proDefTempNum = gribapiDefSteptype(editionNumber, gh, tsteptype, gcinit);
gribapiDefStepUnits(gh, timeunit, gcinit);
endStep = (int) ((days*86400.0 + secs)/factor);
if ( editionNumber > 1 ) GRIB_CHECK(grib_set_long(gh, "significanceOfReferenceTime", 1), 0);
......@@ -2186,8 +2184,6 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
// printf(">>>>> tsteptype %d startStep %ld endStep %ld\n", tsteptype, startStep, endStep);
proDefTempNum = gribapiDefSteptype(editionNumber, gh, tsteptype, gcinit);
if ( proDefTempNum == 0 ) startStep = endStep;
if ( editionNumber > 1 ) GRIB_CHECK(grib_set_long(gh, "forecastTime", startStep), 0);
......@@ -2225,10 +2221,9 @@ void gribapiDefTime(int editionNumber, int typeOfGeneratingProcess, grib_handle
int rdate = taxisInqRdate(taxisID);
int rtime = taxisInqRtime(taxisID);
int timeunit = taxisInqTunit(taxisID);
int factor = gribapiDefStepUnits(gh, timeunit, gcinit);
status = gribapiDefDateTimeRel(editionNumber, gh, rdate, rtime, vdate, vtime,
tsteptype, factor, calendar, gcinit);
tsteptype, timeunit, calendar, gcinit);
if ( status != 0 ) taxistype = TAXIS_ABSOLUTE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment