"Fossies" - the Fresh Open Source Software Archive

Member "PerlCDF38_0/testTT2000.pl" (19 Nov 2019, 4620 Bytes) of package /linux/misc/PerlCDF38_0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "testTT2000.pl" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 36_4_vs_37_0.

    1 #!/usr/bin/perl -w
    2 
    3 #
    4 # testTT2000
    5 #
    6 #   This program tests the PerlCDF internal interface.  PerlCDF must be installed.
    7 #   See README.
    8 #
    9 #  Usage:
   10 #     perl testPerlCDFii.pl
   11 #
   12 # Written By:
   13 #
   14 #    Mike Liu
   15 #    ADNET systems
   16 #
   17 #    1 October, 2011
   18 #
   19 #    Version 1.0
   20 #    Modified by: Michael Liu  - 01 October, 2011
   21 #
   22 #############################################################################
   23 
   24 use strict;
   25 use Math::BigInt;
   26 
   27 BEGIN { unshift @INC,'/home/liu/PerlCDF38_0/blib/arch',
   28                      '/home/liu/PerlCDF38_0/blib/lib'; }
   29 use CDF;
   30 
   31 #############################################################################
   32 # Display title.
   33 #############################################################################
   34 
   35 print "\nTesting Perl-CDF Internal/C interface for TT2000 \n\n";
   36 
   37 #############################################################################
   38 # Open CDF.
   39 #############################################################################
   40 
   41 my ($status, $id);
   42 $status = CDF::CDFlib (&OPEN_, &CDF_, "newtest", \$id,
   43                &NULL_);
   44 QuitCDF ("4.0", $status) if ($status < &CDF_OK) ;
   45 
   46 my $zRecStart = 0;
   47 my $zRecCount = 6;
   48 my $zRecInterval = 1;
   49 my @zIndicesA = (0);
   50 my @zCounts = (1);
   51 my @zIntervals = (1);
   52 my @zVarAvalues;
   53 my $var = "tt2000";
   54 $status = CDF::CDFlib (&SELECT_, &zVAR_NAME_, $var,
   55                                 &zVAR_RECNUMBER_, $zRecStart,
   56                                 &zVAR_RECCOUNT_, $zRecCount,
   57                                 &zVAR_RECINTERVAL_, $zRecInterval,
   58                                 &zVAR_DIMINDICES_, \@zIndicesA,
   59                                 &zVAR_DIMCOUNTS_, \@zCounts,
   60                                 &zVAR_DIMINTERVALS_, \@zIntervals,
   61                        &GET_, &zVAR_HYPERDATA_, \@zVarAvalues,
   62                        &NULL_);
   63 QuitCDF ("10.0z", $status) if ($status < &CDF_OK) ;
   64 
   65 my $i;
   66 my $tt2000;
   67 print "TT2000: \n";
   68 for ($i = 0; $i <= $#zVarAvalues; $i++) {
   69   CDF::encodeTT2000($zVarAvalues[$i], $tt2000);
   70   print $i,": ",$zVarAvalues[$i]," => ",$tt2000," \n";
   71 }
   72 
   73 $var = "newI8";
   74 $zRecCount = 4;
   75 @zCounts = (2);
   76 
   77 $status = CDF::CDFlib (&SELECT_, &zVAR_NAME_, $var,
   78                                 &zVAR_RECNUMBER_, $zRecStart,
   79                                 &zVAR_RECCOUNT_, $zRecCount,
   80                                 &zVAR_RECINTERVAL_, $zRecInterval,
   81                                 &zVAR_DIMINDICES_, \@zIndicesA,
   82                                 &zVAR_DIMCOUNTS_, \@zCounts,
   83                                 &zVAR_DIMINTERVALS_, \@zIntervals,
   84                        &GET_, &zVAR_HYPERDATA_, \@zVarAvalues,
   85                        &NULL_);
   86 QuitCDF ("10.0z", $status) if ($status < &CDF_OK) ;
   87 
   88 print "\nINT8: \n";
   89 for ($i = 0; $i <= $#zVarAvalues; $i++) {
   90   print $i,": ",$zVarAvalues[$i]," \n";
   91 }
   92 
   93 #############################################################################
   94 # Close CDF.
   95 #############################################################################
   96 
   97 $status = CDF::CDFlib (&CLOSE_, &CDF_,
   98                &NULL_);
   99 QuitCDF ("28.2", $status) if ($status < &CDF_OK) ;
  100 
  101 #############################################################################
  102 # Successful completion.
  103 #############################################################################
  104 print "All tests completed successfully\n";
  105 
  106 my $tt = 340203790171876765;
  107 my ($y,$m,$d,$h,$n,$s,$l,$u,$o);
  108 CDF::TT2000breakdown($tt,$y,$m,$d,$h,$n,$s,$l,$u,$o);
  109 my $tt1 = "340203790171876765";
  110 my ($y1,$m1,$d1,$h1,$n1,$s1,$l1,$u1,$o1);
  111 CDF::TT2000breakdown($tt1,$y1,$m1,$d1,$h1,$n1,$s1,$l1,$u1,$o1);
  112 #print $y1,"-",$m1,"-",$d1,"T",$h1,":",$n1,":",$s1,".",$l1,$u1,$o1," VS ",$y,"-",$m,"-",$d,"T",$h,":",$n,":",$s,".",$l,$u,$o,"\n";
  113 printf ("%04d-%02d-%02dT%02d:%02d:%02d.%03d%03d%03d VS %04d-%02d-%02dT%02d:%02d:%02d.%03d%03d%03d\n",$y1,$m1,$d1,$h1,$n1,$s1,$l1,$u1,$o1,$y,$m,$d,$h,$n,$s,$l,$u,$o);
  114 exit;
  115 
  116 #############################################################################
  117 # QuitCDF.
  118 #############################################################################
  119 sub QuitCDF {
  120     my ($where, $status)=@_;
  121 
  122   print "Aborting at $where ...\n";
  123   if ($status < &CDF_OK) {
  124     my $text;
  125     CDF::CDFlib (&SELECT_, &CDF_STATUS_, $status,
  126            &GET_, &STATUS_TEXT_, \$text,
  127            &NULL_);
  128     print $text;
  129   }
  130   CDF::CDFlib (&CLOSE_, &CDF_,
  131       &NULL_);
  132   print "...test aborted.\n";
  133   exit;
  134     
  135 }#endsub QuitCDF
  136 
  137 #############################################################################
  138 #  QuitEPOCH
  139 #############################################################################
  140 sub QuitEPOCH {
  141   my ($where) = @_;
  142   print "Aborting at $where...test aborted.\n";
  143   exit;
  144 
  145 }#endsub QuitEPOCH