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

Compiling with -check bounds

Ashwin_D_
Beginner
5,068 Views

I have looked at this thread - https://software.intel.com/en-us/forums/topic/271337 and I have recompiled my code with -check bounds. However this does not print as output anywhere that array boundaries have been exceeded.

However if there is a subroutine that is having an array declared as  (*)  will that mean this will bypass all array bound checking ?

 

Regards,

Ashwin.

0 Kudos
7 Replies
TimP
Honored Contributor III
5,068 Views

Yes, we've been told that only the Nag Fortran implements bounds checking for assumed size arrays.

Surprisingly often, we see arrays declared as (*) or (1) when the actual intended size is present in the argument list.  "I don't want to know about errors."

0 Kudos
Ashwin_D_
Beginner
5,068 Views

Thank you for your response.

 

I am having a difficult time debugging a segmentation fault and no core is dumped to disk. I did recompile with -g -traceback option and when I ran gdb I get hexadecimal addresses with no source code information.

 

Any other suggestions other than line by line print statements ?
 

0 Kudos
mecej4
Honored Contributor III
5,068 Views

ashwin wrote:
However if there is a subroutine that is having an array declared as  (*)  will that mean this will bypass all array bound checking ?

No, with most compilers bounds checking is skipped for just that variable. Therefore, by successively replacing each '*' with an appropriate expression that is computable from zero or more of the dummy arguments, and fixing the reported array bound errors, you can often narrow down the location of the bug.

0 Kudos
Ashwin_D_
Beginner
5,068 Views

I believe it is being thrown inside this subroutine. Because when I try to print any value inside this subroutine all I get is segmentation fault.

Would this code not print out bounds checking for the th3 array ?

  subroutine calc_theta (th3,t3,p3,
     >                       nx,ny,nz,mdv)


    
      implicit none

c     Declaration of subroutine parameters
      integer   nx,ny,nz
      real      mdv
      real      th3(nx,ny,nz)
      real      t3 (nx,ny,nz)
      real      p3 (nx,ny,nz)
      

      real      rdcp,tzero,p0
      parameter (rdcp=0.286)
      parameter (tzero=273.15)
      parameter (p0=100000.)
      real      eps
      parameter (eps=0.01)
      
c     Auxiliary variables
      integer  i,j,k

c     Calculation

      do i=1,nx
         do j=1,ny
            do k=1,nz
            
               if ((abs(t3(i,j,k)-mdv).gt.eps).and.
     >             (abs(p3(i,j,k)-mdv).gt.eps)) then
               
                 th3(i,j,k)=(t3(i,j,k)+tzero)*( (p0/p3(i,j,k))**rdcp )

              else
                 th3(i,j,k)=mdv
                  

              endif
               
           enddo
        enddo
      enddo

      end

 

0 Kudos
Steven_L_Intel1
Employee
5,068 Views

What happens if you rebuild with "-warn interface"? It is possible that you are not passing the arguments correctly. Only by seeing a complete test case can we really help you.

0 Kudos
Ashwin_D_
Beginner
5,068 Views

Solved it :-)

 

 The problem was with my tcsh. I went to this link https://software.intel.com/en-us/articles/tips-for-debugging-run-time-failures-in-intel-fortran-applicationsand I added this to my shell - limit stacksize unlimited and voila my problem disappeared.

 

 

0 Kudos
Steven_L_Intel1
Employee
5,068 Views

Ok. You might consider "-heap-arrays" (a compiler option) as an alternative.

0 Kudos
Reply