Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

error #6351 , any ideas how to run the code properly ?

Adrian2020
Beginner
589 Views


program Derivare_numerica

implicit none

real*8,parameter:: x0=1.d0,pas=1.d-1
! scrierea in dubla precizie este cu d in fata // h-pas // d-1=10^-1
real*8::x(-2:2),y(-2,2)
real*8::DIDS1, DIDD1,DIDC2,DIDC4,DIIDC4,DIIDS1,DIIDC2,DIIDD1
real*8::error,f
! toate formulele sunt puse in real
integer:: i

do i=-2,2
x(i)=x0+i*pas
y(i)=f(x(i))
end do

!calculul derivatei de ordin 1

DIDS1=(y(0)-y(-1))/pas
DIDD1=(y(1)-y(0))/pas/2.d0
DIDC2=(y(1)-y(-1))/pas-2.d0
DIDC4=(y(-2)-8.d0*y(-1)+8.d0*y(-1)-y(2))/pas/12.d0

!calcul derivata de ordin 2

DIIDC4=(-y(-2)+16.d0*y(-1)-30.d0*y(0)+16.d0*y(1)-y(2))/pas/12.d0/pas
DIIDS1=(y(0)-2.d0*y(-1)+y(-2))/pas
DIIDC2=(y(1)-2.d0*y(0)+y(-1))/pas/2.d0
DIIDD1=(y(0)-2.d0*y(1)+y(2))/pas
!vezi slide 42


! afisarea variabieloer pe consola si tabel
Write(*,*)'Derivata 1 cu diferente la stanga de ordin 1 =', DIDS1
Write(*,*)'Derivata 1 cu diferenta la dreapta de ordin 1 =', DIDD1
Write(*,*)'Derivata 1 cu diferente centru de oridn 2 =', DIDC2
Write(*,*)'Derivata 1 cu diferente centru de ordin 4 =', DIDC4
Write(*,*)'Derivata 2 cu diferente la stanga de ordin 1 =', DIIDS1
Write(*,*)'Derivata 2 cu diferente la dreapta de ordinul 1 =', DIIDD1
Write(*,*)'Derivata 2 cu diferente centru de ordinul 2 =', DIIDC2
Write(*,*)'Derivata 2 cu diferente centru 4 =', DIIDC4


! sa pui mereu chestia asta aici
print *, 'Hello World'
read(*,*)

end program Derivare_numerica

!dexp=scrierea exponentului

function f(x)
implicit none
real*8::x,f
f=(x-1)*dexp(x) ! exponentul se scrie cu exp ^^^^
end function f


function error(x,xaprox)
implicit none
real*8::x,xaprox,error
if (x/=0.d0)then
error=dabs((x-xaprox)/x)*1.d2

else ! impartirea cu 0 se calc eraore abs
error=dabs(x-xaprox)
endif

end function error

0 Kudos
1 Solution
mecej4
Honored Contributor III
578 Views

Did you mean to write 

     real*8 :: x(-2:2), y(-2:2)

rather than 

    real*8 :: x(-2:2), y(-2,2) ?

View solution in original post

2 Replies
mecej4
Honored Contributor III
579 Views

Did you mean to write 

     real*8 :: x(-2:2), y(-2:2)

rather than 

    real*8 :: x(-2:2), y(-2,2) ?

Adrian2020
Beginner
575 Views

yeah , you are right , i was looking at DID## and not that .. youu were right

real*8 :: x(-2:2), y(-2,2)

Now it works . Thanks

0 Kudos
Reply