@@ -320,16 +320,14 @@ subroutine add_hist(me, x, label, xlim, ylim, xscale, yscale, bins, normed, cumu
320
320
logical , intent (in ), optional :: normed ! ! boolean flag that determines whether bin counts are normalized
321
321
logical , intent (in ), optional :: cumulative ! ! boolean flag that determines whether histogram represents the cumulative density of dataset
322
322
323
+ character (len=* ), parameter :: xname = ' x' ! ! x variable name for script
323
324
character (len= :), allocatable :: xstr ! ! x values stringified
324
325
character (len= :), allocatable :: xlimstr ! ! xlim values stringified
325
326
character (len= :), allocatable :: ylimstr ! ! ylim values stringified
326
- character (len=* ), parameter :: xname = ' x' ! ! x variable name for script
327
- character (len= :), allocatable :: extras ! ! optional stuff
328
- character (len= 5 ) :: normedstr= ' ' ! !
329
- character (len= 5 ) :: cumulativestr= ' ' ! !
327
+ character (len= :), allocatable :: normedstr ! ! optional stuff
328
+ character (len= :), allocatable :: cumulativestr ! !
330
329
character (len= max_int_len) :: binsstr ! !
331
330
332
-
333
331
if (allocated (me% str)) then
334
332
335
333
! axis limits (optional):
@@ -345,21 +343,8 @@ subroutine add_hist(me, x, label, xlim, ylim, xscale, yscale, bins, normed, cumu
345
343
346
344
! get optional inputs (if not present, set default value):
347
345
call optional_int_to_string(bins, binsstr, ' 10' )
348
-
349
- ! optional arguments:
350
- if (present (bins)) extras = extras// ' ,' // ' bins="' // binsstr// ' "'
351
-
352
- if (present (normed) .and. normed) then
353
- normedstr = ' True'
354
- else
355
- normedstr = ' False'
356
- end if
357
-
358
- if (present (cumulative) .and. cumulative) then
359
- cumulativestr = ' True'
360
- else
361
- cumulativestr = ' False'
362
- end if
346
+ call optional_logical_to_string(normed, normedstr, ' False' )
347
+ call optional_logical_to_string(cumulative, cumulativestr, ' False' )
363
348
364
349
! write the plot statement:
365
350
call me% add_str(' ax.hist(' // &
@@ -690,6 +675,31 @@ subroutine optional_int_to_string(int_value, string_value, default_value)
690
675
end subroutine optional_int_to_string
691
676
! *****************************************************************************************
692
677
678
+ ! *****************************************************************************************
679
+ ! > author: Jacob Williams
680
+ !
681
+ ! Logical to string, specifying the default value if
682
+ ! the optional argument is not present.
683
+
684
+ subroutine optional_logical_to_string (logical_value , string_value , default_value )
685
+
686
+ logical ,intent (in ),optional :: logical_value
687
+ character (len= :),allocatable ,intent (out ) :: string_value ! ! integer value stringified
688
+ character (len=* ),intent (in ) :: default_value ! ! default integer value
689
+
690
+ if (present (logical_value)) then
691
+ if (logical_value) then
692
+ string_value = ' True'
693
+ else
694
+ string_value = ' False'
695
+ end if
696
+ else
697
+ string_value = default_value
698
+ end if
699
+
700
+ end subroutine optional_logical_to_string
701
+ ! *****************************************************************************************
702
+
693
703
! *****************************************************************************************
694
704
! > author: Jacob Williams
695
705
!
0 commit comments