visual studio 2010 - Error with argument and procedure -


i have use subroutine (neqnf) included in imsl library, let me solve non-linear systems. (link users manual, neqnf page here) main.f90, is:

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 

where subroutine fcn coded in external module, 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) ::    !function var      a=exp(x-1.0)  end function  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 

but these 3 errors:

error   1    error #7061: characteristics of dummy argument 1 of associated actual procedure differ characteristics of dummy argument 1 of dummy procedure. (12.2)   [fcn] error   2    error #7062: characteristics of dummy argument 2 of associated actual procedure differ characteristics of dummy argument 2 of dummy procedure. (12.2)   [fcn] error   3    error #7063: characteristics of dummy argument 3 of associated actual procedure differ characteristics of dummy argument 3 of dummy procedure. (12.2)   [fcn] 

nb: if put code in main program, goes fine! while if code using module (as i've done, posted code) errors! can me?

the problem provide fixed dimension dummy arguments x(3) , f(3) in custom function fcn, while imsl expects variable dimension x(n), f(n):

subroutine fcn(x,f,n)     integer :: n                                  !dummy var !    real(kind=ikind), dimension(3) :: x, f       !<- wrong     real(kind=ikind), dimension(n) :: x, f        !<- correct      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 

a working example reproduce (interface borrowed hybrd1):

module test_int contains   subroutine final(fcn, x, f, n)     interface       subroutine fcn (x, f, n)         integer             n         double precision    x(n), f(n)       end subroutine     end interface     integer          :: n     double precision :: x(n), f(n)     call fcn(x,f,n)   end subroutine end module  module test_fct contains   subroutine fcn(x, f, n)      integer          :: n     double precision :: x(n), f(n)     print *,x ; print *,f ; print *,n   end subroutine end module  program prova   use, intrinsic :: iso_fortran_env   use test_int   use test_fct   implicit none   integer,parameter :: n=2   double precision  :: x(n), f(n)   x = [ 1.d0, 2.d0 ]   f = [ 3.d0, 4.d0 ]   call final(fcn, x, f, n) end program prova 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -