Skip to content

Commit

Permalink
ww3_nonlinear_cg: some more work on the nonlinear stuff ...
Browse files Browse the repository at this point in the history
  • Loading branch information
aronroland committed Oct 5, 2024
1 parent d824eaf commit e9c948d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 8 additions & 6 deletions model/src/w3dispmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ PURE SUBROUTINE WAVNU4 (ALOCAL,SIG,DEP,K,CG)
!
!/ ------------------------------------------------------------------- /
!/
USE CONSTANTS, ONLY : GRAV, PI
USE CONSTANTS, ONLY : GRAV, PI, TPI
!!/S USE W3SERVMD, ONLY: STRACE
!
IMPLICIT NONE
Expand All @@ -537,7 +537,7 @@ PURE SUBROUTINE WAVNU4 (ALOCAL,SIG,DEP,K,CG)
INTEGER :: I1, I2
!!/S INTEGER, SAVE :: IENT = 0
REAL :: TMP, TP, CP, L, T, KD
REAL :: L0, K0, KD0, L1, TMP2, L2, HS, TMP3
REAL :: L0, K0, KD0, L1, TMP2, L2, TMP3, HS, HMONO
REAL :: COTH, COTH2, TANHKD, KD0NU, VBAR1, VBAR2, VBAR, UBAR, U, V
REAL, PARAMETER :: BETA1 = 1.55
REAL, PARAMETER :: BETA2 = 1.3
Expand All @@ -553,14 +553,16 @@ PURE SUBROUTINE WAVNU4 (ALOCAL,SIG,DEP,K,CG)
! IENT does not work with PURE subroutines
!!/S CALL STRACE (IENT, 'WAVNU1')
!

TP = SIG/ZPI
KD0 = ZPI*ZPI*DEP/GRAV*TP*TP
TMP = 1.55 + 1.3*KD0 + 0.216*KD0*KD0
KD = KD0 * (1 + KD0**1.09 * 1./EXP(MIN(KDMAX,TMP))) / SQRT(TANH(MIN(KDMAX,KD0)))
K0 = KD/DEP
CG = 0.5*(1+(2*KD/SINH(MIN(KDMAX,2*KD))))*SIG/K0

HS = ALOCAL ! 2DO: ADD FORMULA FOR COMPUTING Hmono,i
HS = SQRT(4*ALOCAL*TPI*SIG/CG)
HMONO = SQRT(2.)*HS

T = ZPI/SIG
L0 = GRAV*T*T/ZPI
Expand All @@ -570,15 +572,15 @@ PURE SUBROUTINE WAVNU4 (ALOCAL,SIG,DEP,K,CG)
L1 = ZPI/K
TMP = KD0**(0.5*NU)
TMP2 = 1.0/TANH(MIN(KDMAX,TMP))
L2 = L1 / (1 - ALPHA * (HS/L0) * TMP2**(2.0/NU))
L2 = L1 / (1 - ALPHA * (HMONO/L0) * TMP2**(2.0/NU))
K = ZPI/L2
KD = K*DEP
TMP = KD0**(0.50*NU)
COTH = 1.0/TANH(TMP)
COTH2 = COTH**(2.0/NU)
TANHKD = tanh(KD0)
KD0NU = KD0**(0.5*NU)
TMP = (-TANHKD*KD0**(0.5*NU)*COTH**2+KD0*(TANHKD-1)*(TANHKD+1)*COTH+TANHKD*(KD0)**(0.5*NU))*ALPHA*K0*HS*COTH**(2./NU)
TMP = (-TANHKD*KD0**(0.5*NU)*COTH**2+KD0*(TANHKD-1)*(TANHKD+1)*COTH+TANHKD*(KD0)**(0.5*NU))*ALPHA*K0*HMONO*COTH**(2./NU)
TMP2 = - ZPI * COTH * (-TANHKD-KD0+KD0*TANHKD**2)
VBAR1 = GRAV * PI * (TMP+TMP2)
TMP = 1.d0/ZPI*ALPHA*K0*DEP*COTH2
Expand All @@ -590,7 +592,7 @@ PURE SUBROUTINE WAVNU4 (ALOCAL,SIG,DEP,K,CG)
UBAR = 0.5 * (GRAV * tanh(KD) + GRAV * K * (1 - tanh(KD)**2)*DEP) / U
V = SQRT(1.d0/(1.d0-TMP))
TMP2 = (-0.5 * SQRT(2.d0) * PI * ALPHA * HS * COTH2) * (-COTH-KD0**(0.5*NU)+KD0**(0.5*NU)*COTH**2)
TMP3 = 1.d0/(SQRT(PI/(ZPI-ALPHA*K0*HS*COTH2))*(-ZPI+ALPHA*K0*HS*COTH2)**2*COTH)
TMP3 = 1.d0/(SQRT(PI/(ZPI-ALPHA*K0*HMONO*COTH2))*(-ZPI+ALPHA*K0*HMONO*COTH2)**2*COTH)
VBAR = TMP2*TMP3
CG = U * VBAR + V * UBAR
!
Expand Down
4 changes: 3 additions & 1 deletion model/src/w3profsmd_pdlib.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3657,7 +3657,8 @@ SUBROUTINE calcARRAY_JACOBI_VEC(DTG,FACX,FACY,VGX,VGY)

IP_GLOB = IPLG(IP)
#ifdef NOCGTABLE
CALL WAVNU_LOCAL(SIG(IK),DW(IP_GLOB),WN1,CG1)
!CALL WAVNU_LOCAL(SIG(IK),DW(IP_GLOB),WN1,CG1)
CALL WAVNU4 (VA(ISP,IP),SIG(IK),DW(IP_GLOB),WN1,CG1)
#else
CG1 = CG(IK,IP_GLOB)
#endif
Expand Down Expand Up @@ -5650,6 +5651,7 @@ SUBROUTINE PDLIB_JACOBI_GAUSS_SEIDEL_BLOCK(IMOD, FACX, FACY, DTG, VGX, VGY, LCAL
IK = 1 + (ISP-1)/NTH
#ifdef NOCGTABLE
CALL WAVNU_LOCAL(SIG(IK),DW(ISEA),WN1(IK),CG1(IK))
CALL WAVNU4(ACLOC,
#else
CG1(IK) = CG(IK,ISEA)
#endif
Expand Down

0 comments on commit e9c948d

Please sign in to comment.