Skip to content

Commit

Permalink
(bug fix) kind parameter and character object
Browse files Browse the repository at this point in the history
Because the byte-order kind specifier description remained,
I replace them with the module variable sp and dp.
In addition, because there was a case to apply "len_trim"
function for the unallocated character object, some compiler
cause segmentation fault etc. Therefore, I append some
"if statement" for checking allocation status to initialize them.
  • Loading branch information
sakamoti committed Sep 5, 2020
1 parent 2b82afe commit 97dd16d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ogpf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,13 @@ subroutine set_options(this,stropt)
class(gpf):: this
character(len=*), intent(in) :: stropt

if(.not.allocated(this%txtoptions))this%txtoptions=''
if (len_trim(this%txtoptions) == 0 ) then
this%txtoptions = '' ! initialize string
end if
if ( len_trim(stropt)>0 ) then
this%txtoptions = this%txtoptions // splitstr(stropt)
end if
end if

this%hasoptions=.true.

Expand Down Expand Up @@ -550,6 +551,10 @@ subroutine set_label(this, lblname, lbltext, lblcolor, font_size, font_name, rot

if (present(font_name)) then
label%lblfontname = font_name
else
if(.not.allocated(label%lblfontname))then
label%lblfontname = ''
endif
end if

if (present(font_size)) then
Expand Down Expand Up @@ -1598,6 +1603,7 @@ subroutine addscript(this,strcmd)
class(gpf) :: this
character(len=*), intent(in) :: strcmd

if (.not.allocated(this%txtscript)) this%txtscript=''
if (len_trim(this%txtscript) == 0 ) then
this%txtscript = '' ! initialize string
end if
Expand Down Expand Up @@ -2320,7 +2326,7 @@ function num2str_i4(number_in)
! num2str_int: converts integer number to string
!..............................................................................

integer(kind=4), intent(in) :: number_in
integer(kind=kind(1)), intent(in) :: number_in
character(len=:), allocatable :: num2str_i4

! local variable
Expand All @@ -2336,7 +2342,7 @@ function num2str_r4(number_in, strfmt)
! strfmt is the optional format string
!..............................................................................

real(kind=4), intent(in) :: number_in
real(kind=sp), intent(in) :: number_in
character(len=*), intent(in), optional :: strfmt
character(len=:), allocatable :: num2str_r4

Expand All @@ -2361,7 +2367,7 @@ function num2str_r8(number_in, strfmt)
! strfmt is the optional format string
!..............................................................................

real(kind=8), intent(in) :: number_in
real(kind=dp), intent(in) :: number_in
character(len=*), intent(in), optional :: strfmt
character(len=:), allocatable :: num2str_r8

Expand Down

0 comments on commit 97dd16d

Please sign in to comment.