Problem with code in Fortran


by Petar Mali
Tags: code, fortran
Petar Mali
Petar Mali is offline
#1
Feb8-12, 03:11 AM
P: 290
I'm new in programing. Does enybody knows why this don't work.

implicit none
integer i,N,Ntot,istag
real*8 t,U,tpin,k,eg,mstag
real*8 rho,Umstag,Urho
real*8 eaf,eaftot,lambdaminus

write(6,*) 'N,Ntot,t,U'
read (5,*) N,Ntot,t,U
write(36,*) Ntot/2+1

tpin=8.d0*datan(1.do)/dfloat(N)
rho=dfloat(Ntot)/dfloat(N)
Urho=U*rho/2.do

do 1000 istag,Ntot,2

mstag=dfloat(istag)/dfloat(N)
Umstag=U*mstag/2.do

eaftot=0.do
do 200,i=-Ntot/4+1,Ntot/4
k=tpin*dfloat(i)
ek=-2.do*t*dcos(k)
lambdaminus=-dsqrt(ek*ek+Umstag*Umstag)
lambdaminus=lambdaminus+Urho
eaftot=eaftot+lambdaminus
200 continue
eaftot=2.do*eaftot/dfloat(N)-U*(rho*rho-mstag*mstag)/4.do

write(36,990)
990 format(i6,f16.6)

1000 continue
end
Phys.Org News Partner Science news on Phys.org
Lemurs match scent of a friend to sound of her voice
Repeated self-healing now possible in composite materials
'Heartbleed' fix may slow Web performance
jtbell
jtbell is offline
#2
Feb8-12, 06:26 AM
Mentor
jtbell's Avatar
P: 11,221
Please define "this don't work". What is it supposed to do and what does it actually do? What error messages do you get, if any, and when? (when you try to compile the program, or when you try to run it?)
AlephZero
AlephZero is offline
#3
Feb8-12, 07:24 AM
Engineering
Sci Advisor
HW Helper
Thanks
P: 6,341
Your constants like 2.do should be 2.d0 (with a zero, not a letter o).

If that doesn't fix your problem ... what Christo JT Bell said.

Petar Mali
Petar Mali is offline
#4
Feb8-12, 09:01 AM
P: 290

Problem with code in Fortran


Tnx. That was mistake.


Register to reply

Related Discussions
A strange fortran code Programming & Computer Science 5
Help me write Fortran code Programming & Computer Science 2
Looking for fortran code or subroutine ,please help!!! Programming & Computer Science 0
Problem with Fortran g77 code Programming & Computer Science 4
Convert latex code to fortran code? Math & Science Software 1