Re: Group specification of format codes on data of varying dimensions [message #60707] |
Mon, 09 June 2008 07:33 |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
cgoethel@igpp.ucla.edu wrote:
> Hi All,
>
> I am having trouble figuring out how to use group specification of
> formats when my data has varying dimensions. For example:
>
> for i = 0l, c-1 do begin
> printf, lun, time_string, data[i,*], format='(12a,
> ncol(2x,e10.15))'
> endfor
>
> I would like to repeat the format (2x,e10.15) for the number of
> columns in data[i,*]. However, the number of columns varies. When I
> use a variable in the format statement, I get the error 'Expected
> comma or slash'.
> Any suggestions on how to handle this?
Build your format string using string operations:
format = '(12a, ' + strtrim(ncol, 2) + '(2x,e10.15))'
printf, lun, time_string, data[i,*], format=format
If you can construct it outside the loop, even better.
Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
|
|
|