Fortran Why is My Fortran Code Not Working?

  • Thread starter Thread starter Petar Mali
  • Start date Start date
  • Tags Tags
    Code Fortran
AI Thread Summary
The discussion centers around a programming issue related to a Fortran code snippet. The user is seeking help to understand why their code is not functioning as intended. Key points include the need for clarification on what "this don't work" specifically means, including the expected outcome versus the actual behavior of the program. Participants emphasize the importance of identifying any error messages encountered during compilation or execution. Additionally, a suggestion is made to correct the constant notation from "2.do" to "2.d0" to avoid potential issues. The conversation highlights the importance of clear communication regarding programming problems and the need for precise syntax in code.
Petar Mali
Messages
283
Reaction score
0
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
 
Technology news on Phys.org
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?)
 
Your constants like 2.do should be 2.d0 (with a zero, not a letter o).

If that doesn't fix your problem ... what [STRIKE]Christo[/STRIKE] JT Bell said.
 
Last edited by a moderator:
Tnx. That was mistake.
 
Last edited:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
6
Views
2K
Replies
8
Views
2K
Replies
4
Views
2K
Replies
2
Views
2K
Replies
6
Views
3K
Replies
7
Views
14K
Replies
8
Views
6K
Back
Top