source: CPL/oasis3/trunk/src/lib/anaism/src/pmrhal.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: 5.0 KB
Line 
1      SUBROUTINE pmrhal (pr1to2, k1to2, kw1to2,
2     $                   px1, py1, kmsk1, kngx1, kngy1, cdper1, kper1,
3     $                   px2, py2, kmsk2, kngx2, kngy2, cdper2, kper2,
4     $                   kvma1, kvma2, kmskz2, kvmsz2)
5C****
6C               *****************************
7C               * OASIS ROUTINE  -  LEVEL 3 *
8C               * -------------     ------- *
9C               *****************************
10C
11C**** *pmrhal* - Calculate weights and adresses for all the target grid 
12C
13C     Purpose:
14C     -------
15C     For each point of a target grid 2 give the kw1to2 closest neighbours 
16C     adresses k1to2 in source grid 1 and their weight pr1to2. 
17C     Here, neighbours are those in the mesh overlapped by each target point
18C     and weights are proportional to the surface mesh intersections. 
19C     2D grid assumptions are made here.
20C     
21C
22C**   Interface:
23C     ---------
24C       *CALL*  *pmrhal(pr1to2, k1to2, kw1to2,
25C                       px1, py1, kmsk1, kngx1, kngy1, cdper1, kper1,
26C                       px2, py2, kmsk2, kngx2, kngy2, cdper2, kper2,
27C                       kvma1, kvma2, kmskz2, kvmsz2)*
28C     Input:
29C     -----
30C                kw1to2  : maximum number of overlapped neighbors
31C                px1     : longitudes for source grid (real 2D)
32C                py1     : latitudes for source grid (real 2D)
33C                kmsk1   : the mask for source grid (integer 2D)
34C                kngx1   : number of longitudes for source grid
35C                kngy1   : number of latitudes for source grid
36C                cdper1  : source grid periodicity 
37C                kper1   : number of overlapped points for source grid 
38C                px2     : longitudes for target grid (real 2D)
39C                py2     : latitudes for target grid (real 2D)
40C                kmsk2   : the mask of target grid (integer 2D)
41C                kngx2   : number of longitudes for target grid
42C                kngy2   : number of latitudes for target grid
43C                cdper2  : target grid periodicity
44C                kper2   : number of overlapped points for target grid 
45C                kvma1   : the value of the mask for source grid
46C                kvma2   : the value of the mask for target grid 
47C                kvmsz2  : mask value for array kmskz2
48C
49C     Output:
50C     ------
51C                pr1to2  : weights for Anaism interpolation (real 3D)
52C                k1to2   : source grid neighbors adresses (integer 3D)
53C                kmskz2  : number of source grid neighbors (integer 2D)
54C
55C     Workspace:
56C     ---------
57C     None
58C
59C     External:
60C     --------
61C     pmesh, pmrho
62C
63C     References:
64C     ----------
65C     O. Thual, Simple ocean-atmosphere interpolation. 
66C               Part A: The method, EPICOA 0629 (1992)
67C               Part B: Software implementation, EPICOA 0630 (1992)
68C     See also OASIS manual (1995)
69C
70C     History:
71C     -------
72C       Version   Programmer     Date      Description
73C       -------   ----------     ----      ----------- 
74C       1.1       O. Thual       93/04/15  created 
75C       2.0       L. Terray      95/10/01  modified: new structure
76C       2.3       L. Terray      99/09/15  changed periodicity variables
77C
78C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79C
80C* ---------------------------- Include files ---------------------------
81C
82      USE mod_kinds_oasis
83      USE mod_unit
84C
85C* ---------------------------- Argument declarations -------------------
86C
87      REAL (kind=ip_realwp_p) px1(kngx1,kngy1), py1(kngx1,kngy1)
88      REAL (kind=ip_realwp_p) px2(kngx2,kngy2), py2(kngx2,kngy2)
89      REAL (kind=ip_realwp_p) pr1to2(kw1to2,kngx2,kngy2)
90      INTEGER (kind=ip_intwp_p) kmsk1(kngx1,kngy1), kmsk2(kngx2,kngy2)
91      INTEGER (kind=ip_intwp_p) k1to2(kw1to2,kngx2,kngy2), 
92     $    kmskz2(kngx2,kngy2)
93      CHARACTER*8 cdper1, cdper2
94C
95C* ---------------------------- Poema verses ----------------------------
96C
97C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98C
99C*    1. Neighbours determination
100C        ------------------------
101C 
102      DO 110 jy = 1, kngy2
103        DO 120 jx = 1, kngx2
104C
105C* For all target grid points:  zero all weights and set adresses to one
106C 
107          DO 130 jwg = 1, kw1to2
108            pr1to2(jwg,jx,jy) = 0.
109            k1to2(jwg,jx,jy) = 1 
110 130      CONTINUE
111C
112C* Calculate the surface of all the target grid squares (masked or not)
113C
114          CALL pmesh (jx, jy, px2, py2, kngx2, kngy2, cdper2, kper2,
115     $                z2xi, z2xs, z2yi, z2ys)
116C
117C* Calculate the neighbors in the source grid and their weights
118C
119          CALL pmrho (pr1to2(1,jx,jy), k1to2(1,jx,jy), kw1to2,
120     $                z2xi, z2xs, z2yi, z2ys,
121     $                px1, py1, kmsk1, kngx1, kngy1, cdper1, kper1,
122     $                kvma1, kmskz2(jx,jy), kvmsz2)
123C
124C* For masked points: 
125C
126          IF (kmsk2(jx,jy) .EQ. kvma2) THEN
127              DO 140 jwg = 1, kw1to2
128                pr1to2(jwg,jx,jy) = 0.
129                k1to2(jwg,jx,jy) = 1 
130 140          CONTINUE
131          ENDIF
132 120    CONTINUE
133 110  CONTINUE
134C
135C* End of routine
136C
137      RETURN
138      END
Note: See TracBrowser for help on using the repository browser.