Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

VALUE Attribute Vs INTENT(IN)

$
0
0

This is just a general question for peoples opinions on the VALUE attribute used in subroutines. I know it The VALUE attributie is sometimes necessary for interoperability with C, but my interest is what would be the benefit beyond that compared to INTENT(IN). I am assuming  that it makes no sense to have both at the same time.

 

Below is a simple example of what I am talking about

SUBROUTINE DOUBLER(X,Y) 
  REAL,      VALUE::X
  REAL,INTENT(OUT)::Y
  Y=2.*X
END SUBROUTINE

or

SUBROUTINE DOUBLER(X,Y) 
  REAL, INTENT(IN)::X
  REAL,INTENT(OUT)::Y
  Y=2.*X
END SUBROUTINE

 

Or another example would be:

FUNCTION DOUBLER(X) RESULT(Y) 
  REAL, VALUE::X
  REAL::Y
  Y=2.*X
END FUNCTION

or

FUNCTION DOUBLER(X)   RESULT(Y) 
  REAL::X                             !FUNCTION IMPLICITLY USES IN
  REAL::Y
  Y=2.*X
END FUNCTION

Viewing all articles
Browse latest Browse all 3270

Trending Articles



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