OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
create_Vdata_field.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 create_Vdata_field (char *Vdata_name,
9  int32 Vdata_id,
10  char *field_name,
11  char *data_type,
12  int32 order)
13 /*
14 !C************************************************************************
15 
16 !Description: This routine creates the specified Vdata field inside the
17  specified Vdata within the currently open hdf file.
18 
19 !Input Parameters:
20  char *Vdata_name ** the name of the Vdata in which **
21  ** to create the new Vdata field. **
22 
23  int32 Vdata_id ** the Vdata's id **
24 
25  char *field_name ** the name of the field to create **
26 
27  char *data_type ** the field's data type **
28 
29  int32 order ** the number of data type size **
30  ** entries per record **
31 !Output Parameters:
32  None
33 
34 Return Values:
35  MODIS_S_SUCCESS (PGS_MODIS_35005.t)
36  MODIS_E_VSFDEFINE (PGS_MODIS_35005.t)
37  MODIS_E_DATATYPE_FAIL (PGS_MODIS_35005.t)
38  FAIL (hdf.h)
39 
40 Externally Defined:
41  PGSt_SMF_status (PGS_SMF.h)
42  int32 (hdfi.h)
43 
44 Called By:
45  create_Vdata
46 
47 Routines Called:
48  L1A_datatype_to_DFNT
49  VSfdefine
50  log_fmt_msg
51 
52 !Revision History:
53  Revision 2.0 1997/10/01 11:25 EDT
54  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
55  Originated Code.
56 
57  Revision 1.1 1997/09/03 10:55
58  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
59  Incorporate walkthrough comments
60 
61  Revision 1.0 1997/07/14 15:58 EDT
62  David Catozzi/SAIC/GSC (cato@ltpmail.gsfc.nasa.gov)
63  Original design.
64 
65 !Team-unique Header:
66  This software is developed by the MODIS Science
67  Data Support Team (SDST) for the National Aeronautics
68  and Space Administration (NASA), Goddard Space Flight
69  Center (GSFC), under contract NAS5-32373.
70 
71 !References and Credits:
72  HDF portions developed at the National Center for
73  Supercomputing Applications at the University of Illinois
74  at Urbana-Champaign.
75 
76 !Design Notes:
77  None
78 
79 !END************************************************************************
80 */
81 
82  {
83  /**************************************************************************/
84  /* */
85  /* Declare the local variables and initialize them. */
86  /* */
87  /**************************************************************************/
88  /* */
89  /* Set routine to "create_Vdata_field" */
90  /* declare number_type to be a variable of type int32 */
91  /* Set returnStatus to MODIS_S_SUCCESS */
92  /* */
93  /**************************************************************************/
94 
95  char *routine = "create_Vdata_field";
96  char msg[300];
97 
98  PGSt_SMF_status Status; /* SMF-style message returned by function */
99  PGSt_SMF_status returnStatus; /* SMF-style message returned by function */
100 
101  int32 number_type;
102 
103  returnStatus = MODIS_S_SUCCESS;
104 
105  /**************************************************************************/
106  /* */
107  /* CALL L1A_datatype_to_DFNT to assign the data type */
108  /* INPUTS: data_type */
109  /* OUTPUTS: None */
110  /* RETURNS: number_type */
111  /* */
112  /* IF number_type is not equal to MFAIL */
113  /* THEN */
114  /* CALL VSfdefine to define the new field */
115  /* INPUTS: Vdata_id, field_name, number_type, order */
116  /* OUTPUTS: None */
117  /* RESULT: Status */
118  /* */
119  /* IF (Status equals FAIL) */
120  /* THEN */
121  /* set Status to MODIS_E_VSFDEFINE */
122  /* set msg to "unable to define the new field" */
123  /* CALL log_fmt_msg to report that the new field could not be */
124  /* defined */
125  /* INPUTS: Status, routine msg */
126  /* OUTPUTS: None */
127  /* RETURNS: None */
128  /* */
129  /* set returnStatus to FAIL */
130  /* ENDIF */
131  /* */
132  /**************************************************************************/
133 
134  number_type = L1A_datatype_to_DFNT(data_type);
135 
136  if (number_type != MFAIL) {
137  Status = VSfdefine(Vdata_id, field_name, number_type, order);
138 
139  if (Status == FAIL) {
140  sprintf(msg, "unable to define the new field, %s for the Vdata %s",
141  field_name, Vdata_name);
142  log_fmt_msg(MODIS_E_VSFDEFINE, routine, msg);
143  returnStatus = FAIL;
144  }
145  }
146 
147 
148  /**************************************************************************/
149  /* */
150  /* ELSE */
151  /* set Status to MODIS_E_DATATYPE_FAIL */
152  /* set msg to "unable to associate the datatype for Vdata_name" */
153  /* CALL log_fmt_msg to report that the datatype could not be associated*/
154  /* INPUTS: Status, routine msg */
155  /* OUTPUTS: None */
156  /* RETURNS: None */
157  /* */
158  /* set returnStatus to FAIL */
159  /* ENDIF */
160  /* */
161  /* return returnStatus */
162  /* */
163  /**************************************************************************/
164 
165  else {
166  sprintf(msg, "unable to associate the datatype for Vdata Name: %s",
167  Vdata_name);
169  returnStatus = FAIL;
170  }
171 
172  return returnStatus;
173 
174  } /* End of routine create_Vdata_field */
#define MODIS_E_DATATYPE_FAIL
int32 L1A_datatype_to_DFNT(char *datatype)
#define FAIL
Definition: ObpgReadGrid.h:18
PGSt_SMF_status create_Vdata_field(char *Vdata_name, int32 Vdata_id, char *field_name, char *data_type, int32 order)
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
#define MODIS_S_SUCCESS
string msg
Definition: mapgen.py:227
#define MODIS_E_VSFDEFINE