Print data with a pretty format.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(option), | intent(in) | :: | self | Option data. |
||
integer(kind=I4P), | intent(in) | :: | unit | Logic unit. |
||
logical, | intent(in) | :: | retain_comments | Flag for retaining eventual comments. |
||
character, | intent(in), | optional | :: | pref | Prefixing string. |
|
integer(kind=I4P), | intent(out), | optional | :: | iostat | IO error. |
|
character, | intent(out), | optional | :: | iomsg | IO error message. |
subroutine print_option(self, unit, retain_comments, pref, iostat, iomsg)
!< Print data with a pretty format.
class(option), intent(in) :: self !< Option data.
integer(I4P), intent(in) :: unit !< Logic unit.
logical, intent(in) :: retain_comments !< Flag for retaining eventual comments.
character(*), intent(in), optional :: pref !< Prefixing string.
integer(I4P), intent(out), optional :: iostat !< IO error.
character(*), intent(out), optional :: iomsg !< IO error message.
character(len=:), allocatable :: prefd !< Prefixing string.
integer(I4P) :: iostatd !< IO error.
character(500) :: iomsgd !< Temporary variable for IO error message.
character(len=:), allocatable :: comment !< Eventual option comments.
if (self%oname%is_allocated()) then
prefd = '' ; if (present(pref)) prefd = pref
comment = '' ; if (self%ocomm%is_allocated().and.retain_comments) comment = ' ; '//self%ocomm
if (self%ovals%is_allocated()) then
write(unit=unit, fmt='(A)', iostat=iostatd, iomsg=iomsgd)prefd//self%oname//' = '//self%ovals//comment
else
write(unit=unit, fmt='(A)', iostat=iostatd, iomsg=iomsgd)prefd//self%oname//' = '//comment
endif
if (present(iostat)) iostat = iostatd
if (present(iomsg)) iomsg = iomsgd
endif
endsubroutine print_option