@@ -99,6 +99,9 @@ namespace ESMCI {
9999 static bool profileOutputToBinary = false; // output to binary trace?
100100 static bool profileOutputSummary = false; // output aggregate profile on root PET?
101101
102+ // Profile information by type
103+ static int ProfileTypeInfo [ESMC_PROFILETYPE_NUM ];
104+
102105 static bool profileLocalPetThread (){
103106 return (profileLocalPet && VM ::isThreadKnown ());
104107 }
@@ -451,6 +454,35 @@ namespace ESMCI {
451454#endif
452455 }
453456
457+ static void SetProfileTypeInfoFromEnv () {
458+
459+ // Init to 0
460+ for (int i = 0 ; i < ESMC_PROFILETYPE_NUM ; i ++ ) {
461+ ProfileTypeInfo [i ]= 0 ;
462+ }
463+
464+ // Check for environment variable and set based on that
465+ // These will probably be fairly specific to the type, so for now
466+ // not trying to do anything automatic across different types
467+
468+ // NOTE: You need to set up the env variable in ESMCI_VM.C before it'll work here
469+
470+ // Set ESMF_ProfileType_Regrid
471+ char const * envRegridChar = VM ::getenv ("ESMF_RUNTIME_PROFILE_REGRID" );
472+ if (envRegridChar != NULL && strlen (envRegridChar ) > 0 ) {
473+
474+ // Get regrid info from string
475+ int info ;
476+ if (envRegridChar [0 ] == '1' ) info = 1 ;
477+ else if (envRegridChar [0 ] == '2' ) info = 2 ;
478+ else if (envRegridChar [0 ] == '3' ) info = 3 ;
479+
480+ // Set in profile info array
481+ ProfileTypeInfo [ESMC_PROFILETYPE_REGRID ] = info ;
482+ }
483+ }
484+
485+
454486#undef ESMC_METHOD
455487#define ESMC_METHOD "ESMCI::TraceOpen()"
456488 void TraceOpen (std ::string trace_dir , int * profileToLog , int * rc ) {
@@ -464,7 +496,7 @@ namespace ESMCI {
464496 if (ESMC_LogDefault .MsgFoundError (localrc ,
465497 ESMCI_ERR_PASSTHRU , ESMC_CONTEXT , rc ))
466498 return ;
467-
499+
468500 //determine if tracing is turned on for this PET
469501 traceLocalPet = TraceIsEnabledForPET (globalvm -> getLocalPet (), & localrc );
470502 if (ESMC_LogDefault .MsgFoundError (localrc ,
@@ -473,6 +505,7 @@ namespace ESMCI {
473505 return ;
474506 }
475507
508+
476509 //determine if profiling is turned on for this PET
477510 //if tracing is enabled, automatically turn on profiling
478511 profileLocalPet = traceLocalPet || ProfileIsEnabledForPET (globalvm -> getLocalPet (), & localrc );
@@ -481,7 +514,7 @@ namespace ESMCI {
481514 profileLocalPet = false;
482515 return ;
483516 }
484-
517+
485518 //determine output method for profiling, if enabled
486519 if (profileLocalPetThread ()) {
487520 //always output binary if tracing is enabled
@@ -530,6 +563,9 @@ namespace ESMCI {
530563 ESMC_LogDefault .Write ("ESMF Profiling Enabled" , ESMC_LOGMSG_INFO );
531564 }
532565
566+ // Set other profile information
567+ SetProfileTypeInfoFromEnv ();
568+
533569 // initialize the clock
534570 struct esmftrc_platform_filesys_ctx * ctx ;
535571 if (traceLocalPet || profileLocalPetThread ()) {
@@ -1240,6 +1276,7 @@ namespace ESMCI {
12401276 }
12411277
12421278
1279+
12431280
12441281#undef ESMC_METHOD
12451282#define ESMC_METHOD "ESMCI::TraceClose()"
@@ -1329,6 +1366,13 @@ namespace ESMCI {
13291366 }
13301367
13311368
1369+
1370+ #undef ESMC_METHOD
1371+ #define ESMC_METHOD "ESMCI::TraceGetProfileTypeInfo()"
1372+ int TraceGetProfileTypeInfo (enum ESMC_ProfileType type ) {
1373+ return ProfileTypeInfo [type ];
1374+ }
1375+
13321376
13331377 ///////////////////// I/O Tracing //////////////////
13341378
0 commit comments