Kenneth_Smith
Joined: 18 May 2012 Posts: 726 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Wed May 03, 2023 11:53 am Post subject: Possible (minor) bug |
|
|
With FTN95 the following code executes both the write statements in sub1. This is incorrect as access to the functions compiler_version() and compiler_options() from iso_fortran_env should be prevented by the ONLY statement.
Code: | module t_mod
use iso_fortran_env, only : INT8
implicit none
contains
subroutine sub1
write(6,'(/A,1X,I1)') 'Kind number of a 8 bit integer is', int8
write(6,'(/A,1X,A)') 'Compiled with', compiler_version()
write(6,'(/A,1X,A)') 'Compiler options',compiler_options()
end subroutine sub1
end module t_mod
program main
use t_mod
call sub1
end program main |
Fortunately this error appears to relate only to the functions in iso_fortran_env, and it is not apparent in the general case with user written code. FTN95 behaves as expected in the following example, i.e. sub1 has no access to function f2.
Code: | module a_mod
implicit none
contains
integer function f1()
f1 = 1
end function f1
integer function f2()
f2 = 2
end function f2
end module a_mod
module b_mod
use a_mod, only : f1
implicit none
contains
subroutine sub1
write(6,*) f1()
write(6,*) f2()
end subroutine sub1
end b_mod
program main
use b_mod
call sub1
end program main
|
|
|