OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
write_Vdata.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 "hdf.h"
5 #include "hdfi.h"
6 
7 
8 PGSt_SMF_status write_Vdata ( char *Vdata_name,
9  unsigned char *data,
10  int32 num_records )
11 
12 /*
13 !C************************************************************************
14 
15 !Description: This function writes to the specified Vdata in the currently
16  open hdf file, the Vdata values specified in data.
17 
18 !Input Parameters:
19  char *Vdata_name ** The name of the Vdata to write **
20  unsigned char *data ** The data to write (stored in a **
21  ** byte array) **
22  int32 num_records ** The number of records to write **
23 
24 !Output Parameters:
25  None
26 
27 Return Values:
28  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
29  MODIS_E_RECALL_ID (PGS_MODIS_35005.h)
30  MODIS_E_WRITE_VDATA (PGS_MODIS_35005.h)
31  FAIL (hdf.h)
32 
33 Externally Defined:
34  PGSt_SMF_status (PGS_SMF.h)
35  int32 (hdfi.h)
36  FULL_INTERLACE (hdf.h)
37 
38 Called By:
39  write_eng_data
40  write_failed_packets
41 
42 Routines Called:
43  recall_id
44  VSwrite
45  log_fmt_msg
46 
47 !Revision History:
48  Revision 2.0 1997/10/01 13:35 EDT
49  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
50  Originated Code.
51 
52  Revision 1.1 1997/09/03 10:55
53  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
54  Incorporate walkthrough comments
55 
56  Revision 1.0 1997/07/14 15:58 EDT
57  David Catozzi/SAIC/GSC (cato@ltpmail.gsfc.nasa.gov)
58  Original design.
59 
60 !Team-unique Header:
61  This software is developed by the MODIS Science
62  Data Support Team (SDST) for the National Aeronautics
63  and Space Administration (NASA), Goddard Space Flight
64  Center (GSFC), under contract NAS5-32373.
65 
66 !References and Credits:
67  HDF portions developed at the National Center for
68  Supercomputing Applications at the University of Illinois
69  at Urbana-Champaign.
70 
71 !Design Notes:
72  None
73 
74 !END************************************************************************
75 */
76 
77  {
78  /**************************************************************************/
79  /* */
80  /* Declare the local variables and initialize them. */
81  /* */
82  /**************************************************************************/
83  /* */
84  /* Set routine to "write_Vdata" */
85  /* Set returnStatus to MODIS_S_SUCCESS */
86  /* declare num_rcds_written and Vdata_id to be variables of type int32 */
87  /* */
88  /**************************************************************************/
89 
90  PGSt_SMF_status returnStatus; /* SMF-style message returned by function */
91 
92  char *routine = "write_Vdata";
93 
94  char msg[300];
95 
96  int32 num_rcds_written;
97 
98  int32 Vdata_id;
99 
100 
101  returnStatus = MODIS_S_SUCCESS;
102 
103 
104 
105  /**************************************************************************/
106  /* */
107  /* CALL recall_id to get the Vdata id for the Vdata */
108  /* INPUTS: Vdata_name */
109  /* OUTPUTS: None */
110  /* RETURNS: Vdata_id */
111  /* */
112  /* IF Vdata_id is not equal to FAIL */
113  /* THEN */
114  /* {FULL_INTERLACE writes record by record (i.e all fields in a record} */
115  /* {are written before moving on to the next record)} */
116  /* CALL VSwrite to write the data to file */
117  /* INPUTS: Vdata_id, data, num_records, FULL_INTERLACE */
118  /* OUTPUTS: None */
119  /* RETURNS: returnStatus */
120  /* */
121  /* set num_rcds_written to returnStatus */
122  /* */
123  /**************************************************************************/
124 
125  Vdata_id = recall_id(Vdata_name);
126 
127  if (Vdata_id != FAIL) {
128  returnStatus = VSwrite(Vdata_id, data, num_records, FULL_INTERLACE);
129 
130  num_rcds_written = returnStatus;
131 
132 
133  /**************************************************************************/
134  /* */
135  /* IF ( returnStatus equals FAIL ) */
136  /* THEN */
137  /* CALL log_fmt_msg to report that the Vdata could not be written */
138  /* to the L1A granule */
139  /* INPUTS: Status, routine, msg */
140  /* OUTPUTS: None */
141  /* RETURN: None */
142  /* ELSE */
143  /* IF ( num_rcds_written is NOT equal to num_records ) */
144  /* THEN */
145  /* CALL log_fmt_msg to report that not all of the records */
146  /* requested were written to the Vdata in the L1A granule */
147  /* INPUTS: Status, routine, msg */
148  /* OUTPUTS: None */
149  /* RETURN: None */
150  /* */
151  /* set returnStatus to FAIL */
152  /* ENDIF */
153  /* ENDIF */
154  /* */
155  /**************************************************************************/
156 
157  if (returnStatus == FAIL) {
158  sprintf(msg, "Vdata Name: %s", Vdata_name);
159  log_fmt_msg (MODIS_E_WRITE_VDATA, routine, msg);
160  }
161  else if (num_rcds_written != num_records) {
162  sprintf(msg, "VSwrite wrote fewer records than requested: "
163  "Num Written %ld Num Requested %ld",
164  (long)num_rcds_written, (long)num_records);
166 
167  returnStatus = FAIL;
168  }
169  }
170 
171 
172  /**************************************************************************/
173  /* */
174  /* ELSE */
175  /* CALL log_fmt_msg to report that the Vdata id could not be retrieved */
176  /* INPUTS: Status, routine, msg */
177  /* OUTPUTS: None */
178  /* RETURN: None */
179  /* */
180  /* set returnStatus to FAIL */
181  /* ENDIF */
182  /* */
183  /* return returnStatus */
184  /* */
185  /**************************************************************************/
186 
187  else {
188  sprintf(msg, "Vdata Name: %s", Vdata_name);
189  log_fmt_msg(MODIS_E_RECALL_ID, routine, msg);
190 
191  returnStatus = FAIL;
192  }
193 
194  return returnStatus;
195 
196  } /* End of routine write_Vdata */
PGSt_SMF_status write_Vdata(char *Vdata_name, unsigned char *data, int32 num_records)
Definition: write_Vdata.c:8
#define FAIL
Definition: ObpgReadGrid.h:18
#define MODIS_E_RECALL_ID
int32 recall_id(char *Vdata_name)
Definition: recall_id.c:8
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
#define MODIS_E_WRITE_VDATA
#define MODIS_S_SUCCESS
string msg
Definition: mapgen.py:227