<?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 How does one create a uniquely named Windows file via FORTRAN? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820064#M47226</link>
    <description>Huh... Well, not too surprising, these crashes are hard to reproduce... thanks for trying. I don't know whether it matters, but the caller was in one FORTRAN static library project and the callee was in a different static FORTRAN library. I thinkthe problem maylie somewhere in the passing of the string args, especially string constants. I wish I knew what I did that was so wrong, because I hate it when the IDE goes down.</description>
    <pubDate>Thu, 13 May 2010 23:41:44 GMT</pubDate>
    <dc:creator>John6</dc:creator>
    <dc:date>2010-05-13T23:41:44Z</dc:date>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820054#M47216</link>
      <description>Does anyone know a good way to create a new Windows file (via FORTRAN) which is uniquely named?&lt;BR /&gt;In C++ we can call GetTempFileNameW to get new uniquely named files. How can this be done via a FORTRAN call? What I would like is for a blank file to be created so that I can write to it, but it must be uniquely named. Seems like a call to a Windows-OS function should be doable. Is there a FORTRAN equivalent, so that an OS call is not needed?</description>
      <pubDate>Thu, 13 May 2010 19:17:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820054#M47216</guid>
      <dc:creator>John6</dc:creator>
      <dc:date>2010-05-13T19:17:00Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820055#M47217</link>
      <description>GetTempFileName is an Win32 API routine, not part of C++. You can call it in Fortran too. For example:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]use kernel32
integer(UINT) retval
character(MAX_PATH) filename
integer ipos

retval = GetTempFileName ('.'C,'XYZ'C,0,filename)
if (retval /= 0) then
  ipos = index(filename, CHAR(0))
  print *, "File name is ", filename(1:ipos-1)
else
  print *, "Call failed"
end if

end
[/fortran]&lt;/PRE&gt; What GetTempFileName does is start out with a name based on the system time, and then it keeps incrementing the name until it finds one that is unused. You can write standard Fortran code to do this based on SYSTEM_CLOCK, an internal WRITE and an OPEN with STATUS='NEW'.</description>
      <pubDate>Thu, 13 May 2010 19:27:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820055#M47217</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-13T19:27:34Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820056#M47218</link>
      <description>Thanks, that is exactly what I was looking for (an example ofthe GetTempFileName Win32 API call from FORTRAN). Is there a Linux-OS equivalent? (The app I am working on is compiled on both Win32 and 64- bit OS) and Linux, using IVF).</description>
      <pubDate>Thu, 13 May 2010 19:50:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820056#M47218</guid>
      <dc:creator>John6</dc:creator>
      <dc:date>2010-05-13T19:50:09Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820057#M47219</link>
      <description>Not that I know of. Linux lacks a system library like Win32.&lt;BR /&gt;&lt;BR /&gt;Try this.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]character(255) filename

call generate_temp_name('TMP', filename)
print *, trim(filename)


contains

subroutine generate_temp_name (prefix, outname)
implicit none
character(*), intent(in) :: prefix
character(*), intent(out) :: outname

real mrand
integer irand
logical ex
logical, save :: init = .false.
! Initialize random number generator
if (.not. init) then
  call random_seed
  init = .true.
  end if

do
! Get a random number
call random_number(mrand)
! Get the low 24 bits
irand = transfer(mrand, irand)
irand = iand(irand,Z'FFFFFF')
write (outname,101) trim(prefix),irand
101 format (A,Z6.6,'.tmp')
inquire (file=trim(outname),exist=ex)
if (.not.ex) exit
end do

! We have a name that does not exist (at least right now)
return

end subroutine generate_temp_name

