[mesa-users] Bending MESA to your will (AKA using run_star_extras)

Bill Paxton paxton at kitp.ucsb.edu
Mon Aug 17 20:28:30 EDT 2015


Hi Amber,

By "hook" I mean a place inside mesa private code where you can "hang" some code of your own by setting a procedure pointer in the star_info structure to point to a routine of yours, usually in your run_star_extras.  The various "other" routines are examples of using hooks to change or add functionality to mesa/star.

Does that clear it up?   

You can find the current calls on hook routines by grepping 'call s%' in star/private --- here's the list I just got by doing that.



Cheers,
Bill


On Aug 17, 2015, at 5:09 PM, Amber Lauer wrote:

> Could someone clarify what they mean when they say "hook"? I vaguely thought the things one added to run_star_extras.f were hooks. 
> 
> On Mon, Aug 17, 2015 at 4:14 AM, Pablo Marchant <pamarca at gmail.com> wrote:
> But there have already been some equally disruptive changes haven't there? Do you think doing a one time change to turn all the extras_* routines into hooks would be too disruptive? You could just keep them with the same names, and then the only change in the run_star_extras.f would be to assign a procedure pointer for each in extras_controls.
> 
> In any case then, I think I would be happy to have a hook that is called at the very beginning of the evolve_loop (what should it be called?), for the reasons I mentioned earlier. I can of course just make it myself and commit it.
> 
> On Sun, Aug 16, 2015 at 5:58 PM, Bill Paxton <paxton at kitp.ucsb.edu> wrote:
> Hi,
> 
> Hooks are an appealing option instead of adding new routines to run_star_extras, and they are much less of a disruption to existing user code.  So my vote would be to add lots of hooks rather than add any more run_star_extras routines.   New hooks are "invisible" to existing code; new required routines break every existing private version of run_star_extras.
> 
> Historically, it is an accident of timing that we have any run_star_extra routines other than "extra_controls".  Back in the ancient days when I was 1st getting mesa version 1 ready to go, there wasn't an option to store pointers to procedures in structures -- i.e., hooks were not yet possible in that old form of "modern" fortran (they still hadn't caught up with the original C).  As soon as a basic version of procedure variables in structures became available, I happily started adding hooks (and felt that I finally had a real programming language to use for mesa!).  
> 
> As a start could we get a modified version of Josiah's top level flow chart that shows existing and desired hooks at that level (skipping the ones inside "take step" for now).  Then we can easily add the new ones for the next release.
> 
> And then Josiah (and friends) will be perhaps be inspired to add a flowchart for the monster "take step" that show both the logic and where there are hooks for user provided modifications.   That would be a nice next step to take. ;D
> 
> Cheers,
> Bill
> 
> 
> 
> 
> On Aug 16, 2015, at 4:25 AM, Pablo Marchant wrote:
> 
>> Regarding the "prepare for a step phase", has anyone else found a need for an extras function in there? It is a common situation for me to use extras_finish_step to check some conditions and modify controls accordingly for the following step. This works well if I do a normal run from beginning to end, but it does not work quite well when doing restarts. In this case, MESA will just load all controls from the inlist producing an inconsistency on the first step of the restart (or not converging at all depending on what is changed).
>> 
>> I could replicate the code I put on extras_finish_step into extras_startup but having the option to do it in a single place seems more natural.
>> 
>> On Sat, Aug 15, 2015 at 5:23 PM, Josiah Schwab <jwschwab at berkeley.edu> wrote:
>> Hi All,
>> 
>> The 2015 MESA summer school has just wrapped up.  Congratulations to all
>> the students who completed this intensive week!
>> 
>> The opening lecture was an introduction to MESA, with a particular focus
>> on using run_star_extras.f.
>> 
>> A modified version of this material will eventually be merged into the
>> main MESA documentation, but until then, if you're interested in taking
>> your MESA use to the next level, you may want to look at
>> 
>>   http://jschwab.github.io/mesa-2015/
>> 
>> As a teaser, I've attached a flowchart showing how the "extras" hooks
>> fit into MESA.
>> 
>> Best,
>> Josiah
>> 
>> 
>> ------------------------------------------------------------------------------
>> 
>> _______________________________________________
>> mesa-users mailing list
>> mesa-users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/mesa-users
>> 
>> 
>> 
>> 
>> -- 
>> Pablo Marchant Campos
>> M.Sc on Astrophysics, Universidad Católica de Chile
>> PhD student, Argelander-Institut für Astronomie
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> mesa-users mailing list
>> mesa-users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/mesa-users
> 
> 
> 
> 
> -- 
> Pablo Marchant Campos
> M.Sc on Astrophysics, Universidad Católica de Chile
> PhD student, Argelander-Institut für Astronomie
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> mesa-users mailing list
> mesa-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mesa-users
> 
> 
> 
> 
> -- 
> Amber Lauer. M.S. Physics
> PhD Candidate,
> Dept. of Physics & Astronomy,
> Louisiana State University

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20150817/fe27f1a4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list_of_hook_calls
Type: application/octet-stream
Size: 5031 bytes
Desc: not available
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20150817/fe27f1a4/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20150817/fe27f1a4/attachment-0001.html>


More information about the Mesa-users mailing list