📄 gdapi.c
字号:
/* * If Vgroup with gridname and class GRID found, load tables */ if (strcmp(name, gridname) == 0 && strcmp(class, "GRID") == 0) { /* Attach to "Data Fields" and "Grid Attributes" Vgroups */ /* ----------------------------------------------------- */ tags = (int32 *) malloc(sizeof(int32) * 2); if(tags == NULL) { HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); return(-1); } refs = (int32 *) malloc(sizeof(int32) * 2); if(refs == NULL) { HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); free(tags); return(-1); } Vgettagrefs(vgid[0], tags, refs, 2); vgid[1] = Vattach(HDFfid, refs[0], acsCode); vgid[2] = Vattach(HDFfid, refs[1], acsCode); free(tags); free(refs); /* Setup External Arrays */ /* --------------------- */ for (i = 0; i < NGRID; i++) { /* Find empty entry in array */ /* ------------------------- */ if (GDXGrid[i].active == 0) { /* * Set gridID, Set grid entry active, Store root * Vgroup ID, Store sub Vgroup IDs, Store HDF-EOS * file ID */ gridID = i + idOffset; GDXGrid[i].active = 1; GDXGrid[i].IDTable = vgid[0]; GDXGrid[i].VIDTable[0] = vgid[1]; GDXGrid[i].VIDTable[1] = vgid[2]; GDXGrid[i].fid = fid; break; } } /* Get SDS interface ID */ /* -------------------- */ status = GDchkgdid(gridID, "GDattach", &dum, &sdInterfaceID, &dum); /* Get # of entries within Data Vgroup & search for SDS */ /* ---------------------------------------------------- */ nObjects = Vntagrefs(vgid[1]); if (nObjects > 0) { /* Get tag and ref # for Data Vgroup objects */ /* ----------------------------------------- */ tags = (int32 *) malloc(sizeof(int32) * nObjects); if(tags == NULL) { HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); return(-1); } refs = (int32 *) malloc(sizeof(int32) * nObjects); if(refs == NULL) { HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); free(tags); return(-1); } Vgettagrefs(vgid[1], tags, refs, nObjects); /* Count number of SDS & allocate SDS ID array */ /* ------------------------------------------- */ nSDS = 0; for (j = 0; j < nObjects; j++) { if (tags[j] == DFTAG_NDG) { nSDS++; } } GDXGrid[i].sdsID = (int32 *) calloc(nSDS, 4); if(GDXGrid[i].sdsID == NULL && nSDS != 0) { HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); free(tags); free(refs); return(-1); } nSDS = 0; /* Fill SDS ID array */ /* ----------------- */ for (j = 0; j < nObjects; j++) { /* If object is SDS then get id */ /* ---------------------------- */ if (tags[j] == DFTAG_NDG) { index = SDreftoindex(sdInterfaceID, refs[j]); sdid = SDselect(sdInterfaceID, index); GDXGrid[i].sdsID[nSDS] = sdid; nSDS++; GDXGrid[i].nSDS++; } } free(tags); free(refs); } break; } /* Detach Vgroup if not desired Grid */ /* --------------------------------- */ Vdetach(vgid[0]); } /* If Grid not found then set up error message */ /* ------------------------------------------- */ if (gridID == -1) { HEpush(DFE_RANGE, "GDattach", __FILE__, __LINE__); HEreport("Grid: \"%s\" does not exist within HDF file.\n", gridname); } } else { /* Too many files opened */ /* --------------------- */ gridID = -1; strcpy(errbuf, "No more than %d grids may be open simutaneously"); strcat(errbuf, " (%s)"); HEpush(DFE_DENIED, "GDattach", __FILE__, __LINE__); HEreport(errbuf, NGRID, gridname); } } return (gridID);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: GDchkgdid || || DESCRIPTION: || || || Return Value Type Units Description || ============ ====== ========= ===================================== || status intn return status (0) SUCCEED, (-1) FAIL || || INPUTS: || gridID int32 grid structure ID || routname char Name of routine calling GDchkgdid || || OUTPUTS: || fid int32 File ID || sdInterfaceID int32 SDS interface ID || gdVgrpID int32 grid Vgroup ID || || || OUTPUTS: || None || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Jun 96 Joel Gales Original Programmer || || END_PROLOG |-----------------------------------------------------------------------------*/intnGDchkgdid(int32 gridID, char *routname, int32 * fid, int32 * sdInterfaceID, int32 * gdVgrpID){ intn status = 0; /* routine return status variable */ uint8 access; /* Read/Write access code */ int32 gID; /* Grid ID - offset */ int32 idOffset = GDIDOFFSET; /* Grid ID offset */ char message1[] = "Invalid grid id: %d in routine \"%s\". ID must be >= %d and < %d.\n"; char message2[] = "Grid id %d in routine \"%s\" not active.\n"; /* Check for valid grid id */ if (gridID < idOffset || gridID >= NGRID + idOffset) { status = -1; HEpush(DFE_RANGE, "GDchkgdid", __FILE__, __LINE__); HEreport(message1, gridID, routname, idOffset, NGRID + idOffset); } else { /* Compute "reduced" ID */ /* -------------------- */ gID = gridID % idOffset; /* Check for active grid ID */ /* ------------------------ */ if (GDXGrid[gID].active == 0) { status = -1; HEpush(DFE_GENAPP, "GDchkgdid", __FILE__, __LINE__); HEreport(message2, gridID, routname); } else { /* Get file & SDS ids and Grid key */ /* -------------------------------- */ status = EHchkfid(GDXGrid[gID].fid, " ", fid, sdInterfaceID, &access); *gdVgrpID = GDXGrid[gID].IDTable; } } return (status);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: GDdefdim || || DESCRIPTION: Defines a new dimension within the grid. || || || Return Value Type Units Description || ============ ====== ========= ===================================== || status intn return status (0) SUCCEED, (-1) FAIL || || INPUTS: || gridID int32 grid structure ID || dimname char Dimension name to define || dim int32 Dimemsion value || || || OUTPUTS: || None || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Jun 96 Joel Gales Original Programmer || || END_PROLOG |-----------------------------------------------------------------------------*/intnGDdefdim(int32 gridID, char *dimname, int32 dim){ intn status; /* routine return status variable */ int32 fid; /* HDF-EOS file id */ int32 sdInterfaceID; /* HDF SDS interface ID */ int32 gdVgrpID; /* Grid root Vgroup ID */ int32 idOffset = GDIDOFFSET; /* Grid ID offset */ char gridname[80] /* Grid name */ ; /* Check for valid grid id */ status = GDchkgdid(gridID, "GDdefinedim", &fid, &sdInterfaceID, &gdVgrpID); /* Make sure dimension >= 0 */ /* ------------------------ */ if (dim < 0) { status = -1; HEpush(DFE_GENAPP, "GDdefdim", __FILE__, __LINE__); HEreport("Dimension value for \"%s\" less than zero: %d.\n", dimname, dim); } /* Write Dimension to Structural MetaData */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -