Variable Format

Hi all,
I transferred intel fortran code form windows to Unix and cleaned up most of the syntax issues and one issue I am not able to fix it. This is related to variable format. In Intel, i can do the following

Write(NFSnp,“(4x,‘I’,1x,i10)”) (nom(i), i = 1, im)

But in Unix PG fortran (version 9.), I get “illegal character in format string” error. I am not sure if this is taken care of in new version of pg fortran for unix. If it is, then I have to move the code to a unix machine where I have latest version of Fortran.

Please let me know your thought on this issue.

Thanks
Venkat

Hi all,
After review of userguide, I found out that variable format specification is available only for pgf77. This is a very useful method and I am not sure why this was removed in pgf90. I have tons of code that need rewriting of all the formats.

Please let me know if there is any other method is available.

Thanks
Venkat

Hi Venkat,

Variable formats is a Fortran77 extension which we implemented in pgf77. It was discouraged as an extension to F90 primarily because of the availability of internal I/O and the additions of ‘0-width’ edit descriptors such as I0 (that’s I followed by the digit zero).

In the example, the variable format can be constructed using internal I/O:

!! Write(NFSnp,“(4x,‘I’,1x,i10)”) (nom(i), i = 1, im)
character*40 ch
write(ch,99)im
99 format(“(4x,‘I’,1x,”,I0,“i10)”)
Write(NFSnp,fmt=ch) (nom(i), i = 1, im)

  • Mat