[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet popinet at users.sf.net
Fri May 15 02:56:12 UTC 2009


The following commit has been merged in the upstream branch:
commit 1fc84f298a7c8ce048a16619e3518599f920bc0b
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Mon Feb 23 12:08:07 2009 +1100

    New 'wavewatch' module
    
    darcs-hash:20090223010807-d4795-0941f1d098ae31393c6f059d996b46b8c621aff3.gz

diff --git a/configure.in b/configure.in
index cdcbb13..64917a5 100644
--- a/configure.in
+++ b/configure.in
@@ -311,6 +311,9 @@ AM_CONDITIONAL(BUILD_TIDE, test x$netcdf = xtrue -a x$no_gsl = x)
 AC_PROG_F77
 AM_CONDITIONAL(BUILD_STOKES, test x$F77 != x)
 
+# Build wavewatch module if wavewatch is installed
+AM_CONDITIONAL(BUILD_WAVEWATCH, test -f $HOME/.wwatch3.env)
+
 dnl header file checks
 AC_CHECK_HEADERS(fpu_control.h,
   AC_CHECK_DECL(_FPU_SETCW, 
@@ -455,6 +458,7 @@ tools/Makefile
 modules/Makefile
 modules/RStarTree/Makefile
 modules/fes2004/Makefile
+modules/wavewatch/Makefile
 test/Makefile
 doc/Makefile
 doc/tutorial/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 465662b..2f1ada1 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = RStarTree fes2004
+SUBDIRS = RStarTree fes2004 wavewatch
 
 AM_CPPFLAGS = -DGFS_MODULES_DIR=\"$(libdir)/gerris\"
 
@@ -16,6 +16,9 @@ endif
 if BUILD_STOKES
 STOKES = libstokes2D.la libstokes3D.la
 endif
+if BUILD_WAVEWATCH
+WAVEWATCH = libwavewatch2D.la
+endif
 
 pkglib_LTLIBRARIES = \
 	$(MAP) \
@@ -23,7 +26,8 @@ pkglib_LTLIBRARIES = \
 	libterrain3D.la \
 	libterrain2D3.la \
 	$(TIDE) \
-	$(STOKES)
+	$(STOKES) \
+	$(WAVEWATCH)
 
 bin_PROGRAMS = \
 	xyz2rsurface \
@@ -34,13 +38,15 @@ EXTRA_DIST = \
 	map.mod \
 	tide.mod \
 	terrain.mod \
-	stokes.mod
+	stokes.mod \
+	wavewatch.mod
 
 BUILT_SOURCES = \
 	map.c \
 	tide.c \
 	terrain.c \
-	stokes.c
+	stokes.c \
+	wavewatch.c
 
 AM_LDFLAGS = $(NO_UNDEFINED)\
         -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)\
@@ -81,6 +87,10 @@ libstokes3D_la_CFLAGS = $(AM_CFLAGS)
 libstokes2D_la_SOURCES = stokes.c CW263.f
 libstokes2D_la_CFLAGS = $(AM_CFLAGS) -DFTT_2D=1
 
+libwavewatch2D_la_SOURCES = wavewatch.c wavewatch.h
+libwavewatch2D_la_LIBADD = -Lwavewatch -lwavewatch -L/usr/lib/gcc/i486-linux-gnu/4.2 -lgfortran
+libwavewatch2D_la_CFLAGS = $(AM_CFLAGS) -DFTT_2D=1
+
 xyz2rsurface_SOURCES = xyz2rsurface.c rsurface.c rsurface.h
 xyz2rsurface_LDADD = -LRStarTree -lcSmRST
 xyz2rsurface_CFLAGS = $(AM_CFLAGS)
diff --git a/modules/wavewatch.mod b/modules/wavewatch.mod
new file mode 100644
index 0000000..2c756d9
--- /dev/null
+++ b/modules/wavewatch.mod
@@ -0,0 +1,171 @@
+/* Gerris - The GNU Flow Solver                       (-*-C-*-)
+ * Copyright (C) 2001-2008 National Institute of Water and Atmospheric Research
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.  
+ */
+#include "wave.h"
+#include "wavewatch/wavewatch.h"
+
+#define DEBUG 0
+
+/* fixme: needs to be identical to the same function in wave.c */
+static double frequency (int ik)
+{
+  double gamma = 1.1;
+  double f0 = 0.04;
+  return f0*pow(gamma, ik);
+}
+      
+static double theta (guint ith, guint ntheta)
+{
+  return 2.*M_PI*ith/ntheta;
+}
+
+typedef struct {
+  GfsWave * wave;
+  GfsVariable * ustar, * fpi, * u10, * v10;
+  REAL * A;     /* Actions (NK*NTHETA) */
+  REAL * CG;    /* Group velocities (NK) */
+  REAL * WN;    /* Wavenumbers (NK) */
+  REAL * ALPHA; /* Nondimensional 1-D spectrum (NK) */  
+} SourceParams;
+
+static void energy_to_action (FttCell * cell, SourceParams * p)
+{
+  guint i, j;
+  for (i = 0; i < p->wave->nk; i++)
+    for (j = 0; j < p->wave->ntheta; j++)
+      p->A[j + i*p->wave->ntheta] =
+	GFS_VALUE (cell, p->wave->F[i][j])*p->CG[i]/(2.*M_PI*frequency (i));
+}
+
+static void action_to_energy (FttCell * cell, SourceParams * p)
+{
+  guint i, j;
+  for (i = 0; i < p->wave->nk; i++)
+    for (j = 0; j < p->wave->ntheta; j++)
+      GFS_VALUE (cell, p->wave->F[i][j]) = 
+	p->A[j + i*p->wave->ntheta]*(2.*M_PI*frequency (i))/p->CG[i];
+}
+
+static void source (FttCell * cell, SourceParams * p)
+{
+  energy_to_action (cell, p);
+
+  INTEGER IX, IY, IMOD = 1;
+  REAL DEPTH = 1000.; /* fixme: depth is fixed at 1000 m for now */
+
+  double u10 = p->u10 ? GFS_VALUE (cell, p->u10) : 0.;
+  double v10 = p->v10 ? GFS_VALUE (cell, p->v10) : 0.;
+  REAL U10ABS = sqrt (u10*u10 + v10*v10);
+  REAL U10DIR = atan2 (v10, u10);
+
+  REAL USTAR = GFS_VALUE (cell, p->ustar);
+  REAL FPI = GFS_VALUE (cell, p->fpi);
+  REAL DTG = GFS_SIMULATION (p->wave)->advection_params.dt*3600.;
+
+  REAL USTDIR;
+  REAL EMEAN, FMEAN, WMEAN, AMAX;
+  REAL CD, Z0;
+  REAL DTDYN, FCUT;
+  
+  __w3srcemd__w3srce (&IX, &IY, &IMOD, p->A, p->ALPHA, p->WN, p->CG, &DEPTH, 
+		      &U10ABS, &U10DIR, &USTAR, &USTDIR,
+		      &EMEAN, &FMEAN, &WMEAN, &AMAX, 
+		      &FPI, &CD, &Z0, 
+		      &DTDYN, &FCUT, &DTG);
+
+#if DEBUG
+  guint i, j;
+  for (i = 0; i < p->wave->nk; i++) {
+    for (j = 0; j < p->wave->ntheta; j++)      
+      fprintf (stderr, "%g %g %g\n", frequency (i), theta (j, p->wave->ntheta), 
+	       p->A[j + i*p->wave->ntheta]);
+    fprintf (stderr, "\n");
+  }
+#endif
+
+  action_to_energy (cell, p);
+  GFS_VALUE (cell, p->ustar) = USTAR;
+  GFS_VALUE (cell, p->fpi) = FPI;
+}
+
+static void wavewatch_source (GfsWave * wave)
+{
+  GfsDomain * domain = GFS_DOMAIN (wave);
+
+  if (wave->nk != 25 || wave->ntheta != 24)
+    g_assert_not_implemented ();
+
+  static gboolean initialized = FALSE;
+  if (!initialized) {
+    __gfsw3init__gfsw3_init ();
+    initialized = TRUE;
+  }
+
+  SourceParams p;
+  p.wave = wave;
+  p.A = g_malloc (wave->nk*wave->ntheta*sizeof (REAL));
+  p.CG = g_malloc (wave->nk*sizeof (REAL));
+  p.WN = g_malloc (wave->nk*sizeof (REAL));
+  p.ALPHA = g_malloc (wave->nk*sizeof (REAL));
+  p.ustar = gfs_variable_from_name (domain->variables, "Ustar");
+  p.fpi = gfs_variable_from_name (domain->variables, "Fpi");
+  p.u10 = gfs_variable_from_name (domain->variables, "U10");
+  p.v10 = gfs_variable_from_name (domain->variables, "V10");
+
+  guint i;
+  for (i = 0; i < wave->nk; i++) {
+    REAL omega = 2.*M_PI*frequency (i);
+    p.WN[i] = omega*omega/9.81;
+    p.CG[i] = 9.81/omega/2.;
+  }
+
+  gfs_domain_traverse_leaves (domain, (FttCellTraverseFunc) source, &p);
+
+  g_free (p.A);
+  g_free (p.CG);
+  g_free (p.WN);
+  g_free (p.ALPHA);
+}
+
+/* Initialize module */
+
+/* only define gfs_module_name for "official" modules (i.e. those installed in
+   GFS_MODULES_DIR) */
+const gchar gfs_module_name[] = "wavewatch";
+const gchar * g_module_check_init (void);
+void          gfs_module_read     (GtsFile * fp, GfsSimulation * sim);
+
+const gchar * g_module_check_init (void)
+{
+  return NULL;
+}
+
+void gfs_module_read (GtsFile * fp, GfsSimulation * sim)
+{
+  g_return_if_fail (fp != NULL);
+  g_return_if_fail (sim != NULL);
+
+  if (!GFS_IS_WAVE (sim)) {
+    gts_file_error (fp, "wavewatch module can only be used with GfsWave");
+    return;
+  }
+
+  GFS_WAVE (sim)->source = wavewatch_source;
+  gfs_domain_get_or_add_variable (GFS_DOMAIN (sim), "Ustar", "Friction velocity");
+  gfs_domain_get_or_add_variable (GFS_DOMAIN (sim), "Fpi",   "Peak-input frequency");
+}
diff --git a/modules/wavewatch/Makefile.am b/modules/wavewatch/Makefile.am
new file mode 100644
index 0000000..da03ed0
--- /dev/null
+++ b/modules/wavewatch/Makefile.am
@@ -0,0 +1,17 @@
+## Process this file with automake to produce Makefile.in
+
+if BUILD_WAVEWATCH
+WAVEWATCH = libwavewatch.a
+endif
+
+noinst_LIBRARIES = $(WAVEWATCH)
+
+EXTRA_DIST = gfsad3 gfsw3initmd.ftn wavewatch.h ww3_grid.inp
+
+libwavewatch.a: gfsw3initmd.o
+	rm -f libwavewatch.a
+	ar cr libwavewatch.a `grep WWATCH3_DIR $(HOME)/.wwatch3.env | awk '{print $$2 "/obj/w3*.o"}'` gfsw3initmd.o
+	ranlib libwavewatch.a
+
+gfsw3initmd.o: gfsw3initmd.ftn
+	sh gfsad3 gfsw3initmd.ftn
diff --git a/modules/wavewatch/gfsad3 b/modules/wavewatch/gfsad3
new file mode 100755
index 0000000..c866dfa
--- /dev/null
+++ b/modules/wavewatch/gfsad3
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Uses WAVEWATCH III ad3 script to compile an ".ftn" fortran file
+#
+
+if [ "$#" -gt '3' ] || [ "$#" -lt 1 ]; then
+    echo "usage: gfsad3 file.ftn" 1>&2 ; exit 1
+fi
+
+if test -f $HOME/.wwatch3.env; then
+    main_dir=`awk '{if ($1 == "WWATCH3_DIR") print $2;}' < $HOME/.wwatch3.env`
+    tmp_dir=`awk '{if ($1 == "WWATCH3_TMP") print $2;}' < $HOME/.wwatch3.env`
+else
+    echo "gfsad3: Error: Wavewatch environment file '$HOME/.wwatch3.env' not found"
+    exit 1
+fi
+
+if test -f $main_dir/ftn/$1; then
+    echo "gfsad3: Error: file '$main_dir/ftn/$1' already exists"
+    exit 1
+fi
+
+if cp $1 $main_dir/ftn; then :
+else
+    echo "gfsad3: Error: could not copy $1 in '$main_dir/ftn/'"
+    exit 1
+fi
+
+PATH=$PATH:$main_dir/bin
+basename=`basename $1 .ftn`
+ad3 $basename
+rm -f $main_dir/ftn/$1
+
+if test -f $tmp_dir/w3adc.err; then
+    cat $tmp_dir/w3adc.err > /dev/stderr
+    exit 1
+fi
+
+if test -f $tmp_dir/$basename.l; then
+    awk -v basename=$basename 'BEGIN{FS=":| "; i = 0;}{
+      if ($1 == basename ".f90") i = 1;
+      if (i == 1)
+        print $0;
+    }' < $tmp_dir/$basename.l > /dev/stderr
+    exit 1
+fi
+
+mv -f $main_dir/obj/$basename.o .
diff --git a/modules/wavewatch/gfsw3initmd.ftn b/modules/wavewatch/gfsw3initmd.ftn
new file mode 100644
index 0000000..df0b299
--- /dev/null
+++ b/modules/wavewatch/gfsw3initmd.ftn
@@ -0,0 +1,301 @@
+!/ ------------------------------------------------------------------- /
+!
+! Initialisation of Wavewatch when used with Gerris
+! Adapted from ww3_shel.ftn, S. Popinet, 2009
+!
+!/ ------------------------------------------------------------------- /
+      MODULE GFSW3INIT
+!/
+!docb_ww3_shel.doc
+!/                  +-----------------------------------+
+!/                  | WAVEWATCH-III           NOAA/NCEP |
+!/                  |           H. L. Tolman            |
+!/                  |                        FORTRAN 90 |
+!/                  | Last update :         22-Jun-2007 |
+!/                  +-----------------------------------+
+!/
+!/    19-Jan-1999 : Final FORTRAN 77                    ( version 1.18 )
+!/    19-Jan-2000 : Upgrade to FORTRAN 90               ( version 2.00 )
+!/    08-Mar-2000 : Fix time managament bug.            ( version 2.04 )
+!/    09-Jan-2001 : Fix FOUT allocation bug.            ( version 2.05 )
+!/    24-Jan-2001 : Flat grid version.                  ( version 2.06 )
+!/    25-Jan-2002 : Data assimilation set up.           ( version 2.17 )
+!/    08-May-2002 : Clean up for timers.                ( version 2.21 )
+!/    26-Aug-2002 : Generalizing timer.                 ( version 2.22 )
+!/    26-Dec-2002 : Continuously moving grid.           ( version 3.02 )
+!/    01-Aug-2003 : Continuously moving grid, input.    ( version 3.03 )
+!/    07-Oct-2003 : Fixed NHMAX test.                   ( version 3.05 )
+!/    05-Jan-2005 : Multiple grid version.              ( version 3.06 )
+!/    04-May-2005 : Change to MPI_COMM[_WAVE.           ( version 3.07 )
+!/    26-Jun-2006 : Add wiring for output type 6.       ( version 3.07 )
+!/    28-Jun-2006 : Adding file name preamble.          ( version 3.09 )
+!/    28-Oct-2006 : Adding partitioning options.        ( version 3.10 )
+!/    21-Jun-2007 : Dedicated output processes.         ( version 3.11 )
+!/
+!  1. Purpose :
+!
+!     A generic shell for WAVEWATCH-III, using preformatted
+!     input fields.
+!
+!  2. Method :
+!
+!     Driver for the actual wave model (W3WAVE).
+!
+!     Files : ww3_shel.inp  Input commands for shell.
+!             level.ww3     Water level fields (optional).
+!             current.ww3   Current fields (optional).
+!             wind.ww3      Water level fields (optional).
+!             ice.ww3       Water level fields (optional).
+!             data0.ww3     Files with asiimlation data (optional).
+!             data1.ww3
+!             data2.ww3
+!
+!     The file names of the input files are set in W3FLDO
+!
+!  3. Parameters :
+!
+!     Local parameters.
+!     ----------------------------------------------------------------
+!       NDSO    Int.  General output unit number (shell only).
+!       NDSE    Int.  Error output unit number (shell only).
+!       NDST    Int.  Test output unit number (shell only).
+!     ----------------------------------------------------------------
+!
+!       NDS, NTRACE, ..., see W3WAVE
+!
+!  4. Subroutines used :
+!
+!      Name      Type  Module   Description
+!     ----------------------------------------------------------------
+!      W3NMOD    Subr. W3GDATMD Set nummber of data structures
+!      W3SETG    Subr.   Id.    Point to data structure.
+!      W3NDAT    Subr. W3WDATMD Set nummber of data structures
+!      W3SETW    Subr.   Id.    Point to data structure.
+!      W3NMOD    Subr. W3ADATMD Set nummber of data structures
+!      W3NAUX    Subr.   Id.    Point to data structure.
+!      W3NOUT    Subr. W3ODATMD Set nummber of data structures
+!      W3SETO    Subr.   Id.    Point to data structure.
+!      W3NINP    Subr. W3IDATMD Set nummber of data structures
+!      W3SETI    Subr.   Id.    Point to data structure.
+!
+!      NEXTLN    Subr. W3SERVMD Skip to next input line.
+!      STME21    Subr. W3TIMEMD Print date and time readable.
+!      DSEC21    Func.   Id.    Difference between times.
+!      TICK21    Subr.   Id.    Increment time.
+!
+!      W3FLDO    Subr. W3FLDSMD Opens and checks input files.
+!      W3FLDG    Subr.   Id.    Reads from input files.
+!      W3FLDD    Subr.   Id.    Reads from data files.
+!      W3FLDH    Subr.   Id.    Udates homogeneous fields.
+!
+!      W3INIT    Subr. W3INITMD Wave model initialization.
+!      W3WAVE    Subr. W3WAVEMD Wave model.
+!      W3WDAS    Subr. W3WDASMD Data assimilation interface.
+!
+!      MPI_INIT, MPI_COMM_SIZE, MPI_COMM_RANK, MPI_BARRIER,
+!         MPI_FINALIZE
+!                Subr.          Standard MPI routines.
+!     ----------------------------------------------------------------
+!
+!  5. Called by :
+!
+!     None, stand-alone program.
+!
+!  6. Error messages :
+!
+!     - Checks on I-O.
+!     - Check on time interval.
+!
+!  7. Remarks :
+!
+!     - A rigourous input check is made in W3INIT.
+!     - See W3WDAS for documentation on the set-up of the data
+!       assimilation.
+!
+!  8. Structure :
+!
+!     ----------------------------------------------------------------
+!        0.   Set up data structures.                ( W3NMOD, etc. )
+!        1.   I-O setup.
+!          a  For shell.
+!          b  For WAVEWATCH-III.
+!          c  Local parameters.
+!        2.   Define input fields
+!        3.   Set time frame.
+!        4.   Define output
+!          a  Loop over types, do
+!        +--------------------------------------------------------+
+!        | b    Process standard line                             |
+!        | c    If type 1: fields of mean wave parameters         |
+!        | d    If type 2: point output                           |
+!        | e    If type 3: track output                           |
+!        | f    If type 4: restart files                          |
+!        | g    If type 5: boundary output                        |
+!        | h    If type 6: separated wave fields                  |
+!        +--------------------------------------------------------+
+!        5.   Initialzations
+!          a  Wave model.                              ( W3INIT )
+!          b  Read homogeneous field data.
+!          c  Prepare input files.                     ( W3FLDO )
+!          d  Set field times.
+!        6.   If no input fields required, run model in a single
+!             sweep and exit.                          ( W3WAVE )
+!        7.   Run model with input
+!             Do until end time is reached
+!        +--------------------------------------------------------+
+!        | a  Determine next time interval and input fields.      |
+!        |   1  Preparation                                       |
+!        |      Loop over input fields                            |
+!        | +------------------------------------------------------|
+!        | | 2  Check if update is needed                         |
+!        | | 3  Update time and fields                 ( W3FLDG ) |
+!        | |                                           ( W3FLDH ) |
+!        | | 4  Update next ending time                           |
+!        | +------------------------------------------------------|
+!        | b  Run wave model.                          ( W3WAVE ) |
+!        | c  If requested, data assimilation.         ( W3WDAS ) |
+!        | d  Final output if needed.                  ( W3WAVE ) |
+!        | e  Check time                                          |
+!        +--------------------------------------------------------+
+!     ----------------------------------------------------------------
+!
+!  9. Switches :
+!
+!       !/SHRD  Switch for shared / distributed memory architecture.
+!       !/DIST  Id.
+!       !/MPI   Id.
+!
+!       !/LLG   Spherical grid.
+!       !/XYG   Cartesian grid.
+!       !/MGW   Moving grid wind correction.
+!       !/MGP   Moving grid propagation correction.
+!
+!       !/T     Enable test output.
+!       !/O7    Echo input homogeneous fields.
+!
+!       !/NCO   NCEP NCO modifications for operational implementation.
+!
+!       !/F90   Timer function included for F90.
+!
+! 10. Source code :
+!
+!/ ------------------------------------------------------------------- /
+      USE W3GDATMD
+      USE W3WDATMD, ONLY: TIME, W3NDAT, W3DIMW, W3SETW
+      USE W3ADATMD, ONLY: W3NAUX, W3DIMA, W3SETA
+      USE W3IDATMD
+      USE W3ODATMD, ONLY: W3NOUT, W3SETO
+      USE W3ODATMD, ONLY: NAPROC, IAPROC, NAPOUT, NAPERR,             &
+                          NOGRD, IDOUT, FNMPRE, IOSTYP
+!/
+      USE W3INITMD
+!/
+      IMPLICIT NONE
+!
+!/
+!/ ------------------------------------------------------------------- /
+!/ Local parameters
+!/
+      INTEGER             :: NDSO, NDSE, NDST,     &
+                             NDS(13), NTRACE(2),      &
+                             ODAT(30),       &
+                             MPI_COMM = -99, &
+                             IPRT(6)
+      REAL, ALLOCATABLE   :: X(:), Y(:)
+      LOGICAL             :: FLGRD(NOGRD), PRTFRM
+      CHARACTER(LEN=10),                                              &
+              ALLOCATABLE :: PNAMES(:)
+!/
+!/ ------------------------------------------------------------------- /
+!/
+      PUBLIC
+CONTAINS
+      SUBROUTINE GFSW3_INIT ( )
+      IMPLICIT NONE
+!
+!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+! 0.  Set up data structures
+!
+      CALL W3NMOD ( 1, 6, 6 )
+      CALL W3NDAT (    6, 6 )
+      CALL W3NAUX (    6, 6 )
+      CALL W3NOUT (    6, 6 )
+      CALL W3NINP (    6, 6 )
+!
+      CALL W3SETG ( 1, 6, 6 )
+      CALL W3SETW ( 1, 6, 6 )
+      CALL W3SETA ( 1, 6, 6 )
+      CALL W3SETO ( 1, 6, 6 )
+      CALL W3SETI ( 1, 6, 6 )
+!
+!/SHRD      NAPROC = 1
+!/SHRD      IAPROC = 1
+!
+!/MPI      IAPROC = IAPROC + 1
+!
+!/NCO/!     IF ( IAPROC .EQ. 1 ) CALL W3TAGB                         &
+!/NCO/!                         ('WAVEFCST',1998,0007,0050,'NP21   ')
+!
+!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+! 1.  IO set-up
+! 1.a For shell
+!
+      NDSO   =  6
+      NDSE   =  6
+      NDST   =  6
+!
+!/NCO/!
+!/NCO/! Redo according to NCO standard and docblock
+!/NCO/!
+!/NCO      NDSO   =  6
+!/NCO      NDSE   = NDSO
+!/NCO      NDST   = NDSO
+!
+      NAPOUT = 1
+      NAPERR = 1
+!
+! 1.b For WAVEWATCH-III (See W3INIT)
+!
+      NDS( 1) = 20
+      NDS( 2) =  6
+!     NDS( 3) =  6
+      NDS( 3) = 21
+      NDS( 4) =  6
+      NDS( 5) = 30
+      NDS( 6) = 30
+      NDS( 7) = 31
+      NDS( 8) = 32
+      NDS( 9) = 33
+      NDS(10) = 35
+      NDS(11) = 22
+      NDS(12) = 23
+      NDS(13) = 34
+!
+      NTRACE(1) =  NDS(3)
+      NTRACE(2) =  10
+!
+!/NCO/!
+!/NCO/! Redo according to NCO standard and docblock
+!/NCO/!
+!/NCO      NDS( 1) = 51
+!/NCO      NDS( 2) = NDSO
+!/NCO      NDS( 3) = NDSO
+!/NCO      NDS( 4) = NDSO
+!/NCO      NDS( 5) = 20
+!/NCO      NDS( 6) = 21
+!/NCO      NDS( 7) = 52
+!/NCO      NDS( 8) = 53
+!/NCO      NDS( 9) = 22
+!/NCO      NDS(10) = 71
+!/NCO      NDS(11) = 23
+!/NCO      NDS(12) = 54
+!/NCO      NDS(13) = 55
+!/NCO      NTRACE(1) = NDSO
+!
+! 5.a Wave model
+!
+      CALL W3INIT ( 1, 'ww3', NDS, NTRACE, ODAT, FLGRD, 0, X, Y,   &
+                    PNAMES, IPRT, PRTFRM, -99 )
+      RETURN
+      END SUBROUTINE GFSW3_INIT
+    END MODULE GFSW3INIT
diff --git a/modules/wavewatch/wavewatch.h b/modules/wavewatch/wavewatch.h
new file mode 100644
index 0000000..b4acbec
--- /dev/null
+++ b/modules/wavewatch/wavewatch.h
@@ -0,0 +1,55 @@
+/*
+ * These types must match the lengths of wavewatch's REAL and INTEGER types
+ */
+typedef double REAL;
+typedef long long INTEGER;
+
+/**
+ * Initialisation of wavewatch
+ */
+extern void __gfsw3init__gfsw3_init (void);
+
+/**
+ * imported from w3srcemd.f90:W3SRCE
+ * @IX, at IY: Discrete grid point counters (hopefully unused)
+ * @IMOD: Model number (always 1)
+ * @SPEC: Spectrum (action) in 1-D form (NK*NTH elements): INPUT/OUTPUT
+ * @ALPHA: Nondimensional 1-D spectrum (NK)                OUTPUT
+ * @WN1: Discrete wavenumbers (NK)                         INPUT
+ * @CG1: Discrete group velocities (NK)                    INPUT
+ * @DEPTH: Depth                                           INPUT
+ * @U10ABS: Wind speed at reference height                 INPUT
+ * @U10DIR: Wind direction at reference height             INPUT
+ * @USTAR: Friction velocity                               INPUT/OUTPUT
+ * @USTDIR: Friction velocity direction                    OUTPUT (maybe model dependent?)
+ * @EMEAN: Mean energy                                     OUTPUT (maybe model dependent?)
+ * @FMEAN: Mean frequency                                  OUTPUT (maybe model dependent?)
+ * @WMEAN: Mean wavenumber                                 OUTPUT (maybe model dependent?)
+ * @AMAX: Maximum energy                                   OUTPUT
+ * @FPI: Peak-input frequency                              INPUT/OUTPUT
+ * @CD: Drag coefficient                                   OUTPUT (maybe model dependent?)
+ * @Z0: Roughness length                                   OUTPUT (maybe model dependent?)
+ * @DTDYN: Average dynamic time step                       OUTPUT
+ * @FCUT: Cut-off frequency for tail                       OUTPUT
+ * @DTG: Global time step                                  INPUT
+ */
+extern void __w3srcemd__w3srce (INTEGER * IX, INTEGER * IY, INTEGER * IMOD,
+				REAL * SPEC,
+				REAL * ALPHA,
+				REAL * WN1, 
+				REAL * CG1, 
+				REAL * DEPTH, 
+				REAL * U10ABS, 
+				REAL * U10DIR, 
+				REAL * USTAR,
+				REAL * USTDIR,
+				REAL * EMEAN,
+				REAL * FMEAN,
+				REAL * WMEAN,
+				REAL * AMAX,
+				REAL * FPI,
+				REAL * CD,
+				REAL * Z0,
+				REAL * DTDYN,
+				REAL * FCUT,
+				REAL * DTG);
diff --git a/modules/wavewatch/ww3_grid.inp b/modules/wavewatch/ww3_grid.inp
new file mode 100644
index 0000000..7c6babb
--- /dev/null
+++ b/modules/wavewatch/ww3_grid.inp
@@ -0,0 +1,343 @@
+$ -------------------------------------------------------------------- $
+$
+$ This file is a template which can be used to generate the mod_def.ww3
+$ file required when using the 'wavewatch' module of Gerris
+$
+$ Gerris specific comments are preceded with '*Gerris*:'
+$ 
+$ -------------------------------------------------------------------- $
+$ WAVEWATCH III Grid preprocessor input file                           $
+$ -------------------------------------------------------------------- $
+$
+$ Grid name (C*30, in quotes)
+$
+  'Gerris wavewatch module'
+$
+$ Frequency increment factor and first frequency (Hz) ---------------- $
+$ number of frequencies (wavenumbers) and directions, relative offset
+$ of first direction in terms of the directional increment [-0.5,0.5].
+$ In versions 1.18 and 2.22 of the model this value was by definiton 0,
+$ it is added to mitigate the GSE for a first order scheme. Note that
+$ this factor is IGNORED in the print plots in ww3_outp.
+$
+$ *Gerris*: Do not modify!!
+$
+   1.1  0.04  25  24  0.
+$
+$ Set model flags ---------------------------------------------------- $
+$  - FLDRY         Dry run (input/output only, no calculation).
+$  - FLCX, FLCY    Activate X and Y component of propagation.
+$  - FLCTH, FLCK   Activate direction and wavenumber shifts.
+$  - FLSOU         Activate source terms.
+$
+$ *Gerris*: FLDRY, FLCX, FLCY flags are ignored
+$
+   F F F F F T
+$
+$ Set time steps ----------------------------------------------------- $
+$ - Time step information (this information is always read)
+$     maximum global time step, maximum CFL time step for x-y and 
+$     k-theta, minimum source term time step (all in seconds).
+$
+    900. 950. 900. 300.                              
+$
+$ Start of namelist input section ------------------------------------ $
+$   Starting with WAVEWATCH III version 2.00, the tunable parameters
+$   for source terms, propagation schemes, and numerics are read using
+$   namelists. Any namelist found in the folowing sections up to the
+$   end-of-section identifier string (see below) is temporarily written
+$   to ww3_grid.scratch, and read from there if necessary. Namelists
+$   not needed for the given switch settings will be skipped
+$   automatically, and the order of the namelists is immaterial.
+$   As an example, namelist input to change SWELLF and ZWND in the
+$   Tolman and Chalikov input would be
+$
+$   &SIN2 SWELLF = 0.1, ZWND = 15. /
+$
+$ Define constants in source terms ----------------------------------- $
+$
+$ Stresses - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+$   TC 1996 with cap    : Namelist FLX3
+$                           CDMAX  : Maximum allowed CD (cap)
+$                           CTYPE  : Cap type :
+$                                     0: Discontinuous (default).
+$                                     1: Hyperbolic tangent.
+$
+$ Linear input - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+$   Cavaleri and M-R    : Namelist SLN1
+$                           CLIN   : Proportionality constant.
+$                           RFPM   : Factor for fPM in filter.
+$                           RFHF   : Factor for fh in filter.
+$
+$ Exponential input  - - - - - - - - - - - - - - - - - - - - - - - - -
+$   WAM-3               : Namelist SIN1
+$                           CINP   : Proportionality constant.
+$
+$   Tolman and Chalikov : Namelist SIN2
+$                           ZWND   : Height of wind (m).
+$                           SWELLF : swell factor in (n.nn).
+$                           STABSH, STABOF, CNEG, CPOS, FNEG :
+$                                    c0, ST0, c1, c2 and f1 in . (n.nn)
+$                                    through (2.65) for definition of
+$                                    effective wind speed (!/STAB2).
+$
+$ Nonlinear interactions - - - - - - - - - - - - - - - - - - - - - - -
+$   Discrete I.A.       : Namelist SNL1
+$                           LAMBDA : Lambda in source term.
+$                           NLPROP : C in sourc term. NOTE : default
+$                                    value depends on other source
+$                                    terms selected.
+$                           KDCONV : Factor before kd in Eq. (n.nn).
+$                           KDMIN, SNLCS1, SNLCS2, SNLCS3 :
+$                                    Minimum kd, and constants c1-3
+$                                    in depth scaling function.
+$   Exact interactions  : Namelist SNL2
+$                           IQTYPE : Type of depth treatment
+$                                     1 : Deep water
+$                                     2 : Deep water / WAM scaling
+$                                     3 : Shallow water
+$                           TAILNL : Parametric tail power.
+$                           NDEPTH : Number of depths in for which 
+$                                    integration space is established.
+$                                    Used for IQTYPE = 3 only
+$                         Namelist ANL2
+$                           DEPTHS : Array with depths for NDEPTH = 3
+$
+$ Dissipation  - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+$   WAM-3               : Namelist SDS1
+$                           CDIS, APM : As in source term.
+$
+$   Tolman and Chalikov : Namelist SDS2
+$                           SDSA0, SDSA1, SDSA2, SDSB0, SDSB1, PHIMIN :
+$                                    Constants a0, a1, a2, b0, b1 and
+$                                    PHImin.
+$
+$ Bottom friction  - - - - - - - - - - - - - - - - - - - - - - - - - -
+$   JONSWAP             : Namelist SBT1
+$                           GAMMA   : As it says.
+$
+$
+$ Surf breaking  - - - - - - - - - - - - - - - - - - - - - - - - - - -
+$   Battjes and Janssen : Namelist SDB1
+$                           BJALFA  : 
+$                           BJGAM   : 
+$                           BJFLAG  : 
+$
+$ Propagation schemes ------------------------------------------------ $
+$   First order         : Namelist PRO1
+$                           CFLTM  : Maximum CFL number for refraction.
+$
+$   UQ with diffusion   : Namelist PRO2
+$                           CFLTM  : Maximum CFL number for refraction.
+$                           DTIME  : Swell age (s) in garden sprinkler
+$                                    correction. If 0., all diffusion
+$                                    switched off. If small non-zero
+$                                    (DEFAULT !!!) only wave growth
+$                                    diffusion.
+$                           LATMIN : Maximum latitude used in calc. of
+$                                    strength of diffusion for prop.
+$
+$   UQ with averaging   : Namelist PRO3
+$                           CFLTM  : Maximum CFL number for refraction.
+$                           WDTHCG : Tuning factor propag. direction.
+$                           WDTHTH : Tuning factor normal direction.
+$
+$ Miscellaneous ------------------------------------------------------ $
+$   Misc. parameters    : Namelist MISC
+$                           CICE0  : Ice concentration cut-off.
+$                           CICEN  : Ice concentration cut-off.
+$                           PMOVE  : Power p in GSE aleviation for
+$                                    moving grids in Eq. (D.4).
+$                           XSEED  : Xseed in seeding alg. (!/SEED).
+$                           FLAGTR : Indicating presence and type of
+$                                    subgrid information :
+$                                     0 : No subgrid information.
+$                                     1 : Transparancies at cell boun-
+$                                         daries between grid points.
+$                                     2 : Transp. at cell centers.
+$                                     3 : Like 1 with cont. ice.
+$                                     4 : Like 2 with cont. ice.
+$                           XP, XR, XFILT
+$                                    Xp, Xr and Xf for the dynamic
+$                                    integration scheme.
+$                           IHMAX  : Number of discrete levels in part.
+$                           HSPMIN : Minimum Hs in partitioning.
+$                           WSM    : Wind speed multiplier in part.
+$                           WSC    : Cut of wind sea fraction for 
+$                                    identifying wind sea in part.
+$                           FLC    : Flag for combining wind seas in
+$                                    partitioning.
+$                           FMICHE : Constant in Miche limiter.
+$
+$ In the 'Out of the box' test setup we run with sub-grid obstacles 
+$ and with continuous ice treatment.
+$
+$ &MISC FLAGTR = 0 /
+$ &FLX3 CDMAX = 3.5E-3 , CTYPE = 0 /
+$ &SDB1 BJGAM = 1.26, BJFLAG = .FALSE. /
+$
+$ Mandatory string to identify end of namelist input section.
+$
+END OF NAMELISTS
+$
+$ -------------------------------------------------------------------- $
+$   *Gerris* *Gerris* *Gerris* *Gerris* *Gerris* *Gerris* *Gerris*
+$                NOTHING TO MODIFY BELOW THIS LINE
+$   *Gerris* *Gerris* *Gerris* *Gerris* *Gerris* *Gerris* *Gerris*
+$ -------------------------------------------------------------------- $
+$
+$
+$ Define grid -------------------------------------------------------- $
+$ Four records containing :
+$  1 NX, NY. As the outer grid lines are always defined as land
+$    points, the minimum size is 3x3.
+$  2 Grid increments SX, SY (degr.or m) and scaling (division) factor.
+$    If NX*SX = 360., latitudinal closure is applied.
+$  3 Coordinates of (1,1) (degr.) and scaling (division) factor.
+$  4 Limiting bottom depth (m) to discriminate between land and sea
+$    points, minimum water depth (m) as allowed in model, unit number
+$    of file with bottom depths, scale factor for bottom depths (mult.),
+$    IDLA, IDFM, format for formatted read, FROM and filename.
+$      IDLA : Layout indicator :
+$                  1   : Read line-by-line bottom to top.
+$                  2   : Like 1, single read statement.
+$                  3   : Read line-by-line top to bottom.
+$                  4   : Like 3, single read statement.
+$      IDFM : format indicator :
+$                  1   : Free format.
+$                  2   : Fixed format with above format descriptor.
+$                  3   : Unformatted.
+$      FROM : file type parameter
+$               'UNIT' : open file by unit number only.
+$               'NAME' : open file by name and assign to unit.
+$
+$ Example for longitude-latitude grid (switch !/LLG), for Cartesian
+$ grid the unit is meters (NOT km).
+$
+$ *Gerris*: This is a dummy grid. NX and NY should always be set to 3.
+$           All the other parameters below have to do with spatial 
+$           initialisation and are ignored by Gerris (the corresponding
+$           spatial initialisations are controlled through the Gerris
+$           parameter file).
+$
+      3      3
+      1000.     1000.     1.
+     -1000.    -1000.     1.
+     -0.1 2.50  10  -1000. 3 1 '(....)' 'NAME' 'bottom.inp'
+$
+$ If the above unit number equals 10, the bottom data is read from 
+$ this file and follows below (no intermediate comment lines allowed).
+$
+  1 1 1
+  1 1 1
+  1 1 1
+$
+$ If sub-grid information is available as indicated by FLAGTR above,
+$ additional input to define this is needed below. In such cases a
+$ field of fractional obstructions at or between grid points needs to 
+$ be supplied.  First the location and format of the data is defined
+$ by (as above) :
+$  - Unit number of file (can be 10, and/or identical to bottem depth
+$    unit), scale factor for fractional obstruction, IDLA, IDFM,
+$    format for formatted read, FROM and filename
+$
+$   10 0.2  3 1 '(....)' 'NAME' 'obstr.inp'
+$
+$ *** NOTE if this unit number is the same as the previous bottom
+$     depth unit number, it is assumed that this is the same file
+$     without further checks.                                      ***
+$
+$ If the above unit number equals 10, the bottom data is read from 
+$ this file and follows below (no intermediate comment lines allowed,
+$ except between the two fields).
+$
+$  0 0 0
+$  0 0 0
+$  0 0 0
+$
+$  0 0 0
+$  0 0 0
+$  0 0 0
+$
+$
+$ *** NOTE size of fields is always NX * NY                        ***
+$
+$ Input boundary points and excluded points -------------------------- $
+$    The first line identifies where to get the map data, by unit number
+$    IDLA and IDFM, format for formatted read, FROM and filename
+$    if FROM = 'PART', then segmented data is read from below, else
+$    the data is read from file as with the other inputs (as INTEGER)
+$
+   10 3 1 '(....)' 'PART' 'mapsta.inp'
+$
+$ Read the status map from file ( FROM != PART ) --------------------- $ 
+$
+$ 3 3 3 3 3 3 3 3 3 3 3 3
+$ 3 2 1 1 1 1 0 1 1 1 1 3
+$ 3 2 1 1 1 1 0 1 1 1 1 3
+$ 3 2 1 1 1 1 0 1 1 1 1 3
+$ 3 2 1 1 1 1 0 0 1 1 1 3
+$ 3 2 1 1 1 1 1 1 1 1 1 3
+$ 3 2 1 1 1 1 1 1 1 1 1 3
+$ 3 2 1 1 1 1 1 1 1 1 1 3
+$ 3 2 1 1 1 1 1 1 1 1 1 3
+$ 3 2 1 1 1 1 1 1 1 1 1 3
+$ 3 2 1 1 1 1 1 1 1 1 1 3
+$ 3 3 3 3 3 3 3 3 3 3 3 3
+$
+$ The legend for the input map is :
+$
+$    0 : Land point.
+$    1 : Regular sea point.
+$    2 : Active boundary point.
+$    3 : Point excluded from grid.
+$
+$ Input boundary points from segment data ( FROM = PART ) ------------ $
+$   An unlimited number of lines identifying points at which input 
+$   boundary conditions are to be defined. If the actual input data is
+$   not defined in the actual wave model run, the initial conditions
+$   will be applied as constant boundary conditions. Each line contains:
+$     Discrete grid counters (IX,IY) of the active point and a
+$     connect flag. If this flag is true, and the present and previous
+$     point are on a grid line or diagonal, all intermediate points
+$     are also defined as boundary points.
+$
+$      2   2   F
+$      2  11   T
+$
+$  Close list by defining point (0,0) (mandatory)
+$
+      0   0   F
+$
+$ Excluded grid points from segment data ( FROM != PART )
+$   First defined as lines, identical to the definition of the input
+$   boundary points, and closed the same way.
+$
+      0   0   F
+$
+$   Second, define a point in a closed body of sea points to remove
+$   the entire body of sea points. Also close by point (0,0)
+$
+      0   0
+$
+$ Output boundary points --------------------------------------------- $
+$ Output boundary points are defined as a number of straight lines, 
+$ defined by its starting point (X0,Y0), increments (DX,DY) and number
+$ of points. A negative number of points starts a new output file.
+$ Note that this data is only generated if requested by the actual
+$ program. Example again for spherical grid in degrees. Note, these do
+$ not need to be defined for data transfer between grids in te multi
+$ grid driver.
+$
+$     1.75  1.50  0.25 -0.10     3
+$     2.25  1.50 -0.10  0.00    -6
+$     0.10  0.10  0.10  0.00   -10
+$
+$  Close list by defining line with 0 points (mandatory)
+$
+     0.    0.    0.    0.       0
+$
+$ -------------------------------------------------------------------- $
+$ End of input file                                                    $
+$ -------------------------------------------------------------------- $
+

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list