OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
get_lut_igbp_land_cover_nc4.f90
Go to the documentation of this file.
1 subroutine get_lut_igbp_land_cover( lut_file, status)
2  !
3  !f90
4  !description:
5  ! This subroutine reads core SDSs in the IGBP Land Cover
6  ! LUT hdf file.
7  ! file= 'MCD12C1.A2004001.005.Global_IGBP_Land_Cover_0.10deg.hdf'
8  ! includes: IGBP_Land_Cover & Region_Index
9  ! array dimension [3600, 1800]
10 
11  ! ver. 1.0 written by CES (jul 2010)
12  ! ver. 1.1 modified by MJ (aug 2011)
13  !
14  ! use GeneralAuxType
15  ! use lut_arrays
16 
17 ! include 'hdf.f90'
18 ! include 'dffunc.f90'
19  use netcdf
20 
21  implicit none
22  include 'newaottbl90.inc'
23 
24  character(*), intent (in) :: lut_file
25  integer, intent (out) :: status
26  integer, dimension (2) :: start, edge, stride
27 
28  integer :: number_type, nattrs
29  integer :: sds_id,sds_index,attr_index, hdfid
30  character(len=255) :: sds_name
31  character(len=255) :: dset_name
32  character(len=255) :: attr_name
33  character(len=255) :: group_name
34 
35  integer :: nc_id
36  integer :: dim_id
37  integer :: dset_id
38  integer :: grp_id
39 
40  start = (/ 1,1 /)
41  edge = (/ 3600,1800 /)
42  stride = (/ 1,1 /)
43 
44  status = nf90_open(lut_file, nf90_nowrite, nc_id)
45  if (status /= nf90_noerr) then
46  print *, "ERROR: Failed to open deepblue lut_nc4 file: ", status
47  return
48  end if
49 
50  group_name = 'LANDCOVER'
51  status = nf90_inq_ncid(nc_id, group_name, grp_id)
52  if (status /= nf90_noerr) then
53  print *, "ERROR: Failed to get ID of group "//trim(group_name)//": ", status
54  return
55  end if
56 
57  dset_name = 'IGBP'
58  status = nf90_inq_varid(grp_id, dset_name, dset_id)
59  if (status /= nf90_noerr) then
60  print *, "ERROR: Failed to get ID of dataset "//trim(dset_name)//": ", status
61  return
62  end if
63  status = nf90_get_var(grp_id, dset_id, xlcvr_2, start=start, &
64  stride=stride, count=edge)
65  if (status /= nf90_noerr) then
66  print *, "ERROR: Failed to read dataset "//trim(dset_name)//": ", status
67  return
68  end if
69 
70  dset_name = 'REGION_INDEX'
71  status = nf90_inq_varid(grp_id, dset_name, dset_id)
72  if (status /= nf90_noerr) then
73  print *, "ERROR: Failed to get ID of dataset "//trim(dset_name)//": ", status
74  return
75  end if
76  status = nf90_get_var(grp_id, dset_id, regid_2, start=start, &
77  stride=stride, count=edge)
78  if (status /= nf90_noerr) then
79  print *, "ERROR: Failed to read dataset "//trim(dset_name)//": ", status
80  return
81  end if
82 
83  status = nf90_close(nc_id)
84  if (status /= nf90_noerr) then
85  print *, "ERROR: Failed to close lut_nc4 file: ", status
86  return
87  end if
88 
89 end subroutine get_lut_igbp_land_cover
90 
string & trim(string &s, const string &delimiters)
Definition: EnvsatUtil.cpp:29
subroutine get_lut_igbp_land_cover(lut_file, status)