File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,27 @@ subroutine add_str(me,str)
129129 class(pyplot), intent (inout ) :: me ! ! pyplot handler
130130 character (len=* ), intent (in ) :: str ! ! str to be added to pyplot handler buffer
131131
132- me% str = me% str// str// new_line(' ' )
132+ integer :: n_old ! ! current `me%str` length
133+ integer :: n_str ! ! length of input `str`
134+ character (len= :),allocatable :: tmp ! ! tmp string for building the result
135+
136+ ! original
137+ ! me%str = me%str//str//new_line(' ')
138+
139+ if (len (str)==0 ) return
140+
141+ ! the above can sometimes cause a stack overflow in the
142+ ! intel Fortran compiler, so we replace with this:
143+ if (allocated (me% str)) then
144+ n_old = len (me% str)
145+ n_str = len (str)
146+ allocate (character (len= n_old+ n_str+1 ) :: tmp)
147+ tmp(1 :n_old) = me% str
148+ tmp(n_old+1 :) = str// new_line(' ' )
149+ call move_alloc(tmp, me% str)
150+ else
151+ allocate (me% str, source = str// new_line(' ' ))
152+ end if
133153
134154 end subroutine add_str
135155! *****************************************************************************************
You can’t perform that action at this time.
0 commit comments