Tokenize a whitespace/comma-separated constituent list into
catalog indices (case-insensitive). Unknown tokens fail loud;
nconst is the count of recognised entries.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | list | |||
| integer, | intent(out) | :: | cat_idx(:) | |||
| integer, | intent(out) | :: | nconst | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on an unrecognised constituent token when present;
absent behaves as today ( |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=len), | private | :: | buf | ||||
| integer, | private | :: | i | ||||
| integer, | private | :: | i0 | ||||
| integer, | private | :: | idx | ||||
| logical, | private | :: | in_tok | ||||
| integer, | private | :: | n |
subroutine parse_constituent_list(list, cat_idx, nconst, ierr) !! Tokenize a whitespace/comma-separated constituent list into !! catalog indices (case-insensitive). Unknown tokens fail loud; !! `nconst` is the count of recognised entries. character(len=*), intent(in) :: list integer, intent(out) :: cat_idx(:) integer, intent(out) :: nconst integer, intent(out), optional :: ierr !! Non-zero on an unrecognised constituent token when present; !! absent behaves as today (`error stop`). integer :: i, n, i0, idx character(len=len(list)) :: buf logical :: in_tok buf = list ! Normalise commas to spaces. do i = 1, len(buf) if (buf(i:i) == ",") buf(i:i) = " " end do nconst = 0 n = len_trim(buf) in_tok = .false. i0 = 1 do i = 1, n + 1 if (i <= n .and. buf(i:i) /= " ") then if (.not. in_tok) then in_tok = .true. i0 = i end if else if (in_tok) then in_tok = .false. idx = tide_name_index(buf(i0:i - 1)) if (idx < 1) then call fail("ocean_tides_nml: unknown constituent '"// & trim(buf(i0:i - 1))//"'", ierr, OCEAN_STATUS_ERR_SETUP) return end if nconst = nconst + 1 cat_idx(nconst) = idx end if end if end do if (present(ierr)) ierr = OCEAN_STATUS_OK end subroutine parse_constituent_list