How to run UEMS/WRF v19 (19.7.2) in a cluster with slurm Step by step
1. Geogrid will be run on one sbatch script by ems_domain.
2. Ungrib, avgtsfc and metgrid will be rum sequentially by ems_prep on the same sbatch script since they depend on each other.
3. Real and wrf will be run sequentially by ems_run on the same sbatch script since they depend on each other.
4. When we execute ems_domain, ems_prep and ems_run namelist files and scripts containing links to required data will be created and saved automatically on sbatch directory (uems/runs/domain_name/sbatch). In addition sbatch script will be generated and sent to the queue.
5. Sbatch script will use the files and scripts generated in the 4 step.
6. The files that need to be modified are:
- UEMSwrkstn located in uems/etc/modulefiles/UEMSwrkstn
template_uemsBsub.parallel located in uems/data/tables/lsf/
template_uemsBsub.serial located in uems/data/tables/lsf/
Elsf.pm located in uems/strc/Uutils/
Dprocess.pm located in uems/strc/Udomain/
Pungrib.pm located in uems/strc/Uprep/
Pinterp.pm located in uems/strc/Uprep/
Rexe.pm located in uems/strc/Urun/
I. ********************* UEMSwrkstn located in uems/etc/modulefiles/UEMSwrkstn **********************
Edit the file and change:
1.
- setenv LSF_SYS 1
# LSF_MANAGED_RESOURCES
setenv LSF_MANAGED_RESOURCES 1
#MAXIMUM number of nodes
setenv LSF_NODEMAX_DOMAIN 1
setenv LSF_NODEMAX_PREP 1
setenv LSF_NODEMAX_RUN 8
setenv LSF_NODEMAX_POST 2
- setenv LSF_QUEUE_SHARED defq
setenv LSF_QUEUE_EXCLUSIVE defq
- setenv LSF_BSUB_COMMAND "sbatch"
- mkdir ~/.modulerc
cp uems/etc/modulefiles/UEMSwrkstn ~/.modulerc
chmod 755 ~/.modulerc/ UEMSwrkstn
gedit modules.csh
Copy and paste these lines inside the file:
Code: Select all
#-------------------------------------------------------#
# system-wide csh.modules #
# Initialize modules for all csh-derivative shells #
#-------------------------------------------------------#
if ($?tcsh) then
source /cm/local/apps/environment-modules/4.0.0/Modules/default/init/tcsh
else
source /cm/local/apps/environment-modules/4.0.0/Modules/default/init/csh
endif
#-------------------------------------------------------#
- chmod 755 modules.csh
mv modules.csh ~/.sh/
- #UEMSwrkstn Module
source ~/.sh/modules.csh
module load ~/.modulerc/UEMSwrkstn
II. ******************** template_uemsBsub.parallel located in uems/data/tables/lsf/******************
1. Edit the file and replace all the contents by:
Code: Select all
#!/bin/bash
# Note: Lines beginning with '#' (comments) are ignored when writing the
# final batchjob file. Additionally, this template file was designed
# for use on the NWS WCOSS and may need to be changed for your system.
#
# COMMENTS_START - Start of Comments section (not required)
# COMMENTS_STOP - End of Comments section (not required)
#
# BSUBS_START - Start of the BSUB section (required)
# BSUBS_STOP - End of the BSUB section (required)
#
# UEMSCWD - Working directory - just in case
# UEMSEXEC - The location for the command (string) to be executed (required)
#
# Everything else in this file is left intact in the same relative location
#
COMMENTS_START
COMMENTS_STOP
BSUBS_START
BSUBS_STOP
module load cuda91/toolkit/9.1.85
source /cm/shared/apps/intel/ips_2017/bin/compilervars.sh -arch intel64
source /cm/shared/apps/gromacs/intel/64/2018.3/bin/GMXRC
export LANG=en_US
UEMSCWD
sleep 10
ADD_1
ADD_2
SECSS=`date +%s`
mpirun -np SLURM_NTASKS REALEXE
sleep 11
ADD_3
mpirun -np SLURM_NTASKS UEMSEXEC
sleep 10
ADD_4
ADD_5
SECSE=`date +%s`
TSECS=$((SECSE-SECSS))
echo "UEMS parallel job completed in $TSECS seconds ($?)"
III. ******************** template_uemsBsub.serial located in uems/data/tables/lsf/******************
1. Edit the file and replace all the contents by:
Code: Select all
#!/bin/bash
# Note: Lines beginning with '#' (comments) are ignored when writing the
# final batchjob file. Additionally, this template file was designed
# for use on the NWS WCOSS and may need to be changed for your system.
#
# COMMENTS_START - Start of Comments section (not required)
# COMMENTS_STOP - End of Comments section (not required)
#
# BSUBS_START - Start of the BSUB section (required)
# BSUBS_STOP - End of the BSUB section (required)
#
# UEMSCWD - Working directory - just in case
# UEMSEXEC - The location for the command (string) to be executed (required)
#
# Everything else in this file is left intact in the same relative location
#
COMMENTS_START
COMMENTS_STOP
BSUBS_START
BSUBS_STOP
export LANG=en_US
UEMSCWD
sleep 2
ADD1
ADD2
SECSS=`date +%s`
UEMSEXEC
sleep 2
ADD_1
ADD_2
SECSE=`date +%s`
TSECS=$((SECSE-SECSS))
echo "UEMS serial job completed in $TSECS seconds ($?)"
IV. ******************** Elsf.pm located in uems/strc/Uutils/******************
1. We don’t want to create sbatch file for: avgtsfc, metgrid, and real_arw.exe. so replace (line 222) :
Code: Select all
return %lsf if $lsf{error} = &WriteBatchjobFile(\%lsf);
$lsf{uemsexec} = "$ENV{LSF_BSUB_COMMAND} < $lsf{batchfile}";
Code: Select all
#cra
if ($lsf{procexe} ne "$ENV{EMS_BIN}/avgtsfc" and $lsf{procexe} ne "$ENV{EMS_BIN}/metgrid" and $lsf{procexe} ne "$ENV{EMS_BIN}/real_arw.exe > log/run_real1.log"){
return %lsf if $lsf{error} = &WriteBatchjobFile(\%lsf);
$lsf{uemsexec} = "$ENV{LSF_BSUB_COMMAND} < $lsf{batchfile}";
}# No batch file for avgtsfc/metgrid and real
Code: Select all
sub WriteBatchjobFile {
# ===================================================================================
# Write the bachjob file to be submitted to the scheduler on an LSF system. A
# template file for either a serial and mpi batch job is read and and them written
# to $lsf{batchfile} with the appropriate information. The input hash containing
# the necessary variables is created in &ConfigureProcessLSF.
# ===================================================================================
#
my $date = `date -u`; chomp $date;
my @lines = ('#!/bin/bash');
my $lref = shift; my %lsf = %$lref; # Created in &ConfigureProcessLSF
#----------------------------------------------------------------------------------
# Specify the template file to use
#----------------------------------------------------------------------------------
#
my $template = $lsf{serial} ? 'template_uemsBsub.serial' : 'template_uemsBsub.parallel';
$template = $lsf{template} if $lsf{template}; # Allow for user to specify template
my $temppath = "$ENV{EMS_DATA}/tables/lsf/$template";
my $bjtype = $lsf{serial} ? 'serial' : 'mpi';
#----------------------------------------------------------------------------------
# Create the comments block
#----------------------------------------------------------------------------------
#
my @comnts = ();
push @comnts, '----------------------------------------------------------------------------------';
push @comnts, " This $bjtype UEMS batch job file is used to run the $lsf{process} routine.";
push @comnts, " All routines are compiled as static executables.";
push @comnts, "";
push @comnts, " UEMS: $lsf{uemsver}";
push @comnts, " CREATED: $date";
push @comnts, " TEMPLATE: $template";
push @comnts, " AUTHOR: Robert.Rozumalski\@noaa.gov";
push @comnts, '----------------------------------------------------------------------------------';
push @comnts, "";
$_ = "## $_" foreach @comnts;
#----------------------------------------------------------------------------------
# Create the BSUB block. The order is not important but some entries are
# restricted to either serial or parallel jobs.
#----------------------------------------------------------------------------------
#
my @bsubs = ();
push @bsubs, "#SBATCH --comment= $lsf{prjcode}" if $lsf{prjcode};
push @bsubs, "#SBATCH --partition=$lsf{queue}" if $lsf{queue};
push @bsubs, "#SBATCH -J $lsf{jobname}" if $lsf{jobname};
if ($lsf{serial}) {
### -- specify that we need 2GB of memory per core/slot --
push @bsubs, "#SBATCH --mem-per-cpu=$lsf{reqmem}";
### -- specify affinity: number of "cores" for each "process" --
push @bsubs, "#SBATCH --ntasks=1 --ntasks-per-node=$lsf{cpnode}";
} else {
##Not required in sbatch
## push @bsubs, "#BSUB -a intelmpi";
push @bsubs, "#SBATCH --ntasks=$lsf{ncores}"; # Number of MPI ranks
push @bsubs, "#SBATCH --ntasks-per-core=1"; # How many tasks on each node
#request exclusive node allocation:only makes sure that there will be no other jobs running on your nodes.
push @bsubs, "#SBATCH --exclusive";
}
#wall-clock time limit
push @bsubs, "#SBATCH --time=23:50:00" if $lsf{wtime};
push @bsubs, "#SBATCH -o $lsf{logstd}" if $lsf{logstd};
push @bsubs, "#SBATCH -e $lsf{logerr}" if $lsf{logerr};
#----------------------------------------------------------------------------------
# Create the batchjob file with the information and comments
#----------------------------------------------------------------------------------
#
open (my $ifh, '<', $temppath) || return "Error: Can't open template file for reading - $temppath";
while (<$ifh>) {
chomp; s/^\s*//g; s/\s+$//g;
next if /^#/;
next if /_STOP/i;
if (/COMMENTS_START/i) {@lines = (@lines,@comnts); next;}
if (/BSUBS_START/i) {@lines = (@lines,@bsubs); next;}
s/UEMSCWD/cd $lsf{workdir}/g;
if ($lsf{procexe} eq "$ENV{EMS_BIN}/geogrid") {
s{ADD_1}{./sbatch/link_geogrid.csh};
s{ADD_2}{rm -fr sbatch/slurm-geogrid.out};
s{mpirun -np SLURM_NTASKS REALEXE}{};
s{sleep 11}{};
s{ADD_3}{};
s{ADD_4}{mv slurm* sbatch/slurm-geogrid.out};
s{ADD_5}{mkdir -p log/geo/;rm -f log/geo/* static/*.TBL namelist.wps;mv geogrid.log* log/geo/};
s{SLURM_NTASKS}{$lsf{ncores}};
s{UEMSEXEC}{$lsf{procexe} > log/run_geogrid1.log}g;
} elsif ($lsf{procexe} eq "$ENV{EMS_BIN}/ungrib") {
s{ADD1}{./sbatch/link_ungrib.csh};
s{ADD2}{rm -fr sbatch/slurm-ungrib.out};
s{ADD_1}{mv ungrib.log log/run_ungrib2.log;./sbatch/link_metgrid1.csh};
s{ADD_2}{./sbatch/link_metgrid2.csh};
s{UEMSEXEC}{$lsf{procexe} > log/run_ungrib1.log}g;
} elsif ($lsf{procexe} eq "$ENV{EMS_BIN}/wrfm_arw.exe > log/run_wrfm1.log") {
s{ADD_1}{./sbatch/link_real.csh;};
s{ADD_2}{rm -f sbatch/slurm-wrf.out};
s{REALEXE}{$ENV{EMS_BIN}/real_arw.exe > log/run_real1.log};
s{ADD_3}{./sbatch/link_wrf.csh; mkdir -p log/real/;rm -f log/real/*;mv rsl.* log/real/};
s{ADD_4}{mkdir -p log/wrf/;rm -f log/wrf/*;mv rsl.* log/wrf/;mv slurm* sbatch/slurm-wrf.out};
s{ADD_5}{./sbatch/link_rm.csh};
s{SLURM_NTASKS}{$lsf{ncores}};
s/UEMSEXEC/$lsf{procexe}/g;
}
push @lines, $_;
} close $ifh;
#----------------------------------------------------------------------------------
# Write the batchjob file out to $lsf{batchfile}
#----------------------------------------------------------------------------------
#
#cra
open (my $ofh, '>', $lsf{batchfile}) || return "Error: Can't open batchjob file for writing - $lsf{batchfile}";
print $ofh "$_\n" foreach @lines;
close $ofh;
#cra
my $stat;
$stat = `cp -fr $lsf{batchfile} $lsf{workdir}/sbatch/`;
$stat = `chmod 755 $lsf{workdir}/sbatch/*`;
return "Error: Problem while writing to batchjob file - $lsf{batchfile}" unless -s $lsf{batchfile};
return '';
}
V. ******************** Dprocess.pm pm located in uems/strc/Udomain/******************
1. In line 1882 it create a script file that creates symbolic links for geogrid table and nameliste:
After these lines
Code: Select all
symlink $geotbl => 'static/GEOGRID.TBL';
symlink $wpsnl => 'namelist.wps';
Code: Select all
system "mkdir -p sbatch"; #create sbatch directory if doesn't exist
open(my $FILE,">sbatch/link_geogrid.csh") || die "Cannot create sbatch/link_geogrid.csh for writing: $!";
print $FILE "#!/bin/csh -f \n";
my $lcom;
$lcom="ln -sf $geotbl static/GEOGRID.TBL" ;
print $FILE "$lcom \n";
$lcom="ln -sf $wpsnl namelist.wps" ;
print $FILE "$lcom \n";
print $FILE "echo '**** run geogrid ****' \n";
close($FILE);
system "chmod 755 sbatch/link_geogrid.csh";
VI. ******************** Pungrib.pm located in uems/strc/Uprep/ ******************
1. it creates a script file that creates symbolic links (for grib files and vtable)
2. it will copy namelist to sbatch/namelist.wps.ungrib and updates script file
Replace ( from line 238 to 278)
Code: Select all
#-------------------------------------------------------------------------------------
# Save the bc data frequency information for metgrid
#-------------------------------------------------------------------------------------
#
$masternl{SHARE}{interval_seconds}[0] = $intrs if $dstruct->useid == 1 or $dstruct->useid == 3;
if (@{$dstruct->gribs}) { # Process GRIB files unless WRF intermediate files are being used
#-------------------------------------------------------------------------------------
# Begin the pre "running of the ungrib" festivities by creating a link "GRIBFILE.???"
# to each of the GRIB files, followed by the ceremonial "writing of the namelist
# file." A good time will be had by all.
#-------------------------------------------------------------------------------------
#
my $ID = 'AAA';
foreach my $grib (sort @{$dstruct->gribs}) {$grib = File::Spec->abs2rel($grib); symlink $grib, "$emsrun{dompath}/GRIBFILE.$ID"; $ID++;}
symlink $dstruct->useid == 4 ? File::Spec->abs2rel($dstruct->lvtable) : File::Spec->abs2rel($dstruct->vtable) => 'Vtable';
#-------------------------------------------------------------------------------------
# The namelist should be written to the top level of the domain directory
# and not /static; otherwise you will loose important information.
#-------------------------------------------------------------------------------------
#
open (my $lfh, '>', $wpsnl);
print $lfh "\&share\n",
" start_date = \'$start\'\n",
" end_date = \'$stop\'\n",
" interval_seconds = $intrs\n",
" debug_level = 0\n",
"\/\n\n",
"\&ungrib\n",
" out_format = \'WPS\'\n",
" prefix = \'./$wpsprd/$ucdset\'\n",
"\/\n\n";
close $lfh;
Code: Select all
#-------------------------------------------------------------------------------------
# Save the bc data frequency information for metgrid
#-------------------------------------------------------------------------------------
#
$masternl{SHARE}{interval_seconds}[0] = $intrs if $dstruct->useid == 1 or $dstruct->useid == 3;
#Cra line 245 create a script file that creates symbolic links
system "mkdir -p sbatch"; #create sbatch directory if doesn't exist
open(my $FILE,">sbatch/link_ungrib.csh") || die "Cannot create sbatch/link_ungrib.csh for writing: $!";
print $FILE "#!/bin/csh -f \n";
my $lcom;
my $vtab;
if (@{$dstruct->gribs}) { # Process GRIB files unless WRF intermediate files are being used
#-------------------------------------------------------------------------------------
# Begin the pre "running of the ungrib" festivities by creating a link "GRIBFILE.???"
# to each of the GRIB files, followed by the ceremonial "writing of the namelist
# file." A good time will be had by all.
#-------------------------------------------------------------------------------------
#
# my $ID = 'AAA';
# foreach my $grib (sort @{$dstruct->gribs}) {$grib = File::Spec->abs2rel($grib); symlink $grib, "$emsrun{dompath}/GRIBFILE.$ID"; $ID++;}
# symlink $dstruct->useid == 4 ? File::Spec->abs2rel($dstruct->lvtable) : File::Spec->abs2rel($dstruct->vtable) => 'Vtable';
my $ID = 'AAA';
foreach my $grib (sort @{$dstruct->gribs}) {$grib = File::Spec->abs2rel($grib); symlink $grib, "$emsrun{dompath}/GRIBFILE.$ID"; $lcom="ln -sf $grib $emsrun{dompath}/GRIBFILE.$ID" ; print $FILE "$lcom \n"; $ID++;}
symlink $dstruct->useid == 4 ? File::Spec->abs2rel($dstruct->lvtable) : File::Spec->abs2rel($dstruct->vtable) => 'Vtable';
#cra
if($dstruct->useid == 4){
$vtab=File::Spec->abs2rel($dstruct->lvtable);
}else{
$vtab=File::Spec->abs2rel($dstruct->vtable);
}
$lcom="ln -sf $vtab Vtable" ; print $FILE "$lcom \n";
#-------------------------------------------------------------------------------------
# The namelist should be written to the top level of the domain directory
# and not /static; otherwise you will loose important information.
#-------------------------------------------------------------------------------------
#
open (my $lfh, '>', $wpsnl);
print $lfh "\&share\n",
" start_date = \'$start\'\n",
" end_date = \'$stop\'\n",
" interval_seconds = $intrs\n",
" debug_level = 0\n",
"\/\n\n",
"\&ungrib\n",
" out_format = \'WPS\'\n",
" prefix = \'./$wpsprd/$ucdset\'\n",
"\/\n\n";
close $lfh;
#cra a line 279 Pungrib.pm
my $stat;
$stat = `cp -fr namelist.wps $emsrun{dompath}/sbatch/namelist.wps.ungrib`;
#Cra line 282 update script file
print $FILE "cp sbatch/namelist.wps.ungrib namelist.wps \n";
print $FILE "echo '**** run ungrib ****' \n";
close($FILE);
system "chmod 755 sbatch/link_ungrib.csh";
3. Save and exit.
******************** Pinterp.pm located in uems/strc/Uprep/******************
1. It will copy namelist to sbatch/namelist.wps.metgrib
2. It creates two script files that calls namelist file, creates symbolic links for METGRID table, move TAVGSFC to static/ and creates command to execute avgtsfc if we call it before.
3. Add these lines in 157 line where namelist is updated
Code: Select all
#cra
my $stat;
$stat = `cp -fr namelist.wps $emsrun{dompath}/sbatch/namelist.wps.metgrib`;
#Cra line 156 create links to METGRID table and TAVGSFC
open(my $FILE1,">sbatch/link_metgrid1.csh") || die "Cannot create sbatch/link_metgrid1.csh for writing: $!";
print $FILE1 "#!/bin/csh -f \n";
print $FILE1 "sleep 2 \n";
print $FILE1 "cp sbatch/namelist.wps.metgrib namelist.wps \n";
#Cra
open(my $FILE,">sbatch/link_metgrid2.csh") || die "Cannot create sbatch/link_metgrid2.csh for writing: $!";
print $FILE "#!/bin/csh -f \n";
Code: Select all
#----------------------------------------------------------------------------------
# Start the process, or not
#----------------------------------------------------------------------------------
#
&Ecomm::PrintMessage(1,11+$Uprep{arf},144,1,0,"Calculating mean surface temperatures for missing water values - ");
Code: Select all
if ($ENV{LSF_SYS}==1) {
#----------------------------------------------------------------------------------
# While the information is fresh, update the static/namelist.wps file.
#----------------------------------------------------------------------------------
#
if (&Others::Hash2Namelist($emsrun{wpsnl},"$ENV{EMS_DATA}/tables/wps/namelist.wps",%masternl) ) {
my $file = "$ENV{EMS_DATA}/tables/wps/namelist.wps";
$ENV{PMESG} = &Ecomm::TextFormat(0,0,84,0,0,'The Hash2Namelist routine',"BUMMER: Problem writing $file");
return 1;
}
} #if ($ENV{LSF_SYS}==1)
Replace:
Code: Select all
if (my $status = &Ecore::SysExecute($Proc{uemsexec}, $tlog2)) {
Code: Select all
if ($ENV{LSF_SYS} eq 0){
if (my $status = &Ecore::SysExecute($Proc{uemsexec}, $tlog2)) {
Code: Select all
}#if ($ENV{LSF_SYS} eq 0)
&Ecomm::PrintMessage(0,0,96,0,1,"Success");
Code: Select all
&Ecomm::PrintMessage(0,0,96,0,1,"Success");
system "mv $emsrun{dompath}/TAVGSFC $emsrun{wpsprd}";
Code: Select all
#Cra ($conf{noaltsst})
print $FILE1 "echo '**** run avgtsfc ****' \n";
print $FILE1 "$Puems{procexe} > log/run_avgtsfc1.log \n";
print $FILE1 "mv $emsrun{dompath}/TAVGSFC $emsrun{wpsprd} \n";
print $FILE1 "mv logfile.log log/run_avgtsfc2.log \n";
Code: Select all
#==================================================================================
# Time to run the metgrid routine, which is the first time we have to account
# for the number of CPUs allocated for use with the UEMS. The primary purpose
# for this bit of caution is to ensure that the domain is not over-decomposed,
# which may lead to a segmentation fault floating point error. There is another
# potential issue related to IO.
#==================================================================================
Code: Select all
#Cra close sbatch/link_metgrid1.csh
close($FILE1);
system "chmod 755 sbatch/link_metgrid1.csh";
#==================================================================================
# Time to run the metgrid routine, which is the first time we have to account
# for the number of CPUs allocated for use with the UEMS. The primary purpose
# for this bit of caution is to ensure that the domain is not over-decomposed,
# which may lead to a segmentation fault floating point error. There is another
# potential issue related to IO.
#==================================================================================
Code: Select all
#==================================================================================
#
# Create a link from the default metgrid tables to the local directory
#
&Others::rm('METGRID.TBL'); symlink $metgtbl => 'METGRID.TBL';
Code: Select all
#Cra Create a link from the default metgrid tables to the local directory
print $FILE "sleep 2 \n";
print $FILE "ln -sf $metgtbl METGRID.TBL \n";
Code: Select all
if (my $status = &Ecore::SysExecute($Proc{uemsexec}, $mlog2)) {
Code: Select all
#Cra
print $FILE "echo '**** run metgrid ****' \n";
print $FILE "$Puems{procexe} > log/run_metgrid1.log \n";
print $FILE "rm -f GRIBFILE* Vtable logfile.log namelist.wps wpsprd/GFS* *.TBL wpsprd/TAVGSFC \n";
print $FILE "mv slurm* sbatch/slurm-ungrib.out \n";
print $FILE "mv metgrid.log log/run_metgrid2.log \n";
close($FILE);
system "chmod 755 sbatch/link_metgrid2.csh";
#Cra Don't do it for $ENV{LSF_SYS}=1, otherwise we get error message
if ($ENV{LSF_SYS} eq 0){
if (my $status = &Ecore::SysExecute($Proc{uemsexec}, $mlog2)) {
Don’t forget to close the if statement around the line 588 before
Code: Select all
} #if ($ENV{LSF_SYS} eq 0)
#----------------------------------------------------------------------------------
# We're not safe yet - A child process (metgrid) can be terminated and not
# report an error. Check the files just in case.
#----------------------------------------------------------------------------------
********************* Rexe.pm located in uems/strc/Urun/*****************
1. at line 114 before “if (my $err = &Ecore::SysExecute($Proc{uemsexec},$Puems{rlog2})) {” We don’t want uems to run the requested process for $ENV{LSF_SYS}=1 and check for errors, because the sbatch file is in the queue and takes some time to run.
Replace
Code: Select all
if (my $err = &Ecore::SysExecute($Proc{uemsexec},$Puems{rlog2})) {
Code: Select all
#Cra
if ($ENV{LSF_SYS} eq 0){
if (my $err = &Ecore::SysExecute($Proc{uemsexec},$Puems{rlog2})) {
Code: Select all
} #if $ENV{LSF_SYS}
#----------------------------------------------------------------------------------
# Only rename rsllog file if successful
#----------------------------------------------------------------------------------
#
Add these at line 462 and before “ if ($err = $ENV{EMSERR} || $we || $rc || &Others::Ret10to01(&Elove::Check4Success($Puems{rsllog}))) {”
Code: Select all
#Cra
if ($ENV{LSF_SYS} eq 0){
if ($err = $ENV{EMSERR} || $we || $rc || &Others::Ret10to01(&Elove::Check4Success($Puems{rsllog}))) {
Code: Select all
if ($proc eq 'wrfm') {
Code: Select all
##Cra
if ($ENV{LSF_SYS} eq 0){
if ($proc eq 'wrfm') {
Code: Select all
} #if $ENV{LSF_SYS} line 781
4. After these lines (1341)
Code: Select all
#----------------------------------------------------------------------------------
# Step 2. If running WRF REAL, create links to the WPS files in the wpsprd/
# directory. We only want to create links to the domains included
# in the simulation.
#----------------------------------------------------------------------------------
#
if (%{$Process{wpsfls}}) {
foreach my $d (sort {$a <=> $b} keys %{$Process{domains}}) {
foreach my $f (@{$Process{wpsfls}{$d}}) {symlink "wpsprd/$f" => $f; push @delete => $f;}
}
}
Code: Select all
#Cra create scripts that contain namlistes, links to the WPS files and links to the tables required by the physics schemes
if (%{$Process{wpsfls}}) {
#Cra create links to the WPS files
open(my $FILERM,">sbatch/link_rm.csh") || die "Cannot create sbatch/link_rm.csh for writing: $!";
open(my $FILE,">sbatch/link_real.csh") || die "Cannot create sbatch/link_real.csh for writing: $!";
my $lcom;
print $FILE "#!/bin/csh -f \n";
print $FILERM "#!/bin/csh -f \n";
foreach my $d (sort {$a <=> $b} keys %{$Process{domains}}) {
foreach my $f (@{$Process{wpsfls}{$d}}) {$lcom="ln -sf wpsprd/$f $f " ;print $FILE "$lcom \n"; print $FILERM "rm -f $f \n"; push @delete => $f;}
}
#Cra Create links to the tables required by the physics schemes
foreach my $pt (@{$Process{phytbls}}) {
my $l = &Others::popit($pt);
$lcom="ln -sf $pt $l " ;
print $FILE "$lcom \n";
print $FILERM "rm -f $l \n";
push @delete => $l;
}
# requesting that the WRF model do an internal decomposition of your domain across the number of processors being used.
print $FILE "sed -i 's/ nproc_x = 4/ nproc_x = -1/g' static/namelist.real \n";
print $FILE "sed -i 's/ nproc_y = 16/ nproc_y = -1/g' static/namelist.real \n";
print $FILE "ln -sf static/namelist.real namelist.input \n";
print $FILE "echo '**** Run Real ****' \n";
close($FILE);
open(my $FILE,">sbatch/link_wrf.csh") || die "Cannot create sbatch/link_wrf.csh for writing: $!";
print $FILE "#!/bin/csh -f \n";
print $FILE "sed -i 's/ nproc_x = 4/ nproc_x = -1/g' static/namelist.wrfm \n";
print $FILE "sed -i 's/ nproc_y = 16/ nproc_y = -1/g' static/namelist.wrfm \n";
print $FILE "ln -sf static/namelist.wrfm namelist.input \n";
print $FILE "echo '**** Run Wrf ****' \n";
close($FILE);
print $FILERM "rm -f namelist.input \n";
close($FILERM);
system "chmod 755 sbatch/link_wrf.csh sbatch/link_rm.csh sbatch/link_real.csh";
}
Last thing don't update because you will lose everything!
I hope that these instructions are clear. Next time I will show you examples of created scripts.
A big thanks to Pr. Robert Rozumalski for making all our lives easier with this precious tool.
Rachid