OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
recall_id.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 #include "VU_vdata_utility.h"
7 
8 int32 recall_id ( char *Vdata_name )
9 
10 /*
11 !C************************************************************************
12 
13 !Description: This function gets the Vdata id number corresponding to the
14  specified Vdata name.
15 
16 !Input Parameters:
17  char *Vdata_name ** The name of the Vdata for which
18  to recall the id **
19 
20 !Output Parameters:
21  None
22 
23 Return Values:
24  FAIL (hdf.h)
25  Vdata_id ** The Vdata id corresponging to **
26  ** the specified Vdata (or FAIL) **
27 
28 Externally Defined:
29  PGS_SMF_status (PGS_SMF.h)
30  int16 (hdfi.h)
31  int32 (hdfi.h)
32  TRUE (hdf.h)
33  FALSE (hdf.h)
34  global_VU_ID_TABLE_READY (level1a)
35  VU_MAX_NUMBER_OF_VDATAS (VU_vdata_utility.h)
36  MODIS_W_ID_TABLE_NOT_INIT (PGS_MODIS_35005.h)
37  global_VU_VDATA_ID (level1a)
38 
39 Called By:
40  write_Vdata
41  close_Vdata
42 
43 Routines Called:
44  log_fmt_msg
45  equal_strings
46 
47 !Revision History:
48  Revision 2.0 1997/10/01 22:05 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  None
68 
69 !Design Notes:
70  None
71 
72 !END************************************************************************
73 */
74 
75  {
76  /**************************************************************************/
77  /* */
78  /* Declare the global variables. */
79  /* */
80  /**************************************************************************/
81 
82  extern VU_ID_TABLE global_VU_VDATA_ID[VU_MAX_NUMBER_OF_VDATAS];
83 
84  extern int global_VU_ID_TABLE_READY;
85 
86 
87  /**************************************************************************/
88  /* */
89  /* Declare the local variables and initialize them. */
90  /* */
91  /**************************************************************************/
92  /* */
93  /* Set routine to "recall_id" */
94  /* */
95  /* set returnStatus to FAIL */
96  /* */
97  /**************************************************************************/
98 
99  char *routine = "recall_id"; /* Variable to hold routine name */
100 
101  int32 returnStatus; /* int32-style message returned by function */
102 
103  int16 strings_are_equal;
104 
105  int ctr;
106 
107  int Found;
108 
109 
110  returnStatus = FAIL;
111 
112 
113 
114  /**************************************************************************/
115  /* */
116  /* {first ensure that the id table has been initialized} */
117  /* IF ( global_VU_ID_TABLE_READY equals False ) */
118  /* THEN */
119  /* CALL log_fmt_msg to report that the id table is empty */
120  /* INPUTS: Status, routine, "" */
121  /* OUTPUTS: None */
122  /* RETURNS: None */
123  /* */
124  /**************************************************************************/
125 
128 
129  /**************************************************************************/
130  /* */
131  /* ELSE */
132  /* set Found to FALSE */
133  /* set ctr to 0 */
134  /* DO-WHILE (ctr is less than or equal to (VU_MAX_NUMBER_OF_VDATAS-1)) */
135  /* AND (Found is equal to FALSE) */
136  /* CALL equal_strings to test for string equality */
137  /* INPUTS: VDATA_ID[ctr].name, Vdata_name */
138  /* OUTPUTS: None */
139  /* RETURN: strings_are_equal */
140  /* */
141  /* IF (strings_are_equal equals True) */
142  /* THEN */
143  /* set Found to TRUE */
144  /* ELSE */
145  /* Increment ctr */
146  /* ENDIF */
147  /* END-WHILE */
148  /* */
149  /* IF (Found is equal to TRUE) */
150  /* THEN */
151  /* set returnStatus to global_VU_VDATA_ID[ctr].id */
152  /* ENDIF */
153  /* ENDIF */
154  /* */
155  /* RETURN returnStatus */
156  /* */
157  /**************************************************************************/
158 
159  else {
160  Found = FALSE;
161  ctr = 0;
162  while ((ctr < VU_MAX_NUMBER_OF_VDATAS) && (Found == FALSE)) {
163 
164  strings_are_equal = equal_strings(global_VU_VDATA_ID[ctr].name,
165  Vdata_name);
166 
167  if (strings_are_equal == TRUE)
168  Found = TRUE;
169  else
170  ctr++;
171  }
172 
173  if (Found == TRUE)
174  returnStatus = global_VU_VDATA_ID[ctr].id;
175  }
176 
177  return returnStatus;
178 
179  } /* End of routine recall_id */
integer, parameter int16
Definition: cubeio.f90:3
#define VU_MAX_NUMBER_OF_VDATAS
int16 equal_strings(char *a, char *b)
Definition: equal_strings.c:6
#define FAIL
Definition: ObpgReadGrid.h:18
#define FALSE
Definition: rice.h:164
#define TRUE
Definition: rice.h:165
int32 recall_id(char *Vdata_name)
Definition: recall_id.c:8
VU_ID_TABLE global_VU_VDATA_ID[VU_MAX_NUMBER_OF_VDATAS]
Definition: level1a.c:36
#define MODIS_W_ID_TABLE_NOT_INIT
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
int global_VU_ID_TABLE_READY
Definition: level1a.c:26