Page 1 of 1

how to limit the output to screen?

Posted: 13 Oct 2008, 17:04
by cmcg
Is there a way to run elegant without having all the output print to the screen?

Re: how to limit the output to screen?

Posted: 13 Oct 2008, 17:12
by michael_borland
It can be done. Depending on which shell you use, the command is different.

For csh or tcsh, you can redirect the output into a log file using
% elegant inputfile >& logfile

For bash, you should use
% elegant inputfile 2>1 > logfile
(Please observe the spaces carefully.)

If you don't want to put the output in a file but just want to ignore it, use /dev/null instead of a filename for "logfile".

This should work fine on Linux, Unix, OS-X, and Cygwin.

--Michael

Re: how to limit the output to screen?

Posted: 13 Oct 2008, 23:39
by cmcg
Thanks!

Re: how to limit the output to screen?

Posted: 16 Jan 2009, 03:02
by leocmq
michael_borland wrote:It can be done. Depending on which shell you use, the command is different.

For csh or tcsh, you can redirect the output into a log file using
% elegant inputfile >& logfile

For bash, you should use
% elegant inputfile 2>1 > logfile
(Please observe the spaces carefully.)

If you don't want to put the output in a file but just want to ignore it, use /dev/null instead of a filename for "logfile".

This should work fine on Linux, Unix, OS-X, and Cygwin.

--Michael
helps a lot thank you!

Re: how to limit the output to screen?

Posted: 11 Feb 2009, 11:19
by shengb
It just redirects the output to a file or /dev/null.

Is there any plan to support user to disable the output message using a flag?

Guobao

Re: how to limit the output to screen?

Posted: 11 Feb 2009, 13:26
by michael_borland
Guobao,

That would be quite a job since elegant freely sends output to stdout and stderr from within subroutines.

We could probably add a flag that redirects stderr and stdout to /dev/null using freopen(), but I'm not sure if that answers your requirements.

--Michael
shengb wrote:It just redirects the output to a file or /dev/null.

Is there any plan to support user to disable the output message using a flag?

Guobao

Re: how to limit the output to screen?

Posted: 11 Feb 2009, 14:44
by shengb
Hi Michael,
The output to stdout and stderr provides many useful information and very helpful
when using the elegant as a standalone executable application.

It will cause some trouble if we make the elegant as a simulation server and run 24/7,
or even crash the server. I do have some experience on that and hope there is a plan
to have a selection to enable/disable the output.

Another solution might be add a flag such as
#ifdef LIBRARY
set_print_namelist_flags(1);
#else
set_print_namelist_flags(0);
print_namelist(...);
#endif

Then we can select the flag to enable/disable the output when we compile it.
But just as you mentioned, it would be a big job because the output distributes everywhere
in whole SDDS/Elegant code.

I am not sure which one is better.

Guobao

Re: how to limit the output to screen?

Posted: 11 Feb 2009, 15:54
by michael_borland
shengb wrote:Hi Michael,
The output to stdout and stderr provides many useful information and very helpful
when using the elegant as a standalone executable application.

It will cause some trouble if we make the elegant as a simulation server and run 24/7,
or even crash the server. I do have some experience on that and hope there is a plan
to have a selection to enable/disable the output.

Another solution might be add a flag such as
#ifdef LIBRARY
set_print_namelist_flags(1);
#else
set_print_namelist_flags(0);
print_namelist(...);
#endif

Then we can select the flag to enable/disable the output when we compile it.
But just as you mentioned, it would be a big job because the output distributes everywhere
in whole SDDS/Elegant code.

I am not sure which one is better.

Guobao

Re: how to limit the output to screen?

Posted: 11 Feb 2009, 16:02
by michael_borland
Guobao,

I think my last message didn't post because of a large attachment.

It turned out to be very easy to add flags to divert output to a user-specified file (or /dev/null).

I'll send you something about it via private email so you can get the new source.

--Michael
shengb wrote:Hi Michael,
The output to stdout and stderr provides many useful information and very helpful
when using the elegant as a standalone executable application.

It will cause some trouble if we make the elegant as a simulation server and run 24/7,
or even crash the server. I do have some experience on that and hope there is a plan
to have a selection to enable/disable the output.

Another solution might be add a flag such as
#ifdef LIBRARY
set_print_namelist_flags(1);
#else
set_print_namelist_flags(0);
print_namelist(...);
#endif

Then we can select the flag to enable/disable the output when we compile it.
But just as you mentioned, it would be a big job because the output distributes everywhere
in whole SDDS/Elegant code.

I am not sure which one is better.

Guobao