-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathintrinsic.f90
50 lines (50 loc) · 1.08 KB
/
intrinsic.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module iso_fortran_env ! user-defined
implicit none
integer, parameter :: output_unit = -1
end module iso_fortran_env
!
module sin_mod
implicit none
contains
function sin(x) result(y)
! override sin() intrinsic
real, intent(in) :: x
real :: y
y = 10.0
end function sin
end module sin_mod
!
module m
implicit none
contains
subroutine replacements()
use iso_fortran_env
use sin_mod
print*,"in replacements()"
print*,"output_unit =",output_unit
print*,"sin(0.0) =",sin(0.0)
print*
end subroutine replacements
!
subroutine normal()
use, intrinsic :: iso_fortran_env, only: output_unit
intrinsic :: sin ! optional since sin_mod not USEd
print*,"in normal()"
print*,"output_unit =",output_unit
print*,"sin(0.0) =",sin(0.0)
end subroutine normal
end module m
!
program test_intrinsic
use m, only: replacements, normal
implicit none
call replacements()
call normal()
end program test_intrinsic
! in replacements()
! output_unit = -1
! sin(0.0) = 10.0000000
!
! in normal()
! output_unit = 6
! sin(0.0) = 0.00000000