cdm/src/main/java/ucar/nc2/iosp/netcdf3/N3raf.java
protected void writeData( Array values, Layout index, DataType dataType) throws java.io.IOException {
    if ((dataType == DataType.BYTE) || (dataType == DataType.CHAR)) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.write( ii.getByteNext());
      }
      return;

    } else if (dataType == DataType.STRING) { // LOOK not legal
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++) {
          String val = (String) ii.getObjectNext();
          if (val != null) raf.write( val.getBytes(CDM.utf8Charset)); // LOOK ??
        }
      }
      return;

    } else if (dataType == DataType.SHORT) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeShort( ii.getShortNext());
      }
      return;

    } else if (dataType == DataType.INT) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeInt( ii.getIntNext());
      }
      return;

    } else if (dataType == DataType.FLOAT) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeFloat( ii.getFloatNext());
      }
      return;

    } else if (dataType == DataType.DOUBLE) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeDouble( ii.getDoubleNext());
      }
      return;
    }

    throw new IllegalStateException("dataType= "+dataType);
  }
protected void writeData( Array values, Layout index, DataType dataType) throws java.io.IOException {
    if ((dataType == DataType.BYTE) || (dataType == DataType.CHAR)) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.write( ii.getByteNext());
      }
      return;

    } else if (dataType == DataType.STRING) { // LOOK not legal
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++) {
          String val = (String) ii.getObjectNext();
          if (val != null) raf.write( val.getBytes(CDM.utf8Charset)); // LOOK ??
        }
      }
      return;

    } else if (dataType == DataType.SHORT) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeShort( ii.getShortNext());
      }
      return;

    } else if (dataType == DataType.INT) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeInt( ii.getIntNext());
      }
      return;

    } else if (dataType == DataType.FLOAT) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeFloat( ii.getFloatNext());
      }
      return;

    } else if (dataType == DataType.DOUBLE) {
      IndexIterator ii = values.getIndexIterator();
      while (index.hasNext()) {
        Layout.Chunk chunk = index.next();
        raf.seek ( chunk.getSrcPos());
        for (int k=0; k<chunk.getNelems(); k++)
          raf.writeDouble( ii.getDoubleNext());
      }
      return;
    }

    throw new IllegalStateException("dataType= "+dataType);
  }
protected void writeData ( Array values , Layout index , DataType dataType ) throws java . io . IOException { if ( ( dataType == DataType . BYTE ) || ( dataType == DataType . CHAR ) ) { IndexIterator ii = values . getIndexIterator ( ) ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . seek ( chunk . getSrcPos ( ) ) ; for ( int k = 0 ; k < chunk . getNelems ( ) ; k ++ ) raf . write ( ii . getByteNext ( ) ) ; } return ; } else if ( dataType == DataType . STRING ) { // LOOK not legal IndexIterator ii = values . getIndexIterator ( ) ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . seek ( chunk . getSrcPos ( ) ) ; for ( int k = 0 ; k < chunk . getNelems ( ) ; k ++ ) { String val = ( String ) ii . getObjectNext ( ) ; if ( val != null ) raf . write ( val . getBytes ( CDM . utf8Charset ) ) ; // LOOK ?? } } return ; } else if ( dataType == DataType . SHORT ) { IndexIterator ii = values . getIndexIterator ( ) ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . seek ( chunk . getSrcPos ( ) ) ; for ( int k = 0 ; k < chunk . getNelems ( ) ; k ++ ) raf . writeShort ( ii . getShortNext ( ) ) ; } return ; } else if ( dataType == DataType . INT ) { IndexIterator ii = values . getIndexIterator ( ) ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . seek ( chunk . getSrcPos ( ) ) ; for ( int k = 0 ; k < chunk . getNelems ( ) ; k ++ ) raf . writeInt ( ii . getIntNext ( ) ) ; } return ; } else if ( dataType == DataType . FLOAT ) { IndexIterator ii = values . getIndexIterator ( ) ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . seek ( chunk . getSrcPos ( ) ) ; for ( int k = 0 ; k < chunk . getNelems ( ) ; k ++ ) raf . writeFloat ( ii . getFloatNext ( ) ) ; } return ; } else if ( dataType == DataType . DOUBLE ) { IndexIterator ii = values . getIndexIterator ( ) ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . seek ( chunk . getSrcPos ( ) ) ; for ( int k = 0 ; k < chunk . getNelems ( ) ; k ++ ) raf . writeDouble ( ii . getDoubleNext ( ) ) ; } return ; } throw new IllegalStateException ( "dataType= " + dataType ) ; }
write data to a file for a variable.
@param values write this data.
@param index handles skipping around in the file.
@param dataType dataType of the variable
write data to a file for a variable .