#!/usr/bin/perl -w # NetCDF.pl $version = "May 19, 2006/V1.00 # Program reads a NetCDF binary file using ncdump and outputs # a JGOFS/GLOBEC compatible file. The following are the run-time # parameters contained in @ARGV: # $ARGV[0] - configuration file # $ARGV[1] - filename only [root specified in config file] # $ARGV[2] - desired output level, 0, 1, 2, .... # May 19, 2006 R.C. Groman # Assumptions # 1. Level 0 output is from the NetCDF global attributes. Use # all of them. # 2. The data object will need to be defined in such a way as # to specify that the tab character (and newline) are the only data # separators in the resulting JGOFS/GLOBEC data output. # 3. Remove the trailing "f" when present in values in the # global attributes section. # 4. Level 0 variables are those with the smallest dimension, # initially restricted to 1 (maybe). # 5. Level 1, 2, ... are those values with greater than one # dimension or with dependent variables. (maybe) # 6. Items in the global attributes are output as comments. # This could change to make only those entries in capital letters # output as comments with the others as level 0 values, but we'll # see. unshift (@INC, "/data/rgroman/perllib"); require ('sendmessage.pl'); require ('make_log_entry.pl'); require ('bob_setup.pl'); require ('bob_unsetup.pl'); @required_config_params = ( 'comments', 'ncdump_command', 'root_data_director' ); $| = 1; &bob_setup(); $date = scalar localtime; ($configuration_file, $filename, $level) = @ARGV; unless (defined $configuration_file) { &sendmessage($error, "Configuration file not defined.", "Cannot continue."); exit; } unless (defined $filename) { &sendmessage($error, "Data file not specified.", "Cannot continue."); exit; } unless (defined $level) { &sendmessage($error, "Data level not specified.", "Cannot continue."); exit; } my $status = read_configuration_file($config_file); if (exists $config_param{'debug'} and defined $config_param{'debug'} ) { if ($config_param{'debug'} =~ m/^y/i or $config_param{'debug'} =~ m/^1/ or $config_param{'debug'} =~ m/^t/i) { $debug = 'yes'; } else { $debug = 'no'} } else { $debug = 'no'} $status = 'okay'; foreach (@required_config_params) { unless (exists $config_param{$_} and defined $config_param{$_} ) { &sendmessage($error, "$_ parameter not defined", ""); $status = 'ng'; } } unless ($status eq 'okay' ) { sendmessage($error, "One or more required configuration parameters were not defined.", "Cannot continue."); goto END; } &bob_unsetop(); exit;