"Fossies" - the Fresh Open Source Software Archive

Member "PerlCDF38_0/test2.pl" (19 Nov 2019, 6109 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.

    1 #!/usr/bin/perl -w
    2 
    3 use strict;
    4 use Math::BigInt;
    5 
    6 BEGIN { unshift @INC,'/home/liu/PerlCDF38_0/blib/arch',
    7                      '/home/liu/PerlCDF38_0/blib/lib'; }
    8 use CDF;
    9 
   10 my $N_DIMS = 2;
   11 my $DIM_0_SIZE = 2;
   12 my $DIM_1_SIZE = 3;
   13 
   14 my $zN_DIMSa = 1;
   15 my $zDIM_0_SIZEa = 5;
   16 my $zNUM_ELEMSa = 8;
   17 
   18 my $encoding = &NETWORK_ENCODING;
   19 my $actual_encoding = &NETWORK_ENCODING;
   20 my $majority = &ROW_MAJOR;
   21 my $compression = &GZIP_COMPRESSION;
   22 my @compressionLevel = (6);
   23 my $numDims = $N_DIMS;
   24 my @dimSizes = ( $DIM_0_SIZE, $DIM_1_SIZE );
   25 my $zNumDimsA = $zN_DIMSa;
   26 my @zDimSizesA = ( $zDIM_0_SIZEa );
   27 my $var1DataType = &CDF_INT2;
   28 my $var1DataTypeNew = &CDF_UINT2 ;
   29 my $var2DataType = &CDF_REAL8 ;
   30 my $zVarAdataType = &CDF_CHAR ;
   31 my $zVarAdataTypeNew = &CDF_UCHAR ;
   32 my $var1NumElements = 1 ;
   33 my $var1NumElementsNew = 1 ;
   34 my $var2NumElements = 1 ;
   35 my $zVarAnumElements = $zNUM_ELEMSa ;
   36 my $zVarAnumElementsNew = $zNUM_ELEMSa ;
   37 my @var1Values = (1,2,3,4,5,6);
   38 my @var2Values = (1.,2.,3.,4.,5.,6.);
   39 my @zVarAvalues = (
   40   '11111111',
   41   '2222222',
   42   '333333',
   43   '44444',
   44   '5555'
   45 );
   46 my @entry1Values = (1,2,3,4,5,6);
   47 my $recNum = 0 ;
   48 my $recStart = 0 ;
   49 my $recCount = 1 ;
   50 my $recInterval = 1 ;
   51 my @counts = ( $DIM_0_SIZE, $DIM_1_SIZE );
   52 my @intervals = ( 1, 1 );
   53 my $zRecNum =  0;
   54 my $zRecStart =  0;
   55 my $zRecCount =  1;
   56 my $zRecInterval = 1 ;
   57 my @zCounts = ( $zDIM_0_SIZEa );
   58 my @zIntervals = ( 1 );
   59 my $entryNum = 2 ;
   60 my $attrScope = &GLOBAL_SCOPE ;
   61 my $attrScope2 = &VARIABLE_SCOPE ;
   62 my $attrScope3 = &VARIABLE_SCOPE ;
   63 my $attrScope4 = &VARIABLE_SCOPE ;
   64 my $entryDataType = &CDF_INT2 ;
   65 my $entryDataTypeNew = &CDF_UINT2 ;
   66 my $entryNumElems = 1 ;
   67 my $entryValue = 1 ;
   68 my $var1RecVariance = &VARY ;
   69 my $var1RecVarianceNew = &NOVARY ;
   70 my $var2RecVariance = &VARY ;
   71 my $zVarArecVariance = &VARY ;
   72 my $zVarArecVarianceNew = &NOVARY ;
   73 my @var1DimVariances = ( &VARY, &VARY );
   74 my @var1DimVariancesNew = ( &NOVARY, &NOVARY );
   75 my @var2DimVariances = ( &VARY, &VARY );
   76 my @zVarAdimVariances = ( &VARY );
   77 my @zVarAdimVariancesNew = ( &NOVARY );
   78 my $var1Name = "VAR1a";
   79 my $var2Name = "VAR2a";
   80 my $zVarAname = "zVARa1";
   81 my $new_var1Name = "VAR1b";
   82 my $new_var2Name = "VAR2b";
   83 my $new_zVarAname = "zVARa2";
   84 my $attrName = "ATTR1";
   85 my $attrName2 = "ATTR2";
   86 my $attrName3 = "ATTR3";
   87 my $attrName4 = "ATTR4";
   88 my $new_attrName = "ATTR1a";
   89 my $rEntryValue =  4 ;
   90 my $zEntryValue = 4.0 ;
   91 my $pad1 = -999 ;
   92 my $pad2 = -8.0 ;
   93 my $pad3 =  "********" ;
   94 my $extendRecs1 = 3;
   95 my $extendRecs2 = 4;
   96 my $extendRecs3 = 5;
   97 my $allocRecs1 = 10 ;
   98 my $allocRecs2 = 15 ;
   99 my $allocRecs3 = 8 ;
  100 my $nRvars = 2 ;
  101 my @rVarNs = ( 0, 1 );
  102 my @rVarsRecBuffer = (
  103   1,2,3,4,5,6,2.2,4.2,6.2,8.2,10.2,12.2
  104 );
  105 my $nZvars = 1 ;
  106 my @zVarNs = ( 0 );
  107 my @zVarsRecBuffer = (
  108   'aaaaaaa',
  109   'bbbbbb',
  110   'ccccc',
  111   'dddd',
  112   'eee'
  113 );
  114 
  115 #############################################################################
  116 # Display title.
  117 #############################################################################
  118 
  119 print "\nTesting Perl-CDF Internal/C interface\n\n";
  120 
  121 #############################################################################
  122 # Create CDF again (previous delete will allow this).
  123 #############################################################################
  124 my $status;
  125 my $x0;
  126 my $temp1;
  127 my $id;
  128 my $zVarAnum_out;
  129 
  130 $status = CDF::CDFlib (&CREATE_, &CDF_, "TESTz", $numDims, \@dimSizes, \$id,
  131 #              &PUT_, &CDF_ENCODING_, $encoding,
  132 #                &CDF_MAJORITY_, $majority,
  133 #                &CDF_COMPRESSION_, $compression, \@compressionLevel,
  134                &NULL_);
  135 QuitCDF ("6.0", $status) if ($status < &CDF_OK) ;
  136 
  137 $status = CDF::CDFlib (CREATE_, zVAR_, $zVarAname, $zVarAdataType, $zVarAnumElements,
  138                 $zNumDimsA, \@zDimSizesA, $zVarArecVariance,
  139                 \@zVarAdimVariances, \$zVarAnum_out,
  140 #                  &PUT_, &zVAR_ALLOCATERECS_, $allocRecs3,
  141 #                &zVAR_BLOCKINGFACTOR_, $extendRecs3,
  142                &NULL_);
  143 QuitCDF ("7.0c", $status) if ($status < &CDF_OK) ;
  144 
  145 $status = CDF::CDFlib (&SELECT_, &zVAR_, $zVarAnum_out,
  146                 &zVAR_RECNUMBER_, $zRecNum,
  147                &NULL_);
  148 QuitCDF ("8.0z", $status) if ($status < &CDF_OK) ;
  149 
  150 #my @zIndicesA;
  151 #for ($x0 = 0; $x0 < $zDIM_0_SIZEa; $x0++) {
  152 #   $zIndicesA[0] = $x0;
  153 #   $temp1 = $zVarAvalues[$x0];
  154 #print "zindice=",$zIndicesA[0], " value=", $temp1,"\n";
  155 #   $status = CDF::CDFlib (&SELECT_, &zVAR_DIMINDICES_, \@zIndicesA,
  156 #             &PUT_, &zVAR_DATA_, \$temp1,
  157 #             &NULL_);
  158 #   QuitCDF ("8.1z", $status) if ($status < &CDF_OK) ;
  159 #}
  160 
  161 my @zIndicesA;
  162 $zIndicesA[0] = 0;
  163 $status = CDF::CDFlib (&SELECT_, &zVAR_RECNUMBER_, $zRecStart,
  164                                 &zVAR_RECCOUNT_, $zRecCount,
  165                                 &zVAR_RECINTERVAL_, $zRecInterval,
  166                                 &zVAR_DIMINDICES_, \@zIndicesA,
  167                                 &zVAR_DIMCOUNTS_, \@zCounts,
  168                                 &zVAR_DIMINTERVALS_, \@zIntervals,
  169                        &PUT_, &zVAR_HYPERDATA_, \@zVarAvalues,
  170                        &NULL_);
  171 QuitCDF ("10.0z", $status) if ($status < &CDF_OK) ;
  172 
  173 $status = CDF::CDFlib (&CLOSE_, &CDF_,
  174                &NULL_);
  175 QuitCDF ("28.2", $status) if ($status < &CDF_OK) ;
  176 
  177 #############################################################################
  178 # Successful completion.
  179 #############################################################################
  180 print "All tests completed successfully\n";
  181 exit;
  182 
  183 #############################################################################
  184 # QuitCDF.
  185 #############################################################################
  186 sub QuitCDF {
  187     my ($where, $status)=@_;
  188 
  189   print "Aborting at $where ...\n";
  190   if ($status < &CDF_OK) {
  191     my $text;
  192     CDF::CDFlib (&SELECT_, &CDF_STATUS_, $status,
  193            &GET_, &STATUS_TEXT_, \$text,
  194            &NULL_);
  195     print $text;
  196   }
  197   CDF::CDFlib (&CLOSE_, &CDF_,
  198       &NULL_);
  199   print "...test aborted.\n";
  200   exit;
  201     
  202 }#endsub QuitCDF
  203 
  204 #############################################################################
  205 #  QuitEPOCH
  206 #############################################################################
  207 sub QuitEPOCH {
  208   my ($where) = @_;
  209   print "Aborting at $where...test aborted.\n";
  210   exit;
  211 
  212 }#endsub QuitEPOCH