wavebitscientific / wavy

A spectral ocean wave modeling framework
https://wavebitscientific.github.io/wavy/
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link
fortran modeling ocean wave

wavy

A spectral ocean wave modeling framework.

Getting started

Building wavy

git clone --recursive https://github.com/wavebitscientific/wavy.git
FC=gfortran make
mkdir build
cd build
FC=gfortran cmake ..
make
ctest

Change the FC value if building with a different Fortran compiler.

By default, wavy will be built in single precision (32-bit reals). To build it in double (64-bit reals) or quadruple precision (128-bit reals), use the -DREAL argument when invoking cmake:

FC=gfortran cmake .. -DREAL=64 # for double precision

or:

FC=gfortran cmake .. -DREAL=128 # for quad precision

wavy needs gcc-6.3.0 or later to succesfully build and pass all tests.

Building a simple program with wavy

If you compiled wavy in wavy/build, then the module files and the library are located in wavy/build/include and wavy/build/lib, respectively. For example, if we want to build a simple wavy hello world program from the base directory, we could do it like this:

gfortran hello.f90 -o hello -Ibuild/include -Lbuild/lib -lwavy

Examples

Initialize a omnidirectional spectrum instance in the frequency range from 0.04 to 2 Hz with logarithmic increment of 1.1, in mean water depth of 1000 m:

use mod_spectrum,only:spectrum_type
type(spectrum_type) :: spec

! initialize a spectrum instance
spec = spectrum_type(fmin=0.04,fmax=2.,df=1.1,ndirs=1,depth=1000.)

Same as above, but directional spectrum with 36 directional bins:

spec = spectrum_type(fmin=0.04,fmax=2.,df=1.1,ndirs=36,depth=1000.)

Initialize omnidirectional spectrum with JONSWAP shape at wind speed of 10 m/s, and fetch of 100 km:

use mod_spectrum,only:spectrum_type
use mod_spectral_shapes,only:jonswap

type(spectrum_type) :: spec

! initialize a spectrum instance
spec = spectrum_type(fmin=0.04,fmax=2.,df=1.1,ndirs=1,depth=1000.)

! assign a JONSWAP-shape spectrum to the instance
spec = jonswap(spec % getFrequency(),wspd=10.,fetch=1e5,grav=9.8)

Above examples will work with default precision (REAL32). To write code that is always compatible with precision specified at build time, use mod_precision module:

use mod_precision,only:rk => realkind
use mod_spectrum,only:spectrum_type
use mod_spectral_shapes,only:jonswap

type(spectrum_type) :: spec

! initialize a spectrum instance
spec = spectrum_type(fmin=0.04_rk,fmax=2._rk,df=1.1_rk,ndirs=1,depth=1000._rk)

! assign a JONSWAP-shape spectrum to the instance
spec = jonswap(spec % getFrequency(),wspd=10._rk,fetch=1e5_rk,grav=9.8_rk)

There are many pre-built diagnostics that can be output from a spectrum instance, here is a taste of a few:

write(*,*)'Significant wave height [m]: ',spec % significantWaveHeight()
write(*,*)'       Mean wave period [s]: ',spec % meanPeriod()
write(*,*)'      Mean square slope [-]: ',spec % meanSquareSlope()
write(*,*)'         Stokes drift [m/s]: ',spec % stokesDrift([0._rk])

outputs:

 Significant wave height [m]:    2.13949418    
        Mean wave period [s]:    5.20506239    
       Mean square slope [-]:    2.39831898E-02
          Stokes drift [m/s]:    4.87080999E-02

Design principles

Features

API Documentation

Full API documentation is available here.

Development status

wavy is in early development. Contributors are highly needed, especially for implementing source functions. You can start contributing by opening an issue.