- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Recently found how to get WinXP IVF 9.1 task manager memory information using the api GetProcessMemoryInfo. Used the Microsoft C code example and linked to my f90 code as a library. The desired piece of information is the peak process memory usage.
Question: Is there an IVF 9.1 module which would allow one to write this api call in Fortran directly? The C header was #include "psapi.h".
Need a f90 interface for GetProcessMemoryInfo and for the data type PROCESS_MEMORY_COUNTERS.
Any such thing? Thanks
Question: Is there an IVF 9.1 module which would allow one to write this api call in Fortran directly? The C header was #include "psapi.h".
Need a f90 interface for GetProcessMemoryInfo and for the data type PROCESS_MEMORY_COUNTERS.
Any such thing? Thanks
Link Copied
12 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm putting together a PSAPI module. Stay tuned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sounds very good. Any idea when?
How does one know what WinXP api's are in the various Fortran include modules? The documentation almost seems to say one must just look inside the various *.f90 files once a desired api is identified. Trouble is, there are more *.f90 include files than one can practially look in.
Thanks.
How does one know what WinXP api's are in the various Fortran include modules? The documentation almost seems to say one must just look inside the various *.f90 files once a desired api is identified. Trouble is, there are more *.f90 include files than one can practially look in.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well. I would have been able to post it today, but I had a brain cramp and managed to wipe out hours of work without chance of recovery (overwrote the file). Sigh. I'll start over and should have at least that interface done tomorrow.
All you really need to do is look in the Microsoft documentation for the API you want and look to see which .lib it is in. That's the name of the module to use. kernel32.lib = USE KERNEL32, etc.
All you really need to do is look in the Microsoft documentation for the API you want and look to see which .lib it is in. That's the name of the module to use. kernel32.lib = USE KERNEL32, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re; searching for interface blocks for windows API functions: I use CVF in MS DevStudio and under the EDIT menu is a 'Find in files' option which lets you browse to a folder and enter a string to be searched for. I have used this many times to locate an interface block or TYPE definition in the various modules in the INCLUDE folder. It's no problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, attached is a ZIP with a partial PSAPI module, including definitions needed for using GetProcessMemoryInfo, and a Fortran port of the MSDN example for this API. Let me know what you think.
I'll work on filling in the module when I get time (and will try to get it added to the product in the future.)
I'll work on filling in the module when I get time (and will try to get it added to the product in the future.)
PSAPI.zip
(Virus scan in progress ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's a complete PSAPI module and a test program that demonstrates a couple of the interfaces, including the one you wanted. Let me know what you think.
PSAPI.zip
(Virus scan in progress ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Boris Becker may have said, losing to Stefan Edberg at Wimbledon:
"Great service, Steve".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, What a pleasant surprise when I got back from my civic club lunch. Promply installed, set up for my configuration, and best of all, was able to get rid of the C code implemention!
This morning I see you now have the whole package to try.
From what I saw, it looks like the protcol is to have a module to define data structures and a second to define the interfaces with the $DEC's to link directly to the C libraries. Is that about it?
Also liked learning about using !DEC$ OBJCOMMENT lib:"xxx.lib" . Now I don't have to always be specifing libraries on the resource tab in Visual Studio.
Again, Thanks.
This morning I see you now have the whole package to try.
From what I saw, it looks like the protcol is to have a module to define data structures and a second to define the interfaces with the $DEC's to link directly to the C libraries. Is that about it?
Also liked learning about using !DEC$ OBJCOMMENT lib:"xxx.lib" . Now I don't have to always be specifing libraries on the resource tab in Visual Studio.
Again, Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the product, all of the datatype and constant definitions are in module IFWINTY, which is then USEd in the API modules and within the interfaces (In F95, this is how you have to do it.) Look at the existing API modules such as kernel32.f90 to see more examples. Since the PSAPI types aren't yet in IFWINTY, I created a new module for them.
In Fortran 2003, there's a new IMPORT statement that can be used in interface blocks that says to make any symbols in the host scope visible in the interface. (You can also select which symbols to import.) With that, one can do away with the separate module and put all the definitions in the one (PSAPI), so instead of USE IFWINTY (or USE PSAPI_TYPES) in each interface, you just have USE IFWINTY in module PSAPI and then an IMPORT in each interface and either put the types and constants in PSAPI or move them to IFWINTY. I'm not sure which we'd choose in the future. IMPORT will be coming next month to an Intel compiler near you (not this week's release.)
In Fortran 2003, there's a new IMPORT statement that can be used in interface blocks that says to make any symbols in the host scope visible in the interface. (You can also select which symbols to import.) With that, one can do away with the separate module and put all the definitions in the one (PSAPI), so instead of USE IFWINTY (or USE PSAPI_TYPES) in each interface, you just have USE IFWINTY in module PSAPI and then an IMPORT in each interface and either put the types and constants in PSAPI or move them to IFWINTY. I'm not sure which we'd choose in the future. IMPORT will be coming next month to an Intel compiler near you (not this week's release.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry I am aware this is a very old thread. I am trying to find out how to use the API structure "PROCESS_MEMORY_COUNTERS_EX" (the extended version of PROCESS_MEMORY_COUNTERS, as documented here:
But when I searched through psapi.f90, I can only find the type definition, no function that actually accepted the _EX version. I am not very familiar with calling Win API, and what I am essentially trying to do is to find out the Private Bytes of the executing process.
Thanks in advance!
Regards,
Angus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for pointing out this omission. I have attached a revised version of psapi.f90 that takes care of it - just add this to your project. The key is to define a generic interface for GetProcessMemoryInfo with two specific procedures, one that takes the EX structure and one that takes the non-EX structure.
I will have this added to a future release of the compiler.
I will have this added to a future release of the compiler.
psapi.f90
(Virus scan in progress ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Awesome!
Thank you very much for the ultra fast response. It works. :-)
Regards,
Angus

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