Skip to content

Commit

Permalink
Make changing file names easier
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlis committed Jun 15, 2017
1 parent bb4ae06 commit 2d79402
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions bin/seispp/export_to_matlab/export_to_matlab.cc
Expand Up @@ -14,12 +14,14 @@ using namespace SEISPP;

void usage()
{
cerr << "export_to_matlab [-pf pffile] < in "
cerr << "export_to_matlab [-x1 x1f -x2 x2f -x3 x3f -pf pffile] < in "
<<endl
<< "Exports serialized seispp 3C ensemble to 3 matlab matrices"<<endl
<< "(Accepts only text format input)"<<endl
<< "Default files are T.dat, R.dat, and L.dat"<<endl
<< "Use alternate pf pffile to change naming"<<endl;
<< "Exports serialized seispp 3C ensemble to 3 matlab matrices in 3 files"<<endl
<< "Use -x1, -x2, or -x3 to set file names for components 1, 2, 3"<<endl
<< "Default files are x1=T.dat, x2=R.dat, and x3=L.dat"<<endl
<< "Default names can also be changed by editing default pf file "
<< "export_to_matlab.pf"<<endl
<< "(Accepts only text format input)"<<endl;
exit(-1);
}
vector<dmatrix> convert_to_matrices(ThreeComponentEnsemble& d)
Expand Down Expand Up @@ -90,10 +92,11 @@ int main(int argc, char **argv)
{

int i;
const int narg_required(0);
char *pffile=strdup("export_to_matlab");

for(i=narg_required+1;i<argc;++i)
/* We have to pass through the arg list twice - the first pass
is just to set alterntive pf if requested */
for(i=1;i<argc;++i)
{
string sarg(argv[i]);
if(sarg=="-pf")
Expand All @@ -102,8 +105,6 @@ int main(int argc, char **argv)
if(i>=argc)usage();
pffile=argv[i];
}
else
usage();
}
try{
Pf *pf;
Expand All @@ -116,6 +117,36 @@ int main(int argc, char **argv)
string x1file=control.get_string("component1_filename");
string x2file=control.get_string("component2_filename");
string x3file=control.get_string("component3_filename");
for(i=1;i<argc;++i)
{
string sarg(argv[i]);
if(sarg=="-pf")
{
/* in this pass we just skip and can assume the arg following
-pf was there */
++i;
}
else if(sarg=="-x1")
{
++i;
if(i>=argc)usage();
x1file=string(argv[i]);
}
else if(sarg=="-x2")
{
++i;
if(i>=argc)usage();
x2file=string(argv[i]);
}
else if(sarg=="-x3")
{
++i;
if(i>=argc)usage();
x3file=string(argv[i]);
}
else
usage();
}
StreamObjectReader<ThreeComponentEnsemble> ia;
ThreeComponentEnsemble d;
d=ia.read();
Expand Down

0 comments on commit 2d79402

Please sign in to comment.