Commit e33a4f60 authored by ghweber's avatar ghweber

Added Cristina Siegerist's H5Nimrod plugin.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@1000 18c085ea-50e0-402c-830e-de6fd14e8384
parent 2b053e3d
<?xml version="1.0"?>
<Plugin name="H5Nimrod" type="database" label="H5Nimrod" version="1.0" enabled="true" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" dbtype="MTSD" haswriter="false" hasoptions="false">
<CXXFLAGS>
$(HDF5_INCLUDE)
</CXXFLAGS>
<LIBS>
$(HDF5_LIB)
</LIBS>
<Extensions>
.h5nimrod
</Extensions>
<Files components="M">
avtH5NimrodFileFormat.C
H5utils.C
</Files>
<Files components="E">
avtH5NimrodFileFormat.C
H5utils.C
</Files>
<Attribute name="" purpose="" persistent="true" keyframe="true" exportAPI="" exportInclude="">
</Attribute>
</Plugin>
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <H5NimrodPluginInfo.h>
#include <avtH5NimrodFileFormat.h>
#include <avtMTSDFileFormatInterface.h>
#include <avtGenericDatabase.h>
// ****************************************************************************
// Method: H5NimrodCommonPluginInfo::GetDatabaseType
//
// Purpose:
// Returns the type of a H5Nimrod database.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
DatabaseType
H5NimrodCommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_MTSD;
}
// ****************************************************************************
// Method: H5NimrodCommonPluginInfo::GetDefaultExtensions
//
// Purpose:
// Returns the default extensions for a H5Nimrod database.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
std::vector<std::string>
H5NimrodCommonPluginInfo::GetDefaultExtensions()
{
std::vector<std::string> defaultExtensions;
defaultExtensions.push_back(".h5nimrod");
return defaultExtensions;
}
// ****************************************************************************
// Method: H5NimrodCommonPluginInfo::SetupH5NimrodDatabase
//
// Purpose:
// Sets up a H5Nimrod database.
//
// Arguments:
// list A list of file names.
// nList The number of timesteps in list.
// nBlocks The number of blocks in the list.
//
// Returns: A H5Nimrod database from list.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
avtDatabase *
H5NimrodCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
avtMTSDFileFormat **ffl = new avtMTSDFileFormat*[nList];
for (int i = 0 ; i < nList ; i++)
{
ffl[i] = new avtH5NimrodFileFormat(list[i]);
}
avtMTSDFileFormatInterface *inter
= new avtMTSDFileFormatInterface(ffl, nList);
return new avtGenericDatabase(inter);
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <H5NimrodPluginInfo.h>
#if defined(__APPLE__)
#define GetEngineInfo H5Nimrod_GetEngineInfo
#endif
// ****************************************************************************
// Function: GetEngineInfo
//
// Purpose:
// Return a new EnginePluginInfo for the H5Nimrod database.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
extern "C" EngineDatabasePluginInfo* GetEngineInfo()
{
return new H5NimrodEnginePluginInfo;
}
// ****************************************************************************
// Method: H5NimrodCommonPluginInfo::GetWriter
//
// Purpose:
// Sets up a H5Nimrod writer.
//
// Returns: A H5Nimrod writer.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
avtDatabaseWriter *
H5NimrodEnginePluginInfo::GetWriter(void)
{
return NULL;
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <H5NimrodPluginInfo.h>
#if defined(__APPLE__)
#define GetMDServerInfo H5Nimrod_GetMDServerInfo
#endif
// ****************************************************************************
// Function: GetMDServerInfo
//
// Purpose:
// Return a new MDServerPluginInfo for the H5Nimrod database.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
extern "C" MDServerDatabasePluginInfo* GetMDServerInfo()
{
return new H5NimrodMDServerPluginInfo;
}
// this makes compilers happy... remove if we ever have functions here
void H5NimrodMDServerPluginInfo::dummy()
{
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// File: H5NimrodPluginInfo.C
// ************************************************************************* //
#include <H5NimrodPluginInfo.h>
#include <visit-config.h>
#if defined(__APPLE__)
extern "C" const char *H5NimrodVisItPluginVersion = VERSION;
#else
extern "C" const char *VisItPluginVersion = VERSION;
#endif
#if defined(__APPLE__)
#define GetGeneralInfo H5Nimrod_GetGeneralInfo
#endif
// ****************************************************************************
// Function: GetGeneralInfo
//
// Purpose:
// Return a new GeneralPluginInfo for the H5Nimrod database.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
extern "C" GeneralDatabasePluginInfo* GetGeneralInfo()
{
return new H5NimrodGeneralPluginInfo;
}
// ****************************************************************************
// Method: H5NimrodGeneralPluginInfo::GetName
//
// Purpose:
// Return the name of the database plugin.
//
// Returns: A pointer to the name of the database plugin.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
char *
H5NimrodGeneralPluginInfo::GetName() const
{
return "H5Nimrod";
}
// ****************************************************************************
// Method: H5NimrodGeneralPluginInfo::GetVersion
//
// Purpose:
// Return the version of the database plugin.
//
// Returns: A pointer to the version of the database plugin.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
char *
H5NimrodGeneralPluginInfo::GetVersion() const
{
return "1.0";
}
// ****************************************************************************
// Method: H5NimrodGeneralPluginInfo::GetID
//
// Purpose:
// Return the id of the database plugin.
//
// Returns: A pointer to the id of the database plugin.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
char *
H5NimrodGeneralPluginInfo::GetID() const
{
return "H5Nimrod_1.0";
}
// ****************************************************************************
// Method: H5NimrodGeneralPluginInfo::EnabledByDefault
//
// Purpose:
// Return true if this plugin should be enabled by default; false otherwise.
//
// Returns: true/false
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
bool
H5NimrodGeneralPluginInfo::EnabledByDefault() const
{
return true;
}
// ****************************************************************************
// Method: H5NimrodGeneralPluginInfo::HasWriter
//
// Purpose:
// Return true if this plugin has a database writer.
//
// Returns: true/false
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// ****************************************************************************
bool
H5NimrodGeneralPluginInfo::HasWriter() const
{
return false;
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2007, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ****************************************************************************
// H5NimrodPluginInfo.h
// ****************************************************************************
#ifndef H5NIMROD_PLUGIN_INFO_H
#define H5NIMROD_PLUGIN_INFO_H
#include <DatabasePluginInfo.h>
#include <database_plugin_exports.h>
class avtDatabase;
class avtDatabaseWriter;
// ****************************************************************************
// Class: H5NimrodDatabasePluginInfo
//
// Purpose:
// Classes that provide all the information about the H5Nimrod plugin.
// Portions are separated into pieces relevant to the appropriate
// components of VisIt.
//
// Programmer: ghweber -- generated by xml2info
// Creation: Mon May 21 16:30:36 PST 2007
//
// Modifications:
//
// ****************************************************************************
class H5NimrodGeneralPluginInfo : public virtual GeneralDatabasePluginInfo
{
public:
virtual char *GetName() const;
virtual char *GetVersion() const;
virtual char *GetID() const;
virtual bool EnabledByDefault() const;
virtual bool HasWriter() const;
};
class H5NimrodCommonPluginInfo : public virtual CommonDatabasePluginInfo, public virtual H5NimrodGeneralPluginInfo
{
public:
virtual DatabaseType GetDatabaseType();
virtual std::vector<std::string> GetDefaultExtensions();
virtual avtDatabase *SetupDatabase(const char * const *list,
int nList, int nBlock);
};
class H5NimrodMDServerPluginInfo : public virtual MDServerDatabasePluginInfo, public virtual H5NimrodCommonPluginInfo
{
public:
// this makes compilers happy... remove if we ever have functions here
virtual void dummy();
};
class H5NimrodEnginePluginInfo : public virtual EngineDatabasePluginInfo, public virtual H5NimrodCommonPluginInfo
{
public:
virtual avtDatabaseWriter *GetWriter(void);
};
#endif
#include "H5utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
hid_t
_normalize_h5_type (hid_t type)
{
H5T_class_t tclass = H5Tget_class (type);
int size = H5Tget_size (type);
switch (tclass)
{
case H5T_INTEGER:
if (size == 8)
{
return H5T_NATIVE_INT64;
}
else if (size == 4)
{
return H5T_NATIVE_INT32;
}
else if (size == 1)
{
return H5T_NATIVE_CHAR;
}
break;
case H5T_FLOAT:
if (size == 8)
{
return H5T_NATIVE_DOUBLE;
}
else if (size == 4)
{
return H5T_NATIVE_FLOAT;
}
default:
; /* NOP */
}
printf ("Unknown type %d", (int) type);
return -1;
}
int
_transpose_3D (float *data, hsize_t * dims)
{
hsize_t i, j, k, indx;
float *newdata;
hsize_t ndata;
ndata = dims[0] * dims[1] * dims[2];
newdata = (float *) malloc (sizeof (float) * ndata);
indx = 0;
for (k = 0; k < dims[2]; k++)
{
for (i = 0; i < dims[1]; i++)
{
for (j = 0; j < dims[0]; j++)
{
newdata[indx] = data[k + dims[2] * (i + dims[1] * j)]; /* check this */
indx += 1;
}
}
}
memcpy (data, newdata, sizeof (float) * ndata);
free (newdata);
return H5NIMROD_SUCCESS;
}
int
H5NIMROD_read_attrib (hid_t parent_id,
const char *attrib_name, void *attrib_value)
{
herr_t herr;
hid_t attrib_id;
hid_t space_id;
hid_t type_id;
hid_t mytype;
hsize_t nelem;
attrib_id = H5Aopen_name (parent_id, attrib_name);
if (attrib_id <= 0)
return H5NIMROD_ERR;
mytype = H5Aget_type (attrib_id);
if (mytype < 0)
return H5NIMROD_ERR;
space_id = H5Aget_space (attrib_id);
if (space_id < 0)
return H5NIMROD_ERR;
nelem = H5Sget_simple_extent_npoints (space_id);
if (nelem < 0)
return H5NIMROD_ERR;
type_id = _normalize_h5_type (mytype);
herr = H5Aread (attrib_id, type_id, attrib_value);
if (herr < 0)
return H5NIMROD_ERR;
herr = H5Sclose (space_id);
if (herr < 0)
return H5NIMROD_ERR;
herr = H5Tclose (mytype);
if (herr < 0)
return H5NIMROD_ERR;
herr = H5Aclose (attrib_id);
if (herr < 0)
return H5NIMROD_ERR;
return H5NIMROD_SUCCESS;
}
int
H5NIMROD_read_string_attrib (hid_t parent_id,
const char *attrib_name, char **attrib_value)
{
herr_t herr;
hid_t attrib_id;
hid_t type_id;
hid_t mytype, type;
hsize_t nelem;
char *string_value;
*attrib_value = NULL;
attrib_id = H5Aopen_name (parent_id, attrib_name);
if (attrib_id <= 0)
return H5NIMROD_ERR;
mytype = H5Aget_type (attrib_id);
if (mytype < 0)
return H5NIMROD_ERR;
nelem = H5Tget_size (mytype);
if (nelem > 0)
{
string_value = (char *) malloc (nelem);
H5Aread (attrib_id, mytype, string_value);
*attrib_value = string_value;
}
else
{
return H5NIMROD_ERR;
}
herr = H5Tclose (mytype);
if (herr < 0)
return H5NIMROD_ERR;
herr = H5Aclose (attrib_id);
if (herr < 0)
return H5NIMROD_ERR;
return H5NIMROD_SUCCESS;
}
int
H5NIMROD_read_dims (hid_t parent_id,
const char *dataset_name, int *ndims, hsize_t * grid_dims)
{
hsize_t dims[16];
int i, j;
hid_t dataset_id = H5Dopen (parent_id, dataset_name);
if (dataset_id < 0)
return H5NIMROD_ERR;
hid_t dataspace_id = H5Dget_space (dataset_id);
if (dataspace_id < 0)
return H5NIMROD_ERR;
*ndims = H5Sget_simple_extent_dims (dataspace_id, dims, NULL);
for (i = 0, j = *ndims - 1; i < *ndims; i++, j--)
grid_dims[i] = dims[j];
H5Sclose (dataspace_id);
H5Dclose (dataset_id);
return H5NIMROD_SUCCESS;
}
int
H5NIMROD_read_float32_array (hid_t parent_id,
const char *dataset_name,
hsize_t * offset,
int ndims, hsize_t * dims, float *array)
{
hid_t dataspace, dataset, memspace, datatype;
dataset = H5Dopen (parent_id, dataset_name);
if (dataset < 0)
{
printf ("could not open dataset %s\n", dataset_name);
return H5NIMROD_ERR;
}
if (offset == NULL)
dataspace = H5S_ALL;
else
dataspace = H5Dget_space (dataset); /* dataspace identifier */
if (dims == NULL)
{