Index: trunk/SophyaProg/PMixer/skymixer.cc
===================================================================
--- trunk/SophyaProg/PMixer/skymixer.cc	(revision 1239)
+++ trunk/SophyaProg/PMixer/skymixer.cc	(revision 1252)
@@ -29,7 +29,8 @@
 SpectralResponse * getSpectralResponse(DataCards & dc);
 RadSpectra * getEmissionSpectra(DataCards & dc, int nc);
+void SKM_MergeFITSKeywords(char * flnm);
 void RadSpec2Nt(RadSpectra & rs, POutPersist & so, string name);
 void SpectralResponse2Nt(SpectralResponse& sr, POutPersist & so, string name);
-
+ 
 // to add different sky components and corresponding tools
 //----------------------------------------------------------
@@ -68,5 +69,9 @@
 static int  debuglev = 0;     // Debug Level
 static int  printlev = 0;     // Print Level
-static POutPersist * so = NULL;  // Debug PPFOut file
+static POutPersist * so = NULL;    // Debug PPFOut file
+static DVList * dvl_fitskw = NULL; // Global DVList for all FITS Keywords 
+
+// --------- SkyMixer Version --------------
+static double skm_version = 1.4;
 
 // -------------------------------------------------------------------------
@@ -90,4 +95,6 @@
   DataCards dc;
   so = NULL;
+  // DVList for merging all FITS keywords 
+  dvl_fitskw = new DVList;
   
   try {
@@ -127,4 +134,6 @@
 	FITS_SphereHEALPix<float> fios(&outgs);
 	fios.Read(ifnm,2);
+	//  Getting FITS keywords in primary header
+	SKM_MergeFITSKeywords(ifnm); 
       }
       if(printlev>0)
@@ -190,4 +199,6 @@
 	    FITS_SphereHEALPix<float> fiosIn(&ings);
 	    fiosIn.Read(flnm,2);
+	    //  Getting FITS keywords in primary header
+	    SKM_MergeFITSKeywords(flnm); 
 	  }
 	  if (debuglev > 4) {  // Writing the input map to the outppf
@@ -227,4 +238,6 @@
 		FITS_SphereHEALPix<float> fiosBM(&betaMap);
 		fiosBM.Read(flnm,2);
+		//  Getting FITS keywords in primary header
+		SKM_MergeFITSKeywords(flnm); 
 	      }
 	      if (printlev > 2) {
@@ -288,4 +301,12 @@
      FitsOutFile fios(arg[2]);
      fios.firstImageOnPrimaryHeader(false); // Use secondary header 
+     DVList& dvl = (*dvl_fitskw);
+     dvl["PDMTYPE"] = "COMPMAP";
+     dvl.SetComment("PDMTYPE", "Planck Data Model Type"); 
+     dvl["SOPHYVER"] =  SophyaVersion();
+     dvl.SetComment("SOPHYVER", "Sophya Version number"); 
+     dvl["SKYMVER"] =  skm_version;
+     dvl.SetComment("SKYMVER", "skymixer Version number"); 
+     fios.DVListIntoPrimaryHeader(dvl);  
      fios << outgs ;
    }
@@ -450,4 +471,6 @@
     fiis.firstImageOnPrimaryHeader(false); // Use secondary header HDU=2
     fiis >> mtx ; 
+    //  Getting FITS keywords in primary header
+    SKM_MergeFITSKeywords(ifnm); 
     double numin = dc.DParam(key, 2, 1.);
     double numax = dc.DParam(key, 3, 9999.);
@@ -502,4 +525,6 @@
     fiis.firstImageOnPrimaryHeader(false); // Use secondary header HDU=2
     fiis >> mtx ; 
+    //  Getting FITS keywords in primary header
+    SKM_MergeFITSKeywords(ifnm); 
     double numin = dc.DParam(key, 2, 1.);
     double numax = dc.DParam(key, 3, 9999.);
@@ -702,4 +727,44 @@
 
 /* Nouvelle-Fonction */
