Reputation: 859
I recently started writing some simple stochastic models using use IFPORT
to call random_seed
and random_number(variable)
. At the end of my code, I added one call system('gnuplot -p plot.gnu')
— this caused the following error:
>ifort example.f90
error #6552: The CALL statement is invoking a function subprogram as a subroutine. [SYSTEM]
call system('gnuplot -p plot.gnu')
-----^
The code is as follows
program abc
use IFPORT
!declaration and initialization of variables
call random_seed
do while (condition)
call random_number(ranval)
!computation
!write on a file
end do
call system('gnuplot -p plot.gnu')
end program abc
This code cannot be compiled using ifort
. If I comment use IFPORT
, then the code can be compiled and call system
caused no error. So, I am not certain if the use IFPORT
is necessary to use random_seed
and random_number()
.
Upvotes: 1
Views: 921
Reputation: 60008
No, using IFPORT
is not necessary at all.
random_number()
and random_seed()
are intrinsic procedures of Fortran 90 and later and no module has to be used to call them.
system()
is a non-standard extension, but it is also an intrinsic procedure in all compilers I have used so far. Again, no module has to be used to call it.
system()
can be used either as a function or as a subroutine depending on the compiler. The function version is called as
err = system(command)
where err
is an integer variable.
Intel Fortran supports both versions. However, only one of them can be used at the same time! It is seems that use IFPORT
includes an explicit declaration of system()
as a function.
Solution:
Don't use IFPORT
.
Or only import those symbols from IFPORT
which you actually need using use IFPORT, only:
.
If you have to use it, use system()
as a function.
Upvotes: 2