#include "drtp.h"

int main(int argc, char *argv[])
{
	if (argc == 1)
	{
		std::clog << "RTP with variable geomagnetic parameters." << std::endl;
		std::clog << "Usage: ./drtp <config-file>" << std::endl << std::endl;
		std::clog << "Available options:" << std::endl;
		std::clog << "input-grid = <Directory to the netcdf file of the deltaT anomalies>" << std::endl;
		std::clog << "output-grid = <Directory to the output netcdf file>" << std::endl;
		std::clog << "grid-para = <x-axis>,<y-axis>,<data> (Names of data attribute of the netcdf file. The default is x,y,z.)" << std::endl;
		std::clog << "geomag-exe = <Directory to the executable of the geomag.exe program>" << std::endl;
		std::clog << "geomag-para = <Parameters needed by the geomag.exe program>" << std::endl;
		std::clog << "geomag-output = <Directory to the output file of the geomag.exe program>" << std::endl;
		std::clog << "IGRF = <directory to the IGRF model file>" << std::endl;
		std::clog << "call-geomag = yes|no <Call the geomag.exe program to calculate the geomagnetic parameters>" << std::endl;
		std::clog << "mean-geomag = <inc>/<dec> (Use a set of mean geomagnetic parameters defined by the user. \
Use this option to run a non-differential RTP process.)" << std::endl;
		std::clog << "taylor-order = <order> (Differential orders of the taylor series. Must be between 1 and 5. The default order is 2.)" << std::endl;
		std::clog << std::endl << "Required options:" << std::endl;
		std::clog << "1. Non-differential RTP" << std::endl;
		std::clog << "input-grid mean-geomag output-grid(optional) grid-para(optional)" << std::endl;
		std::clog << "2. Differential RTP with no geomag.exe output" << std::endl;
		std::clog << "input-grid output-grid(optional) geomag-exe geomag-para geomag-output IGRF call-geomag(yes) taylor-order(optional) grid-para(optional)" << std::endl;
		std::clog << "3. Differential RTP with geomag.exe output" << std::endl;
		std::clog << "input-grid output-grid(optional) geomag-output call-geomag(no) taylor-order(optional) grid-para(optional)" << std::endl;
		return -1;
	}

	try
	{
		DRTP d;
		d.ReadConfig(argv[1]);
		d.Process();
	}
	catch (std::exception &e)
	{
		GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
	}
	return 0;
}