- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 :).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I meant the forum website, where you post your question :).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page