source: LMDZ5/branches/LMDZ5-DOFOCO/libf/phylmd/cfmip_point_locations.F90 @ 5005

Last change on this file since 5005 was 1687, checked in by Laurent Fairhead, 12 years ago

Nettoyage général pour la bonne marche de makegcm
FH


General housekeeping for makegcm to work as expected
FH

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1MODULE cfmip_point_locations
2  IMPLICIT NONE
3
4CONTAINS
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')
14  OPEN(20, file="pointlocations.txt",status='old',err=999)
15  OPEN(21, file="pointlocations_lon180.txt")
16  np=1
1710 READ(20,*) tab(np), lonCFMIP(np), latCFMIP(np)
18!!! passage de 0-360 a -180/180
19   IF (lonCFMIP(np).GT.180.) THEN
20    lonCFMIP(np)=lonCFMIP(np)-360.
21   ENDIF
22   WRITE(21,*) np, lonCFMIP(np), latCFMIP(np)
23   np=np+1
24   IF(np.LE.npCFMIP) THEN
25    GOTO 10
26   ENDIF
27   CLOSE(20)
28   CLOSE(21)
29999 RETURN
30 END SUBROUTINE read_CFMIP_point_locations
31
32 SUBROUTINE LMDZ_CFMIP_point_locations(npCFMIP, lonCFMIP, latCFMIP, &
33  tabijGCM, lonGCM, latGCM, ipt, jpt)
34  USE dimphy
35  USE iophy
36  USE mod_grid_phy_lmdz
37
38  IMPLICIT none
39#include "dimensions.h"
40  INTEGER :: npCFMIP
41  REAL, DIMENSION(npCFMIP) :: lonCFMIP, latCFMIP
42  INTEGER :: i, j, np, ip
43  INTEGER, DIMENSION(npCFMIP) :: ipt, jpt
44  REAL :: dlon1, dlon2
45  REAL :: dlat1, dlat2
46  REAL, DIMENSION(iim+1) :: lon
47  INTEGER, DIMENSION(npCFMIP) :: tabijGCM
48  REAL, DIMENSION(npCFMIP) :: lonGCM, latGCM
49
50  lon(1:iim)=io_lon(:)
51  lon(iim+1)=-1*lon(1)
52  OPEN(22, file="LMDZ_pointsCFMIP.txt")
53  DO np=1, npCFMIP
54  DO i=1, iim
55!
56! PRINT*,'IM np i lonCF lonGCM lonGCM+1',np,i,lonCFMIP(np),lon(i), &
57!  lon(i+1)
58!
59   IF(lonCFMIP(np).GE.lon(i).AND.lonCFMIP(np).LT.lon(i+1)) THEN
60    dlon1 = abs (lonCFMIP(np) - lon(i))
61    dlon2 = abs (lonCFMIP(np) - lon(i+1))
62    IF (dlon1.LE.dlon2) THEN
63     ipt(np)=i
64    ELSE
65     ipt(np)=i+1
66    ENDIF
67   ENDIF
68  END DO
69  END DO
70!
71   np=1
7230 j=1
7340 IF(latCFMIP(np).LE.io_lat(j).AND.latCFMIP(np).GE.io_lat(j+1)) THEN
74    dlat1 = abs (latCFMIP(np) - io_lat(j))
75    dlat2 = abs (latCFMIP(np) - io_lat(j+1))
76    IF (dlat1.LE.dlat2) THEN
77     jpt(np)=j
78    ELSE
79     jpt(np)=j+1
80    ENDIF
81    np=np+1
82    IF(np.LE.npCFMIP) THEN
83     GOTO 30
84    ENDIF
85   ELSE
86    j=j+1
87    IF(j.LE.jjm) THEN
88     GOTO 40
89    ENDIF
90   ENDIF
91
92  DO np=1, npCFMIP
93   WRITE(22,*) lon(ipt(np)), io_lat(jpt(np))
94  ENDDO
95  CLOSE(22)
96
97  OPEN(23, file="pointsCFMIPvsLMDZ.txt")
98    DO ip=1, npCFMIP
99     lonGCM(ip)=lon(ipt(ip))
100     latGCM(ip)=io_lat(jpt(ip))
101     if(jpt(ip).GE.2.AND.jpt(ip).LE.jjm) THEN     
102      tabijGCM(ip)=1+(jpt(ip)-2)*iim+ipt(ip)
103     else if(jpt(ip).EQ.1) THEN
104      tabijGCM(ip)=1
105     else if(jpt(ip).EQ.jjm+1) THEN
106      tabijGCM(ip)=klon_glo
107     else
108      print*,'ip jpt tabijGCM',ip,jpt(ip),tabijGCM(ip)
109     endif
110!    PRINT*,'CFMIP ip lon lat tabijGCM',ip,lonGCM(ip),latGCM(ip),tabijGCM(ip)
111    ENDDO
112    DO ip=1, npCFMIP
113     if(lonGCM(ip).EQ.io_lon(1)) lonGCM(ip)=360.+lonGCM(ip)
114    ENDDO
115   DO i=1, npCFMIP
116    WRITE(23,*) i, lonCFMIP(i), latCFMIP(i), lonGCM(i), latGCM(i), tabijGCM(i)
117   ENDDO
118   CLOSE(23)
119 END SUBROUTINE LMDZ_CFMIP_point_locations
120
121END MODULE CFMIP_point_locations
Note: See TracBrowser for help on using the repository browser.