Skip to content

Commit 012462f

Browse files
committed
Towards setting restart mode as 'internal' info, rather than 'private'
1 parent d880b91 commit 012462f

File tree

4 files changed

+333
-65
lines changed

4 files changed

+333
-65
lines changed

field/FieldInfo.F90

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ module mapl3g_FieldInfo
1919
public :: FieldInfoSetShared
2020
public :: FieldInfoSetInternal
2121
public :: FieldInfoGetInternal
22-
public :: FieldInfoSetPrivate
23-
public :: FieldInfoGetPrivate
2422
public :: FieldInfoCopyShared
23+
public :: RestartModePlusAliasId
2524

2625
interface FieldInfoSetShared
2726
procedure info_field_set_shared_i4
@@ -41,14 +40,6 @@ module mapl3g_FieldInfo
4140
module procedure field_info_get_internal
4241
end interface FieldInfoGetInternal
4342

44-
interface FieldInfoSetPrivate
45-
module procedure field_info_set_private
46-
end interface FieldInfoSetPrivate
47-
48-
interface FieldInfoGetPrivate
49-
module procedure field_info_get_private
50-
end interface FieldInfoGetPrivate
51-
5243
interface FieldInfoCopyShared
5344
procedure :: field_info_copy_shared
5445
end interface FieldInfoCopyShared
@@ -68,6 +59,11 @@ module mapl3g_FieldInfo
6859
character(*), parameter :: KEY_SPEC_HANDLE = "/spec_handle"
6960
character(*), parameter :: KEY_RESTART_MODE = "/restart_mode"
7061

62+
type RestartModePlusAliasId
63+
integer(kind=kind(MAPL_RESTART_MODE)) :: restart_mode = MAPL_RESTART_REQUIRED
64+
integer :: alias_id = -1
65+
end type RestartModePlusAliasId
66+
7167
contains
7268

7369
subroutine field_info_set_internal(info, unusable, &
@@ -77,6 +73,7 @@ subroutine field_info_set_internal(info, unusable, &
7773
units, long_name, standard_name, &
7874
allocation_status, &
7975
spec_handle, &
76+
restart_mode_plus_alias_id, &
8077
rc)
8178
type(ESMF_Info), intent(inout) :: info
8279
class(KeywordEnforcer), optional, intent(in) :: unusable
@@ -89,11 +86,13 @@ subroutine field_info_set_internal(info, unusable, &
8986
character(*), optional, intent(in) :: standard_name
9087
type(StateItemAllocation), optional, intent(in) :: allocation_status
9188
integer, optional, intent(in) :: spec_handle(:)
89+
type(RestartModePlusAliasId), optional, intent(in) :: restart_mode_plus_alias_id
9290
integer, optional, intent(out) :: rc
9391

94-
integer :: status
9592
type(ESMF_Info) :: ungridded_info
96-
character(:), allocatable :: namespace_
93+
character(:), allocatable :: id_str, namespace_
94+
integer(kind=kind(MAPL_RESTART_MODE)) :: restart_mode
95+
integer :: alias_id, status
9796

9897
namespace_ = INFO_INTERNAL_NAMESPACE
9998
if (present(namespace)) then
@@ -151,6 +150,15 @@ subroutine field_info_set_internal(info, unusable, &
151150
call MAPL_InfoSet(info, namespace_ // KEY_SPEC_HANDLE, spec_handle, _RC)
152151
end if
153152

153+
if (present(restart_mode_plus_alias_id)) then
154+
alias_id = restart_mode_plus_alias_id%alias_id
155+
restart_mode = restart_mode_plus_alias_id%restart_mode
156+
_ASSERT(alias_id >= 0, "alias_id is not set")
157+
id_str = ESMF_UtilStringInt2String(alias_id, _RC)
158+
! NOTE: the 'x' is to keep ESMF_Info from getting confused
159+
call MAPL_InfoSet(info, namespace_ // "/x" // trim(id_str) // "/restart_mode", restart_mode, _RC)
160+
end if
161+
154162
_RETURN(_SUCCESS)
155163
_UNUSED_DUMMY(unusable)
156164
end subroutine field_info_set_internal
@@ -162,6 +170,7 @@ subroutine field_info_get_internal(info, unusable, &
162170
ungridded_dims, &
163171
allocation_status, &
164172
spec_handle, &
173+
restart_mode_plus_alias_id, &
165174
rc)
166175
type(ESMF_Info), intent(in) :: info
167176
class(KeywordEnforcer), optional, intent(in) :: unusable
@@ -175,15 +184,16 @@ subroutine field_info_get_internal(info, unusable, &
175184
type(UngriddedDims), optional, intent(out) :: ungridded_dims
176185
type(StateItemAllocation), optional, intent(out) :: allocation_status
177186
integer, optional, allocatable, intent(out) :: spec_handle(:)
187+
type(RestartModePlusAliasId), optional, intent(inout) :: restart_mode_plus_alias_id
178188
integer, optional, intent(out) :: rc
179189

180-
integer :: status
181-
integer :: num_levels_
182190
type(ESMF_Info) :: ungridded_info
183191
character(:), allocatable :: vert_staggerloc_str, allocation_status_str
184192
type(VerticalStaggerLoc) :: vert_staggerloc_
185-
character(:), allocatable :: namespace_
193+
character(:), allocatable :: namespace_, id_str, key
186194
logical :: key_is_present
195+
integer(kind=kind(MAPL_RESTART_MODE)) :: restart_mode
196+
integer :: status, num_levels_, alias_id
187197

188198
namespace_ = INFO_INTERNAL_NAMESPACE
189199
if (present(namespace)) then
@@ -243,59 +253,23 @@ subroutine field_info_get_internal(info, unusable, &
243253
call MAPL_InfoGet(info, namespace_ // KEY_SPEC_HANDLE, spec_handle, _RC)
244254
end if
245255

246-
_RETURN(_SUCCESS)
247-
_UNUSED_DUMMY(unusable)
248-
end subroutine field_info_get_internal
249-
250-
subroutine field_info_set_private(info, named_alias_id, unusable, restart_mode, rc)
251-
type(ESMF_Info), intent(inout) :: info
252-
integer, intent(in) :: named_alias_id
253-
class(KeywordEnforcer), optional, intent(in) :: unusable
254-
integer(kind=kind(MAPL_RESTART_MODE)), optional, intent(in) :: restart_mode
255-
integer, optional, intent(out) :: rc
256-
257-
integer :: status
258-
character(:), allocatable :: id_str, namespace
259-
260-
id_str = ESMF_UtilStringInt2String(named_alias_id, _RC)
261-
! NOTE: the 'x' is to keep ESMF_Info from getting confused
262-
namespace = INFO_PRIVATE_NAMESPACE // "/x" // trim(id_str)
263-
264-
if (present(restart_mode)) then
265-
call MAPL_InfoSet(info, namespace // KEY_RESTART_MODE, restart_mode, _RC)
266-
end if
267-
268-
_RETURN(_SUCCESS)
269-
_UNUSED_DUMMY(unusable)
270-
end subroutine field_info_set_private
271-
272-
subroutine field_info_get_private(info, named_alias_id, unusable, restart_mode, rc)
273-
type(ESMF_Info), intent(in) :: info
274-
integer, intent(in) :: named_alias_id
275-
class(KeywordEnforcer), optional, intent(in) :: unusable
276-
integer(kind=kind(MAPL_RESTART_MODE)), optional, intent(out) :: restart_mode
277-
integer, optional, intent(out) :: rc
278-
279-
integer :: status
280-
character(:), allocatable :: id_str, namespace, key
281-
logical :: key_is_present
282-
283-
id_str = ESMF_UtilStringInt2String(named_alias_id, _RC)
284-
! NOTE: the 'x' is to keep ESMF_Info from getting confused
285-
namespace = INFO_PRIVATE_NAMESPACE // "/x" // trim(id_str)
286-
287-
if (present(restart_mode)) then
288-
key = namespace // KEY_RESTART_MODE
256+
if (present(restart_mode_plus_alias_id)) then
257+
alias_id = restart_mode_plus_alias_id%alias_id
258+
_ASSERT(alias_id >= 0, "alias_id is not set")
259+
id_str = ESMF_UtilStringInt2String(alias_id, _RC)
260+
! NOTE: the 'x' is to keep ESMF_Info from getting confused
261+
key = namespace_ // "/x" // trim(id_str) // "/restart_mode"
289262
key_is_present = ESMF_InfoIsPresent(info, key=key, _RC)
290263
restart_mode = MAPL_RESTART_REQUIRED
291264
if (key_is_present) then
292265
call MAPL_InfoGet(info, key, restart_mode, _RC)
293266
end if
267+
restart_mode_plus_alias_id%restart_mode = restart_mode
294268
end if
295269

296270
_RETURN(_SUCCESS)
297271
_UNUSED_DUMMY(unusable)
298-
end subroutine field_info_get_private
272+
end subroutine field_info_get_internal
299273

300274
subroutine info_field_get_shared_i4(field, key, value, unusable, rc)
301275
type(ESMF_Field), intent(in) :: field

generic3g/RestartHandler.F90

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module mapl3g_RestartHandler
77
use mapl3g_Geom_API, only: MaplGeom
88
use mapl_ErrorHandling, only: MAPL_Verify, MAPL_Return, MAPL_Assert
99
use mapl3g_geomio, only: bundle_to_metadata, GeomPFIO, make_geom_pfio, get_mapl_geom
10-
use mapl3g_FieldInfo, only: FieldInfoGetPrivate
10+
use mapl3g_FieldInfo, only: FieldInfoGetInternal, RestartModePlusAliasId
1111
use mapl3g_RestartModes, only: MAPL_RESTART_MODE, MAPL_RESTART_SKIP
1212
use pFIO, only: PFIO_READ, FileMetaData, NetCDF4_FileFormatter
1313
use pFIO, only: i_Clients, o_Clients
@@ -155,8 +155,9 @@ function filter_fields_create_bundle_(this, state, rc) result(bundle)
155155
character(len=ESMF_MAXSTR), allocatable :: names(:)
156156
type (ESMF_StateItem_Flag), allocatable :: types(:)
157157
type(ESMF_Info) :: info
158-
integer :: named_alias_id
158+
integer :: alias_id
159159
integer(kind=kind(MAPL_RESTART_MODE)) :: restart_mode
160+
type(RestartModePlusAliasId) :: tmp
160161
integer :: idx, num_fields, status
161162

162163
call ESMF_StateGet(state, itemCount=num_fields, _RC)
@@ -171,8 +172,11 @@ function filter_fields_create_bundle_(this, state, rc) result(bundle)
171172
end if
172173
call ESMF_StateGet(state, names(idx), field, _RC)
173174
call ESMF_InfoGetFromHost(field, info, _RC)
174-
call ESMF_NamedAliasGet(field, id=named_alias_id, _RC)
175-
call FieldInfoGetPrivate(info, named_alias_id, restart_mode=restart_mode, _RC)
175+
call ESMF_NamedAliasGet(field, id=alias_id, _RC)
176+
tmp = RestartModePlusAliasId()
177+
tmp%alias_id = alias_id
178+
call FieldInfoGetInternal(info, restart_mode_plus_alias_id=tmp, _RC)
179+
restart_mode = tmp%restart_mode
176180
if (restart_mode==MAPL_RESTART_SKIP) cycle
177181
call ESMF_FieldBundleAdd(bundle, [field], _RC)
178182
end do

generic3g/specs/FieldClassAspect.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module mapl3g_FieldClassAspect
2424
use mapl3g_ESMF_Utilities, only: get_substate
2525

2626
use mapl3g_Field_API
27-
use mapl3g_FieldInfo, only: FieldInfoSetInternal, FieldInfoSetPrivate
27+
use mapl3g_FieldInfo, only: FieldInfoSetInternal, RestartModePlusAliasId
2828
use mapl3g_RestartModes, only: MAPL_RESTART_MODE
2929

3030
use mapl_FieldUtilities
@@ -428,7 +428,7 @@ subroutine add_to_state(this, multi_state, actual_pt, rc)
428428
if (allocated(this%restart_mode)) then
429429
call ESMF_NamedAliasGet(alias, id=alias_id, _RC)
430430
call ESMF_InfoGetFromHost(alias, info, _RC)
431-
call FieldInfoSetPrivate(info, alias_id, restart_mode=this%restart_mode, _RC)
431+
call FieldInfoSetInternal(info, restart_mode_plus_alias_id=RestartModePlusAliasId(this%restart_mode, alias_id), _RC)
432432
end if
433433

434434
_RETURN(_SUCCESS)

0 commit comments

Comments
 (0)