9 integer*4,
parameter :: idim=43201
10 integer*4,
parameter :: jdim=3601
11 integer*4,
parameter :: idim_p1=43202
12 integer*4,
parameter :: jdim_p1=3602
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 real(kind=4),
allocatable :: topo(:,:)
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 = 0.0_8 + dx*0.5_8
33 allocate(lons(idim),lats(jdim),topo(idim,jdim))
34 allocate(lons_corner(idim_p1),lats_corner(jdim_p1))
37 lons(i) =
real((i-1),8) * dx + lon11
38 if (lons(i) > 360.0_8) lons(i) = 360.0_8 - lons(i)
39 print*,
'lon ',i,lons(i)
43 lats(i) =
real((i-1),8) * dy + lat11
44 print*,
'lat ',i,lats(i)
51 lons_corner(i) =
real((i-1),8) * dx + lon11
52 if (lons_corner(i) > 360.0_8) lons_corner(i) = 360.0_8 - lons_corner(i)
53 print*,
'lon_corner ',i,lons_corner(i)
57 lats_corner(i) =
real((i-1),8) * dy + lat11
58 print*,
'lat_corner ',i,lats_corner(i)
61 fileraw=
"/scratch1/NCEPDEV/global/glopara/fix/raw/orog/thirty.second.antarctic.new.bin"
63 open(11, file=trim(fileraw), form=
'unformatted', access=
'sequential', iostat=istat)
64 print*,
'iostat on open ',istat
65 read(11, iostat=istat) topo
66 print*,
'iostat on read ',istat
67 if (istat /= 0) stop 99
70 print*,
'topo ', maxval(topo),minval(topo)
72 print*,
'point 1/1 ',topo(1,1)
73 print*,
'point idim/jdim ',topo(idim,jdim)
75 filenetcdf=
"./topography.antarctica.ramp.30s.nc"
77 print*,
"- CREATE FILE: ", trim(filenetcdf)
78 status=nf90_create(filenetcdf, ior(nf90_netcdf4,nf90_classic_model), ncid)
79 if (status /= nf90_noerr) stop 1
81 status=nf90_def_dim(ncid,
'idim', idim, dim_i)
82 if (status /= nf90_noerr) stop 3
84 status=nf90_def_dim(ncid,
'jdim', jdim, dim_j)
85 if (status /= nf90_noerr) stop 2
87 status=nf90_def_dim(ncid,
'idim_p1', (idim+1), dim_ip1)
88 if (status /= nf90_noerr) stop 4
90 status=nf90_def_dim(ncid,
'jdim_p1', (jdim+1), dim_jp1)
91 if (status /= nf90_noerr) stop 5
93 status=nf90_put_att(ncid, nf90_global,
'source',
'RADARSAT ANTARCTIC MAPPING PROJECT (RAMP) TOPOGRAPHY DATA')
94 if (status /= nf90_noerr) stop 6
96 status=nf90_put_att(ncid, nf90_global,
'projection',
'regular lat/lon')
97 if (status /= nf90_noerr) stop 67
99 status=nf90_def_var(ncid,
'lat', nf90_double, dim_j, id_lat)
100 if (status /= nf90_noerr) stop 17
102 status=nf90_put_att(ncid, id_lat,
'long_name',
'grid cell center latitude')
103 if (status /= nf90_noerr) stop 10
105 status=nf90_put_att(ncid, id_lat,
'units',
'degrees')
106 if (status /= nf90_noerr) stop 85
108 status=nf90_def_var(ncid,
'lat_corner', nf90_double, dim_jp1, id_lat_corner)
109 if (status /= nf90_noerr) stop 37
111 status=nf90_put_att(ncid, id_lat_corner,
'long_name',
'grid cell corner latitude')
112 if (status /= nf90_noerr) stop 38
114 status=nf90_put_att(ncid, id_lat_corner,
'units',
'degrees')
115 if (status /= nf90_noerr) stop 86
117 status=nf90_def_var(ncid,
'lon', nf90_double, dim_i, id_lon)
118 if (status /= nf90_noerr) stop 16
120 status=nf90_put_att(ncid, id_lon,
'long_name',
'grid cell center longitude')
121 if (status /= nf90_noerr) stop 10
123 status=nf90_put_att(ncid, id_lon,
'units',
'degrees')
124 if (status /= nf90_noerr) stop 87
126 status=nf90_def_var(ncid,
'lon_corner', nf90_double, dim_ip1, id_lon_corner)
127 if (status /= nf90_noerr) stop 16
129 status=nf90_put_att(ncid, id_lon_corner,
'long_name',
'grid cell corner longitude')
130 if (status /= nf90_noerr) stop 40
132 status=nf90_put_att(ncid, id_lon_corner,
'units',
'degrees')
133 if (status /= nf90_noerr) stop 88
135 status=nf90_def_var(ncid,
'topo', nf90_float, (/dim_i,dim_j/), id_data)
136 if (status /= nf90_noerr) stop 20
138 status=nf90_put_att(ncid, id_data,
'long_name',
'topography')
139 if (status /= nf90_noerr) stop 65
141 status=nf90_put_att(ncid, id_data,
'units',
'meters')
142 if (status /= nf90_noerr) stop 55
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, topo)
160 if (status /= nf90_noerr) stop 24
162 status=nf90_close(ncid)
164 end program ramp_netcdf