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
1,404 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
1,396 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 :).

0 Kudos
nicolas_legrand
1,384 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

0 Kudos
Arjen_Markus
Honored Contributor I
1,379 Views

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

0 Kudos
nicolas_legrand
1,372 Views
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,358 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

0 Kudos
Steve_Lionel
Honored Contributor III
1,396 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.

0 Kudos
nicolas_legrand
1,384 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 

0 Kudos
Ron_Green
Moderator
1,356 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. 

 

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,340 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.

0 Kudos
Reply