Redirecting the output to /dev/null

Hello,

I would like redirect output from several sources to /dev/null file. When I try to run this file:

      program test

      open(1,file='/dev/null')
      open(2,file='/dev/null')

      end

I get an error:

  • PGFIO-F-207/OPEN/unit=2/file is already connected to another unit.
    File name = /dev/null
    In source file test.f, at line number 4

Is there anything I can do?

Thanks in advance.

Hi Strider,

Unfortunately, we do not make any distinction of ‘/dev/null’ from any other file and thus do not allow you to open it twice. However, you might be able to get the same behavior if you use “SCRATCH” files instead of redirecting the output. The output will be sent to this temporary file and when the program exits, the file is deleted.

     program test
          open(1, status='SCRATCH')
          open(2, status='SCRATCH')
     end

Hope this helps,
Mat