comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » PRINTF printing to wrong LUN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
PRINTF printing to wrong LUN [message #71666] Wed, 14 July 2010 07:48 Go to next message
polystethylene is currently offline  polystethylene
Messages: 28
Registered: February 2009
Junior Member
Has anyone had any experience of IDL seemingly printing to the wrong
logical unit number?

I have this IF clause in my code:

IF nwestframes GE 1 THEN BEGIN
OPENW,lun2,'rotate.list'
PRINTF,lun2,FORMAT='("'+string(calibprefix)+'",A0)',lightlist[b]
CLOSE,lun2
PRINTF,lun,'rotate @rotate.list @rotate.list 180'
PRINT,'Pier flip occurs at frame
'+string(FORMAT='(I0)',nwestframes+1)+'. 180deg rotation to be applied
to all eastern sky images'
PRINTF,redinfo,'Pier Flip @ frame =
'+string(FORMAT='(A0)',nwestframes+1)
ENDIF

So as you can see I have a new file introduced within the IF clause,
and two previously open units, lun & redinfo.

Up until this point in the code, IDL was correctly printing to each
lun, as I instructed it to. In this case however, it has printed 'Pier
Flip @ frame 100' in the file associated with 'lun' instead of
'redinfo'. redinfo has other info successfully printed to it, so I
have no idea why IDL suddenly messes up here.

Any one seen anything like this before?

Cheers,

Stef
Re: PRINTF printing to wrong LUN [message #71757 is a reply to message #71666] Wed, 14 July 2010 10:53 Go to previous message
jeanh is currently offline  jeanh
Messages: 79
Registered: November 2009
Member
On 14/07/2010 12:20 PM, polystethylene wrote:
>
>>
>>> Any one seen anything like this before?
>>
>> No. :-)
>>
>> I strongly suspect pilot error.
>>
>>
>
> It usually is :)
>
>
> I've just deleted the long winded response where I printed out every
> line in my code that involves either a OPENW,lun,/GET_LUN or a CLOSE
> statement...
>
> Because I realised that before the above snippet of code I have:
>
> OPENW,lun1,'flatB.list',/GET_LUN
> OPENW,lun2,'flatV.list',/GET_LUN
> OPENW,lun3,'flatR.list',/GET_LUN
> OPENW,lun4,'flatI.list',/GET_LUN
> OPENW,lun5,'bias.list',/GET_LUN
> OPENW,lun6,'dark.list',/GET_LUN
> OPENW,lun7,'light.list',/GET_LUN
> OPENW,lun8,'fblight.list',/GET_LUN
> OPENW,lun9,'blight.list',/GET_LUN
>
> PRINTF,lun1,FORMAT='(A0)',Bflatfilelist
> PRINTF,lun2,FORMAT='(A0)',Vflatfilelist
> PRINTF,lun3,FORMAT='(A0)',Rflatfilelist
> PRINTF,lun4,FORMAT='(A0)',Iflatfilelist
> PRINTF,lun5,FORMAT='(A0)',biasfilelist
> PRINTF,lun6,FORMAT='(A0)',darkfilelist
> PRINTF,lun7,FORMAT='(A0)',lightlist
> PRINTF,lun8,FORMAT='("fb",A0)',lightlist
> PRINTF,lun9,FORMAT='("b",A0)',lightlist
>
> CLOSE,/ALL
>
>
> Redinfo is opened before the close,/all statement...
>
>
> So I deduce from this that in the absence of a 'redinfo' to printf to,
> IDL has printed to another open lun...
>
> This is interesting behaviour, I would have expected a message telling
> me that the file unit 'redinfo' doesn't exist?
>
>
> Anyway, thanks everyone. Once again I air my ignorance and shoddy
> bookkeeping skills public on the idl usenet group. I learnt something
> though, which is always good :)

Hi,

well, the file unit is closed, but the variable is not erased.
So if by chance/bad luck, another lun has the same value as in redinfo,
your printf,redinfo statement will print to that file...

ex:
openU, redinfo, /get_lun
print, redinfo --> 5
free_lun, redinfo
print, redinfo --> 5

openU, aaa, /get_lun
print, aaa --> 5

then
printf, redinfo
and
printf, aaa

are the same, and will print in the same file

Jean
Re: PRINTF printing to wrong LUN [message #71759 is a reply to message #71666] Wed, 14 July 2010 09:20 Go to previous message
polystethylene is currently offline  polystethylene
Messages: 28
Registered: February 2009
Junior Member
>
>> Any one seen anything like this before?
>
> No. :-)
>
> I strongly suspect pilot error.
>
>

It usually is :)


I've just deleted the long winded response where I printed out every
line in my code that involves either a OPENW,lun,/GET_LUN or a CLOSE
statement...

Because I realised that before the above snippet of code I have:

OPENW,lun1,'flatB.list',/GET_LUN
OPENW,lun2,'flatV.list',/GET_LUN
OPENW,lun3,'flatR.list',/GET_LUN
OPENW,lun4,'flatI.list',/GET_LUN
OPENW,lun5,'bias.list',/GET_LUN
OPENW,lun6,'dark.list',/GET_LUN
OPENW,lun7,'light.list',/GET_LUN
OPENW,lun8,'fblight.list',/GET_LUN
OPENW,lun9,'blight.list',/GET_LUN

