From 270f2eecf9845954cb06a85d8b629b24c9ee8b61 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 17 Jun 2021 12:21:24 +0200
Subject: [PATCH] ENH: report API information in header #2126

- previously reported the WM_PROJECT_VERSION in the top banner
  but this makes it overly sensitive to arbitrary user naming.

  Change to the current API in the comment banner, include the
  WM_PROJECT_VERSION as part of the reported "Build: ..."
  string instead.
---
 src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C | 6 ++++--
 src/OpenFOAM/global/argList/argList.C          | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
index c66ed91a1e7..1896920238f 100644
--- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
+++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
@@ -83,14 +83,16 @@ Foam::IOobject::writeBanner(Ostream& os, const bool noSyntaxHint)
     {
         // Populate: like strncpy but without trailing '\0'
 
-        std::size_t len = foamVersion::version.length();
+        const std::string apiValue(std::to_string(Foam::foamVersion::api));
+
+        std::size_t len = apiValue.length();
         if (len > 38)
         {
             len = 38;
         }
 
         std::memset(paddedVersion, ' ', 38);
-        std::memcpy(paddedVersion, foamVersion::version.c_str(), len);
+        std::memcpy(paddedVersion, apiValue.c_str(), len);
         paddedVersion[38] = '\0';
     }
 
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C
index 16ab2ed7fa1..e3d6bed3ea2 100644
--- a/src/OpenFOAM/global/argList/argList.C
+++ b/src/OpenFOAM/global/argList/argList.C
@@ -1036,6 +1036,8 @@ void Foam::argList::parse
                 Info<< " patch=" << foamVersion::patch.c_str();
             }
 
+            Info<< " version=" << foamVersion::version.c_str();
+
             Info<< nl
                 << "Arch   : " << foamVersion::buildArch << nl
                 << "Exec   : " << commandLine_.c_str() << nl
-- 
GitLab