Skip to content

Commit

Permalink
Bugfix/jstassi/#364 g5 modules perl wrapper (#365)
Browse files Browse the repository at this point in the history
* update g5_modules_perl_wrapper script to remove loadmodules option from call to g5_modules

* Modified the expand function in Perl_Config.pm so that environment variables will be correctly expanded in the string if the variables are defined.

---------

Co-authored-by: rtodling <[email protected]>
  • Loading branch information
gmao-jstassi and rtodling authored Dec 30, 2024
1 parent 2dc206b commit 766a32b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion GMAO_etc/Perl_Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ sub expand {
#------------------------------------------
foreach $var (@vars) {
($varname = $var) =~ s/[\$[{}]]//g;
($varname = $var) =~ s/\$//; # remove '$'
$varname =~ s/\{//; # remove '{'
$varname =~ s/}//; # remove '}'
$val_ENV = $ENV{$varname};
$val_eval = eval($var);
Expand Down
6 changes: 3 additions & 3 deletions GMAO_etc/g5_modules_perl_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
# conflict with calling script
# 05Feb2018 Stassi Get $bindir from @ARGV, if calling script does not
# reside is same directory as this script
# 23Dec2024 Stassi Remove option to call g5_modules with loadmodules
# argument
########################################################################
use strict;
use warnings;

my ($scriptname, $g5_modules);
my ($BASEDIR, @libmods, $modinit, $loadmodules, @usemods);
my ($BASEDIR, @libmods, $modinit, @usemods);
my (@fields, $LD_LIBRARY_PATH);
my ($arch, $node);
my ($baselib, $status);
Expand Down Expand Up @@ -94,7 +96,6 @@ sub g5_mpw_get_expected_values {
#------------------------------------
chomp( $BASEDIR = `$g5_modules basedir` );
chomp( @libmods = (`$g5_modules modules`) );
chomp( $loadmodules = `$g5_modules loadmodules` );
chomp( @usemods = (`$g5_modules usemodules`) );
chomp( $modinit = `$g5_modules modinit` );

Expand Down Expand Up @@ -137,7 +138,6 @@ sub g5_mpw_set_env_variables {
do $modinit;
module ("purge");

if ($loadmodules) { module ("load modules") };
if (@usemods) { foreach ( @usemods ) { module ("use -a $_") } }
foreach ( @libmods ) { module ("load $_") };
print " for $node\n";
Expand Down

0 comments on commit 766a32b

Please sign in to comment.