如何使用新的 2017 ifort 编译此 Fortran 代码?
How do I compile this Fortran code with new 2017 ifort?
我有以下使用 2017 年之前的 ifort 编译的 Fortran 代码:
program parallel_m
contains
character(500) function PARALLEL_message(i_ss)
character(50) :: Short_Description = " "
integer :: i_s =0
integer :: n_threads = 0
!
PARALLEL_message=" "
!
if (i_s>0) then
if (len_trim("test this ")==0) return
endif
!
if (i_s==0) then
PARALLEL_message=trim("10")//"(CPU)"
if (n_threads>0) PARALLEL_message=trim(PARALLEL_message)//"-"//trim("200")//"(threads)"
else
PARALLEL_message=trim("a")//"(environment)-"//&
& trim("a")//"(CPUs)-"//&
& trim("a")//"(ROLEs)"
endif
!
end function
end program parallel_m
通过预处理器:
icc -ansi -E example.F > test.f90
产生:
# 1 "mod.F"
program parallel_m
contains
character(500) function PARALLEL_message(i_ss)
character(50) :: Short_Description = " "
integer :: i_s =0
integer :: n_threads = 0
!
PARALLEL_message=" "
!
if (i_s>0) then
if (len_trim("test this ")==0) return
endif
!
if (i_s==0) then
PARALLEL_message=trim("10")
if (n_threads>0) PARALLEL_message=trim(PARALLEL_message)
else
PARALLEL_message=trim("a")
& trim("a")
& trim("a")
endif
!
end function
end program parallel_m
这个不幸的是用intel 2017编译不了,一样
输出在 2016 年和 2015 年的 ifort 版本上没有抱怨地编译。
这是我得到的错误:
mod.F(19): error #5082: Syntax error, found '&' when expecting one of: <LABEL> <END-OF-STATEMENT> ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
& trim("a")
------------------------^
mod.F(20): error #5082: Syntax error, found '&' when expecting one of: <LABEL> <END-OF-STATEMENT> ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
& trim("a")
------------------------^
compilation aborted for test.f90 (code 1)
你的程序在预处理后是非法的 Fortran,因为 //
被解释为 C 注释。
干脆不使用icc
,而是ifort
。 Ifort
用于 Fortran,icc
用于 C。Ifort
使用不同的预处理器 fpp
,它不会丢弃 //
.
我有以下使用 2017 年之前的 ifort 编译的 Fortran 代码:
program parallel_m
contains
character(500) function PARALLEL_message(i_ss)
character(50) :: Short_Description = " "
integer :: i_s =0
integer :: n_threads = 0
!
PARALLEL_message=" "
!
if (i_s>0) then
if (len_trim("test this ")==0) return
endif
!
if (i_s==0) then
PARALLEL_message=trim("10")//"(CPU)"
if (n_threads>0) PARALLEL_message=trim(PARALLEL_message)//"-"//trim("200")//"(threads)"
else
PARALLEL_message=trim("a")//"(environment)-"//&
& trim("a")//"(CPUs)-"//&
& trim("a")//"(ROLEs)"
endif
!
end function
end program parallel_m
通过预处理器:
icc -ansi -E example.F > test.f90
产生:
# 1 "mod.F"
program parallel_m
contains
character(500) function PARALLEL_message(i_ss)
character(50) :: Short_Description = " "
integer :: i_s =0
integer :: n_threads = 0
!
PARALLEL_message=" "
!
if (i_s>0) then
if (len_trim("test this ")==0) return
endif
!
if (i_s==0) then
PARALLEL_message=trim("10")
if (n_threads>0) PARALLEL_message=trim(PARALLEL_message)
else
PARALLEL_message=trim("a")
& trim("a")
& trim("a")
endif
!
end function
end program parallel_m
这个不幸的是用intel 2017编译不了,一样 输出在 2016 年和 2015 年的 ifort 版本上没有抱怨地编译。 这是我得到的错误:
mod.F(19): error #5082: Syntax error, found '&' when expecting one of: <LABEL> <END-OF-STATEMENT> ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
& trim("a")
------------------------^
mod.F(20): error #5082: Syntax error, found '&' when expecting one of: <LABEL> <END-OF-STATEMENT> ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
& trim("a")
------------------------^
compilation aborted for test.f90 (code 1)
你的程序在预处理后是非法的 Fortran,因为 //
被解释为 C 注释。
干脆不使用icc
,而是ifort
。 Ifort
用于 Fortran,icc
用于 C。Ifort
使用不同的预处理器 fpp
,它不会丢弃 //
.