new_profile Subroutine

public subroutine new_profile(self, features_array, profile_name, error)

Construct a new profile configuration from a TOML array

Arguments

Type IntentOptional Attributes Name
type(profile_config_t), intent(out) :: self

Instance of the profile configuration

type(toml_array), intent(inout) :: features_array

TOML array containing the feature names

character(len=*), intent(in) :: profile_name

Name of the profile

type(error_t), intent(out), allocatable :: error

Error handling


Source Code

    subroutine new_profile(self, features_array, profile_name, error)

        !> Instance of the profile configuration
        type(profile_config_t), intent(out) :: self

        !> TOML array containing the feature names
        type(toml_array), intent(inout) :: features_array

        !> Name of the profile
        character(len=*), intent(in) :: profile_name

        !> Error handling
        type(error_t), allocatable, intent(out) :: error

        integer :: i, stat
        character(len=:), allocatable :: feature_name

        ! Set profile name
        self%name = profile_name

        ! Get feature names from array
        if (len(features_array) > 0) then
            allocate(self%features(len(features_array)))
            do i = 1, len(features_array)
                call get_value(features_array, i, feature_name, stat=stat)
                if (stat /= toml_stat%success) then
                    call fatal_error(error, "Failed to read feature name from profile " // profile_name)
                    return
                end if
                self%features(i)%s = feature_name
            end do
        else
            allocate(self%features(0))
        end if

    end subroutine new_profile