OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
attr_disp.c
Go to the documentation of this file.
1 #include "fmt_check.h"
2 extern int verbose;
3 extern int fmt_status; /* status of check see fmt_check */
4 
5 void attr_disp(attr_str attr, u_data value, int a_count)
6 /*******************************************************************
7 
8  attr_disp
9 
10  purpose: ~utility to print the info for hdf attributes
11 
12  Returns type: none
13 
14  Parameters: (in calling order)
15  Type Name I/O Description
16  ---- ---- --- -----------
17  attr_str attr I attribute info for this
18  attribute
19  u_data value I actual value of the attribute
20  int a_count I actual count of data items
21  read
22 
23  Modification history:
24  Programmer Date Description of change
25  ---------- ---- ---------------------
26  W. Robinson 1-May-1995 Original development
27  W. Robinson 7-Jun-1995 add UINT8 case
28  W. Robinson 30-jun-1995 add verbose flag
29  W. Robinson 30-Jun-1995 set fmt_status if problems
30  W. Robinson 4-Oct-1995 for char data, print the # bytes
31  in field: a_count
32  W. Robinson 18-Sep-1996 for char data, use a temp string for
33  output and insert '?' in slots with
34  nulls so they fully print
35  W. Robinson 31-Oct-1996 upgrade to handle float64 data type
36  W. Robinson 18-Jul-1997 for copying character strings to tstr,
37  use memcpy
38 
39  *******************************************************************/ {
40  int32 j;
41  char *tstr;
42 
43  /*
44  * if vervose is on, write the attribute information
45  */
46  if (verbose == 0) return;
47 
48  /*
49  * depending on whether it is global or part of an SDS, write out slightly
50  * different information
51  */
52  if (strcmp(attr.obj_nm, "gbl") == 0) {
53  switch (attr.type) {
54  case DFNT_CHAR:
55  tstr = malloc(a_count + 1);
56  memcpy(tstr, value.chr, a_count);
57  *(tstr + a_count) = 0;
58  for (j = 0; j < (a_count - 1); j++)
59  if (*(tstr + j) == 0)
60  *(tstr + j) = '?';
61 
62  printf("'%s'(%d) is '%s'\n",
63  attr.access_nm, a_count, tstr);
64  free(tstr);
65  break;
66  case DFNT_FLOAT32:
67  for (j = 0; j < attr.count; j++) {
68  printf("'%s'[%d] is %f\n", attr.access_nm,
69  j, value.f32[j]);
70  }
71  break;
72  case DFNT_FLOAT64:
73  for (j = 0; j < attr.count; j++) {
74  printf("'%s'[%d] is %f\n", attr.access_nm,
75  j, value.f64[j]);
76  }
77  break;
78  case DFNT_INT16:
79  for (j = 0; j < attr.count; j++) {
80  printf("'%s'[%d] is %d\n", attr.access_nm,
81  j, value.i16[j]);
82  }
83  break;
84  case DFNT_INT32:
85  for (j = 0; j < attr.count; j++) {
86  printf("'%s'[%d] is %d\n", attr.access_nm,
87  j, value.i32[j]);
88  }
89  break;
90  case DFNT_INT8:
91  for (j = 0; j < attr.count; j++) {
92  printf("'%s'[%d] is %d\n", attr.access_nm,
93  j, value.i8[j]);
94  }
95  break;
96  case DFNT_UINT8:
97  for (j = 0; j < attr.count; j++) {
98  printf("'%s'[%d] is %d\n", attr.access_nm,
99  j, value.ui8[j]);
100  }
101  break;
102  default:
103  printf("************* Program Problem DEFAULT CASE OF VALUE CHECKING\n");
104  fmt_status = fmt_status | 1;
105  break;
106  }
107  } else {
108  switch (attr.type) {
109  case DFNT_CHAR:
110  tstr = malloc(a_count + 1);
111  strncpy(tstr, value.chr, a_count);
112  *(tstr + a_count) = 0;
113  for (j = 0; j < (a_count - 1); j++)
114  if (*(tstr + j) == 0)
115  *(tstr + j) = '?';
116 
117  printf("sds: '%s', attr '%s'(%d) is '%s'\n", attr.obj_nm,
118  attr.access_nm, a_count, tstr);
119  free(tstr);
120 
121  break;
122  case DFNT_FLOAT32:
123  for (j = 0; j < attr.count; j++) {
124  printf("sds: '%s', attr '%s'[%d] is %f\n", attr.obj_nm,
125  attr.access_nm, j, value.f32[j]);
126  }
127  break;
128  case DFNT_FLOAT64:
129  for (j = 0; j < attr.count; j++) {
130  printf("sds: '%s', attr '%s'[%d] is %f\n", attr.obj_nm,
131  attr.access_nm, j, value.f64[j]);
132  }
133  break;
134  case DFNT_INT16:
135  for (j = 0; j < attr.count; j++) {
136  printf("sds: '%s', attr '%s'[%d] is %d\n", attr.obj_nm,
137  attr.access_nm, j, value.i16[j]);
138  }
139  break;
140  case DFNT_INT32:
141  for (j = 0; j < attr.count; j++) {
142  printf("sds: '%s', attr '%s'[%d] is %d\n", attr.obj_nm,
143  attr.access_nm, j, value.i32[j]);
144  }
145  break;
146  default:
147  printf("************* Program Problem DEFAULT CASE OF VALUE CHECKING\n");
148  fmt_status = fmt_status | 1;
149  break;
150  }
151  }
152 }
int32 value
Definition: Granule.c:1235
int j
Definition: decode_rs.h:73
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT32
int fmt_status
Definition: fmt_check.c:7
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT16
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_FLOAT32
void attr_disp(attr_str attr, u_data value, int a_count)
Definition: attr_disp.c:5
int verbose
Definition: fmt_check.c:6