formatidl-programming-language

How do I create a space in a print statement?


I have some code that was previously working when I ran IDL on my Linux box. I'm not sure why the format has changed when I run IDL on my Windows box.

Specifically, it seems as if the problem is that a print statement is not creating a space between values.

OPENW, prof2d, outfilename+'.prf', /GET_LUN
printf, prof2d, numalts, altstart, delalt, numlats, latstart,dellat 
printf, prof2d, format='(1(f3.1),500(i))', 0.0, findgen(num)+1.0
for i=0, numlats-1 do begin
printf, prof2d, FORMAT='(1(i),500(e15.8))',i+1, p2d(i,*)
endfor   
CLOSE, prof2d & FREE_LUN, prof2d
popd

This seems to be the line that has an issue: printf, prof2d, FORMAT='(1(i),500(e15.8))',i+1, p2d(i,*)

The linux box produces:

  1 0.00000000e+00 0.00000000e+00 0.00000000e+00....9.17620019e+09

while the windows box produces:

1 0.00000000e+000.00000000e+000.00000000e+00....9.17620019e+09

Any help would be greatly appreciated.

Best regards,

Alex


Solution

  • In your example:

    printf, prof2d, FORMAT='(1(i),500(e15.8))',i+1, p2d(i,*)
    

    the "e15.8" means exponential notation ("e") with 15 total spaces for the number and 8 digits after the decimal place. Which is what the Linux box seems to be doing since "0.00000000e+00" is only 14 characters long, giving one space between values. I don't know why the Windows box is doing something different. But to give space between the values increase the 15 to 16 or more, like:

    printf, prof2d, FORMAT='(1(i),500(e16.8))',i+1, p2d(i,*)
    

    That's going to give two spaces between values on Linux, but should help you on Windows.