CambridgeNuclear / SCONE

Stochastic Calculator Of Neutron transport Equation
https://scone.readthedocs.io
Other
38 stars 22 forks source link

Compilation error with gfortran 13.2 #137

Closed NRavoisin96 closed 1 month ago

NRavoisin96 commented 1 month ago

gfortran 13.2 introduces a compilation error (see attached screenshot) where the compiler seems to wrongfully reject a function passed as an argument during pointer allocation.

compilationErrorgfortran132

In mgNeutronMaterial_inter.f90, changing:

subroutine getMacroXSs_byP(self, xss, p)
    class(mgNeutronMaterial), intent(in) :: self
    type(neutronMacroXSs), intent(out) :: xss
    class(particle), intent(in) :: p
    character(100), parameter :: Here = 'getMacroXSs_byP (mgNeutronMaterial_inter.f90)'

    if (.not. p % isMG) call fatalError(Here, 'CE particle was given to MG data')

    associate (matCache => cache_materialCache(p % matIdx()))

      if (matCache % G_tail /= p % G) then
        ! Get cross sections
        call self % getMacroXSs(xss, p % G, p % pRNG)
        ! Update cache
        matCache % xss = xss
        matCache % G_tail = p % G

      else
        ! Retrieve cross sections from cache
        xss = matCache % xss

      end if

    end associate

  end subroutine getMacroXSs_byP

to:

subroutine getMacroXSs_byP(self, xss, p)
    class(mgNeutronMaterial), intent(in) :: self
    type(neutronMacroXSs), intent(out) :: xss
    class(particle), intent(in) :: p
    integer(smallInt) :: matIdx
    character(100), parameter :: Here = 'getMacroXSs_byP (mgNeutronMaterial_inter.f90)'

    if (.not. p % isMG) call fatalError(Here, 'CE particle was given to MG data')

    matIdx = p % matIdx()
    associate (matCache => cache_materialCache(matIdx))

      if (matCache % G_tail /= p % G) then
        ! Get cross sections
        call self % getMacroXSs(xss, p % G, p % pRNG)
        ! Update cache
        matCache % xss = xss
        matCache % G_tail = p % G

      else
        ! Retrieve cross sections from cache
        xss = matCache % xss

      end if

    end associate

  end subroutine getMacroXSs_byP

fixes the error. Note that this problem does not occur with versions 12 and below.

Awaiting feedback on suggested resolution.

ChasingNeutrons commented 1 month ago

That's annoying. Unless anyone has any objections, I think your suggested fix is a small price for the sake of keeping the latest compiler happy.

Mikolaj-A-Kowalski commented 1 month ago

From my perspective not a problem. It is a bit annoying but ultimately it doesn't matter.
Can you open a pull request with the fix so it can be integrated? Also it will be worth to include a comment to explain why the matIdx variable had to be introduced (above the associate block I think).

NRavoisin96 commented 1 month ago

Done. Awaiting pull request approval.

ChasingNeutrons commented 1 month ago

Resolved by #138