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

enumerate drives

Brooks_Van_Horn
New Contributor I
520 Views

I cannot find any mention of enumerating drives on the forum. I searched msdn and found we need three different functions. 1. findfirstvolume, thn 2. fomdnextvolume and 3. fomdvolume close. Tge problem is that IVF flags them as errors . So if IVF doesn't support them what do I use. I'm trying to find out the available free disk space on various drives. Anyone with an idea or do I resort to trying to put interfaces for these functions and hope the linker can find them in our libs?

 

Brookds Van Horn

0 Kudos
1 Solution
Steven_L_Intel1
Employee
520 Views
interface
    function FindFirstVolume(lpszVolumeName,cchBufferLength)
    import
    !DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"FindFirstVolumeA" :: FindFirstVolume
    integer(HANDLE) :: FindFirstVolume
    character(*), intent(OUT) :: lpszVolumeName
    integer(DWORD), intent(IN) :: cchBufferLength
    !DEC$ ATTRIBUTES VALUE :: cchBufferLength
    end function FindFirstVolume

    function FindNextVolume(hFindVolume,lpszVolumeName,cchBufferLength)
    import
    !DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"FindNextVolumeA" :: FindNextVolume
    integer(BOOL) :: FindNextVolume
    integer(HANDLE), intent(IN) :: hFindVolume
    !DEC$ ATTRIBUTES VALUE :: hFindVolume
    character(*), intent(OUT) :: lpszVolumeName
    !DEC$ ATTRIBUTES REFERENCE :: lpszVolumeName
    integer(DWORD), intent(IN) :: cchBufferLength
    !DEC$ ATTRIBUTES VALUE :: cchBufferLength
    end function FindNextVolume

    function FindVolumeClose(hFindVolume)
    import
    !DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"FindVolumeClose" :: FindVolumeClose
    integer(BOOL) :: FindVolumeClose
    integer(HANDLE), intent(IN) :: hFindVolume
    !DEC$ ATTRIBUTES VALUE :: hFindVolume
    end function FindVolumeClose

end interface

Make sure you have a USE KERNEL32 or USE IFWINTY in the program unit where you include these. These will appear in a future compiler version.

View solution in original post

0 Kudos
10 Replies
Brooks_Van_Horn
New Contributor I
520 Views

Sorry for all the typos. I've had little sleep in the last few days. Age takes its toll.

0 Kudos
Brooks_Van_Horn
New Contributor I
520 Views
            MemAvl = 0
            MemTot = 0
            lnth = 100
            hDsk = FindFirstVolume(myBuffer, lnth)
            do while (hDsk /= NULL)
               uStat = GetDriveType(myBuffer)
               if (uStat == DRIVE_FIXED) Then
                  bret = GetDiskFreeSpaceEx(myBuffer, freeAvl,  freeTot, freeDum)
                  if (bret == TRUE) Then
                     Item = Transfer(freeAvl,Item)
                     MemAvl = MemAvl + Item
                     Item = Transfer(freeTot,Item)
                     memTot = memTot + Item
                     bret = Beep(450, 400)
                  end if
               end if
               bret = FindNextVolume(hDsk, myBuffer, lnth)
               if (bret == 0) Then
                  uStat = GetLastError()
                  if (uStat == RROR_NO_MORE_FILES) Then
                     bret = FindVolumeClose( hDsk )
                     hDsk = NULL
                  End if
               End if
            end do

Here is the code snippet that I'm trying to write. This is x64 code byw.

Brooks

0 Kudos
Steven_L_Intel1
Employee
521 Views
interface
    function FindFirstVolume(lpszVolumeName,cchBufferLength)
    import
    !DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"FindFirstVolumeA" :: FindFirstVolume
    integer(HANDLE) :: FindFirstVolume
    character(*), intent(OUT) :: lpszVolumeName
    integer(DWORD), intent(IN) :: cchBufferLength
    !DEC$ ATTRIBUTES VALUE :: cchBufferLength
    end function FindFirstVolume

    function FindNextVolume(hFindVolume,lpszVolumeName,cchBufferLength)
    import
    !DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"FindNextVolumeA" :: FindNextVolume
    integer(BOOL) :: FindNextVolume
    integer(HANDLE), intent(IN) :: hFindVolume
    !DEC$ ATTRIBUTES VALUE :: hFindVolume
    character(*), intent(OUT) :: lpszVolumeName
    !DEC$ ATTRIBUTES REFERENCE :: lpszVolumeName
    integer(DWORD), intent(IN) :: cchBufferLength
    !DEC$ ATTRIBUTES VALUE :: cchBufferLength
    end function FindNextVolume

    function FindVolumeClose(hFindVolume)
    import
    !DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"FindVolumeClose" :: FindVolumeClose
    integer(BOOL) :: FindVolumeClose
    integer(HANDLE), intent(IN) :: hFindVolume
    !DEC$ ATTRIBUTES VALUE :: hFindVolume
    end function FindVolumeClose

