SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
init_topd.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 !-----------------------------------------------------------------
6 ! #######################
7  SUBROUTINE init_topd(HPROGRAM)
8 ! #######################
9 !
10 !!**** *INIT_TOPD*
11 !!
12 !! PURPOSE
13 !! -------
14 ! This routine aims at initialising the variables
15 ! needed of running Topmodel.
16 !
17 !
18 !!** METHOD
19 !! ------
20 !
21 !! EXTERNAL
22 !! --------
23 !!
24 !! none
25 !!
26 !! IMPLICIT ARGUMENTS
27 !! ------------------
28 !!
29 !!
30 !!
31 !!
32 !!
33 !! REFERENCE
34 !! ---------
35 !!
36 !!
37 !!
38 !! AUTHOR
39 !! ------
40 !!
41 !! K. Chancibault * LTHE / Meteo-France *
42 !! B. Vincendon * Meteo-France *
43 !!
44 !! MODIFICATIONS
45 !! -------------
46 !!
47 !! Original 11/2006
48 !! Modification 04/2007 : Supression of 2 arguments KSTEP,PSTEP
49 !! that are now module arguments from MODD_TOPDDYN_n
50 !! NNB_TOPD_STEP,XTOPD_STEP
51 !! Modification 11/2011 : Exfiltration option removed (B. Vincendon)
52 !! Modification 03/2014 : common init_topd routine called in init_topd_pgd
53 !! and init_topd_ol (B. Vincendon)
54 !-------------------------------------------------------------------------------
55 !
56 !* 0. DECLARATIONS
57 ! ------------
58 !
59 USE modd_coupling_topd, ONLY : nnb_stp_restart
60 USE modd_topodyn, ONLY : ccat, nncat, nnb_topd_step, xtopd_step,&
61  xdxt, nnxc, nnyc,&
62  xnul, xx0, xy0, nnpt,&
63  nx_step_rout, xspeedr,&
64  xspeedh, nnmc, nmesht, npmax,&
65  nline, xdmaxt,&
66  xtopd, xdriv, xdhil, xtime_topd,&
67  xdgrd, xspeedg, xtime_topd_drain,&
68  xqtot, xtanb, xslop, xdarea,&
69  xlambda, xconn, xqb_dr, xqb_run
70 !
71 USE modd_topd_par, ONLY : ndim
72 USE modd_surf_par, ONLY : xundef, nundef
73 !
74 USE modi_get_luout
75 USE modi_read_topd_header_dtm
76 USE modi_read_topd_file
77 USE modi_read_topd_header_connex
78 USE modi_read_connex_file
79 USE modi_read_slope_file
80 !
81 USE yomhook ,ONLY : lhook, dr_hook
82 USE parkind1 ,ONLY : jprb
83 !
84 IMPLICIT NONE
85 !
86 !* 0.1 declarations of arguments
87 !
88  CHARACTER(LEN=*), INTENT(IN) :: hprogram !
89 !
90 !* 0.2 declarations of local variables
91 !
92 !
93  CHARACTER(LEN=50), DIMENSION(NNCAT) :: yfiletop ! topographic file names
94  CHARACTER(LEN=50), DIMENSION(NNCAT) :: yfilecon ! topographic file names
95  CHARACTER(LEN=50), DIMENSION(NNCAT) :: yfileslo
96  CHARACTER(LEN=50), DIMENSION(NNCAT) :: yfiledh
97  CHARACTER(LEN=50), DIMENSION(NNCAT) :: yfiledr
98 INTEGER :: jj,jcat ! loop control
99 INTEGER :: iluout ! Unit of the files
100 !
101 REAL, DIMENSION(:),ALLOCATABLE :: ztopd_read !Topgraphic variable read
102 !
103 REAL(KIND=JPRB) :: zhook_handle
104 !-------------------------------------------------------------------------------
105 IF (lhook) CALL dr_hook('INIT_TOPD',0,zhook_handle)
106 !
107 !* 1 Initialization:
108 ! ---------------
109 !
110  CALL get_luout(hprogram,iluout)
111 !
112 WRITE(iluout,*) 'INITIALISATION INIT_TOPD'
113 !
114 !
115 DO jcat=1,nncat
116  yfiletop(jcat)=trim(ccat(jcat))//'_FilledDTM.map'
117  yfilecon(jcat)=trim(ccat(jcat))//'_connections.vec'
118  yfileslo(jcat)=trim(ccat(jcat))//'_slope.vec'
119  yfiledr(jcat)=trim(ccat(jcat))//'_RiverDist.map'
120  yfiledh(jcat)=trim(ccat(jcat))//'_HillDist.map'
121 ENDDO
122 
123 ALLOCATE(nnmc(nncat))
124 nnmc(:)=0
125 ALLOCATE(nnxc(nncat))
126 nnxc(:)=0
127 ALLOCATE(nnyc(nncat))
128 nnyc(:)=0
129 ALLOCATE(xx0(nncat))
130 xx0(:)=0.0
131 ALLOCATE(xy0(nncat))
132 xy0(:)=0.0
133 ALLOCATE(nnpt(nncat))
134 nnpt(:)=0
135 ALLOCATE(xnul(nncat))
136 ALLOCATE(xdxt(nncat))
137 !
138 !
139 !* 2 Topographic files
140 ! -----------------------------
141 DO jcat=1,nncat
142  CALL read_topd_header_dtm(hprogram,yfiletop(jcat),'FORMATTED',&
143  xx0(jcat),xy0(jcat),nnxc(jcat),nnyc(jcat),&
144  xnul(jcat),xdxt(jcat))
145 ENDDO
146 !
147 nnpt(:) = nnxc(:) * nnyc(:)
148 !
149 npmax = maxval(nnpt(:))
150 !
151 !
152 ALLOCATE(nline(nncat,npmax))
153 nline(:,:)=0
154 ALLOCATE(xtopd(nncat,npmax))
155 xtopd(:,:)=0.0
156 ALLOCATE(ztopd_read(npmax))
157 DO jcat = 1,nncat
158  !
159  CALL read_topd_file(hprogram,yfiletop(jcat),'FORMATTED',nnpt(jcat),ztopd_read)
160  DO jj = 1,nnpt(jcat)
161  xtopd(jcat,jj) = ztopd_read(jj) ! XTOPD can only be >=0
162  ENDDO
163  !
164 ENDDO
165 ! for XTOPD, we do not have to use NLINE, all the pixels of the rectancle around
166 ! the catchment are read.
167 !
168 
169 !* 3 Connection files
170 ! ----------------
171 !
172 DO jcat=1,nncat
173  CALL read_topd_header_connex(hprogram,yfilecon(jcat),'FORMATTED',nnmc(jcat))
174 ENDDO
175 !
176 nmesht=maxval(nnmc(:))
177 !
178 ALLOCATE(xconn(nncat,nmesht,ndim))
179 xconn(:,:,:)=0.0
180 !
181 DO jcat=1,nncat
182  CALL read_connex_file(hprogram,yfilecon(jcat),'FORMATTED',nnmc(jcat),xconn(jcat,:,:),nline(jcat,:))
183 ENDDO
184 
185 !
186 !* 4 Slope files
187 ! -----------
188  ALLOCATE(xtanb(nncat,nmesht))
189  ALLOCATE(xslop(nncat,nmesht))
190  ALLOCATE(xdarea(nncat,nmesht))
191  ALLOCATE(xlambda(nncat,nmesht))
192  !
193  DO jcat=1,nncat
194  CALL read_slope_file(hprogram,yfileslo(jcat),'FORMATTED',nnmc(jcat),&
195  xtanb(jcat,:),xslop(jcat,:),xdarea(jcat,:),xlambda(jcat,:))
196  ENDDO
197  !
198 ALLOCATE(xdriv(nncat,npmax))
199 xdriv(:,:)=0.0
200 ALLOCATE(xdhil(nncat,npmax))
201 xdhil(:,:)=0.0
202 ALLOCATE(xdgrd(nncat,npmax))
203 xdgrd(:,:)=0.0
204 ALLOCATE(xqtot(nncat,nnb_topd_step))
205 xqtot(:,:)=0.0
206 !
207 !* 5 River Distance file
208  ! -------------------
209  !
210  DO jcat=1,nncat
211  CALL read_topd_file(hprogram,yfiledr(jcat),'FORMATTED',nnpt(jcat),ztopd_read)
212  DO jj=1,npmax
213  IF ( nline(jcat,jj)/=0. .AND. nline(jcat,jj)/=xundef ) &
214  xdriv(jcat,nline(jcat,jj)) = ztopd_read(jj)
215  ENDDO
216  ENDDO
217  ! for XDRIV, we must use NLINE, online pixels inside de the catchment are read.
218  !
219  !* 6 Hillslope Distance file
220  ! -----------------------
221  !
222  DO jcat=1,nncat
223  CALL read_topd_file(hprogram,yfiledh(jcat),'FORMATTED',nnpt(jcat),ztopd_read)
224  DO jj=1,npmax
225  IF ( nline(jcat,jj)/=0. .AND. nline(jcat,jj)/=xundef ) &
226  xdhil(jcat,nline(jcat,jj)) = ztopd_read(jj)
227  ENDDO
228  ENDDO
229  !
230  ! for XDHIL, we must use NLINE, online pixels inside de the catchment are read.
231  xdgrd(:,:) = xdhil(:,:)
232 
233 IF (lhook) CALL dr_hook('INIT_TOPD',1,zhook_handle)
234 !
235 END SUBROUTINE init_topd
subroutine read_topd_file(HPROGRAM, HFILE, HFORM, KNPT, PTOPD_READ)
subroutine read_slope_file(HPROGRAM, HFILE, HFORM, KNMC, PTANB, PSLOP, PDAREA, PLAMBDA)
subroutine init_topd(HPROGRAM)
Definition: init_topd.F90:7
subroutine read_topd_header_connex(HPROGRAM, HFILE, HFORM, KNMC)
subroutine read_topd_header_dtm(HPROGRAM, HFILE, HFORM, PX0, PY0, KNXC, KNYC, PNUL, PDXT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine read_connex_file(HPROGRAM, HFILE, HFORM, KNMC, PCONN, KLINE)