Index: trunk/SophyaExt/FitsIOServer/fabtcolread.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 3127)
+++ trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 3128)
@@ -209,4 +209,19 @@
  int sta=0; long val=0;
  if(fits_read_key(fitsptr,TLONG,keyname,&val,NULL,&sta))
+   printerror(sta);
+ return val;
+}
+
+/*!
+  Read a fitsheader key into long
+  \param fitsptr : cfitio pointer to Fits file
+  \param keyname : name of the key
+  \return value into long long
+*/
+LONGLONG FitsOpenFile::ReadKeyLL(fitsfile *fitsptr,char *keyname)
+{
+ if(keyname==NULL || fitsptr==NULL) return 0;
+ int sta=0; LONGLONG val=0;
+ if(fits_read_key(fitsptr,TLONGLONG,keyname,&val,NULL,&sta))
    printerror(sta);
  return val;
@@ -267,5 +282,5 @@
   fbt.Print(3);
   // Read element by element
-  for(long i=0;i<fbt.GetNbLine();i++) {
+  for(LONGLONG i=0;i<fbt.GetNbLine();i++) {
     double x = fbt.Read(i);
     double y = fbt2.Read(i);
@@ -274,5 +289,5 @@
   // Read into a vector
   TVector<double> data;
-  long n = fbt.Read(32,50,data);
+  LONGLONG n = fbt.Read(32,50,data);
     cout<<"Number of values read: "<<n<<endl;
   data.ReSize(100);
@@ -402,5 +417,5 @@
 
  // Get number of rows
- if(fits_get_num_rows(GetFitsPtr(),&NBline,&sta)) {
+ if(fits_get_num_rowsll(GetFitsPtr(),&NBline,&sta)) {
    FitsOpenFile::printerror(sta);
    throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of rows\n");
@@ -425,5 +440,5 @@
 
  // Get column type
- if(fits_get_coltype(GetFitsPtr(),ColNum+1,&ColTypeCode,NULL,NULL,&sta)) {
+ if(fits_get_coltypell(GetFitsPtr(),ColNum+1,&ColTypeCode,NULL,NULL,&sta)) {
    FitsOpenFile::printerror(sta);
    throw ParmError("FitsABTColRd::Init: Error getting column type\n");
@@ -436,12 +451,14 @@
  // Get column name back, tunit, tform
  char tunit[64], tform[64], tdisp[64];
- long repeat=0; double tscale=1., tzero=0.;
+ LONGLONG repeat=0; double tscale=1., tzero=0.;
  int rc=0;
  if(HDUType()==BINARY_TBL) {
-   fits_get_bcolparms(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
+   fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
                      ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);
  } else {
-   fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeat,tunit,tform
+   long repeatlng;
+   fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform
                      ,&tscale,&tzero,NULL,tdisp,&sta);
+   repeat = repeatlng;
  }
  if(rc) {
@@ -525,4 +542,14 @@
 {
  return FitsOpenFile::ReadKeyL(GetFitsPtr(),keyname);
+}
+
+/*!
+  Read a fitsheader key into long long
+  \param keyname : name of the key
+  \return value into long long
+*/
+LONGLONG FitsABTColRd::ReadKeyLL(char *keyname)
+{
+ return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname);
 }
 
@@ -549,5 +576,5 @@
   \endverbatim
 */
-double FitsABTColRd::Read(long n,bool usebuffer)
+double FitsABTColRd::Read(LONGLONG n,bool usebuffer)
 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
 // Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
@@ -581,5 +608,5 @@
  if(n<LineDeb || n>LineFin) {
    NFitsRead++;
-   long row1,row2,nrow;
+   LONGLONG row1,row2,nrow;
    if(BuffSens>0) { // Cas remplissage forward
      row1 = n+1;
@@ -640,5 +667,5 @@
   \endverbatim
 */
-long FitsABTColRd::Read(long n1,long n2,TVector<double>& data)
+LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<double>& data)
 {
  if(n1<0 || n1>=NBline)
@@ -649,8 +676,8 @@
  if(n2>=NBline) n2 = NBline-1;
 
- sa_size_t nread = n2-n1+1;
+ LONGLONG nread = n2-n1+1;
  if(data.Size()<nread) data.SetSize(nread);
 
- //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
+ //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i);
  int sta=0;
  fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
@@ -664,5 +691,5 @@
 
 /*! idem before but for TVector of float */
-long FitsABTColRd::Read(long n1,long n2,TVector<float>& data)
+LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<float>& data)
 {
  if(n1<0 || n1>=NBline)
@@ -673,8 +700,8 @@
  if(n2>=NBline) n2 = NBline-1;
 
- sa_size_t nread = n2-n1+1;
+ LONGLONG nread = n2-n1+1;
  if(data.Size()<nread) data.SetSize(nread);
 
- //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
+ //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i);
  int sta=0;
  fits_read_col(GetFitsPtr(),TFLOAT,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
@@ -688,5 +715,5 @@
 
 /*! idem before but for TVector of unsigned short */
-long FitsABTColRd::Read(long n1,long n2,TVector<uint_2>& data)
+LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data)
 {
  if(n1<0 || n1>=NBline)
@@ -697,5 +724,5 @@
  if(n2>=NBline) n2 = NBline-1;
 
- sa_size_t nread = n2-n1+1;
+ LONGLONG nread = n2-n1+1;
  if(data.Size()<nread) data.SetSize(nread);
 
@@ -711,5 +738,5 @@
 
 /*! idem before but for TVector of int_4 */
-long FitsABTColRd::Read(long n1,long n2,TVector<int_4>& data)
+LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
 {
  if(n1<0 || n1>=NBline)
@@ -720,8 +747,8 @@
  if(n2>=NBline) n2 = NBline-1;
 
- sa_size_t nread = n2-n1+1;
+ LONGLONG nread = n2-n1+1;
  if(data.Size()<nread) data.SetSize(nread);
 
- //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
+ //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i);
  int sta=0;
  int T = (sizeof(long)==4) ? TLONG: TINT;
@@ -736,5 +763,5 @@
 
 /*! idem before but for TVector of int_8 */
-long FitsABTColRd::Read(long n1,long n2,TVector<int_8>& data)
+LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data)
 {
 #ifdef TLONGLONG
@@ -746,5 +773,5 @@
  if(n2>=NBline) n2 = NBline-1;
 
- sa_size_t nread = n2-n1+1;
+ LONGLONG nread = n2-n1+1;
  if(data.Size()<nread) data.SetSize(nread);
 
@@ -773,7 +800,7 @@
   \return <0 means not found
 */
-long FitsABTColRd::FirstRow(double val1,double val2,long rowstart)
-{
- long row = -1;
+LONGLONG FitsABTColRd::FirstRow(double val1,double val2,LONGLONG rowstart)
+{
+ LONGLONG row = -1;
  if(NBline==0) return row;
  // Change buffer for efficiency
@@ -782,5 +809,5 @@
  if(rowstart<0) rowstart = 0;
  if(rowstart>=NBline) rowstart = NBline-1;
- for(long i=rowstart;i<NBline;i++) {
+ for(LONGLONG i=rowstart;i<NBline;i++) {
    double val = Read(i);
    if(val<val1 || val>val2) continue;
@@ -802,7 +829,7 @@
   \endverbatim
 */
-long FitsABTColRd::LastRow(double val1,double val2,long rowstart)
-{
- long row = -1;
+LONGLONG FitsABTColRd::LastRow(double val1,double val2,LONGLONG rowstart)
+{
+ LONGLONG row = -1;
  if(NBline==0) return row;
  // Change buffer for efficiency
@@ -810,5 +837,5 @@
  if(bsens>=0) {ChangeBuffer(BuffLen,-1); bchange=true;}
  if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1;
- for(long i=rowstart;i>=0;i--) {
+ for(LONGLONG i=rowstart;i>=0;i--) {
    double val = Read(i);
    if(val<val1 || val>val2) continue;
@@ -853,5 +880,5 @@
   fbt.Print(3);
   // Read element by element
-  for(long i=0;i<fbt.GetNbLine();i++) {
+  for(LONGLONG i=0;i<fbt.GetNbLine();i++) {
     double x = fbt.Read(i);
     if(i%lpmod==0) cout<<i<<": "<<x<<endl;
@@ -859,5 +886,5 @@
   // Read into a vector
   TVector<double> data;
-  long n = fbt.Read(32,50,data);
+  LONGLONG n = fbt.Read(32,50,data);
     cout<<"Number of values read: "<<n<<endl;
   data.ReSize(100);
@@ -1027,5 +1054,6 @@
  // Get NAXIS 1 et 2
  int nfound=0;
- if(fits_read_keys_lng(GetFitsPtr(),"NAXIS",1,2,Naxis,&nfound,&sta)) {
+ // car fits_read_keys_lnglng n'est pas prototype dans longnam.h
+ if(ffgknjj(GetFitsPtr(),"NAXIS",1,2,Naxis,&nfound,&sta)) {
    FitsOpenFile::printerror(sta);
    throw RangeCheckError("FitsImg2DRd::Init: Error reading NAXIS cards\n");
@@ -1065,4 +1093,14 @@
 {
  return FitsOpenFile::ReadKeyL(GetFitsPtr(),keyname);
+}
+
+/*!
+  Read a fitsheader key into long long
+  \param keyname : name of the key
+  \return value into long long
+*/
+LONGLONG FitsImg2DRd::ReadKeyLL(char *keyname)
+{
+ return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname);
 }
 
@@ -1088,5 +1126,5 @@
 \warning TMatrix data(Naxis2,Naxis1)
 */
-size_t FitsImg2DRd::Read(TMatrix<uint_2>& data)
+LONGLONG FitsImg2DRd::Read(TMatrix<uint_2>& data)
 {
  int sta=0;
@@ -1094,6 +1132,6 @@
  data.ReSize(Naxis[1],Naxis[0]);
 
- for(int j=0;j<Naxis[1];j++) {
-   long deb = j*Naxis[0]+1, nel = Naxis[0];
+ for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TUSHORT,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1102,5 +1140,5 @@
        NotAvailableOperation("FitsImg2DRd::Read(TMatrix<uint_2>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
  }
 
@@ -1110,5 +1148,5 @@
 
 /*! Read image into a TMatrix<int_4> */
-size_t FitsImg2DRd::Read(TMatrix<int_4>& data)
+LONGLONG FitsImg2DRd::Read(TMatrix<int_4>& data)
 {
  int sta=0;
@@ -1117,6 +1155,6 @@
  int T = (sizeof(long)==4) ? TLONG: TINT;
 
- for(int j=0;j<Naxis[1];j++) {
-   long deb = j*Naxis[0]+1, nel = Naxis[0];
+ for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),T,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1125,5 +1163,5 @@
        NotAvailableOperation("FitsImg2DRd::Read(TMatrix<int_4>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
  }
 
@@ -1133,5 +1171,5 @@
 
 /*! Read image into a TMatrix<int_8> */
-size_t FitsImg2DRd::Read(TMatrix<int_8>& data)
+LONGLONG FitsImg2DRd::Read(TMatrix<int_8>& data)
 {
  int sta=0;
@@ -1139,6 +1177,6 @@
  data.ReSize(Naxis[1],Naxis[0]);
 
- for(int j=0;j<Naxis[1];j++) {
-   long deb = j*Naxis[0]+1, nel = Naxis[0];
+ for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TLONGLONG,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1147,5 +1185,5 @@
        NotAvailableOperation("FitsImg2DRd::Read(TMatrix<int_8>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
  }
 
@@ -1155,5 +1193,5 @@
 
 /*! Read image into a TMatrix<float> */
-size_t FitsImg2DRd::Read(TMatrix<float>& data)
+LONGLONG FitsImg2DRd::Read(TMatrix<float>& data)
 {
  int sta=0;
@@ -1161,6 +1199,6 @@
  data.ReSize(Naxis[1],Naxis[0]);
 
- for(int j=0;j<Naxis[1];j++) {
-   long deb = j*Naxis[0]+1, nel = Naxis[0];
+ for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TFLOAT,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1169,5 +1207,5 @@
        NotAvailableOperation("FitsImg2DRd::Read(TMatrix<float>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
  }
 
@@ -1177,5 +1215,5 @@
 
 /*! Read image into a TMatrix<double> */
-size_t FitsImg2DRd::Read(TMatrix<double>& data)
+LONGLONG FitsImg2DRd::Read(TMatrix<double>& data)
 {
  int sta=0;
@@ -1183,6 +1221,6 @@
  data.ReSize(Naxis[1],Naxis[0]);
 
- for(int j=0;j<Naxis[1];j++) {
-   long deb = j*Naxis[0]+1, nel = Naxis[0];
+ for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TDOUBLE,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1191,5 +1229,5 @@
        NotAvailableOperation("FitsImg2DRd::Read(TMatrix<double>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
  }
 
@@ -1343,5 +1381,6 @@
  // Get NAXIS 1, 2 et 3
  int nfound=0;
- if(fits_read_keys_lng(GetFitsPtr(),"NAXIS",1,3,Naxis,&nfound,&sta)) {
+ // car fits_read_keys_lnglng n'est pas prototype dans longnam.h
+ if(ffgknjj(GetFitsPtr(),"NAXIS",1,3,Naxis,&nfound,&sta)) {
    FitsOpenFile::printerror(sta);
    throw RangeCheckError("FitsImg3DRd::Init: Error reading NAXIS cards\n");
@@ -1384,4 +1423,14 @@
 
 /*!
+  Read a fitsheader key into long long
+  \param keyname : name of the key
+  \return value into long long
+*/
+LONGLONG FitsImg3DRd::ReadKeyLL(char *keyname)
+{
+ return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname);
+}
+
+/*!
   Read a fitsheader key into string
   \param keyname : name of the key
@@ -1401,5 +1450,5 @@
 Read 3D image into a TArray<uint_2>
 */
-size_t FitsImg3DRd::Read(TArray<uint_2>& data)
+LONGLONG FitsImg3DRd::Read(TArray<uint_2>& data)
 {
  int sta=0;
@@ -1407,6 +1456,6 @@
  sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TUSHORT,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1415,5 +1464,5 @@
        NotAvailableOperation("FitsImg3DRd::Read(TArray<uint_2>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
  }
 
@@ -1423,5 +1472,5 @@
 
 /*! Read 3D image into a TArray<int_4> */
-size_t FitsImg3DRd::Read(TArray<int_4>& data)
+LONGLONG FitsImg3DRd::Read(TArray<int_4>& data)
 {
  int sta=0;
@@ -1430,6 +1479,6 @@
  int T = (sizeof(long)==4) ? TLONG: TINT;
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),T,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1438,5 +1487,5 @@
        NotAvailableOperation("FitsImg3DRd::Read(TArray<int_4>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
  }
 
@@ -1446,5 +1495,5 @@
 
 /*! Read 3D image into a TArray<int_8> */
-size_t FitsImg3DRd::Read(TArray<int_8>& data)
+LONGLONG FitsImg3DRd::Read(TArray<int_8>& data)
 {
  int sta=0;
@@ -1452,6 +1501,6 @@
  sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TLONGLONG,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1460,5 +1509,5 @@
        NotAvailableOperation("FitsImg3DRd::Read(TArray<int_8>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
  }
 
@@ -1468,5 +1517,5 @@
 
 /*! Read 3D image into a TArray<float> */
-size_t FitsImg3DRd::Read(TArray<float>& data)
+LONGLONG FitsImg3DRd::Read(TArray<float>& data)
 {
  int sta=0;
@@ -1474,6 +1523,6 @@
  sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TFLOAT,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1482,5 +1531,5 @@
        NotAvailableOperation("FitsImg3DRd::Read(TArray<float>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
  }
 
@@ -1490,5 +1539,5 @@
 
 /*! Read 3D image into a TArray<double> */
-size_t FitsImg3DRd::Read(TArray<double>& data)
+LONGLONG FitsImg3DRd::Read(TArray<double>& data)
 {
  int sta=0;
@@ -1496,6 +1545,6 @@
  sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];
    fits_read_img(GetFitsPtr(),TDOUBLE,deb,nel,&NulVal,arr,NULL,&sta);
    if(sta) {
@@ -1504,5 +1553,5 @@
        NotAvailableOperation("FitsImg3DRd::Read(TArray<double>): Error Reading Fits file\n");
    }
-   for(int i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
+   for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i];
  }
 
Index: trunk/SophyaExt/FitsIOServer/fabtcolread.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtcolread.h	(revision 3127)
+++ trunk/SophyaExt/FitsIOServer/fabtcolread.h	(revision 3128)
@@ -43,7 +43,8 @@
   void Print(void);
 
-  static double ReadKey(fitsfile *fitsptr,char *keyname);
-  static long   ReadKeyL(fitsfile *fitsptr,char *keyname);
-  static string ReadKeyS(fitsfile *fitsptr,char *keyname);
+  static double   ReadKey(fitsfile *fitsptr,char *keyname);
+  static long     ReadKeyL(fitsfile *fitsptr,char *keyname);
+  static LONGLONG ReadKeyLL(fitsfile *fitsptr,char *keyname);
+  static string   ReadKeyS(fitsfile *fitsptr,char *keyname);
   static void   printerror(int sta);
 
@@ -72,15 +73,16 @@
   void ChangeBuffer(long blen=100,long bsens=1);
 
-  double ReadKey(char *keyname);
-  long   ReadKeyL(char *keyname);
-  string ReadKeyS(char *keyname);
-
-  double Read(long n,bool usebuffer=true);
-
-  long Read(long n1,long n2,TVector<uint_2>& data);
-  long Read(long n1,long n2,TVector<int_4>& data);
-  long Read(long n1,long n2,TVector<int_8>& data);
-  long Read(long n1,long n2,TVector<float>& data);
-  long Read(long n1,long n2,TVector<double>& data);
+  double    ReadKey(char *keyname);
+  long      ReadKeyL(char *keyname);
+  LONGLONG  ReadKeyLL(char *keyname);
+  string    ReadKeyS(char *keyname);
+
+  double Read(LONGLONG n,bool usebuffer=true);
+
+  LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data);
+  LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data);
+  LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data);
+  LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<float>& data);
+  LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<double>& data);
 
   //! return the value of the first row
@@ -91,6 +93,6 @@
                     {return Read(NBline-1,usebuffer);}
 
-  long FirstRow(double val1,double val2,long rowstart=-1);
-  long LastRow(double val1,double val2,long rowstart=-1);
+  LONGLONG FirstRow(double val1,double val2,LONGLONG rowstart=-1);
+  LONGLONG LastRow(double val1,double val2,LONGLONG rowstart=-1);
 
   //! Set debug level
@@ -115,5 +117,5 @@
          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
   //! Get the number of rows in the FITS HDU to be read
-  inline long GetNbLine(void) const {return NBline;}
+  inline LONGLONG GetNbLine(void) const {return NBline;}
   //! Get the number of columns in the FITS HDU to be read
   inline int GetNbCol(void) const {return NBcol;}
@@ -148,5 +150,5 @@
   string ColLabel,ColTUnit,ColTForm;
   int ColNum,ColTypeCode,NBcol;
-  long NBline;
+  LONGLONG NBline;
 
   double NulVal;
@@ -154,7 +156,7 @@
   long BuffLen, BuffSens;
 
-  unsigned long NFitsRead;
+  LONGLONG NFitsRead;
   FitsOpenFile* FitsOF;
-  long LineDeb, LineFin;
+  LONGLONG LineDeb, LineFin;
   double *Buffer;
   long NBuffer;
@@ -188,13 +190,14 @@
   virtual ~FitsImg2DRd();
 
-  double ReadKey(char *keyname);
-  long   ReadKeyL(char *keyname);
-  string ReadKeyS(char *keyname);
-
-  size_t Read(TMatrix<uint_2>& data);
-  size_t Read(TMatrix<int_4>& data);
-  size_t Read(TMatrix<int_8>& data);
-  size_t Read(TMatrix<float>& data);
-  size_t Read(TMatrix<double>& data);
+  double   ReadKey(char *keyname);
+  long     ReadKeyL(char *keyname);
+  LONGLONG ReadKeyLL(char *keyname);
+  string   ReadKeyS(char *keyname);
+
+  LONGLONG Read(TMatrix<uint_2>& data);
+  LONGLONG Read(TMatrix<int_4>& data);
+  LONGLONG Read(TMatrix<int_8>& data);
+  LONGLONG Read(TMatrix<float>& data);
+  LONGLONG Read(TMatrix<double>& data);
 
   //! Set debug level
@@ -216,12 +219,12 @@
          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
   //! Get NAXIS1
-  inline long Naxis1(void) const {return Naxis[0];}
+  inline LONGLONG Naxis1(void) const {return Naxis[0];}
   //! Get NAXIS2
-  inline long Naxis2(void) const {return Naxis[1];}
+  inline LONGLONG Naxis2(void) const {return Naxis[1];}
 
 protected:
   void Init(FitsOpenFile* fof,int ihdu,int lp);
 
-  long Naxis[2];
+  LONGLONG Naxis[2];
   double NulVal;
   unsigned short DbgLevel;
@@ -251,13 +254,14 @@
   virtual ~FitsImg3DRd();
 
-  double ReadKey(char *keyname);
-  long   ReadKeyL(char *keyname);
-  string ReadKeyS(char *keyname);
-
-  size_t Read(TArray<uint_2>& data);
-  size_t Read(TArray<int_4>& data);
-  size_t Read(TArray<int_8>& data);
-  size_t Read(TArray<float>& data);
-  size_t Read(TArray<double>& data);
+  double   ReadKey(char *keyname);
+  long     ReadKeyL(char *keyname);
+  LONGLONG ReadKeyLL(char *keyname);
+  string   ReadKeyS(char *keyname);
+
+  LONGLONG Read(TArray<uint_2>& data);
+  LONGLONG Read(TArray<int_4>& data);
+  LONGLONG Read(TArray<int_8>& data);
+  LONGLONG Read(TArray<float>& data);
+  LONGLONG Read(TArray<double>& data);
 
   //! Set debug level
@@ -279,14 +283,14 @@
          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
   //! Get NAXIS1
-  inline long Naxis1(void) const {return Naxis[0];}
+  inline LONGLONG Naxis1(void) const {return Naxis[0];}
   //! Get NAXIS2
-  inline long Naxis2(void) const {return Naxis[1];}
+  inline LONGLONG Naxis2(void) const {return Naxis[1];}
   //! Get NAXIS3
-  inline long Naxis3(void) const {return Naxis[2];}
+  inline LONGLONG Naxis3(void) const {return Naxis[2];}
 
 protected:
   void Init(FitsOpenFile* fof,int ihdu,int lp);
 
-  long Naxis[3];
+  LONGLONG Naxis[3];
   double NulVal;
   unsigned short DbgLevel;
Index: trunk/SophyaExt/FitsIOServer/fabtwriter.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtwriter.cc	(revision 3127)
+++ trunk/SophyaExt/FitsIOServer/fabtwriter.cc	(revision 3128)
@@ -53,4 +53,5 @@
  DoubleKey.resize(0);
  LongKey.resize(0);
+ LongLongKey.resize(0);
  StringKey.resize(0);
 
@@ -78,6 +79,6 @@
 
  // create d'un Primary HDU
- //long naxes[1] = {0};
- //if(fits_create_img(FitsPtr,BYTE_IMG,0,naxes,&sta)) {
+ //LONGLONG naxes[1] = {0};
+ //if(fits_create_imgll(FitsPtr,BYTE_IMG,0,naxes,&sta)) {
  //  printerror(sta);
  //  throw NullPtrError("FitsWriter::cr_or_upd_fits: Error creating Primary extension\n");
@@ -125,4 +126,15 @@
 }
 
+/*! Write a long long value into Fits Header */
+void FitsWriter::WriteKey(const char *keyname,LONGLONG val,char* comment)
+{
+ if(keyname==NULL || strlen(keyname)<=0) return;
+ KeyLongLong k;
+ k.keyname=keyname;
+ k.val=val;
+ if(comment) k.comment=comment; else k.comment="";
+ LongLongKey.push_back(k);
+}
+
 /*! Write a string value into Fits Header */
 void FitsWriter::WriteKey(const char *keyname,string val,char* comment)
@@ -142,5 +154,5 @@
  int sta=0;
  if(DoubleKey.size()>0)
-   for(unsigned int i=0;i<DoubleKey.size();i++) {
+   for(unsigned long i=0;i<DoubleKey.size();i++) {
      char* key = const_cast<char*>(DoubleKey[i].keyname.c_str());
      char* com = const_cast<char*>(DoubleKey[i].comment.c_str());
@@ -150,5 +162,5 @@
    }
  if(LongKey.size()>0)
-   for(unsigned int i=0;i<LongKey.size();i++) {
+   for(unsigned long i=0;i<LongKey.size();i++) {
      char* key = const_cast<char*>(LongKey[i].keyname.c_str());
      char* com = const_cast<char*>(LongKey[i].comment.c_str());
@@ -157,6 +169,14 @@
        printerror(sta);
    }
+ if(LongLongKey.size()>0)
+   for(unsigned long i=0;i<LongLongKey.size();i++) {
+     char* key = const_cast<char*>(LongLongKey[i].keyname.c_str());
+     char* com = const_cast<char*>(LongLongKey[i].comment.c_str());
+     LONGLONG val = LongLongKey[i].val;
+     if(fits_update_key(FitsPtr,TLONGLONG,key,&val,com,&sta))
+       printerror(sta);
+   }
  if(StringKey.size()>0)
-   for(unsigned int i=0;i<StringKey.size();i++) {
+   for(unsigned long i=0;i<StringKey.size();i++) {
      char* key = const_cast<char*>(StringKey[i].keyname.c_str());
      char* com = const_cast<char*>(StringKey[i].comment.c_str());
@@ -167,8 +187,9 @@
  DoubleKey.resize(0);
  LongKey.resize(0);
+ LongLongKey.resize(0);
  StringKey.resize(0);
 }
 
-void FitsWriter::printerrorwrite(const char* type,int col,long row,int sta)
+void FitsWriter::printerrorwrite(const char* type,int col,LONGLONG row,int sta)
 {
  if(sta==NUM_OVERFLOW) {NOverFlow++; return;}
@@ -176,5 +197,5 @@
  char str[256];
  sprintf(str,"FitsWriter::Write_%s: Error Writing Fits c=%d r=%ld sta=%d"
-        ,type,col,row,sta);
+        ,type,col,(long)row,sta);
  throw NotAvailableOperation(str);
 }
@@ -208,5 +229,5 @@
   int c5 = fbtw.AddCol("vard","","arcmin",TDOUBLE);    // col=4
   fbtw.SetDebug(3);
-  for(long i=0;i<1000;i++) {
+  for(LONGLONG i=0;i<1000;i++) {
     double x = i;
     fbtw.Write(c1,i,1000.*x); // if overflow, managed by cfitsio
@@ -228,9 +249,9 @@
   TVector<float>  dataf(100);
   TVector<int_4>  datal(100);
-  for(long i=0;i<9990;i+=100) {
-    long i2=i+100-1; if(i2>=9990) i2=9990-1;
-    for(long j=0;j<100;j++) datad(i) =  ...;
-    for(long j=0;j<100;j++) dataf(i) =  ...;
-    for(long j=0;j<100;j++) datal(i) =  ...;
+  for(LONGLONG i=0;i<9990;i+=100) {
+    LONGLONG i2=i+100-1; if(i2>=9990) i2=9990-1;
+    for(LONGLONG j=0;j<100;j++) datad(i) =  ...;
+    for(LONGLONG j=0;j<100;j++) dataf(i) =  ...;
+    for(LONGLONG j=0;j<100;j++) datal(i) =  ...;
     fbtw.Write(1,i,datal);
     fbtw.Write(2,i,dataf);
@@ -251,4 +272,5 @@
    cout<<"Writing Keys"<<endl;
    fbtw.WriteKey("MYKEYL",(long)123456789,"my LONG key");
+   fbtw.WriteKey("MYKEYLL",(LONGLONG)123456789,"my LONGLONG key");
    fbtw.WriteKey("MYKEYD",1.9999999,"my DOUBLE key");
    fbtw.WriteKey("MYKEYC","how are you ?","my CHAR* key");
@@ -265,4 +287,5 @@
    cout<<"Writing Keys"<<endl;
    fbtw2.WriteKey("MYKEYL",(long)-123456789,"my new LONG key");
+   fbtw2.WriteKey("MYKEYLL",(LONGLONG)-123456789,"my new LONGLONG key");
    fbtw2.WriteKey("MYKEYD",-1.9999999,"my new clef DOUBLE key");
    fbtw2.WriteKey("MYKEYC","how are you NOW ?","my new CHAR* key");
@@ -275,5 +298,5 @@
 
    cout<<">>>>> Write into the 2 tables simultaneously"<<endl;
-   for(int i=0;i<NNN;i++) {
+   for(LONGLONG i=0;i<NNN;i++) {
      fbtw.Write(i1,i,i+1.);
      fbtw.Write(i2,i,i+11.);
@@ -462,5 +485,5 @@
    throw ParmError("FitsABTWriter::createtbl: Zero column asked !\n");
 
- long nrows = 0;
+ LONGLONG nrows = 0;
  char *extname = NULL;
  char **ttype   = (char **) malloc(tfields*sizeof(char *));
@@ -472,6 +495,5 @@
    strcpy(extname,ExtName.c_str());
  }
- int i;
- for(i=0;i<tfields;i++) {
+ for(int i=0;i<tfields;i++) {
    ttype[i] = (char *) malloc((strlen(Label[i].c_str())+1)*sizeof(char));
      strcpy(ttype[i],Label[i].c_str());
@@ -491,5 +513,5 @@
  // menage
  if(extname) delete [] extname;
- for(i=0;i<tfields;i++) {
+ for(int i=0;i<tfields;i++) {
    if(ttype[i]) delete [] ttype[i];
    if(tform[i]) delete [] tform[i];
@@ -525,5 +547,5 @@
 
 /*! Write signed char (1 Byte) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,int_1 val)
+void FitsABTWriter::Write(int col,LONGLONG row,int_1 val)
 {
 #ifdef TSBYTE
@@ -538,5 +560,5 @@
 
 /*! Write unsigned char (1 Byte) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,uint_1 val)
+void FitsABTWriter::Write(int col,LONGLONG row,uint_1 val)
 {
   if(FirstTime) createtbl();
@@ -547,5 +569,5 @@
 
 /*! Write short (2 Bytes) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,int_2 val)
+void FitsABTWriter::Write(int col,LONGLONG row,int_2 val)
 {
   if(FirstTime) createtbl();
@@ -556,5 +578,5 @@
 
 /*! Write unsigned short (2 Bytes) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,uint_2 val)
+void FitsABTWriter::Write(int col,LONGLONG row,uint_2 val)
 {
   if(FirstTime) createtbl();
@@ -565,5 +587,5 @@
 
 /*! Write long (4 Bytes) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,int_4 val)
+void FitsABTWriter::Write(int col,LONGLONG row,int_4 val)
 {
   if(FirstTime) createtbl();
@@ -576,5 +598,5 @@
 
 /*! Write unsigned long (4 Bytes) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,uint_4 val)
+void FitsABTWriter::Write(int col,LONGLONG row,uint_4 val)
 {
   if(FirstTime) createtbl();
@@ -587,5 +609,5 @@
 
 /*! Write long long (8 Bytes) data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,int_8 val)
+void FitsABTWriter::Write(int col,LONGLONG row,int_8 val)
 {
 #ifdef TLONGLONG
@@ -600,5 +622,5 @@
 
 /*! Write float data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,float val)
+void FitsABTWriter::Write(int col,LONGLONG row,float val)
 {
   if(FirstTime) createtbl();
@@ -609,5 +631,5 @@
 
 /*! Write double data to FITS file (see below) */
-void FitsABTWriter::Write(int col,long row,double val)
+void FitsABTWriter::Write(int col,LONGLONG row,double val)
 {
   if(FirstTime) createtbl();
@@ -628,8 +650,8 @@
 
 /*! Write a vector of unsigned short (2 Bytes) data to FITS file (see below) */
-long FitsABTWriter::Write(int col,long row,TVector<uint_2>& val)
-{
-  if(FirstTime) createtbl();
-  long nel = val.Size();
+LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<uint_2>& val)
+{
+  if(FirstTime) createtbl();
+  LONGLONG nel = val.Size();
   int sta=0;
   if(fits_write_col(FitsPtr,TUSHORT,col+1,row+1,1,nel,val.Data(),&sta))
@@ -639,8 +661,8 @@
 
 /*! Write a vector of long (4 Bytes) data to FITS file (see below) */
-long FitsABTWriter::Write(int col,long row,TVector<int_4>& val)
-{
-  if(FirstTime) createtbl();
-  long nel = val.Size();
+LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<int_4>& val)
+{
+  if(FirstTime) createtbl();
+  LONGLONG nel = val.Size();
   int sta=0;
   // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ?
@@ -652,9 +674,9 @@
 
 /*! Write a vector of long long (8 Bytes) data to FITS file (see below) */
-long FitsABTWriter::Write(int col,long row,TVector<int_8>& val)
+LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<int_8>& val)
 {
 #ifdef TLONGLONG
   if(FirstTime) createtbl();
-  long nel = val.Size();
+  LONGLONG nel = val.Size();
   int sta=0;
   if(fits_write_col(FitsPtr,TLONGLONG,col+1,row+1,1,nel,val.Data(),&sta))
@@ -667,8 +689,8 @@
 
 /*! 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();
+LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<float>&  val)
+{
+  if(FirstTime) createtbl();
+  LONGLONG nel = val.Size();
   int sta=0;
   if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,nel,val.Data(),&sta))
@@ -678,8 +700,8 @@
 
 /*! 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();
+LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<double>& val)
+{
+  if(FirstTime) createtbl();
+  LONGLONG nel = val.Size();
   int sta=0;
   if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,nel,val.Data(),&sta))
@@ -785,5 +807,5 @@
 
  int sta=0;
- if(fits_create_img(FitsPtr,BitPix,2,Naxis,&sta)) {
+ if(fits_create_imgll(FitsPtr,BitPix,2,Naxis,&sta)) {
    printerror(sta);
    throw NullPtrError("FitsImg2DWriter::createimg: Error creating image extension\n");
@@ -802,7 +824,7 @@
  uint_2* arr = new uint_2[Naxis[0]];
 
- for(int l=0;l<Naxis[1];l++) {
-   for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
-   long deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG l=0;l<Naxis[1];l++) {
+   for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c);
+   LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,TUSHORT,deb,nel,arr,&sta);
    if(sta) {
@@ -823,7 +845,7 @@
  int_4* arr = new int_4[Naxis[0]];
 
- for(int l=0;l<Naxis[1];l++) {
-   for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
-   long deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG l=0;l<Naxis[1];l++) {
+   for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c);
+   LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,T,deb,nel,arr,&sta);
    if(sta) {
@@ -843,7 +865,7 @@
  float* arr = new float[Naxis[0]];
 
- for(int l=0;l<Naxis[1];l++) {
-   for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
-   long deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG l=0;l<Naxis[1];l++) {
+   for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c);
+   LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,TFLOAT,deb,nel,arr,&sta);
    if(sta) {
@@ -863,7 +885,7 @@
  double* arr = new double[Naxis[0]];
 
- for(int l=0;l<Naxis[1];l++) {
-   for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
-   long deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG l=0;l<Naxis[1];l++) {
+   for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c);
+   LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,TDOUBLE,deb,nel,arr,&sta);
    if(sta) {
@@ -972,5 +994,5 @@
 
  int sta=0;
- if(fits_create_img(FitsPtr,BitPix,3,Naxis,&sta)) {
+ if(fits_create_imgll(FitsPtr,BitPix,3,Naxis,&sta)) {
    printerror(sta);
    throw NullPtrError("FitsImg3DWriter::createimg: Error creating 3D image extension\n");
@@ -991,7 +1013,7 @@
  uint_2* arr = new uint_2[Naxis[0]];
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,TUSHORT,deb,nel,arr,&sta);
    if(sta) {
@@ -1015,7 +1037,7 @@
  int_4* arr = new int_4[Naxis[0]];
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,T,deb,nel,arr,&sta);
    if(sta) {
@@ -1038,7 +1060,7 @@
  float* arr = new float[Naxis[0]];
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,TFLOAT,deb,nel,arr,&sta);
    if(sta) {
@@ -1061,7 +1083,7 @@
  double* arr = new double[Naxis[0]];
 
- for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
-   for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
-   long deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
+ for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) {
+   for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
+   LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;
    fits_write_img(FitsPtr,TDOUBLE,deb,nel,arr,&sta);
    if(sta) {
Index: trunk/SophyaExt/FitsIOServer/fabtwriter.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 3127)
+++ trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 3128)
@@ -34,4 +34,6 @@
   //! Write a long value in Fits header.
   void WriteKey(const char *keyname,long val,char* comment=NULL);
+  //! Write a long long value in Fits header.
+  void WriteKey(const char *keyname,LONGLONG val,char* comment=NULL);
   //! Write a string value in Fits header.
   void WriteKey(const char *keyname,string val,char* comment=NULL);
@@ -43,17 +45,18 @@
 
   //! Return the number of overflows managed by cfitsio
-  inline unsigned long GetNOverFlow(void) {return NOverFlow;}
+  inline LONGLONG GetNOverFlow(void) {return NOverFlow;}
 
   //! Return the c-fitsio file pointer
   inline fitsfile * GetFitsPtr() { return FitsPtr; }
 protected:
-  struct KeyDouble {string keyname; double val; string comment;};
-  struct KeyLong   {string keyname; long   val; string comment;};
-  struct KeyString {string keyname; string val; string comment;};
+  struct KeyDouble   {string keyname; double   val; string comment;};
+  struct KeyLong     {string keyname; long     val; string comment;};
+  struct KeyLongLong {string keyname; LONGLONG val; string comment;};
+  struct KeyString   {string keyname; string   val; string comment;};
 
   void cr_or_upd_fits(const char *cfname,bool update,int lp);
 
   void writekeys(void);
-  void printerrorwrite(const char* type,int col,long row,int sta);
+  void printerrorwrite(const char* type,int col,LONGLONG row,int sta);
   void printerror(int sta) const;
 
@@ -63,9 +66,10 @@
   unsigned short DbgLevel;
   fitsfile *FitsPtr;
-  unsigned long NOverFlow;
+  LONGLONG NOverFlow;
 
-  vector<struct KeyDouble> DoubleKey;
-  vector<struct KeyLong>   LongKey;
-  vector<struct KeyString> StringKey;
+  vector<struct KeyDouble>   DoubleKey;
+  vector<struct KeyLong>     LongKey;
+  vector<struct KeyLongLong> LongLongKey;
+  vector<struct KeyString>   StringKey;
 };
 
@@ -95,18 +99,18 @@
      {return addcol(label,tform,tunit,datatype);}
 
-  void Write(int col,long row,int_1 val);
-  void Write(int col,long row,uint_1 val);
-  void Write(int col,long row,int_2 val);
-  void Write(int col,long row,uint_2 val);
-  void Write(int col,long row,int_4 val);
-  void Write(int col,long row,uint_4 val);
-  void Write(int col,long row,int_8 val);
-  void Write(int col,long row,float val);
-  void Write(int col,long row,double val);
-  long Write(int col,long row,TVector<uint_2>& val);
-  long Write(int col,long row,TVector<int_4>& val);
-  long Write(int col,long row,TVector<int_8>& val);
-  long Write(int col,long row,TVector<float>& val);
-  long Write(int col,long row,TVector<double>& val);
+  void Write(int col,LONGLONG row,int_1 val);
+  void Write(int col,LONGLONG row,uint_1 val);
+  void Write(int col,LONGLONG row,int_2 val);
+  void Write(int col,LONGLONG row,uint_2 val);
+  void Write(int col,LONGLONG row,int_4 val);
+  void Write(int col,LONGLONG row,uint_4 val);
+  void Write(int col,LONGLONG row,int_8 val);
+  void Write(int col,LONGLONG row,float val);
+  void Write(int col,LONGLONG row,double val);
+  LONGLONG Write(int col,LONGLONG row,TVector<uint_2>& val);
+  LONGLONG Write(int col,LONGLONG row,TVector<int_4>& val);
+  LONGLONG Write(int col,LONGLONG row,TVector<int_8>& val);
+  LONGLONG Write(int col,LONGLONG row,TVector<float>& val);
+  LONGLONG Write(int col,LONGLONG row,TVector<double>& val);
 
   //! Return the number of created columns
@@ -153,5 +157,5 @@
 
   int BitPix;
-  long Naxis[2];
+  LONGLONG Naxis[2];
   bool FirstTime;
 };
@@ -182,5 +186,5 @@
 
   int BitPix;
-  long Naxis[3];
+  LONGLONG Naxis[3];
   bool FirstTime;
 };
Index: trunk/SophyaExt/FitsIOServer/fboloread.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fboloread.cc	(revision 3127)
+++ trunk/SophyaExt/FitsIOServer/fboloread.cc	(revision 3128)
@@ -28,5 +28,5 @@
 
   cout<<"Reading element by elements"<<endl;
-  for(long i=0; i<fbr.GetNbLine(); i++) {
+  for(LONGLONG i=0; i<fbr.GetNbLine(); i++) {
     double a = fbr.GetAlpha(i);
     double d = fbr.GetDelta(i);
@@ -43,6 +43,6 @@
   TVector<float> Vc1;
   TVector<int_4> Vs;
-  for(long i=0, istep=1000; i<fbr.GetNbLine(); i+=istep) {
-    long i2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1;
+  for(LONGLONG i=0, istep=1000; i<fbr.GetNbLine(); i+=istep) {
+    LONGLONG i2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1;
     fbr.GetSNum(i,i2,Vs);
     fbr.GetBolo(i,i2,Vb);
@@ -148,5 +148,5 @@
 
  // Set the number of rows as the smallest of for connected columns
- long nrows = mFABT[col]->GetNbLine();
+ LONGLONG nrows = mFABT[col]->GetNbLine();
  if(NBline==0) NBline = nrows;
  else if(nrows<NBline) NBline = nrows;
@@ -222,5 +222,5 @@
  for(col=0; col<(int)mFABT.size(); col++) {
    if(mFABT[col]==NULL) continue;
-   long nbl = mFABT[col]->GetNbLine();
+   LONGLONG nbl = mFABT[col]->GetNbLine();
    if(nbl==0) continue;
    if(NBline==0 || nbl<NBline) NBline = nbl;
Index: trunk/SophyaExt/FitsIOServer/fboloread.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fboloread.h	(revision 3127)
+++ trunk/SophyaExt/FitsIOServer/fboloread.h	(revision 3128)
@@ -44,20 +44,20 @@
 
   //! return Alpha value for row "n" into double
-  inline double GetAlpha(long n,bool usebuffer=true)
+  inline double GetAlpha(LONGLONG n,bool usebuffer=true)
                 {return GetCol(ColAlpha,n,usebuffer);}
   //! return Delta value for row "n" into double
-  inline double GetDelta(long n,bool usebuffer=true)
+  inline double GetDelta(LONGLONG n,bool usebuffer=true)
                 {return GetCol(ColDelta,n,usebuffer);}
   //! return Bolo value for row "n" into double
-  inline double GetBolo(long n,bool usebuffer=true)
+  inline double GetBolo(LONGLONG n,bool usebuffer=true)
                 {return GetCol(ColBolo,n,usebuffer);}
   //! return Flag value for row "n" into double
-  inline double GetFlag(long n,bool usebuffer=true)
+  inline double GetFlag(LONGLONG n,bool usebuffer=true)
          {if(!IsFlag()) return 0.; return GetCol(ColFlag,n,usebuffer);}
   //! return SNum value for row "n" into double
-  inline double GetSNum(long n,bool usebuffer=true)
+  inline double GetSNum(LONGLONG n,bool usebuffer=true)
                 {return GetCol(ColSNum,n,usebuffer);}
   //! return column "col" value for row "n" into double
-  inline double GetCol(int col,long n,bool usebuffer=true) {
+  inline double GetCol(int col,LONGLONG n,bool usebuffer=true) {
     if(col<0 || col>=(int)mFABT.size())
       throw ParmError("FitsBoloRead::GetCol: bad column number\n");
@@ -68,53 +68,53 @@
 
   //! return Alpha values for rows [n1,n2] into TVector
-  inline long GetAlpha(long n1,long n2,TVector<double>& data)
+  inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<double>& data)
               {return GetCol(ColAlpha,n1,n2,data);}
-  inline long GetAlpha(long n1,long n2,TVector<float>& data)
+  inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<float>& data)
               {return GetCol(ColAlpha,n1,n2,data);}
-  inline long GetAlpha(long n1,long n2,TVector<int_4>& data)
+  inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
               {return GetCol(ColAlpha,n1,n2,data);}
 
   //! return Delta values for rows [n1,n2] into TVector
-  inline long GetDelta(long n1,long n2,TVector<double>& data)
+  inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<double>& data)
               {return GetCol(ColDelta,n1,n2,data);}
-  inline long GetDelta(long n1,long n2,TVector<float>& data)
+  inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<float>& data)
               {return GetCol(ColDelta,n1,n2,data);}
-  inline long GetDelta(long n1,long n2,TVector<int_4>& data)
+  inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
               {return GetCol(ColDelta,n1,n2,data);}
 
   //! return Bolo values for rows [n1,n2] into TVector
-  inline long GetBolo(long n1,long n2,TVector<double>& data)
+  inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<double>& data)
               {return GetCol(ColBolo,n1,n2,data);}
-  inline long GetBolo(long n1,long n2,TVector<float>& data)
+  inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<float>& data)
               {return GetCol(ColBolo,n1,n2,data);}
-  inline long GetBolo(long n1,long n2,TVector<int_4>& data)
+  inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
               {return GetCol(ColBolo,n1,n2,data);}
 
   //! return Flag values for rows [n1,n2] into TVector
-  inline long GetFlag(long n1,long n2,TVector<double>& data)
+  inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<double>& data)
               {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
-  inline long GetFlag(long n1,long n2,TVector<float>& data)
+  inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<float>& data)
               {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
-  inline long GetFlag(long n1,long n2,TVector<int_4>& data)
+  inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
               {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
 
   //! return Sample Number values for rows [n1,n2] into TVector
-  inline long GetSNum(long n1,long n2,TVector<double>& data)
+  inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<double>& data)
               {return GetCol(ColSNum,n1,n2,data);}
-  inline long GetSNum(long n1,long n2,TVector<float>& data)
+  inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<float>& data)
               {return GetCol(ColSNum,n1,n2,data);}
-  inline long GetSNum(long n1,long n2,TVector<int_4>& data)
+  inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
               {return GetCol(ColSNum,n1,n2,data);}
 
   //! return column "col" values for rows [n1,n2] into TVector
-  inline long GetCol(int col,long n1,long n2,TVector<double>& data) {
+  inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<double>& data) {
     if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
     return mFABT[col]->Read(n1,n2,data);
   }
-  inline long GetCol(int col,long n1,long n2,TVector<float>& data) {
+  inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<float>& data) {
     if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
     return mFABT[col]->Read(n1,n2,data);
   }
-  inline long GetCol(int col,long n1,long n2,TVector<int_4>& data) {
+  inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<int_4>& data) {
     if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
     return mFABT[col]->Read(n1,n2,data);
@@ -144,5 +144,5 @@
   void SetNbLine(int col=-1);
   //! Get the number of rows to be read
-  inline long GetNbLine(void) const {return NBline;}
+  inline LONGLONG GetNbLine(void) const {return NBline;}
   //! Get the number of columns in the FITS HDU to be read
   inline int  GetNbCol(void) const {return mFABT.size();}
@@ -175,5 +175,5 @@
   void Gess_If_Not_Define(int col);
 
-  long NBline;
+  LONGLONG NBline;
   unsigned short DbgLevel;
   long BuffLen, BuffSens;
Index: trunk/SophyaProg/Tests/tstcolread.cc
===================================================================
--- trunk/SophyaProg/Tests/tstcolread.cc	(revision 3127)
+++ trunk/SophyaProg/Tests/tstcolread.cc	(revision 3128)
@@ -99,5 +99,5 @@
 
   if(vsearch) {
-    long mid = fbt->GetNbLine()/2;
+    LONGLONG mid = fbt->GetNbLine()/2;
     cout<<"Search vs1="<<vs1<<" vs2="<<vs2<<endl;
     cout<<"FirstRow: "<<fbt->FirstRow(vs1,vs2,-1)<<endl;
@@ -109,5 +109,5 @@
 #ifdef NO_VECTOR
   cout<<"Writting element by elements"<<endl;
-  for(long i=0;i<fbt->GetNbLine();i++) {
+  for(LONGLONG i=0;i<fbt->GetNbLine();i++) {
     double x = fbt->Read(i);
     if(i%lpmod==0) cout<<i<<": "<<x<<endl;
@@ -125,8 +125,8 @@
   TVector<float> dataf;
   TVector<int_4> datal;
-  long istep = fbt->GetNbLine()/10; if(istep>1000) istep=1000;
-  for(long i=0;i<fbt->GetNbLine();i+=istep) {
-    long i2=i+istep-1; if(i2>=fbt->GetNbLine()) i2=fbt->GetNbLine()-1;
-    long n = fbt->Read(i,i2,data);
+  LONGLONG istep = fbt->GetNbLine()/10; if(istep>1000) istep=1000;
+  for(LONGLONG i=0;i<fbt->GetNbLine();i+=istep) {
+    LONGLONG i2=i+istep-1; if(i2>=fbt->GetNbLine()) i2=fbt->GetNbLine()-1;
+    LONGLONG n = fbt->Read(i,i2,data);
     fbt->Read(i,i2,dataf);
     fbt->Read(i,i2,datal);
