Salome HOME
A forgotten C++ test
[tools/medcoupling.git] / src / ParaMEDMEMTest / test_MPI_Access_ISend_IRecv.cxx
index cd54c259c459311a0adf6d456cc63e708a955348..baa3572c1fc98d34cf272b1d0fa89f17e76de857 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -42,7 +42,7 @@ using namespace ParaMEDMEM;
 
 void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
 
-  cout << "test_MPI_Access_ISend_IRecv" << endl ;
+  debugStream << "test_MPI_Access_ISend_IRecv" << endl ;
 
   //  MPI_Init(&argc, &argv) ; 
 
@@ -52,11 +52,12 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
   MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ;
 
   if ( size < 2 ) {
-    cout << "test_MPI_Access_ISend_IRecv must be runned with 2 procs" << endl ;
-    CPPUNIT_FAIL("test_MPI_Access_ISend_IRecv must be runned with 2 procs") ;
+      cerr << "test_MPI_Access_ISend_IRecv must be runned with 2 procs" << endl ;
+    //CPPUNIT_FAIL("test_MPI_Access_ISend_IRecv must be runned with 2 procs") ;
+    return;
   }
 
-  cout << "test_MPI_Access_ISend_IRecv" << myrank << endl ;
+  debugStream << "test_MPI_Access_ISend_IRecv" << myrank << endl ;
 
   ParaMEDMEM::CommInterface interface ;
 
@@ -83,12 +84,12 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
     if ( myrank == 0 ) {
       sendbuf[i] = i ;
       sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, SendRequestId[i]) ;
-      cout << "test" << myrank << " ISend RequestId " << SendRequestId[i]
+      debugStream << "test" << myrank << " ISend RequestId " << SendRequestId[i]
            << " tag " << mpi_access.sendMPITag(target) << endl ;
     }
     else {
       sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ;
-      cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i]
+      debugStream << "test" << myrank << " IRecv RequestId " << RecvRequestId[i]
            << " tag " << mpi_access.recvMPITag(target) << endl ;
     }
     int j ;
@@ -105,14 +106,14 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
         if ( myrank == 0 ) {
           mpi_access.status( SendRequestId[j], target, tag, error, outcount,
                              true ) ;
-          cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j]
+          debugStream << "test" << myrank << " Test(Send RequestId " << SendRequestId[j]
                << ") : target " << target << " tag " << tag << " error " << error
                << " flag " << flag << endl ;
         }
         else {
           mpi_access.status( RecvRequestId[j], source, tag, error, outcount,
                              true ) ;
-          cout << "test" << myrank << " Test(Recv RequestId "
+          debugStream << "test" << myrank << " Test(Recv RequestId "
                << RecvRequestId[j] << ") : source " << source << " tag " << tag
                << " error " << error << " outcount " << outcount
                << " flag " << flag << endl ;
@@ -123,11 +124,11 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
                       << outcount << " recvbuf " << recvbuf[j] << " KO" << endl
                       << "==========================================================="
                       << endl ;
-            cout << strstream.str() << endl ;
+            debugStream << strstream.str() << endl ;
             CPPUNIT_FAIL( strstream.str() ) ;
           }
           //else {
-          //  cout << "==========================================================="
+          //  debugStream << "==========================================================="
           //       << endl << "test" << myrank << " outcount " << outcount
           //       << " RequestId " << RecvRequestId[j] << " recvbuf "
           //       << recvbuf[j] << " OK" << endl
@@ -140,7 +141,7 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
     char msgerr[MPI_MAX_ERROR_STRING] ;
     int lenerr ;
     mpi_access.errorString(sts, msgerr, &lenerr) ;
-    cout << "test" << myrank << " lenerr " << lenerr << " "
+    debugStream << "test" << myrank << " lenerr " << lenerr << " "
          << msgerr << endl ;
 
     if ( sts != MPI_SUCCESS ) {
@@ -149,12 +150,12 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
                 << "test" << myrank << " KO"
                 << "==========================================================="
                 << endl ;
-      cout << strstream.str() << endl ;
+      debugStream << strstream.str() << endl ;
       CPPUNIT_FAIL( strstream.str() ) ;
     }
   }
 
-  mpi_access.check() ;
+  if(MPI_ACCESS_VERBOSE) mpi_access.check() ;
   if ( myrank == 0 ) {
     mpi_access.waitAll(maxreq, SendRequestId) ;
     mpi_access.deleteRequests(maxreq, SendRequestId) ;
@@ -163,7 +164,7 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
     mpi_access.waitAll(maxreq, RecvRequestId) ;
     mpi_access.deleteRequests(maxreq, RecvRequestId) ;
   }
-  mpi_access.check() ;
+  if(MPI_ACCESS_VERBOSE) mpi_access.check() ;
 
   if ( myrank == 0 ) {
     int sendrequests[maxreq] ;
@@ -174,15 +175,15 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
       strstream << "=========================================================" << endl
                 << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl
                 << "=========================================================" << endl ;
-      cout << strstream.str() << endl ;
+      debugStream << strstream.str() << endl ;
       for ( i = 0 ; i < sendreqsize ; i++ ) {
-        cout << "test" << myrank << " sendrequests[ " << i << " ] = "
+        debugStream << "test" << myrank << " sendrequests[ " << i << " ] = "
              << sendrequests[i] << endl ;
       }
       CPPUNIT_FAIL( strstream.str() ) ;
     }
     else {
-      cout << "=========================================================" << endl
+      debugStream << "=========================================================" << endl
            << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl
            << "=========================================================" << endl ;
     }
@@ -195,11 +196,11 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
       strstream << "=========================================================" << endl
                 << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl
                 << "=========================================================" << endl ;
-      cout << strstream.str() << endl ;
+      debugStream << strstream.str() << endl ;
       CPPUNIT_FAIL( strstream.str() ) ;
     }
     else {
-      cout << "=========================================================" << endl
+      debugStream << "=========================================================" << endl
            << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl
            << "=========================================================" << endl ;
     }
@@ -211,7 +212,7 @@ void MPIAccessTest::test_MPI_Access_ISend_IRecv() {
 
   //  MPI_Finalize();
 
-  cout << "test" << myrank << " OK" << endl ;
+  debugStream << "test" << myrank << " OK" << endl ;
 
   return ;
 }