Index: trunk/SophyaProg/Tests/Makefile
===================================================================
--- trunk/SophyaProg/Tests/Makefile	(revision 3389)
+++ trunk/SophyaProg/Tests/Makefile	(revision 3390)
@@ -1,5 +1,5 @@
 include ../BuildMgr/sophyamake.inc
- 
-PROGS = $(SOPHYAEXEP)arrt $(SOPHYAEXEP)carrt $(SOPHYAEXEP)lpk $(SOPHYAEXEP)obj_fits $(SOPHYAEXEP)ovharr $(SOPHYAEXEP)pizthr $(SOPHYAEXEP)ppftswap $(SOPHYAEXEP)spar $(SOPHYAEXEP)sphg0 $(SOPHYAEXEP)sph2lm $(SOPHYAEXEP)tcmd $(SOPHYAEXEP)tcxxcmpldynl $(SOPHYAEXEP)tdcr $(SOPHYAEXEP)tdynl $(SOPHYAEXEP)tfft $(SOPHYAEXEP)thash $(SOPHYAEXEP)timg $(SOPHYAEXEP)tmxv $(SOPHYAEXEP)tnt $(SOPHYAEXEP)tobjio2 $(SOPHYAEXEP)tobjio $(SOPHYAEXEP)tpipe $(SOPHYAEXEP)tsimplex $(SOPHYAEXEP)tsphereecp $(SOPHYAEXEP)tspm2 $(SOPHYAEXEP)tspm $(SOPHYAEXEP)tstboloread $(SOPHYAEXEP)tstcolread $(SOPHYAEXEP)tstdtable $(SOPHYAEXEP)tstndblk $(SOPHYAEXEP)tstppfwrapstl $(SOPHYAEXEP)tstsegdb $(SOPHYAEXEP)tswfits $(SOPHYAEXEP)tnfits $(SOPHYAEXEP)tfitsdt $(SOPHYAEXEP)tsttmat $(SOPHYAEXEP)tsttminv $(SOPHYAEXEP)tsttvec $(SOPHYAEXEP)ttimestamp $(SOPHYAEXEP)zthr
+
+PROGS = $(SOPHYAEXEP)arrt $(SOPHYAEXEP)carrt $(SOPHYAEXEP)lpk $(SOPHYAEXEP)obj_fits $(SOPHYAEXEP)ovharr $(SOPHYAEXEP)pizthr $(SOPHYAEXEP)ppftswap $(SOPHYAEXEP)spar $(SOPHYAEXEP)sphg0 $(SOPHYAEXEP)sph2lm $(SOPHYAEXEP)tcmd $(SOPHYAEXEP)tcxxcmpldynl $(SOPHYAEXEP)tdcr $(SOPHYAEXEP)tdynl $(SOPHYAEXEP)tfft $(SOPHYAEXEP)thash $(SOPHYAEXEP)timg $(SOPHYAEXEP)tmxv $(SOPHYAEXEP)tnt $(SOPHYAEXEP)tobjio2 $(SOPHYAEXEP)tobjio $(SOPHYAEXEP)tpipe $(SOPHYAEXEP)tsimplex $(SOPHYAEXEP)tsphereecp $(SOPHYAEXEP)tspm2 $(SOPHYAEXEP)tspm $(SOPHYAEXEP)tstboloread $(SOPHYAEXEP)tstcolread $(SOPHYAEXEP)tstdtable $(SOPHYAEXEP)tstndblk $(SOPHYAEXEP)tstppfwrapstl $(SOPHYAEXEP)tstsegdb $(SOPHYAEXEP)tswfits $(SOPHYAEXEP)tnfits $(SOPHYAEXEP)tfitsdt $(SOPHYAEXEP)tsttmat $(SOPHYAEXEP)tsttminv $(SOPHYAEXEP)tsttvec $(SOPHYAEXEP)ttimestamp $(SOPHYAEXEP)zthr $(SOPHYAEXEP)tmtrnd $(SOPHYAEXEP)tmtrnd3
  
 all: $(PROGS)
@@ -7,5 +7,5 @@
 clean:
 	rm -f $(PROGS)
-	rm -f $(SOPHYAOBJP)zthr.o $(SOPHYAOBJP)ttimestamp.o $(SOPHYAOBJP)tsttvec.o $(SOPHYAOBJP)tsttminv.o $(SOPHYAOBJP)tsttmat.o $(SOPHYAOBJP)tfitsdt.o $(SOPHYAOBJP)tnfits.o $(SOPHYAOBJP)tswfits.o $(SOPHYAOBJP)tstsegdb.o $(SOPHYAOBJP)tstppfwrapstl.o $(SOPHYAOBJP)tstndblk.o $(SOPHYAOBJP)tstdtable.o $(SOPHYAOBJP)tstcolread.o $(SOPHYAOBJP)tstboloread.o $(SOPHYAOBJP)tspm.o $(SOPHYAOBJP)tspm2.o $(SOPHYAOBJP)tsphereecp.o $(SOPHYAOBJP)tsimplex.o $(SOPHYAOBJP)tpipe.o $(SOPHYAOBJP)tobjio.o $(SOPHYAOBJP)tobjio2.o $(SOPHYAOBJP)tnt.o $(SOPHYAOBJP)tmxv.o $(SOPHYAOBJP)timg.o $(SOPHYAOBJP)thash.o $(SOPHYAOBJP)tfft.o $(SOPHYAOBJP)tdynl.o $(SOPHYAOBJP)tdcr.o $(SOPHYAOBJP)tcxxcmpldynl.o $(SOPHYAOBJP)tcmd.o $(SOPHYAOBJP)sph2lm.o $(SOPHYAOBJP)sphg0.o $(SOPHYAOBJP)spar.o $(SOPHYAOBJP)ppftswap.o $(SOPHYAOBJP)pizthr.o $(SOPHYAOBJP)ovharr.o $(SOPHYAOBJP)obj_fits.o $(SOPHYAOBJP)lpk.o $(SOPHYAOBJP)carrt.o $(SOPHYAOBJP)arrt.o
+	rm -f $(SOPHYAOBJP)tmtrnd3.o $(SOPHYAOBJP)tmtrnd.o $(SOPHYAOBJP)zthr.o $(SOPHYAOBJP)ttimestamp.o $(SOPHYAOBJP)tsttvec.o $(SOPHYAOBJP)tsttminv.o $(SOPHYAOBJP)tsttmat.o $(SOPHYAOBJP)tfitsdt.o $(SOPHYAOBJP)tnfits.o $(SOPHYAOBJP)tswfits.o $(SOPHYAOBJP)tstsegdb.o $(SOPHYAOBJP)tstppfwrapstl.o $(SOPHYAOBJP)tstndblk.o $(SOPHYAOBJP)tstdtable.o $(SOPHYAOBJP)tstcolread.o $(SOPHYAOBJP)tstboloread.o $(SOPHYAOBJP)tspm.o $(SOPHYAOBJP)tspm2.o $(SOPHYAOBJP)tsphereecp.o $(SOPHYAOBJP)tsimplex.o $(SOPHYAOBJP)tpipe.o $(SOPHYAOBJP)tobjio.o $(SOPHYAOBJP)tobjio2.o $(SOPHYAOBJP)tnt.o $(SOPHYAOBJP)tmxv.o $(SOPHYAOBJP)timg.o $(SOPHYAOBJP)thash.o $(SOPHYAOBJP)tfft.o $(SOPHYAOBJP)tdynl.o $(SOPHYAOBJP)tdcr.o $(SOPHYAOBJP)tcxxcmpldynl.o $(SOPHYAOBJP)tcmd.o $(SOPHYAOBJP)sph2lm.o $(SOPHYAOBJP)sphg0.o $(SOPHYAOBJP)spar.o $(SOPHYAOBJP)ppftswap.o $(SOPHYAOBJP)pizthr.o $(SOPHYAOBJP)ovharr.o $(SOPHYAOBJP)obj_fits.o $(SOPHYAOBJP)lpk.o $(SOPHYAOBJP)carrt.o $(SOPHYAOBJP)arrt.o
  
 arrt: $(SOPHYAEXEP)arrt
@@ -209,9 +209,19 @@
 	$(CXXLINK) $(CXXTEMPFLG) -o $@ $(SOPHYAOBJP)zthr.o $(SOPHYAALLSLBLIST)
  
-$(SOPHYAOBJP)arrt.o: arrt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+tmtrnd: $(SOPHYAEXEP)tmtrnd
+	echo $@ " done"
+$(SOPHYAEXEP)tmtrnd: $(SOPHYAOBJP)tmtrnd.o
+	$(CXXLINK) $(CXXTEMPFLG) -o $@ $(SOPHYAOBJP)tmtrnd.o $(SOPHYAALLSLBLIST)
+ 
+tmtrnd3: $(SOPHYAEXEP)tmtrnd3
+	echo $@ " done"
+$(SOPHYAEXEP)tmtrnd3: $(SOPHYAOBJP)tmtrnd3.o
+	$(CXXLINK) $(CXXTEMPFLG) -o $@ $(SOPHYAOBJP)tmtrnd3.o $(SOPHYAALLSLBLIST)
+ 
+$(SOPHYAOBJP)arrt.o: arrt.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -240,9 +250,9 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  arrt.cc
  
-$(SOPHYAOBJP)carrt.o: carrt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)carrt.o: carrt.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -271,8 +281,8 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  carrt.cc
  
-$(SOPHYAOBJP)lpk.o: lpk.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)lpk.o: lpk.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -304,6 +314,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  lpk.cc
  
-$(SOPHYAOBJP)obj_fits.o: obj_fits.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)obj_fits.o: obj_fits.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -324,6 +333,8 @@
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
+  $(SOPHYAINCP)dvlist.h \
   $(SOPHYAINCP)xntuple.h \
   $(SOPHYAINCP)fitsxntuple.h \
+  $(SOPHYAINCP)xntuple.h \
   $(SOPHYAINCP)fitsfile.h \
   $(SOPHYAINCP)ndatablock.h \
@@ -333,4 +344,5 @@
   $(SOPHYAINCP)fitshandler.h \
   $(SOPHYAINCP)fitsntuple.h \
+  $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)fitstarray.h \
   $(SOPHYAINCP)tarray.h \
@@ -347,9 +359,9 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  obj_fits.cc
  
-$(SOPHYAOBJP)ovharr.o: ovharr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)ovharr.o: ovharr.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -380,8 +392,8 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ovharr.cc
  
