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

Strange problem with Array dimensioned(1)

lesneilson
Beginner
672 Views
Code:
      program hdr

      integer*4 :: larr(1)
      
      larr(1) = 0

      end program hdr


ProjectProperties -> Fortran Runtime Error Checking = ALL
Stops on the assignment line
larr(1) = 0
with :

Run-Time Check Failure #3 - The variable '' is being used without being defined.

Change the dimension to (2) and the error message goes away.
Les
0 Kudos
14 Replies
greldak
Beginner
672 Views
Have you set an option somewhere to use zero based arrays rather than the Fortran default of 1 based ones?
0 Kudos
lesneilson
Beginner
672 Views
Looking at other data types I have found the following
Code:
      program hdr

      integer*4, allocatable :: aarr(:)
      integer*4 :: iarr(1)
      integer*2 :: jarr(1)
      real*4 :: rarr(1)
      double precision :: darr(1)
      character*(50) :: carr(1)
      logical :: larr(1)
      
      allocate (aarr(1),stat=ier)
      
      aarr(1) = 0           ! allocatable array
      iarr(1) = 0           ! integer*4
      jarr(1) = 0           ! integer*2
      carr(1) = ' '         ! character 
      rarr(1) = 0.0         ! real*4
      darr(1) = 0.0d0       ! real*8
      larr(1) = .true.      ! logical

      end program hdr
The error message does not occur for the allocatable arrayor the character array.
The error message does not occur if I dimension the arrays (0:1)
There is no compile time warnig or error message, the error onlyoccurs at runtime in debug and release.
Les
0 Kudos
lesneilson
Beginner
672 Views

Craig,

No I haven't used any switches to use zero-based arrays.

Les

0 Kudos
onkelhotte
New Contributor II
672 Views

Which compiler and OS do you use? With CVF6.6c on WinXP SP2 everything is normal, no run-time error or anything. I have had chekced all run-time error options...

0 Kudos
lesneilson
Beginner
672 Views

OS Windows XP

Visual Studio .NET 2003

Compiler IVF Version 9.0 Build 20051020Z Package ID: W_FC_C_9.0.025

Les
0 Kudos
jim_dempsey
Beginner
672 Views

Les,

I've seen a similar problem, I cannot nail it down as something specific, but it seems to be related to the first code statement. When I insert something in front of it (to try to figure out the problem) then the symptom goes away.

Just for kicks, on your original post, in front of the "larr(1) = 0" insert a "Write(*,*) 'hello'".

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
672 Views
I can't reproduce this in 9.0.025. If you can, please submit a test case and description of the problem to Intel Premier Support. (Yes, I know that one has to turn on uninitialized variable checking to see that kind of error.)
0 Kudos
lesneilson
Beginner
672 Views

Jim,

Mmm interesting.

If I add the write statement and declare the array as integer*4 it works ok.

If the array is integer*2, real, or logicalit fails,

Les

0 Kudos
lesneilson
Beginner
672 Views

Steve,

I keep having problems accessing the premier support page.

I have registered the compiler and set up aan accountetc, but I get "The page cannot be displayed" when I click on the premier.intel.com link.

Les
0 Kudos
Steven_L_Intel1
Employee
672 Views
Please try again. Try it as https://premier.intel.com/ and see if that helps. If it still fails, use https://registrationcenter.intel.com/support
0 Kudos
lesneilson
Beginner
672 Views

Thanks

The premier support page still gave problems, but the registration page was ok

Les

0 Kudos
jim_dempsey
Beginner
672 Views

In one of my files I had to stick this in the beginning of the code section:

Code:

#if 1    
    ! IFORT complains on TOSVX1(1) = -ELMGDD*UITI(1)...
    ! without some dummy instruciton first????
    DUMDUM = 0
#endif


This seems to be your Var(1) problem. Although in this case TOSVX1 is an array of 3 elements.

Couldn't figgure out with the problem was with the compiler and I could not setup a simple example that produced the error.

Try adding ",automatic" to the declaration

integer(2), automatic :: foo(1)

Without the automatic the small array gets placed into a name mangled global space for the subroutine (if not recursive and/or not OpenMP).

Jim Dempsey


0 Kudos
Les_Neilson
Valued Contributor II
672 Views

Jim

Thanks, I tried both the dummy variable and the automatic options without success.

I installed on another pc andmy (unadorned) example program worked perfectly. So I uninstalled and re-installed on my work pc but it still fails.

I guess there must be something strange aboutmy pc.
Les
0 Kudos
jim_dempsey
Beginner
672 Views

What is the difference between the two PCs?

Is there instruction set differences?

Is there option differences?

Are the processors of the same vendor (i.e. one Intel and the other AMD)?

Have you tested running the execuitable built on the PC that works on the PC that doesn't work? If the two systems are networked then from the failing system open the working project up on the working system then run in Debug on the failing system *** without recompiling ***.

If this works then look at compiler options and look at what got linked into your application.

If this fails then it may accidentaly work on the working system or there is a runtime environment difference between the two systems (HT vs Dual Core).

If it reliably fails then maybe you can gleen something by breaking on the statement before it fails. Open a Dissasembly window, then step in trying to interpret the registers while itis happening.

Jim Dempsey

0 Kudos
Reply