Salome HOME
Merging with WPdev
[modules/smesh.git] / src / MEFISTO2 / Rn.h
index 2bf72bc7b312171b31247f6c31de6adab21dca04..aa69c4aaac9888d2df657c8ab0c7e3f40d4d0ed2 100755 (executable)
@@ -41,7 +41,6 @@
 #include <iostream>
 #include <cmath>
 
-using namespace std;
 
 template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
 template<class T> inline void Echange (T& a,T& b) {T c=a;a=b;b=c;}
@@ -67,7 +66,15 @@ typedef unsigned long int N;
 
 //le type Z des nombres entiers relatifs
 //=========
-typedef long int Z;
+// 64-bit porting: "long" replaced with "int". 
+// On 64-bit, C++ long type is 8 byte long. MEFISTO2D C code calls several Fortran subroutines passing
+// arguments of this type, however Fortran knows nothing about changed size of arguments, 
+// therefore stack gets corrupted. With "int" used instead of "long", Fortran calls from C do no harm to the stack
+// After this modification, behavior on 32-bit platforms does not change: on all platforms supported by
+// SALOME 3, "int" and "long" have the same size of 4 bytes. 
+//========
+//typedef long int Z;
+typedef int Z;
 
 //le type R des nombres "reels"
 //=========
@@ -81,14 +88,14 @@ typedef double R;
 //============
 class R2 
 {
-  friend ostream& operator << (ostream& f, const R2 & P)
+  friend std::ostream& operator << (std::ostream& f, const R2 & P)
   { f << P.x << ' ' << P.y ; return f; }
-  friend istream& operator >> (istream& f, R2 & P)
+  friend std::istream& operator >> (std::istream& f, R2 & P)
   { f >> P.x >> P.y ; return f; }
 
-  friend ostream& operator << (ostream& f, const R2 * P)
+  friend std::ostream& operator << (std::ostream& f, const R2 * P)
   { f << P->x << ' ' << P->y ; return f; }
-  friend istream& operator >> (istream& f, R2 * P)
+  friend std::istream& operator >> (std::istream& f, R2 * P)
   { f >> P->x >> P->y ; return f; }
 
 public:
@@ -120,14 +127,14 @@ public:
 //============
 class R3
 {
-  friend ostream& operator << (ostream& f, const R3 & P)
+  friend std::ostream& operator << (std::ostream& f, const R3 & P)
   { f << P.x << ' ' << P.y << ' ' << P.z ; return f; }
-  friend istream& operator >> (istream& f, R3 & P)
+  friend std::istream& operator >> (std::istream& f, R3 & P)
   { f >> P.x >> P.y >> P.z ; return f; }
 
-  friend ostream& operator << (ostream& f, const R3 * P)
+  friend std::ostream& operator << (std::ostream& f, const R3 * P)
   { f << P->x << ' ' << P->y << ' ' << P->z ; return f; }
-  friend istream& operator >> (istream& f, R3 * P)
+  friend std::istream& operator >> (std::istream& f, R3 * P)
   { f >> P->x >> P->y >> P->z ; return f; }
 
 public:  
@@ -173,12 +180,12 @@ public:
 //============
 class R4: public R3
 {
-  friend ostream& operator <<(ostream& f, const R4 & P )
+  friend std::ostream& operator <<(std::ostream& f, const R4 & P )
   { f << P.x << ' ' << P.y << ' ' << P.z << ' ' << P.omega; return f; }
   friend istream& operator >>(istream& f,  R4 & P)
   { f >> P.x >>  P.y >>  P.z >> P.omega ; return f; }
 
-  friend ostream& operator <<(ostream& f, const R4 * P )
+  friend std::ostream& operator <<(std::ostream& f, const R4 * P )
   { f << P->x << ' ' << P->y << ' ' << P->z << ' ' << P->omega; return f; }
   friend istream& operator >>(istream& f,  R4 * P)
   { f >> P->x >>  P->y >>  P->z >> P->omega ; return f; }