Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subroutine does not run

Status
Not open for further replies.

wassim2015

Programmer
Jan 3, 2016
10
DZ
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

 
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top