OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
init_L1A_pix_qual_HDF_sdss.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 "mapiL1A.h"
5 #include "PH_pkt_hdr.h"
6 #include "PGS_SMF.h"
7 
8 
9 PGSt_SMF_status init_L1A_pix_qual_HDF_sdss (MODFILE *mfile,
10  int nscans)
11 
12 /*
13 !C*****************************************************************************
14 
15 !Description: Function init_L1A_pix_qual_HDF_sdss creates all the Pixel Quality
16  Data (section 3 of the MODIS Level 1A Data Product Format) SDSs
17  (arrays) that will be written to by L1A processing.
18 
19 !Input Parameters:
20  MODFILE mfile ** Pointer to MODFILE structure **
21  int nscans ** Number of scans **
22 
23 !Output Parameters:
24  None
25 
26 Return Values:
27  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
28  MODIS_E_SDS_CREATE_FAILED (PGS_MODIS_35005.h)
29 
30 Externally Defined:
31  PGSt_SMF_status (PGS_SMF.h)
32  M01SD_PIX_QUAL (mapiL1A.h)
33  M01SRCA_PIX_QUAL (mapiL1A.h)
34  M01BB_PIX_QUAL (mapiL1A.h)
35  M01SV_PIX_QUAL (mapiL1A.h)
36  M01EV_PIX_QUAL (mapiL1A.h)
37  MFAIL (mapi.h)
38  MODFILE (mapi.h)
39  DATATYPELENMAX (mapi.h)
40  I16 (mapi.h)
41  MFILL_VALUE (mapi.h)
42 
43 Called By:
44  init_L1A_HDF_sdss
45 
46 Routines Called:
47  log_fmt_msg
48  createMODISarray
49  putMODISarinfo
50 
51 !Revision History:
52 $Log: init_L1A_pix_qual_HDF_sdss.c,v $
53 Revision 5.1 2004/09/23 18:30:14 seaton
54 Collection 5 changes. Updated SDSs to have a _FillValue attribute in the product output file.
55 seaton@saicmodis.com
56 
57 
58  Revision 1.0 1997/09/05 17:30:00
59  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
60  Original development
61 
62 !Team-unique Header:
63  This software is developed by the MODIS Science Data Support
64  Team (SDST) for the National Aeronautics and Space Administration
65  (NASA), Goddard Space Flight Center (GSFC), under contract
66  NAS5-32373.
67 
68 !References and Credits:
69  None
70 
71 !Design Notes:
72  None
73 
74 !END***************************************************************************
75 */
76 {
77  /*************************************************************************/
78  /* */
79  /* Define and Initialize Local Variables */
80  /* */
81  /*************************************************************************/
82 
83  char *routine = "init_L1A_pix_qual_HDF_sdss";
84  char msg[300];
85  char data_type[DATATYPELENMAX] = I16;
86  long int rank = 3;
87  char array_name[5][256] = {M01SD_PIX_QUAL, M01SRCA_PIX_QUAL,
88  M01BB_PIX_QUAL, M01SV_PIX_QUAL,
89  M01EV_PIX_QUAL};
90  long int dimsizes[5][3] = {{0,PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX,2},
95  PGSt_SMF_status returnStatus;
96  int i;
97  int16 fill_val[1]={1};
98 
99  /*******************************************************************************/
100  /* */
101  /* Set mapi_status to MAPIOK */
102  /* */
103  /* Set returnStatus to MODIS_S_SUCCESS */
104  /* */
105  /*******************************************************************************/
106 
107  returnStatus = MODIS_S_SUCCESS;
108 
109 
110  /*******************************************************************************/
111  /* */
112  /* Set data_type to "int16" (done during declaration) */
113  /* */
114  /* Set rank to 3 (done during declaration) */
115  /* */
116  /* Store all array names (M01SD_PIX_QUAL, M01SRCA_PIX_QUAL, M01BB_PIX_QUAL, */
117  /* M01SV_PIX_QUAL, M01EV_PIX_QUAL) in array_name (done during declaration)*/
118  /* */
119  /* Store all dimension sizes (nscans,PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX,2; */
120  /* nscans,PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX,2; */
121  /* nscans,PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX,2; */
122  /* nscans,PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX,2; */
123  /* nscans,PH_MOD_SOURCE_ID_EARTH_FRAME_CNT_LIMIT,2) in dimsizes */
124  /* */
125  /*******************************************************************************/
126 
127  dimsizes[0][0] = dimsizes[1][0] = dimsizes[2][0] = dimsizes[3][0] = dimsizes[4][0]
128  = nscans;
129 
130 
131  /*******************************************************************************/
132  /* */
133  /* FOR i equals all elements of Pixel Quality Data (5) */
134  /* CALL createMODISarray to create the appropriate SDS in the L1A file */
135  /* INPUT: mfile, array_name[i], NULL, data_type, rank, dimsizes[i] */
136  /* OUTPUT: None */
137  /* RETURN: mapi_status */
138  /* */
139  /* IF mapi_status is equal to MFAIL */
140  /* THEN */
141  /* Set returnStatus to MODIS_E_SDS_CREATE_FAILED */
142  /* Set msg to "unable to create the 'array_name' SDS" */
143  /* Set routine to "init_L1A_HDF_sdss" */
144  /* CALL log_fmt_msg to report that the 'array_name' SDS was not created */
145  /* INPUT: returnStatus, routine, msg */
146  /* OUTPUT: None */
147  /* RETURN: None */
148  /* ENDIF */
149  /* */
150  /* ENDFOR */
151  /* */
152  /*******************************************************************************/
153 
154  for (i=0; i<5; i++) {
155  if (createMODISarray(mfile,array_name[i],NULL,data_type,rank,dimsizes[i])
156  == MFAIL)
157  {
158  returnStatus = MODIS_E_SDS_CREATE_FAILED;
159  sprintf(msg, "SDS name: %s", array_name[i]);
161  }
162 
163  if (putMODISarinfo(mfile, array_name[i],
164  NULL, MFILL_VALUE,
165  data_type, 1, &fill_val) != MAPIOK) {
166  returnStatus = MODIS_E_SDS_CREATE_FAILED;
167  sprintf(msg, "Could not initialize SDS to %d for SDS Name: %s", *fill_val, array_name[i]);
169  }
170 
171  } /* end for */
172 
173 
174  /*******************************************************************************/
175  /* */
176  /* RETURN returnStatus */
177  /* */
178  /*******************************************************************************/
179 
180  return (returnStatus);
181 }
integer, parameter int16
Definition: cubeio.f90:3
#define NULL
Definition: decode_rs.h:63
#define PH_MOD_SOURCE_ID_EARTH_FRAME_CNT_LIMIT
Definition: PH_pkt_hdr.h:195
#define PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX
Definition: PH_pkt_hdr.h:216
#define MODIS_E_SDS_CREATE_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 init_L1A_pix_qual_HDF_sdss(MODFILE *mfile, int nscans)
#define MODIS_S_SUCCESS
Extra metadata that will be written to the HDF4 file l2prod rank
string msg
Definition: mapgen.py:227
int i
Definition: decode_rs.h:71