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

formatted output

yingwu
Beginner
304 Views
Hi, I am working on a matrix and does anyone know how to print the matrix in format? For example, I have a 5*2 matrix stored in an array

real :: A(5,2)

I have used MKL to generate the matrix's values randomly. So I want to display this matrix, my code is

do i=1,5
print *, A(i,:)
end do

the output is like below,

23538-a2.JPG

However, when I use a third party library, the output looks better and nicer , as shown below

23539-a1.JPG

I want the below one, but I don't know how to do it. Could anybody help me? Thanks very much.


0 Kudos
2 Replies
Les_Neilson
Valued Contributor II
304 Views

use a format
print '(f6.4,2x,f6.4)', a(i,:)

Les
0 Kudos
Greg_T_
Valued Contributor I
304 Views
Hello,

I also like the "es"scientific format to get a non-zero value as the first digit.
Perhaps something like:
print '(es12.4,2x,es12.4)', A(i,:)

Regards,
Greg
0 Kudos
Reply