Skip to content

Refactor read_extra_..._inlist into arrays #368

@warrickball

Description

@warrickball

Since time immemorial (before r4366), various MESA inlists have had the option to read other inlists recursively, with options like

    read_extra_star_job_inlist1 = .false.
    extra_star_job_inlist1_name = 'undefined'
    read_extra_star_job_inlist2 = .false.
    extra_star_job_inlist2_name = 'undefined'
    read_extra_star_job_inlist3 = .false.
    extra_star_job_inlist3_name = 'undefined'
    read_extra_star_job_inlist4 = .false.
    extra_star_job_inlist4_name = 'undefined'
    read_extra_star_job_inlist5 = .false.
    extra_star_job_inlist5_name = 'undefined'

The canonical default inlist itself uses this to load other inlists.

Should we change these to arrays? I say yes. We can also scrap the logical flag and just use the empty string '' to indicate that an inlist should not be read (unless I'm missing a use case where this helpful). e.g. I imagine a user would write

    extra_star_job_inlist_name(1) = 'inlist_project'

and the defaults file containing

    extra_star_job_inlist_name(:) = ''

to cover all values that aren't used. E.g., in a loop like this should work:

do i=1, max_extra_inlists
   if (extra_star_job_inlist_name(i) == '') continue
   ... ! otherwise read it

If the logical flag is useful, we can instead use

do i=1, max_extra_inlists
   if (.not. read_extra_star_job_inlist(i)) continue
   ... ! otherwise read it

The only downside I can think of is that this will (trivially) break some backwards compatibility but I don't think that's a strong argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions