Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
d2f2c891
Commit
d2f2c891
authored
Nov 09, 2019
by
Uwe Schulzweida
Browse files
Replaced cdiZaxisDefKeyStr() by cdiDefKeyString() for CDI_KEY_PSNAME.
parent
071bcf51
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/cdi.h
View file @
d2f2c891
...
@@ -814,6 +814,12 @@ int cdiDefKeyInt(int cdiID, int varID, int key, int value);
...
@@ -814,6 +814,12 @@ int cdiDefKeyInt(int cdiID, int varID, int key, int value);
// cdiInqKeyInt: Get an integer value from a key of a CDI variable
// cdiInqKeyInt: Get an integer value from a key of a CDI variable
int
cdiInqKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
*
value
);
int
cdiInqKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
*
value
);
// cdiDefKeyFloat: Define a float value from a key of a CDI variable
int
cdiDefKeyFloat
(
int
cdiID
,
int
varID
,
int
key
,
double
value
);
// cdiInqKeyFloat Get a float value from a key of a CDI variable
int
cdiInqKeyFloat
(
int
cdiID
,
int
varID
,
int
key
,
double
*
value
);
// cdiDefKeyBytes: Define a bytes array from a key of a CDI variable
// cdiDefKeyBytes: Define a bytes array from a key of a CDI variable
int
cdiDefKeyBytes
(
int
cdiID
,
int
varID
,
int
key
,
const
unsigned
char
bytes
[],
int
length
);
int
cdiDefKeyBytes
(
int
cdiID
,
int
varID
,
int
key
,
const
unsigned
char
bytes
[],
int
length
);
...
@@ -843,9 +849,9 @@ int cdiCopyKeys(int cdiID1, int varID1, int cdiID2, int varID2);
...
@@ -843,9 +849,9 @@ int cdiCopyKeys(int cdiID1, int varID1, int cdiID2, int varID2);
#define CDI_KEY_LONGNAME 943 // Long name of the variable
#define CDI_KEY_LONGNAME 943 // Long name of the variable
#define CDI_KEY_STDNAME 944 // CF Standard name of the variable
#define CDI_KEY_STDNAME 944 // CF Standard name of the variable
#define CDI_KEY_UNITS 945 // Units of the variable
#define CDI_KEY_UNITS 945 // Units of the variable
#define CDI_KEY_PSNAME 950 // Z-axis surface pressure name
#define CDI_KEY_PSNAME
950 // Z-axis surface pressure name
#define CDI_KEY_P0NAME 951 // Z-axis reference pressure name
#define CDI_KEY_P0NAME
951 // Z-axis reference pressure name
#define CDI_KEY_P0VALUE 952 // Z-axis reference pressure in Pa
#define CDI_KEY_P0VALUE
952 // Z-axis reference pressure in Pa
// cdiZaxisDefKeyStr: Define a CDI Z-axis string value from a key
// cdiZaxisDefKeyStr: Define a CDI Z-axis string value from a key
int
cdiZaxisDefKeyStr
(
int
zaxisID
,
int
key
,
int
size
,
const
char
*
mesg
);
int
cdiZaxisDefKeyStr
(
int
zaxisID
,
int
key
,
int
size
,
const
char
*
mesg
);
...
@@ -853,12 +859,6 @@ int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg);
...
@@ -853,12 +859,6 @@ int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg);
// cdiZaxisInqKeyStr: Get a CDI Z-axis string value from a key
// cdiZaxisInqKeyStr: Get a CDI Z-axis string value from a key
int
cdiZaxisInqKeyStr
(
int
zaxisID
,
int
key
,
int
size
,
char
*
mesg
);
int
cdiZaxisInqKeyStr
(
int
zaxisID
,
int
key
,
int
size
,
char
*
mesg
);
// cdiZaxisDefKeyFlt: Define a CDI Z-axis floating point value from a key
int
cdiZaxisDefKeyFlt
(
int
zaxisID
,
int
key
,
double
value
);
// cdiZaxisInqKeyFlt: Get a CDI Z-axis floating point value from a key
int
cdiZaxisInqKeyFlt
(
int
zaxisID
,
int
key
,
double
*
value
);
// gridDefXname: Define the name of a X-axis
// gridDefXname: Define the name of a X-axis
void
gridDefXname
(
int
gridID
,
const
char
*
xname
);
void
gridDefXname
(
int
gridID
,
const
char
*
xname
);
...
...
src/cdi_key.c
View file @
d2f2c891
...
@@ -145,6 +145,10 @@ void cdiPrintVarKeys(cdi_keys_t *keysp)
...
@@ -145,6 +145,10 @@ void cdiPrintVarKeys(cdi_keys_t *keysp)
{
{
printf
(
"%d key %d length %d value %s
\n
"
,
keyid
+
1
,
keyp
->
key
,
keyp
->
length
,
keyp
->
v
.
s
);
printf
(
"%d key %d length %d value %s
\n
"
,
keyid
+
1
,
keyp
->
key
,
keyp
->
length
,
keyp
->
v
.
s
);
}
}
else
if
(
keyp
->
type
==
KEY_FLOAT
)
{
printf
(
"%d key %d value %g
\n
"
,
keyid
+
1
,
keyp
->
key
,
keyp
->
v
.
d
);
}
else
if
(
keyp
->
type
==
KEY_INT
)
else
if
(
keyp
->
type
==
KEY_INT
)
{
{
printf
(
"%d key %d value %d
\n
"
,
keyid
+
1
,
keyp
->
key
,
keyp
->
v
.
i
);
printf
(
"%d key %d value %d
\n
"
,
keyid
+
1
,
keyp
->
key
,
keyp
->
v
.
i
);
...
@@ -222,7 +226,25 @@ void cdiDefVarKeyInt(cdi_keys_t *keysp, int key, int value)
...
@@ -222,7 +226,25 @@ void cdiDefVarKeyInt(cdi_keys_t *keysp, int key, int value)
}
}
}
}
// cdiDefKeyInt: Define an integer value from a key of a CDI variable
/*
@Function cdiDefKeyInt
@Title Define an integer value from a key of a CDI variable
@Prototype int cdiDefKeyInt(int cdiID, int varID, int key, int value)
@Parameter
@Item cdiID CDI ID, from a previous call to @fref{vlistCreate}, @fref{gridCreate} or @fref{zaxisCreate}.
@Item varID Variable identifier or CDI_GLOBAL.
@Item key The key to be searched
@Item value An integer where the data will be read
@Description
The function @func{cdiDefKeyInt} defines a CDI integer value from a key.
@Result
@func{cdiDefKeyInt} returns CDI_NOERR if OK.
@EndFunction
*/
int
cdiDefKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
value
)
int
cdiDefKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
value
)
{
{
int
status
=
CDI_NOERR
;
int
status
=
CDI_NOERR
;
...
@@ -235,12 +257,30 @@ int cdiDefKeyInt(int cdiID, int varID, int key, int value)
...
@@ -235,12 +257,30 @@ int cdiDefKeyInt(int cdiID, int varID, int key, int value)
return
status
;
return
status
;
}
}
// cdiInqKeyInt: Get an integer value from a key of a CDI variable
/*
@Function cdiInqKeyInt
@Title Get a CDI floating point value from a key
@Prototype int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
@Parameter
@Item cdiID CDI ID, from a previous call to @fref{zaxisCreate}, @fref{gridCreate} or @fref{zaxisCreate}.
@Item varID Variable identifier or CDI_GLOBAL.
@Item key The key to be searched.
@Item value The address of an integer where the data will be retrieved.
@Description
The function @func{cdiInqKeyInt} return a CDI integer value from a key.
@Result
@func{cdiInqKeyInt} returns CDI_NOERR if key is available.
@EndFunction
*/
int
cdiInqKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
*
value
)
int
cdiInqKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
*
value
)
{
{
int
status
=
-
1
;
int
status
=
-
1
;
if
(
varID
!=
CDI_GLOBAL
)
status
=
cdiInqKeyInt
(
cdiID
,
CDI_GLOBAL
,
key
,
value
);
//
if ( varID != CDI_GLOBAL ) status = cdiInqKeyInt(cdiID, CDI_GLOBAL, key, value);
cdi_keys_t
*
keysp
=
cdi_get_keysp
(
cdiID
,
varID
);
cdi_keys_t
*
keysp
=
cdi_get_keysp
(
cdiID
,
varID
);
xassert
(
keysp
!=
NULL
);
xassert
(
keysp
!=
NULL
);
...
@@ -259,6 +299,94 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
...
@@ -259,6 +299,94 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
}
}
void
cdiDefVarKeyFloat
(
cdi_keys_t
*
keysp
,
int
key
,
double
value
)
{
cdi_key_t
*
keyp
=
find_key
(
keysp
,
key
);
if
(
keyp
==
NULL
)
keyp
=
new_key
(
keysp
,
key
);
if
(
keyp
!=
NULL
)
{
//if ( keyp->v.i != value )
{
keyp
->
type
=
KEY_INT
;
keyp
->
v
.
d
=
value
;
}
}
}
/*
@Function cdiDefKeyFloat
@Title Define a floating point value from a key of a CDI variable
@Prototype int cdiDefKeyFloat(int cdiID, int varID, int key, double value)
@Parameter
@Item cdiID CDI ID, from a previous call to @fref{vlistCreate}, @fref{gridCreate} or @fref{zaxisCreate}.
@Item varID Variable identifier or CDI_GLOBAL.
@Item key The key to be searched
@Item value A double where the data will be read
@Description
The function @func{cdiDefKeyFloat} defines a CDI floating point value from a key.
@Result
@func{cdiDefKeyFloat} returns CDI_NOERR if OK.
@EndFunction
*/
int
cdiDefKeyFloat
(
int
cdiID
,
int
varID
,
int
key
,
double
value
)
{
int
status
=
CDI_NOERR
;
cdi_keys_t
*
keysp
=
cdi_get_keysp
(
cdiID
,
varID
);
xassert
(
keysp
!=
NULL
);
cdiDefVarKeyFloat
(
keysp
,
key
,
value
);
return
status
;
}
/*
@Function cdiInqKeyFloat
@Title Get a CDI floating point value from a key
@Prototype int cdiInqKeyFloat(int cdiID, int varID, int key, double *value)
@Parameter
@Item cdiID CDI ID, from a previous call to @fref{zaxisCreate}, @fref{gridCreate} or @fref{zaxisCreate}.
@Item varID Variable identifier or CDI_GLOBAL.
@Item key The key to be searched.
@Item value The address of a double where the data will be retrieved.
@Description
The function @func{cdiInqKeyFloat} return a CDI floating point value from a key.
@Result
@func{cdiInqKeyFloat} returns CDI_NOERR if key is available.
@EndFunction
*/
int
cdiInqKeyFloat
(
int
cdiID
,
int
varID
,
int
key
,
double
*
value
)
{
int
status
=
-
1
;
// if ( varID != CDI_GLOBAL ) status = cdiInqKeyFloat(cdiID, CDI_GLOBAL, key, value);
cdi_keys_t
*
keysp
=
cdi_get_keysp
(
cdiID
,
varID
);
xassert
(
keysp
!=
NULL
);
cdi_key_t
*
keyp
=
find_key
(
keysp
,
key
);
if
(
keyp
!=
NULL
)
// key in use
{
if
(
keyp
->
type
==
KEY_FLOAT
)
{
*
value
=
keyp
->
v
.
d
;
status
=
CDI_NOERR
;
}
}
return
status
;
}
void
cdiDefVarKeyBytes
(
cdi_keys_t
*
keysp
,
int
key
,
const
unsigned
char
*
bytes
,
int
length
)
void
cdiDefVarKeyBytes
(
cdi_keys_t
*
keysp
,
int
key
,
const
unsigned
char
*
bytes
,
int
length
)
{
{
cdi_key_t
*
keyp
=
find_key
(
keysp
,
key
);
cdi_key_t
*
keyp
=
find_key
(
keysp
,
key
);
...
@@ -323,11 +451,11 @@ int cdiInqKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int *len
...
@@ -323,11 +451,11 @@ int cdiInqKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int *len
/*
/*
@Function cdiDefKeyString
@Function cdiDefKeyString
@Title Define a
CDI grid
string value from a key
@Title Define a string value from a key
of a CDI variable
@Prototype int cdiDefKeyString(int cdiID, int varID, int key, const char *string)
@Prototype int cdiDefKeyString(int cdiID, int varID, int key, const char *string)
@Parameter
@Parameter
@Item cdiID CDI ID, from a previous call to @fref{vlistCreate}
or
@fref{gridCreate}.
@Item cdiID CDI ID, from a previous call to @fref{vlistCreate}
,
@fref{gridCreate}
or @fref{zaxisCreate}
.
@Item varID Variable identifier or CDI_GLOBAL.
@Item varID Variable identifier or CDI_GLOBAL.
@Item key The key to be searched.
@Item key The key to be searched.
@Item string The address of a string where the data will be read.
@Item string The address of a string where the data will be read.
...
@@ -352,18 +480,18 @@ int cdiDefKeyString(int cdiID, int varID, int key, const char *string)
...
@@ -352,18 +480,18 @@ int cdiDefKeyString(int cdiID, int varID, int key, const char *string)
/*
/*
@Function cdiInqKeyString
@Function cdiInqKeyString
@Title Get a CDI
grid
string value from a key
@Title Get a CDI string value from a key
@Prototype int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length)
@Prototype int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length)
@Parameter
@Parameter
@Item cdiID CDI ID, from a previous call to @fref{vlistCreate}
or
@fref{gridCreate}.
@Item cdiID CDI ID, from a previous call to @fref{vlistCreate}
,
@fref{gridCreate}
or @fref{zaxisCreate}
.
@Item varID Variable identifier or CDI_GLOBAL.
@Item varID Variable identifier or CDI_GLOBAL.
@Item key The key to be searched.
@Item key The key to be searched.
@Item string The address of a string where the data will be retrieved.
@Item string The address of a string where the data will be retrieved.
The caller must allocate space for the returned string.
The caller must allocate space for the returned string.
@Item length The allocated length of the string on input.
@Item length The allocated length of the string on input.
@Description
@Description
The function @func{cdiInqKeyString} return a CDI
grid
string value from a key.
The function @func{cdiInqKeyString} return a CDI string value from a key.
@Result
@Result
@func{cdiInqKeyString} returns CDI_NOERR if key is available.
@func{cdiInqKeyString} returns CDI_NOERR if key is available.
...
...
src/cdi_key.h
View file @
d2f2c891
...
@@ -25,7 +25,9 @@ typedef struct {
...
@@ -25,7 +25,9 @@ typedef struct {
enum
{
KEY_INT
=
1
,
KEY_FLOAT
,
KEY_BYTES
};
enum
{
KEY_INT
=
1
,
KEY_FLOAT
,
KEY_BYTES
};
void
cdiDefVarKeyInt
(
cdi_keys_t
*
keysp
,
int
key
,
int
value
);
void
cdiDefVarKeyInt
(
cdi_keys_t
*
keysp
,
int
key
,
int
value
);
void
cdiDefVarKeyFloat
(
cdi_keys_t
*
keysp
,
int
key
,
double
value
);
void
cdiDefVarKeyBytes
(
cdi_keys_t
*
keysp
,
int
key
,
const
unsigned
char
*
bytes
,
int
length
);
void
cdiDefVarKeyBytes
(
cdi_keys_t
*
keysp
,
int
key
,
const
unsigned
char
*
bytes
,
int
length
);
cdi_key_t
*
find_key
(
cdi_keys_t
*
keysp
,
int
key
);
cdi_key_t
*
find_key
(
cdi_keys_t
*
keysp
,
int
key
);
const
char
*
cdiInqVarKeyStringPtr
(
cdi_keys_t
*
keysp
,
int
key
);
const
char
*
cdiInqVarKeyStringPtr
(
cdi_keys_t
*
keysp
,
int
key
);
...
...
src/stream_cdf_i.c
View file @
d2f2c891
...
@@ -2983,13 +2983,13 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
...
@@ -2983,13 +2983,13 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if
(
zaxisType
==
ZAXIS_HYBRID
)
if
(
zaxisType
==
ZAXIS_HYBRID
)
{
{
if
(
psvarid
!=
-
1
)
if
(
psvarid
!=
-
1
)
cdi
Zaxis
DefKeyStr
(
zaxisID
,
CDI_
KEY_PSNAME
,
(
int
)(
strlen
(
ncvars
[
psvarid
].
name
)
+
1
)
,
ncvars
[
psvarid
].
name
);
cdiDefKeyStr
ing
(
zaxisID
,
CDI_
GLOBAL
,
CDI_KEY_PSNAME
,
ncvars
[
psvarid
].
name
);
if
(
p0varid
!=
-
1
)
if
(
p0varid
!=
-
1
)
{
{
double
px
=
1
;
double
px
=
1
;
cdf_get_var_double
(
ncvars
[
p0varid
].
ncid
,
p0varid
,
&
px
);
cdf_get_var_double
(
ncvars
[
p0varid
].
ncid
,
p0varid
,
&
px
);
cdi
Zaxis
DefKeyFlt
(
zaxisID
,
CDI_KEY_P0VALUE
,
px
);
cdiDefKeyFl
oa
t
(
zaxisID
,
CDI_GLOBAL
,
CDI_KEY_P0VALUE
,
px
);
cdi
Zaxis
DefKeyStr
(
zaxisID
,
CDI_
KEY_P0NAME
,
(
int
)(
strlen
(
ncvars
[
p0varid
].
name
)
+
1
)
,
ncvars
[
p0varid
].
name
);
cdiDefKeyStr
ing
(
zaxisID
,
CDI_
GLOBAL
,
CDI_KEY_P0NAME
,
ncvars
[
p0varid
].
name
);
}
}
}
}
...
...
src/stream_cdf_o.c
View file @
d2f2c891
...
@@ -1214,17 +1214,19 @@ void cdf_def_zaxis_hybrid_cf(stream_t *streamptr, int type, int *ncvaridp, int z
...
@@ -1214,17 +1214,19 @@ void cdf_def_zaxis_hybrid_cf(stream_t *streamptr, int type, int *ncvaridp, int z
const
int
fileID
=
streamptr
->
fileID
;
const
int
fileID
=
streamptr
->
fileID
;
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
char
psname
[
CDI_MAX_NAME
];
psname
[
0
]
=
0
;
char
psname
[
CDI_MAX_NAME
];
cdiZaxisInqKeyStr
(
zaxisID
,
CDI_KEY_PSNAME
,
CDI_MAX_NAME
,
psname
);
int
length
=
CDI_MAX_NAME
;
cdiInqKeyString
(
zaxisID
,
CDI_GLOBAL
,
CDI_KEY_PSNAME
,
psname
,
&
length
);
if
(
psname
[
0
]
==
0
)
strcpy
(
psname
,
"ps"
);
if
(
psname
[
0
]
==
0
)
strcpy
(
psname
,
"ps"
);
char
p0name
[
CDI_MAX_NAME
];
p0name
[
0
]
=
0
;
char
p0name
[
CDI_MAX_NAME
];
p0name
[
0
]
=
0
;
double
p0value
=
1
;
double
p0value
=
1
;
int
p0varid
=
CDI_UNDEFID
;
int
p0varid
=
CDI_UNDEFID
;
const
int
p0status
=
cdi
Zaxis
InqKeyFlt
(
zaxisID
,
CDI_KEY_P0VALUE
,
&
p0value
);
const
int
p0status
=
cdiInqKeyFl
oa
t
(
zaxisID
,
CDI_GLOBAL
,
CDI_KEY_P0VALUE
,
&
p0value
);
if
(
p0status
==
0
)
if
(
p0status
==
CDI_NOERR
)
{
{
cdiZaxisInqKeyStr
(
zaxisID
,
CDI_KEY_P0NAME
,
CDI_MAX_NAME
,
p0name
);
length
=
CDI_MAX_NAME
;
cdiInqKeyString
(
zaxisID
,
CDI_GLOBAL
,
CDI_KEY_P0NAME
,
p0name
,
&
length
);
if
(
p0name
[
0
]
==
0
)
strcpy
(
p0name
,
"p0"
);
if
(
p0name
[
0
]
==
0
)
strcpy
(
p0name
,
"p0"
);
cdf_def_var
(
fileID
,
p0name
,
NC_DOUBLE
,
0
,
0
,
&
p0varid
);
cdf_def_var
(
fileID
,
p0name
,
NC_DOUBLE
,
0
,
0
,
&
p0varid
);
static
const
char
longname
[]
=
"reference pressure"
;
static
const
char
longname
[]
=
"reference pressure"
;
...
...
src/zaxis.c
View file @
d2f2c891
...
@@ -115,9 +115,6 @@ void zaxis_init(zaxis_t *zaxisptr)
...
@@ -115,9 +115,6 @@ void zaxis_init(zaxis_t *zaxisptr)
zaxisptr
->
self
=
CDI_UNDEFID
;
zaxisptr
->
self
=
CDI_UNDEFID
;
zaxisptr
->
dimname
[
0
]
=
0
;
zaxisptr
->
dimname
[
0
]
=
0
;
zaxisptr
->
vdimname
[
0
]
=
0
;
zaxisptr
->
vdimname
[
0
]
=
0
;
zaxisptr
->
psname
[
0
]
=
0
;
zaxisptr
->
p0name
[
0
]
=
0
;
zaxisptr
->
p0value
.
defined
=
false
;
zaxisptr
->
vals
=
NULL
;
zaxisptr
->
vals
=
NULL
;
#ifndef USE_MPI
#ifndef USE_MPI
zaxisptr
->
cvals
=
NULL
;
zaxisptr
->
cvals
=
NULL
;
...
@@ -357,9 +354,6 @@ void *zaxis_key_to_ptr(zaxis_t *zaxisptr, int key)
...
@@ -357,9 +354,6 @@ void *zaxis_key_to_ptr(zaxis_t *zaxisptr, int key)
{
{
case
CDI_KEY_DIMNAME
:
keyptr
=
(
void
*
)
zaxisptr
->
dimname
;
break
;
case
CDI_KEY_DIMNAME
:
keyptr
=
(
void
*
)
zaxisptr
->
dimname
;
break
;
case
CDI_KEY_VDIMNAME
:
keyptr
=
(
void
*
)
zaxisptr
->
vdimname
;
break
;
case
CDI_KEY_VDIMNAME
:
keyptr
=
(
void
*
)
zaxisptr
->
vdimname
;
break
;
case
CDI_KEY_PSNAME
:
keyptr
=
(
void
*
)
zaxisptr
->
psname
;
break
;
case
CDI_KEY_P0NAME
:
keyptr
=
(
void
*
)
zaxisptr
->
p0name
;
break
;
case
CDI_KEY_P0VALUE
:
keyptr
=
(
void
*
)
&
zaxisptr
->
p0value
;
break
;
}
}
return
keyptr
;
return
keyptr
;
...
@@ -442,79 +436,6 @@ int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
...
@@ -442,79 +436,6 @@ int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
return
0
;
return
0
;
}
}
/*
@Function cdiZaxisDefKeyFlt
@Title Define a CDI Z-axis floating point value from a key
@Prototype int cdiZaxisDefKeyFlt(int zaxisID, int key, double value)
@Parameter
@Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate}.
@Item key The key to be searched
@Item value A double where the data will be read
@Description
The function @func{cdiZaxisDefKeyFlt} defines a CDI Z-axis double value from a key.
@Result
@func{cdiZaxisDefKeyFlt} returns 0 if OK and integer value on error.
@EndFunction
*/
int
cdiZaxisDefKeyFlt
(
int
zaxisID
,
int
key
,
double
value
)
{
zaxis_t
*
zaxisptr
=
zaxis_to_pointer
(
zaxisID
);
zkey_double_t
*
keyptr
=
(
zkey_double_t
*
)
zaxis_key_to_ptr
(
zaxisptr
,
key
);
if
(
keyptr
==
NULL
)
{
Warning
(
"CDI zaxis double key %d not supported!"
,
key
);
return
-
1
;
}
keyptr
->
value
=
value
;
keyptr
->
defined
=
true
;
reshSetStatus
(
zaxisID
,
&
zaxisOps
,
RESH_DESYNC_IN_USE
);
return
0
;
}
/*
@Function cdiZaxisInqKeyFlt
@Title Get a CDI Z-axis floating point value from a key
@Prototype int cdiZaxisInqKeyFlt(int zaxisID, int key, double *value)
@Parameter
@Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate}.
@Item key The key to be searched.
@Item value The address of a double where the data will be retrieved.
@Description
The function @func{cdiZaxisInqKeyFlt} return a CDI Z-axis double value from a key.
@Result
@func{cdiZaxisInqKeyFlt} returns 0 if OK and integer value on error.
@EndFunction
*/
int
cdiZaxisInqKeyFlt
(
int
zaxisID
,
int
key
,
double
*
value
)
{
zaxis_t
*
zaxisptr
=
zaxis_to_pointer
(
zaxisID
);
zkey_double_t
*
keyptr
=
(
zkey_double_t
*
)
zaxis_key_to_ptr
(
zaxisptr
,
key
);
if
(
keyptr
==
NULL
)
{
Warning
(
"CDI zaxis double key %d not supported!"
,
key
);
return
-
1
;
}
if
(
!
keyptr
->
defined
)
return
1
;
*
value
=
keyptr
->
value
;
return
0
;
}
/*
/*
@Function zaxisDefName
@Function zaxisDefName
@Title Define the name of a Z-axis
@Title Define the name of a Z-axis
...
...
src/zaxis.h
View file @
d2f2c891
...
@@ -8,18 +8,10 @@
...
@@ -8,18 +8,10 @@
#include "cdi_key.h"
#include "cdi_key.h"
#include "cdi_att.h"
#include "cdi_att.h"
typedef
struct
{
double
value
;
bool
defined
;
}
zkey_double_t
;
typedef
struct
{
typedef
struct
{
char
dimname
[
CDI_MAX_NAME
];
char
dimname
[
CDI_MAX_NAME
];
char
vdimname
[
CDI_MAX_NAME
];
char
vdimname
[
CDI_MAX_NAME
];
char
psname
[
CDI_MAX_NAME
];
char
p0name
[
CDI_MAX_NAME
];
zkey_double_t
p0value
;
double
*
vals
;
double
*
vals
;
#ifndef USE_MPI
#ifndef USE_MPI
char
**
cvals
;
char
**
cvals
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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