I get some nasty error for weeks which is hard to find because the compiler somehow hides it. I am getting Access Violation crash in some subroutine when compiled with /NOCHECK and when I turn all checks and undefs ON the damn error disappears (of course the code in debug mode works much slower)
So i turned to Comment Embedded Directives which i never used and even did not know before (when they appeared in FTN95? at the time of NET development?) in the hope to turn checking (or not checking) one part by one only for small portions of the code inside faulty subroutine. And unfortunately it does not work like i hoped . Will appreciate the clarifications how these directives work.
Here is smallest example of some artificial code where intentionally array elements 4 and 5 are not set and we will be trying to catch that. We compile the code this way
C>FTN95 A.FOR /DEBUG /LINK >z
and inside the code push the directive not to check anything before DO loop and only check DO loop on possible undefined variables turning just before it the UNDEF key ON
Real a(5), b(5), c(5)
!FTN95$OPTIONS(nocheck)
a(1)=1
a(2)=2
a(3)=3
b(1)=10
b(2)=20
b(3)=30
d=c(5)
!FTN95$OPTIONS(undef)
do i=1,5
c(i) = a(i)+b(i)
enddo
print*, c
end
But what happening is that UNDEF starts to work for entire code before and after this directive and for example finds undefined variable at d=c(5) line.
What i am doing wrong ?
If i switch these directives, things become even more weird - i do not get the source code shown in the debugger which confirms that last directive suppresses previous ones in the entire code