Variable format

The syntax you are trying to use is non-standard, it works only in some compilers and I discourage using it.

Also, forget the FORMAT() statements for good, they are obsolete.

You can get your own number inside the format string when you construct it yourself from several parts

character(80) :: form
form = '(          (i10,1x))'
write(form(2:11),'(i10)') matrix

write(*,form) A

You can also write your matrix in a loop per row and then you can use an arbitrarily large count number or a * in Fortran 2008.

do i = 1, matrix
  write(*,'(999(i10,1x))') A(:,i)
end do

do i = 1, matrix
  write(*,'(*(i10,1x))') A
end do

Just check if I did not transpose the matrix inadvertently.

Leave a Comment