Skip to content

Commit

Permalink
Merge branch 'esmf-org:develop' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
WeirAE authored Sep 4, 2024
2 parents 78b8f7e + 82ba326 commit cada4b4
Show file tree
Hide file tree
Showing 39 changed files with 1,050 additions and 278 deletions.
13 changes: 2 additions & 11 deletions src/Infrastructure/Array/include/ESMCI_Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,6 @@ namespace ESMCI {
// entry of 0 indicates replicated dim
// distr. Array dims as 1, 2, 3, .. only
int *contiguousFlag; // [ssiLocalDeCount]
int *exclusiveElementCountPDe; // [deCount] number of elements in
// exclusive region only considering
// DistGrid dims that are associated with
// the Array dims.
// Multiply with tensorElementCount to get
// total number of elements in exclusive
// Array region.
int *totalElementCountPLocalDe; // [ssiLocalDeCount] number of elements in
// total region only considering
// DistGrid dims that are associated with
Expand Down Expand Up @@ -272,7 +265,6 @@ namespace ESMCI {
distgridToPackedArrayMap = NULL;
contiguousFlag = NULL;
tensorElementCount = 0;
exclusiveElementCountPDe = NULL;
totalElementCountPLocalDe = NULL;
sizeSuperUndist = NULL;
sizeDist = NULL;
Expand Down Expand Up @@ -311,7 +303,6 @@ namespace ESMCI {
distgridToPackedArrayMap = NULL;
contiguousFlag = NULL;
tensorElementCount = 0;
exclusiveElementCountPDe = NULL;
totalElementCountPLocalDe = NULL;
sizeSuperUndist = NULL;
sizeDist = NULL;
Expand Down Expand Up @@ -392,8 +383,6 @@ namespace ESMCI {
int getReplicatedDimCount() const {return replicatedDimCount;}
const int *getUndistLBound() const {return undistLBound;}
const int *getUndistUBound() const {return undistUBound;}
const int *getExclusiveElementCountPDe()const
{return exclusiveElementCountPDe;}
const int *getTotalElementCountPLocalDe()const
{return totalElementCountPLocalDe;}
int getTensorElementCount() const {return tensorElementCount;}
Expand Down Expand Up @@ -439,6 +428,8 @@ namespace ESMCI {
const std::string &convention, const std::string &purpose,
bool *overwrite, ESMC_FileStatus_Flag *status,
int *timeslice, ESMC_IOFmt_Flag *iofmt);
void log(std::string prefix,
ESMC_LogMsgType_Flag msgType=ESMC_LOGMSG_INFO, bool deepFlag=false)const;
int print() const;
int sync();
int validate() const;
Expand Down
30 changes: 30 additions & 0 deletions src/Infrastructure/Array/interface/ESMCI_Array_F.C
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,36 @@ extern "C" {
ESMC_NOT_PRESENT_FILTER(rc));
}

void FTN_X(c_esmc_arraylog)(ESMCI::Array **array,
char *prefix, ESMC_LogMsgType_Flag *logMsgFlag, ESMC_Logical *deep, int *rc,
ESMCI_FortranStrLenArg prefix_l){
#undef ESMC_METHOD
#define ESMC_METHOD "c_esmc_arraylog()"
if (rc!=NULL) *rc = ESMC_RC_NOT_IMPL;
// convert to bool
bool deepFlag = false; // default
if (ESMC_NOT_PRESENT_FILTER(deep) != ESMC_NULL_POINTER)
if (*deep == ESMF_TRUE) deepFlag = true;
try{
std::string prefixStr(prefix, prefix_l);
(*array)->log(prefixStr, *logMsgFlag, deepFlag);
}catch(int localrc){
if (ESMC_LogDefault.MsgFoundError(localrc, ESMCI_ERR_PASSTHRU,
ESMC_CONTEXT, rc))
return; // bail out
}catch(std::exception &x){
ESMC_LogDefault.MsgFoundError(ESMC_RC_INTNRL_BAD, x.what(), ESMC_CONTEXT,
rc);
return; // bail out
}catch(...){
ESMC_LogDefault.MsgFoundError(ESMC_RC_INTNRL_BAD, "- Caught exception",
ESMC_CONTEXT, rc);
return;
}
// return successfully
if (rc!=NULL) *rc = ESMF_SUCCESS;
}

void FTN_X(c_esmc_arrayprint)(ESMCI::Array **ptr, int *rc){
#undef ESMC_METHOD
#define ESMC_METHOD "c_esmc_arrayprint()"
Expand Down
1 change: 1 addition & 0 deletions src/Infrastructure/Array/interface/ESMF_Array.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module ESMF_ArrayMod
public ESMF_ArrayHaloRelease ! implemented in ESMF_ArrayHaMod
public ESMF_ArrayHaloStore ! implemented in ESMF_ArrayHaMod
public ESMF_ArrayIsCreated ! implemented in ESMF_ArrayHaMod
public ESMF_ArrayLog ! implemented in ESMF_ArrayHaMod
public ESMF_ArrayPrint ! implemented in ESMF_ArrayHaMod
public ESMF_ArrayRead ! implemented in ESMF_ArrayHaMod
public ESMF_ArrayRedist ! implemented in ESMF_ArrayHaMod
Expand Down
71 changes: 71 additions & 0 deletions src/Infrastructure/Array/interface/ESMF_ArrayHa.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module ESMF_ArrayHaMod
public ESMF_ArrayHaloRelease
public ESMF_ArrayHaloStore
public ESMF_ArrayIsCreated
public ESMF_ArrayLog
public ESMF_ArrayPrint
public ESMF_ArrayRead
public ESMF_ArrayRedist
Expand Down Expand Up @@ -557,6 +558,76 @@ function ESMF_ArrayIsCreated(array, keywordEnforcer, rc)
!------------------------------------------------------------------------------


! -------------------------- ESMF-public method -----------------------------
#undef ESMF_METHOD
#define ESMF_METHOD "ESMF_ArrayLog()"
!BOP
! !IROUTINE: ESMF_ArrayLog - Log Array information

! !INTERFACE:
subroutine ESMF_ArrayLog(array, keywordEnforcer, prefix, logMsgFlag, deepFlag, rc)
!
! !ARGUMENTS:
type(ESMF_Array), intent(in) :: array
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
character(len=*), intent(in), optional :: prefix
type(ESMF_LogMsg_Flag), intent(in), optional :: logMsgFlag
logical, intent(in), optional :: deepFlag
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Write information about {\tt array} to the ESMF default Log.
!
! The arguments are:
! \begin{description}
! \item[array]
! The {\tt ESMF\_Array} object logged.
! \item [{[prefix]}]
! String to prefix the log message. Default is no prefix.
! \item [{[logMsgFlag]}]
! Type of log message generated. See section \ref{const:logmsgflag} for
! a list of valid message types. Default is {\tt ESMF\_LOGMSG\_INFO}.
! \item[{[deepFlag]}]
! When set to {\tt .false.} (default), only log top level information about
! the Array.
! When set to {\tt .true.}, additionally log deep information.
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
!------------------------------------------------------------------------------
integer :: localrc ! local return code
type(ESMF_LogMsg_Flag) :: logMsg
type(ESMF_Logical) :: deep

! initialize return code; assume routine not implemented
localrc = ESMF_RC_NOT_IMPL
if (present(rc)) rc = ESMF_RC_NOT_IMPL

! Check init status of arguments
ESMF_INIT_CHECK_DEEP(ESMF_ArrayGetInit, array, rc)

! deal with optional logMsgFlag
logMsg = ESMF_LOGMSG_INFO ! default
if (present(logMsgFlag)) logMsg = logMsgFlag

! deal with optional deepFlag
deep = ESMF_FALSE ! default
if (present(deepFlag)) deep = deepFlag

! Call into the C++ interface.
call c_esmc_arraylog(array, prefix, logMsg, deep, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! return successfully
if (present(rc)) rc = ESMF_SUCCESS

end subroutine ESMF_ArrayLog
!------------------------------------------------------------------------------


! -------------------------- ESMF-public method -------------------------------
#undef ESMF_METHOD
#define ESMF_METHOD "ESMF_ArrayPrint()"
Expand Down
Loading

0 comments on commit cada4b4

Please sign in to comment.