Spectrum files, input and output

This appendix described the format of the files for spectral input (command BOUNdspec) and output (commands SPECout and NESTout) by SWAN. The files are recognized by SWAN or another reading program by the presence of the keyword SWAN and a version number on the first line of the file. This description is valid for version number 1.


These files contain the following information:

Example of a 1D nonstationary spherical coordinates file

SWAN   1                                Swan standard spectral file, version
$ Data produced by SWAN version 41.51
$ Project:'projname'     ;   run number:'runnum'
TIME                                    time-dependent data
     1                                  time coding option
LONLAT                                  locations in spherical coordinates
     2                                  number of locations
        1.00        1.00
        1.20        1.00
RFREQ                                   relative frequencies in Hz
    25                                  number of frequencies
    0.0418
    0.0477
    0.0545
    0.0622
    0.0710
    0.0810
    0.0924
    0.1055
    0.1204
    0.1375
    0.1569
    0.1791
    0.2045
    0.2334
    0.2664
    0.3040
    0.3470
    0.3961
    0.4522
    0.5161
    0.5891
    0.6724
    0.7675
    0.8761
    1.0000
QUANT
     3                                  number of quantities in table
VaDens                                  variance densities in m2/Hz
m2/Hz                                   unit
   -0.9900E+02                          exception value
CDIR                                    average Cartesian direction in degr
degr                                    unit
   -0.9990E+03                          exception value
DSPRDEGR                                directional spreading
degr                                    unit
   -0.9000E+01                          exception value
19680606.030000                         date and time
LOCATION   1
  0.3772E-03  190.1    6.3
  0.1039E-02  190.2    6.5
  0.2281E-02  190.3    6.7
  0.3812E-02  190.3    6.7
  0.4255E-02  190.3    6.6
  0.2867E-02  190.1    6.3
  0.1177E-02  189.6    5.8
  0.3892E-03  192.0   15.2
  0.8007E-03  244.5   22.9
  0.6016E-02  251.4   11.5
  0.1990E-01  251.0   11.0
  0.3698E-01  249.9   10.9
  0.3874E-01  248.1   12.1
  0.2704E-01  246.6   13.0
  0.1672E-01  247.0   13.5
  0.1066E-01  247.7   13.7
  0.5939E-02  247.3   14.0
  0.3247E-02  246.5   14.6
  0.1697E-02  245.9   14.9
  0.8803E-03  245.6   15.1
  0.4541E-03  245.5   15.3
  0.2339E-03  245.4   15.5
  0.1197E-03  245.5   15.6
  0.6129E-04  245.5   15.7
  0.3062E-04  245.3   15.9
LOCATION   2
  0.7129E-02   67.2   25.3
  0.3503E-01   67.5   21.7
  0.1299E+00   68.2   19.7
  0.5623E+00   69.7   18.0
  0.1521E+01   71.4   18.0
  0.3289E+01   74.0   18.8
  0.4983E+01   77.2   20.3
  0.4747E+01   79.9   22.0
  0.2322E+01   79.4   30.7
  0.1899E+01  341.1   56.2
  0.1900E+01  314.6   39.4
  0.6038E+01  324.3   31.9
  0.8575E+01  326.1   31.0
  0.4155E+01  325.1   30.5
  0.1109E+01  322.8   32.9
  0.7494E+00  323.1   33.3
  0.4937E+00  323.1   33.3
  0.2953E+00  323.3   33.7
  0.1661E+00  323.6   34.0
  0.9788E-01  323.7   33.8
  0.5766E-01  323.8   33.6
  0.3397E-01  324.0   33.5
  0.2001E-01  324.1   33.4
  0.1179E-01  324.2   33.3
  0.6944E-02  324.2   33.2

Example of a 2D stationary Cartesian coordinates file

SWAN   1                                Swan standard spectral file, version
$ Data produced by SWAN version 41.51
$ Project:'projname'     ;   run number:'runnum'
LOCATIONS                               locations in x-y-space
     1                                  number of locations
    22222.22        0.00
RFREQ                                   relative frequencies in Hz
    25                                  number of frequencies
    0.0418
    0.0477
    0.0545
    0.0622
    0.0710
    0.0810
    0.0924
    0.1055
    0.1204
    0.1375
    0.1569
    0.1791
    0.2045
    0.2334
    0.2664
    0.3040
    0.3470
    0.3961
    0.4522
    0.5161
    0.5891
    0.6724
    0.7675
    0.8761
    1.0000
CDIR                                    spectral Cartesian directions in degr
    12                                  number of directions
   30.0000
   60.0000
   90.0000
  120.0000
  150.0000
  180.0000
  210.0000
  240.0000
  270.0000
  300.0000
  330.0000
  360.0000
QUANT
     1                                  number of quantities in table
VaDens                                  variance densities in m2/Hz/degr
m2/Hz/degr                              unit
   -0.9900E+02                          exception value
