SURFEX v8.1
General documentation of Surfex
mode_trip_init.F90
Go to the documentation of this file.
1 !###################
3 !###################
4 !
5 !!**** *MODE_TRIP_INIT*
6 !!
7 !! PURPOSE
8 !! -------
9 !
10 ! The purpose of this routine is to store here all routines
11 ! used by INIT_TRIP.
12 !
13 !!
14 !!** IMPLICIT ARGUMENTS
15 !! ------------------
16 !! NONE
17 !!
18 !! REFERENCE
19 !! ---------
20 !!
21 !!
22 !! AUTHOR
23 !! ------
24 !! B. Decharme * Meteo France *
25 !!
26 !! MODIFICATIONS
27 !! -------------
28 !! Original 15/04/08
29 !--------------------------------------------------------------------------------
30 !
31 !* 0. DECLARATIONS
32 ! ------------
33 !
35 !
36 USE yomhook ,ONLY : lhook, dr_hook
37 USE parkind1 ,ONLY : jprb
38 !
39 !-------------------------------------------------------------------------------
40 !
41  CONTAINS
42 !-------------------------------------------------------------------------------
43 !
44 ! #############################################################
45  SUBROUTINE setnext(KLON,KLAT,KGRCN,KNEXTX,KNEXTY,GMLON,GMLAT)
46 ! #############################################################
47 !
48 !! PURPOSE
49 !! -------
50 !
51 ! set the destination grid point
52 !
53 ! (i, j) ===> (inextx(i,j), inexty(i,j))
54 ! at river mouth : pointing itself
55 ! at sea : 0
56 !
57 IMPLICIT NONE
58 !
59 !* declarations of arguments
60 !
61 INTEGER, INTENT(IN) :: KLON, KLAT
62 !
63 INTEGER, DIMENSION(:,:), INTENT(INOUT) :: KGRCN
64 !
65 INTEGER, DIMENSION(:,:), INTENT(OUT) :: KNEXTX, KNEXTY
66 !
67 LOGICAL, INTENT(IN), OPTIONAL :: GMLON,GMLAT
68 !
69 !* declarations of local variables
70 !
71 INTEGER :: JLON, JLAT, IDIR
72 REAL(KIND=JPRB) :: ZHOOK_HANDLE
73 !
74 !* procedure
75 !
76 IF (lhook) CALL dr_hook('MODE_TRIP_INIT:SETNEXT',0,zhook_handle)
77 !
78 IF(PRESENT(gmlon))THEN
79  IF(gmlon)THEN
80  DO jlat=1,klat
81  IF(kgrcn(klon,jlat)==2..OR.kgrcn(klon,jlat)==3.OR.kgrcn(klon,jlat)==4.)kgrcn(klon,jlat)=15
82  IF(kgrcn( 1,jlat)==6..OR.kgrcn( 1,jlat)==7.OR.kgrcn( 1,jlat)==8.)kgrcn( 1,jlat)=15
83  ENDDO
84  ENDIF
85 ENDIF
86 !
87 IF(PRESENT(gmlat))THEN
88  IF(gmlat)THEN
89  DO jlon=1,klon
90  IF(kgrcn(jlon, 1)==4..OR.kgrcn(jlon, 1)==5.OR.kgrcn(jlon, 1)==6.)kgrcn(jlon, 1)=15
91  IF(kgrcn(jlon,klat)==1..OR.kgrcn(jlon,klat)==2.OR.kgrcn(jlon,klat)==8.)kgrcn(jlon,klat)=15
92  ENDDO
93  ENDIF
94 ENDIF
95 !
96 DO jlat=1,klat
97  DO jlon=1,klon
98 !
99  idir=kgrcn(jlon,jlat)
100 !
101  IF((idir>=1).AND.(idir<=8))THEN
102  knextx(jlon,jlat)=irnxtx(jlon,klon,idir)
103  knexty(jlon,jlat)=irnxty(jlat,klat,idir)
104  ELSEIF(idir>=9)THEN
105  knextx(jlon,jlat)=jlon
106  knexty(jlon,jlat)=jlat
107  ELSE
108  knextx(jlon,jlat)=0
109  knexty(jlon,jlat)=0
110  ENDIF
111 !
112  IF(idir>0)THEN
113  IF (kgrcn(knextx(jlon,jlat),knexty(jlon,jlat))==0) kgrcn(jlon,jlat)=9
114  ENDIF
115 !
116  ENDDO
117 ENDDO
118 !
119 IF (lhook) CALL dr_hook('MODE_TRIP_INIT:SETNEXT',1,zhook_handle)
120 !
121 END SUBROUTINE setnext
122 !
123 !-------------------------------------------------------------------------------
124 !
125 ! #################################################
126  SUBROUTINE setarea(KLAT,PLATMIN,PRES,PAREA)
127 ! #################################################
128 !
129 !! PURPOSE
130 !! -------
131 !
132 ! set area [mē] of each grid box
133 !
134 USE modd_trip_par, ONLY : xpi, xrad
135 !
136 IMPLICIT NONE
137 !
138 !* declarations of arguments
139 !
140 INTEGER, INTENT(IN) :: KLAT
141 REAL, INTENT(IN) :: PRES
142 REAL, INTENT(IN) :: PLATMIN
143 !
144 REAL, DIMENSION(:,:), INTENT(OUT) :: PAREA
145 !
146 !* declarations of local variables
147 !
148 REAL :: ZDLAT, ZDLON, ZLAT
149 !
150 INTEGER :: JI, JJ
151 REAL(KIND=JPRB) :: ZHOOK_HANDLE
152 !
153 !* procedure
154 !
155 IF (lhook) CALL dr_hook('MODE_TRIP_INIT:SETAREA',0,zhook_handle)
156 zdlon=pres
157 zdlat=pres
158 !
159 zlat=platmin-(pres/2.)
160 !
161 DO ji=1,klat
162  zlat=zlat+pres
163  DO jj=1,SIZE(parea,1)
164  parea(jj,ji) = xrad * xrad * xpi/180.*(zdlon) &
165  * (sin((zlat+zdlat/2.)*xpi/180.)-sin((zlat-zdlat/2.)*xpi/180.))
166  ENDDO
167 ENDDO
168 IF (lhook) CALL dr_hook('MODE_TRIP_INIT:SETAREA',1,zhook_handle)
169 !
170 END SUBROUTINE setarea
171 !
172 !-------------------------------------------------------------------------------
173 !
174 ! #############################################################
175  SUBROUTINE setlen(KLON,KLAT,KGRCN,KNEXTX,KNEXTY,PRATMED,PLEN)
176 ! #############################################################
177 !
178 !! PURPOSE
179 !! -------
180 !
181 ! length from (i, j) to the destination in [m]
182 ! river mouth : distance to 1 grid north
183 ! sea : 0.0
184 !
185 IMPLICIT NONE
186 !
187 !* declarations of arguments
188 !
189 INTEGER, INTENT(IN) :: KLON, KLAT
190 REAL, INTENT(IN) :: PRATMED
191 !
192 INTEGER, DIMENSION(:,:), INTENT(IN) :: KGRCN
193 !
194 INTEGER, DIMENSION(:,:), INTENT(IN) :: KNEXTX, KNEXTY
195 !
196 REAL, DIMENSION(:,:), INTENT(OUT) :: PLEN
197 !
198 !* declarations of local variables
199 !
200 REAL :: ZLON, ZLAT, ZLON_N, ZLAT_N
201 !
202 INTEGER :: JLON, JLAT
203 REAL(KIND=JPRB) :: ZHOOK_HANDLE
204 !
205 !* procedure
206 !
207 IF (lhook) CALL dr_hook('MODE_TRIP_INIT:SETLEN',0,zhook_handle)
208 !
209 zlon=0.0
210 zlat=0.0
211 !
212 DO jlat=1,klat
213 !
214  zlat=getlat(klat-jlat+1,klat)
215 !
216  DO jlon=1,klon
217 !
218  zlon=getlon(jlon,klon)
219 !
220  IF(kgrcn(jlon,jlat)>=1.AND.kgrcn(jlon,jlat)<=8)THEN
221  zlon_n = getlon(knextx(jlon,jlat),klon)
222  zlat_n = getlat(klat-knexty(jlon,jlat)+1,klat)
223  plen(jlon,jlat) = givelen(zlon,zlat,zlon_n,zlat_n) * 1000.0
224  ELSEIF(kgrcn(jlon,jlat)>=9)THEN
225  zlat_n = getlat(klat-(jlat-1)+1,klat)
226  plen(jlon,jlat) = givelen(zlon,zlat,zlon,zlat_n) * 1000.0
227  ELSE
228  plen(jlon,jlat) = 0.0
229  ENDIF
230 !
231  ENDDO
232 !
233 ENDDO
234 !
235 plen=plen*pratmed
236 !
237 IF (lhook) CALL dr_hook('MODE_TRIP_INIT:SETLEN',1,zhook_handle)
238 !
239 END SUBROUTINE setlen
240 !
241 !-------------------------------------------------------------------------------
242 !
243 END MODULE mode_trip_init
real function getlat(IY, NY)
subroutine setlen(KLON, KLAT, KGRCN, KNEXTX, KNEXTY, PRATMED, PLEN)
subroutine setarea(KLAT, PLATMIN, PRES, PAREA)
subroutine setnext(KLON, KLAT, KGRCN, KNEXTX, KNEXTY, GMLON, GMLAT)
real function givelen(ZX, ZY, ZX_N, ZY_N)
integer, parameter jprb
Definition: parkind1.F90:32
real, save xrad
logical lhook
Definition: yomhook.F90:15
real, save xpi
real function getlon(IX, NX)
integer function irnxtx(IX, NX, IRIV)
integer function irnxty(IY, NY, IRIV)