diff --git a/CHANGELOG.md b/CHANGELOG.md index a4ae276cef82..ab3315175639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gridcomps/ExtData2G/ExtDataConfig.F90 b/gridcomps/ExtData2G/ExtDataConfig.F90 index 54f87021b213..143ba31a59a0 100644 --- a/gridcomps/ExtData2G/ExtDataConfig.F90 +++ b/gridcomps/ExtData2G/ExtDataConfig.F90 @@ -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 @@ -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 @@ -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() @@ -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() @@ -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 @@ -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 @@ -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() @@ -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()) @@ -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 @@ -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