- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello forum,
Im rather new to fortran (and linux) but do need it for university.
I now have the following problem when compiling a f90-program :
different error messages occur regarding the FORMAT statement and I can`t figure out why:
700 FORMAT (1X,1H,68(1H),1H)
compiler errors:
Syntax error, found END-OF-STATEMENT when expecting one of: ) ...
700 FORMAT (1X,1H,68(1H),1H)
-----------------------------------------^
The format list is missing parentheses as delimiters. [)]
700 FORMAT (1X,1H,68(1H),1H)
--^
(the error messages dont occur anywhere else, e.g.
801 FORMAT (3X,A2)
and I really can`t see the difference)
My professor also had a look at the FORMAT statement and thought it ok, so I guess theres something strange with my compiler?
(the programm is written in a fixed form and is thus compiled with:
ifort -fixed hf2d.f90)
Does anybody have an idea? (and might be able to explain it to me as easy as possible?)
Cheers,
Damaris
Im rather new to fortran (and linux) but do need it for university.
I now have the following problem when compiling a f90-program :
different error messages occur regarding the FORMAT statement and I can`t figure out why:
700 FORMAT (1X,1H,68(1H),1H)
compiler errors:
Syntax error, found END-OF-STATEMENT when expecting one of:
700 FORMAT (1X,1H,68(1H),1H)
-----------------------------------------^
The format list is missing parentheses as delimiters. [)]
700 FORMAT (1X,1H,68(1H),1H)
--^
(the error messages dont occur anywhere else, e.g.
801 FORMAT (3X,A2)
and I really can`t see the difference)
My professor also had a look at the FORMAT statement and thought it ok, so I guess theres something strange with my compiler?
(the programm is written in a fixed form and is thus compiled with:
ifort -fixed hf2d.f90)
Does anybody have an idea? (and might be able to explain it to me as easy as possible?)
Cheers,
Damaris
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume you copied this FORMAT from a book or some printed source, and, not knowing Fortran, you made some errors in the copying. (I also assume that your professor doesn't know old Fortran very well, or he would have seen the problems in your copying.)
The FORMAT item 1Hc, where c is an arbitrary character, has the effect of putting the character c in your output. I suspect that FORMAT 700 was intended to skip one space at the beginning of the line (probably to indicate single space carriage control to a line printer, but that's a subject for a different time), put out one character, 68 copies of second character, and finally a third character (which might be the same as the first). However, it appears you failed to copy the "c" in each of these 1Hc items, so the compiler took the comma as the first "c" (which was probably wrong but didn't upset the compiler) and the two closing parentheses as the second and third "c"s, leaving the FORMAT with unbalanced parentheses and the syntax error reported by the compiler.
At a minimum, you need to go back to you source, determine the "c"s you left out, and insert them. Even better, replace each 1Hc by 'c' or "c". This does the same thing in the output, but most people find it easier to recognize that quoted strings are special than to recognize the H form.
In case you copy more old programs, I will point out that in the general case the number before H can be greater than 1, e.g., 4HWORD. In general, the number before H specifies the number of literal characters following H. Counting characters gets to be a real pain as the strings get longer, so FORTRAN 77 introduced 'WORD' as an alternative to 4HWORD, and Fortran 90 introduced "WORD" as a second alternative. These days, both 'WORD' and "WORD" are considered preferable to 4HWORD in most situations.
Does that help?
-Kurt
The FORMAT item 1Hc, where c is an arbitrary character, has the effect of putting the character c in your output. I suspect that FORMAT 700 was intended to skip one space at the beginning of the line (probably to indicate single space carriage control to a line printer, but that's a subject for a different time), put out one character, 68 copies of second character, and finally a third character (which might be the same as the first). However, it appears you failed to copy the "c" in each of these 1Hc items, so the compiler took the comma as the first "c" (which was probably wrong but didn't upset the compiler) and the two closing parentheses as the second and third "c"s, leaving the FORMAT with unbalanced parentheses and the syntax error reported by the compiler.
At a minimum, you need to go back to you source, determine the "c"s you left out, and insert them. Even better, replace each 1Hc by 'c' or "c". This does the same thing in the output, but most people find it easier to recognize that quoted strings are special than to recognize the H form.
In case you copy more old programs, I will point out that in the general case the number before H can be greater than 1, e.g., 4HWORD. In general, the number before H specifies the number of literal characters following H. Counting characters gets to be a real pain as the strings get longer, so FORTRAN 77 introduced 'WORD' as an alternative to 4HWORD, and Fortran 90 introduced "WORD" as a second alternative. These days, both 'WORD' and "WORD" are considered preferable to 4HWORD in most situations.
Does that help?
-Kurt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
compiling does work now -
thanks a lot
thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will also comment that use of the H edit descriptor is tricky and that it's easy to make mistakes in character counts, etc. It is a holdover from Fortran 66 and I strongly recommend using a character litersl in the format (eg. 'abc') or the X format if you want spacing.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page