FACTOR
    0.675611E-06
    51   242   574   956  1288  1482  1481  1286   957   579   244    51
   129   610  1443  2402  3238  3725  3724  3234  2406  1454   613   128
   273  1287  3054  5084  6846  7872  7869  6837  5091  3076  1295   271
   665  3152  7463 12402 16712 19229 19221 16690 12419  7518  3172   662
  1302  6159 14608 24275 32688 37618 37603 32644 24309 14716  6198  1296
  2328 10989 26020 43341 58358 67109 67080 58281 43401 26213 11058  2317
  3365 15922 37712 62733 84492 97150 97110 84380 62820 37991 16021  3349
  3426 16230 38440 63939 86109 99010 98969 85995 64027 38724 16331  3410
  2027  9612 22730 37790 50909 58529 58505 50841 37843 22898  9672  2018
   672  3178  7538 12535 16892 19440 19432 16870 12552  7594  3198   669
   101   479  1135  1890  2542  2924  2923  2539  1892  1144   482   101
     2    11    26    43    57    66    66    57    43    26    11     2
     0     0     0     1     1     1     1     1     1     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0

Note that the true variance or energy densities are obtained by multiplying each number by the factor given under the keyword FACTOR.

Formal description of the 1D- and 2D-spectral file


This description refers to either write or read energy/variance density spectra to or from the file.


The description of the file to write or read source terms is identical to this description except that the quantities obviously differ.


The format that is used by SWAN or should be used by the user when offering the file to SWAN is free format (FORTRAN convention) except that all keywords and names of quantities (see below) should start on the first position of the line on which they appear (see Appendix B for the syntax of keywords). This format implies that all information on each line after the required input for SWAN is ignored by SWAN. This can be used to enter user's information at the discretion of the user.



First line the keyword SWAN followed by version number  
Then if nonstationary computation: the keyword TIME  
  if stationary computation: not present  
Then if nonstationary computation: time coding option; ISO-notation (=1) is recommended  
  if stationary computation: not present  
Then $\bullet$ the description of the locations:  
  if Cartesian coordinates: the keyword LOCATIONS  
  if spherical coordinates: the keyword LONLAT  
  $\bullet$ number of locations  
  $\bullet$ for each location  
  if Cartesian coordinates: $x-$ and $y-$coordinate (in m, problem coordinates)  
  if spherical coordinates: longitude and latitude  
  Note that if the file is used for input for SWAN (but not generated by  
  SWAN) and the user so desires, the names of locations can be written  
  behind the two coordinates; these names are ignored by SWAN when  
  reading the file (see remark on format above).  
Then the frequency data (for 1D- and 2D-spectra):  
  $\bullet$ the keyword AFREQ or RFREQ (to distinguish between absolute and relative frequencies)  
  $\bullet$ number of frequencies  
  $\bullet$ a column with frequencies always in Hz (each on a new line)  
Then the direction data (only for 2D-spectra):  
  $\bullet$ the keyword NDIR or CDIR (to distinguish between nautical and Cartesian direction)  
  $\bullet$ number of directions  
  $\bullet$ a column with directions always in degrees (each on a new line)  
Then the group describing the quantities in the tables of this file (see the above examples):  
  $\bullet$ the keyword QUANT  
  $\bullet$ number of quantities  
  for each quantity  
  $\bullet$ name of the quantity  
  $\bullet$ unit of the quantity  
  $\bullet$ exception value of the quantity, i.e. the value that is written  
  instead of a computed value if that is undefined  
  Note for 1D spectra:  
  the number of quantities is always 3, and the quantities are always: energy  
  (or variance) density, average direction (CDIR for Cartesian direction or  
  NDIR for nautical direction) and directional spreading (DSPR in terms of  
  DEGREES (SWAN write the keyword DSPRDEGR, SWAN reads the keyword  
  DSPRD or DEGR in case of option DEGREES or the keywords DSPRP or POWER  
  in case of option POWER in command BOUND SHAPE). The quantities appear  
  in the order in which they appear in this description.  
  Note for 2D spectra:  
  the number of quantities is always 1; the quantity is always energy or  
  variance density (EnDens is the (short) name of true energy densities,  
  VaDens for variance densities).  
Then the group with the tables of the quantities:  
VVV $\bullet$ date and time (not present for stationary computation)  
  for each location:  
  if 2D spectrum:  
  $\bullet$ the keyword FACTOR. This keyword is replaced by the keyword ZERO  
  if the spectrum is identical 0 or it is replaced by NODATA if the  
  spectrum is undefined (not computed e.g., on land; no numbers follow)  
  $\bullet$ the factor to multiply the values in the following table  
  $\bullet$ scaled energy/variance densities (truncated by SWAN to integer values  
  for compact writing; SWAN accepts these values as reals when reading  
  this file; other programs (e.g. for postprocessing) should also accept these  
  values as reals; the values should be multiplied by the factor to get the  
  proper values of the densities).  
  else, if 1D spectrum:  
  $\bullet$ the keyword LOCATION followed by the index of the location (on the  
  same line). This is replaced by the keyword NODATA if the spectrum is  
  undefined (not computed e.g. on land; no numbers follow).  
  $\bullet$ a table containing three columns: the 3 quantities per frequency:  
  energy (or variance) density, average direction (CDIR for Cartesian  
  direction and NDIR for nautical direction) and directional spreading  
  (DSPR in terms of DEGREES (writing or reading the file) or POWER  
  (only reading the file), see note for 1D spectra above); the quantities  
  appear in the order in which they appear in this description.  

For nonstationary computations repeat from VVV.

The SWAN team 2024-09-09