GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: phylmd/cfmip_point_locations.F90 Lines: 0 59 0.0 %
Date: 2023-06-30 12:56:34 Branches: 0 46 0.0 %

Line Branch Exec Source
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')
14
  OPEN(20, file="pointlocations.txt",status='old',err=999)
15
  OPEN(21, file="pointlocations_lon180.txt")
16
  np=1
17
10 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)
29
999 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, ONLY: nbp_lon, nbp_lat, klon_glo
37
38
  IMPLICIT none
39
  INTEGER :: npCFMIP
40
  REAL, DIMENSION(npCFMIP) :: lonCFMIP, latCFMIP
41
  INTEGER :: i, j, np, ip
42
  INTEGER, DIMENSION(npCFMIP) :: ipt, jpt
43
  REAL :: dlon1, dlon2
44
  REAL :: dlat1, dlat2
45
  REAL, DIMENSION(nbp_lon+1) :: lon
46
  INTEGER, DIMENSION(npCFMIP) :: tabijGCM
47
  REAL, DIMENSION(npCFMIP) :: lonGCM, latGCM
48
49
  lon(1:nbp_lon)=io_lon(:)
50
  lon(nbp_lon+1)=-1*lon(1)
51
  OPEN(22, file="LMDZ_pointsCFMIP.txt")
52
  DO np=1, npCFMIP
53
  DO i=1, nbp_lon
54
!
55
! PRINT*,'IM np i lonCF lonGCM lonGCM+1',np,i,lonCFMIP(np),lon(i), &
56
!  lon(i+1)
57
!
58
   IF(lonCFMIP(np).GE.lon(i).AND.lonCFMIP(np).LT.lon(i+1)) THEN
59
    dlon1 = abs (lonCFMIP(np) - lon(i))
60
    dlon2 = abs (lonCFMIP(np) - lon(i+1))
61
    IF (dlon1.LE.dlon2) THEN
62
     ipt(np)=i
63
    ELSE
64
     ipt(np)=i+1
65
    ENDIF
66
   ENDIF
67
  END DO
68
  END DO
69
!
70
   np=1
71
30 j=1
72
40 IF(latCFMIP(np).LE.io_lat(j).AND.latCFMIP(np).GE.io_lat(j+1)) THEN
73
    dlat1 = abs (latCFMIP(np) - io_lat(j))
74
    dlat2 = abs (latCFMIP(np) - io_lat(j+1))
75
    IF (dlat1.LE.dlat2) THEN
76
     jpt(np)=j
77
    ELSE
78
     jpt(np)=j+1
79
    ENDIF
80
    np=np+1
81
    IF(np.LE.npCFMIP) THEN
82
     GOTO 30
83
    ENDIF
84
   ELSE
85
    j=j+1
86
    IF(j.LE.nbp_lat-1) THEN
87
     GOTO 40
88
    ENDIF
89
   ENDIF
90
91
  DO np=1, npCFMIP
92
   WRITE(22,*) lon(ipt(np)), io_lat(jpt(np))
93
  ENDDO
94
  CLOSE(22)
95
96
  OPEN(23, file="pointsCFMIPvsLMDZ.txt")
97
    DO ip=1, npCFMIP
98
     lonGCM(ip)=lon(ipt(ip))
99
     latGCM(ip)=io_lat(jpt(ip))
100
     if(jpt(ip).GE.2.AND.jpt(ip).LE.nbp_lat-1) THEN
101
      tabijGCM(ip)=1+(jpt(ip)-2)*nbp_lon+ipt(ip)
102
     else if(jpt(ip).EQ.1) THEN
103
      tabijGCM(ip)=1
104
     else if(jpt(ip).EQ.nbp_lat) THEN
105
      tabijGCM(ip)=klon_glo
106
     else
107
      print*,'ip jpt tabijGCM',ip,jpt(ip),tabijGCM(ip)
108
     endif
109
!    PRINT*,'CFMIP ip lon lat tabijGCM',ip,lonGCM(ip),latGCM(ip),tabijGCM(ip)
110
    ENDDO
111
    DO ip=1, npCFMIP
112
     if(lonGCM(ip).EQ.io_lon(1)) lonGCM(ip)=360.+lonGCM(ip)
113
    ENDDO
114
   DO i=1, npCFMIP
115
    WRITE(23,*) i, lonCFMIP(i), latCFMIP(i), lonGCM(i), latGCM(i), tabijGCM(i)
116
   ENDDO
117
   CLOSE(23)
118
 END SUBROUTINE LMDZ_CFMIP_point_locations
119
120
END MODULE CFMIP_point_locations