I’m getting the following run-time error in one of my Win32 programs.
*** Error 14, Attempt to alter an actual argument that is a constant, an expression, an INTENT(IN) argument, or a DO variable.
I’ve constructed a small program that demonstrates the error and consists of a Main and a Module as follows.
C ------------------------------------------------------------
C DEMO.FOR
PROGRAM DEMO
USE Calc
CALL DibDob() !<<<<<< Line 13
PRINT *, 'Demo program has run'
END
! -----------------------------------------------------------
! CALC.F90
MODULE Calc
PUBLIC :: DibDob
CONTAINS
! ----------------------------------------------------------
SUBROUTINE DibDob (lVar) !<<<<<< Line 17
LOGICAL, OPTIONAL, INTENT(OUT) :: lVar
IF (PRESENT(lVar)) lVar = .TRUE.
END SUBROUTINE
END MODULE
I’m using a recently downloaded FTN95 Personal Edition with the options /ISO /IMPLICIT_NONE /NO_SCALAR_TO_ARRAY /RESTRICT_SYNTAX /CHECKMATE /BRIEF and linking with SLINK. The run-time error information is as follows (I’ve flagged the offending lines in the above code).
CALC!DIBDOB - in file calc.f90 at line 17 [+003c] main - in file demo.for at line 13 [+003b]
The problem seems to be with the OPTIONAL argument of INTENT(OUT). Can anyone see why this causes the error?
Keith