Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed support for the $PROJECT variable in create_test (as well as other minor fixes in the scripts directory) #6

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/ccsm_utils/Machines/mkbatch.edison
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ($PHASE == set_batch) then
#################################################################################

source ./Tools/ccsm_getenv || exit -1
if ($PROJECT == "") then
if ($PROJECT == "PROJECT_UNSET") then
echo " PROJECT must be set in env_case.xml on Edison."
echo " This can be specified in create_newcase with the -project parameter"
echo " or by setting a PROJECT environment variable before executing create_newcase."
Expand Down
2 changes: 1 addition & 1 deletion scripts/ccsm_utils/Machines/mkbatch.hopper
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ($PHASE == set_batch) then
#################################################################################

source ./Tools/ccsm_getenv || exit -1
if ($PROJECT == "") then
if ($PROJECT == "PROJECT_UNSET") then
echo " PROJECT must be set in env_case.xml on Hopper."
echo " This can be specified in create_newcase with the -project parameter"
echo " or by setting a PROJECT environment variable before executing create_newcase."
Expand Down
2 changes: 1 addition & 1 deletion scripts/ccsm_utils/Machines/mkbatch.mira
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ($PHASE == set_batch) then
#################################################################################

source ./Tools/ccsm_getenv || exit -1
if ($PROJECT == "") then
if ($PROJECT == "PROJECT_UNSET") then
echo " PROJECT must be set in env_case.xml on Mira."
echo " This can be specified in create_newcase with the -project parameter"
echo " or by setting a PROJECT environment variable before executing create_newcase."
Expand Down
2 changes: 1 addition & 1 deletion scripts/ccsm_utils/Machines/mkbatch.titan
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ($PHASE == set_batch) then
#################################################################################

source ./Tools/ccsm_getenv || exit -1
if ($PROJECT == "") then
if ($PROJECT == "PROJECT_UNSET") then
echo " PROJECT must be set in env_case.xml on Titan."
echo " This can be specified in create_newcase with the -project parameter"
echo " or by setting a PROJECT environment variable before executing create_newcase."
Expand Down
48 changes: 26 additions & 22 deletions scripts/ccsm_utils/Tools/cesm_buildexe
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,34 @@ endif
#--- save model provenance with the executable
cd $CCSMROOT

git describe > $EXEROOT/GIT_DESCRIBE.$LID
chmod 664 $EXEROOT/GIT_DESCRIBE.$LID
/bin/cp -p $EXEROOT/GIT_DESCRIBE.$LID $EXEROOT/GIT_DESCRIBE

if (-f $CCSMROOT/.git/logs/HEAD) then
/bin/cp $CCSMROOT/.git/logs/HEAD $EXEROOT/GIT_LOGS_HEAD.$LID
chmod 664 $EXEROOT/GIT_LOGS_HEAD.$LID
/bin/cp -p $EXEROOT/GIT_LOGS_HEAD.$LID $EXEROOT/GIT_LOGS_HEAD
else
/bin/rm -f $EXEROOT/GIT_LOGS_HEAD
touch $EXEROOT/GIT_LOGS_HEAD
if (-d $CCSMROOT/.git) then
git describe > $EXEROOT/GIT_DESCRIBE.$LID
chmod 664 $EXEROOT/GIT_DESCRIBE.$LID
/bin/cp -p $EXEROOT/GIT_DESCRIBE.$LID $EXEROOT/GIT_DESCRIBE

if (-f $CCSMROOT/.git/logs/HEAD) then
/bin/cp $CCSMROOT/.git/logs/HEAD $EXEROOT/GIT_LOGS_HEAD.$LID
chmod 664 $EXEROOT/GIT_LOGS_HEAD.$LID
/bin/cp -p $EXEROOT/GIT_LOGS_HEAD.$LID $EXEROOT/GIT_LOGS_HEAD
else
/bin/rm -f $EXEROOT/GIT_LOGS_HEAD
touch $EXEROOT/GIT_LOGS_HEAD
endif
endif

svn info > $EXEROOT/SVN_INFO.$LID
chmod 664 $EXEROOT/SVN_INFO.$LID
/bin/cp -p $EXEROOT/SVN_INFO.$LID $EXEROOT/SVN_INFO

