SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
ini_data_soil.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE ini_data_soil(HISBA,PDG_OUT,PSURF,PSURF2,PROOTDEPTH, &
7  psoildepth,psoilgrid,kwg_layer )
8 ! #########################
9 !
10 !!**** *INI_DATA_SOIL* initializes soil depth and root fraction for a given
11 !! number of soil layers
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !! METHOD
17 !! ------
18 !!
19 !!
20 !! EXTERNAL
21 !! --------
22 !!
23 !! IMPLICIT ARGUMENTS
24 !! ------------------
25 !!
26 !! REFERENCE
27 !! ---------
28 !!
29 !! AUTHOR
30 !! ------
31 !!
32 !! V. Masson Meteo-France
33 !!
34 !! MODIFICATION
35 !! ------------
36 !!
37 !! Original 01/04/2003
38 !----------------------------------------------------------------------------
39 !
40 !* 0. DECLARATION
41 ! -----------
42 !
43 USE modd_surf_par, ONLY : xundef
44 !
45 USE modi_soilgrid
46 USE modi_abor1_sfx
47 !
48 USE yomhook ,ONLY : lhook, dr_hook
49 USE parkind1 ,ONLY : jprb
50 !
51 IMPLICIT NONE
52 !
53 !* 0.1 Declaration of arguments
54 ! ------------------------
55 !
56  CHARACTER(LEN=*), INTENT(IN) :: hisba ! type of soil (Force-Restore OR Diffusion)
57 REAL, DIMENSION(:,:,:), INTENT(OUT) :: pdg_out
58 !
59 REAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: psurf
60 REAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: psurf2
61 REAL, DIMENSION(:,:), OPTIONAL, INTENT(IN) :: prootdepth
62 REAL, DIMENSION(:,:), OPTIONAL, INTENT(IN) :: psoildepth
63 REAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: psoilgrid ! reference soil grid (m)
64 !
65 INTEGER, DIMENSION(:,:), OPTIONAL, INTENT(OUT) :: kwg_layer ! last layers for soil moisture
66 !
67 !* 0.2 Declaration of local variables
68 ! ------------------------------
69 !
70 LOGICAL,DIMENSION(SIZE(PDG_OUT,1)) :: lsurf
71 INTEGER :: jloop ! class loop counter
72 INTEGER :: jlayer ! soil layer loop counter
73 INTEGER :: jveg ! vegetation types loop counter
74 !
75 REAL(KIND=JPRB) :: zhook_handle
76 !-------------------------------------------------------------------------------
77 !-------------------------------------------------------------------------------
78 !
79 !* 1. Allocations
80 ! -----------
81 !
82 IF (lhook) CALL dr_hook('INI_DATA_SOIL',0,zhook_handle)
83 !
84 pdg_out(:,:,:) = xundef
85 !
86 !-------------------------------------------------------------------------------
87 !
88 !* 2. loop on cover types
89 ! -------------------
90 !
91 lsurf(:) = .false.
92 !
93 IF (present(psurf2) .AND. present(psurf)) THEN
94  lsurf(:) = (psurf(:)==0. .AND. psurf2(:)==0.)
95 ELSEIF (present(psurf)) THEN
96  lsurf(:) = (psurf(:)==0.)
97 ENDIF
98 !
99 !* 3. soil depth
100 ! ----------
101 !
102 !* 3.1 force-restore case (2 layers)
103 ! ------------------
104 IF (hisba=='2-L') THEN
105 
106  IF (.NOT.present(prootdepth)) CALL abor1_sfx("INI_DATA_SOIL: FOR HISBA==2-L, PROOTDEPTH IS NEEDED")
107 
108  DO jloop = 1,SIZE(lsurf)
109  IF (lsurf(jloop)) cycle
110  WHERE(prootdepth(jloop,:) /= xundef)
111  pdg_out(jloop,1,:) = 0.01
112  pdg_out(jloop,2,:) = prootdepth(jloop,:)
113  END WHERE
114  ENDDO
115 !
116 !
117 !* 3.2 force-restore case (3 layers)
118 ! ------------------
119 !
120 ELSE
121 
122  IF (.NOT.present(psoildepth)) CALL abor1_sfx("INI_DATA_SOIL: FOR HISBA/=2-L, PSOILDEPTH IS NEEDED")
123 
124  IF (hisba=='3-L') THEN
125 
126  IF (.NOT.present(prootdepth)) CALL abor1_sfx("INI_DATA_SOIL: FOR HISBA==3-L, PROOTDEPTH IS NEEDED")
127 
128  DO jloop = 1,SIZE(lsurf)
129  IF (lsurf(jloop)) cycle
130  WHERE(psoildepth(jloop,:) /= xundef)
131  pdg_out(jloop,1,:) = 0.01
132  pdg_out(jloop,2,:) = prootdepth(jloop,:)
133  pdg_out(jloop,3,:) = psoildepth(jloop,:)
134  END WHERE
135  ENDDO
136 !
137 !
138 !* 3.3 Diffusion case (at least 4 soil layers)
139 ! --------------
140 !
141  ELSE
142 
143  IF (.NOT.present(psoilgrid)) CALL abor1_sfx("INI_DATA_SOIL: FOR HISBA==DIF, PSOILGRID IS NEEDED")
144  IF (.NOT.present(kwg_layer)) CALL abor1_sfx("INI_DATA_SOIL: FOR HISBA==DIF, KWG_LAYER IS NEEDED")
145 
146  CALL soilgrid(psoilgrid,psoildepth,pdg_out,kwg_layer)
147 
148  ENDIF
149 
150 ENDIF
151 !
152 IF (lhook) CALL dr_hook('INI_DATA_SOIL',1,zhook_handle)
153 !-------------------------------------------------------------------------------
154 !
155 END SUBROUTINE ini_data_soil
subroutine soilgrid(PSOILGRID, PSOILDEPTH, PDG, KWG_LAYER)
Definition: soilgrid.F90:6
subroutine ini_data_soil(HISBA, PDG_OUT, PSURF, PSURF2, PROOTDEPTH, PSOILDEPTH, PSOILGRID, KWG_LAYER)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6