I am using since years a program for the Cholesky Decomposition, which is incorporated in several programs. Recently I tried to run one of these programs with the compiler option Checkmate -.NET in Plato as well as in Visual Studio Community 2013. In both environments the program failed with the error message
Salford.Fortran.Checkexception: 420: Reference through NULL Fortran Pointer. The option Checkmate-Win32 does not give this error. I have tried to localize the problem and I ended up with the two programs, which demonstrate the problem:
WinApp
! ##############
Program Case01
! ##############
Implicit None
! ------------------------------------------------------------------
Double Precision , Dimension (:,:), Allocatable :: A
Double Precision , Dimension (: ), Allocatable :: X, B, diag
Integer :: j, k, n, nwrite
Logical :: Fail
Double Precision :: sum
Interface
SUBROUTINE choldc (a, p, fail)
Double Precision , DIMENSION (:,:), INTENT (INOUT) :: a
Double Precision , DIMENSION (: ), INTENT (OUT) :: p
Logical , INTENT (out) :: fail
End SUBROUTINE choldc
End Interface
! ------------------------------------------------------------------
n = 3
Allocate ( A ( 1:n, 1:n ) )
Allocate ( B ( 1:n ) )
Allocate ( X ( 1:n ) )
Allocate ( diag ( 1:n ) )
! ------------------------------------------------------------------
nwrite = 10
Open ( Unit = nwrite, File = 'Case01.out' )
! --- Example for normal system
a (1,1) = 10206.0625000d+00
a (1,2) = 9.62500000000d+00
a (1,3) = 4.81250000000d+00
b ( 1) = 55.7644855000d+00
a (2,1) = 0.00000000000d+00
a (2,2) = 0.125000000000d+00
a (2,3) = 6.250000000000d-02
b ( 2) = 0.699064500000d+00
a (3,1) = 0.00000000000d+00
a (3,2) = 0.00000000000d+00
a (3,3) = 6.250000000000d-02
b ( 3) = 0.335322250000d+00
! --- Fill in below the diagonal from symmetry
Do j = 2, n
Do k = 1, j-1
A(j,k) = A(k,j)
end Do
End Do
! ------------------------------------------------------------------
! --- Calculate Cholesky factor L
! L is stored in lower triangle of A,
! except for its diagonal elements
! which are returned in diag
! ###########
Call Choldc ( A (1:n, 1:n), &
diag (1:n) , &
Fail )
! ###########
! ------------------------------------------------------------------
! ======================
if ( .not. Fail ) then
! ======================
Write ( nwrite, * )
Write ( nwrite, * ) ' Problem runs OK'
Write ( nwrite, * ) ' ###############'
Write ( nwrite, * )
Write ( * , * )
Write ( * , * ) ' Problem runs OK:'
Write ( * , * ) ' ################'
Write ( * , * )
Pause
Stop
! ++++
! ======
end if
! ======
! ##################
End Program Case01
! ##################
Subroutine choldc ( A, p, Fail )
Implicit None
Double Precision , Dimension (:,:) , Intent (inout) :: A
Double Precision , Dimension (:) , Intent (out) :: p
Logical , Intent (out) :: Fail
Logical :: HPFortran
Fail = .false.
!!! HPFortran = .false.
HPFortran = .true.
! ---------------------
If ( HPFortran ) Then
! ---------------------
Call Choldc_95
! ----
Else
! ----
Call Choldc_77
! ------
End If
! ------
! ------------------------------------------------------------------
Contains
! ------------------------------------------------------------------
SUBROUTINE choldc_77
Implicit None
! ----------------------------------------------------------------
Fail = .false.
! --- Just for formal reasons
p(1) = a(1,1)
p(2) = a(2,2)
p(3) = a(3,3)
Return
END SUBROUTINE choldc_77
Subroutine choldc_95
Implicit None
fail = .false.
! --- Just for formal reasons
p(1) = a(1,1)
p(2) = a(2,2)
p(3) = a(3,3)
Return
End Subroutine choldc_95
End Subroutine choldc
Both programs can also be run with little batch files:
Checkmate-Win32 (LinkListCheckMate):
Load Case01.obj Load choldc.obj File Case01.exe
and RunCheckMate.bat:
del comp.lis
del *.dbk
del *.obj
del *.exe
ftn95 Case01.f95 /Checkmate /Debug >> comp.lis
ftn95 Choldc.f95 /Checkmate /Debug >> comp.lis
slink LinkListCheckMate >> comp.lis
sdbg Case01.exe
Checkmate-.NET (LinkListNet; normally I do not work with batch files for .NET)
Case01.exe Case01.dbk choldc.dbk
and RunNET.bat:
del comp.lis
del *.mod
del *.dbk
del *.exe
ftn95 Case01.f95 /Checkmate /Full_Debug /clr /clr_ver 4 >> comp.lis
ftn95 Choldc.f95 /Checkmate /Full_Debug /clr /clr_ver 4 >> comp.lis
DBK_Link4 @linklistNET >> comp.lis
Case01.exe
Have I somewhere overlooked something? Best regards KL