wassim2015
Programmer
Hi, i try to write a program in fortran 90/95 to calculate derivatives from data
But my program does not run. Help me please and thank u in advance
But my program does not run. Help me please and thank u in advance
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
program exemple
implicit none
INTEGER::I
integer,parameter::N=3
real,dimension(N)::beta,gamma,H,dH
OPEN(unit=10,file='MP')
open(unit=30,file='resultats')
open(unit=40,file='deriv')
WRITE(30,200)'beta','gamma','H','dH'
DO I=1,N
READ(10,*)beta(I),gamma(I)
H(I)=0
H(I)=H(I)+(beta(I)*sin(gamma(I)))
WRITE(30,300)beta(I),gamma(I),H(I)
write(*,*) beta(I),gamma(I),H(I)
enddo
DO I=1,N
dH(I)=0
dH(I)=(H(I+1)-H(I-1))/(beta(I+1)-beta(I-1))
enddo
do I=1,N
WRITE(40,400)beta(I),gamma(I),H(I),dH(I)
enddo
CLOSE(10)
close(30)
close(40)
200 format(a10, a10, a10, a10)
300 format(f10.2,f10.2,f10.2)
400 format(f10.2,f10.2,f10.2,f10.2)
end program exemple
write(*,*) beta(I),gamma(I),H(I)
integer,parameter::N=3
integer,parameter::N=144
Then you must have done something wrong.wassim2015 said:I tried with 3 exemples of data file MP and i have no results in Deriv file???
0.1 0.5
0.2 1
0.3 1.5
mikrom@mikrom-Lenovo-S500 ~/Downloads $ gfortran Text1.f90 -o Text1
mikrom@mikrom-Lenovo-S500 ~/Downloads $ ./Text1
beta gamma H dH
0.10 0.50 0.05
0.20 1.00 0.17
0.30 1.50 0.30
0.10 0.50 0.05 0.84
0.20 1.00 0.17 1.26
0.30 1.50 0.30 0.84
program exemple
implicit none
INTEGER::I
integer,parameter::N=3
real,dimension(N)::beta,gamma,H,dH
OPEN(unit=10,file='MP')
open(unit=30,file='resultats')
open(unit=40,file='deriv')
WRITE(30,200)'beta','gamma','H','dH'
DO I=1,N
READ(10,*)beta(I),gamma(I)
H(I)=0
H(I)=H(I)+(beta(I)*sin(gamma(I)))
WRITE(30,300)beta(I),gamma(I),H(I)
enddo
DO I=1,N
dH(I)=0
dH(I)=(H(I+1)-H(I-1))/(beta(I+1)-beta(I-1))
enddo
do I=1,N
WRITE(40,400)beta(I),gamma(I),H(I),dH(I)
enddo
CLOSE(10)
close(30)
close(40)
200 format(a10, a10, a10, a10)
300 format(f10.2,f10.2,f10.2)
400 format(f10.2,f10.2,f10.2,f10.2)
end program exemple
And how many lines of input you have ? Maybe it could be an array size problem.wassim2015 said:But that does not run with N>100, this is the problem
Pd110 HTDA-CRANKING M.IMADALOU COR SEP.2014"""""""
110,46
0.00 0.00 -929.18598 71.62987 0.00000 72.69126 0.17632 0.17632 0.00000
0.05 0.00 -929.61269 75.93454 0.00000 75.95358 0.72401 0.72401 0.00000
...
...
...
open(unit=10,file='MP.txt')
...
! header
read(10,*)
read(10,*)
do I=1,N
...
enddo