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
d713c9aa
Commit
d713c9aa
authored
Apr 18, 2013
by
Uwe Schulzweida
Browse files
added function vlistDefVarExtra() and vlistInqVarExtra()
parent
dd71d42a
Changes
5
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
d713c9aa
2013-04-18 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added function vlistDefVarExtra() and vlistInqVarExtra()
2013-04-04 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* vlistDefVarDatatype: changed default missing values of signed integers to -TYPE_MAX
...
...
src/cdi.h
View file @
d713c9aa
...
...
@@ -503,6 +503,12 @@ void vlistDefVarMissval(int vlistID, int varID, double missval);
/* vlistInqVarMissval: Get the missing value of a Variable */
double
vlistInqVarMissval
(
int
vlistID
,
int
varID
);
/* vlistDefVarExtra: Define extra information of a Variable */
void
vlistDefVarExtra
(
int
vlistID
,
int
varID
,
const
char
*
extra
);
/* vlistInqVarExtra: Get extra information of a Variable */
void
vlistInqVarExtra
(
int
vlistID
,
int
varID
,
char
*
extra
);
void
vlistDefVarScalefactor
(
int
vlistID
,
int
varID
,
double
scalefactor
);
double
vlistInqVarScalefactor
(
int
vlistID
,
int
varID
);
void
vlistDefVarAddoffset
(
int
vlistID
,
int
varID
,
double
addoffset
);
...
...
src/stream_cdf.c
View file @
d713c9aa
...
...
@@ -105,6 +105,7 @@ typedef struct {
char
longname
[
CDI_MAX_NAME
];
char
stdname
[
CDI_MAX_NAME
];
char
units
[
CDI_MAX_NAME
];
char
extra
[
CDI_MAX_NAME
];
ensinfo_t
*
ensdata
;
/* Ensemble information */
}
ncvar_t
;
...
...
@@ -4100,6 +4101,7 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
ncvars
[
ncvarid
].
longname
[
0
]
=
0
;
ncvars
[
ncvarid
].
stdname
[
0
]
=
0
;
ncvars
[
ncvarid
].
units
[
0
]
=
0
;
ncvars
[
ncvarid
].
extra
[
0
]
=
0
;
ncvars
[
ncvarid
].
natts
=
0
;
ncvars
[
ncvarid
].
atts
=
NULL
;
ncvars
[
ncvarid
].
deflate
=
0
;
...
...
@@ -4402,6 +4404,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
#if defined (HAVE_NETCDF4)
if
(
format
==
NC_FORMAT_NETCDF4_CLASSIC
||
format
==
NC_FORMAT_NETCDF4
)
{
char
buf
[
CDI_MAX_NAME
];
int
shuffle
,
deflate
,
deflate_level
;
size_t
chunks
[
nvdims
];
int
storage_in
;
...
...
@@ -4414,10 +4417,20 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
{
ncvars
[
ncvarid
].
chunked
=
1
;
for
(
int
i
=
0
;
i
<
nvdims
;
++
i
)
ncvars
[
ncvarid
].
chunks
[
i
]
=
chunks
[
i
];
/*
printf("storage %d %d %d\n", storage_in, NC_CONTIGUOUS, NC_CHUNKED);
for ( int i = 0; i < nvdims; ++i ) printf("chunk %d %d\n", i, chunks[i]);
*/
if
(
CDI_Debug
)
{
fprintf
(
stderr
,
"
\n
chunking %d %d %d
\n
chunks "
,
storage_in
,
NC_CONTIGUOUS
,
NC_CHUNKED
);
for
(
int
i
=
0
;
i
<
nvdims
;
++
i
)
fprintf
(
stderr
,
"%ld "
,
chunks
[
i
]);
fprintf
(
stderr
,
"
\n
"
);
}
strcat
(
ncvars
[
ncvarid
].
extra
,
"chunks="
);
for
(
int
i
=
nvdims
-
1
;
i
>=
0
;
--
i
)
{
sprintf
(
buf
,
"%ld"
,
(
long
)
chunks
[
i
]);
strcat
(
ncvars
[
ncvarid
].
extra
,
buf
);
if
(
i
>
0
)
strcat
(
ncvars
[
ncvarid
].
extra
,
"x"
);
}
strcat
(
ncvars
[
ncvarid
].
extra
,
" "
);
}
}
}
...
...
@@ -6142,6 +6155,11 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
free
(
ncvars
[
ncvarid
].
ensdata
);
ncvars
[
ncvarid
].
ensdata
=
NULL
;
}
if
(
ncvars
[
ncvarid
].
extra
!=
NULL
&&
ncvars
[
ncvarid
].
extra
[
0
]
!=
0
)
{
vlistDefVarExtra
(
vlistID
,
varID
,
ncvars
[
ncvarid
].
extra
);
}
}
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
...
...
src/vlist.h
View file @
d713c9aa
...
...
@@ -101,6 +101,7 @@ typedef struct
char
*
longname
;
char
*
stdname
;
char
*
units
;
char
*
extra
;
double
missval
;
double
scalefactor
;
double
addoffset
;
...
...
src/vlist_var.c
View file @
d713c9aa
...
...
@@ -50,6 +50,7 @@ void vlistvarInitEntry(int vlistID, int varID)
vlistptr
->
vars
[
varID
].
longname
=
NULL
;
vlistptr
->
vars
[
varID
].
stdname
=
NULL
;
vlistptr
->
vars
[
varID
].
units
=
NULL
;
vlistptr
->
vars
[
varID
].
extra
=
NULL
;
vlistptr
->
vars
[
varID
].
nlevs
=
0
;
vlistptr
->
vars
[
varID
].
levinfo
=
NULL
;
vlistptr
->
vars
[
varID
].
comptype
=
COMPRESS_NONE
;
...
...
@@ -1179,6 +1180,87 @@ void vlistDefVarMissval(int vlistID, int varID, double missval)
vlistptr
->
vars
[
varID
].
missvalused
=
TRUE
;
}
/*
@Function vlistDefVarExtra
@Title Define extra information of a Variable
@Prototype void vlistDefVarExtra(int vlistID, int varID, const char *extra)
@Parameter
@Item vlistID Variable list ID, from a previous call to @fref{vlistCreate}.
@Item varID Variable identifier.
@Item extra Extra information.
@Description
The function @func{vlistDefVarExtra} defines the extra information of a variable.
@EndFunction
*/
void
vlistDefVarExtra
(
int
vlistID
,
int
varID
,
const
char
*
extra
)
{
vlist_t
*
vlistptr
;
if
(
reshGetStatus
(
vlistID
,
&
vlist_ops
)
==
CLOSED
)
{
xwarning
(
"%s"
,
"Operation not executed."
);
return
;
}
vlistptr
=
vlist_to_pointer
(
vlistID
);
vlistCheckVarID
(
__func__
,
vlistID
,
varID
);
if
(
extra
)
{
if
(
vlistptr
->
vars
[
varID
].
extra
)
{
free
(
vlistptr
->
vars
[
varID
].
extra
);
vlistptr
->
vars
[
varID
].
extra
=
NULL
;
}
vlistptr
->
vars
[
varID
].
extra
=
strdupx
(
extra
);
}
}
/*
@Function vlistInqVarExtra
@Title Get extra information of a Variable
@Prototype void vlistInqVarExtra(int vlistID, int varID, char *extra)
@Parameter
@Item vlistID Variable list ID, from a previous call to @fref{vlistCreate}.
@Item varID Variable identifier.
@Item extra Returned variable extra information. The caller must allocate space for the
returned string. The maximum possible length, in characters, of
the string is given by the predefined constant @func{CDI_MAX_NAME}.
@Description
The function @func{vlistInqVarExtra} returns the extra information of a variable.
@Result
@func{vlistInqVarExtra} returns the extra information of the variable to the parameter extra if available,
otherwise the result is an empty string.
@EndFunction
*/
void
vlistInqVarExtra
(
int
vlistID
,
int
varID
,
char
*
extra
)
{
int
tableID
;
int
param
;
int
pdis
,
pcat
,
pnum
;
vlist_t
*
vlistptr
;
vlistptr
=
vlist_to_pointer
(
vlistID
);
vlistCheckVarID
(
__func__
,
vlistID
,
varID
);
if
(
vlistptr
->
vars
[
varID
].
extra
==
NULL
)
sprintf
(
extra
,
"-"
);
else
strcpy
(
extra
,
vlistptr
->
vars
[
varID
].
extra
);
return
;
}
int
vlistInqVarValidrange
(
int
vlistID
,
int
varID
,
double
*
validrange
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment