OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
read_g_attr.c
Go to the documentation of this file.
1 #include <string.h>
2 //#include "netcdf.h"
3 #include "mfhdf.h"
4 #include "l1io.h"
5 
6 int32 read_g_attr(l1info_struct l1info, char *name, int32 *n_type,
7  int32 *count, void *data)
8 /*******************************************************************
9 
10  read_g_attr
11 
12  purpose: read a global attribute to a waiting array (if size correct
13  and type is correct)
14 
15  Returns type: int32 - return status: 0 is good
16 
17  Parameters: (in calling order)
18  Type Name I/O Description
19  ---- ---- --- -----------
20  struct l1info_struct l1info I information struct
21  about the opened file
22  char * name I name of glabal attr to read
23  int32 n_type I number type expected using
24  HDF nomenclature
25  int32 * count I count of values
26  void* data O array of data from the
27  global attribute
28 
29  Modification history:
30  Programmer Date Description of change
31  ---------- ---- ---------------------
32  W. Robinson 5-Feb-1997 Original development
33 
34  *******************************************************************/
35  {
36  int32 attr_index;
37  char a_name[200];
38  int32 a_n_type, a_count;
39 
40  /*
41  * get the index for that attribute name
42  */
43  if ((attr_index = SDfindattr(l1info.sdfid, name))
44  == -1) {
45  printf("read_g_attr: Error in SDfindattr for attribute: '%s'\n",
46  name);
47  return -1;
48  }
49  /*
50  * find out about the attribute and be sure it is the type and size expected
51  */
52  if (SDattrinfo(l1info.sdfid, attr_index, a_name, &a_n_type, &a_count)
53  == -1) {
54  printf("read_g_attr: Error in SDattrinfo for attribute: '%s'\n",
55  name);
56  return -1;
57  }
58 
59  if (a_n_type != *n_type) {
60  printf(
61  "read_g_attr: attribute: '%s', difference in number type found\n",
62  name);
63  printf(" expected: %d, read: %d\n", *n_type, a_n_type);
64  return -1;
65  }
66 
67  if (a_count != *count) {
68  printf("read_g_attr: attribute: '%s', difference in count found\n",
69  name);
70  printf(" expected: %d, read: %d\n", *count, a_count);
71  }
72 
73  /*
74  * read in the stuff
75  */
76  if (SDreadattr(l1info.sdfid, attr_index, data) == -1) {
77  printf("read_g_attr: attribute: '%s', Error reading data\n",
78  name);
79  return -1;
80  }
81  return 0;
82 }
int32 read_g_attr(l1info_struct l1info, char *name, int32 *n_type, int32 *count, void *data)
Definition: read_g_attr.c:6
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
int count
Definition: decode_rs.h:79