INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

subroutine does not run

subroutine does not run

(OP)
Hi, i tried to write a program to calculate numerical derivative in main program + one subroutine
but this subroutine does not run. please help me.
---------------------------------------------------
program exemple
implicit none
INTEGER::i,j
integer,parameter::N=142
real::Dbeta,Dgamma
real,dimension(N)::beta,gamma
real,dimension(N,N)::H,dH

OPEN(unit=10,file='MP')
open(unit=30,file='resultats')

WRITE(30,200)'beta','gamma','H','dH'

DO i=1,N
DO j=1,N
READ(10,*)beta(i),gamma(j)
H(i,i)=0
H(i,j)=H(i,j)+(beta(i)*sin(gamma(j)))
WRITE(30,300)beta(i),gamma(j),H(i,j)
enddo
enddo
200 format(a10, a10, a10, a10,a10)
300 format(f10.2,f10.2,f10.2)

call deriv(H,dH,beta,gamma,Dbeta,Dgamma)

end program exemple

subroutine deriv(H,dH,beta,gamma,Dbeta,Dgamma)

INTEGER::i,j
real::Dbeta,Dgamma
integer,parameter::N=142
real,dimension(N)::beta,gamma
real,dimension(N,N)::H,dH

Dbeta=beta(2)
Dgamma=gamma(3)

open(unit=50,file='deriv')

DO i=1,N-1
DO j=2,N-1

dH(i,j)=0
dH(i,j)=(H(i,j+1)-H(i,j-1))/(2*Dgamma)

enddo
enddo

DO i=1,N-1
DO j=2,N-1

WRITE(50,400)beta(i),gamma(j),H(i,j),dH(i,j)

enddo
enddo

CLOSE(10)
close(30)

400 format(f10.2,f10.2,f10.2,f10.2)
end subroutine deriv
--------------------------------------------------
data file: MP
0.00 0.00
0.05 0.00
0.05 6.00
0.05 12.00
0.05 18.00
0.05 24.00
0.05 30.00
0.05 36.00
0.05 42.00
0.05 48.00
0.05 54.00
0.05 60.00
0.10 0.00
0.10 6.00
0.10 12.00
0.10 18.00
0.10 24.00
0.10 30.00
0.10 36.00
0.10 42.00
0.10 48.00
0.10 54.00
0.10 60.00
0.15 0.00
0.15 6.00
0.15 12.00
0.15 18.00
0.15 24.00
0.15 30.00
0.15 36.00
0.15 42.00
0.15 48.00
0.15 54.00
0.15 60.00
0.20 0.00
0.20 6.00
0.20 12.00
0.20 18.00
0.20 24.00
0.20 30.00
0.20 42.00
0.20 48.00
0.20 54.00
0.20 60.00
0.25 0.00
0.25 6.00
0.25 12.00
0.25 18.00
0.25 24.00
0.25 30.00
0.25 36.00
0.25 42.00
0.25 48.00
0.25 54.00
0.25 60.00
0.30 0.00
0.30 6.00
0.30 12.00
0.30 18.00
0.30 24.00
0.30 30.00
0.30 36.00
0.30 42.00
0.30 48.00
0.30 54.00
0.30 60.00
0.35 0.00
0.35 6.00
0.35 12.00
0.35 18.00
0.35 30.00
0.35 36.00
0.35 42.00
0.35 48.00
0.35 54.00
0.35 60.00
0.40 0.00
0.40 6.00
0.40 12.00
0.40 18.00
0.40 24.00
0.40 30.00
0.40 36.00
0.40 42.00
0.40 48.00
0.40 54.00
0.40 60.00
0.45 0.00
0.45 6.00
0.45 12.00
0.45 18.00
0.45 24.00
0.45 30.00
0.45 36.00
0.45 42.00
0.45 48.00
0.45 54.00
0.45 60.00
0.50 0.00
0.50 6.00
0.50 12.00
0.50 18.00
0.50 24.00
0.50 30.00
0.50 36.00
0.50 42.00
0.50 48.00
0.50 54.00
0.50 60.00
0.55 0.00
0.55 6.00
0.55 12.00
0.55 18.00
0.55 24.00
0.55 30.00
0.55 36.00
0.55 42.00
0.55 48.00
0.55 54.00
0.55 60.00
0.60 0.00
0.60 6.00
0.60 12.00
0.60 18.00
0.60 24.00
0.60 30.00
0.60 36.00
0.60 42.00
0.60 48.00
0.60 54.00
0.60 60.00
0.65 0.00
0.65 6.00
0.65 12.00
0.65 18.00
0.65 24.00
0.65 30.00
0.65 36.00
0.65 42.00
0.65 48.00
0.65 54.00
0.65 60.00

RE: subroutine does not run

What exactly do you mean by it doesn't run? It doesn't compile or it runs giving the wrong results. If the latter, what values are you expecting?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close