OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
end_eng_data_access_to_file.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "PGS_SMF.h"
3 #include "PGS_MODIS_35005.h"
4 #include "EN_eng_data.h"
5 #include "hdf.h"
6 #include "mapiL1A.h"
7 
8 
9 PGSt_SMF_status end_eng_data_access_to_file (MODFILE *L1A_file,
10  EN_VDATA_TYPE_t *eng_data)
11 
12 /*
13 !C************************************************************************
14 
15 !Description: This function is a driver for other Vdata cleanup functions.
16 
17 !Input Parameters:
18  EN_VDATA_TYPE_t *eng_data ** The Vdata array structure **
19 
20 !Output Parameters:
21  None
22 
23 !Input/Output Parameters:
24  MODFILE *L1A_file ** The Level 1A file **
25 
26 Return Values:
27  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
28  FAIL (hdf.h)
29 
30 Externally Defined:
31  PGSt_SMF_status (PGS_SMF.h)
32  EN_NUM_VDATAS (EN_eng_data.h)
33  EN_VDATA_TYPE_t (EN_eng_data.h)
34  MODIS_E_CLOSE_VDATA (PGS_MODIS_35005.h)
35  MODIS_E_END_VDATA_FILE (PGS_MODIS_35005.h)
36 
37 Called By:
38  process_a_granule
39 
40 Routines Called:
41  close_Vdata
42  end_Vdata_access_to_file
43  log_fmt_msg
44 
45 !Revision History:
46  Revision 1.1 1997/09/03 10:55
47  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
48  Incorporate walkthrough comments
49 
50  Revision 1.0 1997/07/14 15:58 EDT
51  David Catozzi/SAIC/GSC (cato@ltpmail.gsfc.nasa.gov)
52  Original design.
53 
54 !Team-unique Header:
55  This software is developed by the MODIS Science
56  Data Support Team (SDST) for the National Aeronautics
57  and Space Administration (NASA), Goddard Space Flight
58  Center (GSFC), under contract NAS5-32373.
59 
60 !References and Credits:
61  None
62 
63 !Design Notes:
64  None
65 
66 !END************************************************************************
67 */
68 
69 
70  {
71  /**************************************************************************/
72  /* */
73  /* Declare the local variables and initialize them. */
74  /* */
75  /**************************************************************************/
76  /* */
77  /* Set routine to "end_Vdata_access_to_file" */
78  /* */
79  /* Set returnStatus to MODIS_S_SUCCESS */
80  /* */
81  /**************************************************************************/
82 
83  PGSt_SMF_status returnStatus; /* SMF-style message returned by function */
84 
85  PGSt_SMF_status tempStatus; /* SMF-style message returned by function */
86 
87  char *routine = "end_eng_data_access_to_file";
88 
89  char msg[300];
90 
91  int i;
92 
93  /**************************************************************************/
94  /* */
95  /* set routine to "end_eng_data_access_to_file" (done during declaration)*/
96  /* */
97  /* set returnStatus to MODIS_S_SUCCESS */
98  /* */
99  /**************************************************************************/
100 
101  returnStatus = MODIS_S_SUCCESS;
102 
103 
104  /**************************************************************************/
105  /* */
106  /* DO FOR ( i = 0 to EN_NUM_VDATAS-1 ) */
107  /* */
108  /* set Vdata_name to eng_data[i].vdata_name */
109  /* */
110  /* CALL close_Vdata to detach it from the file */
111  /* INPUTS: Vdata_name */
112  /* OUTPUTS: None */
113  /* RETURN: tempstatus */
114  /* */
115  /* IF (tempstatus is FAIL) */
116  /* THEN */
117  /* set Status to MODIS_E_CLOSE_VDATA */
118  /* set msg to "close_Vdata failed (couldn't detach an eng_data */
119  /* Vdata)" */
120  /* CALL log_fmt_msg to report that the eng_data Vdata could not */
121  /* be detached from the HDF file */
122  /* INPUTS: Status, routine, msg */
123  /* OUTPUTS: None */
124  /* RETURN: None */
125  /* set returnStatus to FAIL */
126  /* ENDIF */
127  /* END DO */
128  /* */
129  /**************************************************************************/
130 
131  for (i=0; i < EN_NUM_VDATAS; i++)
132  {
133  tempStatus = close_Vdata(eng_data[i].vdata_name);
134  if (tempStatus == FAIL)
135  {
136  sprintf(msg, "Vdata Name: %s", eng_data[i].vdata_name);
138  returnStatus = FAIL;
139  }
140  }
141 
142 
143  /**************************************************************************/
144  /* */
145  /* set Vdata_name to "Discarded Packets" */
146  /* */
147  /* CALL close_Vdata to detach it from the file */
148  /* INPUTS: Vdata_name */
149  /* OUTPUTS: None */
150  /* RETURN: tempstatus */
151  /* */
152  /* IF (tempstatus is FAIL) */
153  /* THEN */
154  /* set Status to MODIS_E_CLOSE_VDATA */
155  /* set msg to "close_Vdata failed (couldn't detach the */
156  /* discarded_packets Vdata)" */
157  /* CALL log_fmt_msg report that the Discarded Packets Vdata could */
158  /* not be detached from the HDF file */
159  /* INPUTS: Status, routine, msg */
160  /* OUTPUTS: None */
161  /* RETURN: None */
162  /* set returnStatus to FAIL */
163  /* ENDIF */
164  /* */
165  /**************************************************************************/
166 
167  tempStatus = close_Vdata(M01DISCARDED_PACKETS);
168  if (tempStatus == FAIL)
169  {
170  log_fmt_msg(MODIS_E_CLOSE_VDATA, routine, "Vdata Name: discarded_packets");
171  returnStatus = FAIL;
172  }
173 
174 
175  /**************************************************************************/
176  /* */
177  /* CALL end_Vdata_access_to_file to do Vdata cleanup */
178  /* INPUTS: None */
179  /* OUTPUTS: None */
180  /* RETURN: tempstatus */
181  /* */
182  /* IF (tempstatus is FAIL) */
183  /* THEN */
184  /* set Status to MODIS_E_END_VDATA_FILE */
185  /* set msg to "end_vdata_access_to_file failed (couldn't do Vdata */
186  /* cleanup)" */
187  /* CALL log_fmt_msg to report that the Vdata cleanup failed */
188  /* INPUTS: Status, routine, msg */
189  /* OUTPUTS: None */
190  /* RETURN: None */
191  /* set returnStatus to FAIL */
192  /* ENDIF */
193  /* */
194  /**************************************************************************/
195 
196  tempStatus = end_Vdata_access_to_file(L1A_file);
197 
198  if (tempStatus == FAIL)
199  {
200  log_fmt_msg(MODIS_E_END_VDATA_FILE, routine, "");
201  returnStatus = FAIL;
202  }
203 
204 
205  /**************************************************************************/
206  /* */
207  /* return returnStatus */
208  /* */
209  /**************************************************************************/
210 
211  return (returnStatus);
212 
213  }
PGSt_SMF_status close_Vdata(char *Vdata_name)
Definition: close_Vdata.c:8
#define FAIL
Definition: ObpgReadGrid.h:18
#define MODIS_E_CLOSE_VDATA
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
PGSt_SMF_status end_eng_data_access_to_file(MODFILE *L1A_file, EN_VDATA_TYPE_t *eng_data)
#define MODIS_E_END_VDATA_FILE
PGSt_SMF_status end_Vdata_access_to_file(MODFILE *L1A_file)
#define EN_NUM_VDATAS
Definition: EN_eng_data.h:64
#define MODIS_S_SUCCESS
string msg
Definition: mapgen.py:227
int i
Definition: decode_rs.h:71