Why is My Fortran Code Not Working?

  • Context: Fortran 
  • Thread starter Thread starter Petar Mali
  • Start date Start date
  • Tags Tags
    Code Fortran
Click For Summary

Discussion Overview

The discussion centers around a Fortran code that a participant is having trouble with. The scope includes programming issues, potential errors in code syntax, and debugging practices.

Discussion Character

  • Technical explanation, Debate/contested

Main Points Raised

  • One participant shares a Fortran code snippet and expresses confusion about why it is not functioning as intended.
  • Another participant requests clarification on what "this don't work" means, asking for details about the expected functionality and any error messages encountered during compilation or execution.
  • A third participant points out a potential issue with the use of "2.do" instead of "2.d0" for defining constants, suggesting that this could be a source of error.
  • The original poster acknowledges the mistake regarding the constant format.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the overall issue, as the original problem remains partially undefined and further clarification is needed.

Contextual Notes

The discussion highlights potential syntax errors in the Fortran code but does not resolve the underlying issue of the program's functionality or the specific errors encountered.

Who May Find This Useful

Individuals interested in Fortran programming, debugging practices, and syntax issues may find this discussion relevant.

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:

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K