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

Version 0.9.7 released

parent e1fde012
2006-05-?? Uwe Schulzweida <schulzweida@dkrz.de>
2006-05-04 Uwe Schulzweida <schulzweida@dkrz.de>
* using GRIB library version 0.6.6
* cdfInqContents: check attlen for attname "axis"
* 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 global int attr support
* add function tableInqParCode
* Version 0.9.7 released
......
......@@ -3012,6 +3012,7 @@ int cdfInqContents(int streamID)
size_t attlen;
int ilev;
char name[256];
int attint;
char attname[256];
const int attstringlen = 1024; char attstring[1024];
char *pname, *plongname, *punits;
......@@ -3127,37 +3128,43 @@ int cdfInqContents(int streamID)
cdf_inq_attname(fileID, NC_GLOBAL, iatt, attname);
cdf_inq_atttype(fileID, NC_GLOBAL, attname, &xtype);
if ( xtype != NC_CHAR ) continue;
if ( strcmp(attname, "history") == 0 )
{
streams[streamID].historyID = iatt;
}
else if ( strcmp(attname, "institution") == 0 )
{
cdfGetAttText(fileID, NC_GLOBAL, attname, attstring, attstringlen);
instID = institutInq(0, 0, NULL, attstring);
if ( instID == UNDEFID )
instID = institutDef(0, 0, NULL, attstring);
}
else if ( strcmp(attname, "source") == 0 )
{
cdfGetAttText(fileID, NC_GLOBAL, attname, attstring, attstringlen);
modelID = modelInq(-1, 0, attstring);
}
else if ( strcmp(attname, "Conventions") == 0 )
{
}
else if ( strcmp(attname, "CDI") == 0 )
{
}
else if ( strcmp(attname, "CDO") == 0 )
if ( xtype == NC_CHAR )
{
if ( strcmp(attname, "history") == 0 )
{
streams[streamID].historyID = iatt;
}
else if ( strcmp(attname, "institution") == 0 )
{
cdfGetAttText(fileID, NC_GLOBAL, attname, attstring, attstringlen);
instID = institutInq(0, 0, NULL, attstring);
if ( instID == UNDEFID )
instID = institutDef(0, 0, NULL, attstring);
}
else if ( strcmp(attname, "source") == 0 )
{
cdfGetAttText(fileID, NC_GLOBAL, attname, attstring, attstringlen);
modelID = modelInq(-1, 0, attstring);
}
else if ( strcmp(attname, "Conventions") == 0 )
{
}
else if ( strcmp(attname, "CDI") == 0 )
{
}
else if ( strcmp(attname, "CDO") == 0 )
{
}
else
{
cdfGetAttText(fileID, NC_GLOBAL, attname, attstring, attstringlen);
vlistDefAttribute(vlistID, attname, attstring);
}
}
else
else if ( xtype == NC_INT )
{
cdfGetAttText(fileID, NC_GLOBAL, attname, attstring, attstringlen);
vlistDefAttribute(vlistID, attname, attstring);
cdfGetAttInt(fileID, NC_GLOBAL, attname, &attint);
vlistDefIntAttribute(vlistID, attname, attint);
}
}
......@@ -4633,6 +4640,7 @@ int cdfInqTimestep(int streamID, int tsID)
return ((int) nrecs);
}
void cdfEndDef(int streamID)
{
int varID, ncvarid;
......@@ -4652,6 +4660,7 @@ void cdfEndDef(int streamID)
}
}
void cdfDefInstitut(int streamID)
{
#if defined (HAVE_LIBNETCDF)
......@@ -4704,6 +4713,7 @@ void cdfDefSource(int streamID)
#endif
}
void cdfDefGlobalAtts(int streamID)
{
#if defined (HAVE_LIBNETCDF)
......@@ -4737,6 +4747,16 @@ void cdfDefGlobalAtts(int streamID)
cdfDefSource(streamID);
cdfDefInstitut(streamID);
if ( vlistptr->niatts > 0 )
{
if ( streams[streamID].ncmode == 2 ) cdf_redef(fileID);
for ( iatt = 0; iatt < vlistptr->niatts; iatt++ )
{
cdf_put_att_int(fileID, NC_GLOBAL, vlistptr->iattnames[iatt], NC_INT, 1L, &vlistptr->iatts[iatt]);
}
if ( streams[streamID].ncmode == 2 ) cdf_enddef(fileID);
}
streams[streamID].globalatts = 1;
#endif
}
......
......@@ -153,6 +153,7 @@ static void vlist_init_entry(VLIST *vlistptr)
vlistptr->tableID = cdiDefaultTableID;
vlistptr->varsAllocated = 0;
vlistptr->natts = 0;
vlistptr->niatts = 0;
vlistptr->ntsteps = CDI_UNDEFID;
}
......@@ -381,6 +382,12 @@ void vlistCopy(int vlistID2, int vlistID1)
vlistptr2->attstrings[attID] = NULL;
}
for ( attID = 0; attID < vlistptr1->niatts; attID++ )
{
vlistptr2->iattnames[attID] = strdupx(vlistptr1->iattnames[attID]);
vlistptr2->iatts[attID] = vlistptr1->iatts[attID];
}
if ( vlistptr1->vars )
{
int nvars = vlistptr1->nvars;
......@@ -574,6 +581,12 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
vlistptr2->attstrings[attID] = NULL;
}
for ( attID = 0; attID < vlistptr1->niatts; attID++ )
{
vlistptr2->iattnames[attID] = strdupx(vlistptr1->iattnames[attID]);
vlistptr2->iatts[attID] = vlistptr1->iatts[attID];
}
if ( vlistptr1->vars )
{
int nvars = vlistptr1->nvars;
......@@ -1507,7 +1520,7 @@ void vlistDefAttribute(int vlistID, const char *attname, const char *attstring)
else
{
for ( attID = 0; attID < vlistptr->natts; attID++ )
if ( strcmp(vlistptr->attnames[attID], attname ) == 0 )
if ( strcmp(vlistptr->attnames[attID], attname) == 0 )
{
if ( vlistptr->attstrings[attID] )
free(vlistptr->attstrings[attID]);
......@@ -1517,7 +1530,7 @@ void vlistDefAttribute(int vlistID, const char *attname, const char *attstring)
if ( attID == vlistptr->natts )
{
attID = vlistptr->natts++;
vlistptr->natts++;
vlistptr->attnames[attID] = strdupx(attname);
}
......@@ -1527,3 +1540,39 @@ void vlistDefAttribute(int vlistID, const char *attname, const char *attstring)
vlistptr->attstrings[attID] = NULL;
}
}
void vlistDefIntAttribute(int vlistID, const char *attname, int attint)
{
static char func[] = "vlistDefIntAttribute";
int attID;
VLIST *vlistptr;
vlistptr = vlist_to_pointer(vlistID);
vlist_check_ptr(func, vlistptr);
if ( attname == NULL ) return;
if ( (vlistptr->niatts + 1) == MAX_ATTRIBUTES )
{
Warning(func, "vlistID %d, maximum of %d int attributes reached!",
vlistID, MAX_ATTRIBUTES);
}
else
{
for ( attID = 0; attID < vlistptr->niatts; attID++ )
if ( strcmp(vlistptr->iattnames[attID], attname) == 0 )
{
break;
}
if ( attID == vlistptr->niatts )
{
vlistptr->niatts++;
vlistptr->iattnames[attID] = strdupx(attname);
}
vlistptr->iatts[attID] = attint;
}
}
......@@ -66,6 +66,9 @@ typedef struct
int natts;
char *attnames[MAX_ATTRIBUTES];
char *attstrings[MAX_ATTRIBUTES];
int niatts;
char *iattnames[MAX_ATTRIBUTES];
int iatts[MAX_ATTRIBUTES];
}
VLIST;
......@@ -85,4 +88,6 @@ void vlistDefVarTime(int vlistID, int varID, int timeID);
int vlistInqVarMissvalUsed(int vlistID, int varID);
int vlistHasTime(int vlistID);
void vlistDefIntAttribute(int vlistID, const char *attname, int attint);
#endif /* _VLIST_H */
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