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

idb, ifort - usefulness optimized away

oh_moose
Beginner
1,393 Views
I get far to often the result because variables have been optimiezd away when I debug with idb a program that was compiled with idb -O0. That is not helpful. When I use "0", I mean zero.


0 Kudos
12 Replies
jimdempseyatthecove
Honored Contributor III
1,393 Views

Can you please provide a simplifiedexample?

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
1,393 Views
Sorry - some optimizations are done even at -O0. But in general variables should not be "optimized away". As Jim suggests, an example would be welcomed.
0 Kudos
clarkca
Beginner
1,393 Views

I have been plagued by this problem before.. I have compiled a somewhat simple example. Attempting to simplify it further caused it to go back into hiding. I have a set of files to send somewhere if I can attach them somehow? Well, in case that is not possible, here is a synopsis -- The program is in hello.f and the error appears whenever I put NBloss ANYWHERE in the namelist. It disappears if NBloss is not there. Here is hello.f with the problem:

Program Hello

Implicit none

INCLUDE 'param.cmn'
INCLUDE 'bndry.cmn'
INCLUDE 'envs.cmn'
INCLUDE 'prop.cmn'
INCLUDE 'raytrc.cmn'
INCLUDE 'user.cmn'
INCLUDE 'dum.cmn'

INTEGER Metric

NAMELIST /INPUTS/ Cenv,Zenv,Fxd,Mvd,Nmov,Wind,Vmaxx,
1Rmin,Rmax,Deltar,Freq,Hdr,Mbenv,Mcenv,Mdenv,B0env,
2Denv,Rdenv,Rcenv,Rbenv,Npths,Metric,ThetaBL,Bloss,
3Qmin,NBloss

READ (5,INPUTS)

Print *,'Hello World!'

end

----- end program -----

Include file containing NBloss :


* ENVS.CMN

Real*8 Cenv(1:Maxs,1:Maxenv),Zenv(1:Maxs,1:Maxenv)
Real*8 C(1:Maxs,1:Maxenv),Z(1:Maxs,1:Maxenv)
Real*8 Rcenv(Maxenv),Rc(Maxenv)
Real*8 Rbenv(Maxenv),Rb(Maxenv)
Real*8 Denv(Maxenv),D(Maxe),Rdenv(Maxenv)
Real*8 Rd(Maxe),Grd(Maxs+1,Maxenv)
Real B0denv(Maxenv),B0div(Maxenv)
Real B0env(Maxenv),B0(Maxenv)
Real ThetaBL(1:Maxb,1:Maxenv),Bloss(1:Maxb,1:Maxenv)
Integer Nsspts,Mbenv,Mcenv,Mdenv,Mb,Mc,Md
Integer NBloss(Maxenv)

COMMON/ENVS/Cenv,Zenv,C,Z,Rcenv,Rc,Rbenv,Rb,Denv,
1D,Rdenv,Rd,Grd,B0denv,B0div,B0env,B0,ThetaBL,Bloss,
2NBloss,Nsspts,Mbenv,Mcenv,Mdenv,Mb,Mc,Md

--- end include file ---

param.cmn include file:


* PARAM.CMN

Real*8 Pi,Twopi,Q1,Deg,Zero,One
Integer Maxrng,Maxs,Maxk,Maxj,Maxb,Maxenv,Maxe
Integer Maxd,Maxpth

Parameter (Zero=0)
Parameter (One=1)
Parameter (Deg=0.017453292)
Parameter (Pi=3.14159265359)
Parameter (Twopi=6.28318530718)
Parameter (Q1=0.626657068658)
Parameter (Maxrng=1001)
Parameter (Maxs=155)
Parameter (Maxk=100)
Parameter (Maxj=40)
Parameter (Maxb=91)
Parameter (Maxenv=25)
Parameter (Maxe=25)
Parameter (Maxd=5)
Parameter (Maxpth=20)

--- end param.cmn include file ---

Input file :

$INPUTS
Mbenv = 2, Mcenv = 2, Mdenv = 2,
Rcenv = 1,100,
Denv = 13.0900890143,0,
Rdenv = 0,2.5,
Wind = 8.,
Rmin = .005, Rmax = 2.50, Deltar = .005,
Nmov = 1, Mvd(1) = .33, Fxd = 6.67,
Freq = 3200., Vmaxx = 20,
Qmin = 0,
&n bsp; Rbenv(1) = 0, Rbenv(2) = 100,
Hdr = 'Wedge.tst ',
$END

--- end input file ---

I don't know if this is enough to reproduce the error. If you provide an e-mail ads I could attach the remaining include files. I run hello and it says hello, but if I idb hello and stop at the print statement, I cannot view variables... it says . Removing NBloss from the namelist and recompiling cures the problem.

I would LOVE to have a solution to this problem. It seems to have something to do with memory allocation? Small changes in the code make it appear and disappear..

Thank you.

Cathy Ann Clark, clarkca@npt.nuwc.navy.mil

0 Kudos
Steven_L_Intel1
Employee
1,393 Views
Go to Intel Premier Support, create an issue and attach a tar file of your example sources.

The program you have, though, does not use any of the variables so the compiler might reasonably optimize them away. What happens if you print some of the variables - can you see those?
0 Kudos
clarkca
Beginner
1,393 Views

I'm not sure how to make a tar file?

The program runs fine, it's just printing variables in the idb that doesn't work.

I don't use the variables because I stripped down the code to make an example I could post.

Please tell me how to tar?

0 Kudos
Steven_L_Intel1
Employee
1,393 Views
tar -czvf problem.tar.gz file1.f90 file2.f90 file3.f90 ...

Or you can attach the files individually if need be, but tar is easier.

It would be better if you had an example showing that the variable was used but still not visible in the debugger.
0 Kudos
clarkca
Beginner
1,393 Views

ok.. when I go there it says I do not have access? How do I create an account?

I have created a tar file -- Note that the only variable I have left in is Qmin -- it is read in with the namelist -- I also added a line saying Qmin=0 and still get from the debugger. In the full model, I cannot access any variables in the debuigger, and believe me, they are all used... The addition of NBloss to the namelist makes the problem appear and disappear.

I will attach the tar file if I can get an account.. Pls advise.

0 Kudos
clarkca
Beginner
1,393 Views

I have sent an email asking for help -- I have had both the username and password e-mailed and entered them verrry carefully multiple times but it will not recognize my login. This problem has my work STALLED!!! Please help.

Thank you.

0 Kudos
clarkca1
Beginner
1,393 Views

well.. i managed to upload the tar file --

I am issue ID 463815.

Thank you for your help.

0 Kudos
oh_moose
Beginner
1,393 Views
Hi Cathy, thank you for posting a nice example so quickly. Happy New Year!

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,393 Views

Cathy,

I noticed than the variable "Fxd" is in the NAMELIST but it does not appear elsewhere. Try declaring it (and any other variables in NAMELIST if not declared elsewhere).

Jim Dempsey

0 Kudos
oh_moose
Beginner
1,393 Views
I find this problem far too frequently in my large project. Local variables as well as function/subroutine arguments are not accessible with the debugger, even if they are used in the current source line indicated by the debugger. Of course I cannot post tens of MB of source code. But Cathy's example should be just fine, with or without NAMELIST.

-g -O0 really should work, but it does not. Are there any other options which might interfere? I tried these two options alone, plus a large number of permutations from the following list (most which I need).

-g
-O0
-debug extended
-debug-parameters all
-assume dummy_aliases
-assume protect_parens
-check arg_temp_created
-check bounds
-check pointers
-check uninit
-common-args
-ftrapuv
-inline-debug-info
-diag-disable id7140
-fkeep-static-consts
-fp-model strict
-fp-stack-check
-fvisibility=default
-no-global-hoist
-prec-sqrt

0 Kudos
Reply