0

IMSL ライブラリに含まれているサブルーチン ( neqnf) を使用する必要があります。これにより、非線形システムを解くことができます。(ユーザーマニュアルへのリンク、ここの neqnf ページ) main.f90は、次のとおりです。

program prova_sistema_in_un_modulo

    include "link_fnl_shared.h"
    use neqnf_int
    use modx

    implicit none

    call d_neqnf(FCN, x, xguess=x_guess, fnorm=f_norm)

end program prova_sistema_in_un_modulo

ここで、サブルーチン FCN は外部モジュールでコーディングされていますmodx.f90

module modx

implicit none

integer, parameter :: ikind = selected_real_kind(8,99)
integer :: n=3
real(kind=ikind) :: f_norm
real(kind=ikind), dimension(3) :: x, x_guess=(/ 4.0, 4.0, 4.0/)

contains

subroutine FCN(x,f,n)
    integer :: n                                  !dummy var
    real(kind=ikind), dimension(3) :: x, f        !dummy var

    f(1)=x(1)+A(x(1))+(x(2)+x(3))*(x(2)+x(3))-27.0            ! =0
    f(2)=B(x(1),x(2))+x(3)*x(3)-10.0                          ! =0
    f(3)=Z(x(2),x(3))                                         ! =0

end subroutine FCN

function A(x)
    real(kind=ikind) :: x    !dummy var
    real(kind=ikind) :: A    !function var

    A=exp(x-1.0)

end function A

function B(x,y)
    real(kind=ikind) :: x,y  !dummy var
    real(kind=ikind) :: B    !function var

    B=exp(y-2.0)/x

end function B

function C(x)
    real(kind=ikind) :: x    !dummy var
    real(kind=ikind) :: C    !function var

    C=sin(x-2.0)

end function C

function Z(x,y)
    real(kind=ikind) :: x,y  !dummy var
    real(kind=ikind) :: Z    !function var

    Z=y+C(x)+x*x-7.0

end function Z
end module modx

しかし、次の 3 つのエラーが発生します。

Error   1    error #7061: The characteristics of dummy argument 1 of the associated actual procedure differ from the characteristics of dummy argument 1 of the dummy procedure. (12.2)   [FCN]
Error   2    error #7062: The characteristics of dummy argument 2 of the associated actual procedure differ from the characteristics of dummy argument 2 of the dummy procedure. (12.2)   [FCN]
Error   3    error #7063: The characteristics of dummy argument 3 of the associated actual procedure differ from the characteristics of dummy argument 3 of the dummy procedure. (12.2)   [FCN]

注意: すべてのコードをメイン プログラムに入れると、すべてうまくいきます。モジュールを使用してコーディングすると(私が行ったように、実際に投稿されたコード)、そのエラーが発生します!誰でも私を助けることができますか?

4

1 に答える 1