<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Disk Full handling in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785320#M29787</link>
    <description>You can get feedback on bytes actually written, but you will have to use the WinAPI functions directly:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]IF (.NOT.WriteFile(ihandl,			&amp;amp;  ! file handle
				  loc_pointer,		&amp;amp;  ! address of data
				  nbytes,			&amp;amp;  ! byte count to write
				  LOC(nact),		&amp;amp;  ! actual bytes written
				  NULL_OVERLAPPED))	THEN
  	! deal with write error
END IF&lt;BR /&gt;&lt;BR /&gt;IF (nact .LT. nbytes) THEN&lt;BR /&gt;     ! disk might be full&lt;BR /&gt;END IF&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[/bash]&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Jul 2011 19:27:55 GMT</pubDate>
    <dc:creator>Paul_Curtis</dc:creator>
    <dc:date>2011-07-22T19:27:55Z</dc:date>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785316#M29783</link>
      <description>I thought, that is simple, however I do not get any error message writing a file to a full USB-Stick.&lt;BR /&gt;The disk is completely full and no Error appears. Files are then generated but 0Bytes large.&lt;BR /&gt;&lt;BR /&gt;here the simple code:&lt;BR /&gt;&lt;BR /&gt;OPEN(UNIT=file_id, FILE=filename, status='REPLACE',form='binary', iostat=iErr)&lt;BR /&gt;write(file_id, iostat=iErr, err= 20) Large_Data&lt;BR /&gt;if (.NOT. COMMITQQ(file_id)) then ! Flushing a file to disk &lt;BR /&gt; iErr = ERR_FILE_IO_ACCESS ! maybe disk is full&lt;BR /&gt;endif&lt;BR /&gt;close (file_id)&lt;BR /&gt;&lt;BR /&gt;no Error appears. Did I something wrong ? I just want to get a warning, when not all data could be written</description>
      <pubDate>Fri, 22 Jul 2011 06:24:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785316#M29783</guid>
      <dc:creator>jaeger0</dc:creator>
      <dc:date>2011-07-22T06:24:17Z</dc:date>
    </item>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785317#M29784</link>
      <description>The OPEN statement will always succeed for an existing file. Any WRITE error directs your code to line 20, not shown, so the code immediately following the WRITE would not be visited.&lt;BR /&gt;&lt;BR /&gt;You might consider finding the available space on the disk before opening the file, using the WinAPI function &lt;B&gt;GetDiskFreeSpaceEx&lt;/B&gt;. IVF provides a declaration in kernel32.f90:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]FUNCTION GetDiskFreeSpaceEx( &amp;amp;
        lpDirectoryName, &amp;amp;
        lpFreeBytesAvailableToCaller, &amp;amp;
        lpTotalNumberOfBytes, &amp;amp;
        lpTotalNumberOfFreeBytes)
