is_valid_module_name Function

public function is_valid_module_name(module_name, package_name, custom_prefix, enforce_module_names) result(valid)

Check that a module name fits the current naming rules: 1) It must be a valid FORTRAN name (<=63 chars, begin with letter, “_” is only allowed non-alphanumeric) 2) It must begin with the package name 3) If longer, package name must be followed by default separator plus at least one char

Basic check: check the name is Fortran-compliant

FPM package enforcing: check that the module name begins with the package name

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in) :: module_name
type(string_t), intent(in) :: package_name
type(string_t), intent(in) :: custom_prefix
logical, intent(in) :: enforce_module_names

Return Value logical


Source Code

logical function is_valid_module_name(module_name,package_name,custom_prefix,enforce_module_names) result(valid)

    type(string_t), intent(in) :: module_name
    type(string_t), intent(in) :: package_name
    type(string_t), intent(in) :: custom_prefix
    logical       , intent(in) :: enforce_module_names


    !> Basic check: check the name is Fortran-compliant
    valid = is_fortran_name(module_name%s); if (.not.valid) return

    !> FPM package enforcing: check that the module name begins with the package name
    if (enforce_module_names) then

        ! Default prefixing is always valid
        valid = has_valid_standard_prefix(module_name,package_name)

        ! If a custom prefix was validated, it provides additional naming options
        ! Because they never overlap with the default prefix, the former is always an option
        if (len_trim(custom_prefix)>0 .and. .not.valid) &
            valid = has_valid_custom_prefix(module_name,custom_prefix)

    end if

end function is_valid_module_name