diff --git a/CHANGELOG.md b/CHANGELOG.md index c3632d656b71..46169ef62b46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +## [2.42.4] - 2023-12-10 + +### Changed + +- Improved error message for missing labels in GridManager. + +### Fixed + +- Corrected some unit tests (and test utilities) to fix dangling pointers detected by NAG. Most (possibly all) of these changes are already on release/MAPL-v3, but it was getting annoying to have NAG fail unit tests with develop branch. +- Fix for CMake an Apple. Needs to set `__DARWIN` as an fpp flag. (Only used by NAG, but ...) + ## [2.42.3] - 2023-12-06 ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index a5677597e57b..c04500255b85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ endif () project ( MAPL - VERSION 2.42.3 + VERSION 2.42.4 LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF # Set the possible values of build type for cmake-gui @@ -220,6 +220,9 @@ include(CheckCompilerCapabilities) if(SUPPORT_FOR_MPI_IERROR_KEYWORD) add_compile_definitions(SUPPORT_FOR_MPI_IERROR_KEYWORD) endif() +if (APPLE) + add_compile_definitions("-D__DARWIN") +endif() add_subdirectory (pfio) add_subdirectory (profiler) @@ -242,6 +245,7 @@ if (PFUNIT_FOUND) add_subdirectory (pfunit EXCLUDE_FROM_ALL) endif () + # Support for automated code generation include(mapl_acg) include(mapl_create_stub_component) diff --git a/base/MAPL_Config.F90 b/base/MAPL_Config.F90 index 9cae1e8cdb2c..f31daf1cc93d 100644 --- a/base/MAPL_Config.F90 +++ b/base/MAPL_Config.F90 @@ -72,7 +72,6 @@ function MAPL_ConfigCreate(unusable, rc) result(config) #endif character, parameter :: NUL = achar(00) !! what it says - _UNUSED_DUMMY(unusable) config = ESMF_ConfigCreate(rc=rc) config%cptr%buffer(1:1) = EOL config%cptr%buffer(2:2) = EOB @@ -80,6 +79,8 @@ function MAPL_ConfigCreate(unusable, rc) result(config) config%cptr%next_line = 1 config%cptr%value_begin = 1 + _RETURN(_SUCCESS) + _UNUSED_DUMMY(unusable) end function MAPL_ConfigCreate !------------------------------------------------------------------------------ diff --git a/base/MAPL_GridManager.F90 b/base/MAPL_GridManager.F90 index eb2bd07b782b..360c784ea808 100644 --- a/base/MAPL_GridManager.F90 +++ b/base/MAPL_GridManager.F90 @@ -291,7 +291,7 @@ function make_grid_from_config(this, config, unusable, prefix, rc) result(grid) end if call ESMF_ConfigGetAttribute(config, label=label, value=grid_type, rc=status) - _ASSERT(status==0,'label not found') + _ASSERT(status==0,'label ['//label//'] not found') allocate(factory, source=this%make_factory(trim(grid_type), config, prefix=prefix, rc=status)) _VERIFY(status) diff --git a/base/tests/Test_GridManager.pf b/base/tests/Test_GridManager.pf index 9e7e6f17fcb9..540437006763 100644 --- a/base/tests/Test_GridManager.pf +++ b/base/tests/Test_GridManager.pf @@ -52,7 +52,7 @@ contains if (status == 0) then call grid_manager%delete(grid) end if - @assertExceptionRaised('label not found') + @assertExceptionRaised('label [GRID_TYPE:] not found') ! Check that it actually failed @assertFalse(0 == status, 'made a grid even though there is no prototype') diff --git a/base/tests/mapl_bundleio_test.F90 b/base/tests/mapl_bundleio_test.F90 index be606ce717a5..ad9981c858c6 100644 --- a/base/tests/mapl_bundleio_test.F90 +++ b/base/tests/mapl_bundleio_test.F90 @@ -150,7 +150,7 @@ function create_cf(grid_name,im_world,jm_world,nx,ny,lm,cs_stretch_param,rc) res call MAPL_ConfigSetAttribute(cf,value=dateline, label=trim(grid_name)//".DATELINE:",_RC) end if - + _RETURN(_SUCCESS) end function create_cf function create_gridname(im,jm,date,pole) result(gridname) @@ -260,7 +260,7 @@ program ut_ReGridding call UnpackGridName(Gridname,im_world_new,jm_world_new,dateline_new,pole_new) lm_world=3 - cfoutput = create_cf(gridname,im_world_new,jm_world_new,nx,ny,lm_world,cs_stretch_param,_RC) + cfoutput = create_cf(trim(gridname),im_world_new,jm_world_new,nx,ny,lm_world,cs_stretch_param,_RC) grid_new=grid_manager%make_grid(cfoutput,prefix=trim(gridname)//".",_RC) bundle=ESMF_FieldBundleCreate(name="cfio_bundle",_RC) call ESMF_FieldBundleSet(bundle,grid=grid_new,_RC) diff --git a/gridcomps/ExtData2G/ExtDataConfig.F90 b/gridcomps/ExtData2G/ExtDataConfig.F90 index 086476a761fe..6ee6f96af98f 100644 --- a/gridcomps/ExtData2G/ExtDataConfig.F90 +++ b/gridcomps/ExtData2G/ExtDataConfig.F90 @@ -87,8 +87,8 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_ if (ESMF_HConfigIsDefined(input_config,keyString="Samplings")) then temp_configs = ESMF_HConfigCreateAt(input_config,keyString="Samplings",_RC) - hconfigIter = ESMF_HConfigIterBegin(temp_configs) hconfigIterBegin = ESMF_HConfigIterBegin(temp_configs) + hconfigIter = hconfigIterBegin hconfigIterEnd = ESMF_HConfigIterEnd(temp_configs) do while (ESMF_HConfigIterLoop(hconfigIter,hconfigIterBegin,hconfigIterEnd)) hconfig_key = ESMF_HConfigAsStringMapKey(hconfigIter,_RC) @@ -96,12 +96,13 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_ ts = ExtDataTimeSample(single_sample,_RC) call ext_config%sample_map%insert(trim(hconfig_key),ts) enddo + call ESMF_HConfigDestroy(temp_configs) end if if (ESMF_HConfigIsDefined(input_config,keyString="Collections")) then temp_configs = ESMF_HConfigCreateAt(input_config,keyString="Collections",_RC) - hconfigIter = ESMF_HConfigIterBegin(temp_configs) hconfigIterBegin = ESMF_HConfigIterBegin(temp_configs) + hconfigIter = hconfigIterBegin hconfigIterEnd = ESMF_HConfigIterEnd(temp_configs) do while (ESMF_HConfigIterLoop(hconfigIter,hconfigIterBegin,hconfigIterEnd)) hconfig_key = ESMF_HConfigAsStringMapKey(hconfigIter,_RC) @@ -111,12 +112,13 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_ ds = ExtDataFileStream(single_collection,current_time,_RC) call ext_config%file_stream_map%insert(trim(hconfig_key),ds) enddo + call ESMF_HConfigDestroy(temp_configs) end if if (ESMF_HConfigIsDefined(input_config,keyString="Exports")) then temp_configs = ESMF_HConfigCreateAt(input_config,keyString="Exports",_RC) - hconfigIter = ESMF_HConfigIterBegin(temp_configs) hconfigIterBegin = ESMF_HConfigIterBegin(temp_configs) + hconfigIter = hconfigIterBegin hconfigIterEnd = ESMF_HConfigIterEnd(temp_configs) do while (ESMF_HConfigIterLoop(hconfigIter,hconfigIterBegin,hconfigIterEnd)) hconfig_key = ESMF_HConfigAsStringMapKey(hconfigIter,_RC) @@ -140,8 +142,8 @@ recursive subroutine new_ExtDataConfig_from_yaml(ext_config,config_file,current_ if (ESMF_HConfigIsDefined(input_config,keyString="Derived")) then temp_configs = ESMF_HConfigCreateAt(input_config,keyString="Derived",_RC) - hconfigIter = ESMF_HConfigIterBegin(temp_configs) hconfigIterBegin = ESMF_HConfigIterBegin(temp_configs) + hconfigIter = hconfigIterBegin hconfigIterEnd = ESMF_HConfigIterEnd(temp_configs) do while (ESMF_HConfigIterLoop(hconfigIter,hconfigIterBegin,hconfigIterEnd)) hconfig_key = ESMF_HConfigAsStringMapKey(hconfigIter,_RC) @@ -162,7 +164,7 @@ end subroutine new_ExtDataConfig_from_yaml function count_rules_for_item(this,item_name,rc) result(number_of_rules) integer :: number_of_rules - class(ExtDataConfig), intent(in) :: this + class(ExtDataConfig), target, intent(in) :: this character(len=*), intent(in) :: item_name integer, optional, intent(out) :: rc @@ -187,7 +189,7 @@ end function count_rules_for_item function get_time_range(this,item_name,rc) result(time_range) type(ESMF_Time), allocatable :: time_range(:) - class(ExtDataConfig), intent(in) :: this + class(ExtDataConfig), target, intent(in) :: this character(len=*), intent(in) :: item_name integer, optional, intent(out) :: rc @@ -265,7 +267,7 @@ function sort_rules_by_start(hconfig_sequence,rc) result(sorted_index) end function sort_rules_by_start function get_item_type(this,item_name,unusable,rc) result(item_type) - class(ExtDataConfig), intent(inout) :: this + class(ExtDataConfig), target, intent(inout) :: this character(len=*), intent(in) :: item_name class(KeywordEnforcer), optional, intent(in) :: unusable integer, optional, intent(out) :: rc diff --git a/gridcomps/ExtData2G/ExtDataGridCompNG.F90 b/gridcomps/ExtData2G/ExtDataGridCompNG.F90 index ce335399f252..0da681786a62 100644 --- a/gridcomps/ExtData2G/ExtDataGridCompNG.F90 +++ b/gridcomps/ExtData2G/ExtDataGridCompNG.F90 @@ -256,7 +256,7 @@ SUBROUTINE Initialize_ ( GC, IMPORT, EXPORT, CLOCK, rc ) integer :: idx type(MAPL_MetaComp),pointer :: MAPLSTATE - type(ExtDataOldTypesCreator),target :: config_yaml + type(ExtDataOldTypesCreator), target :: config_yaml character(len=ESMF_MAXSTR) :: new_rc_file logical :: found_in_config integer :: num_primary,num_derived,num_rules @@ -308,7 +308,7 @@ SUBROUTINE Initialize_ ( GC, IMPORT, EXPORT, CLOCK, rc ) _RETURN(ESMF_SUCCESS) end if - config_yaml = ExtDataOldTypesCreator(new_rc_file,time,_RC) + call new_ExtDataOldTypesCreator(config_yaml, new_rc_file, time, _RC) allocate(ITEMNAMES(ITEMCOUNT), STAT=STATUS) _VERIFY(STATUS) @@ -1449,7 +1449,7 @@ end subroutine createFileLevBracket subroutine IOBundle_Add_Entry(IOBundles,item,entry_num,rc) type(IOBundleNGVector), intent(inout) :: IOBundles - type(primaryExport), intent(inout) :: item + type(primaryExport), target, intent(inout) :: item integer, intent(in) :: entry_num integer, intent(out), optional :: rc diff --git a/gridcomps/ExtData2G/ExtDataOldTypesCreator.F90 b/gridcomps/ExtData2G/ExtDataOldTypesCreator.F90 index f6e4533b2f2c..1abc5720c795 100644 --- a/gridcomps/ExtData2G/ExtDataOldTypesCreator.F90 +++ b/gridcomps/ExtData2G/ExtDataOldTypesCreator.F90 @@ -21,7 +21,9 @@ module MAPL_ExtDataOldTypesCreator use MAPL_ExtDataTimeSample use MAPL_ExtDataTimeSampleMap implicit none + public :: ExtDataOldTypesCreator + public :: new_ExtDataOldTypesCreator type, extends(ExtDataConfig) :: ExtDataOldTypesCreator private @@ -30,32 +32,31 @@ module MAPL_ExtDataOldTypesCreator procedure :: fillin_derived end type ExtDataOldTypesCreator - interface ExtDataOldTypesCreator - module procedure :: new_ExtDataOldTypesCreator - end interface +!# interface ExtDataOldTypesCreator +!# module procedure :: new_ExtDataOldTypesCreator +!# end interface contains - function new_ExtDataOldTypesCreator(config_file,current_time,unusable,rc ) result(ExtDataObj) - character(len=*), intent(in) :: config_file - type(ESMF_Time), intent(in) :: current_time - class(KeywordEnforcer), optional, intent(in) :: unusable - integer, optional, intent(out) :: rc + subroutine new_ExtDataOldTypesCreator(extdataobj, config_file,current_time,unusable,rc ) + type(ExtDataOldTypesCreator), target, intent(out) :: ExtDataObj + character(len=*), intent(in) :: config_file + type(ESMF_Time), intent(in) :: current_time + class(KeywordEnforcer), optional, intent(in) :: unusable + integer, optional, intent(out) :: rc - type(ExtDataOldTypesCreator) :: ExtDataObj - integer :: status - - _UNUSED_DUMMY(unusable) - call ExtDataObj%ExtDataConfig%new_ExtDataConfig_from_yaml(config_file,current_time,rc=status) - _VERIFY(status) - - _RETURN(_SUCCESS) - end function new_ExtDataOldTypesCreator + integer :: status + + call ExtDataObj%ExtDataConfig%new_ExtDataConfig_from_yaml(config_file,current_time,_RC) + + _RETURN(_SUCCESS) + _UNUSED_DUMMY(unusable) + end subroutine new_ExtDataOldTypesCreator subroutine fillin_primary(this,item_name,base_name,primary_item,time,clock,unusable,rc) - class(ExtDataOldTypesCreator), intent(inout) :: this + class(ExtDataOldTypesCreator), target, intent(inout) :: this character(len=*), intent(in) :: item_name character(len=*), intent(in) :: base_name type(PrimaryExport), intent(inout) :: primary_item diff --git a/griddedio/GriddedIO.F90 b/griddedio/GriddedIO.F90 index 7b62d2e0dacf..20d09063a7f8 100644 --- a/griddedio/GriddedIO.F90 +++ b/griddedio/GriddedIO.F90 @@ -108,13 +108,13 @@ function new_MAPL_GriddedIO(metadata,input_bundle,output_bundle,write_collection end function new_MAPL_GriddedIO subroutine CreateFileMetaData(this,items,bundle,timeInfo,vdata,ogrid,global_attributes,rc) - class (MAPL_GriddedIO), intent(inout) :: this + class (MAPL_GriddedIO), target, intent(inout) :: this type(GriddedIOitemVector), target, intent(inout) :: items type(ESMF_FieldBundle), intent(inout) :: bundle type(TimeData), intent(inout) :: timeInfo type(VerticalData), intent(inout), optional :: vdata type (ESMF_Grid), intent(inout), pointer, optional :: ogrid - type(StringStringMap), intent(in), optional :: global_attributes + type(StringStringMap), intent(in), target, optional :: global_attributes integer, intent(out), optional :: rc type(ESMF_Grid) :: input_grid @@ -729,8 +729,8 @@ subroutine RegridVector(this,xName,yName,rc) yptr3d => yptr3d_inter end if else - if (associated(xptr3d)) nullify(xptr3d) - if (associated(yptr3d)) nullify(yptr3d) + nullify(xptr3d) + nullify(yptr3d) end if call ESMF_FieldBundleGet(this%input_bundle,xname,field=xfield,rc=status) diff --git a/pfio/AbstractDirectoryService.F90 b/pfio/AbstractDirectoryService.F90 index 2eceb9d4c121..86088b98c0cd 100644 --- a/pfio/AbstractDirectoryService.F90 +++ b/pfio/AbstractDirectoryService.F90 @@ -53,7 +53,7 @@ subroutine connect_to_client(this, port_name, server, rc) import AbstractSocketVector class (AbstractDirectoryService), target, intent(inout) :: this character(*), intent(in) :: port_name - class (BaseServer), intent(inout) :: server + class (BaseServer), target, intent(inout) :: server integer, optional, intent(out) :: rc end subroutine connect_to_client @@ -61,9 +61,9 @@ subroutine publish(this, port, server, rc) use pFIO_BaseServerMod import AbstractDirectoryService import PortInfo - class (AbstractDirectoryService), intent(inout) :: this + class (AbstractDirectoryService), target, intent(inout) :: this type(PortInfo), target, intent(in) :: port - class (BaseServer), intent(inout) :: server + class (BaseServer), intent(in) :: server integer, optional, intent(out) :: rc end subroutine diff --git a/pfio/DirectoryService.F90 b/pfio/DirectoryService.F90 index 325beb523acb..47a4cde92ad6 100644 --- a/pfio/DirectoryService.F90 +++ b/pfio/DirectoryService.F90 @@ -286,7 +286,7 @@ end subroutine connect_to_server subroutine connect_to_client(this, port_name, server, rc) class (DirectoryService), target, intent(inout) :: this character(*), intent(in) :: port_name - class (BaseServer), intent(inout) :: server + class (BaseServer), target, intent(inout) :: server integer, optional, intent(out) :: rc class (AbstractSocket), pointer :: sckt @@ -422,9 +422,9 @@ end subroutine connect_to_client ! But it would allow future implementation to query for servers ! or possibly to allow servers to satisfy multiple clients. subroutine publish(this, port, server, rc) - class (DirectoryService), intent(inout) :: this + class (DirectoryService), target,intent(inout) :: this type(PortInfo),target, intent(in) :: port - class (BaseServer), intent(inout) :: server + class (BaseServer), intent(in) :: server integer, optional, intent(out) :: rc character(len=MAX_LEN_PORT_NAME) :: port_name integer :: ierror diff --git a/pfio/MultiGroupServer.F90 b/pfio/MultiGroupServer.F90 index 9fe61430bb41..abbee7fd73dd 100644 --- a/pfio/MultiGroupServer.F90 +++ b/pfio/MultiGroupServer.F90 @@ -440,7 +440,7 @@ subroutine start_back(this, rc) integer, parameter :: stag = 6782 integer :: status - type (StringSet) :: FilesBeingWritten + type (StringSet), target :: FilesBeingWritten allocate(this%serverthread_done_msgs(1)) this%serverthread_done_msgs(:) = .false. @@ -625,10 +625,10 @@ subroutine start_back_writers(rc) integer, pointer :: g_4d(:,:,:,:), l_4d(:,:,:,:), g_5d(:,:,:,:,:), l_5d(:,:,:,:,:) integer :: d_rank, request_id integer(kind=INT64) :: msize_word, s0, e0, s1, e1, s2, e2, s3, e3, s4, e4, s5, e5 - type (StringAttributeMap) :: vars_map + type (StringAttributeMap), target :: vars_map type (StringAttributeMapIterator) :: var_iter - type (IntegerMessageMap) :: msg_map - type (IntegerMessageMapIterator) :: msg_iter + type (IntegerMessageMap), target :: msg_map + type (IntegerMessageMapIterator) :: msg_iter class (*), pointer :: x_ptr(:) integer , allocatable :: buffer_v(:) diff --git a/pfio/tests/pfio_ctest_io.F90 b/pfio/tests/pfio_ctest_io.F90 index ff00a0b4795c..df8da3c881eb 100644 --- a/pfio/tests/pfio_ctest_io.F90 +++ b/pfio/tests/pfio_ctest_io.F90 @@ -457,7 +457,7 @@ program main integer :: rank, npes, ierror, provided,required integer :: status, color, key - class(BaseServer),allocatable :: iserver,oserver + class(BaseServer), target, allocatable :: iserver,oserver class(AbstractDirectoryService), allocatable, target :: directory_service type (CommandLineOptions0) :: options