end
[/fortran]&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 May 2010 20:14:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820057#M47219</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-13T20:14:20Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820058#M47220</link>
      <description>Excellent. They both work great. I will use the latter because it is more portable. Interestingly enough, I had slightly modified the first example to not use a constant string for the prefix (I passed it in as a variable), and when (debug) stepping into the subroutine, the IDE crashed (VS 2005). The subroutine looked something like this:&lt;BR /&gt;&lt;P&gt;&lt;BR /&gt;Subroutine foooo (PrefixString, filename)&lt;/P&gt;&lt;P&gt;use kernel32&lt;/P&gt;&lt;P&gt;Implicit None&lt;/P&gt;&lt;P&gt;integer(UINT) retval&lt;/P&gt;&lt;P&gt;character(*) filename, PrefixString&lt;/P&gt;&lt;P&gt;!character(MAX_PATH) filename&lt;/P&gt;&lt;P&gt;integer ipos, LastNoNULL&lt;/P&gt;&lt;P&gt;retval = GetTempFileName ('.'C,PrefixString,0,filename)&lt;/P&gt;&lt;P&gt;End Subroutine foooo&lt;BR /&gt;&lt;BR /&gt;called as: Call foooo ('text1_', tmp_file)&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2010 20:38:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820058#M47220</guid>
      <dc:creator>John6</dc:creator>
      <dc:date>2010-05-13T20:38:00Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820059#M47221</link>
      <description>The API routine wants a null-terminated string, but you left off the null.</description>
      <pubDate>Thu, 13 May 2010 20:40:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820059#M47221</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-13T20:40:17Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820060#M47222</link>
      <description>That is enough to cause the VS 2005 IDE to crash completely?</description>
      <pubDate>Thu, 13 May 2010 20:45:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820060#M47222</guid>
      <dc:creator>John6</dc:creator>
      <dc:date>2010-05-13T20:45:49Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820061#M47223</link>
      <description>Hard to say - depends on what the API code does with it. I'll try this later.</description>
      <pubDate>Thu, 13 May 2010 20:57:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820061#M47223</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-13T20:57:11Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820062#M47224</link>
      <description>Thanks, I appreciate the help. I did try with and without the trailing null, and the IDE crashed both times.&lt;BR /&gt;This occurred on the call into the subroutine, not when the IDE function was called, if that helps.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 May 2010 21:00:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820062#M47224</guid>
      <dc:creator>John6</dc:creator>
      <dc:date>2010-05-13T21:00:46Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820063#M47225</link>
      <description>I can't reproduce the crash.</description>
      <pubDate>Thu, 13 May 2010 23:34:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820063#M47225</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-13T23:34:06Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820064#M47226</link>
      <description>Huh... Well, not too surprising, these crashes are hard to reproduce... thanks for trying. I don't know whether it matters, but the caller was in one FORTRAN static library project and the callee was in a different static FORTRAN library. I thinkthe problem maylie somewhere in the passing of the string args, especially string constants. I wish I knew what I did that was so wrong, because I hate it when the IDE goes down.</description>
      <pubDate>Thu, 13 May 2010 23:41:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820064#M47226</guid>
      <dc:creator>John6</dc:creator>
      <dc:date>2010-05-13T23:41:44Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820065#M47227</link>
      <description>A minor variation in Steve's "try this" is to use his technique to create a new random named folder (directory) then within that directory, create sequentially numbered temp file names. In this manner you should never have a name conflict and as an additional benefit, should you decide to keep the temp files from a known good run, then latershould a production run ab-end (or during debugging), you now have a list of files that may be useful in running a post mortem of the ab-end.&lt;BR /&gt;&lt;BR /&gt;Also, the temp files from program X are isolated from the temp files from program Y&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Fri, 14 May 2010 15:07:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820065#M47227</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-05-14T15:07:54Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820066#M47228</link>
      <description>Read the output of &lt;BR /&gt;&lt;BR /&gt; man 3 mktemp&lt;BR /&gt; man 3 mkstemp</description>
      <pubDate>Wed, 28 Jul 2010 17:17:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820066#M47228</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-07-28T17:17:59Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820067#M47229</link>
      <description>That probably won't work well on Windows.</description>
      <pubDate>Wed, 28 Jul 2010 17:35:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820067#M47229</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-07-28T17:35:33Z</dc:date>
    </item>
    <item>
      <title>How does one create a uniquely named Windows file via FORTRAN?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820068#M47230</link>
      <description>True, but I was responding to #2, which was about Linux.</description>
      <pubDate>Wed, 28 Jul 2010 17:55:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-does-one-create-a-uniquely-named-Windows-file-via-FORTRAN/m-p/820068#M47230</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-07-28T17:55:06Z</dc:date>
    </item>
  </channel>
</rss>

