OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
attached_Vdata_counter.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "hdf.h"
3 #include "hdfi.h"
4 #include "VU_vdata_utility.h"
5 
6 
8 
9 /*
10 !C************************************************************************
11 
12 !Description: This function keeps track of how many Vdatas are currently
13  attached to the HDF file. As an internal consistency check
14  it is useful to check that there are no attached Vdatas prior
15  to closing the HDF file (since detaching Vdatas is required
16  by HDF and one may forget to do it).
17 
18 !Input Parameters:
19  int16 action ** either VU_INCREMENT, **
20  ** VU_DECREMENT, **
21  ** or VU_REPORT **
22 !Output Parameters:
23  None
24 
25 Return Values:
26  FAIL (hdf.h)
27  int16 result ** the number of attached Vdatas **
28  ** (a non-negative integer) or **
29  ** FAIL (-1) **
30 Externally Defined:
31  int16 (hdfi.h)
32  VU_MAX_NUMBER_OF_VDATAS (VU_vdata_utility.h)
33  VU_INCREMENT (VU_vdata_utility.h)
34  VU_DECREMENT (VU_vdata_utility.h)
35  VU_REPORT (VU_vdata_utility.h)
36 
37 Called By:
38  remember
39  forget
40  end_vdata_access_to_file
41 
42 Routines Called:
43  None
44 
45 !Revision History:
46  Revision 2.0 1997/10/02 11:35 EDT
47  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
48  Originated Code.
49 
50  Revision 1.1 1997/09/03 10:55
51  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
52  Incorporate walkthrough comments
53 
54  Revision 1.0 1997/07/14 15:58 EDT
55  David Catozzi/SAIC/GSC (cato@ltpmail.gsfc.nasa.gov)
56  Original design.
57 
58 !Team-unique Header:
59  This software is developed by the MODIS Science
60  Data Support Team (SDST) for the National Aeronautics
61  and Space Administration (NASA), Goddard Space Flight
62  Center (GSFC), under contract NAS5-32373.
63 
64 !References and Credits:
65  None
66 
67 !Design Notes:
68  This PDL cannot be implemented in a language that doesn't
69  provide persistent local variables (i.e. local variables that
70  maintain their values between calls).
71 
72  This is a private function - only to be used by functions
73  internal to the Vdata_id_table.
74 
75 !END************************************************************************
76 */
77 
78  {
79  /**************************************************************************/
80  /* Declare the local variables and initialize them. */
81  /* */
82  /**************************************************************************/
83  /* declare total_number_of_attached_Vdatas to be a persistent local */
84  /* variable of type int16 with initial value of 0 */
85  /* */
86  /**************************************************************************/
87 
88  static int16 total_number_of_attached_Vdatas = 0;
89 
90 
91 
92  /**************************************************************************/
93  /* SWITCH (action) */
94  /* case VU_INCREMENT: */
95  /* IF (total_number_of_attached_Vdatas >= VU_MAX_NUMBER_OF_VDATAS) */
96  /* THEN */
97  /* set total_number_of_attached_Vdatas to FAIL */
98  /* ELSE */
99  /* increment total_number_of_attached_Vdatas */
100  /* ENDIF */
101  /* */
102  /* break */
103  /* */
104  /**************************************************************************/
105 
106  switch (action) {
107  case VU_INCREMENT:
108  if (total_number_of_attached_Vdatas >= VU_MAX_NUMBER_OF_VDATAS)
109  total_number_of_attached_Vdatas = FAIL;
110  else
111  total_number_of_attached_Vdatas++;
112 
113  break;
114 
115 
116 
117  /**************************************************************************/
118  /* case VU_DECREMENT: */
119  /* IF (total_number_of_attached_Vdatas <= 0) */
120  /* THEN */
121  /* set total_number_of_attached_Vdatas to FAIL */
122  /* ELSE */
123  /* decrement total_number_of_attached_Vdatas */
124  /* ENDIF */
125  /* */
126  /* break */
127  /* */
128  /**************************************************************************/
129 
130  case VU_DECREMENT:
131  if (total_number_of_attached_Vdatas <= 0)
132  total_number_of_attached_Vdatas = FAIL;
133  else
134  total_number_of_attached_Vdatas--;
135  break;
136 
137 
138  /**************************************************************************/
139  /* default: */
140  /* {the default case is VU_REPORT} */
141  /* {it returns the number of attached Vdatas} */
142  /* */
143  /* break */
144  /* */
145  /* END_SWITCH */
146  /* */
147  /* return total_number_of_attached_Vdatas */
148  /* */
149  /**************************************************************************/
150 
151  default:
152 
153  break;
154  }
155 
156  return total_number_of_attached_Vdatas;
157 
158  } /* End of routine attached_Vdata_counter */
integer, parameter int16
Definition: cubeio.f90:3
#define VU_MAX_NUMBER_OF_VDATAS
#define VU_INCREMENT
#define FAIL
Definition: ObpgReadGrid.h:18
int16 attached_Vdata_counter(int16 action)
action
Definition: __init__.py:2
#define VU_DECREMENT