-$(SOPHYAOBJP)pizthr.o: pizthr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)pizthr.o: pizthr.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)zthread.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)pisysdep.h \
@@ -389,4 +401,5 @@
   $(SOPHYAINCP)piapplgen.h \
   $(SOPHYAINCP)pimsghandler.h \
+  $(SOPHYAINCP)pisysdep.h \
   $(SOPHYAINCP)picontainerx.h \
   $(SOPHYAINCP)picontainergen.h \
@@ -416,8 +429,11 @@
   $(SOPHYAINCP)psfile.h \
   $(SOPHYAINCP)pigraphps.h \
+  $(SOPHYAINCP)pimenux.h \
+  $(SOPHYAINCP)pistdwdgx.h \
   $(SOPHYAINCP)piwindowx.h \
   $(SOPHYAINCP)piwindowgen.h \
   $(SOPHYAINCP)piperiodx.h \
   $(SOPHYAINCP)periodic.h \
+  $(SOPHYAINCP)picons.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -447,6 +463,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pizthr.cc
  
-$(SOPHYAOBJP)ppftswap.o: ppftswap.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)ppftswap.o: ppftswap.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)sophyainit.h \
   $(SOPHYAINCP)machdefs.h \
@@ -475,12 +490,14 @@
   $(SOPHYAINCP)sopemtx.h \
   $(SOPHYAINCP)fiondblock.h \
-  $(SOPHYAINCP)tarrinit.h
+  $(SOPHYAINCP)fioarr.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppftswap.cc
  
-$(SOPHYAOBJP)spar.o: spar.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)spar.o: spar.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -510,6 +527,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  spar.cc
  
-$(SOPHYAOBJP)sph2lm.o: sph2lm.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)sph2lm.o: sph2lm.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)tarray.h \
   $(SOPHYAINCP)machdefs.h \
@@ -530,4 +546,5 @@
   $(SOPHYAINCP)cimage.h \
   $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
   $(SOPHYAINCP)tmatrix_tsnl.h \
   $(SOPHYAINCP)fioarr.h \
@@ -564,6 +581,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  sph2lm.cc
  
-$(SOPHYAOBJP)sphg0.o: sphg0.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)sphg0.o: sphg0.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)sambainit.h \
   $(SOPHYAINCP)skymapinit.h \
@@ -606,8 +622,8 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  sphg0.cc
  
-$(SOPHYAOBJP)tcmd.o: tcmd.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tcmd.o: tcmd.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
   $(SOPHYAINCP)cexpre.h \
@@ -664,6 +680,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tcxxcmpldynl.cc
  
-$(SOPHYAOBJP)tdcr.o: tdcr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tdcr.o: tdcr.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -696,10 +711,11 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)histos2.h \
+  $(SOPHYAINCP)histos.h \
   $(SOPHYAINCP)psighand.h \
+  $(SOPHYAINCP)fmath.h \
   $(SOPHYAINCP)srandgen.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tdcr.cc
  
-$(SOPHYAOBJP)tdynl.o: tdynl.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tdynl.o: tdynl.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -729,11 +745,12 @@
   $(SOPHYAINCP)sopemtx.h \
   $(SOPHYAINCP)pdlmgr.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)timing.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tdynl.cc
  
-$(SOPHYAOBJP)tfft.o: tfft.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tfft.o: tfft.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)matharr.h \
   $(SOPHYAINCP)tarray.h \
@@ -759,4 +776,5 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)fftmserver.h \
+  $(SOPHYAINCP)fftmayer.h \
   $(SOPHYAINCP)fftwserver.h \
   $(SOPHYAINCP)sspvflags.h \
@@ -767,6 +785,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tfft.cc
  
-$(SOPHYAOBJP)tfitsdt.o: tfitsdt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tfitsdt.o: tfitsdt.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -789,4 +806,5 @@
   $(SOPHYAINCP)timestamp.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)tmatrix.h \
@@ -798,4 +816,5 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)fitshdtable.h \
+  $(SOPHYAINCP)datatable.h \
   $(SOPHYAINCP)fitshandler.h \
   $(SOPHYAINCP)fitsinoutfile.h \
@@ -808,17 +827,16 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tfitsdt.cc
  
-$(SOPHYAOBJP)thash.o: thash.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)ppersist.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)pexceptions.h \
-  $(SOPHYAINCP)gnumd5.h \
-  $(SOPHYAINCP)ppfbinstream.h \
-  $(SOPHYAINCP)rawstream.h \
-  $(SOPHYAINCP)ppfnametag.h
+$(SOPHYAOBJP)thash.o: thash.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)ppersist.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  thash.cc
  
-$(SOPHYAOBJP)timg.o: timg.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)timg.o: timg.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)ntoolsinit.h \
   $(SOPHYAINCP)tarrinit.h \
@@ -850,11 +868,79 @@
   $(SOPHYAINCP)cimage.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)ndatablock.h \
   $(SOPHYAINCP)fiondblock.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  timg.cc
  
-$(SOPHYAOBJP)tmxv.o: tmxv.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
+$(SOPHYAOBJP)tmtrnd.o: tmtrnd.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)zthread.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)resusage.h \
+  $(SOPHYAINCP)ctimer.h \
+  $(SOPHYAINCP)timing.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)fioarr.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)matharr.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)stsrand.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tmtrnd.cc
+ 
+$(SOPHYAOBJP)tmtrnd3.o: tmtrnd3.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)zthread.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)matharr.h \
+  $(SOPHYAINCP)fioarr.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)nbtri.h \
+  $(SOPHYAINCP)timing.h \
+  $(SOPHYAINCP)stsrand.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tmtrnd3.cc
+ 
+$(SOPHYAOBJP)tmxv.o: tmxv.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -879,9 +965,9 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)sopemtx.h \
+  $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)timing.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tmxv.cc
  
-$(SOPHYAOBJP)tnfits.o: tnfits.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tnfits.o: tnfits.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
@@ -890,4 +976,5 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -917,11 +1004,12 @@
   $(SOPHYAINCP)FitsIO/longnam.h \
   $(SOPHYAINCP)fitsblkrw.h \
+  $(SOPHYAINCP)fitsinoutfile.h \
   $(SOPHYAINCP)fitsarrhand.h \
   $(SOPHYAINCP)fitshandler.h \
+  $(SOPHYAINCP)fitsblkrw.h \
   $(SOPHYAINCP)fiosinit.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tnfits.cc
  
-$(SOPHYAOBJP)tnt.o: tnt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tnt.o: tnt.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -942,8 +1030,10 @@
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
+  $(SOPHYAINCP)dvlist.h \
   $(SOPHYAINCP)xntuple.h \
   $(SOPHYAINCP)datatable.h \
   $(SOPHYAINCP)basedtable.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)tmatrix.h \
@@ -960,6 +1050,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tnt.cc
  
-$(SOPHYAOBJP)tobjio2.o: tobjio2.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tobjio.o: tobjio.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -992,11 +1081,13 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)histos2.h \
+  $(SOPHYAINCP)histos.h \
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
-  $(SOPHYAINCP)srandgen.h
-	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio2.cc
- 
-$(SOPHYAOBJP)tobjio.o: tobjio.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)fmath.h \
+  $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)fioarr.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio.cc
+ 
+$(SOPHYAOBJP)tobjio2.o: tobjio2.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -1029,12 +1120,13 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)histos2.h \
+  $(SOPHYAINCP)histos.h \
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
-  $(SOPHYAINCP)srandgen.h \
-  $(SOPHYAINCP)fioarr.h
-	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio.cc
- 
-$(SOPHYAOBJP)tpipe.o: tpipe.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)fmath.h \
+  $(SOPHYAINCP)srandgen.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio2.cc
+ 
+$(SOPHYAOBJP)tpipe.o: tpipe.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)zthread.h \
   $(SOPHYAINCP)machdefs.h \
@@ -1043,6 +1135,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tpipe.cc
  
-$(SOPHYAOBJP)tsimplex.o: tsimplex.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tsimplex.o: tsimplex.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)simplex.h \
   $(SOPHYAINCP)machdefs.h \
@@ -1074,8 +1165,10 @@
   $(SOPHYAINCP)perrors.h \
   $(SOPHYAINCP)fmath.h \
+  $(SOPHYAINCP)generalfunc.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)timing.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsimplex.cc
@@ -1096,4 +1189,5 @@
   $(SOPHYAINCP)pixelmap.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1120,4 +1214,5 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)fiosphereecp.h \
+  $(SOPHYAINCP)sphereecp.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)matharr.h \
@@ -1143,6 +1238,52 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsphereecp.cc
  
-$(SOPHYAOBJP)tspm2.o: tspm2.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tspm.o: tspm.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)skymapinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)skymap.h \
+  $(SOPHYAINCP)spherethetaphi.h \
+  $(SOPHYAINCP)sphericalmap.h \
+  $(SOPHYAINCP)smathconst.h \
+  $(SOPHYAINCP)pixelmap.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)spherepos.h \
+  $(SOPHYAINCP)unitvector.h \
+  $(SOPHYAINCP)vector3d.h \
+  $(SOPHYAINCP)longlat.h \
+  $(SOPHYAINCP)utilgeom.h \
+  $(SOPHYAINCP)datatype.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)spherehealpix.h \
+  $(SOPHYAINCP)HEALPixUtils.h \
+  $(SOPHYAINCP)localmap.h \
+  $(SOPHYAINCP)sphereecp.h \
+  $(SOPHYAINCP)fiospherethetaphi.h \
+  $(SOPHYAINCP)fiospherehealpix.h \
+  $(SOPHYAINCP)fiolocalmap.h \
+  $(SOPHYAINCP)fiosphereecp.h \
+  $(SOPHYAINCP)tod.h \
+  $(SOPHYAINCP)misstime.h \
+  $(SOPHYAINCP)timing.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tspm.cc
+ 
+$(SOPHYAOBJP)tspm2.o: tspm2.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)sambainit.h \
   $(SOPHYAINCP)skymapinit.h \
@@ -1202,56 +1343,9 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tspm2.cc
  
-$(SOPHYAOBJP)tspm.o: tspm.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)skymapinit.h \
-  $(SOPHYAINCP)sophyainit.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)skymap.h \
-  $(SOPHYAINCP)spherethetaphi.h \
-  $(SOPHYAINCP)sphericalmap.h \
-  $(SOPHYAINCP)smathconst.h \
-  $(SOPHYAINCP)pixelmap.h \
-  $(SOPHYAINCP)ppersist.h \
-  $(SOPHYAINCP)pexceptions.h \
-  $(SOPHYAINCP)gnumd5.h \
-  $(SOPHYAINCP)ppfbinstream.h \
-  $(SOPHYAINCP)rawstream.h \
-  $(SOPHYAINCP)ppfnametag.h \
-  $(SOPHYAINCP)dvlist.h \
-  $(SOPHYAINCP)objfio.h \
-  $(SOPHYAINCP)anydataobj.h \
-  $(SOPHYAINCP)mutyv.h \
-  $(SOPHYAINCP)timestamp.h \
-  $(SOPHYAINCP)spherepos.h \
-  $(SOPHYAINCP)unitvector.h \
-  $(SOPHYAINCP)vector3d.h \
-  $(SOPHYAINCP)longlat.h \
-  $(SOPHYAINCP)utilgeom.h \
-  $(SOPHYAINCP)datatype.h \
-  $(SOPHYAINCP)tvector.h \
-  $(SOPHYAINCP)tmatrix.h \
-  $(SOPHYAINCP)tarray.h \
-  $(SOPHYAINCP)basarr.h \
-  $(SOPHYAINCP)ndatablock.h \
-  $(SOPHYAINCP)utilarr.h \
-  $(SOPHYAINCP)tmatrix_tsnl.h \
-  $(SOPHYAINCP)tvector_tsnl.h \
-  $(SOPHYAINCP)spherehealpix.h \
-  $(SOPHYAINCP)HEALPixUtils.h \
-  $(SOPHYAINCP)localmap.h \
-  $(SOPHYAINCP)sphereecp.h \
-  $(SOPHYAINCP)fiospherethetaphi.h \
-  $(SOPHYAINCP)fiospherehealpix.h \
-  $(SOPHYAINCP)fiolocalmap.h \
-  $(SOPHYAINCP)fiosphereecp.h \
-  $(SOPHYAINCP)tod.h \
-  $(SOPHYAINCP)misstime.h \
-  $(SOPHYAINCP)timing.h
-	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tspm.cc
- 
 $(SOPHYAOBJP)tstboloread.o: tstboloread.cc \
   $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)fboloread.h \
@@ -1265,4 +1359,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1284,4 +1379,5 @@
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)fabtcolread.h \
@@ -1295,4 +1391,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1309,6 +1406,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstcolread.cc
  
-$(SOPHYAOBJP)tstdtable.o: tstdtable.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tstdtable.o: tstdtable.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -1332,4 +1428,5 @@
   $(SOPHYAINCP)timestamp.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)tmatrix.h \
@@ -1346,10 +1443,10 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstdtable.cc
  
-$(SOPHYAOBJP)tstndblk.o: tstndblk.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)ntoolsinit.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tstndblk.o: tstndblk.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)ntoolsinit.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)ndatablock.h \
@@ -1365,8 +1462,10 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)ppfwrapstlv.h \
   $(SOPHYAINCP)anydataobj.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1375,6 +1474,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstppfwrapstl.cc
  
-$(SOPHYAOBJP)tstsegdb.o: tstsegdb.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tstsegdb.o: tstsegdb.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
@@ -1383,7 +1481,10 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)segdatablock.h \
   $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)thsafeop.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)fiosegdb.h \
   $(SOPHYAINCP)ppersist.h \
@@ -1392,16 +1493,18 @@
   $(SOPHYAINCP)rawstream.h \
   $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)segdatablock.h \
   $(SOPHYAINCP)ppftpointerio.h \
   $(SOPHYAINCP)swsegdb.h \
   $(SOPHYAINCP)ppfswapper.h \
+  $(SOPHYAINCP)swsegdb.h \
   $(SOPHYAINCP)ppfwrapstlv.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstsegdb.cc
  
-$(SOPHYAOBJP)tsttmat.o: tsttmat.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)ntoolsinit.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tsttmat.o: tsttmat.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)ntoolsinit.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)array.h \
@@ -1413,4 +1516,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1430,6 +1534,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsttmat.cc
  
-$(SOPHYAOBJP)tsttminv.o: tsttminv.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tsttminv.o: tsttminv.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
@@ -1437,4 +1540,5 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)array.h \
@@ -1446,4 +1550,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1464,10 +1569,10 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsttminv.cc
  
-$(SOPHYAOBJP)tsttvec.o: tsttvec.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)ntoolsinit.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tsttvec.o: tsttvec.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)ntoolsinit.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)array.h \
@@ -1479,4 +1584,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1496,6 +1602,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsttvec.cc
  
-$(SOPHYAOBJP)tswfits.o: tswfits.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tswfits.o: tswfits.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -1517,5 +1622,7 @@
   $(SOPHYAINCP)swsegdb.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)fitsinoutfile.h \
+  $(SOPHYAINCP)dvlist.h \
   $(SOPHYAINCP)FitsIO/fitsio.h \
   $(SOPHYAINCP)FitsIO/longnam.h \
@@ -1533,5 +1640,9 @@
   $(SOPHYAINCP)fiosinit.h \
   $(SOPHYAINCP)swfitsdtable.h \
-  $(SOPHYAINCP)fitshandler.h
+  $(SOPHYAINCP)fitsswapper.h \
+  $(SOPHYAINCP)fitshandler.h \
+  $(SOPHYAINCP)datatable.h \
+  $(SOPHYAINCP)fitshdtable.h \
+  $(SOPHYAINCP)datatable.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tswfits.cc
  
@@ -1541,4 +1652,5 @@
   $(SOPHYAINCP)timing.h \
   $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)anydataobj.h \
@@ -1553,13 +1665,37 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)ppfwrapstlv.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ttimestamp.cc
  
-$(SOPHYAOBJP)zthr.o: zthr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)zthr.o: zthr.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)zthread.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
-  $(SOPHYAINCP)timing.h
+  $(SOPHYAINCP)resusage.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)matharr.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)timing.h \
+  $(SOPHYAINCP)ctimer.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  zthr.cc
  
Index: trunk/SophyaProg/Tests/programs
===================================================================
--- trunk/SophyaProg/Tests/programs	(revision 3389)
+++ trunk/SophyaProg/Tests/programs	(revision 3390)
@@ -39,2 +39,4 @@
 ttimestamp ttimestamp.o
 zthr zthr.o
+tmtrnd tmtrnd.o
+tmtrnd3 tmtrnd3.o
Index: trunk/SophyaProg/Tests/smakefile
===================================================================
--- trunk/SophyaProg/Tests/smakefile	(revision 3389)
+++ trunk/SophyaProg/Tests/smakefile	(revision 3390)
@@ -1,5 +1,5 @@
 include $(SOPHYABASE)/include/sophyamake.inc
  
-PROGS = $(SOPHYAEXEP)arrt $(SOPHYAEXEP)carrt $(SOPHYAEXEP)lpk $(SOPHYAEXEP)obj_fits $(SOPHYAEXEP)ovharr $(SOPHYAEXEP)pizthr $(SOPHYAEXEP)ppftswap $(SOPHYAEXEP)spar $(SOPHYAEXEP)sphg0 $(SOPHYAEXEP)sph2lm $(SOPHYAEXEP)tcmd $(SOPHYAEXEP)tcxxcmpldynl $(SOPHYAEXEP)tdcr $(SOPHYAEXEP)tdynl $(SOPHYAEXEP)tfft $(SOPHYAEXEP)thash $(SOPHYAEXEP)timg $(SOPHYAEXEP)tmxv $(SOPHYAEXEP)tnt $(SOPHYAEXEP)tobjio2 $(SOPHYAEXEP)tobjio $(SOPHYAEXEP)tpipe $(SOPHYAEXEP)tsimplex $(SOPHYAEXEP)tsphereecp $(SOPHYAEXEP)tspm2 $(SOPHYAEXEP)tspm $(SOPHYAEXEP)tstboloread $(SOPHYAEXEP)tstcolread $(SOPHYAEXEP)tstdtable $(SOPHYAEXEP)tstndblk $(SOPHYAEXEP)tstppfwrapstl $(SOPHYAEXEP)tstsegdb $(SOPHYAEXEP)tswfits $(SOPHYAEXEP)tnfits $(SOPHYAEXEP)tfitsdt $(SOPHYAEXEP)tsttmat $(SOPHYAEXEP)tsttminv $(SOPHYAEXEP)tsttvec $(SOPHYAEXEP)ttimestamp $(SOPHYAEXEP)zthr
+PROGS = $(SOPHYAEXEP)arrt $(SOPHYAEXEP)carrt $(SOPHYAEXEP)lpk $(SOPHYAEXEP)obj_fits $(SOPHYAEXEP)ovharr $(SOPHYAEXEP)pizthr $(SOPHYAEXEP)ppftswap $(SOPHYAEXEP)spar $(SOPHYAEXEP)sphg0 $(SOPHYAEXEP)sph2lm $(SOPHYAEXEP)tcmd $(SOPHYAEXEP)tcxxcmpldynl $(SOPHYAEXEP)tdcr $(SOPHYAEXEP)tdynl $(SOPHYAEXEP)tfft $(SOPHYAEXEP)thash $(SOPHYAEXEP)timg $(SOPHYAEXEP)tmxv $(SOPHYAEXEP)tnt $(SOPHYAEXEP)tobjio2 $(SOPHYAEXEP)tobjio $(SOPHYAEXEP)tpipe $(SOPHYAEXEP)tsimplex $(SOPHYAEXEP)tsphereecp $(SOPHYAEXEP)tspm2 $(SOPHYAEXEP)tspm $(SOPHYAEXEP)tstboloread $(SOPHYAEXEP)tstcolread $(SOPHYAEXEP)tstdtable $(SOPHYAEXEP)tstndblk $(SOPHYAEXEP)tstppfwrapstl $(SOPHYAEXEP)tstsegdb $(SOPHYAEXEP)tswfits $(SOPHYAEXEP)tnfits $(SOPHYAEXEP)tfitsdt $(SOPHYAEXEP)tsttmat $(SOPHYAEXEP)tsttminv $(SOPHYAEXEP)tsttvec $(SOPHYAEXEP)ttimestamp $(SOPHYAEXEP)zthr $(SOPHYAEXEP)tmtrnd $(SOPHYAEXEP)tmtrnd3
  
 all: $(PROGS)
@@ -7,5 +7,5 @@
 clean:
 	rm -f $(PROGS)
-	rm -f $(SOPHYAOBJP)zthr.o $(SOPHYAOBJP)ttimestamp.o $(SOPHYAOBJP)tsttvec.o $(SOPHYAOBJP)tsttminv.o $(SOPHYAOBJP)tsttmat.o $(SOPHYAOBJP)tfitsdt.o $(SOPHYAOBJP)tnfits.o $(SOPHYAOBJP)tswfits.o $(SOPHYAOBJP)tstsegdb.o $(SOPHYAOBJP)tstppfwrapstl.o $(SOPHYAOBJP)tstndblk.o $(SOPHYAOBJP)tstdtable.o $(SOPHYAOBJP)tstcolread.o $(SOPHYAOBJP)tstboloread.o $(SOPHYAOBJP)tspm.o $(SOPHYAOBJP)tspm2.o $(SOPHYAOBJP)tsphereecp.o $(SOPHYAOBJP)tsimplex.o $(SOPHYAOBJP)tpipe.o $(SOPHYAOBJP)tobjio.o $(SOPHYAOBJP)tobjio2.o $(SOPHYAOBJP)tnt.o $(SOPHYAOBJP)tmxv.o $(SOPHYAOBJP)timg.o $(SOPHYAOBJP)thash.o $(SOPHYAOBJP)tfft.o $(SOPHYAOBJP)tdynl.o $(SOPHYAOBJP)tdcr.o $(SOPHYAOBJP)tcxxcmpldynl.o $(SOPHYAOBJP)tcmd.o $(SOPHYAOBJP)sph2lm.o $(SOPHYAOBJP)sphg0.o $(SOPHYAOBJP)spar.o $(SOPHYAOBJP)ppftswap.o $(SOPHYAOBJP)pizthr.o $(SOPHYAOBJP)ovharr.o $(SOPHYAOBJP)obj_fits.o $(SOPHYAOBJP)lpk.o $(SOPHYAOBJP)carrt.o $(SOPHYAOBJP)arrt.o
+	rm -f $(SOPHYAOBJP)tmtrnd3.o $(SOPHYAOBJP)tmtrnd.o $(SOPHYAOBJP)zthr.o $(SOPHYAOBJP)ttimestamp.o $(SOPHYAOBJP)tsttvec.o $(SOPHYAOBJP)tsttminv.o $(SOPHYAOBJP)tsttmat.o $(SOPHYAOBJP)tfitsdt.o $(SOPHYAOBJP)tnfits.o $(SOPHYAOBJP)tswfits.o $(SOPHYAOBJP)tstsegdb.o $(SOPHYAOBJP)tstppfwrapstl.o $(SOPHYAOBJP)tstndblk.o $(SOPHYAOBJP)tstdtable.o $(SOPHYAOBJP)tstcolread.o $(SOPHYAOBJP)tstboloread.o $(SOPHYAOBJP)tspm.o $(SOPHYAOBJP)tspm2.o $(SOPHYAOBJP)tsphereecp.o $(SOPHYAOBJP)tsimplex.o $(SOPHYAOBJP)tpipe.o $(SOPHYAOBJP)tobjio.o $(SOPHYAOBJP)tobjio2.o $(SOPHYAOBJP)tnt.o $(SOPHYAOBJP)tmxv.o $(SOPHYAOBJP)timg.o $(SOPHYAOBJP)thash.o $(SOPHYAOBJP)tfft.o $(SOPHYAOBJP)tdynl.o $(SOPHYAOBJP)tdcr.o $(SOPHYAOBJP)tcxxcmpldynl.o $(SOPHYAOBJP)tcmd.o $(SOPHYAOBJP)sph2lm.o $(SOPHYAOBJP)sphg0.o $(SOPHYAOBJP)spar.o $(SOPHYAOBJP)ppftswap.o $(SOPHYAOBJP)pizthr.o $(SOPHYAOBJP)ovharr.o $(SOPHYAOBJP)obj_fits.o $(SOPHYAOBJP)lpk.o $(SOPHYAOBJP)carrt.o $(SOPHYAOBJP)arrt.o
  
 arrt: $(SOPHYAEXEP)arrt
@@ -209,9 +209,19 @@
 	$(CXXLINK) $(CXXTEMPFLG) -o $@ $(SOPHYAOBJP)zthr.o $(SOPHYAALLSLBLIST)
  
-$(SOPHYAOBJP)arrt.o: arrt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+tmtrnd: $(SOPHYAEXEP)tmtrnd
+	echo $@ " done"
+$(SOPHYAEXEP)tmtrnd: $(SOPHYAOBJP)tmtrnd.o
+	$(CXXLINK) $(CXXTEMPFLG) -o $@ $(SOPHYAOBJP)tmtrnd.o $(SOPHYAALLSLBLIST)
+ 
+tmtrnd3: $(SOPHYAEXEP)tmtrnd3
+	echo $@ " done"
+$(SOPHYAEXEP)tmtrnd3: $(SOPHYAOBJP)tmtrnd3.o
+	$(CXXLINK) $(CXXTEMPFLG) -o $@ $(SOPHYAOBJP)tmtrnd3.o $(SOPHYAALLSLBLIST)
+ 
+$(SOPHYAOBJP)arrt.o: arrt.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -240,9 +250,9 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  arrt.cc
  
-$(SOPHYAOBJP)carrt.o: carrt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)carrt.o: carrt.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -271,8 +281,8 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  carrt.cc
  
-$(SOPHYAOBJP)lpk.o: lpk.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)lpk.o: lpk.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -304,6 +314,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  lpk.cc
  
-$(SOPHYAOBJP)obj_fits.o: obj_fits.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)obj_fits.o: obj_fits.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -324,6 +333,8 @@
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
+  $(SOPHYAINCP)dvlist.h \
   $(SOPHYAINCP)xntuple.h \
   $(SOPHYAINCP)fitsxntuple.h \
+  $(SOPHYAINCP)xntuple.h \
   $(SOPHYAINCP)fitsfile.h \
   $(SOPHYAINCP)ndatablock.h \
@@ -333,4 +344,5 @@
   $(SOPHYAINCP)fitshandler.h \
   $(SOPHYAINCP)fitsntuple.h \
+  $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)fitstarray.h \
   $(SOPHYAINCP)tarray.h \
@@ -347,9 +359,9 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  obj_fits.cc
  
-$(SOPHYAOBJP)ovharr.o: ovharr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)ovharr.o: ovharr.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -380,8 +392,8 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ovharr.cc
  
-$(SOPHYAOBJP)pizthr.o: pizthr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)pizthr.o: pizthr.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)zthread.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)pisysdep.h \
@@ -389,4 +401,5 @@
   $(SOPHYAINCP)piapplgen.h \
   $(SOPHYAINCP)pimsghandler.h \
+  $(SOPHYAINCP)pisysdep.h \
   $(SOPHYAINCP)picontainerx.h \
   $(SOPHYAINCP)picontainergen.h \
@@ -416,8 +429,11 @@
   $(SOPHYAINCP)psfile.h \
   $(SOPHYAINCP)pigraphps.h \
+  $(SOPHYAINCP)pimenux.h \
+  $(SOPHYAINCP)pistdwdgx.h \
   $(SOPHYAINCP)piwindowx.h \
   $(SOPHYAINCP)piwindowgen.h \
   $(SOPHYAINCP)piperiodx.h \
   $(SOPHYAINCP)periodic.h \
+  $(SOPHYAINCP)picons.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -447,6 +463,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pizthr.cc
  
-$(SOPHYAOBJP)ppftswap.o: ppftswap.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)ppftswap.o: ppftswap.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)sophyainit.h \
   $(SOPHYAINCP)machdefs.h \
@@ -475,12 +490,14 @@
   $(SOPHYAINCP)sopemtx.h \
   $(SOPHYAINCP)fiondblock.h \
-  $(SOPHYAINCP)tarrinit.h
+  $(SOPHYAINCP)fioarr.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppftswap.cc
  
-$(SOPHYAOBJP)spar.o: spar.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)spar.o: spar.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -510,6 +527,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  spar.cc
  
-$(SOPHYAOBJP)sph2lm.o: sph2lm.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)sph2lm.o: sph2lm.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)tarray.h \
   $(SOPHYAINCP)machdefs.h \
@@ -530,4 +546,5 @@
   $(SOPHYAINCP)cimage.h \
   $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
   $(SOPHYAINCP)tmatrix_tsnl.h \
   $(SOPHYAINCP)fioarr.h \
@@ -564,6 +581,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  sph2lm.cc
  
-$(SOPHYAOBJP)sphg0.o: sphg0.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)sphg0.o: sphg0.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)sambainit.h \
   $(SOPHYAINCP)skymapinit.h \
@@ -606,8 +622,8 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  sphg0.cc
  
-$(SOPHYAOBJP)tcmd.o: tcmd.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tcmd.o: tcmd.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
   $(SOPHYAINCP)cexpre.h \
@@ -664,6 +680,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tcxxcmpldynl.cc
  
-$(SOPHYAOBJP)tdcr.o: tdcr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tdcr.o: tdcr.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -696,10 +711,11 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)histos2.h \
+  $(SOPHYAINCP)histos.h \
   $(SOPHYAINCP)psighand.h \
+  $(SOPHYAINCP)fmath.h \
   $(SOPHYAINCP)srandgen.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tdcr.cc
  
-$(SOPHYAOBJP)tdynl.o: tdynl.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tdynl.o: tdynl.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -729,11 +745,12 @@
   $(SOPHYAINCP)sopemtx.h \
   $(SOPHYAINCP)pdlmgr.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)timing.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tdynl.cc
  
-$(SOPHYAOBJP)tfft.o: tfft.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tfft.o: tfft.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)matharr.h \
   $(SOPHYAINCP)tarray.h \
@@ -759,4 +776,5 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)fftmserver.h \
+  $(SOPHYAINCP)fftmayer.h \
   $(SOPHYAINCP)fftwserver.h \
   $(SOPHYAINCP)sspvflags.h \
@@ -767,6 +785,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tfft.cc
  
-$(SOPHYAOBJP)tfitsdt.o: tfitsdt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tfitsdt.o: tfitsdt.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -789,4 +806,5 @@
   $(SOPHYAINCP)timestamp.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)tmatrix.h \
@@ -798,4 +816,5 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)fitshdtable.h \
+  $(SOPHYAINCP)datatable.h \
   $(SOPHYAINCP)fitshandler.h \
   $(SOPHYAINCP)fitsinoutfile.h \
@@ -808,17 +827,16 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tfitsdt.cc
  
-$(SOPHYAOBJP)thash.o: thash.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)ppersist.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)pexceptions.h \
-  $(SOPHYAINCP)gnumd5.h \
-  $(SOPHYAINCP)ppfbinstream.h \
-  $(SOPHYAINCP)rawstream.h \
-  $(SOPHYAINCP)ppfnametag.h
+$(SOPHYAOBJP)thash.o: thash.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)ppersist.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  thash.cc
  
-$(SOPHYAOBJP)timg.o: timg.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)timg.o: timg.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)ntoolsinit.h \
   $(SOPHYAINCP)tarrinit.h \
@@ -850,11 +868,79 @@
   $(SOPHYAINCP)cimage.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)ndatablock.h \
   $(SOPHYAINCP)fiondblock.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  timg.cc
  
-$(SOPHYAOBJP)tmxv.o: tmxv.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
+$(SOPHYAOBJP)tmtrnd.o: tmtrnd.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)zthread.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)resusage.h \
+  $(SOPHYAINCP)ctimer.h \
+  $(SOPHYAINCP)timing.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)fioarr.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)matharr.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
   $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)stsrand.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tmtrnd.cc
+ 
+$(SOPHYAOBJP)tmtrnd3.o: tmtrnd3.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)zthread.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)matharr.h \
+  $(SOPHYAINCP)fioarr.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)nbtri.h \
+  $(SOPHYAINCP)timing.h \
+  $(SOPHYAINCP)stsrand.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tmtrnd3.cc
+ 
+$(SOPHYAOBJP)tmxv.o: tmxv.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
@@ -879,9 +965,9 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)sopemtx.h \
+  $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)timing.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tmxv.cc
  
-$(SOPHYAOBJP)tnfits.o: tnfits.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tnfits.o: tnfits.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
@@ -890,4 +976,5 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)tarray.h \
@@ -917,11 +1004,12 @@
   $(SOPHYAINCP)FitsIO/longnam.h \
   $(SOPHYAINCP)fitsblkrw.h \
+  $(SOPHYAINCP)fitsinoutfile.h \
   $(SOPHYAINCP)fitsarrhand.h \
   $(SOPHYAINCP)fitshandler.h \
+  $(SOPHYAINCP)fitsblkrw.h \
   $(SOPHYAINCP)fiosinit.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tnfits.cc
  
-$(SOPHYAOBJP)tnt.o: tnt.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tnt.o: tnt.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -942,8 +1030,10 @@
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
+  $(SOPHYAINCP)dvlist.h \
   $(SOPHYAINCP)xntuple.h \
   $(SOPHYAINCP)datatable.h \
   $(SOPHYAINCP)basedtable.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)tmatrix.h \
@@ -960,6 +1050,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tnt.cc
  
-$(SOPHYAOBJP)tobjio2.o: tobjio2.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tobjio.o: tobjio.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -992,11 +1081,13 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)histos2.h \
+  $(SOPHYAINCP)histos.h \
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
-  $(SOPHYAINCP)srandgen.h
-	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio2.cc
- 
-$(SOPHYAOBJP)tobjio.o: tobjio.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)fmath.h \
+  $(SOPHYAINCP)srandgen.h \
+  $(SOPHYAINCP)fioarr.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio.cc
+ 
+$(SOPHYAOBJP)tobjio2.o: tobjio2.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -1029,12 +1120,13 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)histos2.h \
+  $(SOPHYAINCP)histos.h \
   $(SOPHYAINCP)ntuple.h \
   $(SOPHYAINCP)ntupintf.h \
-  $(SOPHYAINCP)srandgen.h \
-  $(SOPHYAINCP)fioarr.h
-	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio.cc
- 
-$(SOPHYAOBJP)tpipe.o: tpipe.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)fmath.h \
+  $(SOPHYAINCP)srandgen.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tobjio2.cc
+ 
+$(SOPHYAOBJP)tpipe.o: tpipe.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)zthread.h \
   $(SOPHYAINCP)machdefs.h \
@@ -1043,6 +1135,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tpipe.cc
  
-$(SOPHYAOBJP)tsimplex.o: tsimplex.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tsimplex.o: tsimplex.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)simplex.h \
   $(SOPHYAINCP)machdefs.h \
@@ -1074,8 +1165,10 @@
   $(SOPHYAINCP)perrors.h \
   $(SOPHYAINCP)fmath.h \
+  $(SOPHYAINCP)generalfunc.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)timing.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsimplex.cc
@@ -1096,4 +1189,5 @@
   $(SOPHYAINCP)pixelmap.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1120,4 +1214,5 @@
   $(SOPHYAINCP)tvector_tsnl.h \
   $(SOPHYAINCP)fiosphereecp.h \
+  $(SOPHYAINCP)sphereecp.h \
   $(SOPHYAINCP)array.h \
   $(SOPHYAINCP)matharr.h \
@@ -1143,6 +1238,52 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsphereecp.cc
  
-$(SOPHYAOBJP)tspm2.o: tspm2.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tspm.o: tspm.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)skymapinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)skymap.h \
+  $(SOPHYAINCP)spherethetaphi.h \
+  $(SOPHYAINCP)sphericalmap.h \
+  $(SOPHYAINCP)smathconst.h \
+  $(SOPHYAINCP)pixelmap.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)spherepos.h \
+  $(SOPHYAINCP)unitvector.h \
+  $(SOPHYAINCP)vector3d.h \
+  $(SOPHYAINCP)longlat.h \
+  $(SOPHYAINCP)utilgeom.h \
+  $(SOPHYAINCP)datatype.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)spherehealpix.h \
+  $(SOPHYAINCP)HEALPixUtils.h \
+  $(SOPHYAINCP)localmap.h \
+  $(SOPHYAINCP)sphereecp.h \
+  $(SOPHYAINCP)fiospherethetaphi.h \
+  $(SOPHYAINCP)fiospherehealpix.h \
+  $(SOPHYAINCP)fiolocalmap.h \
+  $(SOPHYAINCP)fiosphereecp.h \
+  $(SOPHYAINCP)tod.h \
+  $(SOPHYAINCP)misstime.h \
+  $(SOPHYAINCP)timing.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tspm.cc
+ 
+$(SOPHYAOBJP)tspm2.o: tspm2.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)sambainit.h \
   $(SOPHYAINCP)skymapinit.h \
@@ -1202,56 +1343,9 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tspm2.cc
  
-$(SOPHYAOBJP)tspm.o: tspm.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)skymapinit.h \
-  $(SOPHYAINCP)sophyainit.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)skymap.h \
-  $(SOPHYAINCP)spherethetaphi.h \
-  $(SOPHYAINCP)sphericalmap.h \
-  $(SOPHYAINCP)smathconst.h \
-  $(SOPHYAINCP)pixelmap.h \
-  $(SOPHYAINCP)ppersist.h \
-  $(SOPHYAINCP)pexceptions.h \
-  $(SOPHYAINCP)gnumd5.h \
-  $(SOPHYAINCP)ppfbinstream.h \
-  $(SOPHYAINCP)rawstream.h \
-  $(SOPHYAINCP)ppfnametag.h \
-  $(SOPHYAINCP)dvlist.h \
-  $(SOPHYAINCP)objfio.h \
-  $(SOPHYAINCP)anydataobj.h \
-  $(SOPHYAINCP)mutyv.h \
-  $(SOPHYAINCP)timestamp.h \
-  $(SOPHYAINCP)spherepos.h \
-  $(SOPHYAINCP)unitvector.h \
-  $(SOPHYAINCP)vector3d.h \
-  $(SOPHYAINCP)longlat.h \
-  $(SOPHYAINCP)utilgeom.h \
-  $(SOPHYAINCP)datatype.h \
-  $(SOPHYAINCP)tvector.h \
-  $(SOPHYAINCP)tmatrix.h \
-  $(SOPHYAINCP)tarray.h \
-  $(SOPHYAINCP)basarr.h \
-  $(SOPHYAINCP)ndatablock.h \
-  $(SOPHYAINCP)utilarr.h \
-  $(SOPHYAINCP)tmatrix_tsnl.h \
-  $(SOPHYAINCP)tvector_tsnl.h \
-  $(SOPHYAINCP)spherehealpix.h \
-  $(SOPHYAINCP)HEALPixUtils.h \
-  $(SOPHYAINCP)localmap.h \
-  $(SOPHYAINCP)sphereecp.h \
-  $(SOPHYAINCP)fiospherethetaphi.h \
-  $(SOPHYAINCP)fiospherehealpix.h \
-  $(SOPHYAINCP)fiolocalmap.h \
-  $(SOPHYAINCP)fiosphereecp.h \
-  $(SOPHYAINCP)tod.h \
-  $(SOPHYAINCP)misstime.h \
-  $(SOPHYAINCP)timing.h
-	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tspm.cc
- 
 $(SOPHYAOBJP)tstboloread.o: tstboloread.cc \
   $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)fboloread.h \
@@ -1265,4 +1359,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1284,4 +1379,5 @@
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)fabtcolread.h \
@@ -1295,4 +1391,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1309,6 +1406,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstcolread.cc
  
-$(SOPHYAOBJP)tstdtable.o: tstdtable.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tstdtable.o: tstdtable.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -1332,4 +1428,5 @@
   $(SOPHYAINCP)timestamp.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)tvector.h \
   $(SOPHYAINCP)tmatrix.h \
@@ -1346,10 +1443,10 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstdtable.cc
  
-$(SOPHYAOBJP)tstndblk.o: tstndblk.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)ntoolsinit.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tstndblk.o: tstndblk.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)ntoolsinit.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)ndatablock.h \
@@ -1365,8 +1462,10 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)ppfwrapstlv.h \
   $(SOPHYAINCP)anydataobj.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1375,6 +1474,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstppfwrapstl.cc
  
-$(SOPHYAOBJP)tstsegdb.o: tstsegdb.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tstsegdb.o: tstsegdb.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
@@ -1383,7 +1481,10 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)segdatablock.h \
   $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)thsafeop.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)fiosegdb.h \
   $(SOPHYAINCP)ppersist.h \
