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

Feature/jstassi/#73 integrate radmon into adas 2 #107

Merged
merged 2 commits into from
Jul 29, 2021
Merged
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
1 change: 1 addition & 0 deletions src/Applications/GEOSdas_App/GEOSdas.csm
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
if ( !($?LOCAL_ACQUIRE) ) setenv LOCAL_ACQUIRE 0
if ( !($?MAP05RST) ) setenv MAP05RST 0
if ( !($?MKRESRST ) ) setenv MKRESRST 0
if ( !($?MONTHLY_RADMON) ) setenv MONTHLY_RADMON 0
if ( !($?MPIRUN_IDF) ) setenv MPIRUN_IDF 0
if ( !($?MPIRUN_UPRST) ) setenv MPIRUN_UPRST /dev/null
if ( !($?NEWRADBC) ) setenv NEWRADBC 0
Expand Down
62 changes: 49 additions & 13 deletions src/Applications/GEOSdas_App/fvsetup
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ $ENV{"PATH"} = $FindBin::Bin .":$ENV{PATH}";
if ($DAO == 0) { while3 ( \&get_mhost ) }
while3 ( \&get_output );
while3 ( \&get_history );
while3 ( \&get_pyradmon );
while3 ( \&get_rstype );
while3 ( \&get_GID );

Expand Down Expand Up @@ -4556,6 +4557,29 @@ sub get_GID {
return 0;
}

#=======================================================================
sub get_pyradmon {

#=========================================================#
# FOR NOW, TAKE DEFAULT RATHER THAN QUERYING FOR LOCATION #
#=========================================================#
$pyradmon = "/discover/nobackup/jstassi/GEOSadas/pyradmon";
return;
#=========================================================#

print "\n------------------------\n"
. "Pyradmon Source Location\n"
. "------------------------\n";

$pyradmon_dflt = "/discover/nobackup/jstassi/GEOSadas/pyradmon";
$pyradmon = query("\n Pyradmon code location?", $pyradmon_dflt);
if (-d $pyradmon) {
$ENV{"PYRADMON"} = $pyradmon;
return;
}
return 1;
}

