Reads the &profiling_input block.
This parser is intentionally explicit because profiling is optional and should be robust to block ordering in case.nml.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename | |||
| type(case_params_t), | intent(inout) | :: | params |
subroutine read_profiling_input(filename, params) character(len=*), intent(in) :: filename type(case_params_t), intent(inout) :: params character(len=512) :: line character(len=256) :: key, value integer :: unit_id, ios, eqpos, comment_pos, comma_pos logical :: in_block, found_block in_block = .false. found_block = .false. open(newunit=unit_id, file=trim(filename), status='old', action='read', iostat=ios) if (ios /= 0) return do read(unit_id, '(a)', iostat=ios) line if (ios /= 0) exit comment_pos = index(line, '!') if (comment_pos > 0) line = line(:comment_pos-1) line = adjustl(line) if (len_trim(line) == 0) cycle if (.not. in_block) then if (index(lowercase(line), '&profiling_input') == 1) then in_block = .true. found_block = .true. end if cycle end if if (index(line, '/') > 0) exit eqpos = index(line, '=') if (eqpos <= 0) cycle key = trim(adjustl(lowercase(line(:eqpos-1)))) value = trim(adjustl(lowercase(line(eqpos+1:)))) comma_pos = index(value, ',') if (comma_pos > 0) value = value(:comma_pos-1) value = trim(value) select case (trim(key)) case ('enable_profiling') call parse_logical_value(value, params%enable_profiling, 'enable_profiling') case ('nested_profiling') call parse_logical_value(value, params%nested_profiling, 'nested_profiling') case ('write_cantera_cache_stats') call parse_logical_value(value, params%write_cantera_cache_stats, 'write_cantera_cache_stats') case ('write_chemistry_screening_stats') call parse_logical_value(value, params%write_chemistry_screening_stats, 'write_chemistry_screening_stats') case ('variable_density_debug') call parse_logical_value(value, params%variable_density_debug, 'variable_density_debug') case ('variable_density_debug_interval') read(value, *, iostat=ios) params%variable_density_debug_interval if (ios /= 0) call fatal_error('input', 'invalid integer for variable_density_debug_interval: '//trim(value)) case default call fatal_error('input', 'unknown variable in &profiling_input: '//trim(key)) end select end do close(unit_id) if (found_block .and. in_block .and. ios /= 0) then call fatal_error('input', 'unterminated &profiling_input block') end if contains !> Parses a string representation of a logical value into a Fortran logical. !! !! Supports common formats like '.true.', 'true', 't', and their false counterparts. !! !! @param value_text The string to parse. !! @param output_value The resulting logical value. !! @param field_name The name of the field being parsed (used for error reporting). subroutine parse_logical_value(value_text, output_value, field_name) character(len=*), intent(in) :: value_text logical, intent(out) :: output_value character(len=*), intent(in) :: field_name select case (trim(value_text)) case ('.true.', 'true', 't', '.t.') output_value = .true. case ('.false.', 'false', 'f', '.f.') output_value = .false. case default call fatal_error('input', 'invalid logical for '//trim(field_name)//': '//trim(value_text)) end select end subroutine parse_logical_value end subroutine read_profiling_input