NASA Logo
Ocean Color Science Software

ocssw V2022
MOD06AlbedoEcoModule.f90
Go to the documentation of this file.
2 
3 ! HI
4 !****************************************************************************
5  ! !F90
6  !
7  ! !Description:
8  ! This module contains the subroutines used to provide albedo and ecosystem
9  ! maps for processing a MOD06 granule.
10  ! There is only one callable routine, getAlbedoEco, which returns albedo
11  ! values and IGBP ecosystem classification for each pixel of the MOD06 granule,
12  ! and for the wavelengths specified. Also returned are values of snow albedos
13  ! by ecosystem class for the wavelengths specified.
14  !
15  ! !Callable routines:
16  ! getAlbedoEco()
17  !
18  ! !Revision History:
19  !
20  ! Revision 1.0 2003/12/18 12:43:43 EGMoody
21  ! Initial revision.
22  !
23  ! !Team-Unique Header:
24  ! Cloud Retrieval Group, NASA Goddard Space Flight Center
25  !
26  ! !References and Credits:
27  ! Written by
28  ! Eric Moody
29  ! Climate and Radiation Branch, Code 913
30  ! NASA/GSFC
31  ! Greenbelt MD 20771
32  ! Eric.Moody@gsfc.nasa.gov
33  !
34  ! !Design Notes:
35  !
36  ! !END
37  !*****************************************************************************
38 
39  !Dependencies:
40 
42  implicit none
43 
44  include 'netcdf.inc'
45 
46  private
47 
48  ! WDR public :: GetNISEType, ReadSnowAlbStats, init_NISE_processing
49  public :: readsnowalbstats
50 
51 
52 
53  !local variables:
54  !counters:
55  integer :: i,j,k,l,m,n
56 
57  !HDF variables:
58  integer :: HDFstatus
59  integer, dimension(10) :: hdfStart, hdfStride, hdfEdge
60  integer :: sds_id, sds_index
61  ! HDFstatus: Used for error checking.
62  ! hdfstart : Follows HDF conventions. The array element from which to begin reading the
63  ! HDF array. Zero based.
64  ! hdfstride: Follows HDF conventions. The frequency with which data should be read in
65  ! each dimension. Stride 1 means read every element.
66  ! hdfedge : Follows HDF conventions. The number of elements to read in each dimension.
67  ! If start(:) == 0 and stride(:) == 1, setting edge equal to the shape of
68  ! the underlying array reads all elements.
69 
70 
71  INTEGER, PARAMETER :: gridsize = 721
72  integer*2, DIMENSION(gridsize, gridsize) :: niseNorth, niseSouth
73 
74 
75 contains
76 
77 ! subroutine init_NISE_processing(nise_file)
78 !
79 ! character(len=*), intent(in) :: nise_file
80 ! integer :: iret
81 !
82 ! iret = Read_NISE(nise_file, gridsize, niseNorth, niseSouth)
83 !
84 !
85 !
86 ! end subroutine init_NISE_processing
87 
88 
89 
90  ! ----------------------------------------------------------------------------------
91  ! ----------------------------------------------------------------------------------
92 
93  subroutine readsnowalbstats ( StatsFN, NumSnowTypes, NumAlbBnds, numEco, &
94  AlbedoMean, errorLevel )
95 
96  character (len = *), intent( in) :: statsfn
97  real , &
98  dimension(:,0:,:), intent(inout):: albedomean
99  integer , intent( in) :: numalbbnds, &
100  numeco, &
101  numsnowtypes
102  INTEGER, INTENT(OUT) :: errorlevel
103 
104  ! !Description:
105  ! This routine will output only a single band of albedo, for the specified amount
106  ! of data, to the specified position within the hdf file.
107  !
108  ! !Input Parameters:
109  ! StatsFN : The name, only, of the new HDF file.
110  ! Albedo : Contains the single band of albedo to be stored.
111  ! NumSnowTypes : 2, Dry or wet, via NISE classes.
112  ! NumAlbBnds : Number of Albedo wavelengths.
113  ! numEco : Number of Ecosystem Classes.
114  !
115  ! !Output Parameters:
116  ! AlbedoMean : Mean statistic
117  !
118  ! !Revision History:
119  ! See Module revision history at the beginning of the file.
120  !
121  ! !Team-Unique Header:
122  ! Cloud Retrieval Group, NASA Goddard Space Flight Center
123  !
124  ! !References and Credits:
125  ! Written by
126  ! Eric Moody
127  ! Climate and Radiation Branch, Code 913
128  ! NASA/GSFC
129  ! Greenbelt MD 20771
130  ! Eric.Moody@gsfc.nasa.gov
131  !
132  ! !Design Notes:
133  !
134  ! !END
135 
136  !local variables:
137  !HDF variables:
138  integer :: status
139  integer , dimension(10) :: hdfstart, hdfstride, hdfedge
140  integer :: sds_id, newhdfid, sds_index
141  character(len = 200) :: sdsname
142  real , &
143  dimension(1:2,1:NumAlbBnds,0:numEco,1:1,1:2) :: dummyalb
144  ! status : Used for error checking.
145  ! hdfstart : Follows HDF conventions. The array element from which to begin reading the
146  ! HDF array. Zero based.
147  ! hdfstride : Follows HDF conventions. The frequency with which data should be read in
148  ! each dimension. Stride 1 means read every element.
149  ! hdfedge : Follows HDF conventions. The number of elements to read in each dimension.
150  ! If start(:) == 0 and stride(:) == 1, setting edge equal to the shape of
151  ! the underlying array reads all elements.
152  ! sds_id,
153  ! newHDFID : HDF SDS ID.
154  ! sds_index : Index of the SDS in the HDF file.
155  ! SDSName : Stores the name of the SDS being procesed.
156 
157  integer :: fail = -1
158 
159  !Set error level
160  errorlevel = success
161 
162  !************************************************************************************
163  ! Open the input file:
164  !************************************************************************************
165  !Open the albedo HDF file:
166  status = nf_open( trim(statsfn), nf_nowrite, newhdfid )
167  call cld_fchk( status, __file__, __line__ )
168 
169  ! WDR the errorLevel was passed back and not dealt with. The above will
170  ! halt the program here
171 
172  !************************************************************************************
173  ! Input the Albedo mean statistic:
174  !************************************************************************************
175  !Set up the output hdf variables, in this case we are writing a Belt:
176  ! hdfStart, note that we are storing the entire Longitude, Albedo Bands and Ecosystems
177  ! so these start at 0, however we are storing a box of Latitude, so this starts at the
178  ! starty counter.
179  hdfstart( : ) = 1
180  hdfstart( 5 ) = 1 !Latitude, 0 = NH, 1 = SH
181  hdfstart( 4 ) = 1 !Longitude, only 1, so 0
182  hdfstart( 3 ) = 1 !Eco
183  hdfstart( 2 ) = 1 !AlbBands
184  hdfstart( 1 ) = 1 !NumSnowTypes
185 
186  !Strides = 1, since we are not skiping points
187  hdfstride( : ) = 1
188 
189  !Edge is the total number of points being read:
190  ! It is the number of Albedo bands, the number of Ecosystems, the Number of Longitude
191  ! boxes, and 1 lat box:
192  hdfedge( : ) = 1
193  hdfedge( 5 ) = 2
194  hdfedge( 4 ) = 1
195  hdfedge( 3 ) = numeco
196  hdfedge( 2 ) = numalbbnds
197  hdfedge( 1 ) = numsnowtypes
198 
199  !Read the Mean data:
200  sdsname = 'Snow_Albedo_Year_Mean'
201  !determine the sds_index for the SDS:
202  status = nf_inq_varid( newhdfid, trim(sdsname), sds_id )
203  call cld_fchk( status, __file__, __line__ )
204 
205  !get access to this SDS:
206 
207  !Read the data:
208  status = nf_get_vara_real( newhdfid, sds_id, hdfstart, hdfedge, dummyalb )
209  call cld_fchk( status, __file__, __line__ )
210 
211  !Store the dummy data in the final array:
212  do i = 1, numalbbnds
213  do j = 0, numeco-1
214  do k = 1, numsnowtypes
215  albedomean(i,j,k) = dummyalb(k,i,j,1,1)
216  end do
217  end do
218  end do
219 
220  !Error Checking:
221  if (sds_index == fail .or. &
222  sds_id == fail .or. &
223  status == fail) then
224  errorlevel = fail
225  return
226  end if
227 
228  !************************************************************************************
229  ! Close the file:
230  !************************************************************************************
231  !Close the HDF file:
232  status = nf_close( newhdfid )
233  call cld_fchk( status, __file__, __line__ )
234 
235  end subroutine readsnowalbstats
236 
237 end module mod06albedoecomodule
subroutine cld_fchk(status, file, line)
Definition: cld_fchk.f90:2
string & trim(string &s, const string &delimiters)
Definition: EnvsatUtil.cpp:29
subroutine, public readsnowalbstats(StatsFN, NumSnowTypes, NumAlbBnds, numEco, AlbedoMean, errorLevel)