Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
fd6de689
Commit
fd6de689
authored
Mar 30, 2009
by
Uwe Schulzweida
Browse files
cdfInqContents: check dimension of curvilinear grids
parent
283fcb0c
Changes
12
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
fd6de689
2009-0
3
-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
2009-0
4
-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using GRIB library version 1.3.0
* add support for NaN in DBL_IS_EQUAL
* add support for GRID type LCC2 (LCC PROJ.4 version)
* add support for TUNIT_QUARTER (15 minutes)
* grbDefTime: define tunit also for absolute time [report: Pruek Pongprueksa]
* change default calendar to CALENDAR_PROLEPTIC
* gridInqXinc: bug fix
* grid_check_cyclic: support for curvilinear grids without bounds
* cdfInqContents: check dimension of curvilinear grids
* streamOpenAppen: set ncmode to 2 (bug fix)
* replaced strncpy/strncmp by memcpy/memcmp
* Version 1.3.1 released
...
...
src/cdf.c
View file @
fd6de689
...
...
@@ -23,7 +23,7 @@ const char *cdfLibraryVersion(void)
#endif
}
#if
(defined (HAVE_LIBNETCDF) && defined(NC_NETCDF4)) ||
defined(HAVE_LIBHDF5)
#if defined(HAVE_LIBHDF5)
#if defined(__cplusplus)
extern
"C"
{
#endif
...
...
@@ -35,7 +35,7 @@ extern "C" {
const
char
*
hdfLibraryVersion
(
void
)
{
#if
(defined (HAVE_LIBNETCDF) && defined(NC_NETCDF4)) ||
defined(HAVE_LIBHDF5)
#if defined(HAVE_LIBHDF5)
static
char
hdf_libvers
[
256
];
unsigned
majnum
,
minnum
,
relnum
;
...
...
@@ -45,7 +45,7 @@ const char *hdfLibraryVersion(void)
return
(
hdf_libvers
);
#else
return
(
NULL
);
return
(
"library undefined"
);
#endif
}
...
...
src/cdi.h
View file @
fd6de689
...
...
@@ -146,6 +146,7 @@ extern "C" {
#define TUNIT_DAY 4
#define TUNIT_MONTH 5
#define TUNIT_YEAR 6
#define TUNIT_QUARTER 7
/* CALENDAR types */
...
...
src/grib.h
View file @
fd6de689
...
...
@@ -47,9 +47,10 @@
/*
* Macros for the product definition section ( Section 1 )
*/
#define ISEC1_TABLE4_MINUTE 0
#define ISEC1_TABLE4_HOUR 1
#define ISEC1_TABLE4_DAY 2
#define ISEC1_TABLE4_MINUTE 0
#define ISEC1_TABLE4_HOUR 1
#define ISEC1_TABLE4_DAY 2
#define ISEC1_TABLE4_QUARTER 13
#define ISEC1_CodeTable (isec1[ 0])
/* Version number of code table */
...
...
src/griblib.c
View file @
fd6de689
/* Automatically generated by m214003 at 2009-03-
1
2, do not edit */
/* Automatically generated by m214003 at 2009-03-2
7
, do not edit */
/* GRIBLIB_VERSION="1.3.0" */
...
...
@@ -1072,6 +1072,7 @@ void gribDateTime(int *isec1, int *date, int *time)
switch
(
ISEC1_TimeUnit
)
{
case
ISEC1_TABLE4_MINUTE
:
addsec
=
60
*
time_period
;
break
;
case
ISEC1_TABLE4_QUARTER
:
addsec
=
900
*
time_period
;
break
;
case
ISEC1_TABLE4_HOUR
:
addsec
=
3600
*
time_period
;
break
;
case
ISEC1_TABLE4_DAY
:
addsec
=
86400
*
time_period
;
break
;
default:
...
...
@@ -8380,7 +8381,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return
(
gribLen
);
}
static
const
char
grb_libvers
[]
=
"1.3.0"
" of ""Mar
1
2 2009"" ""12:
0
7:
20
"
;
static
const
char
grb_libvers
[]
=
"1.3.0"
" of ""Mar 2
7
2009"" ""12:
4
7:
36
"
;
const
char
*
gribLibraryVersion
(
void
)
{
...
...
src/model.c
View file @
fd6de689
...
...
@@ -208,8 +208,8 @@ static void model_defaults(void)
int
instID
;
instID
=
institutInq
(
0
,
0
,
"ECMWF"
,
NULL
);
(
void
)
modelDef
(
instID
,
131
,
"ERA15"
);
(
void
)
modelDef
(
instID
,
199
,
"ERA40"
);
/*
(void) modelDef(instID, 131, "ERA15");
*/
/*
(void) modelDef(instID, 199, "ERA40");
*/
instID
=
institutInq
(
0
,
0
,
"MPIMET"
,
NULL
);
ECHAM5
=
modelDef
(
instID
,
64
,
"ECHAM5.4"
);
...
...
src/stream.c
View file @
fd6de689
...
...
@@ -1885,8 +1885,6 @@ void cdiDefTableID(int tableID)
void
cdiPrintVersion
(
void
)
{
const
char
*
hdf_version
;
fprintf
(
stderr
,
" CDI library version : %s
\n
"
,
cdiLibraryVersion
());
#if defined (HAVE_LIBGRIB)
fprintf
(
stderr
,
" GRIB library version : %s
\n
"
,
gribLibraryVersion
());
...
...
@@ -1896,11 +1894,11 @@ void cdiPrintVersion(void)
fprintf
(
stderr
,
" nc_dap library version : %s
\n
"
,
cdfLibraryVersion
());
# else
fprintf
(
stderr
,
" netCDF library version : %s
\n
"
,
cdfLibraryVersion
());
hdf_version
=
hdfLibraryVersion
();
if
(
hdf_version
)
fprintf
(
stderr
,
" HDF5 library version : %s
\n
"
,
hdf_version
);
# endif
#endif
#if defined (HAVE_LIBHDF5)
fprintf
(
stderr
,
" HDF5 library version : %s
\n
"
,
hdfLibraryVersion
());
#endif
#if defined (HAVE_LIBSERVICE)
fprintf
(
stderr
,
"SERVICE library version : %s
\n
"
,
srvLibraryVersion
());
#endif
...
...
src/stream_cdf.c
View file @
fd6de689
...
...
@@ -765,6 +765,7 @@ void cdfDefTime(int streamID)
decode_date
(
rdate
,
&
year
,
&
month
,
&
day
);
decode_time
(
rtime
,
&
hour
,
&
minute
);
if
(
timeunit
==
TUNIT_QUARTER
)
timeunit
=
TUNIT_MINUTE
;
sprintf
(
unitstr
,
"%s since %d-%02d-%02d %02d:%02d"
,
tunitNamePtr
(
timeunit
),
year
,
month
,
day
,
hour
,
minute
);
}
...
...
@@ -2554,13 +2555,13 @@ int cdfDefVar(int streamID, int varID)
}
}
if
(
longname
)
if
(
longname
&&
*
longname
)
cdf_put_att_text
(
fileID
,
ncvarid
,
"long_name"
,
strlen
(
longname
),
longname
);
if
(
stdname
)
if
(
stdname
&&
*
stdname
)
cdf_put_att_text
(
fileID
,
ncvarid
,
"standard_name"
,
strlen
(
stdname
),
stdname
);
if
(
units
)
if
(
units
&&
*
units
)
cdf_put_att_text
(
fileID
,
ncvarid
,
"units"
,
strlen
(
units
),
units
);
if
(
code
>
0
)
...
...
@@ -3788,34 +3789,31 @@ int cdfInqContents(int streamID)
if
(
attlen
>
0
&&
attstring
[
0
]
!=
0
)
{
if
(
mem
cmp
(
attname
,
"history"
,
7
)
==
0
)
if
(
str
cmp
(
attname
,
"history"
)
==
0
)
{
streamptr
->
historyID
=
iatt
;
}
else
if
(
mem
cmp
(
attname
,
"institution"
,
11
)
==
0
)
else
if
(
str
cmp
(
attname
,
"institution"
)
==
0
)
{
cdfGetAttText
(
fileID
,
NC_GLOBAL
,
attname
,
attstringlen
-
1
,
attstring
);
instID
=
institutInq
(
0
,
0
,
NULL
,
attstring
);
if
(
instID
==
UNDEFID
)
instID
=
institutDef
(
0
,
0
,
NULL
,
attstring
);
}
else
if
(
mem
cmp
(
attname
,
"source"
,
6
)
==
0
)
else
if
(
str
cmp
(
attname
,
"source"
)
==
0
)
{
cdfGetAttText
(
fileID
,
NC_GLOBAL
,
attname
,
attstringlen
-
1
,
attstring
);
modelID
=
modelInq
(
-
1
,
0
,
attstring
);
}
else
if
(
mem
cmp
(
attname
,
"Conventions"
,
11
)
==
0
)
else
if
(
str
cmp
(
attname
,
"Conventions"
)
==
0
)
{
}
else
if
(
mem
cmp
(
attname
,
"CDI"
,
3
)
==
0
)
else
if
(
str
cmp
(
attname
,
"CDI"
)
==
0
)
{
}
else
if
(
mem
cmp
(
attname
,
"CDO"
,
3
)
==
0
)
else
if
(
str
cmp
(
attname
,
"CDO"
)
==
0
)
{
}
else
{
cdfGetAttText
(
fileID
,
NC_GLOBAL
,
attname
,
attstringlen
-
1
,
attstring
);
vlistDefAttTxt
(
vlistID
,
CDI_GLOBAL
,
attname
,
(
int
)
attlen
,
attstring
);
}
}
...
...
@@ -3902,28 +3900,28 @@ int cdfInqContents(int streamID)
cdf_inq_atttype
(
fileID
,
ncvarid
,
attname
,
&
atttype
);
cdf_inq_attlen
(
fileID
,
ncvarid
,
attname
,
&
attlen
);
if
(
mem
cmp
(
attname
,
"long_name"
,
9
)
==
0
)
if
(
str
cmp
(
attname
,
"long_name"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
MAXNAMELEN
,
ncvars
[
ncvarid
].
longname
);
}
else
if
(
mem
cmp
(
attname
,
"standard_name"
,
13
)
==
0
)
else
if
(
str
cmp
(
attname
,
"standard_name"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
MAXNAMELEN
,
ncvars
[
ncvarid
].
stdname
);
}
else
if
(
mem
cmp
(
attname
,
"units"
,
5
)
==
0
)
else
if
(
str
cmp
(
attname
,
"units"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
MAXNAMELEN
,
ncvars
[
ncvarid
].
units
);
}
else
if
(
mem
cmp
(
attname
,
"calendar"
,
8
)
==
0
)
else
if
(
str
cmp
(
attname
,
"calendar"
)
==
0
)
{
ncvars
[
ncvarid
].
calendar
=
TRUE
;
}
else
if
(
mem
cmp
(
attname
,
"code"
,
4
)
==
0
)
else
if
(
str
cmp
(
attname
,
"code"
)
==
0
)
{
cdfGetAttInt
(
fileID
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
code
);
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
mem
cmp
(
attname
,
"table"
,
5
)
==
0
)
else
if
(
str
cmp
(
attname
,
"table"
)
==
0
)
{
cdfGetAttInt
(
fileID
,
ncvarid
,
attname
,
1
,
&
tablenum
);
if
(
tablenum
>
0
)
...
...
@@ -3934,35 +3932,35 @@ int cdfInqContents(int streamID)
}
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
mem
cmp
(
attname
,
"trunc_type"
,
10
)
==
0
)
else
if
(
str
cmp
(
attname
,
"trunc_type"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
attstringlen
-
1
,
attstring
);
if
(
memcmp
(
attstring
,
"Triangular"
,
attlen
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_SPECTRAL
;
}
else
if
(
mem
cmp
(
attname
,
"grid_type"
,
9
)
==
0
)
else
if
(
str
cmp
(
attname
,
"grid_type"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
attstringlen
-
1
,
attstring
);
if
(
mem
cmp
(
attstring
,
"gaussian reduced"
,
16
)
==
0
)
if
(
str
cmp
(
attstring
,
"gaussian reduced"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_GAUSSIAN_REDUCED
;
else
if
(
mem
cmp
(
attstring
,
"gaussian"
,
8
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"gaussian"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_GAUSSIAN
;
else
if
(
mem
cmp
(
attstring
,
"spectral"
,
8
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"spectral"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_SPECTRAL
;
else
if
(
mem
cmp
(
attstring
,
"trajectory"
,
10
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"trajectory"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_TRAJECTORY
;
else
if
(
mem
cmp
(
attstring
,
"generic"
,
7
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"generic"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_GENERIC
;
else
if
(
mem
cmp
(
attstring
,
"cell"
,
4
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"cell"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_CELL
;
else
if
(
mem
cmp
(
attstring
,
"curvilinear"
,
11
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"curvilinear"
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_CURVILINEAR
;
else
if
(
mem
cmp
(
attstring
,
"sinusoidal"
,
10
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"sinusoidal"
)
==
0
)
;
else
if
(
mem
cmp
(
attstring
,
"laea"
,
4
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"laea"
)
==
0
)
;
else
if
(
mem
cmp
(
attstring
,
"lcc2"
,
4
)
==
0
)
else
if
(
str
cmp
(
attstring
,
"lcc2"
)
==
0
)
;
else
{
...
...
@@ -3976,15 +3974,15 @@ int cdfInqContents(int streamID)
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
mem
cmp
(
attname
,
"trunc_count"
,
11
)
==
0
)
else
if
(
str
cmp
(
attname
,
"trunc_count"
)
==
0
)
{
cdfGetAttInt
(
fileID
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
truncation
);
}
else
if
(
mem
cmp
(
attname
,
"truncation"
,
10
)
==
0
)
else
if
(
str
cmp
(
attname
,
"truncation"
)
==
0
)
{
cdfGetAttInt
(
fileID
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
truncation
);
}
else
if
(
mem
cmp
(
attname
,
"add_offset"
,
11
)
==
0
)
else
if
(
str
cmp
(
attname
,
"add_offset"
)
==
0
)
{
if
(
atttype
!=
NC_CHAR
)
{
...
...
@@ -3997,7 +3995,7 @@ int cdfInqContents(int streamID)
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
}
else
if
(
mem
cmp
(
attname
,
"scale_factor"
,
12
)
==
0
)
else
if
(
str
cmp
(
attname
,
"scale_factor"
)
==
0
)
{
if
(
atttype
!=
NC_CHAR
)
{
...
...
@@ -4010,7 +4008,7 @@ int cdfInqContents(int streamID)
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
}
else
if
(
mem
cmp
(
attname
,
"bounds"
,
6
)
==
0
)
else
if
(
str
cmp
(
attname
,
"bounds"
)
==
0
)
{
int
status
,
ncboundsid
;
...
...
@@ -4027,7 +4025,7 @@ int cdfInqContents(int streamID)
else
Warning
(
func
,
"%s - %s"
,
nc_strerror
(
status
),
attstring
);
}
else
if
(
mem
cmp
(
attname
,
"cell_measures"
,
13
)
==
0
)
else
if
(
str
cmp
(
attname
,
"cell_measures"
)
==
0
)
{
char
*
pstring
,
*
cell_measures
=
NULL
,
*
cell_var
=
NULL
;
...
...
@@ -4067,7 +4065,7 @@ int cdfInqContents(int streamID)
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
/*
else if (
mem
cmp(attname, "coordinates"
, 11
) == 0 )
else if (
str
cmp(attname, "coordinates") == 0 )
{
char *pstring, *xvarname = NULL, *yvarname = NULL;
...
...
@@ -4091,8 +4089,8 @@ int cdfInqContents(int streamID)
cdfSetVar(ncvars, ncvarid, TRUE);
}
*/
else
if
(
mem
cmp
(
attname
,
"associate"
,
9
)
==
0
||
mem
cmp
(
attname
,
"coordinates"
,
11
)
==
0
)
else
if
(
str
cmp
(
attname
,
"associate"
)
==
0
||
str
cmp
(
attname
,
"coordinates"
)
==
0
)
{
int
status
;
char
*
pstring
,
*
varname
=
NULL
;
...
...
@@ -4129,7 +4127,7 @@ int cdfInqContents(int streamID)
}
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
mem
cmp
(
attname
,
"grid_mapping"
,
12
)
==
0
)
else
if
(
str
cmp
(
attname
,
"grid_mapping"
)
==
0
)
{
int
status
;
int
nc_gmap_id
;
...
...
@@ -4147,7 +4145,7 @@ int cdfInqContents(int streamID)
cdfSetVar
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
mem
cmp
(
attname
,
"positive"
,
8
)
==
0
)
else
if
(
str
cmp
(
attname
,
"positive"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
attstringlen
-
1
,
attstring
);
...
...
@@ -4161,8 +4159,8 @@ int cdfInqContents(int streamID)
ncdims
[
ncvars
[
ncvarid
].
dimids
[
0
]].
dimtype
=
Z_AXIS
;
}
}
else
if
(
mem
cmp
(
attname
,
"_FillValue"
,
10
)
==
0
||
mem
cmp
(
attname
,
"missing_value"
,
13
)
==
0
)
else
if
(
str
cmp
(
attname
,
"_FillValue"
)
==
0
||
str
cmp
(
attname
,
"missing_value"
)
==
0
)
{
if
(
atttype
!=
NC_CHAR
)
{
...
...
@@ -4171,7 +4169,7 @@ int cdfInqContents(int streamID)
/* cdfSetVar(ncvars, ncvarid, TRUE); */
}
}
else
if
(
mem
cmp
(
attname
,
"cdi"
,
3
)
==
0
)
else
if
(
str
cmp
(
attname
,
"cdi"
)
==
0
)
{
if
(
atttype
==
NC_CHAR
)
{
...
...
@@ -4184,7 +4182,7 @@ int cdfInqContents(int streamID)
}
}
}
else
if
(
mem
cmp
(
attname
,
"axis"
,
4
)
==
0
)
else
if
(
str
cmp
(
attname
,
"axis"
)
==
0
)
{
cdfGetAttText
(
fileID
,
ncvarid
,
attname
,
attstringlen
-
1
,
attstring
);
/* don't check attlen anymore because the meaning changed from COARDS to CF */
...
...
@@ -4793,6 +4791,22 @@ int cdfInqContents(int streamID)
{
ncvars
[
ncvarid
].
gridtype
=
GRID_CURVILINEAR
;
size
=
xsize
*
ysize
;
/* Check size of 2 dimensional coordinate variables */
{
int
dimid
;
size_t
dimsize1
,
dimsize2
;
dimid
=
ncvars
[
xvarid
].
dimids
[
0
];
cdf_inq_dimlen
(
fileID
,
dimid
,
&
dimsize1
);
dimid
=
ncvars
[
xvarid
].
dimids
[
1
];
cdf_inq_dimlen
(
fileID
,
dimid
,
&
dimsize2
);
if
(
dimsize1
*
dimsize2
!=
size
)
{
Warning
(
func
,
"Variable %s has unsupported array structure, skipped!"
,
ncvars
[
ncvarid
].
name
);
ncvars
[
ncvarid
].
isvar
=
-
1
;
continue
;
}
}
}
else
{
...
...
@@ -4842,6 +4856,22 @@ int cdfInqContents(int streamID)
{
ncvars
[
ncvarid
].
gridtype
=
GRID_CURVILINEAR
;
size
=
xsize
*
ysize
;
/* Check size of 2 dimensional coordinate variables */
{
int
dimid
;
size_t
dimsize1
,
dimsize2
;
dimid
=
ncvars
[
xvarid
].
dimids
[
0
];
cdf_inq_dimlen
(
fileID
,
dimid
,
&
dimsize1
);
dimid
=
ncvars
[
xvarid
].
dimids
[
1
];
cdf_inq_dimlen
(
fileID
,
dimid
,
&
dimsize2
);
if
(
dimsize1
*
dimsize2
!=
size
)
{
Warning
(
func
,
"Variable %s has unsupported array structure, skipped!"
,
ncvars
[
ncvarid
].
name
);
ncvars
[
ncvarid
].
isvar
=
-
1
;
continue
;
}
}
}
else
{
...
...
src/stream_grb.c
View file @
fd6de689
...
...
@@ -427,9 +427,10 @@ int gribTimeUnit(int *isec1)
switch
(
ISEC1_TimeUnit
)
{
case
ISEC1_TABLE4_MINUTE
:
timeunit
=
TUNIT_MINUTE
;
break
;
case
ISEC1_TABLE4_HOUR
:
timeunit
=
TUNIT_HOUR
;
break
;
case
ISEC1_TABLE4_DAY
:
timeunit
=
TUNIT_DAY
;
break
;
case
ISEC1_TABLE4_MINUTE
:
timeunit
=
TUNIT_MINUTE
;
break
;
case
ISEC1_TABLE4_QUARTER
:
timeunit
=
TUNIT_QUARTER
;
break
;
case
ISEC1_TABLE4_HOUR
:
timeunit
=
TUNIT_HOUR
;
break
;
case
ISEC1_TABLE4_DAY
:
timeunit
=
TUNIT_DAY
;
break
;
default:
if
(
lprint
)
{
...
...
@@ -1749,10 +1750,11 @@ void grbDefTime(int *isec1, int date, int time, int numavg, int timeID)
switch
(
taxisInqTunit
(
timeID
))
{
case
TUNIT_MINUTE
:
factor
=
60
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_MINUTE
;
break
;
case
TUNIT_HOUR
:
factor
=
3600
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_HOUR
;
break
;
case
TUNIT_DAY
:
factor
=
86400
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_DAY
;
break
;
default:
factor
=
3600
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_HOUR
;
break
;
case
TUNIT_MINUTE
:
factor
=
60
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_MINUTE
;
break
;
case
TUNIT_QUARTER
:
factor
=
900
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_QUARTER
;
break
;
case
TUNIT_HOUR
:
factor
=
3600
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_HOUR
;
break
;
case
TUNIT_DAY
:
factor
=
86400
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_DAY
;
break
;
default:
factor
=
3600
;
ISEC1_TimeUnit
=
ISEC1_TABLE4_HOUR
;
break
;
}
decode_date
(
date
,
&
year
,
&
month
,
&
day
);
decode_time
(
time
,
&
hour
,
&
minute
);
...
...
@@ -1808,9 +1810,10 @@ void grbDefTime(int *isec1, int date, int time, int numavg, int timeID)
/* ISEC1_TimeUnit = 0; */
switch
(
taxisInqTunit
(
timeID
))
{
case
TUNIT_MINUTE
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_MINUTE
;
break
;
case
TUNIT_HOUR
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_HOUR
;
break
;
case
TUNIT_DAY
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_DAY
;
break
;
case
TUNIT_MINUTE
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_MINUTE
;
break
;
case
TUNIT_QUARTER
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_QUARTER
;
break
;
case
TUNIT_HOUR
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_HOUR
;
break
;
case
TUNIT_DAY
:
ISEC1_TimeUnit
=
ISEC1_TABLE4_DAY
;
break
;
}
if
(
numavg
>
0
)
...
...
src/taxis.c
View file @
fd6de689
...
...
@@ -23,6 +23,7 @@ char *Timeunits[] = {
"days"
,
"months"
,
"years"
,
"quarter"
,
};
...
...
@@ -953,7 +954,7 @@ void decode_timevalue(int timeunit, double timevalue, int *days, int *secs)
}
}
static
void
encode_timevalue
(
int
days
,
int
secs
,
int
timeunit
,
double
*
timevalue
)
{
static
char
func
[]
=
"encode_timevalue"
;
...
...
@@ -967,6 +968,10 @@ void encode_timevalue(int days, int secs, int timeunit, double *timevalue)
{
*
timevalue
=
days
*
1440
.
+
secs
/
60
.;
}
else
if
(
timeunit
==
TUNIT_QUARTER
)
{
*
timevalue
=
days
*
1440
.
+
secs
/
60
.;
}
else
if
(
timeunit
==
TUNIT_HOUR
)
{
*
timevalue
=
days
*
24
.
+
secs
/
3600
.;
...
...
@@ -1049,7 +1054,7 @@ double vtime2timeval(int vdate, int vtime, TAXIS *taxis)
int
ryear
,
rmonth
;
int
year
,
month
,
day
,
hour
,
minute
;
int
rdate
,
rtime
;
double
value
;
double
value
=
0
;
int
timeunit
;
int
timeunit0
;
int
calendar
;
...
...
src/vlist_var.c
View file @
fd6de689
...
...
@@ -816,7 +816,11 @@ void vlistDefVarName(int vlistID, int varID, const char *name)
vlistCheckVarID
(
func
,
vlistID
,
varID
);
if
(
vlistptr
->
vars
[
varID
].
name
)
free
(
vlistptr
->
vars
[
varID
].
name
);
if
(
vlistptr
->
vars
[
varID
].
name
)
{
free
(
vlistptr
->
vars
[
varID
].
name
);
vlistptr
->
vars
[
varID
].
name
=
0
;
}
if
(
name
)
vlistptr
->
vars
[
varID
].
name
=
strdupx
(
name
);
}
...
...
@@ -846,7 +850,11 @@ void vlistDefVarLongname(int vlistID, int varID, const char *longname)
vlistCheckVarID
(
func
,
vlistID
,
varID
);
if
(
vlistptr
->
vars
[
varID
].
longname
)
free
(
vlistptr
->
vars
[
varID
].
longname
);
if
(
vlistptr
->
vars
[
varID
].
longname
)
{
free
(
vlistptr
->
vars
[
varID
].
longname
);
vlistptr
->
vars
[
varID
].
longname
=
0
;
}
if
(
longname
)
vlistptr
->
vars
[
varID
].
longname
=
strdupx
(
longname
);
}
...
...
@@ -861,7 +869,11 @@ void vlistDefVarStdname(int vlistID, int varID, const char *stdname)
vlistCheckVarID
(
func
,
vlistID
,
varID
);
if
(
vlistptr
->
vars
[
varID
].
stdname
)
free
(
vlistptr
->
vars
[
varID
].
stdname
);
if
(
vlistptr
->
vars
[
varID
].
stdname
)
{
free
(
vlistptr
->
vars
[
varID
].
stdname
);
vlistptr
->
vars
[
varID
].
stdname
=
0
;
}
if
(
stdname
)
vlistptr
->
vars
[
varID
].
stdname
=
strdupx
(
stdname
);
}
...
...
@@ -891,7 +903,11 @@ void vlistDefVarUnits(int vlistID, int varID, const char *units)
vlistCheckVarID
(
func
,
vlistID
,
varID
);
if
(
vlistptr
->
vars
[
varID
].
units
)
free
(
vlistptr
->
vars
[
varID
].
units
);
if
(
vlistptr
->
vars
[
varID
].
units
)
{
free
(
vlistptr
->
vars
[
varID
].
units
);
vlistptr
->
vars
[
varID
].
units
=
0
;
}
if
(
units
)
vlistptr
->
vars
[
varID
].
units
=
strdupx
(
units
);
}
...
...
@@ -1061,6 +1077,7 @@ void vlistDestroyVarName(int vlistID, int varID)
}
}
void
vlistDestroyVarLongname
(
int
vlistID
,
int
varID
)
{
static
char
func
[]
=
"vlistDestroyVarLongname"
;
...
...
@@ -1075,6 +1092,7 @@ void vlistDestroyVarLongname(int vlistID, int varID)
}
}
void
vlistDestroyVarStdname
(
int
vlistID
,
int
varID
)
{
static
char
func
[]
=
"vlistDestroyVarStdname"
;
...
...
@@ -1089,6 +1107,7 @@ void vlistDestroyVarStdname(int vlistID, int varID)
}
}
void
vlistDestroyVarUnits
(
int
vlistID
,
int
varID
)
{
static
char
func
[]
=
"vlistDestroyVarUnits"
;
...
...
src/zaxis.c
View file @
fd6de689
...
...
@@ -1236,13 +1236,13 @@ void zaxisPrint(int zaxisID)
fprintf
(
fp
,
"#
\n
"
);
fprintf
(
fp
,
"# zaxisID %d
\n
"
,
zaxisID
);
fprintf
(
fp
,
"#
\n
"
);
fprintf
(
fp
,
"zaxistype
:
%s
\n
"
,
zaxisNamePtr
(
type
));
fprintf
(
fp
,
"size
:
%d
\n
"
,
nlevels
);
if
(
zaxisptr
->
name
[
0
]
)
fprintf
(
fp
,
"name
:
%s
\n
"
,
zaxisptr
->
name
);
if
(
zaxisptr
->
longname
[
0
]
)
fprintf
(
fp
,
"longname
:
%s
\n
"
,
zaxisptr
->
longname
);
if
(
zaxisptr
->
units
[
0
]
)
fprintf
(
fp
,
"units
:
%s
\n
"
,
zaxisptr
->
units
);
fprintf
(
fp
,
"zaxistype
=
%s
\n
"
,
zaxisNamePtr
(
type
));
fprintf
(
fp
,
"size
=
%d
\n
"
,
nlevels
);
if
(
zaxisptr
->
name
[
0
]
)
fprintf
(
fp
,
"name
=
%s
\n
"
,
zaxisptr
->
name
);
if
(
zaxisptr
->
longname
[
0
]
)
fprintf
(
fp
,
"longname
=
%s
\n
"
,
zaxisptr
->
longname
);
if
(
zaxisptr
->
units
[
0
]
)
fprintf
(
fp
,
"units
=
%s
\n
"
,
zaxisptr
->
units
);
nbyte0
=
fprintf
(
fp
,
"levels
:
"
);
nbyte0
=
fprintf
(
fp
,
"levels
=
"
);
nbyte
=
nbyte0
;
for
(
levelID
=
0
;
levelID
<
nlevels
;
levelID
++
)
{
...
...
@@ -1261,7 +1261,7 @@ void zaxisPrint(int zaxisID)
{
double
level1
,
level2
;
nbyte
=
nbyte0
;
nbyte0
=
fprintf
(
stdout
,
"%32s
:
"
,
"bounds"
);
nbyte0
=
fprintf
(
stdout
,
"%32s
=
"
,
"bounds"
);
for
(
levelID
=
0
;
levelID
<
nlevels
;
levelID
++
)
{
if
(
nbyte
>
80
)
...
...
@@ -1285,14 +1285,14 @@ void zaxisPrint(int zaxisID)
vctsize
=
zaxisInqVctSize
(
zaxisID
);
vct
=
zaxisInqVctPtr
(
zaxisID
);