boutproject / BOUT-dev

BOUT++: Plasma fluid finite-difference simulation code in curvilinear coordinate systems
http://boutproject.github.io/
GNU Lesser General Public License v3.0
183 stars 95 forks source link

Saving options #2099

Open johnomotani opened 4 years ago

johnomotani commented 4 years ago

Options that were actually used in a run are saved into BOUT.settings.

A backport would be nice to have, but I guess how feasible it is depends on implementation details...

johnomotani commented 4 years ago

For the 'every option as a separate variable' scheme, we would need to make variable names with nested section names. netCDF allows underscore '_', period '.', plus '+', hyphen '-', or at sign '@' (https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_data_set_components.html#object_name). Hopefully at least one of those is not allowed in option names? So we could use say - as a separator?

If we prefixed every variable with "Options-" we'd know which variables were options (so we could add some special handling in xBOUT) and could be pretty sure of avoiding name conflicts.

ZedThree commented 4 years ago

Yes, we should definitely try and save the complete settings as soon as possible.

OptionsNetCDF does some of this already: https://bout-dev.readthedocs.io/en/latest/user_docs/bout_options.html#reading-and-writing-to-netcdf

That uses groups, which I think is the more natural way of saving the hierarchical structure. If I understand the xarray docs correctly, xarray can't load a group structure directly, but you can pass it individual groups to load. xBOUT might then need to iterate over the groups with another library and load them individually perhaps?

I'd really like to be able to deprecate the current DataFile stuff and just use OptionsNetCDF instead, as it's much nicer to use.