Index: trunk/SophyaExt/FitsIOServer/fabtcolread.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 3772)
+++ trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 4023)
@@ -349,5 +349,5 @@
 {
  ColLabel = ""; ColTUnit = ""; ColTForm = "";
- ColNum = -1; ColTypeCode = 0;
+ ColNum = -1; ColTypeCode = 0; ColRepeat=0;
  NBcol = 0; NBline = 0;
  SetNulVal(); SetDebug(0);
@@ -363,5 +363,5 @@
 {
  // Initialisation des Parametres Generaux
- ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0;
+ ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0; ColRepeat=0;
  NBcol = 0; NBline = 0;
  SetNulVal(); SetDebug(lp);
@@ -469,4 +469,5 @@
  ColTUnit = tunit;
  ColTForm = tform;
+ ColRepeat = repeat;
 
  // Set the buffer for reading
@@ -475,8 +476,7 @@
  if(DbgLevel)
    cout<<"FitsABTColRd::Init Num="<<ColNum<<" Label="<<ColLabel
-       <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<endl;
+       <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat<<endl;
  if(DbgLevel>1)
-   cout<<"      (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero
-       <<",tdisp="<<tdisp<<")"<<endl;
+   cout<<"      (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl;
 
 }
@@ -503,5 +503,5 @@
 
  // Compute buffer caracteristics
- BuffLen = (blen<=0)? 1: blen;
+ BuffLen = (blen<=0 || ColRepeat!=1)? 1: blen;
  BuffSens = bsens;
  NBuffer = BuffLen;
@@ -566,5 +566,5 @@
 /////////////////////////////////////////////////
 /*!
-  Read row "n" and return the value into a double
+  Read row "n" element "nfirstel" and return the value into a double
   \warning be carefull for the range: row = [0,NRows[
   \return value in double
@@ -576,17 +576,20 @@
   \endverbatim
 */
-double FitsABTColRd::Read(LONGLONG n,bool usebuffer)
+double FitsABTColRd::Read(LONGLONG n,long nfirstel,bool usebuffer)
 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
 // Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
+// Attention: nfirstel  [0,ColRepeat[ , cfistio veut [1,ColRepeat]
 {
  int sta=0;
  if(n<0 || n>=NBline)
    throw RangeCheckError("FitsABTColRd::Read try to read outside line range\n");
-
- // Pas de bufferisation, on lit betement
- if(NBuffer==1 || !usebuffer) {
+ if(nfirstel<0 || nfirstel>=ColRepeat)
+   throw RangeCheckError("FitsABTColRd::Read try to read outside element range: nfirstel>repeat\n");
+
+ // Pas de bufferisation (ou repeat=1), on lit betement
+ if(NBuffer==1 || !usebuffer || ColRepeat!=1) {
    NFitsRead++;
    double val;
-   fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,1,1,NULL,&val,NULL,&sta);
+   fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,nfirstel+1,1,NULL,&val,NULL,&sta);
    if(sta) {
      FitsOpenFile::printerror(sta);
@@ -603,5 +606,5 @@
  }
 
- // Gestion avec bufferisation
+ // Gestion avec bufferisation (uniquement dans le cas repeat=1)
  if(!Buffer)
    throw RangeCheckError("FitsABTColRd::Read: Buffer not allocated\n");
@@ -669,4 +672,6 @@
 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<double>& data)
 {
+ if(ColRepeat>1)
+   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
  if(n1<0 || n1>=NBline)
    throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
@@ -693,4 +698,6 @@
 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<float>& data)
 {
+ if(ColRepeat>1)
+   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
  if(n1<0 || n1>=NBline)
    throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
@@ -717,4 +724,6 @@
 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data)
 {
+ if(ColRepeat>1)
+   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
  if(n1<0 || n1>=NBline)
    throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
@@ -740,4 +749,6 @@
 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
 {
+ if(ColRepeat>1)
+   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
  if(n1<0 || n1>=NBline)
    throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
@@ -766,4 +777,6 @@
 {
 #ifdef TLONGLONG
+ if(ColRepeat>1)
+   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
  if(n1<0 || n1>=NBline)
    throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
@@ -792,4 +805,5 @@
 /*!
   Return the number of the first row where "val1"<=val<="val2" starting at row "rowstart"
+  for element "nfirstel"
   \verbatim
   - The search is performed from "rowstart" to the end
@@ -800,6 +814,8 @@
   \return <0 means not found
 */
-LONGLONG FitsABTColRd::FirstRow(double val1,double val2,LONGLONG rowstart)
-{
+LONGLONG FitsABTColRd::FirstRow(long nfirstel,double val1,double val2,LONGLONG rowstart)
+{
+ if(nfirstel<0 || nfirstel>=ColRepeat)
+   throw RangeCheckError("FitsABTColRd::FirstRow try to read outside element range: nfirstel>repeat\n");
  LONGLONG row = -1;
  if(NBline==0) return row;
@@ -810,5 +826,5 @@
  if(rowstart>=NBline) rowstart = NBline-1;
  for(LONGLONG i=rowstart;i<NBline;i++) {
-   double val = Read(i);
+   double val = Read(i,nfirstel);
    if(val<val1 || val>val2) continue;
    row = i;
@@ -820,5 +836,6 @@
 
 /*!
-  Return the number of the first row where val1<=val<=val2 starting at row rowstart
+  Return the number of the last row where val1<=val<=val2 starting at row rowstart
+  for element "nfirstel"
   \return <0 means not found
   \verbatim
@@ -829,6 +846,8 @@
   \endverbatim
 */
-LONGLONG FitsABTColRd::LastRow(double val1,double val2,LONGLONG rowstart)
-{
+LONGLONG FitsABTColRd::LastRow(long nfirstel,double val1,double val2,LONGLONG rowstart)
+{
+ if(nfirstel<0 || nfirstel>=ColRepeat)
+   throw RangeCheckError("FitsABTColRd::FirstRow try to read outside element range: nfirstel>repeat\n");
  LONGLONG row = -1;
  if(NBline==0) return row;
@@ -838,5 +857,5 @@
  if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1;
  for(LONGLONG i=rowstart;i>=0;i--) {
-   double val = Read(i);
+   double val = Read(i,nfirstel);
    if(val<val1 || val>val2) continue;
    row = i;
@@ -855,5 +874,5 @@
  os<<"\n... "<<FileName()<<"["<<HDU()<<"/"<<NHDU()<<" type="<<HDUType()<<"]"
    <<"\n... Label["<<ColNum<<"]="<<ColLabel<<" TypeCode="<<ColTypeCode
-   <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm
+   <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat
    <<endl;
 }
@@ -983,5 +1002,5 @@
 {
  // Initialisation des Parametres Generaux
- ColLabel.resize(0); ColTUnit.resize(0); ColTForm.resize(0); ColTypeCode.resize(0);
+ ColLabel.resize(0); ColTUnit.resize(0); ColTForm.resize(0); ColTypeCode.resize(0); ColRepeat.resize(0);
  NBcol = 0; NBline = 0;
  SetNulVal(); SetDebug(lp);
@@ -1077,4 +1096,5 @@
    ColTUnit.push_back(tunit);
    ColTForm.push_back(tform);
+   ColRepeat.push_back(repeat);
    // fill the default buffer limits at init
    LineDeb.push_back(-1);
@@ -1083,8 +1103,7 @@
    if(DbgLevel)
      cout<<"FitsABTColRd1F::Init Num="<<ColNum<<" Label="<<ColLabel[ColNum]
-         <<" TypeCode="<<ColTypeCode[ColNum]<<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum]<<endl;
+         <<" TypeCode="<<ColTypeCode[ColNum]<<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum]<<" Repeat="<<ColRepeat[ColNum]<<endl;
    if(DbgLevel>1)
-     cout<<"      (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero
-         <<",tdisp="<<tdisp<<")"<<endl;
+     cout<<"      (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl;
  }   // ***** ColNum
 
@@ -1198,5 +1217,5 @@
 /////////////////////////////////////////////////
 /*!
-  Read row "n" of column "ColNum" and return the value into a double
+  Read row "n" element "nfirstel" of column "ColNum" and return the value into a double
   \warning be carefull for the range: row = [0,NRows[
   \return value in double
@@ -1208,7 +1227,8 @@
   \endverbatim
 */
-double FitsABTColRd1F::Read(int ColNum,LONGLONG n,bool usebuffer)
+double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel,bool usebuffer)
 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
 // Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
+// Attention: nfirstel  [0,ColRepeat[ , cfistio veut [1,ColRepeat]
 {
  int sta=0;
@@ -1217,9 +1237,11 @@
  if(n<0 || n>=NBline)
    throw RangeCheckError("FitsABTColRd1F::Read try to read outside line range\n");
-
- // Pas de bufferisation, on lit betement
- if(NBuffer==1 || !usebuffer) {
+ if(nfirstel<0 || nfirstel>=ColRepeat[ColNum])
+   throw RangeCheckError("FitsABTColRd1F::Read try to read outside element range: nfirstel>repeat\n");
+
+ // Pas de bufferisation (ou repeat=1), on lit betement
+ if(NBuffer==1 || !usebuffer || ColRepeat[ColNum]!=1) {
    double val;
-   fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,1,1,NULL,&val,NULL,&sta);
+   fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,nfirstel+1,1,NULL,&val,NULL,&sta);
    if(sta) {
      FitsOpenFile::printerror(sta);
@@ -1236,5 +1258,5 @@
  }
 
- // Gestion avec bufferisation
+ // Gestion avec bufferisation (uniquement dans le cas repeat=1)
  if(!Buffer)
    throw RangeCheckError("FitsABTColRd1F::Read: Buffer not allocated\n");
