OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
write_global_metadata.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "hdf.h"
3 #include "MD_metadata.h"
4 #include "mapi.h"
5 #include "PGS_MODIS_35005.h"
6 
7 
8 PGSt_SMF_status write_global_metadata (MODFILE *mfile,
9  PGSt_MET_all_handles md_handles,
10  MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met,
11  MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
12 /*
13 !C***************************************************************************
14 
15 !Description: Function write_global_metadata assigns values of the ECS
16  Granule Inventory Metadata (MD_ECS_INV_MET_t)to metadata
17  attributes in memory and stores L1A Specific Metadata
18  (MD_L1A_SPECIFIC_MET_t) in the L1A file.
19 
20 !Input Parameters:
21  MODIFILE *mfile ** MODFILE structure **
22  PGSt_MET_all_handles md_handles ** metadata group in MCF **
23  MD_ECS_INV_MET_t *ecs_gra_inv_met ** ECS Granule Metadata **
24  MD_L1A_SPECIFIC_MET_t *l1a_specific_met ** L1A Specific Metadata **
25 
26 !Output Parameters:
27  None
28 
29 Return Values:
30  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
31  MODIS_E_WRITE_GLOBAL_METADATA (PGS_MODIS_35005.h)
32 
33 Externally Defined:
34  MODFILE (mapi.h)
35  PGSt_MET_all_handles (PGS_MET.h)
36  MD_ECS_INV_MET_t (MD_metadata.h)
37  MD_L1A_SPECIFIC_MET_t (MD_metadata.h)
38 
39 Called By:
40  process_a_granule
41 
42 Routines Called:
43  write_ECS_metadata
44  write_specific_granule_metadata
45  log_fmt_msg
46 
47 !Revision History:
48 
49  revision 1.0 1997/08/21 17:30:00
50  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
51  Original development
52 
53 !Team-unique Header:
54  This software is developed by the MODIS Science Data Support
55  Team (SDST) for the National Aeronautics and Space Administration
56  (NASA), Goddard Space Flight Center (GSFC), under contract
57  NAS5-32373.
58 
59 !References and Credits:
60  None
61 
62 !Design Notes:
63  None
64 
65 
66 !END***************************************************************************
67 */
68 {
69  /****************************************************************************/
70  /* */
71  /* Define and Initialize Local Variables */
72  /* */
73  /****************************************************************************/
74 
75  char *routine = "write_global_metadata";
76  PGSt_SMF_status returnStatus;
77  PGSt_SMF_status L1A_status;
78 
79 
80  /****************************************************************************/
81  /* */
82  /* Set routine to "write_global_metadata" (done during declaration) */
83  /* */
84  /* Set returnStatus to MODIS_S_SUCCESS */
85  /* */
86  /****************************************************************************/
87 
88  returnStatus = MODIS_S_SUCCESS;
89 
90 
91  /****************************************************************************/
92  /* */
93  /* CALL write_ECS_metadata to set the ECS Granule Metadata attributes */
94  /* INPUT: md_handles, ecs_gra_inv_met */
95  /* OUTPUT: None */
96  /* RETURN: L1A_status */
97  /* */
98  /* IF L1A_status is not equal to MODIS_S_SUCCESS */
99  /* THEN */
100  /* Set returnStatus to MODIS_E_WRITE_GLOBAL_METADATA */
101  /* Set msg to "The ECS Granule Metadata attributes could not be set" */
102  /* CALL log_fmt_msg to report that not all of the ECS Granule Metadata */
103  /* attributes could be set */
104  /* INPUT: L1A_status, routine, msg */
105  /* OUTPUT: None */
106  /* RETURN: None */
107  /* ENDIF */
108  /* */
109  /****************************************************************************/
110 
111  L1A_status = write_ECS_metadata(md_handles,ecs_gra_inv_met);
112  if ( L1A_status != MODIS_S_SUCCESS)
113  {
114  returnStatus = MODIS_E_WRITE_GLOBAL_METADATA;
116  "The ECS Granule Metadata attributes could not be set");
117  }
118 
119 
120  /****************************************************************************/
121  /* */
122  /* CALL write_specific_granule_metadata to store the L1A Specific metadata */
123  /* in the L1A granule */
124  /* INPUT: mfile, l1a_specific_met */
125  /* OUTPUT: None */
126  /* RETURN: L1A_status */
127  /* */
128  /* IF L1A_status is not equal to MODIS_S_SUCCESS */
129  /* THEN */
130  /* Set returnStatus to MODIS_E_WRITE_GLOBAL_METADATA */
131  /* Set msg to "The L1A Specific Metadata could not be written to the */
132  /* L1A granule." */
133  /* CALL log_fmt_msg to report that not all of the L1A Specific Metadata */
134  /* could be written to the L1A granule */
135  /* INPUT: L1A_status, routine, msg */
136  /* OUTPUT: None */
137  /* RETURN: None */
138  /* ENDIF */
139  /* */
140  /****************************************************************************/
141 
142  L1A_status = write_specific_granule_metadata(mfile,l1a_specific_met);
143  if ( L1A_status != MODIS_S_SUCCESS)
144  {
145  returnStatus = MODIS_E_WRITE_GLOBAL_METADATA;
147  "The L1A Specific Metadata could not be written to the L1A granule");
148  }
149 
150 
151  /****************************************************************************/
152  /* */
153  /* RETURN returnStatus */
154  /* */
155  /****************************************************************************/
156  return(returnStatus);
157 }
PGSt_SMF_status write_specific_granule_metadata(MODFILE *mfile, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
#define MODIS_E_GATTRIB_FAILED
#define MODIS_E_WRITE_GLOBAL_METADATA
#define MODIS_E_MET_SETATTR_FAILED
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
PGSt_SMF_status write_ECS_metadata(PGSt_MET_all_handles md_handles, MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met)
#define MODIS_S_SUCCESS
PGSt_SMF_status write_global_metadata(MODFILE *mfile, PGSt_MET_all_handles md_handles, MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)