Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Unititialized and SAVE

$
0
0

Stumbled upon an odd situation last week.

It is likely that the complier setting on the RedHat5 were using "-save" and the RedHat6 I was porting to was not.

The code looks something like this:

      PROGRAM  SunShine
      IMPLICIT NONE
!... Declarations are in here
      CALL XX(Date_n_Time, Sun_Position, SunShine)
!... File writing code is in here
      END PROGRAM SunShine

      SUBROUTINE XX(Time, Sun, SunShine)
      IMPLICIT NONE
      TYPE Position
        REAL(KIND=8) :: Lat
        REAL(KIND=8) :: Lon
        REAL(KIND=8) :: Alt
      END TYPE Position
      TYPE(Position), DIMENSION(360*181)                :: Place_as_a_Vector
!... Additional Declarations are in here...
      LOGICAL(KIND=4) DIMENSION(360,181), INTENT(  OUT) :: SunShine
      TYPE(POSITION)                    , INTENT(IN   ) :: Sun
      REAL(KIND=8)                      , INTENT(IN   ) :: Date_n_Time
      LOGICAL(KIND=4)                                   :: Init_Me = .TRUE.

      IF(Init_Me) THEN
        K = 0
        DO I = 1, 360
          DO J = -90, 90
            K = K + 1
            Place_as_a_Vector(K)%Lat = FLOAT(J)
            Place_as_a_Vector(K)%Lon = FLOAT(I)
            Place_as_a_Vector(K)%Alt = 0.0
           ENDDO
         ENDDO
        Init_Me = .FALSE.
      ENDIF
!... Some more code here...
      RETURN
      END SUBROUTINE XX

Without either ",SAVE" on "Card 15's"  "Place_as_a_Vector" declaration line, or "Place_as_a_Vector = 0" then the variable is not saved.
Are there some strategies for catching these?

"-check uninit" is one, but I am not sure if any other -warn gives insight that can help in identifying where I should be paying attention, especially when I cam coming into a subroutine or function after the first time.

There are /QSave etc, but I probably need to make sure that the code is more bullet proof, and there are quite a few lines of code.


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>