subroutineread_use_specprivate
subroutine read_use_spec(spec, only, renames)
Read what follows the module name in a use statement.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| spec | character(len=*) | in | the text | |
| only | logical | out | true for an | |
| renames | type(rename_t) | out | allocatabledimension(:) | the names used |
Calls
Source
Show the code
subroutine read_use_spec(spec, only, renames)
character(len=*), intent(in) :: spec !! the text
logical, intent(out) :: only !! true for an `only` list
type(rename_t), allocatable, intent(out) :: renames(:) !! the names used
character(len=:), allocatable :: text
type(string_t), allocatable :: items(:)
integer :: k, at
allocate (renames(0))
text = strip(lowercase(spec))
only = starts_with(text, 'only')
if (.not. only) return
at = index(text, ':')
text = text(at + 1:)
items = top_split(text, ',')
do k = 1, size(items)
at = index(items(k)%s, '=>')
if (at > 0) then
renames = [renames, rename_t(strip(items(k)%s(at + 2:)), strip(items(k)%s(:at - 1)))]
else
renames = [renames, rename_t(items(k)%s, items(k)%s)]
end if
end do
end subroutine read_use_spec