Input File for ISEA=1
!21 ISEA NWAVES NWSC
1 1 0
!21 (cont) FREQW PHASEW AMPW HEADW
2.0 0.0 .1 180.0
Input File for ISEA=1
!21 ISEA SIGWHT TMODAL SEAHD SPREAD NFREQ NHEAD NWSC
2 0.027 2.75 180.0 0.0 20 1 2
!21 (cont) WSCSTP WSCFAC = wave scaling data
0 0.0
50 1.0
Input File for ISEA=1
!21 ISEA WSPEC NWSC (Stokes wave)
3 5 2
!21 (cont) FREQW PHASEW AMPW HEADW = single frequency Stokes wave
2.000000 .000000 .100000 180.000000
!21 (cont) WSCSTP WSCFAC = wave scaling data
0 0.0
50 1.0
FSML Fragment
<FileData>
...
<Integer name="ISEA"/>
<Integer name="NWAVES"/>
<Integer name="NWSC"/>
<Float name="FREQW"/>
<Float name="PHASEW"/>
<Float name="AMPW"/>
<Float name="HEADW"/>
<Float name="SIGWHT"/>
<Float name="TMODAL"/>
<Float name="SEAHD"/>
<Float name="SPREAD"/>
<Float name="NFREQ"/>
<Float name="NHEAD"/>
<Integer name="WSCSTP"/>
<Float name="WSCFAC"/>
<Integer name="WSPEC"/>
...
</FileData>
<FileStructure>
...
1 <StaticText>!21 ISEA and associated variables</StaticText>
2 <Record ignoreOnRead="false">
3 <SetValue target="ISEA" />
4 <Condition check="ISEA" operator="EQ" value="1">
5 <SetValue target="NWAVES" />
6 <SetValue target="NWSC" />
7 </Condition>
8 <Condition check="ISEA" operator="EQ" value="2">
9 <SetValue target="SIGWHT" />
10 <SetValue target="TMODAL" />
11 </Condition>
12 <Condition check="ISEA" operator="EQ" value="3">
13 <SetValue target="WSPEC" />
14 <SetValue target="NWSC" />
15 </Condition>
16 </Record>
17 <Condition check="ISEA" operator="EQ" value="1">
18 <StaticText>!21 (cont) FREQW PHASEW AMPW HEADW</StaticText>
19 <Loop start="1" end="NWAVES" incr="1">
20 <Record ignoreOnRead="true">
21 <AddValue target="FREQW" />
22 <AddValue target="PHASEW" />
23 <AddValue target="AMPW" />
24 <AddValue target="HEADW" />
25 </Record>
26 </Loop>
27 </Condition>
28 <Condition check="ISEA" operator="EQ" value="2">
29 <StaticText />
30 <Record ignoreOnRead="true">
31 <SetValue target="SEAHD" />
32 <SetValue target="SPREAD" />
33 <SetValue target="NFREQ" />
34 <SetValue target="NHEAD" />
35 <SetValue target="NWSC" />
36 </Record>
37 </Condition>
38 <Condition check="ISEA" operator="EQ" value="3">
39 <StaticText>!21 (cont) FREQW PHASEW AMPW ...</StaticText>
40 <Record ignoreOnRead="true">
41 <AddValue target="FREQW" />
42 <AddValue target="PHASEW" />
43 <AddValue target="AMPW" />
44 <AddValue target="HEADW" />
45 </Record>
46 </Condition>
47 <Condition check="ISEA" operator="GT" value="0">
48 <StaticText />
49 <Loop start="1" end="NWSC" incr="1">
50 <Record ignoreOnRead="true">
51 <AddValue target="WSCSTP" />
52 <AddValue target="WSCFAC" />
53 </Record>
54 </Loop>
55 </Condition>
...
</FileStructure>
Although it is not defined in the code, a comment typically appears in the file before the value of ISEA is read. We can ensure that this comment is written to the generated file by declaring the StaticText element on line 1 in the FSML.
Next, the value of ISEA is read on line 1 in the code. Because this value is read with its own read statement, it requires moving to the next line in the file before reading. Therefore, a Record is declared with ignoreOnRead set to false on line 2 of the FSML.
The SetValue element then reads (or writes the value of ISEA). Line 2 in the code declares an if statement that corresponds to the Condition declared on line 4. If ISEA = 1, NWAVES and NWSC should be read (or written). This is done on lines 5 and 6 in the FSML.
Each possible value for ISEA requires a separate Condition statement. Lines 5 and 6 in the code indicate an iterative read of some additional parameters. Note that one value is read for each parameter during a single loop iteration. This is represented in FSML by the loop declared on line 19. Because the values are being read with a free format, a new line for each set of parameter values is not required and should not be expected. However, for file readability it is desirable to have each set of parameter values on a separate line. Hence the reading (or writing) of the parameter values is performed on lines 21-24 in the FSML within the record on line 20, which has ignoreOnRead set to true. Why was the loop not defined inside the condition on line 4? Because when the file is written, it is desired, in this case, to have these values start on a new line. This can only be achieved with a record whose ignoreOnRead is set to true.
The condition on line 4 was defined within a record because ISEA should always be read (or written), but other values should be read from the same line depending on the value of ISEA. Because a record cannot contain another record, it is necessary to declare the loop outside of the condition on line 4. Finally, note that in the code, the WSCSTP and WSCFAC arrays are read for all values of ISEA greater than 0. Another loop is therefore declared on line 49 in the FSML for reading these values.
Fortran Code Fragment
1 read(uin,*,err=901,end=900) isea 2 if (isea.eq.1) then 3 backspace(uin) 4 read(uin,*,err=901,end=900) isea,nwaves,nwsc, 5 . (freqw(min(i,maxwav)),phasew(min(i,maxwav)), 6 . ampw(min(i,maxwav)),headw(min(i,maxwav)),i=1,nwaves), 7 . (wscstp(min(i,mxspec)),wscfac(min(i,mxspec)),i=1,nwsc) 8 elseif (isea.eq.2) then 9 backspace(uin) 10 read(uin,*,err=901,end=900) isea,sigwht,tmodal, 11 . seahd,spread,nfreq,nhead,nwsc, 12 . (wscstp(min(i,mxspec)),wscfac(min(i,mxspec)),i=1,nwsc) 13 elseif (isea.eq.3) then 14 backspace(uin) 15 read(uin,*,err=901,end=900) isea,wspec,nwsc, 16 . freqw(1),phasew(1),ampw(1),headw(1), 17 . (wscstp(min(i,mxspec)),wscfac(min(i,mxspec)),i=1,nwsc) 18 endif