[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:56:13 UTC 2009
The following commit has been merged in the upstream branch:
commit 648858ef7c3d28704795192726baa046ff8c5e0c
Author: Stephane Popinet <popinet at users.sf.net>
Date: Mon Feb 23 16:17:04 2009 +1100
Wavewatch initialisation files are created in the background
darcs-hash:20090223051704-d4795-b424f62b49be8437d337608912ce1f12f282370b.gz
diff --git a/modules/wavewatch.mod b/modules/wavewatch.mod
index 2c756d9..972ed34 100644
--- a/modules/wavewatch.mod
+++ b/modules/wavewatch.mod
@@ -16,23 +16,30 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/wait.h>
#include "wave.h"
#include "wavewatch/wavewatch.h"
#define DEBUG 0
/* fixme: needs to be identical to the same function in wave.c */
+#define GAMMA 1.1
+#define F0 0.04
+
static double frequency (int ik)
{
- double gamma = 1.1;
- double f0 = 0.04;
- return f0*pow(gamma, ik);
+ return F0*pow(GAMMA, ik);
}
-
+
+#if DEBUG
static double theta (guint ith, guint ntheta)
{
return 2.*M_PI*ith/ntheta;
}
+#endif
typedef struct {
GfsWave * wave;
@@ -103,20 +110,101 @@ static void source (FttCell * cell, SourceParams * p)
GFS_VALUE (cell, p->fpi) = FPI;
}
-static void wavewatch_source (GfsWave * wave)
+static void deletedir (const char * name)
{
- GfsDomain * domain = GFS_DOMAIN (wave);
-
- if (wave->nk != 25 || wave->ntheta != 24)
- g_assert_not_implemented ();
+ gchar * command = g_strconcat ("rm -r -f ", name, NULL);
+ system (command);
+ g_free (command);
+}
+static void initialize (GfsWave * wave)
+{
static gboolean initialized = FALSE;
if (!initialized) {
+
+ /* Creates temporary directory */
+ char template[] = "/tmp/gfswavewatch.XXXXXX", * tmp;
+ tmp = mkdtemp (template);
+ if (tmp == NULL) {
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
+ "wavewatch module: could not create temporary directory\n"
+ "%s\n", strerror (errno));
+ return;
+ }
+
+ /* Creates wavewatch ww3_grid.inp input file */
+ gchar * sinput = g_strconcat (tmp, "/ww3_grid.inp", NULL);
+ FILE * input = fopen (sinput, "w");
+ g_free (sinput);
+ if (input == NULL) {
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
+ "wavewatch module: could not create input file\n"
+ "%s\n", strerror (errno));
+ deletedir (tmp);
+ return;
+ }
+ fprintf (input,
+ "$\n"
+ " 'Gerris wavewatch module'\n"
+ " %g %g %d %d 0.\n"
+ " F F F F F T\n"
+ " 900. 950. 900. 300.\n"
+ "END OF NAMELISTS\n",
+ GAMMA, F0, wave->nk, wave->ntheta);
+
+ /* Dummy wavewatch parameters */
+ static gchar constant_parameters[] =
+ " 3 3\n"
+ " 1000. 1000. 1.\n"
+ " -1000. -1000. 1.\n"
+ " -0.1 2.50 10 -1000. 3 1 '(....)' 'NAME' 'bottom.inp'\n"
+ " 1 1 1\n"
+ " 1 1 1\n"
+ " 1 1 1\n"
+ " 10 3 1 '(....)' 'PART' 'mapsta.inp'\n"
+ " 0 0 F\n"
+ " 0 0 F\n"
+ " 0 0\n"
+ " 0. 0. 0. 0. 0\n";
+ fputs (constant_parameters, input);
+ fclose (input);
+
+ /* Calls 'ww3_grid' of wavewatch to generate 'mod_def.w3'
+ * required to initialize wavewatch. */
+ char * wdir = getcwd (NULL, 0);
+ char * command = g_strconcat ("cd ", tmp, " && "
+ "test -f $HOME/.wwatch3.env && "
+ "`grep WWATCH3_DIR /home/popinet/.wwatch3.env | "
+ "awk '{print $2}'`/exe/ww3_grid > ", wdir, "/log_grid.ww3 && "
+ "mv mod_def.ww3 ", wdir, " && "
+ "rm -r -f ", tmp,
+ NULL);
+ int status = system (command);
+ deletedir (tmp);
+ free (wdir);
+ g_free (command);
+ if (status == -1 || WEXITSTATUS (status) != 0) {
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
+ "wavewatch module: error when running ww3_grid\nsee log_grid.ww3 for details");
+ return;
+ }
+
+ /* Initialize wavewatch */
__gfsw3init__gfsw3_init ();
+
+ /* cleanup */
+ remove ("mod_def.ww3");
initialized = TRUE;
}
+}
+static void wavewatch_source (GfsWave * wave)
+{
+ GfsDomain * domain = GFS_DOMAIN (wave);
SourceParams p;
+
+ initialize (wave);
+
p.wave = wave;
p.A = g_malloc (wave->nk*wave->ntheta*sizeof (REAL));
p.CG = g_malloc (wave->nk*sizeof (REAL));
diff --git a/modules/wavewatch/gfsw3initmd.ftn b/modules/wavewatch/gfsw3initmd.ftn
index df0b299..aa8165b 100644
--- a/modules/wavewatch/gfsw3initmd.ftn
+++ b/modules/wavewatch/gfsw3initmd.ftn
@@ -227,6 +227,9 @@ CONTAINS
CALL W3SETA ( 1, 6, 6 )
CALL W3SETO ( 1, 6, 6 )
CALL W3SETI ( 1, 6, 6 )
+
+! Time is not set
+ TIME(1) = -1
!
!/SHRD NAPROC = 1
!/SHRD IAPROC = 1
@@ -240,9 +243,9 @@ CONTAINS
! 1. IO set-up
! 1.a For shell
!
- NDSO = 6
- NDSE = 6
- NDST = 6
+ NDSO = 20
+ NDSE = 20
+ NDST = 20
!
!/NCO/!
!/NCO/! Redo according to NCO standard and docblock
@@ -257,10 +260,10 @@ CONTAINS
! 1.b For WAVEWATCH-III (See W3INIT)
!
NDS( 1) = 20
- NDS( 2) = 6
-! NDS( 3) = 6
- NDS( 3) = 21
- NDS( 4) = 6
+ NDS( 2) = 20
+! NDS( 3) = 20
+ NDS( 3) = 20
+ NDS( 4) = 20
NDS( 5) = 30
NDS( 6) = 30
NDS( 7) = 31
diff --git a/modules/wavewatch/ww3_grid.inp b/modules/wavewatch/ww3_grid.inp
deleted file mode 100644
index 7c6babb..0000000
--- a/modules/wavewatch/ww3_grid.inp
+++ /dev/null
@@ -1,343 +0,0 @@
-$ -------------------------------------------------------------------- $
-$
-$ 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