WAVEWATCH III  beta 0.0.1
w3gig1md Module Reference

Functions/Subroutines

real function df1f2theta (s1, s2, WN1, WN2, theta, DEPTH)
 
subroutine w3addig (E, DEPTH, WN, CG, IACTION)
 

Function/Subroutine Documentation

◆ df1f2theta()

real function w3gig1md::df1f2theta ( real, intent(in)  s1,
real, intent(in)  s2,
real  WN1,
real  WN2,
real, intent(in)  theta,
real, intent(in)  DEPTH 
)

Definition at line 61 of file w3gig1md.F90.

61  !/
62  !/ +-----------------------------------+
63  !/ | WAVEWATCH III NOAA/NCEP |
64  !/ | H. L. Tolman |
65  !/ | FORTRAN 90 |
66  !/ | Last update : 29-Nov-1999 |
67  !/ +-----------------------------------+
68  !/ Based on INCYMD of the GLA GCM.
69  !/
70  !/ 18-Oct-1998 : Final FORTRAN 77 ( version 1.18 )
71  !/ 29-Nov-1999 : Upgrade to FORTRAN 90 ( version 2.00 )
72  !/
73  ! 1. Purpose :
74  !
75  ! Computes the coupling coefficient between waves of frequencies f1 and f2
76  ! and an angle theta.
77  ! This is for the surface elevation variance
78  ! See Okihiro et al. 1992
79  ! Code adapted from Matlab by Arshad Rawat, 2012.
80  !
81  ! 3. Parameters :
82  !
83  ! Parameter list
84  ! ----------------------------------------------------------------
85  ! NYMD Int. I Old date in YYMMDD format.
86  ! M Int. I +/- 1 (Day adjustment)
87  ! ----------------------------------------------------------------
88  !
89  ! 4. Subroutines used :
90  !
91  ! Name Type Module Description
92  ! ----------------------------------------------------------------
93  ! STRACE Subr. W3SERVMD Subroutine tracing.
94  ! ----------------------------------------------------------------
95  !
96  ! 5. Called by :
97  !
98  ! Any subroutine.
99  !
100  ! 8. Structure :
101  !
102  ! See source code.
103  !
104  ! 9. Switches :
105  !
106  ! !/S Enable subroutine tracing using STRACE.
107  !
108  ! 10. Source code :
109  !
110  !/ ------------------------------------------------------------------- /
111  !/
112  USE constants
113 
114  IMPLICIT NONE
115 
116  REAL, INTENT(IN) :: s1,s2,theta,DEPTH
117  REAL :: Df1f2theta,WN1,WN2
118  REAL :: k1,k2,co,cok1,cok2,k3,C1,C2,C3,C4
119  REAL :: C1b,s3,sk2,g2,g
120 
121  k1=wn1
122  k2=wn2
123  co=cos(theta)
124  g2=grav**2
125  s3=s1+s2
126  k3=sqrt(k1**2+k2**2+2*k1*k2*co)
127  g=grav
128  sk2=g*k3*tanh(k3*depth)
129 
130  c1=-(k1*k2*co)/(s1*s2)
131  c1b=(s3**2-s1*s2)/g2
132  c2=s3
133  c3=(s3**2-sk2)*s1*s2
134 
135  ! C4 is Hasselmann's D times i
136 
137  c4=s3*(k1*k2*co-((s1*s2)**2)/g2)+0.5*(s1*k2**2+s2*k1**2-s1*s2*(s2**3+s1**3)/g2)
138 
139  df1f2theta=g*(0.5*(c1+c1b)+(c2*c4/c3));
140 
141  RETURN

References constants::grav.

Referenced by w3addig().

◆ w3addig()

subroutine w3gig1md::w3addig ( real, dimension(nspec), intent(inout)  E,
real, intent(in)  DEPTH,
real, dimension(nk), intent(in)  WN,
real, dimension(nk), intent(in)  CG,
integer, intent(in)  IACTION 
)

Definition at line 147 of file w3gig1md.F90.

