Set brackets based on output format type
An unrecognised format_type is reported but never fatal: the NumPy brackets are selected either way, so the caller can always go on to print. If err is present it is set to ERROR_VALIDATION; if err is absent a warning goes to stdout, which is the historical behaviour.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | format_type | |||
| character(len=1), | intent(out) | :: | open_bracket | |||
| character(len=1), | intent(out) | :: | close_bracket | |||
| type(error_t), | intent(inout), | optional | :: | err |
set to ERROR_VALIDATION for an unsupported format_type; the brackets still come back as the NumPy defaults |
subroutine set_brackets(format_type, open_bracket, close_bracket, err) !! Set brackets based on output format type !! !! An unrecognised format_type is reported but never fatal: the NumPy !! brackets are selected either way, so the caller can always go on to !! print. If err is present it is set to ERROR_VALIDATION; if err is absent !! a warning goes to stdout, which is the historical behaviour. character(len=*), intent(in) :: format_type character(len=1), intent(out) :: open_bracket, close_bracket type(error_t), intent(inout), optional :: err !! set to ERROR_VALIDATION for an unsupported format_type; the brackets !! still come back as the NumPy defaults select case (trim(to_upper(adjustl(format_type)))) case ("NUMPY") open_bracket = "[" close_bracket = "]" case ("MATHEMATICA") open_bracket = "{" close_bracket = "}" case ("PLAIN") open_bracket = "[" close_bracket = "]" case default if (present(err)) then call error_raise(err, ERROR_VALIDATION, "pic_print_array: unsupported format type '"//trim(format_type)//"'") else print *, "Warning: Unsupported format type '"//trim(format_type)//"'. Defaulting to NumPy style." end if open_bracket = "[" close_bracket = "]" end select end subroutine set_brackets