MFIX-25.3 issue with force chain and SQP DEM

Hi,

I am running into a new issue (to me)

bedload_water_only.mfx (15.1 KB):

At line 712 of file /gpfs/home/ebreard/miniforge3/envs/mfix-25.3/share/mfix/src/model/des/sq_calc_force_superdem.f
Fortran runtime error: Index ‘2251’ of dimension 1 of array ‘fchain_midpoint’ outside of expected range (1:2250)

@jeff.dietiker , it takes 1.5h on HPC to see the error (at about 0.3s).

Hey @ebreard, didn’t you write the force chain code? :wink:

Looking quickly at the section of sq_calc_force_superdem

            IF(WRITE_FORCE_CHAIN) THEN
! Resize arrays if needed
               IF(FCHAINC>=FCHAINC_OLD.AND.MOD(FCHAINC,100)==0) THEN
                  old_size = size(FCHAIN_MIDPOINT,1)
                  IF(FCHAINC>=INT(0.9*old_size)) THEN
                     new_size = INT(1.5*old_size)
                     call real_grow2_reverse(FCHAIN_MIDPOINT,new_size)
                     FCHAIN_MIDPOINT(old_size+1:new_size,:) = UNDEFINED
                     ....

The line

    IF(FCHAINC>=FCHAINC_OLD.AND.MOD(FCHAINC,100)==0) THEN

seems questionable to me. If we need to resize, we need to resize. Why are we only doing it when FCHAINC is a multiple of 100? Can you try taking out that condition and see if the problem goes away? Change line 669 to

    IF(FCHAINC>=FCHAINC_OLD) THEN

Just a hunch, but something smells fishy with that resize code.

– Charles

well… not for SQP :wink:

This may be something I put in for debugging. Does Charles’ fix help?

It looks good now, @jeff.dietiker , I passed the time where it failed. I will let you know if anything were to change but this is an easy fix then!

I just ran into an issue where restart_1 failed on a SQP sim pointing to the same part of the code, replacing the line as Charles mentioned allowed the restart to go ON.

1 Like