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

Fixes #1544. Adds _ASSERT for missing ExtData file #1545

Merged
merged 1 commit into from
Jun 6, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Modified error messages in FileMetadataUtilities to be unique and print filename
- Updated the ESMA_cmake version to v3.16.0
- Updated GitHub Actions MAPL build tests
- Added assert for missing file with ExtData2G

### Removed

Expand Down
30 changes: 17 additions & 13 deletions gridcomps/ExtData2G/ExtDataConfig.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module MAPL_ExtDataConfig
type(ExtDataDerivedMap) :: derived_map
type(ExtDataFileStreamMap) :: file_stream_map
type(ExtDataTimeSampleMap) :: sample_map

contains
procedure :: add_new_rule
procedure :: get_item_type
Expand All @@ -40,7 +40,7 @@ module MAPL_ExtDataConfig

contains

recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_time,unusable,rc)
recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_time,unusable,rc)
class(ExtDataConfig), intent(inout), target :: ext_config
character(len=*), intent(in) :: config_file
type(ESMF_Time), intent(in) :: current_time
Expand All @@ -65,16 +65,20 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_
integer :: i,num_rules
integer, allocatable :: sorted_rules(:)
character(len=1) :: i_char
logical :: file_found

_UNUSED_DUMMY(unusable)

inquire(file=trim(config_file),exist=file_found)
_ASSERT(file_found,"could not find: "//trim(config_file))

stack_depth=stack_depth+1
p = Parser('core')
fstream=FileStream(config_file)
yaml_node_stack(stack_depth) = p%load(fstream)
call fstream%close()

if (yaml_node_stack(stack_depth)%has("subconfigs")) then
if (yaml_node_stack(stack_depth)%has("subconfigs")) then
subconfigs = yaml_node_stack(stack_depth)%at("subconfigs")
_ASSERT(subconfigs%is_sequence(),'subconfigs is not a sequence')
do i=1,subconfigs%size()
Expand All @@ -83,7 +87,7 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_
_VERIFY(status)
end do
end if

if (yaml_node_stack(stack_depth)%has("Samplings")) then
sample_config = yaml_node_stack(stack_depth)%of("Samplings")
iter = sample_config%begin()
Expand Down Expand Up @@ -122,14 +126,14 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_
if (subcfg%is_mapping()) then
call ext_config%add_new_rule(key,subcfg,_RC)
else if (subcfg%is_sequence()) then
sorted_rules = sort_rules_by_start(subcfg,_RC)
sorted_rules = sort_rules_by_start(subcfg,_RC)
num_rules = subcfg%size()
do i=1,num_rules
rule_map = subcfg%of(sorted_rules(i))
write(i_char,'(I1)')i
new_key = key//rule_sep//i_char
call ext_config%add_new_rule(new_key,rule_map,multi_rule=.true.,_RC)
enddo
enddo
else
_FAIL("Exports must be sequence or map")
end if
Expand Down Expand Up @@ -167,7 +171,7 @@ function count_rules_for_item(this,item_name,rc) result(number_of_rules)
class(ExtDataConfig), intent(in) :: this
character(len=*), intent(in) :: item_name
integer, optional, intent(out) :: rc

type(ExtDataRuleMapIterator) :: rule_iterator
character(len=:), pointer :: key
integer :: idx
Expand Down Expand Up @@ -200,7 +204,7 @@ function get_time_range(this,item_name,rc) result(time_range)
type(ExtDataRule), pointer :: rule
integer :: i,status,idx
type(ESMF_Time) :: very_future_time

rule_iterator = this%rule_map%begin()
do while(rule_iterator /= this%rule_map%end())
key => rule_iterator%key()
Expand Down Expand Up @@ -281,7 +285,7 @@ function get_item_type(this,item_name,unusable,rc) result(item_type)

_UNUSED_DUMMY(unusable)
item_type=ExtData_not_found

found_rule = .false.
rule_iterator = this%rule_map%begin()
do while(rule_iterator /= this%rule_map%end())
Expand Down Expand Up @@ -316,7 +320,7 @@ function get_item_type(this,item_name,unusable,rc) result(item_type)
_RETURN(_SUCCESS)
end function get_item_type

subroutine add_new_rule(this,key,export_rule,multi_rule,rc)
subroutine add_new_rule(this,key,export_rule,multi_rule,rc)
class(ExtDataConfig), intent(inout) :: this
character(len=*), intent(in) :: key
type(configuration), intent(in) :: export_rule
Expand Down Expand Up @@ -385,18 +389,18 @@ function get_extra_derived_items(this,primary_items,derived_items,rc) result(nee
! now we have a stringvector of the variables involved in the expression
! check which of this are already in primary_items list, if any are not
! then we need to createa new list of needed variables and the "derived field"
! wence to coppy them
! wence to coppy them
do i=1,variables_in_expression%size()
sval => variables_in_expression%at(i)
if (.not.string_in_string_vector(sval,primary_items)) then
rule => this%rule_map%at(sval)
_ASSERT(associated(rule),"no rule for "//trim(sval)//" needed by "//trim(derived_name))
call needed_vars%push_back(sval//","//derived_name)
call needed_vars%push_back(sval//","//derived_name)
end if
enddo
call string_iter%next()
enddo

_RETURN(_SUCCESS)
end function get_extra_derived_items

Expand Down