1 | MODULE cfmip_point_locations |
---|
2 | IMPLICIT NONE |
---|
3 | |
---|
4 | CONTAINS |
---|
5 | |
---|
6 | SUBROUTINE read_CFMIP_point_locations(npCFMIP, tab, lonCFMIP, latCFMIP) |
---|
7 | IMPLICIT none |
---|
8 | INTEGER :: npCFMIP |
---|
9 | REAL, DIMENSION(npCFMIP) :: lonCFMIP, latCFMIP |
---|
10 | INTEGER :: tab(npCFMIP), np |
---|
11 | |
---|
12 | WRITE(*,*) 'npCFMIP=',npCFMIP |
---|
13 | OPEN(20, file="pointlocations.txt",status='old',err=999) |
---|
14 | OPEN(21, file="pointlocations_lon180.txt") |
---|
15 | np=1 |
---|
16 | 10 READ(20,*) tab(np), lonCFMIP(np), latCFMIP(np) |
---|
17 | !!! passage de 0-360 a -180/180 |
---|
18 | IF (lonCFMIP(np)>180.) THEN |
---|
19 | lonCFMIP(np)=lonCFMIP(np)-360. |
---|
20 | ENDIF |
---|
21 | WRITE(21,*) np, lonCFMIP(np), latCFMIP(np) |
---|
22 | np=np+1 |
---|
23 | IF(np<=npCFMIP) THEN |
---|
24 | GOTO 10 |
---|
25 | ENDIF |
---|
26 | CLOSE(20) |
---|
27 | CLOSE(21) |
---|
28 | 999 RETURN |
---|
29 | END SUBROUTINE read_CFMIP_point_locations |
---|
30 | |
---|
31 | SUBROUTINE LMDZ_CFMIP_point_locations(npCFMIP, lonCFMIP, latCFMIP, & |
---|
32 | tabijGCM, lonGCM, latGCM, ipt, jpt) |
---|
33 | USE dimphy |
---|
34 | USE iophy |
---|
35 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, klon_glo |
---|
36 | |
---|
37 | IMPLICIT none |
---|
38 | INTEGER :: npCFMIP |
---|
39 | REAL, DIMENSION(npCFMIP) :: lonCFMIP, latCFMIP |
---|
40 | INTEGER :: i, j, np, ip |
---|
41 | INTEGER, DIMENSION(npCFMIP) :: ipt, jpt |
---|
42 | REAL :: dlon1, dlon2 |
---|
43 | REAL :: dlat1, dlat2 |
---|
44 | REAL, DIMENSION(nbp_lon+1) :: lon |
---|
45 | INTEGER, DIMENSION(npCFMIP) :: tabijGCM |
---|
46 | REAL, DIMENSION(npCFMIP) :: lonGCM, latGCM |
---|
47 | |
---|
48 | lon(1:nbp_lon)=io_lon(:) |
---|
49 | lon(nbp_lon+1)=-1*lon(1) |
---|
50 | OPEN(22, file="LMDZ_pointsCFMIP.txt") |
---|
51 | DO np=1, npCFMIP |
---|
52 | DO i=1, nbp_lon |
---|
53 | |
---|
54 | ! PRINT*,'IM np i lonCF lonGCM lonGCM+1',np,i,lonCFMIP(np),lon(i), & |
---|
55 | ! lon(i+1) |
---|
56 | |
---|
57 | IF(lonCFMIP(np)>=lon(i).AND.lonCFMIP(np)<lon(i+1)) THEN |
---|
58 | dlon1 = abs (lonCFMIP(np) - lon(i)) |
---|
59 | dlon2 = abs (lonCFMIP(np) - lon(i+1)) |
---|
60 | IF (dlon1<=dlon2) THEN |
---|
61 | ipt(np)=i |
---|
62 | ELSE |
---|
63 | ipt(np)=i+1 |
---|
64 | ENDIF |
---|
65 | ENDIF |
---|
66 | END DO |
---|
67 | END DO |
---|
68 | |
---|
69 | np=1 |
---|
70 | 30 j=1 |
---|
71 | 40 IF(latCFMIP(np)<=io_lat(j).AND.latCFMIP(np)>=io_lat(j+1)) THEN |
---|
72 | dlat1 = abs (latCFMIP(np) - io_lat(j)) |
---|
73 | dlat2 = abs (latCFMIP(np) - io_lat(j+1)) |
---|
74 | IF (dlat1<=dlat2) THEN |
---|
75 | jpt(np)=j |
---|
76 | ELSE |
---|
77 | jpt(np)=j+1 |
---|
78 | ENDIF |
---|
79 | np=np+1 |
---|
80 | IF(np<=npCFMIP) THEN |
---|
81 | GOTO 30 |
---|
82 | ENDIF |
---|
83 | ELSE |
---|
84 | j=j+1 |
---|
85 | IF(j<=nbp_lat-1) THEN |
---|
86 | GOTO 40 |
---|
87 | ENDIF |
---|
88 | ENDIF |
---|
89 | |
---|
90 | DO np=1, npCFMIP |
---|
91 | WRITE(22,*) lon(ipt(np)), io_lat(jpt(np)) |
---|
92 | ENDDO |
---|
93 | CLOSE(22) |
---|
94 | |
---|
95 | OPEN(23, file="pointsCFMIPvsLMDZ.txt") |
---|
96 | DO ip=1, npCFMIP |
---|
97 | lonGCM(ip)=lon(ipt(ip)) |
---|
98 | latGCM(ip)=io_lat(jpt(ip)) |
---|
99 | IF(jpt(ip)>=2.AND.jpt(ip)<=nbp_lat-1) THEN |
---|
100 | tabijGCM(ip)=1+(jpt(ip)-2)*nbp_lon+ipt(ip) |
---|
101 | else IF(jpt(ip)==1) THEN |
---|
102 | tabijGCM(ip)=1 |
---|
103 | else IF(jpt(ip)==nbp_lat) THEN |
---|
104 | tabijGCM(ip)=klon_glo |
---|
105 | else |
---|
106 | PRINT*,'ip jpt tabijGCM',ip,jpt(ip),tabijGCM(ip) |
---|
107 | endif |
---|
108 | ! PRINT*,'CFMIP ip lon lat tabijGCM',ip,lonGCM(ip),latGCM(ip),tabijGCM(ip) |
---|
109 | ENDDO |
---|
110 | DO ip=1, npCFMIP |
---|
111 | IF(lonGCM(ip)==io_lon(1)) lonGCM(ip)=360.+lonGCM(ip) |
---|
112 | ENDDO |
---|
113 | DO i=1, npCFMIP |
---|
114 | WRITE(23,*) i, lonCFMIP(i), latCFMIP(i), lonGCM(i), latGCM(i), tabijGCM(i) |
---|
115 | ENDDO |
---|
116 | CLOSE(23) |
---|
117 | END SUBROUTINE LMDZ_CFMIP_point_locations |
---|
118 | |
---|
119 | END MODULE CFMIP_point_locations |
---|