next up previous contents
Next: 3.3 How to Process Up: 3.2 How to Process Previous: 3.2.2 Horizontal Arrays (1   Contents


3.2.3 Multi-Dimensional Arrays (m x n)

This example shows how an array of data can be read vertically and horizontally at the same time, by nested loops. The outer loop reads the vertical RPM values, up to the maximum set by the NUMRPM entry. The inner loop reads the horizontal speed values, up to the maximum set by the NUMSPEED entry. In both cases, the Separator elements are used to space the values for easier reading by people.

Snippet from the Input Deck

NUMRPM   5
NUMSPEED 3
RPM    NEAPSPD  INSPEED  OUTSPEED
1000   13.3     13.9     8.8
1500   15.0     15.6     10.2
2000   16.9     17.4     12.0
2500   17.5     19.9     15.1
3000   19.0     22.4     17.4

Snippet from the FSML File

<FileData>
  <Integer name="numrpm" description="number of RPM entries in table"/>
  <Integer name="numspeed" description="number of speed columns in table"/>
  <Array name="rpm" ndims="1" dims="numrpm" baseType="Integer"
         description="engine revolutions per minute"/>
  <Array name="speed" ndims="1" dims="numspeed" baseType="Float"
         description="speed at this tide condition" units="knots"/>
</FileData>
 
<FileStructure>
  <Record ignoreOnRead="false">
    <StaticText>NUMRPM   </StaticText>
    <SetValue target="numrpm"/>
  </Record>
  <Record ignoreOnRead="false">
    <StaticText>NUMSPEED </StaticText>
    <SetValue target="numspeed"/>
  </Record>
  <Record ignoreOnRead="false">
    <StaticText>RPM    NEAPSPD  INSPEED  OUTSPEED</StaticText>
  </Record>
  <Record ignoreOnRead="false">
    <Loop loopVariable="i" start="1" end="numrpm" incr="1">
      <AddValue target="rpm"/>
      <Separator ignoreOnRead="true" string="" repeat="3"/>
      <Loop loopVariable="j" start="1" end="numspeed" incr="1">
        <AddValue target="speed"/>
        <Separator ignoreOnRead="true" string="" repeat="5"/>
      </Loop>
    </Loop>
  </Record>
</FileStructure>


next up previous contents
Next: 3.3 How to Process Up: 3.2 How to Process Previous: 3.2.2 Horizontal Arrays (1   Contents

SAIC Ship Technology Division, Annapolis, Maryland, USA
2004-10-26