The TELEMAC-MASCARET system  trunk
t3d_construct_aed2.F90
Go to the documentation of this file.
1 ! *****************************
2  SUBROUTINE t3d_construct_aed2 &
3 ! *****************************
4 !
5  (dt,ta,rho4aed2,v2dpar,nplan,sali4aed2,temp4aed2,windspd,npoin2,&
6  npoin3,thick4aed2,benth4aed2,rain)
7 !
8 !***********************************************************************
9 ! WAQTEL V8P0
10 !***********************************************************************
11 !
12 !brief Allows exchange of variables when coupling with AED2 for 3D case
13 ! modele tuflowfv_construct-extern_wq
14 !
15 !history M. Jodeau
16 !+ 10/08/2016
17 !+ V7P3
18 !+ CREATION
19 !
20 !history C.-T. PHAM (LNHE)
21 !+ 15/11/2018
22 !+ V8P0
23 !+ Variation of salinity, temperature, density with the order expected
24 !+ by AED2 (from top to bottom, then 2D number) + real wind velocity
25 !
26 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 !| BENTH4AED2 |-->| NUMBER OF THE BENTHOS LAYER
28 !| DT |-->| TIME STEP
29 !| NPLAN |-->| NUMBER OF HORIZONTAL PLANES
30 !| NPOIN2 |-->| NUMBER OF POINTS IN THE 2D MESH
31 !| NPOIN3 |-->| NUMBER OF POINTS IN THE 3D MESH
32 !| RAIN |-->| RAIN
33 !| RHO4AED2 |-->| WATER DENSITY
34 !| SALI4AED2 |-->| SALINITY
35 !| TA |-->| TRACER
36 !| TEMP4AED2 |-->| TEMPERATURE
37 !| THICK4AED2 |-->| THICKNESS OF LAYERS
38 !| V2DPAR |-->| INTEGRAL OF 2D TEST FUNCTIONS
39 !| WINDSPD |-->| MAGNITUDE OF WIND SPEED
40 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41 !
42  USE bief
45  USE meteo_telemac, ONLY : tair
46 #if defined HAVE_AED2
47  USE t3d_aed2
48 #endif
49 !
50  IMPLICIT NONE
51 !
52 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 !
54 ! VARIABLES T3D
55  INTEGER , INTENT(IN) :: NPLAN,NPOIN2,NPOIN3
56  DOUBLE PRECISION, INTENT(IN) :: DT
57  TYPE(bief_obj), INTENT(IN) :: TA,V2DPAR
58  TYPE(bief_obj), INTENT(IN) :: RAIN,WINDSPD
59  TYPE(bief_obj), INTENT(IN) :: RHO4AED2,THICK4AED2,BENTH4AED2
60  TYPE(bief_obj), INTENT(IN) :: TEMP4AED2,SALI4AED2
61 !
62 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 !
64 #if defined HAVE_AED2
65  INTEGER,PARAMETER :: REALKIND = 8
66 !DEC$ END IF
67  INTEGER,PARAMETER :: DOUBLEKIND = 8
68 ! WQ TYPE
69  TYPE :: fvwq
70  LOGICAL :: INIT = .false. ! WQ INITIALISED
71  LOGICAL :: DISABLE = .false. ! WQ CALCULATION FLAG
72  INTEGER :: TYP ! WQ MODEL ID
73  CHARACTER(LEN=30) :: MODEL ! WQ MODEL DESCRIPTION
74  LOGICAL :: UPDATED ! UPDATED STATUS
75  REAL(DOUBLEKIND) :: DT_UPDATE ! UPDATE TIMESTEP
76  REAL(DOUBLEKIND) :: T_UPDATE ! NEXT UPDATE TIME
77  INTEGER :: NC2 ! NUMBER OF 2D CELLS
78  INTEGER :: NC3 ! NUMBER OF 3D CELLS
79  INTEGER :: NWQ ! NUMBER OF WQ CONSTITUENTS
80  INTEGER :: NBEN ! NUMBER OF BENTHIC WQ CONSTITUENTS
81  INTEGER :: NDIAG ! NUMBER OF WQ DIAGNOSTIC VARIABLES
82  CHARACTER(LEN=30),ALLOCATABLE,DIMENSION(:) :: NAMES ! WQ PELAGIC CONSTITUENT NAMES
83  CHARACTER(LEN=30),ALLOCATABLE,DIMENSION(:) :: BEN_NAMES ! WQ BENTHIC CONSTITUENT NAMES
84  CHARACTER(LEN=30),ALLOCATABLE,DIMENSION(:) :: DIAG_NAMES ! WQ DIAGNOSTIC VARIABLE NAMES
85  INTEGER,POINTER,DIMENSION(:) :: SURF_MAP ! SURFACE CELL MAP (NC2)
86  INTEGER,POINTER,DIMENSION(:) :: BENTH_MAP ! BOTTOM/BENTHIC LAYER MAP (NC2)
87  INTEGER,POINTER,DIMENSION(:) :: NL ! NUMBER OF LAYERS (NC2)
88  INTEGER,POINTER,DIMENSION(:,:) :: MAT_ID ! MATERIAL ID (NMG,NC2)
89  REAL(REALKIND),POINTER,DIMENSION(:) :: THICK ! CELL THICKNESS (NC3)
90  REAL(REALKIND),POINTER,DIMENSION(:) :: DEPTH ! LOCAL MID-CELL DEPTH (NC3)
91  REAL(REALKIND),POINTER,DIMENSION(:,:) :: DCDT ! TEMPORAL DERIVATIVE OF WQ CONSTITUENTS (NWQ,NC3)
92  REAL(REALKIND),POINTER,DIMENSION(:) :: SAL ! SALINITY POINTER (NC3)
93  REAL(REALKIND),POINTER,DIMENSION(:) :: TEMP ! TEMPERATURE POINTER (NC3)
94  REAL(REALKIND),POINTER,DIMENSION(:) :: TSS ! TOTAL SUSPENDED SOLIDS POINTER (NC3)
95  REAL(REALKIND),POINTER,DIMENSION(:) :: VVEL ! VERTICAL VELOCITIES (NC3)
96  REAL(REALKIND),POINTER,DIMENSION(:,:) :: PAR ! NET SHORTWAVE RADIATION (NC3)
97  REAL(REALKIND),POINTER,DIMENSION(:,:) :: CC ! WQ CONSTITUENT CONCENTRATIONS (NWQ,NC3)
98  REAL(REALKIND),POINTER,DIMENSION(:,:) :: DIAG ! DIAGNOSTIC WQ VARIABLES (NDIAG,NC3)
99  REAL(REALKIND),POINTER,DIMENSION(:) :: DENSITY ! ABSOLUTE DENSITY (NC3)
100  REAL(REALKIND),POINTER,DIMENSION(:) :: I_0 ! NET SURFACE IRRADIANCE (NC2)
101  REAL(REALKIND),POINTER,DIMENSION(:) :: WIND ! 10M WINDSPEED (NC2)
102  REAL(REALKIND),POINTER,DIMENSION(:) :: PRECIP ! RAIN (NC2) !#MH
103  REAL(REALKIND),POINTER,DIMENSION(:) :: USTAR_BED ! BED FRICTION VELOCITY (NC2)
104  REAL(REALKIND),POINTER,DIMENSION(:) :: USTAR_SURF ! SURFACE FRICTION VELOCITY (NC2)
105  REAL(REALKIND),POINTER,DIMENSION(:) :: AIR_TEMP ! AIR TEMPERATURE (NC2)
106 ! ARRAYS THAT CONTROL FEEDBACKS BETWEEN THE MODELS
107  REAL(REALKIND),POINTER,DIMENSION(:) :: BIOSHADE ! BIOGEOCHEMICAL LIGHT EXTINCTION COEFFICIENT RETURNED FROM WQ (NC3)
108  REAL(REALKIND),POINTER,DIMENSION(:) :: BIODRAG ! ADDITIONAL DRAG ON FLOW FROM BIOLOGY, RETURNED FROM WQ (NC3) !#MH
109  REAL(REALKIND),POINTER,DIMENSION(:) :: SOLARSHADE ! REDUCTION OF SOLAR RADIATION DUE TO SHADING RETURNED FROM WQ (NC2) !#MH
110  REAL(REALKIND),POINTER,DIMENSION(:) :: RAINLOSS ! LOSS OF RAINFALL INTO EXPOSED SEDIMENT RETURNED FROM WQ (NC2) !#MH
111 ! VARIABLES REQUIRED FOR AED2 DRY CELL MODELS
112  LOGICAL,POINTER,DIMENSION(:) :: ACTIVE ! COLUMN ACTIVE STATUS (NC2)
113  REAL(REALKIND),POINTER,DIMENSION(:) :: AREA ! CELL AREA (NC2)
114  REAL(REALKIND),POINTER,DIMENSION(:) :: BATHY ! HEIGHT OF COLUMN BOTTOM (NC2) !#MH
115  END TYPE
116 
117  TYPE(fvwq) :: WQ
118 
119 ! SUBROUTINE ARGUMENTS
120 ! INTEGER,INTENT(IN) :: NLOG
121 
122 ! LOCAL VARIABLES
123  INTEGER I,J
124  INTEGER RC1
125 !
126 !-----------------------------------------------------------------------
127 !
128 ! INITIALISE AED2 LINKAGE
129  WRITE(lu,*) 'INITIALISING "AED2" EXTERNAL MODULE:'
130 ! CORRESPONDANCE T3D-AED2
131  wq%NC3 = npoin3
132 
133 ! VARIABLE 3D
134  ALLOCATE(wq%CC(1:nwqvars,1:npoin3),stat=rc1)
135  IF (rc1.NE.0) stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%CC)'
136 
137  ALLOCATE(wq%DIAG(1:nwqdiags,1:npoin3),stat=rc1)
138  IF (rc1.NE.0) stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%DIAG)'
139 
140  ALLOCATE(wq%TEMP(1:npoin3),stat=rc1)
141  IF (rc1.NE.0) stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%TEMP)'
142 
143  ALLOCATE(wq%SAL(1:npoin3),stat=rc1)
144  IF (rc1.NE.0) stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%SAL)'
145 
146  ALLOCATE(wq%DENSITY(1:npoin3),stat=rc1)
147  IF (rc1.NE.0) THEN
148  stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%DENSITY)'
149  ENDIF
150 
151  ALLOCATE(wq%THICK(1:npoin3),stat=rc1)
152  IF(rc1.NE.0) stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%THICK)'
153 
154  ALLOCATE(wq%TSS(1:npoin3),stat=rc1)
155  IF (rc1.NE.0) stop 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%TSS)'
156 
157 ! ALLOCATE(WQ%PAR(1:NPOIN3, ),STAT=RC1)
158 ! IF (RC1.NE.0) STOP 'ALLOCATE_MEMORY(): ERROR ALLOCATING (WQ%PAR)'
159 
160  ALLOCATE(wq%BIOSHADE(1:npoin3),stat=rc1)
161  ALLOCATE(wq%BIODRAG(1:npoin3),stat=rc1)
162 
163 ! VARIABLES 2D
164  ALLOCATE(wq%AREA(1:npoin2),stat=rc1)
165  ALLOCATE(wq%I_0(1:npoin2),stat=rc1)
166  ALLOCATE(wq%WIND(1:npoin2),stat=rc1)
167  ALLOCATE(wq%PRECIP(1:npoin2),stat=rc1)
168  ALLOCATE(wq%AIR_TEMP(1:npoin2),stat=rc1)
169  ALLOCATE(wq%USTAR_BED(1:npoin2),stat=rc1)
170  ALLOCATE(wq%USTAR_SURF(1:npoin2),stat=rc1)
171  ALLOCATE(wq%DEPTH(1:npoin2),stat=rc1)
172  ALLOCATE(wq%BATHY(1:npoin2),stat=rc1)
173  ALLOCATE(wq%MAT_ID(1:2,1:npoin2),stat=rc1) !NMG ??? NMG=2 A MODIFIER
174  ALLOCATE(wq%ACTIVE(1:npoin2),stat=rc1)
175  ALLOCATE(wq%SURF_MAP (1:npoin2),stat=rc1)
176  ALLOCATE(wq%BENTH_MAP (1:npoin2),stat=rc1)
177 
178 ! AJOUT INITIALISATION
179  wq%ACTIVE = .true.
180  wq%MAT_ID = 0
181 ! WQ%I_0 = 500.D0
182  wq%I_0 => rayaed2%R
183 
184  IF ( .NOT. ASSOCIATED(wq%CC) .OR. .NOT. ASSOCIATED(wq%DIAG) ) THEN
185  WRITE(lu,*) 'WATER QUALITY VARIABLES NOT ASSOCIATED'
186  ENDIF
187 
188 ! ALLOCATE LOCAL MEMORY BLOCK FOR AED2 WQ VARIABLES
189  CALL init_var_aed2_models(wq%NC3,wq%CC,wq%DIAG,wq%NWQ,wq%NBEN,&
190  wq%SURF_MAP,wq%BENTH_MAP)
191  WRITE(lu,*) 'EXIT INIT_VAR_AED2_MODELS'
192 
193  wq%DT_UPDATE = dt
194 
195 ! ASSOCIATION DES POINTEURS AED2 A CEUX DE T3D
196 ! 3D
197  DO j=1,wq%NWQ
198  DO i=1,npoin3
199  wq%CC(j,i) = ta%ADR(j+2)%P%R(i)
200  ENDDO
201  ENDDO
202 
203 ! WQ%TEMP => TA%ADR(IND_T)%P%R
204 ! WQ%SAL => TA%ADR(IND_S)%P%R
205 ! WQ%WIND = 0.D0
206 ! WQ%DENSITY = RHO0
207 
208 ! DO J=1,NPLAN-1
209 ! DO I=1,NPOIN2
210 ! WQ%THICK(I+(J-1)*NPOIN2) = Z(I+J*NPOIN2) - Z(I+(J-1)*NPOIN2)
211 ! ENDDO
212 ! ENDDO
213 
214  wq%TEMP => temp4aed2%R
215  wq%SAL => sali4aed2%R
216  wq%WIND => windspd%R
217  wq%PRECIP => rain%R
218  wq%DENSITY => rho4aed2%R
219 
220  wq%THICK => thick4aed2%R
221 
222  wq%AIR_TEMP => tair%R
223 
224 ! WQ%DEPTH =
225 ! WQ%BATHY =
226  wq%TSS = 0.d0
227 ! 2D
228 ! V2DPAR, NOT VOLU2D IN ORDER TO WORK IN PARALLEL
229  wq%AREA => v2dpar%R
230  wq%SURF_MAP = 1
231 ! WQ%BENTH_MAP = NPLAN
232  wq%BENTH_MAP => benth4aed2%I
233 
234 ! 3D FEEDBACK ARRAYS
235 ! WQ%BIOSHADE =
236 
237 
238 ! 2D FEEDBACK ARRAYS
239 ! WQ%BIODRAG =
240 ! WQ%SOLARSHADE =
241 ! WQ%RAINLOSS =
242  wq%USTAR_BED = 0.d0
243  wq%USTAR_SURF = 0.d0
244 
245  CALL set_env_aed2_models(wq%DT_UPDATE, &
246 ! 3D ENV VARIABLES
247  wq%TEMP, &
248  wq%SAL, &
249  wq%DENSITY, &
250  wq%THICK, &
251  wq%TSS, &
252  wq%PAR, &
253 ! 3D FEEDBACK ARRAYS
254  wq%BIOSHADE, &
255 ! 2D ENV VARIABLES
256  wq%AREA, &
257  wq%I_0, &
258  wq%WIND, &
259  wq%PRECIP, &
260  wq%AIR_TEMP, &
261  wq%USTAR_BED, &
262  wq%USTAR_SURF, &
263  wq%DEPTH, &
264  wq%BATHY, &
265  wq%MAT_ID, &
266  wq%ACTIVE, &
267  wq%BENTH_MAP, &
268 ! 2D FEEDBACK ARRAYS
269  wq%BIODRAG, &
270  wq%SOLARSHADE, &
271  wq%RAINLOSS)
272 
273  WRITE(lu,*) 'SET_ENV_AED2_MODELS SUCCESSFUL'
274 
275  wq%INIT = .true.
276 !
277 #endif
278  RETURN
279 
280  END SUBROUTINE
type(bief_obj), target, public tair
Definition: meteo_telemac.f:44
subroutine t3d_construct_aed2(DT, TA, RHO4AED2, V2DPAR, NPLAN, SALI4AED2, TEMP4AED2, WINDSPD, NPOIN2, NPOIN3, THICK4AED2, BENTH4AED2, RAIN)
type(bief_obj), target rayaed2
Definition: bief.f:3
subroutine, public set_env_aed2_models(DT_, TEMP_, SALT_, RHO_, H_, TSS_, RAD_, EXTCOEFF_, AREA_, I_0_, WND_, RAIN_, AIR_TEMP_, USTAR_BED_, USTAR_SURF_, Z_, BATHY_, MAT_ID_, ACTIVE_, BENTH_MAP_, BIODRAG_, SOLARSHADE_, RAINLOSS_)
Definition: t3d_aed2.F90:725
subroutine, public init_var_aed2_models(NCELLS, CC_, CC_DIAG_, NWQ, NWQBEN, SM, BM)
Definition: t3d_aed2.F90:394