Index: DISpred/src/ControlCards.cxx
===================================================================
--- DISpred/src/ControlCards.cxx	(revision 18)
+++ DISpred/src/ControlCards.cxx	(revision 19)
@@ -1,206 +1,207 @@
 #include <sstream>
 #include <iomanip>
 #include <iostream>
 #include <fstream>
 #include <vector>
+#include <cstdlib>
 
 #include "ControlCards.h"
 
 /*
 
 Control Cards class - Provided by Alex Tapper <a.tapper@imperial.ac.uk>
 
 Copyright (C) 2006 Alex Tapper
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
 using namespace DISPred;
 ControlCards* ControlCards::Instance()
 {
   static ControlCards inst;
   return &inst;
 }
 
 void ControlCards::AddCardDouble(const std::string key, const double defval)
 {
   cd[key]=defval;
   return;
 }
 
 void ControlCards::AddCardInt(const std::string key, const int defval)
 {
   ci[key]=defval;
   return;
 }
 
 void ControlCards::AddCardString(const std::string key, const std::string defval)
 {
   cs[key]=defval;
   return;
 }
 
 void ControlCards::AddCardVector(const std::string key, const std::vector<double> defval)
 {
   cv[key]=defval;
   return;
 }
 
 int ControlCards::readKeys(const char* fileName)
 {
   // Read in the data cards and call printCards to write them out
 
   std::ifstream in(fileName);
   if (!in) return 0;
 
   std::string s;
   std::string t;
   std::string c;
 
   while (1) {
     getline(in,c);
     if (in.eof()) break;
     std::istringstream is(c);
     is >> t;
     if (t.length() == 0) continue;
     if (t[0] == '#') continue; 
     int ok = 0;
 
     // Double precision
     InputControlCardsDouble::iterator i = cd.find(t);
     if ( i != cd.end()) {
       double d;
       is>> d;
       cd[t] = d;
       ok = 1;
     }
 
     // Integer
     if( ok == 0)
     {
       InputControlCardsInt::iterator i1 = ci.find(t);
       if(i1 != ci.end()){
 	int ii;
 	is >> ii;
 	ci[t] = ii;
 	ok =1;
       }
     }
 
     // Std::String
     if (ok == 0) {
       std::istringstream is2(c);
       is2 >> t;
       InputControlCardsString::iterator i2 = cs.find(t);
       if ( i2 != cs.end()) {
 	std::string s2;
 	is>> s2;
 	cs[t] = s2;
 	ok = 1;
       }
     }
 
     // Vector of double precision
     if (ok == 0) {
       std::istringstream is3(c);
       is3 >> t;
       InputControlCardsVector::iterator i3 = cv.find(t);
       if ( i3 != cv.end()) {
 	double d3;
 	while (!is.eof() && is.good()) {
 	  is>>d3;
 	  cv[t].push_back(d3);
 	} 
 	ok = 1;
       }
     }
     if (ok != 1) 
       std::cout << "what's this data card " << t << " ?\n";
   }
 
   // Print out the data cards
   printCards();
   return 1;     
 }
 
 double ControlCards::fetchValueDouble(const std::string& key)
 {
   InputControlCardsDouble::iterator i=cd.find(key);
   if (i == cd.end()) {
     std::cout << " Fatal error fetching unknown data card = " << key << "\n";
     exit(2);
   }
   return i->second;
 }
 
 int ControlCards::fetchValueInt(const std::string& key){
  InputControlCardsInt::iterator i=ci.find(key);
  if( i == ci.end()) {
      std::cout << " Fatal error fetching unknown data card = " << key << "\n";
      exit(2);
    }
    return i->second;
 }
 
 std::string ControlCards::fetchValueString(const std::string& key)
 {
   InputControlCardsString::iterator i=cs.find(key);
   if (i == cs.end()) {
     std::cout << " Fatal error fetching unknown data card  =  " << key << "\n";
     exit(2);
   }
   return i->second;
 }
 
 std::vector<double> ControlCards::fetchValueVector(const std::string& key)
 {
   return cv[key];
 }
 
 void ControlCards::printCards()
 {
   // Write out the values of the data cards 
 
   std::cout << " ============== ControlCards ==============" << std::endl;
 
   InputControlCardsString::const_iterator si = cs.begin();
   for (; si != cs.end(); ++si) {
     std::cout << si->first << " = " << si->second << std::endl;
   }
 
   InputControlCardsInt::const_iterator ii = ci.begin();
   for (; ii != ci.end(); ++ii) {
     std::cout << ii->first << " = " << ii->second << std::endl;
   }
 
   InputControlCardsDouble::const_iterator di = cd.begin();
   for (; di != cd.end(); ++di) {
     std::cout << di->first << " = " << di->second << std::endl;
   }
 
   InputControlCardsVector::iterator iv=cv.begin();
   for (; iv != cv.end(); ++iv) {
     std::vector<double> v = iv->second;
     std::cout << iv->first << "\t = ";
     for (unsigned int i = 0; i < v.size(); i++) {
       std::cout << v[i] << "\t";
     }
     std::cout << std::endl;
   }
 
   std::cout << " =======================================" << std::endl;
 
   return;
 }