Comp Sci Help with Fortran compile error.

  • Thread starter Thread starter speculater
  • Start date Start date
  • Tags Tags
    Error Fortran
AI Thread Summary
The user is encountering a compilation error in Fortran due to an unexpected element '<' in their format string. They initially attempted to resolve the issue by breaking the code into two lines and adding spaces, but these methods did not work. It was suggested that the angle brackets should be omitted, as they are not valid in the format string. After further review, the user discovered that the problematic line was never called, prompting them to consider removing it. The discussion also included suggestions for using a fixed number, like 25, for formatting data values.
speculater
Messages
3
Reaction score
0
1. Hello, I'm doing undergraduate research which requires the use of Fortran. I have one particle line of code that is not allowing me to compile the source. I was wonderding if someone can help?

909 FORMAT(i3,2x,<nvmax>(<nvmax>i1,2x),2x,i4)

2. Provides the error message:

../gensc.f90:289.18: Error: Unexpected element '<' in format string at (1)3. I'm not very familiar with the language yet, but I did try breaking up the code into two lines with the use of &&. I've also tried inserting spaces between all the "<" and ">". Any help would be greatly appreciated.
 
Last edited:
Physics news on Phys.org
It is conventional to use <num> to indicate that you need to insert your own data value here. You should omit the angle brackets.

I'm speaking generally, not specifically of Fortran of which I've forgotten much.
 
I'm at work now, but I can't believe I didn't see this sooner! Now I'm excited to get home :-).

Thank you so much!
 
That didn't fix the compile error, but after reviewing all the code it appears that the line in question is never called on. I'm going to remove it and see if I can get my desired results.
 
nvmax looks like both the number of particular data values per line and the number of digits in each of those data values. If stuck, try 25 and see how it goes. It should be obvious if it is not a good choice for printing. I presume it's printing? :smile:

909 FORMAT(i3,2x,25(251,2x),2x,i4)
 
speculater said:
909 FORMAT(i3,2x,<nvmax>(<nvmax>i1,2x),2x,i4)

NascentOxygen said:
nvmax looks like both the number of particular data values per line and the number of digits in each of those data values. If stuck, try 25 and see how it goes. It should be obvious if it is not a good choice for printing. I presume it's printing? :smile:

909 FORMAT(i3,2x,25(251,2x),2x,i4)

I would try
909 FORMAT(i3,2x,25(25i[/color]1,2x),2x,i4)

IOW, there is an 'i' missing in the innermost set of parentheses.
 

Similar threads

Replies
12
Views
4K
Replies
7
Views
2K
Replies
2
Views
1K
Replies
5
Views
2K
Replies
2
Views
2K
Replies
8
Views
3K
Replies
2
Views
2K
Back
Top