source: CPL/oasis3/trunk/src/mod/oasis3/src/mod_bilin.f @ 1677

Last change on this file since 1677 was 1677, checked in by aclsce, 12 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 3.4 KB
Line 
1      MODULE mod_bilin
2      CONTAINS
3      SUBROUTINE bilin ( pout, px, py, kndx, kndy, pax, pay, kpts
4     $                 , pin, ki, kj)
5C****
6C               *****************************
7C               * OASIS ROUTINE  -  LEVEL 3 *
8C               * -------------     ------- *
9C               *****************************
10C
11C**** *bilin* - Bilinear interpolation
12C
13C     Purpose: Proceed to a bilinear interpolation
14C     -------
15C
16C
17C**   Interface:
18C     ---------
19C     *CALL* *bilin* ( zo, px, py, kndx, kndy, pax, pay, kpts
20C     $                 , z, ki, kj)
21C
22C**   Method
23C     ------
24C
25C     *   *   *   *
26C
27C     *   *   *   *
28C           #        ==>   pt (x,y)
29C     *  (=)  *   *  ==> = pt (kndx, kndy)
30C
31C     *   *   *   *
32C
33C     Input:
34C     -----
35C                px      : longitudes of target grid
36C                py      : latitudes of target grid
37C                kndx    : index of source point in source longitude
38C                kndy    : index of source point in source latitude
39C                pax     : longitudes of source grid
40C                pay     : latitudes of source grid
41C                kpts    : dimension of target grid
42C                pin     : input field on source grid
43C                ki, kj  : dimension of source grid
44C
45C     Output:
46C     ------
47C                pout    : interpolated field on target grid
48C
49C     Workspace:
50C     ---------
51C     Local variables
52C          zy1, zy2, zy3, zy4, i, j, zdx, zdy ,z1, z2, z3, z4
53C     Statement function
54C          cubic
55C
56C     Externals:
57C     ---------
58C     None
59C
60C     Reference:
61C     ---------
62C     See OASIS manual (1995)
63C
64C     History:
65C     -------
66C       Version   Programmer     Date      Description
67C       -------   ----------     ----      ----------- 
68C       2.0       O. Marti       96/07/15  Created
69C
70C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71C
72C *
73      IMPLICIT NONE
74C
75C* ---------------------------- Argument declarations -------------------
76C
77      INTEGER, INTENT ( in) :: kpts, ki, kj
78      REAL, DIMENSION ( kpts), INTENT ( in) :: px, py
79      REAL, DIMENSION ( 0: ki + 1), INTENT ( in) :: pax
80      REAL, DIMENSION ( 0: kj + 1), INTENT ( in) :: pay
81      REAL, DIMENSION ( 0: ki + 1, 0: kj + 1), INTENT ( in) :: pin 
82      INTEGER, DIMENSION ( kpts), INTENT ( in) :: kndx, kndy
83      REAL, DIMENSION ( kpts), INTENT ( out) :: pout
84C
85C* ---------------------------- Local declarations ----------------------
86C
87      REAL    :: zy1, zy2
88      INTEGER :: jn, ji, jj
89C
90C* ---------------------------- Statement fucntions----------------------
91C
92      REAL  ::  zlinear, zdx, zdy , z1, z2
93C
94      zlinear ( z1, z2, zdx) = ( 1.0  - zdx) * z1 + zdx * z2
95C
96C* ---------------------------- Poema verses ----------------------------
97C
98C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99C
100C*    1. Interpolation
101C        -------------
102C
103      DO jn = 1, kpts
104        ji  = kndx ( jn) ; jj  = kndy ( jn)
105        zdx = ( px ( jn) - pax ( ji)) / ( pax ( ji + 1) - pax ( ji))
106        zdy = ( py ( jn) - pay ( jj)) / ( pay ( jj + 1) - pay ( jj))
107        zy1 = zlinear ( pin ( ji, jj  ), pin ( ji+1, jj  ), zdx)
108        zy2 = zlinear ( pin ( ji, jj+1), pin ( ji+1, jj+1), zdx)
109        pout ( jn) = zlinear ( zy1, zy2, zdy)
110      END DO
111C
112C
113C*    3. End of routine
114C        --------------
115C
116      RETURN
117      END SUBROUTINE bilin
118      END MODULE mod_bilin
Note: See TracBrowser for help on using the repository browser.