I'm not sure that I understand the problem.
You have a DLL, with a subroutine. That subroutine uses modules.
logLik is defined as a parameter to the routine.
I don't see the problem, especially as we have been doing this for several years.
The error message implies that you have a name called mp_amin2 that is not being found, and is unrelated to your use of logLik. Because it talks of an external, that would suggest that somewhere you have a statement of either
CALL mp_amin2(...)
or
... = mp_amin2(...)
There is not enough code to diagnose further.
> Message Received: Apr 26 2006, 01:49 PM
> From: "Colin Millar" <[log in to unmask]>
> To: [log in to unmask]
> Cc:
> Subject: USEing modules in DLL's
>
> Hello All,
>
> I have been attempting to reconstruct F90 code into a DLL for use with
> S-Plus and R.
>
> There are several modules that serve different purposes.
>
> Some simply contain related functions and subroutines.
>
> Some contain parameter values
>
> Some contain type definitions and variable declarations
>
>
> I can build and connect to the DLL when I use the modules that contain
> parameter values, but when I try to use variables that have been declared in
> a module in a subroutine that used that module I have problems when it comes
> to linking.
>
> I get the following message:
>
> Linking...
> Creating library Release/sTSA.lib and object Release/sTSA.exp
> sTSA.obj : error LNK2001: unresolved external symbol _kind_module_mp_amin2
> Release/sTSA.dll : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
>
> The main subroutine is currently: (simplified)
>
> subroutine STSA (..., logLik)
> use kind_module
> !DEC$ ATTRIBUTES DLLEXPORT:: STSA
> !DEC$ ATTRIBUTES ALIAS:'stsa_' :: STSA
>
> ...
> ...
>
> Real(wp), intent(out) :: logLik
>
> ! call set_up_data_structures
>
> amin2 = int(1)
>
> logLik = 999.d0
> return
>
> end subroutine STSA
>
>
> Kind module simply contains
>
> module kind_module
>
> integer, parameter :: wp = kind(1.0d0) ! kind-value for
> double precision
> integer :: amin2
>
> end module kind_module
>
>
>
> Do I have to explicitly export / import every variable that is defined in a
> module? Do I have to define variables in the main subroutine? Any help
> would be appreciated.
>
>
>
> Kind regards,
> Colin.
>
>
|