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

Create an Output file

nicolas_legrand
592 Views

Hello, 

 

In my fortran project, I attempt to simply create an output file with some headers in it using the following code:


OPEN(987, file = 'OutputFile.txt', status = 'unknown')

WRITE(987, '(37(A,$))') 'GammaB_CB[1,1,1]',CHAR(9), &
'GammaP_CB[1,1,1]',CHAR(9), &
'Rb_CB[1,1,1]', CHAR(9), &
'Rp_CB[1,1,1]', CHAR(9), &
'def0', CHAR(9), &
'actions', CHAR(9)

 

However, when I compile, the compiler sends back the following error for the line WRITE(987, ...) :

 error #5082: Syntax error, found '&' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ... 

 

It is strange because this piece of code compiles in another fortran project I have made before. Why it does not compile for my new project ? Is there any project configuration I should look at ?

Nicolas

 

Labels (1)
0 Kudos
9 Replies
Arjen_Markus
Honored Contributor I
584 Views

You best use the </> icon to insert source code (under the ... icon), because then indentation is preserved. One possible explanation is that you are now using a fixed-form source file. In that case, the continuation has to be via the sixth column - hence the indentation is important :).

nicolas_legrand
572 Views

where is the </> icon (under ... icon) ? I don't see that .

Attached I put my VS intel fortran interface in case you see it.

 

Thanks

 

Nicolas

Arjen_Markus
Honored Contributor I
567 Views

I meant the forum website, where you post your question :).

nicolas_legrand
560 Views
jimdempseyatthecove
Black Belt
546 Views

The error message refers to line 54 in file constante.txt

I presume used as an INCLUDE file used by cage_bande.f90.

Please examine constante.txt for syntax error.

 

Jim Dempsey

Steve_Lionel
Black Belt Retired Employee
584 Views

You didn't show us the entire error (including the name of the source file). My guess, and reproduced with an experiment, is that you have named your file with a file type other than .f90, such as .f or .for. This tells the compiler that it is fixed-form source, and you'll get exactly this error in such a case.

The fix would be to rename the file to have a .f90 file type.

nicolas_legrand
572 Views

You are right: my project where Open/write synthax works is named in .f90, while my project where Open/write synthax does not work is named in .for: see attached.

However, if I rename the single file cage_bande.for in cage_bande.f90, the compilation generates other errors: see attached.

Should I rename all my files fomr .for to .f90 ? (I have 10' to 100' fortran files !).

thanks 

Ron_Green
Moderator
544 Views

the errors you show are in constante.txt - a text file???  why are you compiling  .TXT file?  shouldn't that be a .f90 file also?

 

.for extension will be compiled as old fixed source form.

.f90 extension for free source form. 

 

 

Steve_Lionel
Black Belt Retired Employee
528 Views

You may want to read one of my favorite posts, Doctor Fortran in "Source Form Just Wants to be Free" - Doctor Fortran (stevelionel.com)

The sources you show use the free source form. In order for them to be compiled properly, they should have the .f90 file type. You may have some other source files that are fixed-form, those can be .for. You will have to look at each source and determine which form it uses.

Reply