WAVEWATCH III  beta 0.0.1
constants.F90
Go to the documentation of this file.
1 
6 #include "w3macros.h"
7 
14 !
15 #ifndef ENDIANNESS
16 #define ENDIANNESS "native"
17 #endif
18 !
19 !/ ------------------------------------------------------------------- /
20 MODULE constants
21  !/
22  !/ +-----------------------------------+
23  !/ | WAVEWATCH III NOAA/NCEP |
24  !/ | H. L. Tolman |
25  !/ | FORTRAN 90 |
26  !/ | Last update : 05-Jun-2018 |
27  !/ +-----------------------------------+
28  !/
29  !/ 11-Nov-1999 : Fortran 90 version. ( version 2.00 )
30  !/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
31  !/ 25-Jun-2011 : Adding Kelvin functions. ( version 4.05 )
32  !/ 03-Sep-2012 : Adding TSTOUT flag. ( version 4.10 )
33  !/ 28-Feb-2013 : Adding cap at 0.5 in FWTABLE ( version 4.08 )
34  !/ 20-Jan-2017 : Add parameters for ESMF ( version 6.02 )
35  !/ 01-Mar-2018 : Add UNDEF parameter ( version 6.02 )
36  !/ 05-Jun-2018 : Add PDLIB parameters ( version 6.04 )
37  !/
38  !/ Copyright 2009-2012 National Weather Service (NWS),
39  !/ National Oceanic and Atmospheric Administration. All rights
40  !/ reserved. WAVEWATCH III is a trademark of the NWS.
41  !/ No unauthorized use without permission.
42  !/
43  ! 1. Purpose :
44  !
45  ! Define some much-used constants for global use (all defined
46  ! as PARAMETER).
47  !
48  ! 2. Variables and types :
49  !
50  ! Name Type Scope Description
51  ! ----------------------------------------------------------------
52  ! UNDEF Real Global Value for undefined variable in output
53  ! ----------------------------------------------------------------
54  !/ ------------------------------------------------------------------- /
55  !/
56  LOGICAL, PARAMETER :: tstout = .false.
57  ! The flag for generating test output files is included here as
58  ! it is needed in both ww3_shel and ww3_multi at the same time.
59  ! Make sure that this flag is true if you want to write to the
60  ! test output file !
61  REAL, PARAMETER :: grav = 9.806
62  REAL, PARAMETER :: dwat = 1000.
63  REAL, PARAMETER :: dair = 1.225
64  REAL, PARAMETER :: nu_air = 1.4e-5
65  !mdo *** Changing nu_water to be consistent with DWAT=1000 (assumes 10degC)
66  !mdo WAS: 3.E-6
67  REAL, PARAMETER :: nu_water = 1.31e-6
68  REAL, PARAMETER :: sed_sg = 2.65
69  REAL, PARAMETER :: kappa = 0.40
70  !
71  REAL, PARAMETER :: pi = 3.141592653589793
72  REAL, PARAMETER :: tpi = 2.0 * pi
73  REAL, PARAMETER :: hpi = 0.5 * pi
74  REAL, PARAMETER :: tpiinv = 1. / tpi
75  REAL, PARAMETER :: hpiinv = 1. / hpi
76  REAL, PARAMETER :: rade = 180. / pi
77  REAL, PARAMETER :: dera = pi / 180.
78  !
79  REAL, PARAMETER :: radius = 4.e7 * tpiinv
80  !
81  REAL, PARAMETER :: g2pi3i = 1. / ( grav**2 * tpi**3 )
82  REAL, PARAMETER :: g1pi1i = 1. / ( grav * tpi )
83  !
84  REAL :: undef = -999.9
85 
86  CHARACTER(*), PARAMETER :: file_endian = endianness
88  !
89  ! Parameters for friction factor table
90  !
91  INTEGER, PARAMETER :: sizefwtable=300
92  REAL :: fwtable(0:sizefwtable)
93  REAL :: delab
94  REAL, PARAMETER :: abmin = -1.
95  REAL, PRIVATE, PARAMETER :: abmax = 8.
96  INTEGER, PARAMETER :: srce_direct = 0
97  INTEGER, PARAMETER :: srce_imp_post = 1
98  INTEGER, PARAMETER :: srce_imp_pre = 2
99  INTEGER, PARAMETER :: debug_node = 1014
100  INTEGER, PARAMETER :: debug_element = 50
101  LOGICAL :: lpdlib = .false.
102  LOGICAL :: lsetup = .false.
103  !
104  ! Parameters in support of running as ESMF component
105  !
106  ! --- Flag indicating whether or not the model has been invoked as an
107  ! ESMF Component. This flag is set to true in the WMESMFMD ESMF
108  ! module during initialization.
109  LOGICAL :: is_esmf_component = .false.
110  !
111 CONTAINS
112  ! ----------------------------------------------------------------------
119  SUBROUTINE tabu_fw
120  !/
121  !/ +-----------------------------------+
122  !/ | WAVEWATCH III NOAA/NCEP |
123  !/ | F. Ardhuin |
124  !/ | FORTRAN 90 |
125  !/ | Last update : 28-Feb-2013 |
126  !/ +-----------------------------------+
127  !/
128  !/ 19-Oct-2007 : Origination. ( version 3.13 )
129  !/ 28-Feb-2013 : Caps the friction factor to 0.5 ( version 4.08 )
130  !/
131  ! 1. Purpose :
132  ! TO estimate friction coefficients in oscillatory boundary layers
133  ! METHOD.
134  ! tabulation on Kelvin functions
135  !
136  ! 2. Method :
137  !
138  ! 3. Parameters :
139  !
140  ! Parameter list
141  ! ----------------------------------------------------------------
142  ! ----------------------------------------------------------------
143  !
144  ! 4. Subroutines used :
145  !
146  ! Name Type Module Description
147  ! ----------------------------------------------------------------
148  ! STRACE Subr. W3SERVMD Subroutine tracing.
149  ! ----------------------------------------------------------------
150  !
151  ! 5. Called by :
152  !
153  ! Name Type Module Description
154  ! ----------------------------------------------------------------
155  ! WW3_GRID Prog. WW3_GRID Model grid initialization
156  ! ----------------------------------------------------------------
157  !
158  ! 6. Error messages :
159  !
160  ! None.
161  !
162  ! 7. Remarks :
163  !
164  ! 8. Structure :
165  !
166  ! See source code.
167  !
168  ! 9. Switches :
169  !
170  ! !/S Enable subroutine tracing.
171  !
172  ! 10. Source code :
173  !
174  !/ ------------------------------------------------------------------- /
175  IMPLICIT NONE
176  INTEGER, PARAMETER :: NITER=100
177  REAL , PARAMETER :: XM=0.50
178  REAL , PARAMETER :: EPS1=0.00001
179  ! ----------------------------------------------------------------------
180  INTEGER I,ITER
181  REAL KER, KEI
182  REAL ABR,ABRLOG,L10,FACT,FSUBW,FSUBWMEMO,dzeta0,dzeta0memo
183  !
184  delab = (abmax-abmin)/real(sizefwtable)
185  l10=alog(10.)
186  DO i=0,sizefwtable
187  !
188  ! index I in this table corresponds to a normalized roughness z0/ABR = 10^ABMIN+REAL(I)*DELAB
189  !
190  abrlog=abmin+real(i)*delab
191  abr=exp(abrlog*l10)
192  fact=1/abr/(21.2*kappa)
193  fsubw=0.05
194  dzeta0=0.
195  DO iter=1,niter
196  fsubwmemo=fsubw
197  dzeta0memo=dzeta0
198  dzeta0=fact*fsubw**(-.5)
199  CALL kerkei(2.*sqrt(dzeta0),ker,kei)
200  fsubw=.08/(ker**2+kei**2)
201  fsubw=.5*(fsubwmemo+fsubw)
202  dzeta0=.5*(dzeta0memo+dzeta0)
203  END DO
204  !
205  ! Maximum value of 0.5 for fe is based on field
206  ! and lab experiment by Lowe et al. JGR 2005, 2007
207  !
208  fwtable(i) = min(fsubw,0.5)
209  ! WRITE(994,*) 'Friction factor:',I,ABR,FWTABLE(I)
210  END DO
211  RETURN
212  END SUBROUTINE tabu_fw
213 
214  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
243  SUBROUTINE kzeone(X, Y, RE0, IM0, RE1, IM1)
244  ! June 1999 adaptation to CRESTb, all tests on range of (x,y) have been
245  ! bypassed, we implicitly expect X to be positive or |x,y| non zero
246  !
247  ! This subroutine is copyright by ACM
248  ! see http://www.acm.org/pubs/copyright_policy/softwareCRnotice.html
249  ! ACM declines any responsibility of any kind
250  !
251  ! THE VARIABLES X AND Y ARE THE REAL AND IMAGINARY PARTS OF
252  ! THE ARGUMENT OF THE FIRST TWO MODIFIED BESSEL FUNCTIONS
253  ! OF THE SECOND KIND,K0 AND K1. RE0,IM0,RE1 AND IM1 GIVE
254  ! THE REAL AND IMAGINARY PARTS OF EXP(X)*K0 AND EXP(X)*K1,
255  ! RESPECTIVELY. ALTHOUGH THE REAL NOTATION USED IN THIS
256  ! SUBROUTINE MAY SEEM INELEGANT WHEN COMPARED WITH THE
257  ! COMPLEX NOTATION THAT FORTRAN ALLOWS, THIS VERSION RUNS
258  ! ABOUT 30 PERCENT FASTER THAN ONE WRITTEN USING COMPLEX
259  ! VARIABLES.
260  ! ACM Libraries
261  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
262  IMPLICIT NONE
263  DOUBLE PRECISION X, Y, X2, Y2, RE0, IM0, RE1, IM1, &
264  R1, R2, T1, T2, P1, P2, RTERM, ITERM, L
265  DOUBLE PRECISION , PARAMETER, DIMENSION(8) :: EXSQ = &
266  (/ 0.5641003087264d0,0.4120286874989d0,0.1584889157959d0, &
267  0.3078003387255d-1,0.2778068842913d-2,0.1000044412325d-3, &
268  0.1059115547711d-5,0.1522475804254d-8 /)
269  DOUBLE PRECISION , PARAMETER, DIMENSION(8) :: TSQ = &
270  (/ 0.0d0,3.19303633920635d-1,1.29075862295915d0, &
271  2.95837445869665d0,5.40903159724444d0,8.80407957805676d0, &
272  1.34685357432515d1,2.02499163658709d1 /)
273  INTEGER N,M,K
274  ! THE ARRAYS TSQ AND EXSQ CONTAIN THE SQUARE OF THE
275  ! ABSCISSAS AND THE WEIGHT FACTORS USED IN THE GAUSS-
276  ! HERMITE QUADRATURE.
277  r2 = x*x + y*y
278  IF (r2.GE.1.96d2) GO TO 50
279  IF (r2.GE.1.849d1) GO TO 30
280  ! THIS SECTION CALCULATES THE FUNCTIONS USING THE SERIES
281  ! EXPANSIONS
282  x2 = x/2.0d0
283  y2 = y/2.0d0
284  p1 = x2*x2
285  p2 = y2*y2
286  t1 = -(dlog(p1+p2)/2.0d0+0.5772156649015329d0)
287  ! THE CONSTANT IN THE PRECEDING STATEMENT IS EULER*S
288  ! CONSTANT
289  t2 = -datan2(y,x)
290  x2 = p1 - p2
291  y2 = x*y2
292  rterm = 1.0d0
293  iterm = 0.0d0
294  re0 = t1
295  im0 = t2
296  t1 = t1 + 0.5d0
297  re1 = t1
298  im1 = t2
299  p2 = dsqrt(r2)
300  l = 2.106d0*p2 + 4.4d0
301  IF (p2.LT.8.0d-1) l = 2.129d0*p2 + 4.0d0
302  DO n=1,int(l)
303  p1 = n
304  p2 = n*n
305  r1 = rterm
306  rterm = (r1*x2-iterm*y2)/p2
307  iterm = (r1*y2+iterm*x2)/p2
308  t1 = t1 + 0.5d0/p1
309  re0 = re0 + t1*rterm - t2*iterm
310  im0 = im0 + t1*iterm + t2*rterm
311  p1 = p1 + 1.0d0
312  t1 = t1 + 0.5d0/p1
313  re1 = re1 + (t1*rterm-t2*iterm)/p1
314  im1 = im1 + (t1*iterm+t2*rterm)/p1
315  END DO
316  r1 = x/r2 - 0.5d0*(x*re1-y*im1)
317  r2 = -y/r2 - 0.5d0*(x*im1+y*re1)
318  p1 = dexp(x)
319  re0 = p1*re0
320  im0 = p1*im0
321  re1 = p1*r1
322  im1 = p1*r2
323  RETURN
324  ! THIS SECTION CALCULATES THE FUNCTIONS USING THE INTEGRAL
325  ! REPRESENTATION, EQN 3, EVALUATED WITH 15 POINT GAUSS-
326  ! HERMITE QUADRATURE
327 30 x2 = 2.0d0*x
328  y2 = 2.0d0*y
329  r1 = y2*y2
330  p1 = dsqrt(x2*x2+r1)
331  p2 = dsqrt(p1+x2)
332  t1 = exsq(1)/(2.0d0*p1)
333  re0 = t1*p2
334  im0 = t1/p2
335  re1 = 0.0d0
336  im1 = 0.0d0
337  DO n=2,8
338  t2 = x2 + tsq(n)
339  p1 = dsqrt(t2*t2+r1)
340  p2 = dsqrt(p1+t2)
341  t1 = exsq(n)/p1
342  re0 = re0 + t1*p2
343  im0 = im0 + t1/p2
344  t1 = exsq(n)*tsq(n)
345  re1 = re1 + t1*p2
346  im1 = im1 + t1/p2
347  END DO
348  t2 = -y2*im0
349  re1 = re1/r2
350  r2 = y2*im1/r2
351  rterm = 1.41421356237309d0*dcos(y)
352  iterm = -1.41421356237309d0*dsin(y)
353  ! THE CONSTANT IN THE PREVIOUS STATEMENTS IS,OF COURSE,
354  ! SQRT(2.0).
355  im0 = re0*iterm + t2*rterm
356  re0 = re0*rterm - t2*iterm
357  t1 = re1*rterm - r2*iterm
358  t2 = re1*iterm + r2*rterm
359  re1 = t1*x + t2*y
360  im1 = -t1*y + t2*x
361  RETURN
362  ! THIS SECTION CALCULATES THE FUNCTIONS USING THE
363  ! ASYMPTOTIC EXPANSIONS
364 50 rterm = 1.0d0
365  iterm = 0.0d0
366  re0 = 1.0d0
367  im0 = 0.0d0
368  re1 = 1.0d0
369  im1 = 0.0d0
370  p1 = 8.0d0*r2
371  p2 = dsqrt(r2)
372  l = 3.91d0+8.12d1/p2
373  r1 = 1.0d0
374  r2 = 1.0d0
375  m = -8
376  k = 3
377  DO n=1,int(l)
378  m = m + 8
379  k = k - m
380  r1 = float(k-4)*r1
381  r2 = float(k)*r2
382  t1 = float(n)*p1
383  t2 = rterm
384  rterm = (t2*x+iterm*y)/t1
385  iterm = (-t2*y+iterm*x)/t1
386  re0 = re0 + r1*rterm
387  im0 = im0 + r1*iterm
388  re1 = re1 + r2*rterm
389  im1 = im1 + r2*iterm
390  END DO
391  t1 = dsqrt(p2+x)
392  t2 = -y/t1
393  p1 = 8.86226925452758d-1/p2
394  ! THIS CONSTANT IS SQRT(PI)/2.0, WITH PI=3.14159...
395  rterm = p1*dcos(y)
396  iterm = -p1*dsin(y)
397  r1 = re0*rterm - im0*iterm
398  r2 = re0*iterm + im0*rterm
399  re0 = t1*r1 - t2*r2
400  im0 = t1*r2 + t2*r1
401  r1 = re1*rterm - im1*iterm
402  r2 = re1*iterm + im1*rterm
403  re1 = t1*r1 - t2*r2
404  im1 = t1*r2 + t2*r1
405  RETURN
406  END SUBROUTINE kzeone
407 
408  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
423  SUBROUTINE kerkei(X,KER,KEI)
424  !**********************************************************************
425  ! Computes the values of the zeroth order Kelvin function Ker and Kei
426  ! These functions are used to determine the friction factor fw as a
427  ! function of the bottom roughness length assuming a linear profile
428  ! of eddy viscosity (See Grant and Madsen, 1979)
429  !**********************************************************************
430  IMPLICIT NONE
431 
432  DOUBLE PRECISION ZR,ZI,CYR,CYI,CYR1,CYI1
433  REAL X,KER,KEI
434 
435  zr=x*.50d0*sqrt(2.0d0)
436  zi=zr
437  CALL kzeone(zr, zi, cyr, cyi,cyr1,cyi1)
438  ker=cyr/exp(zr)
439  kei=cyi/exp(zr)
440  END SUBROUTINE kerkei
441  !/
442  !/ End of module CONSTANTS ------------------------------------------- /
443  !/
444 END MODULE constants
constants::abmin
real, parameter abmin
ABMIN.
Definition: constants.F90:94
constants::pi
real, parameter pi
PI Value of Pi.
Definition: constants.F90:71
constants::srce_imp_pre
integer, parameter srce_imp_pre
srce_imp_pre
Definition: constants.F90:98
constants::kerkei
subroutine kerkei(X, KER, KEI)
Computes the values of the zeroth order Kelvin function Ker and Kei.
Definition: constants.F90:424
include
cmake src_list cmake include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_switches.cmake) check_switches("$
Definition: CMakeLists.txt:15
w3adatmd::as
real, dimension(:), pointer as
Definition: w3adatmd.F90:584
constants::dair
real, parameter dair
DAIR Density of air (kg/m3).
Definition: constants.F90:63
constants::dera
real, parameter dera
DERA Conversion factor from degrees to radians.
Definition: constants.F90:77
constants::nu_air
real, parameter nu_air
NU_AIR Kinematic viscosity of air (m2/s).
Definition: constants.F90:64
constants::srce_direct
integer, parameter srce_direct
srce_direct
Definition: constants.F90:96
constants::g1pi1i
real, parameter g1pi1i
G1PI1I Inverse of gravity * 2 * Pi.
Definition: constants.F90:82
constants::kzeone
subroutine kzeone(X, Y, RE0, IM0, RE1, IM1)
June 1999 adaptation to CRESTb, all tests on range of (x,y) have been bypassed, we implicitly expect ...
Definition: constants.F90:244
constants::lsetup
logical lsetup
LSETUP Logical LSETUP is not used.
Definition: constants.F90:102
constants::tstout
logical, parameter tstout
TSTOUT Flag for generation of test files.
Definition: constants.F90:56
constants::hpiinv
real, parameter hpiinv
HPIINV Inverse of 1/2*Pi.
Definition: constants.F90:75
constants::g2pi3i
real, parameter g2pi3i
G2PI3I Inverse of gravity^2 * (2*Pi)^3.
Definition: constants.F90:81
constants::rade
real, parameter rade
RADE Conversion factor from radians to degrees.
Definition: constants.F90:76
constants::srce_imp_post
integer, parameter srce_imp_post
srce_imp_post
Definition: constants.F90:97
constants::is_esmf_component
logical is_esmf_component
IS_ESMF_COMPONENT Flag for model invoked via ESMF.
Definition: constants.F90:109
m_xnldata::a
real, dimension(:,:), allocatable a
Action density on wave number grid A(sigma,theta)
Definition: mod_xnl4v5.f90:358
set
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $
Definition: CMakeLists.txt:7
constants::sizefwtable
integer, parameter sizefwtable
SIZEFWTABLE.
Definition: constants.F90:91
constants::kappa
real, parameter kappa
KAPPA von Karman's constant (N.D.).
Definition: constants.F90:69
constants::lpdlib
logical lpdlib
LPDLIB Logical for using the PDLIB library.
Definition: constants.F90:101
constants::tpiinv
real, parameter tpiinv
TPIINV Inverse of 2*Pi.
Definition: constants.F90:74
constants::nu_water
real, parameter nu_water
NU_WATER Kinematic viscosity of water (m2/s).
Definition: constants.F90:67
constants::tabu_fw
subroutine tabu_fw
Estimate friction coefficients in oscillatory boundary layers using tabulation on Kelvin functions.
Definition: constants.F90:120
constants::dwat
real, parameter dwat
DWAT Density of water (kg/m3).
Definition: constants.F90:62
file
file(STRINGS ${CMAKE_BINARY_DIR}/switch switch_strings) separate_arguments(switches UNIX_COMMAND $
Definition: CMakeLists.txt:3
constants::radius
real, parameter radius
RADIUS Radius of the earth (m).
Definition: constants.F90:79
constants::tpi
real, parameter tpi
TPI 2*Pi.
Definition: constants.F90:72
constants::fwtable
real, dimension(0:sizefwtable) fwtable
FWTABLE.
Definition: constants.F90:92
wmesmfmd
National Unified Prediction Capability (NUOPC) based Earth System Modeling Framework (ESMF) interface...
Definition: wmesmfmd.F90:72
constants::debug_node
integer, parameter debug_node
DEBUG_NODE Node number used for debugging.
Definition: constants.F90:99
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
constants::delab
real delab
DELAB.
Definition: constants.F90:93
w3initmd::switches
character(len=512), parameter switches
Definition: w3initmd.F90:130
constants::sed_sg
real, parameter sed_sg
SED_SG Specific gravity of sediments (N.D.).
Definition: constants.F90:68
constants::file_endian
character(*), parameter file_endian
FILE_ENDIAN Filled by preprocessor with 'big_endian', 'little_endian', or 'native'.
Definition: constants.F90:86
constants::hpi
real, parameter hpi
HPI 1/2*Pi.
Definition: constants.F90:73
constants::undef
real undef
UNDEF Value for undefined variable in output.
Definition: constants.F90:84
constants::grav
real, parameter grav
GRAV Acc.
Definition: constants.F90:61
w3initmd
Contains module W3INITMD.
Definition: w3initmd.F90:14
constants::debug_element
integer, parameter debug_element
DEBUG_ELEMENT Element number used for debug.
Definition: constants.F90:100