PRINTF,lun1,FORMAT='(A0)',Bflatfilelist
PRINTF,lun2,FORMAT='(A0)',Vflatfilelist
PRINTF,lun3,FORMAT='(A0)',Rflatfilelist
PRINTF,lun4,FORMAT='(A0)',Iflatfilelist
PRINTF,lun5,FORMAT='(A0)',biasfilelist
PRINTF,lun6,FORMAT='(A0)',darkfilelist
PRINTF,lun7,FORMAT='(A0)',lightlist
PRINTF,lun8,FORMAT='("fb",A0)',lightlist
PRINTF,lun9,FORMAT='("b",A0)',lightlist

CLOSE,/ALL


Redinfo is opened before the close,/all statement...


So I deduce from this that in the absence of a 'redinfo' to printf to,
IDL has printed to another open lun...

This is interesting behaviour, I would have expected a message telling
me that the file unit 'redinfo' doesn't exist?


Anyway, thanks everyone. Once again I air my ignorance and shoddy
bookkeeping skills public on the idl usenet group. I learnt something
though, which is always good :)
Re: PRINTF printing to wrong LUN [message #71760 is a reply to message #71666] Wed, 14 July 2010 08:34 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
polystethylene writes:

> Has anyone had any experience of IDL seemingly printing to the wrong
> logical unit number?
>
> I have this IF clause in my code:
>
> IF nwestframes GE 1 THEN BEGIN
> OPENW,lun2,'rotate.list'
> PRINTF,lun2,FORMAT='("'+string(calibprefix)+'",A0)',lightlist[b]
> CLOSE,lun2
> PRINTF,lun,'rotate @rotate.list @rotate.list 180'
> PRINT,'Pier flip occurs at frame
> '+string(FORMAT='(I0)',nwestframes+1)+'. 180deg rotation to be applied
> to all eastern sky images'
> PRINTF,redinfo,'Pier Flip @ frame =
> '+string(FORMAT='(A0)',nwestframes+1)
> ENDIF
>
> So as you can see I have a new file introduced within the IF clause,
> and two previously open units, lun & redinfo.
>
> Up until this point in the code, IDL was correctly printing to each
> lun, as I instructed it to. In this case however, it has printed 'Pier
> Flip @ frame 100' in the file associated with 'lun' instead of
> 'redinfo'. redinfo has other info successfully printed to it, so I
> have no idea why IDL suddenly messes up here.
>
> Any one seen anything like this before?

No. :-)

I strongly suspect pilot error.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: PRINTF printing to wrong LUN [message #71761 is a reply to message #71666] Wed, 14 July 2010 08:34 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On 7/14/10 10:48 AM, polystethylene wrote:
> Has anyone had any experience of IDL seemingly printing to the wrong
> logical unit number?
>
> I have this IF clause in my code:
>
> IF nwestframes GE 1 THEN BEGIN
> OPENW,lun2,'rotate.list'
> PRINTF,lun2,FORMAT='("'+string(calibprefix)+'",A0)',lightlist[b]
> CLOSE,lun2
> PRINTF,lun,'rotate @rotate.list @rotate.list 180'
> PRINT,'Pier flip occurs at frame
> '+string(FORMAT='(I0)',nwestframes+1)+'. 180deg rotation to be applied
> to all eastern sky images'
> PRINTF,redinfo,'Pier Flip @ frame =
> '+string(FORMAT='(A0)',nwestframes+1)
> ENDIF
>
> So as you can see I have a new file introduced within the IF clause,
> and two previously open units, lun& redinfo.
>
> Up until this point in the code, IDL was correctly printing to each
> lun, as I instructed it to. In this case however, it has printed 'Pier
> Flip @ frame 100' in the file associated with 'lun' instead of
> 'redinfo'. redinfo has other info successfully printed to it, so I
> have no idea why IDL suddenly messes up here.
>


Hi,

I adapted your snippet a bit (see below) and it seems to work fine on my
system { x86_64 darwin unix Mac OS X 7.1 Apr 21 2009 64 64}

My guess is that upstream of that code block the LUNs are getting swapped.

Cheers,
Ben

PRO testme

OPENW, lun, "lun.txt", /GET
OPENW, redinfo, "redinfo.txt", /GET
GET_LUN, lun2


nwestframes = 2

IF nwestframes GE 1 THEN BEGIN
PRINT, "lun2= " + STRTRIM(lun2,2)
PRINT, "lun= " + STRTRIM(lun,2)
PRINT, "redinfo= " + STRTRIM(redinfo,2)
OPENW,lun2,'lun2.txt'
PRINTF,lun2,"print to lun2"
CLOSE,lun2
PRINTF,lun,'print to lun'
PRINT,'print to command line'
PRINTF,redinfo,"print to redinfo"
ENDIF

FREE_LUN, lun
FREE_LUN, redinfo
FREE_LUN, lun2

END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: PRINTF printing to wrong LUN
Next Topic: Re: read XML with IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:40:18 PDT 2025

Total time taken to generate the page: 0.00662 seconds