source: CPL/oasis3/trunk/src/mod/oasis3/src/extraw.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.5 KB
Line 
1      SUBROUTINE extraw (pfild, kmask, ksize,
2     $                   cdfic, kunit, cdgrd, knumb,
3     $                   pwork, kwork, knbor, ldread)
4C****
5C               *****************************
6C               * OASIS ROUTINE  -  LEVEL 3 *
7C               * -------------     ------- *
8C               *****************************
9C
10C**** *extraw* - Weighted extrapolation
11C
12C     Purpose:
13C     -------
14C     Do simple weighted extrapolation to replace land point values
15C
16C**   Interface:
17C     ---------
18C       *CALL*  *extraw (pfild, kmask, ksize, cdfic, kunit,
19C                        cdgrd. knumb, pwork, kwork, knbor, ldread)*
20C
21C     Input:
22C     -----
23C                pfild  : field on source grid (real 1D)
24C                kmask  : land-sea mask on source grid (integer 1D)
25C                ksize  : size of field array on source grid (integer)
26C                kunit  : logical unit number for extrapolation file (integer)
27C                cdfic  : filename for extrapolation data (character)
28C                cdgrd  : locator to read  data in cdfic (character)
29C                knumb  : extrapolation dataset identity number (integer)
30C                pwork  : temporary array to read weights (real 2D)
31C                kwork  : temporary array to read adresses (integer 2D)
32C                knbor  : maximum number of source grid neighbors with non zero
33C                         weights  with a source grid-square (integer)
34C                ldread : logical flag to read extrapolation data
35C
36C     Output:
37C     ------
38C                pfild  : field on source grid (real 1D)
39C
40C     Workspace:
41C     ---------
42C     None
43C
44C     Externals:
45C     ---------
46C     locrint, locread
47C
48C     Reference:
49C     ---------
50C     See OASIS manual (1995)
51C
52C     History:
53C     -------
54C       Version   Programmer     Date      Description
55C       -------   ----------     ----      ----------- 
56C       2.2       L. Terray      97/12/16  created
57C       2.3       S. Valcke      99/04/30  added: printing levels
58C
59C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60C
61C* ---------------------------- Include files ---------------------------
62C
63      USE mod_kinds_oasis
64      USE mod_unit
65      USE mod_printing
66C
67C* ---------------------------- Argument declarations -------------------
68C
69      REAL (kind=ip_realwp_p) pfild(ksize), pwork(knbor,ksize)
70      INTEGER (kind=ip_intwp_p) kwork(knbor,ksize), kmask(ksize)
71      CHARACTER*8 cdfic, cdgrd
72      LOGICAL ldread
73C
74C* ---------------------------- Local declarations ----------------------
75C
76      CHARACTER*8 clweight, cladress
77C
78C* ---------------------------- Poema verses ----------------------------
79C
80C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81C
82C*    1. Initialization
83C        --------------
84C
85      IF (nlogprt .GE. 2) THEN
86          WRITE (UNIT = nulou,FMT = *) ' '
87          WRITE (UNIT = nulou,FMT = *) ' '
88          WRITE (UNIT = nulou,FMT = *) 
89     $    '           ROUTINE extraw  -  Level 3'
90          WRITE (UNIT = nulou,FMT = *) 
91     $    '           **************     *******'
92          WRITE (UNIT = nulou,FMT = *) ' '
93          WRITE (UNIT = nulou,FMT = *) ' weighted extrapolation'
94          WRITE (UNIT = nulou,FMT = *) ' '
95          WRITE (UNIT = nulou,FMT = *) ' '
96      ENDIF
97C
98C* initialize error flag for I/O routine
99C
100      iflag = 0
101C
102C
103C*    2. Read extrapolation data the first time
104C        --------------------------------------
105C
106      IF (ldread) THEN
107C
108C* Initialize locators and array sizes
109C
110          WRITE(clweight,'(''WEIGHTS'',I1)') knumb
111          WRITE(cladress,'(''ADRESSE'',I1)') knumb
112          isize = ksize * knbor
113C
114C* Adress of connected points on source grid
115C
116          CALL locrint (cladress, kwork, isize, kunit, iflag)
117C
118C* Checking
119C
120          IF (iflag .NE. 0) THEN
121              CALL prcout
122     $            ('WARNING: problem in reading mapping data',
123     $            cdgrd, 1)
124              CALL prcout
125     $            ('Could not get adress array', cladress, 1)
126              CALL prtout
127     $            ('Error reading logical unit', kunit, 1)
128              CALL prcout
129     $            ('It is connected to file', cdfic, 1)
130              CALL HALTE ('STOP in extraw') 
131          ENDIF
132C
133C* Weights of overlapped points on source grid
134C
135          CALL locread (clweight, pwork, isize, kunit, iflag)
136C
137C* Checking
138C
139          IF (iflag .NE. 0) THEN
140              CALL prcout
141     $            ('WARNING: problem in reading mapping data',
142     $            cdgrd, 1)
143              CALL prcout
144     $            ('Could not get weight array', clweight, 1)
145              CALL prtout
146     $            ('Error reading logical unit', kunit, 1)
147              CALL prcout
148     $            ('It is connected to file', cdfic, 1)
149              CALL HALTE ('STOP in extraw') 
150          ENDIF
151          ldread = .FALSE. 
152      ENDIF
153C
154C
155C*    3. Do the mapping interpolation
156C        ----------------------------
157C
158C* Loop on all the target grid points
159C
160      DO 310 ji = 1, ksize
161C* If it is a land point, we extrapolate
162        IF (kmask(ji) .EQ. 1) THEN
163            zsum = 0.
164            DO 320 jk = 1, knbor
165              zsum = zsum + pwork(jk,ji) * pfild(kwork(jk,ji))
166 320        CONTINUE
167            pfild(ji) = zsum
168        ENDIF
169 310  CONTINUE
170C
171C
172C*    4. End of routine
173C        --------------
174C
175      IF (nlogprt .GE. 2) THEN
176          WRITE (UNIT = nulou,FMT = *) ' '
177          WRITE (UNIT = nulou,FMT = *) 
178     $    '          --------- End of routine extraw ---------'
179          CALL FLUSH (nulou)
180      ENDIF
181      RETURN
182      END
Note: See TracBrowser for help on using the repository browser.