Help with Fortran compile error.

In summary, The conversation is about a Fortran code that is not allowing the user to compile the source due to an unexpected element in the format string. The user has tried various solutions, such as breaking up the code and adding spaces, but the issue persists. Another person suggests using <num> instead of <nvmax> and also adjusting the number of data values and digits per line. The user plans to remove the problematic line and try the suggested solution to see if it works.
  • #1
speculater
3
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
  • #2
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.
 
  • #3
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!
 
  • #4
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.
 
  • #5
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)
 
  • #6
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(25i1,2x),2x,i4)

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

What is a Fortran compile error?

A Fortran compile error is an error that occurs when the computer is unable to successfully translate the written Fortran code into machine code that it can understand and execute. This can happen for various reasons, such as syntax errors, missing libraries, or incompatible code.

How do I fix a Fortran compile error?

The best way to fix a Fortran compile error is to carefully review your code and look for any syntax errors or missing libraries. You can also refer to any error messages or warnings provided by the compiler to help identify the issue. Additionally, seeking help from experienced Fortran programmers or online forums can also be helpful in resolving the error.

Why am I getting a Fortran compile error?

There are several possible reasons for getting a Fortran compile error. Some common reasons include syntax errors, missing libraries, or using incompatible code or compilers. It is also possible that the error is caused by a mistake in the code itself, such as a typo or incorrect variable declaration.

How can I prevent Fortran compile errors?

To prevent Fortran compile errors, it is important to write clean and error-free code. This includes following proper syntax rules and ensuring all necessary libraries are included in the code. It is also helpful to regularly test and debug your code while writing it, rather than waiting until the end to compile and potentially encounter multiple errors.

Can I use any compiler to compile Fortran code?

No, you cannot use any compiler to compile Fortran code. Fortran code is specific to the Fortran programming language, so you will need a compiler that is designed to translate Fortran code into machine code. Some popular Fortran compilers include GNU Fortran, Intel Fortran, and IBM XL Fortran.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
17
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top