Commit 102c70ad authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Renamed cdiZaxisDefString to cdiZaxisDefKeyStr.

parent 07f7bf35
...@@ -986,8 +986,8 @@ void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE]); ...@@ -986,8 +986,8 @@ void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE]);
#define CDI_ZAXIS_LONGNAME 804 // Z-axis longname #define CDI_ZAXIS_LONGNAME 804 // Z-axis longname
#define CDI_ZAXIS_UNITS 805 // Z-axis units #define CDI_ZAXIS_UNITS 805 // Z-axis units
// cdiZaxisDefString: Define a CDI Z-axis string value from a key // cdiZaxisDefKeyStr: Define a CDI Z-axis string value from a key
int cdiZaxisDefString(int zaxisID, int key, int size, const char *mesg); int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg);
// cdiZaxisInqString: Get a CDI Z-axis string value from a key // cdiZaxisInqString: Get a CDI Z-axis string value from a key
int cdiZaxisInqString(int zaxisID, int key, int size, char *mesg); int cdiZaxisInqString(int zaxisID, int key, int size, char *mesg);
......
...@@ -420,7 +420,7 @@ FCALLSCSUB2 (zaxisInqUUID, ZAXISINQUUID, zaxisinquuid, INT, PVOID) ...@@ -420,7 +420,7 @@ FCALLSCSUB2 (zaxisInqUUID, ZAXISINQUUID, zaxisinquuid, INT, PVOID)
/* CDI zaxis string key values */ /* CDI zaxis string key values */
FCALLSCFUN4 (INT, cdiZaxisDefString, CDIZAXISDEFSTRING, cdizaxisdefstring, INT, INT, INT, STRING) FCALLSCFUN4 (INT, cdiZaxisDefKeyStr, CDIZAXISDEFSTRING, cdizaxisdefstring, INT, INT, INT, STRING)
FCALLSCFUN4 (INT, cdiZaxisInqString, CDIZAXISINQSTRING, cdizaxisinqstring, INT, INT, INT, PSTRING) FCALLSCFUN4 (INT, cdiZaxisInqString, CDIZAXISINQSTRING, cdizaxisinqstring, INT, INT, INT, PSTRING)
FCALLSCSUB2 (zaxisDefName, ZAXISDEFNAME, zaxisdefname, INT, STRING) FCALLSCSUB2 (zaxisDefName, ZAXISDEFNAME, zaxisdefname, INT, STRING)
FCALLSCSUB2 (zaxisInqName, ZAXISINQNAME, zaxisinqname, INT, PSTRING) FCALLSCSUB2 (zaxisInqName, ZAXISINQNAME, zaxisinqname, INT, PSTRING)
......
...@@ -162,8 +162,8 @@ void grid_init(grid_t *gridptr) ...@@ -162,8 +162,8 @@ void grid_init(grid_t *gridptr)
} }
static void static
grid_free_components(grid_t *gridptr) void grid_free_components(grid_t *gridptr)
{ {
void *p2free[] = { gridptr->mask, gridptr->mask_gme, void *p2free[] = { gridptr->mask, gridptr->mask_gme,
gridptr->x.vals, gridptr->y.vals, gridptr->x.vals, gridptr->y.vals,
...@@ -171,7 +171,7 @@ grid_free_components(grid_t *gridptr) ...@@ -171,7 +171,7 @@ grid_free_components(grid_t *gridptr)
gridptr->rowlon, gridptr->area, gridptr->rowlon, gridptr->area,
gridptr->reference, gridptr->name}; gridptr->reference, gridptr->name};
for (size_t i = 0; i < sizeof(p2free)/sizeof(p2free[0]); ++i) for ( size_t i = 0; i < sizeof(p2free)/sizeof(p2free[0]); ++i )
if ( p2free[i] ) Free(p2free[i]); if ( p2free[i] ) Free(p2free[i]);
} }
...@@ -187,7 +187,7 @@ grid_t *gridNewEntry(cdiResH resH) ...@@ -187,7 +187,7 @@ grid_t *gridNewEntry(cdiResH resH)
grid_t *gridptr = (grid_t*) Malloc(sizeof(grid_t)); grid_t *gridptr = (grid_t*) Malloc(sizeof(grid_t));
grid_init(gridptr); grid_init(gridptr);
if (resH == CDI_UNDEFID) if ( resH == CDI_UNDEFID )
gridptr->self = reshPut(gridptr, &gridOps); gridptr->self = reshPut(gridptr, &gridOps);
else else
{ {
...@@ -201,28 +201,26 @@ grid_t *gridNewEntry(cdiResH resH) ...@@ -201,28 +201,26 @@ grid_t *gridNewEntry(cdiResH resH)
static static
void gridInit(void) void gridInit(void)
{ {
static int gridInitialized = 0; static bool gridInitialized = false;
if ( gridInitialized ) return; if ( gridInitialized ) return;
gridInitialized = true;
gridInitialized = 1;
const char *env = getenv("GRID_DEBUG"); const char *env = getenv("GRID_DEBUG");
if ( env ) GRID_Debug = atoi(env); if ( env ) GRID_Debug = atoi(env);
} }
static void static
grid_copy_base_scalar_fields(grid_t *gridptrOrig, grid_t *gridptrDup) void grid_copy_base_scalar_fields(grid_t *gridptrOrig, grid_t *gridptrDup)
{ {
memcpy(gridptrDup, gridptrOrig, sizeof(grid_t)); memcpy(gridptrDup, gridptrOrig, sizeof(grid_t));
gridptrDup->self = CDI_UNDEFID; gridptrDup->self = CDI_UNDEFID;
if (gridptrOrig->reference) if ( gridptrOrig->reference )
gridptrDup->reference = strdupx(gridptrOrig->reference); gridptrDup->reference = strdupx(gridptrOrig->reference);
} }
static grid_t * static
grid_copy_base(grid_t *gridptrOrig) grid_t *grid_copy_base(grid_t *gridptrOrig)
{ {
grid_t *gridptrDup = (grid_t *)Malloc(sizeof (*gridptrDup)); grid_t *gridptrDup = (grid_t *)Malloc(sizeof (*gridptrDup));
gridptrOrig->vtable->copyScalarFields(gridptrOrig, gridptrDup); gridptrOrig->vtable->copyScalarFields(gridptrOrig, gridptrDup);
...@@ -609,14 +607,14 @@ int cdiGridDefKeyStr(int gridID, int key, int size, const char *mesg) ...@@ -609,14 +607,14 @@ int cdiGridDefKeyStr(int gridID, int key, int size, const char *mesg)
grid_t *gridptr = gridID2Ptr(gridID); grid_t *gridptr = gridID2Ptr(gridID);
char *gridstring = (char*)grid_key_to_ptr(gridptr, key); char *keyptr = (char*)grid_key_to_ptr(gridptr, key);
if ( gridstring == NULL ) if ( keyptr == NULL )
{ {
Warning("CDI grid string key %d not supported!", key); Warning("CDI grid string key %d not supported!", key);
return -1; return -1;
} }
gridSetString(gridstring, mesg, (size_t)size); gridSetString(keyptr, mesg, (size_t)size);
gridMark4Update(gridID); gridMark4Update(gridID);
return 0; return 0;
...@@ -649,14 +647,14 @@ int cdiGridInqKeyStr(int gridID, int key, int size, char *mesg) ...@@ -649,14 +647,14 @@ int cdiGridInqKeyStr(int gridID, int key, int size, char *mesg)
if ( size < 1 || mesg == NULL ) return -1; if ( size < 1 || mesg == NULL ) return -1;
grid_t *gridptr = gridID2Ptr(gridID); grid_t *gridptr = gridID2Ptr(gridID);
const char *gridstring = (const char*)grid_key_to_ptr(gridptr, key); const char *keyptr = (const char*)grid_key_to_ptr(gridptr, key);
if ( gridstring == NULL) if ( keyptr == NULL)
{ {
Warning("CDI grid string key %d not supported!", key); Warning("CDI grid string key %d not supported!", key);
return -1; return -1;
} }
gridGetString(mesg, gridstring, (size_t)size); gridGetString(mesg, keyptr, (size_t)size);
return 0; return 0;
} }
......
...@@ -2890,10 +2890,10 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int ...@@ -2890,10 +2890,10 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( is_scalar ) zaxisDefScalar(ncvar->zaxisID); if ( is_scalar ) zaxisDefScalar(ncvar->zaxisID);
if ( zdimid != -1 ) if ( zdimid != -1 )
cdiZaxisDefString(ncvar->zaxisID, CDI_ZAXIS_DIMNAME, (int)(strlen(ncdims[zdimid].name)+1), ncdims[zdimid].name); cdiZaxisDefKeyStr(ncvar->zaxisID, CDI_ZAXIS_DIMNAME, (int)(strlen(ncdims[zdimid].name)+1), ncdims[zdimid].name);
/* /*
if ( vdimid != -1 ) if ( vdimid != -1 )
cdiZaxisDefString(ncvar->zaxisID, CDI_ZAXIS_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name); cdiZaxisDefKeyStr(ncvar->zaxisID, CDI_ZAXIS_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name);
*/ */
Free(zvar); Free(zvar);
Free(lbounds); Free(lbounds);
......
...@@ -174,7 +174,7 @@ zaxis_t *zaxisNewEntry(int id) ...@@ -174,7 +174,7 @@ zaxis_t *zaxisNewEntry(int id)
zaxisDefaultValue ( zaxisptr ); zaxisDefaultValue ( zaxisptr );
if (id == CDI_UNDEFID) if ( id == CDI_UNDEFID )
zaxisptr->self = reshPut(zaxisptr, &zaxisOps); zaxisptr->self = reshPut(zaxisptr, &zaxisOps);
else else
{ {
...@@ -185,8 +185,8 @@ zaxis_t *zaxisNewEntry(int id) ...@@ -185,8 +185,8 @@ zaxis_t *zaxisNewEntry(int id)
return zaxisptr; return zaxisptr;
} }
static inline zaxis_t * static inline
zaxisID2Ptr(int id) zaxis_t *zaxisID2Ptr(int id)
{ {
return (zaxis_t *)reshGetVal(id, &zaxisOps); return (zaxis_t *)reshGetVal(id, &zaxisOps);
} }
...@@ -199,7 +199,7 @@ void zaxisInit(void) ...@@ -199,7 +199,7 @@ void zaxisInit(void)
if ( zaxisInitialized ) return; if ( zaxisInitialized ) return;
zaxisInitialized = true; zaxisInitialized = true;
char *env = getenv("ZAXIS_DEBUG"); const char *env = getenv("ZAXIS_DEBUG");
if ( env ) ZAXIS_Debug = atoi(env); if ( env ) ZAXIS_Debug = atoi(env);
} }
...@@ -248,7 +248,6 @@ zaxisCreate_(int zaxistype, int size, int id) ...@@ -248,7 +248,6 @@ zaxisCreate_(int zaxistype, int size, int id)
return zaxisID; return zaxisID;
} }
/* /*
@Function zaxisCreate @Function zaxisCreate
@Title Create a vertical Z-axis @Title Create a vertical Z-axis
...@@ -291,8 +290,7 @@ zaxisDefLevels(zaxisID, levs); ...@@ -291,8 +290,7 @@ zaxisDefLevels(zaxisID, levs);
*/ */
int zaxisCreate(int zaxistype, int size) int zaxisCreate(int zaxistype, int size)
{ {
if ( CDI_Debug ) if ( CDI_Debug ) Message("zaxistype: %d size: %d ", zaxistype, size);
Message("zaxistype: %d size: %d ", zaxistype, size);
zaxisInit (); zaxisInit ();
return zaxisCreate_(zaxistype, size, CDI_UNDEFID); return zaxisCreate_(zaxistype, size, CDI_UNDEFID);
...@@ -329,15 +327,14 @@ static void zaxisDestroyKernel( zaxis_t * zaxisptr ) ...@@ -329,15 +327,14 @@ static void zaxisDestroyKernel( zaxis_t * zaxisptr )
void zaxisDestroy(int zaxisID) void zaxisDestroy(int zaxisID)
{ {
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID); zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
zaxisDestroyKernel(zaxisptr);
zaxisDestroyKernel ( zaxisptr );
} }
static static
void zaxisDestroyP ( void * zaxisptr ) void zaxisDestroyP(void *zaxisptr)
{ {
zaxisDestroyKernel (( zaxis_t * ) zaxisptr ); zaxisDestroyKernel((zaxis_t *) zaxisptr);
} }
...@@ -374,22 +371,22 @@ void zaxisGetString(char *name, const char *zaxisstrname, size_t len) ...@@ -374,22 +371,22 @@ void zaxisGetString(char *name, const char *zaxisstrname, size_t len)
static static
char *zaxis_key_to_string(zaxis_t *zaxisptr, int key) char *zaxis_key_to_string(zaxis_t *zaxisptr, int key)
{ {
char *zaxisstring = NULL; char *keyptr = NULL;
switch (key) switch (key)
{ {
case CDI_ZAXIS_DIMNAME: zaxisstring = zaxisptr->dimname; break; case CDI_ZAXIS_DIMNAME: keyptr = zaxisptr->dimname; break;
case CDI_ZAXIS_VDIMNAME: zaxisstring = zaxisptr->vdimname; break; case CDI_ZAXIS_VDIMNAME: keyptr = zaxisptr->vdimname; break;
} }
return zaxisstring; return keyptr;
} }
/* /*
@Function cdiZaxisDefString @Function cdiZaxisDefKeyStr
@Title Define a CDI Z-axis string value from a key @Title Define a CDI Z-axis string value from a key
@Prototype int cdiZaxisDefString(int zaxisID, int key, int size, const char *mesg) @Prototype int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
@Parameter @Parameter
@Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate}. @Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate}.
@Item key The key to be searched @Item key The key to be searched
...@@ -397,27 +394,27 @@ char *zaxis_key_to_string(zaxis_t *zaxisptr, int key) ...@@ -397,27 +394,27 @@ char *zaxis_key_to_string(zaxis_t *zaxisptr, int key)
@Item mesg The address of a string where the data will be read @Item mesg The address of a string where the data will be read
@Description @Description
The function @func{cdiZaxisDefString} defines a CDI Z-axis string value from a key. The function @func{cdiZaxisDefKeyStr} defines a CDI Z-axis string value from a key.
@Result @Result
@func{cdiZaxisDefString} returns 0 if OK and integer value on error. @func{cdiZaxisDefKeyStr} returns 0 if OK and integer value on error.
@EndFunction @EndFunction
*/ */
int cdiZaxisDefString(int zaxisID, int key, int size, const char *mesg) int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
{ {
if ( size <= 0 || mesg == NULL || *mesg == 0 ) return -1; if ( size < 1 || mesg == NULL || *mesg == 0 ) return -1;
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID); zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
char *zaxisstring = zaxis_key_to_string(zaxisptr, key); char *keyptr = zaxis_key_to_string(zaxisptr, key);
if ( zaxisstring == NULL) if ( keyptr == NULL)
{ {
Warning("CDI zaxis string key %d not supported!", key); Warning("CDI zaxis string key %d not supported!", key);
return -1; return -1;
} }
zaxisSetString(zaxisstring, mesg, (size_t)size); zaxisSetString(keyptr, mesg, (size_t)size);
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE); reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
return 0; return 0;
...@@ -447,17 +444,17 @@ The function @func{cdiZaxisInqString} return a CDI Z-axis string value from a ke ...@@ -447,17 +444,17 @@ The function @func{cdiZaxisInqString} return a CDI Z-axis string value from a ke
*/ */
int cdiZaxisInqString(int zaxisID, int key, int size, char *mesg) int cdiZaxisInqString(int zaxisID, int key, int size, char *mesg)
{ {
if ( size <= 0 || mesg == NULL ) return -1; if ( size < 1 || mesg == NULL ) return -1;
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID); zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
const char *zaxisstring = zaxis_key_to_string(zaxisptr, key); const char *keyptr = zaxis_key_to_string(zaxisptr, key);
if ( zaxisstring == NULL) if ( keyptr == NULL)
{ {
Warning("CDI zaxis string key %d not supported!", key); Warning("CDI zaxis string key %d not supported!", key);
return -1; return -1;
} }
zaxisGetString(mesg, zaxisstring, (size_t)size); zaxisGetString(mesg, keyptr, (size_t)size);
return 0; return 0;
} }
......
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