Skip to content

Commit 7b36ed9

Browse files
committed
Merge branch 'nrl/work-esmx' into develop
2 parents 75cee0a + 6127c62 commit 7b36ed9

30 files changed

+890
-163
lines changed

src/Infrastructure/Array/include/ESMCI_Array.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ namespace ESMCI {
439439
const std::string &convention, const std::string &purpose,
440440
bool *overwrite, ESMC_FileStatus_Flag *status,
441441
int *timeslice, ESMC_IOFmt_Flag *iofmt);
442+
void log(std::string prefix,
443+
ESMC_LogMsgType_Flag msgType=ESMC_LOGMSG_INFO, bool deepFlag=false)const;
442444
int print() const;
443445
int sync();
444446
int validate() const;

src/Infrastructure/Array/interface/ESMCI_Array_F.C

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,36 @@ extern "C" {
839839
ESMC_NOT_PRESENT_FILTER(rc));
840840
}
841841

842+
void FTN_X(c_esmc_arraylog)(ESMCI::Array **array,
843+
char *prefix, ESMC_LogMsgType_Flag *logMsgFlag, ESMC_Logical *deep, int *rc,
844+
ESMCI_FortranStrLenArg prefix_l){
845+
#undef ESMC_METHOD
846+
#define ESMC_METHOD "c_esmc_arraylog()"
847+
if (rc!=NULL) *rc = ESMC_RC_NOT_IMPL;
848+
// convert to bool
849+
bool deepFlag = false; // default
850+
if (ESMC_NOT_PRESENT_FILTER(deep) != ESMC_NULL_POINTER)
851+
if (*deep == ESMF_TRUE) deepFlag = true;
852+
try{
853+
std::string prefixStr(prefix, prefix_l);
854+
(*array)->log(prefixStr, *logMsgFlag, deepFlag);
855+
}catch(int localrc){
856+
if (ESMC_LogDefault.MsgFoundError(localrc, ESMCI_ERR_PASSTHRU,
857+
ESMC_CONTEXT, rc))
858+
return; // bail out
859+
}catch(std::exception &x){
860+
ESMC_LogDefault.MsgFoundError(ESMC_RC_INTNRL_BAD, x.what(), ESMC_CONTEXT,
861+
rc);
862+
return; // bail out
863+
}catch(...){
864+
ESMC_LogDefault.MsgFoundError(ESMC_RC_INTNRL_BAD, "- Caught exception",
865+
ESMC_CONTEXT, rc);
866+
return;
867+
}
868+
// return successfully
869+
if (rc!=NULL) *rc = ESMF_SUCCESS;
870+
}
871+
842872
void FTN_X(c_esmc_arrayprint)(ESMCI::Array **ptr, int *rc){
843873
#undef ESMC_METHOD
844874
#define ESMC_METHOD "c_esmc_arrayprint()"

src/Infrastructure/Array/interface/ESMF_Array.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module ESMF_ArrayMod
8585
public ESMF_ArrayHaloRelease ! implemented in ESMF_ArrayHaMod
8686
public ESMF_ArrayHaloStore ! implemented in ESMF_ArrayHaMod
8787
public ESMF_ArrayIsCreated ! implemented in ESMF_ArrayHaMod
88+
public ESMF_ArrayLog ! implemented in ESMF_ArrayHaMod
8889
public ESMF_ArrayPrint ! implemented in ESMF_ArrayHaMod
8990
public ESMF_ArrayRead ! implemented in ESMF_ArrayHaMod
9091
public ESMF_ArrayRedist ! implemented in ESMF_ArrayHaMod

src/Infrastructure/Array/interface/ESMF_ArrayHa.F90

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module ESMF_ArrayHaMod
6868
public ESMF_ArrayHaloRelease
6969
public ESMF_ArrayHaloStore
7070
public ESMF_ArrayIsCreated
71+
public ESMF_ArrayLog
7172
public ESMF_ArrayPrint
7273
public ESMF_ArrayRead
7374
public ESMF_ArrayRedist
@@ -557,6 +558,76 @@ function ESMF_ArrayIsCreated(array, keywordEnforcer, rc)
557558
!------------------------------------------------------------------------------
558559

559560

561+
! -------------------------- ESMF-public method -----------------------------
562+
#undef ESMF_METHOD
563+
#define ESMF_METHOD "ESMF_ArrayLog()"
564+
!BOP
565+
! !IROUTINE: ESMF_ArrayLog - Log Array information
566+
567+
! !INTERFACE:
568+
subroutine ESMF_ArrayLog(array, keywordEnforcer, prefix, logMsgFlag, deepFlag, rc)
569+
!
570+
! !ARGUMENTS:
571+
type(ESMF_Array), intent(in) :: array
572+
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
573+
character(len=*), intent(in), optional :: prefix
574+
type(ESMF_LogMsg_Flag), intent(in), optional :: logMsgFlag
575+
logical, intent(in), optional :: deepFlag
576+
integer, intent(out), optional :: rc
577+
!
578+
! !DESCRIPTION:
579+
! Write information about {\tt array} to the ESMF default Log.
580+
!
581+
! The arguments are:
582+
! \begin{description}
583+
! \item[array]
584+
! The {\tt ESMF\_Array} object logged.
585+
! \item [{[prefix]}]
586+
! String to prefix the log message. Default is no prefix.
587+
! \item [{[logMsgFlag]}]
588+
! Type of log message generated. See section \ref{const:logmsgflag} for
589+
! a list of valid message types. Default is {\tt ESMF\_LOGMSG\_INFO}.
590+
! \item[{[deepFlag]}]
591+
! When set to {\tt .false.} (default), only log top level information about
592+
! the Array.
593+
! When set to {\tt .true.}, additionally log deep information.
594+
! \item[{[rc]}]
595+
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
596+
! \end{description}
597+
!
598+
!EOP
599+
!------------------------------------------------------------------------------
600+
integer :: localrc ! local return code
601+
type(ESMF_LogMsg_Flag) :: logMsg
602+
type(ESMF_Logical) :: deep
603+
604+
! initialize return code; assume routine not implemented
605+
localrc = ESMF_RC_NOT_IMPL
606+
if (present(rc)) rc = ESMF_RC_NOT_IMPL
607+
608+
! Check init status of arguments
609+
ESMF_INIT_CHECK_DEEP(ESMF_ArrayGetInit, array, rc)
610+
611+
! deal with optional logMsgFlag
612+
logMsg = ESMF_LOGMSG_INFO ! default
613+
if (present(logMsgFlag)) logMsg = logMsgFlag
614+
615+
! deal with optional deepFlag
616+
deep = ESMF_FALSE ! default
617+
if (present(deepFlag)) deep = deepFlag
618+
619+
! Call into the C++ interface.
620+
call c_esmc_arraylog(array, prefix, logMsg, deep, localrc)
621+
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
622+
ESMF_CONTEXT, rcToReturn=rc)) return
623+
624+
! return successfully
625+
if (present(rc)) rc = ESMF_SUCCESS
626+
627+
end subroutine ESMF_ArrayLog
628+
!------------------------------------------------------------------------------
629+
630+
560631
! -------------------------- ESMF-public method -------------------------------
561632
#undef ESMF_METHOD
562633
#define ESMF_METHOD "ESMF_ArrayPrint()"

