|
Re: maximum line length with printf? [message #44669 is a reply to message #44659] |
Thu, 07 July 2005 13:41   |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Nonsense, works fine with arrays: Try
print,findgen(10),100,format='(11f8.2)'
Haje
<francesca_terenzi@yahoo.it> wrote in message
news:1120767202.505829.66730@z14g2000cwz.googlegroups.com...
> Yes, using the format keyword is exactly what I was suggesting to do in
> first place, but badly...!!!!
> In any case, I think that should not work either if one of the
> variables is not an array and if he is using a loop.
> alternatively, he can avoid using the loop at all and just write:
>
> openw,unit,fileout
> printf,data[0],data[1],data[2],data[3],data[4],data[5],doy,
> format='(....)'
> where inside the parentesis he will put the right formatting for each
> and everyone of the data...
>
> actually, i think avoidind the loop will work also if he puts that doy
> data at the end.....
>
> bye bye
>
|
|
|
Re: maximum line length with printf? [message #44670 is a reply to message #44669] |
Thu, 07 July 2005 13:13   |
francesca_terenzi
Messages: 8 Registered: July 2005
|
Junior Member |
|
|
Yes, using the format keyword is exactly what I was suggesting to do in
first place, but badly...!!!!
In any case, I think that should not work either if one of the
variables is not an array and if he is using a loop.
alternatively, he can avoid using the loop at all and just write:
openw,unit,fileout
printf,data[0],data[1],data[2],data[3],data[4],data[5],doy,
format='(....)'
where inside the parentesis he will put the right formatting for each
and everyone of the data...
actually, i think avoidind the loop will work also if he puts that doy
data at the end.....
bye bye
|
|
|
Re: maximum line length with printf? [message #44671 is a reply to message #44670] |
Thu, 07 July 2005 12:58   |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Alternatively you can uise formatted output suing the FORMAT keyword to
printf. Haje
"Ben Tupper" <btupper@bigelow.org> wrote in message
news:3j5eodFod6nrU1@individual.net...
> guillaume.drolet.1@ulaval.ca wrote:
>> Hi all IDL users!
>>
>> I'm currently writing formatted file with IDL using the printf
>> function.
>> I want to have my 7 variables on the same line:
>>
>> printf, lun_1,
>> data[0,m],data[1,m],data[2,m],data[3,m],data[4,m],data[5,m], doy
>>
>> In my output file, the last variable is on the next line, apart from
>> the 6 other variables. Then the loop goes on and it starts a new line
>> with only the first 6 variables and another one with only the seventh,
>> etc...
>>
>> Is the printf function retrained in terms of line length or number of
>> characters?
>>
>> Thanks for helping on this. It is pretty annoying and not the first
>> time I'm running into this problem with IDL.
>>
>> Gui
>>
>
> Hello,
>
> I think you might need to specify the WIDTH keyword when you OPEN the
> file. Try something big like 500.
>
> Ben
|
|
|
Re: maximum line length with printf? [message #44672 is a reply to message #44671] |
Thu, 07 July 2005 12:55   |
francesca_terenzi
Messages: 8 Registered: July 2005
|
Junior Member |
|
|
Ooops...
I've just notices that you last variable: 'doy" is not an array,
while all the other 5 are. Is that right?
I think in this case what I've said above will not work either.
I am not awared of what Ben told you above, but if that does not work
either, ...here is anoother idea...
Why do not you save the "doy" variable separately from the other data?
I mean, something like:
openw,1,fileout
printf,1,doy
for m=0,M-1 do begin
prinft,1,data[0,m],data[1,m],data[2,m],data[3,m],data[4,m] ,data[5,m]
endfor
close,1
|
|
|
|
Re: maximum line length with printf? [message #44674 is a reply to message #44673] |
Thu, 07 July 2005 12:39   |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
guillaume.drolet.1@ulaval.ca wrote:
> Hi all IDL users!
>
> I'm currently writing formatted file with IDL using the printf
> function.
> I want to have my 7 variables on the same line:
>
> printf, lun_1,
> data[0,m],data[1,m],data[2,m],data[3,m],data[4,m],data[5,m], doy
>
> In my output file, the last variable is on the next line, apart from
> the 6 other variables. Then the loop goes on and it starts a new line
> with only the first 6 variables and another one with only the seventh,
> etc...
>
> Is the printf function retrained in terms of line length or number of
> characters?
>
> Thanks for helping on this. It is pretty annoying and not the first
> time I'm running into this problem with IDL.
>
> Gui
>
Hello,
I think you might need to specify the WIDTH keyword when you OPEN the
file. Try something big like 500.
Ben
|
|
|
Re: maximum line length with printf? [message #44744 is a reply to message #44672] |
Sun, 10 July 2005 23:48  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
francesca_terenzi@yahoo.it wrote:
> Ooops...
>
> I've just notices that you last variable: '�doy" is not an array,
> while all the other 5 are. Is that right?
> I think in this case what I've said above will not work either.
> I am not awared of what Ben told you above, but if that does not work
> either, ...here is anoother idea...
> Why do not you save the "doy" variable separately from the other data?
> I mean, something like:
>
> openw,1,fileout
> printf,1,doy
> for m=0,M-1 do begin
> prinft,1,data[0,m],data[1,m],data[2,m],�data[3,m],data[ 4,m],data[5,m]
> endfor
> close,1
>
You should better use
openw,lun,/get_lun, filename
and at the end
free_lun,lun
Because then you don't get into the trouble if somewhere a fixed unit is
already in usage.
If you add width as keyword you can setup a longer width as the detault one.
I am not sure what the loop is used for. Didn't you get the same result
by prinft,lun,data. Probably you only need to transpose?
Idl does not be case sensitive so you see me a bit surprised that's this
work. I would have bet against this
m=5
for m=0,M-1 do begin
For better coding I would suggest to rename M to n_from_what_it_is, and
to use i as increment var. But that's a question of reading/writing style.
cheers
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|