Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: work around gfortran 14.2.0 bug #35

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/julienne/julienne_string_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module julienne_string_m
generic :: operator(/=) => string_t_ne_string_t, string_t_ne_character, character_ne_string_t
generic :: operator(==) => string_t_eq_string_t, string_t_eq_character, character_eq_string_t
generic :: assignment(= ) => assign_string_t_to_character, assign_character_to_string_t
generic :: get_json_value => get_string, get_string_t_array &
generic :: get_json_value => get_string, get_string_t_array_with_character_key, get_string_t_array_with_string_t_key &
,get_real, get_real_with_character_key &
,get_character, get_character_with_character_key &
,get_logical, get_logical_with_character_key &
Expand All @@ -37,7 +37,7 @@ module julienne_string_m
,get_double_precision, get_double_precision_with_character_key &
,get_double_precision_array, get_double_precision_array_with_character_key
procedure, private :: get_real, get_real_with_character_key
procedure, private :: get_string, get_string_t_array
procedure, private :: get_string, get_string_t_array_with_character_key, get_string_t_array_with_string_t_key
procedure, private :: get_logical, get_logical_with_character_key
procedure, private :: get_integer, get_integer_with_character_key
procedure, private :: get_real_array, get_real_array_with_character_key
Expand Down Expand Up @@ -266,9 +266,17 @@ elemental module function get_string(self, key, mold) result(value_)
type(string_t) :: value_
end function

pure module function get_string_t_array(self, key, mold) result(value_)
pure module function get_string_t_array_with_string_t_key(self, key, mold) result(value_)
implicit none
class(string_t), intent(in) :: self, key
class(string_t), intent(in) :: self
type(string_t), intent(in) :: key, mold(:)
type(string_t), allocatable :: value_(:)
end function

pure module function get_string_t_array_with_character_key(self, key, mold) result(value_)
implicit none
class(string_t), intent(in) :: self
character(len=*), intent(in) :: key
type(string_t), intent(in) :: mold(:)
type(string_t), allocatable :: value_(:)
end function
Expand Down
8 changes: 6 additions & 2 deletions src/julienne/julienne_string_s.f90
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@
end associate
end procedure

module procedure get_string_t_array
module procedure get_string_t_array_with_string_t_key
value_ = self%get_string_t_array_with_character_key(key%string(), mold)
end procedure

module procedure get_string_t_array_with_character_key

character(len=:), allocatable :: raw_line
integer i, comma, opening_quotes, closing_quotes
Expand All @@ -242,7 +246,7 @@
associate(colon => index(raw_line, ':'))
associate(opening_bracket => colon + index(raw_line(colon+1:), '['))
associate(closing_bracket => opening_bracket + index(raw_line(opening_bracket+1:), ']'))
associate(commas => count("," == [(raw_line(i:i), i = opening_bracket+1, closing_bracket-1)]))
associate(commas => count([(raw_line(i:i)==",", i = opening_bracket+1, closing_bracket-1)]))
allocate(value_(commas+1))
opening_quotes = opening_bracket + index(raw_line(opening_bracket+1:), '"')
closing_quotes = opening_quotes + index(raw_line(opening_quotes+1:), '"')
Expand Down
24 changes: 13 additions & 11 deletions test/string_test.F90
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ function results() result(test_results)
constructs_from_double_precision_complex_ptr, &
concatenates_ptr, extracts_key_ptr, extracts_real_ptr, extracts_string_ptr, extracts_logical_ptr, extracts_integer_array_ptr, &
extracts_real_array_ptr, extracts_integer_ptr, extracts_file_base_ptr, extracts_file_name_ptr, &
! Remove code that exposes a gfortran compiler bug:
! extracts_string_array_ptr, &
extracts_string_array_ptr, &
extracts_character_ptr, extracts_double_precision_value_ptr, extracts_dp_array_value_ptr, &
brackets_strings_ptr, constructs_separated_values_ptr

Expand All @@ -139,8 +138,7 @@ function results() result(test_results)
extracts_character_ptr => extracts_character_value
extracts_logical_ptr => extracts_logical_value
extracts_integer_array_ptr => extracts_integer_array_value
! Remove code that exposes a gfortran compiler bug:
!extracts_string_array_ptr => extracts_string_array_value
extracts_string_array_ptr => extracts_string_array_value
extracts_real_array_ptr => extracts_real_array_value
extracts_dp_array_value_ptr => extracts_dp_array_value
extracts_integer_ptr => extracts_integer_value
Expand Down Expand Up @@ -176,9 +174,8 @@ function results() result(test_results)
test_description_t(string_t("extracting a logical value from a colon-separated key/value pair"), extracts_logical_ptr), &
test_description_t( &
string_t("extracting an integer array value from a colon-separated key/value pair"), extracts_integer_array_ptr), &
! Remove code that exposes a gfortran compiler bug:
!test_description_t( &
! string_t("extracting an string array value from a colon-separated key/value pair"), extracts_string_array_ptr), &
test_description_t( &
string_t("extracting an string array value from a colon-separated key/value pair"), extracts_string_array_ptr), &
test_description_t( &
string_t("extracting an real array value from a colon-separated key/value pair"), extracts_real_array_ptr), &
test_description_t( &
Expand Down Expand Up @@ -344,14 +341,20 @@ function extracts_logical_value() result(passed)
#endif
end function

#ifndef __GFORTRAN__
function extracts_string_array_value() result(passed)
logical passed

#ifndef _CRAYFTN
associate(key_string_array_pair => string_t('"lead singer" : ["stevie", "ray", "vaughn"],'))
associate(string_array => key_string_array_pair%get_json_value(key=string_t("lead singer"), mold=[string_t::]))
passed = all(string_array == [string_t("stevie"), string_t("ray"), string_t("vaughn")])
associate(string_array => key_string_array_pair%get_json_value(key="lead singer", mold=[string_t::]))
#ifndef __GFORTRAN__
associate(string_array_ => key_string_array_pair%get_json_value(key=string_t("lead singer"), mold=[string_t::]))
#endif
passed = all(string_array == [string_t("stevie"), string_t("ray"), string_t("vaughn")])
#ifndef __GFORTRAN__
& .and. all(string_array_ == [string_t("stevie"), string_t("ray"), string_t("vaughn")])
end associate
#endif
end associate
end associate
#else
Expand All @@ -364,7 +367,6 @@ function extracts_string_array_value() result(passed)
end block
#endif
end function
#endif

function extracts_integer_array_value() result(passed)
logical passed
Expand Down