MFEM  v3.3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
get_hypre_version.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #include "HYPRE_config.h"
13 #include <cstdio>
14 
15 #ifdef HYPRE_RELEASE_VERSION
16 #define HYPRE_VERSION_STRING HYPRE_RELEASE_VERSION
17 #elif defined(HYPRE_PACKAGE_VERSION)
18 #define HYPRE_VERSION_STRING HYPRE_PACKAGE_VERSION
19 #endif
20 
21 // Macros to expand a macro as a string
22 #define STR_EXPAND(s) #s
23 #define STR(s) STR_EXPAND(s)
24 
25 // Convert the HYPRE_RELEASE_VERSION macro (string) to integer.
26 // Examples: "2.10.0b" --> 21000, "2.11.2" --> 21102
27 int main()
28 {
29 #ifdef HYPRE_VERSION_STRING
30  const char *ptr = STR(HYPRE_VERSION_STRING);
31  if (*ptr == '"') { ptr++; }
32  int version = 0;
33  for (int i = 0; i < 3; i++, ptr++)
34  {
35  int pv = 0;
36  for (char d; d = *ptr, '0' <= d && d <= '9'; ptr++)
37  {
38  pv = 10*pv + (d - '0');
39  if (pv >= 100) { return 1; }
40  }
41  version = 100*version + pv;
42  }
43  printf("%i\n", version);
44  return 0;
45 #else
46  return 2;
47 #endif
48 }
int main()