ForestClaw / forestclaw

Quadtree/octree adaptive PDE solver based based on p4est.
http://www.forestclaw.org
BSD 2-Clause "Simplified" License
58 stars 21 forks source link

Command line parsing #75

Closed donnaaboise closed 6 years ago

donnaaboise commented 9 years ago

Originally reported by: Donna Calhoun (Bitbucket: donnaaboise, GitHub: donnaaboise)


I modified the options parsing routine (for the command line) to return a value. Does this look okay?

In new file fclaw2d_options.c (was amr_options_parse in amr_options.c) :

#!C
int fclaw2d_parse_cl(sc_options_t * opt,
                     int argc, char **argv,
                     int log_priority)
{
    int retval;

    retval = sc_options_parse (sc_package_id, SC_LP_ERROR, opt, argc, argv);
    if (retval < 0)
    {
        sc_options_print_usage (sc_package_id, log_priority, opt, NULL);
        fclaw2d_global_log (log_priority, "Command line option parsing failed.  " \
                            "Please see above usage information\n");
        return retval;
    }
    if (sc_is_root ())
    {
        retval = sc_options_save (sc_package_id, SC_LP_ERROR, opt,
                                  "fclaw2d_defaults.ini.used");
        if (retval < 0)
        {
            fclaw2d_global_log (log_priority, "Cannot save <options file>.ini.used.  " \
                                "Make sure you have write permission in this " \
                                "directory\n");
            return retval;
        }
    }
    return retval;
}

donnaaboise commented 9 years ago

Original comment by Donna Calhoun (Bitbucket: donnaaboise, GitHub: donnaaboise):


Cool. Yes, I see where "fclaw_options.ini" can be passed in. But if I understand, I should continue to use my fclaw_options_read_from_file until you have the configfile loading included.

donnaaboise commented 9 years ago

Original comment by Carsten Burstedde (Bitbucket: cburstedde, GitHub: cburstedde):


The options branch provides an interface to name configuration files to be loaded. What's still missing is to add a search through the possible paths for each file and to load it from there. All of this can be done behind the scenes in libsc and fclaw_base, which I'll be working on.

donnaaboise commented 9 years ago

Original comment by Carsten Burstedde (Bitbucket: cburstedde, GitHub: cburstedde):


I think this looks fine. I'm just wondering if we could move a couple functions into the .c file and make them static to clean up the interface. To the outside user it would for example be unclear whether they need to call postprocess and convert_int_array.

What we decide in issue #66 will factor in here, in the matter of sensible default values.

donnaaboise commented 9 years ago

Original comment by Donna Calhoun (Bitbucket: donnaaboise, GitHub: donnaaboise):


This has been modified a few more times - see fclaw_options.c, in branch fix_options.

donnaaboise commented 6 years ago

Outdated issue?