Ignore:
Timestamp:
05/02/11 17:42:21 (14 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: run sd tasks by setting older data format as input

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Automatically run asap2to3 in Scantable constructor when input Scantable is
v2 and the software requires Scantable v3.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r2161 r2162  
    116116  uInt version = tab.keywordSet().asuInt("VERSION");
    117117  if (version != version_) {
    118     throw(AipsError("Unsupported version of ASAP file."));
     118    if ( version == 2 && version_ == 3 ) {
     119      // run asap2to3 command
     120      LogIO os( LogOrigin( "Scantable" ) ) ;
     121      string command="asap2to3" ;
     122      string exec=command+" in="+name ;
     123      string outname=name ;
     124      if ( name.at(name.length()-1) == '/' )
     125        outname = outname.substr( 0, name.length()-1 ) ;
     126      outname += ".asap3" ;
     127      os << LogIO::WARN
     128         << name << " is incompatible data format (Scantable v2)." << endl
     129         << "Running " << command << " to create " << outname << ", " << endl 
     130         << "which is identical to " << name << " but compatible " << endl
     131         << "data format with current software version (Scantable v3)."
     132         << LogIO::POST ; 
     133      int ret = system( string("which "+command+" > /dev/null 2>&1").c_str() ) ;
     134      if ( ret != 0 )
     135        throw(AipsError(command+" is not installed")) ;
     136      os << LogIO::WARN
     137         << "Data will be loaded from " << outname << " instead of "
     138         << name << LogIO::POST ;
     139      system( exec.c_str() ) ;
     140      tab = Table(outname, Table::Update ) ;
     141      //os << "tab.tableName()=" << tab.tableName() << LogIO::POST ;
     142    }
     143    else {
     144      throw(AipsError("Unsupported version of ASAP file."));
     145    }
    119146  }
    120147  if ( type_ == Table::Memory ) {
Note: See TracChangeset for help on using the changeset viewer.