#!/usr/bin/env perl #----------------------------------------------------------------------------------------------- # # create_production_test # # This utility allows the users to specify configuration # cesm tests from an existing case directory # #----------------------------------------------------------------------------------------------- use strict; use Cwd; use English; use Getopt::Long; use IO::File; use IO::Handle; sub usage { die < \$opts{'test'}, "h|help" => \$opts{'help'},) or usage(); usage() if $opts{'help'}; $test = $opts{'test'} if $opts{'test'}; if($test =~ /(\w\w\w)_/){ die usage() unless(grep(/^$1$/,@allowedtests)>0); }else{ die usage() unless(grep(/^$test$/,@allowedtests)>0); } #----------------------------------------------------------------------------------------------- # The XML::Lite module is required to parse the XML configuration files. #----------------------------------------------------------------------------------------------- my $caseroot = getcwd(); (-f "$caseroot/Tools/XML/Lite.pm") or die <<"EOF"; ** Cannot find perl module \"XML/Lite.pm\" in directory \"$caseroot/ccsm_utils/Tools/perl5lib\" ** EOF my $dirs = "$caseroot/Tools"; unshift @INC, $dirs; require XML::Lite; require SetupTools; #----------------------------------------------------------------------------------------------- # Read $caseroot xml files - put restuls in %xmlvars hash #----------------------------------------------------------------------------------------------- my %xmlvars = (); SetupTools::getxmlvars($caseroot, \%xmlvars); foreach my $attr (keys %xmlvars) { $xmlvars{$attr} = SetupTools::expand_env_var($xmlvars{$attr}, \%xmlvars); } my $casename = $xmlvars{CASE}; my $testroot = "$caseroot/.."; my $testname = "${casename}_${test}"; my $ccsmroot = $xmlvars{CCSMROOT}; print "\nCreating test $testname\n"; system("$ccsmroot/scripts/create_clone -case $testroot/$testname -clone $caseroot -testname $test"); chdir("$testroot/$testname"); $ENV{TESTCASE}=$test; $ENV{CASEROOT}="$testroot/$testname"; $ENV{CCSMROOT}=$ccsmroot; system("$ccsmroot/scripts/ccsm_utils/Tools/testcase_setup.csh");