Commit 92354b44 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

A whole bunch of HP fixes

parent bd340909
......@@ -3,6 +3,10 @@ PROJECT(Xdmf)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${Xdmf_SOURCE_DIR}/CMake)
# We need ansi c-flags, especially on HP
SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
INCLUDE_DIRECTORIES(${Xdmf_SOURCE_DIR}/Ice/libsrc)
INCLUDE_DIRECTORIES(${Xdmf_SOURCE_DIR}/libsrc
${Xdmf_BINARY_DIR}/libsrc
......
......@@ -94,6 +94,11 @@
#endif
#cmakedefine ICE_HAVE_64BIT_STREAMS
#ifdef ICE_HAVE_64BIT_STREAMS
#define ICE_64BIT_CAST
#else
#define ICE_64BIT_CAST (long)
#endif
#cmakedefine ICE_HAVE_FCNTL
......
......@@ -50,7 +50,15 @@ if( c != '_' ) {
XdmfErrorMessage("Invalid Array Tag Name: " << TagName );
return( NULL );
}
#ifdef ICE_HAVE_64BIT_STREAMS
Tag >> Id;
#else
{
double d;
Tag >> d;
Id = d;
}
#endif
//cerr << "List = " << List << endl;
//cerr << "ListLength = " << ListLength << endl;
......@@ -93,10 +101,10 @@ PrintAllXdmfArrays() {
XdmfLength i;
for( i = 0 ; i < ListIndex ; i++ ){
cerr << "XdmfArray " << i << '\n';
cerr << "XdmfArray " << ICE_64BIT_CAST i << '\n';
cerr << " NumberType " << List[ i ].Array->GetNumberTypeAsString() << '\n';
cerr << " Time = " << List[ i ].timecntr << '\n';
cerr << " Size = " << List[ i ].Array->GetNumberOfElements() << '\n';
cerr << " Time = " << ICE_64BIT_CAST List[ i ].timecntr << '\n';
cerr << " Size = " << ICE_64BIT_CAST List[ i ].Array->GetNumberOfElements() << '\n';
}
}
......@@ -116,7 +124,7 @@ if( ListIndex >= ListLength ){
List[ ListIndex ].name = NULL;
List[ ListIndex ].timecntr = GlobalTimeCntr;
List[ ListIndex ].Array = this;
Tag << "_" << GlobalTimeCntr << "_XdmfArray" << ends;
Tag << "_" << ICE_64BIT_CAST GlobalTimeCntr << "_XdmfArray" << ends;
ListIndex++;
}
......@@ -205,10 +213,10 @@ return( RetVal );
XdmfInt32 XdmfArray::Allocate( void ){
XdmfDebug("Allocating " <<
this->GetNumberOfElements() * this->GetElementSize() <<
ICE_64BIT_CAST (this->GetNumberOfElements() * this->GetElementSize()) <<
" Bytes");
if( this->DataIsMine ) {
XdmfDebug("Data " << this->DataPointer << " is Mine");
XdmfDebug("Data " << ICE_64BIT_CAST this->DataPointer << " is Mine");
if( this->DataPointer ) {
this->DataPointer = (XdmfInt8 *)realloc( this->DataPointer, this->GetNumberOfElements() * this->GetElementSize());
} else {
......@@ -320,7 +328,7 @@ XdmfInt32 MemberType;
XdmfByte *Ptr;
XdmfDebug("Coping " << NumberOfValues << " Direction = " << Direction );
XdmfDebug("Coping " << ICE_64BIT_CAST NumberOfValues << " Direction = " << Direction );
if( Direction == XDMF_ARRAY_IN ){
TmpArray = new XdmfFloat64[ NumberOfValues ];
......@@ -358,7 +366,7 @@ if( Direction == XDMF_ARRAY_IN ){
MemberIndex = 0;
NumberOfMembers = this->GetNumberOfMembers();
Length = NumberOfValues;
XdmfDebug("Copying " << NumberOfValues << " Out");
XdmfDebug("Copying " << ICE_64BIT_CAST NumberOfValues << " Out");
while( NumberOfValues ){
MemberType = this->GetMemberType( MemberIndex );
MemberLength = this->GetMemberLength( MemberIndex );
......@@ -642,7 +650,7 @@ XdmfInt32 XdmfArray::GetValues( XdmfInt64 Index, XdmfFloat64 *Values,
XdmfPointer ArrayPointer;
ArrayPointer = this->GetDataPointer(Index);
XdmfDebug("Getting " << NumberOfValues << " From Pointer = " << ArrayPointer << " to " << Values );
XdmfDebug("Getting " << ICE_64BIT_CAST NumberOfValues << " From Pointer = " << ArrayPointer << " to " << Values );
XDMF_ARRAY_COPY( ArrayPointer, this->GetNumberType(), ArrayStride,
Values, XDMF_FLOAT64_TYPE, ValuesStride,
XDMF_ARRAY_OUT, NumberOfValues );
......@@ -666,19 +674,19 @@ if( NumberOfValues == 0 ){
}
// NumberOfValues -= 1;
if( this->GetNumberType() == XDMF_COMPOUND_TYPE ){
XdmfDebug("Array is Compound, increasing value of NumberOfValues " << NumberOfValues );
XdmfDebug("Array is Compound, increasing value of NumberOfValues " << ICE_64BIT_CAST NumberOfValues );
MemberLength = 0;
for( i = 0 ; i < this->GetNumberOfMembers() ; i++ ){
MemberLength += this->GetMemberLength(i);
}
NumberOfValues *= MemberLength;
XdmfDebug("New NumberOfValues = " << NumberOfValues );
XdmfDebug("New NumberOfValues = " << ICE_64BIT_CAST NumberOfValues );
}
Values = new XdmfFloat64[ NumberOfValues + 10 ];
this->GetValues( Index, Values, NumberOfValues, ArrayStride, 1 );
i = 0;
while( NumberOfValues-- ) {
StringOutput << Values[i++] << " ";
StringOutput << ICE_64BIT_CAST Values[i++] << " ";
}
StringOutput << ends;
Ptr = StringOutput.str();
......@@ -999,3 +1007,16 @@ XdmfInt32 XdmfArray::SetValue( XdmfInt64 Index, XdmfFloat32 Value ) {
return(this->SetValueFromFloat64( Index, Value ));
}
istrstream& ICE_READ_STREAM64(istrstream& istr, ICE_64_INT& i)
{
#ifdef ICE_HAVE_64BIT_STREAMS
istr >>i;
#else
{
double d;
istr >> d;
i = d;
}
#endif
return istr;
}
......@@ -79,13 +79,13 @@ if( Rank == XDMF_FAIL ) {
return( NULL );
}
for( i = 0 ; i < Rank ; i++ ){
StringOutput << Start[i] << " ";
StringOutput << ICE_64BIT_CAST Start[i] << " ";
}
for( i = 0 ; i < Rank ; i++ ){
StringOutput << Stride[i] << " ";
StringOutput << ICE_64BIT_CAST Stride[i] << " ";
}
for( i = 0 ; i < Rank ; i++ ){
StringOutput << Count[i] << " ";
StringOutput << ICE_64BIT_CAST Count[i] << " ";
}
StringOutput << ends;
Ptr = StringOutput.str();
......@@ -188,7 +188,7 @@ XdmfInt64 i, Rank, Dimensions[ XDMF_MAX_DIMENSION ];
Rank = this->GetShape( Dimensions );
for( i = 0 ; i < Rank ; i++ ){
StringOutput << Dimensions[i] << " ";
StringOutput << ICE_64BIT_CAST Dimensions[i] << " ";
}
StringOutput << ends;
Ptr = StringOutput.str();
......@@ -241,7 +241,7 @@ if( ( this->DataSpace == H5I_BADID ) || ( this->DataSpace == H5S_ALL ) ) {
this->Rank = HRank = Rank;
XdmfDebug("Shape : Rank = " << (int)HRank);
for( i = 0 ; i < Rank ; i++ ) {
XdmfDebug(" Dimension[" << i << "] = " << Dimensions[i] );
XdmfDebug(" Dimension[" << i << "] = " << ICE_64BIT_CAST Dimensions[i] );
this->Count[i] = this->Dimension[i] = HDimension[i] = Dimensions[i];
this->Start[i] = 0;
this->Stride[i] = 1;
......@@ -296,11 +296,11 @@ for( i = 0 ; i < this->Rank ; i++ ) {
} else {
this->Count[i] = (( Dimensions[i] - this->Start[i] - 1 ) / this->Stride[i]) + 1;
}
XdmfDebug("Dim[" << i << "] = " << this->Dimension[i] <<
XdmfDebug("Dim[" << i << "] = " << ICE_64BIT_CAST this->Dimension[i] <<
" Start Stride Count = " <<
(int)this->Start[i] << " " <<
(int)this->Stride[i] << " " <<
(int)this->Count[i] );
ICE_64BIT_CAST this->Start[i] << " " <<
ICE_64BIT_CAST this->Stride[i] << " " <<
ICE_64BIT_CAST this->Count[i] );
}
this->SelectionType = XDMF_HYPERSLAB;
status = H5Sselect_hyperslab( this->DataSpace,
......@@ -379,17 +379,17 @@ istrstream Count_ist(Count, strlen( Count ) );
for( i = 0 ; i < this->Rank ; i++ ){
if( Start ){
Start_ist >> HStart[i];
ICE_READ_STREAM64(Start_ist, HStart[i]);
} else {
HStart[i] = 0;
}
if( Stride ){
Stride_ist >> HStride[i];
ICE_READ_STREAM64(Stride_ist, HStride[i]);
} else {
HStride[i] = 1;
}
if( Count ){
Count_ist >> HCount[i];
ICE_READ_STREAM64(Count_ist, HCount[i]);
} else {
HCount[i] = (this->Dimension[i] - HStart[i]) / HStride[i];
}
......@@ -404,9 +404,9 @@ XdmfDataDesc::SetShapeFromString( const XdmfString String ) {
istrstream counter(String, strlen( String ) );
XdmfInt64 dummy;
while( counter >> dummy ) count++;
while( ICE_READ_STREAM64(counter, dummy) ) count++;
this->Rank = count;
while( ist >> dummy ){
while( ICE_READ_STREAM64(ist,dummy) ){
this->Dimension[i] = dummy;
i++;
}
......@@ -423,13 +423,13 @@ XdmfDataDesc::SelectCoordinatesFromString( const XdmfString String ) {
istrstream counter(String, strlen( String ) );
XdmfInt64 dummy, *Coordinates;
while( counter >> dummy ) count++;
while( ICE_READ_STREAM64(counter, dummy) ) count++;
Coordinates = new XdmfInt64[ count + 1 ];
while( ist >> dummy ){
while( ICE_READ_STREAM64(ist, dummy) ){
Coordinates[i] = dummy;
i++;
}
XdmfDebug("String Contains " << count << " Coordinates" );
XdmfDebug("String Contains " << ICE_64BIT_CAST count << " Coordinates" );
Status = this->SelectCoordinates( count / this->Rank, Coordinates );
delete [] Coordinates;
return( Status );
......@@ -566,7 +566,7 @@ if( Rank == XDMF_FAIL ) {
}
ReturnString[0] = '0';
for( i = 0 ; i < Rank ; i++ ){
ReturnStream << Dimensions[i] << " ";
ReturnStream << ICE_64BIT_CAST Dimensions[i] << " ";
}
ReturnStream << ends;
return( ReturnString );
......@@ -639,7 +639,7 @@ istrstream ShapeString( Shape, strlen(Shape) );
NumberType = StringToXdmfType( NumberTypeString );
i = 0;
while( ShapeString >> Dim ){
while( ICE_READ_STREAM64(ShapeString, Dim) ){
Rank++;
Dimensions[i++] = Dim;
}
......@@ -664,7 +664,7 @@ if( Offset == 0 ){
if( Dimensions == NULL ){
Dimensions = &One;
}
XdmfDebug("Inserting " << Name << " at Offset " << Offset << " as type " << XdmfTypeToString( NumberType ) );
XdmfDebug("Inserting " << Name << " at Offset " << ICE_64BIT_CAST Offset << " as type " << XdmfTypeToString( NumberType ) );
if( this->GetNumberType() != XDMF_COMPOUND_TYPE ){
this->SetNumberType( XDMF_COMPOUND_TYPE );
}
......
......@@ -63,14 +63,24 @@ typedef struct ICE_LLIST_ANCHOR_ITEM {
XdmfLlist *member;
} XdmfLlist_Anchor;
extern int XdmfLlist_init(XDMF_LIST_KEY key);
extern void *XdmfLlist_add_to_tail(XDMF_LIST_KEY key, XDMF_LIST_KEY body_size);
extern void *XdmfLlist_add_to_head(XDMF_LIST_KEY key, XDMF_LIST_KEY body_size);
extern void XdmfLlist_delete_item(XDMF_LIST_KEY key, void *item_to_delete);
extern void *XdmfLlist_first_member(XDMF_LIST_KEY key);
#ifndef __cplusplus
# ifdef __hpux
# define ICE_ARGS(x) ()
# else
# define ICE_ARGS(x) x
# endif
#else
# define ICE_ARGS(x) x
#endif
extern int XdmfLlist_init ICE_ARGS((XDMF_LIST_KEY key));
extern void *XdmfLlist_add_to_tail ICE_ARGS((XDMF_LIST_KEY key, XDMF_LIST_KEY body_size));
extern void *XdmfLlist_add_to_head ICE_ARGS((XDMF_LIST_KEY key, XDMF_LIST_KEY body_size));
extern void XdmfLlist_delete_item ICE_ARGS((XDMF_LIST_KEY key, void *item_to_delete));
extern void *XdmfLlist_first_member ICE_ARGS((XDMF_LIST_KEY key));
extern void *XdmfLlist_next_member(void *member);
extern void *XdmfLlist_add_before(XDMF_LIST_KEY key, void *item_after, XDMF_LIST_KEY body_size);
extern void *XdmfLlist_add_after(XDMF_LIST_KEY key, void *item_before, XDMF_LIST_KEY body_size);
extern void *XdmfLlist_add_before ICE_ARGS((XDMF_LIST_KEY key, void *item_after, XDMF_LIST_KEY body_size));
extern void *XdmfLlist_add_after ICE_ARGS((XDMF_LIST_KEY key, void *item_before, XDMF_LIST_KEY body_size));
extern XDMF_LIST_KEY XdmfLlist_new_key(void);
......
......@@ -53,16 +53,16 @@ Element->Set("Format", this->DataFormat );
Value.seekp(0);
Type = XdmfTypeToClassString( Desc->GetNumberType() );
Element->Set("DataType", Type );
Value << Desc->GetElementSize() << ends;
Value << ICE_64BIT_CAST(Desc->GetElementSize()) << ends;
Value.seekp(0);
Element->Set("Precision", Attribute );
Rank = Desc->GetRank();
Value << Rank << ends;
Value << ICE_64BIT_CAST(Rank) << ends;
Element->Set("Rank", Attribute );
Value.seekp(0);
Value << Desc->GetDimension( 0 );
Value << ICE_64BIT_CAST(Desc->GetDimension( 0 ));
for( i = 1 ; i < Rank ; i++ ){
Value << " " << Desc->GetDimension( i );
Value << " " << ICE_64BIT_CAST(Desc->GetDimension( i ));
}
Value << ends;
Element->Set("Dimensions", Attribute );
......@@ -82,16 +82,16 @@ if( Desc->GetNumberType() == XDMF_COMPOUND_TYPE ){
Value.seekp(0);
Type = XdmfTypeToClassString( Desc->GetMemberType(i) );
Child->Set("DataType", Type );
Value << Desc->GetMemberSize(i) / Desc->GetMemberLength(i) << ends;
Value << ICE_64BIT_CAST(Desc->GetMemberSize(i) / Desc->GetMemberLength(i)) << ends;
Value.seekp(0);
Child->Set("Precision", Attribute );
Rank = Desc->GetMemberShape( i, Dimensions );
Value << Rank << ends;
Child->Set("Rank", Attribute );
Value.seekp(0);
Value << " " << Dimensions[0];
Value << " " << ICE_64BIT_CAST(Dimensions[0]);
for( j = 1 ; j < Rank ; j++ ){
Value << " " << Dimensions[j];
Value << " " << ICE_64BIT_CAST(Dimensions[j]);
}
Value << ends;
Child->Set("Dimensions", Attribute );
......@@ -135,11 +135,11 @@ for( i = 0 ; i < NumberOfMembers ; i++ ){
XdmfDebug("Checking Size for Node Named " << this->DOM->Get( Child, "Name") );
ChildDesc = this->ElementToDataDesc( Child );
TotalSize += ChildDesc->GetElementSize() * ChildDesc->GetNumberOfElements();
XdmfDebug("Running Total = " << TotalSize );
XdmfDebug("Running Total = " << ICE_64BIT_CAST(TotalSize) );
delete ChildDesc;
}
}
XdmfDebug("Total = " << TotalSize );
XdmfDebug("Total = " << ICE_64BIT_CAST(TotalSize) );
Desc->SetNumberType( XDMF_COMPOUND_TYPE, TotalSize );
// Now Fill in the Members
for( i = 0 ; i < NumberOfMembers ; i++ ){
......@@ -230,7 +230,7 @@ if( Attribute ){
Array->SetValues( 0, Values );
Rank = 1;
Dimensions[0] = Array->GetNumberOfElements();
XdmfDebug("Setting Shape to Linear Length = " << Dimensions[0] );
XdmfDebug("Setting Shape to Linear Length = " << ICE_64BIT_CAST(Dimensions[0]) );
delete Array;
Desc->SetShape( Rank, Dimensions );
}
......
......@@ -381,11 +381,11 @@ src_npts = H5Sget_select_npoints( this->GetDataSpace() );
dest_npts = H5Sget_select_npoints( Array->GetDataSpace() );
if( src_npts != dest_npts ) {
XdmfErrorMessage("Source and Target Spaces specify different sizes");
XdmfErrorMessage("Source = " << src_npts << " items");
XdmfErrorMessage("Target = " << dest_npts << " items");
XdmfErrorMessage("Source = " << ICE_64BIT_CAST(src_npts) << " items");
XdmfErrorMessage("Target = " << ICE_64BIT_CAST(dest_npts) << " items");
return( NULL );
} else {
XdmfDebug("Reading " << src_npts << " items");
XdmfDebug("Reading " << ICE_64BIT_CAST(src_npts) << " items");
}
status = H5Dread( this->Dataset,
......@@ -430,11 +430,11 @@ src_npts = H5Sget_select_npoints( this->GetDataSpace() );
dest_npts = H5Sget_select_npoints( Array->GetDataSpace() );
if( src_npts != dest_npts ) {
XdmfErrorMessage("Source and Target Spaces specify different sizes");
XdmfErrorMessage("Source = " << src_npts << " items");
XdmfErrorMessage("Target = " << dest_npts << " items");
XdmfErrorMessage("Source = " << ICE_64BIT_CAST(src_npts) << " items");
XdmfErrorMessage("Target = " << ICE_64BIT_CAST(dest_npts) << " items");
return( NULL );
} else {
XdmfDebug("Writing " << src_npts << " items");
XdmfDebug("Writing " << ICE_64BIT_CAST(src_npts) << " items");
}
status = H5Dwrite( this->Dataset,
......
......@@ -71,7 +71,7 @@ static char ReturnName[80];
ostrstream String(ReturnName,80);
if( Pattern == NULL ) Pattern = "Xdmf_";
String << Pattern << NameCntr++ << ends;
String << Pattern << ICE_64BIT_CAST(NameCntr++) << ends;
return( ReturnName );
}
......@@ -82,7 +82,7 @@ XDMF_64_INT RealObjectPointer;
XdmfObject **Rpt = &Source;
RealObjectPointer = (XDMF_64_INT)*Rpt;
Handle << "_" << hex << RealObjectPointer << "_" << Source->GetClassName() << ends;
Handle << "_" << hex << ICE_64BIT_CAST(RealObjectPointer) << "_" << Source->GetClassName() << ends;
// cout << "XdmfObjectToHandle : Source = " << Source << endl;
// cout << "Handle = " << (XdmfString)Handle.str() << endl;
return( (XdmfString)Handle.str() );
......@@ -103,7 +103,8 @@ if( c != '_' ) {
delete [] src;
return( NULL );
}
Handle >> hex >> RealObjectPointer;
Handle >> hex;
ICE_READ_STREAM64(Handle, RealObjectPointer);
// cout << "Source = " << Source << endl;
// cout << "RealObjectPointer = " << RealObjectPointer << endl;
*Rpt = (XdmfObject *)RealObjectPointer;
......
......@@ -356,6 +356,9 @@ extern void SetGlobalDebug( XdmfInt32 DebugLevel );
extern XdmfString GetUnique( XdmfString Pattern = NULL );
extern XDMF_EXPORT char *XdmfObjectToHandle( XdmfObject *Source );
extern XdmfObject *HandleToXdmfObject( char *Source );
extern istrstream& ICE_READ_STREAM64(istrstream& istr, ICE_64_INT& i);
#endif /* __cplusplus */
#endif /* __XdmfObject_h */
......@@ -7,13 +7,18 @@ vtkXdmfDataArray
# if vtk was found include the use vtk file
IF (VTK_FOUND)
ADD_LIBRARY(vtkXdmf SHARED ${Xdmf_SRCS})
IF(VTK_BUILD_SHARED_LIBS)
SET(LIBTYPE SHARED)
ELSE(VTK_BUILD_SHARED_LIBS)
SET(LIBTYPE STATIC)
ENDIF(VTK_BUILD_SHARED_LIBS)
ADD_LIBRARY(vtkXdmf ${LIBTYPE} ${Xdmf_SRCS})
TARGET_LINK_LIBRARIES(vtkXdmf vtkIO Xdmf)
# Create Tcl wrappers if VTK is wrapped in Tcl.
IF(VTK_WRAP_TCL)
VTK_WRAP_TCL(vtk${PROJECT_NAME}TCL XdmfTCL_SRCS ${Xdmf_SRCS})
ADD_LIBRARY(vtk${PROJECT_NAME}TCL SHARED ${XdmfTCL_SRCS} ${Xdmf_SRCS})
ADD_LIBRARY(vtk${PROJECT_NAME}TCL ${LIBTYPE} ${XdmfTCL_SRCS} ${Xdmf_SRCS})
TARGET_LINK_LIBRARIES(vtk${PROJECT_NAME}TCL vtkIOTCL Xdmf)
ENDIF(VTK_WRAP_TCL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment