Dear colleagues,
I am using the FTN95 compiler since many years, which I use via batch files or by two IDEs: Plato and Visual Studio 2015 Community. Unfortunately, I have experienced from time to time unexplainable errors during the recent years. Today, I have some hope that I am at least close to the source of the problem. Let me try to explain.
I work with FTN95 Personal Edition 8.10, Plato 4.81 and Visual Studio 2015 Community 14.0.25431.01 Update 3. I know that passing an array to a subroutine as dummy argument by reference or passing an array **section **is not identical, but I would expect that passing an array a, dimensioned by (n,n), should give identical results as passing the “array section” a(1:n,1:n). The programme test92 does the following:
-Array sections a(1:n), b(1:n,1:n) are passed from main to sub1 and sub2. -The logical variable “fail” is passed back from sub2 and sub1 to main. -The automatic array c is defined in sub2 and passed back to sub1.
I have constructed this completely pointless demo to investigate some areas where I have experienced problems. And indeed: As expected, the programme test92 runs for all Plato compiler options (Checkmate .Net etc., 9 in total) as well as for all Visual Studio options except for Checkmate Win32. This option gives the following error messages:
Plato: attached file Plato01.pdf
Visual Studio: attached files Visual Studio 01 and 02.pdf
I just would like to mention that under Visual Studio the switch from win86 to win64 does not really work as expected.
The errors are caused by line 85. If this line is commented out and either line 86 or line 87 are used, the error disappears. Can anybody confirm my findings, or is there an error in my programme, which everybody but me sees?
Klaus
**PS. How can I send the three pdf files??? **
winapp
Program test92
! Array sections a(1:n), b(1:n,1:n) are passed from main to sub1 and sub2
! Logical variable fail is passed back from sub2 and sub1 to main
! Automatic array c is defined in sub2 and passed back to sub1
implicit none
! ------------------------------------------------------------------------------
interface
subroutine sub1 (aa, bb, fail)
double precision, dimension (:) , intent (in) :: aa
double precision, dimension (:,:), intent (in) :: bb
logical, intent (out) :: fail
end subroutine sub1
end interface
! ------------------------------------------------------------------------------
double precision, dimension (10) :: a
double precision, dimension (10,10) :: b
integer :: n
logical :: fail
n = 2
a(1:n) = 1.0
b(1:n,1:n) = 2.0
fail = .false.
write (*,*)
write (*,*) ' main:'
write (*,*) ' a = ', a (1:n)
write (*,*) ' b = ', b (1:n,1:n)
write (*,*) ' fail before calling sub1 = ', fail
! ------------------------------------------------------------------------------
call sub1 (a(1:n), b(1:n,1:n), fail)
! ------------------------------------------------------------------------------
write (*,*)
write (*,*) ' main:'
write (*,*) ' fail after calling sub1 = ', fail
write (*,*) ' End of programme'
read (*,*)
end Program test92
! ==============================================================================
subroutine sub1 (a, b, fail)
implicit none
! ------------------------------------------------------------------------------
interface
subroutine sub2 (aa, bb, cc, fail)
double precision , dimension (:) , intent (in) :: aa
double precision , dimension (:,:), intent (in) :: bb
double precision , dimension (:) , intent (out) :: cc
logical , intent (out) :: fail
end subroutine sub2
end interface
! ------------------------------------------------------------------------------
double precision , dimension (:) , intent (in) :: a
double precision , dimension (:,:), intent (in) :: b
logical, intent (out) :: fail
double precision , dimension (size(a)) :: c
integer n
n = size(a)
write (*,*)
write (*,*) ' subroutine sub1:'
write (*,*) ' a = ', a (1:n)
write (*,*) ' b = ', b (1:n,1:n)
! ------------------------------------------------------------------------------
call sub2 ( a(1:n), b(1:n,1:n), c (1:n), fail )
!!! call sub2 ( a, b, c (1:n), fail )
!!! call sub2 ( a, b, c, fail )
! ------------------------------------------------------------------------------
write (*,*)
write (*,*) ' subroutine sub1 after call sub2:'
write (*,*) ' c = ', c (1:n)
end subroutine sub1
! ==============================================================================
subroutine sub2 (aa, bb, cc, Fail)
implicit none
double precision , dimension (:) , intent (in) :: aa
double precision , dimension (:,:), intent (in) :: bb
double precision , dimension (:) , intent (out) :: cc
logical , intent (out) :: fail
integer :: n
n = size(aa)
write (*,*)
write (*,*) ' subroutine sub2:'
write (*,*) ' aa = ', aa (1:n)
write (*,*) ' bb = ', bb (1:n,1:n)
fail = .true.
cc = sum (aa) + sum (bb)
write (*,*) ' cc = ', cc (1:n)
end subroutine sub2