diff -Nru ../trunk.old/code/CMakeLists.txt ./code/CMakeLists.txt
--- ../trunk.old/code/CMakeLists.txt	2016-10-04 14:03:15.000000000 -0400
+++ ./code/CMakeLists.txt	2016-10-04 14:08:44.802154781 -0400
@@ -55,12 +55,49 @@
 include( target )
 include( CASA )
 
-set( CASA_MAJOR_VERSION 5 )
-set( CASA_MINOR_VERSION 0 )
-set( CASA_PATCH_VERSION 0 )
-set( CASA_API_VERSION "${CASA_MAJOR_VERSION}.${CASA_MINOR_VERSION}.${CASA_PATCH_VERSION}" )
+set( CASA_VERSION_MAJOR   5   )
+set( CASA_VERSION_MINOR   0   )
+set( CASA_VERSION_PATCH   0   )
+set( CASA_VERSION_FEATURE 0   )
+set( CASA_VERSION_DESC    "" )
+
+if( ${CASA_VERSION_FEATURE} STREQUAL "0" )
+    execute_process( COMMAND svn info
+                     RESULT_VARIABLE SVNINFOSTATUS
+                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} )
+ 
+    ### hash-bound git will need another solution
+    if ( ${SVNINFOSTATUS} STREQUAL "0" )
+        execute_process(    COMMAND svnversion
+                            OUTPUT_VARIABLE SUBVERSION_REVISION
+                            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                            OUTPUT_STRIP_TRAILING_WHITESPACE )
+
+        execute_process(    COMMAND curl --silent https://svn.cv.nrao.edu/cgi-bin/casa-version-match?rev=${SUBVERSION_REVISION}
+                            COMMAND perl -pe "s|^\\d+\\.\\d+\\.(\\d+)\\s+\\d+\n*$|$1|"
+                            OUTPUT_VARIABLE CASA_VERSION_FEATURE
+                            OUTPUT_STRIP_TRAILING_WHITESPACE )
+
+    else( )
+        execute_process( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/install/resolvegitrevision.sh
+                         OUTPUT_VARIABLE CASA_VERSION_FEATURE_AND_BRANCH_TAG # Getting a list
+                         OUTPUT_STRIP_TRAILING_WHITESPACE )
+        message("resolvegitrevision: ${CASA_VERSION_FEATURE_AND_BRANCH_TAG}")
+        list(LENGTH CASA_VERSION_FEATURE_AND_BRANCH_TAG len)
+        message(STATUS "len = ${len}")
+        list ( GET CASA_VERSION_FEATURE_AND_BRANCH_TAG 0 CASA_VERSION_FEATURE)
+        list ( GET CASA_VERSION_FEATURE_AND_BRANCH_TAG 1 BRANCH_TAG)
+        message("CASA_VERSION_FEATURE: ${CASA_VERSION_FEATURE}")
+        message("CASA_VERSION_DESC: ${BRANCH_TAG}")
+        set(CASA_VERSION_DESC " Branch: ${BRANCH_TAG}")
+    endif( )
+endif( )
+
+set( CASA_API_VERSION "${CASA_VERSION_MAJOR}.${CASA_VERSION_MINOR}.${CASA_VERSION_PATCH}-${CASA_VERSION_FEATURE}" )
 string(TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S UTC" UTC)
 
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.cmake ${CMAKE_CURRENT_SOURCE_DIR}/VERSION )
+
 ###
 ### default name for casa-maintained dbus C++ library... (but could also be called just "dbus-cpp")
 ###
diff -Nru ../trunk.old/code/stdcasa/CMakeLists.txt ./code/stdcasa/CMakeLists.txt
--- ../trunk.old/code/stdcasa/CMakeLists.txt	2016-10-04 14:03:18.000000000 -0400
+++ ./code/stdcasa/CMakeLists.txt	2016-10-04 14:08:44.802154781 -0400
@@ -18,24 +18,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-if( ${CASA_PATCH_VERSION} STREQUAL "0" )
-
-    execute_process( COMMAND svn info
-                     RESULT_VARIABLE SVNINFOSTATUS
-                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} )
-
-    ### hash-bound git will need another solution
-    if ( ${SVNINFOSTATUS} STREQUAL "0" )
-        execute_process( COMMAND svnversion
-                         OUTPUT_VARIABLE CASA_PATCH_VERSION
-                         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} )
-
-        string( REGEX  REPLACE "[a-zA-Z]" "" CASA_PATCH_VERSION ${CASA_PATCH_VERSION} )
-        string( REPLACE "\n" "" CASA_PATCH_VERSION ${CASA_PATCH_VERSION} )
-    endif( )
-
-endif( )
-
 CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/version.cc.cmake version.cc )
 
 casa_add_library( stdcasa
@@ -43,7 +25,6 @@
 	StdCasa/CasacSupport.cc
 	StdCasa/record.cc
 	StdCasa/variant.cc
-	version2.cc
 	version.cc
 	)
 if (UseCrashReporter)
