"Fossies" - the Fresh Open Source Software Archive

Member "PerlCDF38_0/testPerlCDFii.pl" (23 Dec 2019, 49672 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 "testPerlCDFii.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 # testPerlCDFii
    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 #    Emily A. Greene
   15 #    NSSDC / Hughes STX
   16 #
   17 #    17 October, 1995
   18 #
   19 #    Version 1.0
   20 #    Modified by: Michael Liu  - 20 March, 1998
   21 #    Version 2.0
   22 #    Modified by: Michael Liu  - 07 January, 2005
   23 #
   24 #############################################################################
   25 #
   26 #  Translated from qst2ic.c v. 1.10 by J. Love
   27 #
   28 #  Differences include:
   29 #     z Variable is 5 strings each 8 characters long not a 40 character buffer
   30 #          tests changed accordingly
   31 #     maxiumum records written is a variable
   32 #     Arrays are all 1 Dimensional.  2 dimensionality handled within CDF.
   33 #     Added section confirming rVARs recCount, etc.
   34 #     Added a few informational messages
   35 #     Tests Epoch routines
   36 # Note: As Perl uses double, a variable of data type CDF_REAL4/FLOAT will 
   37 #   cause some minor value deviation due to different floating-point type 
   38 #   representations. If the value is returned from the CDF's C routine 
   39 #   and compared with Perl value, an epsilon is used for checkng their
   40 #   equality. 10**(-9) is used for double and 10**(-5) for 
   41 #   float/real. No problem for CDF_REAL8 data type.
   42 #     
   43 #############################################################################
   44 
   45 use strict;
   46 use Math::BigInt;
   47 
   48 BEGIN { unshift @INC,'/home/liu/PerlCDF38_0/blib/arch',
   49                      '/home/liu/PerlCDF38_0/blib/lib'; }
   50 use CDF;
   51 
   52 my $N_DIMS = 2;
   53 my $DIM_0_SIZE = 2;
   54 my $DIM_1_SIZE = 3;
   55 
   56 my $zN_DIMSa = 1;
   57 my $zDIM_0_SIZEa = 5;
   58 my $zNUM_ELEMSa = 8;
   59 
   60 my $encoding = &NETWORK_ENCODING;
   61 my $actual_encoding = &NETWORK_ENCODING;
   62 my $majority = &ROW_MAJOR;
   63 my $compression = &GZIP_COMPRESSION;
   64 my @compressionLevel = (6);
   65 my $numDims = $N_DIMS;
   66 my @dimSizes = ( $DIM_0_SIZE, $DIM_1_SIZE );
   67 my $zNumDimsA = $zN_DIMSa;
   68 my @zDimSizesA = ( $zDIM_0_SIZEa );
   69 my $var1DataType = &CDF_INT2;
   70 my $var1DataTypeNew = &CDF_UINT2 ;
   71 my $var2DataType = &CDF_REAL8 ;
   72 my $zVarAdataType = &CDF_CHAR ;
   73 my $zVarAdataTypeNew = &CDF_UCHAR ;
   74 my $var1NumElements = 1 ;
   75 my $var1NumElementsNew = 1 ;
   76 my $var2NumElements = 1 ;
   77 my $zVarAnumElements = $zNUM_ELEMSa ;
   78 my $zVarAnumElementsNew = $zNUM_ELEMSa ;
   79 my @var1Values = (1,2,3,4,5,6);
   80 my @var2Values = (1.,2.,3.,4.,5.,6.);
   81 my @zVarAvalues = (
   82   '11111111',
   83   '2222222',
   84   '333333',
   85   '44444',
   86   '5555'
   87 );
   88 my @entry1Values = (1,2,3,4,5,6);
   89 my $recNum = 0 ;
   90 my $recStart = 0 ;
   91 my $recCount = 1 ;
   92 my $recInterval = 1 ;
   93 my @counts = ( $DIM_0_SIZE, $DIM_1_SIZE );
   94 my @intervals = ( 1, 1 );
   95 my $zRecNum =  0;
   96 my $zRecStart =  0;
   97 my $zRecCount =  1;
   98 my $zRecInterval = 1 ;
   99 my @zCounts = ( $zDIM_0_SIZEa );
  100 my @zIntervals = ( 1 );
  101 my $entryNum = 2 ;
  102 my $attrScope = &GLOBAL_SCOPE ;
  103 my $attrScope2 = &VARIABLE_SCOPE ;
  104 my $attrScope3 = &VARIABLE_SCOPE ;
  105 my $attrScope4 = &VARIABLE_SCOPE ;
  106 my $entryDataType = &CDF_INT2 ;
  107 my $entryDataTypeNew = &CDF_UINT2 ;
  108 my $entryNumElems = 1 ;
  109 my $entryValue = 1 ;
  110 my $var1RecVariance = &VARY ;
  111 my $var1RecVarianceNew = &NOVARY ;
  112 my $var2RecVariance = &VARY ;
  113 my $zVarArecVariance = &VARY ;
  114 my $zVarArecVarianceNew = &NOVARY ;
  115 my @var1DimVariances = ( &VARY, &VARY );
  116 my @var1DimVariancesNew = ( &NOVARY, &NOVARY );
  117 my @var2DimVariances = ( &VARY, &VARY );
  118 my @zVarAdimVariances = ( &VARY );
  119 my @zVarAdimVariancesNew = ( &NOVARY );
  120 my $var1Name = "VAR1a";
  121 my $var2Name = "VAR2a";
  122 my $zVarAname = "zVARa1";
  123 my $new_var1Name = "VAR1b";
  124 my $new_var2Name = "VAR2b";
  125 my $new_zVarAname = "zVARa2";
  126 my $attrName = "ATTR1";
  127 my $attrName2 = "ATTR2";
  128 my $attrName3 = "ATTR3";
  129 my $attrName4 = "ATTR4";
  130 my $new_attrName = "ATTR1a";
  131 my $rEntryValue =  4 ;
  132 my $zEntryValue = 4.0 ;
  133 my $pad1 = -999 ;
  134 my $pad2 = -8.0 ;
  135 my $pad3 =  "********" ;
  136 my $extendRecs1 = 3;
  137 my $extendRecs2 = 4;
  138 my $extendRecs3 = 5;
  139 my $allocRecs1 = 10 ;
  140 my $allocRecs2 = 15 ;
  141 my $allocRecs3 = 8 ;
  142 my $nRvars = 2 ;
  143 my @rVarNs = ( 0, 1 );
  144 my @rVarsRecBuffer = (
  145   1,2,3,4,5,6,2.2,4.2,6.2,8.2,10.2,12.2
  146 );
  147 my $nZvars = 1 ;
  148 my @zVarNs = ( 0 );
  149 my @zVarsRecBuffer = (
  150   'aaaaaaa',
  151   'bbbbbb',
  152   'ccccc',
  153   'dddd',
  154   'eee'
  155 );
  156 
  157 #############################################################################
  158 # Display title.
  159 #############################################################################
  160 
  161 print "\nTesting Perl-CDF Internal/C interface\n\n";
  162 
  163 #############################################################################
  164 # Create CDF. 
  165 #############################################################################
  166 # Uncomment the following line if you want to create a V2.7 CDF file.
  167 #CDF::CDFsetFileBackward(1);
  168 
  169 my $id; my $status;
  170 $status = CDF::CDFlib(&CREATE_, &CDF_, "TEST",$numDims,\@dimSizes,\$id,
  171               &PUT_, &CDF_ENCODING_, $encoding,
  172                 &CDF_MAJORITY_, $majority,
  173 #               &CDF_COMPRESSION_, $compression, \@compressionLevel,
  174               &NULL_);
  175 if ($status < &CDF_OK) {
  176   if ($status == &CDF_EXISTS) {
  177     $status = CDF::CDFlib (&OPEN_, &CDF_, "TEST", \$id,
  178                &NULL_);
  179     QuitCDF("1.0", $status) if ($status < &CDF_OK) ;
  180 
  181     $status = CDF::CDFlib (&DELETE_, &CDF_,
  182                &NULL_);
  183     QuitCDF ("1.1", $status) if ($status < &CDF_OK) ;
  184 
  185     $status = CDF::CDFlib (&CREATE_, &CDF_, "TEST", $numDims, \@dimSizes, \$id,
  186                &PUT_, &CDF_ENCODING_, $encoding,
  187                  &CDF_MAJORITY_, $majority,
  188 #                    &CDF_COMPRESSION_, $compression,
  189 #                          \@compressionLevel,
  190                    &NULL_);
  191     QuitCDF ("1.2", $status) if ($status < &CDF_OK) ;
  192   }
  193   else {
  194     QuitCDF ("1.3", $status);
  195     }
  196 }
  197 
  198 #############################################################################
  199 # Create variables and set/confirm cache sizes, etc.
  200 #############################################################################
  201 
  202 my ($var1Num_out, $var2Num_out, $zVarAnum_out);
  203 $status = CDF::CDFlib (&CREATE_, &rVAR_, $var1Name, $var1DataType, $var1NumElements,
  204                 $var1RecVariance, \@var1DimVariances,
  205                 \$var1Num_out, 
  206                &PUT_, &rVAR_PADVALUE_, \$pad1,
  207                &NULL_);
  208 QuitCDF ("2.0a", $status) if ($status < &CDF_OK) ;
  209 
  210 $status = CDF::CDFlib (&CREATE_, &rVAR_, $var2Name, $var2DataType, $var2NumElements,
  211                 $var2RecVariance, \@var2DimVariances,
  212                 \$var2Num_out,
  213                &PUT_, &rVAR_PADVALUE_, \$pad2,
  214                &NULL_);
  215 QuitCDF ("2.0b", $status) if ($status < &CDF_OK) ;
  216 
  217 $status = CDF::CDFlib (&CREATE_, &zVAR_, $zVarAname, $zVarAdataType, $zVarAnumElements,
  218                 $zNumDimsA, \@zDimSizesA, $zVarArecVariance,
  219                 \@zVarAdimVariances, \$zVarAnum_out,
  220                &PUT_, &zVAR_PADVALUE_, \$pad3,
  221                    &NULL_);
  222 QuitCDF ("2.0c", $status) if ($status < &CDF_OK) ;
  223 
  224 my ($cacheOut1, $cacheOut2, $cacheOut3);
  225 my ($pad1out, $pad2out, $pad3out);
  226 $status = CDF::CDFlib (&SELECT_, &CDF_, $id,
  227                 &rVAR_, 0,
  228                &GET_, &rVAR_PADVALUE_, \$pad1out,
  229                &SELECT_, &rVAR_, 1,
  230                &GET_, &rVAR_PADVALUE_, \$pad2out,
  231                &SELECT_, &zVAR_, 0,
  232                &GET_, &zVAR_PADVALUE_, \$pad3out,
  233                &NULL_);
  234 QuitCDF ("2a.0", $status) if ($status < &CDF_OK) ;
  235 QuitCDF ("2a.3a", $status) if ($pad1out != $pad1) ;
  236 QuitCDF ("2a.3b", $status) if ($pad2out != $pad2) ;
  237 QuitCDF ("2a.3c", $status) if ($pad3out ne $pad3) ;
  238 
  239 $status = CDF::CDFlib (&SELECT_, &rVAR_, 0,
  240                 &rVAR_CACHESIZE_, 4,
  241                 &zVAR_, 0,
  242                 &zVAR_CACHESIZE_, 8,
  243                &NULL_);
  244 QuitCDF ("2a.4", $status) if ($status < &CDF_OK) ;
  245 
  246 #############################################################################
  247 # Modify variables.
  248 #############################################################################
  249 
  250 $status = CDF::CDFlib (&SELECT_, &rVAR_, 0,
  251                &PUT_, &rVAR_DATASPEC_, $var1DataTypeNew, $var1NumElementsNew,
  252                  &rVAR_RECVARY_, $var1RecVarianceNew,
  253                  &rVAR_DIMVARYS_, \@var1DimVariancesNew,
  254                  &rVAR_INITIALRECS_, 1,
  255                &SELECT_, &zVAR_, 0,
  256                &PUT_, &zVAR_DATASPEC_, $zVarAdataTypeNew, $zVarAnumElementsNew,
  257                  &zVAR_RECVARY_, $zVarArecVarianceNew,
  258                  &zVAR_DIMVARYS_, \@zVarAdimVariancesNew,
  259                  &zVAR_INITIALRECS_, 1,
  260                &NULL_);
  261 QuitCDF ("2c.0", $status) if ($status < &CDF_OK) ;
  262 
  263 #############################################################################
  264 # Close CDF.
  265 #############################################################################
  266 
  267 $status = CDF::CDFlib (&CLOSE_, &CDF_,
  268                &NULL_);
  269 QuitCDF ("3.0", $status) if ($status < &CDF_OK) ;
  270 
  271 #############################################################################
  272 # Reopen CDF.
  273 #############################################################################
  274 
  275 $status = CDF::CDFlib (&OPEN_, &CDF_, "TEST", \$id,
  276                &NULL_);
  277 QuitCDF ("4.0", $status) if ($status < &CDF_OK) ;
  278 
  279 #############################################################################
  280 # Delete CDF.
  281 #############################################################################
  282 $status = CDF::CDFlib (&DELETE_, &CDF_,
  283                &NULL_);
  284 QuitCDF ("5.0", $status) if ($status < &CDF_OK) ;
  285 
  286 #############################################################################
  287 # Create CDF again (previous delete will allow this).
  288 #############################################################################
  289 
  290 $status = CDF::CDFlib (&CREATE_, &CDF_, "TEST", $numDims, \@dimSizes, \$id,
  291                &PUT_, &CDF_ENCODING_, $encoding,
  292                  &CDF_MAJORITY_, $majority,
  293 #                &CDF_COMPRESSION_, $compression, \@compressionLevel,
  294                &NULL_);
  295 QuitCDF ("6.0", $status) if ($status < &CDF_OK) ;
  296 
  297 # Uncomment the following lines if MD5 checksum option is needed.
  298 $status = CDF::CDFlib (&PUT_, &CDF_CHECKSUM_, &MD5_CHECKSUM,
  299                        &NULL_);
  300 QuitCDF ("6.1", $status) if ($status < &CDF_OK) ;
  301 # Or, use this way:
  302 #$status = CDF::CDFsetChecksum ($id, &MD5_CHECKSUM);
  303 #QuitCDF ("6.1", $status) if ($status < &CDF_OK) ;
  304 
  305 #############################################################################
  306 # Create variables.
  307 #############################################################################
  308 
  309 $status = CDF::CDFlib (&CREATE_, &rVAR_, $var1Name, $var1DataType, $var1NumElements,
  310                  $var1RecVariance, \@var1DimVariances,
  311                  \$var1Num_out,
  312                &PUT_, &rVAR_ALLOCATERECS_, $allocRecs1,
  313                  &rVAR_BLOCKINGFACTOR_, $extendRecs1,
  314                &NULL_);
  315 QuitCDF ("7.0a", $status) if ($status < &CDF_OK) ;
  316 
  317 $status = CDF::CDFlib (&CREATE_, &rVAR_, $var2Name, $var2DataType, $var2NumElements,
  318                  $var2RecVariance, \@var2DimVariances,
  319                  \$var2Num_out,
  320                &PUT_, &rVAR_ALLOCATERECS_, $allocRecs2,
  321                  &rVAR_BLOCKINGFACTOR_, $extendRecs2,
  322                &NULL_);
  323 QuitCDF ("7.0b", $status) if ($status < &CDF_OK) ;
  324 
  325 $status = CDF::CDFlib (&CREATE_, &zVAR_, $zVarAname, $zVarAdataType, $zVarAnumElements,
  326                 $zNumDimsA, \@zDimSizesA, $zVarArecVariance,
  327                 \@zVarAdimVariances, \$zVarAnum_out,
  328                    &PUT_, &zVAR_ALLOCATERECS_, $allocRecs3,
  329                  &zVAR_BLOCKINGFACTOR_, $extendRecs3,
  330                &NULL_);
  331 QuitCDF ("7.0c", $status) if ($status < &CDF_OK) ;
  332 
  333 #############################################################################
  334 # PUT to variables.
  335 #############################################################################
  336 
  337 $status = CDF::CDFlib (&SELECT_, &rVARs_RECNUMBER_, $recNum,
  338         &NULL_);
  339 QuitCDF ("8.0", $status) if ($status < &CDF_OK) ;
  340 
  341 my ($x0, $x1, $i, @indices, $temp1, $temp2);
  342 for ($x0 = 0; $x0 < $DIM_0_SIZE; $x0++) {
  343    for ($x1 = 0; $x1 < $DIM_1_SIZE; $x1++) {
  344       $indices[0] = $x0;
  345       $indices[1] = $x1;
  346       $temp1 = $var1Values[$x0*$DIM_1_SIZE + $x1];
  347       $temp2 = $var2Values[$x0*$DIM_1_SIZE + $x1];
  348       $status = CDF::CDFlib (&SELECT_, &rVARs_DIMINDICES_, \@indices,
  349                       &rVAR_, $var1Num_out,
  350                  &PUT_, &rVAR_DATA_, \$temp1,
  351                  &SELECT_, &rVAR_, $var2Num_out,
  352                  &PUT_, &rVAR_DATA_, \$temp2,
  353                  &NULL_);
  354       QuitCDF ("8.1", $status) if ($status < &CDF_OK) ;
  355    }
  356  }
  357 my $maxRecWritten = 0;
  358 
  359 $status = CDF::CDFlib (&SELECT_, &zVAR_, $zVarAnum_out,
  360                 &zVAR_RECNUMBER_, $zRecNum,
  361                &NULL_);
  362 QuitCDF ("8.0z", $status) if ($status < &CDF_OK) ;
  363 
  364 my @zIndicesA;
  365 for ($x0 = 0; $x0 < $zDIM_0_SIZEa; $x0++) {
  366    $zIndicesA[0] = $x0;
  367    $temp1 = $zVarAvalues[$x0];
  368    $status = CDF::CDFlib (&SELECT_, &zVAR_DIMINDICES_, \@zIndicesA,
  369               &PUT_, &zVAR_DATA_, \$temp1,
  370               &NULL_);
  371    QuitCDF ("8.1z", $status) if ($status < &CDF_OK) ;
  372 }
  373 
  374 #############################################################################
  375 # GET from the variables.
  376 #############################################################################
  377 
  378 my ($var1Value_out, $var2Value_out);
  379 for ($x0 = 0; $x0 < $DIM_0_SIZE; $x0++) {
  380    for ($x1 = 0; $x1 < $DIM_1_SIZE; $x1++) {
  381       $indices[0] = $x0;
  382       $indices[1] = $x1;
  383       $status = CDF::CDFlib (&SELECT_, &rVARs_DIMINDICES_, \@indices,
  384                       &rVAR_, $var1Num_out,
  385                  &GET_, &rVAR_DATA_, \$var1Value_out,
  386                  &SELECT_, &rVAR_, $var2Num_out,
  387                  &GET_, &rVAR_DATA_, \$var2Value_out,
  388                  &NULL_);
  389       QuitCDF ("9.0", $status) if ($status < &CDF_OK) ;
  390 
  391       QuitCDF ("9.1", $status) if ($var1Value_out != $var1Values[$x0*$DIM_1_SIZE + $x1]) ;
  392       QuitCDF ("9.2", $status) if ($var2Value_out != $var2Values[$x0*$DIM_1_SIZE + $x1]) ;
  393    }
  394  }
  395 
  396 my $zVarAvalue_out;
  397 for ($x0 = 0; $x0 < $zDIM_0_SIZEa; $x0++) {
  398    $zIndicesA[0] = $x0;
  399    $status = CDF::CDFlib (&SELECT_, &zVAR_DIMINDICES_, \@zIndicesA,
  400               &GET_, &zVAR_DATA_, \$zVarAvalue_out,
  401               &NULL_);
  402    QuitCDF ("9.1z", $status) if ($status < &CDF_OK) ;
  403    QuitCDF ("9.2z", $status) if ($zVarAvalue_out ne $zVarAvalues[$x0]) ;
  404 }
  405 
  406 #############################################################################
  407 # HyperPUT to the variables.
  408 #############################################################################
  409 
  410 for ($x0 = 0; $x0 < $DIM_0_SIZE; $x0++) {
  411    for ($x1 = 0; $x1 < $DIM_1_SIZE; $x1++) {
  412       $var1Values[$x0*$DIM_1_SIZE + $x1] = -$var1Values[$x0*$DIM_1_SIZE + $x1];
  413       $var2Values[$x0*$DIM_1_SIZE + $x1] = -$var2Values[$x0*$DIM_1_SIZE + $x1];
  414    }
  415  }
  416 
  417 $indices[0] = 0;
  418 $indices[1] = 0;
  419 
  420 $status = CDF::CDFlib (&SELECT_, &rVARs_RECNUMBER_, $recStart,
  421                 &rVARs_RECCOUNT_, $recCount,
  422                 &rVARs_RECINTERVAL_, $recInterval,
  423                 &rVARs_DIMINDICES_, \@indices,
  424                 &rVARs_DIMCOUNTS_, \@counts,
  425                 &rVARs_DIMINTERVALS_, \@intervals,
  426                 &rVAR_, $var1Num_out,
  427                &PUT_, &rVAR_HYPERDATA_, \@var1Values,
  428                &SELECT_, &rVAR_, $var2Num_out,
  429                &PUT_, &rVAR_HYPERDATA_, \@var2Values,
  430                &NULL_);
  431 QuitCDF ("10.0", $status) if ($status < &CDF_OK) ;
  432 #for ($x0 = 0; $x0 < $zDIM_0_SIZEa; $x0++) {
  433 #      $zVarAvalues[$x0] = $zVarAvalues[$x0] + $zVarAvalues[0];
  434 #}
  435 $zIndicesA[0] = 0; 
  436 $status = CDF::CDFlib (&SELECT_, &zVAR_RECNUMBER_, $zRecStart,
  437                 &zVAR_RECCOUNT_, $zRecCount,
  438                 &zVAR_RECINTERVAL_, $zRecInterval,
  439                 &zVAR_DIMINDICES_, \@zIndicesA,
  440                 &zVAR_DIMCOUNTS_, \@zCounts,
  441                 &zVAR_DIMINTERVALS_, \@zIntervals,
  442                &PUT_, &zVAR_HYPERDATA_, \@zVarAvalues,
  443                &NULL_);
  444 QuitCDF ("10.0z", $status) if ($status < &CDF_OK) ;
  445 ############################################################################g
  446 # HyperGET from variables.
  447 #############################################################################
  448 
  449 my (@var1Buffer_out, @var2Buffer_out);
  450 $status = CDF::CDFlib (SELECT_, &rVARs_RECNUMBER_, $recStart,
  451                 &rVARs_RECCOUNT_, $recCount,
  452                 &rVARs_RECINTERVAL_, $recInterval,
  453                 &rVARs_DIMINDICES_, \@indices,
  454                 &rVARs_DIMCOUNTS_, \@counts,
  455                 &rVARs_DIMINTERVALS_, \@intervals,
  456                 &rVAR_, $var1Num_out,
  457                &GET_, &rVAR_HYPERDATA_, \@var1Buffer_out,
  458                &SELECT_, &rVAR_, $var2Num_out,
  459                &GET_, &rVAR_HYPERDATA_, \@var2Buffer_out,
  460                &NULL_);
  461 QuitCDF ("11.0", $status) if ($status < &CDF_OK) ;
  462 
  463 for ($x0 = 0; $x0 < $DIM_0_SIZE; $x0++) {
  464    for ($x1 = 0; $x1 < $DIM_1_SIZE; $x1++) {
  465     QuitCDF ("11.1", $status) if ($var1Buffer_out[$x0*$DIM_1_SIZE + $x1] != $var1Values[$x0*$DIM_1_SIZE + $x1]);
  466     QuitCDF ("11.2", $status) if ($var2Buffer_out[$x0*$DIM_1_SIZE + $x1] != $var2Values[$x0*$DIM_1_SIZE + $x1]);
  467    }
  468   }
  469   
  470 #############################################################################
  471 # Confirm hyper parameters for a rVariables.
  472 #############################################################################
  473 
  474 my ($recStartOut, $recCountOut, $recIntervalOut, @indicesOut, @countsOut, @intervalsOut);
  475 $status = CDF::CDFlib (&SELECT_, &rVAR_NAME_, $var1Name,
  476                &CONFIRM_, &rVARs_RECNUMBER_, \$recStartOut,
  477                  &rVARs_RECCOUNT_, \$recCountOut,
  478                  &rVARs_RECINTERVAL_, \$recIntervalOut,
  479                  &rVARs_DIMINDICES_, \@indicesOut,
  480                  &rVARs_DIMCOUNTS_, \@countsOut,
  481                  &rVARs_DIMINTERVALS_, \@intervalsOut,
  482                &NULL_);
  483 QuitCDF ("11a.0r", $status) if ($status < &CDF_OK) ;
  484 
  485 QuitCDF ("11a.1r", $status) if ($recStartOut != $recStart) ;
  486 QuitCDF ("11a.2r", $status) if ($recCountOut != $recCount) ;
  487 QuitCDF ("11a.3r", $status) if ($recIntervalOut != $recInterval) ;
  488 
  489 my $dimN;
  490 for ($dimN = 0; $dimN < $N_DIMS; $dimN++) {
  491    QuitCDF ("11a.4r", $status) if ($indicesOut[$dimN] != $indices[$dimN]) ;
  492    QuitCDF ("11a.5r", $status) if ($countsOut[$dimN] != $counts[$dimN]) ;
  493    QuitCDF ("11a.6r", $status) if ($intervalsOut[$dimN] != $intervals[$dimN]) ;
  494 }
  495 
  496 #############################################################################
  497 
  498 my @zVarAbuffer_out;
  499 $status = CDF::CDFlib (&GET_, &zVAR_HYPERDATA_, \@zVarAbuffer_out,
  500                &NULL_);
  501 QuitCDF ("11.0z", $status) if ($status < &CDF_OK) ;
  502 
  503 for ($x0 = 0; $x0 < $zDIM_0_SIZEa; $x0++) {
  504     QuitCDF ("11.1z", $status) if ($zVarAbuffer_out[$x0] ne $zVarAvalues[$x0]);
  505  }
  506 
  507 #############################################################################
  508 # Confirm hyper parameters for a zVariable.
  509 #############################################################################
  510 
  511 $status = CDF::CDFlib (&CONFIRM_, &zVAR_RECNUMBER_, \$recStartOut,
  512                  &zVAR_RECCOUNT_, \$recCountOut,
  513                  &zVAR_RECINTERVAL_, \$recIntervalOut,
  514                  &zVAR_DIMINDICES_, \@indicesOut,
  515                  &zVAR_DIMCOUNTS_, \@countsOut,
  516                  &zVAR_DIMINTERVALS_, \@intervalsOut,
  517                &NULL_);
  518 QuitCDF ("11a.0", $status) if ($status < &CDF_OK) ;
  519 
  520 QuitCDF ("11a.1", $status) if ($recStartOut != $zRecStart) ;
  521 QuitCDF ("11a.2", $status) if ($recCountOut != $zRecCount) ;
  522 QuitCDF ("11a.3", $status) if ($recIntervalOut != $zRecInterval) ;
  523 
  524 for ($dimN = 0; $dimN < $zN_DIMSa; $dimN++) {
  525    QuitCDF ("11a.4", $status) if ($indicesOut[$dimN] != $zIndicesA[$dimN]) ;
  526    QuitCDF ("11a.5", $status) if ($countsOut[$dimN] != $zCounts[$dimN]) ;
  527    QuitCDF ("11a.6", $status) if ($intervalsOut[$dimN] != $zIntervals[$dimN]) ;
  528 }
  529 
  530 #############################################################################
  531 # Set/confirm sequential access position for a zVariable (and read/write a
  532 # value).
  533 #############################################################################
  534 
  535 my $recNumOut;
  536 
  537 $status = CDF::CDFlib (&SELECT_, &zVAR_SEQPOS_, $zRecStart, \@zIndicesA,
  538                &GET_, &zVAR_SEQDATA_, \$zVarAvalue_out,
  539                        &PUT_, &zVAR_SEQDATA_, \$zVarAvalue_out,
  540                &CONFIRM_, &zVAR_SEQPOS_, \$recNumOut, \@indicesOut,
  541                &NULL_);
  542 QuitCDF ("11b.0", $status) if ($status < &CDF_OK) ;
  543 
  544 QuitCDF ("11b.1", $status) if ($recNumOut != $zRecStart) ;
  545 QuitCDF ("11b.2", $status) if ($indicesOut[0] != $zIndicesA[0] + 2) ;
  546 
  547 #############################################################################
  548 # Create attributes.
  549 #############################################################################
  550 
  551 my $attrNum_out;
  552 $status = CDF::CDFlib (&CREATE_, &ATTR_, $attrName, $attrScope, \$attrNum_out,
  553                 &ATTR_, $attrName2, $attrScope2, \$attrNum_out,
  554                 &ATTR_, $attrName3, $attrScope3, \$attrNum_out,
  555                 &ATTR_, $attrName4, $attrScope4, \$attrNum_out,
  556                &NULL_);
  557 QuitCDF ("12.0", $status) if ($status < &CDF_OK) ;
  558 
  559 #############################################################################
  560 # PUT to attributes.
  561 #############################################################################
  562 
  563 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
  564                 &gENTRY_, $entryNum,
  565                &PUT_, &gENTRY_DATA_, $entryDataType, $entryNumElems,
  566                      \$entryValue,
  567                &SELECT_, &ATTR_, 1,
  568                 &rENTRY_NAME_, $var2Name,
  569                &PUT_, &rENTRY_DATA_, &CDF_BYTE, 1, \$rEntryValue,
  570                &SELECT_, &ATTR_, 2,
  571                 &zENTRY_NAME_, $zVarAname,
  572                &PUT_, &zENTRY_DATA_, &CDF_REAL8, 1, \$zEntryValue,
  573                &SELECT_, &ATTR_, 3,
  574                &PUT_, &zENTRY_DATA_, &CDF_INT2, 6, \@entry1Values,
  575                &NULL_);
  576 QuitCDF ("13.0", $status) if ($status < &CDF_OK) ;
  577 
  578 #############################################################################
  579 # Confirm entry numbers.
  580 #############################################################################
  581 
  582 my ($entryNumOut1, $entryNumOut2, $entryNumOut3);
  583 $status = CDF::CDFlib (&CONFIRM_, &gENTRY_, \$entryNumOut1,
  584                  &rENTRY_, \$entryNumOut2,
  585                  &zENTRY_, \$entryNumOut3,
  586                &NULL_);
  587 QuitCDF ("13a.0", $status) if ($status < &CDF_OK) ;
  588 
  589 QuitCDF ("13a.1", $status) if ($entryNumOut1 != 1) ;
  590 QuitCDF ("13a.2", $status) if ($entryNumOut2 != 1) ;
  591 QuitCDF ("13a.3", $status) if ($entryNumOut3 != 0) ;
  592 
  593 #############################################################################
  594 # GET from attributes.
  595 #############################################################################
  596 
  597 my ($entryValue_out, $rEntryValueOut, $zEntryValueOut, @zEntryValuesOut);
  598 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
  599                 &gENTRY_, $entryNum,
  600                &CONFIRM_, &CURgENTRY_EXISTENCE_,
  601                &GET_, &gENTRY_DATA_, \$entryValue_out,
  602                &NULL_);
  603 QuitCDF ("14.0.1", $status) if ($status < &CDF_OK) ;
  604 
  605 $status = CDF::CDFlib (&SELECT_, &ATTR_, 1,
  606                 &rENTRY_, 1,
  607                &CONFIRM_, &CURrENTRY_EXISTENCE_,
  608                &GET_, &rENTRY_DATA_, \$rEntryValueOut,
  609                &NULL_);
  610 QuitCDF ("14.0.2", $status) if ($status < &CDF_OK) ;
  611 
  612 $status = CDF::CDFlib (&SELECT_, &ATTR_, 2,
  613                 &zENTRY_, 0,
  614                &CONFIRM_, &CURzENTRY_EXISTENCE_,
  615                &GET_, &zENTRY_DATA_, \$zEntryValueOut,
  616                &NULL_);
  617 QuitCDF ("14.0.3", $status) if ($status < &CDF_OK) ;
  618 QuitCDF ("14.1", $status) if ($entryValue_out != $entryValue) ;
  619 QuitCDF ("14.2", $status) if ($rEntryValue != $rEntryValueOut) ;
  620 QuitCDF ("14.3", $status) if ($zEntryValue != $zEntryValueOut) ;
  621 
  622 $status = CDF::CDFlib (&SELECT_, &ATTR_, 3,
  623                                 &zENTRY_, 0,
  624                        &CONFIRM_, &CURzENTRY_EXISTENCE_,
  625                        &GET_, &zENTRY_DATA_, \@zEntryValuesOut,
  626                        &NULL_);
  627 QuitCDF ("14.4.3", $status) if ($status < &CDF_OK) ;
  628 for ($i=0; $i<6; $i++) {
  629   QuitCDF ("14.4", $status) if ($entry1Values[$i] != $zEntryValuesOut[$i]) ;
  630 }
  631 #############################################################################
  632 # Confirm existence of variables/attributes/entries.
  633 #############################################################################
  634 
  635 $status = CDF::CDFlib (&CONFIRM_, &zVAR_EXISTENCE_, $zVarAname,
  636                  &rVAR_EXISTENCE_, $var1Name,
  637                  &ATTR_EXISTENCE_, $attrName3,
  638                &NULL_);
  639 QuitCDF ("14a.0", $status) if ($status < &CDF_OK) ;
  640 
  641 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
  642                &CONFIRM_, &gENTRY_EXISTENCE_, $entryNum,
  643                &SELECT_, &ATTR_, 1,
  644                &CONFIRM_, &rENTRY_EXISTENCE_, 1,
  645                &SELECT_, &ATTR_, 2,
  646                &CONFIRM_, &zENTRY_EXISTENCE_, 0,
  647                &NULL_);
  648 QuitCDF ("14a.1", $status) if ($status < &CDF_OK) ;
  649 
  650 #############################################################################
  651 # Get CDF documentation.
  652 #############################################################################
  653 
  654 my ($version_out, $release_out, $increment_out, $subincrement_out, $CopyRightText);
  655 my $lastUpdated;
  656 $status = CDF::CDFlib (&GET_, &LIB_VERSION_, \$version_out,
  657                  &LIB_RELEASE_, \$release_out,
  658                  &LIB_INCREMENT_, \$increment_out,
  659                  &LIB_subINCREMENT_, \$subincrement_out,
  660                  &LIB_COPYRIGHT_, \$CopyRightText,
  661                  &CDF_LEAPSECONDLASTUPDATED_, \$lastUpdated,
  662                &NULL_);
  663 QuitCDF ("15.0", $status) if ($status < &CDF_OK) ;
  664 print "CDF Library Version $version_out, Release $release_out
  665 Increment $increment_out and subIncrement $subincrement_out
  666 $CopyRightText\n";
  667 print "Leap second LastUpdated: $lastUpdated\n";
  668 
  669 #############################################################################
  670 # Inquire CDF.
  671 #############################################################################
  672 
  673 my ($formatOut, $numDims_out, @dimSizes_out, $encoding_out, $majority_out);
  674 my ($maxRec_out, $numRvars, $numZvars, $numAttrs_out);
  675 $status = CDF::CDFlib (&GET_, &CDF_FORMAT_, \$formatOut,
  676                  &rVARs_NUMDIMS_, \$numDims_out,
  677                  &rVARs_DIMSIZES_, \@dimSizes_out,
  678                  &CDF_ENCODING_, \$encoding_out,
  679                  &CDF_MAJORITY_, \$majority_out,
  680                  &rVARs_MAXREC_, \$maxRec_out,
  681                  &CDF_NUMrVARS_, \$numRvars,
  682                  &CDF_NUMzVARS_, \$numZvars,
  683                  &CDF_NUMATTRS_, \$numAttrs_out,
  684                &NULL_);
  685 QuitCDF ("16.0", $status) if ($status < &CDF_OK) ;
  686 
  687 QuitCDF ("16.1o", $status) if ($formatOut != &SINGLE_FILE) ;
  688 QuitCDF ("16.1", $status) if ($numDims_out != $numDims) ;
  689 
  690 my $x;
  691 for ($x = 0; $x < $N_DIMS; $x++) {
  692    QuitCDF ("16.2", $status) if ($dimSizes_out[$x] != $dimSizes[$x]) ;
  693    }
  694 QuitCDF ("16.3", $status) if ($encoding_out != $actual_encoding) ;
  695 QuitCDF ("16.4", $status) if ($majority_out != $majority) ;
  696 QuitCDF ("16.5", $status) if ($maxRec_out != $maxRecWritten) ;
  697 QuitCDF ("16.6", $status) if ($numRvars != 2) ;
  698 QuitCDF ("16.6z", $status) if ($numZvars != 1) ;
  699 QuitCDF ("16.7", $status) if ($numAttrs_out != 4) ;
  700 
  701 #############################################################################
  702 # Inquire numbers.
  703 #############################################################################
  704 
  705 my ($varNum_out1, $varNum_out2);
  706 $status = CDF::CDFlib (&GET_, &ATTR_NUMBER_, $attrName3, \$attrNum_out,
  707                  &rVAR_NUMBER_, $var2Name, \$varNum_out1,
  708                  &zVAR_NUMBER_, $zVarAname, \$varNum_out2,
  709                &NULL_);
  710 QuitCDF ("16a.0", $status) if ($status < &CDF_OK) ;
  711 
  712 QuitCDF ("16a.1", $status) if ($attrNum_out != 2) ;
  713 QuitCDF ("16a.2", $status) if ($varNum_out1 != 1) ;
  714 QuitCDF ("16a.3", $status) if ($varNum_out2 != 0) ;
  715 
  716 #############################################################################
  717 # Rename variables.
  718 #############################################################################
  719 
  720 $status = CDF::CDFlib (&SELECT_, &rVAR_NAME_, $var1Name,
  721                &PUT_, &rVAR_NAME_, $new_var1Name,
  722                &NULL_);
  723 QuitCDF ("17.0a", $status) if ($status < &CDF_OK) ;
  724 
  725 $status = CDF::CDFlib (&SELECT_, &rVAR_NAME_, $var2Name,
  726                &PUT_, &rVAR_NAME_, $new_var2Name,
  727                &NULL_);
  728 QuitCDF ("17.0b", $status) if ($status < &CDF_OK) ;
  729 
  730 $status = CDF::CDFlib (&SELECT_, &zVAR_NAME_, $zVarAname,
  731                &PUT_, &zVAR_NAME_, $new_zVarAname,
  732                &NULL_);
  733 QuitCDF ("17.0c", $status) if ($status < &CDF_OK) ;
  734 
  735 #############################################################################
  736 # Read/write multiple variable data. 
  737 #############################################################################
  738 
  739 $status = CDF::CDFlib (&SELECT_, &rVARs_RECNUMBER_, 2,
  740                &PUT_, &rVARs_RECDATA_, $nRvars, \@rVarNs, \@rVarsRecBuffer,
  741                &SELECT_, &zVARs_RECNUMBER_, 2,
  742                &PUT_, &zVARs_RECDATA_, $nZvars, \@zVarNs, \@zVarsRecBuffer,
  743                &NULL_);
  744 QuitCDF ("17.0d", $status) if ($status < &CDF_OK) ;
  745 $maxRecWritten = $maxRecWritten + 2;
  746 
  747 my @rVarsRecBufferOut;
  748 my @zVarsRecBufferOut;
  749 my $j;
  750 $status = CDF::CDFlib (&GET_, &rVARs_RECDATA_, $nRvars, \@rVarNs, \@rVarsRecBufferOut,
  751                &NULL_);
  752 QuitCDF ("17.0e", $status) if ($status < &CDF_OK) ;
  753 for ($i=0; $i<12; $i++) {
  754   QuitCDF ("17.0f", $status) # epsilon of 10^(-5) for float, 10^(-9) for double 
  755     if (abs($rVarsRecBufferOut[$i]-$rVarsRecBuffer[$i]) > 10**(-5)); 
  756 }
  757 $status = CDF::CDFlib (&GET_, zVARs_RECDATA_, $nZvars, \@zVarNs, \@zVarsRecBufferOut,
  758                &NULL_);
  759 QuitCDF ("17.0g", $status) if ($status < &CDF_OK) ;
  760 for ($j=0; $j<5; $j++) {
  761   QuitCDF ("17.0h", $status)
  762         if ($zVarsRecBufferOut[$j] ne $zVarsRecBuffer[$j]);
  763 }
  764 #
  765 #############################################################################
  766 # Inquire variables.
  767 #############################################################################
  768 
  769 my ($var1Name_out, $var1DataType_out, $var1NumElements_out, $var1RecVariance_out);
  770 my (@var1DimVariances_out, $extendRecsOut1, $maxAllocOut1, $maxRecOut1);
  771 my ($nIndexRecsOut1, $nIndexEntriesOut1);
  772 $status = CDF::CDFlib (&SELECT_, &rVAR_, $var1Num_out,
  773                &GET_, &rVAR_NAME_, \$var1Name_out,
  774                  &rVAR_DATATYPE_, \$var1DataType_out,
  775                  &rVAR_NUMELEMS_, \$var1NumElements_out,
  776                  &rVAR_RECVARY_, \$var1RecVariance_out,
  777                  &rVAR_DIMVARYS_, \@var1DimVariances_out,
  778                  &rVAR_BLOCKINGFACTOR_, \$extendRecsOut1,
  779                  &rVAR_MAXallocREC_, \$maxAllocOut1,
  780                  &rVAR_MAXREC_, \$maxRecOut1,
  781                  &rVAR_nINDEXRECORDS_, \$nIndexRecsOut1,
  782                  &rVAR_nINDEXENTRIES_, \$nIndexEntriesOut1,
  783                &CONFIRM_, &rVAR_, \$var1Num_out,
  784                &NULL_);
  785 QuitCDF ("18.0a", $status) if ($status < &CDF_OK) ;
  786 
  787 QuitCDF ("18.11", $status) if ($var1Name_out ne $new_var1Name) ;
  788 QuitCDF ("18.12", $status) if ($var1DataType_out != $var1DataType) ;
  789 
  790 QuitCDF ("18.13", $status) if ($var1NumElements_out != $var1NumElements) ;
  791 QuitCDF ("18.14", $status) if ($var1RecVariance_out != $var1RecVariance) ;
  792 QuitCDF ("18.14a", $status) if ($var1Num_out != 0) ;
  793 QuitCDF ("18.14b", $status) if ($extendRecsOut1 != $extendRecs1) ;
  794 QuitCDF ("18.14c", $status) if ($maxAllocOut1 + 1 != $allocRecs1) ;
  795 QuitCDF ("18.14d", $status) if ($maxRecOut1 != $maxRecWritten) ;
  796 
  797 my $dim_n;
  798 for ($dim_n = 0; $dim_n < $numDims; $dim_n++) {
  799    if ($var1DimVariances_out[$dim_n] != $var1DimVariances[$dim_n]) {
  800      QuitCDF ("18.14", $status);
  801    }
  802 }
  803 
  804 my ($var2Name_out, $var2DataType_out, $var2NumElements_out, $var2RecVariance_out);
  805 my (@var2DimVariances_out, $extendRecsOut2, $maxAllocOut2, $maxRecOut2);
  806 my ($nIndexRecsOut2, $nIndexEntriesOut2);
  807 $status = CDF::CDFlib (&SELECT_, &rVAR_, $var2Num_out,
  808                &GET_, &rVAR_NAME_, \$var2Name_out,
  809                  &rVAR_DATATYPE_, \$var2DataType_out,
  810                  &rVAR_NUMELEMS_, \$var2NumElements_out,
  811                  &rVAR_RECVARY_, \$var2RecVariance_out,
  812                  &rVAR_DIMVARYS_, \@var2DimVariances_out,
  813                  &rVAR_BLOCKINGFACTOR_, \$extendRecsOut2,
  814                  &rVAR_MAXallocREC_, \$maxAllocOut2,
  815                  &rVAR_MAXREC_, \$maxRecOut2,
  816                  &rVAR_nINDEXRECORDS_, \$nIndexRecsOut2,
  817                  &rVAR_nINDEXENTRIES_, \$nIndexEntriesOut2,
  818                &CONFIRM_, &rVAR_, \$var2Num_out,
  819                &NULL_);
  820 QuitCDF ("18.0b", $status) if ($status < &CDF_OK) ;
  821 
  822 QuitCDF ("18.21", $status) if ($var2Name_out ne $new_var2Name) ;
  823 QuitCDF ("18.22", $status) if ($var2DataType_out != $var2DataType) ;
  824 QuitCDF ("18.23", $status) if ($var2NumElements_out != $var2NumElements) ;
  825 QuitCDF ("18.24", $status) if ($var2RecVariance_out != $var2RecVariance) ;
  826 QuitCDF ("18.24a", $status) if ($var2Num_out != 1) ;
  827 QuitCDF ("18.24b", $status) if ($extendRecsOut2 != $extendRecs2) ;
  828 QuitCDF ("18.24c", $status) if ($maxAllocOut2 + 1 != $allocRecs2) ;
  829 QuitCDF ("18.24d", $status) if ($maxRecOut2 != $maxRecWritten) ;
  830 
  831 for ($dim_n = 0; $dim_n < $numDims; $dim_n++) {
  832    if ($var2DimVariances_out[$dim_n] != $var2DimVariances[$dim_n]) {
  833      QuitCDF ("18.25", $status);
  834    }
  835 }
  836 
  837 my ($zVarAname_out, $zVarAdataType_out, $zVarAnumElements_out, $zVarArecVariance_out);
  838 my (@zVarAdimVariances_out, @zDimSizesA_out);
  839 my ($zNumDimsA_out, $extendRecsOut3, $maxAllocOut3, $maxRecOut3, $nIndexRecsOut3, $nIndexEntriesOut3);
  840 $status = CDF::CDFlib (&SELECT_, &zVAR_, $zVarAnum_out,
  841                &GET_, &zVAR_NAME_, \$zVarAname_out,
  842                      &zVAR_DATATYPE_, \$zVarAdataType_out,
  843                      &zVAR_NUMELEMS_, \$zVarAnumElements_out,
  844                      &zVAR_RECVARY_, \$zVarArecVariance_out,
  845                      &zVAR_DIMVARYS_, \@zVarAdimVariances_out,
  846                      &zVAR_NUMDIMS_, \$zNumDimsA_out,
  847                      &zVAR_DIMSIZES_, \@zDimSizesA_out,
  848                      &zVAR_BLOCKINGFACTOR_, \$extendRecsOut3,
  849                      &zVAR_MAXallocREC_, \$maxAllocOut3,
  850                      &zVAR_MAXREC_, \$maxRecOut3,
  851                      &zVAR_nINDEXRECORDS_, \$nIndexRecsOut3,
  852                      &zVAR_nINDEXENTRIES_, \$nIndexEntriesOut3,
  853                &NULL_);
  854 QuitCDF ("18.0c1", $status) if ($status < &CDF_OK) ;
  855 
  856 $status = CDF::CDFlib (&CONFIRM_, &zVAR_, \$zVarAnum_out,
  857                &NULL_);
  858 QuitCDF ("18.0c2", $status) if ($status < &CDF_OK) ;
  859 
  860 QuitCDF ("18.21z", $status) if ($zVarAname_out ne $new_zVarAname) ;
  861 QuitCDF ("18.22z", $status) if ($zVarAdataType_out != $zVarAdataType) ;
  862 QuitCDF ("18.23z", $status) if ($zVarAnumElements_out != $zVarAnumElements) ;
  863 QuitCDF ("18.24z", $status) if ($zVarArecVariance_out != $zVarArecVariance) ;
  864 QuitCDF ("18.25z", $status) if ($zNumDimsA_out != $zNumDimsA) ;
  865 QuitCDF ("18.27z", $status) if ($zVarAnum_out != 0) ;
  866 QuitCDF ("18.27z1", $status) if ($extendRecsOut3 != $extendRecs3) ;
  867 QuitCDF ("18.27z2", $status) if ($maxAllocOut3 + 1 != $allocRecs3) ;
  868 QuitCDF ("18.27z3", $status) if ($maxRecOut3 != $maxRecWritten) ;
  869 
  870 for ($dim_n = 0; $dim_n < $zNumDimsA; $dim_n++) {
  871    if ($zDimSizesA_out[$dim_n] != $zDimSizesA[$dim_n]) {
  872      QuitCDF ("18.27z", $status);
  873    }
  874    if ($zVarAdimVariances_out[$dim_n] != $zVarAdimVariances[$dim_n]) {
  875      QuitCDF ("18.28z", $status);
  876    }
  877 }
  878 
  879 #############################################################################
  880 # Rename attribute.
  881 #############################################################################
  882 
  883 $status = CDF::CDFlib (&SELECT_, &ATTR_NAME_, $attrName,
  884                &PUT_, &ATTR_NAME_, $new_attrName,
  885                &NULL_);
  886 QuitCDF ("20.0", $status) if ($status < &CDF_OK) ;
  887 
  888 #############################################################################
  889 # Inquire attribute.
  890 #############################################################################
  891 
  892 my ($attrName_out, $attrScope_out, $maxEntry_out);
  893 $status = CDF::CDFlib (&GET_, &ATTR_NAME_, \$attrName_out,
  894                  &ATTR_SCOPE_, \$attrScope_out,
  895                  &ATTR_MAXgENTRY_, \$maxEntry_out,
  896                &CONFIRM_, &ATTR_, \$attrNum_out,
  897                &NULL_);
  898 QuitCDF ("22.0", $status) if ($status < &CDF_OK) ;
  899 
  900 QuitCDF ("22.1", $status) if ($attrName_out ne $new_attrName) ;
  901 QuitCDF ("22.2", $status) if ($attrScope_out != $attrScope) ;
  902 QuitCDF ("22.3", $status) if ($maxEntry_out != $entryNum) ;
  903 QuitCDF ("22.4", $status) if ($attrNum_out != 0) ;
  904 
  905 #############################################################################
  906 # Inquire attribute entries.
  907 #############################################################################
  908 
  909 my ($entryDataType_out, $entryNumElems_out);
  910 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
  911                 &gENTRY_, $entryNum,
  912                &GET_, &gENTRY_DATATYPE_, \$entryDataType_out,
  913                  &gENTRY_NUMELEMS_, \$entryNumElems_out,
  914                &NULL_);
  915 QuitCDF ("23.0", $status) if ($status < &CDF_OK) ;
  916 
  917 QuitCDF ("23.1", $status) if ($entryDataType_out != $entryDataType) ;
  918 QuitCDF ("23.1", $status) if ($entryNumElems_out != $entryNumElems) ;
  919 
  920 $status = CDF::CDFlib (&SELECT_, &ATTR_, 1,
  921                 &rENTRY_, 1,
  922                &GET_, &rENTRY_DATATYPE_, \$entryDataType_out,
  923                  &rENTRY_NUMELEMS_, \$entryNumElems_out,
  924                &NULL_);
  925 QuitCDF ("23a.0", $status) if ($status < &CDF_OK) ;
  926 
  927 QuitCDF ("23a.1", $status) if ($entryDataType_out != &CDF_BYTE) ;
  928 QuitCDF ("23a.1", $status) if ($entryNumElems_out != 1) ;
  929 
  930 $status = CDF::CDFlib (&SELECT_, &ATTR_, 2,
  931                 &zENTRY_, 0,
  932                &GET_, &zENTRY_DATATYPE_, \$entryDataType_out,
  933                  &zENTRY_NUMELEMS_, \$entryNumElems_out,
  934                &NULL_);
  935 QuitCDF ("23b.0", $status) if ($status < &CDF_OK) ;
  936 
  937 QuitCDF ("23b.1", $status) if ($entryDataType_out != &CDF_REAL8) ;
  938 QuitCDF ("23b.1", $status) if ($entryNumElems_out != 1) ;
  939 
  940 #############################################################################
  941 # Get error text.
  942 #############################################################################
  943 
  944 my $errorText;
  945 $status = CDF::CDFlib (&SELECT_, &CDF_STATUS_, &CDF_OK,
  946                &GET_, &STATUS_TEXT_, \$errorText,
  947                &NULL_);
  948          
  949 QuitCDF ("24.0", $status) if ($status < &CDF_OK) ;
  950 
  951 #############################################################################
  952 # Select zMode and inquire CDF.
  953 #############################################################################
  954 
  955 $status = CDF::CDFlib (&SELECT_, &CDF_zMODE_, &zMODEon2,
  956                &NULL_);
  957 QuitCDF ("25.0a", $status) if ($status < &CDF_OK) ;
  958 
  959 my ($numGattrs, $numVattrs, $maxGentry, $numGentries, $maxRecOut);
  960 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
  961                &GET_, &CDF_NUMgATTRS_, \$numGattrs,
  962                      &CDF_NUMvATTRS_, \$numVattrs,
  963                      &CDF_NUMrVARS_, \$numRvars,
  964                      &CDF_NUMzVARS_, \$numZvars,
  965                      &ATTR_MAXgENTRY_, \$maxGentry,
  966                      &ATTR_NUMgENTRIES_, \$numGentries,
  967                      &zVARs_MAXREC_, \$maxRecOut,
  968                &NULL_);
  969 QuitCDF ("25.0b", $status) if ($status < &CDF_OK) ;
  970 
  971 my ($maxRentry, $numRentries, $maxZentry, $numZentries);
  972 $status = CDF::CDFlib (&SELECT_, &ATTR_, 1,
  973                &GET_, &ATTR_MAXrENTRY_, \$maxRentry,
  974                  &ATTR_NUMrENTRIES_, \$numRentries,
  975                  &ATTR_MAXzENTRY_, \$maxZentry,
  976                  &ATTR_NUMzENTRIES_, \$numZentries,
  977                &NULL_);
  978 QuitCDF ("25.0c", $status) if ($status < &CDF_OK) ;
  979 
  980 $status = CDF::CDFlib (&SELECT_, &CDF_zMODE_, &zMODEoff,
  981         &NULL_);
  982 QuitCDF ("25.0d", $status) if ($status < &CDF_OK) ;
  983 
  984 QuitCDF ("25.1", $status) if ($numGattrs != 1) ; 
  985 QuitCDF ("25.1a", $status) if ($numVattrs != 3) ;
  986 QuitCDF ("25.1b", $status) if ($numRvars != 0) ;
  987 QuitCDF ("25.2", $status) if ($numZvars != 3) ;
  988 QuitCDF ("25.3", $status) if ($maxGentry != $entryNum) ;
  989 QuitCDF ("25.4", $status) if ($numGentries != 1) ;
  990 QuitCDF ("25.5", $status) if ($maxRentry != -1) ;
  991 QuitCDF ("25.6", $status) if ($numRentries != 0) ;
  992 QuitCDF ("25.7", $status) if ($maxZentry != 1);
  993 QuitCDF ("25.8", $status) if ($numZentries != 1) ;
  994 QuitCDF ("25.9", $status) if ($maxRecOut != $maxRecWritten) ;
  995 
  996 #############################################################################
  997 # Attempt to close variables.
  998 #############################################################################
  999 
 1000 $status = CDF::CDFlib (&SELECT_, &rVAR_, 0,
 1001                &CLOSE_, &rVAR_,
 1002                &NULL_);
 1003 QuitCDF ("27.0", $status) if ($status != &SINGLE_FILE_FORMAT) ;
 1004 
 1005 $status = CDF::CDFlib (&SELECT_, &zVAR_, 0,
 1006                &CLOSE_, &zVAR_,
 1007                &NULL_);
 1008 QuitCDF ("27.1", $status) if ($status != &SINGLE_FILE_FORMAT) ;
 1009 
 1010 #############################################################################
 1011 # Modify entries/attribute.
 1012 #############################################################################
 1013 
 1014 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
 1015                 &gENTRY_, $entryNum,
 1016                &PUT_, &gENTRY_DATASPEC_, $entryDataTypeNew, $entryNumElems,
 1017                &NULL_);
 1018 QuitCDF ("27a.0a", $status) if ($status < &CDF_OK) ;
 1019 
 1020 $status = CDF::CDFlib (&SELECT_, &ATTR_, 1,
 1021                 &rENTRY_, 1,
 1022                &PUT_, &rENTRY_DATASPEC_, &CDF_UINT1, 1,
 1023                &NULL_);
 1024 QuitCDF ("27a.0b", $status) if ($status < &CDF_OK) ;
 1025 
 1026 $status = CDF::CDFlib (&SELECT_, &ATTR_, 2,
 1027                 &zENTRY_, 0,
 1028                &PUT_, &zENTRY_DATASPEC_, &CDF_EPOCH, 1,
 1029         &NULL_);
 1030 QuitCDF ("27a.0c", $status) if ($status < &CDF_OK) ;
 1031 
 1032 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
 1033                &PUT_, &ATTR_SCOPE_, &VARIABLE_SCOPE,
 1034                  &ATTR_SCOPE_, &GLOBAL_SCOPE,
 1035                &NULL_);
 1036 QuitCDF ("27a.0d", $status) if ($status < &CDF_OK) ;
 1037 
 1038 #############################################################################
 1039 # Delete entries/attribute/variables.
 1040 #############################################################################
 1041 
 1042 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
 1043                 &gENTRY_, $entryNum,
 1044                &DELETE_, &gENTRY_,
 1045                &SELECT_, &ATTR_, 1,
 1046                 &rENTRY_, 1,
 1047                &DELETE_, &rENTRY_,
 1048                &SELECT_, &ATTR_, 2,
 1049                 &zENTRY_, 0,
 1050                &DELETE_, &zENTRY_,
 1051                &NULL_);
 1052 QuitCDF ("27.1", $status) if ($status < &CDF_OK) ;
 1053 
 1054 $status = CDF::CDFlib (&SELECT_, &ATTR_, 0,
 1055                &DELETE_, &ATTR_,
 1056                &SELECT_, &rVAR_, 0,
 1057 #       &DELETE_, &rVAR_,
 1058                &SELECT_, &zVAR_, 0,
 1059 #       &DELETE_, &zVAR_,
 1060                &NULL_);
 1061 QuitCDF ("27.2", $status) if ($status < &CDF_OK) ;
 1062 
 1063 #############################################################################
 1064 # Checksum.
 1065 #############################################################################
 1066 my $chksum;
 1067 
 1068 $status = CDF::CDFlib (&GET_, &CDF_CHECKSUM_, \$chksum,
 1069                        &NULL_);
 1070 QuitCDF ("28.0", $status) if ($status < &CDF_OK) ;
 1071 
 1072 #QuitCDF ("28.1", $chksum) if ($chksum != MD5_CHECKSUM) ;
 1073 
 1074 #############################################################################
 1075 # Close CDF.
 1076 #############################################################################
 1077 
 1078 $status = CDF::CDFlib (&CLOSE_, &CDF_,
 1079                &NULL_);
 1080 QuitCDF ("28.2", $status) if ($status < &CDF_OK) ;
 1081 
 1082 #############################################################################
 1083 # Test Epoch Routines
 1084 #############################################################################
 1085 print "Test Epoch...\n";
 1086 my $year = 1994;
 1087 my $month = 10;
 1088 my $day = 13;
 1089 my $hour = 1;
 1090 my $minute = 2;
 1091 my $second = 3;
 1092 my $msec = 987;
 1093 
 1094 my $epoch = CDF::computeEPOCH ($year, $month, $day, $hour, $minute,  
 1095                                $second, $msec);
 1096 
 1097 my $epString0True = '13-Oct-1994 01:02:03.987';
 1098 my $epString1True = '19941013.0431017';
 1099 my $epString2True = '19941013010203';
 1100 my $epString3True = '1994-10-13T01:02:03.987Z';
 1101 my $epString4True = '1994-10-13T01:02:03.987';
 1102 
 1103 my ($epString, $epString1, $epString2, $epString3, $epString4);
 1104 
 1105 #CDF::encodeEPOCH ($epoch, $epString);
 1106 CDF::toEncodeEPOCH ($epoch, 0, $epString);
 1107 #QuitEPOCH ("30.0") if ($epString ne $epString0True);
 1108 QuitEPOCH ("30.0") if ($epString ne $epString0True);
 1109 
 1110 #CDF::encodeEPOCH1 ($epoch, $epString1);
 1111 CDF::toEncodeEPOCH ($epoch, 1, $epString1);
 1112 QuitEPOCH ("30.1") if ($epString1 ne $epString1True);
 1113 
 1114 #CDF::encodeEPOCH2 ($epoch, $epString2);
 1115 CDF::toEncodeEPOCH ($epoch, 2, $epString2);
 1116 QuitEPOCH ("30.2") if ($epString2 ne $epString2True);
 1117 
 1118 #CDF::encodeEPOCH3 ($epoch, $epString3);
 1119 CDF::toEncodeEPOCH ($epoch, 3, $epString3);
 1120 QuitEPOCH ("30.3") if ($epString3 ne $epString3True);
 1121 
 1122 #CDF::encodeEPOCH4 ($epoch, $epString4);
 1123 CDF::toEncodeEPOCH ($epoch, 4, $epString4);
 1124 QuitEPOCH ("30.4") if ($epString4 ne $epString4True);
 1125 
 1126 my $epochOut;
 1127 #my $epochOut = CDF::parseEPOCH ($epString);
 1128 $epochOut = CDF::toParseEPOCH ($epString);
 1129 QuitEPOCH ("31.0") if ($epochOut != $epoch);
 1130 #my $epochOut = CDF::parseEPOCHX ($epString3);
 1131 $epochOut = CDF::toParseEPOCH ($epString3);
 1132 QuitEPOCH ("31.1") if ($epochOut != $epoch);
 1133 #my $epochOut = CDF::parseEPOCHX ($epString4);
 1134 $epochOut = CDF::toParseEPOCH ($epString4);
 1135 QuitEPOCH ("31.2") if ($epochOut != $epoch);
 1136 #my $epochOut = CDF::parseEPOCHX ($epString);
 1137 $epochOut = CDF::toParseEPOCH ($epString);
 1138 QuitEPOCH ("31.3") if ($epochOut != $epoch);
 1139 my (@epochs, @epochd);
 1140 $epochs[0] = $epString;
 1141 $epochs[1] = $epString;
 1142 @epochd = CDF::toParseEPOCH (\@epochs);
 1143 QuitEPOCH ("31.4") if ($epochOut != $epochd[0]);
 1144 QuitEPOCH ("31.5") if ($epochOut != $epochd[1]);
 1145 
 1146 my ($yearOut, $monthOut, $dayOut, $hourOut, $minuteOut, $secondOut, 
 1147     $msecOut);
 1148 
 1149 CDF::EPOCHbreakdown ($epoch, $yearOut, $monthOut, $dayOut, $hourOut, 
 1150                      $minuteOut, $secondOut, $msecOut);
 1151 
 1152 QuitEPOCH ("32.1") if ($yearOut != $year) ;
 1153 QuitEPOCH ("32.2") if ($monthOut != $month) ;
 1154 QuitEPOCH ("32.3") if ($dayOut != $day) ;
 1155 QuitEPOCH ("32.4") if ($hourOut != $hour) ;
 1156 QuitEPOCH ("32.5") if ($minuteOut != $minute) ;
 1157 QuitEPOCH ("32.6") if ($secondOut != $second) ;
 1158 QuitEPOCH ("32.7") if ($msecOut != $msec) ;
 1159 
 1160 #############################################################################
 1161 # Test Epoch16 Routines
 1162 #############################################################################
 1163 print "Test Epoch16...\n";
 1164 
 1165 my $usec = 876;
 1166 my $nsec = 765;
 1167 my $psec = 654;
 1168 my @epoch16;
 1169 my $retco = CDF::computeEPOCH16 ($year, $month, $day, $hour, $minute, $second, 
 1170                                  $msec, $usec, $nsec, $psec, \@epoch16);
 1171 
 1172 my $ep16String0True = '13-Oct-1994 01:02:03.987.876.765.654';
 1173 my $ep16String1True = '19941013.043101711536640';
 1174 my $ep16String2True = '19941013010203';
 1175 my $ep16String3True = '1994-10-13T01:02:03.987.876.765.654Z';
 1176 my $ep16String4True = '1994-10-13T01:02:03.987876765654';
 1177 
 1178 my ($ep16String, $ep16String1, $ep16String2, $ep16String3, $ep16String4);
 1179 
 1180 #CDF::encodeEPOCH16 (\@epoch16, $ep16String);
 1181 CDF::toEncodeEPOCH16 (\@epoch16, 0, $ep16String);
 1182 QuitEPOCH ("40.0") if ($ep16String ne $ep16String0True);
 1183 
 1184 #CDF::encodeEPOCH16_1 (\@epoch16, $ep16String1);
 1185 CDF::toEncodeEPOCH16 (\@epoch16, 1, $ep16String1);
 1186 #print "encodeEPOCH16_1:$ep16String1";
 1187 QuitEPOCH ("40.1") if ($ep16String1 ne $ep16String1True);
 1188 
 1189 #CDF::encodeEPOCH16_2 (\@epoch16, $ep16String2);
 1190 CDF::toEncodeEPOCH16 (\@epoch16, 2, $ep16String2);
 1191 QuitEPOCH ("40.2") if ($ep16String2 ne $ep16String2True);
 1192 
 1193 #CDF::encodeEPOCH16_3 (\@epoch16, $ep16String3);
 1194 CDF::toEncodeEPOCH16 (\@epoch16, 3, $ep16String3);
 1195 QuitEPOCH ("40.3") if ($ep16String3 ne $ep16String3True);
 1196 
 1197 #CDF::encodeEPOCH16_4 (\@epoch16, $ep16String4);
 1198 CDF::toEncodeEPOCH16 (\@epoch16, 4, $ep16String4);
 1199 QuitEPOCH ("40.4") if ($ep16String4 ne $ep16String4True);
 1200 
 1201 my @epoch16Out;
 1202 #$retco = CDF::parseEPOCH16X ($ep16String, \@epoch16Out);
 1203 $retco = CDF::toParseEPOCH16 ($ep16String, \@epoch16Out);
 1204 QuitEPOCH ("41.0") if ($epoch16Out[0] != $epoch16[0]) ;
 1205 QuitEPOCH ("41.1") if ($epoch16Out[1] != $epoch16[1]) ;
 1206 #$retco = CDF::parseEPOCH16X ($ep16String3, \@epoch16Out);
 1207 $retco = CDF::toParseEPOCH16 ($ep16String3, \@epoch16Out);
 1208 QuitEPOCH ("41.2") if ($epoch16Out[0] != $epoch16[0]) ;
 1209 QuitEPOCH ("41.3") if ($epoch16Out[1] != $epoch16[1]) ;
 1210 #$retco = CDF::parseEPOCH16X ($ep16String4, \@epoch16Out);
 1211 $retco = CDF::toParseEPOCH16 ($ep16String4, \@epoch16Out);
 1212 QuitEPOCH ("41.4") if ($epoch16Out[0] != $epoch16[0]) ;
 1213 QuitEPOCH ("41.5") if ($epoch16Out[1] != $epoch16[1]) ;
 1214 
 1215 my ($year16Out, $month16Out, $day16Out, $hour16Out, $minute16Out, 
 1216     $second16Out, $msec16Out, $usec16Out, $nsec16Out, $psec16Out);
 1217 
 1218 CDF::EPOCH16breakdown (\@epoch16, $year16Out, $month16Out, $day16Out, 
 1219                        $hour16Out, $minute16Out, $second16Out, $msec16Out,
 1220                        $usec16Out, $nsec16Out, $psec16Out);
 1221 
 1222 QuitEPOCH ("42.0") if ($year16Out != $year) ;
 1223 QuitEPOCH ("42.1") if ($month16Out != $month) ;
 1224 QuitEPOCH ("42.2") if ($day16Out != $day) ;
 1225 QuitEPOCH ("42.3") if ($hour16Out != $hour) ;
 1226 QuitEPOCH ("42.4") if ($minute16Out != $minute) ;
 1227 QuitEPOCH ("42.5") if ($second16Out != $second) ;
 1228 QuitEPOCH ("42.6") if ($msec16Out != $msec) ;
 1229 QuitEPOCH ("42.7") if ($usec16Out != $usec) ;
 1230 QuitEPOCH ("42.8") if ($nsec16Out != $nsec) ;
 1231 QuitEPOCH ("42.9") if ($psec16Out != $psec) ;
 1232 
 1233 #############################################################################
 1234 # Test TT2000 Routines
 1235 #############################################################################
 1236 print "Test TT2000...\n";
 1237 $year = 2010;
 1238 
 1239 my $tt2000=CDF::computeTT2000 ($year, $month, $day, $hour, $minute,  
 1240                                $second, $msec, $usec, $nsec);
 1241 my $ttString0True = '13-Oct-2010 01:02:03.987876765';
 1242 my $ttString3True = '2010-10-13T01:02:03.987876765';
 1243 my $ttString4True = '2010-10-13T01:02:03.987876765Z';
 1244 my ($ttString0, $ttString3, $ttString4);
 1245 
 1246 #CDF::encodeTT2000 ($tt2000, $ttString3);
 1247 CDF::toEncodeTT2000 ($tt2000, 0, $ttString0);
 1248 #print "$ttString0 vs $ttString0True\n";
 1249 QuitEPOCH ("50.0") if ($ttString0 ne $ttString0True);
 1250 CDF::toEncodeTT2000 ($tt2000, 3, $ttString3);
 1251 QuitEPOCH ("50.1") if ($ttString3 ne $ttString3True);
 1252 CDF::toEncodeTT2000 ($tt2000, 4, $ttString4);
 1253 QuitEPOCH ("50.2") if ($ttString4 ne $ttString4True);
 1254 
 1255 my $tt2000Out;
 1256 #$tt2000Out=CDF::parseTT2000 ($ttString3);
 1257 $tt2000Out=CDF::toParseTT2000 ($ttString3);
 1258 QuitEPOCH ("51.0") if ($tt2000Out != $tt2000) ;
 1259 #$tt2000Out=CDF::parseTT2000 ($ttString4True);
 1260 $tt2000Out=CDF::toParseTT2000 ($ttString4True);
 1261 QuitEPOCH ("51.1") if ($tt2000Out != $tt2000) ;
 1262 #$tt2000Out=CDF::parseTT2000 ($ttString0True);
 1263 $tt2000Out=CDF::toParseTT2000 ($ttString0True);
 1264 QuitEPOCH ("51.2") if ($tt2000Out != $tt2000) ;
 1265 my (@tt2000s, @tt2000l);
 1266 $tt2000s[0] = $ttString3;
 1267 $tt2000s[1] = $ttString3;
 1268 @tt2000l=CDF::toParseTT2000 (\@tt2000s);
 1269 QuitEPOCH ("51.3") if ($tt2000l[0] != $tt2000Out) ;
 1270 QuitEPOCH ("51.4") if ($tt2000l[1] != $tt2000Out) ;
 1271 
 1272 my ($usecOut, $nsecOut);
 1273 CDF::TT2000breakdown ($tt2000, $yearOut, $monthOut, $dayOut, $hourOut, 
 1274                       $minuteOut, $secondOut, $msecOut, $usecOut, $nsecOut);
 1275 QuitEPOCH ("52.1") if ($yearOut != $year) ;
 1276 QuitEPOCH ("52.2") if ($monthOut != $month) ;
 1277 QuitEPOCH ("52.3") if ($dayOut != $day) ;
 1278 QuitEPOCH ("52.4") if ($hourOut != $hour) ;
 1279 QuitEPOCH ("52.5") if ($minuteOut != $minute) ;
 1280 QuitEPOCH ("52.6") if ($secondOut != $second) ;
 1281 QuitEPOCH ("52.7") if ($msecOut != $msec) ;
 1282 QuitEPOCH ("52.8") if ($usecOut != $usec) ;
 1283 QuitEPOCH ("52.9") if ($nsecOut != $nsec) ;
 1284 
 1285 #############################################################################
 1286 # Successful completion.
 1287 #############################################################################
 1288 print "All tests completed successfully\n";
 1289 exit;
 1290 
 1291 #############################################################################
 1292 # QuitCDF.
 1293 #############################################################################
 1294 sub QuitCDF {
 1295     my ($where, $status)=@_;
 1296 
 1297   print "Aborting at $where ...\n";
 1298   if ($status < &CDF_OK) {
 1299     my $text;
 1300     CDF::CDFlib (&SELECT_, &CDF_STATUS_, $status,
 1301            &GET_, &STATUS_TEXT_, \$text,
 1302            &NULL_);
 1303     print $text;
 1304   }
 1305   CDF::CDFlib (&CLOSE_, &CDF_,
 1306       &NULL_);
 1307   print "...test aborted.\n";
 1308   exit;
 1309     
 1310 }#endsub QuitCDF
 1311 
 1312 #############################################################################
 1313 #  QuitEPOCH
 1314 #############################################################################
 1315 sub QuitEPOCH {
 1316   my ($where) = @_;
 1317   print "Aborting at $where...test aborted.\n";
 1318   exit;
 1319 
 1320 }#endsub QuitEPOCH