Skip to content

Commit

Permalink
Merge pull request #233 from GEOS-ESM/bugfix/jstassi/#232/update-idch…
Browse files Browse the repository at this point in the history
…eck-pl

The idcheck.pl script was updated for changes in SemperPy
  • Loading branch information
sdrabenh authored Dec 8, 2021
2 parents 38d2fc6 + ce8e308 commit c6addc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Update to `idcheck.pl` to allow fvsetup to check whether the expid already exists in the SemperPy databases

### Changed

### Removed
Expand Down
22 changes: 15 additions & 7 deletions GMAO_etc/idcheck.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
{
init();
check_semperpy_dbs() if $DBcheck;
check_plots_dir() if $PLcheck;
unless ($status == 1) {
check_plots_dir() if $PLcheck;
}
exit $status;
}

Expand Down Expand Up @@ -76,16 +78,17 @@ sub check_semperpy_dbs {
# load SemperPy module
#---------------------
$SHARE = "/discover/nobackup/projects/gmao/share";
$modsDIR = "$SHARE/dasilva/lib/python/gmaopy/modules";
$modsDIR = "/home/dao_ops/gmao_packages/modules";

unless (-e $modsDIR) {
myprint("Warning: Unable to check SemperPy DB info");
myprint("Warning: Unable to check SemperPy DB info: $modsDIR;");
$status = 99 unless $status == 1;
return;
}
$ENV{"MODULEPATH"} .= ":${modsDIR}";
do "/usr/share/modules/init/perl";
module ("load semperpy/1.90");
module ("load gpy/sles12-v1.1.0");
$ENV{"SEMPERPY_CONFIG"} = "/home/dao_ops/gmao_packages/o2h/o2h/config";

# write .pgpass, if it does not already exist
#---------------------------------------------
Expand All @@ -94,7 +97,7 @@ sub check_semperpy_dbs {
unless (-e $pgpass) {
myprint("Writing temporary password file: $pgpass");
open $PGP, "> $pgpass" or die "Error. Unable to write $pgpass\n";
print $PGP "dpdb:*:*:$user:hemperUI9#\n";
print $PGP "edb1:*:*:$user:hemperUI9#\n";
close $PGP;
system "chmod 600 $pgpass";
$removeAfterCheck = 1;
Expand All @@ -103,6 +106,10 @@ sub check_semperpy_dbs {
# find SemperPy bin directory
#----------------------------
chomp($spy_sql = `which spy_sql`);
unless ($spy_sql) {
warn "Cannot find spy_sql. Exiting ... ;";
exit;
}
chomp($bindir = `dirname $spy_sql`);

# look for expid in each logical database
Expand All @@ -111,9 +118,10 @@ sub check_semperpy_dbs {
foreach $logical_db (qw( fc_exp fc_ops im_exp im_ops )) {
chomp($which_pdb = `python $bindir/whichdb.py $logical_db`);
$physical_db = (split /\s+/, $which_pdb)[0];
next unless $physical_db;

$cmd = "select distinct expver from $logical_db.stats";
$psql_cmd = "psql -w -q -U $user -h dpdb $physical_db -c \"$cmd\"";
$psql_cmd = "psql -w -q -U $user -h edb1 $physical_db -c \"$cmd\"";
print "$psql_cmd\n" if $verbose;
$select_results = `$psql_cmd`;

Expand Down Expand Up @@ -265,7 +273,7 @@ sub usage {
=1 => check SemperPy databases
=2 => check geos5 modeling Intranet plot directory
=3 => check both (default)
-rem Remote account to use for accessing Intranet plot directory
-rem acct Remote account to use for accessing Intranet plot directory
default: $ENV{"USER"}\@train
(remote machine must be either "polar" or "train")
-np Take default for \$rem_acct if not provided; Otherwise,
Expand Down

0 comments on commit c6addc4

Please sign in to comment.