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

Check argument values at compile-time?

$
0
0

Hi there,
is it possible to write a subroutine / function which 1) only accepts a discrete number of integer values as inputs and 2) allows to check this at compile time?

module test
integer, parameter :: possible_value1 = 1, possible_value2 = 2
contains
subroutine nice_routine (number)
   integer, intent(in) :: number
end subroutine nice_routine
end module test

In this example any integer number can be passed to the subroutine. Would it be possible to change it in such a way that only "possible_value1" and "possible_value2" are accepted and a compile-time error is issued for other values?

Thanks, Franz


Viewing all articles
Browse latest Browse all 5691

Trending Articles



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