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

Stack Overflow

JohnNichols
Valued Contributor III
1,149 Views
Dear Steve:

You know you learn things all the time.

I always use the implicit none at the top of my code. When I used the batch files in Microsoft Fortran there was a switch one could set to check that all the variables were declared and used.

I just had a new program Iam developing crash with a Stack Overflow error and a out of bounds in Windows fault.

The code had been working perfectly and I moved the subroutine from the main file to a separate f90 file.

Along the way I found out that I have to set the debug switches in the Preferences, I had always assumed these would be set, dumb really, but a simple trap.

Took an age to fix all the code then.

Question: Do I have to put Implicit None at the top of every routine or just in the main program?

Regards

JMN
0 Kudos
5 Replies
JohnNichols
Valued Contributor III
1,149 Views
Dear Steve:

My machine crashed in the middle of the send, so somehow it went a few times

Sorry

JMN
0 Kudos
Steven_L_Intel1
Employee
1,149 Views
IMPLICIT NONE belongs in each program unit. You can use /warn:declarations to have that automatically applied if you wish, but I prefer to have it in the code.

I don't know what switches you thought you had to set - can you explain in more detail? A debug configuration should have what you need by default.
0 Kudos
Steven_L_Intel1
Employee
1,149 Views
I deleted the duplicates - no worries.

Moving code to another file should not affect how the code runs. Stack overflow can happen for many reasons - see this old Doctor Fortran post for more on stack overflow.
0 Kudos
mecej4
Honored Contributor III
1,149 Views
> Do I have to put Implicit None at the top of every routine or just in the main program?

Steve already gave you the answer, and here is a hint that will explain why it has to be so. "Implicit None" is a Fortran statement, not a compiler directive. Because Fortran compiles each subprogram separately, the statement applies only to the subprogram in which it is placed. In contrast to C, Fortran statements do not have source-file scope.

A minor clarification: "Implicit None" is a declaration, and must appear after the subprogram declaration statement and any USE statements.
0 Kudos
JohnNichols
Valued Contributor III
1,149 Views
Dear Respondents:

I set the warn declarations and warn undeclared and that seems to have solved the problem.

I also fixed the implicit none.

I used to use the 4Yd all the time in Powerstation and before in MF.

Fun really.

Fixing all these fixed the stack overflow.

Thanks

JMN
0 Kudos
Reply