OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
write_specific_granule_metadata.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "PGS_MODIS_35005.h"
3 #include "mapi.h"
4 #include "hdf.h"
5 #include "MD_metadata.h"
6 
7 
8 PGSt_SMF_status write_specific_granule_metadata (MODFILE *mfile,
9  MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
10 /*
11 !C***************************************************************************
12 
13 !Description: Function write_specific_granule_metadata stores the L1A Specific
14  Metadata (MD_L1A_SPECIFIC_MET_t) in the L1A file.
15 
16 !Input Parameters:
17  MODFILE mfile ** Address of MODFILE
18  structure **
19  MD_L1A_SPECIFIC_MET_t l1a_specific_met ** L1A Specific Metadata
20  structure **
21 
22 !Output Parameters:
23  None
24 
25 Return Values:
26  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
27  MODIS_E_GATTRIB_FAILED (PGS_MODIS_35005.h)
28 
29 Externally Defined:
30  MODFILE (mapi.h)
31  MAPIOK (mapi.h)
32  MFAIL (mapi.h)
33  I32 (mapi.h)
34  TXT (mapi.h)
35  MD_L1A_SPECIFIC_MET_t (MD_metadata.h)
36  MD_NUM_SCANS_TXT (MD_metadata.h)
37  MD_NUM_DAY_SCANS_TXT (MD_metadata.h)
38  MD_NUM_NIGHT_SCANS_TXT (MD_metadata.h)
39  MD_MAX_TOTAL_FRAMES_TXT (MD_metadata.h)
40  MD_MAX_EARTH_FRAMES_TXT (MD_metadata.h)
41  MD_MAX_SD_FRAMES_TXT (MD_metadata.h)
42  MD_MAX_SRCA_FRAMES_TXT (MD_metadata.h)
43  MD_MAX_BB_FRAMES_TXT (MD_metadata.h)
44  MD_MAX_SV_FRAMES_TXT (MD_metadata.h)
45  MD_SCAN_TYPES_TXT (MD_metadata.h)
46  MD_INCOMPLETE_SCANS_TXT (MD_metadata.h)
47  MD_MISSING_PKTS_TXT (MD_metadata.h)
48  MD_BAD_CRC_PKTS_TXT (MD_metadata.h)
49  MD_DISCARDED_PKTS_TXT (MD_metadata.h)
50 
51 Called By:
52  write_global_metadata
53 
54 Routines Called:
55  putMODISfileinfo
56  log_fmt_msg
57 
58 !Revision History:
59 
60  revision 1.0 1997/08/21 17:30:00
61  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
62  Original development
63 
64 !Team-unique Header:
65  This software is developed by the MODIS Science Data Support
66  Team (SDST) for the National Aeronautics and Space Administration
67  (NASA), Goddard Space Flight Center (GSFC), under contract
68  NAS5-32373.
69 
70 !References and Credits:
71  None
72 
73 !Design Notes:
74  None
75 
76 !END***************************************************************************
77 */
78 
79 {
80  /****************************************************************************/
81  /* */
82  /* Define and Initialize Local Variables */
83  /* */
84  /****************************************************************************/
85 
86  PGSt_SMF_status returnStatus;
87  char *routine = "write_specific_granule_metadata";
88  char msg[300];
89  int mapiStatus;
90 
91 
92  /****************************************************************************/
93  /* */
94  /* Set routine to "write_specific_granule_metadata" (done during */
95  /* (declaration) */
96  /* Set msg to "Unable to set the attribute " */
97  /* Set returnStatus to MODIS_S_SUCCESS */
98  /* Set mapiStatus to MAPIOK */
99  /* */
100  /****************************************************************************/
101 
102  returnStatus = MODIS_S_SUCCESS;
103  mapiStatus = MAPIOK;
104 
105 
106  /****************************************************************************/
107  /* */
108  /* CALL putMODISfileinfo to store the Number of scans attribute */
109  /* INPUT: mfile, MD_NUM_SCANS_TXT, I32, 1, */
110  /* &MD_L1A_SPECIFIC_MET_t.num_scans */
111  /* OUTPUT: None */
112  /* RETURN: mapiStatus */
113  /* */
114  /* IF mapiStatus is equal to MFAIL */
115  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
116  /* CALL log_fmt_msg to report that the attribute could not be set */
117  /* INPUT: mapiStatus, routine, "%s%s\n", msg, NUM_SCANS */
118  /* OUTPUT: None */
119  /* RETURN: None */
120  /* ENDIF */
121  /* */
122  /****************************************************************************/
123 
124  if ((mapiStatus = putMODISfileinfo(mfile, MD_NUM_SCANS_TXT, I32, 1,
125  &(l1a_specific_met->num_scans))) == MFAIL)
126  {
127  returnStatus = MODIS_E_GATTRIB_FAILED;
128  sprintf(msg, "Unable to set the attribute %s", MD_NUM_SCANS_TXT);
130 
131  }
132 
133 
134  /****************************************************************************/
135  /* */
136  /* CALL putMODISfileinfo to store the Number of Day mode scans attribute */
137  /* INPUT: mfile, MD_NUM_DAY_SCANS_TXT, I32, 1, */
138  /* &MD_L1A_SPECIFIC_MET_t.num_day_scans */
139  /* OUTPUT: None */
140  /* RETURN: mapiStatus */
141  /* */
142  /* IF mapiStatus is equal to MFAIL */
143  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
144  /* CALL log_fmt_msg to report that the attribute could not be set */
145  /* INPUT: mapiStatus, routine, "%s%s\n", msg, NUM_DAY_SCANS */
146  /* OUTPUT: None */
147  /* RETURN: None */
148  /* ENDIF */
149  /* */
150  /****************************************************************************/
151 
152  if ((mapiStatus = putMODISfileinfo(mfile, MD_NUM_DAY_SCANS_TXT, I32, 1,
153  &(l1a_specific_met->num_day_scans))) == MFAIL)
154  {
155  returnStatus = MODIS_E_GATTRIB_FAILED;
156  sprintf(msg, "Unable to set the attribute %s", MD_NUM_DAY_SCANS_TXT);
158  }
159 
160 
161  /****************************************************************************/
162  /* */
163  /* CALL putMODISfileinfo to store the Number of Night mode scans attribute */
164  /* INPUT: mfile, MD_NUM_NIGHT_SCANS_TXT, I32, 1, */
165  /* &MD_L1A_SPECIFIC_MET_t.num_night_scans */
166  /* OUTPUT: None */
167  /* RETURN: mapiStatus */
168  /* */
169  /* IF mapiStatus is equal to MFAIL */
170  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
171  /* CALL log_fmt_msg to report that the attribute could not be set */
172  /* INPUT: mapiStatus, routine, "%s%s\n", msg, NUM_NITE_SCANS */
173  /* OUTPUT: None */
174  /* RETURN: None */
175  /* ENDIF */
176  /* */
177  /****************************************************************************/
178 
179  if ((mapiStatus = putMODISfileinfo(mfile, MD_NUM_NIGHT_SCANS_TXT, I32, 1,
180  &(l1a_specific_met->num_night_scans))) == MFAIL)
181  {
182  returnStatus = MODIS_E_GATTRIB_FAILED;
183  sprintf(msg, "Unable to set the attribute %s", MD_NUM_NIGHT_SCANS_TXT);
185  }
186 
187 
188  /****************************************************************************/
189  /* */
190  /* CALL putMODISfileinfo to store the Max Total Frames attribute */
191  /* INPUT: mfile, MD_MAX_TOTAL_FRAMES_TXT, I32, 1, */
192  /* &MD_L1A_SPECIFIC_MET_t.max_total_frames */
193  /* OUTPUT: None */
194  /* RETURN: mapiStatus */
195  /* */
196  /* IF mapiStatus is equal to MFAIL */
197  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
198  /* CALL log_fmt_msg to report that the attribute could not be set */
199  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MAX_TOTAL_FRAMES */
200  /* OUTPUT: None */
201  /* RETURN: None */
202  /* ENDIF */
203  /* */
204  /****************************************************************************/
205 
206  if ((mapiStatus = putMODISfileinfo(mfile, MD_MAX_TOTAL_FRAMES_TXT, I32, 1,
207  &(l1a_specific_met->max_total_frames))) == MFAIL)
208  {
209  returnStatus = MODIS_E_GATTRIB_FAILED;
210  sprintf(msg, "Unable to set the attribute %s", MD_MAX_TOTAL_FRAMES_TXT);
212  }
213 
214 
215  /****************************************************************************/
216  /* */
217  /* CALL putMODISfileinfo to store the Max Earth Frames attribute */
218  /* INPUT: mfile, MD_MAX_EARTH_FRAMES_TXT, I32, 1, */
219  /* &MD_L1A_SPECIFIC_MET_t.max_earth_frames */
220  /* OUTPUT: None */
221  /* RETURN: mapiStatus */
222  /* */
223  /* IF mapiStatus is equal to MFAIL */
224  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
225  /* CALL log_fmt_msg to report that the attribute could not be set */
226  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MAX_EARTH_FRAMES */
227  /* OUTPUT: None */
228  /* RETURN: None */
229  /* ENDIF */
230  /* */
231  /****************************************************************************/
232 
233  if ((mapiStatus = putMODISfileinfo(mfile, MD_MAX_EARTH_FRAMES_TXT, I32, 1,
234  &(l1a_specific_met->max_earth_frames))) == MFAIL)
235  {
236  returnStatus = MODIS_E_GATTRIB_FAILED;
237  sprintf(msg, "Unable to set the attribute %s", MD_MAX_EARTH_FRAMES_TXT);
239  }
240 
241 
242  /****************************************************************************/
243  /* */
244  /* CALL putMODISfileinfo to store the Max SD Frames attribute */
245  /* INPUT: mfile, MD_MAX_SD_FRAMES_TXT, I32, 1, */
246  /* &MD_L1A_SPECIFIC_MET_t.max_sd_frames */
247  /* OUTPUT: None */
248  /* RETURN: mapiStatus */
249  /* */
250  /* IF mapiStatus is equal to MFAIL */
251  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
252  /* CALL log_fmt_msg to report that the attribute could not be set */
253  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MAX_SD_FRAMES */
254  /* OUTPUT: None */
255  /* RETURN: None */
256  /* ENDIF */
257  /* */
258  /****************************************************************************/
259 
260  if ((mapiStatus = putMODISfileinfo(mfile, MD_MAX_SD_FRAMES_TXT, I32, 1,
261  &(l1a_specific_met->max_sd_frames))) == MFAIL)
262  {
263  returnStatus = MODIS_E_GATTRIB_FAILED;
264  sprintf(msg, "Unable to set the attribute %s", MD_MAX_SD_FRAMES_TXT);
266  }
267 
268 
269  /****************************************************************************/
270  /* */
271  /* CALL putMODISfileinfo to store the Max SRCA Frames attribute */
272  /* INPUT: mfile, MD_MAX_SRCA_FRAMES_TXT, I32, 1, */
273  /* &MD_L1A_SPECIFIC_MET_t.max_srca_frames */
274  /* OUTPUT: None */
275  /* RETURN: mapiStatus */
276  /* */
277  /* IF mapiStatus is equal to MFAIL */
278  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
279  /* CALL log_fmt_msg to report that the attribute could not be set */
280  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MAX_SRCA_FRAMES */
281  /* OUTPUT: None */
282  /* RETURN: None */
283  /* ENDIF */
284  /* */
285  /****************************************************************************/
286 
287  if ((mapiStatus = putMODISfileinfo(mfile, MD_MAX_SRCA_FRAMES_TXT, I32, 1,
288  &(l1a_specific_met->max_srca_frames))) == MFAIL)
289  {
290  returnStatus = MODIS_E_GATTRIB_FAILED;
291  sprintf(msg, "Unable to set the attribute %s", MD_MAX_SRCA_FRAMES_TXT);
293  }
294 
295 
296  /****************************************************************************/
297  /* */
298  /* CALL putMODISfileinfo to store the Max BB Frames attribute */
299  /* INPUT: mfile, MD_MAX_BB_FRAMES_TXT, I32, 1, */
300  /* &MD_L1A_SPECIFIC_MET_t.max_bb_frames */
301  /* OUTPUT: None */
302  /* RETURN: mapiStatus */
303  /* */
304  /* IF mapiStatus is equal to MFAIL */
305  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
306  /* CALL log_fmt_msg to report that the attribute could not be set */
307  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MAX_BB_FRAMES */
308  /* OUTPUT: None */
309  /* RETURN: None */
310  /* ENDIF */
311  /* */
312  /****************************************************************************/
313 
314  if ((mapiStatus = putMODISfileinfo(mfile, MD_MAX_BB_FRAMES_TXT, I32, 1,
315  &(l1a_specific_met->max_bb_frames))) == MFAIL)
316  {
317  returnStatus = MODIS_E_GATTRIB_FAILED;
318  sprintf(msg, "Unable to set the attribute %s", MD_MAX_BB_FRAMES_TXT);
320  }
321 
322 
323  /****************************************************************************/
324  /* */
325  /* CALL putMODISfileinfo to store the Max SV Frames attribute */
326  /* INPUT: mfile, MD_MAX_SV_FRAMES_TXT, I32, 1, */
327  /* &MD_L1A_SPECIFIC_MET_t.max_sv_frames */
328  /* OUTPUT: None */
329  /* RETURN: mapiStatus */
330  /* */
331  /* IF mapiStatus is equal to MFAIL */
332  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
333  /* CALL log_fmt_msg to report that the attribute could not be set */
334  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MAX_SV_FRAMES */
335  /* OUTPUT: None */
336  /* RETURN: None */
337  /* ENDIF */
338  /* */
339  /****************************************************************************/
340 
341  if ((mapiStatus = putMODISfileinfo(mfile, MD_MAX_SV_FRAMES_TXT, I32, 1,
342  &(l1a_specific_met->max_sv_frames))) == MFAIL)
343  {
344  returnStatus = MODIS_E_GATTRIB_FAILED;
345  sprintf(msg, "Unable to set the attribute %s", MD_MAX_SV_FRAMES_TXT);
347  }
348 
349 
350  /****************************************************************************/
351  /* */
352  /* CALL putMODISfileinfo to store the Scan Types in product attribute */
353  /* INPUT: mfile, MD_SCAN_TYPES_TXT, TXT, */
354  /* sizeof(MD_L1A_SPECIFIC_MET_t.scan_types_product), */
355  /* MD_L1A_SPECIFIC_MET_t.scan_types_product */
356  /* OUTPUT: None */
357  /* RETURN: mapiStatus */
358  /* */
359  /* IF mapiStatus is equal to MFAIL */
360  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
361  /* CALL log_fmt_msg to report that the attribute could not be set */
362  /* INPUT: mapiStatus, routine, "%s%s\n", msg, SCAN_TYPES_PRO */
363  /* OUTPUT: None */
364  /* RETURN: None */
365  /* ENDIF */
366  /* */
367  /****************************************************************************/
368 
369  if ((mapiStatus = putMODISfileinfo(mfile, MD_SCAN_TYPES_TXT, TXT,
370  sizeof(l1a_specific_met->scan_types_product),
371  &(l1a_specific_met->scan_types_product))) == MFAIL)
372  {
373  returnStatus = MODIS_E_GATTRIB_FAILED;
374  sprintf(msg, "Unable to set the attribute %s", MD_SCAN_TYPES_TXT);
376  }
377 
378 
379  /****************************************************************************/
380  /* */
381  /* CALL putMODISfileinfo to store the Incomplete Scans attribute */
382  /* INPUT: mfile, MD_INCOMPLETE_SCANS_TXT, I32, 1, */
383  /* &MD_L1A_SPECIFIC_MET_t.incomplete_scans */
384  /* OUTPUT: None */
385  /* RETURN: mapiStatus */
386  /* */
387  /* IF mapiStatus is equal to MFAIL */
388  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
389  /* CALL log_fmt_msg to report that the attribute could not be set */
390  /* INPUT: mapiStatus, routine, "%s%s\n", msg, INCOMPLETE_SCANS */
391  /* OUTPUT: None */
392  /* RETURN: None */
393  /* ENDIF */
394  /* */
395  /****************************************************************************/
396 
397  if ((mapiStatus = putMODISfileinfo(mfile, MD_INCOMPLETE_SCANS_TXT, I32, 1,
398  &(l1a_specific_met->incomplete_scans))) == MFAIL)
399  {
400  returnStatus = MODIS_E_GATTRIB_FAILED;
401  sprintf(msg, "Unable to set the attribute %s", MD_INCOMPLETE_SCANS_TXT);
403  }
404 
405 
406  /****************************************************************************/
407  /* */
408  /* CALL putMODISfileinfo to store the Missing Packets attribute */
409  /* INPUT: mfile, MD_MISSING_PKTS_TXT, I32, 1, */
410  /* &MD_L1A_SPECIFIC_MET_t.missing_packets */
411  /* OUTPUT: None */
412  /* RETURN: mapiStatus */
413  /* */
414  /* IF mapiStatus is equal to MFAIL */
415  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
416  /* CALL log_fmt_msg to report that the attribute could not be set */
417  /* INPUT: mapiStatus, routine, "%s%s\n", msg, MISSING_PKTS */
418  /* OUTPUT: None */
419  /* RETURN: None */
420  /* ENDIF */
421  /* */
422  /****************************************************************************/
423 
424  if ((mapiStatus = putMODISfileinfo(mfile, MD_MISSING_PKTS_TXT, I32, 1,
425  &(l1a_specific_met->missing_packets))) == MFAIL)
426  {
427  returnStatus = MODIS_E_GATTRIB_FAILED;
428  sprintf(msg, "Unable to set the attribute %s", MD_MISSING_PKTS_TXT);
430  }
431 
432 
433  /****************************************************************************/
434  /* */
435  /* CALL putMODISfileinfo to store the Packets with bad CRC attribute */
436  /* INPUT: mfile, MD_BAD_CRC_PKTS_TXT, I32, 1, */
437  /* &MD_L1A_SPECIFIC_MET_t.packets_bad_crc */
438  /* OUTPUT: None */
439  /* RETURN: mapiStatus */
440  /* */
441  /* IF mapiStatus is equal to MFAIL */
442  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
443  /* CALL log_fmt_msg to report that the attribute could not be set */
444  /* INPUT: mapiStatus, routine, "%s%s\n", msg, BAD_CRC_PKTS */
445  /* OUTPUT: None */
446  /* RETURN: None */
447  /* ENDIF */
448  /* */
449  /****************************************************************************/
450 
451  if ((mapiStatus = putMODISfileinfo(mfile, MD_BAD_CRC_PKTS_TXT, I32, 1,
452  &(l1a_specific_met->packets_bad_crc))) == MFAIL)
453  {
454  returnStatus = MODIS_E_GATTRIB_FAILED;
455  sprintf(msg, "Unable to set the attribute %s", MD_BAD_CRC_PKTS_TXT);
457  }
458 
459 
460  /****************************************************************************/
461  /* */
462  /* CALL putMODISfileinfo to store the Discarded packets attribute */
463  /* INPUT: mfile, MD_DISCARDED_PKTS_TXT, I32, 1, */
464  /* &MD_L1A_SPECIFIC_MET_t.discarded_packets */
465  /* OUTPUT: None */
466  /* RETURN: mapiStatus */
467  /* */
468  /* IF mapiStatus is equal to MFAIL */
469  /* Set returnStatus to MODIS_E_GATTRIB_FAILED */
470  /* CALL log_fmt_msg to report that the attribute could not be set */
471  /* INPUT: mapiStatus, routine, "%s%s\n", msg, DISCARDED_PKTS */
472  /* OUTPUT: None */
473  /* RETURN: None */
474  /* ENDIF */
475  /* */
476  /****************************************************************************/
477 
478  if ((mapiStatus = putMODISfileinfo(mfile, MD_DISCARDED_PKTS_TXT, I32, 1,
479  &(l1a_specific_met->discarded_packets))) == MFAIL)
480  {
481  returnStatus = MODIS_E_GATTRIB_FAILED;
482  sprintf(msg, "Unable to set the attribute %s", MD_DISCARDED_PKTS_TXT);
484  }
485 
486 
487  /****************************************************************************/
488  /* */
489  /* RETURN returnStatus */
490  /* */
491  /****************************************************************************/
492 
493  return (returnStatus);
494 
495 }
496 
char scan_types_product[10]
Definition: MD_metadata.h:203
#define MD_MAX_SD_FRAMES_TXT
Definition: MD_metadata.h:83
#define MD_MISSING_PKTS_TXT
Definition: MD_metadata.h:89
#define MODIS_E_GATTRIB_FAILED
#define MD_NUM_SCANS_TXT
Definition: MD_metadata.h:78
#define MD_INCOMPLETE_SCANS_TXT
Definition: MD_metadata.h:88
#define MD_BAD_CRC_PKTS_TXT
Definition: MD_metadata.h:90
PGSt_SMF_status write_specific_granule_metadata(MODFILE *mfile, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
#define MD_MAX_SRCA_FRAMES_TXT
Definition: MD_metadata.h:84
#define MD_NUM_DAY_SCANS_TXT
Definition: MD_metadata.h:79
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
#define MD_MAX_TOTAL_FRAMES_TXT
Definition: MD_metadata.h:81
#define MD_MAX_SV_FRAMES_TXT
Definition: MD_metadata.h:86
#define MD_MAX_BB_FRAMES_TXT
Definition: MD_metadata.h:85
#define MD_DISCARDED_PKTS_TXT
Definition: MD_metadata.h:91
#define MODIS_S_SUCCESS
string msg
Definition: mapgen.py:227
#define MD_SCAN_TYPES_TXT
Definition: MD_metadata.h:87
#define MD_NUM_NIGHT_SCANS_TXT
Definition: MD_metadata.h:80
#define MD_MAX_EARTH_FRAMES_TXT
Definition: MD_metadata.h:82