[FLASH-BUGS] Species Flux Handling with USM MHD in FLASH 4.3

Jason Galyardt jason.galyardt at gmail.com
Tue Jan 5 11:12:14 CST 2016


Klaus,

I have had a chance to try the remaining two experiments you requested; the
results are below. I've reverted hy_uhd_unsplit.F90 to the release version
in FLASH 4.3. The short answer is that I'm still perplexed, but it might be
a problem with undefined pointers (i.e. invalid targets). Do you have any
other experiments to try?

Regards,
Jason

On Fri, Dec 18, 2015 at 9:27 PM, Jason Galyardt <jason.galyardt at gmail.com>
wrote:


> It would be helpful if you could try both of the following experiments.
>
>>
>> A. In hy_uhd_unsplit.F90 -- make sure you edit the version of this
>> file that actually gets used for your setup! -- find the lines
>>
>> #if (NSPECIES+NMASS_SCALARS) > 0
>>      if (hy_fullSpecMsFluxHandling .AND. hy_fullRiemannStateArrays &
>>           .AND. NFACE_VARS > 0 .AND. NDIM > 1) then
>>         ! for hy_spcR:
>>         call hy_memAllocScratch(CENTER,&
>>              1,&
>>              hy_numXN,&
>>              2,0,0, &
>>              blockList(1:blockCount), &
>>              highSize=NDIM)
>>         ! for hy_spcL:
>>         call hy_memAllocScratch(SCRATCH_CTR,&
>>              1,&
>>              hy_numXN,&
>>              2,0,0, &
>>              blockList(1:blockCount), &
>>              highSize=NDIM)
>>      end if
>> #endif
>>
>> Change the two lines
>>              2,0,0, &
>> into
>>              3,0,0, &
>> or
>>              4,0,0, &
>> each. (This should result in allocating some auxiliary arrays with more
>> space for guard cells, rather than trying to economize on memory space;
>> slices of these auxiliary arrays are what eventually gets passed to
>> hy_uhd_DataReconstructNormalDir_MH as optional arguments Sl and Sr.)
>>
>>
After reverting hy_uhd_unsplit.F90 to the release version (4.3), I tried
experiment A and FLASH failed in exactly the same way at the same point.
Here's the back trace:

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line
Source
libintlc.so.5      00002B2C3BE691F9  Unknown               Unknown  Unknown
libintlc.so.5      00002B2C3BE67B70  Unknown               Unknown  Unknown
libifcore.so.5     00002B2C3ACD4DDF  Unknown               Unknown  Unknown
libifcore.so.5     00002B2C3AC3C4CF  Unknown               Unknown  Unknown
libifcore.so.5     00002B2C3AC4DBC3  Unknown               Unknown  Unknown
libpthread.so.0    0000003968C0ECA0  Unknown               Unknown  Unknown
flash4             000000000112A4F5  hy_uhd_datarecons         366
hy_uhd_DataReconstructNormalDir_MH.F90
flash4             00000000012F58B0  hy_uhd_datarecons         535
hy_uhd_dataReconstOneStep.F90
flash4             00000000015AAD84  hy_uhd_getriemann         621
hy_uhd_getRiemannState.F90
flash4             00000000016AC681  hy_uhd_unsplit_           496
hy_uhd_unsplit.F90
flash4             000000000075A25D  hydro_                     67
Hydro.F90
flash4             00000000004A289D  driver_evolveflas         287
Driver_evolveFlash.F90
flash4             0000000000503EE1  MAIN__                     51
Flash.F90
flash4             000000000041A176  Unknown               Unknown  Unknown
libc.so.6          000000396801D9C4  Unknown               Unknown  Unknown
flash4             000000000041A079  Unknown               Unknown  Unknown



> B. Put a protection against accessing optionals arguments that are
>> not present into hy_uhd_DataReconstructNormalDir_MH.F90.
>> The region with the offending statement might end up looking like this:
>>
>> #if (NSPECIES+NMASS_SCALARS) > 0
>>      if (hy_fullSpecMsFluxHandling) then
>>       if (present(Sr) .AND. present(Sl)) then
>>         .....
>>         Sr = Sc+0.5*delbarSp
>>         .....
>>       endif
>>      endif ! (hy_fullSpecMsFluxHandling)
>> #endif /*  (NSPECIES+NMASS_SCALARS) > 0 */
>>
>>
In addition, I added a similar presence check for SpcSig in
hy_uhd_DataReconstructNormalDir_MH.F90, around line 287:

