Good evening, I was wondering if there was a way to import parameters from file in FreeFem++, for example in the way JSON does. I am aware of the existence of the getARGV() method but I was hoping for something more practical that didn’t require the insertion of the parameters through command line, as in my case they would be too many and it would definitely require too much time.
Hello,
if you have the data file “datafile.dat” as
1. -3. 2.5
4. 6.
2
You can read it with
real a,b,c,d,e;
int nn;
{
ifstream readparams("datafile.dat");
readparams >> a >> b >> c;// read the first line
readparams >> d >> e;// read second line
readparams >> nn;// read the third line
}
cout << "a=" << a << " b=" << b << " c=" << c << " d=" << d << " e=" << e << " nn=" << nn << endl;
You get the output a=1 b=-3 c=2.5 d=4 e=6 nn=2
I hope this answers your question.