1

I was trying to script storing some info about which compiler was being used with:

gfortran -v 2>&1 >some.file

But upon inspection some.file is empty (plus gfortran printed its output to the terminal). The easy solution is just to store instead:

which gfortran

but i'm curious as to why -v doesn't pipe output on stdout/stderr, presumably it is outputting on some different file handle that eventually ends up on my terminal?

Rob
  • 574
  • 1
  • 4
  • 17
  • In particular, note the answers which talk about the order of redirection. That is, `gfortran -v 2>&1 >some.file` is different from `gfortran -v > some.file 2>&1`. – francescalus Feb 28 '18 at 11:26
  • dam, never realized the order matters, gfortran -v > some.file 2>&1 works for me – Rob Feb 28 '18 at 11:32
  • Tangentially, recent versions of gfortran offer the `compiler_version` function from the intrinsic module `iso_fortran_env`. – francescalus Feb 28 '18 at 11:41

0 Answers0