Ejemplo n.º 1
0
void IO_UncertSimResults::WriteTable(const DC_TableData& tableData)
{
    WriteString(tableData.tableID, DC_TableData::tableIDLen);
    WriteStringArray(tableData.columnDesc);
    WriteStringArray(tableData.rowDesc);
    WriteDoubleMatrix(tableData.dataTable);
}
Ejemplo n.º 2
0
void IO_ProfileSimResults::WriteOneRun(const ProfileSimRunResults& runRes,
                                        int&             nextRec)
{
    // run header
    WriteString(runRes.runID, ProfileSimRunResults::runIDLen);

    WriteStringArray(runRes.caseValDesc);
    WriteStringArray(runRes.caseValShortDesc);
    WriteStringArray(runRes.caseSeqData.sequenceIDs);
    WriteDoubleArray(runRes.caseSeqData.sequenceStartTimes);
    FlushBuffer(nextRec);

    //  next record contains case start records
    BufferReset(nextRec);
    SC_IntArray caseStartRecs(runRes.Size(), -1);
    int runStartRec = nextRec;
    WriteIntArray(caseStartRecs, nextRec);

    // individual case results
    for (int i = 0; i < runRes.Size(); i++)
    {
        caseStartRecs[i] = nextRec;
        WriteOneCase(runRes[i], nextRec);
    }

    //  update case start
    BufferReset(runStartRec);
    WriteIntArray(caseStartRecs);
    FlushBuffer();
}
Ejemplo n.º 3
0
void IO_UncertSimResults::WriteFileHeader(const DC_UncertSimResults&    results)
{
    WriteStdFileHeader(fileHeader, StringLength(fileHeader) + 1, writeVersion, 0);
    WriteInt(nRuns);
    WriteInt(int(results.uncertType));

    WriteBool(results.isMultipleRun);
    if (results.isMultipleRun)
    {
        WriteString(results.resultID, results.resultIDLen);
        WriteStringArray(results.multipleRunVariableIDs);
    }
}
Ejemplo n.º 4
0
//-*****************************************************************************
WrittenArraySampleIDPtr
WriteArray( WrittenArraySampleMap &iMap,
            hid_t iGroup,
            const std::string &iName,
            const AbcA::ArraySample &iSamp,
            const AbcA::ArraySample::Key &iKey,
            hid_t iFileType,
            hid_t iNativeType,
            int iCompressionLevel )
{

    // Dispatch to string writing utils.
    const AbcA::DataType &dataType = iSamp.getDataType();
    if ( dataType.getPod() == kStringPOD )
    {
        return WriteStringArray( iMap, iGroup, iName, iSamp, iKey,
                                 iCompressionLevel );
    }
    else if ( dataType.getPod() == kWstringPOD )
    {
        return WriteWstringArray( iMap, iGroup, iName, iSamp, iKey,
                                  iCompressionLevel );
    }

    // write the dimensions as necessary
    Dimensions dims = iSamp.getDimensions();
    size_t rank = dims.rank();

    ABCA_ASSERT( rank > 0, "Cannot have a rank-0 array sample" );

    // rank 1 is the most common case, and we can easily infer it's size
    // from the dataspace for non-strings, so don't bother writing it out
    if (rank > 1)
    {
        std::string dimsName = iName + ".dims";
        WriteDimensions( iGroup, dimsName, dims );
    }

    // See whether or not we've already stored this.
    WrittenArraySampleIDPtr writeID = iMap.find( iKey );
    if ( writeID )
    {
        CopyWrittenArray( iGroup, iName, writeID );
        return writeID;
    }

    // Okay, need to actually store it.
    // It will be a dataset with an internal attribute for storing
    // the hash id.

    bool hasData = dims.numPoints() > 0;

    hid_t dspaceId = -1;
    if ( hasData )
    {
        hsize_t hdim = dims.numPoints() * dataType.getExtent();
        dspaceId = H5Screate_simple( 1, &hdim, NULL );
    }
    else
    {
        dspaceId = H5Screate( H5S_NULL );
    }

    ABCA_ASSERT( dspaceId >= 0,
                 "WriteArray() Failed in dataspace construction" );
    DspaceCloser dspaceCloser( dspaceId );

    hid_t dsetId = -1;
    if ( iCompressionLevel >= 0 && hasData )
    {
        // Make a compression plist
        hid_t zipPlist = DsetGzipCreatePlist( dims,
            iCompressionLevel > 9 ? 9 : iCompressionLevel );
        PlistCloser plistCloser( zipPlist );

        // Make the dataset.
        dsetId = H5Dcreate2( iGroup, iName.c_str(), iFileType, dspaceId,
                             H5P_DEFAULT, zipPlist, H5P_DEFAULT );
    }
    else
    {
        dsetId = H5Dcreate2( iGroup, iName.c_str(),
                             iFileType, dspaceId,
                             H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
    }
    DsetCloser dsetCloser(dsetId);

    ABCA_ASSERT( dsetId >= 0,
                 "WriteArray() Failed in dataset constructor" );

    // Write the data.
    if ( hasData )
    {
        H5Dwrite( dsetId, iNativeType, H5S_ALL, H5S_ALL, H5P_DEFAULT,
                  iSamp.getData() );
    }

    // Write the array sample key.
    WriteKey( dsetId, "key", iKey );

    writeID.reset( new WrittenArraySampleID( iKey, dsetId ) );
    iMap.store( writeID );

    // Return the reference.
    return writeID;
}