[mesa-users] mesa/star problem with ifort 12.0.4

Bill Paxton paxton at kitp.ucsb.edu
Mon Mar 11 13:26:57 EDT 2013


Hi,

Are you using ifort to compile mesa?   If so, you might want to help track down
a problem that is breaking mesa/star when compiled with ifort 12.0.4 on a mac.
It is present in version 4836 -- many of the test suite cases run, but there
are several that segfault in the same location immediately at the start
of a run.  The segfault is in these 5 lines in the set_xa routine in adjust_mass.

            do k=k_const_mass+1,nz
               do j=1,species
                  s% xa(j,k) = xa_old(j,k)
               end do
            end do

I printed out the sizes of the arrays and they are okay.
If I turn on bounds checking, the segfault doesn't happen.
If I leave bounds checking off, and change from -O2 to -O,
the segfault doesn't happen.
If I rewrite the nested loops as 
            forall (j=1:species,k=k_const_mass+1:nz) s% xa(j,k) = xa_old(j,k)
the segfault doesn't happen even with -O2.
I'm not willing to change the do's to forall's to paper over the problem!
In fact, I'm removing forall's since they making array temporaries
on the stack, and for very large arrays that can produce a segfault.


Does this happen when you run it?   Does it happen in newer ifort's?


Thanks,
Bill


here's the routine with added debugging statements

      subroutine set_xa( &
            s, nz, k_const_mass, species, xa_old, xaccrete, &
            old_cell_xbdy, new_cell_xbdy, mmax, old_cell_mass, new_cell_mass, ierr)
         ! set new values for s% xa(:,:)
         type (star_info), pointer :: s
         integer, intent(in) :: nz, k_const_mass, species
         real(dp), intent(in) :: mmax
         real(dp), intent(in), pointer :: xa_old(:, :), xaccrete(:)
         real(dp), dimension(:), intent(in), pointer :: &
            old_cell_xbdy, new_cell_xbdy, old_cell_mass, new_cell_mass ! (nz)
         integer, intent(out) :: ierr         
         integer :: k, j, op_err
         real(dp), parameter :: max_sum_abs = 10d0
         real(dp), parameter :: xsum_tol = 1d-2  
         include 'formats'       
         ierr = 0
         if (dbg_adjm) write(*,2) 'set_xa: k_const_mass', k_const_mass
         if (k_const_mass < nz) then
            ! for k >= k_const_mass have m_new(k) = m_old(k),
            ! so no change in xa_new(:,k) for k > k_const_mass
            write(*,3) 'set xa', k_const_mass, nz
            write(*,2) 'size(s% xa, dim=1)', size(s% xa, dim=1)
            write(*,2) 'size(xa_old, dim=1)', size(xa_old, dim=1)
            write(*,2) 'species', species
            write(*,2) 'size(s% xa, dim=2)', size(s% xa, dim=2)
            write(*,2) 'size(xa_old, dim=2)', size(xa_old, dim=2)
            write(*,2) 'nz', nz
            write(*,1) 's% xa(1,k_const_mass+1)', s% xa(1,k_const_mass+1)
            write(*,1) 's% xa(species,nz)', s% xa(species,nz)
            write(*,1) 'xa_old(1,k_const_mass+1)', xa_old(1,k_const_mass+1)
            write(*,1) 'xa_old(species,nz)', xa_old(species,nz)
            forall (j=1:species,k=k_const_mass+1:nz) s% xa(j,k) = xa_old(j,k)
            write(*,*) 'done forall'
            do k=k_const_mass+1,nz
               do j=1,species
                  s% xa(j,k) = xa_old(j,k)
               end do
            end do
            write(*,*) 'done'
         end if
!$OMP PARALLEL DO PRIVATE(k, op_err)
         do k = 1, k_const_mass
            op_err = 0
            call set1_xa(s, k, nz, species, xa_old, xaccrete, &
               old_cell_xbdy, new_cell_xbdy, mmax, old_cell_mass, new_cell_mass, op_err)
            if (op_err /= 0) ierr = op_err
         end do
!$OMP END PARALLEL DO

      end subroutine set_xa










More information about the Mesa-users mailing list