is_valid_module_prefix Function

public function is_valid_module_prefix(module_prefix) result(valid)

Check that a custom module prefix fits the current naming rules: 1) Only alphanumeric characters (no spaces, dashes, underscores or other characters) 2) Does not begin with a number (Fortran-compatible syntax)

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in) :: module_prefix

Return Value logical


Source Code

logical function is_valid_module_prefix(module_prefix) result(valid)

    type(string_t), intent(in) :: module_prefix

    character(len=*),parameter :: num='0123456789'
    character(len=*),parameter :: lower='abcdefghijklmnopqrstuvwxyz'
    character(len=*),parameter :: upper='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    character(len=*),parameter :: alpha  =upper//lower
    character(len=*),parameter :: allowed=alpha//num

    character(len=:),allocatable :: name

    name = trim(module_prefix%s)

    if (len(name)>0 .and. len(name)<=63) then
        valid = verify(name(1:1), alpha) == 0 .and. &
                verify(name,allowed)     == 0
    else
        valid = .false.
    endif

end function is_valid_module_prefix