#if (NSPECIES+NMASS_SCALARS) > 0
     if (hy_fullSpecMsFluxHandling) then
        vm1Ptr => Sm (:)
        vc0Ptr => Sc (:)
        vp1Ptr => Sp (:)

        if (present(SpcSig)) then ! added for extra protection.
           call hy_uhd_upwindTransverseFlux&

(dir,hy_transOrder,vm1Ptr,vc0Ptr,vp1Ptr,lambda0,leig0,reig0,HY_NSPEC,SpcSig,speciesScalar=.true.)
        end if
     endif
#endif

After making this change, I still get a crash at almost the same point, but
with a different error message:

forrtl: severe (193): Run-Time Check Failure. The variable 'var$746' is
being used without being defined
Image              PC                Routine            Line
Source
flash4             00000000015AAE04  hy_uhd_getriemann         621
hy_uhd_getRiemannState.F90
flash4             00000000016AC701  hy_uhd_unsplit_           496
hy_uhd_unsplit.F90
flash4             000000000075A25D  hydro_                     67
Hydro.F90
flash4             00000000004A289D  driver_evolveflas         287
Driver_evolveFlash.F90
flash4             0000000000503EE1  MAIN__                     51
Flash.F90
flash4             000000000041A176  Unknown               Unknown  Unknown
libc.so.6          000000379A61D9C4  Unknown               Unknown  Unknown
flash4             000000000041A079  Unknown               Unknown  Unknown

I then added a few more optional argument presence checks to
hy_uhd_getRiemannState.F90, around line 606:

if (order == 1) then
                 !! DEV: THE FIRST ORDER SHOULD GO INTO THE DATA
RECONSTRUCT ONE STEP TO
GET

                 !! TRANSVERSE
FLUXES

                 if (.NOT. allTransUpdateOnly &
                      .and. present(hy_SpcL) .and. present(hy_SpcR)) then !
J.Galyardt
debugging

                    do iDim = 1,NDIM
                       call
fallbackToFirstOrder(iDim,Wn(:,iDim),Wp(:,iDim),Vc,hy_SpcL,hy_SpcR,U,i,j,k)
                    enddo
                 end if

              else ! for high-order
schemes



                 !! Left and right Riemann state
reconstructions

                 if (hy_fullSpecMsFluxHandling .AND. hy_numXN > 0 &
                      .AND. present(hy_SpcR) &
                    .and. present(hy_SpcL) .and. present(hy_SpcSig)) then !
J.Galyardt
debugging

                    call hy_uhd_dataReconstOnestep&
                      (blockID,blkLimitsGC,    &
                       order,i,j,k,dt,del,     &
                       ogravX,ogravY,ogravZ,   &
                       DivU,FlatCoeff,         &
                       TransX_updateOnly,      &
                       TransY_updateOnly,      &
                       TransZ_updateOnly,      &
                       Wp,Wn,                  &
                       sig    (  1,1,i,j,k),   &
                       lambda (  1,1,i,j,k),   &
                       leftEig(1,1,1,i,j,k),   &
                       rghtEig(1,1,1,i,j,k),   &
                       cellCfl, &
                       hy_SpcR,hy_SpcL,hy_SpcSig)


After this test, I received effectively the same error as the previous test:

forrtl: severe (193): Run-Time Check Failure. The variable 'var$746' is
being used without being defined
Image              PC                Routine            Line
Source
flash4             00000000015AAEBB  hy_uhd_getriemann         623
hy_uhd_getRiemannState.F90
flash4             00000000016AC7B9  hy_uhd_unsplit_           496
hy_uhd_unsplit.F90
flash4             000000000075A25D  hydro_                     67
Hydro.F90
flash4             00000000004A289D  driver_evolveflas         287
Driver_evolveFlash.F90
flash4             0000000000503EE1  MAIN__                     51
Flash.F90
flash4             000000000041A176  Unknown               Unknown  Unknown
libc.so.6          0000003900E1D9C4  Unknown               Unknown  Unknown
flash4             000000000041A079  Unknown               Unknown  Unknown

Line 623 in hy_uhd_getRiemannState.F90 is

call hy_uhd_dataReconstOnestep&

as indicated in the modified code block above. So, this tells me that the
optional arguments to hy_uhd_getRiemannState(), hy_SpcR, hy_SpcL, and
hy_SpcSig, are present. However, they are pointers and their targets may
not be properly assigned.  This hypothesis seems to be backed up in the
forrtl error message. From what I've read, 'var$746' is supposed to
indicate the function / subroutine and variable name, separated by a '$',
that's failing the run-time check. However, this reference seems to be
junk, which can happen when a pointer is not pointing to a valid target. I
have a fair amount of experience with pointers in C/C++, but not Fortran
90. What's the best way to ferret out the root of this problem?


More information about the flash-bugs mailing list