SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
irrigation_update.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 irrigation_update (AG, &
7  pirrig, ptstep, kmonth, kday, &
8  ptime,tseedmonth,tseedday,treapmonth,treapday)
9 ! ####################################################################
10 !
11 !!**** *IRRIGATION_UPDATE* - routine to update irrigation fields
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !!** METHOD
17 !! ------
18 !!
19 !! EXTERNAL
20 !! --------
21 !!
22 !!
23 !! IMPLICIT ARGUMENTS
24 !! ------------------
25 !!
26 !! REFERENCE
27 !! ---------
28 !!
29 !!
30 !! AUTHOR
31 !! ------
32 !! P. Le Moigne *Meteo France*
33 !!
34 !! MODIFICATIONS
35 !! -------------
36 !! Original 06/2006
37 !-------------------------------------------------------------------------------
38 !
39 !* 0. DECLARATIONS
40 ! ------------
41 !
42 !
43 USE modd_agri_n, ONLY : agri_t
44 !
45 USE modd_agri, ONLY : jpstage, xthreshold
46 !
47 USE yomhook ,ONLY : lhook, dr_hook
48 USE parkind1 ,ONLY : jprb
49 !
50 IMPLICIT NONE
51 !
52 TYPE(agri_t), INTENT(INOUT) :: ag
53 !
54 INTEGER, DIMENSION(:,:), INTENT(IN) :: tseedmonth
55 INTEGER, DIMENSION(:,:), INTENT(IN) :: tseedday
56 INTEGER, DIMENSION(:,:), INTENT(IN) :: treapmonth
57 INTEGER, DIMENSION(:,:), INTENT(IN) :: treapday
58 REAL , DIMENSION(:,:), INTENT(IN) :: pirrig
59 REAL, INTENT(IN) :: ptstep, ptime
60 INTEGER, INTENT(IN) :: kmonth, kday
61 INTEGER :: il, jl
62 LOGICAL :: gmask
63 REAL(KIND=JPRB) :: zhook_handle
64 !
65 !* 0.1 Declarations of arguments
66 !-------------------------------------------------------------------------------
67 !
68 ! Mask to realize update only once a day
69 !
70 IF (lhook) CALL dr_hook('MODI_IRRIGATION_UPDATE:IRRIGATION_UPDATE',0,zhook_handle)
71 gmask = ( ptime - ptstep < 0. ) .AND. ( ptime >= 0. )
72 !
73 IF (gmask) THEN
74 
75  WHERE( (pirrig(:,:).GT.0.).AND.(ag%LIRRIDAY(:,:)) .AND.(ag%NIRRINUM(:,:).LT.jpstage))
76  ag%NIRRINUM (:,:) = ag%NIRRINUM(:,:) + 1
77  ag%LIRRIDAY (:,:) = .false.
78  ENDWHERE
79 !
80  DO il=1,SIZE(pirrig,1)
81  DO jl=1,SIZE(pirrig,2)
82  ag%XTHRESHOLDSPT(il,jl)=xthreshold(ag%NIRRINUM(il,jl))
83  ENDDO
84  ENDDO
85 !
86 END IF
87 !
88 ! Reinitialization of irrigation stage (necessary for runs from August to August)
89 !
90 IF((kmonth==1).AND.(kday==1)) THEN
91  ag%NIRRINUM(:,:) = 1
92 ENDIF
93 !
94 ag%LIRRIGATE(:,:) = .false.
95 DO il=1,SIZE(pirrig,1)
96  DO jl=1,SIZE(pirrig,2)
97  !
98  ! Activate irrigation after seeding date
99  !
100  IF (kmonth == tseedmonth(il,jl) .AND. kday .GE. tseedday(il,jl)) THEN
101  ag%LIRRIGATE(il,jl) = .true.
102  END IF
103  IF (kmonth > tseedmonth(il,jl)) THEN
104  ag%LIRRIGATE(il,jl) = .true.
105  END IF
106  !
107  ! Stop irrigation after reaping date
108  !
109  IF (kmonth == treapmonth(il,jl) .AND. kday .GT. treapday(il,jl)) THEN
110  ag%LIRRIGATE(il,jl) = .false.
111  END IF
112  IF (kmonth > treapmonth(il,jl)) THEN
113  ag%LIRRIGATE(il,jl) = .false.
114  END IF
115  ENDDO
116 ENDDO
117 IF (lhook) CALL dr_hook('MODI_IRRIGATION_UPDATE:IRRIGATION_UPDATE',1,zhook_handle)
118 !
119 END SUBROUTINE irrigation_update
subroutine irrigation_update(AG, PIRRIG, PTSTEP, KMONTH, KDAY, PTIME, TSEEDMONTH, TSEEDDAY, TREAPMONTH, TREAPDAY)