+void SKM_MergeFITSKeywords(char * flnm)
+{
+  DVList dvl;
+  FitsFile::FitsExtensionType typeOfExtension;
+  int naxis;
+  vector<int> naxisn;
+  FitsFile::FitsDataType dataType;
+  FitsInFile::GetBlockType(flnm, 1, typeOfExtension, naxis, naxisn, dataType, dvl);
+  // Cleaning the keywords 
+#define SZexlst 21
+  char *exlst[SZexlst]=
+  {"SIMPLE","BITPIX" ,"NAXIS" ,"NAXIS#" ,"PCOUNT","GCOUNT",
+     "EXTEND","ORIGIN" ,"DATE*" ,"TFIELDS","TTYPE#","TFORM#",
+     "TUNIT#","EXTNAME","CTYPE#","CRVAL#" ,"CRPIX#","CDELT#",
+     "XTENSION","INSTRUME","TELESCOP"};
+  char  kwex[32];
+  int i,l;
+  for (i=0; i<SZexlst; i++) {
+    strncpy(kwex, exlst[i], 32);
+    l = strlen(kwex)-1;
+    if ((kwex[l] != '*') && (kwex[l] != '#')) {
+      dvl.DeleteKey(kwex);
+    } 
+    else {
+      bool fgd = (kwex[l] == '#') ? true : false;
+      list<string> lstsup;
+      kwex[l] = '\0';
+      DVList::ValList::const_iterator it;
+      for (it = dvl.Begin(); it != dvl.End(); it++) {
+	if ((*it).first.substr(0,l) != kwex) continue;
+	if (fgd && !isdigit((*it).first[l])) continue;
+	lstsup.push_back((*it).first);
+      }
+      list<string>::iterator it2;
+      for (it2 = lstsup.begin(); it2 != lstsup.end(); it2++)
+	dvl.DeleteKey(*it2);
+    }
+  }
+  dvl_fitskw->Merge(dvl);
+}
 
 /* Nouvelle-Fonction */
Index: trunk/SophyaProg/PMixer/tgrsr.cc
===================================================================
--- trunk/SophyaProg/PMixer/tgrsr.cc	(revision 1239)
+++ trunk/SophyaProg/PMixer/tgrsr.cc	(revision 1252)
@@ -135,4 +135,12 @@
   FitsOutFile fios(arg[4]);
   fios.firstImageOnPrimaryHeader(false);  // use secondary header
+  DVList dvl;
+  if (typ == 0) 
+    dvl["PDMTYPE"] = "FGRSPEC";
+  dvl.SetComment("PDMTYPE", "Planck Data Model Type"); 
+  dvl["SOPHYVER"] =  SophyaVersion();
+  dvl.SetComment("SOPHYVER", "Sophya Version"); 
+  dvl["TGRSRKW"] =  "Test Keyword from tgrsr.cc";
+  fios.DVListIntoPrimaryHeader(dvl);  
   fios << mtx ; 
   PrtTim("End of Matrix->FITS ");
Index: trunk/SophyaProg/PMixer/tgsky.cc
===================================================================
--- trunk/SophyaProg/PMixer/tgsky.cc	(revision 1239)
+++ trunk/SophyaProg/PMixer/tgsky.cc	(revision 1252)
@@ -114,7 +114,8 @@
   dvl["PDMTYPE"] = "COMPMAP";
   dvl.SetComment("PDMTYPE", "Planck Data Model Type"); 
-  dvl["SVERSIO"] =  SophyaVersion();
-  dvl.SetComment("SVERSIO", "Sophya Version"); 
-  // fios.DVListIntoPrimaryHeader(dvl);  $CHECK - RZ - GLM 18/10/2000 $
+  dvl["SOPHYVER"] =  SophyaVersion();
+  dvl.SetComment("SOPHYVER", "Sophya Version"); 
+  dvl["TGSKYKW"] =  "Test Keyword from tgsky.cc";
+  fios.DVListIntoPrimaryHeader(dvl);  
   fios << sph; 
   cout << "SphereHEALPix<float> written to FITS file " << (string)(arg[4]) << endl;
