WAVEWATCH III  beta 0.0.1
w3snl4md Module Reference

Generic shallow-water Boltzmann integral (FBI or TSA). More...

Functions/Subroutines

subroutine insnl4
 It reads look-up tables (generated by gridsetr) if file exists otherwise it must generate the look-up tables file. More...
 
subroutine w3snl4 (A, CG, WN, DEPTH, S, D)
 Interface module for TSA type nonlinear interactions. More...
 
subroutine gridsetr (dep, wka1, cgnrng1)
 This routine sets up the geometric part of the Boltzmann integral. More...
 
subroutine shloxr (dep, wk1x, wk1y, wk3x, wk3y)
 General locus solution for input vectors (wk1x,wk1y). More...
 
subroutine shlocr (dep, wk1x, wk1y, wk3x, wk3y)
 N/A. More...
 
subroutine cplshr (w1x0, w1y0, w2x0, w2y0, w3x0, w3y0, h, csq, irng, krng, kang, ipt)
 Calculates four-wave Boltzmann coupling coefficient in shallow water. More...
 
subroutine optsa2 (nrmn, nrmx, npk, fpk, nbins, wka, cga)
 Splits the Action Density into two parts. More...
 
subroutine snlr_fbi (pha, ialt)
 For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to wave-wave interaction. More...
 
subroutine snlr_tsa (pha, ialt)
 For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to wave-wave interaction. More...
 
subroutine interp2 (X)
 Interpolate bi-linearly to fill in tsa/fbi & diag/diag2 arrays. More...
 
real function wkfnc (f, dep)
 Calculate the Wavenumber k (rad/m) as function of frequency 'f' (Hz) and depth 'dep' (m). More...
 
real function cgfnc (f, dep, cvel)
 Calculate the Group velocity Cg (m/s) as function of frequency 'f' (Hz), depth 'dep' (m) and phase speed 'cvel' (m/s). More...
 

Variables

integer, parameter ismo = 1
 
integer, parameter npts = 30
 
integer, parameter ndep = 37
 
integer nrng
 
integer nzz
 
integer kzone
 
integer nb2fp
 
integer nang
 
integer na2p1
 
integer np2p1
 
real dfrq
 
real f0
 
real ainc
 
real twopi
 
real, dimension(:), allocatable frqa
 
real, dimension(:), allocatable oma
 
real, dimension(:), allocatable angl
 
real, dimension(:), allocatable sinan
 
real, dimension(:), allocatable cosan
 
real, dimension(:), allocatable dep_tbl
 
integer, dimension(:,:,:,:), allocatable kref2_tbl
 
integer, dimension(:,:,:,:), allocatable kref4_tbl
 
integer, dimension(:,:,:,:), allocatable jref2_tbl
 
integer, dimension(:,:,:,:), allocatable jref4_tbl
 
real, dimension(:,:,:,:), allocatable wtk2_tbl
 
real, dimension(:,:,:,:), allocatable wtk4_tbl
 
real, dimension(:,:,:,:), allocatable wta2_tbl
 
real, dimension(:,:,:,:), allocatable wta4_tbl
 
real, dimension(:,:,:,:), allocatable tfac2_tbl
 
real, dimension(:,:,:,:), allocatable tfac4_tbl
 
real, dimension(:,:,:,:), allocatable grad_tbl
 
real, dimension(:,:), allocatable pha_tbl
 
integer, dimension(:,:,:), allocatable kref2
 
integer, dimension(:,:,:), allocatable kref4
 
integer, dimension(:,:,:), allocatable jref2
 
integer, dimension(:,:,:), allocatable jref4
 
real, dimension(:,:,:), allocatable wtk2
 
real, dimension(:,:,:), allocatable wtk4
 
real, dimension(:,:,:), allocatable wta2
 
real, dimension(:,:,:), allocatable wta4
 
real, dimension(:,:,:), allocatable tfac2
 
real, dimension(:,:,:), allocatable tfac4
 
real, dimension(:,:,:), allocatable grad
 
real, dimension(:), allocatable wk2x
 
real, dimension(:), allocatable wk2y
 
real, dimension(:), allocatable wk4x
 
real, dimension(:), allocatable wk4y
 
real, dimension(:), allocatable ds
 
real, dimension(:,:), allocatable ef2
 
real, dimension(:), allocatable ef1
 
real, dimension(:,:), allocatable dens1
 
real, dimension(:,:), allocatable dens2
 
real, dimension(:,:), allocatable tsa
 
real, dimension(:,:), allocatable diag
 
real, dimension(:,:), allocatable fbi
 
real, dimension(:,:), allocatable diag2
 

Detailed Description

Generic shallow-water Boltzmann integral (FBI or TSA).

Interface module for TSA type nonlinear interactions. Based on Resio and Perrie (2008) and Perrie and Resio (2009).

Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Function/Subroutine Documentation

◆ cgfnc()

real function w3snl4md::cgfnc ( real, intent(in)  f,
real, intent(in)  dep,
real, intent(in)  cvel 
)

Calculate the Group velocity Cg (m/s) as function of frequency 'f' (Hz), depth 'dep' (m) and phase speed 'cvel' (m/s).

  This routine uses the identity
         sinh(2x) = 2*tanh(x)/(1-tanh(x)**2)
    to avoid extreme sinh(2x) for large x.
    thus,    2kd/sinh(2kd) = kd(1-tanh(kd)**2)/tanh(kd)
    Group velocity Cg (m/s) is returned in "cgfnc".
Parameters
fFrequency (Hz).
depDepth (m).
cvelPhase speed (m/s).
Returns
cgfnc Group velocity (m/s).
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 5409 of file w3snl4md.F90.

5409  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5410  !/
5411  !/ +-----------------------------------+
5412  !/ | WAVEWATCH III BIO |
5413  !/ | Bash Toulany |
5414  !/ | Michael Casey |
5415  !/ | William Perrie |
5416  !/ | FORTRAN 90 |
5417  !/ | Last update : 12-Apr-2016 |
5418  !/ +-----------------------------------+
5419  !/
5420  !/ 01-Mar-2016 : Origination. ( version 5.13 )
5421  !/
5422  !! it returns: group velocity (m/s) in cgfnc
5423  !!
5424  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5425  !! ------------------------------------------------------------------
5426  !! ==================================================================
5427  !!
5428  !!
5429  !! 1. Purpose :
5430  !!
5431  !! Calculate the Group velocity Cg (m/s) as function of
5432  !! frequency 'f' (Hz), depth 'dep' (m) and phase speed 'cvel' (m/s)
5433  !!
5434  !! 2. Method :
5435  !!
5436  !! This routine uses the identity
5437  !! sinh(2x) = 2*tanh(x)/(1-tanh(x)**2)
5438  !! to avoid extreme sinh(2x) for large x.
5439  !! thus, 2kd/sinh(2kd) = kd(1-tanh(kd)**2)/tanh(kd)
5440  !! Group velocity Cg (m/s) is returned in "cgfnc"
5441  !!
5442  !! 3. Parameters :
5443  !!
5444  !! Parameter list
5445  !! ------------------------------------------------------------------
5446  !! Name Type Scope I/O Description
5447  !! ------------------------------------------------------------------
5448  !! twopi Real Public I = TPI; WW3 2*pi=8.*atan(1.) (radians)
5449  !! ------------------------------------------------------------------
5450  !!
5451  !! --------------------------------------------------------------- &
5452  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5453  !! ----------------------------------------------------------------72
5454  !! ==================================================================
5455  !!
5456  !!
5457  IMPLICIT NONE
5458  !!
5459  !! Parameter list
5460  !! --------------
5461  real, intent(in) :: f, dep, cvel
5462  !!
5463  !! Local variables
5464  !! ---------------
5465  real :: wkd, tkd
5466  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5467  !! ---------------------::-----------------------------------------72
5468  !! ##################################################################
5469  !!------------------------------------------------------------------------------
5470  !!==============================================================================
5471  !!
5472  !!
5473  wkd = twopi * f*dep/cvel !* kd
5474  tkd = tanh(wkd) !* tanh(kd)
5475  cgfnc = 0.5*cvel*(1.+wkd*(1.-tkd**2)/tkd)
5476  !! ------------------------------------------------------------------
5477  !! ==================================================================
5478  !!
5479  RETURN
5480  !!

References twopi.

Referenced by insnl4().

◆ cplshr()

subroutine w3snl4md::cplshr ( real, intent(in)  w1x0,
real, intent(in)  w1y0,
real, intent(in)  w2x0,
real, intent(in)  w2y0,
real, intent(in)  w3x0,
real, intent(in)  w3y0,
real, intent(in)  h,
real, intent(out)  csq,
integer, intent(in)  irng,
integer, intent(in)  krng,
integer, intent(in)  kang,
integer, intent(in)  ipt 
)

Calculates four-wave Boltzmann coupling coefficient in shallow water.

Calculates four-wave Boltzmann coupling coefficient in shallow water given k1,k2,k3 and following at least Hasselmann (1962) and probably Herterich and Hasselmann (1982). Dimensional wavenumbers are (wnx0,wny0), n = 1,3, h = depth, csq = coupling coefficient. This is the same as Don's cplesh, except within the algorithm, wavenumbers are made dimensionless with h and frequencies with sqrt(h/g), g = gravitational acceleration (the idea is to simplify and speed up the calculations while keeping a reasonable machine resolution of the result). At the end, dimensionless csqhat is redimensioned as csq = csqhat/(h**6) so it is returned as a dimensional entity.

This calculation can be a touchy bird, so we use double precision for internal calculations, using single precision for input and output.

Parameters
[in]w1x0
[in]w1y0
[in]w2x0
[in]w2y0
[in]w3x0
[in]w3y0
[in]h
[out]csq
[in]irng
[in]krng
[in]kang
[in]ipt
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 2876 of file w3snl4md.F90.

2876  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2877  !/
2878  !/ +-----------------------------------+
2879  !/ | WAVEWATCH III BIO |
2880  !/ | Bash Toulany |
2881  !/ | Michael Casey |
2882  !/ | William Perrie |
2883  !/ | FORTRAN 90 |
2884  !/ | Last update : 12-Apr-2016 |
2885  !/ +-----------------------------------+
2886  !/
2887  !/ 01-Mar-2016 : Origination. ( version 5.13 )
2888  !/
2889  !!
2890  !! it returns: the coupling coefficient csq
2891  !!
2892  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2893  !! ------------------------------------------------------------------
2894  !! ==================================================================
2895  !!
2896  !!
2897  !! 1. Purpose :
2898  !!
2899  !! -----------------------------------------------------------------#
2900  !! !
2901  !! Calculates four-wave Boltzmann coupling coefficient in shallow !
2902  !! water given k1,k2,k3 and following at least Hasselmann (1962) !
2903  !! and probably Herterich and Hasselmann (1982). Dimensional !
2904  !! wavenumbers are (wnx0,wny0), n = 1,3, h = depth, csq = coupling !
2905  !! coefficient. This is the same as Don's cplesh, except within !
2906  !! the algorithm, wavenumbers are made dimensionless with h and !
2907  !! frequencies with sqrt(h/g), g = gravitational acceleration (the !
2908  !! idea is to simplify and speed up the calculations while keeping !
2909  !! a reasonable machine resolution of the result). At the end, !
2910  !! dimensionless csqhat is redimensioned as csq = csqhat/(h**6) !
2911  !! so it is returned as a dimensional entity. !
2912  !! !
2913  !! This calculation can be a touchy bird, so we use double precision!
2914  !! for internal calculations, using single precision for input and !
2915  !! output. !
2916  !! !
2917  !! -----------------------------------------------------------------#
2918  !!
2919  !! 2. Method :
2920  !!
2921  !! 3. Parameters :
2922  !!
2923  !! Parameter list
2924  !! ------------------------------------------------------------------
2925  !! Name Type Scope I/O Description
2926  !! ------------------------------------------------------------------
2927  !! ------------------------------------------------------------------
2928  !!
2929  !! 4. Subroutines used :
2930  !!
2931  !! Name Type Module Description
2932  !! ------------------------------------------------------------------
2933  !! ------------------------------------------------------------------
2934  !!
2935  !! 5. Called by :
2936  !!
2937  !! Name Type Module Description
2938  !! ------------------------------------------------------------------
2939  !! gridsetr Subr. W3SNL4MD Setup geometric integration grid
2940  !! ------------------------------------------------------------------
2941  !!
2942  !! 6. Error messages :
2943  !!
2944  !! None.
2945  !!
2946  !! 7. Remarks :
2947  !!
2948  !! 8. Structure :
2949  !!
2950  !! See source code.
2951  !!
2952  !! 9. Switches :
2953  !!
2954  !! !/S Enable subroutine tracing.
2955  !!
2956  !!10. Source code :
2957  !!
2958  !! --------------------------------------------------------------- &
2959  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2960  !! ----------------------------------------------------------------72
2961  !! ==================================================================
2962  !!
2963  !!
2964  IMPLICIT NONE
2965  !!
2966  !! Parameter list
2967  !! --------------
2968  integer, intent(in) :: irng,krng, kang,ipt
2969  real, intent(in) :: w1x0,w1y0, w2x0,w2y0, w3x0,w3y0
2970  real, intent(in) :: h !* depth 'dep'
2971  real, intent(out) :: csq
2972  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2973  !! ------------------------------------------------------------------
2974  !!
2975  !!
2976  !! Local Parameters & variables
2977  !! -----------------------------
2978  integer :: ipass
2979  double precision :: hh
2980  double precision :: s1, s2, s3
2981  double precision :: k1x, k2x, k3x
2982  double precision :: k1y, k2y, k3y
2983  double precision :: k1, k2, k3
2984  double precision :: om1, om2, om3
2985  double precision :: som1, som2, som3
2986  double precision :: om1sq, om2sq, om3sq
2987  double precision :: k23, k23x, k23y
2988  double precision :: dot23, dot123
2989  double precision :: omsq23
2990  !!mpc
2991  double precision :: k1sq, k2sq, k3sq, k23sq
2992  double precision :: tanh_k1, tanh_k2, tanh_k3, tanh_k23
2993  !!mpc---
2994  double precision :: k1x0, k2x0, k3x0, k1zx
2995  double precision :: k1y0, k2y0, k3y0, k1zy
2996  double precision :: di, e
2997  double precision :: p1, p2, p3, p4
2998  double precision :: t1, t2, t3, t4, t5
2999  !!
3000  double precision :: csqhatd, csqd
3001  double precision :: scple
3002  double precision :: pi4
3003  !!
3004  !!eps Bash; added +eps to avoid dividing by 0.0. Dividing by 0.0 causes NaN
3005  !eps double precision :: eps
3006  !!
3007  !! Bash; Added domsq23 = denominator of t1 in cplshr
3008  !! and sumom = denominator of csqhatd in cplshr
3009  double precision :: domsq23, sumom
3010  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3011  !! ---------------------::-----------------------------------------72
3012  !! ##################################################################
3013  !!------------------------------------------------------------------------------
3014  !!==============================================================================
3015  !!
3016  !!
3017  !! initial constants
3018  !! ------------------
3019  hh = dble(h) !* single to dbl precision
3020  pi4 = 0.785398175d0 !* Set = PI/4 as in CONSTANTS
3021  !eps eps = 1.d-12 !* set eps to a very small number
3022  scple = 0.d0 !* initialize accumulator
3023  !!ini
3024  !! initialize returned variable 'csq'
3025  !! ----------------------------------
3026  csq = 0.d0
3027  !!ini---
3028  !! ------------------------------------------------------------------
3029  !!
3030  do ipass=1,3
3031  !p1
3032  if (ipass .eq. 1) then !* initial pass (+1,+1,-1)
3033  s1 = 1.d0
3034  s2 = 1.d0
3035  s3 = -1.d0
3036  k1x0 = dble(w1x0) * hh !* norm. k elements with h
3037  k1y0 = dble(w1y0) * hh
3038  k2x0 = dble(w2x0) * hh
3039  k2y0 = dble(w2y0) * hh
3040  k3x0 = dble(w3x0) * hh
3041  k3y0 = dble(w3y0) * hh
3042  !p1
3043  !p2
3044  else if (ipass .eq. 2) then !* 1st permutation (+1,-1,+1)
3045  s1 = 1.d0
3046  s2 = -1.d0
3047  s3 = 1.d0
3048  k1zx = k1x0
3049  k1zy = k1y0
3050  k1x0 = k2x0
3051  k1y0 = k2y0
3052  k2x0 = k3x0
3053  k2y0 = k3y0
3054  k3x0 = k1zx
3055  k3y0 = k1zy
3056  !p2
3057  !p3
3058  else !* 2nd permutation (-1,+1,+1)
3059  s1 = -1.d0
3060  s2 = 1.d0
3061  s3 = 1.d0
3062  k1zx = k1x0
3063  k1zy = k1y0
3064  k1x0 = k2x0
3065  k1y0 = k2y0
3066  k2x0 = k3x0
3067  k2y0 = k3y0
3068  k3x0 = k1zx
3069  k3y0 = k1zy
3070  !p3
3071  end if
3072  !!k19p1
3073  !!k19p1 Note: na2p1=nang/2+1 !* this is the angle index opposite to iang=1
3074  !k19p1 if (krng.ne.irng .and. kang.eq.na2p1 .and. ipt.eq.1 .and. &
3075  !k19p1 ipass.eq.1) go to 10
3076  !!k19p1---
3077  !!
3078  k1x = s1 * k1x0 !* sign the norm'ed k parts
3079  k1y = s1 * k1y0
3080  k2x = s2 * k2x0
3081  k2y = s2 * k2y0
3082  k3x = s3 * k3x0
3083  k3y = s3 * k3y0
3084  !!mpc
3085  !mpc k1 = dsqrt(k1x**2 + k1y**2) !* normalized |k|
3086  !mpc k2 = dsqrt(k2x**2 + k2y**2)
3087  !mpc k3 = dsqrt(k3x**2 + k3y**2)
3088  !!mpc---
3089  k1sq = (k1x*k1x + k1y*k1y) !* normalized |k| **2
3090  k2sq = (k2x*k2x + k2y*k2y)
3091  k3sq = (k3x*k3x + k3y*k3y)
3092  k1 = dsqrt(k1sq) !* normalized |k|
3093  k2 = dsqrt(k2sq)
3094  k3 = dsqrt(k3sq)
3095  !!mpc---
3096  !!
3097  !!mpc
3098  !mpc om1 = dsqrt(k1*dtanh(k1)) !* norm. omega (by sqrt(h/g))
3099  !mpc om2 = dsqrt(k2*dtanh(k2))
3100  !mpc om3 = dsqrt(k3*dtanh(k3))
3101  !mpc om1sq = om1**2
3102  !mpc om2sq = om2**2
3103  !mpc om3sq = om3**2
3104  !!mpc---
3105  tanh_k1 = dtanh(k1)
3106  tanh_k2 = dtanh(k2)
3107  tanh_k3 = dtanh(k3)
3108  om1sq = k1*tanh_k1
3109  om2sq = k2*tanh_k2
3110  om3sq = k3*tanh_k3
3111  om1 = dsqrt(om1sq) !* norm. omega (by sqrt(h/g))
3112  om2 = dsqrt(om2sq)
3113  om3 = dsqrt(om3sq)
3114  !!mpc---
3115  !!
3116  som1 = s1 * om1 !* sign the norm'ed omega's
3117  som2 = s2 * om2
3118  som3 = s3 * om3
3119  !! ----------------------------------------------------------------
3120  !! ================================================================
3121  !!
3122  !!
3123  dot23 = k2x*k3x + k2y*k3y !* vector k2 dot vector k3
3124  !!
3125  k23x = k2x + k3x !* (vector k2 + vector k3)_x
3126  k23y = k2y + k3y !* (vector k2 + vector k3)_y
3127  !!
3128  !!mpc
3129  !mpc k23 = dsqrt(k23x**2+k23y**2) !* |vector k2 + vector k3|
3130  !!mpc---
3131  k23sq = (k23x*k23x + k23y*k23y)
3132  k23 = dsqrt(k23sq) !* |vector k2 + vector k3|
3133  !!mpc---
3134  !!
3135  !!mpc
3136  !mpc omsq23 = k23 * dtanh(k23) !* norm sq frq of v.k2+v.k3
3137  !!mpc---
3138  tanh_k23 = dtanh(k23)
3139  omsq23 = k23 * tanh_k23 !* norm sq frq of v.k2+v.k3
3140  !!mpc---
3141  !!
3142  dot123 = k1x*k23x + k1y*k23y !* v.k1 dot (v.k2 + v.k3)
3143  !! ----------------------------------------------------------------
3144  !!
3145  !! note: the "i**2" factor from some reference is included in this term
3146  !!
3147  !!mpc
3148  !mpc di = -(som2+som3)*(om2sq*om3sq-dot23)+0.5d0 * &
3149  !mpc (som2*(k3**2-om3sq**2)+som3*(k2**2-om2sq**2))
3150  !!mpc---
3151  di = -(som2+som3)*(om2sq*om3sq-dot23)+0.5d0 * &
3152  (som2*(k3sq-om3sq*om3sq)+som3*(k2sq-om2sq*om2sq))
3153  !!mpc---
3154  !!
3155  e = 0.5d0*(dot23-som2*som3*(om2sq+om3sq+som2*som3))
3156  !!
3157  p1 = 2.d0 * (som1+som2+som3) * (om1sq*omsq23 - dot123)
3158  !!
3159  !!mpc
3160  !mpc p2 = -som1 * (k23**2 - omsq23**2)
3161  !mpc p3 = -(som2+som3) * (k1**2 - om1sq**2)
3162  !mpc p4 = k1**2 - om1sq**2
3163  !!mpc---
3164  !! equation p2 rewritten to preserve numerical precision
3165  !! equations p3, p4 rearranged to avoid recomputations.
3166  p2 = -som1 * (k23sq*(1 - tanh_k23*tanh_k23))
3167  p4 = (k1sq*(1-tanh_k1*tanh_k1))
3168  p3 = -(som2+som3) * p4
3169  !!mpc---
3170  !! ----------------------------------------------------------------
3171  !!
3172  !! Bash; added & used variable domsq23 = denominator of t1
3173  domsq23 = omsq23 - ((som2+som3)**2) !* Bash; needed for test below
3174  !! ----------------------------------------------------------------
3175  !!
3176  !!cp4 Bash; with !cp4 ON, test if ( domsq23 .eq. 0.d0 )
3177  !cp4 if ( domsq23 .eq. 0.d0 ) then !* Bash; this test was needed
3178  !! !* when !k19p1 & !hv were OFF
3179  !! domsq23=0.0 Dividing by 0.0 causes NaN; here we avoid it
3180  !cp4 t1 = 0.d0
3181  !eps t1 = di * (p1+p2+p3) / (domsq23+eps) !* Add eps to denominator
3182  !! !* and may be to numerator
3183  !cp4 endif
3184  !!cp4---
3185  !! Bash; with !cp4 OFF, don't test if ( domsq23 .eq. 0.d0 )
3186  !! domsq23 is not = 0.0 (when !k19p1 & !hv were OFF)
3187  !b t1 = di * (p1+p2+p3) / (omsq23 - ((som2+som3)**2))
3188  t1 = di * (p1+p2+p3) / (domsq23)
3189  !!cp4---
3190  !! ----------------------------------------------------------------
3191  !!
3192  t2 = -di * som1 * (om1sq+omsq23)
3193  t3 = e * ((som1**3) * (som2+som3) - dot123 - p4)
3194  t4 = 0.5d0 * som1 * dot23 * &
3195  ((som1+som2+som3) * (om2sq+om3sq) + som2*som3*(som2+som3))
3196  !!
3197  !!mpc
3198  !mpc t5 = -0.5d0 * som1 * &
3199  !mpc (om2sq * (k3**2) * (som1+som2 + 2.d0 * som3) + &
3200  !mpc om3sq * (k2**2) * (som1+som3 + 2.d0 * som2))
3201  !!mpc---
3202  t5 = -0.5d0 * som1 * &
3203  (om2sq * (k3sq) * (som1+som2 + 2.d0 * som3) + &
3204  om3sq * (k2sq) * (som1+som3 + 2.d0 * som2))
3205  !!mpc---
3206  !!
3207  scple = scple + t1 + t2 + t3 + t4 + t5
3208  !!
3209  end do ! do ipass=1,3
3210  !! ------------------------------------------------------------------
3211  !! ==================================================================
3212  !!
3213  !!as HH did division by 3 after adding 3 terms
3214  !as scple = scple/3.d0
3215  !!as---
3216  !!
3217  !! Bash; Added sumom = denominator of csqhatd in cplshr
3218  sumom = om1*om2*om3*(om2+om3-om1)
3219  !b csqhatd = scple*scple*pi4/(om1*om2*om3*(om2+om3-om1)) !* Bash; ok
3220  csqhatd = scple*scple*pi4/(sumom)
3221  !! ------------------------------------------------------------------
3222  !!
3223  csqd = csqhatd / (hh**6)
3224  csq = sngl(csqd) !* from dbl to single precision
3225  !! ------------------------------------------------------------------
3226  !! ==================================================================
3227  !!
3228  RETURN
3229  !!

Referenced by gridsetr().

◆ gridsetr()

subroutine w3snl4md::gridsetr ( real, intent(in)  dep,
real, dimension(nrng), intent(in)  wka1,
real, intent(in)  cgnrng1 
)

This routine sets up the geometric part of the Boltzmann integral.

This routine sets up the geometric part of the Boltzmann integral based on a grid of wave frequencies and directions, with wave- numbers related to frequency and depth by linear dispersion. It is adapted from Don's original code with changes to modify the indexing so there are fewer unused elements, and a number of algo- rithmic changes that are mathematically equivalent to Don's but take advantage of intrinsic functions to form smooth results with less reliance on if statements.

It calls locus-solving routines shloxr and shlocr and coupling coefficient routine cplshr. If shlocr does not converge, ierr_gr will be something other than 0 and the routine will terminate, returning ierr_gr to the calling program (see shlocr).

