Function returns double value given by the key and stops if key doesn't exist.
Providing one of the optional arguments will not stop program in case of missing key, default return value is in this case is NaN
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(input_t), | intent(in) | :: | me | |||
| character(len=*), | intent(in) | :: | key |
key to the value in dictionary |
||
| real(kind=dp), | intent(in), | optional | :: | default_value |
default value in case of missing key |
returned value
function input_dbl(me,key,default_value) result(val) !! Function returns `double` value given by the key and stops if key doesn't exist. !! !! Providing one of the optional arguments will not stop program in case of missing !! key, default return value is in this case is NaN class(input_t), intent(in) :: me character(*), intent(in) :: key !! key to the value in dictionary real(dp), optional, intent(in) :: default_value !! default value in case of missing key real(dp) :: val !! returned value logical :: ok type(input_t) :: tmp if(present(default_value)) val = default_value if(.not.me%has_key(key) .and. present(default_value)) return select type(node=>me%node(key));class is(type_scalar) val = node%to_real(val, ok) call continue_if(node, ok) return class is(type_dictionary) tmp%root => node if(get0d_hdf5(tmp,val)) return end select if(present(default_value)) return error stop 'Can not convert to value of "double" for key: '//key end function input_dbl