My Project
mod_wd.f90
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 !/===========================================================================/
13 ! Copyright (c) 2007, The University of Massachusetts Dartmouth
14 ! Produced at the School of Marine Science & Technology
15 ! Marine Ecosystem Dynamics Modeling group
16 ! All rights reserved.
17 !
18 ! FVCOM has been developed by the joint UMASSD-WHOI research team. For
19 ! details of authorship and attribution of credit please see the FVCOM
20 ! technical manual or contact the MEDM group.
21 !
22 !
23 ! This file is part of FVCOM. For details, see http://fvcom.smast.umassd.edu
24 ! The full copyright notice is contained in the file COPYRIGHT located in the
25 ! root directory of the FVCOM code. This original header must be maintained
26 ! in all distributed versions.
27 !
28 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 ! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 ! PURPOSE ARE DISCLAIMED.
32 !
33 !/---------------------------------------------------------------------------/
34 ! CVS VERSION INFORMATION
35 ! $Id$
36 ! $Name$
37 ! $Revision$
38 !/===========================================================================/
39 
40 MODULE mod_wd
41 
42  USE mod_prec
43  IMPLICIT NONE
44  SAVE
45 !
46 !--Parameters for Wet/Dry Treatment
47 !
48 
49 !-----variables controlling porosities through wet/dry determination----------------!
50 
51  INTEGER , ALLOCATABLE :: iswetn(:) !!NODE POROSITY AT NODES FOR TIME N
52  INTEGER , ALLOCATABLE :: iswetc(:) !!CELL POROSITY AT CELLS FOR TIME N
53  INTEGER , ALLOCATABLE :: iswetnt(:) !!NODE POROSITY AT NODES FOR TIME N-1 INTERNAL
54  INTEGER , ALLOCATABLE :: iswetct(:) !!CELL POROSITY AT CELLS FOR TIME N-1 INTERNAL
55  INTEGER , ALLOCATABLE :: iswetce(:) !!CELL POROSITY AT CELLS FOR TIME N-1 EXTERNAL
56 
57 !! REAL(SP), ALLOCATABLE :: UAS(:) !!VERT-AVGD X-VELOC USED FOR MASS CONS IN FLOODING/DRYING PROCESS
58 !! REAL(SP), ALLOCATABLE :: VAS(:) !!VERT-AVGD Y-VELOC USED FOR MASS CONS IN FLOODING/DRYING PROCESS
59 !! REAL(SP), ALLOCATABLE :: UARDS(:) !!UA AVGD OVER EXT INT FOR MASS CONS IN FLOODING/DRYING PROCESS
60 !! REAL(SP), ALLOCATABLE :: VARDS(:) !!VA AVGD OVER EXT INT FOR MASS CONS IN FLOODING/DRYING PROCESS
61 !! REAL(SP), ALLOCATABLE :: US(:,:) !!X-VELOCITY FOR MASS CONS IN FLOODING/DRYING PROCESS
62 !! REAL(SP), ALLOCATABLE :: VS(:,:) !!Y-VELOCITY FOR MASS CONS IN FLOODING/DRYING PROCESS
63 
64  CONTAINS !------------------------------------------------------------------!
65  ! ALLOC_WD_DATA : ALLOCATE AND INITIALIZE WET/DRY ARRAYS !
66  ! SET_WD_DATA : SET VALUES IN WET/DRY ARRAYS !
67  ! WET_JUDGE : DETERMINE IF NODES/ELEMENTS ARE WET/DRY !
68  ! WD_UPDATE : SWAP WET/DRY VARIABLES BETWEEN TIME LEVS !
69  ! WD_DUMP : DUMP WET/DRY FLAGS FOR RESTART !
70  ! WD_READ : READ WET/DRY FLAGS FOR RESTART !
71  ! -----------------------------------------------------------------!
72 
73 !==============================================================================|
74 !==============================================================================|
75 
76 !!$ SUBROUTINE SETUP_WETDRY
77 !!$!------------------------------------------------------------------------------|
78 !!$! READ IN PARAMETERS CONTROLLING WET/DRY TREATMENT |
79 !!$!------------------------------------------------------------------------------|
80 !!$ IMPLICIT NONE
81 !!$ INTEGER :: ISCAN
82 !!$ CHARACTER(LEN=120) :: FNAME
83 !!$
84 !!$ ! NO PARAMETERS NECISARRY FOR WET DRY?
85 !!$ ONLY MAKE FILE OPTIONS
86 !!$!------------------------------------------------------------------------------|
87 !!$! READ IN VARIABLES AND SET VALUES |
88 !!$!------------------------------------------------------------------------------|
89 !!$ END SUBROUTINE SETUP_WETDRY
90 
91 
92 !==============================================================================|
93 !==============================================================================|
94  SUBROUTINE set_wd_data
95 !------------------------------------------------------------------------------|
96 ! INITIALIZE ARRAYS USED FOR WET/DRY TREATMENT |
97 !------------------------------------------------------------------------------|
98 
99  USE all_vars
100  USE mod_par
101  IMPLICIT NONE
102  INTEGER :: I
103 
104  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "START: SET_WD_DATA"
105 
106  IF(startup_type == startup_type_coldstart) THEN
107 
108 !-------- SET WET/DRY FLAGS AND MODIFY WATER SURFACE ELEVATION-----------------!
109 
110  CALL wet_judge
111 
112 !-------- EXCHANGE MODIFIED FREE SURFACE ELEVATION ACROSS PROCESSOR BOUNDS-----!
113 
114 
115 !-------- TRANSFER ELEVATION FIELD TO DEPTH AND OLD TIME LEVELS----------------!
116  el1 = elf1
117  d1 = h1 + el1
118  el = elf
119  et = el
120  d = el + h
121  dt = d
122  dtfa = d
123  et1 = el1
124  dt1 = d1
125 
126 
127  END IF
128 
129  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "END: SET_WD_DATA"
130  RETURN
131  END SUBROUTINE set_wd_data
132 
133 !==============================================================================|
134 !==============================================================================|
135 
136  SUBROUTINE alloc_wd_data
138 !------------------------------------------------------------------------------|
139 ! ALLOCATE AND INITIALIZE WET/DRY TREATMENT ARRAYS |
140 !------------------------------------------------------------------------------|
141 
142  USE mod_prec
143  USE all_vars
144  USE mod_par
145  IMPLICIT NONE
146  INTEGER NCT,NDB
147 
148  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "START: ALLOC_WD_DATA"
149 
150  ndb = 1 !!GWC BASE THIS ON KIND
151 
152 !-----variables controlling porosities through wet/dry determination----------------!
153 
154  ALLOCATE(iswetn(0:mt)) ; iswetn = 1
155  ALLOCATE(iswetc(0:nt)) ; iswetc = 1
156  ALLOCATE(iswetnt(0:mt)) ; iswetnt = 1
157  ALLOCATE(iswetct(0:nt)) ; iswetct = 1
158  ALLOCATE(iswetce(0:nt)) ; iswetce = 1
159 
160  memcnt = memcnt + 3*nt + 2*mt
161 
162 !! ALLOCATE(US(0:NT,KB)) ;US = ZERO !!X-VELOCITY FOR MASS CONSERVATION
163 !! ALLOCATE(VS(0:NT,KB)) ;VS = ZERO !!Y-VELOCITY FOR MASS CONSERVATION
164 
165 !! ALLOCATE(UAS(0:NT)) ;UAS = ZERO !!VERT AVGD X-VELOC FOR MASS CONSERVATION
166 !! ALLOCATE(VAS(0:NT)) ;VAS = ZERO !!VERT AVGD Y-VELOC FOR MASS CONSERVATION
167 !! ALLOCATE(UARDS(0:NT)) ;UARDS = ZERO !!UA AVGD OVER EXTERNAL INT FOR MASS CONSERVATION
168 !! ALLOCATE(VARDS(0:NT)) ;VARDS = ZERO !!VA AVGD OVER EXTERNAL INT FOR MASS CONSERVATION
169 
170 !! memcnt = memcnt + KB*NT*NDB + KB*MT*NDB +NT*4*NDB
171 
172  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "END: ALLOC_WD_DATA"
173  RETURN
174  END SUBROUTINE alloc_wd_data
175 
176 !==============================================================================|
177 !==============================================================================|
178 
179  SUBROUTINE wet_judge
181 !------------------------------------------------------------------------------|
182 ! DETERMINE IF NODES/ELEMENTS ARE WET OR DRY |
183 !------------------------------------------------------------------------------|
184 
185  USE mod_prec
186  USE all_vars
187  USE mod_par
188  IMPLICIT NONE
189  REAL(SP) :: DTMP
190  INTEGER :: ITA_TEMP
191  INTEGER :: I,IL,IA,IB,K1,K2,K3,K4,K5,K6
192 
193  integer :: KT
194 
195  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "START: WET_JUDGE"
196 !
197 !--Determine If Node Points Are Wet/Dry Based on Depth Threshold---------------!
198 !
199  iswetn = 1
200  DO i = 1, m
201  dtmp = h(i) + elf(i)
202 
203  IF((dtmp - min_depth) < 1.0e-5_sp) iswetn(i) = 0
204  END DO
205 
206 !
207 !--Determine if Cells are Wet/Dry Based on Depth Threshold---------------------!
208 !
209  iswetc = 1
210  DO i = 1, n
211  dtmp = max(elf(nv(i,1)),elf(nv(i,2)),elf(nv(i,3))) + &
212  min( h(nv(i,1)), h(nv(i,2)), h(nv(i,3)))
213 
214  IF((dtmp - min_depth) < 1.0e-5_sp) iswetc(i) = 0
215  END DO
216 
217 
218  ! ------ Karsten Lettmann, 2016, May ----------------
219  ! exchange the wet/dry information of elements between CPU
220  ! --------------------------------------------------
221 
222 !
223 !--A Secondary Condition for Nodal Dryness-(All Elements Around Node Are Dry)--!
224 !
225  DO i = 1, m
226  IF(sum(iswetc(nbve(i,1:ntve(i)))) == 0) iswetn(i) = 0
227  END DO
228 
229 !
230 !--Adjust Water Surface So It Does Not Go Below Minimum Depth------------------!
231 !
232  elf = max(elf,-h + min_depth)
233 
234 !
235 !--Recompute Element Based Depths----------------------------------------------!
236 !
237  DO i = 1, n
238  elf1(i) = one_third*(elf(nv(i,1))+elf(nv(i,2))+elf(nv(i,3)))
239  END DO
240 
241 !
242 !--Extend Element/Node Based Wet/Dry Flags to Domain Halo----------------------!
243 !
244 
245  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "END: WET_JUDGE"
246  RETURN
247  END SUBROUTINE wet_judge
248 
249 !==============================================================================|
250 !==============================================================================|
251 
252  SUBROUTINE wd_update(INCASE)
254 !------------------------------------------------------------------------------|
255 ! SHIFT WET/DRY VARIABLES TO NEW TIME LEVELS |
256 !------------------------------------------------------------------------------|
257 
258  USE mod_prec
259  USE all_vars
260  USE mod_par
261  IMPLICIT NONE
262  INTEGER, INTENT(IN) :: INCASE
263  INTEGER :: I
264 
265  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "START: WD_UPDATE"
266 
267  SELECT CASE(incase)
268 
269 !------------------------------------------------------------------------------!
270  CASE(1) !! SHIFT AT END OF EXTERNAL MODE
271 !------------------------------------------------------------------------------!
273 !------------------------------------------------------------------------------!
274  CASE(2) !! UPDATE NODE WET/DRY AFTER DEPTH ADJUSTMENT
275 !------------------------------------------------------------------------------!
276  DO i = 1,m
277  IF(dtfa(i)-min_depth <= 1.0e-5_sp) THEN
278  iswetn(i) = 0
279  END IF
280  END DO
281 
282 ! ------- New: Karsten Lettmann, 2017 Jan --------------------------
283 ! ----------------- end new ----------------------------------------
284 
285 !------------------------------------------------------------------------------!
286  CASE(3) !! SHIFT VARIABLES AT END OF INTERNAL MODE
287 !------------------------------------------------------------------------------!
288 
291 
292  END SELECT
293 
294  IF (dbg_set(dbg_sbr)) WRITE(ipt,*) "END: WD_UPDATE"
295  RETURN
296  END SUBROUTINE wd_update
297 
298 END MODULE mod_wd
real(sp), dimension(:), allocatable, target d
Definition: mod_main.f90:1132
real(sp), dimension(:), allocatable, target d1
Definition: mod_main.f90:1116
integer, dimension(:), allocatable iswetce
Definition: mod_wd.f90:55
real(sp), dimension(:), allocatable, target h
Definition: mod_main.f90:1131
real(sp), dimension(:), allocatable, target dtfa
Definition: mod_main.f90:1124
real(sp), dimension(:), allocatable, target el
Definition: mod_main.f90:1134
integer, dimension(:), allocatable iswetct
Definition: mod_wd.f90:54
subroutine set_wd_data
Definition: mod_wd.f90:95
real(sp), dimension(:), allocatable, target el1
Definition: mod_main.f90:1118
real(sp), dimension(:), allocatable, target et
Definition: mod_main.f90:1135
integer, dimension(:), allocatable, target ntve
Definition: mod_main.f90:1022
real(sp), dimension(:), allocatable, target elf
Definition: mod_main.f90:1140
integer, dimension(:,:), allocatable, target nv
Definition: mod_main.f90:1018
subroutine wet_judge
Definition: mod_wd.f90:180
integer, dimension(:), allocatable iswetnt
Definition: mod_wd.f90:53
subroutine alloc_wd_data
Definition: mod_wd.f90:137
integer, dimension(:), allocatable iswetc
Definition: mod_wd.f90:52
integer, dimension(:,:), allocatable, target nbve
Definition: mod_main.f90:1034
real(sp), dimension(:), allocatable, target dt1
Definition: mod_main.f90:1117
real(sp), dimension(:), allocatable, target h1
Definition: mod_main.f90:1115
real(sp), dimension(:), allocatable, target elf1
Definition: mod_main.f90:1123
subroutine wd_update(INCASE)
Definition: mod_wd.f90:253
real(sp), dimension(:), allocatable, target et1
Definition: mod_main.f90:1119
real(sp), dimension(:), allocatable, target dt
Definition: mod_main.f90:1133
integer, dimension(:), allocatable iswetn
Definition: mod_wd.f90:51