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

Uninitialized variable with correct value

Don_D_
New Contributor I
406 Views

My code sets a variable IC2:

    IC2 = IFLAGS(17,JCONF)

A few lines later it uses this value, which equals the number 2:

    JCOL = IC2

Then, later I use it again:

    DO K = 1,JTRAN        ! RETRACE ENTIRE RAYSET, THIS TIME TO GET GLASS ABSORPTION
        XEN = XR(K)        ! USE ONLY RAYS THAT GOT THROUGH LAST TIME
        YEN = YR(K)    
        AT = AT + AR(K)        ! APODIZATION ONLY

        IF (JPOLD(JCONF) .EQ. 1) THEN    ! POLARIZATION OFF; NO LOSS FROM THAT
            XYAR(K) = 1.0
        ENDIF
        BT = BT + XYAR(K)        ! COATINGS ONLY

        ISTOP = MX
        ICOL = IC2

Only this time I get an error saying that IC2 is not defined!  In the debugger it still has the value it had when defined earlier.  What's going on?

0 Kudos
1 Solution
Don_D_
New Contributor I
406 Views

My bad.  I had a dimension mismatch.  Fixed it.

 

 

View solution in original post

0 Kudos
3 Replies
Don_D_
New Contributor I
407 Views

My bad.  I had a dimension mismatch.  Fixed it.

 

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
406 Views

Does the error occur in an OpenMP region with default(none)?

Or, is the variable IC2 or lC2?

Note, left variable has upper case i and the right variable is lower case L

Jim Dempsey

0 Kudos
andrew_4619
Honored Contributor II
406 Views

I may add that I always use the option "Local Variables AUTOMATIC (/Qauto) " which means  the locals become undefined when you exit the subroutine rather than saving the last value used  which often masks many "uninitialised" variable errors.  With a old program you will find this option throws up quite a number of errors but in reality  these are all bugs that should be fixed.

0 Kudos
Reply