-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrf-partmc_run.sh
executable file
·158 lines (131 loc) · 5.53 KB
/
wrf-partmc_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
#SBATCH --job-name=wrf-partmc-les
#SBATCH --nodes=8
#SBATCH -n 384
#SBATCH --partition=sesempi
#SBATCH --time=96:00:00
#SBATCH --mem-per-cpu=5000
#SBATCH --mail-type=BEGIN
#SBATCH --mail-type=FAIL
#SBATCH --mail-type=END
#SBATCH [email protected]
# Initial condition and emission profile parameters
scenario='uniform-basecase'
#scenario='fx2fy2'
#scenario='fx1fy0'
#scenario='road-10x'
#scenario='point-source-10x10'
#scenario='point-source-1x1'
# Emission rates for aerosols, gases
EMISS_PATH=/data/keeling/a/sf20/b/wrf-partmc-spatial-het/WRFV3/test/em_les/emissions
gas_emiss_data_path=$EMISS_PATH/urbanplume_gas_emiss.csv
#gas_emiss_data_path=$EMISS_PATH/urbanplume_gas_emiss_no-ammonia.csv # SF 4/23/24: Run scenario with no ammonia gas emissions
aero_emiss_data_path=$EMISS_PATH/urbanplume_aero_emiss.csv
# Initial Conditions for aerosols, gases
IC_PATH=/data/keeling/a/sf20/b/wrf-partmc-spatial-het/WRFV3/test/em_les/initial-conditions
aero_ic_data_path=$IC_PATH/urbanplume_aero_ics.json
gas_ic_data_path=$IC_PATH/urbanplume_gas_ics.csv
#aero_ic_data_path=$IC_PATH/urbanplume_aero_ics_no-ammonium.json # SF 4/23/24: Run scenario with no initial ammonium in aerosol
#gas_ic_data_path=$IC_PATH/urbanplume_gas_ics_no-ammonia.csv # SF 4/23/24: Run scenario with no initial ammonia gas conc
# Sounding
SOUNDING_FILE=input_sounding_base
#SOUNDING_FILE=input_sounding_meanwind
# Path to WRF-LES simulation
SIM_PATH=/data/keeling/a/sf20/b/wrf-partmc-spatial-het/WRFV3/test/em_les
cd $SIM_PATH
#ARCHIVE_PATH=/data/nriemer/d/sf20/les_output/wrf-partmc
ARCHIVE_PATH=/data/keeling/a/sf20/e/wrf-partmc-gridded-output # SF 4/30/24: Add path for gridded output directory on E drive
OUTPUT_PATH=$ARCHIVE_PATH/slurm-$SLURM_JOB_ID
mkdir $OUTPUT_PATH
mkdir $OUTPUT_PATH/aero_emit_dists
mkdir $OUTPUT_PATH/ics
mkdir $OUTPUT_PATH/out2
cp $SIM_PATH/partmc-files/aero_data.dat $OUTPUT_PATH/aero_data.dat
cp $SIM_PATH/partmc-files/gas_data.dat $OUTPUT_PATH/gas_data.dat
cp $SIM_PATH/partmc-files/gas_params.csv $OUTPUT_PATH/gas_params.csv
cp $SIM_PATH/ideal.exe $OUTPUT_PATH/ideal.exe
cp $SIM_PATH/namelists-and-soundings/$SOUNDING_FILE $OUTPUT_PATH/input_sounding
cp $SIM_PATH/LANDUSE.TBL $OUTPUT_PATH/LANDUSE.TBL
cp $SIM_PATH/namelist.input $OUTPUT_PATH/namelist.input
cp $SIM_PATH/wrf.exe $OUTPUT_PATH/wrf.exe
cd $OUTPUT_PATH
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "Start : $timestamp"
echo ${run}
source ~/.bashrc
#free the system to have unlimited memory requests
ulimit -s -S unlimited
#make permissions group readable on output files
umask 022
#load libraries that you compiled with
module purge
module load gnu/hdf5-1.10.6-gnu-9.3.0
module load gnu/netcdf4-4.7.4-gnu-9.3.0
module load gnu/openmpi-3.1.6-gnu-9.3.0
export MKL_DEBUG_CPU_TYPE=5
export MKL_CBWR=COMPATIBLE
# Get simulation configuration (chemical mechanism, domain dimensions)
file_path="namelist.input"
# Loop through each line in the file
while IFS= read -r line; do
#echo $line
if [[ $line == *"chem_opt "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at chem_opt for domain 1
CHEM_OPT=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
echo "Using chemical mechanism: $CHEM_OPT"
fi
if [[ $line == *"s_we "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at domain 1
S_WE=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
fi
if [[ $line == *"e_we "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at domain 1
E_WE=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
fi
if [[ $line == *"s_sn "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at domain 1
S_SN=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
fi
if [[ $line == *"e_sn "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at domain 1
E_SN=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
fi
if [[ $line == *"s_vert "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at domain 1
S_VERT=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
fi
if [[ $line == *"e_vert "* ]]; then
line=$(echo "$line" | cut -d ',' -f 1) # only look at domain 1
E_VERT=$(echo "$line" | sed 's/[^0-9]*//g') # remove non-integer values
fi
done < "$file_path"
S_WE=$(expr $S_WE)
E_WE=$(expr $E_WE)
S_SN=$(expr $S_SN)
E_SN=$(expr $E_SN)
S_VERT=$(expr $S_VERT)
E_VERT=$(expr $E_VERT)
extent_we=$(expr $E_WE - $S_WE)
extent_sn=$(expr $E_SN - $S_SN)
extent_vert=$(expr $E_VERT - $S_VERT)
echo "Number of grid cells in west-east: $extent_we"
echo "Number of grid cells in south-north: $extent_sn"
echo "Number of grid cells in vertical: $extent_vert"
# set emissions (gases and aerosols)
python $SIM_PATH/create_aero_emit_dists.py $OUTPUT_PATH $scenario $extent_we $extent_sn $extent_vert $gas_emiss_data_path $aero_emiss_data_path
# set intial conditions (uniform distribution)
python $SIM_PATH/create_aero_ics.py $OUTPUT_PATH 'uniform-basecase' $extent_we $extent_sn $extent_vert $aero_ic_data_path
echo
time mpirun -np 8 ./ideal.exe
# set gas initial conditions
python $SIM_PATH/write_gas_ic_json.py $OUTPUT_PATH $CHEM_OPT $scenario $gas_ic_data_path
python $SIM_PATH/edit_wrfinput_initcond.py $OUTPUT_PATH $CHEM_OPT $extent_we $extent_sn $extent_vert $scenario
echo
time mpirun -np $SLURM_NPROCS ./wrf.exe
echo
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "End : $timestamp"
cp $SIM_PATH/slurm-$SLURM_JOB_ID.out $OUTPUT_PATH/slurm-$SLURM_JOB_ID.out
# move gridded output
mv $ARCHIVE_PATH/gridded-output*.nc $OUTPUT_PATH
rm $SIM_PATH/slurm-$SLURM_JOB_ID.out