#=======================================================================
sub get_dimsg5gcm {

Expand Down Expand Up @@ -5184,9 +5208,11 @@ sub secs2hhmmss {
sub mkdir_fvhome { # create directories on FVHOME

print "\nSetting up FVHOME directory for $expid experiment ...\n";
foreach $dir (qw(ana diag daotovs etc obs prog rs run recycle fcst asens anasa)) {
mkpath("$fvhome/$dir")
or die ">>> ERROR <<< creating directory $fvhome/$dir;";
foreach $dir (qw(ana diag daotovs etc obs prog radmon)) {
mkpath("$fvhome/$dir") or die ">>> ERROR <<< creating directory $fvhome/$dir;";
}
foreach $dir (qw(rs run recycle fcst asens anasa)) {
mkpath("$fvhome/$dir") or die ">>> ERROR <<< creating directory $fvhome/$dir;";
}
foreach $subdir (qw( gaas gocart )) {
mkpath("$fvhome/run/$subdir")
Expand Down Expand Up @@ -7313,9 +7339,10 @@ if ((\$arch_type == "ADAS") && (\$\?yyyymm) && (\$\?dd)) then

# defaults
#---------
if (! \$\?MONTHLY_MEANS ) set MONTHLY_MEANS = 1
if (! \$\?MONTHLY_TAR ) set MONTHLY_TAR = 1
if (! \$\?MONTHLY_PLOTS ) set MONTHLY_PLOTS = 0
if (! \$\?MONTHLY_MEANS ) set MONTHLY_MEANS = 1
if (! \$\?MONTHLY_TAR ) set MONTHLY_TAR = 1
if (! \$\?MONTHLY_PLOTS ) set MONTHLY_PLOTS = 0
if (! \$\?MONTHLY_RADMON ) set MONTHLY_RADMON = 0

# create job script for monthly post processing
#----------------------------------------------
Expand All @@ -7335,14 +7362,12 @@ if ((\$arch_type == "ADAS") && (\$\?yyyymm) && (\$\?dd)) then
# execute job script for monthly means processing
#------------------------------------------------
set flags = ""
if (\$MONTHLY_MEANS) set flags = "\$flags -means"
if (\$MONTHLY_TAR) set flags = "\$flags -tar"
if (\$MONTHLY_PLOTS) set flags = "\$flags -plots"

if (\$MONTHLY_MEANS || \$MONTHLY_TAR || \$MONTHLY_PLOTS) then
\$monthlyPost \$flags
endif
if (\$MONTHLY_MEANS) set flags = "\$flags -means"
if (\$MONTHLY_TAR) set flags = "\$flags -tar"
if (\$MONTHLY_PLOTS) set flags = "\$flags -plots"
if (\$MONTHLY_RADMON) set flags = "\$flags -radmon \$MONTHLY_RADMON"

if (\$flags != "") \$monthlyPost \$flags
endif
endif
endif
Expand Down Expand Up @@ -7631,6 +7656,7 @@ print SCRIPT <<"EOF";
setenv MONTHLY_MEANS $monthly_means # 1 = submit monthly means at end of month; 0 = don't
setenv MONTHLY_TAR $monthly_tar # 1 = submit monthly tar job at end of month; 0 = don't
setenv MONTHLY_PLOTS $monthly_plots # 1 = submit monthly plots job at end of month; 0 = don't
setenv MONTHLY_RADMON 0 # 1 = submit monthly radmon job; 2 = 2 jobs/month; 3 = 3 jobs/month; 0 = don't
setenv NCSUFFIX $ncsuffix
setenv STAGE4FSENS /dev/null
setenv GAAS_ANA $gaas_ana # 1 = aerosol analysis, 0 = disables it
Expand Down Expand Up @@ -8412,6 +8438,10 @@ EOF
set vars = "\$vars,MONTHLY_PLOTS=\$MONTHLY_PLOTS"
endif

if (\$\?MONTHLY_RADMON) then
set vars = "\$vars,MONTHLY_RADMON=\$MONTHLY_RADMON"
endif

# submit archive job
# ------------------
if ( \$BATCH_SUBCMD == "sbatch" ) then
Expand Down Expand Up @@ -9965,6 +9995,12 @@ sub copy_resources {
$fname = "fvsavecf"; # config saving script
$rc = system("/bin/cp $fvbin/$fname $fvhome/run/$fname");
die "Cannot write file $fvhome/run/$fname: $!" if ( $rc );

# Copy radmon.defaults.rc file to FVHOME/radmon
#----------------------------------------------
if (-e "$pyradmon/scripts/radmon.defaults.rc") {
cp("$pyradmon/scripts/radmon.defaults.rc", "$fvhome/radmon");
}
}

#=======================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/Applications/GEOSdas_App/gen_silo_arc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ sub init {
# check for needed executables and rc
#------------------------------------
$edhist_pl = "$fvroot/bin/edhist.pl";
$echorc_x = "$fvroot/bin/echorc.x";
$echorc_x = "$fvroot/bin/echorc.pl";
$gsidiags_rc = "$fvroot/etc/gsidiags.rc";

die "Error. Cannot find $edhist_pl;" unless -x $edhist_pl;
Expand Down
81 changes: 70 additions & 11 deletions src/Applications/GEOSdas_App/monthly.yyyymm.pl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# > compute monthly means
# > tar and clean monthly means inputs
# > create monthly plots
# > run monthly radmon plots
# Notes:
# 1. To use this script,
# - copy to experiment run directory
Expand Down Expand Up @@ -53,12 +54,12 @@ use WriteLog qw(chdir_ mkpath_ unlink_ system_);

# global variables
#-----------------
my ($meansFLG, $plotsFLG, $tarFLG, $finish, $nopush, %doMeans);
my ($EXPID, $FVHOME, $PBS_BIN, $account, $listdir, $mnthlyRC);
my ($meansFLG, $plotsFLG, $radmonFLG, $tarFLG, $finish, $nopush, %doMeans);
my ($EXPID, $FVHOME, $PBS_BIN, $PYRADMON, $account, $listdir, $mnthlyRC);
my ($numnodes_mm, $numnodes_mp, $plotHISTrc, $qcmd, $rundir);
my ($script, $siteID, $workdir, $yyyymm, %newrc, %JOBID);
my ($walltime_cl, $walltime_mm, $walltime_mp, $walltime_pf);
my ($partition, $qos);
my ($partition, $qos, $runlocal);

#$partition = "preops";
#$qos = "dastest";
Expand Down Expand Up @@ -88,6 +89,7 @@ my %valid = ( "fetch" => 1,
archive_monthly_keep_files();
}
monthly_plots() if $plotsFLG;
radmon() if $radmonFLG;
}

#=======================================================================
Expand All @@ -111,10 +113,14 @@ sub init {
#-----------------------
GetOptions( "means" => \$meansFLG,
"tar" => \$tarFLG,

"plots" => \$plotsFLG,
"finish_plots" => \$finish,
"nopush" => \$nopush,

"radmon:i" => \$radmonFLG,
"runlocal" => \$runlocal,

"partition=s" => \$partition,
"qos=s" => \$qos,

Expand All @@ -125,6 +131,10 @@ sub init {
"h|help" => \$help );
usage() if $help;

if (defined($radmonFLG)) {
$radmonFLG = 1 if $radmonFLG < 1 or $radmonFLG > 3;
}

# flags indicating whether to create new resource files
#------------------------------------------------------
if ($#newrc == 0 and $newrc[0] eq "") { $newrc[0] = "1,2" }
Expand All @@ -134,7 +144,8 @@ sub init {
next unless m/^1$/ or m/^2$/;
$newrc{$_} = 1;
}
usage() unless $meansFLG or $tarFLG or $plotsFLG or $finish or %newrc;
usage() unless $meansFLG or $tarFLG or $plotsFLG or $finish
or $radmonFLG or %newrc;

# process options
#----------------
Expand All @@ -153,10 +164,11 @@ sub init {
$opts{"debug"} = $debug if $debug;
perl_config(%opts);

$EXPID = $ENV{"EXPID"};
$FVHOME = $ENV{"FVHOME"};
$PBS_BIN = $ENV{"PBS_BIN"};
$GID = $ENV{"GID"};
$EXPID = $ENV{"EXPID"};
$FVHOME = $ENV{"FVHOME"};
$PBS_BIN = $ENV{"PBS_BIN"};
$PYRADMON = $ENV{"PYRADMON"};
$GID = $ENV{"GID"};

$ENV{"PATH"} = "$rundir:$fvroot/bin:$ENV{PATH}";

Expand Down Expand Up @@ -870,6 +882,43 @@ sub finish_monthly_plots {
}
}

#=======================================================================
# name - radmon
# purpose - run pyradmon code
#=======================================================================
sub radmon {
my ($qFLG, $flags, $pyflags, $radmonRC);

$qFLG = "";
$qFLG = "-qjobs" unless $runlocal;
$flags = "-expid $EXPID -fvhome $FVHOME -np $qFLG";

$radmonRC = "$FVHOME/radmon/radmon.defaults.rc";
$radmonRC = "" unless -e $radmonRC;

if ($radmonFLG == 1) {
$pyflags = $flags ." -startdate ${yyyymm}01";
system("$PYRADMON/scripts/pyradmon_driver.pl $radmonRC $pyflags");
}
elsif ($radmonFLG == 2) {
$pyflags = $flags ." -startdate ${yyyymm}01 -enddate ${yyyymm}15";
system("$PYRADMON/scripts/pyradmon_driver.pl $radmonRC $pyflags");

$pyflags = $flags ." -startdate ${yyyymm}16";
system("$PYRADMON/scripts/pyradmon_driver.pl $radmonRC $pyflags");
}
elsif ($radmonFLG == 3) {
$pyflags = $flags ." -startdate ${yyyymm}01 -enddate ${yyyymm}10";
system("$PYRADMON/scripts/pyradmon_driver.pl $radmonRC $pyflags");

$pyflags = $flags ." -startdate ${yyyymm}11 -enddate ${yyyymm}20";
system("$PYRADMON/scripts/pyradmon_driver.pl $radmonRC $pyflags");

$pyflags = $flags ." -startdate ${yyyymm}21";
system("$PYRADMON/scripts/pyradmon_driver.pl $radmonRC $pyflags");
}
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# UTILITY subroutines
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -1043,11 +1092,21 @@ usage: $script [process options] [plot option] [other options]
process options (see Notes below)
-means calculate monthly means
-tar tar input files

-plots produce monthly plots from monthly means
-finish_plots finish monthly plots job which stopped before completion

plot option (only valid when used with -plots or -finish_plots)
-nopush do not transfer gif files to Web server after plotting
-nopush do not transfer gif files to Web server after plotting;
only valid when used with -plots or -finish_plots flag

-radmon [val] produce radmon plots (see -qjobs option)
if val == 1 ... produce plots for entire month
if val == 2 ... split month into 2 sets
if val == 3 ... split month into 3 sets
if no val is given, then set val to 1
-runlocal run radmon jobs locally if archive is visible; otherwise,
jobs will automatically be sent to slurm queue; they will
be sent there regardless if archive is not visible;
only valid when used with -radmon flag

slurm directive options
-partition partition send monthly means jobs to specified partition
Expand Down
4 changes: 4 additions & 0 deletions src/Applications/GEOSdas_App/monthly_setup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ sub write_plotfiles {
$values{"\@GEOSBIN"} = "$FVROOT/bin";
$values{"\@GEOSSRC"} = $ENV{"GEOSUTIL"};

$values{"\@BATCH_TIME"} = "SBATCH --time=";
$values{"\@BATCH_JOBNAME"} = "SBATCH --jobname=";
$values{"\@BATCH_OUTPUTNAMEOUTPUT"} = "SBATCH --output=OUTPUT";

replaceLabels($infile, $outfil, \%values,\@setenvs);

# write gcm_moveplot.j; copy gcm_quickplot.csh
Expand Down
3 changes: 3 additions & 0 deletions src/Applications/GEOSdas_App/testsuites/C48f.input
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ Output Restart TYPE (bin or nc4) [nc4]
Select group: [g0613]
>

Continue without missing resource files? [y]
>

Edit COLLECTIONS list in run/HISTORY.rc.tmpl (y/n)? [n]
> y

Expand Down
6 changes: 4 additions & 2 deletions src/Applications/GEOSdas_App/write_FVDAS_Run_Config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
my ($FVHOME, $FVROOT, $RUNDIR);
my ($AOD_OBSCLASS, $BERROR, $DO_ECS_OUT, $DO_REM_SYNC, $EXPID, $FVARCH,
$FVBCS, $GID, $MONTHLY_MEANS, $MP_SET_NUMTHREADS, $NCEPINPUT, $NOBACKUP,
$OBSCLASS, $OBSCLASS_NOAIRS, $OMP_NUM_THREADS, $RUN_QUADS, $VTRACK,
$VTXLEVS, $VTXRELOC);
$OBSCLASS, $OBSCLASS_NOAIRS, $OMP_NUM_THREADS, $RUN_QUADS, $PYRADMON,
$VTRACK, $VTXLEVS, $VTXRELOC);
my ($BASEDIR, $FCSTID, $FVDMGET, $G5MODULES, $PLOTS_LOC, $GEOSUTIL, $GTAG);
my ($qalter, $PBS_BIN, $DISCOVERSHARE);
my ($FVSHARE, $SHARE, $REM_GRADS_CONFIG, $G5MGRAM, $LATS4DLOC, $FVBIN,
Expand Down Expand Up @@ -97,6 +97,7 @@ sub init {
$OBSCLASS = $ENV{"OBSCLASS"};
$OBSCLASS_NOAIRS = $ENV{"OBSCLASS_NOAIRS"};
$OMP_NUM_THREADS = $ENV{"OMP_NUM_THREADS"};
$PYRADMON = $ENV{"PYRADMON"};
$RUN_QUADS = $ENV{"RUN_QUADS"};
$VTRACK = $ENV{"VTRACK"};
$VTXLEVS = $ENV{"VTXLEVS"};
Expand Down Expand Up @@ -278,6 +279,7 @@ sub writefile {
print RUNCONF "setenv FVARCH $FVARCH\n" if $FVARCH;
print RUNCONF "setenv FVSPOOL $FVSPOOL\n" if $FVSPOOL;
print RUNCONF "setenv BASEDIR $BASEDIR\n" if $BASEDIR;
print RUNCONF "setenv PYRADMON $PYRADMON\n" if $PYRADMON;
print RUNCONF "#------------------------------\n";
print RUNCONF "setenv G5MODULES \"$G5MODULES\"\n" if $G5MODULES;
print RUNCONF "source \$FVROOT/bin/g5_modules\n";
Expand Down