1 | SUBROUTINE extraw (pfild, kmask, ksize, |
---|
2 | $ cdfic, kunit, cdgrd, knumb, |
---|
3 | $ pwork, kwork, knbor, ldread) |
---|
4 | C**** |
---|
5 | C ***************************** |
---|
6 | C * OASIS ROUTINE - LEVEL 3 * |
---|
7 | C * ------------- ------- * |
---|
8 | C ***************************** |
---|
9 | C |
---|
10 | C**** *extraw* - Weighted extrapolation |
---|
11 | C |
---|
12 | C Purpose: |
---|
13 | C ------- |
---|
14 | C Do simple weighted extrapolation to replace land point values |
---|
15 | C |
---|
16 | C** Interface: |
---|
17 | C --------- |
---|
18 | C *CALL* *extraw (pfild, kmask, ksize, cdfic, kunit, |
---|
19 | C cdgrd. knumb, pwork, kwork, knbor, ldread)* |
---|
20 | C |
---|
21 | C Input: |
---|
22 | C ----- |
---|
23 | C pfild : field on source grid (real 1D) |
---|
24 | C kmask : land-sea mask on source grid (integer 1D) |
---|
25 | C ksize : size of field array on source grid (integer) |
---|
26 | C kunit : logical unit number for extrapolation file (integer) |
---|
27 | C cdfic : filename for extrapolation data (character) |
---|
28 | C cdgrd : locator to read data in cdfic (character) |
---|
29 | C knumb : extrapolation dataset identity number (integer) |
---|
30 | C pwork : temporary array to read weights (real 2D) |
---|
31 | C kwork : temporary array to read adresses (integer 2D) |
---|
32 | C knbor : maximum number of source grid neighbors with non zero |
---|
33 | C weights with a source grid-square (integer) |
---|
34 | C ldread : logical flag to read extrapolation data |
---|
35 | C |
---|
36 | C Output: |
---|
37 | C ------ |
---|
38 | C pfild : field on source grid (real 1D) |
---|
39 | C |
---|
40 | C Workspace: |
---|
41 | C --------- |
---|
42 | C None |
---|
43 | C |
---|
44 | C Externals: |
---|
45 | C --------- |
---|
46 | C locrint, locread |
---|
47 | C |
---|
48 | C Reference: |
---|
49 | C --------- |
---|
50 | C See OASIS manual (1995) |
---|
51 | C |
---|
52 | C History: |
---|
53 | C ------- |
---|
54 | C Version Programmer Date Description |
---|
55 | C ------- ---------- ---- ----------- |
---|
56 | C 2.2 L. Terray 97/12/16 created |
---|
57 | C 2.3 S. Valcke 99/04/30 added: printing levels |
---|
58 | C |
---|
59 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
60 | C |
---|
61 | C* ---------------------------- Include files --------------------------- |
---|
62 | C |
---|
63 | USE mod_kinds_oasis |
---|
64 | USE mod_unit |
---|
65 | USE mod_printing |
---|
66 | C |
---|
67 | C* ---------------------------- Argument declarations ------------------- |
---|
68 | C |
---|
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 |
---|
73 | C |
---|
74 | C* ---------------------------- Local declarations ---------------------- |
---|
75 | C |
---|
76 | CHARACTER*8 clweight, cladress |
---|
77 | C |
---|
78 | C* ---------------------------- Poema verses ---------------------------- |
---|
79 | C |
---|
80 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
81 | C |
---|
82 | C* 1. Initialization |
---|
83 | C -------------- |
---|
84 | C |
---|
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 |
---|
97 | C |
---|
98 | C* initialize error flag for I/O routine |
---|
99 | C |
---|
100 | iflag = 0 |
---|
101 | C |
---|
102 | C |
---|
103 | C* 2. Read extrapolation data the first time |
---|
104 | C -------------------------------------- |
---|
105 | C |
---|
106 | IF (ldread) THEN |
---|
107 | C |
---|
108 | C* Initialize locators and array sizes |
---|
109 | C |
---|
110 | WRITE(clweight,'(''WEIGHTS'',I1)') knumb |
---|
111 | WRITE(cladress,'(''ADRESSE'',I1)') knumb |
---|
112 | isize = ksize * knbor |
---|
113 | C |
---|
114 | C* Adress of connected points on source grid |
---|
115 | C |
---|
116 | CALL locrint (cladress, kwork, isize, kunit, iflag) |
---|
117 | C |
---|
118 | C* Checking |
---|
119 | C |
---|
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 |
---|
132 | C |
---|
133 | C* Weights of overlapped points on source grid |
---|
134 | C |
---|
135 | CALL locread (clweight, pwork, isize, kunit, iflag) |
---|
136 | C |
---|
137 | C* Checking |
---|
138 | C |
---|
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 |
---|
153 | C |
---|
154 | C |
---|
155 | C* 3. Do the mapping interpolation |
---|
156 | C ---------------------------- |
---|
157 | C |
---|
158 | C* Loop on all the target grid points |
---|
159 | C |
---|
160 | DO 310 ji = 1, ksize |
---|
161 | C* 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 |
---|
170 | C |
---|
171 | C |
---|
172 | C* 4. End of routine |
---|
173 | C -------------- |
---|
174 | C |
---|
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 |
---|