Yes, in principle though technically in modern Fortran
, a practitioner will be advised to
- furnish an explicit interface instead of using
EXTERNAL
, and - employ the INTRINSIC attribute/statement to indicate explicitly a reference to an intrinsic procedure
With other readers in mind, an example will be as follows:
real :: sinx
sinx = sin(0.5)
print *, "sin(0.5) = ", sinx
block
intrinsic :: sin
print *, "Using intrinsic implementation:"
print *, "sin(0.5) = ", sin(0.5)
end block
contains
impure elemental function sin(x) result(r)
real, intent(in) :: x
real :: r
real, parameter :: PI = 3.1415926535
real, parameter :: PI2 = PI*PI
print *, "Using Bhaskara approximation:"
r = 16*x*(PI-x)/(5*PI2-4*x*(PI-x))
end function
end
C:\temp>ifort /standard-semantics p.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.5.0 Build 20211109_000000
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.31.31105.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:p.exe
-subsystem:console
p.obj
C:\temp>p.exe
Using Bhaskara approximation:
sin(0.5) = 0.4795828
Using intrinsic implementation:
sin(0.5) = 0.4794255