Menu

fderiv subroutine

Anton F.
2010-10-26
2013-06-11
  • Anton F.

    Anton F. - 2010-10-26

    Hi!
    I wanted to use fderiv.f90 for obtaining first and second order derivatives but unfortunatelly can't succeed yet. I've written this extra-simple code to exclude any unexpected factors:

    program der
    real(8) x(100), y(100), f(100), cf(3,100)
    integer i
    do i=1,100
    x(i)=dble(i)
    y(i)=x(i)**2         
    end do
    call fderiv(1,100,x,y,f,cf)
    do i=1,100
    print *, x(i),f(i)
    end do
    end program der
    

    As one can see it calculates two arrays - of an argument and of a function which is simply argument squared so it's clear that the derivative should be twice argument. But instead of this I get some artificial numbers. Is it a bug or I do something wrong? I perform compiling of course with fderiv.f90 and spline.f90 attached.
    Thanks in advance, Anton

     
  • J. K. Dewhurst

    J. K. Dewhurst - 2010-10-26

    Hi Anton!

    You have to declare the array as cf(4,100). Then all is well.

    Cheers,
    Kay.

     
  • Anton F.

    Anton F. - 2010-10-26

    Hi Kay!
    It turned out that the real reason was that I used some old one of spline.f90. I tried to declare cf(4,100) as you suggested but it didn't help. Then I changed spline.f90 to the one from elk 1.1.4 package and it became OK! But your reply motivated me to check this, so thank you!
    Cheers, Anton

     

Log in to post a comment.