[mesa-users] "Extra" Storage Space of User-Defined Vectors

Bill Paxton paxton at kitp.ucsb.edu
Wed Jul 24 17:06:07 EDT 2013


On Jul 24, 2013, at 1:52 PM, Josiah Schwab wrote:

> Hi All,
> 
> In an other_physics routine, suppose I calculate a vector (some quantity
> defined over the run of the star, like density, 1:s% nz).  I may want to
> reuse that vector later on, for example to add it as a profile column.
> In a few cases this is already provided like s% extra_heat for the
> other_energy routines.
> 
> The naive solution is to define a static-size array in run_star_extras.f
> that has a size bigger than the maximum expected value of nz.  That will
> work, but I was wondering whether there are any arrays for whose size is
> automatically managed as the number of zones change.
> 
> There are many places to store extra scalars, but I didn't find
> anything for extra vectors after perusing star/public.
> 
> Thanks,
> Josiah

Hi Josiah,

You can add a few extra vectors without too much trouble.

1) look in star/private/alloc.f for subroutine star_info_arrays
it is the one that manages reallocations.  e.g.,

            call do1_integer(s% mlt_mixing_type, c% mlt_mixing_type)
            if (failed('mlt_mixing_type')) exit
            call do1(s% mlt_mixing_length, c% mlt_mixing_length)
            if (failed('mlt_mixing_length')) exit

2) check star/public/star_data.inc to see how they are declared

      integer, pointer :: mlt_mixing_type(:) ! as defined in mesa/const
         ! this is the value from mlt, before overshooting has been added.
      real(dp), pointer :: mlt_mixing_length(:) 
         ! mixing_length_alpha * scale_height as computed by mlt

3) add declarations for your extra vectors to star_data

      integer, pointer :: extra_integer_vector(:)
      real(dp), pointer :: extra_vector(:) 

4) add them to star_info_arrays so that they'll be allocated

            call do1_integer(s% extra_integer_vector, c% extra_integer_vector)
            if (failed('extra_integer_vector')) exit
            call do1(s% extra_vector, c% extra_vector)
            if (failed('extra_vector')) exit

5) do cd mesa/star/test; ./cleanup; ./mkx

That should do the trick!

If it works, let's add it to the release.

Perhaps we should have some sort of hook so things like this can be done in the future without editing the base sources -- any ideas how that should be done?

Cheers,
Bill








More information about the Mesa-users mailing list