You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function bool2str(bool) result(str)
logical, intent(in) :: bool
character(len=:), allocatable :: str
if (bool) then
str = '.true.'
else
str = '.false.'
end if
end function bool2str
With gfortran the output of the code
module m
implicit none
contains
function bool2str(bool) result(str)
logical, intent(in) :: bool
character(len=:), allocatable :: str
if (bool) then
str = '.true.'
else
str = '.false.'
end if
end function bool2str
end module m
program main
use m
implicit none
print "(a)", "'" // bool2str(.true.) // "'"
print "(a)", "'" // bool2str(.false.) // "'"
end program main
is
'.true.'
'.false.'
The text was updated successfully, but these errors were encountered:
It can be written more concisely as
With gfortran the output of the code
is
The text was updated successfully, but these errors were encountered: