Index: /trunk/SophyaExt/FitsIOServer/fabtcolread.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 1656)
+++ /trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 1657)
@@ -98,11 +98,9 @@
  SetNulVal();
  SetDebug(lp);
- BuffLen = (blen<=0) ? 1: blen;
- BuffSens = bsens;
  NFitsRead = 0;
  FitsPtr = NULL;
  LineDeb = LineFin = -1;
  Buffer = NULL;
- NBuffer = 0;
+ ChangeBuffer(blen,bsens);
 
  //////////////////////////
@@ -112,5 +110,5 @@
  int sta=0;
  if(FitsFN.size() <= 0 ) {
-   IHdu = -1;
+   IHdu = -1; Delete();
    throw ParmError("FitsABTColRead::Init: Fits file name error\n");
  }
@@ -145,7 +143,6 @@
    }
  if(IHdu<=0 || IHdu>NHdu) {
-   IHdu = 0;
    cout<<"NO BINARY or ASCII hdu found"<<endl;
-   Delete();
+   IHdu = 0; Delete();
    throw TypeMismatchExc("FitsABTColRead::Init: NO BINARY or ASCII hdu found\n");
  }
@@ -230,7 +227,4 @@
        <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<endl;
 
- // Prepare buffer
- NBuffer = (BuffSens==0) ? BuffLen+1: BuffLen;
- Buffer = new double[NBuffer];
 }
 
@@ -246,17 +240,21 @@
 void FitsABTColRead::ChangeBuffer(long blen,long bsens)
 {
+ long oldnbuffer = NBuffer;
+
+ // Compute buffer caracteristics
  BuffLen = (blen<=0)? 1: blen;
  BuffSens = bsens;
-
- // De-allocate
- if(Buffer==NULL) return;
- delete [] Buffer; Buffer=NULL;
+ NBuffer = BuffLen;
+ if(bsens==0 && NBuffer%2==0) NBuffer++;
+
+ // De-allocate if necessary
+ if(Buffer!=NULL && oldnbuffer!=NBuffer)
+   {delete [] Buffer; Buffer=NULL;}
+
+ // Re-allocate
+ if(Buffer==NULL) Buffer = new double[NBuffer];
 
  // Tell program that nothing is into buffer
  LineDeb = LineFin = -1;
-
- // Re-allocate
- NBuffer = (BuffSens==0) ? BuffLen+1: BuffLen;
- Buffer = new double[NBuffer];
 }
 
@@ -264,6 +262,5 @@
 void FitsABTColRead::Delete()
 {
- if(Buffer==NULL) return;
- delete [] Buffer; Buffer=NULL;
+ if(Buffer!=NULL) {delete [] Buffer; Buffer=NULL;}
  LineDeb = LineFin = -1;
  int sta = 0;
@@ -279,5 +276,5 @@
   \endverbatim
 */
-r_8 FitsABTColRead::Read(long n)
+double FitsABTColRead::Read(long n)
 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
 // Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
@@ -288,5 +285,5 @@
 
  // Pas de bufferisation, on lit betement
- if(BuffLen==1) {
+ if(NBuffer==1) {
    NFitsRead++;
    fits_read_col_dbl(FitsPtr,ColNum+1,n+1,1,1,NulVal,Buffer,&anynul,&sta);
@@ -308,11 +305,11 @@
    if(BuffSens>0) { // Cas remplissage forward
      row1 = n+1;
-     row2 = row1+BuffLen-1; if(row2>NBline) row2 = NBline;
+     row2 = row1+NBuffer-1; if(row2>NBline) row2 = NBline;
    } else if(BuffSens<0) { // Cas remplissage backward
      row2 = n+1;
-     row1 = row2-BuffLen+1; if(row1<1) row1 = 1;
+     row1 = row2-NBuffer+1; if(row1<1) row1 = 1;
    } else { // Cas remplissage centre
-     row1 = n+1 - BuffLen/2; if(row1<1) row1 = 1;
-     row2 = n+1 + BuffLen/2; if(row2>NBline) row2 = NBline;
+     row1 = n+1 - NBuffer/2; if(row1<1) row1 = 1;
+     row2 = n+1 + NBuffer/2; if(row2>NBline) row2 = NBline;
    }
    nrow = row2 - row1 + 1;
@@ -339,5 +336,5 @@
   \endverbatim
 */
-void FitsABTColRead::Read(long n1,long n2,TVector<r_8>& data)
+void FitsABTColRead::Read(long n1,long n2,TVector<double>& data)
 {
  if(n1<0 || n1>=NBline || n2<0 || n2>=NBline || n1>n2)
Index: /trunk/SophyaExt/FitsIOServer/fabtcolread.h
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fabtcolread.h	(revision 1656)
+++ /trunk/SophyaExt/FitsIOServer/fabtcolread.h	(revision 1657)
@@ -30,11 +30,11 @@
   void ChangeBuffer(long blen=100,long bsens=1);
 
-  r_8 Read(long n);
-  void Read(long n1,long n2,TVector<r_8>& data);
+  double Read(long n);
+  void Read(long n1,long n2,TVector<double>& data);
 
   //! Set debug level
-  inline void    SetDebug(int lp=0) {DbgLevel = (uint_2) lp;}
+  inline void    SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
   //! Set null value to be return when reading null data (0=return the data)
-  inline void    SetNulVal(r_8 nulval=0.) {NulVal = nulval;}
+  inline void    SetNulVal(double nulval=0.) {NulVal = nulval;}
   //! Get the FITS file name
   inline string  GetFileName(void) {return FitsFN;}
@@ -59,5 +59,5 @@
   //! Get the columns fits tform that is read
   inline string  GetColTForm(void) {return ColTForm;}
-  //! Get the read buffer length
+  //! Get the read requested buffer length
   inline long    GetBLen(void) {return BuffLen;}
   //! Get the read buffer direction
@@ -67,6 +67,6 @@
   //! Print to stdout
   inline  void   Print(int lp=1) const {Print(cout,lp);}
-  //! Get the read buffer effective length
-  inline long    GetBufferLen(void) {return NBuffer;}
+  //! Get the read effective buffer length
+  inline long    GetNBuffer(void) {return NBuffer;}
   //! Get the read bufferpointer
   inline double* GetBuffer(void) {return Buffer;}
@@ -82,9 +82,9 @@
   long NBline;
 
-  r_8 NulVal;
-  uint_2 DbgLevel;
+  double NulVal;
+  unsigned short DbgLevel;
   long BuffLen, BuffSens;
 
-  uint_4 NFitsRead;
+  unsigned long NFitsRead;
   fitsfile *FitsPtr;
   long LineDeb, LineFin;
Index: /trunk/SophyaExt/FitsIOServer/fabtwriter.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fabtwriter.cc	(revision 1656)
+++ /trunk/SophyaExt/FitsIOServer/fabtwriter.cc	(revision 1657)
@@ -14,9 +14,9 @@
   FitsABTWriter fbtw("myfits.fits",BINARY_TBL,3);
   fbtw.SetExtName("MY_OWN_EXTENSION");
-  fbtw.AddCol("vars",TSHORT,"","km");      // col=0
-  fbtw.AddCol("vars2",TSHORT,"","km");     // col=1
-  fbtw.AddCol("varl",TLONG,"","Degre");    // col=2
-  fbtw.AddCol("varf",TFLOAT,"","");        // col=3
-  fbtw.AddCol("vard",TDOUBLE,"","arcmin"); // col=4
+  fbtw.AddCol("vars",TSHORT,"","km");       // col=0
+  fbtw.AddCol("vars2",TSHORT,"","km");      // col=1
+  fbtw.AddCol("varl",TINT32BIT,"","Degre"); // col=2
+  fbtw.AddCol("varf",TFLOAT,"","");         // col=3
+  fbtw.AddCol("vard",TDOUBLE,"","arcmin");  // col=4
   fbtw.SetDebug(3);
   for(long i=0;i<1000;i++) {
@@ -83,5 +83,5 @@
  }
 
- // create d'un Primary HDU */
+ // create d'un Primary HDU
  //long naxes[1] = {0};
  //if(fits_create_img(FitsPtr,BYTE_IMG,0,naxes,&sta)) {
@@ -105,5 +105,5 @@
   \verbatim
   label : column label
-  datatype : TSHORT TLONG TFLOAT or TDOUBLE
+  datatype : TSHORT TINT32BIT TFLOAT or TDOUBLE
   tform : fits tform definition
           (can be automatically set if BINARY_TBL and tform="")
@@ -117,5 +117,5 @@
     throw AllocationError("FitsABTWriter::addcol: table already created\n");
 
- if(  datatype!=TSHORT && datatype!=TLONG
+ if(  datatype!=TSHORT && datatype!=TINT32BIT
    && datatype!=TFLOAT && datatype!=TDOUBLE )
    throw ParmError("FitsABTWriter::addcol: datatype not allowed\n");
@@ -126,8 +126,8 @@
  if(HduType==BINARY_TBL && strlen(tform)<=0) {
    char str[16];
-   if(datatype==TSHORT)       strcpy(str,"1I");
-   else if(datatype==TLONG)   strcpy(str,"1J");
-   else if(datatype==TFLOAT)  strcpy(str,"1E");
-   else if(datatype==TDOUBLE) strcpy(str,"1D");
+   if(datatype==TSHORT)         strcpy(str,"1I");
+   else if(datatype==TINT32BIT) strcpy(str,"1J");
+   else if(datatype==TFLOAT)    strcpy(str,"1E");
+   else if(datatype==TDOUBLE)   strcpy(str,"1D");
    TForm.push_back(str);
  } else TForm.push_back(tform);
@@ -217,17 +217,17 @@
 {
   if(FirstTime) createtbl();
-  short x[1] = {val};
-  int sta=0;
-  if(fits_write_col(FitsPtr,TSHORT,col+1,row+1,1,1,x,&sta))
+  int sta=0;
+  if(fits_write_col(FitsPtr,TSHORT,col+1,row+1,1,1,&val,&sta))
     printerrorwrite("short",col,row,sta);
 }
 
 /*! Write long data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,long val)
-{
-  if(FirstTime) createtbl();
-  long x[1] = {val};
-  int sta=0;
-  if(fits_write_col(FitsPtr,TLONG,col+1,row+1,1,1,x,&sta))
+void FitsABTWriter::Write(int col,long row,int_4 val)
+{
+  if(FirstTime) createtbl();
+  int sta=0;
+  // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ?
+  int T = (sizeof(long)==4) ? TLONG: TINT;
+  if(fits_write_col(FitsPtr,T,col+1,row+1,1,1,&val,&sta))
     printerrorwrite("long",col,row,sta);
 }
@@ -237,7 +237,6 @@
 {
   if(FirstTime) createtbl();
-  float x[1] = {val};
-  int sta=0;
-  if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,1,x,&sta))
+  int sta=0;
+  if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,1,&val,&sta))
     printerrorwrite("float",col,row,sta);
 }
@@ -247,10 +246,55 @@
 {
   if(FirstTime) createtbl();
-  double x[1] = {val};
-  int sta=0;
-  if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,1,x,&sta))
+  int sta=0;
+  if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,1,&val,&sta))
     printerrorwrite("double",col,row,sta);
 }
 
+//////////////////////////////////////////////////////////////
+/*!
+  Write a vector of long data to FITS file.
+  \verbatim
+  col : column number [0,ncol[
+  row : starting row number    [0,nrow[
+  val : vector to be written
+  Return: number of the last written row (remember row=[0,nrow[)
+  \endverbatim
+*/
+/*! Write a vector of long data to FITS file (see below) */
+long FitsABTWriter::Write(int col,long row,TVector<int_4>& val)
+{
+  if(FirstTime) createtbl();
+  long nel = val.Size();
+  int sta=0;
+  // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ?
+  int T = (sizeof(long)==4) ? TLONG: TINT;
+  if(fits_write_col(FitsPtr,T,col+1,row+1,1,nel,val.Data(),&sta))
+    printerrorwrite("long",col,row,sta);
+  return row+nel;
+}
+
+/*! Write a vector of float data to FITS file (see below) */
+long FitsABTWriter::Write(int col,long row,TVector<float>&  val)
+{
+  if(FirstTime) createtbl();
+  long nel = val.Size();
+  int sta=0;
+  if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,nel,val.Data(),&sta))
+    printerrorwrite("float",col,row,sta);
+  return row+nel;
+}
+
+/*! Write a vector of double data to FITS file (see below) */
+long FitsABTWriter::Write(int col,long row,TVector<double>& val)
+{
+  if(FirstTime) createtbl();
+  long nel = val.Size();
+  int sta=0;
+  if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,nel,val.Data(),&sta))
+    printerrorwrite("double",col,row,sta);
+  return row+nel;
+}
+
+//////////////////////////////////////////////////////////////
 void FitsABTWriter::printerrorwrite(char* type,int col,long row,int sta)
 {
Index: /trunk/SophyaExt/FitsIOServer/fabtwriter.h
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 1656)
+++ /trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 1657)
@@ -37,12 +37,15 @@
   inline void SetExtName(char* extname="") {ExtName = extname;}
   //! Set debug level
-  inline void SetDebug(int lp=0) {DbgLevel = (uint_2) lp;}
+  inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 
-  void Write(int col,long row,short  val);
-  void Write(int col,long row,long   val);
-  void Write(int col,long row,float  val);
+  void Write(int col,long row,short val);
+  void Write(int col,long row,int_4 val);
+  void Write(int col,long row,float val);
   void Write(int col,long row,double val);
+  long Write(int col,long row,TVector<int_4>& val);
+  long Write(int col,long row,TVector<float>& val);
+  long Write(int col,long row,TVector<double>& val);
   //! Return the number of overflows managed by cfitsio
-  inline uint_4 GetNOverFlow(void) {return NOverFlow;}
+  inline unsigned long GetNOverFlow(void) {return NOverFlow;}
 
 protected:
@@ -56,5 +59,5 @@
   string FitsFN,ExtName;
   int HduType;
-  uint_2 DbgLevel;
+  unsigned short DbgLevel;
   fitsfile *FitsPtr;
   bool FirstTime;
@@ -63,5 +66,5 @@
   vector<string> TForm;
   vector<string> TUnit;
-  uint_4 NOverFlow;
+  unsigned long NOverFlow;
 };
 
