Pregunta

I'm writing a UI to go around some numerics code for my research, and I'm having some problems redirecting the output of the code.

The code is written in fortran 90 i believe, and unfortunately, my experience with fortran is fairly minimal. I'm running linux mint 15, and I can't get statements like ./codepath > file to work. These commands work for shell scripts, so I'm confident that the problem lies in the fortran.

Usually the code just prints to the terminal window, so I'm wondering if for some reason PRINT*, doesn't write to standard output? Is there another redirect I can do so I don't have to rewrite the fortran code? If not, what do I change those print statements to so that it will go to standard output?

EDIT: For reference, the bits of the program that I'm talking about look like this:

IF (MOD(n,dn) .EQ. 0) THEN
     IF ((DDnew .EQ. 0) .AND. (DDold .EQ. 0)) THEN
        DDerr = 1
     ELSE
        DDerr=ABS(DDnew-DDold)
        RRerr=ABS(MAXVAL(ff(:,:,4))-RRold)
        ERRsum=DDerr+RRerr
        print *, "ERROR =", ERRsum
        CALL output(xx,yy,ff,cw,ycw)
     END IF
  END IF

The end goal is to redirect these prints to a text field in the UI program, but I'd like to be able to do that without editing the fortran code too much, thus the need for this to work correctly. :P

¿Fue útil?

Solución

It's possible it's printing to standard error which is picked up by the terminal but won't be picked up by a standard redirection. Can you try this:

./codepath > output.txt 2>&1

If that doesn't work can you post some of the Fortran code?

Calling

CALL flush(6)
CALL flush(0)

After your print statements may also help.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top