<?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 Re: File Handles in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965398#M22706</link>
    <description>Check out CVF's Portability Library - it offers some C-like functions such as FSEEK that operate on Fortran I/O units.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
    <pubDate>Sat, 01 Sep 2001 23:22:40 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2001-09-01T23:22:40Z</dc:date>
    <item>
      <title>File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965394#M22702</link>
      <description>I have some very specialized C file-reading functions that I would like to use in my CVF  Windows program.  Several of these functions require that I pass the handle of the open file.  How do I get the file handle in CVF?</description>
      <pubDate>Wed, 29 Aug 2001 17:57:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965394#M22702</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-08-29T17:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965395#M22703</link>
      <description>I don't see a way to do this.  What sort of specialized functions are these?  Perhaps they can be simuilated by other Fortran calls...&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Thu, 30 Aug 2001 08:53:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965395#M22703</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-08-30T08:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965396#M22704</link>
      <description>A general rule of thumb when working with I/O is that you mustn't mix libraries when working with files; that is, you can use Fortran's OPEN...WRITE/READ...CLOSE, or C's fopen...fprintf/fscanf...fclose, or Win32 CreateFile...WriteFile/ReadFile...CloseHandle -- but you shouldn't mix the methods, at least not simultaneously on the same file. &lt;BR /&gt; &lt;BR /&gt;So, if I got you right that the C file expects a Win32-based handle, you can open it in Fortran with CreateFile (see SDK documentation), which returns its handle. If it expects another library-based handle (such as standard C RTL fopen), you'll have to create C wrapper functions and link them with the rest or fortran sources.</description>
      <pubDate>Thu, 30 Aug 2001 17:55:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965396#M22704</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-08-30T17:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965397#M22705</link>
      <description>The advice on not mixing libraries opened my eyes!  I certainly was going to try something along that line when using my C functions.  And so I have bit the bullet, translated the C to Fortran.  At present I am using open/read, but would prefer to use the CreateFile family because SetFilePointer would be most useful for this project.  If time allows.... &lt;BR /&gt; &lt;BR /&gt;Thanks for the advice.</description>
      <pubDate>Sat, 01 Sep 2001 17:17:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965397#M22705</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-01T17:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965398#M22706</link>
      <description>Check out CVF's Portability Library - it offers some C-like functions such as FSEEK that operate on Fortran I/O units.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Sat, 01 Sep 2001 23:22:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965398#M22706</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-09-01T23:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965399#M22707</link>
      <description>Here are some routines which implement handle-based file i/o in F90, &lt;BR /&gt;using the Win32 API functions.  Not true Fortran, not portable, but &lt;BR /&gt;IMHO a whole lot more versatile than the the limited i/o capabilities &lt;BR /&gt;of Fortran, since one can transfer a specified byte count to/from a &lt;BR /&gt;specified offset position in a file, without any need for records or &lt;BR /&gt;any other form of internal formatting.  (If the posted/rec'd versions &lt;BR /&gt;of the code are illegible, email me at pcurtis@kiltel.com &amp;amp; I'll be &lt;BR /&gt;glad to send the code directly). &lt;BR /&gt; &lt;BR /&gt;!======================================================================= &lt;BR /&gt;!          Files/disk access routines &lt;BR /&gt;!======================================================================= &lt;BR /&gt;MODULE filesubs &lt;BR /&gt;    USE kernel32   ! Win32 API interfaces &lt;BR /&gt; &lt;BR /&gt;CONTAINS &lt;BR /&gt; &lt;BR /&gt;    FUNCTION file_exists (fname) RESULT (size) &lt;BR /&gt;        IMPLICIT NONE &lt;BR /&gt;        TYPE(T_WIN32_FIND_DATA)            :: fdata &lt;BR /&gt;        CHARACTER(LEN=*),INTENT(IN)        :: fname  ! full pathname to file &lt;BR /&gt;        INTEGER                            :: size &lt;BR /&gt;        IF (FindFirstFile(fname,fdata) /= INVALID_HANDLE_VALUE) THEN &lt;BR /&gt;            size = fdata%nFileSizeLow &lt;BR /&gt;        ELSE &lt;BR /&gt;            size = -1 &lt;BR /&gt;        ENDIF &lt;BR /&gt;    END FUNCTION file_exists &lt;BR /&gt; &lt;BR /&gt;    FUNCTION open_the_file (fullpath, rwmode) RESULT (ihandl) &lt;BR /&gt;        IMPLICIT NONE &lt;BR /&gt;        INTEGER                        :: access,ihandl &lt;BR /&gt;        CHARACTER(LEN=*),INTENT(IN)    :: fullpath,rwmode &lt;BR /&gt; &lt;BR /&gt;        ! old-style Fortran file open &lt;BR /&gt;        IF      (rwmode == 'F') THEN &lt;BR /&gt;            IF (file_exists(fullpath) &amp;gt; 0) THEN &lt;BR /&gt;                OPEN (ihandl,FILE=fullpath,STATUS='OLD') &lt;BR /&gt;            ELSE     &lt;BR /&gt;                OPEN (ihandl,FILE=fullpath,STATUS='NEW') &lt;BR /&gt;            END IF &lt;BR /&gt;            RETURN &lt;BR /&gt;          &lt;BR /&gt;        ! Win32 file opens &lt;BR /&gt;        ELSE IF (rwmode == 'R') THEN     &lt;BR /&gt;            access = GENERIC_READ &lt;BR /&gt;        ELSE &lt;BR /&gt;            access = IOR(GENERIC_READ,GENERIC_WRITE) &lt;BR /&gt;        END IF         &lt;BR /&gt; &lt;BR /&gt;        ihandl = CreateFile (fullpath,                  &amp;amp; &lt;BR /&gt;                             access,                    &amp;amp; &lt;BR /&gt;                             FILE_SHARE_READ,           &amp;amp; &lt;BR /&gt;                             NULL_SECURITY_ATTRIBUTES,  &amp;amp;  &lt;BR /&gt;                             OPEN_ALWAYS,               &amp;amp; &lt;BR /&gt;                             FILE_ATTRIBUTE_NORMAL,     &amp;amp; &lt;BR /&gt;                             NULL                       ) &lt;BR /&gt;    END FUNCTION open_the_file &lt;BR /&gt; &lt;BR /&gt;    SUBROUTINE full_path (root,subdir,fnam,extn,pathname) &lt;BR /&gt;        IMPLICIT NONE &lt;BR /&gt;        CHARACTER(LEN=*),INTENT(IN)     :: root,subdir,fnam,extn &lt;BR /&gt;        CHARACTER(LEN=*),INTENT(OUT)    :: pathname &lt;BR /&gt;        CHARACTER(LEN=1),PARAMETER      :: slash = '', dot = '.' &lt;BR /&gt;        WRITE (pathname,'(8A)') root(1:LEN_TRIM(root)),         &amp;amp; &lt;BR /&gt;                                slash,                          &amp;amp; &lt;BR /&gt;                                subdir(1:LEN_TRIM(subdir)),     &amp;amp; &lt;BR /&gt;                                slash,                          &amp;amp; &lt;BR /&gt;                                fnam(1:LEN_TRIM(fnam)),         &amp;amp; &lt;BR /&gt;                                dot,                            &amp;amp; &lt;BR /&gt;                                extn(1:MIN0(3,LEN_TRIM(extn))), &amp;amp; &lt;BR /&gt;                                CHAR(0) &lt;BR /&gt;    END SUBROUTINE full_path &lt;BR /&gt; &lt;BR /&gt;    SUBROUTINE rw_file (rwmode,ihandl,nbytes,offset,loc_pointer) &lt;BR /&gt;
        IMPLICIT NONE &lt;BR /&gt;        CHARACTER(LEN=1),INTENT(IN)       :: rwmode &lt;BR /&gt;        INTEGER,INTENT(IN)                :: ihandl,nbytes,offset &lt;BR /&gt;        INTEGER,INTENT(IN)                :: loc_pointer &lt;BR /&gt;        INTEGER                           :: nact &lt;BR /&gt;        LOGICAL                           :: rslt &lt;BR /&gt; &lt;BR /&gt;        ! position pointer if offset is provided &lt;BR /&gt;        IF (offset &amp;gt; 0) rslt = SetFilePointer (ihandl,offset,NULL,FILE_BEGIN) &lt;BR /&gt; &lt;BR /&gt;        IF (rwmode == 'R') THEN &lt;BR /&gt;            rslt = ReadFile  (ihandl,           &amp;amp;  ! file handle &lt;BR /&gt;                              loc_pointer,      &amp;amp;  ! address of data &lt;BR /&gt;                              nbytes,           &amp;amp;  ! byte count to read &lt;BR /&gt;                              LOC(nact),</description>
      <pubDate>Mon, 03 Sep 2001 03:53:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965399#M22707</guid>
      <dc:creator>pcurtis</dc:creator>
      <dc:date>2001-09-03T03:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965400#M22708</link>
      <description>These look like excellent routines.  I had already tried to implement the WinAPI functions on my own, because I need byte transfer, and need to be able to position the file for input/output.  However, I quit after a few hours because I couldn't solve one of the compilation problems.  I am going to try these out right away.</description>
      <pubDate>Mon, 03 Sep 2001 09:51:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965400#M22708</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-03T09:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965401#M22709</link>
      <description>Having problems with the defined parameters for CreateFile (in Paul's module).  Same problems that I had when I tried to do it myself.  I am running CVF 6.1A, compiling a quickwin pgm, and get the following error message for link: &lt;BR /&gt; &lt;BR /&gt;Linking... &lt;BR /&gt;Filesubs.obj : error LNK2001: unresolved external symbol _DFWINTY_mp_NULL_SECURITY_ATTRIBUTES &lt;BR /&gt;Filesubs.obj : error LNK2001: unresolved external symbol _DFWINTY_mp_NULL_OVERLAPPED &lt;BR /&gt; &lt;BR /&gt;What module do I need to include?  Why aren't these defined in dfwinty?</description>
      <pubDate>Tue, 04 Sep 2001 00:37:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965401#M22709</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-04T00:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965402#M22710</link>
      <description>How are you linking?  These should be pulled in for you automatically from DFWIN.LIB.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 04 Sep 2001 04:35:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965402#M22710</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-09-04T04:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965403#M22711</link>
      <description>Linking via Visual Fortran IDE. &lt;BR /&gt;(Is it important that I also have a version of Microsoft Visual Studio 6.0 on my hard drive?  Is there cross-talk here?)  Anyway, I added dfwin.lib to the link libraries and now all is fine.  Thanks everyone.</description>
      <pubDate>Tue, 04 Sep 2001 05:08:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965403#M22711</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-04T05:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965404#M22712</link>
      <description>You should not have needed to add dfwin.lib unless you disabled processing of default libraries.  It does not matter if you have Visual Studio 6 installed.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 04 Sep 2001 05:58:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965404#M22712</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-09-04T05:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965405#M22713</link>
      <description>"running CVF 6.1A, compiling a quickwin pgm" &lt;BR /&gt; &lt;BR /&gt;Nothing disabed.  Thanks for your expert advice.  Enjoy the rest of your Labor Day.  I will enjoy mine!</description>
      <pubDate>Tue, 04 Sep 2001 06:54:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965405#M22713</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-04T06:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: File Handles</title>
      <link>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965406#M22714</link>
      <description>Correction.  My thinking disabled.  Already half way through a glass of wine.  I had checked "Ignore all default libraries", to avoid a conflict in libcd.</description>
      <pubDate>Tue, 04 Sep 2001 07:10:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-Handles/m-p/965406#M22714</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-04T07:10:25Z</dc:date>
    </item>
  </channel>
</rss>

