如何使用2017 2017新版本编译此Fortran代码?

时间:2016-10-18 15:22:18

标签: fortran c-preprocessor intel-fortran

我有以下fortran代码编译2017之前的ifort:

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)

1 个答案:

答案 0 :(得分:3)

您的程序在预处理后是非法的Fortran,因为//被解释为C注释。

只是不要使用icc,而是使用ifortIfort适用于Fortran,icc适用于C. Ifort使用不会丢弃fpp的其他预处理器//