-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.job
210 lines (166 loc) · 7.09 KB
/
template.job
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash -l
# redirect output
exec 3>&1
exec &> "@OUTDIR@/logfile.txt"
# host specific setup
host=$(hostname)
ip=$(hostname -i)
echo "Running on: " $host -- $ip
@HOST_SETUP@
# create output folder
mkdir -p "@OUTDIR@"
# flag needed for ubuntu
export GFORTRAN_UNBUFFERED_PRECONNECTED=yes
## Figure out where CIME SCRIPTS are installed
cd @REFCASE@
IFS=' ' read -ra SCRIPTROOT <<< `./xmlquery SCRIPTSROOT --value`
echo "CIME script root: "
echo ${SCRIPTROOT}
## Seem to be stuck having to build a new case. Will try and avoid this in the future
cd ${SCRIPTROOT}
echo "*** Run create_newcase ***"
echo " ----- Case details:"
echo @CASEDIR@
echo "Res: @RES@ "
echo "Compset: @COMPSET@ "
echo "Machine: @MACHINE@ "
echo "Compiler: @COMPILER@ "
echo "Project_name: @PROJECT@ "
echo "--------------------------"
./create_newcase --case @CASEDIR@ --res @RES@ --compset @COMPSET@ --mach @MACHINE@ --compiler @COMPILER@ --project @PROJECT@ --driver nuopc --run-unsupported
cd "@RUNDIR@"
## RECURSIVELY COPY/SYMLINK REFERENCE INPUTS DIRECTORY (DIN_LOC_ROOT)
## create folders and symbolic links. Links will later be deleted when non-default files are specified
mkdir input
echo "PEcAn.FATES::recurse.create('input','@DEFAULT@')" | R --vanilla
cd "@CASEDIR@"
## THINGS THAT ARE IN REFCASE
# Modifying : env_mach_pes.xml
echo "*** Modify XMLs ***"
## --- turning off these settings needs testing on other machines. Works on modex
#./xmlchange --file env_mach_pes.xml --id NTASKS_ATM --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_LND --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_ICE --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_OCN --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_CPL --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_GLC --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_ROF --val 1
#./xmlchange --file env_mach_pes.xml --id NTASKS_WAV --val 1
#./xmlchange --file env_mach_pes.xml --id MAX_TASKS_PER_NODE -val 1
#./xmlchange --file env_mach_pes.xml --id TOTALPES --val 1
## ---
# Modifying : env_build.xml
./xmlchange --file env_build.xml --id GMAKE --val make
./xmlchange --file env_build.xml --id DEBUG --val FALSE
# Modifying : env_run.xml
./xmlchange --file env_run.xml --id REST_N --val 1
./xmlchange --file env_run.xml --id REST_OPTION --val nyears
./xmlchange --file env_run.xml --id DATM_CLMNCEP_YR_START --val 1974 #Long term, may not want to have these set with a large range. Will require download
./xmlchange --file env_run.xml --id DATM_CLMNCEP_YR_END --val 2004 #Long term, may not want to have these set with a large range. Will require download
./xmlchange --file env_run.xml --id DIN_LOC_ROOT --val '@INDIR@'
./xmlchange --file env_run.xml --id DIN_LOC_ROOT_CLMFORC --val '@INDIR@/atm/datm7' # updated, needed?
./xmlchange --file env_run.xml --id DOUT_S --val TRUE
./xmlchange --file env_run.xml --id DOUT_S_ROOT --val '@CASEDIR@/run'
./xmlchange --file env_run.xml --id PIO_DEBUG_LEVEL --val 0
./xmlchange --file env_run.xml --id ATM_DOMAIN_FILE --val 'domain.lnd.@[email protected]'
./xmlchange --file env_run.xml --id ATM_DOMAIN_PATH --val '@INDIR@/share/domains/domain.clm/'
./xmlchange --file env_run.xml --id LND_DOMAIN_FILE --val 'domain.lnd.@[email protected]'
./xmlchange --file env_run.xml --id LND_DOMAIN_PATH --val '@INDIR@/share/domains/domain.clm/'
./xmlchange --file env_run.xml --id CLM_USRDAT_NAME --val '@SITE_NAME@'
## END REFCASE
## NEW_xmlchange"---------------"
./xmlchange CLM_USRDAT_DIR=/ctsm-api/resources/data/SOD1
./xmlchange PTS_LON=26.6385
./xmlchange PTS_LAT=67.3623
./xmlchange MPILIB=mpich # need rebuild
./xmlchange RUN_STARTDATE="2014-01-01"
./xmlchange STOP_OPTION="ndays"
./xmlchange STOP_N="365"
./xmlchange DATM_YR_START="2014"
./xmlchange DATM_YR_END="2014"
## "--------------------------"
## ENV_BUILD update configurations
./xmlchange --file env_build.xml --id CIME_OUTPUT_ROOT --val @CASEDIR@
./xmlchange --file env_build.xml --id EXEROOT --val @CASEDIR@/bld # temporary fix
## DATES -> ENV_RUN
./xmlchange --file env_run.xml --id RUNDIR --val @CASEDIR@/run
./xmlchange --file env_run.xml --id RUN_STARTDATE --val @START_DATE@
./xmlchange --file env_run.xml --id STOP_OPTION --val ndays
./xmlchange --file env_run.xml --id STOP_N --val @STOP_N@
./xmlchange --id CLM_FORCE_COLDSTART --val on
## SITE INFO --> DOMAIN FILE
rm @INDIR@/share/domains/domain.clm/*
ln -s @RUNDIR@/domain.lnd.@[email protected] @INDIR@/share/domains/domain.clm/
## SURFDATA
rm @INDIR@/lnd/clm2/surfdata_map/surfdata*
ln -s @RUNDIR@/surfdata_@SITE_NAME@_simyr2000.nc @INDIR@/lnd/clm2/surfdata_map/
# update namelist
cat >> user_nl_clm << EOF
fsurdat = '@INDIR@/lnd/clm2/surfdata_map/surfdata_@SITE_NAME@_simyr2000.nc'
EOF
## PARAMETERS
rm @INDIR@/lnd/clm2/paramdata/*
ln -s @RUNDIR@/clm_params.@[email protected] @INDIR@/lnd/clm2/paramdata/
ln -s @RUNDIR@/fates_params.@[email protected] @INDIR@/lnd/clm2/paramdata/
# update namelist
cat >> user_nl_clm << EOF
fates_paramfile = '@INDIR@/lnd/clm2/paramdata/fates_params.@[email protected]'
paramfile = '@INDIR@/lnd/clm2/paramdata/clm_params.@[email protected]'
EOF
## APPLY CONFIG CHANGES
echo "*** Run case.setup ***"
./case.setup
## Define CLM-FATES outputs for the run
cat >> user_nl_clm <<EOF
hist_empty_htapes = .true.
hist_fincl1='NEP','NPP','GPP','TLAI','TSOI_10CM','QVEGT','EFLX_LH_TOT','AR','HR','ED_biomass','ED_bleaf','ED_balive','DDBH_SCPF','BA_SCPF','NPLANT_SCPF','M1_SCPF','M2_SCPF','M3_SCPF','M4_SCPF','M5_SCPF','M6_SCPF','GPP_BY_AGE','PATCH_AREA_BY_AGE','CANOPY_AREA_BY_AGE','BA_SCLS','NPLANT_CANOPY_SCLS','NPLANT_UNDERSTORY_SCLS','DDBH_CANOPY_SCLS','DDBH_UNDERSTORY_SCLS','MORTALITY_CANOPY_SCLS','MORTALITY_UNDERSTORY_SCLS','WIND','ZBOT','FSDS','RH','TBOT','PBOT','QBOT','RAIN','FLDS'
hist_mfilt = 8760
hist_nhtfrq = -1
EOF
echo "*** Run case.build ***"
sleep 10
./case.build # ! Long run, we should not be building the model. But current BUILD_COMPLETE doesn't seem to be working !
sleep 10
## RUN
echo "*** Run ***"
now=`date`
echo "Simulation start: $now"
cd run
mkdir timing
echo `pwd`
echo `ls -altr`
## ----------- Disabled for now
## RUNDIR FILE LINKS -- CURRENTLY GETTING SEG FAULTS WHEN TRYING TO RUN WITH PECAN MET
#if [ -e @RUNDIR@/datm_atm_in ]
# then
# rm datm_atm_in datm_in
# ln -s @RUNDIR@/datm_atm_in .
# ln -s @RUNDIR@/datm_atm_in datm_in
#fi
#if [ -e @RUNDIR@/datm.streams.txt.PEcAn_met ]
# then
#rm datm.stream.txt.CLM_QIAN*
# rm datm.streams.txt.CLM_QIAN* # bug fix, s was missing!
# ln -s @RUNDIR@/datm.streams.txt.PEcAn_met .
#fi
## ------------- MET needs to be re-enabled in a later PR
"@CASEDIR@/bld/cesm.exe"
STATUS=$?
# check the status
if [ $STATUS -ne 0 ]; then
echo -e "ERROR IN MODEL RUN\nLogfile is located at '@OUTDIR@/logfile.txt'" >&3
exit $STATUS
fi
# host specific post-run
@HOST_TEARDOWN@
# convert output
cp *clm2.h0.*.nc @OUTDIR@
echo "library(PEcAn.FATES); model2netcdf.FATES('@OUTDIR@')" | R --vanilla
# copy readme with specs to output
cp "@RUNDIR@/README.txt" "@OUTDIR@/README.txt"
# write tag so future execution knows run finished
echo $(date) >> "@OUTDIR@/pecan.done"
sleep 60
# all done
echo -e "MODEL FINISHED\nLogfile is located at '@OUTDIR@/logfile.txt'" >&3
# DONE