1 | SUBROUTINE subgrid (pfldn, pfldo, ksizn, ksizo, |
---|
2 | $ pcoar, pfine, pdqdt, |
---|
3 | $ cdfic, kunit, knumb, cdname, |
---|
4 | $ pwork, kwork, knbor, ldread, cdtype) |
---|
5 | C**** |
---|
6 | C ***************************** |
---|
7 | C * OASIS ROUTINE - LEVEL 3 * |
---|
8 | C * ------------- ------- * |
---|
9 | C ***************************** |
---|
10 | C |
---|
11 | C**** *subgrid* - submesh variabiity |
---|
12 | C |
---|
13 | C Purpose: |
---|
14 | C ------- |
---|
15 | C Interpolate with subgrid linear technique. This is rigorously |
---|
16 | C conservative if the models exchange fields at every timestep |
---|
17 | C and if sea-land mismatch is accounted for. |
---|
18 | C |
---|
19 | C** Interface: |
---|
20 | C --------- |
---|
21 | C *CALL* *subgrid (pfild, ksize, pcoar, pfine, pdqdt)* |
---|
22 | C |
---|
23 | C Input: |
---|
24 | C ----- |
---|
25 | C pfldo : initial field on source grid (real 1D) |
---|
26 | C ksizn : size of final field array (integer) |
---|
27 | C ksizo : size of initial field array (integer) |
---|
28 | C pcoar : coarse grid additional field (real 1D) |
---|
29 | C pfine : fine grid additional field (real 1D) |
---|
30 | C pdqdt : coarse grid coupling ratio (real 1D) |
---|
31 | C kunit : logical unit numbers for subgrid file (integer) |
---|
32 | C cdfic : filename for subgrid data (character) |
---|
33 | C knumb : subgrid dataset identity number (integer) |
---|
34 | C cdname : name of final field on target grid (character) |
---|
35 | C pwork : temporary array to read subgrid weights (real 1D) |
---|
36 | C kwork : temporary array to read subgrid array (integer 1D) |
---|
37 | C knbor : maximum number of source grid neighbors with non zero |
---|
38 | C intersection with a target grid-square (integer) |
---|
39 | C The source grid is here the coarse grid while the |
---|
40 | C target grid is the fine one. |
---|
41 | C ldread : logical flag to read subgrid data (logical) |
---|
42 | C cdtype : type of subgrid interpolation (character) |
---|
43 | C |
---|
44 | C Output: |
---|
45 | C ------ |
---|
46 | C pfldn : final field on target grid (real 1D) |
---|
47 | C |
---|
48 | C Workspace: |
---|
49 | C --------- |
---|
50 | C None |
---|
51 | C |
---|
52 | C Externals: |
---|
53 | C --------- |
---|
54 | C None |
---|
55 | C |
---|
56 | C Reference: |
---|
57 | C --------- |
---|
58 | C See OASIS manual (1995) |
---|
59 | C |
---|
60 | C History: |
---|
61 | C ------- |
---|
62 | C Version Programmer Date Description |
---|
63 | C ------- ---------- ---- ----------- |
---|
64 | C 2.0 L. Terray 96/02/01 created |
---|
65 | C 2.1 L. Terray 96/08/05 modified: new structure |
---|
66 | C 2.3 S. Valcke 99/04/30 added: printing levels |
---|
67 | C |
---|
68 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
69 | C |
---|
70 | C* ---------------------------- Include files --------------------------- |
---|
71 | C |
---|
72 | USE mod_kinds_oasis |
---|
73 | USE mod_unit |
---|
74 | USE mod_printing |
---|
75 | C |
---|
76 | C* ---------------------------- Argument declarations ------------------- |
---|
77 | C |
---|
78 | REAL (kind=ip_realwp_p) pfldn(ksizn), pfldo(ksizo) |
---|
79 | REAL (kind=ip_realwp_p) pcoar(ksizo), pfine(ksizn), pdqdt(ksizo) |
---|
80 | REAL (kind=ip_realwp_p) pwork(knbor,ksizn) |
---|
81 | INTEGER (kind=ip_intwp_p) kwork(knbor,ksizn) |
---|
82 | CHARACTER*8 cdfic, cdname, cdtype |
---|
83 | LOGICAL ldread |
---|
84 | C |
---|
85 | C* ---------------------------- Local declarations ---------------------- |
---|
86 | C |
---|
87 | CHARACTER*8 clweight, cladress |
---|
88 | C |
---|
89 | C* ---------------------------- Poema verses ---------------------------- |
---|
90 | C |
---|
91 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
92 | C |
---|
93 | C* 1. Initialization |
---|
94 | C -------------- |
---|
95 | C |
---|
96 | IF (nlogprt .GE. 2) THEN |
---|
97 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
98 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
99 | WRITE (UNIT = nulou,FMT = *) |
---|
100 | $ ' ROUTINE subgrid - Level 3' |
---|
101 | WRITE (UNIT = nulou,FMT = *) |
---|
102 | $ ' *************** *******' |
---|
103 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
104 | WRITE (UNIT = nulou,FMT = *) ' Linear subgrid interpolation' |
---|
105 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
106 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
107 | ENDIF |
---|
108 | C |
---|
109 | C* initialize error flag for I/O routine |
---|
110 | C |
---|
111 | iflag = 0 |
---|
112 | C |
---|
113 | C |
---|
114 | C* 2. Read subgrid data the first time |
---|
115 | C -------------------------------- |
---|
116 | C |
---|
117 | IF (ldread) THEN |
---|
118 | C |
---|
119 | C* Initialize locators and array sizes |
---|
120 | C |
---|
121 | WRITE(clweight,'(''WEIGHTS'',I1)') knumb |
---|
122 | WRITE(cladress,'(''ADRESSE'',I1)') knumb |
---|
123 | isize = ksizn * knbor |
---|
124 | C |
---|
125 | C* Adress of overlapped points on source grid |
---|
126 | C |
---|
127 | CALL locrint (cladress, kwork, isize, kunit, iflag) |
---|
128 | C |
---|
129 | C* Checking |
---|
130 | C |
---|
131 | IF (iflag .NE. 0) THEN |
---|
132 | CALL prcout |
---|
133 | $ ('WARNING: problem in reading |
---|
134 | $ subgrid data for field', |
---|
135 | $ cdname, 1) |
---|
136 | CALL prcout |
---|
137 | $ ('Could not get adress array', cladress, 1) |
---|
138 | CALL prtout |
---|
139 | $ ('Error reading logical unit', kunit, 1) |
---|
140 | CALL prcout |
---|
141 | $ ('It is connected to file', cdfic, 1) |
---|
142 | CALL HALTE ('STOP in subgrid') |
---|
143 | ENDIF |
---|
144 | C |
---|
145 | C* Weights of overlapped points on source grid |
---|
146 | C |
---|
147 | CALL locread (clweight, pwork, isize, kunit, iflag) |
---|
148 | C |
---|
149 | C* Checking |
---|
150 | C |
---|
151 | IF (iflag .NE. 0) THEN |
---|
152 | CALL prcout |
---|
153 | $ ('WARNING: problem in reading |
---|
154 | $ subgrid data for field', |
---|
155 | $ cdname, 1) |
---|
156 | CALL prcout |
---|
157 | $ ('Could not get weight array', clweight, 1) |
---|
158 | CALL prtout |
---|
159 | $ ('Error reading logical unit', kunit, 1) |
---|
160 | CALL prcout |
---|
161 | $ ('It is connected to file', cdfic, 1) |
---|
162 | CALL HALTE ('STOP in subgrid') |
---|
163 | ENDIF |
---|
164 | ldread = .FALSE. |
---|
165 | ENDIF |
---|
166 | C |
---|
167 | C |
---|
168 | C* 3. Modify main field according to type of subgrid interpolation |
---|
169 | C ------------------------------------------------------------ |
---|
170 | C* Case of non solar flux |
---|
171 | C |
---|
172 | IF (cdtype .EQ. 'NONSOLAR') THEN |
---|
173 | C |
---|
174 | C* Loop on all target points |
---|
175 | C |
---|
176 | DO 310 ji = 1, ksizn |
---|
177 | zsum = 0.0 |
---|
178 | C |
---|
179 | C* Loop on active neighbors |
---|
180 | C |
---|
181 | DO 320 jk = 1, knbor |
---|
182 | IF (kwork(jk,ji) .gt. 0) then |
---|
183 | zsum = zsum + pwork(jk,ji) * |
---|
184 | $ ( pfldo(kwork(jk,ji)) + pdqdt(kwork(jk,ji)) |
---|
185 | $ * ( pfine(ji) - pcoar(kwork(jk,ji)) ) ) |
---|
186 | ENDIF |
---|
187 | 320 CONTINUE |
---|
188 | pfldn(ji) = zsum |
---|
189 | 310 CONTINUE |
---|
190 | C |
---|
191 | C* Case of solar flux |
---|
192 | C |
---|
193 | ELSE IF (cdtype .EQ. 'SOLAR') THEN |
---|
194 | DO 330 ji = 1, ksizn |
---|
195 | zsum = 0.0 |
---|
196 | C |
---|
197 | C* Loop on active neighbors |
---|
198 | C |
---|
199 | DO 340 jk = 1, knbor |
---|
200 | IF (kwork(jk,ji) .gt. 0) then |
---|
201 | zsum = zsum + pwork(jk,ji) * pfldo(kwork(jk,ji)) * |
---|
202 | $ ( 1. - pfine(ji)) / ( 1. - pcoar(kwork(jk,ji))) |
---|
203 | ENDIF |
---|
204 | 340 CONTINUE |
---|
205 | pfldn(ji) = zsum |
---|
206 | 330 CONTINUE |
---|
207 | ENDIF |
---|
208 | C |
---|
209 | C |
---|
210 | C* 4. End of routine |
---|
211 | C -------------- |
---|
212 | C |
---|
213 | IF (nlogprt .GE. 2) THEN |
---|
214 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
215 | WRITE (UNIT = nulou,FMT = *) |
---|
216 | $ ' --------- End of routine subgrid ---------' |
---|
217 | CALL FLUSH (nulou) |
---|
218 | ENDIF |
---|
219 | RETURN |
---|
220 | END |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | |
---|