Passing an internal procedure as argument

后端 未结 3 1729
面向向阳花
面向向阳花 2020-12-19 11:02

I want to solve a differential equation lots of times for different parameters. It is more complicated than this, but for the sake of clarity let\'s say the ODE is y\'

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 12:02

    You could put this all in a module, and make a a global module variable. Make faux a module procedure. That way, it has access to a.

    module ode_module
        double precision::a
    
        contains
    
        subroutine f(x,a,ans)
            implicit none
            double precision f,ans,y,tol,c(24),w(9)
    
            call dverk(1,faux,x,y,1.d0,tol,ind,c,1,w)
    
        end subroutine 
    
        subroutine faux(n,xx,yy,yprime)
           implicite none
           integer n
           double precision xx,yy(n),yprime(n)
           yprime(1) = (yy(1)+a)*xx
        end subroutine faux
    
    end module
    

提交回复
热议问题