-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
2771 lines (2672 loc) · 98.3 KB
/
setup.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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
#-----------------------------------------------------------------------
#
# This file defines and then calls a function that sets a secondary set
# of parameters needed by the various scripts that are called by the
# FV3-LAM rocoto community workflow. This secondary set of parameters is
# calculated using the primary set of user-defined parameters in the de-
# fault and custom experiment/workflow configuration scripts (whose file
# names are defined below). This script then saves both sets of parame-
# ters in a global variable definitions file (really a bash script) in
# the experiment directory. This file then gets sourced by the various
# scripts called by the tasks in the workflow.
#
#-----------------------------------------------------------------------
#
function setup() {
#
#-----------------------------------------------------------------------
#
# Get the full path to the file in which this script/function is located
# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in
# which the file is located (scrfunc_dir).
#
#-----------------------------------------------------------------------
#
local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" )
local scrfunc_fn=$( basename "${scrfunc_fp}" )
local scrfunc_dir=$( dirname "${scrfunc_fp}" )
#
#-----------------------------------------------------------------------
#
# Get the name of this function.
#
#-----------------------------------------------------------------------
#
local func_name="${FUNCNAME[0]}"
#
#-----------------------------------------------------------------------
#
#
#
#-----------------------------------------------------------------------
#
USHdir="${scrfunc_dir}"
#
#-----------------------------------------------------------------------
#
# Source bash utility functions.
#
#-----------------------------------------------------------------------
#
. $USHdir/source_util_funcs.sh
#
#-----------------------------------------------------------------------
#
# Source other necessary files.
#
#-----------------------------------------------------------------------
#
. $USHdir/set_cycle_dates.sh
. $USHdir/set_gridparams_GFDLgrid.sh
. $USHdir/set_gridparams_ESGgrid.sh
. $USHdir/link_fix.sh
. $USHdir/set_ozone_param.sh
. $USHdir/set_thompson_mp_fix_files.sh
. $USHdir/check_ruc_lsm.sh
#
#-----------------------------------------------------------------------
#
# Save current shell options (in a global array). Then set new options
# for this script/function.
#
#-----------------------------------------------------------------------
#
{ save_shell_opts; set -u +x; } > /dev/null 2>&1
#
#-----------------------------------------------------------------------
#
# Set the name of the configuration file containing default values for
# the experiment/workflow variables. Then source the file.
#
#-----------------------------------------------------------------------
#
EXPT_DEFAULT_CONFIG_FN="config_defaults.sh"
. $USHdir/${EXPT_DEFAULT_CONFIG_FN}
#
#-----------------------------------------------------------------------
#
# If a user-specified configuration file exists, source it. This file
# contains user-specified values for a subset of the experiment/workflow
# variables that override their default values. Note that the user-
# specified configuration file is not tracked by the repository, whereas
# the default configuration file is tracked.
#
#-----------------------------------------------------------------------
#
if [ -f "${EXPT_CONFIG_FN}" ]; then
#
# We require that the variables being set in the user-specified configu-
# ration file have counterparts in the default configuration file. This
# is so that we do not introduce new variables in the user-specified
# configuration file without also officially introducing them in the de-
# fault configuration file. Thus, before sourcing the user-specified
# configuration file, we check that all variables in the user-specified
# configuration file are also assigned default values in the default
# configuration file.
#
. $USHdir/compare_config_scripts.sh
#
# Now source the user-specified configuration file.
#
. $USHdir/${EXPT_CONFIG_FN}
#
fi
#
#-----------------------------------------------------------------------
#
# Source the script defining the valid values of experiment variables.
#
#-----------------------------------------------------------------------
#
. $USHdir/valid_param_vals.sh
#
#-----------------------------------------------------------------------
#
# Make sure that VERBOSE is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "VERBOSE" "valid_vals_VERBOSE"
#
# Set VERBOSE to either "TRUE" or "FALSE" so we don't have to consider
# other valid values later on.
#
VERBOSE=${VERBOSE^^}
if [ "$VERBOSE" = "TRUE" ] || \
[ "$VERBOSE" = "YES" ]; then
VERBOSE="TRUE"
elif [ "$VERBOSE" = "FALSE" ] || \
[ "$VERBOSE" = "NO" ]; then
VERBOSE="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that USE_CRON_TO_RELAUNCH is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "USE_CRON_TO_RELAUNCH" "valid_vals_USE_CRON_TO_RELAUNCH"
#
# Set USE_CRON_TO_RELAUNCH to either "TRUE" or "FALSE" so we don't have to consider
# other valid values later on.
#
USE_CRON_TO_RELAUNCH=${USE_CRON_TO_RELAUNCH^^}
if [ "${USE_CRON_TO_RELAUNCH}" = "TRUE" ] || \
[ "${USE_CRON_TO_RELAUNCH}" = "YES" ]; then
USE_CRON_TO_RELAUNCH="TRUE"
elif [ "${USE_CRON_TO_RELAUNCH}" = "FALSE" ] || \
[ "${USE_CRON_TO_RELAUNCH}" = "NO" ]; then
USE_CRON_TO_RELAUNCH="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that RUN_TASK_MAKE_GRID is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "RUN_TASK_MAKE_GRID" "valid_vals_RUN_TASK_MAKE_GRID"
#
# Set RUN_TASK_MAKE_GRID to either "TRUE" or "FALSE" so we don't have to
# consider other valid values later on.
#
RUN_TASK_MAKE_GRID=${RUN_TASK_MAKE_GRID^^}
if [ "${RUN_TASK_MAKE_GRID}" = "TRUE" ] || \
[ "${RUN_TASK_MAKE_GRID}" = "YES" ]; then
RUN_TASK_MAKE_GRID="TRUE"
elif [ "${RUN_TASK_MAKE_GRID}" = "FALSE" ] || \
[ "${RUN_TASK_MAKE_GRID}" = "NO" ]; then
RUN_TASK_MAKE_GRID="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that RUN_TASK_MAKE_OROG is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "RUN_TASK_MAKE_OROG" "valid_vals_RUN_TASK_MAKE_OROG"
#
# Set RUN_TASK_MAKE_OROG to either "TRUE" or "FALSE" so we don't have to
# consider other valid values later on.
#
RUN_TASK_MAKE_OROG=${RUN_TASK_MAKE_OROG^^}
if [ "${RUN_TASK_MAKE_OROG}" = "TRUE" ] || \
[ "${RUN_TASK_MAKE_OROG}" = "YES" ]; then
RUN_TASK_MAKE_OROG="TRUE"
elif [ "${RUN_TASK_MAKE_OROG}" = "FALSE" ] || \
[ "${RUN_TASK_MAKE_OROG}" = "NO" ]; then
RUN_TASK_MAKE_OROG="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that RUN_TASK_MAKE_SFC_CLIMO is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value \
"RUN_TASK_MAKE_SFC_CLIMO" "valid_vals_RUN_TASK_MAKE_SFC_CLIMO"
#
# Set RUN_TASK_MAKE_SFC_CLIMO to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
RUN_TASK_MAKE_SFC_CLIMO=${RUN_TASK_MAKE_SFC_CLIMO^^}
if [ "${RUN_TASK_MAKE_SFC_CLIMO}" = "TRUE" ] || \
[ "${RUN_TASK_MAKE_SFC_CLIMO}" = "YES" ]; then
RUN_TASK_MAKE_SFC_CLIMO="TRUE"
elif [ "${RUN_TASK_MAKE_SFC_CLIMO}" = "FALSE" ] || \
[ "${RUN_TASK_MAKE_SFC_CLIMO}" = "NO" ]; then
RUN_TASK_MAKE_SFC_CLIMO="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that RUN_TASK_RUN_PRDGEN is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value \
"RUN_TASK_RUN_PRDGEN" "valid_vals_RUN_TASK_RUN_PRDGEN"
#
# Set RUN_TASK_RUN_PRDGEN to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
RUN_TASK_RUN_PRDGEN=${RUN_TASK_RUN_PRDGEN^^}
if [ "${RUN_TASK_RUN_PRDGEN}" = "TRUE" ] || \
[ "${RUN_TASK_RUN_PRDGEN}" = "YES" ]; then
RUN_TASK_RUN_PRDGEN="TRUE"
elif [ "${RUN_TASK_RUN_PRDGEN}" = "FALSE" ] || \
[ "${RUN_TASK_RUN_PRDGEN}" = "NO" ]; then
RUN_TASK_RUN_PRDGEN="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that DO_SHUM is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "DO_SHUM" "valid_vals_DO_SHUM"
#
# Set DO_SHUM to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
DO_SHUM=${DO_SHUM^^}
if [ "${DO_SHUM}" = "TRUE" ] || \
[ "${DO_SHUM}" = "YES" ]; then
DO_SHUM="TRUE"
elif [ "${DO_SHUM}" = "FALSE" ] || \
[ "${DO_SHUM}" = "NO" ]; then
DO_SHUM="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that DO_SPPT is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "DO_SPPT" "valid_vals_DO_SPPT"
#
# Set DO_SPPT to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
DO_SPPT=${DO_SPPT^^}
if [ "${DO_SPPT}" = "TRUE" ] || \
[ "${DO_SPPT}" = "YES" ]; then
DO_SPPT="TRUE"
elif [ "${DO_SPPT}" = "FALSE" ] || \
[ "${DO_SPPT}" = "NO" ]; then
DO_SPPT="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that DO_SPP is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "DO_SPP" "valid_vals_DO_SPP"
#
# Set DO_SPP to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
DO_SPP=${DO_SPP^^}
if [ "${DO_SPP}" = "TRUE" ] || \
[ "${DO_SPP}" = "YES" ]; then
DO_SPP="TRUE"
elif [ "${DO_SPP}" = "FALSE" ] || \
[ "${DO_SPP}" = "NO" ]; then
DO_SPP="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that DO_LSM_SPP is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "DO_LSM_SPP" "valid_vals_DO_LSM_SPP"
#
# Set DO_LSM_SPP to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
DO_LSM_SPP=${DO_LSM_SPP^^}
if [ "${DO_LSM_SPP}" = "TRUE" ] || \
[ "${DO_LSM_SPP}" = "YES" ]; then
DO_LSM_SPP="TRUE"
elif [ "${DO_LSM_SPP}" = "FALSE" ] || \
[ "${DO_LSM_SPP}" = "NO" ]; then
DO_LSM_SPP="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that DO_SKEB is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "DO_SKEB" "valid_vals_DO_SKEB"
#
# Set DO_SKEB to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
DO_SKEB=${DO_SKEB^^}
if [ "${DO_SKEB}" = "TRUE" ] || \
[ "${DO_SKEB}" = "YES" ]; then
DO_SKEB="TRUE"
elif [ "${DO_SKEB}" = "FALSE" ] || \
[ "${DO_SKEB}" = "NO" ]; then
DO_SKEB="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Set magnitude of stochastic ad-hoc schemes to -999.0 if they are not
# being used. This is required at the moment, since "do_shum/sppt/skeb"
# does not override the use of the scheme unless the magnitude is also
# specifically set to -999.0. If all "do_shum/sppt/skeb" are set to
# "false," then none will run, regardless of the magnitude values.
#
#-----------------------------------------------------------------------
#
if [ "${DO_SHUM}" = "FALSE" ]; then
SHUM_MAG=-999.0
fi
if [ "${DO_SKEB}" = "FALSE" ]; then
SKEB_MAG=-999.0
fi
if [ "${DO_SPPT}" = "FALSE" ]; then
SPPT_MAG=-999.0
fi
#
#-----------------------------------------------------------------------
#
# If running with SPP in MYNN PBL, MYNN SFC, GSL GWD, Thompson MP, or
# RRTMG, count the number of entries in SPP_VAR_LIST to correctly set
# N_VAR_SPP, otherwise set it to zero.
#
#-----------------------------------------------------------------------
#
N_VAR_SPP=0
if [ "${DO_SPP}" = "TRUE" ]; then
N_VAR_SPP=${#SPP_VAR_LIST[@]}
fi
#
#-----------------------------------------------------------------------
#
# If running with Noah or RUC-LSM SPP, count the number of entries in
# LSM_SPP_VAR_LIST to correctly set N_VAR_LNDP, otherwise set it to zero.
# Also set LNDP_TYPE to 2 for LSM SPP, otherwise set it to zero. Finally,
# initialize an "FHCYC_LSM_SPP" variable to 0 and set it to 999 if LSM SPP
# is turned on. This requirement is necessary since LSM SPP cannot run with
# FHCYC=0 at the moment, but FHCYC cannot be set to anything less than the
# length of the forecast either. A bug fix will be submitted to
# ufs-weather-model soon, at which point, this requirement can be removed
# from regional_workflow.
#
#-----------------------------------------------------------------------
#
N_VAR_LNDP=0
LNDP_TYPE=0
FHCYC_LSM_SPP_OR_NOT=0
if [ "${DO_LSM_SPP}" = "TRUE" ]; then
N_VAR_LNDP=${#LSM_SPP_VAR_LIST[@]}
LNDP_TYPE=2
FHCYC_LSM_SPP_OR_NOT=0
fi
#
#-----------------------------------------------------------------------
#
# If running with SPP, confirm that each SPP-related namelist value
# contains the same number of entries as N_VAR_SPP (set above to be equal
# to the number of entries in SPP_VAR_LIST).
#
#-----------------------------------------------------------------------
#
if [ "${DO_SPP}" = "TRUE" ]; then
if [ "${#SPP_MAG_LIST[@]}" != "${N_VAR_SPP}" ] || \
[ "${#SPP_LSCALE[@]}" != "${N_VAR_SPP}" ] || \
[ "${#SPP_TSCALE[@]}" != "${N_VAR_SPP}" ] || \
[ "${#SPP_SIGTOP1[@]}" != "${N_VAR_SPP}" ] || \
[ "${#SPP_SIGTOP2[@]}" != "${N_VAR_SPP}" ] || \
[ "${#SPP_STDDEV_CUTOFF[@]}" != "${N_VAR_SPP}" ] || \
[ "${#ISEED_SPP[@]}" != "${N_VAR_SPP}" ]; then
print_err_msg_exit "\
All MYNN PBL, MYNN SFC, GSL GWD, Thompson MP, or RRTMG SPP-related namelist
variables set in ${CONFIG_FN} must be equal in number of entries to what is
found in SPP_VAR_LIST:
Number of entries in SPP_VAR_LIST = \"${#SPP_VAR_LIST[@]}\""
fi
fi
#
#-----------------------------------------------------------------------
#
# If running with LSM SPP, confirm that each LSM SPP-related namelist
# value contains the same number of entries as N_VAR_LNDP (set above to
# be equal to the number of entries in LSM_SPP_VAR_LIST).
#
#-----------------------------------------------------------------------
#
if [ "${DO_LSM_SPP}" = "TRUE" ]; then
if [ "${#LSM_SPP_MAG_LIST[@]}" != "${N_VAR_LNDP}" ]; then
print_err_msg_exit "\
All Noah or RUC-LSM SPP-related namelist variables (except ISEED_LSM_SPP)
set in ${CONFIG_FN} must be equal in number of entries to what is found in
SPP_VAR_LIST:
Number of entries in SPP_VAR_LIST = \"${#LSM_SPP_VAR_LIST[@]}\""
fi
fi
#
#-----------------------------------------------------------------------
#
# Make sure that USE_FVCOM is set to a valid value and assign directory
# and file names.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "USE_FVCOM" "valid_vals_USE_FVCOM"
#
# Set USE_FVCOM to either "TRUE" or "FALSE" so we don't have to consider
# other valid values later on.
#
USE_FVCOM=${USE_FVCOM^^}
if [ "$USE_FVCOM" = "TRUE" ] || \
[ "$USE_FVCOM" = "YES" ]; then
USE_FVCOM="TRUE"
elif [ "$USE_FVCOM" = "FALSE" ] || \
[ "$USE_FVCOM" = "NO" ]; then
USE_FVCOM="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that DOT_OR_USCORE is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "DOT_OR_USCORE" "valid_vals_DOT_OR_USCORE"
#
#-----------------------------------------------------------------------
#
# Make sure the following options are set to a valid value.
# Convert YES/yes/true to TRUE and NO/no/false to FALSE
#
#-----------------------------------------------------------------------
#
optionList[0]=DO_DACYCLE
optionList[1]=DO_SURFACE_CYCLE
optionList[2]=DO_RETRO
optionList[3]=LBCS_ICS_ONLY
optionList[4]=DO_NONVAR_CLDANAL
optionList[5]=DO_REFL2TTEN
optionList[6]=SAVE_CYCLE_LOG
optionList[7]=DO_SOIL_ADJUST
optionList[8]=DO_UPDATE_BC
optionList[9]=DO_RADDA
optionList[10]=DO_RECENTER
optionList[11]=DO_BUFRSND
optionList[12]=USE_RRFSE_ENS
optionList[13]=DO_JEDI_ENVAR_IODA
optionList[14]=DO_SMOKE_DUST
optionList[15]=DO_POST_PROD
optionList[16]=DO_POST_SPINUP
optionList[17]=DO_PARALLEL_PRDGEN
optionList[18]=DO_ENSEMBLE
optionList[19]=DO_ENSINIT
optionList[20]=DO_ENSFCST
optionList[21]=DO_SAVE_INPUT
optionList[22]=DO_SAVE_DA_OUTPUT
optionList[23]=DO_ENS_RADDA
optionList[24]=DO_GSIDIAG_OFFLINE
optionList[25]=USE_CLM
optionList[26]=DO_PM_DA
optionList[27]=DO_ENSFCST_MULPHY
optionList[28]=DO_GLM_FED_DA
optionList[29]=GLMFED_DATA_MODE
optionList[30]=EBB_DCYCLE
obs_number=${#optionList[@]}
for (( i=0; i<${obs_number}; i++ ));
do
value2check=${optionList[$i]}
check_var_valid_value "$value2check" "valid_vals_$value2check"
eval value2change=\$$value2check
value2change=${value2change^^}
if [ "${value2change}" = "TRUE" ] ||
[ "${value2change}" = "YES" ]; then
value2change="TRUE"
elif [ "${value2change}" = "FALSE" ] ||
[ "${value2change}" = "NO" ]; then
value2change="FALSE"
fi
eval ${value2check}=${value2change}
done
#
#-----------------------------------------------------------------------
#
# Convert machine name to upper case if necessary. Then make sure that
# MACHINE is set to a valid value.
#
#-----------------------------------------------------------------------
#
MACHINE=$( printf "%s" "$MACHINE" | sed -e 's/\(.*\)/\U\1/' )
check_var_valid_value "MACHINE" "valid_vals_MACHINE"
#
#-----------------------------------------------------------------------
#
# Set the number of cores per node, the job scheduler, and the names of
# several queues. These queues are defined in the default and local
# workflow/experiment configuration script.
#
#-----------------------------------------------------------------------
#
case $MACHINE in
"WCOSS2")
NCORES_PER_NODE=128
SCHED="pbspro"
QUEUE_DEFAULT=${QUEUE_DEFAULT:-"dev"}
QUEUE_HPSS=${QUEUE_HPSS:-"dev_transfer"}
QUEUE_FCST=${QUEUE_FCST:-"dev"}
QUEUE_ANALYSIS=${QUEUE_ANALYSIS:-"dev"}
QUEUE_PRDGEN=${QUEUE_PRDGEN:-"dev"}
QUEUE_POST=${QUEUE_POST:-"dev"}
;;
"HERA")
NCORES_PER_NODE=40
SCHED="${SCHED:-slurm}"
PARTITION_DEFAULT=${PARTITION_DEFAULT:-"hera"}
QUEUE_DEFAULT=${QUEUE_DEFAULT:-"batch"}
PARTITION_HPSS=${PARTITION_HPSS:-"service"}
QUEUE_HPSS=${QUEUE_HPSS:-"batch"}
PARTITION_FCST=${PARTITION_FCST:-"hera"}
QUEUE_FCST=${QUEUE_FCST:-"batch"}
QUEUE_PRDGEN=${QUEUE_PRDGEN:-"batch"}
QUEUE_POST=${QUEUE_POST:-"batch"}
;;
"ORION")
NCORES_PER_NODE=40
SCHED="${SCHED:-slurm}"
PARTITION_DEFAULT=${PARTITION_DEFAULT:-"orion"}
QUEUE_DEFAULT=${QUEUE_DEFAULT:-"batch"}
PARTITION_HPSS=${PARTITION_HPSS:-"service"}
QUEUE_HPSS=${QUEUE_HPSS:-"batch"}
PARTITION_FCST=${PARTITION_FCST:-"orion"}
QUEUE_FCST=${QUEUE_FCST:-"batch"}
;;
"HERCULES")
NCORES_PER_NODE=40
SCHED="${SCHED:-slurm}"
PARTITION_DEFAULT=${PARTITION_DEFAULT:-"hercules"}
QUEUE_DEFAULT=${QUEUE_DEFAULT:-"batch"}
PARTITION_HPSS=${PARTITION_HPSS:-"service"}
QUEUE_HPSS=${QUEUE_HPSS:-"batch"}
PARTITION_FCST=${PARTITION_FCST:-"hercules"}
QUEUE_FCST=${QUEUE_FCST:-"batch"}
;;
"JET")
NCORES_PER_NODE=${NCORES_PER_NODE}
SCHED="${SCHED:-slurm}"
PARTITION_DEFAULT=${PARTITION_DEFAULT:-"sjet,vjet,kjet,xjet"}
QUEUE_DEFAULT=${QUEUE_DEFAULT:-"batch"}
PARTITION_HPSS=${PARTITION_HPSS:-"service"}
QUEUE_HPSS=${QUEUE_HPSS:-"batch"}
PARTITION_FCST=${PARTITION_FCST:-"sjet,vjet,kjet,xjet"}
QUEUE_FCST=${QUEUE_FCST:-"batch"}
PARTITION_GRAPHICS=${PARTITION_GRAPHICS:-"kjet,xjet"}
QUEUE_GRAPHICS=${QUEUE_GRAPHICS:-"batch"}
PARTITION_ANALYSIS=${PARTITION_ANALYSIS:-"vjet,kjet,xjet"}
QUEUE_ANALYSIS=${QUEUE_ANALYSIS:-"batch"}
PARTITION_PRDGEN=${PARTITION_PRDGEN:-"sjet,vjet,kjet,xjet"}
QUEUE_PRDGEN=${QUEUE_PRDGEN:-"batch"}
PARTITION_POST=${PARTITION_POST:-"sjet,vjet,kjet,xjet"}
QUEUE_POST=${QUEUE_POST:-"batch"}
;;
esac
#
#-----------------------------------------------------------------------
#
# Make sure that the job scheduler set above is valid.
#
#-----------------------------------------------------------------------
#
SCHED="${SCHED,,}"
check_var_valid_value "SCHED" "valid_vals_SCHED"
#
#-----------------------------------------------------------------------
#
# Verify that the ACCOUNT variable is not empty. If it is, print out an
# error message and exit.
#
#-----------------------------------------------------------------------
#
if [ -z "$ACCOUNT" ]; then
print_err_msg_exit "\
The variable ACCOUNT cannot be empty:
ACCOUNT = \"$ACCOUNT\""
fi
#
#-----------------------------------------------------------------------
#
# Set the grid type (GTYPE). In general, in the FV3 code, this can take
# on one of the following values: "global", "stretch", "nest", and "re-
# gional". The first three values are for various configurations of a
# global grid, while the last one is for a regional grid. Since here we
# are only interested in a regional grid, GTYPE must be set to "region-
# al".
#
#-----------------------------------------------------------------------
#
GTYPE="regional"
TILE_RGNL="7"
#
#-----------------------------------------------------------------------
#
# Make sure that GTYPE is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "GTYPE" "valid_vals_GTYPE"
#
#-----------------------------------------------------------------------
#
# Make sure PREDEF_GRID_NAME is set to a valid value.
#
#-----------------------------------------------------------------------
#
if [ ! -z ${PREDEF_GRID_NAME} ]; then
err_msg="\
The predefined regional grid specified in PREDEF_GRID_NAME is not sup-
ported:
PREDEF_GRID_NAME = \"${PREDEF_GRID_NAME}\""
check_var_valid_value \
"PREDEF_GRID_NAME" "valid_vals_PREDEF_GRID_NAME" "${err_msg}"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that PREEXISTING_DIR_METHOD is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value \
"PREEXISTING_DIR_METHOD" "valid_vals_PREEXISTING_DIR_METHOD"
#
#-----------------------------------------------------------------------
#
# Make sure CCPP_PHYS_SUITE is set to a valid value.
#
#-----------------------------------------------------------------------
#
err_msg="\
The CCPP physics suite specified in CCPP_PHYS_SUITE is not supported:
CCPP_PHYS_SUITE = \"${CCPP_PHYS_SUITE}\""
check_var_valid_value \
"CCPP_PHYS_SUITE" "valid_vals_CCPP_PHYS_SUITE" "${err_msg}"
#
#-----------------------------------------------------------------------
#
# Check that DATE_FIRST_CYCL and DATE_LAST_CYCL are strings consisting
# of exactly 8 digits.
#
#-----------------------------------------------------------------------
#
DATE_OR_NULL=$( printf "%s" "${DATE_FIRST_CYCL}" | \
sed -n -r -e "s/^([0-9]{8})$/\1/p" )
if [ -z "${DATE_OR_NULL}" ]; then
print_err_msg_exit "\
DATE_FIRST_CYCL must be a string consisting of exactly 8 digits of the
form \"YYYYMMDD\", where YYYY is the 4-digit year, MM is the 2-digit
month, and DD is the 2-digit day-of-month.
DATE_FIRST_CYCL = \"${DATE_FIRST_CYCL}\""
fi
DATE_OR_NULL=$( printf "%s" "${DATE_LAST_CYCL}" | \
sed -n -r -e "s/^([0-9]{8})$/\1/p" )
if [ -z "${DATE_OR_NULL}" ]; then
print_err_msg_exit "\
DATE_LAST_CYCL must be a string consisting of exactly 8 digits of the
form \"YYYYMMDD\", where YYYY is the 4-digit year, MM is the 2-digit
month, and DD is the 2-digit day-of-month.
DATE_LAST_CYCL = \"${DATE_LAST_CYCL}\""
fi
#
#-----------------------------------------------------------------------
#
# Check that all elements of CYCL_HRS are strings consisting of exactly
# 2 digits that are between "00" and "23", inclusive.
#
#-----------------------------------------------------------------------
#
CYCL_HRS_str=$(printf "\"%s\" " "${CYCL_HRS[@]}")
CYCL_HRS_str="( $CYCL_HRS_str)"
i=0
for CYCL in "${CYCL_HRS[@]}"; do
CYCL_OR_NULL=$( printf "%s" "$CYCL" | sed -n -r -e "s/^([0-9]{2})$/\1/p" )
if [ -z "${CYCL_OR_NULL}" ]; then
print_err_msg_exit "\
Each element of CYCL_HRS must be a string consisting of exactly 2 digits
(including a leading \"0\", if necessary) specifying an hour-of-day. Ele-
ment #$i of CYCL_HRS (where the index of the first element is 0) does not
have this form:
CYCL_HRS = $CYCL_HRS_str
CYCL_HRS[$i] = \"${CYCL_HRS[$i]}\""
fi
if [ "${CYCL_OR_NULL}" -lt "0" ] || \
[ "${CYCL_OR_NULL}" -gt "23" ]; then
print_err_msg_exit "\
Each element of CYCL_HRS must be an integer between \"00\" and \"23\", in-
clusive (including a leading \"0\", if necessary), specifying an hour-of-
day. Element #$i of CYCL_HRS (where the index of the first element is 0)
does not have this form:
CYCL_HRS = $CYCL_HRS_str
CYCL_HRS[$i] = \"${CYCL_HRS[$i]}\""
fi
i=$(( $i+1 ))
done
#
#-----------------------------------------------------------------------
#
# Call a function to generate the array ALL_CDATES containing the cycle
# dates/hours for which to run forecasts. The elements of this array
# will have the form YYYYMMDDHH. They are the starting dates/times of
# the forecasts that will be run in the experiment. Then set NUM_CYCLES
# to the number of elements in this array.
#
#-----------------------------------------------------------------------
#
set_cycle_dates \
date_start="${DATE_FIRST_CYCL}" \
date_end="${DATE_LAST_CYCL}" \
cycle_hrs="${CYCL_HRS_str}" \
output_varname_all_cdates="ALL_CDATES"
NUM_CYCLES="${#ALL_CDATES[@]}"
#
#-----------------------------------------------------------------------
#
# Set various directories.
#
# HOMErrfs:
# Top directory of the clone of the FV3-LAM workflow git repository.
#
# USHdir:
# Directory containing the shell scripts called by the workflow.
#
# SCRIPTSdir:
# Directory containing the ex scripts called by the workflow.
#
# JOBSdir:
# Directory containing the jjobs scripts called by the workflow.
#
# SORCdir:
# Directory containing various source codes.
#
# PARMdir:
# Directory containing parameter files, template files, etc.
#
# EXECdir:
# Directory containing various executable files.
#
# LIB64dir:
# Directory containing various library files.
#
# UFS_WTHR_MDL_DIR:
# Directory in which the UFS Weather Model application is located.
#
#-----------------------------------------------------------------------
#
HOMErrfs=${scrfunc_dir%/*}
USHdir="$HOMErrfs/ush"
SCRIPTSdir="$HOMErrfs/scripts"
JOBSdir="$HOMErrfs/jobs"
SORCdir="$HOMErrfs/sorc"
PARMdir="$HOMErrfs/parm"
MODULES_DIR="$HOMErrfs/modulefiles"
EXECdir="$HOMErrfs/exec"
LIB64dir="$HOMErrfs/sorc/build/lib64"
FIXgsm=${FIXgsm:-"$HOMErrfs/fix/am"}
FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"$HOMErrfs/fix/lam"}
FIX_GSI=${FIX_GSI:-"${HOMErrfs}/fix/gsi"}
FIX_UPP=${FIX_UPP:-"${HOMErrfs}/fix/upp"}
#FIX_CRTM=${FIX_CRTM:-"${CRTM_FIX}"}
#FIX_UPP_CRTM=${FIX_UPP_CRTM:-"${CRTM_FIX}"}
FIX_SMOKE_DUST=${FIX_SMOKE_DUST:-"${HOMErrfs}/fix/smoke_dust"}
FIX_BUFRSND=${FIX_BUFRSND:-"${HOMErrfs}/fix/bufrsnd"}
AIRCRAFT_REJECT=${AIRCRAFT_REJECT:-"${FIX_GSI}"}
SFCOBS_USELIST=${SFCOBS_USELIST:-"${FIX_GSI}"}
case $MACHINE in
"WCOSS2")
FIXgsm=${FIXgsm:-"/lfs/h2/emc/lam/noscrub/UFS_SRW_App/develop/fix/fix_am"}
TOPO_DIR=${TOPO_DIR:-"/lfs/h2/emc/lam/noscrub/UFS_SRW_App/develop/fix/fix_orog"}
SFC_CLIMO_INPUT_DIR=${SFC_CLIMO_INPUT_DIR:-"/lfs/h2/emc/lam/noscrub/UFS_SRW_App/develop/fix/fix_sfc_climo"}
FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"/lfs/h2/emc/lam/noscrub/UFS_SRW_App/develop/FV3LAM_pregen"}
;;
"HERA")
FIXgsm=${FIXgsm:-"/scratch1/NCEPDEV/nems/role.epic/UFS_SRW_data/develop/fix/fix_am"}
TOPO_DIR=${TOPO_DIR:-"/scratch1/NCEPDEV/nems/role.epic/UFS_SRW_data/develop/fix/fix_orog"}
SFC_CLIMO_INPUT_DIR=${SFC_CLIMO_INPUT_DIR:-"/scratch1/NCEPDEV/nems/role.epic/UFS_SRW_data/develop/fix/fix_sfc_climo"}
FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"/scratch1/NCEPDEV/nems/role.epic/UFS_SRW_data/develop/FV3LAM_pregen"}
;;
"ORION"|"HERCULES")
FIXgsm=${FIXgsm:-"/work/noaa/epic/role-epic/contrib/UFS_SRW_data/develop/fix/fix_am"}
TOPO_DIR=${TOPO_DIR:-"/work/noaa/epic/role-epic/contrib/UFS_SRW_data/develop/fix/fix_orog"}
SFC_CLIMO_INPUT_DIR=${SFC_CLIMO_INPUT_DIR:-"/work/noaa/epic/role-epic/contrib/UFS_SRW_data/develop/fix/fix_sfc_climo"}
FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"/work/noaa/epic/role-epic/contrib/UFS_SRW_data/develop/FV3LAM_pregen"}
;;
"JET")
FIXgsm=${FIXgsm:-"/mnt/lfs4/HFIP/hfv3gfs/role.epic/UFS_SRW_data/develop/fix/fix_am"}
TOPO_DIR=${TOPO_DIR:-"/mnt/lfs4/HFIP/hfv3gfs/role.epic/UFS_SRW_data/develop/fix/fix_orog"}
SFC_CLIMO_INPUT_DIR=${SFC_CLIMO_INPUT_DIR:-"/mnt/lfs4/HFIP/hfv3gfs/role.epic/UFS_SRW_data/develop/fix/fix_sfc_climo"}
FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"/mnt/lfs4/HFIP/hfv3gfs/role.epic/UFS_SRW_data/develop/FV3LAM_pregen"}
;;
*)
print_err_msg_exit "\
One or more fix file directories have not been specified for this machine:
MACHINE = \"$MACHINE\"
FIXgsm = \"${FIXgsm:-\"\"}
TOPO_DIR = \"${TOPO_DIR:-\"\"}
SFC_CLIMO_INPUT_DIR = \"${SFC_CLIMO_INPUT_DIR:-\"\"}
FIXLAM_NCO_BASEDIR = \"${FIXLAM_NCO_BASEDIR:-\"\"}
You can specify the missing location(s) in config.sh"
;;
esac
#
#-----------------------------------------------------------------------
#
# Set the base directories in which codes obtained from external reposi-
# tories (using the manage_externals tool) are placed. Obtain the rela-
# tive paths to these directories by reading them in from the manage_ex-
# ternals configuration file. (Note that these are relative to the lo-
# cation of the configuration file.) Then form the full paths to these
# directories. Finally, make sure that each of these directories actu-
# ally exists.
#
#-----------------------------------------------------------------------
#
mng_extrns_cfg_fn=$( readlink -f "${HOMErrfs}/Externals.cfg" )
property_name="local_path"
#
# Get the base directory of the FV3 forecast model code.
#
UFS_WTHR_MDL_DIR="${SORCdir}/ufs-weather-model"
if [ ! -d "${UFS_WTHR_MDL_DIR}" ]; then
print_err_msg_exit "\
The base directory in which the FV3 source code should be located
(UFS_WTHR_MDL_DIR) does not exist:
UFS_WTHR_MDL_DIR = \"${UFS_WTHR_MDL_DIR}\"
Please clone the external repository containing the code in this directory,
build the executable, and then rerun the workflow."
fi
#
# Get the base directory of the UFS_UTILS codes.
#
UFS_UTILS_DIR="${SORCdir}/UFS_UTILS"
if [ ! -d "${UFS_UTILS_DIR}" ]; then
print_err_msg_exit "\
The base directory in which the UFS utilities source codes should be lo-
cated (UFS_UTILS_DIR) does not exist:
UFS_UTILS_DIR = \"${UFS_UTILS_DIR}\"
Please clone the external repository containing the code in this direct-
ory, build the executables, and then rerun the workflow."
fi
#
# Get the base directory of the UPP code.
#
UPP_DIR="${SORCdir}/UPP"
if [ ! -d "${UPP_DIR}" ]; then
print_err_msg_exit "\
The base directory in which the UPP source code should be located
(UPP_DIR) does not exist:
UPP_DIR = \"${UPP_DIR}\"
Please clone the external repository containing the code in this directory,
build the executable, and then rerun the workflow."
fi
#
# Get the base directory of the Python Graphics code.
#
PYTHON_GRAPHICS_DIR="${HOMErrfs}/python_graphics"
if [ ! -d "${PYTHON_GRAPHICS_DIR}" ]; then
print_err_msg_exit "
The base directory in which the Python Graphics source code should be located
(PYTHON_GRAPHICS_DIR) does not exist:
PYTHON_GRAPHICS_DIR = \"${PYTHON_GRAPHICS_DIR}\"
Please clone the external repository containing the code in this directory,
build the executable, and then rerun the workflow."
fi
#
#
#-----------------------------------------------------------------------
#
# Make sure that USE_CUSTOM_POST_CONFIG_FILE is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value \
"USE_CUSTOM_POST_CONFIG_FILE" "valid_vals_USE_CUSTOM_POST_CONFIG_FILE"
#
# Set USE_CUSTOM_POST_CONFIG_FILE to either "TRUE" or "FALSE" so we don't
# have to consider other valid values later on.
#
USE_CUSTOM_POST_CONFIG_FILE=${USE_CUSTOM_POST_CONFIG_FILE^^}
if [ "$USE_CUSTOM_POST_CONFIG_FILE" = "TRUE" ] || \
[ "$USE_CUSTOM_POST_CONFIG_FILE" = "YES" ]; then
USE_CUSTOM_POST_CONFIG_FILE="TRUE"
elif [ "$USE_CUSTOM_POST_CONFIG_FILE" = "FALSE" ] || \
[ "$USE_CUSTOM_POST_CONFIG_FILE" = "NO" ]; then
USE_CUSTOM_POST_CONFIG_FILE="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Add graphics for the additional post-processed domains
#
#-----------------------------------------------------------------------
#
if [ ${#ADDNL_OUTPUT_GRIDS[@]} -ne 0 ]; then
for grid in ${ADDNL_OUTPUT_GRIDS[@]} ; do
TILE_SETS="${TILE_SETS} ${grid}"
TILE_LABELS="${TILE_LABELS} ${grid}"
done
fi
#
#-----------------------------------------------------------------------
#
# If using a custom post configuration file, make sure that it exists.
#
#-----------------------------------------------------------------------
#
if [ ${USE_CUSTOM_POST_CONFIG_FILE} = "TRUE" ]; then
if [ ! -f "${CUSTOM_POST_CONFIG_FP}" ]; then
print_err_msg_exit "
The custom post configuration specified by CUSTOM_POST_CONFIG_FP does not
exist:
CUSTOM_POST_CONFIG_FP = \"${CUSTOM_POST_CONFIG_FP}\""
fi
fi
#
#-----------------------------------------------------------------------
#
# The forecast length (in integer hours) cannot contain more than 3 cha-
# racters. Thus, its maximum value is 999. Check whether the specified
# forecast length exceeds this maximum value. If so, print out a warn-
# ing and exit this script.