Format statement error when passing a variable to statement

I am altering a pre-existing fortran 90 code and have encountered an error in format statements, where a representative error is given below:

100 format (7x, (1x,f5.3), ’ |’ ,(1x,f5.3))

I believe the statements are what are causing the errors (all other errors are associated with format statements containing <>'s). The variable ibssz is an integer and from what I understand, the format necessary to pass a variable into a format statement is compiler dependent. I was wondering if this is true, and if so what the correct form for pgf90 compilers is. Thanks!


Hi Jack,

This is a good news/bad news one. This is a non-standard F77 extension which pgf77 supports but pgf90 does not. So if the file can be compiled with pgf77, then you’re set, otherwise it will need to be rewritten.


So does pgf90 support any type of variable passing into format statements, that I could change all of these statement types over to? Or does this mean that there is no way to do this sort of a thing in pgf90? Thanks!


Hi Jack,

I’ve been trying to come up with an F90 alternate version but have been unable. I’ve sent a feature request to our compiler team to see if this can be added to pgf90 as well as pgf77. Hopefully, it wouldn’t be too difficult to add.

Sorry I don’t have a better solution other than to use pgf77 for this file.


Don’t use f77. There is an easy way to dynamically generate format statements. Just create a string of the format statement and then use that string as the output format. Here is a short example (fix the formatting to test):

       program test
       implicit none
       integer i,ni
       character*80 fmt100

c      *** Change ni to see the code in action
       ni= 3

       write(unit=fmt100,fmt='(a,2(i3,a))') '(7x,',ni,'(1x,f5.3),"|",',ni,'(1x,f5.3))'

       write(6,*) '-- Format: '//trim(fmt100)

       write(6,fmt=fmt100) (dble(i),i=1,ni),(dble(i*2),i=1,ni)