나는 인텔에서 계정을 열지는 못하지만 stackexchange에 대해서는 언급하지 않기 때문에이 글을 여기에 넣기로했다. 포트란을 배우면서 어쨌든, 나 자신 F03 코드의이 조각 쓰기 발견 : 그래서ifort에 발생 가능한 버그
module log_module
implicit none
public :: assignment(=), operator(+), operator(-), &
operator(*), operator(==), operator(/=)
private :: logical_to_integer, integer_to_logical, &
log_plus_log, log_minus, log_times_log, &
log_equals_log, log_nequals_log
interface assignment(=)
module procedure logical_to_integer, &
integer_to_logical
end interface
interface operator(+)
module procedure log_plus_log
end interface
interface operator(-)
module procedure log_minus
end interface
interface operator(*)
module procedure log_times_log
end interface
interface operator(==)
module procedure log_equals_log
end interface
interface operator(/=)
module procedure log_nequals_log
end interface
contains
elemental function log_equals_log(x, y) result(log_result)
logical, intent(in) :: x, y
logical :: log_result
log_result = x .eqv. y
end function log_equals_log
elemental function log_nequals_log(x, y) result(log_result)
logical, intent(in) :: x, y
logical :: log_result
log_result = x .neqv. y
end function log_nequals_log
function log_plus_log(x, y) result(log_result)
logical, intent(in) :: x, y
logical :: log_result
log_result = x .or. y
end function log_plus_log
function log_minus(x) result(log_result)
logical, intent(in) :: x
logical :: log_result
log_result = .not. x
end function log_minus
function log_times_log(x, y) result(log_result)
logical, intent(in) :: x, y
logical :: log_result
log_result = x .and. y
end function log_times_log
subroutine logical_to_integer(i, log_exp)
integer, intent(out) :: i
logical, intent(in) :: log_exp
if(log_exp) then
i = 1
else
i = 0
end if
end subroutine logical_to_integer
subroutine integer_to_logical(logic, inte)
integer, intent(in) :: inte
logical, intent(out) :: logic
if(inte == 0) then
logic = .false.
else
logic = .true.
end if
end subroutine integer_to_logical
end module log_module
program test
use log_module
implicit none
integer :: i, j
logical :: k
logical, dimension(:), allocatable :: a, b
a = [.true., .true.]
b = [.false., .true.]
print *, a
i = .false.
print *, i
j = (5 < 7) .and. (sin(0.3) < 1.0)
print *, j
k = 3*5 - 5*3
if(.not.k) print *, "Conversion to logical is correct"
print *
print *, .false. + .true.
print *, .true. * .true.
print *, (2.2>5.5) + (2.2<5.5) ! + has higher precedence than <or>
print *, 2.2>5.5 .or. 2.2<5.5 ! see my point?
print *
print *, [.true., .false.] == [.true., .false.]
if(all(a == b)) then
print *, "something's wrong"
else if(any(a /= b)) then
print *, "Array non-equality check"
end if
end program test
를, 내가 ifort를 사용하여 컴파일하고 "뭔가 잘못"메시지를 가지고, 그때 gfortran을 사용 를 컴파일하고 예상대로 실행 . 을 할당 할 수있는 논리 배열 변수 (여기서는 a 및 b)에 논리 배열을 할당하려고 시도 할 때 문제가있는 것으로 보입니다.
현재, ifort 15의 평가판을 사용하고 있습니다. 미래에는 수치 시뮬레이션 코드에 대한 학생 (라이센스 당 200 달러) 패키지를 구입할 계획입니다. 어떤 사람들은 "왜 너는 gfortran을 계속 사용하지 않는가?"라고 물을 수도 있습니다. 물론, 내가 포트란 2003 기능을 좋아하고, 언어의 몇 가지 중요한 측면이 :(아직 gfortran에서 구현되지 않습니다.
의견? 제안? 불만?
글쎄, 실제로'forrtl : severe (408) : fort : (8) : 할당 가능 변수 A가 할당되지 않았을 때 가져 오기 시도 '및'ifort'를 사용하여 코드를 실행할 때 해당 줄 15. 단일 웹 검색에서 나에게 답을주었습니다 ... 다음 번에 열심히 노력하십시오. –
마크, 정확하게 당신이 무엇을 말하는지 모르겠지만 ... 만약 당신이 컴파일하면 내가 무슨 말을하는지 보게 될 것입니다. 어쩌면 나는 본문에서 분명히하지 않았다. 죄송합니다 – Kbzon
@ Alexander Vogt 행운의 당신, 왜냐하면 나는 그런 경고를받지 못했습니다. ifort -warn all – Kbzon