-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added control scripts. To run the test case: - go to config/vort2d_testcase and make changes, choose config/env/localhost and change inside the paths accordingly - set -a; . config/vort2d_testcase - run truth simulation by "cd models/vort2d; ./run_forecast.sh truth" - run cycling by "cd scripts; ./run_cycle.sh" - monitor job status by "cd scripts; ./jstat" - go to $SCRATCH/vort2d_testcase/cycle... to see results
- Loading branch information
Showing
24 changed files
with
487 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#!/bin/bash | ||
host=betzy | ||
hostppn=128 | ||
|
||
nnodes=$SLURM_NNODES | ||
ntasks=$SLURM_NTASKS | ||
tasks_per_node=128 | ||
|
||
SCRATCH=/cluster/work/users/yingyue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ulimit -s 2000000 | ||
|
||
# Load the right modules | ||
module --force purge | ||
ml load StdEnv | ||
ml load GCCcore/12.3.0 | ||
ml load Python/3.11.3-GCCcore-12.3.0 | ||
ml load FFTW/3.3.10-GCC-12.3.0 | ||
ml load impi/2021.9.0-intel-compilers-2023.1.0 | ||
|
||
export PYTHONPATH=$PYTHONPATH:$HOME/code/NEDAS | ||
|
||
|
||
##enter the project env | ||
source $HOME/yp/bin/activate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#!/bin/bash | ||
|
||
host=localhost | ||
hostppn=4 | ||
|
||
nnodes=1 | ||
ntasks=4 | ||
tasks_per_node=4 | ||
|
||
SCRATCH=/Users/yueng/scratch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import numpy as np | ||
import models.vort2d as model | ||
import config as c | ||
import sys | ||
from conversion import s2t | ||
|
||
time = s2t(sys.argv[1]) | ||
|
||
##input random seed is provided, set it | ||
if len(sys.argv) > 2: | ||
np.random.seed(int(sys.argv[2])) | ||
|
||
state = model.initialize(c.grid, model.Vmax, model.Rmw, model.Vbg, model.Vslope) | ||
|
||
model.write_var('./', c.grid, state, name='velocity', is_vector=True, time=time) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
. $config_file | ||
rundir=$work_dir/cycle/$time/vort2d | ||
if [[ ! -d $rundir ]]; then mkdir -p $rundir; echo waiting > $rundir/stat; fi | ||
|
||
cd $rundir | ||
if [[ `cat stat` == "complete" ]]; then exit; fi | ||
|
||
##check dependency | ||
if [[ $time == $time_start ]]; then wait_for_module ../perturb; fi | ||
if [[ $time -gt $time_start ]]; then | ||
if $run_assim; then | ||
wait_for_module ../analysis | ||
else | ||
wait_for_module ../../$prev_time/vort2d | ||
fi | ||
fi | ||
|
||
echo running > stat | ||
|
||
echo " Running ensemble forecast for vort2d model..." | ||
|
||
##load env if necessary | ||
src_file=$script_dir/../config/env/$host/vort2d.src | ||
if [[ -f $src_file ]]; then source $src_file; fi | ||
|
||
tid=0 | ||
nt=$ntasks | ||
for m in `seq 1 $nens`; do | ||
m_id=`padzero $m 3` | ||
if [[ ! -d $m_id ]]; then mkdir -p $m_id; fi | ||
touch $m_id/run.log | ||
|
||
##run the model for member m | ||
cd $m_id | ||
|
||
##link files for model run | ||
mv ../${time:0:8}_${time:8:2}_mem$m_id.nc . | ||
|
||
$script_dir/job_submit.sh 1 1 0 python $script_dir/../models/vort2d/run.py $time $m >& run.log & | ||
|
||
cd .. | ||
|
||
##wait if ntasks processors are all in use | ||
tid=$((tid+1)) | ||
if [[ $tid == $nt ]]; then tid=0; wait; fi | ||
|
||
done | ||
wait | ||
|
||
nextdir=$work_dir/cycle/$next_time/vort2d | ||
if [[ ! -d $nextdir ]]; then mkdir -p $nextdir; fi | ||
|
||
##collect output files, make a copy of forecast files to next cycle | ||
for m in `seq 1 $nens`; do | ||
m_id=`padzero $m 3` | ||
|
||
watch_log $m_id/run.log successfully 5 $rundir | ||
|
||
mv $m_id/${next_time:0:8}_${next_time:8:2}_mem$m_id.nc . | ||
cp -L ${next_time:0:8}_${next_time:8:2}_mem$m_id.nc $nextdir/. | ||
done | ||
wait | ||
|
||
echo complete > stat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
. $config_file | ||
rundir=$work_dir/cycle/$time/vort2d | ||
if [[ ! -d $rundir ]]; then mkdir -p $rundir; echo waiting > $rundir/stat; fi | ||
|
||
cd $rundir | ||
if [[ `cat stat` == "complete" ]]; then exit; fi | ||
|
||
##check dependency | ||
if [[ $time == $time_start ]]; then wait_for_module ../icbc; fi | ||
|
||
echo running > stat | ||
|
||
echo " Running forecast for vort2d model..." | ||
|
||
##load env if necessary | ||
src_file=$script_dir/../config/env/$host/vort2d.src | ||
if [[ -f $src_file ]]; then source $src_file; fi | ||
|
||
touch run.log | ||
|
||
$script_dir/job_submit.sh 1 1 0 python $script_dir/../models/vort2d/run.py $time >& run.log | ||
|
||
nextdir=$work_dir/cycle/$next_time/vort2d | ||
if [[ ! -d $nextdir ]]; then mkdir -p $nextdir; fi | ||
|
||
watch_log run.log successfully 5 $rundir | ||
|
||
cp -L ${next_time:0:8}_${next_time:8:2}.nc $nextdir/. | ||
|
||
echo complete > stat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
. $config_file | ||
|
||
if [[ $time -gt $time_start ]]; then exit; fi | ||
|
||
rundir=$work_dir/cycle/$time/icbc | ||
if [[ ! -d $rundir ]]; then mkdir -p $rundir; echo waiting > $rundir/stat; fi | ||
|
||
cd $rundir | ||
if [[ `cat stat` == "complete" ]]; then exit; fi | ||
|
||
echo running > stat | ||
|
||
echo " Generating initial and boundary conditions..." | ||
|
||
##load env if necessary | ||
src_file=$script_dir/../config/env/$host/vort2d.src | ||
if [[ -f $src_file ]]; then source $src_file; fi | ||
|
||
$script_dir/job_submit.sh 1 1 0 python $script_dir/../models/vort2d/generate_ic.py $time >& icbc.log | ||
|
||
##check output | ||
icfile=${time:0:8}_${time:8:2}.nc | ||
watch_file $icfile 5 $rundir | ||
|
||
if [[ ! -d ../vort2d ]]; then mkdir -p ../vort2d; fi | ||
mv $icfile ../vort2d/. | ||
|
||
echo complete > stat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
. $config_file | ||
|
||
if [[ $time -gt $time_start ]]; then exit; fi | ||
|
||
rundir=$work_dir/cycle/$time/perturb | ||
if [[ ! -d $rundir ]]; then mkdir -p $rundir; echo waiting > $rundir/stat; fi | ||
|
||
cd $rundir | ||
if [[ `cat stat` == "complete" ]]; then exit; fi | ||
|
||
echo running > stat | ||
|
||
echo " Generating perturbed ensemble members..." | ||
|
||
##load env if necessary | ||
src_file=$script_dir/../config/env/$host/vort2d.src | ||
if [[ -f $src_file ]]; then source $src_file; fi | ||
|
||
$script_dir/job_submit.sh 1 1 0 python $script_dir/../models/vort2d/perturb_ic.py $time $nens >& perturb.log | ||
|
||
if [[ ! -d ../vort2d ]]; then mkdir -p ../vort2d; fi | ||
|
||
##check output | ||
for m in `seq 1 $nens`; do | ||
m_id=`padzero $m 3` | ||
|
||
icfile=${time:0:8}_${time:8:2}_mem$m_id.nc | ||
watch_file $icfile 1 $rundir | ||
|
||
mv $icfile ../vort2d/. | ||
done | ||
|
||
echo complete > stat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import numpy as np | ||
import models.vort2d as model | ||
import config as c | ||
import sys | ||
from conversion import s2t | ||
|
||
time = s2t(sys.argv[1]) | ||
nens = int(sys.argv[2]) | ||
|
||
for m in range(nens): | ||
state = model.initialize(c.grid, model.Vmax, model.Rmw, model.Vbg, model.Vslope, loc_sprd=model.loc_sprd) | ||
|
||
model.write_var('./', c.grid, state, name='velocity', is_vector=True, time=time, member=m) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
##run forecast using the vort2d model | ||
##this program is mimicking the run script of a real model, it is called by | ||
##top level control script run_cycle.sh to spawm several runs simultaneously | ||
##as if running ensemble forecasts | ||
|
||
import numpy as np | ||
import sys | ||
from datetime import datetime, timedelta | ||
import config as c | ||
import models.vort2d as model | ||
from conversion import s2t, t2s | ||
|
||
##current cycle time | ||
time = s2t(sys.argv[1]) | ||
|
||
##member index, start from 0 | ||
if len(sys.argv) > 2: | ||
mem_id = int(sys.argv[2]) - 1 | ||
else: | ||
mem_id = None | ||
|
||
##time at next cycle, where current forecast will end | ||
next_time = time + timedelta(hours=1) * c.cycle_period | ||
|
||
path = './' | ||
|
||
##read the initial condition | ||
state = model.read_var(path, c.grid, name='velocity', is_vector=True, time=time, member=mem_id) | ||
|
||
t = time | ||
print('vort2d model forecast start at', t) | ||
while t < next_time: | ||
t += timedelta(hours=1) * model.restart_dt | ||
|
||
##run the model | ||
state = model.advance_time(state, model.dx, model.restart_dt, model.dt, model.gen, model.diss) | ||
|
||
##save restart file | ||
model.write_var(path, c.grid, state, name='velocity', is_vector=True, time=t, member=mem_id) | ||
|
||
print(t) | ||
|
||
print('vort2d model forecast finished successfully') | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.