Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Suppress print statement from nested procedures
Hello all, I built a wrapper for a procedure (it calls many others, in turn), but the output that was important for the original program is no long important. In fact it's quite a nuisance. I'd rather not dig down into the subroutines to add the option to turn off printing -- this would be a major effort. Is there an IDL equivalent of redirecting to /dev/null (or a text file) when calling a procedure from within another procedure? In a perfect world, it would be: pro wrapper [snip] while i lt 1000 do begin [snip] main_procedure >& /dev/null [snip] i++ endwhile [snip] end Thanks! Sam
Re: Suppress print statement from nested procedures
On Thursday, November 14, 2013 6:24:37 PM UTC-5, Sam wrote: > Hello all, > > > > I built a wrapper for a procedure (it calls many others, in turn), but the output that was important for the original program is no long important. In fact it's quite a nuisance. I'd rather not dig down into the subroutines to add the option to turn off printing -- this would be a major effort. Is there an IDL equivalent of redirecting to /dev/null (or a text file) when calling a procedure from within another procedure? In a perfect world, it would be: > Sorry, but there is no simple solution. PRINTing will always print. You're going to have to do some digging. Craig
Le vendredi 15 novembre 2013 00:24:37 UTC+1, Sam a écrit : > Hello all, > > > > I built a wrapper for a procedure (it calls many others, in turn), but the output that was important for the original program is no long important. In fact it's quite a nuisance. I'd rather not dig down into the subroutines to add the option to turn off printing -- this would be a major effort. Is there an IDL equivalent of redirecting to /dev/null (or a text file) when calling a procedure from within another procedure? In a perfect world, it would be: > > > > pro wrapper > > [snip] > > while i lt 1000 do begin > > [snip] > > main_procedure >& /dev/null > > [snip] > > i++ > > endwhile > > [snip] > > end > > > > > > Thanks! > > > > Sam I see two possible solutions to suppress PRINT output. 1) PRINT,text is equivalent to PRINTF,-1,text. It mean that logical unit -1 is used for stdout by IDL (you can confirm that by looking at FSTAT(-1) output). Then, you might redirect the logical unit -1 to some disk file. The drawback is that there is no way (afaik) to go back again to normal stdout behavior. 2) you could run your program in a detached IDL session created from your main session (see the IDL_IDLbridge class). In this case your PRINT messages will be discarded or, if you want them, stored in some file (OUTPUT keyword). You will have to manage the way in which you can eventually transfer your program results from the detached session to the main IDL session. By the way, for any informational messaging in IDL, it is better to use MESSAGE,/INFO rather than PRINT. In particular, you can use the !QUIET system variable to control the output at the main level. alx.
On 11/14/13, 4:24 pm, Sam wrote: > Hello all, > > I built a wrapper for a procedure (it calls many others, in turn), > but the output that was important for the original program is no long > important. In fact it's quite a nuisance. I'd rather not dig down > into the subroutines to add the option to turn off printing -- this > would be a major effort. Is there an IDL equivalent of redirecting to > /dev/null (or a text file) when calling a procedure from within > another procedure? In a perfect world, it would be: > > pro wrapper [snip] while i lt 1000 do begin [snip] main_procedure >& > /dev/null [snip] i++ endwhile [snip] end > > > Thanks! > > Sam > I use MG_LOG for these types of output. I can set a level (CRITICAL, ERROR, WARNING, INFORMATIONAL, DEBUG) on each message so that the printed messages can be conditionally printed by being compared to a global level, i.e., set the level to DEBUG and all messages will be printed or set the level to CRITICAL and only the CRITICAL messages will be printed. You can find MG_LOG here: https://github.com/mgalloy/mglib/tree/master/src/dist_tools You will need other stuff from mglib also, so I would grab the whole library. Mike -- Michael Galloy www.michaelgalloy.com Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com) Research Mathematician Tech-X Corporation
On 5/19/15 7:16 AM, rryan.asu@gmail.com wrote: > At risk of waking the dead... I wanted to do this same thing. I did this.... > > openw,lun,'/dev/null',/get_lun > > and all the print statements become > > printf,lun,'my message' > > and I can simply change the value of lun to direct the output to a file, stdout, stderr. > > -russell > > > On Thursday, November 14, 2013 at 6:24:37 PM UTC-5, Sam wrote: >> Hello all, >> >> I built a wrapper for a procedure (it calls many others, in turn), >> but the output that was important for the original program is no >> long important. In fact it's quite a nuisance. I'd rather not dig >> down into the subroutines to add the option to turn off printing -- >> this would be a major effort. Is there an IDL equivalent of >> redirecting to /dev/null (or a text file) when calling a procedure >> from within another procedure? In a perfect world, it would be: >> >> pro wrapper >> [snip] >> while i lt 1000 do begin >> [snip] >> main_procedure >& /dev/null >> [snip] >> i++ >> endwhile >> [snip] >> end >> >> >> Thanks! >> >> Sam It won't necessarily help your current issue, but this is why I created MG_LOG. It lets you configure your output to send it to a screen, change it format (maybe add a add date/time stamp or routine the MG_LOG statement was called from), or turn output on/off by levels from CRITICAL to DEBUG. Check out a recent post of my site for some more information (before it goes off into the weeds about a specific issue on subloggers): http://michaelgalloy.com/2015/05/12/mg_log-sublogger-level-h andling-change.html Mike -- Michael Galloy www.michaelgalloy.com Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)