#!/usr/bin/env perl # +-======-+ # Copyright (c) 2003-2007 United States Government as represented by # the Admistrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, # REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN # COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS # REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY"). # THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN # INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR # REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, # DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED # HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE # RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. # # Government Agency: National Aeronautics and Space Administration # Government Agency Original Software Designation: GSC-15354-1 # Government Agency Original Software Title: GEOS-5 GCM Modeling Software # User Registration Requested. Please Visit http://opensource.gsfc.nasa.gov # Government Agency Point of Contact for Original Software: # Dale Hithon, SRA Assistant, (301) 286-2691 # # +-======-+ #======================================================================= # name - pasta # purpose - wrapper for pasta subroutine in pasta.pm package # # Revision History: # ---------------- # 03Feb2011 Stassi Moved routine to package and wrote script to access #======================================================================= use strict; use warnings; use FindBin; use lib $FindBin::Bin; use Pasta ("pasta"); my $name; # main program #------------- { my (@params, @retVals); init(); @params = @ARGV; @retVals = pasta(@params); print "@retVals\n"; } #======================================================================= # name - init # purpose - get runtime parameters and flags #======================================================================= sub init { use File::Basename; use Getopt::Long; my $help; $name = basename $0; GetOptions( "h" => \$help, "help" => \$help ); usage() if $help; usage() unless scalar(@ARGV) == 2; return; } #======================================================================= # name - usage # purpose - print usage information #======================================================================= sub usage { print << "EOF"; usage: $name string template Purpose: Use tokens in template to extract information from string Supported tokens: %s experiment ID (a string followed by ".") %y4 year, e.g., 1997 %y2 year, e.g., 97 %m2 month, e.g., 12 %d2 day, e.g., 31 %h2 hour, e.g., 18 %n2 minute, e.g., 30 %c single wildcard character, e.g. %c%c for nh Restrictions: 1. The token "%s" must be followed by a "." 2. %m3 is not an allowable token. Return values: year yr mo mon dy hr expid grads_string min where year = 4-digit year yr = 2-digit year mo = 2-digit month mon = 3-character month label dy = 2-digit day hr = 2-digit hour expid = experiment ID string grads_string = GRADS string min = 2-digit minutes Examples and results: > $name efake.prog.t19971231.18Z %s.prog.t%y4%m2%d2.%h2Z 1997 97 12 dec 31 18 efake 18:00Z31dec1997 00 > $name efake.prog.t19971231.18Z efake.%s.t%y4%m2%d2.%h2Z 1997 97 12 dec 31 18 prog 18:00Z31dec1997 00 EOF exit; }