Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error F6987

Status
Not open for further replies.

blueagle91

Programmer
Dec 8, 2010
2
I am new here, and i am new with FORTRAN. I hope i came to right place to ask a beginners question.
Here is my little code, what it does is not important some physics.
rogram zad87
implicit none
double precision,parameter :: m=5.98d24,g=6.672d11
double precision :: x
real :: r=6371,h
write(*,"(' Calculating h from 200 to 800 km')")

write (*,10) m,g
10 format (//,'result',//,&
3x,'Earth mass M=',d11.7,/,&
3x,'Constant G=',d11.7,//)

do h=200,800,50
x=-g*m/(r+h)**2

write(*,'(T2,f3,T18,d7.4)')h,x
end do

end program zad87

In attachent is image of program running. Now i know those stras means i need more space, but i have problem there too.
I have constanr m=5.98d24 when i put more places like d18.5 i get number .598000d25

And check the error belof F6987, i founded on net but i do not understand it.

I know C++ not FORTRAN so please help me.
It is program for school.

Thanks in advance.
 
Hi bluagle91

Your output format was incorret or not wide enough. The programming was also rather "messy", so I made it more clear. Try the following program:

Code:
	program zad87

	implicit none

	real*8 m,g,x
	real*8 r,h

	m = 5.98 d24
	g = 6.672 d11
	r = 6371

	write (*,'(1x,a)') 'Calculating h from 200 to 800 km'

	write (*,'(1x,a)') 'Result'
	write (*,'(1x,a,1x,f30.2)') 'Earth mass M =', m
	write (*,'(1x,a,1x,f30.2)') 'Constant G =  ', g

	do h=200,800,50
	   x = -g*m/(r+h)**2
	   write(*,'(T2,f10.3,T10,d20.8)') h,x 
	enddo

	end
 
Thank you very much gullipe,
this is very helpful. Program works as it is expected to work.
I know it is messy, this are my first attempts, adapting to new language.
Thank you again.
 
Never use real variables in iterative do loop header.
It does not conform to the modern Fortran standard.
 
The error code refers to your format in the write statement. It is printing H with format f3. Gullipe has changed this to f10.3 in the code reformat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top