CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

PStream/IPstream/OPstream class support for int64_t?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 1, 2010, 12:46
Default PStream/IPstream/OPstream class support for int64_t?
  #1
New Member
 
Allen Zhao
Join Date: Mar 2009
Location: Westmont, IL, USA
Posts: 26
Rep Power: 8
allenzhao is on a distinguished road
Hi,

I am using OpenFOAM-1.4.1-dev with gcc. But I have a need to pass int64_t type data using IPstream/OPstream class, and apparently, the PStream class does not support int64_t type ( at compilation time:

Example:
typedef int64_t INTEGER8;

INTEGER8 masterData, slaveData;

from master node:
OPstream toSlave(slave);
toSlave << (INTEGER8) masterData;

On slave node:
IPstream fromMaster(Pstream::masterNo());
fromMaster >> slaveData;

gcc (with either -m32 or -m64) will give something like following:

../gtopenfoamLib/FoamCalls.cpp:181: error: ambiguous overload for ‚operator>>‚ in ‚fromSlave >> objSlave‚
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/Istream.H:160: note: candidates are: Foam::Istream& Foam:operator>>(Foam::Istream&, Foam::IOstream& (*)(Foam::IOstream&)) <near match>
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/Istream.H:154: note: Foam::Istream& Foam:operator>>(Foam::Istream&, Foam::Istream& (*)(Foam::Istream&)) <near match>
../gtopenfoamLib/FoamCalls.cpp:182: warning: use of old-style cast
../gtopenfoamLib/FoamCalls.cpp:182: warning: use of old-style cast
../gtopenfoamLib/FoamCalls.cpp:189: warning: use of old-style cast
../gtopenfoamLib/FoamCalls.cpp:189: error: ambiguous overload for ‚operator<<‚ in ‚toMaster << (long int)lpFoamObjectRef‚
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/uint.H:58: note: candidates are: Foam::Ostream& Foam::operator<<(Foam::Ostream&, unsigned int)
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/Ostream.H:203: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::IOstream& (*)(Foam::IOstream&)) <near match>
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/Ostream.H:197: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::Ostream& (*)(Foam::Ostream&)) <near match>
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/IOstream.H:537: note: Foam::IOstream& Foam::operator<<(Foam::IOstream&, Foam::IOstream& (*)(Foam::IOstream&)) <near match>
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/Scalar.H:260: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::doubleScalar)
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/Scalar.H:260: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::floatScalar)
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/bool.H:51: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, bool)
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/int.H:59: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, int)
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/string.H:196: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const std::string&) <near match>
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/char.H:52: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const char*) <near match>
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/char.H:51: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, char)
/Apps/openfoam/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/lnInclude/IOstream.H:99: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOstream::streamFormat&) <near match>
../gtopenfoamLib/FoamCalls.cpp:200: warning: use of old-style cast


So apparently, we have some issues with pass 64-bit integer with MPI.

Here is my question:
What is the quickest way to patch the PStream class to enable the int64_t type? Any pointer will help.
allenzhao is offline   Reply With Quote

Old   November 1, 2010, 17:18
Default
  #2
New Member
 
Allen Zhao
Join Date: Mar 2009
Location: Westmont, IL, USA
Posts: 26
Rep Power: 8
allenzhao is on a distinguished road
My current work around is following function:

/*-----------------------------------------------/
OpenFOAM's PStream does not support int64_t data
type. Following 3 functions are utility functions
to divide INTEGER8 to 2 INTERGER or conbine 2
INTEGER data to INTEGER8 data.
------------------------------------------------*/
static INTEGER HiInteger8(INTEGER8 lNnumber)
{
return (INTEGER) ((lNnumber >> 32) & 0xFFFFFFFF);
}

static INTEGER LoInteger8(INTEGER8 lNnumber)
{
return (INTEGER) (lNnumber & 0xFFFFFFFF);
}

static INTEGER8 ToInteger8(INTEGER nHigh, INTEGER nLow)
{
return ((((INTEGER8)nHigh) << 32) | nLow);
}

But it will be ideal is PStream class can handle it by default.
allenzhao is offline   Reply With Quote

Reply

Tags
int64_t, ipstream, opstream, pstream

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 08:21
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30
About UList and List class leosding OpenFOAM Running, Solving & CFD 1 December 2, 2005 00:52


All times are GMT -4. The time now is 02:05.