9 integer*4,
parameter :: idim=43200
10 integer*4,
parameter :: jdim=21600
11 integer*4,
parameter :: idim_p1=43201
12 integer*4,
parameter :: jdim_p1=21601
14 character(len=150) :: filenetcdf, fileraw
16 integer :: i, istat, ncid, status, dim_i, dim_j
17 integer :: dim_ip1, dim_jp1
18 integer :: id_lon, id_lat, id_data
19 integer :: id_lat_corner, id_lon_corner
21 integer(kind=1),
allocatable :: mask(:,:)
23 real(kind=8),
allocatable :: lats(:), lons(:)
24 real(kind=8),
allocatable :: lats_corner(:), lons_corner(:)
25 real(kind=8) :: lat11, lon11, dx, dy
30 lat11 = 90.0_8 + dy*0.5_8
31 lon11 = -180.0_8 + dx*0.5_8
33 allocate(lons(idim),lats(jdim),mask(idim,jdim))
34 allocate(lons_corner(idim_p1),lats_corner(jdim_p1))
37 lons(i) =
real((i-1),8) * dx + lon11
38 print*,
'lon ',i,lons(i)
42 lats(i) =
real((i-1),8) * dy + lat11
43 print*,
'lat ',i,lats(i)
50 lons_corner(i) =
real((i-1),8) * dx + lon11
51 print*,
'lon_corner ',i,lons_corner(i)
55 lats_corner(i) =
real((i-1),8) * dy + lat11
56 print*,
'lat_corner ',i,lats_corner(i)
59 fileraw=
"/scratch1/NCEPDEV/global/glopara/fix/raw/orog/landcover30.fixed"
61 open(11, file=trim(fileraw), access=
'direct', recl=idim*jdim)
62 read(11, rec=1, iostat=istat) mask
63 if (istat /= 0) stop 99
66 print*,
'mask ', maxval(mask),minval(mask)
67 where(mask > 0) mask = 1
69 filenetcdf=
"./landcover.umd.30s.nc"
71 print*,
"- CREATE FILE: ", trim(filenetcdf)
72 status=nf90_create(filenetcdf, ior(nf90_netcdf4,nf90_classic_model), ncid)
73 if (status /= nf90_noerr) stop 1
75 status=nf90_def_dim(ncid,
'idim', idim, dim_i)
76 if (status /= nf90_noerr) stop 3
78 status=nf90_def_dim(ncid,
'jdim', jdim, dim_j)
79 if (status /= nf90_noerr) stop 2
81 status=nf90_def_dim(ncid,
'idim_p1', (idim+1), dim_ip1)
82 if (status /= nf90_noerr) stop 4
84 status=nf90_def_dim(ncid,
'jdim_p1', (jdim+1), dim_jp1)
85 if (status /= nf90_noerr) stop 5
87 status=nf90_put_att(ncid, nf90_global,
'source',
'Univ. of Maryland land use data')
88 if (status /= nf90_noerr) stop 6
90 status=nf90_put_att(ncid, nf90_global,
'reference',
'http://glcf.umiacs.umd.edu/data/landcover/data.shtml')
91 if (status /= nf90_noerr) stop 66
93 status=nf90_put_att(ncid, nf90_global,
'projection',
'regular lat/lon')
94 if (status /= nf90_noerr) stop 67
96 status=nf90_def_var(ncid,
'lat', nf90_double, dim_j, id_lat)
97 if (status /= nf90_noerr) stop 17
99 status=nf90_put_att(ncid, id_lat,
'long_name',
'grid cell center latitude')
100 if (status /= nf90_noerr) stop 10
102 status=nf90_put_att(ncid, id_lat,
'units',
'degrees')
103 if (status /= nf90_noerr) stop 65
105 status=nf90_def_var(ncid,
'lat_corner', nf90_double, dim_jp1, id_lat_corner)
106 if (status /= nf90_noerr) stop 37
108 status=nf90_put_att(ncid, id_lat_corner,
'long_name',
'grid cell corner latitude')
109 if (status /= nf90_noerr) stop 38
111 status=nf90_put_att(ncid, id_lat_corner,
'units',
'degrees')
112 if (status /= nf90_noerr) stop 68
114 status=nf90_def_var(ncid,
'lon', nf90_double, dim_i, id_lon)
115 if (status /= nf90_noerr) stop 16
117 status=nf90_put_att(ncid, id_lon,
'long_name',
'grid cell center longitude')
118 if (status /= nf90_noerr) stop 10
120 status=nf90_put_att(ncid, id_lon,
'units',
'degrees')
121 if (status /= nf90_noerr) stop 69
123 status=nf90_def_var(ncid,
'lon_corner', nf90_double, dim_ip1, id_lon_corner)
124 if (status /= nf90_noerr) stop 16
126 status=nf90_put_att(ncid, id_lon_corner,
'long_name',
'grid cell corner longitude')
127 if (status /= nf90_noerr) stop 40
129 status=nf90_put_att(ncid, id_lon_corner,
'units',
'degrees')
130 if (status /= nf90_noerr) stop 70
132 status=nf90_def_var(ncid,
'land_mask', nf90_byte, (/dim_i,dim_j/), id_data)
133 if (status /= nf90_noerr) stop 20
135 status=nf90_put_att(ncid, id_data,
'units',
'category')
136 if (status /= nf90_noerr) stop 75
138 status=nf90_put_att(ncid, id_data,
'Non-land', int((/0/)))
139 if (status /= nf90_noerr) stop 55
141 status=nf90_put_att(ncid, id_data,
'Land', int((/1/)))
142 if (status /= nf90_noerr) stop 59
144 status=nf90_enddef(ncid)
145 if (status /= nf90_noerr) stop 22
147 status=nf90_put_var(ncid, id_lon, lons)
148 if (status /= nf90_noerr) stop 19
150 status=nf90_put_var(ncid, id_lon_corner, lons_corner)
151 if (status /= nf90_noerr) stop 59
153 status=nf90_put_var(ncid, id_lat, lats)
154 if (status /= nf90_noerr) stop 20
156 status=nf90_put_var(ncid, id_lat_corner, lats_corner)
157 if (status /= nf90_noerr) stop 57
159 status=nf90_put_var(ncid, id_data, mask)
160 if (status /= nf90_noerr) stop 24
162 status=nf90_close(ncid)
164 end program mask_netcdf