34 implicit double precision(a-h,o-z)
35 parameter(len=5401*5401)
36 parameter(gran=3600.d0)
40 real*4 z(len),glo,gla,val
41 equivalence(h(1),z(1))
54 open(lin,file=fname,status=
'old',form=
'binary')
63 open(lout,file=fname,status=
'new',form=
'unformatted')
71 if(yesno.eq.
'y'.or.yesno.eq.
'Y')
then 89 if(makpos(glo))
continue 91 if(gla.gt.glamx) glamx=gla
92 if(gla.lt.glamn) glamn=gla
93 if(glo.gt.glomx) glomx=glo
94 if(glo.lt.glomn) glomn=glo
99 100
read(lin,end=777) glo,gla,val
101 if(makpos(glo))
continue 103 if(gla.gt.glamx) glamx=gla
104 if(gla.lt.glamn) glamn=gla
105 if(glo.gt.glomx) glomx=glo
106 if(glo.lt.glomn) glomn=glo
110 if(dla.gt.dgla.and.dla.lt.(glamx-glamn)/2.d0 ) dgla=dla
111 if(dlo.gt.dglo.and.dlo.lt.(glomx-glomn)/2.d0 ) dglo=dlo
120 glamn=idnint(gran*glamn)/gran
121 glamx=idnint(gran*glamx)/gran
122 glomn=idnint(gran*glomn)/gran
123 glomx=idnint(gran*glomx)/gran
124 dgla =idnint(gran*dgla )/gran
125 dglo =idnint(gran*dglo )/gran
126 nla=idnint((glamx-glamn)/dgla)+1
127 nlo=idnint((glomx-glomn)/dglo)+1
128 dgla=(glamx-glamn)/dble(nla-1)
129 dglo=(glomx-glomn)/dble(nlo-1)
132 write(*,*)
' kind=',ikind
133 write(*,*)
' LAT min=',glamn
134 write(*,*)
' del=',dgla,
' # lat=',nla
135 write(*,*)
' max=',glamn+(nla-1)*dgla
136 write(*,*)
' LON min=',glomn
137 write(*,*)
' del=',dglo,
' # lon=',nlo
138 write(*,*)
' max=',glomn+(nlo-1)*dglo
142 if(nla*nlo.gt.len) stop 12345
155 10
read(lin,end=7777) glo,gla,val
157 if(makpos(glo))
continue 160 call put1(ival,gla,glo,h,nla,nlo,glamn,dgla,glomn,dglo,iclip)
162 call put2( val,gla,glo,z,nla,nlo,glamn,dgla,glomn,dglo,iclip)
169 write(lout) glamn,glomn,dgla,dglo,nla,nlo,ikind
171 call w1(lout,h,nla,nlo,glamn,dgla,glomn,dglo)
173 call w2(lout,z,nla,nlo,glamn,dgla,glomn,dglo)
176 write(*,*)
' all, icount, iclip = ',nla*nlo,icount,iclip
180 subroutine put1(ival,gla,glo,h,nla,nlo,glamn,dgla,glomn,dglo,iclp)
184 implicit double precision(a-h,o-z)
188 i=idnint((gla-glamn)/dgla)+1
189 if(i.lt.1.or.i.gt.nla)
then 193 j=idnint((glo-glomn)/dglo)+1
194 if(j.lt.1.or.j.gt.nlo)
then 202 subroutine put2(val,gla,glo,z,nla,nlo,glamn,dgla,glomn,dglo,iclip)
206 implicit double precision(a-h,o-z)
207 real*4 z(nla,nlo),val,gla,glo
209 i=idnint((gla-glamn)/dgla)+1
210 if(i.lt.1.or.i.gt.nla)
then 214 j=idnint((glo-glomn)/dglo)+1
215 if(j.lt.1.or.j.gt.nlo)
then 223 subroutine w1(lout,h,nla,nlo,glamn,dgla,glomn,dglo)
227 implicit double precision(a-h,o-z)
231 1
write(lout) (h(i,j),j=1,nlo)
235 subroutine w2(lout,z,nla,nlo,glamn,dgla,glomn,dglo)
239 implicit double precision(a-h,o-z)
243 1
write(lout) (z(i,j),j=1,nlo)
247 logical function makpos(glon)
253 1
if(glon.lt.0.d0)
then 259 2
if(glon.ge.360.d0)
then subroutine w1(lout, h, nla, nlo, glamn, dgla, glomn, dglo)
subroutine put2(val, gla, glo, z, nla, nlo, glamn, dgla, glomn, dglo, iclip)
logical function makpos(glon)
subroutine w2(lout, z, nla, nlo, glamn, dgla, glomn, dglo)
subroutine put1(ival, gla, glo, h, nla, nlo, glamn, dgla, glomn, dglo, iclp)
program xyz2b
Part of the NADCON5 NADCON5 Core Library , Converts GMT *.grd to a *.b NADCON style grid file...