Help with Fortran compile error.

  • Context: Comp Sci 
  • Thread starter Thread starter speculater
  • Start date Start date
  • Tags Tags
    Error Fortran
Click For Summary

Discussion Overview

The discussion revolves around a compile error encountered in Fortran code related to a FORMAT statement. Participants are exploring potential solutions and clarifications regarding the syntax and usage of format strings in Fortran.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant presents a FORMAT statement that is causing a compile error due to the use of angle brackets, which are not conventional in Fortran syntax.
  • Another participant suggests omitting the angle brackets, indicating that they are meant to represent placeholders for user-defined values.
  • A later reply expresses excitement about the potential solution but notes that the error persists after reviewing the code, leading to the decision to remove the problematic line.
  • Another participant proposes that the variable nvmax could represent both the number of data values per line and the number of digits in each value, suggesting a trial value of 25 for testing purposes.
  • A further contribution reiterates the suggestion to use 25 for nvmax and points out a missing 'i' in the innermost parentheses of the FORMAT statement, implying a correction to the syntax.

Areas of Agreement / Disagreement

Participants do not reach a consensus on a definitive solution to the compile error, as multiple suggestions are offered, and the discussion includes both proposed corrections and ongoing uncertainties regarding the correct syntax.

Contextual Notes

There are unresolved issues regarding the specific role of nvmax in the FORMAT statement and the implications of the suggested changes on the overall functionality of the code.

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
7
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K