Does gfortran support format like <n>g15.7 as Intel Fortran does?

Dear all,
A simple code below,

  integer :: n
  real, allocatable :: x(:)
  n=5
  allocate(x(n))
  x=100.0
  write(6,'( <n>(g15.7,1x) )') x
  end

The output is

100.0000        100.0000        100.0000        100.0000        100.0000

Note that <n> in the format is support in Intel Fortran, which is very convenient in my opinion. So the format can be easily controlled by the the variable n.

I wonder does gfortran support such a thing or have something similar?

Thank you very much in advance!

1 Like

This is an extension typical for Intel Fortran, so I’d say no. Note that a standard feature is the use of an “unlimited” format specifier:

write(6,'(*(g15.7,1x))') x

which, in this case, will achieve the very same thing. (Even without the “1x” you need to “group” the format specifier - ‘(*(g15.7))’)

2 Likes

This is an Intel extension inherited from VMS. The easy way to remove the constructs is to write them to a string and then to embed the string in the format. There was a post describing this in comp.lang.fortran a long time ago which I haven’t managed to find. If you have a lot of them, fpt will make this change automatically - please see http://simconglobal.com/fpt_ref_remove_embedded_expressions_from_formats.html
John.

1 Like