/**********************************************************

This software is part of J.-S. Caux's ABACUS library.

Copyright (c) J.-S. Caux.

-----------------------------------------------------------

File:  Smoothen_ODSLF_DSF.cc

Purpose:  produces .dsf and .ssf files from a .raw file

***********************************************************/

#include "ABACUS.h"

using namespace std;
using namespace ABACUS;


int main(int argc, char* argv[])
{
  if (argc != 10 && argc != 11) { // Print out instructions
    cout << "Usage of Smoothen_ODSLF_DSF executable: " << endl << endl;
    cout << "Provide arguments using one of the following options:" << endl << endl;
    cout << "1) (for general momenta) whichDSF Delta N M iKmin iKmax ommin ommax Nom gwidth" << endl << endl;
    cout << "2) (for fixed momentum) whichDSF Delta N M iKneeded ommin ommax Nom gwidth" << endl << endl;
  }

  else if (argc == 11) { // !fixed_iK
    char whichDSF = *argv[1];
    DP Delta = atof(argv[2]);
    int N = atoi(argv[3]);
    int M = atoi(argv[4]);
    int iKmin = atoi(argv[5]);
    int iKmax = atoi(argv[6]);
    DP ommin = atof(argv[7]);
    DP ommax = atof(argv[8]);
    int Nom = atoi(argv[9]);
    DP gwidth = atof(argv[10]);

    stringstream filenameprefix;
    ODSLF_Data_File_Name (filenameprefix, whichDSF, Delta, N, M, iKmin, iKmax, 0.0, 0);
    string prefix = filenameprefix.str();

    DP normalization = twoPI;

    cout << "Smoothing:  sumcheck = " << Smoothen_RAW_into_SF (prefix, iKmin, iKmax, 0.0, ommin, ommax,
							       Nom, gwidth, normalization) << endl;

    Write_K_File (N, iKmin, iKmax);
    Write_Omega_File (Nom, ommin, ommax);

  }

  else if (argc == 10) { // fixed_iK
    char whichDSF = *argv[1];
    DP Delta = atof(argv[2]);
    int N = atoi(argv[3]);
    int M = atoi(argv[4]);
    int iKneeded = atoi(argv[5]);
    DP ommin = atof(argv[6]);
    DP ommax = atof(argv[7]);
    int Nom = atoi(argv[8]);
    DP gwidth = atof(argv[9]);

    bool fixed_iK = true;

    stringstream filenameprefix;
    Data_File_Name (filenameprefix, whichDSF, Delta, N, M, fixed_iK, iKneeded, 0.0, 0);
    string prefix = filenameprefix.str();

    DP normalization = twoPI;
    int iKmin = iKneeded;
    int iKmax = iKneeded;

    cout << "Smoothing:  sumcheck = " << Smoothen_RAW_into_SF (prefix, iKmin, iKmax, 0.0, ommin, ommax,
							       Nom, gwidth, normalization) << endl;
  }

  else ABACUSerror("Wrong number of arguments to Smoothen_Heis_DSF executable.");
}