Index: /trunk/src/pvo-FITS-fileIO.cc
===================================================================
--- /trunk/src/pvo-FITS-fileIO.cc	(revision 111)
+++ /trunk/src/pvo-FITS-fileIO.cc	(revision 112)
@@ -4,6 +4,6 @@
 #include <string>
 #include <time.h>
+#include <math.h>
 #include <fitsio.h>
-#include <math.h>
 #include "pvo-FITS.hh"
 #include "pvo-utils.hh"
@@ -113,34 +113,47 @@
       this->setBeam(block.getKeyword<int>(IBEAM));
 
-      if(block.getSurveyType()==S70) this->setInitialBlock(block.getKeyword<int>(BLK_CNTR));
-      else this->setInitialBlock(1);
-
-      this->setFITSname(block.getSurveyType());
-
-      if(this->newFile && this->fileExists()){
-	std::stringstream errmsg;
-	errmsg << "\aThe file "<< this->getFITSname() 
-	       << " already exists.\n"
-	       << "Don't want to overwrite, so exiting...\n";
-	if(this->verbose) PVOError("FITS initialise",errmsg.str());
-	return FAILURE;
+      if(block.getSurveyType()==S70) 
+	this->setInitialBlock(block.getKeyword<int>(BLK_CNTR));
+      else 
+	this->setInitialBlock(1);
+
+      this->setFITSname(block);
+
+      if(this->writingData){
+
+	if(this->newFile && this->fileExists()){
+	  std::stringstream errmsg;
+	  errmsg << "\aThe file "<< this->getFITSname() 
+		 << " already exists.\n"
+		 << "Don't want to overwrite, so exiting...\n";
+	  if(this->verbose) PVOError("FITS initialise",errmsg.str());
+	  return FAILURE;
+	}
+
+	if(this->openFile()) {
+	  if(this->verbose) 
+	    std::cerr << "\aCannot open file "<< this->getFITSname()
+		      << ".\nExiting...\n";
+	  return FAILURE;
+	}
+
+	if(this->newFile){
+      
+	  //      this->writeHistoryTapeFile();
+	  this->writeHistoryCommand(block);
+  
+	  this->writePHU(block);
+
+	  this->setupSubint(block);
+    
+	}
+
       }
-
-      if(this->openFile()) {
-	if(this->verbose) 
-	  std::cerr << "\aCannot open file "<< this->getFITSname()
-		    << ".\nExiting...\n";
-	return FAILURE;
-      }
-
-      if(this->newFile){
-      
-	//      this->writeHistoryTapeFile();
-	this->writeHistoryCommand(block);
-  
-	this->writePHU(block);
-
-	this->setupSubint(block);
-    
+      else{
+	if(this->newFile){
+	  std::cerr << this->FITSname;
+	  if(this->fileExists()) std::cerr << " --> File Exists!";
+	  std::cerr << "\n";
+	}
       }
 
@@ -294,108 +307,114 @@
        *      <li> Increment the number of samples.
        * </ul>
+       * If PSRFits::writingData is false, we are not writing data to
+       * the file, and so only the incrementing is done.
        * \param block The block containing the header info & the data.
        */
 
-      this->gotoSubint();
-      this->startNewSubintRow(); 
-
-      float tsubint = block.getKeyword<float>(BLK_SEC);
-      double off_sub;
-    
-      off_sub = 0.5*(2.*(block.getKeyword<int>(BLK_CNTR)-this->blk_initial)+1)
-	* block.getKeyword<double>(BLK_SEC);
-
-      double lst_sub  = dmsToDec(block.getKeyword<std::string>(LST));
-      double ra_sub   = dmsToDec(block.getKeyword<std::string>(RA))*15.;
-      double dec_sub  = dmsToDec(block.getKeyword<std::string>(DEC));
-      double glon_sub = block.getKeyword<double>(GL);
-      double glat_sub = block.getKeyword<double>(GB);
-      float  fd_ang   = block.getKeyword<float>(FEED_ANGLE);
-      float  par_ang  = block.getKeyword<float>(PANGLE);
-      float  pos_ang  = remainderf(par_ang + fd_ang, 360.);
-      float  tel_az   = block.getKeyword<float>(TEL_AZ);
-      float  tel_zen  = block.getKeyword<float>(TEL_ZEN);
-    
-      this->writeColumnValue("TSUBINT",  tsubint);
-      this->writeColumnValue("OFFS_SUB", off_sub);
-      this->writeColumnValue("LST_SUB",  lst_sub);
-      this->writeColumnValue("RA_SUB",   ra_sub);
-      this->writeColumnValue("DEC_SUB",  dec_sub);
-      this->writeColumnValue("GLON_SUB", glon_sub);
-      this->writeColumnValue("GLAT_SUB", glat_sub);
-      this->writeColumnValue("FD_ANG",   fd_ang);
-      this->writeColumnValue("POS_ANG",  pos_ang);
-      this->writeColumnValue("PAR_ANG",  par_ang);
-      this->writeColumnValue("TEL_AZ",   tel_az);
-      this->writeColumnValue("TEL_ZEN",  tel_zen);
-
-      /////////////////////////////////////
-
-      long nrows = this->getNumRows();
-      int colnum = this->getColnum("DAT_FREQ");
-      int status=0;
-      fits_modify_vector_len (this->fptr, colnum, 
-			      this->subintTable.nch_file, &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-      status=0;
-      fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
-		     this->subintTable.nch_file, this->subintTable.dat_freq, 
-		     &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-
-      colnum = this->getColnum("DAT_WTS");
-      status=0;
-      fits_modify_vector_len (this->fptr, colnum, 
-			      this->subintTable.nch_file, &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-      status=0;
-      fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
-		     this->subintTable.nch_file, this->subintTable.dat_wts, 
-		     &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-
-      colnum = this->getColnum("DAT_OFFS");
-      status=0;
-      fits_modify_vector_len (this->fptr, colnum, 
-			      this->subintTable.nch_file, &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-      status=0;
-      fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
-		     this->subintTable.nch_file, this->subintTable.dat_offs, 
-		     &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-
-      colnum = this->getColnum("DAT_SCL");
-      status=0;
-      fits_modify_vector_len (this->fptr, colnum, 
-			      this->subintTable.nch_file, &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-      status=0;
-      fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
-		     this->subintTable.nch_file, this->subintTable.dat_scl, 
-		     &status);
-      if(status) this->FITSError("PSRFits::writeSubintRow", status);
-
-      //////////////////////////////////////////
-
-      unsigned char *data = (unsigned char *)block.getData();
-
-      if(this->FITSname == "PM_061222_150342_01.fits" && nrows==1){
-	std::cout << charToBinary(data[0]);
-	std::cout << charToBinary(data[1]);
-	std::cout << charToBinary(data[2]);
-	std::cout << "\n";
-      }
-
-      colnum = this->getColnum("DATA");
-      status=0;
-      fits_write_col_byt(this->fptr, colnum, nrows, 1, this->subintTable.getDataSizeBytes(), data, &status);
-      if(status) this->FITSError("PSRFits::writeDataArray 4", status);
-
-      //////////////////////////////////////////
-
-      // Increment the number of samples
+      // First, increment the number of samples
       this->numSamples += (block.getKeyword<int>(GRP_BLK) * 
 			   block.getKeyword<int>(SAMP_GRP) );
+
+      // Then only write data if the correct flag is set.
+      if(this->areWritingData()){
+
+	this->gotoSubint();
+	this->startNewSubintRow(); 
+
+	float tsubint = block.getKeyword<float>(BLK_SEC);
+	double off_sub;
+    
+	off_sub = 0.5 * 
+	  (2.*(block.getKeyword<int>(BLK_CNTR)-this->blk_initial)+1)
+	  * block.getKeyword<double>(BLK_SEC);
+
+	double lst_sub  = dmsToDec(block.getKeyword<std::string>(LST));
+	double ra_sub   = dmsToDec(block.getKeyword<std::string>(RA))*15.;
+	double dec_sub  = dmsToDec(block.getKeyword<std::string>(DEC));
+	double glon_sub = block.getKeyword<double>(GL);
+	double glat_sub = block.getKeyword<double>(GB);
+	float  fd_ang   = block.getKeyword<float>(FEED_ANGLE);
+	float  par_ang  = block.getKeyword<float>(PANGLE);
+	float  pos_ang  = remainderf(par_ang + fd_ang, 360.);
+	float  tel_az   = block.getKeyword<float>(TEL_AZ);
+	float  tel_zen  = block.getKeyword<float>(TEL_ZEN);
+    
+	this->writeColumnValue("TSUBINT",  tsubint);
+	this->writeColumnValue("OFFS_SUB", off_sub);
+	this->writeColumnValue("LST_SUB",  lst_sub);
+	this->writeColumnValue("RA_SUB",   ra_sub);
+	this->writeColumnValue("DEC_SUB",  dec_sub);
+	this->writeColumnValue("GLON_SUB", glon_sub);
+	this->writeColumnValue("GLAT_SUB", glat_sub);
+	this->writeColumnValue("FD_ANG",   fd_ang);
+	this->writeColumnValue("POS_ANG",  pos_ang);
+	this->writeColumnValue("PAR_ANG",  par_ang);
+	this->writeColumnValue("TEL_AZ",   tel_az);
+	this->writeColumnValue("TEL_ZEN",  tel_zen);
+
+	/////////////////////////////////////
+
+	long nrows = this->getNumRows();
+	int colnum = this->getColnum("DAT_FREQ");
+	int status=0;
+	fits_modify_vector_len (this->fptr, colnum, 
+				this->subintTable.nch_file, &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+	status=0;
+	fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
+		       this->subintTable.nch_file, this->subintTable.dat_freq, 
+		       &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+
+	colnum = this->getColnum("DAT_WTS");
+	status=0;
+	fits_modify_vector_len (this->fptr, colnum, 
+				this->subintTable.nch_file, &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+	status=0;
+	fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
+		       this->subintTable.nch_file, this->subintTable.dat_wts, 
+		       &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+
+	colnum = this->getColnum("DAT_OFFS");
+	status=0;
+	fits_modify_vector_len (this->fptr, colnum, 
+				this->subintTable.nch_file, &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+	status=0;
+	fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
+		       this->subintTable.nch_file, this->subintTable.dat_offs, 
+		       &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+
+	colnum = this->getColnum("DAT_SCL");
+	status=0;
+	fits_modify_vector_len (this->fptr, colnum, 
+				this->subintTable.nch_file, &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+	status=0;
+	fits_write_col(this->fptr, TFLOAT, colnum, nrows, 1, 
+		       this->subintTable.nch_file, this->subintTable.dat_scl, 
+		       &status);
+	if(status) this->FITSError("PSRFits::writeSubintRow", status);
+
+	//////////////////////////////////////////
+
+	unsigned char *data = (unsigned char *)block.getData();
+
+	if(this->FITSname == "PM_061222_150342_01.fits" && nrows==1){
+	  std::cout << charToBinary(data[0]);
+	  std::cout << charToBinary(data[1]);
+	  std::cout << charToBinary(data[2]);
+	  std::cout << "\n";
+	}
+
+	colnum = this->getColnum("DATA");
+	status=0;
+	fits_write_col_byt(this->fptr, colnum, nrows, 1, this->subintTable.getDataSizeBytes(), data, &status);
+	if(status) this->FITSError("PSRFits::writeDataArray 4", status);
+
+      } // end of if(areWritingData()) loop
 
     }
Index: /trunk/src/pvo-FITS.cc
===================================================================
--- /trunk/src/pvo-FITS.cc	(revision 111)
+++ /trunk/src/pvo-FITS.cc	(revision 112)
@@ -26,4 +26,5 @@
       this->UT_initial = decToDMS(0.);
       this->verbose = true;
+      this->writingData = true;
     }
     //-----------------------------------------------------------------------
@@ -34,4 +35,5 @@
       this->openFile(name);
       this->verbose = true;
+      this->writingData = true;
     }
     //-----------------------------------------------------------------------
@@ -188,5 +190,5 @@
     //----------------------------------------------------------------------
 
-    void PSRFits::setFITSname(Header::SURVEY surveyType)
+    void PSRFits::setFITSname(DataBlock &block)
     {
       /**
@@ -197,8 +199,10 @@
        * <ul> <li> S70_yymmdd_hhmmss.fits
        *      <li> PM_yymmdd_hhmmss_bb.fits </ul>
-       * \param surveyType The enumerated type of the survey data.
+       * \param block The block that incorporates the survey type and
+       *        allows us to work out what filename extension to use.
        * \return String containing the FITS filename.
        */
       std::string date;
+      Header::SURVEY surveyType = block.getSurveyType();
 
       for(unsigned int i=0;i<this->DATE_initial.size();i++)
@@ -221,5 +225,18 @@
 	       << this->beam_number;
 
-      output << ".fits";
+      //      output << ".fits";
+      // Get the extension.
+      //  Base this on the MOVE parameter. 
+      PVO::FITS::EXT_TYPE ext;
+      std::string obsmode = block.getObs_mode();
+      if(obsmode=="SEARCH") ext=SEARCH;
+      else if(obsmode=="PSR") ext=TIMING;
+      else{
+	std::stringstream errmsg;
+	errmsg << "Unknown OBS_MODE (" << obsmode << ")!\n";
+	PVOError("PSRFits::setFITSname",errmsg.str());
+	ext=SEARCH;
+      }
+      output << PVO::FITS::extension[ext];
 
       this->FITSname = output.str();
@@ -258,5 +275,4 @@
       if(exists<=0){
 	char *template_file = (char *)getPSRFITSdefn().c_str();
-	std::cerr << template_file << "\n";
 	fits_create_template(&this->fptr, (char *)name.c_str(), template_file, &status);
 	if(status) this->FITSError("PSRFits::openFile 2",status);
Index: /trunk/src/pvo-FITS.hh
===================================================================
--- /trunk/src/pvo-FITS.hh	(revision 111)
+++ /trunk/src/pvo-FITS.hh	(revision 112)
@@ -29,4 +29,7 @@
     };
 
+    const int numExtension = 2;
+    enum EXT_TYPE { SEARCH, TIMING };
+    const std::string extension[numExtension] = {".sf", ".rf"};
 
 
@@ -200,7 +203,7 @@
 
 
-      // Functions found in PSRFits.cc (in the same order...)
+      // Functions found in pvo-FITS.cc (in the same order...)
       /** Generate the name of the fits file. */
-      void        setFITSname(Header::SURVEY surveyType); 
+      void        setFITSname(DataBlock &block); 
 
       /** Does the file exist on disk already? */
Index: /trunk/src/pvo.hh
===================================================================
--- /trunk/src/pvo.hh	(revision 111)
+++ /trunk/src/pvo.hh	(revision 112)
@@ -32,4 +32,7 @@
   -H                Use the PH (High Latitude) Survey settings, rather than\n\
   --highlat          those for the PM/Multibeam Survey\n\
+  -t                Run through the input files as normal, but do not write\n\
+  --test             any new files, just list the filenames that would be\n\
+                     created and note whether they exist or not.\n\
   -V                Verbose mode for error/warning messages.\n\
   --verbose\n\
@@ -47,5 +50,8 @@
  Note that more than one input file can be given.\n\
  Output files will be encoded according to the survey type and date & time\n\
-  of observation.\n";
+  of observation.\n
+ The -t option provides the ability to see what files pvoconvert would\n\
+  produce, without actually producing them. It also tells you if a file \n\
+  already exists (which would cause a problem).";
   /** Brief help text for pvoconvert -h */
   const std::string pvoconvert_usage_text_short = 
@@ -57,4 +63,7 @@
   -H                Use the PH (High Latitude) Survey settings, rather than\n\
   --highlat          those for the PM/Multibeam Survey\n\
+  -t                Run through the input files as normal, but do not write\n\
+  --test             any new files, just list the filenames that would be\n\
+                     created and note whether they exist or not.\n\
   -V                Verbose mode for error/warning messages.\n\
   --verbose\n\
Index: /trunk/src/pvoconvert.cc
===================================================================
--- /trunk/src/pvoconvert.cc	(revision 111)
+++ /trunk/src/pvoconvert.cc	(revision 112)
@@ -56,4 +56,5 @@
   bool verbFlag = false;
   bool usingHighLatitude = false;
+  bool writingData = true;
   unsigned int i;
 
@@ -70,4 +71,5 @@
       {"highlat", 0, 0, 'H'},
       {"directory", 1, 0, 'D'},
+      {"test", 1, 0, 't'},
       {"verbose", 1, 0, 'V'},
       {"version", 1, 0, 'v'},
@@ -75,5 +77,5 @@
     };
 
-    c = getopt_long (argc, argv, "D:HVvh",
+    c = getopt_long (argc, argv, "D:HVvht",
 		     long_options, &option_index);
 
@@ -110,4 +112,7 @@
       }
       break;
+    case 't': // test mode -- don't write any data, just report the filenames.
+      writingData = false;
+      break;
     case 'h': // give help statement
       std::cout << PVO::pvoconvert_usage_text;
@@ -133,4 +138,10 @@
   }
 
+  if(!writingData){
+    std::cout << "List of files that will be produced if -t is not used: \n";
+    if(namelist.size()>1)
+      std::cout << "  (grouped according to input file)\n";
+  }
+
   for(i=0; i<namelist.size(); i++){
 
@@ -140,5 +151,5 @@
     SURVEY currentSurvey = idSurvey(fname);
     if(currentSurvey == NONEXISTENT) {
-      std::cerr << "ERROR: File " << fname <<" does not exist. Skipping this.\n";
+      std::cout << "ERROR: File " << fname <<" does not exist. Skipping this.\n";
       doThisOne = false;
     }
@@ -147,5 +158,5 @@
       if(currentSurvey == PM) currentSurvey = PH;
       else if(currentSurvey!=DUD){
-	std::cerr << "WARNING: " << fname << " is a " << surveyNames[currentSurvey] <<" file.\n"
+	std::cout << "WARNING: " << fname << " is a " << surveyNames[currentSurvey] <<" file.\n"
 		  << " High Latitude survey settings are NOT being used.\n";
 // 	doThisOne = false;
@@ -163,8 +174,13 @@
     }
     file_loc += fname;
-    std::cerr << "Input file " << file_loc <<" : " << surveyNames[currentSurvey]<<"\n";
-    if(currentSurvey == DUD){
-      std::cerr << "  Skipping this file.\n";
-      doThisOne = false;
+    if(doThisOne) {
+      std::cout << "Input file " << file_loc <<" : ";
+      if(currentSurvey == DUD){
+	std::cout << "  Skipping this file.\n";
+	doThisOne = false;
+      }
+      else {
+	std::cout << surveyNames[currentSurvey]<<"\n";
+      }
     }
 
@@ -184,4 +200,5 @@
 
       PSRFits fitsfile;
+      fitsfile.setWritingData(writingData);
       fitsfile.setVerbosity(verbFlag);
       //      fitsfile.setOldFilename(fname);
Index: /trunk/src/pvosummary.cc
===================================================================
--- /trunk/src/pvosummary.cc	(revision 111)
+++ /trunk/src/pvosummary.cc	(revision 112)
@@ -127,14 +127,18 @@
     //No file has been specified, so we are working on the directory
     //as a whole.
-    glob_t globbuf1,globbuf2;
-    globbuf1.gl_offs = 0;
-    globbuf2.gl_offs = 0;
-    glob("*.fits", GLOB_DOOFFS, NULL, &globbuf1);
-    glob("*.rf", GLOB_DOOFFS, NULL, &globbuf2);
-    namelist.resize(globbuf1.gl_pathc+globbuf2.gl_pathc);
-    for(i=0;i<globbuf1.gl_pathc+globbuf1.gl_offs;i++) 
-      namelist[i] = globbuf1.gl_pathv[i];
-    for(i=0;i<globbuf2.gl_pathc+globbuf2.gl_offs;i++) 
-      namelist[globbuf1.gl_pathc+i] = globbuf2.gl_pathv[i];
+    glob_t list1,list2,list3;
+    list1.gl_offs = 0;
+    list2.gl_offs = 0;
+    list3.gl_offs = 0;
+    glob("*.fits", GLOB_DOOFFS, NULL, &list1);
+    glob("*.rf", GLOB_DOOFFS, NULL, &list2);
+    glob("*.sf", GLOB_DOOFFS, NULL, &list3);
+    namelist.resize(list1.gl_pathc+list2.gl_pathc+list3.gl_pathc);
+    for(i=0;i<list1.gl_pathc+list1.gl_offs;i++) 
+      namelist[i] = list1.gl_pathv[i];
+    for(i=0;i<list2.gl_pathc+list2.gl_offs;i++) 
+      namelist[list1.gl_pathc+i] = list2.gl_pathv[i];
+    for(i=0;i<list3.gl_pathc+list3.gl_offs;i++) 
+      namelist[list1.gl_pathc+list2.gl_pathc+i] = list3.gl_pathv[i];
   }
 
