- Port to SL-5

SKIPPED:
	psi/tecs/make_crv
This commit is contained in:
koennecke
2008-01-03 09:56:55 +00:00
parent 64e5c22369
commit 1f862889ce
21 changed files with 912 additions and 517 deletions

92
napi5.c
View File

@@ -93,6 +93,7 @@ static void ignoreError(void *data, char *text){
/*---------------------------------------------------------------------*/
static void buildCurrentPath(pNexusFile5 self, char *pathBuffer,
int pathBufferLen){
int length;
memset(pathBuffer,0,pathBufferLen);
if(self->iCurrentG != 0) {
@@ -574,6 +575,14 @@ static int nxToHDF5Type(int datatype)
{
type=H5T_NATIVE_UINT;
}
else if (datatype == NX_INT64)
{
type = H5T_NATIVE_INT64;
}
else if (datatype == NX_UINT64)
{
type = H5T_NATIVE_UINT64;
}
else if (datatype == NX_FLOAT32)
{
type=H5T_NATIVE_FLOAT;
@@ -642,18 +651,30 @@ static int nxToHDF5Type(int datatype)
{
/*
* This assumes string lenght is in the last dimensions and
* the logic must be the same as used in NX5getglab and NX5getinfo
* the logic must be the same as used in NX5getslab and NX5getinfo
*
* search for tests on H5T_STRING
*/
byte_zahl=dimensions[rank-1];
dimensions[rank-1]=1;
for(i = 0; i < rank; i++)
{
mydim1[i] = dimensions[i];
}
dimensions[rank-1] = byte_zahl;
dataspace=H5Screate_simple(rank,mydim1,NULL);
mydim1[rank-1] = 1;
if (dimensions[rank-1] > 1)
{
mydim[rank-1] = maxdims[rank-1] = size[rank-1] = 1;
}
if (chunkdims[rank-1] > 1)
{
chunkdims[rank-1] = 1;
}
if (dimensions[0] == NX_UNLIMITED)
{
mydim1[0] = 1;
maxdims[0] = H5S_UNLIMITED;
}
dataspace=H5Screate_simple(rank,mydim1,maxdims);
} else {
if (dimensions[0] == NX_UNLIMITED)
{
@@ -944,18 +965,29 @@ static void killAttVID(pNexusFile5 pFile, int vid){
return NX_ERROR;
}
rank = H5Sget_simple_extent_ndims(pFile->iCurrentS);
iRet = H5Sget_simple_extent_dims(pFile->iCurrentS, NULL, maxdims);
for(i = 0; i < rank; i++)
{
myStart[i] = iStart[i];
mySize[i] = iSize[i];
size[i] = iSize[i];
}
iRet = H5Sget_simple_extent_dims(pFile->iCurrentS, NULL, maxdims);
if (H5Tget_class(pFile->iCurrentT) == H5T_STRING)
{
mySize[rank - 1] = 1;
myStart[rank - 1] = 0;
}
dataspace = H5Screate_simple (rank, mySize, NULL);
if (maxdims[0] == NX_UNLIMITED)
{
size[0]=iStart[0] + iSize[0];
iRet = H5Dextend(pFile->iCurrentD, size);
if (iRet < 0)
{
NXIReportError (NXpData, "ERROR: extend slab failed");
return NX_ERROR;
}
filespace = H5Dget_space(pFile->iCurrentD);
/* define slab */
@@ -970,6 +1002,10 @@ static void killAttVID(pNexusFile5 pFile, int vid){
/* write slab */
iRet = H5Dwrite(pFile->iCurrentD, pFile->iCurrentT, dataspace,
filespace, H5P_DEFAULT,data);
if (iRet < 0)
{
NXIReportError (NXpData, "ERROR: writing slab failed");
}
iRet = H5Sclose(filespace);
} else {
/* define slab */
@@ -984,12 +1020,16 @@ static void killAttVID(pNexusFile5 pFile, int vid){
/* write slab */
iRet = H5Dwrite(pFile->iCurrentD, pFile->iCurrentT, dataspace,
pFile->iCurrentS, H5P_DEFAULT,data);
if (iRet < 0)
{
NXIReportError (NXpData, "ERROR: writing slab failed");
}
}
/* deal with HDF errors */
iRet = H5Sclose(dataspace);
if (iRet < 0)
{
NXIReportError (NXpData, "ERROR: writing slab failed");
NXIReportError (NXpData, "ERROR: closing slab failed");
return NX_ERROR;
}
return NX_OK;
@@ -1042,6 +1082,7 @@ static void killAttVID(pNexusFile5 pFile, int vid){
static NXstatus NX5settargetattribute(pNexusFile5 pFile, NXlink *sLink)
{
herr_t length, dataID, status, aid2, aid1, attID;
int type = NX_CHAR;
char name[] = "target";
length = strlen(sLink->targetPath);
@@ -1093,6 +1134,7 @@ NXstatus NX5makenamedlink(NXhandle fid, CONSTCHAR *name, NXlink *sLink)
{
pNexusFile5 pFile;
char linkTarget[1024];
int type = NX_CHAR, length;
int status;
pFile = NXI5assert (fid);
@@ -1127,6 +1169,7 @@ NXstatus NX5makenamedlink(NXhandle fid, CONSTCHAR *name, NXlink *sLink)
{
pNexusFile5 pFile;
char linkTarget[1024];
int type = NX_CHAR, length;
char *itemName = NULL;
int status;
@@ -1325,6 +1368,15 @@ static int hdf5ToNXType(int data_id, hid_t atype)
} else {
iPtype=NX_UINT32;
}
}
else if(size_id == 8)
{
if (sign_id==H5T_SGN_2)
{
iPtype=NX_INT64;
} else {
iPtype=NX_UINT64;
}
}
} else if (data_id==H5T_FLOAT)
{
@@ -1383,6 +1435,15 @@ static int h5MemType(hid_t atype)
memtype_id = H5T_NATIVE_UINT32;
}
}
else if (size_id==8)
{
if (sign_id==H5T_SGN_2)
{
memtype_id = H5T_NATIVE_INT64;
} else {
memtype_id = H5T_NATIVE_UINT64;
}
}
} else if (data_id==H5T_FLOAT)
{
size_id=H5Tget_size(atype);
@@ -1406,7 +1467,7 @@ static int h5MemType(hid_t atype)
pNexusFile5 pFile;
hid_t grp, attr1,type,atype;
int iRet,iPtype, i;
int idx,data_id;
int idx,data_id,size_id, sign_id;
char data[128];
char ph_name[1024];
info_type op_data;
@@ -1529,7 +1590,7 @@ static int h5MemType(hid_t atype)
{
pNexusFile5 pFile;
int iStart[H5S_MAX_RANK], status;
hid_t data_id, memtype_id;
hid_t data_id, memtype_id, size_id, sign_id;
int dims;
pFile = NXI5assert (fid);
@@ -1576,7 +1637,7 @@ static int h5MemType(hid_t atype)
pNexusFile5 pFile;
int i, iRank, mType, iRet;
hsize_t myDim[H5S_MAX_RANK];
hid_t data_id;
hid_t data_id,size_id,sign_id;
pFile = NXI5assert (fid);
/* check if there is an Dataset open */
@@ -1612,7 +1673,7 @@ static int h5MemType(hid_t atype)
hsize_t mySize[H5S_MAX_RANK];
hsize_t mStart[H5S_MAX_RANK];
hid_t memspace, iRet, data_id;
hid_t memtype_id;
hid_t memtype_id, size_id, sign_id;
char *tmp_data = NULL;
char *data1;
int i, dims, iRank, mtype = 0;
@@ -1636,6 +1697,7 @@ static int h5MemType(hid_t atype)
/*
* FAA 24/1/2007: I don't think this will work for multidimensional
* string arrays.
* MK 23/7/2007: You are right Freddie.
*/
mtype = NX_CHAR;
if (mySize[0] == 1) {
@@ -1711,7 +1773,7 @@ static int h5MemType(hid_t atype)
int *iLength, int *iType)
{
pNexusFile5 pFile;
hid_t attr_id;
hid_t attr_id,size_id,sign_id;
hid_t iRet, atype, aspace;
int iPType,rank;
char *iname = NULL;
@@ -1753,8 +1815,8 @@ static int h5MemType(hid_t atype)
return NX5getnextattr(fileid, pName, iLength, iType);
}
strcpy(pName, iname);
iname = NULL;
free(iname);
iname = NULL;
} else {
strcpy(pName,"What is this?");
}
@@ -1841,8 +1903,10 @@ static int h5MemType(hid_t atype)
NXstatus NX5getattrinfo (NXhandle fid, int *iN)
{
pNexusFile5 pFile;
char *iname = NULL;
unsigned int idx;
int vid;
herr_t iRet;
pFile = NXI5assert (fid);
idx=0;
@@ -1869,7 +1933,8 @@ static int h5MemType(hid_t atype)
NXstatus NX5getgroupID (NXhandle fileid, NXlink* sRes)
{
pNexusFile5 pFile;
int datalen, type = NX_CHAR;
int u, datalen, type = NX_CHAR;
char group_name[64], class_name[64];
ErrFunc oldErr;
pFile = NXI5assert (fileid);
@@ -1950,6 +2015,7 @@ void NX5assignFunctions(pNexusFunction fHandle)
fHandle->nxputslab=NX5putslab;
fHandle->nxgetdataID=NX5getdataID;
fHandle->nxmakelink=NX5makelink;
fHandle->nxmakenamedlink=NX5makenamedlink;
fHandle->nxgetdata=NX5getdata;
fHandle->nxgetinfo=NX5getinfo;
fHandle->nxgetnextentry=NX5getnextentry;