diff --git a/examples/suite_FV3_test_memcheck.xml b/examples/suite_FV3_test_memcheck.xml
new file mode 100644
index 00000000..3b5f0a8b
--- /dev/null
+++ b/examples/suite_FV3_test_memcheck.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+ GFS_time_vary_pre
+ GFS_rrtmg_setup
+ GFS_rad_time_vary
+ GFS_phys_time_vary
+ stochastic_physics
+ stochastic_physics_sfc
+
+
+
+
+ GFS_suite_interstitial_rad_reset
+ GFS_rrtmg_pre
+ rrtmg_sw_pre
+ rrtmg_sw
+ rrtmg_sw_post
+ rrtmg_lw_pre
+ rrtmg_lw
+ rrtmg_lw_post
+ GFS_rrtmg_post
+
+
+
+
+
+
+
+ GFS_suite_interstitial_phys_reset
+ GFS_suite_stateout_reset
+ get_prs_fv3
+ GFS_suite_interstitial_1
+ dcyc2t3
+ GFS_surface_generic_pre
+
+
+
+ sfc_ex_coef
+ GFS_surface_loop_control_part1
+ sfc_nst_pre
+ sfc_nst
+ sfc_nst_post
+ lsm_noah
+ sfc_sice
+ GFS_surface_loop_control_part2
+
+
+
+ dcyc2t3_post
+ sfc_diag
+ GFS_surface_generic_post
+ GFS_PBL_generic_pre
+ hedmf
+ GFS_PBL_generic_post
+ gwdps_pre
+ gwdps
+ gwdps_post
+ rayleigh_damp
+ ozphys
+ GFS_DCNV_generic_pre
+ get_phi_fv3
+ GFS_suite_interstitial_3
+ samfdeepcnv
+ GFS_DCNV_generic_post
+ memcheck
+ gwdc_pre
+ gwdc
+ gwdc_post
+ GFS_SCNV_generic_pre
+ samfshalcnv
+ samfshalcnv_post
+ GFS_SCNV_generic_post
+ GFS_suite_interstitial_4
+ cnvc90
+ zhaocarr_gscond
+ zhaocarr_precpd
+ GFS_MP_generic_post
+ sfc_sice_post
+
+
+
+
+ GFS_stochastics
+
+
+
+
diff --git a/scripts/ccpp_prebuild_config_FV3.py b/scripts/ccpp_prebuild_config_FV3.py
index f7a4810e..b3bd401e 100755
--- a/scripts/ccpp_prebuild_config_FV3.py
+++ b/scripts/ccpp_prebuild_config_FV3.py
@@ -142,6 +142,8 @@
'ccpp/physics/physics/sfc_sice.f' : [ 'slow_physics' ],
# stochastic physics
'ccpp/physics/stochastic_physics/stochastic_physics.F90' : [ 'slow_physics' ],
+ # memcheck utility
+ 'ccpp/physics/physics/memcheck.F90' : [ 'slow_physics' ],
}
# Auto-generated makefile/cmakefile snippets that contain all schemes
@@ -215,6 +217,9 @@
'mean_effective_radius_for_snow_flake',
],
},
+ 'memcheck' : {
+ 'memcheck_run' : [ 'mpi_root' ],
+ },
#'subroutine_name_1' : 'all',
#'subroutine_name_2' : 'none',
#'subroutine_name_2' : [ 'var1', 'var3'],
diff --git a/src/ccpp_memory.c b/src/ccpp_memory.c
index e8597358..70f65d74 100644
--- a/src/ccpp_memory.c
+++ b/src/ccpp_memory.c
@@ -35,6 +35,9 @@
#ifdef MPI
#include
#endif
+#ifdef OPENMP
+#include
+#endif
#include "ccpp_memory.h"
@@ -153,6 +156,17 @@ int ccpp_memory_usage_c(const int mpicomm, char* str, int lstr){
mpisize = 1;
#endif
+ // Get OpenMP thread number and total number of threads
+ int ompthread;
+ int ompthreads;
+#ifdef OPENMP
+ ompthread = omp_get_thread_num();
+ ompthreads = omp_get_num_threads();
+#else
+ ompthread = 0;
+ ompthreads = 1;
+#endif
+
// Retrieve hostname
char hostname[128];
gethostname(hostname, sizeof(hostname));
@@ -211,7 +225,7 @@ int ccpp_memory_usage_c(const int mpicomm, char* str, int lstr){
#ifndef MPI
snprintf(strtmp, sizeof(strtmp),
"--------------------------------------------------------------------------------\n\
-Memory usage - MPI rank %d/%d\n\
+Memory usage - MPI rank %d/%d - OMP thread %d/%d\n\
\n\
Statistics for node %s:\n\
Total virtual memory: %lld MB\n\
@@ -224,12 +238,13 @@ Virtual memory this process: %d MB\n\
Physical memory this process: %d MB\n\
Max. phys. memory this process: %d MB\n\
--------------------------------------------------------------------------------\n\
-", mpirank, mpisize, hostname, totalVirtMem, virtMemUsed, totalPhysMem, physMemUsed,
+", mpirank, mpisize, ompthread, ompthreads,
+hostname, totalVirtMem, virtMemUsed, totalPhysMem, physMemUsed,
pid, virtMemPerProcess, physMemPerProcess, physMemPerProcessMax);
#else
snprintf(strtmp, sizeof(strtmp),
"--------------------------------------------------------------------------------\n\
-Memory usage - MPI rank %d/%d\n\
+Memory usage - MPI rank %d/%d - OMP thread %d/%d\n\
\n\
Statistics for node %s:\n\
Total virtual memory: %lld MB\n\
@@ -247,7 +262,8 @@ Virtual memory average: %d MB\n\
Physical memory average: %d MB\n\
Max. phys. memory average: %d MB\n\
--------------------------------------------------------------------------------\n\
-", mpirank, mpisize, hostname, totalVirtMem, virtMemUsed, totalPhysMem, physMemUsed,
+", mpirank, mpisize, ompthread, ompthreads,
+hostname, totalVirtMem, virtMemUsed, totalPhysMem, physMemUsed,
pid, virtMemPerProcess, physMemPerProcess, physMemPerProcessMax, virtMemPerProcessAvg,
physMemPerProcessAvg, physMemPerProcessMaxAvg);
#endif
@@ -294,7 +310,16 @@ int ccpp_memory_usage_c(const int mpicomm, char* str, int lstr){
mpisize = 1;
#endif
- // Retrieve memory statistics
+ // Get OpenMP thread number and total number of threads
+ int ompthread;
+ int ompthreads;
+#ifdef OPENMP
+ ompthread = omp_get_thread_num();
+ ompthreads = omp_get_num_threads();
+#else
+ ompthread = 0;
+ ompthreads = 1;
+#endif
// Available physical memory - in Byte
unsigned long long totalPhysMem;
@@ -338,7 +363,7 @@ int ccpp_memory_usage_c(const int mpicomm, char* str, int lstr){
#ifndef MPI
snprintf(strtmp, sizeof(strtmp),
"--------------------------------------------------------------------------------\n\
-Memory usage - MPI rank %d/%d\n\
+Memory usage - MPI rank %d/%d - OMP thread %d/%d\n\
\n\
Size of physical memory: %llu MB\n\
\n\
@@ -346,11 +371,12 @@ Virtual memory this process: %d MB\n\
Physical memory this process: %d MB\n\
Max. phys. memory this process: %d MB\n\
--------------------------------------------------------------------------------\n\
-", mpirank, mpisize, totalPhysMem, virtMemPerProcess, physMemPerProcess, physMemPerProcessMax);
+", mpirank, mpisize, ompthread, ompthreads,
+totalPhysMem, virtMemPerProcess, physMemPerProcess, physMemPerProcessMax);
#else
snprintf(strtmp, sizeof(strtmp),
"--------------------------------------------------------------------------------\n\
-Memory usage - MPI rank %d/%d\n\
+Memory usage - MPI rank %d/%d - OMP thread %d/%d\n\
\n\
Size of physical memory: %llu MB\n\
\n\
@@ -363,7 +389,8 @@ Virtual memory average: %d MB\n\
Physical memory average: %d MB\n\
Max. phys. memory average: %d MB\n\
--------------------------------------------------------------------------------\n\
-", mpirank, mpisize, totalPhysMem, virtMemPerProcess, physMemPerProcess, physMemPerProcessMax,
+", mpirank, mpisize, ompthread, ompthreads,
+totalPhysMem, virtMemPerProcess, physMemPerProcess, physMemPerProcessMax,
virtMemPerProcessAvg, physMemPerProcessAvg, physMemPerProcessMaxAvg);
#endif