How to silence a pipeline?

Hi all.
I am running an external fortran code that reads an input file and outputs another. While the program runs it prints some lines.

I am calling the program with run and pipeline:

run(pipeline(cat in.love,./love));

And this lines get printed in the Julia terminal too…

enter input model file:
enter output file:
enter eigfn output file:
WARNING!!! Is your input in MKS units???
corrected for WARNING as follows:
r,rho,vpv,vsv,vph,vsh multiplied by 1000 to
convert to MKS units.
enter eps
frequency spacing is computed as 1.0/timelength
if used for synthetics, time length must be dt * 2**n
enter power of two (e.g. 8) or 0 for custom list of periods:
Give periods, end with 0:
enter highest mode number (fundamental=0):
enter min, max Vphase (km/s):
the modes file contains eigenvectors at the top of the model
too many layers will use up lots of disk space
how many layers (from top) to eigenfunction file?
Custom list of frequencies (Hz):
1 0.0500
2 0.0455
3 0.0435
4 0.0400
5 0.0357
6 0.0333
7 0.0312
8 0.0286
9 0.0263
10 0.0244
11 0.0227
12 0.0208
13 0.0192
14 0.0179
15 0.0164
16 0.0152
17 0.0139
18 0.0128
19 0.0119
20 0.0110
21 0.0101
22 0.0093
23 0.0086
24 0.0080
25 0.0074
26 0.0068
27 0.0063
28 0.0058
29 0.0053
30 0.0049
31 0.0046
32 0.0042
33 0.0039
34 0.0036
35 0.0033
36 0.0031
37 0.0028
38 0.0026
39 0.0024
40 0.0022
Computation progress
If mmax exceeds nbran= 8 it is truncated

 i          Hz  mmin  mmax
 1    0.050000     0    20
 2    0.045455     0    19
 3    0.043478     0    18
 4    0.040000     0    17
 5    0.035714     0    15
 6    0.033333     0    14
 7    0.031250     0    13
 8    0.028571     0    12
 9    0.026316     0    11
10    0.024390     0    10
11    0.022727     0     9
12    0.020833     0     9
13    0.019231     0     8
14    0.017857     0     8
15    0.016393     0     7
16    0.015152     0     6
17    0.013889     0     6
18    0.012821     0     6
19    0.011905     0     5
20    0.010989     0     5
21    0.010101     0     5
22    0.009346     0     4
23    0.008621     0     4
24    0.008000     0     4
25    0.007353     0     3
26    0.006803     0     3
27    0.006289     0     3
28    0.005780     0     3
29    0.005348     0     3
30    0.004926     0     3
31    0.004566     0     2
32    0.004202     0     2
33    0.003891     0     2
34    0.003584     0     2
35    0.003311     0     2
36    0.003058     0     2
37    0.002825     0     2
38    0.002604     0     2
39    0.002410     0     1
40    0.002198     0     1

Note: The following floating-point exceptions are signalling: IEEE_UNDERFLOW_FLAG

Is there a way to stop showing this output in the Julia screen?

Thanks!

If your fortran program print to standard output, you can use the stdout keyword in pipeline:

run(pipeline(`myprogram`, stdout=devnull))

to redirect output to nowhere.

1 Like

I am running the same lines with the added stdout and get an error :(:

ERROR: LoadError: MethodError: no method matching pipeline(::Cmd, ::Cmd; stdout=Base.DevNull())
Closest candidates are:
pipeline(::Base.AbstractCmd, ::Any) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/cmd.jl:337 got unsupported keyword argument “stdout”
pipeline(::Any, ::Any, ::Any, ::Any…) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/cmd.jl:358 got unsupported keyword argument “stdout”
pipeline(::Base.AbstractCmd; stdin, stdout, stderr, append) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/cmd.jl:321

Stacktrace:
[1] SWD_Nolet(model::Matrix{Float64})
@ Main ~/Documents/JULIA/SWD_Nolet/src/SWD_Nolet.jl:13
[2] top-level scope
@ ~/Documents/JULIA/SWD_Nolet/Call_Nolet00.jl:43
[3] eval
@ ./boot.jl:373 [inlined]
[4] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
in expression starting at /Users/omenbonum/Documents/JULIA/SWD_Nolet/Call_Nolet00.jl:43

What about using an extra pipeline? Like so:

run(pipeline(pipeline(`cat in.love`, `./love`), stdout=devnull))
1 Like

This Works well. I though the double pipeline might slow the process down, but it works equally fast.

All the fortran code has write(*,6) and things like that, I guess why the first pipeline wont shut the stdout! Thanks