[mesa-users] Code snippets to restart a from_file search in astero module

Warrick Ball wball at astro.physik.uni-goettingen.de
Wed Apr 20 06:00:31 EDT 2016


Oops!  Forgot a line in astero_data.f, around line 427 (under 
namelist /astero_search_controls/ &):

   restart_from_file_from_file, &

Fixed file attached.

W



------------
Warrick Ball
Postdoc, Institut für Astrophysik Göttingen
wball at astro.physik.uni-goettingen.de
+49 (0) 551 39 5069

On Wed, 20 Apr 2016, Warrick Ball wrote:

> Hi all,
>
> Some time ago, I coded up a feature that I've found useful, so I thought I 
> should share it.  The astero module includes various optimization routines as 
> well as an option to try the parameter values listed in a file.  This is 
> selected by
>
>  search_type = 'from_file'
>
> in inlist_astero_search_controls.  The other methods have options to restart 
> (i.e. resume from a previous run) but from_file doesn't.  So, because MESA is 
> so easy to understand and modify, I added one!  I have my own use case (using 
> external programs to choose parameters) but the obvious use is if the run 
> terminates for some reason. e.g. if you, like me, have hard upper limits on 
> how long single cluster jobs can run.
>
> Anyway, my implementation (which is very basic and not thoroughly tested) 
> works like this.  Referring to r8118, I added the following snippets, which 
> are included in the attached files.
>
> First, a default option, in star/astero/defaults/astero_search.defaults at 
> line 387:
>
>  restart_from_file_from_file = .false.
>
> Second, to read this option, in star/astero/src/astero_data.f at line 194:
>
>  logical :: restart_from_file_from_file
>
> Finally, to use this flag to skip ahead in the output file, in 
> star/astero/src/run_star_extras_astero.f, I first added an integer to count 
> how many lines to add.  It's declared at line 264:
>
>  integer :: iounit, num_to_read, from_file_skip_number
>
> and initialized to 0 at line 271:
>
>  from_file_skip_number = 0
>
> Then, at line 274, I read the existing samples if necessary:
>
>  if (restart_from_file_from_file) then
>    call read_samples_from_file(from_file_output_filename, ierr)
>    if (ierr /= 0) return
>    from_file_skip_number = sample_number
>    sample_number = 0
>    write(*,2) 'from_file_skip_number', from_file_skip_number
>  end if
>
> and at line 346, skip them:
>
>  if (sample_number < from_file_skip_number) then
>    sample_number = sample_number+1
>    cycle
>  end if
>
> With these additions, if you ask to restart from file, the from_file method 
> will preserve your existing results.  Note that there is no checking that the 
> results actually correspond to your input file!  It's basically just reading 
> the existing data and checking how many lines to skip in the input file. 
> This possibly causes a mismatch if MESA fails to find a matching chi^2 for a 
> particular run but I simply have a script that, when the MESA exits 
> completely, reads the output file and writes the input parameters to the 
> input file so that they match.
>
> Cheers,
> Warrick
>
>
>
>
>
>
> ------------
> Warrick Ball
> Postdoc, Institut für Astrophysik Göttingen
> wball at astro.physik.uni-goettingen.de
> +49 (0) 551 39 5069
-------------- next part --------------
A non-text attachment was scrubbed...
Name: astero_data.f
Type: text/x-fortran
Size: 80647 bytes
Desc: 
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20160420/f031fe22/attachment.bin>


More information about the Mesa-users mailing list