A derived type can group related configuration fields before validation checks run.

Program

Play the program to change the worker count and validate the record.

config_record_validation.f90
program config_record_validation_demo
    implicit none
    type :: app_config
        integer :: port
        integer :: workers
        integer :: timeout
    end type app_config
    type(app_config) :: cfg
    integer :: valid_count

    cfg%port = 8080
    cfg%workers = 
    cfg%timeout = 30
    valid_count = 0
    if (cfg%port > 0) valid_count = valid_count + 1
    if (cfg%workers > 0) valid_count = valid_count + 1
    if (cfg%timeout <= 60) valid_count = valid_count + 1
    print '(I0, 1X, I0)', cfg%workers, valid_count
end program config_record_validation_demo
program config_record_validation_demo
    implicit none
    type :: app_config
        integer :: port
        integer :: workers
        integer :: timeout
    end type app_config
    type(app_config) :: cfg
    integer :: valid_count

    cfg%port = 8080
    cfg%workers = 
    cfg%timeout = 30
    valid_count = 0
    if (cfg%port > 0) valid_count = valid_count + 1
    if (cfg%workers > 0) valid_count = valid_count + 1
    if (cfg%timeout <= 60) valid_count = valid_count + 1
    print '(I0, 1X, I0)', cfg%workers, valid_count
end program config_record_validation_demo
program config_record_validation_demo
    implicit none
    type :: app_config
        integer :: port
        integer :: workers
        integer :: timeout
    end type app_config
    type(app_config) :: cfg
    integer :: valid_count

    cfg%port = 8080
    cfg%workers = 
    cfg%timeout = 30
    valid_count = 0
    if (cfg%port > 0) valid_count = valid_count + 1
    if (cfg%workers > 0) valid_count = valid_count + 1
    if (cfg%timeout <= 60) valid_count = valid_count + 1
    print '(I0, 1X, I0)', cfg%workers, valid_count
end program config_record_validation_demo
derived type `app_config` groups related configuration fields.
field access `cfg%workers` reads or writes one field on the record.
validation count `valid_count` summarizes how many checks passed.