src/Infrastructure/Array/src/ESMCI_Array.C

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,6 +4154,47 @@ int Array::write(
41544154
}
41554155
//-----------------------------------------------------------------------------
41564156

4157+
//-----------------------------------------------------------------------------
4158+
#undef ESMC_METHOD
4159+
#define ESMC_METHOD "ESMCI::Array::log()"
4160+
//BOPI
4161+
// !IROUTINE: ESMCI::Array::log
4162+
//
4163+
// !INTERFACE:
4164+
void Array::log(
4165+
//
4166+
// !DESCRIPTION:
4167+
// Log details of Array object
4168+
//
4169+
// !ARGUMENTS:
4170+
//
4171+
std::string prefix,
4172+
ESMC_LogMsgType_Flag msgType,
4173+
bool deepFlag
4174+
)const{
4175+
//
4176+
//EOPI
4177+
//-----------------------------------------------------------------------------
4178+
std::stringstream msg;
4179+
msg << prefix << "--- Array::log() start -----------------------------------";
4180+
ESMC_LogDefault.Write(msg.str(), msgType);
4181+
4182+
if (ESMC_BaseGetStatus()!=ESMF_STATUS_READY){
4183+
msg.str(""); // clear
4184+
msg << prefix << "Array object is invalid! Not created or deleted!";
4185+
ESMC_LogDefault.Write(msg.str(), msgType);
4186+
}else{
4187+
msg.str(""); // clear
4188+
msg << prefix << " <name: " << getName() << ">";
4189+
ESMC_LogDefault.Write(msg.str(), msgType);
4190+
if (deepFlag) getDistGrid()->log(prefix+"! ", msgType, deepFlag);
4191+
}
4192+
msg.str(""); // clear
4193+
msg << prefix << "--- Array::log() end -------------------------------------";
4194+
ESMC_LogDefault.Write(msg.str(), msgType);
4195+
}
4196+
//-----------------------------------------------------------------------------
4197+
41574198
//-----------------------------------------------------------------------------
41584199
#undef ESMC_METHOD
41594200
#define ESMC_METHOD "ESMCI::Array::print()"

src/Infrastructure/ArrayBundle/include/ESMCI_ArrayBundle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class ArrayBundle : public ESMC_Base { // inherits from ESMC_Base class
121121
bool *overwrite, ESMC_FileStatus_Flag *status,
122122
int *timeslice, ESMC_IOFmt_Flag *iofmt);
123123
// misc.
124+
void log(std::string prefix,
125+
ESMC_LogMsgType_Flag msgType=ESMC_LOGMSG_INFO, bool deepFlag=false)const;
124126
int print() const;
125127
// serialize() and deserialize()
126128
int serialize(char *buffer,int *length,int *offset,

src/Infrastructure/ArrayBundle/interface/ESMCI_ArrayBundle_F.C

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,36 @@ extern "C" {
381381
ESMC_NOT_PRESENT_FILTER(rc));
382382
}
383383

384+
void FTN_X(c_esmc_arraybundlelog)(ESMCI::ArrayBundle **arraybundle,
385+
char *prefix, ESMC_LogMsgType_Flag *logMsgFlag, ESMC_Logical *deep,
386+
int *rc, ESMCI_FortranStrLenArg prefix_l){
387+
#undef ESMC_METHOD
388+
#define ESMC_METHOD "c_esmc_arraybundlelog()"
389+
if (rc!=NULL) *rc = ESMC_RC_NOT_IMPL;
390+
// convert to bool
391+
bool deepFlag = false; // default
392+
if (ESMC_NOT_PRESENT_FILTER(deep) != ESMC_NULL_POINTER)
393+
if (*deep == ESMF_TRUE) deepFlag = true;
394+
try{
395+
std::string prefixStr(prefix, prefix_l);
396+
(*arraybundle)->log(prefixStr, *logMsgFlag, deepFlag);
397+
}catch(int localrc){
398+
if (ESMC_LogDefault.MsgFoundError(localrc, ESMCI_ERR_PASSTHRU,
399+
ESMC_CONTEXT, rc))
400+
return; // bail out
401+
}catch(std::exception &x){
402+
ESMC_LogDefault.MsgFoundError(ESMC_RC_INTNRL_BAD, x.what(), ESMC_CONTEXT,
403+
rc);
404+
return; // bail out
405+
}catch(...){
406+
ESMC_LogDefault.MsgFoundError(ESMC_RC_INTNRL_BAD, "- Caught exception",
407+
ESMC_CONTEXT, rc);
408+
return;
409+
}
410+
// return successfully
411+
if (rc!=NULL) *rc = ESMF_SUCCESS;
412+
}
413+
384414
void FTN_X(c_esmc_arraybundleprint)(ESMCI::ArrayBundle **ptr, int *rc){
385415
#undef ESMC_METHOD
386416
#define ESMC_METHOD "c_esmc_arraybundleprint()"

src/Infrastructure/ArrayBundle/interface/ESMF_ArrayBundle.F90

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module ESMF_ArrayBundleMod
8989
public ESMF_ArrayBundleHaloRelease
9090
public ESMF_ArrayBundleHaloStore
9191
public ESMF_ArrayBundleIsCreated
92+
public ESMF_ArrayBundleLog
9293
public ESMF_ArrayBundlePrint
9394
public ESMF_ArrayBundleRead
9495
public ESMF_ArrayBundleRedist
@@ -1587,6 +1588,75 @@ function ESMF_ArrayBundleIsCreated(arraybundle, keywordEnforcer, rc)
15871588
!------------------------------------------------------------------------------
15881589

15891590

1591+
! -------------------------- ESMF-public method -----------------------------
1592+
#undef ESMF_METHOD
1593+
#define ESMF_METHOD "ESMF_ArrayBundleLog()"
1594+
!BOP
1595+
! !IROUTINE: ESMF_ArrayBundleLog - Log ArrayBundle information
1596+
1597+
! !INTERFACE:
1598+
subroutine ESMF_ArrayBundleLog(arraybundle, keywordEnforcer, prefix, logMsgFlag, deepFlag, rc)
1599+
!
1600+
! !ARGUMENTS:
1601+
type(ESMF_ArrayBundle), intent(in) :: arraybundle
1602+
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
1603+
character(len=*), intent(in), optional :: prefix
1604+
type(ESMF_LogMsg_Flag), intent(in), optional :: logMsgFlag
1605+
logical, intent(in), optional :: deepFlag
1606+
integer, intent(out), optional :: rc
1607+
!
1608+
! !DESCRIPTION:
1609+
! Write information about {\tt arraybundle} to the ESMF default Log.
1610+
!
1611+
! The arguments are:
1612+
! \begin{description}
1613+
! \item[arraybundle]
1614+
! {\tt ESMF\_ArrayBundle} object logged.
1615+
! \item [{[prefix]}]
1616+
! String to prefix the log message. Default is no prefix.
1617+
! \item [{[logMsgFlag]}]
1618+
! Type of log message generated. See section \ref{const:logmsgflag} for
1619+
! a list of valid message types. Default is {\tt ESMF\_LOGMSG\_INFO}.
1620+
! \item[{[deepFlag]}]
1621+
! When set to {\tt .false.} (default), only log top level information for
1622+
! each item contained in the ArrayBundle.
1623+
! When set to {\tt .true.}, additionally log information for each item.
1624+
! \item[{[rc]}]
1625+
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
1626+
! \end{description}
1627+
!
1628+
!EOP
1629+
!------------------------------------------------------------------------------
1630+
integer :: localrc ! local return code
1631+
type(ESMF_LogMsg_Flag) :: logMsg
1632+
type(ESMF_Logical) :: deep
1633+
1634+
! initialize return code; assume routine not implemented
1635+
localrc = ESMF_RC_NOT_IMPL
1636+
if (present(rc)) rc = ESMF_RC_NOT_IMPL
1637+
1638+
! Check init status of arguments
1639+
ESMF_INIT_CHECK_DEEP_SHORT(ESMF_ArrayBundleGetInit, arraybundle, rc)
1640+
1641+
! deal with optional logMsgFlag
1642+
logMsg = ESMF_LOGMSG_INFO ! default
1643+
if (present(logMsgFlag)) logMsg = logMsgFlag
1644+
1645+
! deal with optional deepFlag
1646+
deep = ESMF_FALSE ! default
1647+
if (present(deepFlag)) deep = deepFlag
1648+
1649+
! Call into the C++ interface.
1650+
call c_esmc_arraybundlelog(arraybundle, prefix, logMsg, deep, localrc)
1651+
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
1652+
ESMF_CONTEXT, rcToReturn=rc)) return
1653+
1654+
! return successfully
1655+
if (present(rc)) rc = ESMF_SUCCESS
1656+
1657+
end subroutine ESMF_ArrayBundleLog
1658+
!------------------------------------------------------------------------------
1659+
15901660

15911661
! -------------------------- ESMF-public method -------------------------------
15921662
#undef ESMF_METHOD

src/Infrastructure/ArrayBundle/src/ESMCI_ArrayBundle.C

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,57 @@ int ArrayBundle::write(
536536
//
537537
//-----------------------------------------------------------------------------
538538

539+
//-----------------------------------------------------------------------------
540+
#undef ESMC_METHOD
541+
#define ESMC_METHOD "ESMCI::ArrayBundle::log()"
542+
//BOPI
543+
// !IROUTINE: ESMCI::ArrayBundle::log
544+
//
545+
// !INTERFACE:
546+
void ArrayBundle::log(
547+
//
548+
// !DESCRIPTION:
549+
// Log details of ArrayBundle object
550+
//
551+
// !ARGUMENTS:
552+
//
553+
std::string prefix,
554+
ESMC_LogMsgType_Flag msgType,
555+
bool deepFlag
556+
)const{
557+
//
558+
//EOPI
559+
//-----------------------------------------------------------------------------
560+
std::stringstream msg;
561+
msg << prefix << "--- ArrayBundle::log() start -----------------------------";
562+
ESMC_LogDefault.Write(msg.str(), msgType);
563+
564+
if (ESMC_BaseGetStatus()!=ESMF_STATUS_READY){
565+
msg.str(""); // clear
566+
msg << prefix << "ArrayBundle object is invalid! Not created or deleted!";
567+
ESMC_LogDefault.Write(msg.str(), msgType);
568+
}else{
569+
msg.str(""); // clear
570+
msg << prefix << "ArrayBundle object is valid!"
571+
<< " <name: " << getName() << "> <itemCount: " << getCount() << ">";
572+
ESMC_LogDefault.Write(msg.str(), msgType);
573+
int item=0;
574+
for (auto it = arrayContainer.begin(); it != arrayContainer.end(); ++it,
575+
item++){
576+
msg.str(""); // clear
577+
msg << prefix << "+-<item: " << item << "> <itemName: "
578+
<< it->second->second->getName() << ">";
579+
ESMC_LogDefault.Write(msg.str(), msgType);
580+
if (deepFlag) it->second->second->log(prefix+"! ", msgType, deepFlag);
581+
}
582+
}
583+
msg.str(""); // clear
584+
msg << prefix << "--- ArrayBundle::log() end -------------------------------";
585+
ESMC_LogDefault.Write(msg.str(), msgType);
586+
}
587+
//-----------------------------------------------------------------------------
588+
589+
539590
//-----------------------------------------------------------------------------
540591
#undef ESMC_METHOD
541592
#define ESMC_METHOD "ESMCI::ArrayBundle::print()"

0 commit comments

Comments
 (0)