diff -Nru ../trunk.old/code/stdcasa/version.cc.cmake ./code/stdcasa/version.cc.cmake
--- ../trunk.old/code/stdcasa/version.cc.cmake	2016-10-04 14:03:18.000000000 -0400
+++ ./code/stdcasa/version.cc.cmake	2016-10-04 14:08:44.802154781 -0400
@@ -4,41 +4,95 @@
 // and can be confused by altering even one character in this section.
 
 #include <stdcasa/version.h>
+#include <cstdlib>
+#include <numeric>
+#include <cstdlib>
+#include <cctype>
+#include <string>
+using std::getenv;
+using std::accumulate;
+using std::isdigit;
+using std::stoi;
+using std::string;
+using std::to_string;
 
 namespace casa {
 
-const int    VersionInfo::aips_major_version = @CASA_MAJOR_VERSION@;
-const int    VersionInfo::aips_minor_version = @CASA_MINOR_VERSION@;
-const int    VersionInfo::aips_patch_version = @CASA_PATCH_VERSION@;
-
-const char * VersionInfo::aips_version_date  = "@COMPILE_TIME@";
-const char * VersionInfo::aips_version_info  = "";
-
-} //# NAMESPACE CASA - END
-
-#include <iostream>
-#include <iomanip>
-
-using namespace std;
-
-namespace casa { //# NAMESPACE CASA
-
-void report_aips_version(ostream &os)
-{
-   os << "CASA version: "
-      << setfill('0')
-      << setw(2)  << VersionInfo::aips_major_version
-      << "."
-      << setw(3)  << VersionInfo::aips_minor_version
-      << "."
-      << setw(2)  << VersionInfo::aips_patch_version
-      << " "
-      << setfill(' ')
-      << setiosflags(ios::left)
-      << setw(31) << VersionInfo::aips_version_date
-      << "  "
-      << setw(0)  << VersionInfo::aips_version_info
-      << endl;
-}
+    static int environ_version( const char *evar ) {
+        char *cstr = getenv(evar);
+        if ( cstr ) {
+            std::string val(cstr);
+            bool alldigits = accumulate( val.begin(), val.end(), true,
+                                      [=](bool sum, char c){return sum && isdigit(c);} );
+            if ( alldigits ) return stoi(val);
+        }
+        return -1;
+    }
+
+    int VersionInfo::major( ) {
+        static bool initialized = false;
+        static int version = -1;
+        if ( initialized == false ) {
+            initialized = true;
+            version = environ_version("CASA_VERSION_MAJOR");
+        }
+        return version > 0 ? version : @CASA_VERSION_MAJOR@;
+    }
+
+    int VersionInfo::minor( ) {
+        static bool initialized = false;
+        static int version = -1;
+        if ( initialized == false ) {
+            initialized = true;
+            version = environ_version("CASA_VERSION_MINOR");
+        }
+        return version > 0 ? version : @CASA_VERSION_MINOR@;
+    }
+
+    int VersionInfo::patch( ) {
+        static bool initialized = false;
+        static int version = -1;
+        if ( initialized == false ) {
+            initialized = true;
+            version = environ_version("CASA_VERSION_PATCH");
+        }
+        return version > 0 ? version : @CASA_VERSION_PATCH@;
+    }
+
+    int VersionInfo::feature( ) {
+        static bool initialized = false;
+        static int version = -1;
+        if ( initialized == false ) {
+            initialized = true;
+            version = environ_version("CASA_VERSION_FEATURE");
+        }
+        return version > 0 ? version : @CASA_VERSION_FEATURE@;
+    }
+
+    std::string VersionInfo::desc( ) {
+        static bool initialized = false;
+        static std::string version("@CASA_VERSION_DESC@");
+        if ( initialized == false ) {
+            initialized = true;
+            char *desc = getenv("CASA_VERSION_DESC");
+            if ( desc ) version = desc;
+        }
+        return version;
+    }
+
+    std::string VersionInfo::info( ) {
+        static bool initialized = false;
+        static std::string version = to_string(major( )) + "." +
+                                     to_string(minor( )) + "." +
+                                     to_string(patch( )) + "-" +
+                                     to_string(feature( )) + 
+                                     (desc( ).size( ) > 0 ? " " + desc( ) : "");
+        if ( initialized == false ) {
+            initialized = true;
+            char *desc = getenv("CASA_VERSION_INFO");
+            if ( desc ) version = desc;
+        }
+        return version;
+    }
 
 } //# NAMESPACE CASA - END