if (-f $CCSMROOT/.svn/wc.db) then
/bin/cp $CCSMROOT/.svn/wc.db $EXEROOT/SVN_WC.DB.$LID
chmod 664 $EXEROOT/SVN_WC.DB.$LID
/bin/cp -p $EXEROOT/SVN_WC.DB.$LID $EXEROOT/SVN_WC.DB
else
/bin/rm -f $EXEROOT/SVN_WC.DB
touch $EXEROOT/SVN_WC.DB
if (-d $CCSMROOT/.svn) then
svn info > $EXEROOT/SVN_INFO.$LID
chmod 664 $EXEROOT/SVN_INFO.$LID
/bin/cp -p $EXEROOT/SVN_INFO.$LID $EXEROOT/SVN_INFO

if (-f $CCSMROOT/.svn/wc.db) then
/bin/cp $CCSMROOT/.svn/wc.db $EXEROOT/SVN_WC.DB.$LID
chmod 664 $EXEROOT/SVN_WC.DB.$LID
/bin/cp -p $EXEROOT/SVN_WC.DB.$LID $EXEROOT/SVN_WC.DB
else
/bin/rm -f $EXEROOT/SVN_WC.DB
touch $EXEROOT/SVN_WC.DB
endif
endif

if (-d $CASEROOT/SourceMods) then
Expand Down
2 changes: 2 additions & 0 deletions scripts/create_newcase
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ if (defined $opts{'confopts'}) {
#-----------------------------------------------------------------------------------------------
if (defined $project and length $project){
$cfg_ref->set('PROJECT' , "$project");
} else {
$project = 'PROJECT_UNSET';
}

#-----------------------------------------------------------------------------------------------
Expand Down
52 changes: 33 additions & 19 deletions scripts/create_test
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,27 @@ sub checkOptions
$opts{'guessmach'} = $1;
}

# Check whether project is set via one of the other supported mechanisms
if(! defined $opts{'project'})
{
if (defined $ENV{'PROJECT'}){
$project = $ENV{'PROJECT'};
}
my $ccsm_proj_file = $ENV{'HOME'} . "/.ccsm_proj";
if (-f $ccsm_proj_file){
open my $ccsm_proj, '<', $ccsm_proj_file;
my $firstline = <$ccsm_proj>;
if ($firstline =~ /^\s*(\S*)/){
$project = $1;
}
close $ccsm_proj;
}
if (defined $project and length $project){
$opts{'project'} = $project;
Debug("project: $opts{'project'}\n");
}
}

# Read options from config_machines.xml
my $machine = (defined $opts{mach}) ? $opts{mach} : $opts{xml_mach};

Expand All @@ -598,25 +619,6 @@ sub checkOptions
if(!defined $opts{'baselineroot'}) {
$opts{'baselineroot'} = SetupTools::expand_env_var($cfg_ref->get('CCSM_BASELINE'), $cfg_ref);
}
if(! defined $opts{'project'})
{
if (defined $ENV{'PROJECT'}){
$project = $ENV{'PROJECT'};
}
my $ccsm_proj_file = $ENV{'HOME'} . "/.ccsm_proj";
if (-f $ccsm_proj_file){
open my $ccsm_proj, '<', $ccsm_proj_file;
my $firstline = <$ccsm_proj>;
if ($firstline =~ /^\s*(\S*)/){
$project = $1;
}
close $ccsm_proj;
}
if (defined $project and length $project){
$opts{'project'} = $project;
Debug("project: $opts{'project'}\n");
}
}
if(! defined $opts{'scratchroot'})
{
$opts{'scratchroot'} = $cfg_ref->get('CESMSCRATCHROOT');
Expand All @@ -625,6 +627,18 @@ sub checkOptions
if(! defined $opts{'sharedlibroot'} && $suitemode)
{
$opts{'sharedlibroot'} = $opts{scratchroot}.'/sharedlibroot.' . $opts{'testid'};

# When sharedlibroot is passed to create_newcase, anything
# that looks like an environment variable gets expanded by the
# shell. This is problematic for $PROJECT, which is now a CESM
# xml variable: if you don't have a $PROJECT environment
# variable defined on machines that use $PROJECT in
# $CESMSCRATCHROOT, it will get expanded to ''. To avoid this,
# we escape the '$' in '$PROJECT'. (Note: we may want to more
# generally escape all instances of '$' in sharedlibroot, but
# that might cause its own problems.)
$opts{'sharedlibroot'} =~ s/\$PROJECT/\\\$PROJECT/g;

Debug("sharedlibroot: $opts{'sharedlibroot'}\n");
}

Expand Down