Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem with code in Fortran

  1. Feb 8, 2012 #1
    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
     
  2. jcsd
  3. Feb 8, 2012 #2

    jtbell

    User Avatar

    Staff: Mentor

    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?)
     
  4. Feb 8, 2012 #3

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    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: Feb 8, 2012
  5. Feb 8, 2012 #4
    Tnx. That was mistake.
     
    Last edited: Feb 8, 2012
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Problem with code in Fortran
  1. Fortran code problem (Replies: 2)

  2. Running a Fortran code (Replies: 4)

  3. Help with fortran code (Replies: 17)

  4. Help with fortran code (Replies: 4)

Loading...