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

Comments

felipin85
Einsteiger
2.899Aufrufe
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 Lösung
Steven_L_Intel1
Mitarbeiter
2.899Aufrufe
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.

Lösung in ursprünglichem Beitrag anzeigen

10 Antworten
John4
Geschätzter Beitragender I
2.899Aufrufe

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.

felipin85
Einsteiger
2.899Aufrufe
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.
TimP
Geehrter Beitragender III
2.899Aufrufe
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.
felipin85
Einsteiger
2.899Aufrufe
Thanks for yor response! which is this option? But, Is possilble the I using the fortran 90 options and I name as .for? Thanks
Udit_P_Intel
Mitarbeiter
2.899Aufrufe
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.
felipin85
Einsteiger
2.899Aufrufe
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
Udit_P_Intel
Mitarbeiter
2.899Aufrufe
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
TimP
Geehrter Beitragender III
2.899Aufrufe
The ! form of comments will work regardless of fixed or free format.
Steven_L_Intel1
Mitarbeiter
2.900Aufrufe
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.
felipin85
Einsteiger
2.899Aufrufe
Ok, Thanks for your help!
Antworten