From ddf14763f7c11b637966ca871c4440df0c0965c8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 11 Mar 2020 19:28:58 -0400 Subject: [PATCH] port diskfree detection in fix halt for MacOSX --- src/fix_halt.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/fix_halt.cpp b/src/fix_halt.cpp index 0559c2e125..409bfbe8a1 100644 --- a/src/fix_halt.cpp +++ b/src/fix_halt.cpp @@ -306,21 +306,25 @@ double FixHalt::tlimit() /* ---------------------------------------------------------------------- determine available disk space, if supported. Return -1 if not. ------------------------------------------------------------------------- */ -#if defined(__linux) +#if defined(__linux) || defined(__APPLE__) #include #endif double FixHalt::diskfree() { -#if defined(__linux) +#if defined(__linux) || defined(__APPLE__) struct statvfs fs; double disk_free = -1.0; if (dlimit_path) { disk_free = 1.0e100; int rv = statvfs(dlimit_path,&fs); - if (rv == 0) + if (rv == 0) { +#if defined(__linux) disk_free = fs.f_bavail*fs.f_bsize/1048576.0; - else +#elif defined(__APPLE__) + disk_free = fs.f_bavail*fs.f_frsize/1048576.0; +#endif + } else disk_free = -1.0; MPI_Bcast(&disk_free,1,MPI_DOUBLE,0,world);