end interface

Make sure you have a USE KERNEL32 or USE IFWINTY in the program unit where you include these. These will appear in a future compiler version.

0 Kudos
Brooks_Van_Horn
New Contributor I
520 Views

Perfect Steve!! It worked the first try.

How did you happen to have the interfaces and when do you think it will be in future versions?

Brooks

PS, the GlobalMemoryStatusEX is not totally working. The two fields on virtual memory are about 10 times too big for my system.

0 Kudos
Steven_L_Intel1
Employee
520 Views

I have been working on updating the interfaces and I had already done these. I am going to try to get them in for the "2017" release later this year, but haven't yet asked (as I am still working on them - just going through kernel32 is a lot of work - I have barely touched the other libraries.

Are you using the MemoryStatus sample we provide? Seems to work ok for me:

45% of memory is in use
15.99GB total physical memory
8.71GB available physical memory
31.98GB total pageable memory
24.15GB available pageable memory
8192.00GB total virtual memory
8191.99GB available virtual memory

This is built as 64-bit. For 32-bit:

45% of memory is in use
15.99GB total physical memory
8.73GB available physical memory
31.98GB total pageable memory
24.15GB available pageable memory
2.00GB total virtual memory
1.98GB available virtual memory

 

0 Kudos
Steven_L_Intel1
Employee
520 Views

See also https://software.intel.com/en-us/articles/memory-limits-applications-windows

0 Kudos
Brooks_Van_Horn
New Contributor I
520 Views

Steve,

In your first example how can you have basically 48GB of RAM and pagefile space and jump to 8 TB of virtual memory?

Brooks

0 Kudos
Steven_L_Intel1
Employee
520 Views

8TB of virtual memory is what everyone on Windows x64 gets. That's the total address space, from lowest address to highest address. I can't allocate that much, though.  That's not the amount of virtual memory you can allocate. To be honest, this routine doesn't really tell you much other than physical memory load. You might infer that I could allocate maybe 8GB more before other processes started to show an impact.

What exactly are you trying to do? Predicting the behavior of virtual memory management is usually a losing proposition.

0 Kudos
Brooks_Van_Horn
New Contributor I
520 Views

I have 32GB RAM, 2 TB of HD and my VM was showing 128TB. New kind of physics at work here. Maybe quantum entanglement. Seriously, I'm running Win 10 x64 Enterprise. I have Intel i7-4770 running at 3.4GHz. I have the 2013 version MSVS and the 2916 version of IVF Parelel Studio XE Composer Edition and my program is running under X64 mode in VS graphics. Sorry for jumping arround here. Just trying to get in all my system data. An Intel program gave me the following info:

Intel(R) Processor Identification Utility
Version: 5.30.20150729
Time Stamp: 2015/10/10 00:57:04
Operating System: 6.2-9200-
Number of processors in system: 1
Current processor: #1
Active cores per processor: 4
Disabled cores per processor: 0
Processor Name: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Type: 0
Family: 6
Model: 3C
Stepping: 3
Revision: 1C
Maximum CPUID Level: D
L1 Instruction Cache: 4 x 32 KB
L1 Data Cache: 4 x 32 KB
L2 Cache: 4 x 256 KB
L3 Cache: 8 MB
Packaging: LGA1150
Enhanced Intel SpeedStep(R) Technology: Yes
MMX(TM): Yes
Intel(R) SSE: Yes
Intel(R) SSE2: Yes
Intel(R) SSE3: Yes
Intel(R) SSE4: Yes
Intel(R) AES-NI: Yes
Intel(R) AVX: Yes
Enhanced Halt State: No
Execute Disable Bit: Yes
Intel(R) Hyper-Threading Technology: Yes
Intel(R) 64 Architecture: Yes
Intel(R) Virtualization Technology: Yes
Intel(R) VT-x with Extended Page Tables: Yes
System Graphics: Add-in Graphics
Base TDP: 84
Expected Processor Frequency: 3.40 GHz
Reported Processor Frequency: 3.89 GHz
Expected System Bus Frequency: 100 MHz
Reported System Bus Frequency: 100 MHz

 

0 Kudos
Steven_L_Intel1
Employee
520 Views

Ah, Windows 10 Enterprise may have a larger address space. The processor features are really not all that interesting to a running program, though you do have many of the modern features (not AVX2, however.)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx#memory_limits says that Windows 8.1 and Windows Server 2012 R2 have a 128TB virtual address space. Odd that it doesn't mention Win10 here (but does under Physical Memory.)

0 Kudos
Reply