I have a problem with the following code, which calls a routine named "SALTCHEM" located in a dll (saltchem.dll):
pointer(pp,ii) pointer(qq,rtn_saltchem) pp = loadlibrary("saltchem.dll"C) ! load the dll into memory qq = getprocaddress(pp, "SALTCHEM"C) ! set up a pointer to the routine "SALTCHEM" located in the dll call rtn_saltchem(...) ! call the routine "SALTCHEM"
This procedure works when all these statements are in the main program.
However, what I really want to do, is to call this routine "SALTCHEM" from another subroutine X,
i.e. not from the main program where I loaded the dll.
So, I'm setting up the pointers pp and qq in the main program, as above,
then I'm bringing them over to subroutine X which now contains the call to "SALTCHEM" (call rtn_saltchem(...)).
This seems to work when I bring over the pointers pp and qq from the main program to subroutine X
through a COMMON block, but it doesn't work when I bring them over through a module.
In the latter case, I get the following compiler error:
Error: This scalar name is invalid in this context. [RTN_SALTCHEM]
Why does it work with a COMMON block but not with a MODULE? Any suggestions?