Silverfrost Forums

Welcome to our forums

Bug in 8.3 - error passing automatic array

20 Apr 2018 9:10 #21891

In the code below an automatic array freq is declared since the extents of each dimension are defined variables in the module.

This code is ANSI/ISO compliant.

When run with /CHECKMATE enabled the following error message is provided. The error happens when trying to make the call to scale_vector.

*** Error 14, Attempt to alter an actual argument that is a constant, an expression, an INTENT(IN) argument, or a DO variable

This error occurs with 32 bit (whether debugging or not).

Using the 64 bit compiler and /CHECKMATE the code works but the debugger doesn't work (it doesn't open).

This code works in version 7.2 and 8.05.

module proc_mod

   integer :: num
   integer :: bins

contains

   subroutine run_analysis
      bins = 40
      num = 1
      call process
   end subroutine run_analysis

   subroutine process
   
      integer :: k, k1

      ! Automatic array
      integer, dimension(bins,num) :: freq

      freq = 0

      do k=1, num
         call scale_vector(freq(:,k), 100, k1)
      end do
   
   contains

      subroutine scale_vector(c, n, nn)
         integer, intent(in) :: n
         integer, intent(out) :: nn
         integer, intent(inout) :: c(:)
         print *,'subroutine was called'
      end subroutine scale_vector

   end subroutine process
   
end module proc_mod

program main

   use proc_mod, only: run_analysis

   call run_analysis

end program main
20 Apr 2018 11:42 #21894

I could not reproduce the error using Ver 8.30.0 or Ver8.30 + dll.23

I tried: ftn95 /64 /check /lgo david.f90 (this ran to completion)

ftn95 /64 /check david.f90 /link slink64 david.exe I stepped through with F7 to completion

My ftn95.cfg file (since 2003) is: /ERROR_NUMBERS /IMPLICIT_NONE /INTL /LOGL

20 Apr 2018 11:58 #21895

I see the bug with /checkmate in 32-bit FTN95 8.30. Furthermore, the line number displayed in the traceback (or the highlighted line in SDBG) is wrong -- 27 is the line with 'contains', whereas the subroutine statement is on line 29.

I see no problems stepping through the program to the end in SDBG64.

The test program does have one error: SCALE_VECTOR has an INTENT(OUT) argument that is never defined in the subroutine. Rather than flag that defect, the compiler simply warns that the variable NN is unused.

20 Apr 2018 11:12 #21902

mecej4, there is no error. Just because a variable is intent(out) doesn't mean the subroutine needs to define it.

All this code does is set the variable to undefined (or it should if it was working). In fact this is where the bug must lie since using /CHECK does not give a run time error and using /CHECKMATE does.

The bug occurs when running in 32 bit mode; John's tests were on 64 bit.

23 Apr 2018 9:47 #21921

This has been fixed by removing the argument checking in this context. The fix will be in the next release of FTN95.

It is worth noting that the problem arises in the context passing a section of an automatic array (that is within a module procedure) to an internal subroutine. In other words a CONTAINS within a CONTAINS.

In the meantime there are various ways to avoid the failure. You can use /check rather than /checkmate - the problem relates to checking for incorrect INTENT(OUT) usage. Alternatively you can use /inhibit_check 14.

23 Apr 2018 4:01 #21933

Paul, Thanks. Using /inhibit_check 14 resolves this issue with the 32 bit compiler until the next release. I don't want to turn off /CHECKMATE because I am generally glad of the additional checking over /CHECK.

Please login to reply.