147  !/
148  !/ +-----------------------------------+
149  !/ | WAVEWATCH III |
150  !/ | A. Rawat and F. Ardhuin |
151  !/ | FORTRAN 90 |
152  !/ | Last update : 05-Jul-2012 |
153  !/ +-----------------------------------+
154  !/
155  !/ 31-Mar-2010 : Origination. ( version 4.07 )
156  !/
157  ! 1. Purpose :
158  !
159  ! This subroutine computes :
160  ! - the second order spectrum, in particular for infragravity waves
161  ! 2. Method :
162  ! Uses 2nd order coupling coefficient (Biesel 1952, Hasselmann 1962)
163  !
164  ! 3. Parameters :
165  !
166  ! Parameter list
167  ! ----------------------------------------------------------------
168  ! E R.A. I/O Energy density spectrum (1-D), f-theta
169  ! DEPTH Real I Water depth
170  ! WN R.A. wavenumbers
171  ! CG R.A. group velocities
172  ! IACTION Int I Switch to specify if the input spectrum
173  ! is E(f,theta) or A(k,theta)
174  ! ----------------------------------------------------------------
175  !
176  ! 4. Subroutines used :
177  !
178  ! Name Type Module Description
179  ! ----------------------------------------------------------------
180  ! STRACE Subr. W3SERVMD Subroutine tracing.
181  ! ----------------------------------------------------------------
182  !
183  ! 5. Called by :
184  !
185  ! Name Type Module Description
186  ! ----------------------------------------------------------------
187  ! W3SREF Subr. W3REF1MD Shoreline reflection source term
188  ! W3EXPO Subr. N/A Point output post-processor.
189  ! ----------------------------------------------------------------
190  !
191  ! 6. Error messages :
192  !
193  ! None.
194  !
195  ! 7. Remarks :
196  !
197  ! 8. Structure :
198  !
199  ! See source code.
200  !
201  ! 9. Switches :
202  !
203  ! !/S Enable subroutine tracing.
204  !
205  ! 10. Source code :
206  !
207  !/ ------------------------------------------------------------------- /
208  USE constants
209  USE w3dispmd
210  USE w3gdatmd, ONLY: nk, nth, nspec, sig, th, dth, dden, &
211  ecos, esin, ec2, mapth, mapwn, &
213 
214 #ifdef W3_S
215  USE w3servmd, ONLY: strace
216 #endif
217  !/
218  !
219  IMPLICIT NONE
220  !/
221  !/ ------------------------------------------------------------------- /
222  !/ Parameter list
223  !/
224  REAL, INTENT(INOUT) :: E(NSPEC)
225  REAL, INTENT(IN) :: DEPTH
226  REAL, INTENT(IN) :: WN(NK)
227  REAL, INTENT(IN) :: CG(NK)
228  INTEGER, INTENT(IN) :: IACTION
229 
230  !*****************************************************************************
231  ! Computes the "second order spectrum" (only difference interaction, not sum)
232  !*****************************************************************************
233  ! Reads in the wave frequency-directional spectrum
234  !
235 
236 
237  INTEGER :: NKIG,iloc,NSPECIG
238  INTEGER :: i,iIG,IFR,IK,ith,ith1,ith2,itime,I2, ISP1, ISP2, ISP3
239  INTEGER , DIMENSION(:,:), ALLOCATABLE :: ifr2c
240 
241  REAL :: d,deltaf,dfIG,CG2
242  REAL :: WN1,K1,K2,Dkx,Dky,Eadd,thetaIG,memo
243 
244  REAL , DIMENSION(:), ALLOCATABLE :: df,fIG,II,Efmall
245  REAL , DIMENSION(:,:), ALLOCATABLE :: wfr1,Efth
246  REAL , DIMENSION(:), ALLOCATABLE :: EfthIG
247  REAL , DIMENSION(:,:,:,:), ALLOCATABLE :: DD
248  REAL , DIMENSION(NSPEC) :: ESPEC
249  CHARACTER(120) ::path,filename,filename2
250 
251 
252  ! Defines the spectral domain for the IG computation
253  nkig=igpars(5)
254  nspecig=nkig*nth
255 
256  ALLOCATE(dd(nkig,nk,nth,nth))
257  ALLOCATE(wfr1(nkig,nk))
258  ALLOCATE(ifr2c(nkig,nk))
259  ALLOCATE(efthig(nspecig))
260  efthig(:)=0.
261 
262  ! WRITE(*,*) 'Computing coupling coefficient for SURFACE ELEVATION'
263 
264  IF (iaction.EQ.0) THEN
265  espec=e
266  ELSE
267  DO ik = 1,nk
268  DO ith = 1, nth
269  isp1=ith+(ik-1)*nth
270  espec(isp1)=e(isp1)*sig(ik)*tpi / cg(ik)
271  END DO
272  END DO
273  END IF
274  !
275  DO iig=1,nkig
276  DO ifr=1,nk
277  CALL wavnu1 (sig(ifr)+sig(iig),depth,wn1,cg2)
278  DO ith1=1,nth
279  DO ith2=1,nth
280  !
281  ! This is the coupling coefficient for the SURFACE ELEVATION. See .e.g. forristall (JPO 2000)
282  !
283  dd(iig,ifr,ith1,ith2)=(df1f2theta(sig(ifr)+sig(iig),-sig(ifr), wn1,wn(ifr), &
284  (abs(th(ith1)-th(ith2))+pi),depth))**2
285 
286  END DO
287  END DO
288  !
289  ! weights
290  !
291  wfr1(iig,ifr)=dble(dsip(ifr))*dth
292  !
293  ! Computes indices for a proper integration over the spectral domain using Rectangle's rule
294  ! since we integrate E(f)*E(f+fIG)*df for a fixed fIG
295 
296  iloc=1
297 
298  if (sig(iig) < 0.5*dsip(ifr))THEN
299  ifr2c(iig,ifr)=ifr
300  else
301  iloc=minloc(abs((sig(1:nk)-dsip(1:nk))-(sig(iig)+sig(ifr))), 1)
302  !find(f-df< (fIG(iIG)+f(ifr)))
303  if (iloc /= 0) THEN
304  ifr2c(iig,ifr)=iloc ! index of frequency f+fIG
305  else
306  ifr2c(iig,ifr)=nk
307  end if
308 
309  !wfr1(iIG,ifr)=0.0
310  end if
311  end do
312  end do
313 
314 
315  DO iig=1,nkig
316  DO ifr = 1,nk-1
317 
318  ! AR calculating k1 and k2 before loops on th1 and th2
319 
320  k1=wn(ifr)
321  k2=wn(ifr2c(iig,ifr))
322 
323  DO ith1 = 1,nth
324  DO ith2 = 1,nth
325 
326  ! Adds the effect of interaction of frequency f(ifr), theta(ith1) with f(ifr)+fIG(:), theta(ith2)
327  isp1 = ith1 + (ifr2c(iig,ifr)-1)*nth
328  isp2 = ith2 + (ifr-1)*nth
329 
330  eadd=dd(iig,ifr,ith1,ith2)*wfr1(iig,ifr) &
331  *espec(isp1)*espec(isp2) ! Rectangle rule by AR
332  dkx=k2*cos(dble(dth*ith2))- k1*cos(dble(dth*ith1))
333  dky=k2*sin(dble(dth*ith2))- k1*sin(dble(dth*ith1))
334 
335  thetaig=atan2(dky,dkx)
336 
337  if (thetaig.LT.0) thetaig=2*pi+thetaig
338  ! Finding corresponding index of theta IG in theta array
339  !I=INT((thetaIG/(2*pi))*nth)
340 
341  i=minloc(abs(thetaig-th), 1)-1
342  if (i==0) i=nth
343  isp3 = i + (iig-1)*nth
344  ! memo=EfthIG(ISP3)
345  efthig(isp3)= efthig(isp3)+eadd;
346  ! IF (EfthIG(ISP3).NE.EfthIG(ISP3).AND.Eadd.NE.0) WRITE(6,*) 'EfthIG:',IIG, IFR, ITH1,ITH2,ISP3, &
347  ! EfthIG(ISP3),Eadd,memo
348  END DO
349  END DO
350  end do
351  end do
352 
353  ! ESPEC(1:NSPECIG)=ESPEC(1:NSPECIG)+EfthIG(:)
354  espec(1:nspecig)=efthig(:)
355 
356  IF (iaction.EQ.0) THEN
357  DO isp1=1,nspecig
358  e(isp1)=espec(isp1)
359  END DO
360  ELSE
361  DO ik = 1,nkig
362  DO ith = 1, nth
363  isp1=ith+(ik-1)*nth
364  e(isp1)=espec(isp1)*cg(ik)/(sig(ik)*tpi)
365  END DO
366  END DO
367  END IF
368 
369  ! OPEN(5555,FILE='testos.dat',status='unknown')
370  ! WRITE(5555,*) E,EfthIG !f,fIG,tet!ifr2c !Efth, !!, Efth,
371 
372  !/
373  !/ End of W3ADDIG ----------------------------------------------------- /
374  !/

