dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #15186
Re: [HG DOLFIN] Automatically read parameters from the following files in increasing
On Mon, Sep 07, 2009 at 12:14:22PM +0200, Johannes Ring wrote:
> On Mon, Sep 7, 2009 at 11:12 AM, Anders Logg<logg@xxxxxxxxx> wrote:
> > On Mon, Sep 07, 2009 at 08:47:00AM +0200, Johannes Ring wrote:
> >> On Sun, Sep 6, 2009 at 12:00 PM, DOLFIN<dolfin@xxxxxxxxxx> wrote:
> >> > One or more new changesets pushed to the primary dolfin repository.
> >> > A short summary of the last three changesets is included below.
> >> >
> >> > changeset: 6951:b552e55f706da220bc3b205976f08e34f1c9a547
> >> > tag: tip
> >> > user: Anders Logg <logg@xxxxxxxxx>
> >> > date: Sun Sep 06 11:57:03 2009 +0200
> >> > files: demo/parameters/cpp/main.cpp dolfin/fem/VariationalProblem.cpp dolfin/parameter/GlobalParameters.cpp dolfin/parameter/Parameters.cpp
> >> > description:
> >> > Automatically read parameters from the following files in increasing
> >> > order of priority:
> >> >
> >> > $HOME/.dolfin/parameters.xml.gz
> >> > $HOME/.dolfin/parameters.xml
> >> > parameters.xml.gz
> >> > parameters.xml
> >> >
> >> > The global parameter set will be *updated* with values found in
> >> > these parameter sets.
> >> >
> >> > Not sure how the first two files work on a Windows system.
> >>
> >> Not very well as HOME is not defined. You should use the USERPROFILE
> >> environment variable on Windows.
> >>
> >> In Python one should use os.path.expanduser("~") which works on all platforms.
> >>
> >> Johannes
> >
> > I'm not sure how to do this and I can't test it. Could you suggest a fix?
> >
> > I guess we would need some #ifdef around the following code in GlobalParameters.cpp:
> >
> > std::string home_directory(std::getenv("HOME"));
> > parameter_files.push_back(home_directory + "/.dolfin/parameters.xml.gz");
> > parameter_files.push_back(home_directory + "/.dolfin/parameters.xml");
>
> This works fine:
>
> diff -r 7d63ee768f5b dolfin/parameter/GlobalParameters.cpp
> --- a/dolfin/parameter/GlobalParameters.cpp Mon Sep 07 11:27:24 2009 +0200
> +++ b/dolfin/parameter/GlobalParameters.cpp Mon Sep 07 12:07:11 2009 +0200
> @@ -23,9 +23,15 @@
>
> // Search paths to parameter files in order of increasing priority
> std::vector<std::string> parameter_files;
> +#ifdef _WIN32
> + std::string home_directory(std::getenv("USERPROFILE"));
> + parameter_files.push_back(home_directory + "\\.dolfin\\parameters.xml.gz");
> + parameter_files.push_back(home_directory + "\\.dolfin\\parameters.xml");
> +#else
> std::string home_directory(std::getenv("HOME"));
> parameter_files.push_back(home_directory + "/.dolfin/parameters.xml.gz");
> parameter_files.push_back(home_directory + "/.dolfin/parameters.xml");
> +#endif
> parameter_files.push_back("parameters.xml.gz");
> parameter_files.push_back("parameters.xml");
>
> Johannes
Looks good. Just go ahead and push it.
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References