Topic: Problem handling files when coming from Win->MacOS

Sorry if this may be silly thing, but I am clueless:

I changed from Win11 to MacOS. But I have some (beginner's?) trouble when opening and writing files. To check the situation, I wrote a simple program (see below), which should just read an ascii-file and write another ascii-file into a sub-folder.

During compilation, everything runs well, but when starting the executable by double click, an "end of file message" is being displayed referring to program line 11. But the file could be read during compilation, and the output file is being created in the existing sub-folder /out during compilation, too.

---------------------------------
program filetest

character (len=4) dummy
real a
integer b

write(*,*) 'hello'

open(unit=1, file='./input.inp')

read(1,*) dummy          ! line 11
write(*,*) dummy
read(1,*) a
write(*,*) a
read(1,*) b
write(*,*) b

close(1)

write(*,*) dummy,a,b

open(unit=2, file='./out/output.out')
write(2,*) dummy
write(2,*) a
write(2,*) b
close(2)

end program

Re: Problem handling files when coming from Win->MacOS

I think we discussed this via email, but macOS Finder, when a program is double-clicked, always treats the working directory as the user's home directory.  If you ran the code from the macOS Terminal from the directory where your executable exists with input.inp in said directory, it will work fine.

You just need to be aware of the difference between a working directory and the directory where your executable happens to exist; they aren't necessarily the same.

Jeff Armstrong
Approximatrix, LLC