OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
rdsdsid.c
Go to the documentation of this file.
1 #include <mfhdf.h>
2 #include "ancil.h"
3 #include "ancnrt_proto.h"
4 
5 /*****************************************************************
6  * Function: rdsdsid
7  * Purpose: return HDF Scientific Data Set (SDS) id value
8  * Description: read HDF Scientific Data Set (SDS) and return
9  * Reads one SDS at a time.
10  * Input parameters:
11  * Output parameters:
12  * Returns:
13  * Local variables:
14  * Subs called: HDF library routines
15  * History: none
16  * Note: similar to rdsds routine but only returns
17  * refid for a simple (single Vgroup level) SDS.
18  * Primarily used as a workaround to IDL not yet
19  * supporting the HDF structures. Perhaps this
20  * can be removed in the future.
21  *
22  * Author: Brian D. Schieber, GSC, 2/94
23  * Modification history:
24  *****************************************************************/
25 
26 int rdsdsid(fid, sdfid, vgname, sdslabel)
27 int32 fid, sdfid;
28 char *vgname;
29 char *sdslabel;
30 {
31  int j;
32  int32 vid, vg;
33  int32 sdsindex, sdsid;
34  int32 rank, numbertype;
35  int32 tagarray1[255], refarray1[255], nrefs1, nattrs1;
36  int32 dimsizes[2];
37  char lname[MAXNAMELNG];
38 
39  /* Open the Vgroup by name and fileid, attach to it and get the number
40  * and tag type (SDG, VH, etc) in it, loop over each item and find
41  * the ones that match the desired SDS and return SDSid.
42  */
43 
44  if ((vid = Vfind(fid, vgname)) <= 0) return (ERROR);
45  vg = Vattach(fid, vid, "r");
46  nrefs1 = Vntagrefs(vg);
47  nattrs1 = nrefs1;
48  Vgettagrefs(vg, tagarray1, refarray1, nattrs1);
49 
50  for (j = 0; j < nrefs1; j++) {
51  if ((tagarray1[j] == DFTAG_NDG) ||
52  (tagarray1[j] == DFTAG_SD)) { /* SDS found */
53  sdsindex = SDreftoindex(sdfid, refarray1[j]);
54  sdsid = SDselect(sdfid, sdsindex);
55  SDgetinfo(sdsid, lname, &rank, dimsizes, &numbertype,
56  &nattrs1);
57  if (!strcmp(sdslabel, lname)) {
58  Vdetach(vg);
59  return (sdsid); /* SUCCESS */
60  }
61  } /* tagarray1[j] */
62  } /* for j */
63  Vdetach(vg);
64  pwarning("SDS data id not found");
65  return (-1);
66 } /* rdsdsid */
67 
int j
Definition: decode_rs.h:73
int rdsdsid(int32 fid, int32 sdfid, char *vgname, char *sdslabel)
Definition: rdsdsid.c:26
int pwarning(char *string)
Definition: pexit.c:21
Extra metadata that will be written to the HDF4 file l2prod rank
#define MAXNAMELNG
Definition: ancil.h:43
#define ERROR
Definition: ancil.h:24