# ## Copyright (c) 1995-2004 University Corporation for Atmospheric Research ## All rights reserved # #/**---------------------------------------------------------------------- # @file Dplib.pm # # This module contains global variables, configuration information # and utility routines needed for most all COSMIC perl programs. # # Please only put things in here which are needed by everyone! # Special purpose routines should be put in a 'tools' module # specific to a subsystem. # # @author Doug Hunt # @since 05/25/98 # @version $URL: svn://svn1.cosmic.ucar.edu/trunk/src/perllib/Dplib.pm $ $Id: Dplib.pm 26240 2020-07-23 22:01:51Z maggie $ # -----------------------------------------------------------------------*/ package Dplib; # /** # @var $err # Value used for non-existant or erroneous data # */ $Dplib::err = -999; #$Dplib::err = 999; # Modified by Jun, cause -999 write into file is incorrect, Later find it is okay, won't report error #/**---------------------------------------------------------------------- # @sub simplefn # # Find the simple file name, given a full path # # @parameter path The full path of a file or directory # @return simplefn The simple file or directory name past all slashes # @example my $sfn = Dplib::simplefn ('/ops/tools/bin'); # 'bin' # ----------------------------------------------------------------------*/ sub simplefn { return (substr ($_[0], rindex ($_[0], '/')+1)); } #/**---------------------------------------------------------------------- # @sub protoMission # # Find the name of the prototype mission, or die if an illegal or unknown # mission name is used. # Example: protoMission('gpsmetrt') => 'gpsmet' # # @parameter mission The name of the input mission # @return protoMission The prototype name for this mission # @exception Returns exception if the mission cannot be found in the # prototype table, or if it is too long. # @example my $proto = Dplib::protoMission ('gpsmet2'); # returns 'gpsmet' # ----------------------------------------------------------------------*/ sub protoMission { my $mission = shift; $mission =~ tr/A-Z/a-z/; # lowercase # die "Illegal mission name $mission. Mission name limited to eight characters" if (length($mission) > 8); # This restriction lifted for COSMIC. Hopefully BERN5 will permit this!!! D. Hunt 7/24/2006 foreach my $p (keys %Dplib::prototypeMissions) { return $p if ($mission =~ /^$p/); } die "Mission name $mission not found"; } 1; # make require happy