Commit ac1c2a76 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

fix runtime error when -s/-e options expect an int

parent 2141aa68
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ python/drspine/version.py
# misc other files
.history*
.gdbinit
drspine_profile
fits_*
Makefile.def

+16 −3
Original line number Diff line number Diff line
@@ -118,10 +118,20 @@ program drspine
     case('S')
        call configure_instrument_defaults(INST_SNSNSE, tbins, tau_bins, q_bins)
     case('e')
        read(optarg, *)  itmp
        if (is_integer(optarg)) then
            read(optarg, '(i5)') itmp
            call eshape_select(itmp)
        else
            write(output_unit,'(a,a,a)') "option '-e' requires an integer, got:'",trim(optarg),"'"
            stop
        end if
     case('s')
        read(optarg, *) data_allocation
        if (is_integer(optarg)) then
            read(optarg, '(i5)') data_allocation
        else
            write(output_unit,'(a,a,a)') "option '-s' requires an integer, got:'",trim(optarg),"'"
            stop
        end if
     !case('i')
     !   instrument_config_file = optarg
     !case('r')
@@ -158,6 +168,7 @@ program drspine
        stop
     case default
        write(error_unit,'(1x,a,a,a)') 'unhandled option ', optopt, ' (this is a bug)'
        stop
     end select
  end do

@@ -174,6 +185,8 @@ program drspine
  !group_indx = 0
  call set_progvar()
  call msg_info('drspine', 'instrument selected: '//trim(instrument_name(instrument_parameters%id)))
  call msg_info('drspine', 'current echo shape : '//trim(cformat_eshape())//&
                ' '//msg_fmt('("[",i0,"]")',eshape_get()))

  if (get_loglevel()>LOG_INFO) call shwudf ! show defined variables

+25 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ module strings_module
  public :: split, tolower, toupper, simple_glob
  public :: replace_char, replace_str
  public :: string_replace ! function
  public :: is_number, is_integer

contains

@@ -318,4 +319,28 @@ contains
  END FUNCTION simple_glob


  function is_number(astring)
    logical :: is_number
    character(len=*), intent(in) :: astring
    real    :: xval
    integer :: ierr

    is_number = .false.
    read(astring,'(F12.5)',iostat=ierr) xval
    is_number = ((ierr == 0) .and. (.not. isnan(xval)))
  end function is_number

  function is_integer(astring)
    logical :: is_integer
    character(len=*), intent(in) :: astring
    integer :: ival
    integer :: ierr

    is_integer = .false.
    read(astring,'(i10)',iostat=ierr) ival
    is_integer = (ierr == 0)
  end function is_integer



end module strings_module