Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Test does not initialize a variable.

$
0
0

Is it OK in subroutine Program_main? Should be inicialized variable c in subroutine Program_main (before calling Subprogram)? When I started with Fortan (10 years ago) this example caused the program crash.  It is now a long time and I do not remember the details. Now, the example works well (Fortran v 2016.0.110). For performance reasons, I want to initialize only the necessary variables. 

!*******************************************************************************
  subroutine Program_main
    use, intrinsic :: ieee_arithmetic, only: IEEE_VALUE, IEEE_QUIET_NAN, IEEE_QUIET_NAN, IEEE_POSITIVE_DENORMAL, IEEE_NEGATIVE_DENORMAL
    implicit none
    real(8) :: a, b, c

    a = 10.d0
    b = 20.d0

    c = IEEE_VALUE (c, IEEE_QUIET_NAN)  ! IEEE_QUIET_NAN
    call Experiment13_subprogram (a, b, c)

    return
  end subroutine Program_main


  !*******************************************************************************
  subroutine Subprogram (a, b, c)
    implicit none
    real(8), intent(in) :: a, b
    real(8), intent(out) :: c
    c = a + b
    return
  end subroutine Subprogram

 

Zone: 

Thread Topic: 

Question

Viewing all articles
Browse latest Browse all 5691

Trending Articles



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