Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

Program Exception - array bounds exceeded

YenShih_C_
Beginner
1,448 Views

Hello,

I have a problem while running a fixed format Fortran program.

I use IMSL to calculate a integral equation: F(T)=exp(-Ea/T) dT, where Ea is a 5*3 matrix of random number.

Somehow the integral equation in the real function F(T) can't read the value Ea which is defined in main program.

When I execute the program, it shows "forrtl : severe <161> : Program Exception - array bounds exceeded"

Therefore, I would like to ask how to read the value from main program and execute successfully.

Thank you!

 

Here is the entire program,

program main
    use imsl
    implicit real*8 (a-h,o-z)
    integer NOUT
      
    real, external :: F
    real D,U
    real, parameter :: errabs = 1E-5
    real, parameter :: errrel = 1E-5
    real ans, err
    real Ea(12,12)
    common Ea,i,k
    namelist/limit/No_of_agen,No_of_comp

    D=0
    U=3
    No_of_agen=5
    No_of_comp=3

!-----------------------------------------------------
! initail random Ea
!-----------------------------------------------------
    Do k=1,No_of_agen
      Do i=1,No_of_comp  

        call random_number(rn01)
        Ea(k,i)=10*rn01

        write(*,*) Ea(k,i)
      end do
    end do

!-----------------------------------------------------
! integral of each Ea
!-----------------------------------------------------
    Do 10 k=1,No_of_agen
      Do 20 i=1,No_of_comp
    
        ans=0

        Call QDAGS (F, D, U, errabs, errrel, ans, err)

        write(*,*) ans

20   continue
10  continue

    end 

    real function F(T)
    implicit real*8 (a-h,o-z)
    real Ea(12,12)
    real T
    common /part1/ Ea,i,k
    
    F = EXP(-Ea(k,i)/T)
      write(*,*) Ea(k,i)

    return
    end function

0 Kudos
2 Replies
mecej4
Honored Contributor III
1,448 Views

You have two different common blocks. The one in the main program is blank common, and the one in the subroutine is labeled /part1/ . Make the two blocks the same.

If you intend to call QDAGS using the implicit (F77) interface, do not have a USE IMSL... statement in the caller. The F95+ interface has the RESULT variable as the fourth argument, whereas the implicit interface contains ERRABS in that position.

0 Kudos
YenShih_C_
Beginner
1,448 Views

Thank you so much!

The problem has been solved!

Thank you!

0 Kudos
Reply