My Project
mod_obcs3.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_obcs3
41 
42  USE all_vars
43  USE mod_prec
44  USE mod_obcs
45 
46  USE mod_meanflow
47  USE mod_obcs2
48 
49  IMPLICIT NONE
50  SAVE
51 
52 !--Nonlinear Velocity Open Boundary Condition Arrays
53  REAL(sp), ALLOCATABLE :: fluxobn2(:),cxobc(:),cyobc(:)
54  REAL(sp), ALLOCATABLE :: fluxobc2d_x(:), fluxobc2d_y(:)
55  REAL(sp), ALLOCATABLE :: obc2d_x_tide(:), obc2d_y_tide(:)
56  REAL(sp), ALLOCATABLE :: fluxobc3d_x(:,:), fluxobc3d_y(:,:)
57  REAL(sp), ALLOCATABLE :: fluxobc3d_x_2(:,:), fluxobc3d_y_2(:,:)
58  CONTAINS
59 
60 
61 !=========================================================================|
62  SUBROUTINE alloc_obc3_data
63 
64  IMPLICIT NONE
65 
66  ALLOCATE(fluxobn2(0:iobcn)) ;fluxobn2 = zero
67  ALLOCATE(cxobc(0:nt)) ;cxobc = zero
68  ALLOCATE(cyobc(0:nt)) ;cyobc = zero
69  ALLOCATE(fluxobc2d_x(0:nmfcell_i)) ;fluxobc2d_x = zero
70  ALLOCATE(fluxobc2d_y(0:nmfcell_i)) ;fluxobc2d_y = zero
71  ALLOCATE(fluxobc3d_x(0:nmfcell_i,1:kbm1)) ;fluxobc3d_x = zero
72  ALLOCATE(fluxobc3d_y(0:nmfcell_i,1:kbm1)) ;fluxobc3d_y = zero
73  ALLOCATE(fluxobc3d_x_2(0:nmfcell_i,1:kbm1)) ;fluxobc3d_x_2 = zero
74  ALLOCATE(fluxobc3d_y_2(0:nmfcell_i,1:kbm1)) ;fluxobc3d_y_2 = zero
75 
76  ALLOCATE(obc2d_x_tide(0:nmfcell),obc2d_y_tide(0:nmfcell))
77 
78  RETURN
79  END SUBROUTINE alloc_obc3_data
80 !==========================================================================|
81 
82 !==========================================================================|
83  SUBROUTINE zero_obc3
84 
85  IMPLICIT NONE
86 
87  integer :: I
88 
89  IF (nmfcell > 0) THEN
90  DO i = 0, nmfcell
91  obc2d_x_tide(i) = 0.0_sp
92  obc2d_y_tide(i) = 0.0_sp
93  END DO
94  END IF
95 
96  RETURN
97  END SUBROUTINE zero_obc3
98 !==========================================================================|
99 
100 
101 !==============================================================================|
102  SUBROUTINE setup_obc3
104  IMPLICIT NONE
105 
106  INTEGER :: I, I1, I2, J, IC, N1, N2, N3
107  REAL(SP) :: DXN,DYN,DXC,DYC,CROSS
108 
109  IF (iobcn > 0) THEN
110  DO i=1,iobcn
111  i1 = i_obc_n(i)
112  i2 = adjn_obc(i,1)
113  DO j = 1, ntve(i1)
114  ic = nbve(i1,j)
115  n1 = nv(ic,1) ; n2 = nv(ic,2) ; n3 = nv(ic,3)
116  IF( n1-i2 == 0 .OR. n2-i2 == 0 .OR. n3-i2 == 0)THEN
117  dxn = vx(i2)-vx(i1) ; dyn = vy(i2)-vy(i1)
118  dxc = xc(ic)-vx(i1) ; dyc = yc(ic)-vy(i1)
119  cross = sign(1.0_sp,dxc*dyn - dyc*dxn)
120  cxobc(ic) = cross*dyn/sqrt(dxn**2 +dyn**2)
121  cyobc(ic) = -cross*dxn/sqrt(dxn**2 +dyn**2)
122  END IF
123  END DO
124 
125  IF(nadjn_obc(i) > 1)THEN
126  i2 = adjn_obc(i,2)
127  DO j = 1, ntve(i1)
128  ic = nbve(i1,j)
129  n1 = nv(ic,1) ; n2 = nv(ic,2) ; n3 = nv(ic,3)
130  IF( n1-i2 == 0 .OR. n2-i2 == 0 .OR. n3-i2 == 0)THEN
131  dxn = vx(i2)-vx(i1) ; dyn = vy(i2)-vy(i1)
132  dxc = xc(ic)-vx(i1) ; dyc = yc(ic)-vy(i1)
133  cross = sign(1.0_sp,dxc*dyn - dyc*dxn)
134  cxobc(ic) = cross*dyn/sqrt(dxn**2 +dyn**2)
135  cyobc(ic) =-cross*dxn/sqrt(dxn**2 +dyn**2)
136  END IF
137  END DO
138  END IF
139  END DO
140  END IF
141 
142  RETURN
143  END SUBROUTINE setup_obc3
144 
145 !==============================================================================|
146  SUBROUTINE flux_obn2d(KKT)
148  IMPLICIT NONE
149 
150  INTEGER, INTENT(IN) :: KKT
151  INTEGER :: I,I1,N1,N2,N3,C1,C2
152  REAL(SP) :: E1_X,E1_Y,E2_X,E2_Y
153  REAL(SP) :: FLUXF_OBC_1,FLUXF_OBC_2
154 
155 
156 ! IF (IOBCN > 0) THEN
157 ! DO I = 1, IOBCN
158 ! IF(NADJN_OBC(I) == 1)THEN
159 ! N1 = I_OBC_N(I)
160 ! N2 = ADJN_OBC(I,1)
161 ! I1 = I_OBC_NODE(N1)
162 !
163 ! E1_Y = VY(N1)-VY(N2)
164 !# if defined (SPHERICAL)
165 ! X1_DP = VX(N2)
166 ! Y1_DP = VY(N2)
167 ! X2_DP = VX(N1)
168 ! Y2_DP = VY(N1)
169 ! CALL ARCX(X1_DP,Y1_DP,X2_DP,Y2_DP,SIDE)
170 ! E1_X = SIDE
171 ! E1_Y = TPI*E1_Y
172 !# else
173 ! E1_X = VX(N1)-VX(N2)
174 !# endif
175 !
176 ! C1 = I_OBC_CELL2(ADJC_OBC(I,1))
177 ! FLUXF_OBC_1 = 0.5_SP*SQRT(E1_X**2+E1_Y**2)* &
178 ! (UANP(C1)*CXOBC(ADJC_OBC(I,1))+VANP(C1)*CYOBC(ADJC_OBC(I,1)))
179 !
180 ! FLUXOBN2(I) = -FLUXF_OBC_1*(H(N1)+ELT(I1)+ELP(I1))
181 !
182 ! ELSE
183 ! N1 = I_OBC_N(I)
184 ! N2 = ADJN_OBC(I,1)
185 ! N3 = ADJN_OBC(I,2)
186 ! I1 = I_OBC_NODE(N1)
187 !
188 ! E1_Y = VY(N1)-VY(N2)
189 !# if defined (SPHERICAL)
190 ! X1_DP = VX(N2)
191 ! Y1_DP = VY(N2)
192 ! X2_DP = VX(N1)
193 ! Y2_DP = VY(N1)
194 ! CALL ARCX(X1_DP,Y1_DP,X2_DP,Y2_DP,SIDE)
195 ! E1_X = SIDE
196 ! E1_Y = TPI*E1_Y
197 !# else
198 ! E1_X = VX(N1)-VX(N2)
199 !# endif
200 !
201 ! E2_Y = VY(N1)-VY(N3)
202 !# if defined (SPHERICAL)
203 ! X1_DP = VX(N3)
204 ! Y1_DP = VY(N3)
205 ! X2_DP = VX(N1)
206 ! Y2_DP = VY(N1)
207 ! CALL ARCX(X1_DP,Y1_DP,X2_DP,Y2_DP,SIDE)
208 ! E2_X = SIDE
209 ! E2_Y = TPI*E2_Y
210 !# else
211 ! E2_X = VX(N1)-VX(N3)
212 !# endif
213 !
214 ! C1 = I_OBC_CELL2(ADJC_OBC(I,1))
215 ! C2 = I_OBC_CELL2(ADJC_OBC(I,2))
216 ! FLUXF_OBC_1 = 0.5_SP*SQRT(E1_X**2+E1_Y**2)* &
217 ! (UANP(C1)*CXOBC(ADJC_OBC(I,1))+VANP(C1)*CYOBC(ADJC_OBC(I,1)))
218 ! FLUXF_OBC_2 = 0.5_SP*SQRT(E2_X**2+E2_Y**2)* &
219 ! (UANP(C2)*CXOBC(ADJC_OBC(I,2))+VANP(C2)*CYOBC(ADJC_OBC(I,2)))
220 !
221 ! FLUXOBN2(I) = -(FLUXF_OBC_1+FLUXF_OBC_2)*(H(N1)+ELT(I1)+ELP(I1))
222 ! END IF
223 ! END DO
224 ! END IF
225 
226  IF (nmfcell > 0) THEN
227  DO i = 1, nmfcell
228  c1= i_obc_node2(node_mfcell(i,1))
229  c2= i_obc_node2(node_mfcell(i,2))
230  fluxobn2(c1) = fluxobn2(c1) - mfqdis(i)*rdismf(i,1)
231  fluxobn2(c2) = fluxobn2(c2) - mfqdis(i)*rdismf(i,2)
232  END DO
233  END IF
234 
235  RETURN
236  END SUBROUTINE flux_obn2d
237 
238 
239 !==============================================================================|
240  SUBROUTINE flux_obc2d
242  IMPLICIT NONE
243 
244  INTEGER :: I,II,I1,I2,J,J1,J2,ITMP,JTMP
245  REAL(DP) DX12,DY12,TMP1,DTMP
246  REAL(SP) :: FLUXF_OBC_1,FLUXF_OBC_2
247 
248  IF (nmfcell_i > 0) THEN
249  DO i = 1, nmfcell_i
250  ii= i_mfcell_n(i)
251  itmp=0
252  DO j=1,3
253  IF(nbe(ii,j) == 0) THEN
254  jtmp=j
255  itmp=itmp+1
256  END IF
257  END DO
258  IF (itmp /= 1) THEN
259  print*,'something is wrong here 2'
260  CALL pstop
261  END IF
262 
263  j1=jtmp+1-int((jtmp+1)/4)*3
264  j2=jtmp+2-int((jtmp+2)/4)*3
265  i1=nv(ii,j1)
266  i2=nv(ii,j2)
267  dy12=vy(i1)-vy(i2)
268  dx12=vx(i1)-vx(i2)
269 
270  dtmp = 0.5_sp*(h(i1)+h(i2)+elt(i_obc_node(i1))+elt(i_obc_node(i2))) ! May be a problem, should be replaced by D
271 ! TMP1 = -(UANT(I)*cos(ANGLEMF(I))+VANT(I)*sin(ANGLEMF(I))*(SQRT(DX12**2+DY12**2))
272  tmp1 = uant(i) * dy12 - vant(i) * dx12
273  fluxobc2d_x(i) = dtmp * tmp1 * uant(i)
274  fluxobc2d_y(i) = dtmp * tmp1 * vant(i)
275 
276  END DO
277  END IF
278 
279  END SUBROUTINE flux_obc2d
280 
281 
282 !==============================================================================|
283  SUBROUTINE flux_obc3d
285  IMPLICIT NONE
286 
287  INTEGER :: I,II,I1,I2,J,J1,J2,K,ITMP,JTMP
288  REAL(DP) DX12,DY12,TMP1,DTMP
289  REAL(SP) :: UTMP,VTMP
290 
291  IF (nmfcell > 0) THEN
292 
293 ! 2-D and 3-D adjustment
294  obc2d_x_tide = obc2d_x_tide/float(isplit)
295  obc2d_y_tide = obc2d_y_tide/float(isplit)
296 
297  DO i = 1, nmfcell
298  ii= i_mfcell_n(i)
299  itmp=0
300  DO j=1,3
301  IF(nbe(ii,j) == 0 .and. isonb(nv(ii,j)) /= 2) THEN
302  jtmp=j
303  itmp=itmp+1
304  END IF
305  END DO
306  IF (itmp /= 1) THEN
307  print*,'something is wrong here 3'
308  CALL pstop
309  END IF
310 
311  j1=jtmp+1-int((jtmp+1)/4)*3
312  j2=jtmp+2-int((jtmp+2)/4)*3
313  i1=nv(ii,j1)
314  i2=nv(ii,j2)
315  dtmp = 0.5_sp*(h(i1)+h(i2)+eltdt(i_obc_node(i1))+eltdt(i_obc_node(i2))) ! May be a problem, should be replaced by D
316 
317  utmp = 0.0_sp ; vtmp = 0.0_sp
318  DO k=1,kbm1
319  utmp = utmp + unt(i,k)*dz1(ii,k)
320  vtmp = vtmp + vnt(i,k)*dz1(ii,k)
321  END DO
322  utmp = utmp * dtmp
323  vtmp = vtmp * dtmp
324  DO k=1,kbm1
325  unt(i,k) = unt(i,k) - (utmp-obc2d_x_tide(i))/dtmp
326  vnt(i,k) = vnt(i,k) - (vtmp-obc2d_y_tide(i))/dtmp
327  END DO
328  END DO
329  END IF
330 
331  IF (nmfcell_i > 0) THEN
332  DO i = 1, nmfcell_i
333  ii= i_mfcell_n(i)
334  itmp=0
335  DO j=1,3
336  IF(nbe(ii,j) == 0) THEN
337  jtmp=j
338  itmp=itmp+1
339  END IF
340  END DO
341  j1=jtmp+1-int((jtmp+1)/4)*3
342  j2=jtmp+2-int((jtmp+2)/4)*3
343  i1=nv(ii,j1)
344  i2=nv(ii,j2)
345  dy12=vy(i1)-vy(i2)
346  dx12=vx(i1)-vx(i2)
347 
348  dtmp = 0.5_sp*(h(i1)+h(i2)+eltdt(i_obc_node(i1))+eltdt(i_obc_node(i2))) ! May be a problem, should be replaced by D
349  DO k =1, kbm1
350 ! TMP1 = -(UNT(I,K)*cos(ANGLEMF(I))+VNT(I,K)*sin(ANGLEMF(I))*(SQRT(DX12**2+DY12**2))
351  tmp1 = unt(i,k) * dy12 - vnt(i,k) * dx12
352  fluxobc3d_x(i,k) = dtmp * tmp1 * unt(i,k)
353  fluxobc3d_y(i,k) = dtmp * tmp1 * vnt(i,k)
354  END DO
355  END DO
356 
357  END IF
358 
359  END SUBROUTINE flux_obc3d
360 
361 
362 !==============================================================================|
363  SUBROUTINE flux_obc3d_2
365  USE all_vars
366  USE mod_obcs
367  USE mod_obcs2
368 
369  IMPLICIT NONE
370 
371  INTEGER :: I,II,I1,I2,J,J1,J2,K,ITMP,JTMP
372  REAL(DP) DX12,DY12,TMP1,DTMP
373  REAL(SP) :: UTMP,VTMP
374 
375  IF (nmfcell > 0) THEN
376 
377 ! 2-D and 3-D adjustment
378  DO i = 1, nmfcell
379  ii= i_mfcell_n(i)
380  utmp = sum(unt(i,1:kbm1)*dz1(ii,1:kbm1))
381  vtmp = sum(vnt(i,1:kbm1)*dz1(ii,1:kbm1))
382  unt(i,1:kbm1) = unt(i,1:kbm1) + (uant(i) - utmp)
383  vnt(i,1:kbm1) = vnt(i,1:kbm1) + (vant(i) - vtmp)
384  END DO
385  END IF
386 
387  IF (nmfcell_i > 0) THEN
388  DO i = 1, nmfcell_i
389  ii= i_mfcell_n(i)
390  itmp=0
391  DO j=1,3
392  IF(nbe(ii,j) == 0) THEN
393  jtmp=j
394  itmp=itmp+1
395  END IF
396  END DO
397  j1=jtmp+1-int((jtmp+1)/4)*3
398  j2=jtmp+2-int((jtmp+2)/4)*3
399  i1=nv(ii,j1)
400  i2=nv(ii,j2)
401  dy12=vy(i1)-vy(i2)
402  dx12=vx(i1)-vx(i2)
403 
404  dtmp = 0.5_sp*(h(i1)+h(i2)+eltdt(i_obc_node(i1))+eltdt(i_obc_node(i2))) ! May be a problem, should be replaced by D
405  DO k =1, kbm1
406 ! TMP1 = -(UNT(I,K)*cos(ANGLEMF(I))+VNT(I,K)*sin(ANGLEMF(I))*(SQRT(DX12**2+DY12**2))
407  tmp1 = unt(i,k) * dy12 - vnt(i,k) * dx12
408  fluxobc3d_x_2(i,k) = dtmp * tmp1 * unt(i,k)
409  fluxobc3d_y_2(i,k) = dtmp * tmp1 * vnt(i,k)
410  END DO
411  END DO
412 
413  END IF
414 
415  END SUBROUTINE flux_obc3d_2
416 
417 !========================================================================
418 END MODULE mod_obcs3
real(sp), dimension(:), allocatable fluxobn2
Definition: mod_obcs3.f90:53
real(sp), dimension(:), allocatable eltdt
Definition: mod_obcs2.f90:58
real(sp), dimension(:), allocatable fluxobc2d_y
Definition: mod_obcs3.f90:54
real(sp), dimension(:), allocatable, target h
Definition: mod_main.f90:1131
integer, dimension(:,:), allocatable node_mfcell
integer, dimension(:), allocatable i_mfcell_n
subroutine alloc_obc3_data
Definition: mod_obcs3.f90:63
integer, dimension(:,:), allocatable adjn_obc
Definition: mod_obcs.f90:86
integer, dimension(:), allocatable nadjn_obc
Definition: mod_obcs.f90:85
real(sp), dimension(:), allocatable, target yc
Definition: mod_main.f90:1004
integer, dimension(:), allocatable i_obc_node
Definition: mod_obcs2.f90:55
real(sp), dimension(:), allocatable obc2d_x_tide
Definition: mod_obcs3.f90:55
real(sp), dimension(:), allocatable elt
Definition: mod_obcs2.f90:58
real(sp), dimension(:,:), allocatable vnt
Definition: mod_obcs2.f90:67
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
real(sp), dimension(:,:), allocatable fluxobc3d_y
Definition: mod_obcs3.f90:56
real(sp), dimension(:), allocatable cxobc
Definition: mod_obcs3.f90:53
real(sp), dimension(:,:), allocatable fluxobc3d_x_2
Definition: mod_obcs3.f90:57
integer, parameter sp
Definition: mod_prec.f90:48
real(sp), dimension(:), allocatable cyobc
Definition: mod_obcs3.f90:53
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
integer, dimension(:), allocatable, target ntve
Definition: mod_main.f90:1022
integer, dimension(:,:), allocatable, target nbe
Definition: mod_main.f90:1020
subroutine flux_obn2d(KKT)
Definition: mod_obcs3.f90:147
integer, dimension(:,:), allocatable, target nv
Definition: mod_main.f90:1018
integer nmfcell
real(sp), dimension(:), allocatable uant
Definition: mod_obcs2.f90:63
subroutine flux_obc3d_2
Definition: mod_obcs3.f90:364
real(sp), dimension(:,:), allocatable unt
Definition: mod_obcs2.f90:67
subroutine flux_obc2d
Definition: mod_obcs3.f90:241
real(sp), dimension(:), allocatable vant
Definition: mod_obcs2.f90:63
real(sp), dimension(:), allocatable fluxobc2d_x
Definition: mod_obcs3.f90:54
integer, dimension(:,:), allocatable, target nbve
Definition: mod_main.f90:1034
integer, dimension(:), allocatable i_obc_node2
Definition: mod_obcs2.f90:55
real(sp), dimension(:), allocatable, target xc
Definition: mod_main.f90:1003
real(sp), dimension(:,:), allocatable, target dz1
Definition: mod_main.f90:1096
real(sp), dimension(:), allocatable mfqdis
real(sp), dimension(:), allocatable obc2d_y_tide
Definition: mod_obcs3.f90:55
real(sp), dimension(:,:), allocatable fluxobc3d_x
Definition: mod_obcs3.f90:56
real(sp), dimension(:,:), allocatable fluxobc3d_y_2
Definition: mod_obcs3.f90:57
real(sp), dimension(:,:), allocatable rdismf
subroutine setup_obc3
Definition: mod_obcs3.f90:103
subroutine zero_obc3
Definition: mod_obcs3.f90:84
integer nmfcell_i
integer, dimension(:), allocatable, target isonb
Definition: mod_main.f90:1024
subroutine flux_obc3d
Definition: mod_obcs3.f90:284