[Mesa-users] length of cell
Pablo Marchant
pamarca at gmail.com
Sat Jul 4 05:35:17 EDT 2020
Dear Ebrahim,
this is exactly the same issue from your previous post. If your question
now is in regard to how you should replace r(s% nz+1), think about what r
exactly means. In MESA s% r(i) is defined as the outer radius of cell i,
while r(i+1) represents, for i+1<nz, the inner radius of cell i. As nz
represents the innermost cell, r(s% nz+1) (if it existed) would represent
the inner radius of the central cell, for which you can imagine what the
value should be. So the simple answer is to do your do loop from 1 to s%
nz-1, and cover the case of nz outside of the loop as a special one.
A different comment, the way your do loop is written you're overwriting
part3_h1 in each iteration, likely you want to be adding up results.
Cheers
On Sat, Jul 4, 2020 at 10:43 AM Francis Timmes via Mesa-users <
mesa-users at lists.mesastar.org> wrote:
> the arrays run from i=1 to i=nz.
> trying to access an array at i=0 or i=nz+1 would produce an out of bounds
> error.
>
> examine your part3_h1 expression when i=1 and i=nz ;
> do they access array positions that are invalid?
>
> fxt
>
>
>
>
> > On Jul 3, 2020, at 11:16 PM, Ebrahim Hassani via Mesa-users <
> mesa-users at lists.mesastar.org> wrote:
> >
> > Dear Mesa-user
> >
> > I need to calculate the length of each cell and then multiply the result
> to the radius of the star at the position of each cell. The piece of code
> that I used in 'run_star_extras.f' file is :
> >
> > part3_h1 = 0
> > do i = s% nz, 1, -1
> > part3_h1 = (s% r(i)) * ( (s% r(i)) - (s% r(i+1)) )
> > end do
> >
> > but it gives the below error:
> >
> > Fortran runtime error: Index '875' of dimension 1 of array 's%r' above
> upper bound of 874
> >
> > Is there any other way to calculate the length of each cell?
> > _______________________________________________
> > mesa-users at lists.mesastar.org
> > https://lists.mesastar.org/mailman/listinfo/mesa-users
> >
>
> _______________________________________________
> mesa-users at lists.mesastar.org
> https://lists.mesastar.org/mailman/listinfo/mesa-users
>
>
--
Pablo Marchant Campos
M.Sc on Astrophysics, Universidad Católica de Chile
PhD on Astrophysics, Argelander-Institut für Astronomie, Universität Bonn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20200704/5a7941c1/attachment.htm>
More information about the Mesa-users
mailing list