Skip to content

Commit

Permalink
Merge pull request #3003 from GEOS-ESM/mapl3/tclune/cleanup
Browse files Browse the repository at this point in the history
Various cleanup to reduce compiler warnings.  Reduced by about 250.
  • Loading branch information
tclune authored Sep 3, 2024
2 parents b00e498 + 3b5f941 commit 5d7bb69
Show file tree
Hide file tree
Showing 35 changed files with 193 additions and 190 deletions.
1 change: 0 additions & 1 deletion generic3g/ComponentSpecParser/parse_geometry_spec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module function parse_geometry_spec(mapl_cfg, rc) result(geometry_spec)
logical :: has_geometry_provider
character(:), allocatable :: geometry_kind_str
character(:), allocatable :: provider
integer :: geometry_kind
type(ESMF_HConfig) :: geometry_cfg
type(ESMF_HConfig) :: esmf_geom_cfg
type(ESMF_HConfig) :: vertical_grid_cfg
Expand Down
4 changes: 2 additions & 2 deletions generic3g/ComponentSpecParser/parse_var_specs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc)

short_name = name
typekind = to_typekind(attributes, _RC)
call val_to_float(default_value, attributes, 'default_value', _RC)
call val_to_float(default_value, attributes, KEY_DEFAULT_VALUE, _RC)
vertical_dim_spec = to_VerticalDimSpec(attributes,_RC)
ungridded_dims = to_UngriddedDims(attributes, _RC)

Expand Down Expand Up @@ -127,7 +127,7 @@ subroutine val_to_float(x, attributes, key, rc)
integer :: status
logical :: has_default_value

has_default_value = ESMF_HConfigIsDefined(attributes, keyString=KEY_DEFAULT_VALUE, _RC)
has_default_value = ESMF_HConfigIsDefined(attributes, keyString=key, _RC)
_RETURN_UNLESS(has_default_value)

allocate(x)
Expand Down
8 changes: 4 additions & 4 deletions generic3g/ESMF_HConfigUtilities/MAPL_HConfigMatch.F90
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ recursive logical function MAPL_HConfigMatchScalar(a, b, rc) result(match)
b_as_float = ESMF_HConfigAsR8(b, _RC)
match = (a_as_float == b_as_float)

case default
case (CORE_SCHEMA_STR_TAG)
! Otherwise they are strings ...
a_str = ESMF_HConfigAsString(a, _RC)
b_str = ESMF_HConfigAsString(b, _RC)
match = (a_str == b_str)


case default
_FAIL('unsupported yaml tag: <'//a_tag//'>')
end select

_RETURN(_SUCCESS)
Expand All @@ -139,7 +141,6 @@ recursive logical function MAPL_HConfigMatchSequence(a, b, rc) result(match)
integer, optional, intent(out) :: rc

integer :: status
type(ESMF_HConfig) :: a_val_hconfig, b_val_hconfig
integer :: i
integer :: a_size, b_size

Expand Down Expand Up @@ -173,7 +174,6 @@ recursive logical function MAPL_HConfigMatchMapping(a, b, rc) result(match)
integer, optional, intent(out) :: rc

integer :: status
type(ESMF_HConfig) :: a_val_hconfig, b_val_hconfig
character(:), allocatable :: key
type(ESMF_HConfigIter) :: iter, iter_begin, iter_end
integer :: a_size, b_size
Expand Down
83 changes: 51 additions & 32 deletions generic3g/MAPL_Generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module mapl3g_Generic
use :: esmf, only: ESMF_KIND_I4, ESMF_KIND_I8, ESMF_KIND_R4, ESMF_KIND_R8
use :: esmf, only: ESMF_StateItem_Flag, ESMF_STATEITEM_FIELD, ESMF_STATEITEM_FIELDBUNDLE
use :: esmf, only: ESMF_STATEITEM_STATE, ESMF_STATEITEM_UNKNOWN
use :: esmf, only: ESMF_KIND_R8, ESMF_KIND_R4, ESMF_NOKIND
use :: esmf, only: ESMF_TYPEKIND_R8, ESMF_TYPEKIND_R4, ESMF_NOKIND
use mapl3g_hconfig_get
use :: pflogger, only: logger_t => logger
use mapl_ErrorHandling
Expand Down Expand Up @@ -239,6 +241,7 @@ subroutine gridcomp_get(gridcomp, unusable, &
if (present(geom)) geom = outer_meta_%get_geom()

_RETURN(_SUCCESS)
_UNUSED_DUMMY(unusable)
end subroutine gridcomp_get

subroutine add_child_by_name(gridcomp, child_name, setservices, config, rc)
Expand Down Expand Up @@ -343,20 +346,18 @@ subroutine gridcomp_set_entry_point(gridcomp, method_flag, userProcedure, unusab

integer :: status
type(OuterMetaComponent), pointer :: outer_meta
type(GriddedComponentDriver), pointer :: user_gc_driver

call MAPL_GridCompGetOuterMeta(gridcomp, outer_meta, _RC)
user_gc_driver => outer_meta%get_user_gc_driver()
call outer_meta%set_entry_point(method_flag, userProcedure, phase_name=phase_name, _RC)

_RETURN(ESMF_SUCCESS)
_UNUSED_DUMMY(unusable)
end subroutine gridcomp_set_entry_point


subroutine add_spec_basic(gridcomp, var_spec, rc)
subroutine add_spec_basic(gridcomp, variable_spec, rc)
type(ESMF_GridComp), intent(inout) :: gridcomp
type(VariableSpec), intent(in) :: var_spec
type(VariableSpec), intent(in) :: variable_spec
integer, optional, intent(out) :: rc

integer :: status
Expand All @@ -365,7 +366,7 @@ subroutine add_spec_basic(gridcomp, var_spec, rc)

call MAPL_GridCompGetOuterMeta(gridcomp, outer_meta, _RC)
component_spec => outer_meta%get_component_spec()
call component_spec%var_specs%push_back(var_spec)
call component_spec%var_specs%push_back(variable_spec)

_RETURN(_SUCCESS)
end subroutine add_spec_basic
Expand All @@ -384,10 +385,17 @@ subroutine add_spec_explicit(gridcomp, state_intent, unusable, short_name, stand
integer :: status
type(VariableSpec) :: var_spec

!!$ var_spec = VariableSpec(...)
var_spec = VariableSpec( &
state_intent=state_intent, &
short_name=short_name, &
standard_name=standard_name, &
typekind=typekind, &
ungridded_dims=ungridded_dims, &
units=units)
call MAPL_AddSpec(gridcomp, var_spec, _RC)

_RETURN(_SUCCESS)
_UNUSED_DUMMY(unusable)
end subroutine add_spec_explicit


Expand Down Expand Up @@ -419,14 +427,22 @@ subroutine add_import_spec_legacy(gc, short_name, long_name, &

integer :: status
type(VariableSpec) :: var_spec
type(ESMF_TypeKind_Flag), allocatable :: typekind

!!$ var_spec = VariableSpec( &
!!$ state_intent=ESMF_STATEINTENT_IMPORT, &
!!$ short_name=short_name, &
!!$ typekind=to_typekind(precision), &
!!$ state_item=to_state_item(datatype), &
!!$ units=units, &
!!$ ungridded_dims=to_ungridded_dims(dims, vlocation, ungridded_dims, ungridded_coords) )
! Leave unallocated if precision is not PRESENT. Default (R4)
! is actually set inside VariableSpec constructor.
if (present(precision)) then
typekind = to_typekind(precision)
end if

var_spec = VariableSpec( &
state_intent=ESMF_STATEINTENT_IMPORT, &
short_name=short_name, &
typekind=typekind, &
itemtype=to_itemtype(datatype), &
units=units &
!# ungridded_dims=to_ungridded_dims(dims, vlocation, ungridded_dims, ungridded_coords), &
)

call MAPL_AddSpec(gc, var_spec, _RC)

Expand All @@ -440,14 +456,14 @@ function to_typekind(precision) result(tk)
tk = ESMF_TYPEKIND_R4 ! GEOS default
if (.not. present(precision)) return

!!$ select case (precision)
!!$ case (?? single)
!!$ tk = ESMF_TYPEKIND_R4
!!$ case (?? double)
!!$ tk = ESMF_TYPEKIND_R8
!!$ case default
!!$ tk = ESMF_NOKIND
!!$ end select
select case (precision)
case (ESMF_KIND_R4)
tk = ESMF_TYPEKIND_R4
case (ESMF_KIND_R8)
tk = ESMF_TYPEKIND_R8
case default
tk = ESMF_NOKIND
end select

end function to_typekind

Expand All @@ -471,24 +487,24 @@ function to_ungridded_dims(dims, vlocation, legacy_ungridded_dims, ungridded_coo

end function to_ungridded_dims

function to_state_item(datatype) result(state_item)
type(ESMF_StateItem_Flag) :: state_item
function to_itemtype(datatype) result(itemtype)
type(ESMF_StateItem_Flag) :: itemtype
integer, optional, intent(in) :: datatype

state_item = ESMF_STATEITEM_FIELD ! GEOS default
itemtype = ESMF_STATEITEM_FIELD ! GEOS default
if (.not. present(datatype)) return

select case (datatype)
case (MAPL_FieldItem)
state_item = ESMF_STATEITEM_FIELD
itemtype = ESMF_STATEITEM_FIELD
case (MAPL_BundleItem)
state_item = ESMF_STATEITEM_FIELDBUNDLE
itemtype = ESMF_STATEITEM_FIELDBUNDLE
case (MAPL_StateItem)
state_item = ESMF_STATEITEM_STATE
itemtype = ESMF_STATEITEM_STATE
case default
state_item = ESMF_STATEITEM_UNKNOWN
itemtype = ESMF_STATEITEM_UNKNOWN
end select
end function to_state_item
end function to_itemtype


subroutine add_export_spec(gridcomp, unusable, short_name, standard_name, units, rc)
Expand Down Expand Up @@ -525,10 +541,14 @@ subroutine add_internal_spec(gridcomp, unusable, short_name, standard_name, unit

call MAPL_GridCompGetOuterMeta(gridcomp, outer_meta, _RC)
component_spec => outer_meta%get_component_spec()
call component_spec%var_specs%push_back(VariableSpec(ESMF_STATEINTENT_INTERNAL, &
short_name=short_name, standard_name=standard_name))
call component_spec%var_specs%push_back(VariableSpec( &
ESMF_STATEINTENT_INTERNAL, &
short_name=short_name, &
standard_name=standard_name, &
units=units))

_RETURN(ESMF_SUCCESS)
_UNUSED_DUMMY(unusable)
end subroutine add_internal_spec

subroutine MAPL_GridCompSetVerticalGrid(gridcomp, vertical_grid, rc)
Expand Down Expand Up @@ -923,7 +943,6 @@ logical function gridcomp_is_user(gridcomp, rc)

integer :: status
type(ESMF_Info) :: info
logical :: found

gridcomp_is_user = .not. MAPL_GridCompIsGeneric(gridcomp, _RC)

Expand Down
11 changes: 6 additions & 5 deletions generic3g/MultiState.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function newMultiState_user(unusable, importState, exportState, internalState) r
multi_state%exportState = get_state('export', exportState)
multi_state%internalState = get_state('internal', internalState)

_UNUSED_DUMMY(unusable)
contains

function get_state(name, state) result(new_state)
Expand All @@ -57,7 +58,7 @@ function get_state(name, state) result(new_state)
new_state = ESMF_StateCreate(name=name)

end function get_state

end function newMultiState_user


Expand Down Expand Up @@ -117,15 +118,15 @@ subroutine write_multistate(this, unit, iotype, v_list, iostat, iomsg)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg

type(ESMF_State) :: state
integer :: status
character(ESMF_MAXSTR) :: name
integer :: itemCount

#ifndef __GFORTRAN__
write(unit,*, iostat=iostat, iomsg=iomsg) 'IMPORT:', this%importState
write(unit,*, iostat=iostat, iomsg=iomsg) 'EXPORT:', this%exportState
#endif

_UNUSED_DUMMY(iotype)
_UNUSED_DUMMY(v_list)
end subroutine write_multistate

subroutine destroy(this, rc)
Expand All @@ -137,8 +138,8 @@ subroutine destroy(this, rc)
call ESMF_StateDestroy(this%importState, _RC)
call ESMF_StateDestroy(this%exportState, _RC)
call ESMF_StateDestroy(this%internalState, _RC)
_RETURN(_SUCCESS)

_RETURN(_SUCCESS)
end subroutine destroy

end module mapl3g_MultiState
7 changes: 1 addition & 6 deletions generic3g/OuterMetaComponent.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module mapl3g_OuterMetaComponent
use mapl3g_VariableSpecVector
use mapl3g_ComponentSpec
use mapl3g_GenericPhases
use mapl3g_Validation, only: is_valid_name
use mapl3g_InnerMetaComponent
use mapl3g_MethodPhasesMap
use mapl3g_StateItemSpec
Expand All @@ -21,24 +20,20 @@ module mapl3g_OuterMetaComponent
use mapl3g_ActualPtVector
use mapl3g_ConnectionVector
use mapl3g_StateRegistry
use mapl3g_ESMF_Interfaces, only: I_Run, MAPL_UserCompGetInternalState, MAPL_UserCompSetInternalState
use mapl3g_ESMF_Interfaces, only: I_Run
use mapl3g_ComponentDriver
use mapl3g_GriddedComponentDriver
use mapl3g_ComponentDriverVector
use mapl3g_GriddedComponentDriverMap, only: GriddedComponentDriverMap
use mapl3g_GriddedComponentDriverMap, only: GriddedComponentDriverMapIterator
use mapl3g_GriddedComponentDriverMap, only: operator(/=)
use mapl3g_ActualPtComponentDriverMap
use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE
use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_UPDATE
use mapl_ErrorHandling
use mapl3g_VerticalGrid
use mapl3g_GeometrySpec
use gFTL2_StringVector
use mapl_keywordEnforcer, only: KE => KeywordEnforcer
use esmf
use pflogger, only: logging, Logger
use mapl3g_RestartHandler, only: RestartHandler

implicit none
private
Expand Down
1 change: 1 addition & 0 deletions generic3g/OuterMetaComponent/SetServices.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use mapl3g_ChildSpecMap
use mapl3g_GenericGridComp
use mapl3g_BasicVerticalGrid
use mapl3g_GriddedComponentDriverMap
implicit none

contains
Expand Down
2 changes: 1 addition & 1 deletion generic3g/OuterMetaComponent/add_child_by_name.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use mapl3g_ChildSpec
use mapl3g_ChildSpecMap
use mapl3g_GenericGridComp
use mapl3g_Validation
implicit none

contains

module recursive subroutine add_child_by_name(this, child_name, setservices, hconfig, rc)
use mapl3g_GenericGridComp, only: generic_setservices => setservices
class(OuterMetaComponent), target, intent(inout) :: this
character(len=*), intent(in) :: child_name
class(AbstractUserSetServices), intent(in) :: setservices
Expand Down
1 change: 1 addition & 0 deletions generic3g/OuterMetaComponent/apply_to_children_custom.F90
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_OuterMetaComponent) apply_to_children_custom_smod
use mapl3g_GriddedComponentDriverMap
implicit none

contains
Expand Down
3 changes: 2 additions & 1 deletion generic3g/OuterMetaComponent/attach_outer_meta.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "MAPL_Generic.h"

submodule (mapl3g_OuterMetaComponent) attach_outer_meta_smod
implicit none
use mapl3g_ESMF_Interfaces, only: MAPL_UserCompSetInternalState
implicit none (type, external)

contains

Expand Down
9 changes: 7 additions & 2 deletions generic3g/OuterMetaComponent/finalize.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "MAPL_Generic.h"

submodule (mapl3g_OuterMetaComponent) finalize_smod
implicit none
use mapl3g_GriddedComponentDriverMap
implicit none (type, external)

contains

Expand All @@ -16,7 +17,7 @@ module recursive subroutine finalize(this, importState, exportState, clock, unus

type(GriddedComponentDriver), pointer :: child
type(GriddedComponentDriverMapIterator) :: iter
integer :: status, userRC
integer :: status
character(*), parameter :: PHASE_NAME = 'GENERIC::FINALIZE_USER'
type(StringVector), pointer :: finalize_phases
logical :: found
Expand Down Expand Up @@ -44,6 +45,10 @@ module recursive subroutine finalize(this, importState, exportState, clock, unus
end associate

_RETURN(ESMF_SUCCESS)
_UNUSED_DUMMY(importState)
_UNUSED_DUMMY(exportState)
_UNUSED_DUMMY(clock)
_UNUSED_DUMMY(unusable)
end subroutine finalize

end submodule finalize_smod
3 changes: 2 additions & 1 deletion generic3g/OuterMetaComponent/free_outer_meta.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "MAPL_Generic.h"

submodule (mapl3g_OuterMetaComponent) free_outer_meta_smod
implicit none
use mapl3g_ESMF_Interfaces, only: MAPL_UserCompGetInternalState
implicit none (type, external)

contains

Expand Down
Loading

0 comments on commit 5d7bb69

Please sign in to comment.