It returns array grad(,,), which is an estimate of the product C(k1,k2,k3,k4)*H(k1,k3,k4)*ds/|dW/dn| (where n and the k's are all vectors) as given, for example, by Eq.(7) of 'Nonlinear energy fluxes and the finite depth equilibrium range in wave spectra,' by Resio, Pihl, Tracy and Vincent (2001, JGR, 106(C4), p. 6985), as well as arrays for indexing, interpolating and weighting locus- based wavenumber vectors within the discrete solution grid.

Parameters
[in]depDepth (m)
[in]wka1Wavenumber array at one depth dim=(nrng)
[in]cgnrng1Group velocity at nrng at one depth.
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 1481 of file w3snl4md.F90.

1481  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1482  !/
1483  !/ +-----------------------------------+
1484  !/ | WAVEWATCH III BIO |
1485  !/ | Bash Toulany |
1486  !/ | Michael Casey |
1487  !/ | William Perrie |
1488  !/ | FORTRAN 90 |
1489  !/ | Last update : 12-Apr-2016 |
1490  !/ +-----------------------------------+
1491  !/
1492  !/ 01-Mar-2016 : Origination. ( version 5.13 )
1493  !/
1494  !! ------------------------------------------------------------------
1495  !!
1496  !! it returns: kref2,kref4, jref2,jref4, wtk2,wtk4, wta2,wta4,
1497  !! tfac2,tfac4 and grad all dim=(npts,nang,nzz)
1498  !!
1499  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1500  !! ------------------------------------------------------------------
1501  !! ==================================================================
1502  !!
1503  !!
1504  !! 1. Purpose :
1505  !!
1506  !! -------------------------------------------------------------------------#
1507  !! !
1508  !! This routine sets up the geometric part of the Boltzmann integral !
1509  !! based on a grid of wave frequencies and directions, with wave- !
1510  !! numbers related to frequency and depth by linear dispersion. It !
1511  !! is adapted from Don's original code with changes to modify the !
1512  !! indexing so there are fewer unused elements, and a number of algo- !
1513  !! rithmic changes that are mathematically equivalent to Don's but !
1514  !! take advantage of intrinsic functions to form smooth results with !
1515  !! less reliance on if statements. !
1516  !! !
1517  !! It calls locus-solving routines shloxr and shlocr and coupling !
1518  !! coefficient routine cplshr. If shlocr does not converge, ierr_gr !
1519  !! will be something other than 0 and the routine will terminate, !
1520  !! returning ierr_gr to the calling program (see shlocr). !
1521  !! !
1522  !! It returns array grad(,,), which is an estimate of the product !
1523  !! C(k1,k2,k3,k4)*H(k1,k3,k4)*ds/|dW/dn| (where n and the k's are all !
1524  !! vectors) as given, for example, by Eq.(7) of 'Nonlinear energy !
1525  !! fluxes and the finite depth equilibrium range in wave spectra,' !
1526  !! by Resio, Pihl, Tracy and Vincent (2001, JGR, 106(C4), p. 6985), !
1527  !! as well as arrays for indexing, interpolating and weighting locus- !
1528  !! based wavenumber vectors within the discrete solution grid. !
1529  !! -------------------------------------------------------------------------#
1530  !!
1531  !!
1532  !! 2. Method :
1533  !!
1534  !! 3. Parameters :
1535  !!
1536  !! Parameter list
1537  !! ------------------------------------------------------------------
1538  !! Name Type Scope I/O Description
1539  !! ------------------------------------------------------------------
1540  !! nrng int. Public I # of freq. or rings
1541  !! nang int. Public I # of angles
1542  !! npts int. Public I # of points on the locus
1543  !! nzz int. Public I linear irngxkrng = (NK*(NK+1))/2
1544  !! kzone int. Public I zone of influence = INT(alog(4.0)/alog(dfrq))
1545  !! na2p1 int. Public I = nang/2 + 1
1546  !! np2p1 int. Public I = npts/2 + 1
1547  !! ------------------------------------------------------------------
1548  !!
1549  !! dfrq Real Public I frequency multiplier for log freq. spacing
1550  !! f0 Real Public I = frqa(1); first freq. (Hz)
1551  !! twopi Real Public I = TPI; WW3i 2*pi = 8.*atan(1.) (radians)
1552  !! ainc Real Public I = DTH; WW3 angle increment (radians)
1553  !! dep Real local I = depth (m)
1554  !! frqa R.A. Public I = oma(:)/twopi WW3 frequency array dim=(nrng)
1555  !! angl R.A. Public I = TH(1:NTH); WW3 angles array dim=(nang)
1556  !! sinan R.A. Public I = ESIN(1:NTH); WW3 sin(angl(:)) array dim=(nang)
1557  !! cosan R.A. Public I = ECOS(1:NTH); WW3 cos(angl(:)) array dim=(nang)
1558  !! wka1 R.A. local I = wavenumber array at one depth dim=(nrng)
1559  !! cgnrng1 Real local I = Group Vel. at nrng at one depth
1560  !! ------------------------------------------------------------------
1561  !!
1562  !! *** The 11 grid integration geometry arrays at one given depth
1563  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
1564  !! kref2 I.A. Public O Index of reference wavenumber for k2
1565  !! kref4 I.A. Public O Idem for k4
1566  !! jref2 I.A. Public O Index of reference angle for k2
1567  !! jref4 I.A. Public O Idem for k4
1568  !! wtk2 R.A. Public O k2 Interpolation weigth along wavenumbers
1569  !! wtk4 R.A. Public O Idem for k4
1570  !! wta2 R.A. Public O k2 Interpolation weigth along angles
1571  !! wta4 R.A. Public O Idem for k4
1572  !! tfac2 R.A. Public O Norm. for interp Action Density at k2
1573  !! tfac4 R.A. Public O Idem for k4
1574  !! grad R.A. Public O Coupling and gradient term in integral
1575  !! grad = C * H * g**2 * ds / |dW/dn|
1576  !! ------------------------------------------------------------------
1577  !!
1578  !! 4. Subroutines used :
1579  !!
1580  !! Name Type Module Description
1581  !! ------------------------------------------------------------------
1582  !! shloxr Subr. W3SERVMD General locus solution for input vectors
1583  !! k1 & k3 when |k1| .eq. |k3|
1584  !! shlocr Subr. W3SERVMD General locus solution for input vectors
1585  !! k1 & k3 when |k1| .ne. |k3|
1586  !! cplshr Subr. W3SERVMD Calculates Boltzmann coupling coefficient
1587  !! in shallow water
1588  !! ------------------------------------------------------------------
1589  !!
1590  !! 5. Called by :
1591  !!
1592  !! Name Type Module Description
1593  !! ------------------------------------------------------------------
1594  !! insnl4 Subr. W3SNL4MD initialize the grid geometry
1595  !! ------------------------------------------------------------------
1596  !!
1597  !! 6. Error messages :
1598  !!
1599  !! None.
1600  !!
1601  !! 7. Remarks :
1602  !!
1603  !! 8. Structure :
1604  !!
1605  !! See source code.
1606  !!
1607  !! 9. Switches :
1608  !!
1609  !! !/S Enable subroutine tracing.
1610  !!
1611  !!10. Source code :
1612  !!
1613  !! --------------------------------------------------------------- &
1614  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1615  !! ----------------------------------------------------------------72
1616  !! ==================================================================
1617  !!
1618  !!
1619  IMPLICIT NONE
1620  !!
1621  !! Parameter list
1622  !! --------------
1623  real, intent(in) :: dep
1624  real, intent(in) :: wka1(nrng), cgnrng1 !* Use new names locally
1625  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1626  !! ------------------------------------------------------------------
1627  !!
1628  !!
1629  !! Local Parameters & variables
1630  !! -----------------------------
1631  integer :: irng,krng, iang,kang, ipt
1632  integer :: iizz, izz, ir, i
1633  integer :: kmax !* = min(irng+kzone, nrng)
1634  !!
1635  real :: g, gsq
1636  real :: alf0,aldfrq, wk1x,wk1y, wk3x,wk3y
1637  !!
1638  real :: wn2,th2, wn2d,tnh2, om2,f2,cg2, tt2,w2
1639  real :: wn4,th4, wn4d,tnh4, om4,f4,cg4, tt4,w4
1640  real :: dWdnsq,dWdn, dif13,dif14, er
1641  !!
1642  !!hv Bash; with !hv ON, move Heaviside section up & don't use var Heaviside
1643  !hv real :: Heaviside
1644  !!hv---
1645  !!
1646  real :: csq
1647  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1648  !! ---------------------::-----------------------------------------72
1649  !! ##################################################################
1650  !!------------------------------------------------------------------------------
1651  !!==============================================================================
1652  !!
1653  !!
1654  !! initial constants
1655  !! ------------------
1656  g = 9.806 !* set = GRAV as in CONSTANTS
1657  gsq = 96.157636 !* set = GRAV**2
1658  !!
1659  alf0 = alog(frqa(1)) !* ln(f0) for ir calc. below
1660  aldfrq = alog(dfrq) !* ln(dfrq) "
1661  !!
1662  !!ini
1663  !! initialize array grad
1664  !! ----------------------
1665  grad(:,:,:) = 0.0
1666  kref2(:,:,:) = 0
1667  kref4(:,:,:) = 0
1668  jref2(:,:,:) = 0
1669  jref4(:,:,:) = 0
1670  wtk2(:,:,:) = 0.0
1671  wtk4(:,:,:) = 0.0
1672  wta2(:,:,:) = 0.0
1673  wta4(:,:,:) = 0.0
1674  tfac2(:,:,:) = 0.0
1675  tfac4(:,:,:) = 0.0
1676  !!ini---
1677  !!------------------------------------------------------------------------------
1678  !!
1679  !!
1680  !! irng and iang are k1 parameters; krng and kang are k3 parameters
1681  iang = 1 !* set = 1 and will remain = 1
1682  !!
1683  !!20
1684  do 20 irng=1,nrng
1685  !!kz
1686  kmax = min(irng+kzone, nrng) !* Bash; Sometimes a locus pt is outside nrng
1687  !kz kmax = min(irng+kzone, nrng-1) !* Bash; Taking 1 out will not affect kzone, try it
1688  !!kz---
1689  !!kz---
1690  !!
1691  wk1x = wka1(irng)
1692  wk1y = 0.0 !* set = 0.0 and will remain = 0.0
1693  iizz = (nrng-1)*(irng-1)-((irng-2)*(irng-1))/2
1694  !!30
1695  !!kz
1696  do 30 krng=irng,kmax
1697  !!kz---
1698  !kz do 30 krng=irng,nrng
1699  !!
1700  !! Bash; check1 - change this ratio from > 4 to > 3 and
1701  !! make it consistent with similar test done in subr. snlr_'s
1702  !kz if ( frqa(krng)/frqa(irng) .gt. 2. ) go to 30 !* Bash; use .gt. 2 for speed
1703  !kz if ( frqa(krng)/frqa(irng) .gt. 3. ) go to 30 !* original snlr_'s
1704  !kz if ( frqa(krng)/frqa(irng) .gt. 4. ) go to 30 !* original gridsetr
1705  !!kz---
1706  izz = krng+iizz
1707  !!40
1708  do 40 kang=1,nang
1709  !!
1710  wk3x = wka1(krng)*cosan(kang)
1711  wk3y = wka1(krng)*sinan(kang)
1712  !!
1713  if ( krng.eq.irng ) then !* wn3 = wn1
1714  !!
1715  !!ba1 Bash; skip k1 but keep the opposite angle to k1 - orig setting
1716  !!ba1 remember here iang = 1
1717  if ( kang .eq. 1 ) go to 40 !* th3 = th1
1718  !!ba1---
1719  !! ----------------------------------------------------------
1720  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1721  call shloxr ( dep, wk1x,wk1y,wk3x,wk3y )
1722  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1723  !! it returns: wk2x, wk2y, wk4x, wk4y & ds all dim=(npts)
1724  !! and all are PUBLIC
1725  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1726  !! ----------------------------------------------------------
1727  !!
1728  else !* wn3 > wn1
1729  !!
1730  !! ----------------------------------------------------------
1731  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1732  call shlocr ( dep, wk1x,wk1y,wk3x,wk3y )
1733  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1734  !! it returns: wk2x, wk2y, wk4x, wk4y & ds all dim=(npts)
1735  !! and all are PUBLIC
1736  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1737  !! ----------------------------------------------------------
1738  !!
1739  end if !! if ( krng.eq.irng )
1740  !!
1741  !! set the Heaviside coefficient
1742  !b dif13 = (wk1x-wk3x)**2 + (wk1y-wk3y)**2 !* wk1y = 0.0
1743  !b dif13 = (wk1x-wk3x)**2 + (wk3y)**2
1744  dif13 = (wk1x-wk3x)*(wk1x-wk3x) + wk3y*wk3y
1745  !!50
1746  do 50 ipt=1,npts
1747  !!
1748  !!xlc1 Bash; skip k1 but keep the opposite angle to k1 - original setting
1749  if ( kang.eq.1 ) then !* th3=+th1, iang=1
1750  if (ipt.eq.1 .or. ipt.eq.np2p1) go to 50 !* skip x-axis loci
1751  end if
1752  !!xlc1---
1753  !! ----------------------------------------------------------
1754  !!
1755  !!hv Bash; with !hv ON, move Heaviside section from below to here
1756  !! Bash moved this section here. *** Check first compute after ***
1757  !! Skip first then compute only if Heaviside=1, without using it
1758  !! i.e. compute only if dif13.le.dif14 with Heaviside=1 omitted.
1759  !! Note; with !hv option is ON, you don't need to turn options
1760  !! ---- !k19p1 nor !cp4 ON.aYou only need one of the three.
1761  !! ----------------------------------------------------------
1762  !! set the Heaviside coefficient
1763  !b dif14 = (wk1x-wk4x(ipt))**2 + (wk1y-wk4y(ipt))**2 !* wk1y=0.0
1764  !b dif14 = (wk1x-wk4x(ipt))**2 + (wk4y(ipt))**2
1765  dif14 = (wk1x-wk4x(ipt))*(wk1x-wk4x(ipt)) + &
1766  wk4y(ipt)*wk4y(ipt)
1767  !!
1768  if ( dif13 .gt. dif14 ) go to 50 !* skip, don't compute
1769  !!
1770  !b if ( dif13 .gt. dif14 ) then
1771  !b Heaviside = 0. !* Eq(12) of RPTV
1772  !b go to 50
1773  !b else
1774  !b Heaviside = 1. !* Eq(11) of RPTV
1775  !b end if
1776  !!hv---
1777  !! ----------------------------------------------------------
1778  !!
1779  !! Set the coupling coefficient for ipt'th locus position
1780  !! ----------------------------------------------------------
1781  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1782  call cplshr ( wk4x(ipt),wk4y(ipt), wk3x,wk3y, &
1783  wk2x(ipt),wk2y(ipt), dep, csq, &
1784  irng,krng,kang,ipt )
1785  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1786  !! it returns: the coupling coefficient csq
1787  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1788  !! ----------------------------------------------------------
1789  !!
1790  !!wn2 Set parameters related to ipt'th locus wavenumber vector k2
1791  !! ----------------------------------------------------------
1792  !b wn2 = sqrt(wk2x(ipt)**2 + wk2y(ipt)**2) !* k2
1793  wn2 = sqrt(wk2x(ipt)*wk2x(ipt) + wk2y(ipt)*wk2y(ipt)) !* k2
1794  th2 = atan2(wk2y(ipt),wk2x(ipt)) !* k2 direction
1795  if ( th2 .lt. 0. ) th2 = th2 + twopi !* +ve in radians
1796  wn2d = wn2*dep !* k2*depth
1797  tnh2 = tanh(wn2d) !* tanh(k2*depth)
1798  om2 = sqrt(g*wn2*tnh2) !* omega2 (rad)
1799  !b cg2 = 0.5*(om2/wn2)*(1.+wn2d*(1.-tnh2**2)/tnh2) !* group velocity
1800  cg2 = 0.5*(om2/wn2)*(1.+wn2d*((1./tnh2)-tnh2)) !* group velocity
1801  f2 = om2/twopi !* f2 (Hz)
1802  !! ----------------------------------------------------------
1803  !!
1804  !!wn4 Set parameters related to ipt'th locus wavenumber vector k4
1805  !! ----------------------------------------------------------
1806  !b wn4 = sqrt(wk4x(ipt)**2 + wk4y(ipt)**2)
1807  wn4 = sqrt(wk4x(ipt)*wk4x(ipt) + wk4y(ipt)*wk4y(ipt))
1808  th4 = atan2(wk4y(ipt),wk4x(ipt))
1809  if ( th4 .lt. 0. ) th4 = th4 + twopi
1810  wn4d = wn4*dep
1811  tnh4 = tanh(wn4d)
1812  om4 = sqrt(g*wn4*tnh4)
1813  !b cg4 = 0.5*(om4/wn4)*(1.+wn4d*(1.-tnh4**2)/tnh4)
1814  cg4 = 0.5*(om4/wn4)*(1.+wn4d*((1./tnh4)-tnh4))
1815  f4 = om4/twopi
1816  !! ----------------------------------------------------------
1817  !!
1818  !!
1819  !!hv Bash; with !hv ON, move Heaviside section up
1820  !! Bash moved this section up. Check first compute after.
1821  !! ----------------------------------------------------------
1822  !! set the Heaviside coefficient
1823  !b dif14 = (wk1x-wk4x(ipt))**2 + (wk1y-wk4y(ipt))**2 !* wk1y=0.0
1824  !b dif14 = (wk1x-wk4x(ipt))**2 + (wk4y(ipt))**2
1825  !hv dif14 = (wk1x-wk4x(ipt))*(wk1x-wk4x(ipt)) + &
1826  !hv wk4y(ipt)*wk4y(ipt)
1827  !hv if ( dif13 .gt. dif14 ) then
1828  !hv Heaviside = 0. !* Eq(12) of RPTV
1829  !hv else
1830  !hv Heaviside = 1. !* Eq(11) of RPTV
1831  !hv end if
1832  !!hv---
1833  !! ----------------------------------------------------------
1834  !!
1835  !!
1836  !! dWdn is the same as sqrt(zzsum) in Don's code, here reduced to a
1837  !! simpler but mathematically equivalent form that should vary
1838  !! smoothly between deep and intermediate water owing to identities
1839  !! using the computer's tanh() function
1840  !! ----------------------------------------------------------
1841  !!
1842  !! set grad(,,);
1843  !! looks like the g^2 goes with csq (Webb'1978, eq. A2)
1844  !! ----------------------------------------------------------
1845  !!
1846  !b dWdnsq = cg2**2 - 2.*cg2*cg4 * cos(th2-th4) + cg4**2
1847  dwdnsq = cg2*cg2 - 2.*cg2*cg4 * cos(th2-th4) + cg4*cg4
1848  !! ----------------------------------------------------------
1849  !!
1850  dwdn = sqrt(dwdnsq)
1851  !! ----------------------------------------------------------
1852  !!
1853  !!hv Bash; with !hv ON, don't use var Heaviside (by here it's = 1.0)
1854  grad(ipt,kang,izz) = ds(ipt)*csq*gsq/dwdn
1855  !!hv---
1856  !hv grad(ipt,kang,izz) = Heaviside*ds(ipt)*csq*gsq/dWdn
1857  !!hv---
1858  !! ----------------------------------------------------------
1859  !! ==========================================================
1860  !!
1861  !!
1862  !! Set interpolation, indexing and weight parameters for
1863  !! computations along wavenumber radials
1864  !! ----------------------------------------------------------
1865  !!
1866  !!f2 --------------------
1867  if ( f2 .lt. f0 ) then
1868  wtk2(ipt,kang,izz) = 1.
1869  tfac2(ipt,kang,izz) = 0.
1870  kref2(ipt,kang,izz) = 1
1871  else
1872  ir = 1+int((alog(f2)-alf0)/aldfrq)
1873  if ( ir+1 .gt. nrng ) then
1874  wtk2(ipt,kang,izz) = 0.
1875  er = (wka1(nrng)/wn2)**(2.5)
1876  tt2= er*(cg2/cgnrng1)*(frqa(nrng)/f2)*(wka1(nrng)/wn2)
1877  tfac2(ipt,kang,izz) = tt2
1878  kref2(ipt,kang,izz) = nrng - 1
1879  else
1880  w2 = (f2-frqa(ir))/(frqa(ir+1)-frqa(ir))
1881  wtk2(ipt,kang,izz) = 1. - w2
1882  tfac2(ipt,kang,izz) = 1.
1883  kref2(ipt,kang,izz) = ir
1884  end if
1885  end if
1886  !! ----------------------------------------------------------
1887  !!
1888  !!f4 --------------------
1889  if ( f4 .lt. f0 ) then
1890  wtk4(ipt,kang,izz) = 1.
1891  tfac4(ipt,kang,izz) = 0.
1892  kref4(ipt,kang,izz) = 1
1893  else
1894  ir = 1+int((alog(f4)-alf0)/aldfrq)
1895  if ( ir+1 .gt. nrng ) then
1896  wtk4(ipt,kang,izz) = 0.
1897  er = (wka1(nrng)/wn4)**2.5
1898  tt4= er*(cg4/cgnrng1)*(frqa(nrng)/f4)*(wka1(nrng)/wn4)
1899  tfac4(ipt,kang,izz) = tt4
1900  kref4(ipt,kang,izz) = nrng - 1
1901  else
1902  w2 = (f4-frqa(ir))/(frqa(ir+1)-frqa(ir))
1903  wtk4(ipt,kang,izz) = 1. - w2
1904  tfac4(ipt,kang,izz) = 1.
1905  kref4(ipt,kang,izz) = ir
1906  end if
1907  end if
1908  !! ----------------------------------------------------------
1909  !!
1910  !!
1911  !! Set indexing and weight parameters for computations around
1912  !! azimuths; it appears that jref2 and jref4 should be bounded
1913  !! between 0 and nang-1 so that when iang (=1,nang) is added in
1914  !! the integration section, the proper bin index will arise;
1915  !! the weights wta2 and wta4 seem to be the fractional bin
1916  !! widths between th2 or th4 and the next increasing
1917  !! directional bin boundary
1918  !! ----------------------------------------------------------
1919  !!
1920  i = int(th2/ainc)
1921  wta2(ipt,kang,izz) = 1. - abs(th2-i*ainc)/ainc
1922  if ( i .ge. nang ) i = i - nang
1923  jref2(ipt,kang,izz) = i
1924  !mpc jref2(ipt,kang,izz) = MOD(i,nang) !* is this better that the above two lines?
1925  !!
1926  i = int(th4/ainc)
1927  wta4(ipt,kang,izz) = 1. - abs(th4-i*ainc)/ainc
1928  if ( i .ge. nang ) i = i - nang
1929  jref4(ipt,kang,izz) = i
1930  !mpc jref4(ipt,kang,izz) = MOD(i,nang) !* is this better that the above two lines?
1931  !!
1932 50 end do !* end of ipt loop
1933  !!
1934 40 end do !* end of kang loop
1935  !!
1936 30 end do !* end of krng loop
1937  !!
1938 20 end do !* end of irng loop
1939  !! ------------------------------------------------------------------
1940  !! ==================================================================
1941  !!
1942  RETURN
1943  !!

References ainc, cosan, cplshr(), dfrq, ds, f0, frqa, grad, jref2, jref4, kref2, kref4, kzone, nang, np2p1, npts, shlocr(), shloxr(), sinan, tfac2, tfac4, twopi, wk2x, wk2y, wk4x, wk4y, wta2, wta4, wtk2, and wtk4.

Referenced by insnl4().

◆ insnl4()

subroutine w3snl4md::insnl4

It reads look-up tables (generated by gridsetr) if file exists otherwise it must generate the look-up tables file.

Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 219 of file w3snl4md.F90.

219  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
220  !! ------------------------------------------------------------------
221  !/
222  !/ +-----------------------------------+
223  !/ | WAVEWATCH III BIO |
224  !/ | Bash Toulany |
225  !/ | Michael Casey |
226  !/ | William Perrie |
227  !/ | FORTRAN 90 |
228  !/ | Last update : 12-Apr-2016 |
229  !/ +-----------------------------------+
230  !/
231  !/ 01-Mar-2016 : Origination. ( version 5.13 )
232  !/
233  !!
234  !! it returns: 11 look-up tables arrays dim=(npts,nang,nzz,ndep)
235  !! kref2_tbl, kref4_tbl, jref2_tbl, jref4_tbl,
236  !! wtk2_tbl, wtk4_tbl, wta2_tbl, wta4_tbl,
237  !! tfac2_tbl, tfac4_tbl & grad_tbl
238  !! plus pha_tbl dim=(nrng,ndep)
239  !! and dep_tbl dim=(ndep)
240  !! ------------------------------------------------------------------
241  !! ==================================================================
242  !!
243  !! 1. Purpose :
244  !! It reads look-up tables (generated by gridsetr) if file exists
245  !! otherwise it must generate the look-up tables file
246  !!
247  !! 2. Method :
248  !! See subr gridsetr and subr W3SNL4 (or subr. W3IOGR)
249  !!
250  !! 3. Parameters :
251  !!
252  !! Parameter list
253  !! ------------------------------------------------------------------
254  !! Name Type Scope I/O Description
255  !! ------------------------------------------------------------------
256  !! nrng int. Public I # of freq. or rings
257  !! nang int. Public I # of angles
258  !! npts int. Public I # of points on the locus
259  !! ndep int. Public I # of depths in look-up tables
260  !! dfrq Real Public I frequency multiplier for log freq. spacing
261  !! dep_tbl R.A. Public O depthes in Look-up tables arrays dim=(ndep)
262  !! grdfname chr. Local - Look-up tables filename (C*80)
263  !! ------------------------------------------------------------------
264  !!
265  !! *** The 11 look-up tables for grid integration geometry arrays
266  !! *** at all selected 'ndep' depths defined in dep_tbl(ndep)' array
267  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
268  !! kref2_tbl I.A. Public O Index of reference wavenumber for k2
269  !! kref4_tbl I.A. Public O Idem for k4
270  !! jref2_tbl I.A. Public O Index of reference angle for k2
271  !! jref4_tbl I.A. Public O Idem for k4
272  !! wtk2_tbl R.A. Public O k2 Interpolation weigth along wavenumbers
273  !! wtk4_tbl R.A. Public O Idem for k4
274  !! wta2_tbl R.A. Public O k2 Interpolation weigth along angles
275  !! wta4_tbl R.A. Public O Idem for k4
276  !! tfac2_tbl R.A. Public O Norm. for interp Action Density at k2
277  !! tfac4_tbl R.A. Public O Idem for k4
278  !! grad_tbl R.A. Public O Coupling and gradient term in integral
279  !! grad = C * H * g**2 * ds / |dW/dn|
280  !! ------------------------------------------------------------------
281  !!
282  !! *** The 11 grid integration geometry arrays at one given depth
283  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
284  !! kref2 I.A. Public O Index of reference wavenumber for k2
285  !! kref4 I.A. Public O Idem for k4
286  !! jref2 I.A. Public O Index of reference angle for k2
287  !! jref4 I.A. Public O Idem for k4
288  !! wtk2 R.A. Public O k2 Interpolation weigth along wavenumbers
289  !! wtk4 R.A. Public O Idem for k4
290  !! wta2 R.A. Public O k2 Interpolation weigth along angles
291  !! wta4 R.A. Public O Idem for k4
292  !! tfac2 R.A. Public O Norm. for interp Action Density at k2
293  !! tfac4 R.A. Public O Idem for k4
294  !! grad R.A. Public O Coupling and gradient term in integral
295  !! grad = C * H * g**2 * ds / |dW/dn|
296  !! ------------------------------------------------------------------
297  !!
298  !! 4. Subroutines used :
299  !!
300  !! Name Type Module Description
301  !! ------------------------------------------------------------------
302  !! gridsetr Subr. W3SERVMD Calc. the 11 grid geometry arrays for one depth
303  !! ------------------------------------------------------------------
304  !!
305  !! 5. Called by :
306  !!
307  !! Name Type Module Description
308  !! ------------------------------------------------------------------
309  !! STRACE Subr. W3SERVMD Subroutine tracing.
310  !! W3SNL4 Subr. W3SNL4MD Interface for TSA nonlinear interactions
311  !! - or - the option below was not used
312  !! W3IOGR Subr. W3INITMD Initialization (called by W3SHEL or WMINIT)
313  !! ------------------------------------------------------------------
314  !!
315  !! 6. Error messages :
316  !! None.
317  !!
318  !! 7. Remarks :
319  !!
320  !! 8. Structure :
321  !!
322  !! See source code.
323  !!
324  !! 9. Switches :
325  !! !/S Enable subroutine tracing.
326  !!
327  !!10. Source code :
328  !!
329  !! --------------------------------------------------------------- &
330  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
331  !! ----------------------------------------------------------------72
332  !! ==================================================================
333  !!
334  !!
335 #ifdef W3_S
336  USE w3servmd, ONLY: strace
337 #endif
338  USE w3odatmd, ONLY: ndse, ndst, ndso
339 #ifdef W3_MPI
340  USE wmmdatmd, ONLY: nmpscr, improc
341 #endif
342  USE constants, ONLY: file_endian
343  !! ------------------------------------------------------------------
344  !! ==================================================================
345  !!
346  IMPLICIT NONE
347  !!
348  !! ==================================================================
349  !!
350  !! Local variables & Parameters
351  !! ----------------------------
352 #ifdef W3_S
353  INTEGER, SAVE :: IENT = 0
354 #endif
355  !!
356  integer :: irng !* dummy integer
357  integer :: nd !* dummy integer
358  !!
359  logical :: unavail = .true.
360  logical :: file_exists
361  character :: grdfname*80
362  integer :: io_unit
363  !!
364  !!
365  !! Dimension wv# array and
366  !! declare local var. dep2, cvel & cgnrng at nrng & depth 'nd'
367  real :: wka2(nrng) !* wv# array at depth nd (local)
368  real :: pha2(nrng) !* pha array at depth nd (local)
369  real :: dep2 !* = dep_tbl(nd) depth at nd
370  real :: cvel !* Phase Velocity at (nrng,nd)
371  real :: cgnrng !* Group Velocity at (nrng,nd)
372  real :: dwka !* dummy storage for dk
373  !! ---------------------::-----------------------------------------72
374  !! ##################################################################
375  !!------------------------------------------------------------------------------
376  !!==============================================================================
377  !!
378  !!
379 #ifdef W3_S
380  CALL strace (ient, 'W3SNL4')
381 #endif
382  !!
383  !! ==================================================================
384  !!
385  !!
386  !!-1 Make-up the filename from the main parameters
387  !! ------------------------------------------------------------------
388  !b example filename; grdfname = 'grd_1.1025_35_36_30_37.dat'
389  !! grdfname = 'grd_dfrq_nr_na_np_nd.dat'
390  !! where fm = freq. mult. (dfrq) ex. dfrq = 1.1025 (F6.4)
391  !! nr = # of rings (nrng) ex. nrng = 35 (I2.2)
392  !! na = # of angles (nang) ex. nang = 36 (I2.2)
393  !! np = # of points (npts) ex. npts = 30 (I2.2)
394  !! nd = # of depths (ndep) ex. nd = 37 (I2.2)
395  write(grdfname,'(A,F6.4,A,I2.2,A,I2.2,A,I2.2,A,I2.2,A)') &
396  'grd_', dfrq,'_', nrng,'_', nang,'_', npts,'_', ndep, '.dat'
397  !! ==================================================================
398  !!
399  !!
400  !!-2 Check if the propre gridsetr Look-up tables file is available.
401  !! if available read it and if not must generate it (by calling gridsetr)
402  !! ------------------------------------------------------------------
403  INQUIRE ( file=grdfname, exist=file_exists )
404  !! Assign an unused UNIT number to io_unit.
405  !! Note; It's important to look for an available unused number
406  io_unit = 60
407  do while (unavail)
408  io_unit = io_unit + 1
409  INQUIRE ( io_unit, opened=unavail )
410  enddo
411  !prt print *, 'io_unit = ', io_unit
412  !! ==================================================================
413  !!
414  !!
415  !!
416  !!
417  IF ( file_exists ) THEN
418  !!
419  !!-3 File exists open it and read it
420  !!
421 #ifdef W3_MPI
422  if ( improc .eq. nmpscr ) then
423 #endif
424  write ( ndso, 900 ) grdfname
425 #ifdef W3_MPI
426  end if
427 #endif
428  !!
429  open (unit=io_unit, file=grdfname, status='old', &
430  access='sequential', action='read', form='unformatted', convert=file_endian)
431  read (io_unit) kref2_tbl, kref4_tbl, jref2_tbl, jref4_tbl, &
435  close (io_unit)
436  !! ----------------------------------------------------------------
437  !!
438  ELSE !* ELSE IF ( file_exists )
439  !!
440  !!
441  !!-4 File does not exist, create it here
442  !!
443 #ifdef W3_MPI
444  if ( improc .eq. nmpscr ) then
445 #endif
446  write ( ndso, 901 ) grdfname
447 #ifdef W3_MPI
448  end if
449 #endif
450  !! ----------------------------------------------------------------
451  !!
452  !!-4a Define Look-up tables depth array 'dep_tbl(ndep)' for ndep=37
453  !! with depths are +ve values
454  !! ----------------------------------------------------------------
455  dep_tbl(1:ndep) = &
456  (/ 2., 4., 6., 8., 10., 12., 14., 16., 18., 20., &
457  25., 30., 35., 40., 45., 50., 55., 60., 65., 70., &
458  80., 90.,100.,110.,120.,130.,140.,150.,160.,170., &
459  220.,270.,320.,370.,420.,470.,520. /)
460  !prt print *, ' ndep = ', ndep
461  !prt print *, ' dep_tbl(1:ndep) = ', dep_tbl
462  !! ----------------------------------------------------------------
463  !! ================================================================
464  !!
465  !!
466  do nd = 1,ndep
467  !!
468  !!
469  !!-4b For given new depth dep2 = dep_tbl(nd) calculate
470  !! a new array wka2(:) & new cgnrng corresp. to this depth
471  dep2 = dep_tbl(nd)
472  do irng=1,nrng
473  wka2(irng) = wkfnc(frqa(irng),dep2)
474  end do
475  cvel = oma(nrng)/wka2(nrng) !* Phase Vel. at (nrng,nd)
476  cgnrng = cgfnc(frqa(nrng),dep2,cvel) !* Group Vel. at (nrng,nd)
477  !! --------------------------------------------------------------
478  !! ==============================================================
479  !!
480  !!
481  !!-4c Call gridsetr for this depth at nd
482  !! --------------------------------------------------------------
483  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
484  call gridsetr ( dep2, wka2, cgnrng )
485  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
486  !! it returns: 11 gridsetr arrays which are declared PUBLIC
487  !! kref2,kref4, jref2,jref4, wtk2,wtk4, wta2,wta4,
488  !! tfac2,tfac4 and grad all dim=(npts,nang,nzz)
489  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
490  !! --------------------------------------------------------------
491  !! ==============================================================
492  !!
493  !!-4d Store in Look-up tables arrays at depth bin # 'nd'
494  kref2_tbl(:,:,:,nd) = kref2(:,:,:)
495  kref4_tbl(:,:,:,nd) = kref4(:,:,:)
496  jref2_tbl(:,:,:,nd) = jref2(:,:,:)
497  jref4_tbl(:,:,:,nd) = jref4(:,:,:)
498  wtk2_tbl(:,:,:,nd) = wtk2(:,:,:)
499  wtk4_tbl(:,:,:,nd) = wtk4(:,:,:)
500  wta2_tbl(:,:,:,nd) = wta2(:,:,:)
501  wta4_tbl(:,:,:,nd) = wta4(:,:,:)
502  tfac2_tbl(:,:,:,nd) = tfac2(:,:,:)
503  tfac4_tbl(:,:,:,nd) = tfac4(:,:,:)
504  grad_tbl(:,:,:,nd) = grad(:,:,:)
505  !! --------------------------------------------------------------
506  !! ==============================================================
507  !!
508  !!
509  !!-4e Calculate pha2(:) at nd depth and store it in pha_tbl(:,:)
510  !! pha2()=k*dk*dtheta, the base area at a grid intersection
511  !! for use in integration of 2-D Density functions.
512  !! --------------------------------------------------------------
513  !! Below: variable dwka = dk centered at ring 1 (between 0 & 2)
514  !! and computed pha2(1) = k*dk*dtheta at ring 1
515  !! with wkfnc(frqa(1)/dfrq,dep2) is like wka2(0)
516  !! --assuming frqa(1)/dfrq is like frqa(0)
517  dwka = ( wka2(2) - wkfnc(frqa(1)/dfrq,dep2) ) / 2.
518  pha2(1) = wka2(1)*dwka*ainc
519  !!
520  do irng=2,nrng-1
521  !! Below: variable dwka = dk centered at irng (between irng-1 & irng+1)
522  !! and computed pha2(irng) = k*dk*dtheta at irng
523  dwka = ( wka2(irng+1) - wka2(irng-1) ) / 2.
524  pha2(irng) = wka2(irng)*dwka*ainc
525  end do
526  !!
527  !! Below: variable dwka = dk centered at nrng (between nrng-1 & nrng+1)
528  !! and computed pha2(nrng) = k*dk*dtheta at nrng
529  !! with wkfnc(dfrq*frqa(nrng),dep2) is like wka2(nrng+1)
530  !! --assuming dfrq*frqa(nrng) is like frqa(nrng+1)
531  dwka = ( wkfnc(dfrq*frqa(nrng),dep2) - wka2(nrng-1) ) / 2.
532  pha2(nrng) = wka2(nrng)*dwka*ainc
533  !! --------------------------------------------------------------
534  !! ==============================================================
535  !!
536  !!
537  !!-4f Store pha2(:) at nd in pha_tbl(:,nd) to be added to Look-up tables
538  pha_tbl(1:nrng, nd) = pha2(1:nrng)
539  !! --------------------------------------------------------------
540  !! ==============================================================
541  !!
542  !!
543  end do ! nd = 1,ndep
544  !! ----------------------------------------------------------------
545  !! ================================================================
546  !!
547  !!
548  !!-5 Ounce the Look-up tables arrays are full write it out to 'io_unit'
549  !!
550 #ifdef W3_MPI
551  if ( improc .eq. nmpscr ) then
552 #endif
553  write( ndso,902 )
554  open (unit=io_unit, file=grdfname, status='new', &
555  access='sequential', action='write', form='unformatted', convert=file_endian)
556  write (io_unit) kref2_tbl, kref4_tbl, jref2_tbl, jref4_tbl, &
560  close (io_unit)
561  write( ndso,903 ) grdfname
562 #ifdef W3_MPI
563  end if
564 #endif
565  !! ----------------------------------------------------------------
566  !! ================================================================
567  !!
568  ENDIF !* End IF ( file_exists )
569  !! ------------------------------------------------------------------
570  !! ==================================================================
571  !!
572  !!
573  RETURN
574  !!
575 900 format ( ' grdfname does exist = ',a/ &
576  ' open, read & close file ' )
577  !!
578 901 format ( ' grdfname does not exist = ',a/ &
579  ' Generate look-up table arrays ' )
580  !!
581 902 format ( ' Done generating look-up table arrays ----------- ' )
582  !!
583 903 format ( ' Done writing & closing grdfname ', a )
584  !!

References ainc, cgfnc(), dep_tbl, dfrq, file(), constants::file_endian, frqa, grad, grad_tbl, gridsetr(), wmmdatmd::improc, jref2, jref2_tbl, jref4, jref4_tbl, kref2, kref2_tbl, kref4, kref4_tbl, nang, ndep, w3odatmd::ndse, w3odatmd::ndso, w3odatmd::ndst, wmmdatmd::nmpscr, npts, oma, pha_tbl, w3servmd::strace(), tfac2, tfac2_tbl, tfac4, tfac4_tbl, wkfnc(), wta2, wta2_tbl, wta4, wta4_tbl, wtk2, wtk2_tbl, wtk4, and wtk4_tbl.

Referenced by w3snl4().

◆ interp2()

subroutine w3snl4md::interp2 ( real, dimension(nrng,nang), intent(inout)  X)

Interpolate bi-linearly to fill in tsa/fbi & diag/diag2 arrays.

Optionally smooth the interior and the corners after alternating the irng, iang, krng & kang loops in snlr's.

Parameters
[in,out]XArray to be interpolated and smoothed.
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 5018 of file w3snl4md.F90.

5018  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5019  !/
5020  !/ +-----------------------------------+
5021  !/ | WAVEWATCH III BIO |
5022  !/ | Bash Toulany |
5023  !/ | Michael Casey |
5024  !/ | William Perrie |
5025  !/ | FORTRAN 90 |
5026  !/ | Last update : 12-Apr-2016 |
5027  !/ +-----------------------------------+
5028  !/
5029  !/ 01-Mar-2016 : Origination. ( version 5.13 )
5030  !/
5031  !!
5032  !! 1. Purpose :
5033  !!
5034  !! Interpolate bi-linearly to fill in tsa/fbi & diag/diag2 arrays
5035  !! and then (optional) smooth the interior and the corners
5036  !! after alternating the irng, iang, krng & kang loops in snlr's
5037  !!
5038  !! 2. Method :
5039  !!
5040  !! 3. Parameters :
5041  !!
5042  !! Parameter list
5043  !! ------------------------------------------------------------------
5044  !! Name Type Scope I/O Description
5045  !! ------------------------------------------------------------------
5046  !! nrng int. Public I # of freq. or rings
5047  !! nang int. Public I # of angles
5048  !! ismo int. Local I switch; ismo=0 skip smoothing
5049  !! ismo.ne.0 do smoothing
5050  !! X R.A. Local I/O Array to be ineterp. & smoothing
5051  !! its returned to snlr_tsa as tsa or diag
5052  !! and to snlr_fbi as fbi or diag2
5053  !! dim=(nrng,nang)
5054  !! ------------------------------------------------------------------
5055  !!
5056  !! 4. Subroutines used :
5057  !!
5058  !! Name Type Module Description
5059  !! ----------------------------------------------------------------
5060  !! ----------------------------------------------------------------
5061  !!
5062  !! 5. Called by :
5063  !!
5064  !! Name Type Module Description
5065  !! ----------------------------------------------------------------
5066  !! snlr_tsa Subr. W3SNL4MD Computes dN(k,theta)/dt for TSA
5067  !! -------- due to wave-wave inter. (set itsa = 1)
5068  !! snlr_fbi Subr. W3SNL4MD Computes dN(k,theta)/dt for FBI
5069  !! -------- due to wave-wave inter. (set itsa = 0)
5070  !! ----------------------------------------------------------------
5071  !!
5072  !! 6. Error messages :
5073  !!
5074  !! None.
5075  !!
5076  !! 7. Remarks :
5077  !!
5078  !! 8. Structure :
5079  !!
5080  !! See source code.
5081  !!
5082  !! 9. Switches :
5083  !!
5084  !! !/S Enable subroutine tracing.
5085  !!
5086  !!10. Source code :
5087  !!
5088  !! --------------------------------------------------------------- &
5089  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5090  !! ----------------------------------------------------------------72
5091  !! ==================================================================
5092  !!
5093  !!
5094  IMPLICIT NONE
5095  !!
5096  !!
5097  !! Parameter list
5098  !! --------------
5099  REAL, INTENT(INOUT) :: X(nrng,nang)
5100  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5101  !! ------------------------------------------------------------------
5102  !!
5103  !!
5104  !! Local Parameters
5105  !! ----------------
5106  integer :: irng, iang
5107  real :: Y(nrng,nang) !* dummy array used in smoothing
5108  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5109  !! ---------------------::-----------------------------------------72
5110  !! ##################################################################
5111  !!------------------------------------------------------------------------------
5112  !!==============================================================================
5113  !!
5114  !!
5115  !!-0 Initial Y(:,:) array before it's computed
5116  !!ini
5117  y(:,:) = 0.0
5118  !!ini---
5119  !! ------------------------------------------------------------------
5120  !! ==================================================================
5121  !!
5122  !!
5123  !!-1 Interpolate using simple 2 point averaging to fill in X
5124  !! Remeber: nang must be an even number ==> nang-2 is an even number
5125  !! and nrng must be an odd number ==> nrng-1 is an even number
5126  !! Example numbers used here are for nrng=35 & nang=36
5127  !! ------------------------------------------------------------------
5128  !!
5129  !!-1a For every calculated iang (1,3,5,..,nang-1=35)
5130  !! fill in missing irng's (2,4,6,..,nrng-1=34)
5131  do iang=1,nang-1,2 !* = 1,3,5,...,nang-1=35
5132  do irng=2,nrng-1,2 !* = 2,4,6,...,nrng-1=34
5133  x(irng,iang) = 0.5 * ( x(irng-1,iang) + x(irng+1,iang) )
5134  end do
5135  end do
5136  !! ------------------------------------------------------------------
5137  !!
5138  !!-1b Now, for every irng (1,2,3,..,nrng =35)
5139  !! fill missing iang's (2,4,6,..,nang-2=34)
5140  do irng=1,nrng !* 1,2,3,..,nrng =35
5141  do iang=2,nang-2,2 !* 2,4,6,..,nang-2=34
5142  x(irng,iang) = 0.5 * ( x(irng,iang-1) + x(irng,iang+1) )
5143  end do
5144  end do
5145  !! ------------------------------------------------------------------
5146  !!
5147  !!-1c for iang = nang (special case since nang is an even number)
5148  do irng=1,nrng
5149  x(irng,nang) = 0.5 * ( x(irng,nang-1) + x(irng,1) )
5150  end do
5151  !! ------------------------------------------------------------------
5152  !! ==================================================================
5153  !!
5154  !!
5155  !!
5156  !! Skip smoothing only if ismo = 0
5157  !!
5158  !!
5159  if ( ismo.eq.0 ) goto 99
5160  !!
5161  !!
5162  !!
5163  !!-2 Smoothing the 2D array X into array Y
5164  !!
5165  !!-2a Smoothing the interior [2;nrng-1] x [2:nang-1]
5166  !!- Using 9 points averaged with equal weights.
5167  !!- Here use the dummy array so we don't spoil the original array.
5168  do irng=2,nrng-1
5169  do iang=2,nang-1
5170  y(irng,iang)=(x(irng-1,iang-1)+x(irng-1,iang)+x(irng-1,iang+1) + &
5171  x(irng, iang-1)+x(irng, iang)+x(irng, iang+1) + &
5172  x(irng+1,iang-1)+x(irng+1,iang)+x(irng+1,iang+1))/9.
5173  end do
5174  end do
5175  !! ------------------------------------------------------------------
5176  !! ==================================================================
5177  !!
5178  !!
5179  !!-3 Smooth first & last line at iang=1 & iang=nang (special cases)
5180  !!
5181  !!-3a Smooth line at iang = 1 (special case)
5182  !!- Using 9 points averaged with equal weights.
5183  do irng=2,nrng-1
5184  y(irng, 1) = (x(irng-1,nang) + x(irng-1, 1) + x(irng-1, 2) + &
5185  x(irng, nang) + x(irng, 1) + x(irng, 2) + &
5186  x(irng+1,nang) + x(irng+1, 1) + x(irng+1, 2) )/9.
5187  end do
5188  !! ------------------------------------------------------------------
5189  !!
5190  !!-3b Smooth line at iang = nang (special case)
5191  !!- Using 9 points averaged with equal weights.
5192  do irng=2,nrng-1
5193  y(irng,nang)=(x(irng-1,nang-1) +x(irng-1,nang) +x(irng-1,1) + &
5194  x(irng, nang-1) +x(irng, nang) +x(irng, 1) + &
5195  x(irng+1,nang-1) +x(irng+1,nang) +x(irng+1,1))/9.
5196  end do
5197  !! ------------------------------------------------------------------
5198  !! ==================================================================
5199  !!
5200  !!
5201  !!-4 Smooth first & last col. at irng=1 & irng=nrng (special cases)
5202  !!
5203  !!-4a Smooth col. at irng = 1 (low frq. can be skipped)
5204  !!- Using 6 points averaged with equal weights.
5205  do iang=2,nang-1
5206  y(1,iang) = (x(1,iang-1) + x(1,iang) + x(1,iang+1) + &
5207  x(2,iang-1) + x(2,iang) + x(2,iang+1) )/6.
5208  end do
5209  !! ------------------------------------------------------------------
5210  !!
5211  !!-4b Smooth col. at irng = nrng (high frq. can be skipped)
5212  !!- Using 6 points averaged with equal weights.
5213  do iang=2,nang-1
5214  y(nrng,iang)=(x(nrng-1,iang-1)+x(nrng-1,iang)+x(nrng-1,iang+1)+ &
5215  x(nrng, iang-1)+x(nrng, iang)+x(nrng, iang+1) )/6.
5216  end do
5217  !! ------------------------------------------------------------------
5218  !! ==================================================================
5219  !!
5220  !!
5221  !!-5 Smooth the 4 corners (optional): <== Skip no sig. effect
5222  !!- Using 6 points averaged with equal weights
5223  !!
5224  !!-5a Corner (1, 1)
5225  y(1, 1) =( x(1,nang) + x(1, 1) + x(1, 2) + &
5226  x(2,nang) + x(2, 1) + x(2, 2) )/6.0
5227  !! ------------------------------------------------------------------
5228  !!
5229  !!-5b Corner (nrng,1)
5230  y(nrng,1) =( x(nrng-1,nang) + x(nrng-1,1) + x(nrng-1,2) + &
5231  x(nrng, nang) + x(nrng, 1) + x(nrng, 2) )/6.0
5232  !! ------------------------------------------------------------------
5233  !!
5234  !!-5c Corner (1,nang)
5235  y(1,nang) =( x(1,nang-1) + x(1,nang) + x(1, 1) + &
5236  x(2,nang-1) + x(2,nang) + x(2, 1) ) / 6.
5237  !! ------------------------------------------------------------------
5238  !!
5239  !!-5d Corner (nrng,nang)
5240  y(nrng,nang) =( x(nrng-1,nang-1) +x(nrng-1,nang) +x(nrng-1,1) + &
5241  x(nrng, nang-1) +x(nrng, nang) +x(nrng, 1) )/6.
5242  !! ------------------------------------------------------------------
5243  !! ==================================================================
5244  !!
5245  !!
5246  !!-6 Final, dump smoothed array Y(:,:) into X(:,:) to be returned
5247  !!
5248  !!-6a Done with X(:,:) re-initial before it's replaced by Y(:,:)
5249  !!ini
5250  x(:,:) = 0.0
5251  !!ini---
5252  !!
5253  !!-6b Dump smoothed array Y(:,:) into X(:,:) to be returned
5254  do iang=1,nang
5255  do irng=1,nrng
5256  x(irng,iang) = y(irng,iang)
5257  end do
5258  end do
5259  !! Bash; can simplify in one line
5260  !b X(1:nrng, 1:nang) = Y(1:nrng, 1:nang)
5261  !! ------------------------------------------------------------------
5262  !! ==================================================================
5263  !!
5264 99 continue
5265  !! ------------------------------------------------------------------
5266  !! ==================================================================
5267  !!
5268  !!
5269  RETURN
5270  !!

References ismo.

Referenced by snlr_fbi(), and snlr_tsa().

◆ optsa2()

subroutine w3snl4md::optsa2 ( integer, intent(in)  nrmn,
integer, intent(in)  nrmx,
integer, intent(in)  npk,
real, intent(in)  fpk,
integer, intent(in)  nbins,
real, dimension(nrng), intent(in)  wka,
real, dimension(nrng), intent(in)  cga 
)

Splits the Action Density into two parts.

    (1) large-scale part dens1(nrng,nang)  and
    (2) small-scale part dens2(nrng,nang)
    dens1 & dens2 in Polar Action Density (k,theta) space Norm. (in k)
Parameters
[in]nrmnNumber of first frequency bin in [1,nrng-1].
[in]nrmxNumber of last frequency bin in [2,nrng].
[in]npkNumber of peak frequency in [2,nrng-1].
[in]fpkPeak frequency [Hz] of initial frequency spectrum.
[in]nbinsnumber of bins (see more below).
[in]wkaWavenumbers array [1/m].
[in]cgaGroup velocities array [m/s].
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 3259 of file w3snl4md.F90.

3259  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3260  !/
3261  !/ +-----------------------------------+
3262  !/ | WAVEWATCH III BIO |
3263  !/ | Bash Toulany |
3264  !/ | Michael Casey |
3265  !/ | William Perrie |
3266  !/ | FORTRAN 90 |
3267  !/ | Last update : 12-Apr-2016 |
3268  !/ +-----------------------------------+
3269  !/
3270  !/ 01-Mar-2016 : Origination. ( version 5.13 )
3271  !/
3272  !! ------------------------------------------------------------------
3273  !! ==================================================================
3274  !!
3275  !! ------------------------------------------------------------------
3276  !!
3277  !! It returns variables dens1(nrng,nang) and dens2(nrng,nang)
3278  !!
3279  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3280  !! ------------------------------------------------------------------
3281  !! ==================================================================
3282  !!
3283  !!
3284  !! 1. Purpose :
3285  !!
3286  !! Splits the Action Density into two parts:
3287  !! (1) large-scale part dens1(nrng,nang) and
3288  !! (2) small-scale part dens2(nrng,nang)
3289  !! dens1 & dens2 in Polar Action Density (k,theta) space Norm. (in k)
3290  !!
3291  !! 2. Method :
3292  !!
3293  !! 3. Parameters :
3294  !!
3295  !! Parameter list
3296  !! ------------------------------------------------------------------
3297  !! Name Type Scope I/O Description
3298  !! ------------------------------------------------------------------
3299  !!op2
3300  !! nrmn int. Local I number of first freq. bin in [1,nrng-1]
3301  !! nrmx int. Local I number of last freq. bin in [2,nrng]
3302  !! npk int. Local I number of peak frequency in [2,nrng-1]
3303  !! nbins int. Local I actual # of bins > npk (incl. nfs) or
3304  !! actual # of bins > npk2 (incl. nrng)
3305  !! to guarantee a min 1 bin in equi. range
3306  !! (see subr. W3SNL4)
3307  !! ------------------------------------------------------------ !!op2
3308  !!
3309  !! nrng int. Public I # of freq. or rings
3310  !! nang int. Public I # of angles
3311  !!
3312  !! dfrq Real Public I freq mult. for log freq spacing
3313  !! fpk Real Public I peak freq. [Hz] of initial freq spectrum
3314  !! oma R.A. Public I rel. freq. array (rad*Hz) ----- dim=(nrng)
3315  !! frqa R.A. Public I radian frequencies (Hz) ------- dim=(nrng)
3316  !!
3317  !! ainc Real Public I angle increment (radians)
3318  !! angl R.A. Public I dir. array (rad) (full circle); dim=(nrng)
3319  !! cosan R.A. Public I cosine angles array ----------- dim=(nang)
3320  !! sinan R.A. Public I sine angles array ----------- dim=(nang)
3321  !! ------------------------------------------------------------------
3322  !!
3323  !! wka R.A. Local I wavenumbers array [1/m] ------- dim=(nrng)
3324  !! cga R.A. Local I group velocities array [m/s] -- dim=(nrng)
3325  !! wka & cga arrays are corrsp. to depth 'dep'
3326  !! ------------------------------------------------------------------
3327  !!
3328  !! ef2 R.A. Public I 2D Energy Density spectrum ef2(theta,f)
3329  !! = A(theta,k)*2*pi*oma(f)/cga(f) dim=(nrng,nang)
3330  !! ef1 R.A. Public I 1D Energy Density spectrum ef1(f) dim=(nrng)
3331  !! ------------------------------------------------------------------
3332  !!
3333  !! dens1 R.A. Public O large-scale Action Density (k,theta)
3334  !! dim=(nrng,nang)
3335  !! dens2 R.A. Public O Small-scale Action Density (k,theta)
3336  !! dim=(nrng,nang)
3337  !! ------------------------------------------------------------------
3338  !!
3339  !! 4. Subroutines used :
3340  !!
3341  !! Name Type Module Description
3342  !! ------------------------------------------------------------------
3343  !! ------------------------------------------------------------------
3344  !!
3345  !! 5. Called by :
3346  !!
3347  !! Name Type Module Description
3348  !! ------------------------------------------------------------------
3349  !! gridsetr Subr. W3SNL4MD Setup geometric integration grid
3350  !! ------------------------------------------------------------------
3351  !!
3352  !! 6. Error messages :
3353  !!
3354  !! None.
3355  !!
3356  !! 7. Remarks :
3357  !!
3358  !! 8. Structure :
3359  !!
3360  !! See source code.
3361  !!
3362  !! 9. Switches :
3363  !!
3364  !! !/S Enable subroutine tracing.
3365  !!
3366  !!10. Source code :
3367  !!
3368  !! --------------------------------------------------------------- &
3369  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3370  !! ----------------------------------------------------------------72
3371  !! ==================================================================
3372  !!
3373  !!
3374  !!
3375  IMPLICIT NONE
3376  !!
3377  !!
3378  !!
3379  !! Parameter list
3380  !! --------------
3381  !!op2 Bash; new for optsa2
3382  integer, intent(in) :: nrmn, nrmx, nbins
3383  !! ------------------------------------------------------------ !!op2
3384  !!
3385  integer, intent(in) :: npk
3386  real, intent(in) :: fpk
3387  real, intent(in) :: wka(nrng), cga(nrng)
3388  !! ------------------------------------------------------------------
3389  !!
3390  !!
3391  !! Local Parameters & variables
3392  !! -----------------------------
3393  integer :: irng, iang
3394  !!
3395  !!p2
3396  !! Bash; Uses of original "psi2(:)", it was very bad (see below)
3397  !p2 integer :: n1, n2, m, mm
3398  !p2 integer :: nn1, nn2, ii, idif
3399  !p2 real :: q(16)
3400  !p2 real :: emax
3401  !p2 real :: y, qmin, adif
3402  !!p2---
3403  !!
3404  !!p3
3405  !! Bash; This is an attempt to replace the original psi2(:)
3406  !! with a distr. based on sin()**mm with 'newmaxang'
3407  !! - not good enough (see below)
3408  !! !!p4 is an override of !!p3 with mm=4
3409  !p3 integer :: n1, n2, m, mm
3410  !p3 real :: q(16)
3411  !p3 real :: y, qmin, adif
3412  !! The var. below are needed to find 'newmaxang' used in !p3 & !p4
3413  integer :: maxang, newmaxang
3414  integer :: maxangshift
3415  integer :: halfangl, halfangu
3416  real :: ef2maxrow(nang)
3417  real :: ef2shift(nang)
3418  real :: halfmax
3419  !!p3---
3420  !!
3421  !!p4
3422  !! Bash; !!p4 is an override of !!p3 with mm=4
3423  integer :: n1, n2
3424  real :: q4
3425  !!p4---
3426  !!
3427  !!eq
3428  !! Bash; Use variable equi. range suitable to TSA min condition
3429  !! simplifed to one point equi. range nearest to 2.*fp
3430  !eq integer :: neq
3431  !eq real :: fovfp
3432  !!eq---
3433  !!
3434  integer :: igam
3435  real :: sum1, fac
3436  real :: beta, gam
3437  real :: fdenp, fr, ratio, z, ddd
3438  real :: sigz !* sigz = 0.109
3439  real :: fk(nrng), fknrm(nrng)
3440  real :: bscl1(nrng), fkscl1(nrng)
3441  real :: psi2(nang)
3442  real :: act2d(nrng,nang)
3443  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3444  !! ---------------------::-----------------------------------------72
3445  !! ##################################################################
3446  !!------------------------------------------------------------------------------
3447  !!==============================================================================
3448  !!
3449  !!
3450  !!ini
3451  !! Bash; initialize psi2() array here
3452  psi2(:) = 0.0
3453  !!
3454  !! Initialize all the 1d & 2d arrays that are being used
3455  !! and especially those that are being returned
3456  fk(:) = 0.0
3457  fknrm(:) = 0.0
3458  fkscl1(:) = 0.0
3459  bscl1(:) = 0.0
3460  act2d(:,:) = 0.0
3461  dens1(:,:) = 0.0
3462  dens2(:,:) = 0.0
3463  !!ini---
3464  !! ------------------------------------------------------------------
3465  !!
3466  !!
3467  !!* Convert 2D Energy Density ef2(f,theta)
3468  !! to 2D Polar Action Density act2d(k,theta) Norm. (in k)
3469  do irng=nrmn,nrmx
3470  fac = cga(irng)/(twopi*oma(irng)*wka(irng))
3471  do iang=1,nang
3472  act2d(irng,iang) = ef2(irng,iang) * fac
3473  end do
3474  !!
3475  !!* Convert ef1(f) to fk(k); both are 1d Energy Density
3476  fk(irng) = cga(irng)*ef1(irng)/twopi !* fk(k) energy
3477  !!
3478  !!* Normalize the 1d wavenumber Energy Density fk(k) to give fknrm(k)
3479  fknrm(irng) = fk(irng)*wka(irng)**2.5 !* fknrm(k) = Norm. fk(k)
3480  end do
3481  !! ------------------------------------------------------------------
3482  !!
3483  !!
3484  !! Fit parameters to spectrum
3485  !! --------------------------
3486  !!eq
3487  !eq sum1 = 0.
3488  !eq neq = 0
3489  !eq do 26 irng=nrmn,nrmx
3490  !eq fovfp = frqa(irng)/fpk
3491  !! Bash; check2 test equilibrium range
3492  !b if ( fovfp.ge.1.55.and.fovfp.le.2.45 ) then !* orig equi range
3493  !b if ( fovfp.ge.1.20.and.fovfp.le.2.20 ) then !* wide equi range
3494  !b if ( fovfp.ge.1.90.and.fovfp.le.2.20 ) then !* narrow equi range
3495  !! --------------------------------------------------------------!* <<<<<
3496  !! Bash; select variable equi. range suitable to TSA min condition
3497  !eq if ( fovfp.ge.(dfrq**(nbins))-0.005 .and. &
3498  !eq fovfp.le.(dfrq**(nbins))+0.005 ) then !* narrow equi range <<<<<
3499  !! --------------------------------------------------------------!* <<<<<
3500  !eq sum1 = sum1 + fknrm(irng)
3501  !eq neq = neq + 1
3502  !eq endif
3503  ! 26 end do
3504  !eq beta = sum1 / neq
3505  !eq gam = fknrm(npk) / beta
3506  !!eq---
3507  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3508  !! Simplify
3509  beta = fknrm(npk+nbins)
3510  gam = fknrm(npk) / beta
3511  !!eq---
3512  !! ------------------------------------------------------------------
3513  !!
3514  do irng=nrmn,nrmx
3515  fknrm(irng) = fknrm(irng) / beta
3516  end do
3517  !! ==================================================================
3518  !!
3519  !!
3520  !!p2
3521  !! Construct Directional Distribution "psi2(:)" - original option
3522  !! ------------------------------------------------------------------
3523  !!
3524  !! Solve for Normalizing Coefficient for Integral [1.0/(cos**m)]
3525  !! Note: n1, n2 spans half circle (from -pi/2 to +pi/2 going through 0.)
3526  !p2 n1 = -nang/4 + 1
3527  !p2 n2 = nang/4 + 1
3528  !p2 do m=1,16
3529  !p2 sum1 = 0.
3530  !p2 do iang=n1,n2
3531  !p2 ii = iang
3532  !p2 if ( iang .lt. 1 ) ii = iang + nang
3533  !p2 sum1 = sum1 + cosan(ii)**m
3534  ! end do
3535  !p2 q(m) = 1./(sum1*ainc)
3536  ! end do
3537  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3538  !!
3539  !! Find peak direction "maxang" in ef2() at "npk" the peak in ef1()
3540  !! needed to define the energy spreading factor y=ef2(npk,maxang)/ef1(npk)
3541  !! Bash; Note; This original "psi2(:)" was simply very bad because the drift
3542  !! in "maxang" location causing the 2D Snl to lose symmetry
3543  !p2 emax = 0.
3544  !p2 maxang = 0
3545  !p2 do iang=1,nang
3546  !p2 if ( ef2(npk,iang).gt.emax ) then
3547  !p2 emax = ef2(npk,iang)
3548  !p2 maxang = iang !* in [1,nang]
3549  !p2 endif
3550  ! end do
3551  !p2 y = ef2(npk,maxang)/ef1(npk) !* Bash; Energy Spread
3552  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3553  !!
3554  !! Compare value of peak with q-array for closest fit to cos()**m at peak
3555  !p2 mm = 1
3556  !p2 qmin = abs(q(1)-y)
3557  !p2 do m=2,16
3558  !p2 adif = abs(q(m)-y)
3559  !p2 if ( adif.lt.qmin ) then
3560  !p2 qmin = adif
3561  !p2 mm = m
3562  !p2 endif
3563  ! end do
3564  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3565  !!
3566  !p2 nn1 = maxang - nang/4 !* nn1 in [-8, 27], -ve/+ve (incl. 0)
3567  !p2 nn2 = maxang + nang/4 !* nn2 in [10, 45], all +ve (no 0)
3568  !p2 do iang=nn1,nn2 !* Bash; nn1 -> nn2 covers half circle
3569  !p2 ii = iang !* ii always in range [1,nang]
3570  !p2 if ( ii .lt. 1 ) ii = ii + nang !* ""
3571  !p2 if ( ii .gt. nang ) ii = ii - nang !* ""
3572  !p2 idif = iabs(maxang-iang) + 1 !* =10,9,..,2,1,2,..,9,10
3573  !p2 psi2(ii) = q(mm) * cos(angl(idif))**mm !* Normalized psi2 distr.
3574  ! end do
3575  !!p2---
3576  !! ==================================================================
3577  !!
3578  !!
3579  !!p3
3580  !! Construct New Directional Distribution "psi2(:)"
3581  !! In an attempt to replace the original psi2(:) with
3582  !! a distribution based on sin()**mm with 'newmaxang' - not good enough
3583  !! ------------------------------------------------------------------
3584  !!
3585  !! Solve for Normalizing Coefficient for Integral [1.0/(sin()**m)]
3586  !! Note: n1, n2 spans half circle (from 0 to +pi)
3587  !p3 n1 = 1
3588  !p3 n2 = nang/2 + 1
3589  !p3 do m=1,16
3590  !p3 sum1 = 0.
3591  !p3 do iang=n1,n2
3592  !p3 sum1 = sum1 + sinan(iang)**m
3593  ! end do
3594  !p3 q(m) = 1./(sum1*ainc)
3595  ! end do
3596  !!p3---
3597  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3598  !!
3599  !!p3
3600  ef2maxrow(:) = ef2(npk,:)
3601  maxang = maxloc(ef2maxrow,1)
3602  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3603  !!
3604  !! Shift the row so that the max is at location of 90 degress
3605  !! Negative shift is to the right, Postive to the left
3606  !! halfangl - lower angular limit of the half maximum
3607  !! halfangu - upper angular limit of the half maximum
3608  ef2shift(:) = cshift( ef2maxrow(:), (maxang-1-nang/4) )
3609  halfangu = nang/4+2
3610  halfangl = nang/4
3611  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3612  !!
3613  halfmax = 0.5 * ef2(npk,maxang)
3614  do while((ef2shift(halfangu).gt.halfmax).and.(halfangu.lt.nang/2))
3615  halfangu = halfangu + 1
3616  enddo
3617  do while((ef2shift(halfangl).gt.halfmax).and.(halfangl.gt.1))
3618  halfangl = halfangl - 1
3619  enddo
3620  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3621  !!
3622  !! Convert angles indices with respect to peak
3623  !! e.g. halfangl should go to halfangl - (nang/4+1)
3624  !! halfangu should go to halfangu - (nang/4+1)
3625  halfangl = halfangl - (nang/4+1)
3626  halfangu = halfangu - (nang/4+1)
3627  !!
3628  !! Now average the positions, round to nearest integer.
3629  !! -ve result means the centre is one greater than it should be.
3630  maxangshift = nint( 0.5 * (halfangl + halfangu) )
3631  newmaxang = maxang + maxangshift
3632  if (newmaxang .lt. 1) newmaxang = newmaxang + nang
3633  if (newmaxang .gt. nang) newmaxang = newmaxang - nang
3634  !!p3---
3635  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3636  !!
3637  !!p3
3638  !! Bash; need this section if you want to try sin()**mm with 'newmaxang'
3639  !p3 y = ef2(npk,newmaxang) / ef1(npk) !* New Energy Spread
3640  !!
3641  !! Compare value of peak with q-array for closest fit to sin()**m at peak
3642  !! This !p3 section is needed for use with sin()**mm
3643  !! Bash; Note; This new "psi2(:)" although better than original "psi2(:)"
3644  !! it was still not good enough: the 2D Energy was OK but
3645  !! the 2D Snl, now with better symmetry, didn't always have the side lobes.
3646  !p3 mm = 1
3647  !p3 qmin = abs(q(1)-y)
3648  !p3 do m=2,16
3649  !p3 adif = abs(q(m)-y)
3650  !p3 if ( adif.lt.qmin ) then
3651  !p3 qmin = adif
3652  !p3 mm = m
3653  !p3 endif
3654  ! end do
3655  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3656  !!
3657  !! Final step, use 'mm' for sin()**mm
3658  !p3 psi2(n1:n2) = (sinan(n1:n2))**mm !* Un-norm. psi2 distr.
3659  !p3 psi2(n1:n2) = q(mm) * psi2(n1:n2) !* Norm. psi2 distr.
3660  !! Rotate peak to correct angle
3661  !p3 psi2(:) = CSHIFT( psi2(:), newmaxang-1+nang/4 )
3662  !!p3---
3663  !! ------------------------------------------------------------------
3664  !! ==================================================================
3665  !!
3666  !!
3667  !!p4
3668  !! !!p4 is an override of !!p3 with mm=4, so go straight to Final step
3669  !! Note; all you need from !!p3 is the "newmaxang"
3670  !! So it's a sin()**4 distr. shifted to "newmaxang" - worked very well
3671  !! ------------------------------------------------------------------
3672  !!
3673  !! Solve for Normalizing Coefficient for Integral [1.0/(sin()**4)]
3674  !! Note: n1, n2 spans half circle (from 0 to +pi)
3675  n1 = 1
3676  n2 = nang/2 + 1
3677  !p4 sum1 = 0.
3678  !p4 do iang=n1,n2
3679  !p4 sum1 = sum1 + sinan(iang)**4
3680  ! end do
3681  !p4 q4 = 1.0/(sum1*ainc)
3682  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3683  !!
3684  !! Change the angles that aren't zero (0 deg to +180 deg)
3685  psi2(n1:n2) = (sinan(n1:n2))**4 !* Un-norm. psi2 distr.
3686  q4 = 1.0/(sum(psi2(n1:n2))*ainc)
3687  psi2(n1:n2) = q4 * psi2(n1:n2) !* Norm. psi2 distr.
3688  !!
3689  !! Rotate peak to correct angle
3690  psi2(:) = cshift( psi2(:), newmaxang-1+nang/4 )
3691  !!p4---
3692  !! ------------------------------------------------------------------
3693  !! ==================================================================
3694  !!
3695  !!
3696  !!
3697  !! Estimate parametric spectrum and deviation from parametric spectrum
3698  !! ------------------------------------------------------------------
3699  igam = (gam-0.4)*10 + 0.5
3700  sigz = 0.109
3701  gam = igam/10. + 0.4
3702  fdenp = gam * beta / wka(npk)**2.5
3703  !!
3704  !!
3705  do irng=nrmn,nrmx
3706  fr = frqa(irng) / fpk
3707  if ( fr.le.1.0001 ) then
3708  if ( fr.ge.0.85 ) then
3709  ratio = 1.-(1.-fr)*0.7/0.15
3710  else
3711  ratio = 0.3*exp(-17.3*(0.85-fr))
3712  endif
3713  fkscl1(irng) = fdenp*ratio
3714  bscl1(irng) = fkscl1(irng)/oma(irng)
3715  else
3716  z = 0.5*((fr-1.)/sigz)**1.2
3717  if ( z.gt.6. ) z = 6.
3718  ratio = 1.+exp(-z)*(gam-1.)
3719  fkscl1(irng) = beta*ratio/wka(irng)**2.5
3720  bscl1(irng) = fkscl1(irng)/oma(irng)
3721  endif
3722  !!
3723  do iang=1,nang
3724  ddd = bscl1(irng) * psi2(iang) / wka(irng) !* large-scale
3725  dens1(irng,iang) = ddd !* large-scale
3726  dens2(irng,iang) = act2d(irng,iang) - ddd !* small-scale
3727  end do
3728  end do ! do irng=nrmn,nrmx
3729  !! ------------------------------------------------------------------
3730  !! ==================================================================
3731  !!
3732  RETURN
3733  !!

References ainc, dens1, dens2, ef1, ef2, frqa, oma, sinan, and twopi.

Referenced by w3snl4().

◆ shlocr()

subroutine w3snl4md::shlocr ( real, intent(in)  dep,
real, intent(in)  wk1x,
real, intent(in)  wk1y,
real, intent(in)  wk3x,
real, intent(in)  wk3y 
)

N/A.

  With wavenumber vector n identified by (wknx,wkny), its magnitude
  given by wkn = sqrt(wknx**2+wkny**2) and its associated radian
  frequency given by sign = sqrt[g*wkn*tanh(wkn*dep)], where g is
  gravitational acceleration and dep is water depth, the four-wave
  resonance condition is satisfied along a locus of pts defined by

  [1]  (wk1x,wk1y) + (wk2x,wk2y) - (wk3x,wk3y) - (wk4x,wk4y) = 0

  [2]  sig1 + sig2 - sig3 - sig4 = 0

  Because of the influence of depth, it is convenient to define new
  vectors (wnx,wny) = (wknx*dep,wkny*dep) with magnitudes wn =
  sqrt(wnx**2+wny**2) = wkn*dep such that a dimensionless frequency
  is sign*sqrt(dep/g) = sqrt[wkn*dep*tanh(wkn*dep)]
                      = sqrt[wn*tanh(wn)].
  With these definitions and vectors (wk1x,wk1y) and (wk3x,wk3y)
  given as input, we can write (with some rearrangement
  of [1] and [2])

  [3]  w3x - w1x = px = w2x - w4x
  [4]  w3y - w1y = py = w2y - w4y
  [5]  sqrt[w3*tanh(w3)] - sqrt[w1*tanh(w1)] = q
       = sqrt[w2*tanh(w2)] - sqrt[w4*tanh(w4)]

  With dimensionless vector (px,py) = (w3x-w1x,w3y-w1y) [magnitude
  p = sqrt(px**2+py**2), direction atan2(py,px)] and dimensionless
  frequency difference q = sqrt(w3*tanh(w3)] - sqrt(w1*tanh(w1)]
  defined by input parameters, we see from [3] and [4] that
  (w4x,w4y) = (w2x-px,w2y-py) [magnitude w4 = sqrt((w2x-px)**2 +
  (w2y-py)**2)] and thus from [5] we must basically find elements
  w2x and w2y that satisfy

  [6] sqrt[sqrt(w2x**2+w2y**2)*tanh(sqrt(w2x**2+w2y**2))] -
      sqrt[sqrt((w2x-px)**2+(w2y-py)**2) *
           tanh(sqrt((w2x-px)**2+(w2y-py)**2] = q

  The locus curve defined by the set of pts (w2x,w2y) crosses the
  p-vector axis at two points; one with magnitude w2=rmin*p with
  0.5 < rmin < 1.0 and one with magnitude w2=rmax*p with rmax > 1.
  We first isolate rmin, rmax using various iterative algorithms,
  and then find locus pts that are not on the p-vector axis with
  another iterative scheme.  At the end, we un-normalize the w2
  and w4 vectors to find the wk2 and wk4 vectors.
Parameters
[in]dep
[in]wk1x
[in]wk1y
[in]wk3x
[in]wk3y
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 2306 of file w3snl4md.F90.

2306  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2307  !/
2308  !/ +-----------------------------------+
2309  !/ | WAVEWATCH III BIO |
2310  !/ | Bash Toulany |
2311  !/ | Michael Casey |
2312  !/ | William Perrie |
2313  !/ | FORTRAN 90 |
2314  !/ | Last update : 12-Apr-2016 |
2315  !/ +-----------------------------------+
2316  !/
2317  !/ 01-Mar-2016 : Origination. ( version 5.13 )
2318  !/
2319  !! ------------------------------------------------------------------
2320  !!
2321  !! it returns: wk2x, wk2y, wk4x, wk4y & ds all dim=(npts)
2322  !!
2323  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2324  !! ------------------------------------------------------------------
2325  !! ==================================================================
2326  !!
2327  !!
2328  !! 1. Purpose :
2329  !!
2330  !! -----------------------------------------------------------------#
2331  !! !
2332  !! With wavenumber vector n identified by (wknx,wkny), its magnitude!
2333  !! given by wkn = sqrt(wknx**2+wkny**2) and its associated radian !
2334  !! frequency given by sign = sqrt[g*wkn*tanh(wkn*dep)], where g is !
2335  !! gravitational acceleration and dep is water depth, the four-wave !
2336  !! resonance condition is satisfied along a locus of pts defined by !
2337  !! !
2338  !! [1] (wk1x,wk1y) + (wk2x,wk2y) - (wk3x,wk3y) - (wk4x,wk4y) = 0 !
2339  !! !
2340  !! [2] sig1 + sig2 - sig3 - sig4 = 0 !
2341  !! !
2342  !! Because of the influence of depth, it is convenient to define new!
2343  !! vectors (wnx,wny) = (wknx*dep,wkny*dep) with magnitudes wn = !
2344  !! sqrt(wnx**2+wny**2) = wkn*dep such that a dimensionless frequency!
2345  !! is sign*sqrt(dep/g) = sqrt[wkn*dep*tanh(wkn*dep)] !
2346  !! = sqrt[wn*tanh(wn)]. !
2347  !! With these definitions and vectors (wk1x,wk1y) and (wk3x,wk3y) !
2348  !! given as input, we can write (with some rearrangement !
2349  !! of [1] and [2]) !
2350  !! !
2351  !! [3] w3x - w1x = px = w2x - w4x !
2352  !! [4] w3y - w1y = py = w2y - w4y !
2353  !! [5] sqrt[w3*tanh(w3)] - sqrt[w1*tanh(w1)] = q !
2354  !! = sqrt[w2*tanh(w2)] - sqrt[w4*tanh(w4)] !
2355  !! !
2356  !! With dimensionless vector (px,py) = (w3x-w1x,w3y-w1y) [magnitude !
2357  !! p = sqrt(px**2+py**2), direction atan2(py,px)] and dimensionless !
2358  !! frequency difference q = sqrt(w3*tanh(w3)] - sqrt(w1*tanh(w1)] !
2359  !! defined by input parameters, we see from [3] and [4] that !
2360  !! (w4x,w4y) = (w2x-px,w2y-py) [magnitude w4 = sqrt((w2x-px)**2 + !
2361  !! (w2y-py)**2)] and thus from [5] we must basically find elements !
2362  !! w2x and w2y that satisfy !
2363  !! !
2364  !! [6] sqrt[sqrt(w2x**2+w2y**2)*tanh(sqrt(w2x**2+w2y**2))] - !
2365  !! sqrt[sqrt((w2x-px)**2+(w2y-py)**2) * !
2366  !! tanh(sqrt((w2x-px)**2+(w2y-py)**2] = q !
2367  !! !
2368  !! The locus curve defined by the set of pts (w2x,w2y) crosses the !
2369  !! p-vector axis at two points; one with magnitude w2=rmin*p with !
2370  !! 0.5 < rmin < 1.0 and one with magnitude w2=rmax*p with rmax > 1. !
2371  !! We first isolate rmin, rmax using various iterative algorithms, !
2372  !! and then find locus pts that are not on the p-vector axis with !
2373  !! another iterative scheme. At the end, we un-normalize the w2 !
2374  !! and w4 vectors to find the wk2 and wk4 vectors. !
2375  !! -----------------------------------------------------------------#
2376  !!
2377  !! 2. Method :
2378  !!
2379  !! 3. Parameters :
2380  !!
2381  !! Parameter list
2382  !! ------------------------------------------------------------------
2383  !! Name Type Scope I/O Description
2384  !! ------------------------------------------------------------------
2385  !! npts int. Public I # of points on the locus
2386  !! np2p1 int. Public I = npts/2 + 1
2387  !! ----------------------------------------------------------------
2388  !!
2389  !! *** arrays wk2x,wk2y, wk4x,wk4y & ds are related to locus solutioni
2390  !! for given vectors K1 & k3 all have dim=(npts)
2391  !! wk2x R.A. Public O x_cmp of vector k2 solution on the locus
2392  !! wk2y R.A. Public O y_cmp of vector k2 solution on the locus
2393  !! wk4x R.A. Public O x_cmp of vector k4 solution on the locus
2394  !! wk4y R.A. Public O y_cmp of vector k4 solution on the locus
2395  !! ds R.A. Public O element length along the locus
2396  !! (npts*ds circles the whole locus)
2397  !! ----------------------------------------------------------------
2398  !!
2399  !! 4. Subroutines used :
2400  !!
2401  !! Name Type Module Description
2402  !! ----------------------------------------------------------------
2403  !! ----------------------------------------------------------------
2404  !!
2405  !! 5. Called by :
2406  !!
2407  !! Name Type Module Description
2408  !! ----------------------------------------------------------------
2409  !! gridsetr Subr. W3SNL4MD Setup geometric integration grid
2410  !! ----------------------------------------------------------------
2411  !!
2412  !! 6. Error messages :
2413  !!
2414  !! None.
2415  !!
2416  !! 7. Remarks :
2417  !!
2418  !! 8. Structure :
2419  !!
2420  !! See source code.
2421  !!
2422  !! 9. Switches :
2423  !!
2424  !! !/S Enable subroutine tracing.
2425  !!
2426  !!10. Source code :
2427  !!
2428  !! --------------------------------------------------------------- &
2429  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2430  !! ----------------------------------------------------------------72
2431  !! ==================================================================
2432  !!
2433  !!
2434  USE w3servmd, ONLY: extcde
2435  USE w3odatmd, ONLY: ndse
2436  !!
2437  !!
2438  IMPLICIT NONE
2439  !!
2440  !! Parameter list
2441  !! --------------
2442  real, intent(in) :: dep
2443  real, intent(in) :: wk1x,wk1y, wk3x,wk3y
2444  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2445  !! ------------------------------------------------------------------
2446  !!
2447  !!
2448  !! Local Parameters & variables
2449  !! -----------------------------
2450  integer :: n, np, nnp, nplace
2451  integer :: ierr_gr
2452  !!
2453  real :: p, px, py, q, qrtp, qsqp, &
2454  dr, dth, thp, dphi, cphi, &
2455  w1, w1x, w1y, wk1, w3, w3x, w3y, wk3, &
2456  rold, rold1, rold2, rnew, rnew1, rnew2, &
2457  pxod, pyod, zpod, &
2458  t, t1, t2, t3, tm, tp, ds1, ds2, &
2459  rmin, rmax, rcenter, rradius
2460  !!
2461  double precision :: dbt3,dbt4,dbt5,dbt6, dbz, dbp, dbqrtp, &
2462  cdthold, cdthnew, wate1, wate2
2463  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2464  !! ---------------------::-----------------------------------------72
2465  !! ##################################################################
2466  !!------------------------------------------------------------------------------
2467  !!==============================================================================
2468  !!
2469  !!
2470  !!ini
2471  !! initial all returned arrays before they are computed
2472  !! -----------------------------------------------------
2473  wk2x(:) = 0.0
2474  wk2y(:) = 0.0
2475  wk4x(:) = 0.0
2476  wk4y(:) = 0.0
2477  ds(:) = 0.0
2478  !!ini---
2479  !! ------------------------------------------------------------------
2480  !!
2481  !!
2482  !b wk1 = sqrt(wk1x**2 + wk1y**2) !* k1=wk1x since wk1y=0.0
2483  wk1 = wk1x
2484  !b wk3 = sqrt(wk3x**2 + wk3y**2)
2485  wk3 = sqrt(wk3x*wk3x + wk3y*wk3y)
2486  !!
2487  w1 = wk1 * dep
2488  w1x = wk1x * dep
2489  !b w1y = wk1y * dep
2490  w1y = wk1y !* wk1y=0.0
2491  !!
2492  w3 = wk3 * dep
2493  w3x = wk3x * dep
2494  w3y = wk3y * dep
2495  !!
2496  px = w3x - w1x
2497  py = w3y - w1y
2498  !b p = sqrt(px**2 + py**2) !* argument never = 0.0
2499  p = sqrt(px*px + py*py) !* argument never = 0.0
2500 
2501  thp = atan2(py,px)
2502  q = sqrt(w3*tanh(w3)) - sqrt(w1*tanh(w1))
2503  qrtp = q / sqrt(p)
2504  qsqp = qrtp*qrtp
2505  !!
2506  !!
2507  !! -----------------------------------------------------------------#
2508  !! !
2509  !! for (w2x,w2y) = rmin*(px,py) (locus crossing the p-vector axis !
2510  !! nearest the origin), we have (w4x,w4y) = (w2x,w2y) - (px,py) !
2511  !! = rmin*(px,py) - (px,py) = (rmin - 1)*(px,py); note that because !
2512  !! rmin < 1, the length of (w4x,w4y) is w4 = (1 - rmin)*p; then [6] !
2513  !! takes the simpler form !
2514  !! !
2515  !! [7] sqrt(rmin*p*tanh(rmin*p)) - sqrt[(1-rmin)*p*tanh((1-rmin)*p)]!
2516  !! = q !
2517  !! !
2518  !! assuming the tanh() functions are slowly varying and can be !
2519  !! treated as separate entities, [7] can be written as a quadratic !
2520  !! in sqrt(rmin), i.e., !
2521  !! !
2522  !! 2*qrtp*sqrt(rmin*p) !
2523  !! [8] rmin - ------------------- sqrt(rmin) + !
2524  !! T !
2525  !! !
2526  !! qsqp-p*tanh((1-rmin)*p) !
2527  !! ----------------------- = 0, !
2528  !! T !
2529  !! !
2530  !! where T = tanh(rmin*p) + tanh((1-rmin)*p), !
2531  !! qrtp = q/sqrt(p) and qsqp = qrtp**2 !
2532  !! !
2533  !! the square of the most positive root of [8] can (with some !
2534  !! algebra) be written !
2535  !! !
2536  !! [9] rmin = !
2537  !! (1/T**2)*{qsqp*[tanh(rmin*p)-tanh((1-rmin)*p)]+T*tanh((1-rmin)*p) !
2538  !! +2*qrtp*sqrt[tanh(rmin*p)*tanh((1-rmin)*p)]*sqrt(T-qsqp)} !
2539  !! !
2540  !! setting rnew=rmin on the LHS and rold=rmin on the RHS in all !
2541  !! instances allows the creation of an iterative algorithm for rmin;!
2542  !! convergence can be slow in general, so a coarse search for the !
2543  !! crossing of [9] with the rnew=rold line is conducted first, then !
2544  !! a weighted iterative replacement loop is executed until the !
2545  !! desired accuracy is achieved; !
2546  !! Note that if p is sufficiently large, all tanh() -> 1 !
2547  !! and [9] becomes the analytic expression !
2548  !! rmin = 0.5*[1 + qrtp*sqrt(2-qsqp)] !
2549  !! !
2550  !! following is the coarse search using rold1 = 0.5,0.1,1.0, !
2551  !! rold2 = rold1 + 0.1: !
2552  !! !
2553  !! -----------------------------------------------------------------#
2554  !!
2555  !!
2556  ierr_gr = 0
2557  !!
2558  rold1 = 0.5
2559  tp = tanh(rold1 * p)
2560  tm = tanh((1.-rold1) * p)
2561  t = tp + tm
2562  t1 = qsqp * (tp-tm)
2563  t2 = t * tm
2564  t3 = 2. * qrtp * sqrt(tp*tm) * sqrt(t-qsqp)
2565  rnew1 = (t1 + t2 + t3) / (t*t)
2566  !!
2567  !!
2568  do n=1,4
2569  rold2 = rold1 + 0.1
2570  tp = tanh(rold2 * p)
2571  tm = tanh((1.-rold2) * p)
2572  t = tp + tm
2573  t1 = qsqp * (tp-tm)
2574  t2 = t * tm
2575  t3 = 2. * qrtp * sqrt(tp*tm) * sqrt(t-qsqp)
2576  rnew2 = (t1 + t2 + t3) / (t*t)
2577  if ( rnew2 .lt. rold2 ) then
2578  rold = (rold2*rnew1-rold1*rnew2)/(rold2-rold1-rnew2+rnew1)
2579  go to 11
2580  end if
2581  rold1 = rold2
2582  rnew1 = rnew2
2583  end do ! do n=1,4
2584  rold = 0.9 !* default if not otherwise found
2585 11 continue
2586  !! ------------------------------------------------------------------
2587  !!
2588  !!
2589  !! iterative replacement search for rmin
2590  do n=1,50
2591  tp = tanh(rold * p)
2592  tm = tanh((1.-rold) * p)
2593  t = tp + tm
2594  t1 = qsqp * (tp-tm)
2595  t2 = t * tm
2596  t3 = 2. * qrtp*sqrt(tp*tm)*sqrt(t-qsqp)
2597  rnew = (t1 + t2 + t3) / (t*t)
2598  if ( abs(rnew-rold) .lt. 0.00001 ) then
2599  rmin = rnew
2600  go to 21
2601  end if
2602  rold = 0.5 * (rold + rnew)
2603  end do
2604  ierr_gr = ierr_gr + 1 !* set 1's flag in ierr_gr if no convergence
2605  rmin = rnew
2606 21 continue
2607  !! ------------------------------------------------------------------
2608  !!
2609  !! set (dimensional) wavenumber components for this point on locus
2610  wk2x(1) = rmin * px / dep
2611  wk2y(1) = rmin * py / dep
2612  wk4x(1) = (rmin-1.) * px / dep
2613  wk4y(1) = (rmin-1.) * py / dep
2614  !!
2615  !!
2616  !! -----------------------------------------------------------------#
2617  !! !
2618  !! for (w2x,w2y) = rmax*(px,py) (locus crossing the p-vector axis !
2619  !! farthest from the origin), we have (w4x,w4y)=(w2x,w2y) - (px,py) !
2620  !! = rmax*(px,py) - (px,py) = (rmax - 1)*(px,py); !
2621  !! here, because rmax > 1, the length of (w4x,w4y) is !
2622  !! w4 = (rmax - 1)*p; then [6] takes the form !
2623  !! !
2624  !! [10] sqrt(rmax*p*tanh(rmax*p))-sqrt[(rmax-1)*p*tanh((rmax-1)*p)] !
2625  !! = q !
2626  !! !
2627  !! rearranging terms, squaring both sides and again rearranging !
2628  !! terms yields !
2629  !! !
2630  !! [11] rmax*p*[tanh(rmax*p) - tanh((rmax-1)*p)] !
2631  !! = 2*q*sqrt(tanh(rmax*p))*sqrt(rmax*p) + !
2632  !! q**2 + p*tanh((rmax-1)*p) !
2633  !! !
2634  !! because the difference of the two tanh()'s on the LHS tend to !
2635  !! make the whole term small, we solve for rmax from the rapidly !
2636  !! varying part of the first term on the RHS, i.e., !
2637  !! !
2638  !! [tanh((rmax-1)*p)+qsqp + rmax*T]**2 !
2639  !! [12] rmax = ----------------------------------- , !
2640  !! 4*qsqp*tanh(rmax*p) !
2641  !! !
2642  !! where, in this algorithm, T = tanh(rmax*p) - tanh((rmax-1)*p); !
2643  !! as for rmin in [9], setting rnew=rmax on the LHS and rold=rmax !
2644  !! in all instances on the RHS allows the formation of an iterative !
2645  !! algorithm; initially, we only know rmax > 1 so we do a coarse !
2646  !! search in the 10's place out to some reasonably big number to !
2647  !! try to find the place where [12] crosses the rnew = rold line !
2648  !! (if this fails, we set an error flag); in refining the estimate, !
2649  !! it appears that [12] can get a little squirrely, so we do a !
2650  !! brute force successive decimation search to nplace decimal places!
2651  !! to home in on the answer; note that if p is big enough for the !
2652  !! tanh()'s to reach unity, [12] becomes exact and !
2653  !! rmax = [(1 + qsqp)**2]/(4*qsqp) !
2654  !! following is the coarse search with rold = 1,10,2001: !
2655  !! !
2656  !! -----------------------------------------------------------------#
2657  !!
2658  rold = 1.0
2659  do n=1,200
2660  rold = rold + 10.
2661  tp = tanh(rold * p)
2662  tm = tanh((rold-1.) * p)
2663  t = tp - tm
2664  t1 = tm + qsqp
2665  t2 = 4. * tp * qsqp
2666  rnew = ((t1+rold*t)**2) / t2
2667  if ( rnew .lt. rold ) then
2668  rold = rold - 10.
2669  go to 31
2670  end if
2671  end do
2672  ierr_gr = ierr_gr + 10 !* set 10's place in ierr_gr if no sol'n
2673 31 continue
2674  !! ------------------------------------------------------------------
2675  !!
2676  !!
2677  !! successive decimation search to refine rmax
2678  dr = 10.
2679  do nplace=1,6
2680  dr = dr/10.
2681  do n=1,10
2682  rold = rold + dr
2683  tp = tanh(rold * p)
2684  tm = tanh((rold-1.) * p)
2685  t = tp - tm
2686  t1 = tm + qsqp
2687  t2 = 4. * tp * qsqp
2688  rnew = ((t1+rold*t)**2) / t2
2689  if ( rnew .lt. rold ) then
2690  rold = rold - dr
2691  go to 51
2692  end if
2693  end do
2694 51 continue
2695  end do
2696  !!
2697  rmax = rold
2698  !!
2699  !! set (dimensional) wavenumber components for this locus point
2700  !!
2701  wk2x(np2p1) = rmax * px / dep
2702  wk2y(np2p1) = rmax * py / dep
2703  wk4x(np2p1) = (rmax-1.) * px / dep
2704  wk4y(np2p1) = (rmax-1.) * py / dep
2705  !!
2706  !!
2707  !! -----------------------------------------------------------------#
2708  !! !
2709  !! search for cos(dth) for off-p-vector solutions; use a circle !
2710  !! centered on the p-vector axis at a distance !
2711  !! rcenter = 0.5*(rmax+rmin) from the origin with a !
2712  !! radius = 0.5*(rmax-rmin); radii from the center of the circle !
2713  !! at successive angle increments np*dphi intersect the circle at !
2714  !! distances r*p from the origin of the p vector such that !
2715  !! !
2716  !! [13] r**2 = rradius**2 + rcenter**2 - !
2717  !! 2*rcenter*rradius*cos(np*dphi) !
2718  !! !
2719  !! and makes an angle dth with the p vector satisfying !
2720  !! !
2721  !! [14] cdth = cos(dth) = (rcenter/r) - (rradius/r)*cos(np*dphi) !
2722  !! !
2723  !! we then rotate this vector, holding its length=r*p constant and !
2724  !! successively estimating cdth (using the above equation as an !
2725  !! initial guess) until it intersects the locus curve; some algebra !
2726  !! yields the estimation equation as !
2727  !! !
2728  !! r**2 + 1 [sqrt(r*tanh(rp)) - q/sqrt(p)]**4 !
2729  !! [15] cdthnew= ------- - ---------------------------------------- !
2730  !! 2*r 2*r*[tanh(p*sqrt(r**2-2*r*cdthold+1))]**2!
2731  !! !
2732  !! we use a weighted new estimate of cdthold with the weights based !
2733  !! on the argument of the tanh() function in the denominator !
2734  !! (if the argument is big, tanh() -> 1 and cdthnew is found in one !
2735  !! pass; for small arguments, convergence is faster with equal !
2736  !! weighting of old and new estimates; all this is empirical to try !
2737  !! to increase speed); double precision is used to gain enough !
2738  !! accuracy when the arccos is taken; note that if p is big enough !
2739  !! for all tanh()'s -> 1, [15] is exact and !
2740  !! cdthnew = cdth = [r**2 + 1 - (sqrt(r) - qrtp)**4]/(2*r) !
2741  !! !
2742  !! -----------------------------------------------------------------#
2743  !!
2744  !!
2745  rcenter = 0.5 * (rmax + rmin)
2746  rradius = 0.5 * (rmax - rmin)
2747  t1 = rradius**2 + rcenter**2
2748  t2 = 2. * rradius * rcenter
2749  dphi = 6.283185308 / float(npts)
2750  pxod = px / dep
2751  pyod = py / dep
2752  !!
2753  dbp = dble(p)
2754  dbqrtp = dble(qrtp)
2755  !!
2756  !!
2757  do np=2,npts/2 !* np = 2 --> 15
2758  !!
2759  cphi = cos(float(np-1)*dphi)
2760  dbz = dsqrt(dble(t1-t2*cphi))
2761  cdthold = dble(rcenter-rradius*cphi) / dbz
2762  dbt3 = (dbz*dbz) + 1.d0
2763  dbt4 = dbt3 / (2.d0*dbz)
2764  dbt5 = ((dsqrt(dbz*dtanh(dbz*dbp))-dbqrtp)**4)/(2.d0*dbz)
2765  dbt6 = dbp * dsqrt(dbt3-2.d0*dbz*cdthold)
2766  !!
2767  if ( dbt6 .gt. 0.55d0 ) then
2768  wate1 = dtanh(dbt6)
2769  wate2 = 1.d0 - wate1
2770  else
2771  wate1 = 0.5d0
2772  wate2 = 0.5d0
2773  end if
2774  !!
2775  do n=1,25
2776  cdthnew = dbt4 - dbt5 / ((dtanh(dbt6))**2)
2777  if ( dabs(cdthnew-cdthold) .lt. 0.0000001d0 ) go to 71
2778  cdthold = wate1 * cdthnew + wate2 * cdthold
2779  dbt6 = dbp * dsqrt(dbt3-2.d0*dbz*cdthold)
2780  end do
2781  ierr_gr = ierr_gr + 100 !* add to 100's place for every failure
2782 71 continue
2783  !!
2784  dth = sngl(dacos(cdthnew))
2785  zpod = sngl(dbz) * p / dep
2786  !!
2787  wk2x(np) = zpod * cos(thp+dth)
2788  wk2y(np) = zpod * sin(thp+dth)
2789  wk4x(np) = wk2x(np) - pxod
2790  wk4y(np) = wk2y(np) - pyod
2791  !!
2792  nnp = npts-np+2 !* for npts = 30
2793  !! !* nnp = 30 --> 17
2794  !!
2795  wk2x(nnp) = zpod * cos(thp-dth)
2796  wk2y(nnp) = zpod * sin(thp-dth)
2797  wk4x(nnp) = wk2x(nnp) - pxod
2798  wk4y(nnp) = wk2y(nnp) - pyod
2799  !!
2800  end do ! do np=2,npts/2
2801  !! ------------------------------------------------------------------
2802  !!
2803  !!
2804  if ( ierr_gr .ne. 0 ) then
2805  write ( ndse,1000 ) ierr_gr
2806  CALL extcde ( 60 )
2807  endif
2808  !! ------------------------------------------------------------------
2809  !!
2810  !!
2811  !! set arc length ds as the sum of half the segment lengths on either
2812  !! side of a given point
2813  !!
2814  ds1 = sqrt((wk2x(2)-wk2x(1))**2+(wk2y(2)-wk2y(1))**2)
2815  ds(1) = ds1
2816  do np=3,npts/2+1
2817  ds2 = sqrt((wk2x(np)-wk2x(np-1))**2+(wk2y(np)-wk2y(np-1))**2)
2818  ds(np-1) = 0.5*(ds1+ds2)
2819  ds(npts-np+3) = ds(np-1)
2820  ds1 = ds2
2821  end do
2822  ds(npts/2+1) = ds2
2823  !! ------------------------------------------------------------------
2824  !! ==================================================================
2825  !!
2826  RETURN
2827  !!
2828 1000 format ( ' W3SNL4 Error : In shlocr. Error from gridset ',i10)
2829  !!

References ds, w3servmd::extcde(), w3odatmd::ndse, np2p1, npts, wk2x, wk2y, wk4x, and wk4y.

Referenced by gridsetr().

◆ shloxr()

subroutine w3snl4md::shloxr ( real, intent(in)  dep,
real, intent(in)  wk1x,
real, intent(in)  wk1y,
real, intent(in)  wk3x,
real, intent(in)  wk3y 
)

General locus solution for input vectors (wk1x,wk1y).

    General locus solution for input vectors (wk1x,wk1y) and
    (wk3x,wk3y) of the same magnitude but NOT in the same direction
    (or singularness will occur), output vectors (wk2x,wk2y) and
    (wk4x,wk4y), and element length ds along locus curve:

    With wavenumber vector n identified by (wknx,wkny), its magnitude
    given by wkn = sqrt(wknx**2+wkny**2) and its associated radian
    frequency given by sign = sqrt[g*wkn*tanh(wkn*dep)], where g is
    gravitational acceleration and dep is water depth, the four-wave
    resonance condition is satisfied along a locus of pts defined by

    [1]  (wk1x,wk1y) + (wk2x,wk2y) - (wk3x,wk3y) - (wk4x,wk4y) = 0

    [2]  sig1 + sig2 - sig3 - sig4 = 0

    In the case where k1 [= sqrt(wk1x**2+wk1y**2)] is equal to k3
    [= sqrt(wk3x**2+wk3y**2)], we have by dispersion,

    [3]  sig1 = sqrt[g*k1*tanh(k1*h)] = sqrt[g*k3*tanh(k3*h)] = sig3

    so sig1 - sig3 = 0 and [2] becomes sig2 = sig4, where, again by
    dispersion,

    [4]  sig2 = sqrt(g*k2*tanh(k2*h)] = sig4 = sqrt(g*k4*tanh(k4*h)]

    and consequently k2 = k4.  This simplifies the locus solution
    considerably, and it can be shown that the (wk2x,wk2y) locus is
    along the perpendicular bisector of the (px,py) vector given by

    [5]  (px,py) = (wk3x-wk1x,wk3y-wk1y)

    and thereby from [1]
    [6]  (wk4x,wk4y) = (wk2x,wk2y) - (px,py)

    We note that these loci are independent of depth, although depth
    is used to set the length of the locus line by requiring that its
    range on either side of the p vector correspond to a wave with a
    wkx freq four times that of the k1 vector (the locus line is made
    up of npts segments of length ds; the outer edges of the terminal
    segments satisfy the length constraint; vectors k2 and k4 extend
    to segment centers and will sufficiently approximate the length
    constraint).  As compared to srshlocr.f, we can do all
    calculations here in dimensional space.
Parameters
[in]dep
[in]wk1x
[in]wk1y
[in]wk3x
[in]wk3y
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 2011 of file w3snl4md.F90.

2011  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2012  !/
2013  !/ +-----------------------------------+
2014  !/ | WAVEWATCH III BIO |
2015  !/ | Bash Toulany |
2016  !/ | Michael Casey |
2017  !/ | William Perrie |
2018  !/ | FORTRAN 90 |
2019  !/ | Last update : 12-Apr-2016 |
2020  !/ +-----------------------------------+
2021  !/
2022  !/ 01-Mar-2016 : Origination. ( version 5.13 )
2023  !/
2024  !! ------------------------------------------------------------------
2025  !!
2026  !! it returns: wk2x, wk2y, wk4x, wk4y & ds all dim=(npts)
2027  !!
2028  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2029  !! ------------------------------------------------------------------
2030  !! ==================================================================
2031  !!
2032  !!
2033  !! 1. Purpose :
2034  !!
2035  !! -------------------------------------------------------------------------#
2036  !! !
2037  !! General locus solution for input vectors (wk1x,wk1y) and !
2038  !! (wk3x,wk3y) of the same magnitude but NOT in the same direction !
2039  !! (or singularness will occur), output vectors (wk2x,wk2y) and !
2040  !! (wk4x,wk4y), and element length ds along locus curve: !
2041  !! !
2042  !! With wavenumber vector n identified by (wknx,wkny), its magnitude !
2043  !! given by wkn = sqrt(wknx**2+wkny**2) and its associated radian !
2044  !! frequency given by sign = sqrt[g*wkn*tanh(wkn*dep)], where g is !
2045  !! gravitational acceleration and dep is water depth, the four-wave !
2046  !! resonance condition is satisfied along a locus of pts defined by !
2047  !! !
2048  !! [1] (wk1x,wk1y) + (wk2x,wk2y) - (wk3x,wk3y) - (wk4x,wk4y) = 0 !
2049  !! !
2050  !! [2] sig1 + sig2 - sig3 - sig4 = 0 !
2051  !! !
2052  !! In the case where k1 [= sqrt(wk1x**2+wk1y**2)] is equal to k3 !
2053  !! [= sqrt(wk3x**2+wk3y**2)], we have by dispersion, !
2054  !! !
2055  !! [3] sig1 = sqrt[g*k1*tanh(k1*h)] = sqrt[g*k3*tanh(k3*h)] = sig3 !
2056  !! !
2057  !! so sig1 - sig3 = 0 and [2] becomes sig2 = sig4, where, again by !
2058  !! dispersion, !
2059  !! !
2060  !! [4] sig2 = sqrt(g*k2*tanh(k2*h)] = sig4 = sqrt(g*k4*tanh(k4*h)] !
2061  !! !
2062  !! and consequently k2 = k4. This simplifies the locus solution !
2063  !! considerably, and it can be shown that the (wk2x,wk2y) locus is !
2064  !! along the perpendicular bisector of the (px,py) vector given by !
2065  !! !
2066  !! [5] (px,py) = (wk3x-wk1x,wk3y-wk1y) !
2067  !! !
2068  !! and thereby from [1] !
2069  !! [6] (wk4x,wk4y) = (wk2x,wk2y) - (px,py) !
2070  !! !
2071  !! We note that these loci are independent of depth, although depth !
2072  !! is used to set the length of the locus line by requiring that its !
2073  !! range on either side of the p vector correspond to a wave with a !
2074  !! wkx freq four times that of the k1 vector (the locus line is made !
2075  !! up of npts segments of length ds; the outer edges of the terminal !
2076  !! segments satisfy the length constraint; vectors k2 and k4 extend !
2077  !! to segment centers and will sufficiently approximate the length !
2078  !! constraint). As compared to srshlocr.f, we can do all !
2079  !! calculations here in dimensional space. !
2080  !! -------------------------------------------------------------------------#
2081  !!
2082  !! 2. Method :
2083  !!
2084  !! 3. Parameters :
2085  !!
2086  !! Parameter list
2087  !! ------------------------------------------------------------------
2088  !! Name Type Scope I/O Description
2089  !! ------------------------------------------------------------------
2090  !! npts int. Public I # of points on the locus
2091  !! np2p1 int. Public I = npts/2 + 1
2092  !! ----------------------------------------------------------------
2093  !!
2094  !! *** arrays wk2x,wk2y, wk4x,wk4y & ds are related to locus solutioni
2095  !! for given vectors K1 & k3 all have dim=(npts)
2096  !! wk2x R.A. Public O x_cmp of vector k2 solution on the locus
2097  !! wk2y R.A. Public O y_cmp of vector k2 solution on the locus
2098  !! wk4x R.A. Public O x_cmp of vector k4 solution on the locus
2099  !! wk4y R.A. Public O y_cmp of vector k4 solution on the locus
2100  !! ds R.A. Public O element length along the locus
2101  !! (npts*ds circles the whole locus)
2102  !! ----------------------------------------------------------------
2103  !!
2104  !! 4. Subroutines used :
2105  !!
2106  !! Name Type Module Description
2107  !! ----------------------------------------------------------------
2108  !! ----------------------------------------------------------------
2109  !!
2110  !! 5. Called by :
2111  !!
2112  !! Name Type Module Description
2113  !! ----------------------------------------------------------------
2114  !! gridsetr Subr. W3SNL4MD Setup geometric integration grid
2115  !! ----------------------------------------------------------------
2116  !!
2117  !! 6. Error messages :
2118  !!
2119  !! None.
2120  !!
2121  !! 7. Remarks :
2122  !!
2123  !! 8. Structure :
2124  !!
2125  !! See source code.
2126  !!
2127  !! 9. Switches :
2128  !!
2129  !! !/S Enable subroutine tracing.
2130  !!
2131  !!10. Source code :
2132  !!
2133  !! --------------------------------------------------------------- &
2134  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2135  !! ----------------------------------------------------------------72
2136  !! ==================================================================
2137  !!
2138  !!
2139  !!wvn
2140  !wvn USE W3DISPMD, ONLY: WAVNU2
2141  !!wvn---
2142  !!
2143  IMPLICIT NONE
2144  !!
2145  !! Parameter list
2146  !! --------------
2147  real, intent(in) :: dep
2148  real, intent(in) :: wk1x,wk1y, wk3x,wk3y
2149  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2150  !! ------------------------------------------------------------------
2151  !!
2152  !!
2153  !! Local Parameters & variables
2154  !! -----------------------------
2155  integer :: m, n
2156  real :: g
2157  real :: wk1, f1, fx
2158  real :: wkx, db, px, py, p, thp, halfp
2159  real :: a, b, dth, a_halfp
2160  !a real :: wkfnc !* real function or use WAVNU2
2161  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2162  !! ---------------------::-----------------------------------------72
2163  !! ##################################################################
2164  !!------------------------------------------------------------------------------
2165  !!==============================================================================
2166  !!
2167  !!
2168  !! initial constants
2169  !! ------------------
2170  g = 9.806 !* set = GRAV as in CONSTANTS
2171  !!
2172  !!ini
2173  !! initial all returned arrays before they are computed
2174  !! -----------------------------------------------------
2175  wk2x(:) = 0.0
2176  wk2y(:) = 0.0
2177  wk4x(:) = 0.0
2178  wk4y(:) = 0.0
2179  ds(:) = 0.0
2180  !!ini---
2181  !! ------------------------------------------------------------------
2182  !!
2183  !!wkx Bash; Try use wkx = wka(nrng) instead of wkx = wkfnc(4.*f1,dep)
2184  !b wk1 = sqrt(wk1x**2+wk1y**2) !* k1=wk1x since wk1y=0.0
2185  wk1 = wk1x
2186  f1 = sqrt(g*wk1*tanh(wk1*dep))/twopi !* f1=f(k1,dep)
2187  fx = 4. * f1 !* fx = 4*f1
2188  !!
2189  !!wvn Bash; Try use subr WAVNU2 instead of function wkfnc
2190  !wvn call WAVNU2(twopi*fx,dep,wkx,cgx) !* => wkx=k(4*f1,dep) & cgx=Cg(4*f1,dep)
2191  wkx = wkfnc(fx,dep) !* +> wkx=k(4*f1,dep) (cgx not needed)
2192  !!wvn---
2193  !! ------------------------------------------------------------------
2194  !!
2195  db = wkx/float(np2p1-1) !* locus length increment
2196  !!
2197  !!
2198  px = wk3x - wk1x
2199  py = wk3y - wk1y !* wk1y=0.0 can be omitted
2200  !b p = sqrt(px**2 + py**2) !* argument never = 0.0
2201  p = sqrt(px*px + py*py)
2202  thp = atan2(py,px)
2203  halfp = 0.5*p
2204  !!
2205  !!
2206  do n=np2p1,npts !* for npts = 30
2207  !! !* n = 16 --> 30
2208  !!
2209  !b b = 0.5 * db + float(n-np2p1) * db
2210  b = db * (0.5 + float(n-np2p1))
2211  !b a = sqrt(1. + (2.*b/p)**2)
2212  a = sqrt(1. + (2.*b/p)*(2.*b/p))
2213  dth = acos(1./a)
2214  a_halfp = a*halfp
2215  !!
2216  !b wk2x(n) = a*halfp * cos(thp+dth)
2217  !b wk2y(n) = a*halfp * sin(thp+dth)
2218  wk2x(n) = a_halfp * cos(thp+dth)
2219  wk2y(n) = a_halfp * sin(thp+dth)
2220  wk4x(n) = wk2x(n) - px
2221  wk4y(n) = wk2y(n) - py
2222  ds(n) = db
2223  !!
2224  m = npts - n + 1 !* m = 15 --> 1
2225  !b wk2x(m) = a*halfp * cos(thp-dth)
2226  !b wk2y(m) = a*halfp * sin(thp-dth)
2227  wk2x(m) = a_halfp * cos(thp-dth)
2228  wk2y(m) = a_halfp * sin(thp-dth)
2229  wk4x(m) = wk2x(m) - px
2230  wk4y(m) = wk2y(m) - py
2231  ds(m) = db
2232  !!
2233  end do ! do n=np2p1,npts
2234  !! ------------------------------------------------------------------
2235  !! ==================================================================
2236  !!
2237  RETURN
2238  !!

References ds, np2p1, npts, twopi, wk2x, wk2y, wk4x, wk4y, and wkfnc().

Referenced by gridsetr().

◆ snlr_fbi()

subroutine w3snl4md::snlr_fbi ( real, dimension(nrng), intent(in)  pha,
integer, intent(in)  ialt 
)

For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to wave-wave interaction.

For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to wave-wave interaction, as well as some ancillary arrays relating to positive and negative fluxes and their integrals.

Parameters
[in]phaPha = k*dk*dtheta.
[in]ialtInteger switch.
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 3758 of file w3snl4md.F90.

3758  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3759  !/
3760  !/ +-----------------------------------+
3761  !/ | WAVEWATCH III BIO |
3762  !/ | Bash Toulany |
3763  !/ | Michael Casey |
3764  !/ | William Perrie |
3765  !/ | FORTRAN 90 |
3766  !/ | Last update : 12-Apr-2016 |
3767  !/ +-----------------------------------+
3768  !/
3769  !/ 01-Mar-2016 : Origination. ( version 5.13 )
3770  !/
3771  !! ------------------------------------------------------------------
3772  !!
3773  !! it returns: fbi & diag2 all dim=(nrng,nang)
3774  !!
3775  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3776  !! ------------------------------------------------------------------
3777  !! ==================================================================
3778  !!
3779  !!
3780  !! 1. Purpose :
3781  !!
3782  !! -----------------------------------------------------------------#
3783  !! !
3784  !! For a given Action Density array dens1(k,theta), computes the !
3785  !! rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to !
3786  !! wave-wave interaction, as well as some ancillary arrays !
3787  !! relating to positive and negative fluxes and their integrals. !
3788  !! !
3789  !! -----------------------------------------------------------------#
3790  !! !
3791  !! Compute: !
3792  !! -------- !
3793  !! for both -tsa and -fbi !
3794  !! + sumint contains scale 1 contibution for Snl -tsa & Snl -fbi !
3795  !! !
3796  !! for -tsa !
3797  !! + sumintsa contains tsa approximation to Snl -tsa !
3798  !! !
3799  !! for -fbi !
3800  !! + sumintp contains scale 2 contribution to Snl -fbi !
3801  !! + sumintx contains cross interactions between scales 1 and 2 !
3802  !! -----------------------------------------------------------------#
3803  !!
3804  !! 2. Method :
3805  !!
3806  !! 3. Parameters :
3807  !!
3808  !! Parameter list
3809  !! ------------------------------------------------------------------
3810  !! Name Type Scope I/O Description
3811  !! ------------------------------------------------------------------
3812  !! nrng int. Public I # of freq. or rings
3813  !! nang int. Public I # of angles
3814  !! npts int. Public I # of points on the locus
3815  !! nzz int. Public I linear irng x krng = (NK*(NK+1))/2
3816  !! ialt int. Public I integer switch ialt=2; do alternate
3817  !! ialt=1; do not alternate
3818  !! kzone int. Public I zone of influence = INT(alog(4.0)/alog(dfrq))
3819  !! na2p1 int. Public I = nang/2 + 1
3820  !! np2p1 int. Public I = npts/2 + 1
3821  !! dfrq real Public I frequency multiplier for log freq. spacing
3822  !! frqa R.A. Public I radian frequencies (Hz); dim=(nrng)
3823  !! pha R.A. local I pha = k*dk*dtheta ; dim=(nrng)
3824  !! ------------------------------------------------------------------
3825  !!
3826  !! *** The 11 grid integration geometry arrays at one given depth
3827  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
3828  !! kref2 I.A. Public I Index of reference wavenumber for k2
3829  !! kref4 I.A. Public I Idem for k4
3830  !! jref2 I.A. Public I Index of reference angle for k2
3831  !! jref4 I.A. Public I Idem for k4
3832  !! wtk2 R.A. Public I k2 Interpolation weigth along wavenumbers
3833  !! wtk4 R.A. Public I Idem for k4
3834  !! wta2 R.A. Public I k2 Interpolation weigth along angles
3835  !! wta4 R.A. Public I Idem for k4
3836  !! tfac2 R.A. Public I Norm. for interp Action Density at k2
3837  !! tfac4 R.A. Public I Idem for k4
3838  !! grad R.A. Public I Coupling and gradient term in integral
3839  !! grad = C * H * g**2 * ds / |dW/dn|
3840  !! ------------------------------------------------------------------
3841  !!
3842  !! *** large & small scale Action Density from optsa dim=(nrng,nang)
3843  !! dens1 R.A. Public I lrg-scl Action Density (k,theta);
3844  !! dens2 R.A. Public I Sml-scl Action Density (k,theta);
3845  !! ------------------------------------------------------------------
3846  !!
3847  !! for both -tsa and -fbi
3848  !! sumint R.A. local O contains scale 1 contribution to Snl
3849  !! dim=(nrng,nang)
3850  !! for -tsa
3851  !! sumintsa R.A. local O contains tsa approximation to Snl -tsa
3852  !! dim=(nrng,nang)
3853  !! for -fbi
3854  !! sumintp R.A. local O contains scale 2 contribution to Snl -fbi
3855  !! dim=(nrng,nang)
3856  !! sumintx R.A. local O contains cross interactions " " " -fbi
3857  !! dim=(nrng,nang)
3858  !! ------------------------------------------------------------------
3859  !!
3860  !! for -tsa; The 2 returned arrays tsa & diag dim=(nrng,nang)
3861  !! tsa R.A. Public O Snl-tsa = sumint + sumintsa
3862  !! diag R.A. Public O Snl-tsa diagonal term = [dN/dn1]
3863  !! ------------------------------------------------------------------
3864  !!
3865  !! for -fbi; The 2 returned arrays fbi & diag2 dim=(nrng,nang)
3866  !! fbi R.A. Public O Snl-fbi = sumint + sumintp + sumintx
3867  !! diag2 R.A. Public O Snl-fbi diagonal term = [dN/dn1]
3868  !! ------------------------------------------------------------------
3869  !!
3870  !! 4. Subroutines used :
3871  !!
3872  !! Name Type Module Description
3873  !! ----------------------------------------------------------------
3874  !! ----------------------------------------------------------------
3875  !!
3876  !! 5. Called by :
3877  !!
3878  !! Name Type Module Description
3879  !! ----------------------------------------------------------------
3880  !! gridsetr Subr. W3SNL4MD Setup geometric integration grid
3881  !! ----------------------------------------------------------------
3882  !!
3883  !! 6. Error messages :
3884  !!
3885  !! None.
3886  !!
3887  !! 7. Remarks :
3888  !!
3889  !! 8. Structure :
3890  !!
3891  !! See source code.
3892  !!
3893  !! 9. Switches :
3894  !!
3895  !! !/S Enable subroutine tracing.
3896  !!
3897  !!10. Source code :
3898  !!
3899  !! --------------------------------------------------------------- &
3900  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3901  !! ----------------------------------------------------------------72
3902  !! ==================================================================
3903  !!
3904  !!
3905  IMPLICIT NONE
3906  !!
3907  !! Parameter list
3908  !! --------------
3909  real, intent(in) :: pha(nrng)
3910  integer, intent(in) :: ialt
3911  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3912  !! ------------------------------------------------------------------
3913  !!
3914  !!
3915  !! Local Parameters & variables
3916  !! -----------------------------
3917  !! for both -tsa and -fbi
3918  integer :: irng,krng, iang,kang
3919  integer :: ipt, iizz, izz
3920  integer :: kmax
3921  integer :: ia2, ia2p, k2, k2p
3922  integer :: ia4, ia4p, k4, k4p
3923  integer :: nref
3924  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3925  !!
3926  !! for -tsa
3927  !tsa integer :: nklimit, nalimit
3928  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3929  !!
3930  !! for both -tsa and -fbi
3931  real :: d1, d3, d2, d4
3932  real :: dp1, dp3
3933  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3934  !!
3935  !! for both -tsa and -fbi
3936  !! but for -tsa they are being calc. inside if/endif if test is successful
3937  !! and for -fbi they are being calc. outside if/endif always
3938  real :: dz4, dz5
3939  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3940  !!
3941  !! for both -tsa and -fbi
3942  real :: dx13, ds13, dxp13, dsp13
3943  real :: dgm, t31, tr31
3944  real :: w2, w2p, wa2, wa2p, d2a, d2b, tt2
3945  real :: w4, w4p, wa4, wa4p, d4a, d4b, tt4
3946  real :: sumint(nrng,nang)
3947  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3948  !!
3949  !! for -tsa
3950  !tsa real :: dz2a, dz3a, ttsa, trtsa
3951  !tsa real :: ddn1, ddn3, diagk1, diagk3
3952  !tsa real :: sumintsa(nrng,nang)
3953  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3954  !!
3955  !! for -fbi
3956  real :: dp2, dp4
3957  real :: d2pa, d4pa
3958  real :: d2pb, d4pb
3959  real :: dz1, dz2, dz3, dz6, dz7, dz8
3960  real :: dgmp, tp31, trp31, dzsum, txp31, trx31
3961  !!
3962  !! for -fbi; Bash added 4 new terms for a full expression of diag2 term
3963  real :: ddp1, ddp2, ddp3, ddp4 !* ddpi=di+dpi for i=1,4
3964  real :: dd2n1, dd2n3, diag2k1, diag2k3
3965  real :: sumintp(nrng,nang)
3966  real :: sumintx(nrng,nang)
3967  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3968  !! ---------------------::-----------------------------------------72
3969  !! ##################################################################
3970  !!------------------------------------------------------------------------------
3971  !!==============================================================================
3972  !!
3973  !!
3974  !! for -tsa
3975  !! Bash; hardwire these two parameters
3976  !tsa nklimit = 6
3977  !tsa nalimit = 6
3978  !!
3979  !!
3980  !!ini
3981  !! Bash; move initialization of all returned arrays from below to here
3982  !! ------------------------------------------------------------------
3983  !! for both -tsa and -fbi
3984  !! sumint is now initialized here instead of below!
3985  sumint(:,:) = 0.0
3986  !!
3987  !! for -tsa
3988  !! sumintsa are now initialized here instead of below!
3989  !tsa sumintsa(:,:) = 0.0
3990  !tsa tsa(:,:) = 0.0
3991  !tsa diag(:,:) = 0.0
3992  !!
3993  !! for -fbi
3994  !! sumintp and sumintx are now initialized here instead of below!
3995  sumintp(:,:) = 0.0
3996  sumintx(:,:) = 0.0
3997  fbi(:,:) = 0.0
3998  diag2(:,:) = 0.0
3999  !!ini---
4000  !! ------------------------------------------------------------------
4001  !! ------------------------------------------------------------------
4002  !! ##################################################################
4003  !!
4004  !!
4005  !! for -tsa
4006  !tsa ddn1 = 0.0 !* for -tsa diag [dN/dn1]
4007  !tsa ddn3 = 0.0 !* for -tsa diag [dN/dn3]
4008  !!
4009  !! for -fbi
4010  dd2n1 = 0.0 !* for -fbi diag2 [dN/dn1]
4011  dd2n3 = 0.0 !* for -fbi diag2 [dN/dn3]
4012  !!
4013  !!
4014  !!
4015  !!50
4016  do 50 irng=1,nrng,ialt
4017  !!kz
4018  kmax = min(irng+kzone, nrng) !* Bash; Sometimes a locus pt is outside nrng
4019  !kz kmax = min(irng+kzone, nrng-1) !* Bash; Taking 1 out will not affect kzone, try it
4020  !!kz---
4021  !!
4022  iizz = (nrng-1)*(irng-1) - ((irng-2)*(irng-1))/2
4023  !! ----------------------------------------------------------------
4024  !!
4025  !!
4026  !!60
4027  do 60 iang=1,nang,ialt
4028  !!
4029  !! for both -tsa and -fbi
4030  d1 = dens1(irng,iang)
4031  dp1 = dens2(irng,iang)
4032  !!
4033  !! for -fbi
4034  ddp1 = d1+dp1 !! for full expression of diag2 term
4035  !!
4036  !!70
4037  !!kz
4038  !kz do 70 krng=irng,nrng
4039  do 70 krng=irng,kmax,ialt
4040  !!
4041  !! for both -tsa and -fbi
4042  !! Bash; check5 be consistent with gridsetr
4043  !! moved here from below (was after do 80 kang=1,nang)
4044  !! and changed go to 80 into go to 70 (i.e. go to next krng)
4045  !kz if ( frqa(krng)/frqa(irng) .gt. 4. ) go to 70 !* original gridsetr
4046  !kz if ( frqa(krng)/frqa(irng) .gt. 3. ) go to 70 !* original snlr_'s
4047  !kz if ( frqa(krng)/frqa(irng) .gt. 2. ) go to 70 !* Bash; use .gt. 2
4048  !!kz---
4049  !!
4050  izz = krng + iizz
4051  !! ------------------------------------------------------------
4052  !!
4053  !!80
4054  do 80 kang=1,nang,ialt
4055  !!
4056  !! for both -tsa and -fbi
4057  !!ba1 Bash; Remove self interaction
4058  !! skip k1 but keep the opposite angle to k1 - original setting
4059  if ( krng.eq.irng ) then !* wn3 = wn1
4060  if ( kang.eq.iang ) go to 80 !* th3 = th1
4061  endif
4062  !!ba1---
4063  !! ----------------------------------------------------------
4064  !!
4065  !! for both -tsa and -fbi
4066  d3 = dens1(krng,kang)
4067  dp3 = dens2(krng,kang)
4068  !!
4069  !! for -fbi
4070  ddp3 = d3+dp3 !! for full expression of diag2 term
4071  !!
4072  !!
4073  !! for both -tsa and -fbi
4074  nref = kang - iang + 1
4075  if ( nref .lt. 1 ) nref = nref + nang
4076  !!
4077  !!
4078  !! for both -tsa and -fbi
4079  !! Bash; check5 be consistent with gridsetr
4080  !! and move this test above right after do 70 krng=irng,nrng
4081  !x if ( frqa(krng)/frqa(irng) .gt. 4. ) go to 80 !* gridsetr
4082  !b if ( frqa(krng)/frqa(irng) .gt. 3. ) go to 80 !* original
4083  !!
4084  !!
4085  !! for both -tsa and -fbi
4086  t31 = 0.0 !* must be reset to 0.0
4087  !!
4088  !! for -tsa
4089  !tsa ttsa = 0.0 !* must be reset to 0.0
4090  !tsa diagk1 = 0.0 !* must be reset to 0.0
4091  !tsa diagk3 = 0.0 !* must be reset to 0.0
4092  !!
4093  !! for -fbi
4094  tp31 = 0.0 !* must be reset to 0.0
4095  txp31 = 0.0 !* must be reset to 0.0
4096  diag2k1 = 0.0 !* must be reset to 0.0
4097  diag2k3 = 0.0 !* must be reset to 0.0
4098  !!
4099  !! for both -tsa and -fbi
4100  dx13 = d1*d3
4101  ds13 = d3-d1
4102  dxp13 = dp1*dp3
4103  dsp13 = dp3-dp1
4104  !! ----------------------------------------------------------
4105  !!
4106  !!90
4107  do 90 ipt=1,npts
4108  !!
4109  !! for both -tsa and -fbi
4110  !! save time by skipping insignificant contributions
4111  !!e-30
4112  !e-30 if ( grad(ipt,nref,izz) .lt. 1.e-30 ) go to 90
4113  !!e-30---
4114  if ( grad(ipt,nref,izz) .lt. 1.e-15 ) go to 90
4115  !!e-30---
4116  !! --------------------------------------------------------
4117  !!
4118  !!xlc1 Bash; skip k1 but keep the opposite angle to k1 - original setting
4119  !xlc1 if ( kang.eq.iang ) then !* th3=+th1
4120  !xlc1 if (ipt.eq.1 .or. ipt.eq.np2p1) go to 90 !* skip x-axis loci
4121  !xlc1 end if
4122  !!xlc1---
4123  !! --------------------------------------------------------
4124  !!
4125  !!
4126  !!2 Estimation of Density for wave #2
4127  !!
4128  !! for both -tsa and -fbi
4129  k2 = kref2(ipt,nref,izz)
4130  k2p = k2 + 1
4131  w2 = wtk2(ipt,nref,izz)
4132  w2p = 1. - w2
4133  !!
4134  !! for both -tsa and -fbi
4135  ia2 = iang + jref2(ipt,nref,izz)
4136  if ( ia2 .gt. nang ) ia2 = ia2 - nang
4137  !!
4138  !! for both -tsa and -fbi
4139  ia2p = ia2 + 1
4140  if ( ia2p .gt. nang ) ia2p = ia2p - nang
4141  !!
4142  !! for both -tsa and -fbi
4143  wa2 = wta2(ipt,nref,izz)
4144  wa2p = 1. - wa2
4145  d2a = w2 * dens1(k2,ia2) + w2p * dens1(k2p,ia2)
4146  d2b = w2 * dens1(k2,ia2p) + w2p * dens1(k2p,ia2p)
4147  tt2 = tfac2(ipt,nref,izz)
4148  d2 = (wa2*d2a + wa2p*d2b) * tt2
4149  !!
4150  !! for -fbi
4151  d2pa = w2 * dens2(k2,ia2) + w2p * dens2(k2p,ia2)
4152  d2pb = w2 * dens2(k2,ia2p) + w2p * dens2(k2p,ia2p)
4153  !!
4154  !! for -fbi
4155  dp2 = (wa2*d2pa + wa2p*d2pb) * tt2 !* for -fbi
4156  ddp2 = d2+dp2 !! for full expression of diag2 term
4157  !! ========================================================
4158  !!
4159  !!
4160  !!4 Estimation of Density for wave #4
4161  !!
4162  !! for both -tsa and -fbi
4163  k4 = kref4(ipt,nref,izz)
4164  k4p = k4 + 1
4165  w4 = wtk4(ipt,nref,izz)
4166  w4p = 1. - w4
4167  !!
4168  !! for both -tsa and -fbi
4169  ia4 = iang + jref4(ipt,nref,izz)
4170  if ( ia4 .gt. nang ) ia4 = ia4 - nang
4171  !!
4172  !! for both -tsa and -fbi
4173  ia4p= ia4 + 1
4174  if ( ia4p .gt. nang ) ia4p = ia4p - nang
4175  !!
4176  !! for both -tsa and -fbi
4177  wa4 = wta4(ipt,nref,izz)
4178  wa4p = 1. - wa4
4179  d4a = w4*dens1(k4,ia4) + w4p*dens1(k4p,ia4)
4180  d4b = w4*dens1(k4,ia4p) + w4p*dens1(k4p,ia4p)
4181  tt4 = tfac4(ipt,nref,izz)
4182  d4 = (wa4*d4a + wa4p*d4b) * tt4
4183  !!
4184  !! for -fbi
4185  d4pa = w4*dens2(k4,ia4) + w4p*dens2(k4p,ia4)
4186  d4pb = w4*dens2(k4,ia4p) + w4p*dens2(k4p,ia4p)
4187  !!
4188  !! for -fbi
4189  dp4 = (wa4*d4pa + wa4p*d4pb) * tt4 !* for -fbi
4190  ddp4 = d4+dp4 !! for full expression of diag2 term
4191  !! ========================================================
4192  !!
4193  !!
4194  !! for both -tsa and -fbi
4195  dgm = dx13*(d4-d2) + ds13*d4*d2 !* dgm=B of R&P'08 eqn(8)
4196  !! !* represents Broad Scale interactions
4197  t31 = t31 + dgm * grad(ipt,nref,izz)
4198  !! --------------------------------------------------------
4199  !!
4200  !! for -fbi
4201  dgmp = dxp13*(dp4-dp2) + dsp13*dp4*dp2 !* dgmp=L of R&P'08 eqn(8)
4202  !! !* represents Local Scale interactions
4203  tp31 = tp31 + dgmp * grad(ipt,nref,izz)
4204  !! --------------------------------------------------------
4205  !! ========================================================
4206  !!
4207  !!
4208  !! for -tsa : -diag
4209  !! use this expression for the diagonal term
4210  !! whose derivation neglect "dp2" & "dp4"
4211  !tsa ddn1 = (d3+dp3)*(d4-d2) - d4*d2 !* dN/dn1
4212  !tsa ddn3 = (d1+dp1)*(d4-d2) + d4*d2 !* dN/dn3
4213  !tsa diagk1 = diagk1 + ddn1 * grad(ipt,nref,izz)
4214  !tsa diagk3 = diagk3 + ddn3 * grad(ipt,nref,izz)
4215  !! --------------------------------------------------------
4216  !!
4217  !! for -fbi : -diag2
4218  !! use the full expression for the diagonal terms
4219  !! whose derivation keeps all large + small scale
4220  dd2n1 = ddp3*(ddp4-ddp2) - ddp4*ddp2 !* dN/dn1
4221  dd2n3 = ddp1*(ddp4-ddp2) + ddp4*ddp2 !* dN/dn3
4222  diag2k1 = diag2k1 + dd2n1 * grad(ipt,nref,izz)
4223  diag2k3 = diag2k3 + dd2n3 * grad(ipt,nref,izz)
4224  !! --------------------------------------------------------
4225  !! ========================================================
4226  !!
4227  !!
4228  !! for -fbi
4229  dz1 = dx13 * (dp4-dp2)
4230  dz2 = d1*dp3 * ((d4-d2)+(dp4-dp2))
4231  dz3 = d3*dp1 * ((d4-d2)+(dp4-dp2))
4232  !!
4233  !! for -fbi (calc. dz4 & dz5 here)
4234  dz4 = dxp13 * (d4-d2)
4235  dz5 = d2*d4 * dsp13
4236  !!
4237  !! for -tsa
4238  !! Cross-interactions between parametric and perturbation
4239  !! that occur only when k3 is close enough to k1
4240  !! Bash; added an extra check on (nang-nalimit)
4241  !b if ( iabs(irng-krng).lt.nklimit .and. &
4242  !b iabs(iang-kang).lt.nalimit ) then !* original
4243  !!
4244  !tsa if ( (krng-irng).lt.nklimit .and. &
4245  !tsa ( iabs(kang-iang).lt.nalimit .or. &
4246  !tsa iabs(kang-iang).gt.(nang-nalimit) ) ) then !* Bash
4247  !!
4248  !! for -tsa (calc. dz4 & dz5 here)
4249  !tsa dz4 = dxp13 * (d4-d2)
4250  !tsa dz5 = d2*d4 * dsp13
4251  !tsa dz2a = d1*dp3 * (d4-d2)
4252  !tsa dz3a = d3*dp1 * (d4-d2)
4253  !!
4254  !tsa ttsa = ttsa + (dz4+dz5+dz2a+dz3a)*grad(ipt,nref,izz)
4255  !!
4256  !tsa endif
4257  !! --------------------------------------------------------
4258  !!
4259  !! for -fbi
4260  dz6 = d2*dp4 * (ds13+dsp13)
4261  dz7 = d4*dp2 * (ds13+dsp13)
4262  dz8 = dp2*dp4 * ds13
4263  dzsum = dz1 + dz2 + dz3 + dz4 + dz5 + dz6 + dz7 + dz8
4264  txp31 = txp31 + dzsum * grad(ipt,nref,izz)
4265  !! --------------------------------------------------------
4266  !! ========================================================
4267  !!
4268  !!
4269 90 end do !* end of ipt (locus) loop
4270  !! ----------------------------------------------------------
4271  !!
4272  !!
4273  !! multiply the following components by factor 2. in here
4274  !!
4275  !! for both -tsa and -fbi
4276  tr31 = 2. * t31
4277  !!
4278  !! for -tsa
4279  !tsa trtsa = 2. * ttsa
4280  !!
4281  !! for -fbi
4282  trp31 = 2. * tp31
4283  trx31 = 2. * txp31
4284  !!
4285  !! for -tsa : -diag
4286  !tsa diagk1 = 2. * diagk1
4287  !tsa diagk3 = 2. * diagk3
4288  !!
4289  !! for -fbi : -diag2
4290  diag2k1 = 2. * diag2k1
4291  diag2k3 = 2. * diag2k3
4292  !! ----------------------------------------------------------
4293  !!
4294  !! for both -tsa and -fbi
4295  sumint(irng,iang) = sumint(irng,iang) + tr31*pha(krng)
4296  sumint(krng,kang) = sumint(krng,kang) - tr31*pha(irng)
4297  !! ----------------------------------------------------------
4298  !!
4299  !! for -tsa
4300  !tsa sumintsa(irng,iang)= sumintsa(irng,iang)+ trtsa*pha(krng)
4301  !tsa sumintsa(krng,kang)= sumintsa(krng,kang)- trtsa*pha(irng)
4302  !! ----------------------------------------------------------
4303  !!
4304  !! for -fbi
4305  sumintp(irng,iang) = sumintp(irng,iang) + trp31*pha(krng)
4306  sumintp(krng,kang) = sumintp(krng,kang) - trp31*pha(irng)
4307  !!
4308  !! for -fbi
4309  sumintx(irng,iang) = sumintx(irng,iang) + trx31*pha(krng)
4310  sumintx(krng,kang) = sumintx(krng,kang) - trx31*pha(irng)
4311  !! ----------------------------------------------------------
4312  !!
4313  !! for -tsa : -diag
4314  !tsa diag(irng,iang) = diag(irng,iang) + diagk1*pha(krng)
4315  !tsa diag(krng,kang) = diag(krng,kang) - diagk3*pha(irng)
4316  !! ----------------------------------------------------------
4317  !!
4318  !! for -fbi : -diag2
4319  diag2(irng,iang) = diag2(irng,iang) + diag2k1*pha(krng)
4320  diag2(krng,kang) = diag2(krng,kang) - diag2k3*pha(irng)
4321  !! ----------------------------------------------------------
4322  !!
4323 80 end do !* end of kang loop
4324  !!
4325 70 end do !* end of krng loop
4326  !!
4327 60 end do !* end of iang loop
4328  !!
4329 50 end do !* end of irng loop
4330  !!------------------------------------------------------------------------------
4331  !!==============================================================================
4332  !!
4333  !!
4334  !! Final sum-up to get Snl and diag. term to be returned
4335  !!
4336  !! for -tsa
4337  !tsa tsa(:,:) = sumint(:,:) + sumintsa(:,:)
4338  !b diag(:,:) = diag(:,:) !* is Ok, already summed up
4339  !!
4340  !! for -fbi
4341  fbi(:,:) = sumint(:,:) + sumintp(:,:) + sumintx(:,:)
4342  !b diag2(:,:) = diag2(:,:) !* is Ok, already summed up
4343  !! --------------------------------------------------------------------------
4344  !! ==========================================================================
4345  !!
4346  !!
4347  !!alt Call interp2 only if ialt=2,
4348  !! Interpolate bi-linearly to fill in tsa/fbi & diag/diag2 arrays
4349  !! after alternating the irng, iang, krng & kang loops above
4350  !! ------------------------------------------------------------------
4351  if ( ialt.eq.2 ) then
4352  !! for -tsa
4353  !tsa call interp2 ( tsa )
4354  !tsa call interp2 ( diag )
4355  !!
4356  !! for -fbi
4357  call interp2 ( fbi )
4358  call interp2 ( diag2 )
4359  endif
4360  !!alt---
4361  !! --------------------------------------------------------------------------
4362  !! ==========================================================================
4363  !!
4364  RETURN
4365  !!

References dens1, dens2, diag2, fbi, grad, interp2(), jref2, jref4, kref2, kref4, kzone, npts, tfac2, tfac4, wta2, wta4, wtk2, and wtk4.

Referenced by w3snl4().

◆ snlr_tsa()

subroutine w3snl4md::snlr_tsa ( real, dimension(nrng), intent(in)  pha,
integer, intent(in)  ialt 
)

For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to wave-wave interaction.

For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to wave-wave interaction, as well as some ancillary arrays relating to positive and negative fluxes and their integrals.

Parameters
[in]phaPha = k*dk*dtheta.
[in]ialtInteger switch.
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 4391 of file w3snl4md.F90.

4391  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4392  !/
4393  !/ +-----------------------------------+
4394  !/ | WAVEWATCH III BIO |
4395  !/ | Bash Toulany |
4396  !/ | Michael Casey |
4397  !/ | William Perrie |
4398  !/ | FORTRAN 90 |
4399  !/ | Last update : 12-Apr-2016 |
4400  !/ +-----------------------------------+
4401  !/
4402  !/ 01-Mar-2016 : Origination. ( version 5.13 )
4403  !/
4404  !! ------------------------------------------------------------------
4405  !!
4406  !! it returns: tsa & diag all dim=(nrng,nang)
4407  !!
4408  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4409  !! ------------------------------------------------------------------
4410  !! ==================================================================
4411  !!
4412  !!
4413  !! 1. Purpose :
4414  !!
4415  !! -----------------------------------------------------------------#
4416  !! !
4417  !! For a given Action Density array dens1(k,theta), computes the !
4418  !! rate-of-change array sumint(k,theta) = dN(k,theta)/dt owing to !
4419  !! wave-wave interaction, as well as some ancillary arrays !
4420  !! relating to positive and negative fluxes and their integrals. !
4421  !! !
4422  !! -----------------------------------------------------------------#
4423  !! !
4424  !! Compute: !
4425  !! -------- !
4426  !! for both -tsa and -fbi !
4427  !! + sumint contains scale 1 contibution for Snl -tsa & Snl -fbi !
4428  !! !
4429  !! for -tsa !
4430  !! + sumintsa contains tsa approximation to Snl -tsa !
4431  !! !
4432  !! for -fbi !
4433  !! + sumintp contains scale 2 contribution to Snl -fbi !
4434  !! + sumintx contains cross interactions between scales 1 and 2 !
4435  !! -----------------------------------------------------------------#
4436  !!
4437  !! 2. Method :
4438  !!
4439  !! 3. Parameters :
4440  !!
4441  !! Parameter list
4442  !! ------------------------------------------------------------------
4443  !! Name Type Scope I/O Description
4444  !! ------------------------------------------------------------------
4445  !! nrng int. Public I # of freq. or rings
4446  !! nang int. Public I # of angles
4447  !! npts int. Public I # of points on the locus
4448  !! nzz int. Public I linear irng x krng = (NK*(NK+1))/2
4449  !! ialt int. Public I integer switch ialt=2; do alternate
4450  !! ialt=1; do not alternate
4451  !! kzone int. Public I zone of influence = INT(alog(4.0)/alog(dfrq))
4452  !! na2p1 int. Public I = nang/2 + 1
4453  !! np2p1 int. Public I = npts/2 + 1
4454  !! dfrq real Public I frequency multiplier for log freq. spacing
4455  !! frqa R.A. Public I radian frequencies (Hz); dim=(nrng)
4456  !! pha R.A. local I pha = k*dk*dtheta ; dim=(nrng)
4457  !! ------------------------------------------------------------------
4458  !!
4459  !! *** The 11 grid integration geometry arrays at one given depth
4460  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
4461  !! kref2 I.A. Public I Index of reference wavenumber for k2
4462  !! kref4 I.A. Public I Idem for k4
4463  !! jref2 I.A. Public I Index of reference angle for k2
4464  !! jref4 I.A. Public I Idem for k4
4465  !! wtk2 R.A. Public I k2 Interpolation weigth along wavenumbers
4466  !! wtk4 R.A. Public I Idem for k4
4467  !! wta2 R.A. Public I k2 Interpolation weigth along angles
4468  !! wta4 R.A. Public I Idem for k4
4469  !! tfac2 R.A. Public I Norm. for interp Action Density at k2
4470  !! tfac4 R.A. Public I Idem for k4
4471  !! grad R.A. Public I Coupling and gradient term in integral
4472  !! grad = C * H * g**2 * ds / |dW/dn|
4473  !! ------------------------------------------------------------------
4474  !!
4475  !! *** large & small scale Action Density from optsa dim=(nrng,nang)
4476  !! dens1 R.A. Public I lrg-scl Action Density (k,theta);
4477  !! dens2 R.A. Public I Sml-scl Action Density (k,theta);
4478  !! ------------------------------------------------------------------
4479  !!
4480  !! for both -tsa and -fbi
4481  !! sumint R.A. local O contains scale 1 contribution to Snl
4482  !! dim=(nrng,nang)
4483  !! for -tsa
4484  !! sumintsa R.A. local O contains tsa approximation to Snl -tsa
4485  !! dim=(nrng,nang)
4486  !! for -fbi
4487  !! sumintp R.A. local O contains scale 2 contribution to Snl -fbi
4488  !! dim=(nrng,nang)
4489  !! sumintx R.A. local O contains cross interactions " " " -fbi
4490  !! dim=(nrng,nang)
4491  !! ------------------------------------------------------------------
4492  !!
4493  !! for -tsa; The 2 returned arrays tsa & diag dim=(nrng,nang)
4494  !! tsa R.A. Public O Snl-tsa = sumint + sumintsa
4495  !! diag R.A. Public O Snl-tsa diagonal term = [dN/dn1]
4496  !! ------------------------------------------------------------------
4497  !!
4498  !! for -fbi; The 2 returned arrays fbi & diag2 dim=(nrng,nang)
4499  !! fbi R.A. Public O Snl-fbi = sumint + sumintp + sumintx
4500  !! diag2 R.A. Public O Snl-fbi diagonal term = [dN/dn1]
4501  !! ------------------------------------------------------------------
4502  !!
4503  !! 4. Subroutines used :
4504  !!
4505  !! Name Type Module Description
4506  !! ----------------------------------------------------------------
4507  !! ----------------------------------------------------------------
4508  !!
4509  !! 5. Called by :
4510  !!
4511  !! Name Type Module Description
4512  !! ----------------------------------------------------------------
4513  !! gridsetr Subr. W3SNL4MD Setup geometric integration grid
4514  !! ----------------------------------------------------------------
4515  !!
4516  !! 6. Error messages :
4517  !!
4518  !! None.
4519  !!
4520  !! 7. Remarks :
4521  !!
4522  !! 8. Structure :
4523  !!
4524  !! See source code.
4525  !!
4526  !! 9. Switches :
4527  !!
4528  !! !/S Enable subroutine tracing.
4529  !!
4530  !!10. Source code :
4531  !!
4532  !! --------------------------------------------------------------- &
4533  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4534  !! ----------------------------------------------------------------72
4535  !! ==================================================================
4536  !!
4537  !!
4538  IMPLICIT NONE
4539  !!
4540  !! Parameter list
4541  !! --------------
4542  real, intent(in) :: pha(nrng)
4543  integer, intent(in) :: ialt
4544  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4545  !! ------------------------------------------------------------------
4546  !!
4547  !!
4548  !! Local Parameters & variables
4549  !! -----------------------------
4550  !! for both -tsa and -fbi
4551  integer :: irng,krng, iang,kang
4552  integer :: ipt, iizz, izz
4553  integer :: kmax
4554  integer :: ia2, ia2p, k2, k2p
4555  integer :: ia4, ia4p, k4, k4p
4556  integer :: nref
4557  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4558  !!
4559  !! for -tsa
4560  integer :: nklimit, nalimit
4561  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4562  !!
4563  !! for both -tsa and -fbi
4564  real :: d1, d3, d2, d4
4565  real :: dp1, dp3
4566  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4567  !!
4568  !! for both -tsa and -fbi
4569  !! but for -tsa they are being calc. inside if/endif if test is successful
4570  !! and for -fbi they are being calc. outside if/endif always
4571  real :: dz4, dz5
4572  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4573  !!
4574  !! for both -tsa and -fbi
4575  real :: dx13, ds13, dxp13, dsp13
4576  real :: dgm, t31, tr31
4577  real :: w2, w2p, wa2, wa2p, d2a, d2b, tt2
4578  real :: w4, w4p, wa4, wa4p, d4a, d4b, tt4
4579  real :: sumint(nrng,nang)
4580  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4581  !!
4582  !! for -tsa
4583  real :: dz2a, dz3a, ttsa, trtsa
4584  real :: ddn1, ddn3, diagk1, diagk3
4585  real :: sumintsa(nrng,nang)
4586  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4587  !!
4588  !! for -fbi
4589  !fbi real :: dp2, dp4
4590  !fbi real :: d2pa, d4pa
4591  !fbi real :: d2pb, d4pb
4592  !fbi real :: dz1, dz2, dz3, dz6, dz7, dz8
4593  !fbi real :: dgmp, tp31, trp31, dzsum, txp31, trx31
4594  !!
4595  !! for -fbi; Bash added 4 new terms for a full expression of diag2 term
4596  !fbi real :: ddp1, ddp2, ddp3, ddp4 !* ddpi=di+dpi for i=1,4
4597  !fbi real :: dd2n1, dd2n3, diag2k1, diag2k3
4598  !fbi real :: sumintp(nrng,nang)
4599  !fbi real :: sumintx(nrng,nang)
4600  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4601  !! ---------------------::-----------------------------------------72
4602  !! ##################################################################
4603  !!------------------------------------------------------------------------------
4604  !!==============================================================================
4605  !!
4606  !!
4607  !! for -tsa
4608  !! Bash; hardwire these two parameters
4609  nklimit = 6
4610  nalimit = 6
4611  !!
4612  !!
4613  !!ini
4614  !! Bash; move initialization of all returned arrays from below to here
4615  !! ------------------------------------------------------------------
4616  !! for both -tsa and -fbi
4617  !! sumint is now initialized here instead of below!
4618  sumint(:,:) = 0.0
4619  !!
4620  !! for -tsa
4621  !! sumintsa are now initialized here instead of below!
4622  sumintsa(:,:) = 0.0
4623  tsa(:,:) = 0.0
4624  diag(:,:) = 0.0
4625  !!
4626  !! for -fbi
4627  !! sumintp and sumintx are now initialized here instead of below!
4628  !fbi sumintp(:,:) = 0.0
4629  !fbi sumintx(:,:) = 0.0
4630  !fbi fbi(:,:) = 0.0
4631  !fbi diag2(:,:) = 0.0
4632  !!ini---
4633  !! ------------------------------------------------------------------
4634  !! ------------------------------------------------------------------
4635  !! ##################################################################
4636  !!
4637  !!
4638  !! for -tsa
4639  ddn1 = 0.0 !* for -tsa diag [dN/dn1]
4640  ddn3 = 0.0 !* for -tsa diag [dN/dn3]
4641  !!
4642  !! for -fbi
4643  !fbi dd2n1 = 0.0 !* for -fbi diag2 [dN/dn1]
4644  !fbi dd2n3 = 0.0 !* for -fbi diag2 [dN/dn3]
4645  !!
4646  !!
4647  !!
4648  !!50
4649  do 50 irng=1,nrng,ialt
4650  !!kz
4651  kmax = min(irng+kzone, nrng) !* Bash; Sometimes a locus pt is outside nrng
4652  !kz kmax = min(irng+kzone, nrng-1) !* Bash; Taking 1 out will not affect kzone, try it
4653  !!kz---
4654  !!
4655  iizz = (nrng-1)*(irng-1) - ((irng-2)*(irng-1))/2
4656  !! ----------------------------------------------------------------
4657  !!
4658  !!
4659  !!60
4660  do 60 iang=1,nang,ialt
4661  !!
4662  !! for both -tsa and -fbi
4663  d1 = dens1(irng,iang)
4664  dp1 = dens2(irng,iang)
4665  !!
4666  !! for -fbi
4667  !fbi ddp1 = d1+dp1 !! for full expression of diag2 term
4668  !!
4669  !!70
4670  !!kz
4671  !kz do 70 krng=irng,nrng
4672  do 70 krng=irng,kmax,ialt
4673  !!
4674  !! for both -tsa and -fbi
4675  !! Bash; check5 be consistent with gridsetr
4676  !! moved here from below (was after do 80 kang=1,nang)
4677  !! and changed go to 80 into go to 70 (i.e. go to next krng)
4678  !kz if ( frqa(krng)/frqa(irng) .gt. 4. ) go to 70 !* original gridsetr
4679  !kz if ( frqa(krng)/frqa(irng) .gt. 3. ) go to 70 !* original snlr_'s
4680  !kz if ( frqa(krng)/frqa(irng) .gt. 2. ) go to 70 !* Bash; use .gt. 2
4681  !!kz---
4682  !!
4683  izz = krng + iizz
4684  !! ------------------------------------------------------------
4685  !!
4686  !!80
4687  do 80 kang=1,nang,ialt
4688  !!
4689  !! for both -tsa and -fbi
4690  !!ba1 Bash; Remove self interaction
4691  !! skip k1 but keep the opposite angle to k1 - original setting
4692  if ( krng.eq.irng ) then !* wn3 = wn1
4693  if ( kang.eq.iang ) go to 80 !* th3 = th1
4694  endif
4695  !!ba1---
4696  !! ----------------------------------------------------------
4697  !!
4698  !! for both -tsa and -fbi
4699  d3 = dens1(krng,kang)
4700  dp3 = dens2(krng,kang)
4701  !!
4702  !! for -fbi
4703  !fbi ddp3 = d3+dp3 !! for full expression of diag2 term
4704  !!
4705  !!
4706  !! for both -tsa and -fbi
4707  nref = kang - iang + 1
4708  if ( nref .lt. 1 ) nref = nref + nang
4709  !!
4710  !!
4711  !! for both -tsa and -fbi
4712  !! Bash; check5 be consistent with gridsetr
4713  !! and move this test above right after do 70 krng=irng,nrng
4714  !x if ( frqa(krng)/frqa(irng) .gt. 4. ) go to 80 !* gridsetr
4715  !b if ( frqa(krng)/frqa(irng) .gt. 3. ) go to 80 !* original
4716  !!
4717  !!
4718  !! for both -tsa and -fbi
4719  t31 = 0.0 !* must be reset to 0.0
4720  !!
4721  !! for -tsa
4722  ttsa = 0.0 !* must be reset to 0.0
4723  diagk1 = 0.0 !* must be reset to 0.0
4724  diagk3 = 0.0 !* must be reset to 0.0
4725  !!
4726  !! for -fbi
4727  !fbi tp31 = 0.0 !* must be reset to 0.0
4728  !fbi txp31 = 0.0 !* must be reset to 0.0
4729  !fbi diag2k1 = 0.0 !* must be reset to 0.0
4730  !fbi diag2k3 = 0.0 !* must be reset to 0.0
4731  !!
4732  !! for both -tsa and -fbi
4733  dx13 = d1*d3
4734  ds13 = d3-d1
4735  dxp13 = dp1*dp3
4736  dsp13 = dp3-dp1
4737  !! ----------------------------------------------------------
4738  !!
4739  !!90
4740  do 90 ipt=1,npts
4741  !!
4742  !! for both -tsa and -fbi
4743  !! save time by skipping insignificant contributions
4744  !!e-30
4745  !e-30 if ( grad(ipt,nref,izz) .lt. 1.e-30 ) go to 90
4746  !!e-30---
4747  if ( grad(ipt,nref,izz) .lt. 1.e-15 ) go to 90
4748  !!e-30---
4749  !! --------------------------------------------------------
4750  !!
4751  !!xlc1 Bash; skip k1 but keep the opposite angle to k1 - original setting
4752  !xlc1 if ( kang.eq.iang ) then !* th3=+th1
4753  !xlc1 if (ipt.eq.1 .or. ipt.eq.np2p1) go to 90 !* skip x-axis loci
4754  !xlc1 end if
4755  !!xlc1---
4756  !! --------------------------------------------------------
4757  !!
4758  !!
4759  !!2 Estimation of Density for wave #2
4760  !!
4761  !! for both -tsa and -fbi
4762  k2 = kref2(ipt,nref,izz)
4763  k2p = k2 + 1
4764  w2 = wtk2(ipt,nref,izz)
4765  w2p = 1. - w2
4766  !!
4767  !! for both -tsa and -fbi
4768  ia2 = iang + jref2(ipt,nref,izz)
4769  if ( ia2 .gt. nang ) ia2 = ia2 - nang
4770  !!
4771  !! for both -tsa and -fbi
4772  ia2p = ia2 + 1
4773  if ( ia2p .gt. nang ) ia2p = ia2p - nang
4774  !!
4775  !! for both -tsa and -fbi
4776  wa2 = wta2(ipt,nref,izz)
4777  wa2p = 1. - wa2
4778  d2a = w2 * dens1(k2,ia2) + w2p * dens1(k2p,ia2)
4779  d2b = w2 * dens1(k2,ia2p) + w2p * dens1(k2p,ia2p)
4780  tt2 = tfac2(ipt,nref,izz)
4781  d2 = (wa2*d2a + wa2p*d2b) * tt2
4782  !!
4783  !! for -fbi
4784  !fbi d2pa = w2 * dens2(k2,ia2) + w2p * dens2(k2p,ia2)
4785  !fbi d2pb = w2 * dens2(k2,ia2p) + w2p * dens2(k2p,ia2p)
4786  !!
4787  !! for -fbi
4788  !fbi dp2 = (wa2*d2pa + wa2p*d2pb) * tt2 !* for -fbi
4789  !fbi ddp2 = d2+dp2 !! for full expression of diag2 term
4790  !! ========================================================
4791  !!
4792  !!
4793  !!4 Estimation of Density for wave #4
4794  !!
4795  !! for both -tsa and -fbi
4796  k4 = kref4(ipt,nref,izz)
4797  k4p = k4 + 1
4798  w4 = wtk4(ipt,nref,izz)
4799  w4p = 1. - w4
4800  !!
4801  !! for both -tsa and -fbi
4802  ia4 = iang + jref4(ipt,nref,izz)
4803  if ( ia4 .gt. nang ) ia4 = ia4 - nang
4804  !!
4805  !! for both -tsa and -fbi
4806  ia4p= ia4 + 1
4807  if ( ia4p .gt. nang ) ia4p = ia4p - nang
4808  !!
4809  !! for both -tsa and -fbi
4810  wa4 = wta4(ipt,nref,izz)
4811  wa4p = 1. - wa4
4812  d4a = w4*dens1(k4,ia4) + w4p*dens1(k4p,ia4)
4813  d4b = w4*dens1(k4,ia4p) + w4p*dens1(k4p,ia4p)
4814  tt4 = tfac4(ipt,nref,izz)
4815  d4 = (wa4*d4a + wa4p*d4b) * tt4
4816  !!
4817  !! for -fbi
4818  !fbi d4pa = w4*dens2(k4,ia4) + w4p*dens2(k4p,ia4)
4819  !fbi d4pb = w4*dens2(k4,ia4p) + w4p*dens2(k4p,ia4p)
4820  !!
4821  !! for -fbi
4822  !fbi dp4 = (wa4*d4pa + wa4p*d4pb) * tt4 !* for -fbi
4823  !fbi ddp4 = d4+dp4 !! for full expression of diag2 term
4824  !! ========================================================
4825  !!
4826  !!
4827  !! for both -tsa and -fbi
4828  dgm = dx13*(d4-d2) + ds13*d4*d2 !* dgm=B of R&P'08 eqn(8)
4829  !! !* represents Broad Scale interactions
4830  t31 = t31 + dgm * grad(ipt,nref,izz)
4831  !! --------------------------------------------------------
4832  !!
4833  !! for -fbi
4834  !fbi dgmp = dxp13*(dp4-dp2) + dsp13*dp4*dp2 !* dgmp=L of R&P'08 eqn(8)
4835  !! !* represents Local Scale interactions
4836  !fbi tp31 = tp31 + dgmp * grad(ipt,nref,izz)
4837  !! --------------------------------------------------------
4838  !! ========================================================
4839  !!
4840  !!
4841  !! for -tsa : -diag
4842  !! use this expression for the diagonal term
4843  !! whose derivation neglect "dp2" & "dp4"
4844  ddn1 = (d3+dp3)*(d4-d2) - d4*d2 !* dN/dn1
4845  ddn3 = (d1+dp1)*(d4-d2) + d4*d2 !* dN/dn3
4846  diagk1 = diagk1 + ddn1 * grad(ipt,nref,izz)
4847  diagk3 = diagk3 + ddn3 * grad(ipt,nref,izz)
4848  !! --------------------------------------------------------
4849  !!
4850  !! for -fbi : -diag2
4851  !! use the full expression for the diagonal terms
4852  !! whose derivation keeps all large + small scale
4853  !fbi dd2n1 = ddp3*(ddp4-ddp2) - ddp4*ddp2 !* dN/dn1
4854  !fbi dd2n3 = ddp1*(ddp4-ddp2) + ddp4*ddp2 !* dN/dn3
4855  !fbi diag2k1 = diag2k1 + dd2n1 * grad(ipt,nref,izz)
4856  !fbi diag2k3 = diag2k3 + dd2n3 * grad(ipt,nref,izz)
4857  !! --------------------------------------------------------
4858  !! ========================================================
4859  !!
4860  !!
4861  !! for -fbi
4862  !fbi dz1 = dx13 * (dp4-dp2)
4863  !fbi dz2 = d1*dp3 * ((d4-d2)+(dp4-dp2))
4864  !fbi dz3 = d3*dp1 * ((d4-d2)+(dp4-dp2))
4865  !!
4866  !! for -fbi (calc. dz4 & dz5 here)
4867  !fbi dz4 = dxp13 * (d4-d2)
4868  !fbi dz5 = d2*d4 * dsp13
4869  !!
4870  !! for -tsa
4871  !! Cross-interactions between parametric and perturbation
4872  !! that occur only when k3 is close enough to k1
4873  !! Bash; added an extra check on (nang-nalimit)
4874  !b if ( iabs(irng-krng).lt.nklimit .and. &
4875  !b iabs(iang-kang).lt.nalimit ) then !* original
4876  !!
4877  if ( (krng-irng).lt.nklimit .and. &
4878  ( iabs(kang-iang).lt.nalimit .or. &
4879  iabs(kang-iang).gt.(nang-nalimit) ) ) then !* Bash
4880  !!
4881  !! for -tsa (calc. dz4 & dz5 here)
4882  dz4 = dxp13 * (d4-d2)
4883  dz5 = d2*d4 * dsp13
4884  dz2a = d1*dp3 * (d4-d2)
4885  dz3a = d3*dp1 * (d4-d2)
4886  !!
4887  ttsa = ttsa + (dz4+dz5+dz2a+dz3a)*grad(ipt,nref,izz)
4888  !!
4889  endif
4890  !! --------------------------------------------------------
4891  !!
4892  !! for -fbi
4893  !fbi dz6 = d2*dp4 * (ds13+dsp13)
4894  !fbi dz7 = d4*dp2 * (ds13+dsp13)
4895  !fbi dz8 = dp2*dp4 * ds13
4896  !fbi dzsum = dz1 + dz2 + dz3 + dz4 + dz5 + dz6 + dz7 + dz8
4897  !fbi txp31 = txp31 + dzsum * grad(ipt,nref,izz)
4898  !! --------------------------------------------------------
4899  !! ========================================================
4900  !!
4901  !!
4902 90 end do !* end of ipt (locus) loop
4903  !! ----------------------------------------------------------
4904  !!
4905  !!
4906  !! multiply the following components by factor 2. in here
4907  !!
4908  !! for both -tsa and -fbi
4909  tr31 = 2. * t31
4910  !!
4911  !! for -tsa
4912  trtsa = 2. * ttsa
4913  !!
4914  !! for -fbi
4915  !fbi trp31 = 2. * tp31
4916  !fbi trx31 = 2. * txp31
4917  !!
4918  !! for -tsa : -diag
4919  diagk1 = 2. * diagk1
4920  diagk3 = 2. * diagk3
4921  !!
4922  !! for -fbi : -diag2
4923  !fbi diag2k1 = 2. * diag2k1
4924  !fbi diag2k3 = 2. * diag2k3
4925  !! ----------------------------------------------------------
4926  !!
4927  !! for both -tsa and -fbi
4928  sumint(irng,iang) = sumint(irng,iang) + tr31*pha(krng)
4929  sumint(krng,kang) = sumint(krng,kang) - tr31*pha(irng)
4930  !! ----------------------------------------------------------
4931  !!
4932  !! for -tsa
4933  sumintsa(irng,iang)= sumintsa(irng,iang)+ trtsa*pha(krng)
4934  sumintsa(krng,kang)= sumintsa(krng,kang)- trtsa*pha(irng)
4935  !! ----------------------------------------------------------
4936  !!
4937  !! for -fbi
4938  !fbi sumintp(irng,iang) = sumintp(irng,iang) + trp31*pha(krng)
4939  !fbi sumintp(krng,kang) = sumintp(krng,kang) - trp31*pha(irng)
4940  !!
4941  !! for -fbi
4942  !fbi sumintx(irng,iang) = sumintx(irng,iang) + trx31*pha(krng)
4943  !fbi sumintx(krng,kang) = sumintx(krng,kang) - trx31*pha(irng)
4944  !! ----------------------------------------------------------
4945  !!
4946  !! for -tsa : -diag
4947  diag(irng,iang) = diag(irng,iang) + diagk1*pha(krng)
4948  diag(krng,kang) = diag(krng,kang) - diagk3*pha(irng)
4949  !! ----------------------------------------------------------
4950  !!
4951  !! for -fbi : -diag2
4952  !fbi diag2(irng,iang) = diag2(irng,iang) + diag2k1*pha(krng)
4953  !fbi diag2(krng,kang) = diag2(krng,kang) - diag2k3*pha(irng)
4954  !! ----------------------------------------------------------
4955  !!
4956 80 end do !* end of kang loop
4957  !!
4958 70 end do !* end of krng loop
4959  !!
4960 60 end do !* end of iang loop
4961  !!
4962 50 end do !* end of irng loop
4963  !!------------------------------------------------------------------------------
4964  !!==============================================================================
4965  !!
4966  !!
4967  !! Final sum-up to get Snl and diag. term to be returned
4968  !!
4969  !! for -tsa
4970  tsa(:,:) = sumint(:,:) + sumintsa(:,:)
4971  !b diag(:,:) = diag(:,:) !* is Ok, already summed up
4972  !!
4973  !! for -fbi
4974  !fbi fbi(:,:) = sumint(:,:) + sumintp(:,:) + sumintx(:,:)
4975  !b diag2(:,:) = diag2(:,:) !* is Ok, already summed up
4976  !! --------------------------------------------------------------------------
4977  !! ==========================================================================
4978  !!
4979  !!
4980  !!alt Call interp2 only if ialt=2,
4981  !! Interpolate bi-linearly to fill in tsa/fbi & diag/diag2 arrays
4982  !! after alternating the irng, iang, krng & kang loops above
4983  !! ------------------------------------------------------------------
4984  if ( ialt.eq.2 ) then
4985  !! for -tsa
4986  call interp2 ( tsa )
4987  call interp2 ( diag )
4988  !!
4989  !! for -fbi
4990  !fbi call interp2 ( fbi )
4991  !fbi call interp2 ( diag2 )
4992  endif
4993  !!alt---
4994  !! --------------------------------------------------------------------------
4995  !! ==========================================================================
4996  !!
4997  RETURN
4998  !!

References dens1, dens2, diag, grad, interp2(), jref2, jref4, kref2, kref4, kzone, npts, tfac2, tfac4, tsa, wta2, wta4, wtk2, and wtk4.

Referenced by w3snl4().

◆ w3snl4()

subroutine w3snl4md::w3snl4 ( real, dimension(nth,nk), intent(in)  A,
real, dimension(nk), intent(in)  CG,
real, dimension(nk), intent(in)  WN,
real, intent(in)  DEPTH,
real, dimension(nth,nk), intent(out)  S,
real, dimension(nth,nk), intent(out)  D 
)

Interface module for TSA type nonlinear interactions.

Based on Resio and Perrie (2008) and Perrie and Resio (2009).

Parameters
[in,out]A2D Action Density A(NTH,NK) as function of direction (rad) and wavenumber (theta,k).
[in,out]CGGroup velocities.
[in,out]WNWavenumbers.
[in,out]DEPTHWater depth (m).
[in,out]SSource term.
[in,out]DDiagonal term of derivative.
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 611 of file w3snl4md.F90.

611  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
612  !! ------------------------------------------------------------------
613  !/
614  !/ +-----------------------------------+
615  !/ | WAVEWATCH III BIO |
616  !/ | Bash Toulany |
617  !/ | Michael Casey |
618  !/ | William Perrie |
619  !/ | FORTRAN 90 |
620  !/ | Last update : 12-Apr-2016 |
621  !/ +-----------------------------------+
622  !/
623  !/ 01-Mar-2016 : Origination. ( version 5.13 )
624  !/
625  !! ------------------------------------------------------------------
626  !!
627  !! it returns: S & D dim = (NTH,NK) = (nang,nrng)
628  !!
629  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
630  !! ------------------------------------------------------------------
631  !! ==================================================================
632  !!
633  !! 1. Purpose :
634  !!
635  !! Interface module for TSA type nonlinear interactions.
636  !! Based on Resio and Perrie (2008) and Perrie and Resio (2009)
637  !!
638  !! 2. Method :
639  !!
640  !! 3. Parameters :
641  !!
642  !! Parameter list
643  !! ------------------------------------------------------------------
644  !! Name Type Scope I/O Description
645  !! ------------------------------------------------------------------
646  !! A R.A. I 2D Action Density A(NTH,NK) as function of
647  !! direction (rad) and wavenumber (theta,k)
648  !! CG R.A. I Group velocities dim=NK
649  !! WN R.A. I Wavenumbers dim=NK
650  !! DEPTH Real I Water depth (m)
651  !! S R.A. O Source term. dim=(NTH,NK)
652  !! D R.A. O Diagonal term of derivative. dim=(NTH,NK)
653  !! ------------------------------------------------------------------
654  !!
655  !! nrng int. Public O # of freq. or rings
656  !! nang int. Public O # of angles
657  !! npts int. Public I # of points on the locus
658  !! ndep int. Public I # of depths in look-up tables
659  !! nzz int. Public O linear irngxkrng = (NK*(NK+1))/2
660  !! kzone int. Public O zone of influence = INT(alog(4.0)/alog(dfrq))
661  !! nb2fp int. Public O # of bins over fp => dfrq**nb2fp)*fp ~ 2.*fp
662  !! = INT(alog(2.0)/alog(dfrq))
663  !! na2p1 int. Public O = nang/2 + 1
664  !! np2p1 int. Public O = npts/2 + 1
665  !! dfrq Real Public O frequency multiplier for log freq. spacing
666  !! f0 Real Public O = frqa(1); first freq. (Hz)
667  !! ainc Real Public O = DTH; WW3 angle increment (radians)
668  !! twopi Real Public O = TPI; WW3i 2*pi = 8.*atan(1.) (radians)
669  !! oma R.A. Public O = SIG(1:NK) WW3 waveumber array dim=(nrng)
670  !! frqa R.A. Public O = oma(:)/twopi WW3 frequency array dim=(nrng)
671  !! angl R.A. Public O = TH(1:NTH); WW3 angles array dim=(nang)
672  !! sinan R.A. Public O = ESIN(1:NTH); WW3 sin(angl(:)) array dim=(nang)
673  !! cosan R.A. Public O = ECOS(1:NTH); WW3 cos(angl(:)) array dim=(nang)
674  !! dep_tbl R.A. Public I depthes in Look-up tables arrays dim=(ndep)
675  !! ------------------------------------------------------------------
676  !!
677  !! *** The 11 look-up tables for grid integration geometry arrays
678  !! *** at all selected 'ndep' depths defined in dep_tbl(ndep)' array
679  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
680  !! kref2_tbl I.A. Public I Index of reference wavenumber for k2
681  !! kref4_tbl I.A. Public I Idem for k4
682  !! jref2_tbl I.A. Public I Index of reference angle for k2
683  !! jref4_tbl I.A. Public I Idem for k4
684  !! wtk2_tbl R.A. Public I k2 Interpolation weigth along wavenumbers
685  !! wtk4_tbl R.A. Public I Idem for k4
686  !! wta2_tbl R.A. Public I k2 Interpolation weigth along angles
687  !! wta4_tbl R.A. Public I Idem for k4
688  !! tfac2_tbl R.A. Public I Norm. for interp Action Density at k2
689  !! tfac4_tbl R.A. Public I Idem for k4
690  !! grad_tbl R.A. Public I Coupling and gradient term in integral
691  !! grad = C * H * g**2 * ds / |dW/dn|
692  !! ------------------------------------------------------------------
693  !!
694  !! *** The 11 grid integration geometry arrays at one given depth
695  !! *** from gridsetr. dim=(npts,nang,nzz,ndep)
696  !! kref2 I.A. Public O Index of reference wavenumber for k2
697  !! kref4 I.A. Public O Idem for k4
698  !! jref2 I.A. Public O Index of reference angle for k2
699  !! jref4 I.A. Public O Idem for k4
700  !! wtk2 R.A. Public O k2 Interpolation weigth along wavenumbers
701  !! wtk4 R.A. Public O Idem for k4
702  !! wta2 R.A. Public O k2 Interpolation weigth along angles
703  !! wta4 R.A. Public O Idem for k4
704  !! tfac2 R.A. Public O Norm. for interp Action Density at k2
705  !! tfac4 R.A. Public O Idem for k4
706  !! grad R.A. Public O Coupling and gradient term in integral
707  !! grad = C * H * g**2 * ds / |dW/dn|
708  !! ------------------------------------------------------------------
709  !!
710  !! ef2 R.A. Public O 2D Energy Density spectrum ef2(theta,f)
711  !! = A(theta,k) * 2*pi*oma(f)/cga(f)
712  !! dim=(nrng,nang)
713  !! ef1 R.A. Public O 1D Energy Density spectrum ef1(f)
714  !! dim=(nrng)
715  !!
716  !! dens1 R.A. Public O large-scale Action Density (k,theta)
717  !! dim=(nrng,nang)
718  !! dens2 R.A. Public O Small-scale Action Density (k,theta)
719  !! dim=(nrng,nang)
720  !! ------------------------------------------------------------------
721  !!
722  !! for -tsa; The 2 returned arrays tsa & diag dim=(nrng,nang)
723  !! tsa R.A. Public O Snl-tsa = sumint + sumintsa
724  !! diag R.A. Public O Snl-tsa diagonal term = [dN/dn1]
725  !! ------------------------------------------------------------------
726  !!
727  !! for -fbi; The 2 returned arrays fbi & diag2 dim=(nrng,nang)
728  !! fbi R.A. Public O Snl-fbi = sumint + sumintp + sumintx
729  !! diag2 R.A. Public O Snl-fbi diagonal term = [dN/dn1]
730  !! ------------------------------------------------------------------
731  !!
732  !! 4. Subroutines used :
733  !!
734  !! Name Type Module Description
735  !! ------------------------------------------------------------------
736  !! STRACE Subr. W3SERVMD Subroutine tracing.
737  !! optsa2 Subr. W3SERVMD Converts the 2D Energy Density (f,theta)
738  !! ------ to Polar Action Density (k,theta) Norm. (in k)
739  !! then splits it into large and small scale
740  !! snlr_tsa Subr. W3SERVMD Computes dN(k,theta)/dt for TSA
741  !! -------- due to wave-wave inter. (set itsa = 1)
742  !! snlr_fbi Subr. W3SERVMD Computes dN(k,theta)/dt for FBI
743  !! -------- due to wave-wave inter. (set itsa = 0)
744  !! ------------------------------------------------------------------
745  !!
746  !! 5. Called by :
747  !!
748  !! Name Type Module Description
749  !! ------------------------------------------------------------------
750  !! W3SRCE Subr. w3srcemd Source term integration.
751  !! W3EXPO Subr. ww3_outp Point output post-processor.
752  !! W3EXNC Subr. ww3_ounp NetCDF Point output post-processor.
753  !! GXEXPO Subr. gx_outp GrADS Point output post-processor.
754  !! ------------------------------------------------------------------
755  !!
756  !! 6. Error messages :
757  !!
758  !! None.
759  !!
760  !! 7. Remarks :
761  !!
762  !! 8. Structure :
763  !!
764  !! See source code.
765  !!
766  !! 9. Switches :
767  !!
768  !! !/S Enable subroutine tracing.
769  !!
770  !!10. Source code :
771  !!
772  !! --------------------------------------------------------------- &
773  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
774  !! ----------------------------------------------------------------72
775  !! ==================================================================
776  !!
777  !!
778  USE constants, ONLY: tpi
779  USE w3gdatmd, ONLY: nk, nth, xfr, dth, sig, th, ecos, esin, &
780  itsa, ialt
781  !! dimension: SIG(0:NK+1),TH(NTH), ECOS(NSPEC+NTH), ESIN(NSPEC+NTH)
782  !!
783  USE w3servmd, ONLY: extcde
784  USE w3odatmd, ONLY: ndse, ndst, ndso
785 #ifdef W3_S
786  USE w3servmd, ONLY: strace
787 #endif
788  !! ==================================================================
789  !!
790  IMPLICIT NONE
791  !!
792  !! Parameter list
793  !! --------------
794  REAL, INTENT(IN) :: A(NTH,NK), CG(NK), WN(NK), DEPTH
795  REAL, INTENT(OUT) :: S(NTH,NK), D(NTH,NK)
796  !!
797  LOGICAL, SAVE :: FIRST_TSA = .true.
798  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
799  !! ------------------------------------------------------------------
800  !!
801  !! Local Parameters & variables
802  !! -----------------------------
803 #ifdef W3_S
804  INTEGER, SAVE :: IENT = 0
805 #endif
806  integer :: irng, iang
807  integer :: nd3 !* bin # corresp. to ww3 dep
808  real :: dep !* depth (m), get it from WW3 DEPTH
809  real :: wka(NK) !* from WW3 WN(1:NK) corresp. to "DEPTH"
810  real :: cga(NK) !* from WW3 CG(1:NK) corresp. to "DEPTH"
811  real :: pha(NK) !* k*dk*dtheta array corresp. to "DEPTH"
812  real :: fac !* twopi*oma()/cga()
813  real :: sum1 !* dummy variable
814  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
815  !!
816  integer :: npk !* bin# at peak frequency fpk
817  integer :: npk2 !* bin# of second peak frequency
818  integer :: npk0 !* dummy int. used in the shuffle of npk's
819  integer :: nsep !* min # of bins that separates npk & npk2
820  !* set nsep = 2
821  integer :: npeaks !* # of peaks (=0, 1, or 2)
822  integer :: nfs !* bin# of freq. separation
823  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
824  !!
825  integer :: nbins !* actual # of bins > npk (incl. nfs) or
826  !! !* actual # of bins > npk2 (incl. nrng)
827  !! !* to guarantee a min 1 bin in equi. range
828  real :: fpk !* peak frequency (Hz)
829  real :: fpk2 !* second peak frequency (Hz)
830  real :: e1max !* 1D energy at 1st peak 'fpk'
831  real :: e1max2 !* 1D energy at 2nd peak 'fpk2'
832  real :: sumd1 !* sum dens1+dens2 at nfs
833  real :: sumd2 !* sum dens1+dens2 at nfs+1
834  real :: densat1 !* averaged dens1 at nfs
835  real :: densat2 !* averaged dens1 at nfs+1
836  !! --------------------------------------------------------------- &
837  !! ---------------------::-----------------------------------------72
838  !! ##################################################################
839  !!------------------------------------------------------------------------------
840  !!==============================================================================
841  !!
842  !!
843 #ifdef W3_S
844  CALL strace (ient, 'W3SNL4')
845 #endif
846  !!
847  !!ini
848  !! Initialization of the output arrays
849  !! before calling TSA subroutines.
850  !! -----------------------------------
851  s(:,:) = 0.0
852  d(:,:) = 0.0
853  !!ini---
854  !! ------------------------------------------------------------------
855  !! ==================================================================
856  !!------------------------------------------------------------------------------
857  !!==============================================================================
858  !!
859  !!
860  !!
861  IF ( first_tsa ) THEN
862  !!
863  !!
864  !!-0 Set parameters & constants
865  !! ---------------------------
866  nrng = nk !* nrng = NK must be odd <---
867  nzz = (nk * (nk+1)) / 2 !* linear irng, krng
868  nang = nth !* nang = NTH must be even <---
869  na2p1 = nang/2 + 1 !* mid-angle or angle opposite to 1
870  np2p1 = npts/2 + 1 !* mid-index of locus array
871  twopi = tpi !* twopi = 8.*atan(1.)
872  !* get it from WW3 TPI
873  !! ----------------------------------------------------------------
874  !! ================================================================
875  !!
876  !!
877  !!-1 Allocate freq & angle related array declared as PUBLIC
878  if ( allocated (frqa) ) deallocate (frqa)
879  if ( allocated (oma) ) deallocate (oma)
880  if ( allocated (angl) ) deallocate (angl)
881  if ( allocated (sinan) ) deallocate (sinan)
882  if ( allocated (cosan) ) deallocate (cosan)
883  if ( allocated (dep_tbl) ) deallocate (dep_tbl)
884  allocate(frqa(nrng))
885  allocate(oma(nrng))
886  allocate(angl(nang))
887  allocate(sinan(nang))
888  allocate(cosan(nang))
889  allocate(dep_tbl(ndep))
890  !! ----------------------------------------------------------------
891  !!
892  !!-1a Initialize frequency arrays and related parameters
893  !! --------------------------------------------------
894  oma(:) = sig(1:nk) !* get it from WW3 SIG(1:NK)
895  frqa(:) = oma(:) / twopi
896  f0 = frqa(1)
897  dfrq = xfr !* WW3 freq mult. for log freq
898  !* get it from WW3 XFR
899  !! ----------------------------------------------------------------
900  !!
901  !!-1b Initialize direction arrays and related parameters
902  !! --------------------------------------------------
903  angl(:) = th(1:nth) !* get it from WW3 TH(1:NTH)
904  cosan(:) = ecos(1:nth) !* get it from WW3 ECOS(1:NTH)
905  sinan(:) = esin(1:nth) !* get it from WW3 ESIN(1:NTH)
906  ainc = dth !* WW3 angle increment (radians)
907  !* get it from WW3 DTH
908  !! ----------------------------------------------------------------
909  !!
910  !!-1c Define kzone & nb2fp
911  !!kz
912  !! kzone = zone of freq influence, function of dfrq
913  !! for different values of x = 2,3,4 & 5
914  !! So, kzone(x) = INT( alog(x)/alog(dfrq) )
915  !! +--------+----------+----------+----------+----------+
916  !! | dfrq | kzone(2) | kzone(3) | kzone(4) | kzone(5) |
917  !! +--------+----------+----------+----------+----------+
918  !! | 1.05 | 14 | 22 | 28 | 33 |
919  !! +--------+----------+----------+----------+----------+
920  !! | 1.07 | 10 | 16 | 20 | 24 |
921  !! +--------+----------+----------+----------+----------+
922  !! | 1.10 | 7 | 11 | 14 | 17 |
923  !! +--------+----------+----------+----------+----------+
924  kzone = int( alog(2.0)/alog(dfrq) ) !* Bash; faster without loss of accuracy
925  !kz kzone = INT( alog(3.0)/alog(dfrq) ) !* as in gridsetr & snlr_'s
926  !kz kzone = INT( alog(4.0)/alog(dfrq) ) !* as in gridsetr & snlr_'s
927  !kz kzone = INT( alog(5.0)/alog(dfrq) ) !* as in gridsetr & snlr_'s
928  !!kz---
929  !!
930  !!op2
931  !! nb2fp = # of bins over fp (not incl. fp) - this depends on dfrq
932  !! so that (dfrq**nb2fp)*fp ~ 2.*fp (like kzone(2))
933  !! used in 1 bin equi. range
934  nb2fp = int( alog(2.0)/alog(dfrq) ) !* for equi. range near 2*fp
935  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - !!op2
936  !! ================================================================
937  !!
938  !!
939  !!-2 Allocate gridsetr 11 look-up tables arrays
940  !! plus pha_tbl array dim=(nrng,ndep) declared as PUBLIC
941  if ( allocated (kref2_tbl) ) deallocate (kref2_tbl)
942  if ( allocated (kref4_tbl) ) deallocate (kref4_tbl)
943  allocate(kref2_tbl(npts,nang,nzz,ndep))
944  allocate(kref4_tbl(npts,nang,nzz,ndep))
945  !!
946  if ( allocated (jref2_tbl) ) deallocate (jref2_tbl)
947  if ( allocated (jref4_tbl) ) deallocate (jref4_tbl)
948  allocate(jref2_tbl(npts,nang,nzz,ndep))
949  allocate(jref4_tbl(npts,nang,nzz,ndep))
950  !!
951  if ( allocated (wtk2_tbl) ) deallocate (wtk2_tbl)
952  if ( allocated (wtk4_tbl) ) deallocate (wtk4_tbl)
953  allocate(wtk2_tbl(npts,nang,nzz,ndep))
954  allocate(wtk4_tbl(npts,nang,nzz,ndep))
955  !!
956  if ( allocated (wta2_tbl) ) deallocate (wta2_tbl)
957  if ( allocated (wta4_tbl) ) deallocate (wta4_tbl)
958  allocate(wta2_tbl(npts,nang,nzz,ndep))
959  allocate(wta4_tbl(npts,nang,nzz,ndep))
960  !!
961  if ( allocated (tfac2_tbl) ) deallocate (tfac2_tbl)
962  if ( allocated (tfac4_tbl) ) deallocate (tfac4_tbl)
963  allocate(tfac2_tbl(npts,nang,nzz,ndep))
964  allocate(tfac4_tbl(npts,nang,nzz,ndep))
965  !!
966  if ( allocated (grad_tbl) ) deallocate (grad_tbl)
967  allocate(grad_tbl(npts,nang,nzz,ndep))
968  !!
969  if ( allocated (pha_tbl) ) deallocate (pha_tbl)
970  allocate(pha_tbl(nrng,ndep))
971  !! ----------------------------------------------------------------
972  !! ================================================================
973  !!
974  !!
975  !!-3 Allocate gridsetr 11 returned arrays declared as PUBLIC
976  if ( allocated (kref2) ) deallocate (kref2)
977  if ( allocated (kref4) ) deallocate (kref4)
978  allocate(kref2(npts,nang,nzz))
979  allocate(kref4(npts,nang,nzz))
980  !!
981  if ( allocated (jref2) ) deallocate (jref2)
982  if ( allocated (jref4) ) deallocate (jref4)
983  allocate(jref2(npts,nang,nzz))
984  allocate(jref4(npts,nang,nzz))
985  !!
986  if ( allocated (wtk2) ) deallocate (wtk2)
987  if ( allocated (wtk4) ) deallocate (wtk4)
988  allocate(wtk2(npts,nang,nzz))
989  allocate(wtk4(npts,nang,nzz))
990  !!
991  if ( allocated (wta2) ) deallocate (wta2)
992  if ( allocated (wta4) ) deallocate (wta4)
993  allocate(wta2(npts,nang,nzz))
994  allocate(wta4(npts,nang,nzz))
995  !!
996  if ( allocated (tfac2) ) deallocate (tfac2)
997  if ( allocated (tfac4) ) deallocate (tfac4)
998  allocate(tfac2(npts,nang,nzz))
999  allocate(tfac4(npts,nang,nzz))
1000  !!
1001  if ( allocated (grad) ) deallocate (grad)
1002  allocate(grad(npts,nang,nzz))
1003  !! ----------------------------------------------------------------
1004  !! ================================================================
1005  !!
1006  !!
1007  !!-4 Allocate shloxr/shlocr 5 returned arrays declared as PUBLIC
1008  if ( allocated (wk2x) ) deallocate (wk2x)
1009  if ( allocated (wk2y) ) deallocate (wk2y)
1010  allocate(wk2x(npts))
1011  allocate(wk2y(npts))
1012  !!
1013  if ( allocated (wk4x) ) deallocate (wk4x)
1014  if ( allocated (wk4y) ) deallocate (wk4y)
1015  allocate(wk4x(npts))
1016  allocate(wk4y(npts))
1017  !!
1018  if ( allocated (ds) ) deallocate (ds)
1019  allocate(ds(npts))
1020  !! ----------------------------------------------------------------
1021  !! ================================================================
1022  !!
1023  !!
1024  !!-5 Allocate w3snlx/optsa2 2 shared arrays declared as PUBLIC
1025  if ( allocated (ef2) ) deallocate (ef2)
1026  if ( allocated (ef1) ) deallocate (ef1)
1027  allocate(ef2(nrng,nang))
1028  allocate(ef1(nrng))
1029  !! ----------------------------------------------------------------
1030  !! ================================================================
1031  !!
1032  !!
1033  !!-6 Allocate optsa2 2 returned arrays declared as PUBLIC
1034  if ( allocated (dens1) ) deallocate (dens1)
1035  if ( allocated (dens2) ) deallocate (dens2)
1036  allocate(dens1(nrng,nang))
1037  allocate(dens2(nrng,nang))
1038  !! ----------------------------------------------------------------
1039  !! ================================================================
1040  !!
1041  !!
1042  !!-7 Allocate snlr_??? 2 returned arrays declared as PUBLIC
1043  if ( itsa .eq. 1) then
1044  !! allocate tsa, diag used for -tsa
1045  if ( allocated (tsa) ) deallocate (tsa)
1046  if ( allocated (diag) ) deallocate (diag)
1047  allocate(tsa(nrng,nang))
1048  allocate(diag(nrng,nang))
1049  elseif ( itsa .eq. 0) then
1050  !! allocate fbi, diag2 used for -fbi
1051  if ( allocated (fbi) ) deallocate (fbi)
1052  if ( allocated (diag2) ) deallocate (diag2)
1053  allocate(fbi(nrng,nang))
1054  allocate(diag2(nrng,nang))
1055  else
1056  write ( ndse,1000 ) itsa
1057  CALL extcde ( 115 )
1058  endif
1059  !! ----------------------------------------------------------------
1060  !! ================================================================
1061  !!
1062  !!
1063  !!-8 Get the 11 look-up table arrays by calling INSNL4
1064  !! ----------------------------------------------------------------
1065  !!
1066  !! ----------------------------------------------------------------
1067  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1068  call insnl4
1069  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1070  !!
1071  !! it returns: 11 look-up tables arrays dim=(npts,nang,nzz,ndep)
1072  !! kref2_tbl, kref4_tbl, jref2_tbl, jref4_tbl,
1073  !! wtk2_tbl, wtk4_tbl, wta2_tbl, wta4_tbl,
1074  !! tfac2_tbl, tfac4_tbl & grad_tbl
1075  !! plus pha_tbl dim=(nrng,ndep)
1076  !! and dep_tbl dim=(ndep)
1077  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1078  !! ----------------------------------------------------------------
1079  !! ================================================================
1080  !!
1081  !!
1082  first_tsa = .false.
1083  !!
1084  !!
1085  ENDIF !! IF ( FIRST_TSA ) THEN
1086  !! ------------------------------------------------------------------
1087  !! ==================================================================
1088  !! ##################################################################
1089  !!
1090  !!
1091  !!
1092  !!*i1 Map input ww3 "DEPTH" to "dep" and find corresp. depth bin # "nd3"
1093  !! ------------------------------------------------------------------
1094  dep = depth !* ww3 depth at a given time & loc.
1095  nd3 = minloc( abs(dep - dep_tbl(:)), dim=1 )
1096  !prt print *, 'DEPTH, corresp depth bin # (nd3) = ', DEPTH, nd3
1097  !! ------------------------------------------------------------------
1098  !!
1099  !!
1100  !!*i2 Map from Look-up tables the 11 gridsetr arrays corresp. to "nd3"
1101  !! kref2(:,:,:) -> grad(:,:,:) are used in subrs. "snlr_*"
1102  !! ------------------------------------------------------------------
1103  kref2(:,:,:) = kref2_tbl(:,:,:,nd3)
1104  kref4(:,:,:) = kref4_tbl(:,:,:,nd3)
1105  jref2(:,:,:) = jref2_tbl(:,:,:,nd3)
1106  jref4(:,:,:) = jref4_tbl(:,:,:,nd3)
1107  wtk2(:,:,:) = wtk2_tbl(:,:,:,nd3)
1108  wtk4(:,:,:) = wtk4_tbl(:,:,:,nd3)
1109  wta2(:,:,:) = wta2_tbl(:,:,:,nd3)
1110  wta4(:,:,:) = wta4_tbl(:,:,:,nd3)
1111  tfac2(:,:,:) = tfac2_tbl(:,:,:,nd3)
1112  tfac4(:,:,:) = tfac4_tbl(:,:,:,nd3)
1113  grad(:,:,:) = grad_tbl(:,:,:,nd3)
1114  pha(:) = pha_tbl(:,nd3)
1115  !! ------------------------------------------------------------------
1116  !!
1117  !!
1118  !!*i3 Map input ww3 arrays "WN(:)" & "CG(:)" to "wka(:)" & "cga(:)"
1119  !! Note; Arrays wka(:) & cga(:) corresp to ww3 "DEPTH" & to be used in "optsa2"
1120  !! ------------------------------------------------------------------
1121  wka(:) = wn(1:nk) !* Wavenumber array at ww3 "DEPTH"
1122  cga(:) = cg(1:nk) !* Group velocity array at ww3 "DEPTH"
1123  !! ------------------------------------------------------------------
1124  !!
1125  !!
1126  !!*i4 Convert input WW3 2D Action Density spectrum "A(theta,k)"
1127  !! to 2D Energy Density spectrum "ef2(theta,f)" & reverse indices
1128  !! ==> ef2(f,theta) = A(theta,k) * 2*pi*oma(f)/cga(f)
1129  !! ------------------------------------------------------------------
1130  do irng=1,nrng
1131  fac = twopi*oma(irng)/cga(irng)
1132  do iang=1,nang
1133  ef2(irng,iang) = a(iang,irng) * fac
1134  end do
1135  end do
1136  !! ------------------------------------------------------------------
1137  !!
1138  !!
1139  !!*i5 Calculte the 1D Energy Density "ef1(f)"
1140  !! ------------------------------------------------------------------
1141  do irng=1,nrng
1142  sum1 = 0.0
1143  do iang=1,nang
1144  sum1 = sum1 + ef2(irng,iang)
1145  end do
1146  ef1(irng) = sum1 * ainc
1147  end do
1148  !! ------------------------------------------------------------------
1149  !! ==================================================================
1150  !!------------------------------------------------------------------------------
1151  !!==============================================================================
1152  !!
1153  !!
1154  !!op2
1155  !!* Bash;
1156  !!* Find 1 or 2 peaks that satisfy TSA min condition (below) ------- *
1157  !!* before calling TSA subrs. otherwise bailout (return) ----------- *
1158  !!* Bailout & return with init. values of S & D = 0.0 -------------- *
1159  !!* nsep = min # of bins that separates between npk & npk2 (set=2) *
1160  !!* nbins = actual # of bins > npk (incl. nfs) -- or -- *
1161  !!* actual # of bins > npk2 (incl. nrng) *
1162  !!* to guarantee a min 1 bin in equi. range *
1163  !!* *
1164  !!* ===> In case of just 1 peak the TSA min condition ------------- * *****
1165  !!* ===> is relative to nrng and is satisfied when ---------------- * <<<<<
1166  !!* ===> npk.le.nrng-1, to guarantee min 1 bin (incl nrng) > npk -- * <<<<<
1167  !!* ===> we only need 1 bin in optsa2 to be in the equi. range ---- * <<<<<
1168  !!* ===> skip if condition is not met ie if npk.gt.nrng-1 ------- * <<<<<
1169  !!* ---------------------------------------------------------------- *
1170  !!* *
1171  !!* ===> In case of 2 peaks the TSA min condition is applied twice: * *****
1172  !!* ===> *1) at low freq peak (npk), *2) at high freq peak (npk2) * *****
1173  !!* ===> *1) TSA min condition for the low freq peak (npk) --------- * *****
1174  !!* ===> is relative to nfs and is satisfied when ----------------- * <<<<<
1175  !!* ===> npk.le.nfs-1, to guarantee min 1 bin (incl nfs) > npk2 --- * <<<<<
1176  !!* ===> we only need 1 bin in optsa2 to be in the equi. range ---- * <<<<<
1177  !!* ===> skip if condition is not met ie if npk.gt.nfs-1 -------- * <<<<<
1178  !!* *
1179  !!* ===> *2) TSA min condition for the high freq peak (npk2) ------- * *****
1180  !!* ===> is relative to nrng and is satisfied when ---------------- * <<<<<
1181  !!* ===> npk2.le.nrng-1 to guarantee min 1 bin (incl nrng) > npk2 * <<<<<
1182  !!* ===> we only need 1 bin in optsa2 to be in the equi. range ---- * <<<<<
1183  !!* ===> skip if condition is not met ie if npk2.gt.nrng-1 ------- * <<<<<
1184  !!* ---------------------------------------------------------------- *
1185  !! ------------------------------------------------------------ !!op2
1186  !! ==================================================================
1187  !!
1188  !!op2 ctd
1189  !! First find the overall peak in ef1(:) with e1max must be > 0.000001
1190  !! Starting from low freq. find the Energy max "e1max" and
1191  !! corresp. peak freq. "fpk" and its freq. number "npk".
1192  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1193  npk = 0
1194  fpk = 0.0
1195  e1max = 0.0
1196  npeaks = 0
1197  !! Look in the freq range that works for TSA call (see condition below)
1198  do irng=2,nrng-1 !* last peak loc. is at nrng-1 <<<<<
1199  !! Pick the 1st local abs. max in [2,nrng-1] using (ef1(irng).gt.e1max)
1200  !! so that if 2 equal adj. peaks are found it will pick the 1st e1max
1201  !! encountered (i.e. the lower freq. one)
1202  !! --------------------------------------------------------------!* <<<<<
1203  if ( ef1(irng).gt.ef1(irng-1) .and. ef1(irng).gt.ef1(irng+1) &
1204  .and. ef1(irng).gt.e1max ) then
1205  !! --------------------------------------------------------------!* <<<<<
1206  npk = irng !* update npk
1207  fpk = frqa(npk) !* update fpk
1208  e1max = ef1(npk) !* update e1max
1209  npeaks = 1
1210  endif
1211  end do
1212  !! ------------------------------------------------------------------
1213  !!
1214  !!B if a 1st peak is not found (npeaks=0 & e1max=0.0 < eps) or
1215  !!B if a 1st peak is found with a tiny peak energy (e1max < eps) or
1216  !!B if TSA min condition is not met rel. to nrng (npk.gt.nrng-1) <<<<<
1217  !!B this spectrum is Not suitable for tsa, so don't call tsa
1218  !!B just return (don't stop) with init. values of S(:,:) and D(:,:)=0.0
1219  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1220  if ( e1max.lt.0.000001 ) return
1221  !! ------------------------------------------------------------ !!op2
1222  !! ==================================================================
1223  !!
1224  !!
1225  !!op2 ctd
1226  !! Bash; if we are here (i.e. we did not return) then we must
1227  !! have found the 1st good peak (= overall peak) with e1max > eps
1228  !!
1229  !! Now we look for a new 2nd peak that is at least 'nsep' bins away from
1230  !! the 1st peak (nsep=2) (i.e. iabs(irng-npk).gt.nsep) before
1231  !! calling new "optsa2" (the 2nd peak will have e1max2 < e1max)
1232  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1233  nsep = 2
1234  npk2 = 0
1235  fpk2 = 0.0
1236  e1max2 = 0.0
1237  !! Again look in the freq range that is in line with TSA min condition
1238  !! and find the 2nd highest peak with eps < e1max2 < e1max
1239  do irng=2,nrng-1 !* last peak loc. is at nrng-1 <<<<<
1240  !! Pick the 2nd local abs. max in [2,nrng-1] that is at least 'nsep'
1241  !! bins away from the 1st peak using (ef1(irng).ge.e1max2) so that
1242  !! if 2 equal adj. peaks are found it will pick the 2nd e1max2
1243  !! encountered (i.e. the higher freq. one)
1244  !! --------------------------------------------------------------!* <<<<<
1245  if ( ef1(irng).gt.ef1(irng-1) .and. ef1(irng).gt.ef1(irng+1) &
1246  .and. ef1(irng).ge.e1max2 .and. iabs(irng-npk).gt.nsep ) then
1247  !! --------------------------------------------------------------!* <<<<<
1248  npk2 = irng !* update npk2
1249  fpk2 = frqa(npk2) !* update fpk2
1250  e1max2 = ef1(npk2) !* update e1max2
1251  npeaks = 2
1252  endif
1253  end do
1254  !! ------------------------------------------------------------------
1255  !!
1256  !!B if a 2nd peak is not found (npeaks=1 & e1max2=0.0 < eps)
1257  !!B if a 2nd peak is found with a tiny peak energy (e1max2 < eps) or
1258  !!B if TSA min condition is not met rel. to nrng (npk2.gt.nrng-1) <<<<<
1259  !!B This 2nd peak is not suitable for tsa, drop it and stay with just 1st peak.
1260  if ( e1max2.lt.0.000001 ) then
1261  npeaks = 1
1262  goto 200 !* skip the remaings tests goto 200
1263  endif
1264  !! ------------------------------------------------------------ !!op2
1265  !! ==================================================================
1266  !!
1267  !!
1268  !!
1269  !!
1270  !!op2 ctd
1271  if ( npeaks.eq.2 ) then
1272  !!-1 Shuffle the 2 peaks (if necessary) to keep npk to be always < npk2
1273  !! This says nothing about which peak is the dominant peak
1274  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1275  if ( npk2.lt.npk ) then
1276  npk0 = npk2
1277  npk2 = npk
1278  npk = npk0 !* this way npk < npk2 always
1279  fpk = frqa(npk)
1280  fpk2 = frqa(npk2)
1281  endif
1282  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1283  !!
1284  !!-2 here we have 2 peaks (npeaks=2) with npk < npk2
1285  !! find the freq. separation "nfs" (that divide the freq. regime into 2)
1286  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1287  nfs = int( (npk+npk2) / 2.0 ) !* take the lower bin # to be nfs
1288  !b nfs = INT ( (npk+npk2+1) / 2.0 ) !* take the higher bin # to be nfs
1289  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1290  endif !! if ( npeaks.eq.2 )
1291  !!
1292 200 continue
1293  !! ------------------------------------------------------------ !!op2
1294  !! ==================================================================
1295  !!
1296  !!
1297  !! Bash; With the new "optsa2" you are allowed one call (if 1 peak)
1298  !! or 2 calls (if 2 peaks) o account for spectra with double peaks.
1299  !! Note; when nrmn=1 & nrmx=nrng ==> optsa2 = the old optsa
1300  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1301  !!
1302  if ( npeaks.eq.1 ) then
1303  !!-1 one call to optsa2 for the whole freq. regime ( 1 --> nrng )
1304  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1305  nbins = nrng - npk !* # of bins in (npk, nrng] not incl. npk
1306  if ( nbins.gt.nb2fp ) nbins=nb2fp !* limit equi. range to ~2.0*fp
1307  !! ----------------------------------------------------------------
1308  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1309  call optsa2 ( 1,nrng, npk, fpk, nbins, wka, cga )
1310  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1311  !! It returns variables dens1(nrng,nang) and dens2(nrng,nang)
1312  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1313  !! ----------------------------------------------------------------
1314  endif !! if ( npeaks.eq.1 )
1315  !! ==================================================================
1316  !!
1317  !!
1318  if ( npeaks.eq.2 ) then
1319  !!
1320  !!-2 Now make two calls to new "optsa2" one for each freq regime.
1321  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1322  nbins = nfs - npk !* # of bins in (npk, nfs] not incl. npk
1323  if ( nbins.gt.nb2fp ) nbins=nb2fp !* limit equi. range to ~2.0*fp
1324  !! ---------------------------------------------------------------
1325  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1326  call optsa2 ( 1,nfs, npk, fpk, nbins, wka, cga )
1327  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1328  !! It returns variables dens1(nrng,nang) and dens2(nrng,nang)
1329  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1330  !! ----------------------------------------------------------------
1331  !!
1332  nbins = nrng - npk2 !* # of bins in (npk2, nrng] not incl. npk2
1333  if ( nbins.gt.nb2fp ) nbins=nb2fp !* limit equi. range to ~2.0*fp
1334  !! ----------------------------------------------------------------
1335  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1336  call optsa2 ( nfs+1,nrng, npk2,fpk2, nbins, wka, cga )
1337  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1338  !! It returns variables dens1(nrng,nang) and dens2(nrng,nang)
1339  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1340  !! ----------------------------------------------------------------
1341  !! ================================================================
1342  !!
1343  !!-3 Remove the step like jump (if exists) in dens1() between nfs & nfs+1
1344  do iang=1,nang
1345  sumd1 = dens1(nfs,iang) + dens2(nfs,iang) !* sum at nfs
1346  sumd2 = dens1(nfs+1,iang) + dens2(nfs+1,iang) !* sum at nfs+1
1347  !!
1348  !! do 3 bin average for dens1() at nfs and store in densat1
1349  densat1 = ( dens1(nfs-1,iang) + dens1(nfs,iang) + &
1350  dens1(nfs+1,iang) ) / 3.
1351  !! do 3 bin average for dens1() at nfs+1 and store in densat2
1352  densat2 = ( dens1(nfs,iang) + dens1(nfs+1,iang) + &
1353  dens1(nfs+2,iang) ) / 3.
1354  !!
1355  !! subtitute back into dens1(nfs,iang) & dens1(nfs+1,iang)
1356  dens1(nfs,iang) = densat1 ! dens1 at nfs
1357  dens1(nfs+1,iang) = densat2 ! dens1 at nfs+1
1358  !!
1359  !! recalculate dens2(nfs,iang) & dens2(nfs+1,iang)
1360  dens2(nfs,iang) = sumd1 - densat1 ! dens2 at nfs
1361  dens2(nfs+1,iang) = sumd2 - densat2 ! dens2 at nfs+1
1362  end do
1363  !!
1364  endif !! if ( npeaks.eq.2 )
1365  !! ==================================================================
1366  !!
1367  !!
1368  !!
1369  !! -----------------------------------------------------------------#
1370  !! !
1371  !! Get Snl source term and its diagonal term from "snlr" !
1372  !! for -tsa only use "snlr_tsa" itsa = 1 !
1373  !! for -fbi only use "snlr_fbi" itsa = 0 !
1374  !! !
1375  !! -----------------------------------------------------------------#
1376  !!
1377  !!
1378  if ( itsa .eq. 1) then
1379  !!
1380  !! ----------------------------------------------------------------
1381  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1382  call snlr_tsa ( pha, ialt )
1383  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1384  !! It returns tsa(nrng,nang) & diag(nrng,nang)
1385  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1386  !! ----------------------------------------------------------------
1387  !!
1388  !! Pack results in proper format ---------------------------------- *
1389  !! S() & D() arrays are to be returned to WW3 in (k,theta) space
1390  do irng=1,nrng
1391  do iang=1,nang
1392  !! Convert the Norm. (in k) Polar tsa(k,theta) to Polar S(theta,k)
1393  !! and reverse indices back to (iang,irng) as in WW3
1394  s(iang,irng) = tsa(irng,iang) * wka(irng) !* <=============
1395  d(iang,irng) = diag(irng,iang)
1396  !! ---------------------------
1397  end do
1398  end do
1399  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1400  !!
1401  !!
1402  elseif ( itsa .eq. 0) then
1403  !!
1404  !!
1405  !! ----------------------------------------------------------------
1406  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1407  call snlr_fbi ( pha, ialt )
1408  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1409  !! It returns fbi(nrng,nang) & diag2(nrng,nang)
1410  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1411  !! ----------------------------------------------------------------
1412  !!
1413  !! Pack results in proper format ---------------------------------- *
1414  !! S() & D() arrays are to be returned to WW3 in (k,theta) space
1415  do irng=1,nrng
1416  do iang=1,nang
1417  !! Convert the Norm. (in k) Polar fbi(k,theta) to Polar S(theta,k)
1418  !! and reverse indices back to (iang,irng) as in WW3
1419  s(iang,irng) = fbi(irng,iang) * wka(irng) !* <=============
1420  d(iang,irng) = diag2(irng,iang)
1421  !! --------------------------------
1422  end do
1423  end do
1424  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1425  !!
1426  else
1427  !!
1428  write( ndse,1000 ) itsa
1429  CALL extcde ( 130 )
1430  !! --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1431  !!
1432  endif
1433  !! ------------------------------------------------------------------
1434  !! ==================================================================
1435  !!
1436  RETURN
1437  !!
1438 1000 format ( ' W3SNL4 Error : Bad itsa value ',i4)
1439  !!

References ainc, angl, cosan, dens1, dens2, dep_tbl, dfrq, diag, diag2, ds, w3gdatmd::dth, w3gdatmd::ecos, ef1, ef2, w3gdatmd::esin, w3servmd::extcde(), f0, fbi, frqa, grad, grad_tbl, w3gdatmd::ialt, insnl4(), w3gdatmd::itsa, jref2, jref2_tbl, jref4, jref4_tbl, kref2, kref2_tbl, kref4, kref4_tbl, kzone, na2p1, nang, nb2fp, ndep, w3odatmd::ndse, w3odatmd::ndso, w3odatmd::ndst, w3gdatmd::nk, np2p1, npts, nrng, w3gdatmd::nth, nzz, oma, optsa2(), pha_tbl, w3gdatmd::sig, sinan, snlr_fbi(), snlr_tsa(), w3servmd::strace(), tfac2, tfac2_tbl, tfac4, tfac4_tbl, w3gdatmd::th, constants::tpi, tsa, twopi, wk2x, wk2y, wk4x, wk4y, wta2, wta2_tbl, wta4, wta4_tbl, wtk2, wtk2_tbl, wtk4, wtk4_tbl, and w3gdatmd::xfr.

Referenced by gxexpo(), w3exnc(), w3expo(), and w3srcemd::w3srce().

◆ wkfnc()

real function w3snl4md::wkfnc ( real, intent(in)  f,
real, intent(in)  dep 
)

Calculate the Wavenumber k (rad/m) as function of frequency 'f' (Hz) and depth 'dep' (m).

  Using what looks like a "Pade approximation" of an inversion
  of the linear wave dispersion relation.

      sigma^2 = gk*tanh(kd),  sigma = 2*pi*f
      Wavenumber k (rad/m) is returned in "wkfnc"
Parameters
fFrequency (Hz).
depDepth (m).
Returns
wkfnc Wavenumber 'k'
Author
Bash Toulany
Michael Casey
William Perrie
Date
12-Apr-2016

Definition at line 5299 of file w3snl4md.F90.

5299  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5300  !/
5301  !/ +-----------------------------------+
5302  !/ | WAVEWATCH III BIO |
5303  !/ | Bash Toulany |
5304  !/ | Michael Casey |
5305  !/ | William Perrie |
5306  !/ | FORTRAN 90 |
5307  !/ | Last update : 12-Apr-2016 |
5308  !/ +-----------------------------------+
5309  !/
5310  !/ 01-Mar-2016 : Origination. ( version 5.13 )
5311  !/
5312  !!
5313  !! it returns: wavenumber 'k' in wkfnc
5314  !!
5315  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5316  !! ------------------------------------------------------------------
5317  !! ==================================================================
5318  !!
5319  !! 1. Purpose :
5320  !!
5321  !! Calculate the Wavenumber k (rad/m) as function of
5322  !! frequency 'f' (Hz) and depth 'dep' (m).
5323  !!
5324  !! 2. Method :
5325  !!
5326  !! Using what looks like a "Pade approximation" of an inversion
5327  !! of the linear wave dispersion relation.
5328  !! sigma^2 = gk*tanh(kd), sigma = 2*pi*f
5329  !! Wavenumber k (rad/m) is returned in "wkfnc"
5330  !!
5331  !! 3. Parameters :
5332  !!
5333  !! Parameter list
5334  !! ------------------------------------------------------------------
5335  !! Name Type Scope I/O Description
5336  !! ------------------------------------------------------------------
5337  !! twopi Real Public I = TPI; WW3 2*pi=8.*atan(1.) (radians)
5338  !! ------------------------------------------------------------------
5339  !!
5340  !! --------------------------------------------------------------- &
5341  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5342  !! ----------------------------------------------------------------72
5343  !! ==================================================================
5344  !!
5345  !!
5346  IMPLICIT NONE
5347  !!
5348  !! Parameter list
5349  !! --------------
5350  real, intent(in) :: f, dep
5351  !!
5352  !! Local variables
5353  !! ---------------
5354  real(KIND=8) :: g, y, x
5355  !! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5356  !! ---------------------::-----------------------------------------72
5357  !! ##################################################################
5358  !!------------------------------------------------------------------------------
5359  !!==============================================================================
5360  !!
5361  !!
5362  g = 9.806 !* set = GRAV as in CONSTANTS
5363  !!
5364  y = ( (twopi*f)**2 ) * dep / g !* sigma^2 d/g
5365  !!
5366  !! --------------------------------------------------------------- &
5367  x = y * ( y + &
5368  1./(1.00000+y*(0.66667+y*(0.35550+y*(0.16084+y*(0.06320 &
5369  +y*(0.02174+y*(0.00654+y*(0.00171+y*(0.00039+y*0.00011) &
5370  )))))))))
5371  !! --------------------------------------------------------------- &
5372  !!
5373  x = sqrt(x) !* kd
5374  !!
5375  wkfnc = x / dep !* k
5376  !! ------------------------------------------------------------------
5377  !! ==================================================================
5378  !!
5379  RETURN
5380  !!

References twopi.

Referenced by insnl4(), and shloxr().

Variable Documentation

◆ ainc

real w3snl4md::ainc

Definition at line 142 of file w3snl4md.F90.

142  real :: ainc, twopi

Referenced by gridsetr(), insnl4(), optsa2(), and w3snl4().

◆ angl

real, dimension(:), allocatable w3snl4md::angl

Definition at line 144 of file w3snl4md.F90.

144  real, allocatable, dimension(:) :: angl, sinan, cosan

Referenced by w3snl4().

◆ cosan

real, dimension(:), allocatable w3snl4md::cosan

Definition at line 144 of file w3snl4md.F90.

Referenced by gridsetr(), and w3snl4().

◆ dens1

real, dimension(:,:), allocatable w3snl4md::dens1

Definition at line 188 of file w3snl4md.F90.

188  real, allocatable, dimension(:,:) :: dens1, dens2

Referenced by optsa2(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ dens2

real, dimension(:,:), allocatable w3snl4md::dens2

Definition at line 188 of file w3snl4md.F90.

Referenced by optsa2(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ dep_tbl

real, dimension(:), allocatable w3snl4md::dep_tbl

Definition at line 145 of file w3snl4md.F90.

145  real, allocatable, dimension(:) :: dep_tbl

Referenced by insnl4(), and w3snl4().

◆ dfrq

real w3snl4md::dfrq

Definition at line 141 of file w3snl4md.F90.

141  real :: dfrq, f0

Referenced by gridsetr(), insnl4(), and w3snl4().

◆ diag

real, dimension(:,:), allocatable w3snl4md::diag

Definition at line 195 of file w3snl4md.F90.

Referenced by snlr_tsa(), and w3snl4().

◆ diag2

real, dimension(:,:), allocatable w3snl4md::diag2

Definition at line 196 of file w3snl4md.F90.

Referenced by snlr_fbi(), and w3snl4().

◆ ds

real, dimension(:), allocatable w3snl4md::ds

Definition at line 173 of file w3snl4md.F90.

Referenced by gridsetr(), shlocr(), shloxr(), and w3snl4().

◆ ef1

real, dimension(:), allocatable w3snl4md::ef1

Definition at line 181 of file w3snl4md.F90.

181  real, allocatable, dimension(:) :: ef1

Referenced by optsa2(), and w3snl4().

◆ ef2

real, dimension(:,:), allocatable w3snl4md::ef2

Definition at line 180 of file w3snl4md.F90.

180  real, allocatable, dimension(:,:) :: ef2

Referenced by optsa2(), and w3snl4().

◆ f0

real w3snl4md::f0

Definition at line 141 of file w3snl4md.F90.

Referenced by gridsetr(), and w3snl4().

◆ fbi

real, dimension(:,:), allocatable w3snl4md::fbi

Definition at line 196 of file w3snl4md.F90.

196  real, allocatable, dimension(:,:) :: fbi, diag2

Referenced by snlr_fbi(), and w3snl4().

◆ frqa

real, dimension(:), allocatable w3snl4md::frqa

Definition at line 143 of file w3snl4md.F90.

143  real, allocatable, dimension(:) :: frqa, oma

Referenced by gridsetr(), insnl4(), optsa2(), and w3snl4().

◆ grad

real, dimension(:,:,:), allocatable w3snl4md::grad

Definition at line 167 of file w3snl4md.F90.

167  real, allocatable, dimension(:,:,:) :: grad

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ grad_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::grad_tbl

Definition at line 156 of file w3snl4md.F90.

156  real, allocatable, dimension(:,:,:,:) :: grad_tbl

Referenced by insnl4(), and w3snl4().

◆ ismo

integer, parameter w3snl4md::ismo = 1

Definition at line 126 of file w3snl4md.F90.

126  integer, parameter :: ismo = 1 !* = 1 do smooth in interp2

Referenced by interp2().

◆ jref2

integer, dimension(:,:,:), allocatable w3snl4md::jref2

Definition at line 163 of file w3snl4md.F90.

163  integer, allocatable, dimension(:,:,:) :: jref2, jref4

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ jref2_tbl

integer, dimension(:,:,:,:), allocatable w3snl4md::jref2_tbl

Definition at line 152 of file w3snl4md.F90.

152  integer, allocatable, dimension(:,:,:,:) :: jref2_tbl, jref4_tbl

Referenced by insnl4(), and w3snl4().

◆ jref4

integer, dimension(:,:,:), allocatable w3snl4md::jref4

Definition at line 163 of file w3snl4md.F90.

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ jref4_tbl

integer, dimension(:,:,:,:), allocatable w3snl4md::jref4_tbl

Definition at line 152 of file w3snl4md.F90.

Referenced by insnl4(), and w3snl4().

◆ kref2

integer, dimension(:,:,:), allocatable w3snl4md::kref2

Definition at line 162 of file w3snl4md.F90.

162  integer, allocatable, dimension(:,:,:) :: kref2, kref4

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ kref2_tbl

integer, dimension(:,:,:,:), allocatable w3snl4md::kref2_tbl

Definition at line 151 of file w3snl4md.F90.

151  integer, allocatable, dimension(:,:,:,:) :: kref2_tbl, kref4_tbl

Referenced by insnl4(), and w3snl4().

◆ kref4

integer, dimension(:,:,:), allocatable w3snl4md::kref4

Definition at line 162 of file w3snl4md.F90.

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ kref4_tbl

integer, dimension(:,:,:,:), allocatable w3snl4md::kref4_tbl

Definition at line 151 of file w3snl4md.F90.

Referenced by insnl4(), and w3snl4().

◆ kzone

integer w3snl4md::kzone

Definition at line 138 of file w3snl4md.F90.

Referenced by gridsetr(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ na2p1

integer w3snl4md::na2p1

Definition at line 139 of file w3snl4md.F90.

Referenced by w3snl4().

◆ nang

integer w3snl4md::nang

Definition at line 139 of file w3snl4md.F90.

139  integer :: nang, na2p1

Referenced by gridsetr(), insnl4(), and w3snl4().

◆ nb2fp

integer w3snl4md::nb2fp

Definition at line 138 of file w3snl4md.F90.

Referenced by w3snl4().

◆ ndep

integer, parameter w3snl4md::ndep = 37

Definition at line 131 of file w3snl4md.F90.

131  integer, parameter :: ndep = 37 !* # of depths in look-up tables

Referenced by insnl4(), and w3snl4().

◆ np2p1

integer w3snl4md::np2p1

Definition at line 140 of file w3snl4md.F90.

140  integer :: np2p1

Referenced by gridsetr(), shlocr(), shloxr(), and w3snl4().

◆ npts

integer, parameter w3snl4md::npts = 30

Definition at line 129 of file w3snl4md.F90.

129  integer, parameter :: npts = 30 !* # of points on the locus

Referenced by gridsetr(), insnl4(), shlocr(), shloxr(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ nrng

integer w3snl4md::nrng

Definition at line 138 of file w3snl4md.F90.

138  integer :: nrng, nzz, kzone, nb2fp

Referenced by w3snl4().

◆ nzz

integer w3snl4md::nzz

Definition at line 138 of file w3snl4md.F90.

Referenced by w3snl4().

◆ oma

real, dimension(:), allocatable w3snl4md::oma

Definition at line 143 of file w3snl4md.F90.

Referenced by insnl4(), optsa2(), and w3snl4().

◆ pha_tbl

real, dimension(:,:), allocatable w3snl4md::pha_tbl

Definition at line 157 of file w3snl4md.F90.

157  real, allocatable, dimension(:,:) :: pha_tbl

Referenced by insnl4(), and w3snl4().

◆ sinan

real, dimension(:), allocatable w3snl4md::sinan

Definition at line 144 of file w3snl4md.F90.

Referenced by gridsetr(), optsa2(), and w3snl4().

◆ tfac2

real, dimension(:,:,:), allocatable w3snl4md::tfac2

Definition at line 166 of file w3snl4md.F90.

166  real, allocatable, dimension(:,:,:) :: tfac2, tfac4

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ tfac2_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::tfac2_tbl

Definition at line 155 of file w3snl4md.F90.

155  real, allocatable, dimension(:,:,:,:) :: tfac2_tbl, tfac4_tbl

Referenced by insnl4(), and w3snl4().

◆ tfac4

real, dimension(:,:,:), allocatable w3snl4md::tfac4

Definition at line 166 of file w3snl4md.F90.

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ tfac4_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::tfac4_tbl

Definition at line 155 of file w3snl4md.F90.

Referenced by insnl4(), and w3snl4().

◆ tsa

real, dimension(:,:), allocatable w3snl4md::tsa

Definition at line 195 of file w3snl4md.F90.

195  real, allocatable, dimension(:,:) :: tsa, diag

Referenced by snlr_tsa(), and w3snl4().

◆ twopi

real w3snl4md::twopi

Definition at line 142 of file w3snl4md.F90.

Referenced by cgfnc(), gridsetr(), optsa2(), shloxr(), w3snl4(), and wkfnc().

◆ wk2x

real, dimension(:), allocatable w3snl4md::wk2x

Definition at line 172 of file w3snl4md.F90.

172  real, allocatable, dimension(:) :: wk2x, wk2y

Referenced by gridsetr(), shlocr(), shloxr(), and w3snl4().

◆ wk2y

real, dimension(:), allocatable w3snl4md::wk2y

Definition at line 172 of file w3snl4md.F90.

Referenced by gridsetr(), shlocr(), shloxr(), and w3snl4().

◆ wk4x

real, dimension(:), allocatable w3snl4md::wk4x

Definition at line 173 of file w3snl4md.F90.

173  real, allocatable, dimension(:) :: wk4x, wk4y, ds

Referenced by gridsetr(), shlocr(), shloxr(), and w3snl4().

◆ wk4y

real, dimension(:), allocatable w3snl4md::wk4y

Definition at line 173 of file w3snl4md.F90.

Referenced by gridsetr(), shlocr(), shloxr(), and w3snl4().

◆ wta2

real, dimension(:,:,:), allocatable w3snl4md::wta2

Definition at line 165 of file w3snl4md.F90.

165  real, allocatable, dimension(:,:,:) :: wta2, wta4

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ wta2_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::wta2_tbl

Definition at line 154 of file w3snl4md.F90.

154  real, allocatable, dimension(:,:,:,:) :: wta2_tbl, wta4_tbl

Referenced by insnl4(), and w3snl4().

◆ wta4

real, dimension(:,:,:), allocatable w3snl4md::wta4

Definition at line 165 of file w3snl4md.F90.

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ wta4_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::wta4_tbl

Definition at line 154 of file w3snl4md.F90.

Referenced by insnl4(), and w3snl4().

◆ wtk2

real, dimension(:,:,:), allocatable w3snl4md::wtk2

Definition at line 164 of file w3snl4md.F90.

164  real, allocatable, dimension(:,:,:) :: wtk2, wtk4

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ wtk2_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::wtk2_tbl

Definition at line 153 of file w3snl4md.F90.

153  real, allocatable, dimension(:,:,:,:) :: wtk2_tbl, wtk4_tbl

Referenced by insnl4(), and w3snl4().

◆ wtk4

real, dimension(:,:,:), allocatable w3snl4md::wtk4

Definition at line 164 of file w3snl4md.F90.

Referenced by gridsetr(), insnl4(), snlr_fbi(), snlr_tsa(), and w3snl4().

◆ wtk4_tbl

real, dimension(:,:,:,:), allocatable w3snl4md::wtk4_tbl

Definition at line 153 of file w3snl4md.F90.

Referenced by insnl4(), and w3snl4().

w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3snl4md::wk2y
real, dimension(:), allocatable wk2y
Definition: w3snl4md.F90:172
w3snl4md::gridsetr
subroutine gridsetr(dep, wka1, cgnrng1)
This routine sets up the geometric part of the Boltzmann integral.
Definition: w3snl4md.F90:1481
w3snl4md::wtk2_tbl
real, dimension(:,:,:,:), allocatable wtk2_tbl
Definition: w3snl4md.F90:153
w3gdatmd::dth
real, pointer dth
Definition: w3gdatmd.F90:1232
w3snl4md::np2p1
integer np2p1
Definition: w3snl4md.F90:140
w3snl4md::cplshr
subroutine cplshr(w1x0, w1y0, w2x0, w2y0, w3x0, w3y0, h, csq, irng, krng, kang, ipt)
Calculates four-wave Boltzmann coupling coefficient in shallow water.
Definition: w3snl4md.F90:2876
w3snl4md::kref2
integer, dimension(:,:,:), allocatable kref2
Definition: w3snl4md.F90:162
wmmdatmd::nmpscr
integer nmpscr
NMPSCR.
Definition: wmmdatmd.F90:324
w3snl4md::oma
real, dimension(:), allocatable oma
Definition: w3snl4md.F90:143
w3snl4md::optsa2
subroutine optsa2(nrmn, nrmx, npk, fpk, nbins, wka, cga)
Splits the Action Density into two parts.
Definition: w3snl4md.F90:3259
w3snl4md::ds
real, dimension(:), allocatable ds
Definition: w3snl4md.F90:173
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3gdatmd::ecos
real, dimension(:), pointer ecos
Definition: w3gdatmd.F90:1234
w3snl4md::dep_tbl
real, dimension(:), allocatable dep_tbl
Definition: w3snl4md.F90:145
w3snl4md::frqa
real, dimension(:), allocatable frqa
Definition: w3snl4md.F90:143
w3snl4md::tfac2
real, dimension(:,:,:), allocatable tfac2
Definition: w3snl4md.F90:166
w3snl4md::wtk2
real, dimension(:,:,:), allocatable wtk2
Definition: w3snl4md.F90:164
w3snl4md::pha_tbl
real, dimension(:,:), allocatable pha_tbl
Definition: w3snl4md.F90:157
w3snl4md::dens2
real, dimension(:,:), allocatable dens2
Definition: w3snl4md.F90:188
wmmdatmd::improc
integer improc
IMPROC.
Definition: wmmdatmd.F90:322
w3gdatmd::th
real, dimension(:), pointer th
Definition: w3gdatmd.F90:1234
w3snl4md::npts
integer, parameter npts
Definition: w3snl4md.F90:129
w3snl4md::wta2_tbl
real, dimension(:,:,:,:), allocatable wta2_tbl
Definition: w3snl4md.F90:154
w3snl4md::shloxr
subroutine shloxr(dep, wk1x, wk1y, wk3x, wk3y)
General locus solution for input vectors (wk1x,wk1y).
Definition: w3snl4md.F90:2011
w3snl4md::nang
integer nang
Definition: w3snl4md.F90:139
w3snl4md::twopi
real twopi
Definition: w3snl4md.F90:142
w3snl4md::grad_tbl
real, dimension(:,:,:,:), allocatable grad_tbl
Definition: w3snl4md.F90:156
w3snl4md::cgfnc
real function cgfnc(f, dep, cvel)
Calculate the Group velocity Cg (m/s) as function of frequency 'f' (Hz), depth 'dep' (m) and phase sp...
Definition: w3snl4md.F90:5409
w3snl4md::ef2
real, dimension(:,:), allocatable ef2
Definition: w3snl4md.F90:180
w3snl4md::wk4y
real, dimension(:), allocatable wk4y
Definition: w3snl4md.F90:173
w3gdatmd::ialt
integer, pointer ialt
Definition: w3gdatmd.F90:1368
scrip_timers::status
character(len=8), dimension(max_timers), save status
Definition: scrip_timers.f:63
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3snl4md::snlr_tsa
subroutine snlr_tsa(pha, ialt)
For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,...
Definition: w3snl4md.F90:4391
w3gdatmd::esin
real, dimension(:), pointer esin
Definition: w3gdatmd.F90:1234
w3snl4md::wta4_tbl
real, dimension(:,:,:,:), allocatable wta4_tbl
Definition: w3snl4md.F90:154
w3snl4md::insnl4
subroutine insnl4
It reads look-up tables (generated by gridsetr) if file exists otherwise it must generate the look-up...
Definition: w3snl4md.F90:219
w3snl4md::nb2fp
integer nb2fp
Definition: w3snl4md.F90:138
w3snl4md::ef1
real, dimension(:), allocatable ef1
Definition: w3snl4md.F90:181
w3snl4md::snlr_fbi
subroutine snlr_fbi(pha, ialt)
For a given Action Density array dens1(k,theta), computes the rate-of-change array sumint(k,...
Definition: w3snl4md.F90:3758
w3servmd
Definition: w3servmd.F90:3
w3snl4md::jref2
integer, dimension(:,:,:), allocatable jref2
Definition: w3snl4md.F90:163
w3snl4md::interp2
subroutine interp2(X)
Interpolate bi-linearly to fill in tsa/fbi & diag/diag2 arrays.
Definition: w3snl4md.F90:5018
w3snl4md::wta4
real, dimension(:,:,:), allocatable wta4
Definition: w3snl4md.F90:165
w3gdatmd::nth
integer, pointer nth
Definition: w3gdatmd.F90:1230
w3snl4md::f0
real f0
Definition: w3snl4md.F90:141
w3snl4md::jref4_tbl
integer, dimension(:,:,:,:), allocatable jref4_tbl
Definition: w3snl4md.F90:152
w3snl4md::wta2
real, dimension(:,:,:), allocatable wta2
Definition: w3snl4md.F90:165
w3odatmd
Definition: w3odatmd.F90:3
w3snl4md::dens1
real, dimension(:,:), allocatable dens1
Definition: w3snl4md.F90:188
w3gdatmd::itsa
integer, pointer itsa
Definition: w3gdatmd.F90:1368
w3snl4md::kzone
integer kzone
Definition: w3snl4md.F90:138
w3snl4md::jref2_tbl
integer, dimension(:,:,:,:), allocatable jref2_tbl
Definition: w3snl4md.F90:152
w3snl4md::diag
real, dimension(:,:), allocatable diag
Definition: w3snl4md.F90:195
w3snl4md::kref4
integer, dimension(:,:,:), allocatable kref4
Definition: w3snl4md.F90:162
file
file(STRINGS ${CMAKE_BINARY_DIR}/switch switch_strings) separate_arguments(switches UNIX_COMMAND $
Definition: CMakeLists.txt:3
w3snl4md::wk2x
real, dimension(:), allocatable wk2x
Definition: w3snl4md.F90:172
constants::tpi
real, parameter tpi
TPI 2*Pi.
Definition: constants.F90:72
w3snl4md::shlocr
subroutine shlocr(dep, wk1x, wk1y, wk3x, wk3y)
N/A.
Definition: w3snl4md.F90:2306
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3snl4md::diag2
real, dimension(:,:), allocatable diag2
Definition: w3snl4md.F90:196
w3odatmd::ndso
integer, pointer ndso
Definition: w3odatmd.F90:456
w3snl4md::wk4x
real, dimension(:), allocatable wk4x
Definition: w3snl4md.F90:173
w3gdatmd::xfr
real, pointer xfr
Definition: w3gdatmd.F90:1232
w3snl4md::tfac2_tbl
real, dimension(:,:,:,:), allocatable tfac2_tbl
Definition: w3snl4md.F90:155
w3snl4md::tsa
real, dimension(:,:), allocatable tsa
Definition: w3snl4md.F90:195
w3snl4md::angl
real, dimension(:), allocatable angl
Definition: w3snl4md.F90:144
w3snl4md::ainc
real ainc
Definition: w3snl4md.F90:142
w3odatmd::ndst
integer, pointer ndst
Definition: w3odatmd.F90:456
w3snl4md::na2p1
integer na2p1
Definition: w3snl4md.F90:139
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3gdatmd
Definition: w3gdatmd.F90:16
wmmdatmd
Define data structures to set up wave model dynamic data for several models simultaneously.
Definition: wmmdatmd.F90:16
constants::file_endian
character(*), parameter file_endian
FILE_ENDIAN Filled by preprocessor with 'big_endian', 'little_endian', or 'native'.
Definition: constants.F90:86
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3snl4md::nzz
integer nzz
Definition: w3snl4md.F90:138
w3snl4md::tfac4_tbl
real, dimension(:,:,:,:), allocatable tfac4_tbl
Definition: w3snl4md.F90:155
w3tidemd::ir
integer, dimension(180) ir
Definition: w3tidemd.F90:103
w3snl4md::ismo
integer, parameter ismo
Definition: w3snl4md.F90:126
w3snl4md::wtk4
real, dimension(:,:,:), allocatable wtk4
Definition: w3snl4md.F90:164
w3snl4md::kref4_tbl
integer, dimension(:,:,:,:), allocatable kref4_tbl
Definition: w3snl4md.F90:151
w3snl4md::kref2_tbl
integer, dimension(:,:,:,:), allocatable kref2_tbl
Definition: w3snl4md.F90:151
w3snl4md::tfac4
real, dimension(:,:,:), allocatable tfac4
Definition: w3snl4md.F90:166
w3tidemd::fac
double precision, parameter fac
Definition: w3tidemd.F90:87
w3snl4md::jref4
integer, dimension(:,:,:), allocatable jref4
Definition: w3snl4md.F90:163
w3snl4md::dfrq
real dfrq
Definition: w3snl4md.F90:141
w3snl4md::sinan
real, dimension(:), allocatable sinan
Definition: w3snl4md.F90:144
w3snl4md::fbi
real, dimension(:,:), allocatable fbi
Definition: w3snl4md.F90:196
w3snl4md::cosan
real, dimension(:), allocatable cosan
Definition: w3snl4md.F90:144
w3snl4md::wkfnc
real function wkfnc(f, dep)
Calculate the Wavenumber k (rad/m) as function of frequency 'f' (Hz) and depth 'dep' (m).
Definition: w3snl4md.F90:5299
w3snl4md::grad
real, dimension(:,:,:), allocatable grad
Definition: w3snl4md.F90:167
w3snl4md::ndep
integer, parameter ndep
Definition: w3snl4md.F90:131
w3snl4md::nrng
integer nrng
Definition: w3snl4md.F90:138
w3snl4md::wtk4_tbl
real, dimension(:,:,:,:), allocatable wtk4_tbl
Definition: w3snl4md.F90:153