-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo_join.f90
executable file
·38 lines (38 loc) · 1.39 KB
/
demo_join.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
program demo_join
use M_strings, only: join
implicit none
character(len=*),parameter :: w='(/,*(g0,/,g0))'
character(len=:),allocatable :: s(:)
s=[character(len=10) :: &
& ' United', &
& 'we', &
& 'stand,', &
& 'divided', &
& 'we fall.']
write(*,w) 'SIMPLE JOIN: ',&
join(s)
write(*,w) 'SIMPLE JOIN WITH SEPARATOR: ',&
join(s,sep=' ')
write(*,w) 'CUSTOM SEPARATOR: ',&
join(s,sep='==>')
write(*,w) 'LEFT AND RIGHT AND SEPARATOR: ',&
join(s,sep=';',left='[',right=']')
write(*,w) 'NO TRIMMING: ',&
join(s,trm=.false.)
write(*,w) 'LEFT AND RIGHT: ',&
join(s,left='[',right=']')
write(*,w) 'START,END AND EVERYTHING: ',&
join(s,trm=.false.,sep=',',start='[',end=']',left='"',right='"')
write(*,w) 'TABLE'
call line()
write(*,'(a)') join(s(1:3),trm=.false.,sep='|',start='|',end='|')
write(*,'(a)') join([s(4:5),repeat(' ',len(s))],&
& trm=.false.,sep='|',start='|',end='|')
call line()
contains
subroutine line()
integer :: i
write(*,'(a)') join([(repeat('-',len(s)),i=1,3)],&
& sep='#',start='#',end='#')
end subroutine line
end program demo_join