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

add function tableInqParCode

parent ef5209f5
......@@ -5,6 +5,7 @@
* cdfInqContents: use coord vars from attr coordinates (bug report: Alberto Maurizi)
* gridPrint: print xfirst and xinc if xinc is constant
* gridGenYvals: try to calculate non global gaussian latitides
* add function tableInqParCode
* Version 0.9.7 released
2006-03-08 Uwe Schulzweida <schulzweida@dkrz.de>
......
......@@ -28,18 +28,18 @@ case "${HOSTNAME}" in
--with-netcdf=/scratch/localA/m214003/local \
CC=gcc CFLAGS="-ansi -g -O2 -Wall" CFINT=-Df2cFortran
;;
# sparc-sun-solaris2.6
regen | gardiken)
./configure --prefix=$HOME/local/SUN \
--with-netcdf=/pf/m/m214089/local/SUN \
CC=gcc CFLAGS="-g -O2 -Wall"
;;
# sparc-sun-solaris2.8
xxf)
./configure --prefix=$HOME/local/SUN \
--with-netcdf=/client \
CC=cc CFLAGS="-fast"
;;
# sparc-sun-solaris2.9
executor | yang | yin)
./configure --prefix=$HOME/local/SUN64 \
--with-netcdf=/scratch/small/m214/m214089/local/SunOS64 \
CC=cc CFLAGS="-g -mt -fast -xtarget=native -xarch=v9a"
;;
# sx6-nec-superux12.2
cs*)
./configure --prefix=$HOME/local \
......
......@@ -607,6 +607,7 @@ int tableInqModel(int tableID);
void tableInqPar(int tableID, int code, char *name, char *longname, char *units);
int tableInqParCode(int tableID, char *name, int *code);
int tableInqParName(int tableID, int code, char *name);
int tableInqParLongname(int tableID, int code, char *longname);
int tableInqParUnits(int tableID, int code, char *units);
......
......@@ -265,6 +265,10 @@ static void cdfGetAttText(int fileID, int ncvarid, char *attname, char *atttext,
if ( (int) attlen > maxlen ) attlen = maxlen;
memcpy(atttext, attbuf, attlen);
}
else
{
atttext[0] = 0;
}
}
#endif
......
......@@ -660,6 +660,7 @@ void tableWrite(const char *ptfile, int tableID)
fclose(ptfp);
}
void tableWriteC(const char *filename, int tableID)
{
static char func[] = "tableWriteC";
......@@ -746,6 +747,36 @@ void tableWriteC(const char *filename, int tableID)
fclose(ptfp);
}
int tableInqParCode(int tableID, char *varname, int *code)
{
int item, npars;
int err = 0;
npars = parTable[tableID].npars;
if ( tableID == UNDEFID || varname == NULL )
{
err = 1;
}
else
{
for ( item = 0; item < npars; item++ )
{
if ( parTable[tableID].pars[item].name )
if ( strcmp(parTable[tableID].pars[item].name, varname) == 0 )
{
*code = parTable[tableID].pars[item].id;
break;
}
}
if ( item == npars ) err = 1;
}
return (err);
}
int tableInqParName(int tableID, int code, char *varname)
{
int item, npars;
......@@ -774,6 +805,7 @@ int tableInqParName(int tableID, int code, char *varname)
return (err);
}
char *tableInqParNamePtr(int tableID, int code)
{
char *name = NULL;
......@@ -795,6 +827,7 @@ char *tableInqParNamePtr(int tableID, int code)
return (name);
}
char *tableInqParLongnamePtr(int tableID, int code)
{
char *longname = NULL;
......@@ -816,6 +849,7 @@ char *tableInqParLongnamePtr(int tableID, int code)
return (longname);
}
char *tableInqParUnitsPtr(int tableID, int code)
{
char *units = NULL;
......@@ -837,6 +871,7 @@ char *tableInqParUnitsPtr(int tableID, int code)
return (units);
}
int tableInqParLongname(int tableID, int code, char *longname)
{
int item, npars;
......@@ -865,6 +900,7 @@ int tableInqParLongname(int tableID, int code, char *longname)
return (err);
}
int tableInqParUnits(int tableID, int code, char *units)
{
int item, npars;
......@@ -893,6 +929,7 @@ int tableInqParUnits(int tableID, int code, char *units)
return (err);
}
void tableInqPar(int tableID, int code, char *name, char *longname, char *units)
{
int item, npars;
......
......@@ -5,7 +5,8 @@
# include "cdi_limits.h"
#endif
#define MAX_ATTRIBUTES 99
#define MAX_ATTRIBUTES 256
typedef struct
{
......@@ -15,6 +16,7 @@ typedef struct
}
LEVINFO;
typedef struct
{
int flag;
......@@ -43,6 +45,7 @@ typedef struct
}
VARINFO;
typedef struct
{
int self;
......@@ -66,6 +69,7 @@ typedef struct
}
VLIST;
VLIST *vlist_to_pointer(int vlistID);
int vlistNlock(int vlistID);
void vlistLock(int vlistID);
......
......@@ -318,12 +318,20 @@ int vlistInqVarCode(int vlistID, int varID)
{
static char func[] = "vlistInqVarCode";
VLIST *vlistptr;
int code;
vlistptr = vlist_to_pointer(vlistID);
vlistCheckVarID(func, vlistID, varID);
return (vlistptr->vars[varID].code);
code = vlistptr->vars[varID].code;
if ( code < 0 && vlistptr->vars[varID].tableID != -1 && vlistptr->vars[varID].name != NULL )
{
tableInqParCode(vlistptr->vars[varID].tableID, vlistptr->vars[varID].name, &code);
}
return (code);
}
......
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