Fixing Nonnegative and Positive Width Errors in Fortran Code Format Strings

In summary, when compiling a Fortran code (*.f90), there were two errors: 1) Nonnegative width required in format string and 2) Positive width required in format specifier D. These errors were referred to in the code as format(1000i) and format(1000d), respectively, in Code::Blocks IDE. To solve this, the correct format should have been specified as i4 for four digit integers and d4.2 for two decimal places. However, this led to a new error message regarding the module file 'dfport.mod' not being found. After researching and trying various solutions, including removing the USE DFORT statement, the issue was resolved by switching off the statement altogether. It was mentioned
  • #1
MrElec
When compiling a fortran code (*.f90) i got these errors:

1- Nonnegative width required in format string.
2- Positive width required in format specifier D.

In Code::Blocks Ide, these errors are referred in the code to :

format( 1000i ) and format ( 1000d ) respectively.

How can i solve this?
 
Last edited by a moderator:
Technology news on Phys.org
  • #3
Thanks, I've tried your solution and WoW these errors disapeared but unfortunately i got this message : D:\Simulations\CM\LAPACK_ARPACK\DOUBLE LAPACK\dsecnd.f|16| Fatal Error: Can't open module file 'dfport.mod' for reading at (1): No such file or directory|. Do you have an idea about this problem
 
  • #4
THese questions are best answered by searching with Google to see if others have encountered them:

https://stackoverflow.com/questions/35015117/fatal-error-cant-open-module-file-dfport-mod-for-reading-at-1
 
  • Like
Likes MrElec
  • #5
I've googled this problem before posting it here. In the link you gave, the authors could not give a functional solution. For my case, I'm using gnu fortron as compiler and C::B as an ide.
 
  • #6
What about this from the link?

One suggestion is to remove the use statements, and see what the compiler/linker complains about being missing
 
  • #7
I've tried to remove the use dfport statement, i got other error as etime
 
  • #9
Thank you, i think that I've resolved my problem by switching off USE DFORT statement.
 

Related to Fixing Nonnegative and Positive Width Errors in Fortran Code Format Strings

1. What are nonnegative and positive width errors in Fortran code format strings?

Nonnegative and positive width errors refer to errors in the formatting of data in Fortran code, specifically when specifying the width of a particular data item. These errors occur when the specified width is either negative or positive, rather than the expected format of a positive number followed by a letter indicating the type of data (e.g. I for integer, F for floating point).

2. How do these errors affect the performance of Fortran code?

These errors can cause unexpected behavior in Fortran code, as the incorrect formatting can result in the wrong data being read or written. This can lead to incorrect calculations or output, and can be difficult to debug.

3. What causes nonnegative and positive width errors in Fortran code?

These errors are typically caused by typos or mistakes in the formatting of data items in the code. For example, using a period instead of a comma to separate the width and type, or forgetting to include a letter indicating the type altogether.

4. How can these errors be fixed?

To fix nonnegative and positive width errors, the formatting of data items in the Fortran code needs to be carefully reviewed and corrected. This may involve checking for typos and ensuring that the width and type are properly specified for each data item.

5. Are there any tools or resources available to help with fixing these errors?

Yes, there are several tools and resources available to assist with fixing nonnegative and positive width errors in Fortran code. These include online tutorials, forums, and code editors with syntax highlighting and error detection features.

Similar threads

  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
4
Views
663
  • Programming and Computer Science
Replies
5
Views
10K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
5K
  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
Back
Top