Index: trunk/SophyaExt/FitsIOServer/fabtcolread.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 1813)
+++ trunk/SophyaExt/FitsIOServer/fabtcolread.cc	(revision 1814)
@@ -244,4 +244,13 @@
 }
 
+//////////////////////////////////////////////////////////////
+double FitsABTColRead::ReadKey(char *keyname)
+{
+ if(keyname==NULL) return 0.;
+ int sta=0; double val;
+ if(fits_read_key(FitsPtr,TDOUBLE,keyname,&val,NULL,&sta))
+   printerror(sta);
+ return val;
+}
 
 //////////////////////////////////////////////////////////////
Index: trunk/SophyaExt/FitsIOServer/fabtcolread.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtcolread.h	(revision 1813)
+++ trunk/SophyaExt/FitsIOServer/fabtcolread.h	(revision 1814)
@@ -29,4 +29,6 @@
 
   void ChangeBuffer(long blen=100,long bsens=1);
+
+  double ReadKey(char *keyname);
 
   double Read(long n,bool usebuffer=true);
Index: trunk/SophyaExt/FitsIOServer/fabtwriter.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtwriter.cc	(revision 1813)
+++ trunk/SophyaExt/FitsIOServer/fabtwriter.cc	(revision 1814)
@@ -111,6 +111,61 @@
 {
  int sta = 0;
+ writekeys();
  if(fits_close_file(FitsPtr,&sta)) printerror(sta);
  FitsPtr = NULL;
+}
+
+/*! Flush the FitsIO buffer to set good Fits file in case of problems */
+void FitsABTWriter::Flush(void)
+{
+ if(FitsPtr==NULL) return;
+ int sta = 0;
+ if(fits_flush_file(FitsPtr,&sta)) printerror(sta);
+}
+
+/*! Write a double value into Fits Header */
+void FitsABTWriter::WriteKey(const char *keyname,double val,char* comment)
+{
+ if(keyname==NULL || strlen(keyname)<=0) return;
+ KeyDouble k;
+ k.keyname=keyname;
+ k.val=val;
+ if(comment) k.comment=comment; else k.comment="";
+ DoubleKey.push_back(k);
+}
+
+/*! Write a long value into Fits Header */
+void FitsABTWriter::WriteKey(const char *keyname,long val,char* comment)
+{
+ if(keyname==NULL || strlen(keyname)<=0) return;
+ KeyLong k;
+ k.keyname=keyname;
+ k.val=val;
+ if(comment) k.comment=comment; else k.comment="";
+ LongKey.push_back(k);
+}
+
+void FitsABTWriter::writekeys(void)
+// Ecriture effective des clefs
+{
+ int sta=0;
+ if(DoubleKey.size()>0)
+   for(unsigned int 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());
+     double val = DoubleKey[i].val;
+     if(fits_update_key(FitsPtr,TDOUBLE,key,&val,com,&sta))
+       printerror(sta);
+   }
+ if(LongKey.size()>0)
+   for(unsigned int 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());
+     long val = LongKey[i].val;
+     if(fits_update_key(FitsPtr,TLONG,key,&val,com,&sta))
+       printerror(sta);
+   }
+ DoubleKey.resize(0);
+ LongKey.resize(0);
 }
 
@@ -208,4 +263,7 @@
    throw NullPtrError("FitsABTWriter::createtbl: Error creating Table extension\n");
  }
+
+ // Append Fits key
+ writekeys();
 
  // menage
Index: trunk/SophyaExt/FitsIOServer/fabtwriter.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 1813)
+++ trunk/SophyaExt/FitsIOServer/fabtwriter.h	(revision 1814)
@@ -22,4 +22,11 @@
   FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
   virtual ~FitsABTWriter();
+
+  void Flush(void);
+
+  //! Write a double value in Fits header.
+  void WriteKey(const char *keyname,double val,char* comment=NULL);
+  //! Write a long value in Fits header.
+  void WriteKey(const char *keyname,long val,char* comment=NULL);
 
   //! Add a new column to the FITS table and return its number (see addcol).
@@ -58,8 +65,12 @@
 
 protected:
+  struct KeyDouble {string keyname; double val; string comment;};
+  struct KeyLong   {string keyname; long   val; string comment;};
+
   void createfits(const char *cfname,int hdutype,int lp);
   int addcol(const char* label,const char* tform
             ,const char* tunit,int datatype);
   void createtbl(void);
+  void writekeys(void);
   void printerrorwrite(const char* type,int col,long row,int sta);
   void printerror(int sta) const;
@@ -74,4 +85,7 @@
   vector<string> TUnit;
   unsigned long NOverFlow;
+
+  vector<struct KeyDouble> DoubleKey;
+  vector<struct KeyLong>   LongKey;
 };
 
