Takes a string in the form 0.0,1.0,0.5 and returns an array of the real num
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=maxlen), | intent(in) | :: | string_tmp | |||
| real(kind=dp), | intent(out) | :: | outvec(3) | |||
| type(w90_error_type), | intent(out), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm |
subroutine utility_string_to_coord(string_tmp, outvec, error, comm) !================================================! ! !! Takes a string in the form 0.0,1.0,0.5 !! and returns an array of the real num ! !================================================! use w90_constants, only: maxlen use w90_error, only: w90_error_type, set_error_input implicit none character(len=maxlen), intent(in) :: string_tmp real(kind=dp), intent(out) :: outvec(3) type(w90_error_type), allocatable, intent(out) :: error type(w90_comm_type), intent(in) :: comm integer :: pos character(len=maxlen) :: ctemp character(len=maxlen) :: ctemp2 ctemp = string_tmp pos = index(ctemp, ',') if (pos <= 0) then call set_error_input(error, 'utility_string_to_coord: Problem reading string into real number '//trim(string_tmp), comm) return end if ctemp2 = ctemp(1:pos - 1) read (ctemp2, *, err=100, end=100) outvec(1) ctemp = ctemp(pos + 1:) pos = index(ctemp, ',') ctemp2 = ctemp(1:pos - 1) read (ctemp2, *, err=100, end=100) outvec(2) ctemp = ctemp(pos + 1:) read (ctemp, *, err=100, end=100) outvec(3) return 100 call set_error_input(error, 'utility_string_to_coord: Problem reading string into real number '//trim(string_tmp), comm) return ! this is kinda ugly, JJ end subroutine utility_string_to_coord