Quick background: I developed a program two years ago in Fortran to perform a set of calculations based on structured text file input. I'll refer to this program as "Program A". Program A's Release *.exe was last used successfully in 2018. Fast forward to September 2019, and Program A's Release *.exe was used for the first time since 2018 but now no longer works correctly, even when using input text files that had been previously run without problems.
The previous PC with the combination of Visual Studio and Intel Visual Fortran used to develop, build and compile Program A's Release *.exe was reclaimed by IT earlier this year. So I have just installed Intel(R) Visual Fortran Composer XE 2013 SP1 Update 6 Integration for Microsoft Visual Studio 2010 on a PC, with the intent on debugging the source to figure out why the program no longer works well.
My current problem:
I opened up the old Program A project solution in the recently installed IVF and it was converted successfully into the new IDE.
Now when I debug Program A, I see that some variables and arrays declared in a MODULE are showing up as Undefined in the main PROGRAM and its subroutines (Undefined variable 'x' or Undefined pointer/array 'y'), but some of these do report values.
I am not sure why some of the MODULE variables & arrays have values and others are Undefined, when in the last IDE the compiled source code executed without any issue.
Excerpt of MODULE and main PROGRAM are reproduced below:
MODULE CONSTANTS_MODULE USE IFPORT USE IFWIN USE, INTRINSIC :: IEEE_ARITHMETIC IMPLICIT NONE INTEGER, PARAMETER :: NCOMP=8 INTEGER, PARAMETER :: NPTS=48 INTEGER, PARAMETER :: NFAC=1 INTEGER, PARAMETER :: NRESTOP=32 ... REAL*8 :: cokeRho REAL*8, PARAMETER :: piconst=3.14159 ... REAL*8 :: MWcomp(NCOMP) DATA MWcomp / 12.0107, 18.0152, 28.0101, 44.0095, 2.01588, 31.9988, 28.0134, 39.948 / ... REAL*8, DIMENSION(1:400) :: inarr, inarr2, inarr3, inarr4, inarr5 REAL*8, DIMENSION(1:400) :: inarr6, inarr7, inarr8, inarr9, inarr10 ... INTEGER, PARAMETER :: CASENUM=10 ... LOGICAL, DIMENSION(:,:), ALLOCATABLE :: GOPRINT REAL*8, DIMENSION(0:NPTS*NFAC,NRESTOP) :: HOLDPRINT ... SAVE END MODULE CONSTANTS_MODULE PROGRAM MAINDRV USE CONSTANTS_MODULE IMPLICIT NONE ... END PROGRAM MAINDRV
Note: There are many more variables and arrays declared in the module which I am not showing.
During debug while I am in PROGRAM MAINDRV:
1. The allocatable array GOPRINT shows up as an Undefined pointer/array
2. All of the integer parameters NCOMP, NPTS, NFAC, NRESTOP, CASENUM show up as Undefined variables
3. The REAL*8 parameter piconst shows up as Undefined variable
4. The REAL*8 array MWcomp(NCOMP) shows up as Undefined variable
5. The REAL*8 arrays inarr, inarr2, inarr3, inarr4, inarr5, inarr6, inarr7, inarr8, inarr9, inarr10 are populated with values
6. The array HOLDPRINT with dimension (0:NPTS*NFAC,NRESTOP) has correct dimension (0:48,32) and is populated with values
7. The REAL*8 variable cokeRho is populated with value
The main program and its subroutines depend on all of the variables and arrays that are defined in CONSTANTS_MODULE. How do I get all of the module variables and arrays to be available in the main program?
I have tried researching online and have not been able to figure this one out yet. I am probably missing something simple, but I am not a professional programmer and do not code often (as you can see it has been two years since I last coded in Fortran). I am wondering if some syntax has changed since I last coded in Fortran, or if there is some project option that needs to be toggled to a particular setting, etc.
Thanks in advance for any help you can provide on the subject.
It's only the debugger that's giving you trouble, right? The program still works?
If I recall correctly, the debugger will see only module variables that are used in the current scope. You should be able to access other variables using the syntax modname::varname in a QuickView pane.
Thanks for your reply Steve. It was not just the debugger giving me trouble; the program was not working either. I thought it had something to do with module variables/arrays not being defined in the main program, since that is what the debugger was showing. Turns out the program was modified and the input file was outdated. With the proper input file the program worked like a charm.
I have a similar problem - is it OK to continue this thread, or should I start a new one? I have a program that worked OK a couple of years ago. Now, a variable declared in a module becomes undefined within a subroutine, even though the subroutine USEs this module so the variable should be in scope. I've made a slimmed down version of the code to illustrate the issue. If I put a breakpoint in at "NumDates = NumObservationDates", the watch says "Undefined variable NumObservationDates".
Since writing the original code I've got a new version of the compiler, I'm now running: Intel® Parallel Studio XE 2018 Composer Edition for Fortran Windows* Integration for Microsoft Visual Studio* 2015, Version 18.0.0033.14
Perhaps I have got one of the settings wrong. I've tried:
Local Variable Storage = Default Local Storage
Local Variable Storage = All Variables SAVE (/Qsave)
I've also tried just running the exe (ouside the debugger) but it behaves the same.
I'm not brilliant at Fortran but I thought I understood this - that variables declared in a module are kept in memory. I'd be grateful for any advice.
end program RunMADOC
integer :: NumDates
NumDates = NumObservationDates
end subroutine MADOC
integer, parameter :: NumObservationDates = 1
end module SetUpMADOC
See the Option on project setting> fortran> debug
Used in the Program (/debug-parameters:used)
It then includes debug symbols for parameters where they are used,
If you step over the line NumDates gets the correct value from the parameter, yes?
Yes that's sorted it. It wasn't that the parameter value was undefined, it was that the debugger wasn't displaying the value. And when I realised that, I went on to find the bug in my code that was making the exe behave unexpectedly.
Many thanks Andrew