References w3gdatmd::dden, df1f2theta(), w3gdatmd::dsip, w3gdatmd::dth, w3gdatmd::ec2, w3gdatmd::ecos, w3gdatmd::esin, w3gdatmd::gtype, w3gdatmd::igpars, w3gdatmd::iobpd, w3gdatmd::mapth, w3gdatmd::mapwn, w3gdatmd::nk, w3gdatmd::nspec, w3gdatmd::nth, constants::pi, w3gdatmd::sig, w3servmd::strace(), w3gdatmd::th, constants::tpi, w3gdatmd::ungtype, and w3dispmd::wavnu1().

Referenced by w3exnc(), w3outp(), and w3ref1md::w3sref().

w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
constants::pi
real, parameter pi
PI Value of Pi.
Definition: constants.F90:71
w3gdatmd::dth
real, pointer dth
Definition: w3gdatmd.F90:1232
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
w3gdatmd::ungtype
integer, parameter ungtype
Definition: w3gdatmd.F90:626
w3gdatmd::mapth
integer, dimension(:), pointer mapth
Definition: w3gdatmd.F90:1231
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3gdatmd::ecos
real, dimension(:), pointer ecos
Definition: w3gdatmd.F90:1234
w3gdatmd::dsip
real, dimension(:), pointer dsip
Definition: w3gdatmd.F90:1234
w3gdatmd::th
real, dimension(:), pointer th
Definition: w3gdatmd.F90:1234
w3gdatmd::esin
real, dimension(:), pointer esin
Definition: w3gdatmd.F90:1234
w3servmd
Definition: w3servmd.F90:3
w3gdatmd::nth
integer, pointer nth
Definition: w3gdatmd.F90:1230
w3gdatmd::iobpd
integer *1, dimension(:,:), pointer iobpd
Definition: w3gdatmd.F90:1130
constants::tpi
real, parameter tpi
TPI 2*Pi.
Definition: constants.F90:72
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3gdatmd::gtype
integer, pointer gtype
Definition: w3gdatmd.F90:1094
w3gdatmd::mapwn
integer, dimension(:), pointer mapwn
Definition: w3gdatmd.F90:1231
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3gdatmd::dden
real, dimension(:), pointer dden
Definition: w3gdatmd.F90:1234
w3gdatmd
Definition: w3gdatmd.F90:16
w3dispmd::wavnu1
subroutine wavnu1(SI, H, K, CG)
Definition: w3dispmd.F90:85
w3gdatmd::igpars
real, dimension(:), pointer igpars
Definition: w3gdatmd.F90:1142
w3gdatmd::ec2
real, dimension(:), pointer ec2
Definition: w3gdatmd.F90:1234
w3dispmd
Definition: w3dispmd.F90:3
constants::grav
real, parameter grav
GRAV Acc.
Definition: constants.F90:61