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

Added function cdf_get_gmapvarname().

parent 532dbd4f
......@@ -282,6 +282,25 @@ void cdfDefLocalAtts(stream_t *streamptr)
if ( streamptr->ncmode == 2 ) cdf_enddef(fileID);
}
static
void cdf_get_gmapvarname(int gridID, char *gmapvarname)
{
char mapping[CDI_MAX_NAME]; mapping[0] = 0;
cdiGridInqKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, mapping);
if ( !mapping[0] )
{
int projID = gridInqProj(gridID);
if ( projID != CDI_UNDEFID ) cdiGridInqKeyStr(projID, CDI_KEY_MAPPING, CDI_MAX_NAME, mapping);
}
if ( mapping[0] )
{
cdiGridInqKeyStr(gridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, gmapvarname);
if ( !gmapvarname[0] ) strcpy(gmapvarname, "dummy");
}
}
static
int cdfDefVar(stream_t *streamptr, int varID)
{
......@@ -594,16 +613,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
else if ( gridtype == GRID_LAEA ) strcpy(gmapvarname, "laea");
else if ( gridtype == GRID_LCC2 ) strcpy(gmapvarname, "Lambert_Conformal");
else if ( gridtype == GRID_LONLAT && gridIsRotated(gridID) ) strcpy(gmapvarname, "rotated_pole");
else
{
char mapping[CDI_MAX_NAME]; mapping[0] = 0;
cdiGridInqKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, mapping);
if ( mapping[0] )
{
cdiGridInqKeyStr(gridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, gmapvarname);
if ( !gmapvarname[0] ) strcpy(gmapvarname, "dummy");
}
}
else cdf_get_gmapvarname(gridID, gmapvarname);
if ( gmapvarname[0] ) cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(gmapvarname), gmapvarname);
......
......@@ -2070,7 +2070,6 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
}
}
static
void cdfDefGrid(stream_t *streamptr, int gridID)
{
......@@ -2188,31 +2187,22 @@ void cdfDefVars(stream_t *streamptr)
Error("Internal problem! vlist undefined for streamptr %p", streamptr);
int ngrids = vlistNgrids(vlistID);
int nzaxis = vlistNzaxis(vlistID);
/*
if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
*/
if ( ngrids > 0 )
for ( int index = 0; index < ngrids; index++ )
{
int gridID = vlistGrid(vlistID, index);
cdfDefGrid(streamptr, gridID);
int projID = gridInqProj(gridID);
// if ( projID != CDI_UNDEFID ) cdfDefGrid(streamptr, projID);
}
int nzaxis = vlistNzaxis(vlistID);
if ( nzaxis > 0 )
for ( int index = 0; index < nzaxis; index++ )
{
int zaxisID = vlistZaxis(vlistID, index);
if ( streamptr->zaxisID[index] == UNDEFID ) cdfDefZaxis(streamptr, zaxisID);
}
/* define time first!!!
int nvars = vlistNvars(vlistID);
for ( int varID = 0; varID < nvars; varID++ )
{
int ncvarid = cdfDefVar(streamptr, varID);
}
*/
}
#endif
......
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