@@ -1392,16 +1493,18 @@
   $(SOPHYAINCP)rawstream.h \
   $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)segdatablock.h \
   $(SOPHYAINCP)ppftpointerio.h \
   $(SOPHYAINCP)swsegdb.h \
   $(SOPHYAINCP)ppfswapper.h \
+  $(SOPHYAINCP)swsegdb.h \
   $(SOPHYAINCP)ppfwrapstlv.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tstsegdb.cc
  
-$(SOPHYAOBJP)tsttmat.o: tsttmat.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)ntoolsinit.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tsttmat.o: tsttmat.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)ntoolsinit.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)array.h \
@@ -1413,4 +1516,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1430,6 +1534,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsttmat.cc
  
-$(SOPHYAOBJP)tsttminv.o: tsttminv.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tsttminv.o: tsttminv.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)timing.h \
@@ -1437,4 +1540,5 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)array.h \
@@ -1446,4 +1550,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1464,10 +1569,10 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsttminv.cc
  
-$(SOPHYAOBJP)tsttvec.o: tsttvec.cc \
-  $(SOPHYAINCP)sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  $(SOPHYAINCP)ntoolsinit.h \
-  $(SOPHYAINCP)tarrinit.h \
-  $(SOPHYAINCP)sophyainit.h \
+$(SOPHYAOBJP)tsttvec.o: tsttvec.cc $(SOPHYAINCP)sopnamsp.h \
+  $(SOPHYAINCP)machdefs.h \
+  $(SOPHYAINCP)ntoolsinit.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)array.h \
@@ -1479,4 +1584,5 @@
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)gnumd5.h \
   $(SOPHYAINCP)ppfbinstream.h \
@@ -1496,6 +1602,5 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsttvec.cc
  
-$(SOPHYAOBJP)tswfits.o: tswfits.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)tswfits.o: tswfits.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)histinit.h \
   $(SOPHYAINCP)ntoolsinit.h \
@@ -1517,5 +1622,7 @@
   $(SOPHYAINCP)swsegdb.h \
   $(SOPHYAINCP)segdatablock.h \
+  $(SOPHYAINCP)thsafeop.h \
   $(SOPHYAINCP)fitsinoutfile.h \
+  $(SOPHYAINCP)dvlist.h \
   $(SOPHYAINCP)FitsIO/fitsio.h \
   $(SOPHYAINCP)FitsIO/longnam.h \
@@ -1533,5 +1640,9 @@
   $(SOPHYAINCP)fiosinit.h \
   $(SOPHYAINCP)swfitsdtable.h \
-  $(SOPHYAINCP)fitshandler.h
+  $(SOPHYAINCP)fitsswapper.h \
+  $(SOPHYAINCP)fitshandler.h \
+  $(SOPHYAINCP)datatable.h \
+  $(SOPHYAINCP)fitshdtable.h \
+  $(SOPHYAINCP)datatable.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tswfits.cc
  
@@ -1541,4 +1652,5 @@
   $(SOPHYAINCP)timing.h \
   $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)objfio.h \
   $(SOPHYAINCP)anydataobj.h \
@@ -1553,13 +1665,37 @@
   $(SOPHYAINCP)tarrinit.h \
   $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)pexceptions.h \
   $(SOPHYAINCP)ppfwrapstlv.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ttimestamp.cc
  
-$(SOPHYAOBJP)zthr.o: zthr.cc \
-  $(SOPHYAINCP)sopnamsp.h \
+$(SOPHYAOBJP)zthr.o: zthr.cc $(SOPHYAINCP)sopnamsp.h \
   $(SOPHYAINCP)zthread.h \
   $(SOPHYAINCP)machdefs.h \
   $(SOPHYAINCP)pexceptions.h \
-  $(SOPHYAINCP)timing.h
+  $(SOPHYAINCP)resusage.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tarray.h \
+  $(SOPHYAINCP)basarr.h \
+  $(SOPHYAINCP)anydataobj.h \
+  $(SOPHYAINCP)mutyv.h \
+  $(SOPHYAINCP)timestamp.h \
+  $(SOPHYAINCP)objfio.h \
+  $(SOPHYAINCP)ppersist.h \
+  $(SOPHYAINCP)gnumd5.h \
+  $(SOPHYAINCP)ppfbinstream.h \
+  $(SOPHYAINCP)rawstream.h \
+  $(SOPHYAINCP)ppfnametag.h \
+  $(SOPHYAINCP)dvlist.h \
+  $(SOPHYAINCP)ndatablock.h \
+  $(SOPHYAINCP)utilarr.h \
+  $(SOPHYAINCP)tmatrix_tsnl.h \
+  $(SOPHYAINCP)tvector.h \
+  $(SOPHYAINCP)tmatrix.h \
+  $(SOPHYAINCP)tvector_tsnl.h \
+  $(SOPHYAINCP)matharr.h \
+  $(SOPHYAINCP)tarrinit.h \
+  $(SOPHYAINCP)sophyainit.h \
+  $(SOPHYAINCP)timing.h \
+  $(SOPHYAINCP)ctimer.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  zthr.cc
  
