Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Discussions

Calling Kernel32 routine: OpenFileMapping

toreleraand
Beginner
886 Views
I just ported a fortran project from Compaq Visual Fortran to Intel and need to know the proper calling convention for the (Kernel32) "OpenFileMapping" routine.
My call was like this:
hMapObject = OpenFileMapping (FILE_MAP_READ,.FALSE., MapID)
It would compilewith the Compaq Visual Fortran compiler, when I used the DFWIN module instead of the KERNEL32 module.
I have included the entire Function that won't compile at the end of this message. I'll appreciate any advice for how to properly make this call.
Tore Leraand

FUNCTION GetEntireReadMap(MapID, strCallingProg, hMapObject)

USE KERNEL32, only: OpenFileMapping, MapViewOfFile, FILE_MAP_READ

! Return as handle to Map View of entire FileMapping

! ..also return hMapObject which is the File Mapping Handle

INTEGER*4 GetEntireReadMap, MapView

INTEGER*4 hMapObject

CHARACTER*(*) MapID

CHARACTER*(*) strCallingProg

GetEntireReadMap=0 !Default return unsuccessful...

hMapObject = OpenFileMapping (FILE_MAP_READ,.FALSE., MapID)

if (hMapObject==0) then

write(*,*) strCallingProg // ': OpenFileMapping failed'

else !Try to create a map view...

MapView = MapViewOfFile (hMapObject, FILE_MAP_READ, 0, 0, 0)

if (MapView==0) then

write(*,*) strCallingProg // ': MapViewOfFile failed'

else

GetEntireReadMap=MapView

endif

endif

return

END FUNCTION

0 Kudos
3 Replies
Steven_L_Intel1
Employee
886 Views
Taking a quick look - replace ".FALSE." in the call with "FALSE". ".FALSE." is the Fortran LOGICAL type, which is not the same as the C BOOL type that WIn32 API routines want. CVF ignored some type mismatches with explicit interfaces, sometimes leading to unexpected results. Intel Visual Fortran honors the explicit interface.
0 Kudos
toreleraand
Beginner
886 Views
Steve,
Thanks, ...I can now compile the routine.
I included a "use IFWINTY" statement, and made the call to the OpenFileMapping routine with FALSE as parameter, and it compiled.
Is there no equivalentconstant in Fortran that can be passed in tothe OpenFileMapping routine?
Tore
0 Kudos
Steven_L_Intel1
Employee
886 Views
Um, sure, it's FALSE, as defined in the Win32 API modules. There's also TRUE. Fortran does not have a direct equivalent to the C bool type. Use the constants as defined in the modules. Just add FALSE to your ONLY list, same as you would other constants you get from the module.
0 Kudos
Reply