anisomt.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <string>
00003 #include "Util.h"
00004 #include "C1DAnisoMTSynthData.h"
00005 #include "MTStation.h"
00006 #include "PTensorMTStation.h"
00007 #include <iterator>
00008 
00009 using namespace std;
00010 
00011 int main(int argc, char *argv[])
00012   {
00013     try
00014       {
00015         if (argc ==1) //if we have no additional command line arguments, output some info
00016 
00017           {
00018             string version = "$Id: anisomt.cpp 1615 2007-12-31 18:48:42Z mmoorkamp $";
00019             cout << endl << endl;
00020             cout << "Program " << version << endl;
00021             cout << "Calculates 1D MT Responses with Anisotropy from input models " << endl;
00022             cout << "Based on Pek and Santos code. " << endl;
00023             cout << "You can give up to 3 command line parameters: " << endl;
00024             cout << "  anisomt modelfilename outfilebase masterfile " << endl << endl;
00025             cout << "  Modelfilename: The name of the file containing the model" << endl << endl;
00026             cout << "  Outfilebase: The name of the outputfiles without ending," << endl;
00027             cout << "  the code will produce 2 files with additional endings .mtt and .ptensor" << endl << endl;
00028             cout << "  Masterfile: A regular MT data file, the frequencies in this files " << endl;
00029             cout << "  will be used as the frequencies for the forward calculation " << endl << endl;
00030             cout << "If not command line parameters are given the program will ask for the first two parameters" << endl;
00031             cout << "and use a standard set of frequencies. "<< endl << endl;
00032           }
00033 
00034         C1DAnisoMTSynthData Synthetic; // create Object for Calculation of Synthetics
00035 
00036         string modelfilename,mttfilename;
00037 
00038         if (argc > 1) // if we have at least one additional command line parameter
00039 
00040           {
00041             modelfilename = argv[1]; // interpret the first one as a model file name
00042           }
00043         else //ask for model file interactively
00044 
00045           {
00046             modelfilename = AskFilename("Model filename: ");
00047           }
00048 
00049         Synthetic.ReadModel(modelfilename); // read in model
00050         if (argc > 2)//if we have at least two command line parameters
00051 
00052           {
00053             mttfilename = argv[2]; //interpret the second one as the name of the output file
00054           }
00055         else
00056           {
00057             cout << "Output Format is .mtt ! Do not append ending. " << endl;
00058             mttfilename = AskFilename("Output Filename: ");
00059           }
00060         if (argc > 3) //if we have 3 command line parameters
00061 
00062           {
00063             MTStation Masterfile(argv[3]); //read data from filename 
00064             Synthetic.SetFrequencies(Masterfile.GetFrequencies()); //set the calculation frequencies to master frequencies
00065           }
00066         Synthetic.GetData(); // Calculate Model
00067         Synthetic.WriteAsMtt(mttfilename); // Write out Mtt file
00068         PTensorMTStation Tensor;
00069         Tensor = Synthetic;
00070         Tensor.WriteData(mttfilename);
00071       }
00072     catch(CFatalException &e)
00073       {
00074         cerr << e.what() << endl;
00075         return -1;
00076       }
00077     catch(...)
00078       {
00079         cerr << "Fatal Error, aborting !" << endl;
00080         return 100;
00081       }
00082   }

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5