Index: trunk/SophyaProg/Tests/tmtrnd.cc
===================================================================
--- trunk/SophyaProg/Tests/tmtrnd.cc	(revision 3390)
+++ trunk/SophyaProg/Tests/tmtrnd.cc	(revision 3390)
@@ -0,0 +1,243 @@
+#include "sopnamsp.h"
+#include "zthread.h"
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string>
+#include <iostream>
+
+#include "tvector.h"
+#include "fioarr.h"
+#include "matharr.h"
+#include "tarrinit.h"
+
+#include "srandgen.h"
+#include "stsrand.h"
+
+//--------------------------------------------------------------------------------
+// Programme d'exemple multi-threads et test de la classe de generateur aleatoire
+//   R. Ansari - C. Magneville  ,   Novembre 2007
+//   (C) UPS+LAL IN2P3/CNRS   (C) DAPNIA/SPP  CEA  - 2007
+// Exemples de commandes pour test (dans l'ordre ci-dessous :
+// csh> tmtrnd OCG 1000000 XXX
+// csh> tmtrnd STG 1000000 1024
+// csh> tmtrnd RDG 1000000 rg1.ppf
+// csh> tmtrnd MTG 3000000 4 
+//--------------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------------
+// Definition d'une classe heritant de ZThread, pour remplir un vecteur avec 
+// des aleatoires
+class MTRnd : public ZThread {
+public:
+  MTRnd(TVector<r_8>& v, bool fgg=true);
+  virtual void run(); 
+protected:
+  string nom_;
+  TVector<r_8> vv_;
+  bool fgg_; // true -> gaussien, false rand01() 
+};
+
+static int mtrandId = 0;  // Pour donner un identificateur a chaque thread
+
+MTRnd::MTRnd(Vector& v, bool fgg)
+  : vv_(v,true), fgg_(fgg)  // Partage de reference du vecteur 
+{
+  char buff[32];
+  sprintf(buff, "MTRnd-Id=%d", mtrandId);
+  mtrandId++;
+  nom_ = buff;
+  cout << " Thread MTRnd(" << nom_ << " ) Created ... " << endl;
+}
+
+
+// Le travail fait dans chaque thread (appele par start())
+void MTRnd::run()
+{
+  Timer tm(nom_.c_str());
+  cout << "MTRnd::run() - Nom= " << nom_ << " vv.Size()= " << vv_.Size() << endl;
+  RandomGenerator rgen;
+  if (fgg_) 
+    for(sa_size_t k=0; k<vv_.Size(); k++) vv_(k) = rgen.Gaussian();
+  else
+    for(sa_size_t k=0; k<vv_.Size(); k++) vv_(k) = rgen.Flat01();
+}
+// ----- Fin de la definition de la classe MTRnd ----
+//---------------------------------------------------------------------------------
+
+//----------------- Les fonction de test -----------------
+//------- f0_tmtrnd()
+int f0_tmtrnd(sa_size_t VSZ, bool fgg=true)
+{
+  cout << "[1] f0_tmtrnd/starting, VSZ= " << VSZ << endl;
+  TVector<r_8> DATA(VSZ);
+  {
+    Timer tm("f0_tmtrnd-GauRnd/drand01");
+    if (fgg) 
+      for(sa_size_t k=0; k<VSZ; k++)  DATA(k) = GauRnd(0., 1.);
+    else 
+      for(sa_size_t k=0; k<VSZ; k++)  DATA(k) = drand01();
+    cout << "[2] f0_tmtrnd/ End of random generation using GauRnd()/drand01() " << endl;
+  }
+  POutPersist po("data0.ppf");
+  po << DATA;
+  cout << "[3] f0_tmtrnd/  DATA saved to file data0.ppf " << endl;
+  return 0; 
+}
+//------- f1_tmtrnd()
+int f1_tmtrnd(sa_size_t VSZ, size_t seqsz, bool fgg=true)
+{
+  cout << "[1] f1_tmtrnd/starting, VSZ= " << VSZ << " SeqSz=" << seqsz << endl;
+  TVector<r_8> DATA(VSZ);
+  RandomGenerator rg(seqsz, (seqsz==0)?false:true);  
+  unsigned short seed[3];
+  rg.GetSeed(seed, 2);  // pour imprimer l'etat du generateur
+  {
+    Timer tm("f0_tmtrnd-GauRnd/drand01");
+    if (fgg) 
+      for(sa_size_t k=0; k<VSZ; k++)  DATA(k) = rg.Gaussian();
+    else 
+      for(sa_size_t k=0; k<VSZ; k++)  DATA(k) = rg.Flat01();
+    cout << "[2] f1_tmtrnd/ End of random generation using RandomGen class " << endl;
+  }
+  POutPersist po("data1.ppf");
+  po << DATA;
+  cout << "[3] f1_tmtrnd/  DATA saved to file data1.ppf " << endl;
+  POutPersist porg("rg1.ppf");
+  porg << rg;
+  rg.GetSeed(seed, 2);  // pour imprimer l'etat du generateur
+  cout << "[4] f1_tmtrnd/  RandGen saved to file rg1.ppf " << endl;
+  return 0; 
+}
+//------- f2_tmtrnd()
+int f2_tmtrnd(sa_size_t VSZ, string & inppf, bool fgg=true)
+{
+  cout << "[1] f2_tmtrnd/starting, VSZ= " << VSZ << " InPPFName=" << inppf << endl;
+  TVector<r_8> DATA(VSZ);
+  RandomGenerator rg;
+  PInPersist pirg(inppf);
+  pirg >> rg;
+  cout << "[1.b] f2_tmtrnd/ RandGen read from InPPF OK " << endl;
+  unsigned short seed[3];
+  rg.GetSeed(seed, 2);  // pour imprimer l'etat du generateur
+  {
+    Timer tm("f0_tmtrnd-GauRnd/drand01");
+    if (fgg) 
+      for(sa_size_t k=0; k<VSZ; k++)  DATA(k) = rg.Gaussian();
+    else 
+      for(sa_size_t k=0; k<VSZ; k++)  DATA(k) = rg.Flat01();
+    cout << "[2] f1_tmtrnd/ End of random generation using RandomGen class " << endl;
+  }
+  POutPersist po("data2.ppf");
+  po << DATA;
+  cout << "[3] f1_tmtrnd/  DATA saved to file data2.ppf " << endl;
+  POutPersist porg("rg2.ppf");
+  porg << rg;
+  rg.GetSeed(seed, 2);  // pour imprimer l'etat du generateur
+  cout << "[4] f1_tmtrnd/  RandGen saved to file rg2.ppf " << endl;
+  return 0; 
+}
+
+//------- f3_tmtrnd()
+int f3_tmtrnd(sa_size_t VSZ, int NTH, bool fgg=true) 
+{
+  cout << "[1] f3_tmtrnd/starting, VSZ= " << VSZ << " NTH= " << NTH << endl;
+  ResourceUsage res(ResourceUsage::RU_All);
+  vector<MTRnd *> vth;
+  TVector<r_8> DATA(VSZ);
+  sa_size_t csz = VSZ / NTH;
+  sa_size_t first, last;
+  cout << "[2] f3_tmtrnd/creating threads " << endl;
+  for(int kt=0; kt<NTH; kt++) {
+    first = kt*csz;
+    last = (kt == NTH-1) ? VSZ-1 : first+csz-1;
+    TVector<r_8> sv = DATA(Range(first, last));
+    vth.push_back(new MTRnd(sv, fgg) );
+  }
+  cout << "[3] f3_tmtrnd/starting threads " << endl;
+  for(int kt=0; kt<NTH; kt++)  vth[kt]->start();
+  
+  cout << "[4] f3_tmtrnd/waiting for all  threads to finish " << endl;
+  sleep(2);
+  for(int kt=0; kt<NTH; kt++)  vth[kt]->join();
+  
+  cout << "[5] f3_tmtrnd/deleting thread objects " << endl;
+  for(int kt=0; kt<NTH; kt++)  delete vth[kt];
+  
+  cout << "[6] f3_tmtrnd/saving DATA to file data3.ppf " << endl;
+  POutPersist po("data3.ppf");
+  po << DATA;
+  cout << res;
+  return 0;
+}
+//----------------- FIN des fonctions de test -----------------
+
+//-------------------------------------------------------------
+//---------------------- MAIN MAIN MAIN -----------------------
+//-------------------------------------------------------------
+
+int main(int narg, char *arg[])
+
+{
+  InitTim();
+  SophyaInit();
+
+  // Enregistrement des handlers PPF pour les RandomGenerator
+  PPRegister(ObjFileIO<RandomGenerator>);
+  DObjRegister(ObjFileIO<RandomGenerator>, RandomGenerator);
+
+  int rc = 0;
+  if (narg < 4) {
+    cout << " tmtrnd/Error args - Usage: tmtrnd SEL arg1 arg2 ... " << endl;
+    cout << "    ==> SEL=OCG/OCF : tmtrnd OCG/OCF VecSize XXX  (-> f0_tmtrnd())" << endl;
+    cout << "        OCG/OCF Random gen. with (old) c-functions G/F-> Gaussian/Flat " << endl;
+    cout << "    ==> SEL=STG/STF : tmtrnd STG/STF VecSize SeqSize  (-> f2_tmtrnd())" << endl;
+    cout << "        STG/STF RandGen(SeqSize) SeqSz=0 -> NO-ThSafe G/F-> Gaussian/Flat " << endl;
+    cout << "    ==> SEL=RDG/RDF : tmtrnd RDG/RDF VecSize InPPFName  (-> f2_tmtrnd())" << endl;
+    cout << "        RDG/RDF Read RandGen object from file InPPFName G/F-> Gaussian/Flat " << endl;
+    cout << "    ==> SEL=MTG/MTF : tmtrnd MTG/MTF VecSize NThread (-> f3_tmtrnd()) " << endl;
+    cout << "        MTG/MTF Multithread generation, MTG-> Gaussian, MTF-> Flat " << endl;
+    return 1;
+  }
+  string sel = arg[1];
+
+  try {
+    bool fgg = (sel[2]=='G')?true:false;
+    if ((sel == "OCG")||(sel == "OCF")) {
+      sa_size_t VSZ = atoi(arg[2]);
+      rc = f0_tmtrnd(VSZ, fgg);
+    }
+    if ((sel == "STG")||(sel == "STF")) {
+      sa_size_t VSZ = atoi(arg[2]);
+      size_t seqsz = atoi(arg[3]);
+      rc = f1_tmtrnd(VSZ, seqsz, fgg);
+    }
+    if ((sel == "RDG")||(sel == "RDF")) {
+      sa_size_t VSZ = atoi(arg[2]);
+      string inppf = arg[3];
+      rc = f2_tmtrnd(VSZ, inppf, fgg);
+    }
+    if ((sel == "MTG")||(sel == "MTF")) {
+      sa_size_t VSZ = atoi(arg[2]);
+      int NTH = atoi(arg[3]);
+      rc = f3_tmtrnd(VSZ, NTH, fgg);
+    }
+
+  }
+  catch (PThrowable exc) {
+    cerr << "zthr: catched Exception " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (...) {
+    cerr << " catched unknown (...) exception (tmtrnd.cc) " << endl; 
+    rc = 78; 
+  } 
+  cout << "----------- tmtrnd/END ------- " << endl;
+  PrtTim("---END tmtrnd---");
+  return(rc);
+  
+}
Index: trunk/SophyaProg/Tests/tmtrnd3.cc
===================================================================
--- trunk/SophyaProg/Tests/tmtrnd3.cc	(revision 3390)
+++ trunk/SophyaProg/Tests/tmtrnd3.cc	(revision 3390)
@@ -0,0 +1,330 @@
+// Test des operations de tirages aleatoires thread safe/nosafe
+#include "sopnamsp.h"
+#include "zthread.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string>
+#include <iostream>
+
+#include "tvector.h"
+#include "matharr.h"
+#include "fioarr.h"
+#include "tarrinit.h"
+#include "srandgen.h"
+#include "nbtri.h"
+#include "timing.h"
+
+#include "stsrand.h"
+
+long Check_Redondances(TVector<r_8>& v);
+
+//---------------------------------------------------------------------
+// Classe heritant de ZThread, pour remplir un vecteur avec des aleatoires
+class MTRndTest : public ZThread {
+public:
+  MTRndTest(TVector<r_8>& v,bool thsafe=true,int nbuff=1024);
+  virtual void run(); 
+protected:
+  string nom_; int inum_;
+  TVector<r_8> vv_;
+  bool thsafe_;
+  int nbuff_;
+};
+
+static int mtrandId = 0;  // Pour donner un identificateur a chaque thread
+
+MTRndTest::MTRndTest(Vector& v,bool thsafe,int nbuff)
+  : vv_(v,true) , thsafe_(thsafe), nbuff_(nbuff)
+{
+  if(nbuff_<=0) nbuff_ = 1024;
+  char buff[32];
+  inum_ = mtrandId;
+  sprintf(buff,"MTRndTest-Id=%d",mtrandId);
+  mtrandId++;
+  nom_ = buff;
+  cout<<"Thread MTRndTest("<<nom_<<" ) Created ... with threadsafe="<<thsafe_
+      <<", nbuff="<<nbuff_<<endl;
+}
+
+
+// Le travail fait dans chaque thread (appelle par start())
+void MTRndTest::run()
+{
+  cout<<"MTRndTest::run() - Nom= "<<nom_<<" vv.Size()= "<<vv_.Size()
+      <<" with threadsafe="<<thsafe_<<endl;
+  if(thsafe_) {  // On appele RandomGenerator Thread-Safe
+    RandomGenerator rgen(nbuff_,true);
+    for(sa_size_t k=0; k<vv_.Size(); k++) vv_(k) = rgen.Flat01();
+  } else {  // On appele RandomGenerator NO Thread-Safe
+    // ATTENTION: le comportement est different selon qu'un thread
+    // se termine avant ou apres que le suivant commence:
+    // Pour de petits VSZ le run() du thread "n" se termine
+    // avant que le run() du thread "n+1" ne commence:
+    // cela donne un comportement "tread_safe" APPARENT mais
+    // dans la realite drand48() N'EST PAS thread_safe !!!!
+    RandomGenerator rgen(0,false);
+    for(sa_size_t k=0; k<vv_.Size(); k++) vv_(k) = rgen.Flat01();
+  }
+  cout<<"....MTRndTest::run() - "<<nom_<<" ENDED !!!!!!!!!"<<endl;
+}
+
+//---------------------------------------------------------------------
+int main(int narg, char *arg[])
+
+{
+  SophyaInit();
+
+  if(narg<3) {cout<<"usage: tmtrnd3 ntir nthreads [nbuff]"<<endl; return -1;}
+  sa_size_t VSZ = atoi(arg[1]);
+  int NTH = atoi(arg[2]);
+  int NBUFF = (narg>3) ? atoi(arg[3]): 64;
+  if(NTH<=0) NTH = 1;
+  cout<<"tmtrnd/arguments, VSZ= "<<VSZ<<" NTH= "<<NTH<<" NBUFF="<<NBUFF<<endl;
+  // Il ne faut pas que les buffers de RandomGenerator soient remplis
+  // au dela de ce qui est necessaire si on veut faire
+  // la comparaison avec le mono thread
+  int lmod = NTH*NBUFF;
+  if(VSZ<lmod) VSZ = lmod;
+  if(VSZ%lmod!=0) VSZ = int(VSZ/(double)lmod+0.5)*lmod;
+  cout<<"tmtrnd/starting, lmod="<<lmod<<" NTH= "<<NTH<<" -> changed VSZ= "<<VSZ<<endl;
+
+  int rc = 0;
+  sa_size_t csz = VSZ / NTH;
+  sa_size_t first, last;
+
+  try {
+
+    //---
+    //--- Init et set de l'aleatoire
+    //---
+    RandomGenerator rgen_nothsf(0,false);
+    unsigned short seed_16v[3];
+    {
+    cout<<"\n>>>>>>> Init de l'aleatoire"<<endl;
+    rgen_nothsf.AutoInit(5);
+    rgen_nothsf.GetSeed(seed_16v,5);
+    }
+
+    InitTim();
+
+    //---
+    //--- remplissage en mono-thread directement avec drand48
+    //---
+    TVector<r_8> DATA0(VSZ);
+    {
+    cout<<"\n>>>>>>> Remplissage en mono-thread avec drand48()"<<endl;
+    rgen_nothsf.Init(seed_16v,5);
+    for(int i=0;i<VSZ;i++) DATA0(i) = drand48();
+    PrtTim(" ");
+    }
+
+    //---
+    //--- Remplissage par threads avec RandomGenerator thread safe
+    //---
+    TVector<r_8> DATA1(VSZ);
+    {
+    cout<<"\n>>>>>>> Remplissage par threads avec RandomGenerator thread safe"<<endl;
+    rgen_nothsf.Init(seed_16v,5);
+    vector<MTRndTest *> vth1;
+    cout<<"...tmtrnd/creating threads "<<endl;
+    for(int kt=0; kt<NTH; kt++) {
+      first = kt*csz;
+      last = (kt == NTH-1) ? VSZ-1 : first+csz-1;
+      TVector<r_8> sv = DATA1(Range(first, last));
+      vth1.push_back(new MTRndTest(sv,true,NBUFF) );
+    }
+    cout<<"...tmtrnd/starting threads"<<endl;
+    for(int kt=0; kt<NTH; kt++)  vth1[kt]->start();
+    cout<<"...tmtrnd/waiting for all  threads to finish"<<endl;
+    sleep(2);
+    for(int kt=0; kt<NTH; kt++)  vth1[kt]->join();
+    cout<<"...tmtrnd/deleting thread objects"<<endl;
+    for(int kt=0; kt<NTH; kt++)  delete vth1[kt];
+    PrtTim(" ");
+    }
+
+    //---
+    //--- Remplissage par threads avec RandomGenerator SANS thread safe
+    //---
+    TVector<r_8> DATA2(VSZ);
+    {
+    cout<<"\n>>>>>>> Remplissage par threads avec RandomGenerator SANS thread safe"<<endl;
+    rgen_nothsf.Init(seed_16v,5);
+    vector<MTRndTest *> vth2;
+    cout << "......tmtrnd/creating threads " << endl;
+    for(int kt=0; kt<NTH; kt++) {
+      first = kt*csz;
+      last = (kt == NTH-1) ? VSZ-1 : first+csz-1;
+      TVector<r_8> sv = DATA2(Range(first, last));
+      vth2.push_back(new MTRndTest(sv,false) );
+    }
+    cout<<"......tmtrnd/starting threads"<<endl;
+    for(int kt=0; kt<NTH; kt++)  vth2[kt]->start();
+    cout<<"......tmtrnd/waiting for all  threads to finish"<<endl;
+    sleep(2);
+    for(int kt=0; kt<NTH; kt++)  vth2[kt]->join();
+    cout<<"......tmtrnd/deleting thread objects "<<endl;
+    for(int kt=0; kt<NTH; kt++)  delete vth2[kt];
+    PrtTim(" ");
+    }
+
+    //---
+    //--- remplissage en mono-thread avec RandomGenerator
+    //---
+    TVector<r_8> DATA0R(VSZ);
+    {
+    cout<<"\n>>>>>>> Remplissage en mono-thread avec RandomGenerator"<<endl;
+    rgen_nothsf.Init(seed_16v,5);
+    for(int i=0;i<VSZ;i++) DATA0R(i) = rgen_nothsf.Flat01();
+    PrtTim(" ");
+    }
+
+    //---
+    //--- checking
+    //---
+    cout<<"\n>>>>>>> Sorting"<<endl;
+    qsort(DATA0.Data(),(size_t)VSZ,sizeof(double),qSort_Dble);
+    qsort(DATA1.Data(),(size_t)VSZ,sizeof(double),qSort_Dble);
+    qsort(DATA2.Data(),(size_t)VSZ,sizeof(double),qSort_Dble);
+    qsort(DATA0R.Data(),(size_t)VSZ,sizeof(double),qSort_Dble);
+    PrtTim(" ");
+
+    cout<<"\n>>>>>>> Checking differences"<<endl;
+    double vmax00=0., vmax01=0., vmax02=0., vmax12=0.;
+    for(int i=0;i<VSZ;i++) {
+      double v;
+      v = fabs(DATA0R(i)-DATA0(i));
+      if(v>vmax00) vmax00 = v;
+      v = fabs(DATA1(i)-DATA0(i));
+      if(v>vmax01) vmax01 = v;
+      v = fabs(DATA2(i)-DATA0(i));
+      if(v>vmax02) vmax02 = v;
+      v = fabs(DATA2(i)-DATA1(i));
+      if(v>vmax12) vmax12 = v;
+    }
+    cout<<"vmax00 = "<<vmax00<<endl
+        <<"vmax01 = "<<vmax01<<endl
+        <<"vmax02 = "<<vmax02<<endl
+        <<"vmax12 = "<<vmax12<<endl;
+
+    
+    cout<<"\n>>>>>>> Checking redondances"<<endl;
+    cout<<"DATA0:"<<endl; Check_Redondances(DATA0);
+    cout<<"DATA1:"<<endl; Check_Redondances(DATA1);
+    cout<<"DATA2:"<<endl; Check_Redondances(DATA2);
+    cout<<"DATA0R:"<<endl; Check_Redondances(DATA0R);
+
+    //--- persisting
+    cout<<"\n>>>>>>> Writing to ppf"<<endl;
+    string tag;
+    POutPersist pos("tmtrnd3.ppf");
+    tag = "d0r"; pos.PutObject(DATA0R,tag);
+    tag = "d0"; pos.PutObject(DATA0,tag);
+    tag = "d1"; pos.PutObject(DATA1,tag);
+    tag = "d2"; pos.PutObject(DATA2,tag);
+
+    double eps = 1.e-25;
+    if(vmax00>eps || vmax01>eps) rc = 1;
+
+  }
+  catch (PThrowable exc) {
+    cerr<<"zthr: catched Exception "<<exc.Msg()<<endl;
+    rc = 77;
+  }  
+  catch (...) {
+    cerr<<"catched unknown (...) exception (lpk.cc)"<<endl; 
+    rc = 78; 
+  } 
+
+  cout<<"\n>>>>>>>  tmtrnd3/END"<<endl;
+
+  return(rc);
+}
+
+//---------------------------------------------------------------------
+long Check_Redondances(TVector<r_8>& v)
+// Recherche des aleatoire tires 2 fois
+// Le vecteur "v" doit deja etre trie par valeurs CROISSANTES
+{
+ int k=0;
+ double eps=1.e-25;
+ TVector<r_8> dd(v,false);
+ for(int i=dd.Size()-1;i>=1;i--) dd(i) -= dd(i-1);
+ dd(0) = 0.;
+ qsort(dd.Data(),(size_t)dd.Size(),sizeof(double),qSort_Dble);
+ for(int i=1;i<dd.Size();i++) if(fabs(dd(i))<eps) k++;
+ cout<<"Number of redondances pour v<"<<eps<<" : k="<<k<<endl;
+ return k;
+}
+
+/*
+delobjs *
+openppf tmtrnd3.ppf
+
+#------ les tableaux sont ranges par valeurs croissantes
+disp d0
+disp d0r "same"
+disp d1 "same red"
+disp d2 "same blue"
+
+
+#------
+newh1d hd0 0. 1. 1000
+n/proj hd0 d0.val
+newh1d hd1 0. 1. 1000
+n/proj hd1 d1.val
+newh1d hd2 0. 1. 1000
+n/proj hd2 d2.val
+
+disp hd0
+disp hd1 "same red"
+disp hd2 "same blue"
+
+#------ tableaux des differences / a la reference
+del d00 d10 d20 d21
+c++exec \
+TVector<r_8> d00(d0r,false); d00 -= d0; \
+TVector<r_8> d10(d1,false); d10 -= d0; \
+TVector<r_8> d20(d2,false); d20 -= d0; \
+TVector<r_8> d21(d2,false); d21 -= d1; \
+KeepObj(d00); KeepObj(d10); KeepObj(d20); KeepObj(d21); \
+cout<<"-- Fin"<<endl;
+
+# Doivent avoir min=max=0
+echo d00 min =  ${d00.min} , max =  ${d00.max}
+echo d10 min =  ${d10.min} , max =  ${d10.max}
+# Doivent avoir min!=0 et max!=0
+echo d20 min =  ${d20.min} , max =  ${d20.max}
+echo d21 min =  ${d21.min} , max =  ${d21.max}
+
+disp d00
+disp d10
+
+disp d20
+disp d21 "same red"
+
+#------ tableaux des redondances
+del dd1 dd2
+c++exec \
+TVector<r_8> dd1(d1,false); \
+for(int i=dd1.Size()-1;i>=1;i--) dd1(i) -= dd1(i-1); dd1(0) = 0.; \
+TVector<r_8> dd2(d2,false); \
+for(int i=dd2.Size()-1;i>=1;i--) dd2(i) -= dd2(i-1); dd2(0) = 0.; \
+qsort(dd1.Data(),(size_t)dd1.Size(),sizeof(double),qSort_Dble); \
+qsort(dd2.Data(),(size_t)dd2.Size(),sizeof(double),qSort_Dble); \
+double eps=1.e-25; \
+int k1=0; for(int i=1;i<dd1.Size();i++) if(fabs(dd1(i))<eps) k1++; \
+int k2=0; for(int i=1;i<dd2.Size();i++) if(fabs(dd2(i))<eps) k2++; \
+cout<<"Number of v<"<<eps<<" : k1="<<k1<<" , k2="<<k2<<endl; \
+KeepObj(dd1); KeepObj(dd2); \
+cout<<"-- Fin"<<endl;
+
+# Regarder pour les petites separations
+# dd1 ne doit pas avoir de redondance
+disp dd1
+# dd2 doit avoir des redondances
+disp dd2
+
+ */
