Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28470 Discussions

Syntax of a logical expression containing a logical function.

OP1
New Contributor II
260 Views

Could someone help me understand (or point at the right place in the IVF documentation) why the commented line in the following code doesn't work (the compiler issues a #6423 error), while the line above does? This is with IVF 11.1.

Thanks,
Olivier

[fortran]MODULE MY_MODULE IMPLICIT NONE CONTAINS LOGICAL FUNCTION MY_FUNCTION MY_FUNCTION = .TRUE. END FUNCTION MY_FUNCTION END MODULE MY_MODULE PROGRAM MY_PROGRAM USE MY_MODULE IMPLICIT NONE IF (MY_FUNCTION()) THEN !IF (MY_FUNCTION) THEN WRITE(*,*) 'Hi!' END IF END PROGRAM MY_PROGRAM[/fortran]
0 Kudos
2 Replies
Anonymous66
Valued Contributor I
260 Views
The parentheses after the function name in the call to MY_FUNCTION are a part of standard Fortran syntax.If any variables are passed to the function, they are put inside of the parentheses and they are necessary to distinguish between function and variable names.
0 Kudos
OP1
New Contributor II
260 Views
OK - Thanks Annalee. I guess I assumed a little too quickly that the parenthesis were optional when the function does not have any arguments.

Olivier
0 Kudos
Reply