15 |
! - pi/2 et pour que la coordonnée pression soit décroissante. |
! - pi/2 et pour que la coordonnée pression soit décroissante. |
16 |
|
|
17 |
use comconst, only: pi |
use comconst, only: pi |
18 |
use nrutil, only: assert_eq |
use nr_util, only: assert_eq |
19 |
|
|
20 |
REAL, intent(in):: xd(:), yd(:) ! longitudes et latitudes initiales |
REAL, intent(in):: xd(:), yd(:) ! longitudes et latitudes initiales, en rad |
21 |
REAL, intent(in):: zd(:) ! pressure levels, in Pa or hPa |
REAL, intent(in):: zd(:) ! pressure levels, in Pa or hPa |
22 |
|
|
23 |
REAL, intent(out):: xf(:) ! longitude, in rad, - pi to pi |
REAL, intent(out):: xf(:) ! longitude, in rad, - pi to pi |
28 |
! Variables locales : |
! Variables locales : |
29 |
|
|
30 |
INTEGER lons, lats, levs |
INTEGER lons, lats, levs |
31 |
LOGICAL radianlon, invlon , radianlat |
LOGICAL invlon |
32 |
REAL rlatmin, rlatmax, oldxd1 |
REAL rlatmin, rlatmax, oldxd1 |
33 |
INTEGER i |
INTEGER i |
34 |
|
|
39 |
levs = assert_eq(size(zd), size(zf), size(champd, 3), "conf_dat3d levs") |
levs = assert_eq(size(zd), size(zf), size(champd, 3), "conf_dat3d levs") |
40 |
|
|
41 |
IF (xd(1) >= - pi - 0.5 .AND. xd(lons) <= pi + 0.5) THEN |
IF (xd(1) >= - pi - 0.5 .AND. xd(lons) <= pi + 0.5) THEN |
|
radianlon = .TRUE. |
|
42 |
invlon = .FALSE. |
invlon = .FALSE. |
43 |
ELSE IF (xd(1) >= -0.5 .AND. xd(lons) <= 2 * pi+0.5) THEN |
ELSE IF (xd(1) >= -0.5 .AND. xd(lons) <= 2 * pi+0.5) THEN |
|
radianlon = .TRUE. |
|
|
invlon = .TRUE. |
|
|
ELSE IF (xd(1) >= -180.5 .AND. xd(lons) <= 180.5) THEN |
|
|
radianlon = .FALSE. |
|
|
invlon = .FALSE. |
|
|
ELSE IF (xd(1) >= -0.5 .AND. xd(lons) <= 360.5) THEN |
|
|
radianlon = .FALSE. |
|
44 |
invlon = .TRUE. |
invlon = .TRUE. |
45 |
ELSE |
ELSE |
46 |
print *, 'Problème sur les longitudes des données' |
print *, 'Problème sur les longitudes des données' |
50 |
rlatmin = MIN(yd(1), yd(lats)) |
rlatmin = MIN(yd(1), yd(lats)) |
51 |
rlatmax = MAX(yd(1), yd(lats)) |
rlatmax = MAX(yd(1), yd(lats)) |
52 |
|
|
53 |
IF (rlatmin >= -pi / 2 - 0.5 .AND. rlatmax <= pi / 2 + 0.5) THEN |
IF (rlatmin < -pi / 2 - 0.5 .or. rlatmax > pi / 2 + 0.5) THEN |
|
radianlat = .TRUE. |
|
|
ELSE IF (rlatmin >= - 90. - 0.5 .AND. rlatmax <= 90. + 0.5) THEN |
|
|
radianlat = .FALSE. |
|
|
ELSE |
|
54 |
print *, ' Problème sur les latitudes des données' |
print *, ' Problème sur les latitudes des données' |
55 |
stop 1 |
stop 1 |
56 |
ENDIF |
ENDIF |
57 |
|
|
58 |
IF (radianlon) THEN |
xf(:) = xd(:) |
59 |
xf(:) = xd(:) |
yf(:) = yd(:) |
|
else |
|
|
xf(:) = xd(:) * pi / 180. |
|
|
ENDIF |
|
|
|
|
|
IF (radianlat) THEN |
|
|
yf(:) = yd(:) |
|
|
else |
|
|
yf(:) = yd(:) * pi / 180. |
|
|
ENDIF |
|
60 |
|
|
61 |
IF (invlon) THEN |
IF (invlon) THEN |
62 |
! On tourne les longitudes pour avoir - pi à pi |
! On tourne les longitudes pour avoir - pi à pi |