- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have several modules in a DLL project. Functions/subroutines in one module call those in the other modules. To make it all work together, as well as with calls from VB, i added the following statement to each function/sub that calls a function/sub in a different module:
!dec$ attributes stdcall, alias :'PSAT_F' :: psat_FNC
In the actual function/sub, i set the attributes as:
!dec$ attributes dllexport :: psat_fnc
!dec$ attributes stdcall, REFERENCE, alias :'PSAT_F' :: psat_FNC
This seems to work fine. To make it easier to keep track of all the references, i put all the attribute statements from each module in an include file. I then just need to 'include' the file in a module that is calling routines from a different module, i.e., include 'DEC_PSAT.for'
This was all going well. But now i receive the warning:
Warning 2 warning #7341: Non-global variable with DEC$ ATTRIBUTES STDCALL makes no sense. [PSAT_FNC] D:\\ST\\Active Jobs\\SCA08-005 Turbocharger DLL development\\Software and Templates\\TuMS Correction Validation Modules\\Source Props\\GasProps\\DEC_PROPS_WATER.for 1
This shows up twice with two different warning numbers. The other number is 7337. It does not show up for everything, only a few of them.
DOes anyone know what causes these warnings?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you say "several modules in a DLL project", do you mean modules in a fortran sense? I don't see any MODULE or USE statements in your snippet.
Consider:
[fortran]! In ConversionFunctions.f90 (or .for for fixed form) MODULE ConversionFunctions IMPLICIT NONE CONTAINS real(8) function PSIToPa_fnc(Arg) !dec$ attributes dllexport :: PSIToPa_fnc !dec$ attributes stdcall, REFERENCE, alias :'PSITOPA_F' :: PSIToPa_fnc real(8), INTENT(IN) :: Arg PSIToPa_fnc = Arg * 6894.76 END FUNCTION PSIToPa_fnc real(8) function KtoF_fnc(Arg) !dec$ attributes dllexport :: KtoF_fnc !dec$ attributes stdcall, REFERENCE, alias :'KTOF_F' :: KtoF_fnc real(8), INTENT(IN) :: Arg ! Note: do not declare the types of functions that are available ! through host association (procedures in the same module). KtoF_fnc = RtoF_fnc(KtoR_fnc(Arg)) END FUNCTION KtoF_fnc REAL(8) FUNCTION RtoF_fnc(arg) !... END FUNCTION RtoF_fnc REAL(8) FUNCTION KtoR_fnc(arg) !... END FUNCTION KtoR_fnc END MODULE ConversionFunctions ! In 'Properties Water.f90/.for' ! TODO: Put this in a module too! real(8) function psat_fnc(T) !dec$ attributes dllexport :: psat_fnc !dec$ attributes stdcall, REFERENCE, alias :'PSAT_F' :: psat_FNC USE ConversionFunctions ! Makes PSIToPa_fnc and friends available. implicit none ! Note: do not declare the types of functions that are available ! through USE association - the compiler already knows. real(8) T, some_variable, blah_blah !... some_variable = PSIToPA_fnc(blah_blah) !... END FUNCTION psat_fnc [/fortran]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your module routines have the ATTRIBUTES STDCALL, DLLEXPORT, etc. in them, there is no need to also include that line where the module is used. The USEing routine will automatically pick up the attributes.
I have not completely followed all that you wrote - paraphrases of code are less illuminating than the actual code - but it sounds as if the compiler does not see a reference to PSAT_FNC as a procedure and hence thinks you're declaring a variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, here is the code that is causing me issues. It is located in a file called 'Properties Water.for'
real(8) function psat_fnc(T)
!dec$ attributes dllexport :: psat_fnc
!dec$ attributes stdcall, REFERENCE, alias :'PSAT_F' :: psat_FNC
!dec$ attributes stdcall, alias :'PSITOPA_F' :: PSIToPa_fnc
!dec$ attributes stdcall, alias :'KTOF_F' :: KtoF_fnc
C include 'DEC_CONVERSIONS.for'
implicit none
include 'Common_Gases.for'
real (8) T, PSATT,KtoF_fnc,PSITOPA_FNC
psat_fnc = 10.0 !PSATT(KtoF_fnc(T))
! psat_fnc = PsiToPa_fnc(psat_fnc)
return
end
THe functions for KtoF_fnc and PsiToPa_fnc are in the file 'conversionfunctions.for'
real(8) function PSIToPa_fnc(Arg)
C Arg Length (m)
C MToFt_fnc Returned length (ft)
!dec$ attributes dllexport :: PSIToPa_fnc
!dec$ attributes stdcall, REFERENCE, alias :'PSITOPA_F' :: PSIToPa_fnc
implicit none
real(8) Arg
PSIToPa_fnc = Arg * 6894.76
return
end
real(8) function KtoF_fnc(Arg)
C Arg Temperature (F)
C RtoR_fnc Returned temperature (K)
!dec$ attributes dllexport :: KtoF_fnc
!dec$ attributes stdcall, REFERENCE, alias :'KTOF_F' :: KtoF_fnc
implicit none
real(8) Arg, KtoR_fnc,RtoF_fnc
KtoF_fnc = RtoF_fnc(KtoR_fnc(Arg))
return
end
Now, in the pasted code i commented out the lines in psat_fnc that call these functions. This is when i receive the error:
Warning 1 warning #7337: Non-global variable with DEC$ ATTRIBUTES ALIAS makes no sense. [PSITOPA_FNC] D:\ST\Active Jobs\SCA08-005 Turbocharger DLL development\Software and Templates\TuMS Correction Validation Modules\Source Props\GasProps\Properties Water.for 4
I do not receive the same type of warning for the KToF_fnc statement and it, too, is commented out.Goofup on this particular line -- It does cause the same error, so i think i understand that if you declare something like this, it has to be used in the function. Is that correct?
Is there an easier way to force routines in one file to recognize those in another? All my problems started when i added the line:
!dec$ attributes stdcall, REFERENCE, alias :'PSITOPA_F' :: PSIToPa_fnc
After that, the functions in other files, but files that are still part of the same project, are no longer recognized.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you say "several modules in a DLL project", do you mean modules in a fortran sense? I don't see any MODULE or USE statements in your snippet.
Consider:
[fortran]! In ConversionFunctions.f90 (or .for for fixed form) MODULE ConversionFunctions IMPLICIT NONE CONTAINS real(8) function PSIToPa_fnc(Arg) !dec$ attributes dllexport :: PSIToPa_fnc !dec$ attributes stdcall, REFERENCE, alias :'PSITOPA_F' :: PSIToPa_fnc real(8), INTENT(IN) :: Arg PSIToPa_fnc = Arg * 6894.76 END FUNCTION PSIToPa_fnc real(8) function KtoF_fnc(Arg) !dec$ attributes dllexport :: KtoF_fnc !dec$ attributes stdcall, REFERENCE, alias :'KTOF_F' :: KtoF_fnc real(8), INTENT(IN) :: Arg ! Note: do not declare the types of functions that are available ! through host association (procedures in the same module). KtoF_fnc = RtoF_fnc(KtoR_fnc(Arg)) END FUNCTION KtoF_fnc REAL(8) FUNCTION RtoF_fnc(arg) !... END FUNCTION RtoF_fnc REAL(8) FUNCTION KtoR_fnc(arg) !... END FUNCTION KtoR_fnc END MODULE ConversionFunctions ! In 'Properties Water.f90/.for' ! TODO: Put this in a module too! real(8) function psat_fnc(T) !dec$ attributes dllexport :: psat_fnc !dec$ attributes stdcall, REFERENCE, alias :'PSAT_F' :: psat_FNC USE ConversionFunctions ! Makes PSIToPa_fnc and friends available. implicit none ! Note: do not declare the types of functions that are available ! through USE association - the compiler already knows. real(8) T, some_variable, blah_blah !... some_variable = PSIToPA_fnc(blah_blah) !... END FUNCTION psat_fnc [/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm sorry. When I use the word Module, I mean separate files. I was not using MODULE in the fortran sense, but will give that a try. IN fact, that sounds exactly like what i am trying to accomplish! Thanks much -- will not be able to try this until later, but will let you know.
One quick question -- does this make them available throughout other .for files that are part of the project? I assume it does.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page