15 SUBROUTINE inter_barxy(dlonid, dlatid, champ, rlonimod, rlatimod, champint)
20 include
"dimensions.h"
29 REAL,
intent(in):: dlonid(:)
32 REAL,
intent(in):: dlatid(:), champ(:, :), rlonimod(:)
34 REAL,
intent(in):: rlatimod(:)
37 real,
intent(out):: champint(:, :)
45 REAL champy(
iim, size(champ, 2))
46 integer j, i, jnterfd, jmods
48 REAL yjmod(size(champint, 2))
51 REAL yjdat(size(dlatid) + 1)
56 jnterfd =
assert_eq(
size(champ, 2) - 1,
size(dlatid), &
57 "inter_barxy jnterfd")
58 jmods =
size(champint, 2)
59 call assert(
size(champ, 1) ==
size(dlonid),
"inter_barxy size(champ, 1)")
60 call assert((/
size(rlonimod),
size(champint, 1)/) ==
iim, &
62 call assert(any(jmods == (/jjm, jjm + 1/)),
'inter_barxy jmods')
63 call assert(
size(rlatimod) == jjm,
"inter_barxy size(rlatimod)")
67 IF (rlatimod(i) >= rlatimod(i-1)) stop &
68 '"inter_barxy": "rlatimod" should be strictly decreasing'
72 IF (jmods == jjm + 1)
THEN
73 IF (90. - yjmod(jjm) < 0.01) stop &
74 '"inter_barxy": with jmods = jjm + 1, yjmod(jjm) should be < 90.'
77 IF (abs(yjmod(jjm) - 90.) > 0.01) stop &
78 '"inter_barxy": with jmods = jjm, yjmod(jjm) should be 90.'
81 if (jmods == jjm + 1) yjmod(jjm + 1) = 90.
84 champy(:, j) =
inter_barx(dlonid, champ(:, j), rlonimod)
88 IF (decrois) champy(:, :) = champy(:, jnterfd + 1:1:-1)
90 champint(i, :) =
inter_bary(yjdat, champy(i, :), yjmod)
92 champint(:, :) = champint(:, jmods:1:-1)
94 IF (jmods == jjm + 1)
THEN
96 champint(:, 1) = sum(
aire(:
iim, 1) * champint(:, 1)) /
apoln
97 champint(:, jjm + 1) = sum(
aire(:
iim, jjm + 1) &
98 * champint(:, jjm + 1)) /
apols
123 REAL,
intent(in):: dlonid(:)
124 real,
intent(in):: fdat(:)
125 real,
intent(in):: rlonimod(:)
127 real inter_barx(size(rlonimod))
131 INTEGER idatmax, imodmax
132 REAL xxid(size(dlonid)+1), xxd(size(dlonid)+1), fdd(size(dlonid)+1)
133 REAL fxd(size(dlonid)+1), xchan(size(dlonid)+1), fdchan(size(dlonid)+1)
134 REAL xxim(size(rlonimod))
136 REAL x0, xim0, dx, dxm
137 REAL chmin, chmax, pi
139 INTEGER imod, idat, i, ichang, id0, id1, nid, idatmax1
143 idatmax =
assert_eq(
size(dlonid),
size(fdat),
"inter_barx idatmax")
144 imodmax =
size(rlonimod)
151 xxim(imod) = rlonimod(imod)
154 CALL minmax( imodmax, xxim, chmin, chmax)
155 IF( chmax.LT.6.50 )
THEN
157 xxim(imod) = xxim(imod) * 180./pi
161 xim0 = xxim(imodmax) - 360.
164 xxim(imod) = xxim(imod) - xim0
167 idatmax1 = idatmax +1
170 xxd(idat) = dlonid(idat)
173 CALL minmax( idatmax, xxd, chmin, chmax)
174 IF( chmax.LT.6.50 )
THEN
176 xxd(idat) = xxd(idat) * 180./pi
181 xxd(idat) = mod( xxd(idat) - xim0, 360. )
182 fdd(idat) = fdat(idat)
186 DO while (xxd(i) >= xxd(i-1) .and. i < idatmax)
189 IF (xxd(i) < xxd(i-1))
THEN
192 nid = idatmax - ichang +1
194 xchan(i) = xxd(i+ichang -1 )
195 fdchan(i) = fdd(i+ichang -1 )
198 xchan(i+ nid) = xxd(i)
199 fdchan(i+nid) = fdd(i)
215 IF ( xxd( idatmax1- idat ).LT.360.)
exit
220 IF (xxd(idat).GT.0.)
exit
226 xxid(idat) = xxd(idatmax - id1 + idat) - 360.
227 fxd(idat) = fdd(idatmax - id1 + idat)
229 DO idat = 1, idatmax - id1
230 xxid(idat + id1) = xxd(idat)
231 fxd(idat + id1) = fdd(idat)
236 DO idat = 1, idatmax - id0
237 xxid(idat) = xxd(idat + id0)
238 fxd(idat) = fdd(idat + id0)
242 xxid(idatmax - id0 + idat) = xxd(idat) + 360.
243 fxd(idatmax - id0 + idat) = fdd(idat)
247 xxid(idat) = xxd(idat)
248 fxd(idat) = fdd(idat)
251 xxid(idatmax1) = xxid(1) + 360.
252 fxd(idatmax1) = fxd(1)
265 do while (imod <= imodmax)
266 do while (xxim(imod).GT.xxid(idat))
269 inter_barx(imod) = inter_barx(imod) + dx * fxd(idat)
273 IF (xxim(imod).LT.xxid(idat))
THEN
276 inter_barx(imod) = (inter_barx(imod) + dx * fxd(idat)) / dxm
283 inter_barx(imod) = (inter_barx(imod) + dx * fxd(idat)) / dxm
305 REAL,
intent(in):: yjdat(:)
309 REAL,
intent(in):: fdat(:)
311 REAL,
intent(in):: yjmod(:)
315 REAL inter_bary(size(yjmod))
325 call assert(
size(yjdat) ==
size(fdat),
"inter_bary")
334 do while (jmod <=
size(yjmod))
335 do while (yjmod(jmod) > yjdat(jdat))
336 dy = yjdat(jdat) - y0
338 inter_bary(jmod) = inter_bary(jmod) + dy * fdat(jdat)
342 IF (yjmod(jmod) < yjdat(jdat))
THEN
343 dy = yjmod(jmod) - y0
345 inter_bary(jmod) = (inter_bary(jmod) + dy * fdat(jdat)) / dym
351 dy = yjmod(jmod) - y0
353 inter_bary(jmod) = (inter_bary(jmod) + dy * fdat(jdat)) / dym
382 REAL,
intent(in):: xi(:)
389 REAL,
intent(out):: xo(:)
390 LOGICAL,
intent(out):: decrois
397 nmax =
assert_eq(
size(xi),
size(xo) - 1,
"ord_coord")
400 decrois = xi(2) < xi(1)
402 IF (decrois .neqv. xi(i) < xi(i-1)) stop &
403 '"ord_coord": latitudes are not monotonic'
406 IF (abs(xi(1)) <
pi)
then
408 xo(:nmax) = xi(:) * 180. /
pi
414 IF (abs(abs(xo(1)) - 90) < 0.001 .or. abs(abs(xo(nmax)) - 90) < 0.001)
THEN
416 print *,
'"xi" should contain the latitudes of the boundaries of ' &
417 //
'grid cells, not the centers of grid cells.'
421 IF (decrois) xo(:nmax) = xo(nmax:1:- 1)
438 REAL,
intent(in):: xi(:)
439 REAL ord_coordm(size(xi))
443 IF (xi(1) < 6.5)
THEN
445 ord_coordm(:) = xi(
size(xi):1:-1) * 180. /
pi
448 ord_coordm(:) = xi(
size(xi):1:-1)
!$Header!CDK comgeom COMMON comgeom apols
subroutine ord_coord(xi, xo, decrois)
!$Id mode_top_bound COMMON comconstr && pi
!$Header!CDK comgeom COMMON comgeom aire
real function, dimension(size(yjmod)) inter_bary(yjdat, fdat, yjmod)
!$Header!CDK comgeom COMMON comgeom apoln
real function, dimension(size(rlonimod)) inter_barx(dlonid, fdat, rlonimod)
subroutine minmax(imax, xi, zmin, zmax)
subroutine, public inter_barxy(dlonid, dlatid, champ, rlonimod, rlatimod, champint)
c c zjulian c cym CALL iim cym klev iim
real function, dimension(size(xi)) ord_coordm(xi)