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
Neuer Beitragender III
449Aufrufe

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 Antworten
Steven_L_Intel1
Mitarbeiter
449Aufrufe

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.

JVanB
Geschätzter Beitragender II
449Aufrufe

A one-line possibility is

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

OP1
Neuer Beitragender III
449Aufrufe

Thanks Repeat Offender for the elegant solution.

Antworten