Index: trunk/SophyaProg/Tests/tobjio.cc
===================================================================
--- trunk/SophyaProg/Tests/tobjio.cc	(revision 3572)
+++ trunk/SophyaProg/Tests/tobjio.cc	(revision 3752)
@@ -15,14 +15,173 @@
 #include "fmath.h"
 #include "srandgen.h"
+#include "tarray.h"
+#include "arrctcast.h"
 #include "fioarr.h"
-
-
+#include "timing.h"
+
+#include <typeinfo> 
+#include <datatype.h> 
+
+/* ------------------------------------------------------------------
+  Programme de test des fonctionalites de persistance (PPF) de SOPHYA 
+  (C) LAL/IN2P3-CNRS, Univ. Paris Sud,   IRFU-CEA   1999-2010
+  SOPHYA::PPersist .... 
+  Utilisation:
+  csh> tobjio --> mini help 
+  csh> tobjio A 
+  csh> tobjio B 
+*/
+
+static int ppftstA();
+static int ppftstB();
+
+/* -- Main program -- */
 int main(int narg, char* arg[])
 {
 
+int rc = 0;
+if (narg < 2) {
+  cout << " Usage: tobjio A/B \n" 
+       << "   A : Create tobjio.ppf file containing Histo/NTuple/Array \n" 
+       << "   B : Check PPF I/O on TArray<T> \n" << endl;
+  return 1;
+}
+string opt = arg[1]; 
+try {
   SophyaInit();
-
+  InitTim();
   cout << "Hash check, OMatrix : " << hex << PIOPersist::Hash("OMatrix") << dec << endl;
-
+  if (opt=="A")  rc = ppftstA();
+  else rc = ppftstB();
+}
+catch (PThrowable & exc) {
+  cerr << " tobjio.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name() 
+       << " - Msg= " << exc.Msg() << endl;
+  rc = 99;
+ }
+catch (std::exception & e) {
+  cerr << " tobjio.cc: Catched std::exception what()=" << e.what() << endl;
+  rc=98;
+ }
+catch (...) {
+  cerr << " tobjio.cc: some other exception (...) was caught ! " << endl;
+  rc = 97;
+}
+PrtTim("End tobjio " );
+cout << " ---- Programme tobjio.cc-  FIN  (Rc=" << rc << ") --- " << endl;
+return rc;
+
+}
+
+
+
+
+static sa_size_t NX = 15;
+static sa_size_t NY = 20;
+
+/* --Fonction-- */
+template <class T>
+int ckppf_arr(T x) 
+{
+  int rc=0;
+  cout << " ---- ckppf_arr ----- T= " << typeid(x).name() << " , " 
+       << DataTypeInfo<T>::getTypeName() << endl;
+  TArray<T> a(10,12);
+  a = RegularSequence();
+  {
+    POutPersist po("arrtobj.ppf");
+    po << a;
+  }
+  TArray<T> b;
+  {
+    PInPersist pin("arrtobj.ppf");
+    pin >> b;
+  }
+  TArray<T> d = a-b;
+  T min, max;
+  d.MinMax(min,max);
+  cout << "  diff d=a-b, Min=" << min << " Max=" << max << endl;
+  if ((min != T(0))||(max != T(0)))  rc=9;
+  if (rc==0) 
+    cout << " ===>>> PPF I/O TArray< " << DataTypeInfo<T>::getTypeName() << " > OK " << endl;
+  else 
+    cout << " ===>>> PPF I/O TArray< " << DataTypeInfo<T>::getTypeName() << " > ERROR !!!! " << endl;
+  return rc;
+}
+
+/* --Fonction-- */
+template <class T>
+int ckppf_arrZ(T x) 
+{
+  int rc=0;
+  cout << " ---- ckppf_arrZ ----- complex< T= " << typeid(x).name() << " , " 
+       << DataTypeInfo<T>::getTypeName() << " > " << endl;
+  TArray< complex<T> > a(10,12);
+  TArray<T> rea = SDRealPart(a);
+  TArray<T> ima = SDImagPart(a);
+  
+  rea = RegularSequence();
+  ima = RegularSequence(0.5,2.);
+  {
+    POutPersist po("arrtobj.ppf");
+    po << a;
+  }
+  TArray< complex<T> > b;
+  {
+    PInPersist pin("arrtobj.ppf");
+    pin >> b;
+  }
+  TArray< complex<T> > d = a-b;
+  T remin, remax;
+  SDRealPart(d).MinMax(remin, remax);
+  T immin, immax;
+  SDImagPart(d).MinMax(immin, immax);
+
+  cout << "  diff real[d=a-b], Min=" << remin << " Max=" << remax << endl;
+  cout << "  diff imag[d=a-b], Min=" << immin << " Max=" << immax << endl;
+  if ((remin != T(0))||(remax != T(0)) ||
+      (immin != T(0))||(immax != T(0)) )  rc=9;
+  if (rc==0) 
+    cout << " ===>>> PPF I/O TArray< complex<" << DataTypeInfo<T>::getTypeName() << " > > OK " << endl;
+  else 
+    cout << " ===>>> PPF I/O TArray< complex< " << DataTypeInfo<T>::getTypeName() << " > > ERROR !!!! " << endl;
+  return rc;
+}
+
+/* --Fonction-- */
+int ppftstB()
+{
+  int rcg=0;
+  int rc;
+  int_4 i=1;
+  int_8 l=1;
+  r_4 f=1.;
+  r_8 d=1.;
+  rc=ckppf_arr(i);
+  if (rc!=0) rcg+=10;
+  rc=ckppf_arr(l);
+  if (rc!=0) rcg+=10;
+  rc=ckppf_arr(f);
+  if (rc!=0) rcg+=10;
+  rc=ckppf_arr(d);
+  if (rc!=0) rcg+=10;
+  rc=ckppf_arrZ(f);
+  if (rc!=0) rcg+=10;
+  rc=ckppf_arrZ(d);
+  if (rc!=0) rcg+=10;
+#ifdef SO_LDBLE128
+  r_16 ld=1.;
+  rc=ckppf_arr(ld);
+  if (rc!=0) rcg+=10;
+  rc=ckppf_arrZ(ld);
+  if (rc!=0) rcg+=10;
+#endif
+  return rcg;
+}
+
+
+/* --Fonction-- */
+int ppftstA()
+{
   cout << "Test Creation / PPersist Save NTuple, Histo, ..." << endl;
 
@@ -169,6 +328,5 @@
   cout << "Writing " << nom << endl;
   }
-
-  cout << " End --- exit .... " << endl;
-}
-
+  return 0;
+}
+
