Index: trunk/SophyaProg/Tests/arrt.cc
===================================================================
--- trunk/SophyaProg/Tests/arrt.cc	(revision 2890)
+++ trunk/SophyaProg/Tests/arrt.cc	(revision 2918)
@@ -9,4 +9,15 @@
 #include "array.h"
 #include "timing.h"
+
+/*  --------------------------------------------------------- */
+/*  ------- Programme de test des fonctions de base  -------  */
+/*  ----    sur les TArray/TMatrix de SOPHYA    ----          */
+/*  2000-2006      -   C. Magneville,  R. Ansari              */
+/*  arrt -> Help/Usage                                        */
+/*  Pour effectuer les tests avec RC                          */
+/*  arrt  check       -> Rc=0 OK                              */
+/*  Pour verification avec les impressions                    */
+/*  arrt a / w / m / ascio                                    */
+/*  --------------------------------------------------------- */
 
 static void tstarr(bool tio);
@@ -15,4 +26,6 @@
 static void tstmtx(int n);
 void _ZZ_TestTMatrixRC_YY_(TMatrix<r_8> & m);
+// Methode de verification des fonctionalites - Fev 2006 
+static int checktarr();
 
 static int prtlev = 1;
@@ -29,4 +42,5 @@
 	 << " a: Simple Array Test  w: a+ PPersist Test (FIO_TArray<T>) \n" 
 	 << " m: Matrix and Vector Test \n" 
+	 << " check: TArray Test/Check with Rc  \n" 
 	 << " ascio: Test of ascii I/O \n" 
 	 << " z: Appel_ZZ_TestTMatrixRC_YY_ " << endl;
@@ -43,4 +57,5 @@
   BaseArray::SetMaxPrint(nprt, prtlev);
 
+  int rc = 0;
   try {
     if (opt == "w")  tstarr(true);
@@ -56,4 +71,5 @@
     else if (opt == "m") tstmtx(n);
     else if (opt == "ascio") tstasciiio();
+    else if (opt == "check") rc = checktarr();
     else {
       cout << " arrt/Error : unknown option ! " << endl;
@@ -62,10 +78,13 @@
   catch (PThrowable exc) {
     cerr << " catched Exception " << exc.Msg() << endl;
+    rc = 97;
   }  
   catch (...) {
     cerr << " catched unknown (...) exception " << endl; 
+    rc  = 99;
   }  
   PrtTim("--- End of arrt ---");
-  cout << " ---------------  END of ArrayTest programme -------------- " << endl;
+  cout << " -----------  END of ArrayTest (Rc= " << rc << ") --------- " << endl;
+  return 0;
 }
 
@@ -393,2 +412,118 @@
 
 }
