"Fossies" - the Fresh Open Source Software Archive

Member "PerlCDF38_0/CDF.pm" (16 Apr 2020, 71880 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 "CDF.pm" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 36_4_vs_37_0.

    1 #******************************************************************************
    2 # Copyright 1996-2013 United States Government as represented by the
    3 # Administrator of the National Aeronautics and Space Administration.
    4 # All Rights Reserved.
    5 #*****************************************************************************/
    6 
    7 package CDF;
    8 
    9 require Exporter;
   10 require DynaLoader;
   11 use AutoLoader;
   12 use Data::Dumper;
   13 
   14 @ISA = qw(Exporter DynaLoader);
   15 # Items to export into callers namespace by default. Note: do not export
   16 # names by default without a very good reason. Use EXPORT_OK instead.
   17 # Do not simply export all your public functions/methods/constants.
   18 @EXPORT = qw(
   19     AHUFF_COMPRESSION
   20     ALPHAOSF1_DECODING
   21     ALPHAOSF1_ENCODING
   22     ALPHAVMSd_DECODING
   23     ALPHAVMSd_ENCODING
   24     ALPHAVMSg_DECODING
   25     ALPHAVMSg_ENCODING
   26     ALPHAVMSi_DECODING
   27     ALPHAVMSi_ENCODING
   28         ARM_BIG_DECODING
   29         ARM_BIG_ENCODING
   30         ARM_LITTLE_DECODING
   31         ARM_LITTLE_ENCODING
   32     ATTR_
   33     ATTR_EXISTANCE_
   34     ATTR_EXISTENCE_
   35     ATTR_EXISTS
   36     ATTR_MAXENTRY_
   37     ATTR_MAXgENTRY_
   38     ATTR_MAXrENTRY_
   39     ATTR_MAXzENTRY_
   40     ATTR_NAME_
   41     ATTR_NAME_TRUNC
   42     ATTR_NUMBER_
   43     ATTR_NUMENTRIES_
   44     ATTR_NUMgENTRIES_
   45     ATTR_NUMrENTRIES_
   46     ATTR_NUMzENTRIES_
   47     ATTR_SCOPE_
   48     BAD_ALLOCATE_RECS
   49     BAD_ARGUMENT
   50     BAD_ATTR_NAME
   51     BAD_ATTR_NUM
   52     BAD_BLOCKING_FACTOR
   53     BAD_CACHE_SIZE
   54     BAD_CHECKSUM
   55     BAD_CDFSTATUS
   56     BAD_CDF_EXTENSION
   57     BAD_CDF_ID
   58     BAD_CDF_NAME
   59     BAD_COMPRESSION_PARM
   60     BAD_DATA_TYPE
   61     BAD_DECODING
   62     BAD_DIM_COUNT
   63     BAD_DIM_INDEX
   64     BAD_DIM_INTERVAL
   65     BAD_DIM_SIZE
   66     BAD_ENCODING
   67     BAD_ENTRY_NUM
   68     BAD_EXTEND_RECS
   69     BAD_FNC_OR_ITEM
   70     BAD_FORMAT
   71     BAD_INITIAL_RECS
   72     BAD_MAJORITY
   73     BAD_MALLOC
   74     BAD_NEGtoPOSfp0_MODE
   75     BAD_NUM_DIMS
   76     BAD_NUM_ELEMS
   77     BAD_NUM_VARS
   78     BAD_READONLY_MODE
   79     BAD_REC_COUNT
   80     BAD_REC_INTERVAL
   81     BAD_REC_NUM
   82     BAD_SCOPE
   83     BAD_SCRATCH_DIR
   84     BAD_SPARSEARRAYS_PARM
   85     BAD_VAR_NAME
   86     BAD_VAR_NUM
   87     BAD_zMODE
   88     CANNOT_ALLOCATE_RECORDS
   89     CANNOT_CHANGE
   90     CANNOT_COMPRESS
   91     CANNOT_SPARSEARRAYS
   92     CANNOT_SPARSERECORDS
   93     CDF_
   94     CDF_ACCESS_
   95     CDF_BYTE
   96     CDF_CACHESIZE_
   97     CDF_CHAR
   98     CDF_CHECKSUM_
   99     CDF_CLOSE_ERROR
  100     CDF_COMPRESSION_
  101     CDF_COPYRIGHT_
  102     CDF_CREATE_ERROR
  103     CDF_DECODING_
  104     CDF_DELETE_ERROR
  105     CDF_DIMCOUNTS_
  106     CDF_DIMINDICES_
  107     CDF_DIMINTERVALS_
  108     CDF_DIMSIZES_
  109     CDF_DOUBLE
  110     CDF_ENCODING_
  111     CDF_EPOCH
  112     CDF_EPOCH16
  113     CDF_EXISTS
  114     CDF_FLOAT
  115     CDF_FORMAT_
  116     CDF_INCREMENT_
  117     CDF_INFO_
  118     CDF_INT1
  119     CDF_INT2
  120     CDF_INT4
  121     CDF_INT8
  122     CDF_INTERNAL_ERROR
  123     CDF_LEAPSECONDLASTUPDATED_
  124     CDF_MAJORITY_
  125     CDF_MAXREC_
  126     CDF_MAX_DIMS
  127     CDF_MAX_PARMS
  128     CDF_MIN_DIMS
  129     CDF_NAME_
  130     CDF_NAME_TRUNC
  131     CDF_NEGtoPOSfp0_MODE_
  132     CDF_NUMATTRS_
  133     CDF_NUMDIMS_
  134     CDF_NUMVARS_
  135     CDF_NUMgATTRS_
  136     CDF_NUMrVARS_
  137     CDF_NUMvATTRS_
  138     CDF_NUMzVARS_
  139     CDF_OK
  140     CDF_OPEN_ERROR
  141     CDF_READONLY_MODE_
  142     CDF_READ_ERROR
  143     CDF_REAL4
  144     CDF_REAL8
  145     CDF_RECCOUNT_
  146     CDF_RECINTERVAL_
  147     CDF_RECNUMBER_
  148     CDF_RELEASE_
  149     CDF_SCRATCHDIR_
  150     CDF_STATUS_
  151     CDF_TIME_TT2000
  152     CDF_UCHAR
  153     CDF_UINT1
  154     CDF_UINT2
  155     CDF_UINT4
  156     CDF_VERSION_
  157     CDF_WARN
  158     CDF_WRITE_ERROR
  159     CDF_zMODE_
  160     CDFwithSTATS_
  161     CHECKSUM_
  162     CHECKSUM_ERROR
  163     CHECKSUM_NOT_ALLOWED
  164     CLOSE_
  165     COLUMN_MAJOR
  166     COL_MAJOR
  167     COMPRESSION_ERROR
  168     COMPRESS_CACHESIZE_
  169     CONFIRM_
  170     CORRUPTED_V2_CDF
  171     CORRUPTED_V3_CDF
  172     CREATE_
  173     CURgENTRY_EXISTENCE_
  174     CURrENTRY_EXISTENCE_
  175     CURzENTRY_EXISTENCE_
  176     BACKWARDFILEon
  177     BACKWARDFILEoff
  178     VALIDATEFILEon
  179     VALIDATEFILEoff
  180     DATATYPE_SIZE_
  181     DECOMPRESSION_ERROR
  182     DECSTATION_DECODING
  183     DECSTATION_ENCODING
  184     DELETE_
  185     DID_NOT_COMPRESS
  186     EMPTY_COMPRESSED_CDF
  187     END_OF_VAR
  188     ENTRY_
  189     ENTRY_DATATYPE_
  190     ENTRY_DATA_
  191     ENTRY_NUMELEMS_
  192     EPOCH_STRING_LEN
  193     EPOCH1_STRING_LEN
  194     EPOCH2_STRING_LEN
  195     EPOCH3_STRING_LEN
  196     EPOCH4_STRING_LEN
  197     EPOCH16_STRING_LEN
  198     EPOCH16_1_STRING_LEN
  199     EPOCH16_2_STRING_LEN
  200     EPOCH16_3_STRING_LEN
  201     EPOCH16_4_STRING_LEN
  202     EPOCHx_FORMAT_MAX
  203     EPOCHx_STRING_MAX
  204     FORCED_PARAMETER
  205     GET_
  206     GLOBAL_SCOPE
  207     GLOBAL_SCOPE_ASSUMED
  208     GZIP_COMPRESSION
  209     HOST_DECODING
  210     HOST_ENCODING
  211     HP_DECODING
  212     HP_ENCODING
  213     HUFF_COMPRESSION
  214         IA64VMSi_DECODING
  215         IA64VMSi_ENCODING
  216         IA64VMSd_DECODING
  217         IA64VMSd_ENCODING
  218         IA64VMSg_DECODING
  219         IA64VMSg_ENCODING
  220     IBMPC_DECODING
  221     IBMPC_ENCODING
  222     IBMRS_DECODING
  223     IBMRS_ENCODING
  224     IBM_PC_OVERFLOW
  225     ILLEGAL_EPOCH_VALUE
  226     ILLEGAL_FOR_SCOPE
  227     ILLEGAL_IN_zMODE
  228     ILLEGAL_ON_V1_CDF
  229     ILLEGAL_TT2000_VALUE
  230     IS_A_NETCDF
  231     LIB_COPYRIGHT_
  232     LIB_INCREMENT_
  233     LIB_RELEASE_
  234     LIB_VERSION_
  235     LIB_subINCREMENT_
  236     MAC_DECODING
  237     MAC_ENCODING
  238     MD5_CHECKSUM
  239     MIPSEB_ENCODING
  240     MIPSEL_ENCODING
  241     MULTI_FILE
  242     MULTI_FILE_FORMAT
  243     NA_FOR_VARIABLE
  244     NEGATIVE_FP_ZERO
  245     NEGtoPOSfp0off
  246     NEGtoPOSfp0on
  247     NETWORK_DECODING
  248     NETWORK_ENCODING
  249     NOT_A_CDF_OR_NOT_SUPPORTED
  250     NOVARY
  251     NO_ATTR_SELECTED
  252     NO_CDF_SELECTED
  253     NO_CHECKSUM
  254     NO_COMPRESSION
  255     NO_DELETE_ACCESS
  256     NO_ENTRY_SELECTED
  257     NO_MORE_ACCESS
  258     NO_PADVALUE_SPECIFIED
  259     NO_SPARSEARRAYS
  260     NO_SPARSERECORDS
  261     NO_STATUS_SELECTED
  262     NO_SUCH_ATTR
  263     NO_SUCH_CDF
  264     NO_SUCH_ENTRY
  265     NO_SUCH_RECORD
  266     NO_SUCH_VAR
  267     NO_VARS_IN_CDF
  268     NO_VAR_SELECTED
  269     NO_WRITE_ACCESS
  270     NONE_CHECKSUM
  271     NULL_
  272     NeXT_DECODING
  273     NeXT_ENCODING
  274     OPEN_
  275     OPTIMAL_ENCODING_TREES
  276     PAD_SPARSERECORDS
  277     PRECEEDING_RECORDS_ALLOCATED
  278     PREV_SPARSERECORDS
  279     PUT_
  280     READONLYoff
  281     READONLYon
  282     READ_ONLY_DISTRIBUTION
  283     READ_ONLY_MODE
  284     RESERVED_CDFID
  285     RESERVED_CDFSTATUS
  286     RLE_COMPRESSION
  287     RLE_OF_ZEROs
  288     ROW_MAJOR
  289     SCRATCH_CREATE_ERROR
  290     SCRATCH_DELETE_ERROR
  291     SCRATCH_READ_ERROR
  292     SCRATCH_WRITE_ERROR
  293     SELECT_
  294     SGi_DECODING
  295     SGi_ENCODING
  296     SINGLE_FILE
  297     SINGLE_FILE_FORMAT
  298     SOME_ALREADY_ALLOCATED
  299     STAGE_CACHESIZE_
  300     STATUS_TEXT_
  301     STRINGDELIMITER
  302     SUN_DECODING
  303     SUN_ENCODING
  304     TOO_MANY_PARMS
  305     TOO_MANY_VARS
  306     TTT2000_0_STRING_LEN
  307     TTT2000_1_STRING_LEN
  308     TTT2000_2_STRING_LEN
  309     TTT2000_3_STRING_LEN
  310     TTT2000_4_STRING_LEN
  311     UNKNOWN_COMPRESSION
  312     UNKNOWN_SPARSENESS
  313     UNSUPPORTED_OPERATION
  314     VARIABLE_SCOPE
  315     VARIABLE_SCOPE_ASSUMED
  316     VARY
  317     VAR_
  318     VAR_ALREADY_CLOSED
  319     VAR_CLOSE_ERROR
  320     VAR_CREATE_ERROR
  321     VAR_DATASPEC_
  322     VAR_DATATYPE_
  323     VAR_DATA_
  324     VAR_DELETE_ERROR
  325     VAR_DIMVARYS_
  326     VAR_EXISTS
  327     VAR_EXTENDRECS_
  328     VAR_FILLVALUE_
  329     VAR_HYPERDATA_
  330     VAR_INITIALRECS_
  331     VAR_MAXREC_
  332     VAR_NAME_
  333     VAR_NAME_TRUNC
  334     VAR_NUMBER_
  335     VAR_NUMELEMS_
  336     VAR_OPEN_ERROR
  337     VAR_READ_ERROR
  338     VAR_RECVARY_
  339     VAR_SEQDATA_
  340     VAR_SEQPOS_
  341     VAR_WRITE_ERROR
  342     VAX_DECODING
  343     VAX_ENCODING
  344     VIRTUAL_RECORD_DATA
  345     gENTRY_
  346     gENTRY_DATASPEC_
  347     gENTRY_DATATYPE_
  348     gENTRY_DATA_
  349     gENTRY_EXISTANCE_
  350     gENTRY_EXISTENCE_
  351     gENTRY_NUMELEMS_
  352     rENTRY_
  353     rENTRY_DATASPEC_
  354     rENTRY_DATATYPE_
  355     rENTRY_DATA_
  356     rENTRY_EXISTANCE_
  357     rENTRY_EXISTENCE_
  358     rENTRY_NAME_
  359     rENTRY_NUMELEMS_
  360     rENTRY_NUMSTRINGS_
  361     rENTRY_STRINGSDATA_
  362     rVAR_
  363     rVAR_ALLOCATEBLOCK_
  364     rVAR_ALLOCATEDFROM_
  365     rVAR_ALLOCATEDTO_
  366     rVAR_ALLOCATERECS_
  367     rVAR_BLOCKINGFACTOR_
  368     rVAR_CACHESIZE_
  369     rVAR_COMPRESSION_
  370     rVAR_DATASPEC_
  371     rVAR_DATATYPE_
  372     rVAR_DATA_
  373     rVAR_DIMVARYS_
  374     rVAR_EXISTANCE_
  375     rVAR_EXISTENCE_
  376     rVAR_EXTENDRECS_
  377     rVAR_HYPERDATA_
  378     rVAR_INITIALRECS_
  379     rVAR_MAXREC_
  380     rVAR_MAXallocREC_
  381     rVAR_NAME_
  382     rVAR_NUMBER_
  383     rVAR_NUMELEMS_
  384     rVAR_NUMRECS_
  385     rVAR_NUMallocRECS_
  386     rVAR_PADVALUE_
  387     rVAR_RECORDS_
  388     rVAR_RECORDS_RENUMBER_
  389     rVAR_RECVARY_
  390     rVAR_RESERVEPERCENT_
  391     rVAR_SEQDATA_
  392     rVAR_SEQPOS_
  393     rVAR_SPARSEARRAYS_
  394     rVAR_SPARSERECORDS_
  395     rVAR_nINDEXENTRIES_
  396     rVAR_nINDEXLEVELS_
  397     rVAR_nINDEXRECORDS_
  398     rVARs_CACHESIZE_
  399     rVARs_DIMCOUNTS_
  400     rVARs_DIMINDICES_
  401     rVARs_DIMINTERVALS_
  402     rVARs_DIMSIZES_
  403     rVARs_MAXREC_
  404     rVARs_NUMDIMS_
  405     rVARs_RECCOUNT_
  406     rVARs_RECDATA_
  407     rVARs_RECINTERVAL_
  408     rVARs_RECNUMBER_
  409     zENTRY_
  410     zENTRY_DATASPEC_
  411     zENTRY_DATATYPE_
  412     zENTRY_DATA_
  413     zENTRY_EXISTANCE_
  414     zENTRY_EXISTENCE_
  415     zENTRY_NAME_
  416     zENTRY_NUMELEMS_
  417     zENTRY_NUMSTRINGS_
  418     zENTRY_STRINGSDATA_
  419     zMODEoff
  420     zMODEon1
  421     zMODEon2
  422     zVAR_
  423     zVAR_ALLOCATEBLOCK_
  424     zVAR_ALLOCATEDFROM_
  425     zVAR_ALLOCATEDTO_
  426     zVAR_ALLOCATERECS_
  427     zVAR_BLOCKINGFACTOR_
  428     zVAR_CACHESIZE_
  429     zVAR_COMPRESSION_
  430     zVAR_DATASPEC_
  431     zVAR_DATATYPE_
  432     zVAR_DATA_
  433     zVAR_DIMCOUNTS_
  434     zVAR_DIMINDICES_
  435     zVAR_DIMINTERVALS_
  436     zVAR_DIMSIZES_
  437     zVAR_DIMVARYS_
  438     zVAR_EXISTANCE_
  439     zVAR_EXISTENCE_
  440     zVAR_EXTENDRECS_
  441     zVAR_HYPERDATA_
  442     zVAR_INITIALRECS_
  443     zVAR_MAXREC_
  444     zVAR_MAXallocREC_
  445     zVAR_NAME_
  446     zVAR_NUMBER_
  447     zVAR_NUMDIMS_
  448     zVAR_NUMELEMS_
  449     zVAR_NUMRECS_
  450     zVAR_NUMallocRECS_
  451     zVAR_PADVALUE_
  452     zVAR_RECCOUNT_
  453     zVAR_RECINTERVAL_
  454     zVAR_RECNUMBER_
  455     zVAR_RECORDS_
  456     zVAR_RECORDS_RENUMBER_
  457     zVAR_RECVARY_
  458     zVAR_RESERVEPERCENT_
  459     zVAR_SEQDATA_
  460     zVAR_SEQPOS_
  461     zVAR_SPARSEARRAYS_
  462     zVAR_SPARSERECORDS_
  463     zVAR_nINDEXENTRIES_
  464     zVAR_nINDEXLEVELS_
  465     zVAR_nINDEXRECORDS_
  466     zVARs_CACHESIZE_
  467     zVARs_MAXREC_
  468     zVARs_RECDATA_
  469     zVARs_RECNUMBER_
  470 );
  471 sub AUTOLOAD {
  472     # This AUTOLOAD is used to 'autoload' constants from the constant()
  473     # XS function.  If a constant is not found then control is passed
  474     # to the AUTOLOAD in AutoLoader.
  475 
  476     local($constname);
  477     ($constname = $AUTOLOAD) =~ s/.*:://;
  478     $val = constant($constname);
  479     if ($! != 0) {
  480     if ($! =~ /Invalid/i) {
  481       $AutoLoader::AUTOLOAD = $AUTOLOAD;
  482       goto &AutoLoader::AUTOLOAD;
  483     }
  484     else {
  485       ($pack,$file,$line) = caller;
  486       die "You have not defined CDF macro $constname at $file line $line";
  487     }
  488     }
  489     eval "sub $AUTOLOAD { $val }";
  490     goto &$AUTOLOAD;
  491 }
  492 
  493 bootstrap CDF;
  494 
  495 # Preloaded methods go here.
  496 
  497 # Autoload methods go after __END__, and are processed by the autosplit program.
  498 
  499 1;
  500 __END__
  501 
  502 #############################################################################
  503 #
  504 #  Perl interface to CDF's internal interface CDFlib
  505 #
  506 #  Usage:
  507 #     $status = CDFlib(&CREATE_, &CDF_, $CDFpath, ..., &NULL_);
  508 #
  509 #   Translation from the C internal interface:
  510 #   All variables passed by value are Perl Scalars
  511 #              $status = CDFlib(&PUT_, &CDF_MAJORITY_, $majorty, &NULL_);
  512 #   All variables passed as Perl Reference to Scalars are to have values 
  513 #           returned
  514 #              $status = CDFlib(&GET_, &CDF_MAJORITY_, \$majority, &NULL_);
  515 #   All arrays are passed by reference, regardless of whether they are 
  516 #       returned
  517 #   All macro constants defined in cdf.h need to have a & prepended
  518 #
  519 #############################################################################
  520 #
  521 #   The names of the XSUB are based on the number of and datatype of the 
  522 #   calling arguments, except for a few special cases. Used in the CDF 
  523 #   interface is specified
  524 #   data 
  525 #   type  input output description 
  526 #   ----- ----- ------ ---------------------------------------
  527 #   array   a     1    used for long array (passed by reference) as long 
  528 #                      varname[];
  529 #   void 1  b     2    used for reference to an array of values as void *buffer;
  530 #   char    c     3    used for single char as char varname; or char *varname;
  531 #   CDFid   d     4    used for type CDFid as CDFid id; or CDFid *id; 
  532 #                      (actually a type of void *)  
  533 #   long    l     5    used for type long as long varname; or long *varname;
  534 #   string  s     6    used for multiple chars as char *varname; 
  535 #   void 2  v     7    used for reference to a single value passed as 
  536 #                      void *value;
  537 #
  538 #  The letters are used for input paraneters and numbers for output
  539 #  (The reason for doing this is to eliminate conflicts on platforms that
  540 #   only use all upper or lower cases letters, eg PC and VMS.)
  541 #  Parameters expecting returned values are scalar references from a Perl 
  542 #  script calling to this package. They are dereferenced in this package
  543 #
  544 #############################################################################
  545 
  546 sub CDFlib {
  547     use strict;
  548     my $operation = shift;
  549     my $status;
  550 
  551 #operation (Function) block  Labelled to avoid messy elsif construct    
  552 FCN: {
  553     return &CDF_OK if ($operation == &NULL_);
  554     
  555 #############################################################################
  556 # CLOSE
  557 #############################################################################
  558 
  559     if ($operation == &CLOSE_) {
  560       for (;;) {
  561         my $item = shift;
  562         if ($item == &CDF_ || $item == &rVAR_ || $item == &zVAR_) {
  563          $status = CDFlibnone($operation, $item);
  564         } else {
  565           unshift (@_, $item);
  566           last FCN;
  567         } #end if
  568         return $status if ($status != &CDF_OK);
  569       } #end for
  570     } #end if CLOSE_
  571     
  572 #############################################################################
  573 # CONFIRM
  574 #############################################################################
  575 
  576     if ($operation == &CONFIRM_) {
  577       for (;;) {
  578         my $item = shift;
  579         if ($item == &ATTR_ || $item == &CDF_CACHESIZE_ || 
  580         $item == &CDF_DECODING_ ||
  581         $item == &CDF_NEGtoPOSfp0_MODE_ || 
  582         $item == &CDF_READONLY_MODE_ || $item == &CDF_STATUS_ || 
  583         $item == &CDF_zMODE_ || $item == &COMPRESS_CACHESIZE_ || 
  584         $item == &gENTRY_ || $item == &rENTRY_ || 
  585         $item == &rVAR_ || $item == &rVAR_CACHESIZE_ || 
  586         $item == &rVAR_RESERVEPERCENT_ || 
  587         $item == &rVARs_RECCOUNT_ || $item == &rVARs_RECINTERVAL_ || 
  588         $item == &rVARs_RECNUMBER_ || $item == &STAGE_CACHESIZE_ || 
  589         $item == &zENTRY_ || $item == &zVAR_ || 
  590         $item == &zVAR_CACHESIZE_ || $item == &zVAR_RECCOUNT_ || 
  591         $item == &zVAR_RECINTERVAL_ || $item == &zVAR_RECNUMBER_ || 
  592                 $item == &rVARs_CACHESIZE_ || $item == &zVARs_CACHESIZE_ || 
  593         $item == &zVAR_RESERVEPERCENT_ ) {
  594            my $LongRef = shift;
  595            $status = CDFlib5($operation, $item, $$LongRef);
  596 
  597         } elsif ($item == &ATTR_EXISTENCE_ || $item == &zVAR_EXISTENCE_ ||
  598              $item == &rVAR_EXISTENCE_) {
  599             my $String = shift;
  600             $status = CDFlibs($operation, $item, $String);
  601 
  602         } elsif ($item == &CDF_NAME_) {
  603             my $StringRef = shift;
  604             $status = CDFlib6($operation, $item, $$StringRef);
  605 
  606         } elsif ($item == &CDF_ACCESS_ || $item == &CURgENTRY_EXISTENCE_ || 
  607              $item == &CURrENTRY_EXISTENCE_ || 
  608              $item == &CURzENTRY_EXISTENCE_ || 
  609              $item == &rVAR_PADVALUE_ || $item == &zVAR_PADVALUE_ ||
  610              $item == &CDF_CHECKSUM_) {
  611             $status = CDFlibnone($operation, $item);
  612 
  613         } elsif ($item == &gENTRY_EXISTENCE_ || 
  614              $item == &rENTRY_EXISTENCE_ || 
  615              $item == &zENTRY_EXISTENCE_) {
  616             my $Long = shift;
  617             $status = CDFlibl($operation, $item, $Long);
  618 
  619         } elsif ($item == &rVAR_SEQPOS_ || $item == &zVAR_SEQPOS_) {
  620             my $LongRef = shift;
  621             my $LongArrayRef = shift;
  622             $status = CDFlib51($operation, $item, $$LongRef, 
  623                        $LongArrayRef);
  624         } elsif ($item == &rVARs_DIMCOUNTS_ || 
  625              $item == &rVARs_DIMINDICES_ || 
  626              $item == &rVARs_DIMINTERVALS_ || 
  627              $item == &zVAR_DIMCOUNTS_ || 
  628              $item == &zVAR_DIMINDICES_ || 
  629              $item == &zVAR_DIMINTERVALS_) {
  630             my $LongArrayRef = shift;
  631             $status = CDFlib1($operation, $item, $LongArrayRef);
  632 
  633         } elsif ($item == &CDF_) {
  634             my $CDFidRef = shift;
  635             $status = CDFlib4($operation, $item, $$CDFidRef);
  636 
  637         } else {
  638             unshift (@_, $item);
  639             last FCN;
  640            } #end if
  641         return $status if ($status != &CDF_OK);
  642       } #end for
  643     } #end if CONFIRM_
  644     
  645 #############################################################################
  646 # CREATE
  647 #############################################################################
  648 
  649     if ($operation == &CREATE_) {
  650       for (;;) {
  651         my $item = shift;
  652         if ($item == &ATTR_) {
  653             my $String = shift;
  654             my $Long = shift;
  655             my $LongRef = shift;
  656             $status = CDFCreateAttr($operation, $item, $String, 
  657                         $Long, $$LongRef);
  658         } elsif ($item == &CDF_) {
  659             my $String = shift;
  660             my $Long = shift;
  661             my $ArrayRef = shift;
  662             my $CDFidRef = shift;
  663             $status = CDFCreateCDF($operation, $item, $String, 
  664                            $Long, $ArrayRef, $$CDFidRef);
  665         } elsif ($item == &rVAR_) {
  666             my $String = shift;
  667             my $Long = shift;
  668             my $Long1 = shift;
  669             my $Long2 = shift;
  670             my $ArrayRef = shift;
  671             my $LongRef = shift;
  672             $status = CDFCreateRvar($operation, $item, $String, 
  673                         $Long, $Long1, $Long2, 
  674                         $ArrayRef, $$LongRef);
  675         } elsif ($item == &zVAR_) {
  676             my $String = shift;
  677             my $Long = shift;
  678             my $Long1 = shift;
  679             my $Long2 = shift;
  680             my $ArrayRef = shift;
  681             my $Long3 = shift;
  682             my $ArrayRef1 = shift;
  683             my $LongRef = shift;
  684             $status = CDFCreateZvar($operation, $item, $String, 
  685                         $Long, $Long1, $Long2, 
  686                         $ArrayRef, $Long3, $ArrayRef1, 
  687                         $$LongRef);
  688         } else {
  689             unshift (@_, $item);
  690             last FCN;
  691         } #end if
  692         return $status if ($status != &CDF_OK);
  693        } #end for
  694     } #end if CREATE_
  695     
  696 #############################################################################
  697 # DELETE
  698 #############################################################################
  699     
  700     if ($operation == &DELETE_) {
  701        for (;;) {
  702         my $item = shift;
  703         if ($item == &ATTR_ || $item == &CDF_ || $item == &gENTRY_ || 
  704             $item == &rENTRY_ || $item == &rVAR_ || 
  705             $item == &zENTRY_ || $item == &zVAR_) {
  706             $status = CDFlibnone($operation, $item);
  707 
  708         } elsif ($item == &rVAR_RECORDS_ || $item == &zVAR_RECORDS_ ||
  709                          $item == &rVAR_RECORDS_RENUMBER_ ||
  710                          $item == &zVAR_RECORDS_RENUMBER_) {
  711             my $Long1 = shift;
  712             my $Long2 = shift;
  713             $status = CDFlibll($operation, $item, $Long1, $Long2);
  714  
  715         } else {
  716             unshift (@_, $item);
  717             last FCN;
  718         } #end if
  719         return $status if ($status != &CDF_OK);
  720        } #end for
  721     } #end if DELETE_
  722 
  723 #############################################################################
  724 # GET
  725 #############################################################################
  726     
  727     if ($operation == &GET_) {
  728        for (;;) {
  729         my $item = shift;
  730         if ($item == &ATTR_MAXgENTRY_ || $item == &ATTR_MAXrENTRY_ || 
  731             $item == &ATTR_MAXzENTRY_ || $item == &ATTR_NUMgENTRIES_ || 
  732             $item == &ATTR_NUMrENTRIES_ || 
  733             $item == &ATTR_NUMzENTRIES_ ||
  734             $item == &ATTR_SCOPE_ || $item == &CDF_ENCODING_ || 
  735             $item == &CDF_FORMAT_ || $item == &CDF_INCREMENT_ || 
  736             $item == &CDF_MAJORITY_ || $item == &CDF_NUMATTRS_ ||
  737             $item == &CDF_NUMgATTRS_ ||
  738             $item == &CDF_NUMrVARS_ || $item == &CDF_NUMvATTRS_ || 
  739             $item == &CDF_NUMzVARS_ || $item == &CDF_RELEASE_ || 
  740             $item == &CDF_VERSION_ || $item == &gENTRY_DATATYPE_ ||
  741             $item == &gENTRY_NUMELEMS_ || $item == &LIB_INCREMENT_ || 
  742             $item == &LIB_RELEASE_ || $item == &LIB_VERSION_ || 
  743             $item == &rENTRY_DATATYPE_ || $item == &rENTRY_NUMELEMS_ ||
  744             $item == &rENTRY_NUMSTRINGS_ ||
  745             $item == &rVAR_BLOCKINGFACTOR_ || 
  746             $item == &rVAR_DATATYPE_ ||
  747             $item == &rVAR_MAXallocREC_ || $item == &rVAR_MAXREC_ || 
  748             $item == &rVAR_nINDEXENTRIES_ || 
  749             $item == &rVAR_nINDEXLEVELS_ ||
  750             $item == &rVAR_nINDEXRECORDS_ || 
  751             $item == &rVAR_NUMallocRECS_ ||
  752             $item == &rVAR_NUMELEMS_ || $item == &rVAR_NUMRECS_ ||
  753             $item == &rVAR_RECVARY_ || $item == &rVAR_SPARSERECORDS_ || 
  754             $item == &rVARs_MAXREC_ || $item == &rVARs_NUMDIMS_ || 
  755             $item == &zENTRY_DATATYPE_ || $item == &zENTRY_NUMELEMS_ ||
  756             $item == &zENTRY_NUMSTRINGS_ ||
  757             $item == &zVAR_BLOCKINGFACTOR_ || 
  758             $item == &zVAR_DATATYPE_ || 
  759             $item == &zVAR_MAXallocREC_ || $item == &zVAR_MAXREC_ || 
  760             $item == &zVAR_nINDEXENTRIES_ || 
  761             $item == &zVAR_nINDEXLEVELS_ ||
  762             $item == &zVAR_nINDEXRECORDS_ || 
  763             $item == &zVAR_NUMallocRECS_ ||
  764             $item == &zVAR_NUMDIMS_ || $item == &zVAR_NUMELEMS_ || 
  765             $item == &zVAR_NUMRECS_ ||
  766             $item == &CDF_LEAPSECONDLASTUPDATED_ ||
  767             $item == &zVAR_RECVARY_ || $item == &zVAR_SPARSERECORDS_ ||
  768             $item == &zVARs_MAXREC_ || $item == &CDF_CHECKSUM_) {
  769             my $LongRef = shift;
  770             $status = CDFlib5($operation, $item, $$LongRef);
  771 
  772         } elsif ($item == &ATTR_NAME_ || $item == &CDF_COPYRIGHT_ || 
  773                  $item == &LIB_COPYRIGHT_ || 
  774                  $item == &rVAR_NAME_ || $item == &STATUS_TEXT_ ||
  775                  $item == &zVAR_NAME_) {
  776             my $StringRef = shift;
  777             $status = CDFlib6($operation, $item, $$StringRef);
  778 
  779         } elsif ($item == &LIB_subINCREMENT_) {
  780             my $CharRef = shift;
  781             $status = CDFlib3($operation, $item, $$CharRef);
  782 
  783         } elsif ($item == &ATTR_NUMBER_ || $item == &rVAR_NUMBER_ || 
  784                  $item == &zVAR_NUMBER_) {
  785             my $String = shift;
  786             my $LongRef = shift;
  787             $status = CDFlibs5($operation, $item, $String, 
  788                        $$LongRef);
  789 
  790         } elsif ($item == &DATATYPE_SIZE_ || 
  791              $item == &rVAR_ALLOCATEDFROM_ ||
  792              $item == &rVAR_ALLOCATEDTO_ || 
  793              $item == &zVAR_ALLOCATEDFROM_ ||
  794              $item == &zVAR_ALLOCATEDTO_) {
  795             my $Long = shift;
  796             my $LongRef = shift;
  797             $status = CDFlibl5($operation, $item, $Long, $$LongRef);
  798 
  799         } elsif ($item == &gENTRY_DATA_ || $item == &rENTRY_DATA_ || 
  800                  $item == &rVAR_DATA_ || $item == &rVAR_PADVALUE_ || 
  801                  $item == &rVAR_SEQDATA_ || $item == &zENTRY_DATA_ ||
  802                  $item == &zVAR_DATA_ || $item == &zVAR_PADVALUE_ || 
  803              $item == &zVAR_SEQDATA_) { 
  804                         my $VoidRef = shift;
  805             if (ref($VoidRef) eq "SCALAR") {
  806                           $status = CDFlib7($operation, $item, $VoidRef);
  807             } else {
  808               $status = CDFlib7A($operation, $item, $VoidRef);
  809             }
  810 
  811         } elsif ($item == &rENTRY_STRINGSDATA_ || 
  812                  $item == &zENTRY_STRINGSDATA_) {
  813                         my $VoidRef = shift;
  814             $status = CDFlib8A($operation, $item, $VoidRef);
  815 
  816         } elsif ($item == &rVAR_HYPERDATA_ || 
  817              $item == &zVAR_HYPERDATA_) {
  818             my $VoidArrayRef = shift;
  819             $status = CDFlib2($operation, $item, $VoidArrayRef);
  820 
  821         } elsif ($item == &rVAR_DIMVARYS_ || 
  822              $item == &rVARs_DIMSIZES_ || 
  823                  $item == &zVAR_DIMSIZES_ || $item == &zVAR_DIMVARYS_) {
  824 #if called for a 0 dimension z variable, a 0 is returned
  825 # to be more Perlish, an undef would be more appropriate
  826             my $LongArrayRef = shift;
  827             $status = CDFlib1($operation, $item, $LongArrayRef);
  828 
  829         } elsif ($item == &rVARs_RECDATA_ || $item == &zVARs_RECDATA_) {
  830             my $Long = shift;
  831             my $LongArrayRef = shift;
  832             my $VoidArrayRef = shift;
  833             $status = CDFlibla2($operation, $item, $Long, 
  834                         $LongArrayRef, $VoidArrayRef);
  835 
  836         } elsif ($item == &CDF_COMPRESSION_ || 
  837              $item == &rVAR_COMPRESSION_ ||
  838              $item == &rVAR_SPARSEARRAYS_ || 
  839              $item == &zVAR_COMPRESSION_ ||
  840              $item == &zVAR_SPARSEARRAYS_) {
  841             my $Long1Ref = shift;
  842             my $LongArrayRef = shift;
  843             my $Long2Ref = shift;
  844             $status = CDFlib515($operation, $item, $$Long1Ref, 
  845                         $LongArrayRef, $$Long2Ref);
  846 
  847         } elsif ($item == &CDF_INFO_) {
  848             my $String = shift;
  849             my $Long1Ref = shift;
  850             my $LongArrayRef = shift;
  851             my $Long2Ref = shift;
  852             my $Long3Ref = shift;
  853             $status = CDFlibs5155($operation, $item, $String, 
  854                           $$Long1Ref, $LongArrayRef, 
  855                           $$Long2Ref, $$Long3Ref);
  856 
  857         } else {
  858             unshift (@_, $item);
  859             last FCN;
  860         } #end if
  861         return $status if ($status != &CDF_OK);
  862        } #end for
  863     } #end if GET_
  864 
  865     
  866 #############################################################################
  867 # OPEN
  868 #############################################################################
  869     
  870     if ($operation == &OPEN_) {
  871        for (;;) {
  872         my $item = shift;
  873         if ($item == &CDF_) {
  874           my $String = shift;
  875           my $CDFidRef = shift;
  876           $status = CDFlibs4($operation, $item, $String, $$CDFidRef);
  877         } else {
  878           unshift (@_, $item);
  879           last FCN;
  880         } #end if
  881         return $status if ($status != &CDF_OK);
  882        } #end for
  883     } #end if OPEN_
  884 
  885 #############################################################################
  886 # PUT
  887 #############################################################################
  888     
  889     if ($operation == &PUT_) {
  890        for (;;) {
  891         my $item = shift;
  892         if ($item == &ATTR_NAME_ || $item == &rVAR_NAME_ || 
  893             $item == &zVAR_NAME_) {
  894             my $String = shift;
  895             $status = CDFlibs($operation, $item, $String);
  896 
  897         } elsif ($item == &ATTR_SCOPE_ || $item == &CDF_ENCODING_ || 
  898                  $item == &CDF_FORMAT_ || $item == &CDF_MAJORITY_ || 
  899                  $item == &rVAR_ALLOCATERECS_ || 
  900              $item == &rVAR_BLOCKINGFACTOR_ ||
  901                  $item == &rVAR_INITIALRECS_ || 
  902              $item == &rVAR_RECVARY_ || 
  903              $item == &rVAR_SPARSERECORDS_ ||
  904                  $item == &zVAR_ALLOCATERECS_ || 
  905              $item == &zVAR_BLOCKINGFACTOR_ || 
  906                  $item == &zVAR_INITIALRECS_ || 
  907              $item == &zVAR_RECVARY_ ||
  908              $item == &zVAR_SPARSERECORDS_ || 
  909              $item == &CDF_LEAPSECONDLASTUPDATED_ ||
  910              $item == &CDF_CHECKSUM_) {
  911             my $Long = shift;
  912             $status = CDFlibl($operation, $item, $Long);
  913 
  914         } elsif ($item == &gENTRY_DATA_ || $item == &rENTRY_DATA_  || 
  915                  $item == &zENTRY_DATA_) {
  916             my $Long1 = shift;
  917             my $Long2 = shift;
  918             my $VoidData = shift;
  919             if ((($Long1 != &CDF_CHAR && $Long1 != &CDF_UCHAR) &&
  920                 ($Long2 != 1)) || ref($VoidData) eq "ARRAY") {
  921               $status = CDFliblla($operation, $item, $Long1,
  922                           $Long2, $VoidData);
  923             } else {
  924               $status = CDFlibllv($operation, $item, $Long1, 
  925                           $Long2, $VoidData);
  926             }
  927 
  928         } elsif ($item == &rENTRY_STRINGSDATA_  ||
  929                          $item == &zENTRY_STRINGSDATA_) {
  930             my $VoidData = shift;
  931                         my $Long1;
  932                         $Long1 = scalar(@$VoidData);
  933             $status = CDFlib8B($operation, $item, $Long1,
  934                        $VoidData);
  935 
  936         } elsif ($item == &gENTRY_DATASPEC_ || 
  937              $item == &rENTRY_DATASPEC_ ||
  938                  $item == &rVAR_DATASPEC_ || 
  939              $item == &zENTRY_DATASPEC_ || 
  940                  $item == &zVAR_DATASPEC_ || 
  941              $item == &rVAR_ALLOCATEBLOCK_ ||
  942              $item == &zVAR_ALLOCATEBLOCK_) {
  943             my $Long = shift;
  944             my $Long1 = shift;
  945             $status = CDFlibll($operation, $item, $Long, $Long1);
  946 
  947         } elsif ($item == &rVAR_DATA_ || $item == &rVAR_PADVALUE_ || 
  948              $item == &rVAR_SEQDATA_ || $item == &zVAR_DATA_ ||
  949              $item == &zVAR_PADVALUE_ || $item == &zVAR_SEQDATA_) {
  950             my $VoidRef = shift;
  951             if (ref($VoidRef) eq "ARRAY") {
  952               $status = CDFliba($operation, $item, $VoidRef);
  953             } else {
  954               $status = CDFlibv($operation, $item, $VoidRef);
  955             }
  956                 } elsif ($item == &rVAR_HYPERDATA_ ||
  957                          $item == &zVAR_HYPERDATA_ ) {
  958                         my $VoidArrayRef = shift;
  959                         $status = CDFlibb($operation, $item, $VoidArrayRef);
  960 
  961         } elsif ($item == &rVAR_DIMVARYS_ || $item == &zVAR_DIMVARYS_) {
  962             my $LongArrayRef = shift;
  963             $status = CDFliba($operation, $item, $LongArrayRef);
  964 
  965         } elsif ($item == &rVARs_RECDATA_ || $item == &zVARs_RECDATA_) {
  966             my $Long = shift;
  967             my $LongArrayRef = shift;
  968             my $VoidArrayRef= shift;
  969             $status = CDFliblab($operation, $item, $Long, 
  970                         $LongArrayRef, $VoidArrayRef);
  971 
  972         } elsif ($item == &CDF_COMPRESSION_ || 
  973              $item == &rVAR_COMPRESSION_ ||
  974              $item == &zVAR_COMPRESSION_ || 
  975              $item == &rVAR_SPARSEARRAYS_ ||
  976              $item == &zVAR_SPARSEARRAYS_) {
  977             my $Long = shift;
  978             my $LongArrayRef = shift;
  979             $status = CDFlibla($operation, $item, $Long, 
  980                        $LongArrayRef);
  981 
  982         } else {
  983             unshift (@_, $item);
  984             last FCN;
  985         } #end if
  986         return $status if ($status != &CDF_OK);
  987        } #end for
  988     } #end if PUT_
  989 
  990 #############################################################################
  991 # SELECT
  992 #############################################################################
  993 
  994     if ($operation == &SELECT_) {
  995        for (;;) {
  996         my $item = shift;
  997         if ($item == &ATTR_ || $item == &CDF_CACHESIZE_ || 
  998             $item == &CDF_DECODING_ ||
  999             $item == &CDF_NEGtoPOSfp0_MODE_ || 
 1000             $item == &CDF_READONLY_MODE_ || 
 1001             $item == &CDF_STATUS_ || $item == &CDF_zMODE_ || 
 1002             $item == &COMPRESS_CACHESIZE_ || $item == &gENTRY_ || 
 1003             $item == &rENTRY_ || $item == &rVAR_ || 
 1004             $item == &rVAR_CACHESIZE_ || 
 1005             $item == &rVAR_RESERVEPERCENT_ || 
 1006             $item == &rVARs_CACHESIZE_ ||
 1007             $item == &rVARs_RECCOUNT_ || 
 1008             $item == &rVARs_RECINTERVAL_ || 
 1009             $item == &rVARs_RECNUMBER_ ||
 1010             $item == &STAGE_CACHESIZE_ || 
 1011             $item == &zENTRY_ || $item == &zVAR_ || 
 1012             $item == &zVAR_CACHESIZE_ || 
 1013             $item == &zVAR_RECCOUNT_ || $item == &zVAR_RECINTERVAL_ || 
 1014             $item == &zVAR_RECNUMBER_ || 
 1015             $item == &zVAR_RESERVEPERCENT_ ||
 1016             $item == &zVARs_CACHESIZE_ || $item == &zVARs_RECNUMBER_) {
 1017             my $Long = shift;
 1018             $status = CDFlibl($operation, $item, $Long);
 1019 
 1020         } elsif ($item == &ATTR_NAME_ || $item == &CDF_SCRATCHDIR_ || 
 1021              $item == &rENTRY_NAME_ || $item == &rVAR_NAME_ || 
 1022              $item == &zENTRY_NAME_ || $item == &zVAR_NAME_) {
 1023             my $String = shift;
 1024             $status = CDFlibs($operation, $item, $String);
 1025 
 1026         } elsif ($item == &CDF_) {
 1027 #the CDFid datatype is void *. It becomes an IV in the XSUB 
 1028             my $CDFid = shift;
 1029             $status = CDFlibd($operation, $item, $CDFid);
 1030 
 1031         } elsif ($item == &rVAR_SEQPOS_ || $item == &zVAR_SEQPOS_) {
 1032             my $Long = shift;
 1033             my $LongArrayRef = shift;
 1034             $status = CDFlibla($operation, $item, $Long, 
 1035                        $LongArrayRef);
 1036 
 1037         } elsif ($item == &rVARs_DIMCOUNTS_ || 
 1038              $item == &rVARs_DIMINDICES_ || 
 1039                  $item == &rVARs_DIMINTERVALS_ || 
 1040              $item == &zVAR_DIMCOUNTS_ || 
 1041                  $item == &zVAR_DIMINDICES_ || 
 1042              $item == &zVAR_DIMINTERVALS_) {
 1043             my $LongArrayRef = shift;
 1044             $status = CDFliba($operation, $item, $LongArrayRef);
 1045 
 1046         } else {
 1047             unshift (@_, $item);
 1048             last FCN;
 1049         } #end if
 1050         return $status if ($status != &CDF_OK);
 1051        } #end for
 1052     } #end if SELECT_
 1053     
 1054 #unknown operation 
 1055     return &BAD_FNC_OR_ITEM;
 1056 }#end FCN
 1057 
 1058 #continue with next command
 1059 $status = CDF::CDFlib (@_);
 1060 
 1061 } #end sub CDFlib
 1062 
 1063 sub CDFcreate {
 1064         use strict;
 1065         my $path = shift;
 1066     my $numDims = shift;
 1067     my $dimSizesRef = shift;
 1068     my $encoding = shift;
 1069     my $majority = shift;
 1070     my $id = shift;
 1071         my $status;
 1072         $status = CDFcreateX( $path, $numDims, $dimSizesRef, $encoding,
 1073                   $majority, $$id);
 1074     return $status;
 1075 } #end sub CDFcreate
 1076 
 1077 sub CDFopen {
 1078         use strict;
 1079         my $path = shift;
 1080         my $id = shift;
 1081     my $status;
 1082         $status = CDFopenX( $path, $$id);
 1083         return $status;
 1084 }#end sub CDFopen
 1085  
 1086 sub CDFdoc {
 1087         use strict;
 1088         my $id = shift;
 1089     my $version = shift;
 1090     my $release = shift;
 1091     my $text = shift;
 1092     my $status;
 1093         $status = CDFdocX( $id, $$version, $$release, $$text);
 1094         return $status;
 1095 }#end sub CDFdoc
 1096 
 1097 sub CDFinquire {
 1098         use strict;
 1099         my $id = shift;
 1100     my $numDims = shift;
 1101         my $dimSizesRef = shift;
 1102         my $encoding = shift;
 1103         my $majority = shift;
 1104         my $maxRec = shift;
 1105         my $numVars = shift;
 1106         my $numAttrs = shift;
 1107         my $status;
 1108         $status = CDFinquireX( $id, $$numDims, $dimSizesRef, $$encoding, 
 1109                    $$majority, $$maxRec, $$numVars, $$numAttrs);
 1110         return $status;
 1111 }#end sub CDFinquire
 1112 
 1113 sub CDFclose {
 1114         use strict;
 1115         my $id = shift;
 1116     my $status;
 1117         $status = CDFcloseX( $id);
 1118         return $status;
 1119 }#end sub CDFclose
 1120 
 1121 sub CDFdelete {
 1122         use strict;
 1123         my $id = shift;
 1124     my $status;
 1125         $status = CDFdeleteX( $id);
 1126         return $status;
 1127 }#end sub CDFdelete
 1128 
 1129 sub CDFerror {
 1130         use strict;
 1131         my $stat = shift;
 1132     my $text = shift;
 1133     my $status;
 1134         $status = CDFerrorX( $stat, $$text);
 1135         return $status;
 1136 }#end sub CDFerror
 1137 
 1138 sub CDFattrCreate {
 1139         use strict;
 1140         my $id = shift;
 1141         my $attrName = shift;
 1142         my $attrScope = shift;
 1143         my $attrNum = shift;
 1144         my $status;
 1145         $status = CDFattrCreateX( $id, $attrName, $attrScope, $$attrNum);
 1146         return $status;
 1147 }#end sub CDFattrCreate
 1148 
 1149 sub CDFattrNum {
 1150         use strict;
 1151         my $id = shift;
 1152         my $attrName = shift;
 1153         my $status;
 1154         $status = CDFattrNumX( $id, $attrName);
 1155     return $status;
 1156 }#end sub CDFattrNum
 1157 
 1158 sub CDFattrRename {
 1159         use strict;
 1160         my $id = shift;
 1161         my $attrNum = shift;
 1162         my $attrName = shift;
 1163         my $status;
 1164         $status = CDFattrRenameX( $id, $attrNum, $attrName);
 1165         return $status;
 1166 }#end sub CDFattrRename
 1167 
 1168 sub CDFattrInquire {
 1169         use strict;
 1170         my $id = shift;
 1171         my $attrNum = shift;
 1172         my $attrName = shift;
 1173         my $attrScope = shift;
 1174         my $maxEntry = shift;
 1175         my $status;
 1176         $status = CDFattrInquireX( $id, $attrNum, $$attrName, $$attrScope, 
 1177                    $$maxEntry );
 1178         return $status;
 1179 }#end sub CDFattrInquire
 1180 
 1181 sub CDFattrEntryInquire {
 1182         use strict;
 1183         my $id = shift;
 1184         my $attrNum = shift;
 1185         my $entryNum = shift;
 1186     my $dataType = shift;
 1187     my $numElems = shift;
 1188         my $status;
 1189         $status = CDFattrEntryInquireX( $id, $attrNum, $entryNum, $$dataType,
 1190                         $$numElems);
 1191         return $status;
 1192 }#end sub CDFattrEntryInquire
 1193 
 1194 sub CDFattrGet {
 1195         use strict;
 1196         my $id = shift;
 1197         my $attrNum = shift;
 1198         my $entryNum = shift;
 1199         my $value = shift;
 1200         my $status;
 1201     if (ref($value) eq "SCALAR") {
 1202           $status = CDFattrGetX( $id, $attrNum, $entryNum, $value);
 1203     } else {
 1204       $status = CDFattrGetXA( $id, $attrNum, $entryNum, $value);
 1205     }
 1206         return $status;
 1207 }#end sub CDFattrGet
 1208 
 1209 sub CDFattrPut {
 1210         use strict;
 1211         my $id = shift;
 1212         my $attrNum = shift;
 1213         my $entryNum = shift;
 1214         my $dataType = shift;
 1215         my $numElems = shift;
 1216     my $value = shift;
 1217         my $status;
 1218     if (ref($value) eq "SCALAR") {
 1219           $status = CDFattrPutX( $id, $attrNum, $entryNum, $dataType, $numElems,
 1220                      $value);
 1221     } else {
 1222       $status = CDFattrPutXA( $id, $attrNum, $entryNum, $dataType, $numElems,
 1223                   $value);
 1224     }
 1225         return $status;
 1226 }#end sub CDFattrPut
 1227 
 1228 sub CDFvarCreate {
 1229         use strict;
 1230         my $id = shift;
 1231         my $varName = shift;
 1232         my $dataType = shift;
 1233         my $numElements = shift;
 1234         my $recVary = shift;
 1235         my $dimVarysRef = shift;
 1236         my $varNum = shift;
 1237         my $status;
 1238         $status = CDFvarCreateX( $id, $varName, $dataType, $numElements, 
 1239                  $recVary, $dimVarysRef, $$varNum);
 1240         return $status;
 1241 }#end sub CDFvarCreate
 1242 
 1243 sub CDFvarNum {
 1244         use strict;
 1245         my $id = shift;
 1246         my $varName = shift;
 1247         my $varNum;
 1248         $varNum = CDFvarNumX( $id, $varName);
 1249         return $varNum;
 1250 }#end sub CDFvarNum
 1251 
 1252 sub CDFvarRename {
 1253         use strict;
 1254         my $id = shift;
 1255         my $varNum = shift;
 1256         my $varName = shift;
 1257         my $status;
 1258         $status = CDFvarRenameX( $id, $varNum, $varName);
 1259         return $status;
 1260 }#end sub CDFvarRename
 1261 
 1262 sub CDFvarInquire {
 1263         use strict;
 1264         my $id = shift;
 1265         my $varNum = shift;
 1266         my $varName = shift;
 1267         my $dataType = shift;
 1268         my $numElements = shift;
 1269         my $recVary = shift;
 1270         my $dimVarysRef = shift;
 1271         my $status;
 1272         $status = CDFvarInquireX( $id, $varNum, $$varName, $$dataType, 
 1273                   $$numElements, $$recVary, $dimVarysRef);
 1274         return $status;
 1275 }#end sub CDFvarInquire
 1276 
 1277 sub CDFvarPut {
 1278         use strict;
 1279         my $id = shift;
 1280         my $varNum = shift;
 1281         my $recNum = shift;
 1282         my $indicesRef = shift;
 1283         my $value = shift;
 1284         my $status;
 1285         if (ref($value) eq "SCALAR") {
 1286           $status = CDFvarPutX( $id, $varNum, $recNum, $indicesRef, $value);
 1287     } else {
 1288       $status = CDFvarPutXA( $id, $varNum, $recNum, $indicesRef, $value);
 1289     }
 1290         return $status;
 1291 }#end sub CDFvarPut
 1292 
 1293 sub CDFvarGet {
 1294         use strict;
 1295         my $id = shift;
 1296         my $varNum = shift;
 1297         my $recNum = shift;
 1298         my $indicesRef = shift;
 1299         my $value = shift;
 1300         my $status;
 1301         if (ref($value) eq "SCALAR") {
 1302           $status = CDFvarGetX( $id, $varNum, $recNum, $indicesRef, $value);
 1303     } else {
 1304       $status = CDFvarGetXA( $id, $varNum, $recNum, $indicesRef, $value);
 1305     }
 1306         return $status;
 1307 }#end sub CDFvarGet
 1308 
 1309 sub CDFvHpPut {
 1310         use strict;
 1311         my $id = shift;
 1312         my $varNum = shift;
 1313         my $recStart = shift;
 1314         my $recCount = shift;
 1315         my $recInterval = shift;
 1316         my $dimStartRef = shift;
 1317         my $dimCountRef = shift;
 1318         my $dimIntervalRef = shift;
 1319     my $buffer = shift;
 1320         my $status;
 1321         $status = CDFvHpPutX( $id, $varNum, $recStart, $recCount, 
 1322                    $recInterval, $dimStartRef, $dimCountRef, 
 1323                    $dimIntervalRef, $buffer);
 1324         return $status;
 1325 }#end sub CDFvHpPut
 1326 
 1327 sub CDFvHpGet {
 1328         use strict;
 1329         my $id = shift;
 1330         my $varNum = shift;
 1331         my $recStart = shift;
 1332         my $recCount = shift;
 1333         my $recInterval = shift;
 1334         my $dimStartRef = shift;
 1335         my $dimCountRef = shift;
 1336         my $dimIntervalRef = shift;
 1337         my $buffer = shift;
 1338         my $status;
 1339         $status = CDFvHpGetX( $id, $varNum, $recStart, $recCount,
 1340                                    $recInterval, $dimStartRef, $dimCountRef,
 1341                                    $dimIntervalRef, $buffer);
 1342         return $status;
 1343 }#end sub CDFvHpGet
 1344 
 1345 sub CDFvarClose {
 1346     use strict;
 1347     my $id = shift;
 1348     my $varNum = shift;
 1349     my $status;
 1350     $status = CDFvarCloseX( $id, $varNum);
 1351     return $status;
 1352 }#end sub CDFvarClose
 1353 
 1354 sub CDFsetFileBackward {
 1355         use strict;
 1356         my $flag = shift;
 1357         CDFsetFileBackwardX( $flag);
 1358 }#end sub CDFsetFileBackward
 1359 
 1360 sub CDFgetFileBackward {
 1361         use strict; 
 1362         my $flag;
 1363         $flag = CDFgetFileBackwardX();
 1364         return $flag;
 1365 }#end sub CDFgetFileBackward
 1366         
 1367 sub CDFsetChecksum {
 1368         use strict;
 1369         my $id = shift;
 1370         my $chksum = shift;
 1371         my $status;
 1372         $status = CDFsetChecksumX($id, $chksum);
 1373         return $status;
 1374 }#end sub CDFsetChecksum
 1375 
 1376 sub CDFgetChecksum {
 1377         use strict;
 1378         my $id = shift;
 1379         my $chksum = shift;
 1380         my $status;
 1381         $status = CDFgetChecksumX($id, $$chksum);
 1382         return $status;
 1383 }#end sub CDFgetChecksum
 1384 
 1385 sub CDFsetValidate {
 1386         use strict;
 1387         my $validateX = shift;
 1388         CDFsetValidateX($validateX);
 1389 }#end sub CDFsetValidate
 1390 
 1391 sub CDFgetValidate {
 1392         use strict;
 1393         my $validateX;
 1394         $validateX = CDFgetValidateX();
 1395         return $validateX;
 1396 }#end sub CDFgetValidate
 1397 
 1398 sub computeEPOCH {
 1399         my $year = shift;
 1400         my $month = shift;
 1401         my $day = shift;
 1402         my $hour = shift;
 1403         my $minute = shift;
 1404         my $second = shift;
 1405         my $milsec = shift;
 1406     if (ref($year) ne "ARRAY") {
 1407           return computeEPOCHX ($year, $month, $day, $hour, $minute, $second,
 1408                         $milsec); 
 1409     } else {
 1410       my @values;
 1411       my @years = @$year;
 1412       my @months = @$month;
 1413       my @days = @$day;
 1414       my @hours = @$hour;
 1415       my @minutes = @$minute;
 1416       my @seconds = @$second;
 1417       my @milsecs = @$milsec;
 1418       $#values = $#years;
 1419       for (my $i = 0; $i <= $#years; $i++) {
 1420             $values[$i] = computeEPOCHX ($years[$i], $months[$i], $days[$i],
 1421                      $hours[$i], $minutes[$i], $seconds[$i],
 1422                      $milsecs[$i]);
 1423       }
 1424           return @values;
 1425     }
 1426 }#end sub computeEPOCH
 1427 
 1428 sub toParseEPOCH {
 1429         use strict;
 1430         my $epochString = shift;
 1431         my $len;
 1432         if (ref($epochString) ne "ARRAY") {
 1433           return parseEPOCHX ($epochString);
 1434         } else {
 1435           my @values;
 1436           my @strs = @$epochString;
 1437           $#values = $#strs;
 1438           for (my $i = 0; $i <= $#strs; $i++) {
 1439             $values[$i] =  parseEPOCHX ($strs[$i]);
 1440           }
 1441           return @values;
 1442         }
 1443 }#end sub toParseEPOCH
 1444 
 1445 sub toParseEPOCH16 {
 1446         use strict;
 1447         my $epochString = shift;
 1448         my $epoch = shift;
 1449         return parseEPOCH16X($epochString, $epoch);
 1450 }#end sub toParseEPOCH16
 1451 
 1452 sub parseEPOCH {
 1453         use strict;
 1454         my $epochString = shift;
 1455     if (ref($epochString) ne "ARRAY") {
 1456           return parseEPOCHX ($epochString);
 1457     } else {
 1458       my @values;
 1459       my @strs = @$epochString;
 1460       $#values = $#strs;
 1461       for (my $i = 0; $i <= $#strs; $i++) {
 1462             $values[$i] = parseEPOCHX ($strs[$i]);
 1463       }
 1464           return @values;
 1465     }
 1466 }#end sub parseEPOCH
 1467 
 1468 sub toEncodeEPOCH {
 1469         my $epoch = $_[0];
 1470         my $style = $_[1];
 1471     my $stra = $_[2];
 1472         if ($style < 0 || $style > 4) {
 1473           $style = 4;
 1474         }
 1475     if (ref($epoch) ne "ARRAY") {
 1476           if ($style == 0) {
 1477             encodeEPOCH ($epoch, $_[2]);
 1478           } elsif ($style == 1) {
 1479             encodeEPOCH1 ($epoch, $_[2]);
 1480           } elsif ($style == 2) {
 1481             encodeEPOCH2 ($epoch, $_[2]);
 1482           } elsif ($style == 3) {
 1483             encodeEPOCH3 ($epoch, $_[2]);
 1484           } else {
 1485             encodeEPOCH4 ($epoch, $_[2]);
 1486           }
 1487     } else {
 1488       my @t1 = @$epoch;
 1489       my ($i, $astr);
 1490       for ($i=0; $i <= $#t1; $i++) {
 1491             if ($style == 0) {
 1492               encodeEPOCH ($t1[$i], $astr);
 1493             } elsif ($style == 1) {
 1494               encodeEPOCH1 ($t1[$i], $astr);
 1495             } elsif ($style == 2) {
 1496               encodeEPOCH2 ($t1[$i], $astr);
 1497             } elsif ($style == 3) {
 1498               encodeEPOCH3 ($t1[$i], $astr);
 1499             } else {
 1500               encodeEPOCH4 ($t1[$i], $astr);
 1501             }
 1502         $$stra[$i] = $astr;
 1503       }
 1504     }
 1505 }#end sub toEncodeEPOCH
 1506 
 1507 sub toEncodeEPOCH16 {
 1508         my $epoch = $_[0];
 1509         my $style = $_[1];
 1510     my $stra = $_[2];
 1511         if ($style < 0 || $style > 4) {
 1512          $style = 4;
 1513         }
 1514         if ($style == 0) {
 1515             encodeEPOCH16 ($epoch, $_[2]);
 1516         } elsif ($style == 1) {
 1517             encodeEPOCH16_1 ($epoch, $_[2]);
 1518         } elsif ($style == 2) {
 1519             encodeEPOCH16_2 ($epoch, $_[2]);
 1520         } elsif ($style == 3) {
 1521             encodeEPOCH16_3 ($epoch, $_[2]);
 1522         } else {
 1523             encodeEPOCH16_4 ($epoch, $_[2]);
 1524         }
 1525 }#end sub toEncodeEPOCH16
 1526 
 1527 sub EPOCHtoUnixTime {
 1528         my $epoch = $_[0];
 1529     my $unixTime = $_[1];
 1530     if (ref($epoch) ne "ARRAY") {
 1531           my (@epochs, @times);
 1532           $epochs[0] = $epoch;
 1533           EPOCHtoUnixTimeX (\@epochs, \@times);
 1534           $_[1] = $times[0];
 1535     } else {
 1536           EPOCHtoUnixTimeX ($epoch, $unixTime);
 1537     }
 1538 }#end sub EPOCHtoUnixTime
 1539 
 1540 sub EPOCH16toUnixTime {
 1541         my $epoch = $_[0];
 1542     my $unixTime = $_[1];
 1543     if (ref($epoch) ne "ARRAY") {
 1544           my @epochs;
 1545           $epochs[0] = $epoch;
 1546           $epochs[1] = 0;
 1547           EPOCH16toUnixTimeX (\@epochs, $unixTime);
 1548           $_[1] = $times[0];
 1549     } else {
 1550           EPOCH16toUnixTimeX ($epoch, $unixTime);
 1551     }
 1552 }#end sub EPOCH16toUnixTime
 1553 
 1554 sub TT2000toUnixTime {
 1555         my $epoch = $_[0];
 1556     my $unixTime = $_[1];
 1557     if (ref($epoch) ne "ARRAY") {
 1558           my (@epochs, @times);
 1559           $epochs[0] = $epoch;
 1560           TT2000toUnixTimeX (\@epochs, \@times);
 1561           $_[1] = $times[0];
 1562     } else {
 1563           TT2000toUnixTimeX ($epoch, $unixTime);
 1564     }
 1565 }#end sub TT2000toUnixTime
 1566 
 1567 sub UnixTimetoEPOCH {
 1568         my $epoch = $_[1];
 1569     my $unixTime = $_[0];
 1570     if (ref($unixTime) ne "ARRAY") {
 1571           my (@epochs, @times);
 1572           $times[0] = $unixTime;
 1573           UnixTimetoEPOCHX (\@times, \@epochs);
 1574           $_[1] = $epochs[0];
 1575     } else {
 1576           UnixTimetoEPOCHX ($unixTime, $epoch);
 1577     }
 1578 }#end sub UnixTimetoEPOCH
 1579 
 1580 sub UnixTimetoEPOCH16 {
 1581         my $epoch = $_[1];
 1582     my $unixTime = $_[0];
 1583     if (ref($unixTime) ne "ARRAY") {
 1584           my @times;
 1585           $times[0] = $unixTime;
 1586           UnixTimetoEPOCH16X (\@times, $epoch);
 1587           $_[1] = \@epochs;
 1588     } else {
 1589           UnixTimetoEPOCH16X ($unixTime, $epoch);
 1590     }
 1591 }#end sub UnixTimetoEPOCH16
 1592 
 1593 sub UnixTimetoTT2000 {
 1594         my $epoch = $_[1];
 1595     my $unixTime = $_[0];
 1596     if (ref($unixTime) ne "ARRAY") {
 1597           my (@epochs, @times);
 1598           $times[0] = $unixTime;
 1599           UnixTimetoTT2000X (\@times, \@epochs);
 1600           $_[1] = $epochs[0];
 1601     } else {
 1602           UnixTimetoTT2000X ($unixTime, $epoch);
 1603     }
 1604 }#end sub UnixTimetoTT2000
 1605 
 1606 sub encodeEPOCH {
 1607         my $epoch = $_[0];
 1608     my $stra = $_[1];
 1609     if (ref($epoch) ne "ARRAY") {
 1610           encodeEPOCHX ($epoch, $_[1]);
 1611     } else {
 1612       my @t1 = @$epoch;
 1613       my ($i, $astr);
 1614       for ($i=0; $i <= $#t1; $i++) {
 1615             encodeEPOCHX ($t1[$i], $astr);
 1616         $$stra[$i] = $astr;
 1617       }
 1618     }
 1619 }#end sub encodeEPOCH
 1620 
 1621 sub computeTT2000 {
 1622         use strict;
 1623         use Math::BigInt;
 1624         my $year = shift;
 1625         my $month = shift;
 1626         my $day = shift;
 1627         my $hour = shift;
 1628         my $minute = shift;
 1629         my $second = shift;
 1630         my $milsec = shift;
 1631         my $micsec = shift;
 1632         my $nansec = shift;
 1633     if (ref($year) ne "ARRAY") {
 1634           my $tt2000Str;
 1635           computeTT2000X ($year, $month, $day, $hour, $minute, $second, $milsec,
 1636                           $micsec, $nansec, $tt2000Str); 
 1637           return Math::BigInt->new($tt2000Str);
 1638     } else {
 1639       my @values;
 1640       my @years = @$year;
 1641       my @months = @$month;
 1642       my @days = @$day;
 1643       my @hours = @$hour;
 1644       my @minutes = @$minute;
 1645       my @seconds = @$second;
 1646       my @milsecs = @$milsec;
 1647       my @micsecs = @$micsec;
 1648       my @nansecs = @$nansec;
 1649       $#values = $#years;
 1650       my $value;
 1651       for (my $i = 0; $i <= $#years; $i++) {
 1652             computeTT2000X ($years[$i], $months[$i], $days[$i], $hours[$i],
 1653                 $minutes[$i], $seconds[$i], $milsecs[$i],
 1654                             $micsecs[$i], $nansecs[$i], $value); 
 1655             $values[$i] = Math::BigInt->new($value);
 1656       }
 1657           return @values;
 1658     }
 1659 }#end sub computeTT2000
 1660 
 1661 sub toParseTT2000 {
 1662         my $tt2000String = shift;
 1663         return parseTT2000 ($tt2000String);
 1664 }#end sub toParseTT2000
 1665 
 1666 sub parseTT2000 {
 1667         use strict;
 1668         use Math::BigInt;
 1669         my $tt2000String = shift;
 1670     if (ref($tt2000String) ne "ARRAY") {
 1671           my $tt2000Str;
 1672           parseTT2000X ($tt2000String, $tt2000Str);
 1673           my $tt2000 = Math::BigInt->new($tt2000Str);
 1674           return $tt2000;
 1675     } else {
 1676       my @values;
 1677       my @strs = @$tt2000String;
 1678       $#values = $#strs;
 1679       my $value;
 1680       for (my $i = 0; $i <= $#strs; $i++) {
 1681             parseTT2000X ($strs[$i], $value);
 1682             $values[$i] = Math::BigInt->new($value);
 1683       }
 1684           return @values;
 1685     }
 1686 }#end sub parseTT2000
 1687 
 1688 sub toEncodeTT2000 {
 1689         use strict;
 1690         my $tt2000 = $_[0];
 1691     my $stra = $_[2];
 1692         my $format = $_[1];
 1693         if ($format < 0 || $format > 4) {
 1694           $format = 3;
 1695         }
 1696     if (ref($tt2000) ne "ARRAY") {
 1697           encodeTT2000X ($tt2000, $_[2], $format);
 1698     } else {
 1699       my @t1 = @$tt2000;
 1700       # my @t2 = @$stra;
 1701       # $#t2 = $#t1;
 1702       my ($i, $astr);
 1703       for ($i=0; $i <= $#t1; $i++) {
 1704             encodeTT2000X ($t1[$i], $astr, $format);
 1705         $$stra[$i] = $astr;
 1706       }
 1707     }
 1708 }#end sub toEncodeTT2000
 1709 
 1710 sub encodeTT2000 {
 1711         use strict;
 1712         my $tt2000 = $_[0];
 1713     my $stra = $_[1];
 1714         my $format;
 1715         if (scalar(@_) == 3) {
 1716           $format = $_[2];
 1717         } else {
 1718           $format = 3;
 1719         }
 1720     if (ref($tt2000) ne "ARRAY") {
 1721           encodeTT2000X ($tt2000, $_[1], $format);
 1722     } else {
 1723       my @t1 = @$tt2000;
 1724       # my @t2 = @$stra;
 1725       # $#t2 = $#t1;
 1726       my ($i, $astr);
 1727       for ($i=0; $i <= $#t1; $i++) {
 1728             encodeTT2000X ($t1[$i], $astr, $format);
 1729         $$stra[$i] = $astr;
 1730       }
 1731     }
 1732 }#end sub encodeTT2000
 1733 
 1734 sub leapsecondsinfo {
 1735         use strict;
 1736         my $debug;
 1737         if (scalar(@_) == 1) {
 1738           my $value;
 1739           $value = shift;
 1740           $debug = int($value);
 1741         } else {
 1742           $debug = 0;
 1743         }
 1744         leapsecondsinfoX ($debug);
 1745 }#end sub leapseonds_infoX
 1746 
 1747 sub CDFgetGlobalMetaData {
 1748         use strict;
 1749         my @args = @_;
 1750         my $cdf = $args[0];
 1751         my @globals = ();
 1752         my $enteredGlobals = -1;
 1753         my $metaEncoding = 1;
 1754         if (scalar(@_) > 1) {
 1755           my $haveGlobals = $args[1];
 1756           if (ref($haveGlobals) eq "ARRAY") {
 1757             if ($#$haveGlobals == -1) {
 1758               $enteredGlobals = -1;
 1759             } else {
 1760               @globals = @$haveGlobals;
 1761               $enteredGlobals = $#globals + 1;
 1762             }
 1763           } else {
 1764             if (!(defined $haveGlobals)) {
 1765               $enteredGlobals = -1;
 1766             } else {
 1767               if ($haveGlobals ne "ALL") {
 1768                 @globals = split(',', $haveGlobals);
 1769                 $enteredGlobals = $#globals + 1;
 1770               } else {
 1771                 $enteredGlobals = -1;
 1772               }
 1773             }
 1774           }
 1775         }
 1776         if (scalar(@_) > 2) {
 1777           $metaEncoding = $args[2];
 1778           if ($metaEncoding != 0) {
 1779             $metaEncoding = 1;
 1780           }
 1781         }
 1782         my $id = ();
 1783         my ($toClose, $status, $cdfName, $numAttrs, $i, $scope, $attrName);
 1784         my %metax = ();
 1785         $toClose = 0;
 1786         if ($cdf =~ /^\d+$/) {
 1787           $status = CDFlib(&SELECT_, &CDF_, $cdf,
 1788                            &NULL_);
 1789           if ($status != &CDF_OK) {
 1790             $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 1791                              &NULL_);
 1792             $toClose = 1;
 1793           } else {
 1794             $id = $cdf;
 1795           }
 1796         } else {
 1797           $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 1798                            &NULL_);
 1799           $toClose = 1;
 1800         }
 1801         if ($status != &CDF_OK) {
 1802           return ($status, ());
 1803         }
 1804         $status = CDFlib (&GET_, &CDF_NUMATTRS_, \$numAttrs,
 1805                           &NULL_);
 1806         if ($status != &CDF_OK) {
 1807           return ($status, %metax);
 1808         }
 1809         my $found;
 1810         for ($i = 0; $i < $numAttrs; $i++) {
 1811           $status = CDFlib(&SELECT_, &ATTR_, $i,
 1812                            &GET_, &ATTR_SCOPE_, \$scope,
 1813                                   &ATTR_NAME_, \$attrName,
 1814                            &NULL_);
 1815           if ($scope != &GLOBAL_SCOPE) {
 1816             next;
 1817           } else {
 1818             $found = 1;
 1819             if ($enteredGlobals != -1) {
 1820               $found = 0;
 1821               my $l;
 1822               for ($l = 0; $l < $enteredGlobals; $l++) {
 1823                 if ($globals[$l] =~ /^\d+$/) {
 1824                   if ($i == $globals[$l]) {
 1825                     $found = 1;
 1826                     last;
 1827                   }
 1828                 } else {
 1829                   if ($attrName eq $globals[$l]) {
 1830                     $found = 1;
 1831                     last;
 1832                   }
 1833                 }
 1834               }
 1835             }
 1836           }
 1837           if ($found == 0) {
 1838             next;
 1839           } else {
 1840             my $maxEntry;
 1841             $status = CDFlib(&GET_, &ATTR_MAXgENTRY_, \$maxEntry,
 1842                              &NULL_);
 1843             if ($status != &CDF_OK || $maxEntry < 0) {
 1844               next;
 1845             } else {
 1846               my ($j, $dataType, $numElems, $entry);
 1847               my %meta2 = ();
 1848               for ($j = 0; $j <= $maxEntry; $j++) {
 1849                 my @entry2 = ();
 1850                 $status = CDFlib(&SELECT_, &gENTRY_, $j,
 1851                                  &GET_, &gENTRY_DATATYPE_, \$dataType,
 1852                                         &gENTRY_NUMELEMS_, \$numElems,
 1853                                  &NULL_);
 1854                 if ($status != &CDF_OK) {
 1855                   next;
 1856                 } 
 1857                 if ($dataType == &CDF_EPOCH16 || ($numElems > 1 &&
 1858                                                   ($dataType != &CDF_CHAR &&
 1859                                                    $dataType != &CDF_UCHAR))) {
 1860                   $status = CDFlib(&GET_, &gENTRY_DATA_, \@entry2,
 1861                                    &NULL_);
 1862                 } else {
 1863                   $status = CDFlib(&GET_, &gENTRY_DATA_, \$entry,
 1864                                    &NULL_);
 1865                 }
 1866                 if ($metaEncoding == 1) {
 1867                   if ($dataType == &CDF_EPOCH) {
 1868                     if ($numElems == 1) {
 1869                       my $epoch;
 1870                       toEncodeEPOCH ($entry, 4, $epoch);
 1871                       $meta2{$j} = $epoch;
 1872                     } else {
 1873                       my @epoch;
 1874                       toEncodeEPOCH (@entry2, 4, \@epoch);
 1875                       $meta2{$j} = \@epoch;
 1876                     }
 1877                   } elsif ($dataType == &CDF_EPOCH16) {
 1878                     if ($numElems == 1) {
 1879                       my $epoch2;
 1880                       toEncodeEPOCH16 (\@entry2, 4, $epoch2);
 1881                       $meta2{$j} = $epoch2;
 1882                     } else {
 1883                       my @epoch2;
 1884                       toEncodeEPOCH16 (\@entry2, 4, \@epoch2);
 1885                       $meta2{$j} = \@epoch2;
 1886                     }
 1887                   } elsif ($dataType == &CDF_TIME_TT2000) {
 1888                     if ($numElems == 1) {
 1889                       my $epoch;
 1890                       toEncodeTT2000 ($entry, 3, $epoch);
 1891                       $meta2{$j} = $epoch;
 1892                     } else {
 1893                       my @epoch2;
 1894                       toEncodeTT2000 (\@entry2, 3, \@epoch2);
 1895                       $meta2{$j} = \@epoch2;
 1896                     }
 1897                   } else {
 1898                     if ($dataType == &CDF_CHAR || $dataType == &CDF_UCHAR ||
 1899                         $numElems == 1) {
 1900                       $meta2{$j} = $entry;
 1901                     } else {
 1902                       $meta2{$j} = \@entry2;
 1903                     }
 1904                   }
 1905                 } else {
 1906                   if ($dataType == &CDF_EPOCH16 || ($dataType != &CDF_CHAR &&
 1907                                                     $dataType != &CDF_UCHAR &&
 1908                                                     $numElems > 1)) {
 1909                     $meta2{$j} = \@entry2;
 1910                   } else {
 1911                     $meta2{$j} = $entry;
 1912                   }
 1913                 }
 1914               }
 1915               $metax{$attrName} = {%meta2};
 1916             }
 1917           }
 1918         }
 1919         if ($toClose == 1) {
 1920           $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 1921         }
 1922         $status = &CDF_OK;
 1923         return ($status, %metax);
 1924 }#end sub CDFgetGlobalMetaData
 1925 
 1926 sub CDFgetVarMetaData {
 1927         use strict;
 1928         my @args = @_;
 1929         my $cdf = $args[0];
 1930         my $var = $args[1];
 1931         my $metaEncoding;
 1932         if (scalar(@_) > 2) {
 1933           $metaEncoding = $args[2];
 1934         } else {
 1935           $metaEncoding = 1;
 1936         }
 1937         my $id = ();
 1938         my ($toClose, $varName, $varNum, $numElems, $status, $numAttrs,$zMode);
 1939         $toClose = 0;
 1940         my %metax = ();
 1941         if ($cdf =~ /^\d+$/) {
 1942           $status = CDFlib(&SELECT_, &CDF_, $cdf,
 1943                            &NULL_);
 1944           if ($status != &CDF_OK) {
 1945             $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 1946                              &NULL_);
 1947             $toClose = 1;
 1948           }
 1949         } else {
 1950           $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 1951                            &NULL_);
 1952           $toClose = 1;
 1953         }
 1954         if ($status != &CDF_OK) {
 1955           return ($status, ());
 1956         }
 1957         $status = CDFlib(&CONFIRM_, &CDF_zMODE_, \$zMode,
 1958                          &GET_, &CDF_NUMATTRS_, \$numAttrs,
 1959                          &SELECT_, &CDF_zMODE_, &zMODEon2,
 1960                          &NULL_);
 1961         if ($status != &CDF_OK) {
 1962           return ($status, ());
 1963         }
 1964         my $check = 0;
 1965         if ($var =~ /^\d+$/) {
 1966           $varNum = $var;
 1967           $status = CDFlib(&SELECT_, &zVAR_, $varNum,
 1968                            &GET_, &zVAR_NAME_, \$varName,
 1969                            &NULL_);
 1970           if ($status == &CDF_OK) {
 1971             $check++;
 1972           }
 1973         } 
 1974         if ($check == 0) {
 1975           $varName = $var;
 1976           $status = CDFlib(&GET_, &zVAR_NUMBER_, $varName, \$varNum,
 1977                            &NULL_);
 1978           if ($status != &CDF_OK) {
 1979             if ($toClose == 1) {
 1980               $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 1981             }
 1982             return (&BAD_VAR_NAME, ());
 1983           }
 1984         }
 1985         $status = CDFlib (&SELECT_, &zVAR_, $varNum,
 1986                                     &zENTRY_, $varNum,
 1987                           &NULL_);
 1988         if ($status != &CDF_OK) {
 1989           if ($toClose == 1) {
 1990             $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 1991           }
 1992           return ($status, ());
 1993         }
 1994         my ($i, $scope, $attrName, $entry, $dataType);
 1995         for ($i = 0; $i < $numAttrs; $i++) {
 1996           my @entry2 = ();
 1997           $status = CDFlib(&SELECT_, &ATTR_, $i,
 1998                            &GET_, &ATTR_SCOPE_, \$scope,
 1999                                   &ATTR_NAME_, \$attrName,
 2000                            &NULL_);
 2001           if ($scope == &GLOBAL_SCOPE) {
 2002             next;
 2003           } else {
 2004             $status = CDFlib(&SELECT_, &zENTRY_, $varNum,
 2005                              &GET_, &zENTRY_DATATYPE_, \$dataType,
 2006                                     &zENTRY_NUMELEMS_, \$numElems,
 2007                              &NULL_);
 2008             if ($status != &CDF_OK) {
 2009               next;
 2010             }
 2011             if ($dataType == &CDF_EPOCH16 || ($dataType != &CDF_CHAR &&
 2012                                               $dataType != &CDF_UCHAR &&
 2013                                               $numElems > 1)) {
 2014               $status = CDFlib(&GET_, &zENTRY_DATA_, \@entry2,
 2015                                &NULL_);
 2016             } else {
 2017               $status = CDFlib(&GET_, &zENTRY_DATA_, \$entry,
 2018                                &NULL_);
 2019             }
 2020             if ($metaEncoding == 1) {
 2021               if ($dataType == &CDF_EPOCH) {
 2022                 if ($numElems == 1) {
 2023                   my $epoch;
 2024                   toEncodeEPOCH ($entry, 4, $epoch);
 2025                   $metax{$attrName} = $epoch;
 2026                 } else {
 2027                   my @epoch;
 2028                   toEncodeEPOCH (\@entry2, 4, \@epoch);
 2029                   $metax{$attrName} = \@epoch;
 2030                 }
 2031               } elsif ($dataType == &CDF_EPOCH16) {
 2032                 if ($numElems == 1) {
 2033                   my $epoch2;
 2034                   toEncodeEPOCH16 (\@entry2, 4, $epoch2);
 2035                   $metax{$attrName} = $epoch2;
 2036                 } else {
 2037                   my @epoch2;
 2038                   my ($jj, $ep16String);
 2039                   my @ep16;
 2040                   for ($jj = 0; $jj < $numElems; ++$jj) {
 2041                     $ep16[0] = $entry2[2*$jj];
 2042                     $ep16[1] = $entry2[2*$jj+1];
 2043                     toEncodeEPOCH16 (\@ep16, 4, $ep16String);
 2044                     $epoch2[$jj] = $ep16String;
 2045                   }
 2046 #                  toEncodeEPOCH16 (\@entry2, 4, \@epoch2);
 2047                   $metax{$attrName} = \@epoch2;
 2048                 }
 2049               } elsif ($dataType == &CDF_TIME_TT2000) {
 2050                 if ($numElems == 1) {
 2051                   my $epoch;
 2052                   toEncodeTT2000 ($entry, 3, $epoch);
 2053                   $metax{$attrName} = $epoch;
 2054                 } else {
 2055                   my @epoch;
 2056                   toEncodeTT2000 (\@entry2, 3, \@epoch);
 2057                   $metax{$attrName} = \@epoch;
 2058                 }
 2059               } else {
 2060                 if ($numElems == 1 || ($dataType == &CDF_CHAR ||
 2061                                        $dataType == &CDF_UCHAR)) {
 2062                   $metax{$attrName} = $entry;
 2063                 } else {
 2064                   $metax{$attrName} = \@entry2;
 2065                 }
 2066               }
 2067             } else {
 2068               if ($dataType == &CDF_EPOCH16 || ($dataType != &CDF_CHAR &&
 2069                                                 $dataType != &CDF_UCHAR &&
 2070                                                 $numElems > 1)) {
 2071                 $metax{$attrName} = \@entry2;
 2072               } else {
 2073                 $metax{$attrName} = $entry;
 2074               }
 2075             }
 2076           }
 2077         }
 2078         if ($toClose == 1) {
 2079           $status = CDFlib (&CLOSE_, &CDF_, &NULL_);
 2080         } else {
 2081           $status = CDFlib (&SELECT_, &CDF_zMODE_, $zMode,
 2082                             &NULL_);
 2083         }
 2084         return (&CDF_OK, %metax);
 2085 }#end sub CDFgetVarMetaData
 2086 
 2087 sub CDFgetLIBInfo {
 2088         use strict;
 2089         my $id;
 2090         my ($status, $year, $month, $day);
 2091         my ($lib_ver, $lib_rel, $lib_inc);
 2092         my %libInfo;
 2093         $status = CDFlib(&GET_, &LIB_VERSION_, \$lib_ver,
 2094                                 &LIB_RELEASE_, \$lib_rel,
 2095                                 &LIB_INCREMENT_, \$lib_inc,
 2096                          &NULL_);
 2097         if ($status != &CDF_OK) {
 2098           return ($status, ());
 2099         }
 2100         $libInfo{"LIB_VERSION"} = $lib_ver.".".$lib_rel.".".$lib_inc;
 2101         leapsecondsinfoY ($year, $month, $day);
 2102         $libInfo{"LATEST_LEAPSECOND_IN_TABLE"} = $year*10000+$month*100+$day;
 2103         return (&CDF_OK, %libInfo);
 2104 }#end sub CDFgetLIBInfo
 2105 
 2106 sub CDFgetCDFInfo {
 2107         use strict;
 2108         my $cdf = shift;
 2109         my $id = ();
 2110         my ($toClose, $numrVars, $numzVars, $status, $numgAttrs, $numvAttrs);
 2111         my ($majority, $format, $encoding, $release, $version, $increment);
 2112         my ($lastleap, $cdfName);
 2113         my %cdfInfo;
 2114         $toClose = 0;
 2115         if ($cdf =~ /^\d+$/) {
 2116           $status = CDFlib(&SELECT_, &CDF_, $cdf,
 2117                            &NULL_);
 2118           if ($status != &CDF_OK) {
 2119             $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 2120                              &NULL_);
 2121             $toClose = 1;
 2122           }
 2123         } else {
 2124           $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 2125                            &NULL_);
 2126           $toClose = 1;
 2127         }
 2128         if ($status != &CDF_OK) {
 2129           return ($status, ());
 2130         }
 2131         $status = CDFlib(&GET_, &CDF_NUMrVARS_, \$numrVars,
 2132                                 &CDF_NUMzVARS_, \$numzVars,
 2133                                 &CDF_NUMgATTRS_, \$numgAttrs,
 2134                                 &CDF_NUMvATTRS_, \$numvAttrs,
 2135                                 &CDF_ENCODING_, \$encoding,
 2136                                 &CDF_FORMAT_, \$format,
 2137                                 &CDF_MAJORITY_, \$majority,
 2138                                 &CDF_RELEASE_, \$release,
 2139                                 &CDF_VERSION_, \$version,
 2140                                 &CDF_INCREMENT_, \$increment,
 2141                                 &CDF_LEAPSECONDLASTUPDATED_, \$lastleap,
 2142                           &NULL_);
 2143         if ($status != &CDF_OK) {
 2144           return ($status, ());
 2145         }
 2146         if ($toClose == 1) {
 2147           $cdfInfo{"NAME"} = $cdf;
 2148         }
 2149         $cdfInfo{"FORMAT"} = getFormat($format);
 2150         $cdfInfo{"MAJORITY"} = getMajority($majority);
 2151         $cdfInfo{"ENCODING"} = getEncoding($encoding);
 2152         $cdfInfo{"CDF_VERSION"} = $version.".".$release.".".$increment;
 2153         $cdfInfo{"BASED_LEAPSECOND_LAST_UPDATED"} = $lastleap;
 2154         $cdfInfo{"NUMrVARS"} = $numrVars;
 2155         $cdfInfo{"NUMzVARS"} = $numzVars;
 2156         $cdfInfo{"NUMgATTRS"} = $numgAttrs;
 2157         $cdfInfo{"NUMvATTRS"} = $numvAttrs;
 2158         if ($toClose == 1) {
 2159           $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2160         }
 2161         return (&CDF_OK, %cdfInfo);
 2162 }#end sub CDFgetCDFInfo
 2163 
 2164 sub CDFgetVarInfo {
 2165         use strict;
 2166         my @args = @_;
 2167         my $cdf = $args[0];
 2168         my $var = $args[1];
 2169         my $id = ();
 2170         my ($toClose, $varNum, $status, $dataType, $numElems);
 2171         my ($numDims, $recVary, $maxRec, $varName, $zMode);
 2172         my (@dimSizes, @dimVarys);
 2173         my %varInfo;
 2174         $toClose = 0;
 2175         if ($cdf =~ /^\d+$/) {
 2176           $status = CDFlib(&SELECT_, &CDF_, $cdf,
 2177                            &NULL_);
 2178           if ($status != &CDF_OK) {
 2179             $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 2180                              &NULL_);
 2181             $toClose = 1;
 2182           }
 2183         } else {
 2184           $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 2185                            &NULL_);
 2186           $toClose = 1;
 2187         }
 2188         if ($status != &CDF_OK) {
 2189           return ($status, ());
 2190         }
 2191         $status = CDFlib(&CONFIRM_, &CDF_zMODE_, \$zMode,
 2192                          &SELECT_, &CDF_zMODE_, &zMODEon2,
 2193                          &NULL_);
 2194         if ($status != &CDF_OK) {
 2195           if ($toClose == 1) {
 2196             $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2197           }
 2198           return ($status, ());
 2199         }
 2200         my $check = 0;
 2201         if ($var =~ /^\d+$/) {
 2202           $varNum = $var;
 2203           $status = CDFlib(&SELECT_, &zVAR_, $varNum,
 2204                            &GET_, &zVAR_NAME_, \$varName,
 2205                            &NULL_);
 2206           if ($status == &CDF_OK) {
 2207             $check++;
 2208           }
 2209         }
 2210         if ($check == 0) {
 2211           $varName = $var;
 2212           $status = CDFlib(&GET_, &zVAR_NUMBER_, $varName, \$varNum,
 2213                            &NULL_);
 2214           if ($status != &CDF_OK) {
 2215             if ($toClose == 1) {
 2216               $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2217             }
 2218             return (&BAD_VAR_NAME, ());
 2219           }
 2220         }
 2221         $status = CDFlib (&SELECT_, &zVAR_, $varNum,
 2222                           &GET_, &zVAR_DATATYPE_, \$dataType,
 2223                                  &zVAR_NUMELEMS_, \$numElems,
 2224                                  &zVAR_NUMDIMS_, \$numDims,
 2225                                  &zVAR_DIMSIZES_, \@dimSizes,
 2226                                  &zVAR_DIMVARYS_, \@dimVarys,
 2227                                  &zVAR_RECVARY_, \$recVary,
 2228                                  &zVAR_MAXREC_, \$maxRec,
 2229                           &NULL_);
 2230         if ($status != &CDF_OK) {
 2231           if ($toClose == 1) {
 2232             $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2233           }
 2234           return ($status, ());
 2235         }
 2236         $varInfo{"DataType"} = getStringDataType($dataType);
 2237         $varInfo{"NumElems"} = $numElems;
 2238         $varInfo{"NumDims"} = $numDims;
 2239         if ($numDims > 0) {
 2240           my $i; my %indices;
 2241           for ($i = 0; $i < $numDims; $i++) {
 2242             $varInfo{"DimSizes"}{$i} = $dimSizes[$i];
 2243           }
 2244           for ($i = 0; $i < $numDims; $i++) {
 2245             $varInfo{"DimVarys"}{$i} = $dimVarys[$i]==0?"False":"True";
 2246           }
 2247         }
 2248         $varInfo{"RecVary"} = $recVary==0?"False":"True";
 2249         $varInfo{"VarName"} = $varName;
 2250         $varInfo{"MaxRec"} = $maxRec;
 2251         if ($toClose == 1) {
 2252           $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2253         } else {
 2254           $status = CDFlib (&SELECT_, &CDF_zMODE_, $zMode,
 2255                             &NULL_);
 2256         }
 2257         return (&CDF_OK, %varInfo);
 2258 }#end sub CDFgetVarInfo
 2259 
 2260 sub CDFgetVarAllData {
 2261         use strict;
 2262         my @args = @_;
 2263         my $cdf = $args[0];
 2264         my $var = $args[1];
 2265         my $id = ();
 2266         my ($matrix, $varNum, $status, $maxRec, $numDims, $varName, $dataType);
 2267         my (@dimSizes, @dimIndices, @dimIntervals);
 2268         my ($toClose, $zMode);
 2269         my (@values, @outData);
 2270         $toClose = 0;
 2271         $matrix = 0;
 2272         my $dataEncoding = 0;
 2273         if (scalar(@_) > 2) {
 2274           $dataEncoding = $args[2];
 2275         }
 2276         if (scalar(@_) > 3) {
 2277           $matrix = $args[3];
 2278         }
 2279 
 2280         if ($cdf =~ /^\d+$/) {
 2281           $status = CDFlib(&SELECT_, &CDF_, $cdf,
 2282                            &NULL_);
 2283           if ($status != &CDF_OK) {
 2284             $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 2285                              &NULL_);
 2286             $toClose = 1;
 2287           }
 2288         } else {
 2289           $status = CDFlib(&OPEN_, &CDF_, $cdf, \$id,
 2290                            &NULL_);
 2291           $toClose = 1;
 2292         }
 2293         if ($status != &CDF_OK) {
 2294           return ($status, ());
 2295         }
 2296         $status = CDFlib(&CONFIRM_, &CDF_zMODE_, \$zMode,
 2297                          &SELECT_, &CDF_zMODE_, &zMODEon2,
 2298                          &NULL_);
 2299         if ($status != &CDF_OK) {
 2300           if ($toClose == 1) {
 2301             $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2302           }
 2303           return ($status, ());
 2304         }
 2305         my $check = 0;
 2306         if ($var =~ /^\d+$/) {
 2307           $varNum = $var;
 2308           $status = CDFlib(&SELECT_, &zVAR_, $varNum,
 2309                            &GET_, &zVAR_NAME_, \$varName,
 2310                            &NULL_);
 2311           if ($status == &CDF_OK) {
 2312             $check++;
 2313           }
 2314         }
 2315         if ($check == 0) {
 2316           $varName = $var;
 2317           $status = CDFlib(&GET_, &zVAR_NUMBER_, $varName, \$varNum,
 2318                            &NULL_);
 2319           if ($status != &CDF_OK) {
 2320             if ($toClose == 1) {
 2321               $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2322             }
 2323             return (&BAD_VAR_NAME, ());
 2324           }
 2325         }
 2326         $status = CDFlib (&SELECT_, &zVAR_, $varNum,
 2327                           &GET_, &zVAR_DIMSIZES_, \@dimSizes,
 2328                                  &zVAR_MAXREC_, \$maxRec,
 2329                                  &zVAR_NUMDIMS_, \$numDims,
 2330                                  &zVAR_DATATYPE_, \$dataType,
 2331                           &NULL_);
 2332         if ($status == &CDF_OK && $maxRec > -1) {
 2333           my $i;
 2334           if ($numDims > 0) {
 2335             for ($i = 0; $i < $numDims; ++$i) {
 2336               $dimIndices[$i] = 0;
 2337               $dimIntervals[$i] = 1;
 2338             }
 2339           } else {
 2340               $dimIndices[0] = 0;
 2341               $dimIntervals[0] = 1;
 2342           }
 2343           $status = CDFlib (&SELECT_, &zVAR_RECNUMBER_, 0,
 2344                                       &zVAR_RECCOUNT_, ($maxRec + 1),
 2345                                       &zVAR_RECINTERVAL_, 1,
 2346                                       &zVAR_DIMINDICES_, \@dimIndices,
 2347                                       &zVAR_DIMCOUNTS_, \@dimSizes,
 2348                                       &zVAR_DIMINTERVALS_, \@dimIntervals,
 2349                             &NULL_);
 2350           $status = CDFlib2(&GET_, &zVAR_HYPERDATA_,\@values);
 2351           if ($dataEncoding == 1) {
 2352             if ($dataType == &CDF_EPOCH) {
 2353               toEncodeEPOCH(\@values, 4, \@outData);
 2354             } elsif ($dataType == &CDF_TIME_TT2000) {
 2355               toEncodeTT2000(\@values, 3, \@outData);
 2356             } elsif ($dataType == &CDF_EPOCH16) {
 2357               my @ep16;
 2358               my $ep16String;
 2359               for ($i = 0; $i <= $maxRec; ++$i) {
 2360                 $ep16[0] = $values[2*$i];
 2361                 $ep16[1] = $values[2*$i+1];
 2362                 toEncodeEPOCH16(\@ep16, 3, $ep16String);
 2363                 $outData[$i] = $ep16String;
 2364               }
 2365             } else {
 2366               @outData = @values;
 2367             }
 2368           } else {
 2369             @outData = @values;
 2370           }
 2371 
 2372           if ($status >= &CDF_OK && $matrix == 1) {
 2373             if ($dataType == &CDF_EPOCH16) {
 2374               if ($numDims == 0) {
 2375                 $dimSizes[0] = 2;
 2376               } else {
 2377                 push @dimSizes, 2;
 2378               }
 2379               $numDims++;
 2380             }
 2381             my $numRecs = $maxRec + 1;
 2382             if ($numDims > 0) {
 2383               if ($numRecs > 1) {
 2384                 unshift @dimSizes, $numRecs;
 2385               }
 2386               my $matrix = make_matrix(\@dimSizes, \@outData);
 2387               @outData = @$matrix;
 2388             }
 2389           }
 2390         } else {
 2391           @outData = ();
 2392         }
 2393         if ($toClose == 1) {
 2394           $status = CDFlib(&CLOSE_, &CDF_, &NULL_);
 2395         } else {
 2396           $status = CDFlib (&SELECT_, &CDF_zMODE_, $zMode,
 2397                             &NULL_);
 2398         }
 2399         return ($status, @outData);
 2400 }#end sub CDFgetVarAllData
 2401 
 2402 sub make_matrix {
 2403   my ($dims_ref, $flat_ref) = @_;
 2404   my @dims        = @$dims_ref;
 2405   my $current_dim = shift @dims;
 2406   my $result      = [];
 2407   return [ splice @$flat_ref, 0, $current_dim ] unless @dims;
 2408   for ( 1 .. $current_dim ) {
 2409     push @$result, make_matrix( \@dims, $flat_ref );
 2410   }
 2411   return $result;
 2412 }#end sub make_matrix
 2413 
 2414 sub getStringDataType {
 2415   my $cdfDataType = shift;
 2416   my $cDataType;
 2417   if ($cdfDataType == &CDF_BYTE) {
 2418     $cDataType = "CDF_BYTE";
 2419   } elsif ($cdfDataType == &CDF_CHAR) {
 2420     $cDataType = "CDF_CHAR";
 2421   } elsif ($cdfDataType == &CDF_UCHAR) {
 2422     $cDataType = "CDF_UCHAR";
 2423   } elsif ($cdfDataType == &CDF_INT1) {
 2424     $cDataType = "CDF_INT1";
 2425   } elsif ($cdfDataType == &CDF_UINT1) {
 2426     $cDataType = "CDF_UINT1";
 2427   } elsif ($cdfDataType == &CDF_INT2) {
 2428     $cDataType = "CDF_INT2";
 2429   } elsif ($cdfDataType == &CDF_UINT2) {
 2430     $cDataType = "CDF_UINT2";
 2431   } elsif ($cdfDataType == &CDF_INT4) {
 2432     $cDataType = "CDF_INT4";
 2433   } elsif ($cdfDataType == &CDF_UINT4) {
 2434     $cDataType = "CDF_UINT4";
 2435   } elsif ($cdfDataType == &CDF_INT8) {
 2436     $cDataType = "CDF_INT8";
 2437   } elsif ($cdfDataType == &CDF_REAL4) {
 2438     $cDataType = "CDF_REAL4";
 2439   } elsif ($cdfDataType == &CDF_FLOAT) {
 2440     $cDataType = "CDF_FLOAT";
 2441   } elsif ($cdfDataType == &CDF_REAL8) {
 2442     $cDataType = "CDF_REAL8";
 2443   } elsif ($cdfDataType == &CDF_DOUBLE) {
 2444     $cDataType = "CDF_DOUBLE";
 2445   } elsif ($cdfDataType == &CDF_EPOCH) {
 2446     $cDataType = "CDF_EPOCH";
 2447   } elsif ($cdfDataType == &CDF_EPOCH16) {
 2448     $cDataType = "CDF_EPOCH16";
 2449   } elsif ($cdfDataType == &CDF_TIME_TT2000) {
 2450     $cDataType = "CDF_TIME_TT2000";
 2451   } else {
 2452     $cDataType = "UNKNOWN";
 2453   }
 2454   return $cDataType;
 2455 }
 2456 
 2457 sub getEncoding {
 2458   my $encoding = shift;
 2459   my @cEncoding = (" ", "NETWORK", "SUN", "VAX", "DECSTATION", "SGi",
 2460                    "IBMPC", "IBMRS", "HOST", "PPC", " ", "HP",
 2461                    "NeXT", "ALPHAOSF1", "ALPHAVMSd", "ALPHAVMSg",
 2462                    "ALPHAVMSi", "ARM_LITTLE", "ARM_BIG", "IA64VMSi",
 2463                    "IA64VMSd", "IA64VMSg");
 2464   return $cEncoding[$encoding];
 2465 }
 2466 
 2467 sub getMajority {
 2468   my $major = shift;
 2469   my @cMajor = ("", "ROW", "COLUMN");
 2470   return $cMajor[$major];
 2471 }
 2472 
 2473 sub getFormat {
 2474   my $format = shift;
 2475   my @cFormat = ("", "SINGLE", "MULTI");
 2476   return $cFormat[$format];
 2477 }
 2478 
 2479