Calling a function that squares a number:
program Square_prog
use, intrinsic :: iso_fortran_env, only: RK => real64
use Square_mod, only: getSquare
implicit none
real(RK) :: val = 100_RK
interface
function getSq(val) result(valSquared)
!DEC$ ATTRIBUTES DLLIMPORT, DECORATE, ALIAS: 'getSq' :: getSq
use, intrinsic :: iso_fortran_env, only: RK => real64
real(RK), intent(in) :: val
real(RK) :: valSquared
end function getSq
end interface
write(*,"(*(g0.13,:,' '))") "getSquare(", val, ") =", getSquare(val)
write(*,"(*(g0.13,:,' '))") " getSq(", val, ") =", getSq(val)
end program Square_prog
The number to be squared (val) is hard coded, I would like to be able to enter the number with a write read statement.
However that doesn’t work. When I try to do that I get an error: A specification statement cannot appear in the executable section
Roger