mecej4
Joined: 31 Oct 2006 Posts: 1885
|
Posted: Sun Feb 16, 2020 11:46 am Post subject: Harmless semicolon shifts warning message to wrong line |
|
|
The subroutine below gets compiled without any messages when the default options are used, with Version 8.51 (32 or 64 bit).
If /check or /checkmate is used, however, I see the perplexing warning:
Code: | S:\lang\ftn95\V86>ftn95 /check /64 chol.f90
[FTN95/x64 Ver. 8.51.0 Copyright (c) Silverfrost Ltd 1993-2019]
0021) lnpd = .true. ! warning for this line!
WARNING - A 32 bit INTEGER has been converted to REAL with a 24 bit mantissa
NO ERRORS, 1 WARNING [<CHOLESKY_FACTOR> FTN95 v8.51.0]
|
If the unnecessary but harmless semicolon at the end of the subroutine is removed, the warning changes to:
Code: | [FTN95/x64 Ver. 8.51.0 Copyright (c) Silverfrost Ltd 1993-2019]
0022) temp = (trace/real(n))*1.0d-8 ! should have used dble(n)
WARNING - A 32 bit INTEGER has been converted to REAL with a 24 bit mantissa
NO ERRORS, 1 WARNING [<CHOLESKY_FACTOR> FTN95 v8.51.0]
|
The source code of the subroutine:
Code: | subroutine cholesky_factor (a,r)
implicit none
real*8, dimension(:,:) :: a, r
integer :: n, i, j, k
real*8 :: temp, diag, trace
logical :: lnpd
!
trace = 0.0d0
r = 0.0d0
n = ubound(a,1)
do i = 1,n
trace = trace + abs(a(i,i))
if (a(i,i) <= 0.0d0) then
lnpd = .true.
exit
endif
end do
do k = 1,n
temp = a(k,k) - dot_product(r(k,1:k-1),r(k,1:k-1))
if (temp <= 1.0d-12*(1.0d0+abs(a(k,k)))) then
lnpd = .true. ! warning for this line!
temp = (trace/real(n))*1.0d-8 ! should have used dble(n)
return
end if
diag = sqrt(temp)
r(k,k) = diag
do j = k+1,n
r(j,k) = (a(j,k) - dot_product(r(j,1:k-1),r(k,1:k-1)))/diag
end do
end do
print *, lnpd
end subroutine; ! the semicolon here is the cause!
|
|
|