NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
bilin.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page bilin
4 c> \endif
5 c>
6 c> Subroutine to perform bilinear interpolation
7 c>
8 c> Performs a bilinear interpolation
9 c> at location `xla,xlo` off of grid `data`, whose
10 c> header information is the standard `.b` header
11 c> information
12 c>
13 c> \param[in] data Input Data assumed to be real*4
14 c> \param[in] glamn minimum latitude (real*8 decimal degrees) `*.b`
15 c> \param[in] glomn minimum longitude (real*8 decimal degrees) `*.b`
16 c> \param[in] dla latitude spacing (real*8 decimal degrees) `*.b`
17 c> \param[in] dlo longitude spacing (real*8 decimal degrees) `*.b`
18 c> \param[in] nla number of lat rows (integer*4) `*.b`
19 c> \param[in] nlo number of lon cols (integer*4) `*.b`
20 c> \param[in] maxla actual dimensioned size of "data" in rows `*.b`
21 c> \param[in] maxlo actual dimensioned size of "data" in cols `*.b`
22 c> \param[in] xla lat of pt for interpolation (real*8 dec. def)
23 c> \param[in] xlo lon of pt for interpolation (real*8 dec. def)
24 c> \param[out] val interpolated value (real*8)
25  subroutine bilin(data,glamn,glomn,dla,dlo,
26  *nla,nlo,maxla,maxlo,xla,xlo,val)
27 c - Subroutine to perform a bilinear interpolation
28 c - at location "xla,xlo" off of grid "data", whose
29 c - header information is the standard ".b" header
30 c - information of
31 c - glamn = minimum latitude (real*8 decimal degrees)
32 c - glomn = minimum longitude (real*8 decimal degrees)
33 c - dla = latitude spacing (real*8 decimal degrees)
34 c - dlo = longitude spacing (real*8 decimal degrees)
35 c - nla = number of lat rows (integer*4)
36 c - nlo = number of lon cols (integer*4)
37 c - maxla = actual dimensioned size of "data" in rows
38 c - maxlo = actual dimensioned size of "data" in cols
39 
40 c - data is assumed real*4
41  implicit real*8 (a-h,o-z)
42  real*4 data(maxla,maxlo)
43  logical onedlat,onedlon
44 
45 c - HACK
46 c do 8787 i=1,nla
47 c do 8788 j=1,nlo
48 c write(6,8789)i,j,data(i,j)
49 c8788 continue
50 c8787 continue
51 c8789 format(i5,1x,i5,1x,f20.10)
52 
53 c - Find the row of xla
54  difla = (xla - glamn)
55  ratla = difla / dla
56  ila = int(ratla)+1
57  gla0 = glamn + (ila-1)*dla
58 
59 c - Find the col of xlo
60  diflo = (xlo - glomn)
61  ratlo = diflo / dlo
62  ilo = int(ratlo)+1
63  glo0 = glomn + (ilo-1)*dlo
64 
65 
66 c - Do the interpolation.
67  t=(xlo-glo0)/dlo
68  u=(xla-gla0)/dla
69 
70  val = (1.d0-t)*(1.d0-u)*data(ila ,ilo )
71  * + ( t)*(1.d0-u)*data(ila ,ilo+1)
72  * + ( t)*( u)*data(ila+1,ilo+1)
73  * + (1.d0-t)*( u)*data(ila+1,ilo )
74 
75 c - HACK
76  return
77  write(6,198)xla,xlo
78  write(6,200)ila,ilo,gla0,glo0
79  write(6,199)xla-gla0,xlo-glo0
80  write(6,201)ila,ilo,gla0,glo0,
81  *data(ila,ilo)
82  write(6,201)ila,ilo+1,gla0,glo0+dlo,
83  *data(ila,ilo+1)
84  write(6,201)ila+1,ilo,gla0+dla,glo0,
85  *data(ila+1,ilo)
86  write(6,201)ila+1,ilo+1,gla0+dla,glo0+dlo,
87  *data(ila+1,ilo+1)
88  write(6,202)'SW',(1.d0-t)*(1.d0-u)
89  write(6,202)'SE',( t)*(1.d0-u)
90  write(6,202)'NW',( t)*( u)
91  write(6,202)'NE',(1.d0-t)*( u)
92  202 format(
93  *'Weight to ',a,' corner = ',f20.15)
94 
95  198 format(
96  *6x,'bilin.f: lat/lon = ',f10.6,1x,f10.6)
97  199 format(
98  *6x,'bilin.f: diff from SW corner of cell = ',f10.6,1x,f10.6)
99  200 format(
100  *6x,'bilin.f: SW corner: ',i6,1x,i6,1x,f10.6,1x,f10.6)
101  201 format(
102  *6x,2(i6,1x),2(f10.6,1x),f20.15)
103 
104 
105 c write(6,801)xla,xlo,ila,ilo,gla0,glo0,t,u,val
106  801 format(f15.8,1x,f15.8,1x,i6,1x,i6,1x,
107  *f15.8,1x,f15.8,1x,f8.6,1x,f8.6,1x,f20.10)
108 
109 c write(6,802)data(ila ,ilo ),
110 c *data(ila ,ilo+1),data(ila+1,ilo+1),
111 c *data(ila+1,ilo )
112  802 format(4(f15.8,1x))
113 
114  return
115  end
116 
117 
118 
119 
subroutine bilin(data, glamn, glomn, dla, dlo, nla, nlo, maxla, maxlo, xla, xlo, val)
Subroutine to perform bilinear interpolation.
Definition: bilin.f:27