LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Fortan Error: Nonnegative width required in format string at (1) (https://www.linuxquestions.org/questions/programming-9/fortan-error-nonnegative-width-required-in-format-string-at-1-a-813400/)

Astrodude 06-10-2010 01:45 PM

Fortan Error: Nonnegative width required in format string at (1)
 
Hi all,

I'm in the process of debugging and compiling about sixty FORTRAN 95 programs and could use a little bit of your help before my brain is fried and fingers are cramped. Thanks for your time!

I receive the following errors:

In file test_break60.f:12

120 format(2f)
1
Error: Nonnegative width required in format string at (1)
In file test_break60.f:19

145 format(i)
1
Error: Nonnegative width required in format string at (1)
In file test_break60.f:27

150 format(' i=',i3, 2x,f,2x,f)
1
Error: Nonnegative width required in format string at (1)



Here is my code:

implicit none
integer*4 n_out,i
real*4 lat1,lat2,long1,long2,long_out(100),lat_out(100)

100 continue
write(6,110)
110 format('$lat1,long1: ')
read(5,120) lat1,long1
120 format(2f)
write(6,130)
130 format('$lat2,long2: ')
read(5,120) lat2,long2
write(6,140)
140 format('$Number of arc segments: ')
read(5,145) n_out
145 format(i)

lat_out(1) = lat1
lat_out(n_out) = lat2
long_out(1) = long1
long_out(n_out) = long2
call arc_break60(n_out,lat_out,long_out)
write(6,150) (i,lat_out(i),long_out(i),i=1,n_out)
150 format(' i=',i3, 2x,f,2x,f)
go to 100
end

JZL240I-U 06-11-2010 03:59 AM

Done from memory about 30 years old (using FORTRAN IV and later 77):
Code:

120 format(f6.2)
meaning 6 digits total, with 2 behind the decimal dot (which can either be given or skipped, i.e. 123456 equals 1234.56
Code:

145 format(i4)
integers, with four decimal digits like 1234
Code:

150 format(' i=',i3, 2x,f,2x,f)
same for this one. I guess that "2x" means two blank spaces. Just try doing that literally like
Code:

150 format(' i=',i3,"  ",f6.2,"  ",f6.2)
Substitute the numbers I used with the values needed for your program.

Also, remember that REAL in FORTRAN on a 32bit machine has only 7 meaningful digits. For more you need double precision.

Astrodude 06-11-2010 08:41 AM

Thank you! Your memory seemed to do the trick. Now I just have one last error that reads:

undefined reference to 'arc_break60__'


According to my memory that seems to be a linking issue. Agree?

JZL240I-U 06-11-2010 08:51 AM

Code:

call arc_break60(n_out,lat_out,long_out)
This is the call of a procedure. Must be a file also to be compiled and linked (or resides in a library). If you don't have either, you are done for ;).

Astrodude 06-11-2010 09:03 AM

Linked and running! :D

Many thanks.

JZL240I-U 06-14-2010 01:55 AM

You're welcome. Sometimes even "prehistoric" memories are useful, glad I could help.


All times are GMT -5. The time now is 09:45 PM.