NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: your mail

NOTE: The decoders mailing list is no longer active. The list archives are made available for historical reasons.

On 8 May 2000, Jason Burks wrote:


     Robb,
I have some code that can be used to decode the strings read out of the netcdf files in a slightly different manner than your example on the support archives. This method uses the pack command. Just thought I would send you the code: This example reads out the station name into @statName list which is decoded in the for loop and pushed into the @nameid list, an entry for each station. $length is the max length of the string. ######################################################################
     NetCDF::varget($ncid,$varidName,\@start,\@count,\@statName);
for ($counter=0; $counter<$#statName; $counter=$counter+$length-1) {
         push @nameid, pack("C*",@statName[$counter..$counter+$length-1]);
     }
     ######################################################################

Jason,

Yes, the pack code is a much cleaner solution.  Never thought of using it
until lately.  Will keep the code on-hand for future reference.


Thanks,

Robb...




Thought you might be interested in this. This is an alternative to the code below: for( $i = 0; $i <= $#STNS; $i += 4 ) {
             for( $j = $i; $j < ( $i + $stn_name_len ); $j++ ) {
                      $station .= chr( $STNS[ $j ] ) ;
             }
             print "Station = $station\n" ;
             undef( $station ) ;
        }
Jason


==============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
rkambic@xxxxxxxxxxxxxxxx                   WWW: http://www.unidata.ucar.edu/
==============================================================================


  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the decoders archives: