Skip to content

Instantly share code, notes, and snippets.

@JeffIrwin
Created October 6, 2018 14:30
Show Gist options
  • Save JeffIrwin/3b519cda2c1e1771b2203caa77a412cf to your computer and use it in GitHub Desktop.
Save JeffIrwin/3b519cda2c1e1771b2203caa77a412cf to your computer and use it in GitHub Desktop.
subroutine eniuq(t)
character(len = :), allocatable :: s
character(len = *) :: t
integer :: i
s = ''
do i = 1, len(t)
if (t(i:i) == char(10)) then
s = s//char(34)//'//char(10)// &'//t(i:i)//' '//char(34)
else
s = s//t(i:i)
end if
end do
print '(a)', t//'('//char(34)//s//char(34)//')'//char(10)//'end program p'
end subroutine eniuq
program p
call eniuq("subroutine eniuq(t)"//char(10)// &
" character(len = :), allocatable :: s"//char(10)// &
" character(len = *) :: t"//char(10)// &
" integer :: i"//char(10)// &
" s = ''"//char(10)// &
" do i = 1, len(t)"//char(10)// &
" if (t(i:i) == char(10)) then"//char(10)// &
" s = s//char(34)//'//char(10)// &'//t(i:i)//' '//char(34)"//char(10)// &
" else"//char(10)// &
" s = s//t(i:i)"//char(10)// &
" end if"//char(10)// &
" end do"//char(10)// &
" print '(a)', t//'('//char(34)//s//char(34)//')'//char(10)//'end program p'"//char(10)// &
"end subroutine eniuq"//char(10)// &
char(10)// &
"program p"//char(10)// &
" call eniuq")
end program p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment