Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28167 Discussions

Intel compiler seems to consider '//' as a comment in my FORTRAN 90 code

RobAstro
Beginner
343 Views

Hi there, I am using fortran 90 and compiling my .F90 file with intel-compiler/2019.5.281 

 

My file has the following lines: 

fname_lower_bound = "sevoldata" // trim(lower_bound) // ".txt"

read_file(fname_lower_bound, input_data_lower_bound, num_rows_lower_bound)

 

where 'lower_bound' is a string, 'read_file' is a function that reads in the file and I want to concatenate it with "sevoldata" and ".txt" to read the right text file. However, while compiling, I run into this error: 

 

Particles_sinkStellarEvolution.F90(293): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( % [ . = =>
read_file(fname_lower_bound, input_data_lower_bound, num_rows_lower_bound)
----------------------------------------------------------------------------------^

It seems that the compiler treats '//' as a comment, because when I load the .F90 file into a text reader that can identify and format fortran code, everything from the first '//' in this line becomes a comment. I cannot change the intel-compiler as this file is a part of a much bigger code (developed for the years) that only runs with this compiler. Any suggestions for how can I successfully concatenate the file name (or tricks)?

 

Thanks!

Labels (2)
0 Kudos
1 Solution
jimdempseyatthecove
Black Belt
301 Views

You also have fpp option to disable C style comments:

/c_com=<yes|no> Recognize or not C style comments. Default value /c_com=yes

use /c_com=no

Jim Dempsey

View solution in original post

5 Replies
Arjen_Markus
Honored Contributor I
334 Views

Are you using the preprocessor option? I can imagine that the preprocessor is confusing string concatenation with C++ comment lines. The extension .F90 (instead of .f90) might be the guilty party here.

0 Kudos
RobAstro
Beginner
317 Views

Thanks for your response @Arjen_Markus I renamed the file from .F90 to .f90, and I can see that the formatting doesn't show the line above as a comment after '//'. However, I include some .h files in this file early on, and changing the extension from .F90 to .f90 generates some bad preprocessor line errors:

Particles_sinkStellarEvolution.f90(36): warning #5117: Bad # preprocessor line
#include "constants.h"
-^

Is there a way to resolve this?

0 Kudos
Arjen_Markus
Honored Contributor I
303 Views

It depends a bit: is the included file a regular Fortran file that defines a number of parameters? Or is it a C-style include file, with such lines as:

#define GRAVITY 9.81

In the first case, you can use the include statement:

include 'constants.h'

In the second case, you should translate it into regular Fortran and use the include statement.

0 Kudos
jimdempseyatthecove
Black Belt
302 Views

You also have fpp option to disable C style comments:

/c_com=<yes|no> Recognize or not C style comments. Default value /c_com=yes

use /c_com=no

Jim Dempsey

RobAstro
Beginner
288 Views

Thanks both! Disabling C style comments worked.

0 Kudos
Reply