DevelopmentActivities/MergeHydro: diff_1_9_Matthieu_version_Jan.diff

File diff_1_9_Matthieu_version_Jan.diff, 100.9 KB (added by nvuilsce, 10 years ago)

Fichier des diffs entre la version LMD et la version 1.9

Line 
1_______________________________________________________________________________________________________________________
2diff -w --ignore-all-space --ignore-case --recursive --exclude='cvs_diff*' --exclude='*.flc' --exclude='*.bak' --exclude='*.svn*' --exclude='*.lst' --exclude='i.*.L' --exclude='*~' --exclude=Entries --exclude=Tag --exclude=CVS --exclude Makefile /login/IPSL_CODE/WORK_HYDRO/ORCHIDEE_1_9/modeles/ORCHIDEE/src_parameters/constantes.f90 /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_parameters/constantes.f90
337a38,40
4>   REAL(r_std), PARAMETER                          :: R_Earth = 6378000.
5>   REAL(r_std), PARAMETER                          :: mincos  = 0.0001
6> !
744a48
8>   INTEGER(i_std),PARAMETER :: undef_int = 999999999
971a76,77
10>     LOGICAL :: do_floodplains
11>     LOGICAL :: do_irrigation
12_______________________________________________________________________________________________________________________
13diff -w --ignore-all-space --ignore-case --recursive --exclude='cvs_diff*' --exclude='*.flc' --exclude='*.bak' --exclude='*.svn*' --exclude='*.lst' --exclude='i.*.L' --exclude='*~' --exclude=Entries --exclude=Tag --exclude=CVS --exclude Makefile /login/IPSL_CODE/WORK_HYDRO/ORCHIDEE_1_9/modeles/ORCHIDEE/src_sechiba/condveg.f90 /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_sechiba/condveg.f90
1452,54c52,57
15<   REAL(r_std), PARAMETER             :: z0_over_height = un/16.          !! to get z0 from height
16<   REAL(r_std), PARAMETER             :: height_displacement = 0.75       !! Magic number which relates the
17<                                                                           !! height to the displacement height.
18---
19> !
20> !  Using the linear formula proposed by Lettau (1969) and with parameters updated in paper of Verhoef et al. (1997)
21> !  An option would be to move to the equations of Raupach as discussed in Verhoef et al. (1997)
22> !
23>   REAL(r_std), PARAMETER             :: z0_over_height = 0.046          !! to get z0 from height
24>   REAL(r_std), PARAMETER             :: height_displacement = 0.67      !! See Verhoef.
2581,83c84,86
26<        & lalo, neighbours, resolution, contfrac, veget, veget_max, frac_nobio, totfrac_nobio, &
27<        & zlev, snow, snow_age, snow_nobio, snow_nobio_age, &
28<        & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, soiltype, rest_id, hist_id, hist2_id)
29---
30>        & lalo, neighbours, resolution, contfrac, veget, frac_nobio, totfrac_nobio, &
31>        & zlev, snow, snow_age, snow_nobio, snow_nobio_age, frac_bare, &
32>        & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, rest_id, hist_id, hist2_id)
33102d104
34<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT(in) :: veget_max        !! Fraction of vegetation type
35109a112
36>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT(in)     :: frac_bare     !! Bare fraction in each tile
37119d121
38<     REAL(r_std),DIMENSION (kjpindex,nstm), INTENT (in) :: soiltype       !! fraction of soil types
39129,134c131,133
40<         CALL condveg_var_init (ldrestart_read, kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, &
41<              & drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
42<         ! Nathalie - Fevrier 2007 - c'est veget_max qu'il faut passer
43<         !CALL condveg_snow (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
44<         !                   snow, snow_age, snow_nobio, snow_nobio_age, albedo, albedo_snow, albedo_glob)
45<         CALL condveg_snow (ldrestart_read, kjpindex, veget_max, frac_nobio, totfrac_nobio, &
46---
47>         CALL condveg_var_init (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
48>              & frac_bare, drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
49>         CALL condveg_snow (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
50141,146c140,142
51<     CALL condveg_var_update (ldrestart_read, kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, &
52<          & drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
53<     ! Nathalie - Fevrier 2007 - c'est veget_max qu'il faut passer
54<     !CALL condveg_snow (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
55<     !                   snow, snow_age, snow_nobio, snow_nobio_age, albedo, albedo_snow, albedo_glob)
56<     CALL condveg_snow (ldrestart_read, kjpindex, veget_max, frac_nobio, totfrac_nobio, &
57---
58>     CALL condveg_var_update (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
59>          & frac_bare, drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
60>     CALL condveg_snow (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
61327,328c323,324
62<   SUBROUTINE condveg_var_init  (ldrestart_read, kjpindex, veget, veget_max, frac_nobio, totfrac_nobio,&
63<        & drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
64---
65>   SUBROUTINE condveg_var_init  (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio,&
66>        & frac_bare, drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
67336d331
68<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT(in) :: veget_max        !! Fraction of vegetation type
69338a334
70>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT(in)     :: frac_bare             !! Bare fraction in each tile
71426c422
72<        CALL condveg_albcalc (kjpindex,deadleaf_cover,veget,drysoil_frac,albedo)
73---
74>        CALL condveg_albcalc (kjpindex,deadleaf_cover,veget,frac_bare,drysoil_frac,albedo)
75430,442d425
76<     !! calculs de z0
77<     !!
78<     !
79<     !Config Key  = Z0CDRAG_AVE
80<     !Config Desc = Average method for z0
81<     !Config Def  = y
82<     !Config Help = If this flag is set to true (y) then the neutral Cdrag
83<     !Config        is averaged instead of the log(z0). This should be
84<     !Config        the prefered option. We still wish to keep the other
85<     !Config        option so we can come back if needed. If this is
86<     !Config        desired then one should set Z0CDRAG_AVE=n
87<     z0cdrag_ave = .TRUE.
88<     CALL getin_p('Z0CDRAG_AVE', z0cdrag_ave)
89474,475c457
90<        IF ( z0cdrag_ave ) THEN
91<           CALL condveg_z0cdrag(kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, zlev, &
92---
93>        CALL condveg_z0cdrag(kjpindex, veget, frac_bare, frac_nobio, totfrac_nobio, zlev, &
94477,480d458
95<        ELSE
96<           CALL condveg_z0logz(kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, height, &
97<                &              z0, roughheight)
98<        ENDIF
99492,493c470,471
100<   SUBROUTINE condveg_var_update  (ldrestart_read, kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, &
101<        & drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
102---
103>   SUBROUTINE condveg_var_update  (ldrestart_read, kjpindex, veget, frac_nobio, totfrac_nobio, &
104>        & frac_bare, drysoil_frac, zlev, height, deadleaf_cover, emis, albedo, z0, roughheight)
105501d478
106<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT(in) :: veget_max        !! Fraction of vegetation type
107503a481
108>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT(in)     :: frac_bare             !! Bare fraction in each tile
109534c512
110<        CALL condveg_albcalc (kjpindex,deadleaf_cover,veget,drysoil_frac,albedo)
111---
112>        CALL condveg_albcalc (kjpindex,deadleaf_cover,veget,frac_bare,drysoil_frac,albedo)
113551,555c529
114<        IF ( z0cdrag_ave ) THEN
115<           CALL condveg_z0cdrag (kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, zlev, height, &
116<                &                z0, roughheight)
117<        ELSE
118<           CALL condveg_z0logz (kjpindex, veget, veget_max, frac_nobio, totfrac_nobio, height, &
119---
120>        CALL condveg_z0cdrag (kjpindex, veget, frac_bare, frac_nobio, totfrac_nobio, zlev, height, &
121557d530
122<        ENDIF
123729a703,704
124>   REAL(r_std), ALLOCATABLE, DIMENSION(:,:,:) :: resol_lu
125>   INTEGER(i_std) :: nix, njx
126799a775,780
127>   ALLOC_ERR=-1
128>   ALLOCATE(resol_lu(iml,jml,2), STAT=ALLOC_ERR)
129>   IF (ALLOC_ERR/=0) THEN
130>      WRITE(numout,*) "ERROR IN ALLOCATION of resol_lu : ",ALLOC_ERR
131>      STOP
132>   ENDIF
133821a803,824
134>         !
135>         ! Resolution in longitude
136>         !
137>         coslat = MAX( COS( lat_rel(ip,jp) * pi/180. ), 0.001 )     
138>         IF ( ip .EQ. 1 ) THEN
139>            resol_lu(ip,jp,1) = ABS( lon_rel(ip+1,jp) - lon_rel(ip,jp) ) * pi/180. * R_Earth * coslat
140>         ELSEIF ( ip .EQ. iml ) THEN
141>            resol_lu(ip,jp,1) = ABS( lon_rel(ip,jp) - lon_rel(ip-1,jp) ) * pi/180. * R_Earth * coslat
142>         ELSE
143>            resol_lu(ip,jp,1) = ABS( lon_rel(ip+1,jp) - lon_rel(ip-1,jp) )/2. * pi/180. * R_Earth * coslat
144>         ENDIF
145>         !
146>         ! Resolution in latitude
147>         !
148>         IF ( jp .EQ. 1 ) THEN
149>            resol_lu(ip,jp,2) = ABS( lat_rel(ip,jp) - lat_rel(ip,jp+1) ) * pi/180. * R_Earth
150>         ELSEIF ( jp .EQ. jml ) THEN
151>            resol_lu(ip,jp,2) = ABS( lat_rel(ip,jp-1) - lat_rel(ip,jp) ) * pi/180. * R_Earth
152>         ELSE
153>            resol_lu(ip,jp,2) =  ABS( lat_rel(ip,jp-1) - lat_rel(ip,jp+1) )/2. * pi/180. * R_Earth
154>         ENDIF
155>         !
156825c828,833
157<   nbvmax = 200
158---
159>   IF (is_root_prc) THEN
160>      nix=INT(MAXVAL(resolution_g(:,1))/MAXVAL(resol_lu(:,:,1)))+2
161>      njx=INT(MAXVAL(resolution_g(:,2))/MAXVAL(resol_lu(:,:,2)))+2
162>      nbvmax = nix*njx
163>   ENDIF
164>   CALL bcast(nbvmax)
165829d836
166<   DO WHILE ( .NOT. ok_interpol )
167852,858d858
168<      IF ( .NOT. ok_interpol ) THEN
169<         DEALLOCATE(sub_area)
170<         DEALLOCATE(sub_index)
171<      ENDIF
172<      !
173<      nbvmax = nbvmax * 2
174<   ENDDO
175866d865
176<   ! Ajout Nathalie
177882d880
178<         ! Ajout Nathalie
179900d897
180<               ! Ajout Nathalie
181919d915
182<            ! Ajout Nathalie
183927d922
184<            ! Ajout Nathalie
185958c953
186<   SUBROUTINE condveg_z0cdrag (kjpindex,veget,veget_max,frac_nobio,totfrac_nobio,zlev, height, &
187---
188>   SUBROUTINE condveg_z0cdrag (kjpindex, veget, frac_bare, frac_nobio, totfrac_nobio, zlev, height, &
189968c963
190<     REAL(r_std), DIMENSION(kjpindex,nvm), INTENT(in) :: veget_max
191---
192>     REAL(r_std), DIMENSION(kjpindex,nvm), INTENT(in) :: frac_bare
193971c966
194<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)    :: zlev             !! Height of first layer
195---
196>     REAL(r_std), DIMENSION(kjpindex), INTENT(in)     :: zlev
197980,981c975,978
198<     REAL(r_std), DIMENSION(kjpindex)                 :: sumveg, ztmp, ave_height
199<     REAL(r_std), DIMENSION(kjpindex)                 :: d_veg, zhdispl
200---
201>     REAL(r_std), DIMENSION(kjpindex)                 :: sumveg, ave_height
202>     REAL(r_std), DIMENSION(kjpindex)                 :: ave_drag, z0_veg
203>     REAL(r_std), DIMENSION(kjpindex, nvm)            :: d_veg
204>     REAL(r_std), DIMENSION(kjpindex)                 :: zhdispl, tot_frac_bare
205984,986c981,982
206<     ! The grid average z0 is computed by averaging the neutral drag coefficients.
207<     ! This is pretty straight forward except for the reference level which needs
208<     ! to be chosen.
209---
210>     ! This routine ccomputes the average displacement height and surface roughness
211>     ! by averaging the neutral drag coefficients.
212988,989d983
213<     ! We need a reference lever high enough above the canopy else we get into
214<     ! singularities of the LOG.
215991,993d984
216<     ztmp(:) = MAX(10., zlev(:))
217<     !
218<     z0(:) = veget(:,1) * (ct_karman/LOG(ztmp(:)/z0_bare))**2
219994a986
220>     d_veg(:,1) =  veget(:,1)
221998c990
222<        !
223---
224>        d_veg(:,1) = d_veg(:,1) + veget(:,jv) * frac_bare(:,jv)
2251001c993
226<           d_veg(:) = veget_max(:,jv)
227---
228>           d_veg(:,jv) = veget(:,jv)
2291004c996
230<           d_veg(:) = veget(:,jv)
231---
232>           d_veg(:,jv) = veget(:,jv) * (un - frac_bare(:,jv))
2331007,1008c999
234<        z0(:) = z0(:) + d_veg(:) * (ct_karman/LOG(ztmp(:)/MAX(height(:,jv)*z0_over_height,z0_bare)))**2
235<        sumveg(:) = sumveg(:) + d_veg(:)
236---
237>        sumveg(:) = sumveg(:) + d_veg(:,jv)
2381010c1001
239<        ave_height(:) = ave_height(:) + veget_max(:,jv)*height(:,jv)
240---
241>        ave_height(:) = ave_height(:) + veget(:,jv)*height(:,jv)
2421014c1005,1026
243<     WHERE ( sumveg(:) .GT. 0.0 ) z0(:) = z0(:) / sumveg(:)
244---
245>     ! We compute the zero plane displacement height
246>     !
247>     zhdispl(:) = ave_height(:) * height_displacement
248>     !
249>     ! In order to get a variable independent of the height of the
250>     ! vegetation we compute what we call the effective roughness height.
251>     ! This is the height over which the roughness acts. It combines the
252>     ! zero plane displacement height and the vegetation height.
253>     !
254>     roughheight(:) = ave_height(:) - zhdispl(:)
255>     !
256>     ! Normalize the fraction of roughness elements.
257>     !
258>     WHERE ( sumveg(:) > zero )  d_veg(:,1) =  d_veg(:,1)/sumveg(:)
259>     !
260>     ! Contribution of bare soil
261>     !
262>     ave_drag(:) = d_veg(:,1)/((LOG((zlev(:)+roughheight(:))/z0_bare))**2.)
263>     !
264>     ! Contribution of vegetation types
265>     !
266>     DO jv = 2, nvm
2671016c1028,1037
268<     z0(:) = (un - totfrac_nobio(:)) * z0(:)
269---
270>        z0_veg(:) = MAX(height(:,jv)*z0_over_height, z0_bare)
271>        !
272>        ! Normalize the fraction of roughness elements. 
273>        !
274>        WHERE ( sumveg(:) > zero )  d_veg(:,jv) =  d_veg(:,jv)/sumveg(:)
275>        !
276>        ave_drag(:) = ave_drag(:) + d_veg(:,jv)/((LOG((zlev(:)+roughheight(:))/z0_veg(:)))**2.)
277>        !
278>        !
279>     ENDDO
2801024c1045
281<           STOP 'DO NOT KNOW ROUGHNESS OF THIS SURFACE TYPE'
282---
283>           STOP 'DO NOT KNOW ROUGHNESS OF THIS SURFACE TYPE. From condveg_z0cdrag.'
2841027c1048,1049
285<        z0(:) = z0(:) + frac_nobio(:,jv) * (ct_karman/LOG(ztmp(:)/z0_nobio))**2
286---
287>        ave_drag(:) = (un-totfrac_nobio(:))*ave_drag(:) + &
288>             &        frac_nobio(:,jv)/((LOG((zlev(:)+roughheight(:))/z0_nobio))**2.)
2891031,1033c1053
290<     z0(:) = ztmp(:) / EXP(ct_karman/SQRT(z0(:)))
291<     !
292<     ! Temporarily we compute the zero plane displacement height
293---
294>     ! Compute the average roughness from the average drag coefficient
2951035,1042c1055
296<     zhdispl(:) = ave_height(:) * height_displacement
297<     !
298<     ! In order to get a variable independent of the height of the
299<     ! vegetation we compute what we call the effective roughness height.
300<     ! This is the height over which the roughness acts. It combines the
301<     ! zero plane displacement height and the vegetation height.
302<     !
303<     roughheight(:) = ave_height(:) - zhdispl(:)
304---
305>     z0(:) = EXP(LOG(zlev(:)+roughheight(:)) - un/SQRT(ave_drag(:)))
3061048c1061
307<   SUBROUTINE condveg_albcalc (kjpindex,deadleaf_cover,veget,drysoil_frac,albedo)
308---
309>   SUBROUTINE condveg_albcalc (kjpindex,deadleaf_cover,veget,frac_bare,drysoil_frac,albedo)
3101057a1071
311>     REAL(r_std), DIMENSION(kjpindex,nvm), INTENT(in) :: frac_bare
3121063a1078
313>     REAL(r_std),DIMENSION (kjpindex)                 :: tot_frac_bare
3141068a1084,1087
315>     tot_frac_bare(:) = veget(:,1)
316>     DO jv = 2, nvm
317>        tot_frac_bare(:) = tot_frac_bare(:) + veget(:,jv) * frac_bare(:,jv)
318>     ENDDO
3191074a1094,1095
320> !MG Jan Test limit albedo for NLDAS due to high swdown
321> !          alb_bare(:) =( soilalb_wet(:,ks) + drysoil_frac(:) * (soilalb_dry(:,ks) -  soilalb_wet(:,ks)) ) / 0.75
3221081c1102
323<        !albedo(:,ks) = veget(:,1) * ( (1.-deadleaf_cover(:))*alb_bare(:) + &
324---
325>        !albedo(:,ks) = tot_frac_bare(:) * ( (1.-deadleaf_cover(:))*alb_bare(:) + &
3261083c1104
327<        albedo(:,ks) = veget(:,1) * alb_bare(:)
328---
329>        albedo(:,ks) = tot_frac_bare(:) * alb_bare(:)
3301087c1108,1110
331<           albedo(:,ks) = albedo(:,ks) + veget(:,jv)*alb_leaf_tmp(jv,ks)
332---
333>           albedo(:,ks) = albedo(:,ks) + veget(:,jv)*(un-frac_bare(:,jv))*alb_leaf_tmp(jv,ks)
334> !MG Jan Test limit albedo for NLDAS due to high swdown
335> !          albedo(:,ks) = albedo(:,ks) + ( veget(:,jv)*(un-frac_bare(:,jv))*alb_leaf_tmp(jv,ks) ) / 0.75
336Seulement dans /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_sechiba: condveg.f90.orig
337_______________________________________________________________________________________________________________________
338diff -w --ignore-all-space --ignore-case --recursive --exclude='cvs_diff*' --exclude='*.flc' --exclude='*.bak' --exclude='*.svn*' --exclude='*.lst' --exclude='i.*.L' --exclude='*~' --exclude=Entries --exclude=Tag --exclude=CVS --exclude Makefile /login/IPSL_CODE/WORK_HYDRO/ORCHIDEE_1_9/modeles/ORCHIDEE/src_sechiba/diffuco.f90 /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_sechiba/diffuco.f90
33936d35
340<   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)    :: rstruct                   !! architectural resistance
34169,74c68,72
342< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
343< !     & zlev, z0, roughheight, temp_sol, temp_air, rau, q_cdrag, qsurf, qair, pb, &
344<      & zlev, z0, roughheight, temp_sol, temp_air, rau, q_cdrag, qsurf, qair, q2m, t2m, pb, &
345<      & rsol, evap_bare_lim, evapot, snow, frac_nobio, snow_nobio, totfrac_nobio, &
346<      & swnet, swdown, ccanopy, humrel, veget, veget_max, lai, qsintveg, qsintmax, assim_param, &
347<      & vbeta , valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, rveget, cimean, rest_id, hist_id, hist2_id)
348---
349>      & zlev, z0, roughheight, temp_sol, temp_air, rau, q_cdrag, qsurf, qair, pb, &
350>      & rsol, evap_bare_lim, evapot, evapot_corr, snow, flood_frac, flood_res, frac_nobio, snow_nobio, totfrac_nobio, &
351>      & swnet, swdown, ccanopy, humrel, frac_bare, veget, lai, qsintveg, qsintmax, assim_param, &
352>      & vbeta , valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, vbetaco2, rveget, rstruct, cimean, &
353>      & rest_id, hist_id, hist2_id)
35499,101c97
355< ! Ajout Nathalie - declaration q2m
356<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: q2m              !! 2m specific humidity
357<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: t2m              !! 2m air temperature
358---
359>     !
360102a99,100
361>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: flood_frac       !! Fraction of floodplains
362>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: flood_res        !! Reservoir in floodplains (estimation to avoid over-evaporation)
363106a105
364>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: evapot_corr      !! Soil Potential Evaporation
365112a112
366>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)  :: frac_bare        !! Fraction of bare soil per vegetation
367114d113
368<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)  :: veget_max        !! Max. fraction of vegetation type (LAI->infty)
369126a126
370>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)     :: vbeta5           !! Beta for floodplains
371129a130
372>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (out) :: vbeta3pot        !! Beta for potential transpiration
373130a132
374>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (out) :: rstruct          !! Structural resistance for the vegetation
375144,148d145
376<         IF (long_print) WRITE (numout,*) ' call diffuco_init '
377<
378<         CALL diffuco_init(kjit, ldrestart_read, kjpindex, index, rest_id)
379<
380<
381163a161,165
382>         IF (long_print) WRITE (numout,*) ' call diffuco_init '
383>
384>         ! If cdrag is
385>         CALL diffuco_init(kjit, ldrestart_read, kjpindex, index, rest_id, q_cdrag, rstruct)
386>
387167,168d168
388<     ! MM
389<     wind(:) = SQRT (u(:)*u(:) + v(:)*v(:))
390197a198,199
391>     ! MM
392>     wind(:) = SQRT (u(:)*u(:) + v(:)*v(:))
393203c205
394<        CALL diffuco_aero (kjpindex, kjit, u, v, zlev, z0, roughheight, veget_max, temp_sol, temp_air, &
395---
396>        CALL diffuco_aero (kjpindex, kjit, u, v, zlev, z0, roughheight, temp_sol, temp_air, &
397221a224,229
398>     ! beta coefficient for floodplains (surface reservoir)
399>     !
400>     CALL diffuco_flood (kjpindex, dtradia, qair, qsatt, rau, u, v, q_cdrag, evapot, evapot_corr, &
401>          & flood_frac, flood_res, vbeta5)
402>
403>     !
404232,237d239
405<     ! beta coefficient for bare soil
406<     !
407<
408<     CALL diffuco_bare (kjpindex, dtradia, u, v, q_cdrag, rsol, evap_bare_lim, evapot, humrel, veget, vbeta4)
409<
410<     !
411240d241
412<
413243,247d243
414< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
415<       ! Correction Nathalie - Juin 2006 - introduction d'un terme vbeta23
416<       !CALL diffuco_trans_co2 (kjpindex, dtradia, swdown, temp_air, pb, qair, rau, u, v, q_cdrag, humrel, &
417<       !                        assim_param, ccanopy, &
418<       !                        veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2)
419249c245
420<       CALL diffuco_trans_co2 (kjpindex, dtradia, swdown, temp_air, pb, qair, q2m, t2m, rau, u, v, q_cdrag, humrel, &
421---
422>       CALL diffuco_trans_co2 (kjpindex, dtradia, swdown, temp_air, pb, qair, rau, u, v, q_cdrag, humrel, &
423251c247
424<                               veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2, vbeta23)
425---
426>                               veget, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2, vbeta23)
427260c256,257
428<                           veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2, vbeta23)
429---
430>                         & veget, lai, qsintveg, qsintmax, vbeta3, vbeta3pot, rveget, rstruct, cimean, &
431>                         & vbetaco2, vbeta23)
432264a262,268
433>     ! beta coefficient for bare soil
434>     !
435>
436>     CALL diffuco_bare (kjpindex, dtradia, u, v, q_cdrag, rsol, evap_bare_lim, evapot, humrel, &
437>          & frac_bare, veget, vbeta2, vbeta3, vbeta4)
438>
439>     !
440270c274
441<        & veget, vbeta1, vbeta2, vbeta3, vbeta4, valpha, vbeta, qsintmax)   
442---
443>        & veget, frac_bare, vbeta1, vbeta2, vbeta3, vbeta4, valpha, vbeta, qsintmax)   
444273d276
445<        CALL histwrite(hist_id, 'rstruct', kjit, rstruct, kjpindex*nvm, indexveg)
446280d282
447<           CALL histwrite(hist2_id, 'rstruct', kjit, rstruct, kjpindex*nvm, indexveg)
448297c299,301
449<   SUBROUTINE diffuco_init(kjit, ldrestart_read, kjpindex, index, rest_id)
450---
451>  ! SUBROUTINE diffuco_init(kjit, ldrestart_read, kjpindex, index, rest_id)
452> !MG
453>   SUBROUTINE diffuco_init(kjit, ldrestart_read, kjpindex, index, rest_id, q_cdrag, rstruct)
454305a310,312
455>     REAL(r_std),DIMENSION (kjpindex), INTENT (inout)   :: q_cdrag          !! Surface drag
456> !MG
457>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (out) :: rstruct    !! STOMATE: architectural resistance
458337,342d343
459<     ALLOCATE (rstruct(kjpindex,nvm),stat=ier)
460<     IF (ier.NE.0) THEN
461<         WRITE (numout,*) ' error in rstuct allocation. We stop. We need kjpindex x nvm words = ' ,kjpindex,' x ' ,nvm,&
462<            & ' = ',kjpindex*nvm
463<         STOP 'diffuco_init'
464<     END IF
465435d435
466<       IF (ALLOCATED (rstruct)) DEALLOCATE (rstruct)
467444c444
468<   SUBROUTINE diffuco_aero (kjpindex, kjit, u, v, zlev, z0, roughheight, veget_max, temp_sol, temp_air, &
469---
470>   SUBROUTINE diffuco_aero (kjpindex, kjit, u, v, zlev, z0, roughheight, temp_sol, temp_air, &
471456d455
472<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: veget_max        !! Fraction of vegetation type
473526,529d524
474< !!
475< !!        In some situations it might be useful to give an upper limit on the cdrag as well.
476< !!        The line here should then be uncommented.
477< !!          q_cdrag(ji) = MIN(q_cdrag(ji), 0.5/MAX(speed,min_wind))
478608c603
479<            !    the atmospheric demande.
480---
481>            !    the atmospheric demand.
482633a629,688
483>   !! This routine computes partial beta coefficient : floodplains
484>   !!
485>   SUBROUTINE diffuco_flood (kjpindex, dtradia, qair, qsatt, rau, u, v, q_cdrag, evapot, evapot_corr, &
486>        & flood_frac, flood_res, vbeta5)
487>
488>     ! interface description
489>     ! input scalar
490>     INTEGER(i_std), INTENT(in)                               :: kjpindex   !! Domain size
491>     REAL(r_std), INTENT (in)                                 :: dtradia    !! Time step in seconds
492>     ! input fields
493>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: qair       !! Lowest level specific humidity
494>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: qsatt      !! Surface saturated humidity
495>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: rau        !! Density
496>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: u          !! Lowest level wind speed
497>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: v          !! Lowest level wind speed
498>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: q_cdrag    !! Surface drag
499>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: flood_res  !! water mass in flood reservoir
500>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: flood_frac !! fraction of floodplains
501>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: evapot     !! Potential evaporation
502>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: evapot_corr!! Potential evaporation2
503>     ! output fields
504>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: vbeta5     !! Beta for floodplains
505>
506>     ! local declaration
507>     REAL(r_std)                                              :: subtest, zrapp, speed
508>     INTEGER(i_std)                                          :: ji, jv
509>
510>     !
511>     ! beta coefficient for sublimation for floodplains
512>     !
513>     DO ji=1,kjpindex
514>        !
515>        IF (evapot(ji) .GT. min_sechiba) THEN
516>           vbeta5(ji) = flood_frac(ji) *evapot_corr(ji)/evapot(ji)
517>        ELSE
518>           vbeta5(ji) = flood_frac(ji)
519>        ENDIF
520>        !
521>        ! -- Limitation of evaporation in case of water amounts smaller than
522>        !    the atmospheric demand.
523>       
524>        !
525>        speed = MAX(min_wind, SQRT (u(ji)*u(ji) + v(ji)*v(ji)))
526>        !
527>        subtest = dtradia * vbeta5(ji) * speed * q_cdrag(ji) * rau(ji) * &
528>                & ( qsatt(ji) - qair(ji) )
529>        ! 
530>        IF ( subtest .GT. zero ) THEN
531>           zrapp = flood_res(ji) / subtest
532>           IF ( zrapp .LT. un ) THEN
533>              vbeta5(ji) = vbeta5(ji) * zrapp
534>           ENDIF
535>        ENDIF
536>        !
537>     END DO
538>
539>     IF (long_print) WRITE (numout,*) ' diffuco_flood done '
540>
541>   END SUBROUTINE diffuco_flood
542>
543670a726
544>
545671a728
546>     
547687a745,746
548>             ! Comment the line below if you want to use a formula of evaporation that uses zqsvegrap (see vbeta3)
549>             zqsvegrap = un
550689a749
551>
552704c764
553<                     vbeta23(ji,jv) = MAX(vbeta2(ji,jv) - vbeta2(ji,jv) * zrapp, 0.)
554---
555>                     vbeta23(ji,jv) = MAX(vbeta2(ji,jv) - vbeta2(ji,jv) * zrapp, zero)
556709a770,775
557>         ! Autre formulation possible pour l'evaporation permettant une transpiration sur tout le feuillage
558>         !commenter si formulation Nathalie sinon Tristan
559> !MG
560>         speed = MAX(min_wind, wind(ji))
561>         
562>         vbeta23(ji,jv) = MAX(zero, veget(ji,jv) * (un / (un + speed * q_cdrag(ji) * rstruct(ji,jv))) - vbeta2(ji,jv))
563721c787,788
564<   SUBROUTINE diffuco_bare (kjpindex, dtradia, u, v, q_cdrag, rsol, evap_bare_lim, evapot, humrel, veget, vbeta4)
565---
566>   SUBROUTINE diffuco_bare (kjpindex, dtradia, u, v, q_cdrag, rsol, evap_bare_lim, evapot, humrel, &
567>        & frac_bare, veget, vbeta2, vbeta3, vbeta4)
568735a803,805
569>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: frac_bare  !! Bare soil fraction per vegetation
570>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: vbeta2     !! Beta for Interception
571>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: vbeta3     !! Beta for Transpiration
572737c807
573<     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: vbeta4     !! Beta for bare soil evpaoration
574---
575>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: vbeta4     !! Beta for bare soil evaporation
576741a812
577>     REAL(r_std)                                    :: humveg_prod
578749,750c820
579<           !      note: veget (  ,1) contains the fraction of bare soil
580<           !            see hydrol module
581---
582>           !      Using bare soil fraction
583752d821
584<           IF (veget(ji,1) .GE. min_sechiba) THEN
585755a825,829
586>           humveg_prod = zero
587>           !
588>           DO jv = 1, nvm
589>              humveg_prod = humveg_prod + frac_bare(ji,jv) * veget(ji,jv) * humrel(ji,jv)
590>           ENDDO
591761c835,839
592<              vbeta4(ji) = veget(ji,1) * (un / (un + speed * q_cdrag(ji) * rsol(ji)))
593---
594>           !Decommenter la ligne ci-dessous si calcul Nathalie         
595>           !vbeta4(ji) = veget(ji,1) * (un / (un + speed * q_cdrag(ji) * rsol(ji)))
596>           !Commenter la ligne ci-dessous si calcul Nathalie sinon Tristan
597>           vbeta4(ji) = MIN(humveg_prod * (un / (un + speed * q_cdrag(ji) * rsol(ji))), &
598>                & un - SUM(vbeta2(ji,:)+vbeta3(ji,:)))
599763d840
600<           ENDIF
601768c845,846
602<           vbeta4(ji) = evap_bare_lim(ji)
603---
604>           ! The limitation by 1-beta2-beta3 is due to the fact that evaporation under vegetation is possible
605>           vbeta4(ji) = MIN(evap_bare_lim(ji), un - SUM(vbeta2(ji,:)+vbeta3(ji,:)))
606778,780c856
607<   ! Nathalie - Juin 2006 - introduction de vbeta23
608<   !SUBROUTINE diffuco_trans (kjpindex, dtradia, swnet, temp_air, pb, qair, rau, u, v, q_cdrag, humrel, &
609<   !                          veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2) 
610---
611>
612782c858
613<                             veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2, vbeta23) 
614---
615>                             veget, lai, qsintveg, qsintmax, vbeta3, vbeta3pot, rveget, rstruct, cimean, vbetaco2, vbeta23) 
616799d874
617<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: veget_max        !! Max. vegetation fraction (LAI -> infty)
618804d878
619<     ! AJout Nathalie - Juin 2006
620806d879
621<     ! Fin ajout Nathalie
622808a882
623>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (out)       :: vbeta3pot        !! Beta for Potential Transpiration
624817a892
625>     REAL(r_std),DIMENSION (kjpindex,nvm)           :: rveget_min                 !! Minimal Surface resistance of vegetation
626831a907
627>       rveget_min(:,jv) = undef_sechiba
628833c909
629<
630---
631>       vbeta3pot(:,jv) = zero
632849a926,929
633>
634>             rveget_min(ji,jv) = (defc_plus / kzero(jv)) * (un / lai(ji,jv))
635>
636> !!!!! To be taken out at a later point
637854,855c934,935
638<             vbeta3(ji,jv) = veget(ji,jv) * (un - zqsvegrap(ji)) * humrel(ji,jv) * &
639<                  (un / (un + speed * q_cdrag(ji) * (rveg_pft(jv)*(rveget(ji,jv) + rstruct(ji,jv)))))
640---
641>             !vbeta3(ji,jv) = veget(ji,jv) * (un - zqsvegrap(ji)) * humrel(ji,jv) * &
642>             !     (un / (un + speed * q_cdrag(ji) * (rveg_pft(jv)*(rveget(ji,jv) + rstruct(ji,jv)))))
643858,860c938,940
644<             vbeta3(ji,jv) = vbeta3(ji,jv) + MIN( vbeta23(ji,jv), &
645<                  veget(ji,jv) * zqsvegrap(ji) * humrel(ji,jv) * &
646<                  (un / (un + speed * q_cdrag(ji) * (rveg_pft(jv)*(rveget(ji,jv) + rstruct(ji,jv))))))
647---
648>             !vbeta3(ji,jv) = vbeta3(ji,jv) + MIN( vbeta23(ji,jv), &
649>             !     veget(ji,jv) * zqsvegrap(ji) * humrel(ji,jv) * &
650>             !     (un / (un + speed * q_cdrag(ji) * (rveg_pft(jv)*(rveget(ji,jv) + rstruct(ji,jv))))))
651862c942,951
652<
653---
654>             ! Autre possibilite permettant la transpiration sur toute la canopee
655>             !Commenter si formulation Nathalie sinon Tristan
656> !!!!!!
657>
658>             vbeta3(ji,jv) = MAX(zero, MIN(vbeta23(ji,jv), &
659>                  & veget(ji,jv) * humrel(ji,jv) / (un + speed * q_cdrag(ji) * (rveg_pft(jv)*(rveget(ji,jv) + rstruct(ji,jv))))))
660>
661>            ! vbeta3pot for computation of potential transpiration (needed for irrigation)
662>             vbeta3pot(ji,jv) = &
663>                  &  MAX(zero, veget(ji,jv) / (un + speed * q_cdrag(ji) * (rveg_pft(jv)*(rveget_min(ji,jv) + rstruct(ji,jv)))))
664868a958
665>
666880,885c970,971
667< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
668<   ! Nathalie - Juin 2006 - introduction de vbeta23
669<   !SUBROUTINE diffuco_trans_co2 (kjpindex, dtradia, swdown, temp_air, pb, qair, rau, u, v, q_cdrag, humrel, &
670<   !                              assim_param, ccanopy, &
671<   !                              veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2)
672<   SUBROUTINE diffuco_trans_co2 (kjpindex, dtradia, swdown, temp_air, pb, qair, q2m, t2m, rau, u, v, q_cdrag, humrel, &
673---
674>
675>   SUBROUTINE diffuco_trans_co2 (kjpindex, dtradia, swdown, temp_air, pb, qair, rau, u, v, q_cdrag, humrel, &
676887c973
677<                                 veget, veget_max, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2, vbeta23)
678---
679>                                 veget, lai, qsintveg, qsintmax, vbeta3, rveget, rstruct, cimean, vbetaco2, vbeta23)
680898,900c984
681< ! Ajout Nathalie - Juin 2006 - declaration q2m
682<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: q2m              !! 2m specific humidity
683<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: t2m              !! 2m air temperature
684---
685>     !
686909d992
687<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: veget_max        !! Max. vegetation fraction (LAI -> infty)
688992,997c1075,1076
689< ! correction Nathalie, on utilise q2m/t2m au lieu de qair - Juin 2006
690< !    CALL qsatcalc (kjpindex, temp_air, pb, qsatt)
691< !    air_relhum(:) = &
692< !      ( qair(:) * pb(:) / (0.622+qair(:)*0.378) ) / &
693< !      ( qsatt(:)*pb(:) / (0.622+qsatt(:)*0.378 ) )
694<     CALL qsatcalc (kjpindex, t2m, pb, qsatt)
695---
696>
697>     CALL qsatcalc (kjpindex, temp_air, pb, qsatt)
698999c1078
699<       ( q2m(:) * pb(:) / (0.622+q2m(:)*0.378) ) / &
700---
701>       ( qair(:) * pb(:) / (0.622+qair(:)*0.378) ) / &
7021000a1080
703>
7041418c1498
705<           vbeta3(iainia,jv) = veget_max(iainia,jv) * &
706---
707>           vbeta3(iainia,jv) = veget(iainia,jv) * &
7081433c1513
709<           ! vbetaco2(iainia,jv) = veget_max(iainia,jv) * &
710---
711>           ! vbetaco2(iainia,jv) = veget(iainia,jv) * &
7121437c1517
713<           vbetaco2(iainia,jv) = veget_max(iainia,jv) * &
714---
715>           vbetaco2(iainia,jv) = veget(iainia,jv) * &
7161446c1526
717<              ( vbetaco2(iainia,jv)/veget_max(iainia,jv) * &
718---
719>              ( vbetaco2(iainia,jv)/veget(iainia,jv) * &
7201464c1544
721<        & snow, veget, vbeta1, vbeta2, vbeta3 , vbeta4, valpha, vbeta, qsintmax)   
722---
723>        & snow, veget, frac_bare, vbeta1, vbeta2, vbeta3 , vbeta4, valpha, vbeta, qsintmax)   
7241480a1561
725>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: frac_bare  !! Bare soil fraction per vegetation
7261578c1659,1662
727<         vbeta4(ji) = veget(ji,1)
728---
729>         vbeta4(ji) = zero
730>         DO jv = 1, nvm
731>            vbeta4(ji) = vbeta4(ji) + frac_bare(ji,jv) * veget(ji,jv)
732>         ENDDO
733_______________________________________________________________________________________________________________________
734diff -w --ignore-all-space --ignore-case --recursive --exclude='cvs_diff*' --exclude='*.flc' --exclude='*.bak' --exclude='*.svn*' --exclude='*.lst' --exclude='i.*.L' --exclude='*~' --exclude=Entries --exclude=Tag --exclude=CVS --exclude Makefile /login/IPSL_CODE/WORK_HYDRO/ORCHIDEE_1_9/modeles/ORCHIDEE/src_sechiba/enerbil.f90 /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_sechiba/enerbil.f90
73553a54,55
736>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: q_sol_pot               !! Potential surface humidity
737>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: temp_sol_pot            !! Potential surface temperature (unstressed)
73874,77c76,79
739<      & index, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef, &
740<      & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, &
741<      & cimean, ccanopy, emis, soilflx, soilcap, q_cdrag, humrel, fluxsens, fluxlat, &
742<      & vevapp, transpir, gpp, vevapnu, vevapwet, vevapsno, t2mdiag, temp_sol, tsol_rad, &
743---
744>        & index, indexveg, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef, &
745>        & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, &
746>        & vbetaco2, cimean, ccanopy, emis, soilflx, soilcap, q_cdrag, humrel, fluxsens, fluxlat, &
747>        & vevapp, transpir, transpot, gpp, vevapnu, vevapwet, vevapsno, vevapflo, t2mdiag, temp_sol, tsol_rad, &
74890a93
749>     INTEGER(i_std),DIMENSION(kjpindex*nvm), INTENT(in) :: indexveg         !! Indeces of the points on the 3D map
750108a112
751>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: vbeta5           !! Floodplains resistance
752116a121
753>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)  :: vbeta3pot        !! Vegetation resistance for potential transpiration
754127a133,134
755>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)     :: vevapflo         !! Floodplains evaporation
756>
757132a140
758>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (out) :: transpot         !! Potential transpiration
759139a148,149
760> !MG
761>     INTEGER(i_std)                                :: ji,jv
762147c157
763<              &             qsurf, tsol_rad, vevapp, fluxsens, fluxlat, gpp, evapot)
764---
765>              &             qsurf, tsol_rad, vevapp, fluxsens, fluxlat, gpp, evapot, evapot_corr)
766182a193,198
767>         var_name= 'tempsolpot'
768>         CALL restput_p(rest_id, var_name, nbp_glo, 1, 1, kjit, temp_sol_pot, 'scatter',  nbp_glo, index_g)
769>
770>         var_name= 'qsolpot'
771>         CALL restput_p(rest_id, var_name, nbp_glo, 1, 1, kjit, q_sol_pot, 'scatter',  nbp_glo, index_g)
772>
773208c224
774<        & valpha, vbeta1, soilcap, lwdown, swnet, psnew, qsol_sat_new, temp_sol_new, &
775---
776>        & valpha, vbeta1, vbeta5, soilcap, lwdown, swnet, psnew, qsol_sat_new, temp_sol_new, &
777212c228
778<     ! 3. computes tsol_new, netrad, vevapp, fluxlat, fluxsubli and fluxsens
779---
780>     ! 2.1 computes surface temperature and humidity for a saturated surface
781213a230,232
782>     CALL enerbil_pottemp (kjpindex, dtradia, zlev, emis, &
783>        & epot_air, petAcoef, petBcoef, qair, peqAcoef, peqBcoef, soilflx, rau, u, v, q_cdrag, vbeta,&
784>        & valpha, vbeta1, vbeta5, soilcap, lwdown, swnet, q_sol_pot, temp_sol_pot)
785215c234,237
786<     CALL enerbil_flux (kjpindex, dtradia, emis, temp_sol, rau, u, v, q_cdrag, vbeta, valpha, vbeta1, &
787---
788>     !
789>     ! 3. computes tsol_new, netrad, vevapp, fluxlat, fluxsubli and fluxsens
790>     !
791>     CALL enerbil_flux (kjpindex, dtradia, emis, temp_sol, rau, u, v, q_cdrag, vbeta, valpha, vbeta1, vbeta5, &
792224,225c246,248
793<     CALL enerbil_evapveg (kjpindex, dtradia, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, cimean, &
794<        & ccanopy, rau, u, v, q_cdrag, qair_new, humrel, vevapsno, vevapnu , vevapwet, transpir, gpp, evapot)
795---
796>     CALL enerbil_evapveg (kjpindex, dtradia, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, vbetaco2, &
797>        & cimean, ccanopy, rau, u, v, q_cdrag, qair_new, humrel, vevapsno, vevapnu , vevapflo, vevapwet, &
798>        & transpir, transpot, gpp, evapot)
799249a273,274
800>        CALL histwrite(hist_id, 'PotEvapOld', kjit, evapot, kjpindex, index)
801>        CALL histwrite(hist_id, 'PotSurfT', kjit, temp_sol_pot, kjpindex, index)
802265c290
803<        &                   qsurf, tsol_rad, vevapp, fluxsens, fluxlat, gpp, evapot)
804---
805>        &                   qsurf, tsol_rad, vevapp, fluxsens, fluxlat, gpp, evapot, evapot_corr)
806287a313
807>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: evapot_corr        !! Soil Potential Evaporation
808371a398,409
809>     ALLOCATE (q_sol_pot(kjpindex),stat=ier)
810>     IF (ier.NE.0) THEN
811>         WRITE (numout,*) ' error in q_sol_pot allocation. We stop. We need kjpindex words = ',kjpindex
812>         STOP 'enerbil_init'
813>     END IF
814>
815>     ALLOCATE (temp_sol_pot(kjpindex),stat=ier)
816>     IF (ier.NE.0) THEN
817>         WRITE (numout,*) ' error in temp_sol_pot allocation. We stop. We need kjpindex words = ',kjpindex
818>         STOP 'enerbil_init'
819>     END IF
820>
821377c415
822<         IF (long_print) WRITE (numout,*) ' we have to read a restart file for HYDROLOGIC variables'
823---
824>         IF (long_print) WRITE (numout,*) ' we have to read a restart file for ENERBIL variables'
825382a421,426
826>
827>         IF ( MINVAL(temp_sol) < 0. .OR. MAXVAL(temp_sol) > 500.) THEN
828>            WRITE(numout, *) "Big problem with surface temperature at restart : ",  MINVAL(temp_sol), MAXVAL(temp_sol)
829>            WHERE ( temp_sol < 0.) temp_sol = 280.
830>         ENDIF
831>
832413a458
833>         evapot_corr(:) = evapot(:)
834447a493,509
835>
836>         var_name= 'tempsolpot'
837>         CALL ioconf_setatt('UNITS', 'K')
838>         CALL ioconf_setatt('LONG_NAME','Potential surface temperature')
839>         CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., temp_sol_pot, "gather", nbp_glo, index_g)
840>         IF ( ALL( temp_sol_pot(:) .EQ. val_exp ) ) THEN
841>            temp_sol_pot = temp_sol
842>         ENDIF
843>
844>         var_name= 'qsolpot'
845>         CALL ioconf_setatt('UNITS', 'kg/m^2')
846>         CALL ioconf_setatt('LONG_NAME','Potential saturated surface humidity')
847>         CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., q_sol_pot, "gather", nbp_glo, index_g)
848>         IF ( ALL( q_sol_pot(:) .EQ. val_exp ) ) THEN
849>            q_sol_pot = qsurf
850>         ENDIF
851>
852488a551,552
853>     IF ( ALLOCATED (q_sol_pot)) DEALLOCATE (q_sol_pot)
854>     IF ( ALLOCATED (temp_sol_pot)) DEALLOCATE (temp_sol_pot)
855599c663
856<      & valpha, vbeta1, soilcap, lwdown, swnet, psnew, qsol_sat_new, temp_sol_new, &
857---
858>      & valpha, vbeta1, vbeta5, soilcap, lwdown, swnet, psnew, qsol_sat_new, temp_sol_new, &
859621a686
860>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: vbeta5        !! Floodplains resistance
861659,661c724,727
862<       larsub_old = chalsu0 * vbeta1(ji) * (peqBcoef(ji) -  qsol_sat(ji)) / (zikq - peqAcoef(ji))
863<       lareva_old = chalev0 * (un - vbeta1(ji)) * vbeta(ji) * &
864<            & (peqBcoef(ji) -  valpha(ji) * qsol_sat(ji)) / (zikq - peqAcoef(ji))
865---
866>       larsub_old = chalsu0 * vbeta1(ji) * (un - vbeta5(ji)) * (peqBcoef(ji) -  qsol_sat(ji)) / (zikq - peqAcoef(ji))
867>       lareva_old = chalev0 * (un - vbeta1(ji)) * (un - vbeta5(ji)) * vbeta(ji) * &
868>            & (peqBcoef(ji) -  valpha(ji) * qsol_sat(ji)) / (zikq - peqAcoef(ji)) &
869>            & + chalev0 * vbeta5(ji) * (peqBcoef(ji) -  qsol_sat(ji)) / (zikq - peqAcoef(ji))
870669,670c735,736
871<       larsub_sns = chalsu0 * vbeta1(ji) * zicp(ji) * pdqsold(ji) / (zikq - peqAcoef(ji))
872<       lareva_sns = chalev0 * (un - vbeta1(ji)) * vbeta(ji) * valpha(ji) * &
873---
874>       larsub_sns = chalsu0 * vbeta1(ji) * (un - vbeta5(ji)) * zicp(ji) * pdqsold(ji) / (zikq - peqAcoef(ji))
875>       lareva_sns = chalev0 * ((un - vbeta1(ji))*(un - vbeta5(ji)) * vbeta(ji) * valpha(ji) + vbeta5(ji)) * &
876694,695c760,762
877<         qair_new(ji) = zikq * un / (chalev0 * (un - vbeta1(ji)) * vbeta(ji) * valpha(ji) + &
878<            & chalsu0 *  vbeta1(ji)) * fevap + qsol_sat_new(ji)
879---
880>         qair_new(ji) = zikq * un / ( chalsu0 *  vbeta1(ji) * (un - vbeta5(ji)) + &
881>            & chalev0 * ((un - vbeta1(ji))*(un - vbeta5(ji)) * vbeta(ji) * valpha(ji) + vbeta5(ji)) ) &
882>            & * fevap + qsol_sat_new(ji)
883704a772,830
884>   !
885>   ! This subroutine computes the surface temperature and humidity should the surface been unstressed.
886>   !
887>   SUBROUTINE enerbil_pottemp (kjpindex, dtradia, zlev, emis, epot_air, &
888>      & petAcoef, petBcoef, qair, peqAcoef, peqBcoef, soilflx, rau, u, v, q_cdrag, vbeta,&
889>      & valpha, vbeta1, vbeta5, soilcap, lwdown, swnet, q_sol_pot, temp_sol_pot)
890>
891>     ! interface
892>     ! input scalar
893>     INTEGER(i_std), INTENT(in)                               :: kjpindex      !! Domain size
894>     REAL(r_std), INTENT(in)                                  :: dtradia       !! Time step in seconds
895>     ! input fields
896>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: zlev          !! Height of first layer
897>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: emis          !! Emissivity
898>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: epot_air      !! Air potential energy
899>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: petAcoef      !! PetAcoef
900>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: petBcoef      !! PetBcoef
901>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: qair          !! Lowest level specific humidity
902>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: peqAcoef      !! PeqAcoef
903>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: peqBcoef      !! PeqBcoef
904>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: soilflx       !! Soil flux
905>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: rau           !! Density
906>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: u, v          !! Wind
907>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: q_cdrag       !!
908>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: vbeta         !! Resistance coefficient
909>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: valpha        !! Resistance coefficient
910>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: vbeta1        !! Snow resistance
911>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: vbeta5        !! Floodplains resistance
912>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: soilcap       !! Soil calorific capacity
913>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: lwdown        !! Down-welling long-wave flux
914>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: swnet         !! Net surface short-wave flux
915>     ! output fields
916>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: q_sol_pot     !! Potential surface air moisture
917>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: temp_sol_pot  !! Potential soil temperature
918>
919>
920>     ! local declaration
921>     INTEGER(i_std)                  :: ji
922>     REAL(r_std),DIMENSION (kjpindex) :: zicp
923>     REAL(r_std)                      :: fevap
924>     REAL(r_std)                      :: sensfl_old, larsub_old, lareva_old, dtheta, sum_old, sum_sns
925>     REAL(r_std)                      :: zikt, zikq, netrad_sns, sensfl_sns, larsub_sns, lareva_sns
926>     REAL(r_std)                      :: speed
927>
928>     zicp = un / cp_air
929>     !
930>     DO ji=1,kjpindex
931>
932>        dtheta = zero
933>        fevap = zero
934>
935>        temp_sol_pot(ji) = temp_sol_pot(ji) + dtheta
936>
937>        q_sol_pot(ji) = q_sol_pot(ji) + fevap
938>
939>     ENDDO
940>
941>   END SUBROUTINE enerbil_pottemp
942>
943707,708c833,834
944<   SUBROUTINE enerbil_flux (kjpindex, dtradia, emis, temp_sol, rau, u, v, q_cdrag, vbeta, valpha, &
945<      & vbeta1, qair, epot_air, psnew, qsurf, fluxsens, fluxlat, fluxsubli, vevapp, temp_sol_new, &
946---
947>   SUBROUTINE enerbil_flux (kjpindex, dtradia, emis, temp_sol, rau, u, v, q_cdrag, vbeta, valpha, vbeta1, vbeta5, &
948>        & qair, epot_air, psnew, qsurf, fluxsens, fluxlat, fluxsubli, vevapp, temp_sol_new, &
949723a850
950>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: vbeta5        !! Flood resistance
951746c873
952<     INTEGER(i_std)                                 :: ji
953---
954>     INTEGER(i_std)                                 :: ji,jv
955777,778c904,905
956<       qsurf(ji) = vbeta1(ji) * qsol_sat_new(ji) + &
957<            & (un - vbeta1(ji)) * vbeta(ji) * valpha(ji) * qsol_sat_new(ji)
958---
959>       qsurf(ji) = (vbeta1(ji) * (un - vbeta5(ji)) + vbeta5(ji)) * qsol_sat_new(ji) + &
960>            & (un - vbeta1(ji))*(un - vbeta5(ji)) * vbeta(ji) * valpha(ji) * qsol_sat_new(ji)
961783,784c910,912
962<       vevapp(ji) = dtradia * rau(ji) * qc * vbeta1(ji) * (qsol_sat_new(ji) - qair(ji)) + &
963<            & dtradia * rau(ji) * qc * (un - vbeta1(ji)) * vbeta(ji) * &
964---
965>       vevapp(ji) = dtradia * rau(ji) * qc * (vbeta1(ji) * (un - vbeta5(ji)) + vbeta5(ji)) * &
966>            & (qsol_sat_new(ji) - qair(ji)) + &
967>            &  dtradia * rau(ji) * qc * (un - vbeta1(ji))*(un-vbeta5(ji)) * vbeta(ji) * &
968787c915,917
969<       fluxlat(ji) = chalsu0 * rau(ji) * qc * vbeta1(ji) *&
970---
971>       fluxlat(ji) = chalsu0 * rau(ji) * qc * vbeta1(ji) * (un - vbeta5(ji)) * &
972>            & (qsol_sat_new(ji) - qair(ji)) + &
973>            &  chalev0 * rau(ji) * qc * vbeta5(ji) *&
974789c919
975<            &  chalev0 * rau(ji) * qc * (un - vbeta1(ji)) * vbeta(ji) * &
976---
977>            &  chalev0 * rau(ji) * qc * (un - vbeta1(ji)) * (un - vbeta5(ji)) * vbeta(ji) * &
978792c922
979<       fluxsubli(ji) = chalsu0 * rau(ji) * qc * vbeta1(ji) *&
980---
981>       fluxsubli(ji) = chalsu0 * rau(ji) * qc * vbeta1(ji) * (un - vbeta5(ji)) * &
982802c932
983<
984---
985> !
986841,842c971,973
987<   SUBROUTINE enerbil_evapveg (kjpindex, dtradia, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, cimean, &
988<      & ccanopy, rau, u, v, q_cdrag, qair, humrel, vevapsno, vevapnu , vevapwet, transpir, gpp, evapot)
989---
990>   SUBROUTINE enerbil_evapveg (kjpindex, dtradia, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, vbetaco2, &
991>      & cimean, ccanopy, rau, u, v, q_cdrag, qair, humrel, vevapsno, vevapnu , vevapflo, vevapwet, &
992>      & transpir, transpot, gpp, evapot)
993850a982
994>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: vbeta5           !! Floodplains resistance
995859a992
996>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)        :: vbeta3pot        !! Vegetation resistance for potential transpiration
997864a998
998>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)           :: vevapflo         !! Floodplains evaporation
999865a1000
1000>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (out)       :: transpot         !! Potential Transpiration
1001870a1006
1002>     REAL(r_std), DIMENSION(kjpindex)               :: vbeta2sum, vbeta3sum
1003874c1010,1016
1004<     ! initialisation
1005---
1006>     ! initialisation: utile pour calculer l'evaporation des floodplains dans lesquelles il y a de la vegetation
1007>     vbeta2sum(:) = 0.
1008>     vbeta3sum(:) = 0.
1009>     DO jv = 1, nvm
1010>       vbeta2sum(:) = vbeta2sum(:) + vbeta2(:,jv)
1011>       vbeta3sum(:) = vbeta3sum(:) + vbeta3(:,jv)
1012>     ENDDO
1013887c1029
1014<       vevapsno(ji) = vbeta1(ji) * dtradia * rau(ji) * speed * q_cdrag(ji) * (qsol_sat_new(ji) - qair(ji))
1015---
1016>       vevapsno(ji) = (un - vbeta5(ji)) * vbeta1(ji) * dtradia * rau(ji) * speed * q_cdrag(ji) * (qsol_sat_new(ji) - qair(ji))
1017892c1034
1018<       vevapnu(ji) = (un - vbeta1(ji)) * vbeta4(ji) * dtradia * rau(ji) * speed * q_cdrag(ji) &
1019---
1020>       vevapnu(ji) = (un - vbeta1(ji)) * (un-vbeta5(ji)) * vbeta4(ji) * dtradia * rau(ji) * speed * q_cdrag(ji) &
1021894a1037,1042
1022>       !
1023>       ! 1.3 floodplains evaporation - transpiration et interception prioritaires dans les floodplains
1024>       !
1025>       vevapflo(ji) = vbeta5(ji) * (1 - vbeta2sum(ji) - vbeta3sum(ji)) &
1026>            & * dtradia * rau(ji) * speed * q_cdrag(ji) * (qsol_sat_new(ji) - qair(ji))
1027>
1028918a1067
1029>         transpot(ji,jv) = xx(ji) * vbeta3pot(ji,jv)
1030_______________________________________________________________________________________________________________________
1031diff -w --ignore-all-space --ignore-case --recursive --exclude='cvs_diff*' --exclude='*.flc' --exclude='*.bak' --exclude='*.svn*' --exclude='*.lst' --exclude='i.*.L' --exclude='*~' --exclude=Entries --exclude=Tag --exclude=CVS --exclude Makefile /login/IPSL_CODE/WORK_HYDRO/ORCHIDEE_1_9/modeles/ORCHIDEE/src_sechiba/hydrolc.f90 /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_sechiba/hydrolc.f90
103239d38
1033<   LOGICAL, SAVE                                     :: check_waterbal=.TRUE. !! The check the water balance
103454a54
1035>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)      :: tot_flux         !! Total water flux
103695a96
1037>   !! - call hydrolc_flood for floodplain process
103899a101
1039>   !! @call hydrolc_flood
1040102,106c104,108
1041<   SUBROUTINE hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, &
1042<      & temp_sol_new, run_off_tot, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1043<      & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age, tot_melt, transpir, &
1044<      & precip_rain, precip_snow, returnflow, irrigation, humrel, vegstress, rsol, drysoil_frac, evapot, evapot_corr,&
1045<      & shumdiag, litterhumdiag, soilcap, rest_id, hist_id, hist2_id)   
1046---
1047>   SUBROUTINE hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, control_in, &
1048>      & temp_sol_new, floodout, run_off_tot, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare, &
1049>      & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age, tot_melt, transpir, &
1050>      & precip_rain, precip_snow, returnflow, reinfiltration,irrigation, humrel, vegstress, rsol, drysoil_frac, &
1051>      & evapot, evapot_corr, flood_frac, flood_res, shumdiag, litterhumdiag, soilcap, rest_id, hist_id, hist2_id)   
1052119a122,123
1053>     TYPE(control_type), INTENT (in)                    :: control_in       !! Flags that (de)activate parts of the model
1054>     !
1055122a127
1056>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: reinfiltration       !! Routed water which comes back into the soil
1057128a134
1058>     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)  :: frac_bare        !! Fraction of bare soil in each vegetation type           
1059130d135
1060<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)  :: veget_max        !! Max. fraction of vegetation type (LAI -> infty)
1061134a140
1062>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: flood_frac  !! Flooded fraction
1063135a142
1064>     REAL(r_std),DIMENSION (kjpindex), INTENT (inout)   :: flood_res   !! Flood reservoir estimate
1065137a145
1066>     REAL(r_std),DIMENSION (kjpindex), INTENT (inout)   :: vevapflo         !! Snow evaporation
1067144a153
1068>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)     :: floodout      !! flux out of floodplains
1069149c158
1070<     REAL(r_std),DIMENSION (kjpindex), INTENT (out)     :: rsol          !! Resistence to bare soil evaporation
1071---
1072>     REAL(r_std),DIMENSION (kjpindex), INTENT (out)     :: rsol          !! Resistance to bare soil evaporation
1073171c180
1074<         CALL hydrolc_var_init (kjpindex, veget, veget_max, rsol, drysoil_frac, mx_eau_var, ruu_ch, shumdiag, litterhumdiag)
1075---
1076>         CALL hydrolc_var_init (kjpindex, veget, rsol, drysoil_frac, mx_eau_var, ruu_ch, shumdiag, litterhumdiag)
1077177,178c186,187
1078<                 & precip_rain, precip_snow, returnflow, irrigation, tot_melt, vevapwet, transpir, vevapnu, vevapsno,&
1079<                 & run_off_tot, drainage)
1080---
1081>                 & precip_rain, precip_snow, returnflow, reinfiltration, irrigation, tot_melt, vevapwet, transpir, &
1082>                 & vevapnu, vevapsno, vevapflo, floodout,run_off_tot, drainage)
1083254a264,267
1084>     ! computes surface reservoir
1085>     !
1086>     CALL hydrolc_flood(kjpindex, dtradia, vevapnu, vevapflo, flood_frac, flood_res, floodout)
1087>     !
1088257,258c270,272
1089<     CALL hydrolc_soil(kjpindex, vevapnu, precisol, returnflow, irrigation, tot_melt, mx_eau_var, veget, ruu_ch, transpir,&
1090<          & gqsb, bqsb, dsg, dss, rsol, drysoil_frac, dsp, runoff, run_off_tot, drainage, humrel, vegstress, shumdiag, litterhumdiag)
1091---
1092>     CALL hydrolc_soil(kjpindex, vevapnu, precisol, returnflow, reinfiltration, irrigation, tot_melt, mx_eau_var, veget, &
1093>          & frac_bare, ruu_ch, transpir, gqsb, bqsb, dsg, dss, rsol, drysoil_frac, dsp, runoff, run_off_tot, drainage, humrel, &
1094>          & vegstress, shumdiag, litterhumdiag)
1095270,271c284,285
1096<             & precip_rain, precip_snow, returnflow, irrigation, tot_melt, vevapwet, transpir, vevapnu, vevapsno,&
1097<             & run_off_tot, drainage )
1098---
1099>             & precip_rain, precip_snow, returnflow, reinfiltration, irrigation, tot_melt, vevapwet, transpir, vevapnu, vevapsno,&
1100>             & vevapflo, floodout, run_off_tot, drainage )
1101291a306,308
1102>        IF ( control_in%do_floodplains ) THEN
1103>           CALL histwrite(hist_id, 'floodout', kjit, floodout, kjpindex, index)
1104>        ENDIF
1105299d315
1106<        CALL histwrite(hist_id, 'DelSWE', kjit, delswe, kjpindex, index)
1107300a317
1108>        CALL histwrite(hist_id, 'DelSWE', kjit, delswe, kjpindex, index)
1109316a334
1110>           CALL histwrite(hist2_id, 'floodout', kjit, floodout, kjpindex, index)
1111322a341,346
1112>           !
1113>           IF (check_waterbal) THEN
1114>              CALL histwrite(hist2_id, 'TotWater', kjit, tot_water_end, kjpindex, index)
1115>              CALL histwrite(hist2_id, 'TotWaterFlux', kjit, tot_flux, kjpindex, index)
1116>           ENDIF
1117>
1118330d353
1119<           CALL histwrite(hist2_id, 'DelSWE', kjit, delswe, kjpindex, index)
1120331a355
1121>           CALL histwrite(hist2_id, 'DelSWE', kjit, delswe, kjpindex, index)
1122529a554,559
1123>        ALLOCATE (tot_flux(kjpindex),stat=ier)
1124>        IF (ier.NE.0) THEN
1125>           WRITE (numout,*) ' error in tot_flux allocation. We stop. We need kjpindex words = ',kjpindex
1126>           STOP 'hydrolc_init'
1127>        END IF
1128>
1129857a888
1130>     IF (ALLOCATED  (tot_flux)) DEALLOCATE (tot_flux)
1131874c905
1132<   SUBROUTINE hydrolc_var_init (kjpindex, veget, veget_max, rsol, drysoil_frac, mx_eau_var, ruu_ch, shumdiag, litterhumdiag)
1133---
1134>   SUBROUTINE hydrolc_var_init (kjpindex, veget, rsol, drysoil_frac, mx_eau_var, ruu_ch, shumdiag, litterhumdiag)
1135881d911
1136<     REAL(r_std),DIMENSION (kjpindex,nvm), INTENT (in)  :: veget_max     !! Max. fraction of vegetation type
1137987,988c1017,1020
1138<           !rsol(ji) = dss(ji,1) * rsol_cste
1139<           rsol(ji) =  ( drysoil_frac(ji) + 1./(10.*(dpu_cste - drysoil_frac(ji))+1.e-10)**2 ) * rsol_cste
1140---
1141>           !Ancienne formulation
1142>           rsol(ji) = dss(ji,1) * rsol_cste
1143>           !Nouvelle formulation Nath         
1144>           !rsol(ji) =  ( drysoil_frac(ji) + 1./(10.*(dpu_cste - drysoil_frac(ji))+1.e-10)**2 ) * rsol_cste
11451101,1102c1133,1134
1146<             warnings(ji) = .TRUE.
1147<             any_warning = .TRUE.
1148---
1149> !!            warnings(ji) = .TRUE.
1150> !!            any_warning = .TRUE.
11511364,1365c1396,1399
1152<       !qsintveg(:,jv) = qsintveg(:,jv) + veget(:,jv) * precip_rain(:)
1153<       qsintveg(:,jv) = qsintveg(:,jv) + veget(:,jv) * ((1-throughfall_by_pft(jv))*precip_rain(:))
1154---
1155>       !Ancienne formulation
1156>       qsintveg(:,jv) = qsintveg(:,jv) + veget(:,jv) * precip_rain(:)
1157>       !Nouvelle formulation Nath
1158>       !qsintveg(:,jv) = qsintveg(:,jv) + veget(:,jv) * ((1-throughfall_by_pft(jv))*precip_rain(:))
11591376,1377c1410,1413
1160<         !precisol(ji,jv) = qsintveg(ji,jv ) - zqsintvegnew (ji,jv)
1161<         precisol(ji,jv) = (veget(ji,jv)*throughfall_by_pft(jv)*precip_rain(ji)) + qsintveg(ji,jv ) - zqsintvegnew (ji,jv)
1162---
1163>         !Ancienne formulation
1164>         precisol(ji,jv) = qsintveg(ji,jv ) - zqsintvegnew (ji,jv)
1165>         !Nouvelle formulation Nath
1166>         !precisol(ji,jv) = (veget(ji,jv)*throughfall_by_pft(jv)*precip_rain(ji)) + qsintveg(ji,jv ) - zqsintvegnew (ji,jv)
11671533a1570,1617
1168>   !! this routine computes the evolution of the surface reservoir (floodplain)
1169>   !!
1170>   SUBROUTINE hydrolc_flood (kjpindex, dtradia, vevapnu, vevapflo, flood_frac, flood_res, floodout)
1171>     ! input scalar
1172>     INTEGER(i_std), INTENT(in)                               :: kjpindex
1173>     ! input fields
1174>     REAL(r_std), INTENT (in)                                 :: dtradia          !! Time step in seconds
1175>     REAL(r_std), DIMENSION (kjpindex), INTENT(in)            :: flood_frac       !! Fraction of floodplains in grid box
1176>     ! modified fields
1177>     REAL(r_std), DIMENSION (kjpindex), INTENT(out)           :: floodout         !! Flux to take out from floodplains
1178>     REAL(r_std), DIMENSION (kjpindex), INTENT(inout)         :: flood_res        !! Floodplains reservoir estimate
1179>     REAL(r_std), DIMENSION (kjpindex), INTENT(inout)         :: vevapnu          !! Bare soil evaporation
1180>     REAL(r_std), DIMENSION (kjpindex), INTENT(inout)         :: vevapflo         !! Evaporation over floodplains
1181>     ! local declaration
1182>     INTEGER(i_std)                                          :: ji, jst, jv      !! indices
1183>     REAL(r_std)                                              :: k_m              !! conductivity in the soil
1184>     REAL(r_std)                                              :: temp              !!
1185>
1186>     !-
1187>     !- 1. Take out vevapflo from the reservoir and transfer the remaining to vevapnu
1188>     !-
1189>     DO ji = 1,kjpindex
1190>        temp = MIN(flood_res(ji), vevapflo(ji))
1191>        flood_res(ji) = flood_res(ji) - temp
1192>        vevapnu(ji) = vevapnu(ji) + vevapflo(ji) - temp
1193>        vevapflo(ji) = temp
1194>     ENDDO
1195>
1196>     !-
1197>     !- 2. Compute the total flux from floodplain floodout (transfered to routing)
1198>     !-
1199>     DO ji = 1,kjpindex
1200>        floodout(ji) = vevapflo(ji) - flood_frac(ji) * SUM(precisol(ji,:))
1201>     ENDDO
1202>
1203>     !-
1204>     !- 3. Discriminate between precip over land and over floodplain
1205>     !-
1206>     DO jv=1, nvm
1207>        DO ji = 1,kjpindex
1208>           precisol(ji,jv) = precisol(ji,jv) * (1 - flood_frac(ji))
1209>        ENDDO
1210>     ENDDO
1211>
1212>     IF (long_print) WRITE (numout,*) ' hydrolc_flood done'
1213>
1214>   END SUBROUTINE hydrolc_flood
1215>   !!
12161536,1537c1620,1622
1217<   SUBROUTINE hydrolc_soil(kjpindex, vevapnu, precisol, returnflow, irrigation, tot_melt, mx_eau_var, veget, ruu_ch, transpir,&
1218<        & gqsb, bqsb, dsg, dss, rsol, drysoil_frac, dsp, runoff, run_off_tot, drainage, humrel, vegstress, shumdiag, litterhumdiag)
1219---
1220>   SUBROUTINE hydrolc_soil(kjpindex, vevapnu, precisol, returnflow, reinfiltration, irrigation, tot_melt, mx_eau_var, &
1221>        & veget, frac_bare, ruu_ch, transpir,gqsb, bqsb, dsg, dss, rsol, drysoil_frac, dsp, runoff, run_off_tot, drainage, &
1222>        & humrel, vegstress, shumdiag, litterhumdiag)
12231545a1631
1224>     REAL(r_std), DIMENSION (kjpindex), INTENT(in)            :: reinfiltration       !! Water returning to the top reservoir
12251550a1637
1226>     REAL(r_std), DIMENSION (kjpindex,nvm), INTENT (in)       :: frac_bare        !! Bare soil fraction in each tile
12271586a1674
1228>     REAL(r_std), DIMENSION(kjpindex)               :: tot_frac_bare
12291610,1611c1698,1699
1230<
1231<     ! case 1 - there is vegetation and bare soil
1232---
1233>     tot_frac_bare(:) = zero
1234>     DO jv = 1, nvm
12351613,1615c1701,1702
1236<       IF ( (vegtot(ji) .GT. zero) .AND. (veget(ji,1) .GT. min_sechiba) ) THEN
1237<         zeflux(ji,1) = vevapnu(ji)/veget(ji,1)
1238<       ENDIF
1239---
1240>           tot_frac_bare(ji) = tot_frac_bare(ji) + veget(ji,jv) * frac_bare(ji,jv)
1241>        ENDDO
12421618,1619c1705
1243<     ! case 2 - there is vegetation but no bare soil
1244<     DO jv = 1, nvm
1245---
1246>     ! case 1 and 2 are treated in the same loop (vegetation with or without bare soil)
12471621,1623c1707,1712
1248<         IF ( (vegtot(ji) .GT. zero) .AND. (veget(ji,1) .LE. min_sechiba)&
1249<              & .AND. (veget(ji,jv) .GT. min_sechiba)) THEN
1250<           zeflux(ji,jv) =  zeflux(ji,jv) + vevapnu(ji)/vegtot(ji)
1251---
1252>       IF (vegtot(ji) .GT. zero) THEN
1253>          IF (tot_frac_bare(ji) .GT. min_sechiba)  THEN
1254>             zeflux(ji,:) = zeflux(ji,:) + vevapnu(ji) * frac_bare(ji,:) / tot_frac_bare(ji)
1255>          ELSE
1256>             zeflux(ji,:) = zeflux(ji,:) + vevapnu(ji)/vegtot(ji)
1257>          ENDIF
12581625d1713
1259<       ENDDO
12601645c1733
1261<         ! 1.2 Add snow and ice melt, troughfall from vegetation and irrigation.
1262---
1263>         ! 1.2 Add snow and ice melt, troughfall from vegetation, reinfiltration and irrigation.
12641648,1649c1736,1737
1265<            !  snow and ice melt and troughfall from vegetation
1266<            gqsb(ji,jv) = gqsb(ji,jv) + zpreci(ji,jv) + tot_melt(ji)/vegtot(ji)
1267---
1268>            !  snow and ice melt, reinfiltration and troughfall from vegetation
1269>            gqsb(ji,jv) = gqsb(ji,jv) + zpreci(ji,jv) + (tot_melt(ji)+reinfiltration(ji))/vegtot(ji)
12701941c2029
1271<         run_off_tot(ji) = tot_melt(ji) + irrigation(ji)
1272---
1273>         run_off_tot(ji) = tot_melt(ji) + irrigation(ji) + reinfiltration(ji)
12741946d2033
1275<     !
12762004,2006c2091,2094
1277<                !zhumrel_lo(ji) = EXP( - humcste(jv) * dpu_cste * (dsp(ji,jv)/dpu_cste) )
1278<                !zhumrel_up(ji) = EXP( - humcste(jv) * dpu_cste * (dss(ji,jv)/dsg(ji,jv)) )
1279<                !humrel(ji,jv) = MAX(zhumrel_lo(ji),zhumrel_up(ji))
1280---
1281>                !Ancienne formulation
1282>                zhumrel_lo(ji) = EXP( - humcste(jv) * dpu_cste * (dsp(ji,jv)/dpu_cste) )
1283>                zhumrel_up(ji) = EXP( - humcste(jv) * dpu_cste * (dss(ji,jv)/dsg(ji,jv)) )
1284>                humrel(ji,jv) = MAX(zhumrel_lo(ji),zhumrel_up(ji))
12852011,2012c2099,2101
1286<                zhumrel_lo(ji) = EXP( - humcste(jv) * dsp(ji,jv))
1287<                zhumrel_up(ji) = EXP( - humcste(jv) * dss(ji,jv))
1288---
1289>                !Nouvelle formulation Nathalie
1290>                !zhumrel_lo(ji) = EXP( - humcste(jv) * dsp(ji,jv))
1291>                !zhumrel_up(ji) = EXP( - humcste(jv) * dss(ji,jv))
12922014,2015c2103,2104
1293<                a_subgrd(ji,jv)=MIN(MAX(dsg(ji,jv)-dss(ji,jv),0.)/dsg_min,1.)
1294<                humrel(ji,jv)=a_subgrd(ji,jv)*zhumrel_up(ji)+(1.-a_subgrd(ji,jv))*zhumrel_lo(ji)
1295---
1296>                !a_subgrd(ji,jv)=MIN(MAX(dsg(ji,jv)-dss(ji,jv),0.)/dsg_min,1.)
1297>                !humrel(ji,jv)=a_subgrd(ji,jv)*zhumrel_up(ji)+(1.-a_subgrd(ji,jv))*zhumrel_lo(ji)
12982071,2072c2160,2163
1299<     !drysoil_frac(:) = MIN(MAX(dss(:,1),0.)*10._r_std, un)
1300<     drysoil_frac(:) = a_subgrd(:,1)*dss(:,1) + (1.-a_subgrd(:,1))*dsp(:,1)
1301---
1302>     !Ancienne formulation   
1303>     drysoil_frac(:) = MIN(MAX(dss(:,1),0.)*10._r_std, un)
1304>     !Nouvelle formulation Nathalie
1305>     !drysoil_frac(:) = a_subgrd(:,1)*dss(:,1) + (1.-a_subgrd(:,1))*dsp(:,1)
13062078c2169,2176
1307<        IF (veget(ji,1) .GE. min_sechiba) THEN
1308---
1309> !MG selon tristan le 10.01.08
1310> !       IF (veget(ji,1) .GE. min_sechiba) THEN
1311>        IF (tot_frac_bare(ji) .GE. min_sechiba) THEN
1312>           rsol(ji) = zero
1313>           DO jv = 1, nvm
1314>              rsol(ji) = rsol(ji) + dss(ji,jv) * rsol_cste * &
1315>                   & frac_bare(ji,jv) * veget(ji,jv) / tot_frac_bare(ji)
1316>           ENDDO
13172083,2084c2181,2184
1318<           !rsol(ji) = dss(ji,1) * rsol_cste
1319<           rsol(ji) =  ( drysoil_frac(ji) + 1./(10.*(dpu_cste - drysoil_frac(ji))+1.e-10)**2 ) * rsol_cste
1320---
1321>           !Ancien calcul de rsol         
1322>           rsol(ji) = dss(ji,1) * rsol_cste
1323>           !Nathalie calcul rsol
1324>           !rsol(ji) =  ( drysoil_frac(ji) + 1./(10.*(dpu_cste - drysoil_frac(ji))+1.e-10)**2 ) * rsol_cste
13252101,2102c2201,2202
1326<        & precip_rain, precip_snow, returnflow, irrigation, tot_melt, vevapwet, transpir, vevapnu, vevapsno, run_off_tot, &
1327<        & drainage)
1328---
1329>        & precip_rain, precip_snow, returnflow, reinfiltration, irrigation, tot_melt, vevapwet, transpir, vevapnu, &
1330>        & vevapsno, vevapflo, floodout, run_off_tot, drainage)
13312119a2220
1332>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: reinfiltration   !! Water returning from routing to the top reservoir
13332125a2227
1334>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: vevapflo     !! Open water evaporation
13352126a2229
1336>     REAL(r_std),DIMENSION (kjpindex), INTENT (in)      :: floodout     !! Outflow from floodplains
13372134c2237
1338<     REAL(r_std),DIMENSION (kjpindex) :: watveg, delta_water, tot_flux, sum_snow_nobio, sum_vevapwet, sum_transpir
1339---
1340>     REAL(r_std),DIMENSION (kjpindex) :: watveg, delta_water, sum_snow_nobio, sum_vevapwet, sum_transpir
13412156a2260
1342>        tot_flux(:) = zero
13432164a2269
1344>     tot_flux(:) = zero
13452206,2208c2311,2313
1346<        tot_flux(ji) =  precip_rain(ji) + precip_snow(ji) + returnflow(ji) + irrigation(ji) - &
1347<              & sum_vevapwet(ji) - sum_transpir(ji) - vevapnu(ji) - vevapsno(ji) - &
1348<              & run_off_tot(ji) - drainage(ji)
1349---
1350>        tot_flux(ji) =  precip_rain(ji) + precip_snow(ji) + returnflow(ji) + reinfiltration(ji) + irrigation(ji) - &
1351>              & sum_vevapwet(ji) - sum_transpir(ji) - vevapnu(ji) - vevapsno(ji) - vevapflo(ji) + &
1352>              & floodout(ji) - run_off_tot(ji) - drainage(ji)
13532214a2320
1354>
13552220,2222c2326,2329
1356<           WRITE(numout,*) 'The error in mm/d is :', (delta_water-tot_flux)/dtradia, ' and in mm/dt : ', delta_water-tot_flux
1357<           WRITE(numout,*) 'delta_water : ', delta_water, ' tot_flux : ', tot_flux
1358<           WRITE(numout,*) 'Actual and allowed error : ', ABS(delta_water-tot_flux), allowed_err
1359---
1360>           WRITE(numout,*) 'The error in mm/d is :', (delta_water(ji)-tot_flux(ji))/(dtradia/one_day), &
1361>                & ' and in mm/dt : ', delta_water(ji)-tot_flux(ji)
1362>           WRITE(numout,*) 'delta_water : ', delta_water(ji), ' tot_flux : ', tot_flux(ji)
1363>           WRITE(numout,*) 'Actual and allowed error : ', ABS(delta_water(ji)-tot_flux(ji)), allowed_err
13642226c2333
1365<           WRITE(numout,*) 'Water from irrigation : ', returnflow(ji), irrigation(ji)
1366---
1367>           WRITE(numout,*) 'Water from irrigation : ', reinfiltration(ji), returnflow(ji), irrigation(ji)
13682234,2235c2341,2344
1369<           WRITE(numout,*) 'evapnu, evapsno : ', vevapnu(ji), vevapsno(ji)
1370<
1371---
1372>           WRITE(numout,*) 'sum_evapwet : ', sum_vevapwet(ji)
1373>           WRITE(numout,*) 'sum_transpir : ', sum_transpir(ji)
1374>           WRITE(numout,*) 'evapnu, evapsno, evapflo : ', vevapnu(ji), vevapsno(ji), vevapflo(ji)
1375>           WRITE(numout,*) 'floodout : ', floodout(ji)
13762237c2346,2347
1377<           STOP 'in hydrolc_waterbal'
1378---
1379>           waterbal_error=.TRUE.
1380> !          STOP 'in hydrolc_waterbal'
1381_______________________________________________________________________________________________________________________
1382diff -w --ignore-all-space --ignore-case --recursive --exclude='cvs_diff*' --exclude='*.flc' --exclude='*.bak' --exclude='*.svn*' --exclude='*.lst' --exclude='i.*.L' --exclude='*~' --exclude=Entries --exclude=Tag --exclude=CVS --exclude Makefile /login/IPSL_CODE/WORK_HYDRO/ORCHIDEE_1_9/modeles/ORCHIDEE/src_sechiba/sechiba.f90 /login/IPSL_UTILISATEURS/MATTHIEU/VERSION_Jan_NEW/modeles/ORCHIDEE/src_sechiba/sechiba.f90
138344c44
1384<   INTEGER(i_std), ALLOCATABLE, SAVE, DIMENSION (:) :: indexnobio     !! indexing array for the 3D fields of other surfaces (ice, lakes, ...)
1385---
1386>   INTEGER(i_std), ALLOCATABLE, SAVE, DIMENSION (:) :: indexnobio !! indexing array for the 3D fields of other surf(ice,lakes ...)
138759c59,60
1388<   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: lai            !! Surface foliere
1389---
1390>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: frac_bare      !! Bare soil fraction for each tile
1391>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: lai            !! Surface foliaire
139263c64
1393<   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: soiltype       !! Map of soil types, created in slowproc in the
1394---
1395>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: soiltile       !! Map of soil types, created in slowproc in the
139669a71
1397>   INTEGER(i_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: njsc         !! Soilclass index
139872,73c74,76
1399<   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: soilcap        !! Soil calorific capacity
1400<   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: soilflx        !! Soil flux
1401---
1402>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: vbeta5         !! Floodplains resistance
1403>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: soilcap        !!
1404>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: soilflx        !!
140575a79,80
1406>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: flood_res      !! flood reservoir estimate
1407>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: flood_frac     !! flooded fraction
140882a88
1409>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: vevapflo       !! Floodplains evaporation
141092c98
1411<   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: co2_flux       !! CO2 flux (gC/m**2 of average ground/s)
1412---
1413>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: co2_flux       !! CO2 flux (gC/m**2 of average ground/s)
141493a100
1415>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: floodout       !! Flow out of floodplains from hydrol
141696a104
1417>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: reinfiltration !! Routed water which returns into the soil
1418100a109
1419>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)    :: reinf_slope    !! slope coefficient (reinfiltration)
1420107a117
1421>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:)      :: k_litt       !! litter cond.
1422116a127
1423>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: vbeta3pot      !! Potential vegetation resistance
1424120a132
1425>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: transpot       !! Potential Transpiration (needed for irrigation)
1426122a135
1427>   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)  :: rstruct        !! Vegetation structural resistance
1428179,181c192
1429< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
1430< !     & zlev, u, v, qair, temp_air, epot_air, ccanopy, &
1431<     & zlev, u, v, qair, q2m, t2m, temp_air, epot_air, ccanopy, &
1432---
1433>        & zlev, u, v, qair, temp_air, epot_air, ccanopy, &
1434220,222c231
1435< ! Ajout Nathalie - Juin 2006 - Q2M/t2m pour calcul Rveget
1436<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: q2m              !! 2m specific humidity
1437<     REAL(r_std),DIMENSION (kjpindex), INTENT (in)            :: t2m              !! 2m air temperature
1438---
1439>     !
1440250c259,260
1441<     INTEGER(i_std) :: i, iloc
1442---
1443>     REAL(r_std),DIMENSION (kjpindex)                         :: var_write        !! Variable to write
1444>     INTEGER(i_std) :: i, iloc, jv, ll(1)
1445263d272
1446<
1447266c275
1448<             index, indexveg, lalo, neighbours, resolution, contfrac, soiltype, &
1449---
1450>             index, indexveg, lalo, neighbours, resolution, contfrac, soiltile, reinf_slope, &
1451271c280
1452<             lai, height, veget, frac_nobio, veget_max, totfrac_nobio, qsintmax, &
1453---
1454>             lai, frac_bare, height, veget, frac_nobio, njsc, veget_max, totfrac_nobio, qsintmax, &
1455279,284c288,292
1456< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
1457< !           & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, pb ,  &
1458<             & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, q2m, t2m, pb ,  &
1459<             & rsol, evap_bare_lim, evapot, snow, frac_nobio, snow_nobio, totfrac_nobio, &
1460<             & swnet, swdown, ccanopy, humrel, veget, veget_max, lai, qsintveg, qsintmax, assim_param, &
1461<             & vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, rveget, cimean, rest_id, hist_id, hist2_id)
1462---
1463>             & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, pb ,  &
1464>             & rsol, evap_bare_lim, evapot, evapot_corr, snow, flood_frac, flood_res, frac_nobio, snow_nobio, totfrac_nobio, &
1465>             & swnet, swdown, ccanopy, humrel, frac_bare, veget, lai, qsintveg, qsintmax, assim_param, &
1466>             & vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, vbetaco2, rveget, rstruct, cimean, &
1467>             & rest_id, hist_id, hist2_id)
1468289,292c297,300
1469<             & index, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef,&
1470<             & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, &
1471<             & cimean, ccanopy, emis, soilflx, soilcap, tq_cdrag, humrel, fluxsens, fluxlat, &
1472<             & vevapp, transpir, gpp, vevapnu, vevapwet, vevapsno, t2mdiag, temp_sol, tsol_rad, &
1473---
1474>             & index, indexveg, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef,&
1475>             & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, &
1476>             & vbetaco2, cimean, ccanopy, emis, soilflx, soilcap, tq_cdrag, humrel, fluxsens, fluxlat, &
1477>             & vevapp, transpir, transpot, gpp, vevapnu, vevapwet, vevapsno, vevapflo, t2mdiag, temp_sol, tsol_rad, &
1478295c303
1479<        ! computes initialisation of hydrologie
1480---
1481>        ! computes initialisation of hydrology
1482298,302c306,311
1483<           CALL hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, &
1484<                & temp_sol_new, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1485<                & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age,&
1486<                & tot_melt, transpir, precip_rain, precip_snow, returnflow, irrigation, humrel, &
1487<                & vegstress, rsol, drysoil_frac, evapot, evapot_corr, shumdiag, litterhumdiag, soilcap, rest_id, hist_id, hist2_id)
1488---
1489>           CALL hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, control_in, &
1490>                & temp_sol_new, floodout, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare,&
1491>                & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age,&
1492>                & tot_melt, transpir, precip_rain, precip_snow, returnflow, reinfiltration, irrigation, humrel, &
1493>                & vegstress, rsol, drysoil_frac, evapot, evapot_corr, flood_frac, flood_res, shumdiag, litterhumdiag, &
1494>                & soilcap, rest_id, hist_id, hist2_id)
1495303a313
1496>           k_litt(:) = huit
1497305,310c315,322
1498<           CALL hydrol_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, indexsoil, indexlayer, &
1499<                & temp_sol_new, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1500<                & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age,&
1501<                & tot_melt, transpir, precip_rain, precip_snow, returnflow, irrigation, humrel, &
1502<                & vegstress, drysoil_frac, evapot, evapot_corr, evap_bare_lim, &
1503<                & shumdiag, litterhumdiag, soilcap, soiltype, rest_id, hist_id, hist2_id)
1504---
1505>           CALL hydrol_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, &
1506>                & index, indexveg, indexsoil, indexlayer, control_in, &
1507>                & temp_sol_new, floodout, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare, njsc,&
1508>                & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age,&
1509>                & tot_melt, transpir, precip_rain, precip_snow, returnflow, reinfiltration, irrigation, humrel, &
1510>                & vegstress, drysoil_frac, evapot, evapot_corr, evap_bare_lim, flood_frac, flood_res, &
1511>                & shumdiag, k_litt, litterhumdiag, soilcap, soiltile, reinf_slope, rest_id, hist_id, hist2_id)
1512>           rsol(:) = -un
1513316,318c328,330
1514<             & lalo, neighbours, resolution, contfrac, veget, veget_max, frac_nobio, totfrac_nobio, &
1515<             & zlev, snow, snow_age, snow_nobio, snow_nobio_age, &
1516<             & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, soiltype, rest_id, hist_id, hist2_id)
1517---
1518>             & lalo, neighbours, resolution, contfrac, veget, frac_nobio, totfrac_nobio, &
1519>             & zlev, snow, snow_age, snow_nobio, snow_nobio_age, frac_bare, &
1520>             & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, rest_id, hist_id, hist2_id)
1521331,334c343,346
1522<           CALL routing_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, &
1523<                & lalo, neighbours, resolution, contfrac, totfrac_nobio, veget_max, runoff, &
1524<                & drainage, evapot_corr, precip_rain, humrel, &
1525<                & stempdiag, returnflow, irrigation, riverflow, coastalflow, rest_id, hist_id, hist2_id)
1526---
1527>           CALL routing_main (kjit, kjpindex, dtradia, control_in, ldrestart_read, ldrestart_write, index, &
1528>                & lalo, neighbours, resolution, contfrac, totfrac_nobio, veget, floodout, runoff, &
1529>                & drainage, transpot, precip_rain, humrel, k_litt, flood_frac, flood_res, &
1530>                & stempdiag, reinf_slope, returnflow, reinfiltration, irrigation, riverflow, coastalflow, rest_id, hist_id, hist2_id)
1531338a351
1532>           reinfiltration(:) = zero
1533339a353,354
1534>           flood_frac(:) = zero
1535>           flood_res(:) = zero
1536367c382
1537<          index, indexveg, lalo, neighbours, resolution, contfrac, soiltype, &
1538---
1539>          index, indexveg, lalo, neighbours, resolution, contfrac, soiltile, reinf_slope, &
1540372c387
1541<          lai, height, veget, frac_nobio, veget_max, totfrac_nobio, qsintmax, &
1542---
1543>          lai, frac_bare, height, veget, frac_nobio, njsc, veget_max, totfrac_nobio, qsintmax, &
1544379,384c394,398
1545< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
1546< !        & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, pb ,  &
1547<          & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, q2m, t2m, pb ,  &
1548<          & rsol, evap_bare_lim, evapot, snow, frac_nobio, snow_nobio, totfrac_nobio, &
1549<          & swnet, swdown, ccanopy, humrel, veget, veget_max, lai, qsintveg, qsintmax, assim_param, &
1550<          & vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, rveget, cimean, rest_id, hist_id, hist2_id)
1551---
1552>          & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, pb ,  &
1553>          & rsol, evap_bare_lim, evapot, evapot_corr, snow, flood_frac, flood_res, frac_nobio, snow_nobio, totfrac_nobio, &
1554>          & swnet, swdown, ccanopy, humrel, frac_bare, veget, lai, qsintveg, qsintmax, assim_param, &
1555>          & vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, vbetaco2, rveget, rstruct, cimean, &
1556>          & rest_id, hist_id, hist2_id)
1557391,394c405,408
1558<          & index, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef, &
1559<          & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, &
1560<          & cimean, ccanopy, emis, soilflx, soilcap, tq_cdrag, humrel, fluxsens, fluxlat, &
1561<          & vevapp, transpir, gpp, vevapnu, vevapwet, vevapsno, t2mdiag, temp_sol, tsol_rad, &
1562---
1563>          & index, indexveg, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef,&
1564>          & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, &
1565>          & vbetaco2, cimean, ccanopy, emis, soilflx, soilcap, tq_cdrag, humrel, fluxsens, fluxlat, &
1566>          & vevapp, transpir, transpot, gpp, vevapnu, vevapwet, vevapsno, vevapflo, t2mdiag, temp_sol, tsol_rad, &
1567400,404c414,419
1568<        CALL hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, myfalse, index, indexveg, &
1569<             & temp_sol_new, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1570<             & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age,&
1571<             & tot_melt, transpir, precip_rain, precip_snow, returnflow, irrigation, humrel, &
1572<             & vegstress, rsol, drysoil_frac, evapot, evapot_corr, shumdiag, litterhumdiag, soilcap, rest_id, hist_id, hist2_id)
1573---
1574>        CALL hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, myfalse, index, indexveg, control_in, &
1575>             & temp_sol_new, floodout, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare, &
1576>             & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age,&
1577>             & tot_melt, transpir, precip_rain, precip_snow, returnflow, reinfiltration, irrigation, humrel, &
1578>             & vegstress, rsol, drysoil_frac, evapot, evapot_corr, flood_frac, flood_res, shumdiag, litterhumdiag, &
1579>             & soilcap, rest_id, hist_id, hist2_id)
1580405a421
1581>        k_litt(:) = huit
1582407,412c423,430
1583<        CALL hydrol_main (kjit, kjpindex, dtradia, ldrestart_read, myfalse, index, indexveg, indexsoil, indexlayer, &
1584<             & temp_sol_new, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1585<             & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age,&
1586<             & tot_melt, transpir, precip_rain, precip_snow, returnflow, irrigation, humrel, &
1587<             & vegstress, drysoil_frac, evapot, evapot_corr, evap_bare_lim, &
1588<             & shumdiag, litterhumdiag, soilcap, soiltype, rest_id, hist_id, hist2_id)
1589---
1590>        CALL hydrol_main (kjit, kjpindex, dtradia, ldrestart_read, myfalse, &
1591>             & index, indexveg, indexsoil, indexlayer, control_in, &
1592>             & temp_sol_new, floodout, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare, njsc,&
1593>             & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age,&
1594>             & tot_melt, transpir, precip_rain, precip_snow, returnflow, reinfiltration, irrigation, humrel, &
1595>             & vegstress, drysoil_frac, evapot, evapot_corr, evap_bare_lim, flood_frac, flood_res, &
1596>             & shumdiag, k_litt, litterhumdiag, soilcap, soiltile, reinf_slope, rest_id, hist_id, hist2_id)
1597>        rsol(:) = -un
1598423,425c441,443
1599<          & lalo, neighbours, resolution, contfrac, veget, veget_max, frac_nobio, totfrac_nobio, &
1600<          & zlev, snow, snow_age, snow_nobio, snow_nobio_age, &
1601<          & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, soiltype, rest_id, hist_id, hist2_id)
1602---
1603>          & lalo, neighbours, resolution, contfrac, veget, frac_nobio, totfrac_nobio, &
1604>          & zlev, snow, snow_age, snow_nobio, snow_nobio_age, frac_bare, &
1605>          & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, rest_id, hist_id, hist2_id)
1606431a450
1607>
1608438,442c457,460
1609<        CALL routing_main (kjit, kjpindex, dtradia, ldrestart_read, myfalse, index, &
1610<             & lalo, neighbours, resolution, contfrac, totfrac_nobio, veget_max, runoff, &
1611<             & drainage, evapot_corr, precip_rain, humrel, &
1612<             & stempdiag, returnflow, irrigation, riverflow, coastalflow, rest_id, hist_id, hist2_id)
1613<        !       returnflow(:) = returnflow(:) * 100.
1614---
1615>        CALL routing_main (kjit, kjpindex, dtradia, control_in, ldrestart_read, myfalse, index, &
1616>             & lalo, neighbours, resolution, contfrac, totfrac_nobio, veget, floodout, runoff, &
1617>             & drainage, transpot, precip_rain, humrel, k_litt, flood_frac, flood_res, &
1618>             & stempdiag, reinf_slope, returnflow, reinfiltration, irrigation, riverflow, coastalflow, rest_id, hist_id, hist2_id)
1619446a465
1620>        reinfiltration(:) = zero
1621447a467,468
1622>        flood_frac(:) = zero
1623>        flood_res(:) = zero
1624470d490
1625<        CALL histwrite(hist_id, 'maxvegetfrac', kjit, veget_max, kjpindex*nvm, indexveg)
1626480a501
1627>        CALL histwrite(hist_id, 'vbeta5', kjit, vbeta5, kjpindex, index)   
1628482a504
1629>        CALL histwrite(hist_id, 'rstruct', kjit, rstruct, kjpindex*nvm, indexveg)
1630488c510,520
1631<        CALL histwrite(hist_id, 'soiltype',  kjit, soiltype, kjpindex*nstm, indexsoil)
1632---
1633>        CALL histwrite(hist_id, 'frac_bare', kjit, frac_bare, kjpindex*nvm, indexveg)
1634>        !
1635>        IF ( control_in%hydrol_cwrr ) THEN
1636>           CALL histwrite(hist_id, 'soiltile',  kjit, soiltile, kjpindex*nstm, indexsoil)
1637>           CALL histwrite(hist_id, 'soilindex',  kjit, REAL(njsc, r_std), kjpindex, index)
1638>           CALL histwrite(hist_id, 'reinf_slope',  kjit, reinf_slope, kjpindex, index)
1639>        ENDIF
1640>        IF ( control_in%do_floodplains ) THEN
1641>           CALL histwrite(hist_id, 'evapflo', kjit, vevapflo, kjpindex, index)
1642>           CALL histwrite(hist_id, 'flood_frac', kjit, flood_frac, kjpindex, index)
1643>        ENDIF
1644496d527
1645<        CALL histwrite(hist_id, 'maxvegetfrac', kjit, veget_max, kjpindex*nvm, indexveg)
1646499d529
1647<        CALL histwrite(hist_id, 'SWE', kjit, snow, kjpindex, index)
1648501,502c531,542
1649<        CALL histwrite(hist_id, 'TVeg', kjit, transpir, kjpindex*nvm, indexveg)
1650<        CALL histwrite(hist_id, 'ECanop', kjit, vevapwet, kjpindex*nvm, indexveg)
1651---
1652>        CALL histwrite(hist_id, 'EWater', kjit, vevapflo, kjpindex, index)
1653>        CALL histwrite(hist_id, 'SWE', kjit, snow, kjpindex, index)
1654>        var_write(:)=zero
1655>        DO jv=1,nvm
1656>           var_write(:) = var_write(:) + transpir(:,jv)
1657>        ENDDO
1658>        CALL histwrite(hist_id, 'TVeg', kjit, var_write, kjpindex, index)
1659>        var_write(:)=zero
1660>        DO jv=1,nvm
1661>           var_write(:) = var_write(:) + vevapwet(:,jv)
1662>        ENDDO
1663>        CALL histwrite(hist_id, 'ECanop', kjit, var_write, kjpindex, index)
1664504a545,553
1665>        !
1666>        CALL histwrite(hist_id, 'Z0', kjit, z0, kjpindex, index)
1667>        CALL histwrite(hist_id, 'EffectHeight', kjit, roughheight, kjpindex, index)
1668>        !
1669>        IF ( control_in%do_floodplains ) THEN
1670>           CALL histwrite(hist_id, 'Qflood', kjit, vevapflo, kjpindex, index)
1671>           CALL histwrite(hist_id, 'FloodFrac', kjit, flood_frac, kjpindex, index)
1672>        ENDIF
1673>        !
1674507a557
1675>        !
1676521d570
1677<           CALL histwrite(hist2_id, 'maxvegetfrac', kjit, veget_max, kjpindex*nvm, indexveg)
1678524a574
1679>           CALL histwrite(hist2_id, 'vevapflo', kjit, vevapflo, kjpindex, index)
1680531a582
1681>           CALL histwrite(hist2_id, 'vbeta5', kjit, vbeta5, kjpindex, index)   
1682533a585
1683>           CALL histwrite(hist2_id, 'rstruct', kjit, rstruct, kjpindex*nvm, indexveg)
1684539c591,597
1685<           CALL histwrite(hist2_id, 'soiltype',  kjit, soiltype, kjpindex*nstm, indexsoil)
1686---
1687>           !
1688>           IF (  control_in%hydrol_cwrr ) THEN
1689>              CALL histwrite(hist2_id, 'soiltile',  kjit, soiltile, kjpindex*nstm, indexsoil)
1690>              CALL histwrite(hist2_id, 'soilindex',  kjit, REAL(njsc, r_std), kjpindex, index)
1691>              CALL histwrite(hist2_id, 'reinf_slope',  kjit, reinf_slope, kjpindex, index)
1692>           ENDIF
1693>           !
1694547d604
1695<           CALL histwrite(hist2_id, 'maxvegetfrac', kjit, veget_max, kjpindex*nvm, indexveg)
1696550d606
1697<           CALL histwrite(hist2_id, 'SWE', kjit, snow, kjpindex, index)
1698552,553c608,619
1699<           CALL histwrite(hist2_id, 'TVeg', kjit, transpir, kjpindex*nvm, indexveg)
1700<           CALL histwrite(hist2_id, 'ECanop', kjit, vevapwet, kjpindex*nvm, indexveg)
1701---
1702>           CALL histwrite(hist2_id, 'EWater', kjit, vevapflo, kjpindex, index)
1703>           CALL histwrite(hist2_id, 'SWE', kjit, snow, kjpindex, index)
1704>           var_write(:)=zero
1705>           DO jv=1,nvm
1706>              var_write(:) = var_write(:) + transpir(:,jv)
1707>           ENDDO
1708>           CALL histwrite(hist2_id, 'TVeg', kjit, var_write, kjpindex, index)
1709>           var_write(:)=zero
1710>           DO jv=1,nvm
1711>              var_write(:) = var_write(:) + vevapwet(:,jv)
1712>           ENDDO
1713>           CALL histwrite(hist2_id, 'ECanop', kjit, vevapwet, kjpindex, index)
1714574c640
1715<             index, indexveg, lalo, neighbours, resolution, contfrac, soiltype, &
1716---
1717>             index, indexveg, lalo, neighbours, resolution, contfrac, soiltile, reinf_slope, &
1718579c645
1719<             lai, height, veget, frac_nobio, veget_max, totfrac_nobio, qsintmax, &
1720---
1721>             lai, frac_bare, height, veget, frac_nobio, njsc, veget_max, totfrac_nobio, qsintmax, &
1722588,594c654,658
1723< ! Ajout Nathalie - Juin 2006 - passage q2m/t2m pour calcul Rveget
1724< !           & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, pb ,  &
1725<             & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, q2m, t2m, pb ,  &
1726<             & rsol, evap_bare_lim, evapot, snow, frac_nobio, snow_nobio, totfrac_nobio, &
1727<             & swnet, swdown, ccanopy, humrel, veget, veget_max, lai, qsintveg, qsintmax, assim_param, &
1728<             & vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, rveget, cimean, rest_id, hist_id, hist2_id)
1729<
1730---
1731>             & zlev, z0, roughheight, temp_sol, temp_air, rau, tq_cdrag, qsurf, qair, pb ,  &
1732>             & rsol, evap_bare_lim, evapot, evapot_corr, snow, flood_frac, flood_res, frac_nobio, snow_nobio, totfrac_nobio, &
1733>             & swnet, swdown, ccanopy, humrel, frac_bare, veget, lai, qsintveg, qsintmax, assim_param, &
1734>             & vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, vbetaco2, rveget, rstruct, cimean, &
1735>             & rest_id, hist_id, hist2_id)
1736599,602c663,666
1737<             & index, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef,&
1738<             & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta4, vbetaco2, &
1739<             & cimean, ccanopy, emis, soilflx, soilcap, tq_cdrag, humrel, fluxsens, fluxlat, &
1740<             & vevapp, transpir, gpp, vevapnu, vevapwet, vevapsno, t2mdiag, temp_sol, tsol_rad, &
1741---
1742>             & index, indexveg, zlev, lwdown, swnet, epot_air, temp_air, u, v, petAcoef, petBcoef,&
1743>             & qair, peqAcoef, peqBcoef, pb, rau, vbeta, valpha, vbeta1, vbeta2, vbeta3, vbeta3pot, vbeta4, vbeta5, &
1744>             & vbetaco2, cimean, ccanopy, emis, soilflx, soilcap, tq_cdrag, humrel, fluxsens, fluxlat, &
1745>             & vevapp, transpir, transpot, gpp, vevapnu, vevapwet, vevapsno, vevapflo, t2mdiag, temp_sol, tsol_rad, &
1746604d667
1747<
1748609,614c672,677
1749<           CALL hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, &
1750<                & temp_sol_new, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1751<                & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age,&
1752<                & tot_melt, transpir, precip_rain, precip_snow, returnflow, irrigation, &
1753<                & humrel, vegstress, rsol, drysoil_frac, evapot, evapot_corr, shumdiag, litterhumdiag, soilcap, &
1754<                & rest_id, hist_id, hist2_id)
1755---
1756>           CALL hydrolc_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, control_in, &
1757>                & temp_sol_new, floodout, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare,&
1758>                & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age,&
1759>                & tot_melt, transpir, precip_rain, precip_snow, returnflow, reinfiltration, irrigation, humrel, &
1760>                & vegstress, rsol, drysoil_frac, evapot, evapot_corr, flood_frac, flood_res, shumdiag, litterhumdiag, &
1761>                & soilcap, rest_id, hist_id, hist2_id)
1762615a679
1763>           k_litt(:) = huit
1764617,622c681,687
1765<           CALL hydrol_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, indexveg, indexsoil, indexlayer, &
1766<                & temp_sol_new, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, veget_max,&
1767<                & qsintmax, qsintveg, vevapnu, vevapsno, snow, snow_age, snow_nobio, snow_nobio_age,&
1768<                & tot_melt, transpir, precip_rain, precip_snow, returnflow, irrigation, humrel, &
1769<                & vegstress, drysoil_frac, evapot, evapot_corr, evap_bare_lim, &
1770<                & shumdiag, litterhumdiag, soilcap, soiltype, rest_id, hist_id, hist2_id)
1771---
1772>           CALL hydrol_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, &
1773>                & index, indexveg, indexsoil, indexlayer, control_in, &
1774>                & temp_sol_new, floodout, runoff, drainage, frac_nobio, totfrac_nobio, vevapwet, veget, frac_bare, njsc, &
1775>                & qsintmax, qsintveg, vevapnu, vevapsno, vevapflo, snow, snow_age, snow_nobio, snow_nobio_age,&
1776>                & tot_melt, transpir, precip_rain, precip_snow, returnflow, reinfiltration, irrigation, humrel, &
1777>                & vegstress, drysoil_frac, evapot, evapot_corr, evap_bare_lim, flood_frac, flood_res, &
1778>                & shumdiag, k_litt, litterhumdiag, soilcap, soiltile, reinf_slope, rest_id, hist_id, hist2_id)
1779629,631c694,696
1780<             & lalo, neighbours, resolution, contfrac, veget, veget_max, frac_nobio, totfrac_nobio, &
1781<             & zlev, snow, snow_age, snow_nobio, snow_nobio_age, &
1782<             & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, soiltype, rest_id, hist_id, hist2_id)
1783---
1784>             & lalo, neighbours, resolution, contfrac, veget, frac_nobio, totfrac_nobio, &
1785>             & zlev, snow, snow_age, snow_nobio, snow_nobio_age, frac_bare, &
1786>             & drysoil_frac, height, deadleaf_cover, emis, albedo, z0, roughheight, rest_id, hist_id, hist2_id)
1787645,648c710,713
1788<           CALL routing_main (kjit, kjpindex, dtradia, ldrestart_read, ldrestart_write, index, &
1789<                & lalo, neighbours, resolution, contfrac, totfrac_nobio, veget_max, runoff, &
1790<                & drainage, evapot_corr, precip_rain, humrel, &
1791<                & stempdiag, returnflow, irrigation, riverflow, coastalflow, rest_id, hist_id, hist2_id)
1792---
1793>           CALL routing_main (kjit, kjpindex, dtradia, control_in, ldrestart_read, ldrestart_write, index, &
1794>                & lalo, neighbours, resolution, contfrac, totfrac_nobio, veget, floodout, runoff, &
1795>                & drainage, transpot, precip_rain, humrel, k_litt, flood_frac, flood_res, &
1796>                & stempdiag, reinf_slope, returnflow, reinfiltration, irrigation, riverflow, coastalflow, rest_id, hist_id, hist2_id)
1797651a717
1798>           reinfiltration(:) = zero
1799653a720,721
1800>           flood_frac(:) = zero
1801>           flood_res(:) = zero
1802737a806,821
1803>     ALLOCATE (flood_res(kjpindex),stat=ier)
1804>     IF (ier.NE.0) THEN
1805>        WRITE (numout,*) ' error in flood_res allocation. We stop. We need kjpindex words = ',kjpindex
1806>        STOP 'sechiba_init'
1807>     END IF
1808>     flood_res(:) = undef_sechiba
1809>
1810>     IF (long_print) WRITE (numout,*) 'Allocation of 1D variables. We need for each kjpindex words = ',kjpindex
1811>     ALLOCATE (flood_frac(kjpindex),stat=ier)
1812>     IF (ier.NE.0) THEN
1813>        WRITE (numout,*) ' error in flood_frac allocation. We stop. We need kjpindex words = ',kjpindex
1814>        STOP 'sechiba_init'
1815>     END IF
1816>     flood_frac(:) = undef_sechiba
1817>
1818>     IF (long_print) WRITE (numout,*) 'Allocation of 1D variables. We need for each kjpindex words = ',kjpindex
1819797c881
1820<     ALLOCATE (soiltype(kjpindex,nstm),stat=ier)
1821---
1822>     ALLOCATE (njsc(kjpindex),stat=ier)
1823799c883
1824<        WRITE (numout,*) ' error in soiltype allocation. We stop. we need kjpindex words = ',kjpindex
1825---
1826>        WRITE (numout,*) ' error in njsc allocation. We stop. we need kjpindex words = ',kjpindex
1827802c886,900
1828<     soiltype(:,:)=undef_sechiba
1829---
1830>     njsc(:)= undef_int
1831>
1832>     ALLOCATE (soiltile(kjpindex,nstm),stat=ier)
1833>     IF (ier.NE.0) THEN
1834>        WRITE (numout,*) ' error in soiltile allocation. We stop. we need kjpindex words = ',kjpindex
1835>        STOP 'sechiba_init'
1836>     END IF
1837>     soiltile(:,:)=undef_sechiba
1838>
1839>     ALLOCATE (reinf_slope(kjpindex),stat=ier)
1840>     IF (ier.NE.0) THEN
1841>        WRITE (numout,*) ' error in reinf_slope allocation. We stop. we need kjpindex words = ',kjpindex
1842>        STOP 'sechiba_init'
1843>     END IF
1844>     reinf_slope(:)=undef_sechiba
1845815a914,919
1846>     ALLOCATE (vbeta5(kjpindex),stat=ier)
1847>     IF (ier.NE.0) THEN
1848>        WRITE (numout,*) ' error in vbeta5 allocation. We stop. We need kjpindex words = ',kjpindex
1849>        STOP 'sechiba_init'
1850>     END IF
1851>
1852865a970,976
1853>     ALLOCATE (vbeta3pot(kjpindex,nvm),stat=ier)
1854>     IF (ier.NE.0) THEN
1855>        WRITE (numout,*) ' error in vbeta3pot allocation. We stop.We need kjpindex x nvm words = ',&
1856>             & kjpindex,' x ' ,nvm, ' = ',kjpindex*nvm
1857>        STOP 'sechiba_init'
1858>     END IF
1859>
1860911a1023,1030
1861>     ALLOCATE (frac_bare(kjpindex,nvm),stat=ier)
1862>     IF (ier.NE.0) THEN
1863>        WRITE (numout,*) ' error in frac_bare allocation. We stop. We need kjpindex x nvm words = ',&
1864>             & kjpindex,' x ' ,nvm, ' = ',kjpindex*nvm
1865>        STOP 'sechiba_init'
1866>     END IF
1867>     frac_bare(:,:)=undef_sechiba
1868>
1869955a1075,1080
1870>     ALLOCATE (vevapflo(kjpindex),stat=ier)
1871>     IF (ier.NE.0) THEN
1872>        WRITE (numout,*) ' error in vevapflo allocation. We stop. We need kjpindex words = ',kjpindex
1873>        STOP 'sechiba_init'
1874>     END IF
1875>
1876979a1105,1110
1877>     ALLOCATE (floodout(kjpindex),stat=ier)
1878>     IF (ier.NE.0) THEN
1879>        WRITE (numout,*) ' error in floodout allocation. We stop. We need kjpindex words = ',kjpindex
1880>        STOP 'sechiba_init'
1881>     END IF
1882>
1883998a1130,1136
1884>     ALLOCATE (reinfiltration(kjpindex),stat=ier)
1885>     IF (ier.NE.0) THEN
1886>        WRITE (numout,*) ' error in reinfiltration allocation. We stop. We need kjpindex words = ',kjpindex
1887>        STOP 'sechiba_init'
1888>     END IF
1889>     reinfiltration(:) = zero
1890>
18911067c1205
1892<     ALLOCATE (co2_flux(kjpindex),stat=ier)
1893---
1894>     ALLOCATE (co2_flux(kjpindex, nvm),stat=ier)
18951085a1224,1229
1896>     ALLOCATE (k_litt(kjpindex),stat=ier)
1897>     IF (ier.NE.0) THEN
1898>        WRITE (numout,*) ' error in k_litt allocation. We stop. We need kjpindex words = ',kjpindex
1899>        STOP 'sechiba_init'
1900>     END IF
1901>
19021093a1238
1903>     vevapwet(:,:)=undef_sechiba
19041101a1247,1253
1905>     ALLOCATE (transpot(kjpindex,nvm),stat=ier)
1906>     IF (ier.NE.0) THEN
1907>        WRITE (numout,*) ' error in transpot allocation. We stop. We need kjpindex x nvm words = ',&
1908>             & kjpindex,' x ' ,nvm, ' = ',kjpindex*nvm
1909>        STOP 'sechiba_init'
1910>     END IF
1911>
19121115a1268,1274
1913>     ALLOCATE (rstruct(kjpindex,nvm),stat=ier)
1914>     IF (ier.NE.0) THEN
1915>        WRITE (numout,*) ' error in rstruct allocation. We stop. We need kjpindex x nvm words = ',&
1916>             & kjpindex,' x ' ,nvm, ' = ',kjpindex*nvm
1917>        STOP 'sechiba_init'
1918>     END IF
1919>
19201149,1161c1308
1921< !MM, T. d'O. : before in constantes_soil :
1922< !          diaglev = &
1923< !               & (/ 0.001, 0.004, 0.01,  0.018, 0.045, &
1924< !               &    0.092, 0.187, 0.375, 0.750, 1.5,   &
1925< !               &    2.0 /)
1926<
1927< !MM Problem here with dpu which depends on soil type           
1928<     DO jv = 1, nbdl-1
1929<        ! first 2.0 is dpu
1930<        ! second 2.0 is average
1931<        diaglev(jv) = 2.0/(2**(nbdl-1) -1) * ( ( 2**(jv-1) -1) + ( 2**(jv) -1) ) / 2.0
1932<     ENDDO
1933<     diaglev(nbdl) = 2.0
1934---
1935>     ! tdo - diaglev is now computed in intersurf (for output reasons - see histvert)
19361185a1333,1334
1937>     ! tdo - ajout de hydrol_cwrr ici pour fonctionnement de diffuco
1938>     control%hydrol_cwrr = control_in%hydrol_cwrr
19391216a1366,1367
1940>     IF ( ALLOCATED (flood_res)) DEALLOCATE (flood_res)
1941>     IF ( ALLOCATED (flood_frac)) DEALLOCATE (flood_frac)
19421226c1377,1379
1943<     IF ( ALLOCATED (soiltype)) DEALLOCATE (soiltype)
1944---
1945>     IF ( ALLOCATED (soiltile)) DEALLOCATE (soiltile)
1946>     IF ( ALLOCATED (njsc)) DEALLOCATE (njsc)
1947>     IF ( ALLOCATED (reinf_slope)) DEALLOCATE (reinf_slope)
19481228a1382
1949>     IF ( ALLOCATED (vbeta5)) DEALLOCATE (vbeta5)
19501235a1390
1951>     IF ( ALLOCATED (vbeta3pot)) DEALLOCATE (vbeta3pot)
19521240d1394
1953<     IF ( ALLOCATED (veget_max)) DEALLOCATE (veget_max)
19541241a1396
1955>     IF ( ALLOCATED (frac_bare)) DEALLOCATE (frac_bare)
19561247a1403
1957>     IF ( ALLOCATED (vevapflo)) DEALLOCATE (vevapflo)
19581251a1408
1959>     IF ( ALLOCATED (floodout)) DEALLOCATE (floodout)
19601254c1411
1961<     IF ( ALLOCATED (returnflow)) DEALLOCATE (returnflow)
1962---
1963>     IF ( ALLOCATED (reinfiltration)) DEALLOCATE (reinfiltration)
19641265a1423
1965>     IF ( ALLOCATED (k_litt)) DEALLOCATE (k_litt)
19661267a1426
1967>     IF ( ALLOCATED (transpot)) DEALLOCATE (transpot)
19681269a1429
1969>     IF ( ALLOCATED (rstruct)) DEALLOCATE (rstruct)
1970_______________________________________________________________________________________________________________________