a function to read size from string with K,M,G.
[charm.git] / src / conv-core / convcore.c
index d72a0107bf5aa0c45707c741d824dbb2d3cc1b4b..17a5ff76979f329a8f0d80cbc933dca76595bfaf 100644 (file)
@@ -3762,4 +3762,25 @@ int CmiMyRank_()
   return CmiMyRank();
 }
 
+int CmiReadSize(char *str)
+{
+    int val;
+    if (strpbrk(str,"G")) {
+        sscanf(str, "%lldG", &val);
+        val *= 1024ll*1024*1024;
+    }
+    else if (strpbrk(str,"M")) {
+        sscanf(str, "%lldM", &val);
+        val *= 1024*1024;
+    }
+    else if (strpbrk(str,"K")) {
+        sscanf(str, "%lldK", &val);
+        val *= 1024;
+    }
+    else {
+        sscanf(str, "%lld", &val);
+    }
+    return val;
+}
+
 /*@}*/