Skip to content

Commit 8f35e98

Browse files
committed
format -> character parameter
1 parent 6e5a7ce commit 8f35e98

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

example/linalg/example_svd.f90

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ program example_svd
55
implicit none
66

77
real(dp), allocatable :: A(:,:),s(:),u(:,:),vt(:,:)
8+
character(*), parameter :: fmt = "(a,*(1x,f12.8))"
89

910
! We want to find the singular value decomposition of matrix:
1011
!
@@ -21,30 +22,29 @@ program example_svd
2122
call svd(A,s,u,vt)
2223

2324
! Singular values: [5, 3]
24-
print 1, ' '
25-
print 1, 'S = ',s
26-
print 1, ' '
25+
print fmt, ' '
26+
print fmt, 'S = ',s
27+
print fmt, ' '
2728

2829
! Left vectors (may be flipped):
2930
! [Ã2/2 Ã2/2]
3031
! U = [Ã2/2 -Ã2/2]
3132
!
32-
print 1, ' '
33-
print 1, 'U = ',u(1,:)
34-
print 1, ' ',u(2,:)
33+
print fmt, ' '
34+
print fmt, 'U = ',u(1,:)
35+
print fmt, ' ',u(2,:)
3536

3637

3738
! Right vectors (may be flipped):
3839
! [Ã2/2 Ã2/2 0]
3940
! V = [1/Ã18 -1/Ã18 4/Ã18]
4041
! [ 2/3 -2/3 -1/3]
4142
!
42-
print 1, ' '
43-
print 1, ' ',vt(1,:)
44-
print 1, 'VT= ',vt(2,:)
45-
print 1, ' ',vt(3,:)
46-
print 1, ' '
43+
print fmt, ' '
44+
print fmt, ' ',vt(1,:)
45+
print fmt, 'VT= ',vt(2,:)
46+
print fmt, ' ',vt(3,:)
47+
print fmt, ' '
4748

48-
1 format(a,*(1x,f12.8))
4949

5050
end program example_svd

example/linalg/example_svdvals.f90

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ program example_svdvals
55
implicit none
66

77
real(dp), allocatable :: A(:,:),s(:)
8+
character(*), parameter :: fmt="(a,*(1x,f12.8))"
89

910
! We want to find the singular values of matrix:
1011
!
@@ -18,10 +19,8 @@ program example_svdvals
1819
s = svdvals(A)
1920

2021
! Singular values: [5, 3]
21-
print 1, ' '
22-
print 1, 'S = ',s
23-
print 1, ' '
22+
print fmt, ' '
23+
print fmt, 'S = ',s
24+
print fmt, ' '
2425

25-
1 format(a,*(1x,f12.8))
26-
2726
end program example_svdvals

0 commit comments

Comments
 (0)