Quantcast Accessing Fortran Modules within a Fortran library from Fortran Text - Physics Forums Library

PDA

View Full Version : Accessing Fortran Modules within a Fortran library from Fortran


LLopes
Jul12-08, 04:31 PM
Yes, a lot of FORTRAN, but here goes.
I am very new to creating libraries so give me some credit.
I have a main fortran code which calls a library.

LibraryCode.f90

program LibraryCode
implicit none

character(len=4)::string

string = 'here'
print*, string
call LibraryCall(string)
pause
end program LibraryCode

and in my library i have the subroutine

Library.f90

subroutine LibraryCall(string)
!DEC$ ATTRIBUTES DLLEXPORT::LibraryCall
character(len=4)::string

print*, string
end subroutine LibraryCall

I can compile this just fine, it creates the dll and I can access it from the LibraryCode.f90 just fine. However, I need to wrap this in a module, i.e.

module Library

subroutine LibraryCall(string)
!DEC$ ATTRIBUTES DLLEXPORT::LibraryCall
character(len=4)::string

print*, string
end subroutine LibraryCall

end module Library

When I don't have the module there everything works fine, but when I do, I get unresolved external. I also have several functions and files. Most of them are just function calls. Some of them use the module I would like to add therefore I know it's compiled into the dll, however I cannot access the parameters in the module directly. I have tried using things like

module Library
!DEC$ ATTRIBUTES DLLEXPORT::Library

but the compiler just tells me this is useless and it doesn't find the module's data.


Any help or clarification needed and I would be willing to provide it.