Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

WRITE(*,'(<my_var>X,A)') my_text

OP1
New Contributor III
454 Views

Intel Fortran has a (very) nifty language extension that allows an edit descriptor to be an integer expression, using the < > brackets has shown in the subject line above. But is there a standard compliant equivalent form or workaround?

0 Kudos
3 Replies
Steven_L_Intel1
Employee
454 Views

The standard-compliant way is to write the format into a character variable and then use that variable as the format. That extension, Variable Format Expressions, dates back to the DEC PDP-11 days and has earned us the enmity of lots of other compiler developers.

0 Kudos
JVanB
Valued Contributor II
454 Views

A one-line possibility is

WRITE(*,'(2A)') REPEAT(' ',my_var), my_text

0 Kudos
OP1
New Contributor III
454 Views

Thanks Repeat Offender for the elegant solution.

0 Kudos
Reply