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

Debugging inside a BLOCK construct

Andrew_Smith
Geschätzter Beitragender I
1.871Aufrufe

With IFORT (Intel® Fortran Compiler Classic 2021.12.0 [Intel(R) 64]) the variables declared local to the block cannot be seen by the debugger.

So I switched to IFX (Intel® Fortran Compiler 2025.2.1 [Intel(R) 64]) and now they can be seen. But the local variables declared outside the block are now invisible!

Attached files replicate the problem with IFX. The use of an include file triggers the issue.

 

6 Antworten
jimdempseyatthecove
Geehrter Beitragender III
1.853Aufrufe

You win some - you lose some.

As a hack

block
associate(VariableOfInterest_=>VariableOfInterest)
real :: blockLocalVariable
...
end associate
end block

Jim Dempsey

 

JohnNichols
Geehrter Beitragender I
1.829Aufrufe

Jim:

Why would you use a block? 

It is like starting a fire with a match when someone has a torch. 

JMN

andrew_4619
Geehrter Beitragender III
1.827Aufrufe

You would use one because they can be quite useful and they exist!

jimdempseyatthecove
Geehrter Beitragender III
1.751Aufrufe

Think of a BLOCK as an inline contained subroutine complete with its own local variable declarations yet within the scope of the procedure containing the block.

 

Jim Dempsey

Andrew_Smith
Geschätzter Beitragender I
1.735Aufrufe

The c language and most others allow variables to be declared when needed anywhere within your statements.

Fortran restricts us to declare all variables before any statements. I am not sure why Fortran has always had this restriction. Has there been proposals to change the standard in this area? I cant imagine it would affect performance but would greatly improve the coding experience.

A Fortran BLOCK allows you to create new variables almost anywhere. Its not as nice or as flexible as c. 

JohnNichols
Geehrter Beitragender I
1.539Aufrufe

Accepting all that is said, I like a nice subroutine name such as 

INPUT

LOAD

ANALYSIS

EIGENVALUES

OUTPUT

 

Antworten