diff -Nru ../trunk.old/code/stdcasa/version.h ./code/stdcasa/version.h
--- ../trunk.old/code/stdcasa/version.h	2016-10-04 14:03:18.000000000 -0400
+++ ./code/stdcasa/version.h	2016-10-04 14:12:25.493678096 -0400
@@ -1,5 +1,5 @@
 //# version.h: Version information for AIPS++
-//# Copyright (C) 1996,1997,1999,2000,2001,2002,2004
+//# Copyright (C) 1996,1997,1999,2000,2001,2002,2004,2016
 //# Associated Universities, Inc. Washington DC, USA.
 //#
 //# This library is free software; you can redistribute it and/or modify it
@@ -30,149 +30,30 @@
 #define CASA_VERSION_H
 
 //# Includes
-#include <casa/aips.h>
-
-//# Forward declarations
-#include <casa/iosfwd.h>
+#include <iostream>
 
 namespace casa { //# NAMESPACE CASA - BEGIN
 
-// <summary>
-// Version information for AIPS++
-// </summary>
-
-// <use visibility=export>
-
-// <reviewed reviewer="nkilleen" date="1996/10/24" tests="tversion.cc" demos="">
-// </reviewed>
-
-// <synopsis>
-// VersionInfo is a small class that reports information on the  version
-// of AIPS++ that an executable was linked with. Normally an application
-// programmer won't use this class directly, rather it will be used by
-// the ``Tasking'' system which will report this information in a standard
-// way.
-//
-// The available information is:
-// <ul>
-//    <li> <src>majorVersion()</src>: Major version of AIPS++, changes about twice
-//         a year.
-//    <li> <src>minorVersion()</src>: Minor version of AIPS++, changes about three
-//         times a day. (every exhale).
-//    <li> <src>patch()</src>: Patch number of this release. Changes when a
-//         bug-fix patch is created.
-//    <li> <src>date()</src>: casacore::String representation of the date when this
-//         release was created (when "exhale" was run).
-//    <li> <src>info()</src>: Extra information about this release, e.g.
-//         "beta release."
-// </ul>
-//
-// Additionally, there is a <src>report()</src> member function which
-// summarizes the above to an <src>ostream</src>.
-//
-// When released to end users, the minor number is always 0. On the other
-// hand, along the development path the patch number is always zero. The
-// <src>report()</src> member function takes advantage of this to reformat
-// the version information to be more in line with what people are used to.
-// For example, 07.247.00 becomes "0.7 (build 247)" and 08.000.5 becomes
-// 0.8.5. Note that major version 10 will thus be reported as version
-// 1.0
-//
-// The version information is maintained automatically by "exhale" and
-// is made available at link time by the make system.
-// </synopsis>
-//
-// <example>
-// If you knew that a format change occurred at release 10.0 you could write
-// code like:
-// <srcBlock>
-// if (VersionInfo::majorVersion() >= 10) {
-//    ... process the new way
-// } else {
-//    ... process the old way
-// }
-// </srcBlock>
-// Of course generally it would be better to provide a conversion program
-// for the persistent data, rather than filling applications with tests
-// like this.
-// </example>
-//
-// <motivation>
-// It is important for bug-reporting and other such purposes to be able
-// to uniquely identify the version of AIPS++ that some problem occurs
-// in.
-// </motivation>
-//
-// <todo asof="1996/10/24">
-// <li> It would be useful to document the compiler/platform as well.
-// </todo>
-
-class VersionInfo
-{
-public:
-
-    // Major version of AIPS++, changes about twice a year.
-
-    static int majorVersion()
-    {
-        return aips_major_version;
-    }
-
-    // Minor version of AIPS++, changes about three times a
-    // day (every exhale).
-
-    static int minorVersion()
-    {
-        return aips_minor_version;
-    }
-
-    // Patch number of this release. Changes when a bug-fix patch is
-    // created.
-
-    static int patch()
-    {
-        return aips_patch_version;
-    }
-
-    // casacore::String representation of the date when this release was created
-    // (when "exhale" was run).
-
-    static const char * date()
-    {
-        return aips_version_date;
-    }
-
-    // Extra information about this release, e.g. "beta release."
-
-    static const char * info()
-    {
-        return aips_version_info;
-    }
+class VersionInfo {
+    public:
+
+    static int major( );            // major version number: e.g. 4
+    static int minor( );            // minor version number: e.g. 7
+    static int patch( );            // patch number: e.g.         1
+    static int feature( );          // feature increment: e.g.    298
+    static std::string desc( );     // description: e.g.          "DEV" or "REL"
+    static std::string info( );     // combined string: e.g.      "4.7.1-DEV (298)"
 
     // Summarize the above into an ostream. Note that an 
     // <src>ostringstream</src> can be converted to a 
-    // <linkto class="casacore::String">casacore::String</linkto> via a constructor.
+    // <linkto class="String">String</linkto> via a constructor.
     // This information is NOT prepended with "AIPS++ version:" or anything
     // like that. You may wish to add this yourself. The date is also not
     // included.
-
-    static void report(std::ostream &os);
-
-private:
-
-    friend void report_aips_version(std::ostream &os);
-
-    static const int   aips_major_version;
-    static const int   aips_minor_version;
-    static const int   aips_patch_version;
-    static const char * aips_version_date;
-    static const char * aips_version_info;
+    static void report(std::ostream &os) { os << info( ); }
 
 };
 
-//# Inlines ------------------------------------------------------------------
-
-
 } //# NAMESPACE CASA - END
 
 #endif
diff -Nru ../trunk.old/code/VERSION ./code/VERSION
--- ../trunk.old/code/VERSION	2016-10-04 14:02:47.000000000 -0400
+++ ./code/VERSION	1969-12-31 19:00:00.000000000 -0500
@@ -1 +0,0 @@
-4.6.0 Tue 2014/07/29 05:00:37 UTC
diff -Nru ../trunk.old/code/VERSION.cmake ./code/VERSION.cmake
--- ../trunk.old/code/VERSION.cmake	1969-12-31 19:00:00.000000000 -0500
+++ ./code/VERSION.cmake	2016-10-04 14:08:44.802154781 -0400
@@ -0,0 +1 @@
+@CASA_API_VERSION@ @COMPILE_TIME@
diff -Nru ../trunk.old/gcwrap/python/scripts/casa_in_py.py ./gcwrap/python/scripts/casa_in_py.py
--- ../trunk.old/gcwrap/python/scripts/casa_in_py.py	2016-10-04 14:02:33.000000000 -0400
+++ ./gcwrap/python/scripts/casa_in_py.py	2016-10-04 14:08:44.803154770 -0400
@@ -26,9 +26,12 @@
 home=os.environ['HOME']
 
 import casadef
+import __casac__
+cu = __casac__.utils.utils()
+
 casa = { 'build': {
              'time': casadef.build_time,
-             'version': casadef.casa_version,
+             'version': cu.version_info( ),
              'number': casadef.subversion_revision
          },
          'source': {
diff -Nru ../trunk.old/gcwrap/python/scripts/casa.py ./gcwrap/python/scripts/casa.py
--- ../trunk.old/gcwrap/python/scripts/casa.py	2016-10-04 14:02:41.000000000 -0400
+++ ./gcwrap/python/scripts/casa.py	2016-10-04 14:08:44.803154770 -0400
@@ -29,9 +29,12 @@
     else :
         raise RuntimeError, "CASAPATH environment variable must be set"
 
+import __casac__
+cu = __casac__.utils.utils()
+
 casa = { 'build': {
              'time': casadef.build_time,
-             'version': casadef.casa_version,
+             'version': cu.version_info( ),
              'number': casadef.subversion_revision
          },
          'source': {
diff -Nru ../trunk.old/gcwrap/python/scripts/casapy_engine.py ./gcwrap/python/scripts/casapy_engine.py
--- ../trunk.old/gcwrap/python/scripts/casapy_engine.py	2016-10-04 14:02:39.000000000 -0400
+++ ./gcwrap/python/scripts/casapy_engine.py	2016-10-04 14:08:44.804154758 -0400
@@ -38,9 +38,12 @@
 
 
 import casadef
+import __casac__
+cu = __casac__.utils.utils()
+
 casa = { 'build': {
              'time': casadef.build_time,
-             'version': casadef.casa_version,
+             'version': cu.version_info( ),
              'number': casadef.subversion_revision
          },
          'source': {
diff -Nru ../trunk.old/gcwrap/python/scripts/casapy.py ./gcwrap/python/scripts/casapy.py
--- ../trunk.old/gcwrap/python/scripts/casapy.py	2016-10-04 14:02:25.000000000 -0400
+++ ./gcwrap/python/scripts/casapy.py	2016-10-04 14:08:44.804154758 -0400
@@ -128,10 +128,12 @@
    sys.exit(1)
 
 import casadef
+import __casac__
+cu = __casac__.utils.utils()
 
 casa = { 'build': {
              'time': casadef.build_time,
-             'version': casadef.casa_version,
+             'version': cu.version_info( ),
              'number': casadef.subversion_revision
          },
          'source': {
@@ -285,7 +287,7 @@
             if casa['helpers'][entry] is not None:
                 break
 
-print "CASA Version " + casa['build']['version'] + "-DEV (r" + casa['source']['revision'] + ")\n  Compiled on: " + casa['build']['time']
+print "CASA Version " + casa['build']['version'] + "\n  Compiled on: " + casa['build']['time']
 
 a = [] + sys.argv             ## get a copy from goofy python
 a.reverse( )
diff -Nru ../trunk.old/gcwrap/python/scripts/regressions/alma-24ant-calibration-regression.py ./gcwrap/python/scripts/regressions/alma-24ant-calibration-regression.py
--- ../trunk.old/gcwrap/python/scripts/regressions/alma-24ant-calibration-regression.py	2016-10-04 14:02:33.000000000 -0400
+++ ./gcwrap/python/scripts/regressions/alma-24ant-calibration-regression.py	2016-10-04 14:08:44.805154747 -0400
@@ -62,7 +62,7 @@
 #es = aU.stuffForScienceDataReduction() 
 
 
-if re.search('^4.', casadef.casa_version) == None:
+if cu.compare_version('>=',[5]):
  sys.exit('ERROR: PLEASE USE CASA 4.x')
 
 
diff -Nru ../trunk.old/gcwrap/python/scripts/regressions/alma_asdm+reimported-asdm_sf.py ./gcwrap/python/scripts/regressions/alma_asdm+reimported-asdm_sf.py
--- ../trunk.old/gcwrap/python/scripts/regressions/alma_asdm+reimported-asdm_sf.py	2016-10-04 14:02:35.000000000 -0400
+++ ./gcwrap/python/scripts/regressions/alma_asdm+reimported-asdm_sf.py	2016-10-04 14:08:44.806154736 -0400
@@ -199,7 +199,7 @@
         useversion='v3'
         )
 
-    if(casadef.casa_version>='3.4.0' and genwvr): # generate the WVR correction table
+    if(cu.compare_version('>=',[3,4,0]) and genwvr): # generate the WVR correction table
         print ">> Generating the WVR caltable ", caltablename0
         os.system('rm -rf '+caltablename0)
         wvrgcal(vis=msn, caltable=caltablename0, segsource=False, toffset=-2, reversespw='0~7')
@@ -286,7 +286,7 @@
         print ">> SPW: ",i
         os.system('rm -rf '+caltablename+'_spw'+str(i)+'.G_WVR')
         wvrspw = 0
-        if(casadef.casa_version>='3.4.0'):
+        if(cu.compare_version('>=',[3,4,0])):
             wvrspw = i
         gaincal(
             vis=msn,
@@ -308,7 +308,7 @@
         print ">> SPW: ",i
         os.system('rm -rf '+caltablename+'.GSPLINE_WVR_'+str(i))
         wvrspw = 0
-        if(casadef.casa_version>='3.4.0'):
+        if(cu.compare_version('>=',[3,4,0])):
             wvrspw = i
         gaincal(
             vis=msn,
@@ -362,7 +362,7 @@
     for i in range (2):
         print ">> SPW: ",i
         wvrspw = 0
-        if(casadef.casa_version>='3.4.0'):
+        if(cu.compare_version('>=',[3,4,0])):
             wvrspw = i
         applycal(
             vis=msn,
diff -Nru ../trunk.old/gcwrap/python/scripts/regressions/alma-m100-analysis-regression.py ./gcwrap/python/scripts/regressions/alma-m100-analysis-regression.py
--- ../trunk.old/gcwrap/python/scripts/regressions/alma-m100-analysis-regression.py	2016-10-04 14:02:35.000000000 -0400
+++ ./gcwrap/python/scripts/regressions/alma-m100-analysis-regression.py	2016-10-04 14:08:44.805154747 -0400
@@ -24,7 +24,6 @@
 # generation which we ommit in this regression by using canned Tsys cal tables
 # for 3.4.0, the tsys table can be generated without the help of aU
 
-
 step_title = { 0 : 'Data import',
 	       1 : 'Generate antenna position cal tables',
 	       2 : 'Generate tsys cal tables (if possible) or use canned ones',
@@ -185,7 +184,7 @@
     print 'Step ', mystep, step_title[mystep]
 
 
-    if(casadef.casa_version>='3.4.0'):
+    if(cu.compare_version('>=',[3,4,0])):
 
         for name in basename:
             os.system('rm -rf cal-tsys_'+name+'.fdm')
@@ -291,7 +290,7 @@
 
     tsysinterp = 'nearest'
     tsysspwmap=[]
-    if(casadef.casa_version>='3.4.0'):
+    if(cu.compare_version('>=', [3,4,0])):
         print "Using linear interpolation for Tsys in applycal ..."
         tsysinterp='linear'
         tsysspwmap=[0,9,0,11,0,13,0,15]
diff -Nru ../trunk.old/gcwrap/python/scripts/regressions/alma-m100-sd-regression.py ./gcwrap/python/scripts/regressions/alma-m100-sd-regression.py
--- ../trunk.old/gcwrap/python/scripts/regressions/alma-m100-sd-regression.py	2016-10-04 14:02:35.000000000 -0400
+++ ./gcwrap/python/scripts/regressions/alma-m100-sd-regression.py	2016-10-04 14:15:48.558401873 -0400
@@ -53,9 +53,9 @@
 
 version = casadef.casa_version
 
-print "You are using " + version
+print "You are using " + cu.version_info( )
 
-if (version < '4.5.0'):
+if (cu.compare_version('<',[4,3,0])):
     print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."
     print "PLEASE UPDATE IT BEFORE PROCEEDING."
 else:
diff -Nru ../trunk.old/gcwrap/python/scripts/regressions/pipelineTest_regression.py ./gcwrap/python/scripts/regressions/pipelineTest_regression.py
--- ../trunk.old/gcwrap/python/scripts/regressions/pipelineTest_regression.py	2016-10-04 14:02:33.000000000 -0400
+++ ./gcwrap/python/scripts/regressions/pipelineTest_regression.py	2016-10-04 14:08:44.806154736 -0400
@@ -43,7 +43,7 @@
     if MIN_CASA_REVISION > revision:
         msg = ('Minimum CASA revision for the pipeline is r%s, '
                'got CASA %s (r%s).' % (MIN_CASA_REVISION, 
-                casadef.casa_version,
+                cu.version_info( ),
                 casadef.subversion_revision))
         print msg
         regstate = False
diff -Nru ../trunk.old/gcwrap/python/scripts/task_plotbandpass.py ./gcwrap/python/scripts/task_plotbandpass.py
--- ../trunk.old/gcwrap/python/scripts/task_plotbandpass.py	2016-10-04 14:02:39.000000000 -0400
+++ ./gcwrap/python/scripts/task_plotbandpass.py	2016-10-04 14:08:44.809154702 -0400
@@ -1266,7 +1266,7 @@
     # Now open the associated ms tables via msmd tool
 #     msAnt = []  # comment this out when CAS-6801 changes are in place
     if (debug): print  "creating msmd tool"
-    if (casadef.casa_version < '4.1.0'):
+    if (cu.compare_version('<',[4,1,0])):
         print "This version of casa is too old to use the msmd tool.  Use au.plotbandpass instead."
         return
     mymsmd = ''
@@ -1276,7 +1276,7 @@
         if (os.path.exists(msName) == False):
             msName = os.path.dirname(caltable)+'/'+msName
             if (debug): print  "found msName = %s." % (msName)
-        if (casadef.casa_version < '4.1.0'):
+        if (cu.compare_version('<',[4,1,0])):
             print "This version of casa is too old to use the msmd tool.  Use au.plotbandpass instead."
             return
         try:
@@ -1435,7 +1435,7 @@
             print "WARNING: spw %d is not in the solution. Removing it from the list to plot." % (myspw)
             print "Available spws = ", uniqueSpwsInCalTable
             keepSpwsToPlot.remove(myspw)
-            if (casadef.casa_version >= '4.1.0' and mymsmd != ''):  
+            if (cu.compare_version('>=',[4,1,0]) and mymsmd != ''):  
 # #              nonwvrspws = list(set(range(mymsmd.nspw())).difference(set(mymsmd.wvrspws())))
                 if (myspw not in range(mymsmd.nspw())):
                     print "FATAL: spw %d is not even in the ms.  There might be a bug in your script." % (myspw)
@@ -1450,7 +1450,7 @@
     originalSpwsToPlot = computeOriginalSpwsToPlot(spwsToPlot, originalSpw, tableFormat, debug)
            
     # Now generate the list of minimal basebands that contain the spws to be plotted
-    if (casadef.casa_version >= '4.1.0' and msFound):
+    if (cu.compare_version('>=',[4,1,0]) and msFound):
         allBasebands = []
         if (mymsmd != ''):
           try:
@@ -2691,7 +2691,7 @@
         for baseband in basebands:
             myspwlist = []
             for spw in spwsToPlot:
-                if (casadef.casa_version >= '4.1.0' and msFound):
+                if (cu.compare_version('>=',[4,1,0]) and msFound):
                     if (mymsmd.baseband(originalSpwsToPlot[list(spwsToPlot).index(spw)]) == baseband):
                         myspwlist.append(spw)
                 else:
@@ -2727,7 +2727,7 @@
           if (debug): print "setting spwsToPlot for baseband %d (bbctr=%d) to %s" % (baseband, bbctr, str(spwsToPlot))
        else:
            baseband = 0  # add from here to "ispw=" on 2014-04-05
-           if (casadef.casa_version >= '4.1.0'):
+           if (cu.compare_version('>=',[4,1,0])):
                if (debug): print "A, msName=%s, vis=%s" % (msName,vis)
                if (getBasebandDict(vis=msName,caltable=caltable) != {}):
                    if (debug): print "B"
@@ -2756,7 +2756,7 @@
                 allTimesFlaggedOnThisSpw = True # used only by overlay='time'
                 if (groupByBaseband == False):
                     baseband = 0
-                    if (casadef.casa_version >= '4.1.0'):
+                    if (cu.compare_version('>=',[4,1,0])):
                         if (getBasebandDict(vis=msName,caltable=caltable) != {}):
                             try:
                                 baseband = mymsmd.baseband(originalSpwsToPlot[spwctr])
@@ -6326,7 +6326,7 @@
     Uses msmd, unless the ms is not found, in which case it uses
     the spw information inside the (new-style) cal-table.
     """
-    if (mymsmd != '' and casadef.casa_version >= '4.1.0'):
+    if (mymsmd != '' and cu.compare_version('>=',[4,1,0])):
         return(frequencyRangeForSpws(mymsmd,spwlist))
     else:
         freqs = []
@@ -6422,7 +6422,7 @@
         return
     if (type(bbs) == int):  # old datasets will bomb on msmd.baseband()
         return(bbdict)
-    if (casadef.casa_version >= '4.1.0' and vis != None):
+    if (cu.compare_version('>=',[4,1,0]) and vis != None):
         if (os.path.exists(vis)):
             mymsmd = createCasaTool(msmdtool)
             mymsmd.open(vis)
diff -Nru ../trunk.old/gcwrap/tools/casa/logsink_cmpt.cc ./gcwrap/tools/casa/logsink_cmpt.cc
--- ../trunk.old/gcwrap/tools/casa/logsink_cmpt.cc	2016-10-04 14:02:00.000000000 -0400
+++ ./gcwrap/tools/casa/logsink_cmpt.cc	2016-10-04 14:08:44.809154702 -0400
@@ -103,7 +103,6 @@
   ostringstream os1, os2;
   os1 << "CASA Version ";
   casa::VersionInfo::report(os1);
-  os2 << "  Tagged on: "<< casa::VersionInfo::date();
   std::string mymess = os1.str();
 
   thelogsink->postLocally(LogMessage(mymess, *itsorigin, LogMessage::NORMAL));
diff -Nru ../trunk.old/gcwrap/tools/utils/utils_cmpt.cc ./gcwrap/tools/utils/utils_cmpt.cc
--- ../trunk.old/gcwrap/tools/utils/utils_cmpt.cc	2016-10-04 14:02:03.000000000 -0400
+++ ./gcwrap/tools/utils/utils_cmpt.cc	2016-10-04 14:08:44.810154691 -0400
@@ -13,6 +13,7 @@
 #include <iostream>
 #include <fstream>
 #include <stdcasa/record.h>
+#include <stdcasa/version.h>
 #include <utils_cmpt.h>
 #include <tools/utils/stdBaseInterface.h>
 #include <tools/xerces/stdcasaXMLUtil.h>
@@ -25,6 +26,10 @@
 #include <casa/OS/HostInfo.h>
 #include <stdcasa/StdCasa/CrashReporter.h>
 #include <signal.h>
+#include <string>
+#include <vector>
+#include <cstdlib>
+
 
 using namespace std;
 using namespace casacore;
@@ -380,5 +385,72 @@
 }
 
 
+std::vector<int>
+utils::version( ) {
+    std::vector<int> result = {
+        VersionInfo::major( ),
+        VersionInfo::minor( ),
+        VersionInfo::patch( ),
+        VersionInfo::feature( )
+    };
+    return result;
+}
+
+std::string
+utils::version_desc( ) { return VersionInfo::desc( ); }
+
+std::string
+utils::version_info( ) { return VersionInfo::info( ); }
+
+bool
+ utils::compare_version(const  string& comparitor,  const std::vector<int>& vec) {
+  vector<int> current_version = { 5, 0, 0, 15 };
+  for ( unsigned int i=0; i < vec.size( ); ++i )
+    if ( vec[i] < 0 ) throw(AipsError("negative values not allowed in version numbers"));
+
+  unsigned int limit = min(current_version.size( ),vec.size( ));
+  if ( comparitor == ">" ) {
+    for ( unsigned int i=0; i < limit; ++i ) {
+      if ( current_version[i] > vec[i] ) return true;
+      else if ( current_version[i] < vec[i] ) return false;
+    }
+    for ( unsigned int i=limit; i < current_version.size( ); ++i )
+      if ( current_version[i] > 0 ) return true;
+    return false;
+  } else if ( comparitor == "<" ) {
+    for ( unsigned int i=0; i < limit; ++i ) {
+      if ( current_version[i] > vec[i] ) return false;
+      else if ( current_version[i] < vec[i] ) return true;
+    }
+    return false;
+  } else if ( comparitor == ">=" ) {
+    for ( unsigned int i=0; i < limit; ++i ) {
+      if ( current_version[i] > vec[i] ) return true;
+      else if ( current_version[i] < vec[i] ) return false;
+    }
+    return true;
+  } else if ( comparitor == "<=" ) {
+    for ( unsigned int i=0; i < limit; ++i ) {
+      if ( current_version[i] > vec[i] ) return false;
+      else if ( current_version[i] < vec[i] ) return true;
+    }
+    for ( unsigned int i=limit; i < current_version.size( ); ++i )
+      if ( current_version[i] > 0 ) return false;
+    return true;
+  } else if ( comparitor == "=" || comparitor == "==" ) {
+    for ( unsigned int i=0; i < limit; ++i ) {
+      if ( current_version[i] != vec[i] ) return false;
+    }
+    for ( unsigned int i=limit; i < current_version.size( ); ++i )
+      if ( current_version[i] > 0 ) return false;
+    return true;
+  } else if ( comparitor == "!=" ) {
+    return ! compare_version("=",vec);
+  } else {
+    throw(AipsError("unknown comparator"));
+  }
+  return false;
+}
+
 } // casac namespace
 
diff -Nru ../trunk.old/gcwrap/tools/utils/utils.xml ./gcwrap/tools/utils/utils.xml
--- ../trunk.old/gcwrap/tools/utils/utils.xml	2016-10-04 14:02:03.000000000 -0400
+++ ./gcwrap/tools/utils/utils.xml	2016-10-04 14:08:44.810154691 -0400
@@ -318,6 +318,60 @@
 
 </method>
 
+<method type="function" name="version">
+<shortdescription>returns four element vector for the version</shortdescription>
+   
+<returns type="intArray"/>
+<description>
+
+Returns a four element vector representing the version (major, minor, patch and feature).
+
+</description>
+</method>
+
+<method type="function" name="version_desc">
+<shortdescription>returns the descriptive version string, e.g. DEV or REL</shortdescription>
+   
+<returns type="string"/>
+<description>
+
+The descriptive string describes a particular packaged version. During a development
+cycle there are different sorts of packaged distributions. For example, a development
+version ("DEV") or a release version ("REL").
+
+</description>
+</method>
+
+<method type="function" name="version_info">
+<shortdescription>Returns the complete version description as a string.</shortdescription>
+   
+<returns type="string"/>
+<description>
+
+Returns a description string that includes the version information and the descriptive string..
+
+</description>
+</method>
+
+<method type="function" name="compare_version">
+<shortdescription>Returns the complete version description as a string.</shortdescription>
+   
+<input>
+    <param type="string" name="comparitor">
+	    <description>what sort of comparison to do, one of &gt;, &lt;, &lt;=, &gt;=, ==, = !=</description>
+    </param>
+    <param type="intArray" name="vec">
+	    <description>vector to use to compare current version number against vec</description>
+    </param>
+</input>
+
+<returns type="bool"/>
+<description>
+
+Returns a description string that includes the version information and the descriptive string..
+
+</description>
+</method>
 
 </tool>
 
