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

Comments

felipin85
Beginner
2,364 Views
Hi everybody! I like make a question of curiosity. I normaly do the comments in fortran 95/90 with "!", but I read in Intel Fortran Programmers Reference that I can create a comment with "C or c",with "*" and with "#", but I try in hola.f90, and I get the following errors:


Estoy compilando, tardo un ratn...
hola.f90(2): error #5082: Syntax error, found IDENTIFIER 'THIS' when expecting one of: ( % [ : . = =>
C THIS IS A COMMENT
--^
hola.f90(3): error #5082: Syntax error, found '*' when expecting one of:
0 Kudos
1 Solution
Steven_L_Intel1
Employee
2,364 Views
Please do not use -fixed or -free. Instead, rename the source file to have the .f90 file type if it is free-form source, or .f or .for if it is fixed-form source.

You misunderstood the documentation - the part where it talks about C as a comment delimiter is in the section for fixed-form source specifically.

I strongly recommend the use of free-form source in all new development.

View solution in original post

0 Kudos
10 Replies
John4
Valued Contributor I
2,364 Views

The .f90 extension (and .f95, .f2k, .f03, .f08, ...) is usually associated to free-form source files, and therefore only "!" is allowed to indicate the beginning of a comment (anywhere between columns 1 and 132).

The fixed-form source files (which usually have extensions .f, .for, .f77, .ftn, ...) allow "C" or "*" but only in the first column. Fixed-form files also allow "!" anywhere between columns 1 and 5 and between columns 7 and 72.

The compiler will let you put "!" after column 132 (in free-form) or after column 73 (in fixed form), but some extra flags might be required and it's not a portable solution.

0 Kudos
felipin85
Beginner
2,364 Views
I was surprised it did not work because I read in the guide intel fortran. It's a shame, because I would have liked to reuse code that I have on. for or. f77 and change them. f90.
0 Kudos
TimP
Honored Contributor III
2,364 Views
If you want to use fixed form input with .f90 file name, there is an option for that, but the usual way is to continue to use those file names with .f or .for suffixes.
0 Kudos
felipin85
Beginner
2,364 Views
Thanks for yor response! which is this option? But, Is possilble the I using the fortran 90 options and I name as .for? Thanks
0 Kudos
Udit_P_Intel
Employee
2,364 Views
I think that you can use -fixed and -free options to specifically tell the compiler that the program is Fixed Form (F77 style) and Free Form (F90 and later) respectively. Unless I am missing something, these options will override the extension of the filename.
0 Kudos
felipin85
Beginner
2,364 Views
Ok, then I must add in the makefile in the line:

FFLAGS=-openmp -O3 -traceback

the option -fixe or free?:

FFLAGS=-openmp -O3 -traceback -fixed


Thanks for your help

Regards
0 Kudos
Udit_P_Intel
Employee
2,364 Views
You should add -fixed in the makefile. This will enable a .f90 file to be treated in fixed form. In other words, your original code should work without the syntax error with this option.

Best!
-Udit
0 Kudos
TimP
Honored Contributor III
2,364 Views
The ! form of comments will work regardless of fixed or free format.
0 Kudos
Steven_L_Intel1
Employee
2,365 Views
Please do not use -fixed or -free. Instead, rename the source file to have the .f90 file type if it is free-form source, or .f or .for if it is fixed-form source.

You misunderstood the documentation - the part where it talks about C as a comment delimiter is in the section for fixed-form source specifically.

I strongly recommend the use of free-form source in all new development.
0 Kudos
felipin85
Beginner
2,364 Views
Ok, Thanks for your help!
0 Kudos
Reply