#! /usr/bin/perl -w

#*******************************************************************************
# get path for data_source
#*******************************************************************************

$path = $ENV{"PATH"};
unless ( $MK_PATH ) { $MK_PATH = " " }
$file = "data_ax";
$path =~ s/:/ /g;
@path_list = split( / /, $path );
PATH:
 foreach $path (@path_list) {
  $path_file = "$path/$file"; $path_file =~ s/ //g;
  if ( -e "$path_file") { last PATH }
 }
# if can not find it try the default
if ( ! -e $path_file) { $path_file = "/usr/local/models/UVic_ESCM/data_source" }
if ( ! -e $path_file) { 
 print "get_path can not find the path to data_source.\nCheck if data_source ";
 print "exists and/or your PATH environment variable points to it.\n" }
else { open OUT, ">path"; { print OUT "$path_file\n" }; close OUT }
