<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Where are Read/Write files live?]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=741&amp;type=atom" />
	<updated>2025-12-06T17:31:07Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=741</id>
		<entry>
			<title type="html"><![CDATA[Re: Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=4533#p4533" />
			<content type="html"><![CDATA[<p>Thanks Jeff.&nbsp; I&#039;m ready to close the topic. Getting familiar with Simply Fortran now, and the file location issue is not really a problem.&nbsp; I just open a Terminal window, cd to the particular directory with my files, and ./ the program.</p><p>Being strictly an end-user of Fortran, I only want to know enough unix to get by.&nbsp; Have to admit I was spoiled in the 80s by Language Systems Fortran using Apple&#039;s MPW and the SADE debugger.&nbsp; At the time, it was light-years ahead of my co-workers at Boeing who were struggling with the DOS prompt on their PCs.&nbsp; And a huge leap ahead of coding sheets, punched cards and OTC batch processing on the mainframe IBM, CDC and Cray.&nbsp; There, one typo meant next day turnaround.&nbsp; &nbsp;Back then, I studied the three volumes of &quot;Inside MacIntosh&quot; and built Fortran interfaces to many of Apple&#039;s primitives, especially graphics, so I could generate and interact in real time with visual representations of my algorithms.&nbsp; Sadly, that all went away (for me) with &quot;new and improved&quot; systems.</p>]]></content>
			<author>
				<name><![CDATA[m.banner]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=4535</uri>
			</author>
			<updated>2025-12-06T17:31:07Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=4533#p4533</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=4528#p4528" />
			<content type="html"><![CDATA[<p>My understanding was that Absoft did some tricks with &quot;terminal&quot; programs on macOS to avoid the behavior you&#039;re seeing.&nbsp; Our compiler is just generating a basic macOS executable that doesn&#039;t treat macOS as anything special; however, macOS&#039;s GUI is a little &quot;odd&quot; as far as UNIX compatibility goes.&nbsp; </p><p>The solution if you want to double-click in Finder is either:</p><p>1. Create a shell script that changes the working directory and then calls your Fortran program.&nbsp; You could then double-click that.</p><p>or:</p><p>2. Add a bit of Fortran to change the directory:</p><div class="codebox"><pre><code>character(128)::exe
integer::final_slash

    call get_command_argument(0, exe)
    final_slash = index(exe, &quot;/&quot;, back=.true.)
    if(final_slash .ge. 1) then
        exe(final_slash:128) = &#039; &#039;
        call chdir(exe)
    end if</code></pre></div><p>which <em>should</em> change the directory to the directory where the executable exists.&nbsp; I realize neither is ideal, though.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2025-12-05T13:37:38Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=4528#p4528</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=4525#p4525" />
			<content type="html"><![CDATA[<p>Ok, I see my problem.&nbsp; And I may have to change the way I&#039;m used to working?&nbsp; I have indeed been using the project build function in the IDE, but.. rather than running the executable from a terminal command line, I&#039;ve been just double clicking it.&nbsp; So my &quot;working&quot; directory remains my &quot;home&quot; directory, thus that&#039;s where my output files are appearing.</p><p>In the past, most recently working with Absoft Fortran and their IDE, after developing a program, I could create a directory anywhere, containing my input files, then move or copy my executable into that directory and double click.&nbsp; The output files would appear in that same directory.&nbsp; Any possibility, maybe in the make/build process, to imitate this behavior?</p><p>The advantage was, I could have data files with the same names but kept in separate folders, e.g., &quot;case studies,&quot; and just move or copy my executable into each folder and double click.&nbsp; Then all i/o would be contained in that folder.</p>]]></content>
			<author>
				<name><![CDATA[m.banner]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=4535</uri>
			</author>
			<updated>2025-12-03T17:46:23Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=4525#p4525</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=4523#p4523" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>m.banner wrote:</cite><blockquote><p>It would work best for me if the default location of file i/o were the same as that of the executable.&nbsp; But I see it&#039;s always my home directory, regardless of where the executable is located.&nbsp; Is this a change from the below post in 2020?&nbsp; And if so, can I redirect it, i.e., w/o including a path name in every open?</p></blockquote></div><p>When you compile an executable, that executable is now subject to the rules and whims of the operating system,&nbsp; By default, an executable will access files, when no full, absolute path is provided, in the current working directory.&nbsp; </p><p>In Simply Fortran, when you launch an executable <em>that was built as a project</em>, the current working directory is set to the directory where the project file is saved (not the source file).&nbsp; If you haven&#039;t changed any <a href="https://simplyfortran.com/docs/full/macos/options/project.html">Launch options</a>, the executable will be run from the directory where the project file was saved.</p><p>If you&#039;re using the <em>Compile and Run Current File</em> feature in the Build menu, the resulting executable should be located in and run from the same directory where the source file is found.&nbsp; Even if you have this file in a project, that menu option will cause the working directory to be the same as the source directory.</p><p>I&#039;m not sure what the circumstances are in your case, though.&nbsp; Where exactly is the executable being built?&nbsp; And how are you building the executable, via project?</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2025-12-03T12:29:21Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=4523#p4523</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=4522#p4522" />
			<content type="html"><![CDATA[<p>I began using Simply Fortran for the first time today and love it!&nbsp; Many thanks, Jeff, for your support.&nbsp; It would work best for me if the default location of file i/o were the same as that of the executable.&nbsp; But I see it&#039;s always my home directory, regardless of where the executable is located.&nbsp; Is this a change from the below post in 2020?&nbsp; And if so, can I redirect it, i.e., w/o including a path name in every open?</p><div class="quotebox"><cite>jeff wrote:</cite><blockquote><p>I responded to this via email too a few moments ago.&nbsp; Basically, you&#039;ll want to use <em>OPEN</em> statements to actually access files.&nbsp; These files, by default, will be opened in the current working directory of your program.&nbsp; In Simply Fortran, this is the same directory as the executable and/or project file is located.&nbsp; This can be changed, but that&#039;s the default.</p><p>The <em>Print</em> statement is merely a shortcut for writing to the screen.&nbsp; The following are equivalent:</p><div class="codebox"><pre><code>WRITE(*,*) &quot;I am writing to the screen&quot;</code></pre></div><p>and</p><div class="codebox"><pre><code>PRINT *, &quot;I am writing to the screen&quot;</code></pre></div><p>The <em>Print</em> statement can&#039;t be used to write to files, only the standard output.</p><p>Writing to a printer is far too complex, and there is no quick and easy way to do so.&nbsp; It would require non-portable operating system calls.&nbsp; Furthermore, modern printers have no good way to deal with Fortran&#039;s &quot;line-by-line&quot; output style any longer.&nbsp; It&#039;s best to write to a file and subsequently print that file.</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[m.banner]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=4535</uri>
			</author>
			<updated>2025-12-03T04:07:45Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=4522#p4522</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3444#p3444" />
			<content type="html"><![CDATA[<p>I responded to this via email too a few moments ago.&nbsp; Basically, you&#039;ll want to use <em>OPEN</em> statements to actually access files.&nbsp; These files, by default, will be opened in the current working directory of your program.&nbsp; In Simply Fortran, this is the same directory as the executable and/or project file is located.&nbsp; This can be changed, but that&#039;s the default.</p><p>The <em>Print</em> statement is merely a shortcut for writing to the screen.&nbsp; The following are equivalent:</p><div class="codebox"><pre><code>WRITE(*,*) &quot;I am writing to the screen&quot;</code></pre></div><p>and</p><div class="codebox"><pre><code>PRINT *, &quot;I am writing to the screen&quot;</code></pre></div><p>The <em>Print</em> statement can&#039;t be used to write to files, only the standard output.</p><p>Writing to a printer is far too complex, and there is no quick and easy way to do so.&nbsp; It would require non-portable operating system calls.&nbsp; Furthermore, modern printers have no good way to deal with Fortran&#039;s &quot;line-by-line&quot; output style any longer.&nbsp; It&#039;s best to write to a file and subsequently print that file.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2020-03-20T14:05:49Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3444#p3444</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Where are Read/Write files live?]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3440#p3440" />
			<content type="html"><![CDATA[<p>I understand the Read and write statements as far as how they specify the keyboard/monitor or an external file as the in/out recipient. But where do you specify where - what folder - the file is located? Is it a given that the file you are trying to read or write to is in the same location as the executable? Similarily, I wonder about “Print” - does it go so the system default printer with it’s default parameters. I’m so use do dialog boxes to specify those locations, which printer (with attributes like 2 sided, etc.).</p><p>So I see how it can read something like “MyData.txt” but where does MyData.txt live?</p>]]></content>
			<author>
				<name><![CDATA[designer]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3903</uri>
			</author>
			<updated>2020-03-20T04:43:59Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3440#p3440</id>
		</entry>
</feed>