import
  integer(BOOL) :: GetDiskFreeSpaceEx ! BOOL
    !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'GetDiskFreeSpaceExA' :: GetDiskFreeSpaceEx
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpDirectoryName
  character*(*) lpDirectoryName ! LPCSTR lpDirectoryName
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpFreeBytesAvailableToCaller
  TYPE(T_LARGE_INTEGER)  lpFreeBytesAvailableToCaller
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpTotalNumberOfBytes
  TYPE(T_LARGE_INTEGER)  lpTotalNumberOfBytes 
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpTotalNumberOfFreeBytes
  TYPE(T_LARGE_INTEGER) lpTotalNumberOfFreeBytes
 END FUNCTION[/bash]&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2011 10:23:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785317#M29784</guid>
      <dc:creator>Paul_Curtis</dc:creator>
      <dc:date>2011-07-22T10:23:31Z</dc:date>
    </item>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785318#M29785</link>
      <description>Paul's advice is right-on, but also note that in a multitasking OS other processes can consume and free up disk space during the course of running the program in question. If, for example, the USB drive is used by "ReadyBoost" or contains the TMP/TEMP directories, the amount of free space could change in a way that is impossible to predict.</description>
      <pubDate>Fri, 22 Jul 2011 10:35:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785318#M29785</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-07-22T10:35:14Z</dc:date>
    </item>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785319#M29786</link>
      <description>here the completer code: I never get an error, the line 20 is never passed. Of course one could check available disk space, however I do not have any guess, how large my files will become. If write does not provide an error, is there a possibility to proof for example if data_array have completely written, or to proof, how many bytes where written ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;OPEN(UNIT=file_id, FILE=filename, status='REPLACE',form='binary', iostat=iErr)&lt;BR /&gt;write(file_id, iostat=iErr, err= 20) data_array&lt;BR /&gt;close (file_id)&lt;BR /&gt;goto 10&lt;BR /&gt; &lt;BR /&gt;20 iErr = ERR_FILE_IO_ACCESS ! maybe disk is full &lt;BR /&gt;10 continue</description>
      <pubDate>Fri, 22 Jul 2011 13:08:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785319#M29786</guid>
      <dc:creator>jaeger0</dc:creator>
      <dc:date>2011-07-22T13:08:10Z</dc:date>
    </item>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785320#M29787</link>
      <description>You can get feedback on bytes actually written, but you will have to use the WinAPI functions directly:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]IF (.NOT.WriteFile(ihandl,			&amp;amp;  ! file handle
				  loc_pointer,		&amp;amp;  ! address of data
				  nbytes,			&amp;amp;  ! byte count to write
				  LOC(nact),		&amp;amp;  ! actual bytes written
				  NULL_OVERLAPPED))	THEN
  	! deal with write error
END IF&lt;BR /&gt;&lt;BR /&gt;IF (nact .LT. nbytes) THEN&lt;BR /&gt;     ! disk might be full&lt;BR /&gt;END IF&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[/bash]&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2011 19:27:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785320#M29787</guid>
      <dc:creator>Paul_Curtis</dc:creator>
      <dc:date>2011-07-22T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785321#M29788</link>
      <description>I never had problems with IOSTAT= or ERR=. But I also never used them together. So remove ERR=20 from your write-statement an check the value of iErr after the write statement (and after the open statement!).&lt;BR /&gt;&lt;BR /&gt;To check if an error can be recognized, remove IOSTAT= and IERR=. If your program does not crash thers's perhaps a problem with your USB-Port or an USB-driver.</description>
      <pubDate>Mon, 25 Jul 2011 06:40:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785321#M29788</guid>
      <dc:creator>rwg</dc:creator>
      <dc:date>2011-07-25T06:40:17Z</dc:date>
    </item>
    <item>
      <title>Disk Full handling</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785322#M29789</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=77713" class="basic" href="https://community.intel.com/en-us/profile/77713/"&gt;Paul Curtis&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;I&gt;You can get feedback on bytes actually written, but you will have to use the WinAPI functions directly:&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;PRE&gt;&lt;I&gt;&lt;I&gt;[bash]IF (.NOT.WriteFile(ihandl,			&amp;amp;  ! file handle
				  loc_pointer,		&amp;amp;  ! address of data
				  nbytes,			&amp;amp;  ! byte count to write
				  LOC(nact),		&amp;amp;  ! actual bytes written
				  NULL_OVERLAPPED))	THEN
  	! deal with write error
END IF&lt;BR /&gt;&lt;BR /&gt;IF (nact .LT. nbytes) THEN&lt;BR /&gt;     ! disk might be full&lt;BR /&gt;END IF&lt;BR /&gt;[/bash]&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;Note the return value from WriteFile (if that's just the raw Win32 API without any wrapper) is not a Fortran logical - to be safe the returned value should be explictly compared with zero.&lt;BR /&gt;&lt;BR /&gt;You also need the right flags to the CreateFile call in order to avoid the OS doing lazy writes, etc. Even with the right flags I'm not sure if you can still guarantee that the device driver that ultimately does the write won't do some caching.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2011 21:32:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Disk-Full-handling/m-p/785322#M29789</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2011-07-25T21:32:36Z</dc:date>
    </item>
  </channel>
</rss>

