33 implicit double precision(a-h,o-z)
34 parameter(len=6000*40000)
35 real*4 z(len),zrec(40000)
36 integer h(len),hrec(40000)
38 equivalence(h(1),z(1)),(hrec(1),zrec(1))
39 common/gstuff/glamn,dgla,glamx,glomn,dglo,glomx,nla,nlo,nclip
46 write(*,*)
'program regrd2' 50 2
format(
'Enter master grid file: ',$)
53 open(lin,file=fname,status=
'old',form=
'unformatted')
54 read(lin) glamn,glomn,dgla,dglo,nla,nlo,ikind
55 glamx=glamn+dgla*(nla-1)
56 glomx=glomn+dglo*(nlo-1)
57 if(nla*nlo.gt.len) stop 12345
58 if(nla.lt.4.or.nlo.lt.4) stop 54321
62 write(*,*)
'kind=',ikind
63 write(*,*)
'LAT min=',glamn
64 write(*,*)
' del=',dgla,
' # lat=',nla
65 write(*,*)
' max=',glamx
66 write(*,*)
'LON min=',glomn
67 write(*,*)
' del=',dglo,
' # lon=',nlo
68 write(*,*)
' max=',glomx
72 3
format(
'Enter regridded output file:',$)
74 open(lout,file=fname,status=
'new',form=
'unformatted')
115 94
format(
'Enter new number of rows (latitude) : ',$)
117 if(nla2.lt.0)
go to 93
120 99
format(
'Enter new number of columns (longitude): ',$)
122 if(nlo2.lt.0)
go to 98
128 dgla2=(glamx2-glamn2)/(nla2-1)
129 dglo2=(glomx2-glomn2)/(nlo2-1)
136 call r1(lin,h,nla,nlo)
138 call r2(lin,z,nla,nlo)
144 write(lout) glamn2,glomn2,dgla2,dglo2,nla2,nlo2,ikind
148 gla=glamn2+(ir-1)*dgla2
150 glo=glomn2+(ic-1)*dglo2
151 call bquad1(h,gla,glo,ival)
152 if(ival.ge.2147483647) stop 11111
155 write(lout) (hrec(i),i=1,nlo2)
159 gla=glamn2+(ir-1)*dgla2
161 glo=glomn2+(ic-1)*dglo2
162 call bquad2(z,gla,glo,val)
163 if(val.ge.1.d30) stop 22222
166 write(lout) (zrec(i),i=1,nlo2)
172 subroutine bquad1(h,gla,glo,ival)
177 implicit double precision(a-h,o-z)
179 real*4 x,y,fx0,fx1,fx2,val,qterp1,qterp2
180 external qterp1,qterp2
181 common/gstuff/glamn,dgla,glamx,glomn,dglo,glomx,nla,nlo,nclip
183 if(gla.lt.glamn.or.gla.gt.glamx.or.
184 * glo.lt.glomn.or.glo.gt.glomx)
then 191 ix=(glo-glomn)/dglo+1.d0
204 x=(glo-dglo*(ix-1)-glomn)/dglo
208 if(x.lt.0.5.and.ix.gt.1)
then 214 if(x.lt.0..or.x.gt.2.) stop 55555
218 jy=(gla-glamn)/dgla+1.d0
227 y=(gla-dgla*(jy-1)-glamn)/dgla
228 if(y.lt.0.5.and.jy.gt.1)
then 234 if(y.lt.0..or.y.gt.2.) stop 33333
236 fx0=qterp1(x, h(jy ,ix ), h(jy ,ix1), h(jy ,ix2))
237 fx1=qterp1(x, h(jy1,ix ), h(jy1,ix1), h(jy1,ix2))
238 fx2=qterp1(x, h(jy2,ix ), h(jy2,ix1), h(jy2,ix2))
239 val=qterp2(y, fx0 , fx1 , fx2 )
245 subroutine bquad2(z,gla,glo,val)
250 implicit double precision(a-h,o-z)
252 real*4 x,y,fx0,fx1,fx2,qterp2
254 common/gstuff/glamn,dgla,glamx,glomn,dglo,glomx,nla,nlo,nclip
256 if(gla.lt.glamn.or.gla.gt.glamx.or.
257 * glo.lt.glomn.or.glo.gt.glomx)
then 264 ix=(glo-glomn)/dglo+1.d0
277 x=(glo-dglo*(ix-1)-glomn)/dglo
281 if(x.lt.0.5.and.ix.gt.1)
then 287 if(x.lt.0..or.x.gt.2.) stop 66666
291 jy=(gla-glamn)/dgla+1.d0
300 y=(gla-dgla*(jy-1)-glamn)/dgla
301 if(y.lt.0.5.and.jy.gt.1)
then 307 if(y.lt.0..or.y.gt.2.) stop 44444
309 fx0= qterp2(x, z(jy ,ix ), z(jy ,ix1), z(jy ,ix2))
310 fx1= qterp2(x, z(jy1,ix ), z(jy1,ix1), z(jy1,ix2))
311 fx2= qterp2(x, z(jy2,ix ), z(jy2,ix1), z(jy2,ix2))
312 val=dble(qterp2(y, fx0 , fx1 , fx2 ))
317 real function qterp1(x,if0,if1,if2)
329 qterp1=if0 + x*idf0 + 0.5*x*(x-1.)*id2f0
333 real function qterp2(x,f0,f1,f2)
345 qterp2=f0 + x*df0 + 0.5*x*(x-1.)*d2f0
349 subroutine r1(lin,h,nla,nlo)
353 implicit double precision(a-h,o-z)
357 1
read(lin) (h(i,j),j=1,nlo)
361 subroutine r2(lin,z,nla,nlo)
365 implicit double precision(a-h,o-z)
369 1
read(lin) (z(i,j),j=1,nlo)
subroutine bquad2(z, gla, glo, val)
subroutine bquad1(h, gla, glo, ival)
real function qterp2(x, f0, f1, f2)
real function qterp1(x, if0, if1, if2)
subroutine r2(lin, z, nla, nlo)
program regrd2
Part of the NADCON5 NADCON5 Core Library , regrid data.
subroutine r1(lin, h, nla, nlo)