+
+// ----- Fonction de verification des fonctions de base de TArray 
+// Retourne 0 si OK 
+int checktarr()
+{
+  int rc = 0;
+
+  int NX = 17;
+  int NY = 8;
+  int NZ = 6;
+  int NT = 5;
+  if (prtlev > 0)  
+    cout << " CheckArry: Starting Test-1 EltAcc/SubArray <int> " << endl;
+  TArray<int> IA(NX, NY, NZ, NT);
+  for(int ix=0; ix<NX; ix++)
+    for(int iy=0; iy<NY; iy++)
+      for(int iz=0; iz<NZ; iz++)
+	for(int it=0; it<NT; it++)
+	  IA(ix, iy, iz, it) = it*10000+iz*1000+iy*100+ix;
+
+  TArray<int> IB(NX, NY);
+  TMatrix<int> IMXB(IB);
+  for(int ir=0; ir<IMXB.NRows(); ir++) {
+    IMXB.Row(ir) = RegularSequence(0.1);  
+    IMXB.Row(ir) += ir*100;
+  }
+
+  int nerr = 0;
+  int min=99, max=99;
+  for(int iz=0; iz<NZ; iz++)
+    for(int it=0; it<NT; it++)  {
+      TArray<int> IC = IB+(it*10000+iz*1000);
+      TArray<int> IAI = IA(Range::all(), Range::all(), Range(iz, iz), Range(it, it));
+      // Fait par SubArray      IAI.CompactTrailingDim();
+      if (prtlev > 2) {
+	cout << " CheckArry/Debug: Test-1 iz=" << iz << " it=" << it << endl;
+	cout << "IAI= \n " << IAI << " IC= \n " << IC << endl;
+      }
+      TArray<int> ID = IAI - IC;
+      ID.MinMax(min, max);
+      if ((min!=0) || (max!=0)) nerr++;
+    }
+  
+  if (nerr == 0)
+    cout << "(1) CheckTArray <int>  EltAcc, SubArray OK " << endl; 
+  else {
+    cout << "(1) CheckTArray <int>  EltAcc, SubArray ERROR -> Rc += 1 !!! NErr=" 
+	 << nerr << endl; 
+    rc += 1;
+  }
+
+  if (prtlev > 0)  
+    cout << " CheckArry: Starting Test-2 SubArray/Range <int> " << endl;  nerr = 0;
+  {
+  TArray<int> ID, IAI;
+  IAI = IA(Range::all(), Range::all(), Range::last(), Range::first());
+  // Fait par SubArray  IAI.CompactTrailingDim();
+  // cout << "---DBG- IAI= \n " << IAI << " IB= \n " << IB << endl;
+  ID = IAI - IB;
+  ID -= ((NZ-1)*1000);
+  // cout << "---DBG- ID= \n" << ID ;
+  ID.MinMax(min, max);
+  if ((min!=0) || (max!=0)) nerr++;
+  }
+  {
+  TArray<int> ID, IAI;
+  IAI = IA(Range::all(), Range::all(), Range::last(), Range::last());
+  // Fait par SubArray  IAI.CompactTrailingDim();
+  //  cout << "---DBG- IAI= \n " << IAI << " IB= \n " << IB << endl;
+  ID = IAI - IB;
+  ID -= ((NZ-1)*1000+(NT-1)*10000);
+  // cout << "---DBG- ID= \n" << ID ;
+  ID.MinMax(min, max);
+  if ((min!=0) || (max!=0)) nerr++;
+  }
+  if (nerr == 0)
+    cout << "(2) CheckTArray <int>  SubArray/Range::last() OK " << endl; 
+  else {
+    cout << "(2) CheckTArray <int>  SubArray/Range::last() ERROR  Rc += 2 !!! NErr=" 
+	 << nerr << endl; 
+    rc += 2;
+  }
+
+  if (prtlev > 0)  
+    cout << " CheckArry: Starting Test-3 SubArray(SubArray) <int> " << endl;  nerr = 0;
+  TArray<int> IAE = IA(Range::all(), Range::all(), 
+		       //	      		       Range(1, 0, 3, 2), Range::last() );
+  		       Range(Range::lastIndex(), Range::lastIndex(), 3, 2), Range::last() );
+  // Fait par SubArray  IAE.CompactTrailingDim();
+
+  TArray<int> IBE(NX/3, NY/2);  
+  for(int ix=0; ix<NX/3; ix++)
+    for(int iy=0; iy<NY/2; iy++)
+      IBE(ix, iy, 0) = 3*ix+(2*100*iy);
+
+  nerr = 0;
+  for(int iz=0; iz<IAE.SizeZ(); iz++) {
+    TArray<int> IAI = IAE(Range::all(), Range::all(), Range(iz, iz));
+    // Fait par SubArray  IAI.CompactTrailingDim();
+    //    cout << "---DBG- iz= " << iz << " IAI= \n " << IAI << " IB= \n " << IB << endl;
+    TArray<int> ID = IAI-IB;
+    ID -= ((iz*2+1)*1000+(NT-1)*10000);
+    ID.MinMax(min, max);
+    if ((min!=0) || (max!=0)) nerr++;
+  }
+
+  if (nerr == 0)
+    cout << "(3) CheckTArray <int>  SubArray(SubArray) OK " << endl; 
+  else {
+    cout << "(3) CheckTArray <int>  SubArray(SubArray)  ERROR  Rc += 4 !!! NErr=" 
+	 << nerr << endl; 
+    rc += 4;
+  }
+
+  return rc;
+}
