fsiesta_mpi.F90: Reopening /dev/stdout doesn't work with position="append" with gfortran
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Siesta |
New
|
Undecided
|
Unassigned |
Bug Description
As the title says: I am trying to use the fsiesta_mpi.F90 interface to use Siesta as a subroutine. When compiled with gfortran (it does not happen with ifort), I get a crash with the error "Fortran runtime error: Illegal seek".
The particular error occurs at line 501 in fsiesta_mpi.F90, where the code reads:
```
#ifdef MPI
! Go back to parent directory and reset output file
call chdir('..')
close(unit=6)
open(unit=6, file=trim(
#endif
```
It closes the temporary output file and reopens the previous one (which is stdout, at least in my case). I can reproduce it in a minimal fortran example:
```
program MyTest
implicit none
close(unit=6)
open(unit=6, file="/dev/stdout", position="append")
write(6, *) "testtest"
end program
```
which shows the same behaviour of crashing when compiled with gfortran but not ifort. Removing the position="append" part works, and I have done that for myself now, but I guess that if an actual file is specified as mainOutFile, it'd be overwritten. So perhaps another solution is needed.
Which version of gfortran are you using?
Your test runs fine on my Mac with
$ gfortran --version
GNU Fortran (Homebrew GCC 7.2.0) 7.2.0