Access a parameter from an interface (Fortran) -


i using parameter fix precision of used types. works fine until try use same type within interface. consider small example:

module hello     implicit none      save     integer, parameter  :: k = selected_real_kind(10)  contains      subroutine dosomething(fun)         real(k)     :: foo         interface            function fun(bar)                 real(k) :: bar                 real(k) :: fun            end function fun         end interface     end subroutine  end module 

here, foo of desired type, whereas compiler (gfortran) complains 'bar' , 'fun'.

the error is

error: parameter 'k' @ (1) has not been declared or variable,  not reduce constant expression 

is there way working? (for now, writing selected_real_kind(10) everywhere not elegant @ all)

thank you!

the easiest way add import inside interface. of misdesign definitions of module outside scope of interface. plain import import everything.

....     subroutine dosomething(fun)         real(k)     :: foo         interface            function fun(bar)                 import                 real(k) :: bar                 real(k) :: fun            end function fun         end interface     end subroutine .... 

also possible: import :: k


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -