-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.sh
executable file
·1733 lines (1605 loc) · 63.2 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
set -xa
# -----------------------------------------------------------
# UNIX Shell Script File
# Tested Operating System(s): RHEL 5,6
# Tested Run Level(s): 3, 5
# Shell Used: BASH shell
# Original Author(s): Alex Gibbs, Tony Freeman, Pablo Santos, Douglas Gaer
# File Creation Date: 06/01/2009
# Date Last Modified: 11/18/2014
#
# Version control: 1.14
#
# Support Team:
#
# Contributors: Roberto Padilla-Hernandez
#
# -----------------------------------------------------------
# ------------- Program Description and Details -------------
# -----------------------------------------------------------
#
# Script used to setup an NWPS domain for SWAN and WW3
#
# -----------------------------------------------------------
# Check to see if our SITEID is set
if [ "${SITEID}" == "" ]
then
echo "ERROR - Your SITEID variable is not set"
export err=1; err_chk
fi
# Setup our NWPS environment
if [ "${HOMEnwps}" == "" ]
then
echo "ERROR - Your NWPSdir variable is not set"
export err=1; err_chk
fi
PROGRAMNAME=setup.sh
mkdir -p ${LOGdir}
LOGFILE=${LOGdir}/domain_setup.log
cat /dev/null > ${LOGdir}/domain_setup.log
NUMCPUS=$(cat /proc/cpuinfo | grep processor | wc -l | tr -d " ")
JETLAG=$(expr $(date -u +%H) - $(date +%H))
YMD=$(date +%Y%m%d)
YMDHM=$(date +%Y%m%d%H%M)
### FUNCTIONS AREA ##################################
function logit () {
echo "$@" | tee -a ${LOGFILE}
}
#function get_wd () {
# CWD=$1
# COUNT=$(echo $CWD | tr "/" " " | wc -w)
# PROGRAM=$(echo $CWD | tr "/" " " | awk "{ print \$$COUNT }")
# PATHTEST=$(echo "$CWD" | sed -e "s#/$PROGRAM##g")
# if [[ $PATHTEST == "./" || $PATHTEST == "" || $PATHTEST == "." ]]
# then
# WD="."
# else
# WD="$PATHTEST"
# fi
# if [[ $WD == "." ]]
# then
# WD=$(pwd)
# fi
#}
#function check_pwd () {
# get_wd $0
# cd $WD
# if [[ ! -f $PROGRAMNAME ]]
# then
# logit " "
# logit "Unable to find $PROGRAMNAME"
# logit " "
# logit "Please execute $PROGRAMNAME from the directory in which it resides"
# logit " "
# logit "Example: "
# logit " cd ${DATA}/"
# logit " ${USHnwps}/setup.sh"
# logit " "
# logit "Exiting ... "
# logit " "
# export err=1; err_chk
# else
# echo "found $PROGRAMNAME in $WD ..." >> ${LOGFILE}
# fi
#}
function get_sid () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Please enter your Site ID in lowercase. Example: tae"
logit " "
read -p "Enter the Site ID in lowercase letters: " BLAH
MYSID=$BLAH
if [[ -z $MYSID ]]
then
logit "MYSID is not present. Please correct this problem."
logit "Exiting ..."
export err=1; err_chk
fi
LSID=$(echo "$MYSID" | tr "[A-Z]" "[a-z]")
USID=$(echo "$MYSID" | tr "[a-z]" "[A-Z]")
}
function get_rid () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Please enter your Region ID in lowercase. Example: sr"
logit " "
logit "NWS Region IDs are:"
logit "al - Alaska Region"
logit "cr - Central Region, Great Lakes"
logit "er - Eastern Region"
logit "gr - Eastern Region, Great Lakes"
logit "pr - Pacific Region"
logit "sr - Southern Region"
logit "wr - Western Region"
logit " "
read -p "Enter the Site ID in lowercase letters: " BLAH
MYRID=$BLAH
if [[ -z $MYRID ]]
then
logit "MYRID is not present. Please correct this problem."
logit "Exiting ..."
export err=1; err_chk
fi
LRID=$(echo "$MYRID" | tr "[A-Z]" "[a-z]")
URID=$(echo "$MYRID" | tr "[a-z]" "[A-Z]")
}
function get_modeltype () {
clear
MODEL=NONE
while [[ "$MODEL" != "SWAN" && "$MODEL" != "UNSWAN" && "$MODEL" != "WW3" ]]
do
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit "Enter the name of the Wave Model you want to run (SWAN, UNSWAN or WW3). Example:SWAN "
logit " "
read -p ": " BLAH
MODEL=$BLAH
BLAH=""
done
}
function get_ne_lat () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Enter the North East Latitude. Example: 30.50"
logit " "
read -p "Enter the NE Latitude: " BLAH
BLAH=$(echo "$BLAH + 0.0" | bc | tr -d "-")
BLAH=$(printf "%.02f" $BLAH)
if [[ $BLAH == "0.00" ]]
then
logit " "
logit "Sorry. I cannot determine [ $BLAH ] to be a valid lat/lon point"
logit " "
logit "Exiting ... "
logit " "
export err=1; err_chk
else
NELAT="$BLAH"
fi
BLAH=""
}
function get_ne_lon () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Enter the North East Longitude. Example: 82.30"
logit " "
read -p "Enter the NE Longitude: " BLAH
BLAH=$(echo "$BLAH + 0.0" | bc | tr -d "-")
BLAH=$(printf "%.02f" $BLAH)
if [[ $BLAH == "0.00" ]]
then
logit " "
logit "Sorry. I cannot determine [ $BLAH ] to be a valid lat/lon point"
logit " "
logit "Exiting ... "
logit " "
export err=1; err_chk
else
NELON="$BLAH"
NELONCIRC=$(echo "360.00 - $BLAH" | bc)
fi
BLAH=""
}
function get_sw_lat () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Enter the South West Latitude. Example: 27.50"
logit " "
read -p "Enter the SW Latitude: " BLAH
BLAH=$(echo "$BLAH + 0.0" | bc | tr -d "-")
BLAH=$(printf "%.02f" $BLAH)
if [[ $BLAH == "0.00" ]]
then
logit " "
logit "Sorry. I cannot determine [ $BLAH ] to be a valid lat/lon point"
logit " "
logit "Exiting ... "
logit " "
export err=1; err_chk
else
SWLAT="$BLAH"
fi
BLAH=""
}
function get_sw_lon () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Enter the South West Longitude. Example: 88.20"
logit " "
read -p "Enter the SW Longitude: " BLAH
BLAH=$(echo "$BLAH + 0.0" | bc | tr -d "-")
BLAH=$(printf "%.02f" $BLAH)
if [[ $BLAH == "0.00" ]]
then
logit " "
logit "Sorry. I cannot determine [ $BLAH ] to be a valid lat/lon point"
logit " "
logit "Exiting ... "
logit " "
export err=1; err_chk
else
SWLON="$BLAH"
SWLONCIRC=$(echo "360.00 - $BLAH" | bc)
fi
BLAH=""
}
function get_res () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Enter the Desired Resolution. Example: 1.5 for 1.5 km (recommended)"
logit " "
read -p "Enter the spatial resolution: " BLAH
BLAH=$(echo "$BLAH + 0.0" | bc | tr -d "-")
BLAH=$(printf "%.02f" $BLAH)
if [[ $BLAH == "0.00" ]]
then
logit " "
logit "Sorry. I cannot determine [ $BLAH ] to be a valid entry"
logit " "
logit "Exiting ... "
logit " "
export err=1; err_chk
else
RES="$BLAH"
fi
BLAH=""
}
function get_time_step () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit " "
logit "Enter the Desired Time Step. Example: 3 for 3 hours (recommended)"
logit " "
read -p "Enter the Desired Time Step for SWAN Runs: " BLAH
if [[ $BLAH == "0" ]]
then
logit " "
logit "Sorry. I cannot determine [ $BLAH ] to be a valid entry"
logit " "
logit "Exiting ... "
logit " "
export err=1; err_chk
else
TSTEP="$BLAH"
fi
BLAH=""
}
################################################################################
#funcion get_coord_spc1d #
#Goal: To read the coordinates and name of one or several locations where the #
# user wants to have 1D spectra from the wave model #
# #
#Written by : Roberto Padilla-Hernandez EMC/NCEP/MMAB/IMSG #
#Base on : createHeader subroutine #
#Explanation: #
# Ask to the user for the number (NUMSPC) of output locations for 1D spectra. #
# Read the Longitude, Latitud and Name of every location. #
# Those data are introduced to the SWAN input file (inputCG#) by the main #
# program (setup.sh) #
#first written: 04/20/11 #
#last update: ---- #
# #
################################################################################
function get_coord_spc1d () {
clear
spclons=""
spclats=""
spcnames=""
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit "Enter the NUMBER OF POINTS FOR WAVE PARTITION (GERLING-HANSON PLOTS) & OUTPUT SPECTRA. Example: 4 "
logit " "
read -p ": " BLAH
NUMSPC=$BLAH
numofchars=0
BLAH=""
#LOOP OVER THE NUMBER OF SPECTRA
x=1
while [ $x -le $NUMSPC ]
do
clear
logit " "
logit "----------------------------------------------------------------------------"
logit " "
if [ $numofchars -gt "8" ];then
logit "**************************************************************"
logit "*****Name HAS MORE THAN 8 CHARACTERS. IT HAS: $numofchars *****"
logit "**************************************************************"
fi
logit "Enter the West Longitude, Latitude and Name (NO MORE THAN 8 CHARACTERS LONG)"
logit " of the output spectra location number --$x--"
logit " Example: 88.50 22.40 BUOY304c"
logit " "
read -p " " BLAH BLAHLA BLAHNAME
BLAHLO=$(echo "360.00 - $BLAH" | bc)
numofchars=${#BLAHNAME}
if [ $numofchars -le "8" ];then
spclons[$x]=$BLAHLO
spclats[$x]=$BLAHLA
spcnames[$x]=$BLAHNAME
BLAH="";BLAHLO=""; BLAHLA=""; BLAHNAME=""
numofchars=0
x=$(( $x + 1 ))
fi
logit "Counter: $x"
done
logit "LONGITUDES: ${spclons[*]} "
logit "LATITUDES : ${spclats[*]} "
logit "LOC. NAMES: ${spcnames[*]} "
}
################################################################################
#funcion edit_input_for_blockout #
#Goal: To include block output lines. In the case of regular grids, this is #
# done with a frame with dimensions of the COMPGRID. For unstructured #
# meshes, this is written to the native mesh COMPGRID in netcdf4 format. #
# #
#Written by : Andre van der Westhuysen EMC/NCEP/MMAB/IMSG #
#Base on : #
#Explanation: #
# The ouput locations (names, longs and lats) command lines are introduced #
# to the wave input file (inputCG#) #
# #
#first written: 05/12/17 #
#last update: 05/12/2017
# #
################################################################################
function edit_inputCG_for_blockout () {
if [ "${MODELCORE}" == "UNSWAN" ]; then
# For UNSTRUC mode we output the mesh in netCDF format, and extract the AWIPS grids with swn_reginterpCG1.py
# In the postproc step (GraphicOutput.pm) we will pack this mesh at the FRAMECG1 resolution.
#AW lineprt1="BLOCK 'COMPGRID' NOHEAD 'CG_UNSTRUC.nc' LAY 3 XP YP HSIG WIND TPS DIR PDIR VEL WATL HSWE WLEN DEPTH \&"
lineprt1="BLOCK 'COMPGRID' NOHEAD 'CG_UNSTRUC.nc' LAY 3 XP YP HSIG WIND TPS DIR PDIR VEL WATL HSWE \&"
lineprt2="OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt3="$ FRAMECG1 'OUTGRID' #SWLONCIRC# #SWLAT# 0. #XLENC# #YLENC# #MESHLON# #MESHLAT#"
lineprt4="$ FRAMECG2 'OUTGRID' #SWLONCIRCN1# #SWLATN1# 0. #XLENCN1# #YLENCN1# #MESHLONN1# #MESHLATN1#"
lineprt5="$ FRAMECG3 'OUTGRID' #SWLONCIRCN2# #SWLATN2# 0. #XLENCN2# #YLENCN2# #MESHLONN2# #MESHLATN2#"
lineprt6="$ FRAMECG4 'OUTGRID' #SWLONCIRCN3# #SWLATN3# 0. #XLENCN3# #YLENCN3# #MESHLONN3# #MESHLATN3#"
lineprt7="$ FRAMECG5 'OUTGRID' #SWLONCIRCN4# #SWLATN4# 0. #XLENCN4# #YLENCN4# #MESHLONN4# #MESHLATN4#"
sed -i "s/$ BLOCK UNSTRUC LINE01/${lineprt1}/g" inputCG1
sed -i "s/$ BLOCK UNSTRUC LINE02/${lineprt2}/g" inputCG1
sed -i "s/$ BLOCK UNSTRUC LINE03/${lineprt3}/g" inputCG1
sed -i "s/$ BLOCK UNSTRUC LINE04/${lineprt4}/g" inputCG1
sed -i "s/$ BLOCK UNSTRUC LINE05/${lineprt5}/g" inputCG1
sed -i "s/$ BLOCK UNSTRUC LINE06/${lineprt6}/g" inputCG1
sed -i "s/$ BLOCK UNSTRUC LINE07/${lineprt7}/g" inputCG1
else
lineprt1="FRAME 'OUTGRID' #SWLONCIRC# #SWLAT# 0. #XLENC# #YLENC# #MESHLON# #MESHLAT#"
lineprt2="BLOCK 'OUTGRID' NOHEAD 'HSIG.CG1.CGRID' LAY 3 HSIG OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt3="BLOCK 'OUTGRID' NOHEAD 'WIND.CG1.CGRID' LAY 3 WIND OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt4="BLOCK 'OUTGRID' NOHEAD 'TPS.CG1.CGRID' LAY 3 TPS OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt5="BLOCK 'OUTGRID' NOHEAD 'DIR.CG1.CGRID' LAY 3 DIR OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt6="BLOCK 'OUTGRID' NOHEAD 'PDIR.CG1.CGRID' LAY 3 PDIR OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt7="BLOCK 'OUTGRID' NOHEAD 'VEL.CG1.CGRID' LAY 3 VEL OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt8="BLOCK 'OUTGRID' NOHEAD 'WATL.CG1.CGRID' LAY 3 WATL OUTPUT 20100301.1800 #TSTEP#.0 HR"
lineprt9="BLOCK 'OUTGRID' NOHEAD 'HSWE.CG1.CGRID' LAY 3 HSWE OUTPUT 20100301.1800 #TSTEP#.0 HR"
#AW lineprt10="BLOCK 'OUTGRID' NOHEAD 'WLEN.CG1.CGRID' LAY 3 WLEN OUTPUT 20100301.1800 #TSTEP#.0 HR"
#AW lineprt11="BLOCK 'OUTGRID' NOHEAD 'DEPTH.CG1.CGRID' LAY 3 DEPTH OUTPUT 20100301.1800 #TSTEP#.0 HR"
sed -i "s/$ BLOCK REG LINE01/${lineprt1}/g" inputCG1
sed -i "s/$ BLOCK REG LINE02/${lineprt2}/g" inputCG1
sed -i "s/$ BLOCK REG LINE03/${lineprt3}/g" inputCG1
sed -i "s/$ BLOCK REG LINE04/${lineprt4}/g" inputCG1
sed -i "s/$ BLOCK REG LINE05/${lineprt5}/g" inputCG1
sed -i "s/$ BLOCK REG LINE06/${lineprt6}/g" inputCG1
sed -i "s/$ BLOCK REG LINE07/${lineprt7}/g" inputCG1
sed -i "s/$ BLOCK REG LINE08/${lineprt8}/g" inputCG1
sed -i "s/$ BLOCK REG LINE09/${lineprt9}/g" inputCG1
#AW sed -i "s/$ BLOCK REG LINE10/${lineprt10}/g" inputCG1
#AW sed -i "s/$ BLOCK REG LINE11/${lineprt11}/g" inputCG1
fi
}
################################################################################
#funcion get_coord_hsplots #
#Goal: get the proper flags if the users wants or not hanson plots #
# If Hanson plots, then ask for coordinates of output location #
# #
#Written by : Roberto Padilla-Hernandez EMC/NCEP/MMAB/IMSG #
#Base on : #
#Explanation: #
# If the user wants hanson plots then the subroutine reads the coordinates and #
# name of the locations where the user wants to have the wave partition and #
# the corresponding hanson plots #
# Those data are introduced to the user-defined input file (inputCG#) #
# program (setup.sh) #
# #
# first written: 06/02/11 #
# last update: 08/27/2011
# #
################################################################################
function get_coord_hsplots () {
HSFLAGS[0]="n"
HSFLAGS[1]="n"
HSFLAGS[2]="n"
NUMPRT=0
clear
logit " "
logit "----------------------------------------------------------------------------"
logit " "
logit "Do you want Hanson Plots in some locations?"
logit " y or n "
logit " "
read -p ": " hspyorn
logit $hspyorn
if [ $hspyorn == "y" ];
then
HSFLAGS[0]="y"
HSFLAGS[1]="y"
HSFLAGS[2]="y"
prtlons=""
prtlats=""
prtnames=""
clear
logit " "
logit "---------------------------------------------------------------------"
logit "You can repeat name and coordinates from output spectra location "
logit "but you can NOT use same name with different coordinates"
logit "You CAN give different name repeating coordinates from spectral locations "
logit " "
logit "Enter the Number of locations for Hanson Plots. Example: 4 "
logit " "
read -p ": " BLAH
NUMPRT=$BLAH
numofchars=0
BLAH=""
#LOOP OVER THE NUMBER OF OUTPUT LOCATIONS
x=1
while [ $x -le $NUMPRT ]
do
clear
logit " "
logit "----------------------------------------------------------------------------"
logit " "
if [ $numofchars -gt "8" ];then
logit "**************************************************************"
logit "*****Name HAS MORE THAN 8 CHARACTERS. IT HAS: $numofchars *****"
logit "**************************************************************"
fi
logit "Enter the West Longitude, Latitude and Name (NO MORE THAN 8 CHARACTERS LONG)"
logit " of the output partition location number --$x--"
logit " Example: 88.50 22.40 BUOYXZ1c"
logit " "
read -p " " BLAH BLAHLA BLAHNAME
BLAHLO=$(echo "360.00 - $BLAH" | bc)
numofchars=${#BLAHNAME}
if [ $numofchars -le "8" ];then
prtlons[$x]=$BLAHLO
prtlats[$x]=$BLAHLA
prtnames[$x]=$BLAHNAME
BLAH="";BLAHLO=""; BLAHLA=""; BLAHNAME=""
numofchars=0
x=$(( $x + 1 ))
fi
done
fi
}
################################################################################
#funcion edit_input_for_partition #
#Goal: To include in the wave model user-input file the locations for partition#
# output and the parameters required by the user #
# #
#Written by : Roberto Padilla-Hernandez EMC/NCEP/MMAB/IMSG #
#Base on : #
#Explanation: #
# The ouput locations (names, longs and lats) command lines are introduced #
# to the wave input file (inputCG#) #
# #
#first written: 06/06/11 #
#last update: 08/27/2011
# #
################################################################################
function edit_inputCG_for_partition () {
if [ $hspyorn == "y" ]; then
if [ $WVTONCG -eq 1 ]; then
lineprt1="BLOCK 'COMPGRID' HEADER 'swan_part.CG1.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP#.0 HR"
sed -i "/$PARTITION OUTCOMMANDS/ a $lineprt1" inputCG1
else
lineprt2="BLOCK 'RAWGRID' HEADER 'swan_part.CG1.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
sed -i "/$PARTITION OUTCOMMANDS/ a $lineprt2" inputCG1
lineprt1="FRAME 'RAWGRID' #SWLONCIRCWT# #SWLATWT# 0. #XLENWT# #YLENWT# #MESHLONWT# #MESHLATWT#"
sed -i "/$PARTITION OUTCOMMANDS/ a $lineprt1" inputCG1
fi
#THIS PART IS READY TO ACTIVATE THE WAVE PARTITION IN SWAN FOR THE NESTED GRIDS
#, NEEDS TO BE TESTED JUST UNCOMMENT THE LINES
# if [ -f "inputCG2" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG2.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG2
# fi
# if [ -f "inputCG3" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG3.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG3
# fi
# if [ -f "inputCG4" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG4.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG4
# fi
# if [ -f "inputCG5" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG5.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG5
# fi
#
# if [ -f "inputCG6" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG6.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG6
# fi
#
# if [ -f "inputCG7" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG7.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG7
# fi
# if [ -f "inputCG8" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG8.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG8
# fi
#
# if [ -f "inputCG9" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG9.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG9
# fi
#
# if [ -f "inputCG10" ];then
# lineprtN1="BLOCK 'COMPGRID' HEADER 'swan_part.CG10.raw' LAY 3 PARTITIONS OUTPUT 20100301.1800 #TSTEP# HR"
# sed -i "/$PARTITION OUTCOMMANDS/ a $lineprtN1" inputCG10
# fi
fi
}
################################################################################
function edit_inputCG_for_currents () {
if [ "${CURRL1}" != "" ]; then
sed -i "/$ CURR STARTS HERE/ a ${CURRL1}" inputCG1
sed -i "/$ CURR ENDS HERE/ a ${CURRL2}" inputCG1
sed -i '/$ CURR STARTS HERE/d ' inputCG1
sed -i '/$ CURR ENDS HERE/d ' inputCG1
# NEST GRID 1
sed -i "/$ CURR STARTS HERE/ a ${CURRL1}" inputCG2
sed -i "/$ CURR ENDS HERE/ a ${CURRL2}" inputCG2
sed -i '/$ CURR STARTS HERE/d ' inputCG2
sed -i '/$ CURR ENDS HERE/d ' inputCG2
# NEST GRID 2
sed -i "/$ CURR STARTS HERE/ a ${CURRL1}" inputCG3
sed -i "/$ CURR ENDS HERE/ a ${CURRL2}" inputCG3
sed -i '/$ CURR STARTS HERE/d ' inputCG3
sed -i '/$ CURR ENDS HERE/d ' inputCG3
# NEST GRID 3
sed -i "/$ CURR STARTS HERE/ a ${CURRL1}" inputCG4
sed -i "/$ CURR ENDS HERE/ a ${CURRL2}" inputCG4
sed -i '/$ CURR STARTS HERE/d ' inputCG4
sed -i '/$ CURR ENDS HERE/d ' inputCG4
# NEST GRID 4
sed -i "/$ CURR STARTS HERE/ a ${CURRL1}" inputCG5
sed -i "/$ CURR ENDS HERE/ a ${CURRL2}" inputCG5
sed -i '/$ CURR STARTS HERE/d ' inputCG5
sed -i '/$ CURR ENDS HERE/d ' inputCG5
fi
}
################################################################################
function confirm_values () {
clear
logit " "
logit " "
logit "---------------------------------------------------------------------"
logit "CONFIRM VALUES AND INSTALL"
logit "---------------------------------------------------------------------"
logit " "
logit "Your Site ID = $LSID"
logit "Your Region ID = $LSID"
logit " "
logit "NE LATITUDE = $NELAT"
logit "NE LONGITUDE = $NELON (Spherical Coord = $NELONCIRC)"
logit "SW LATITUDE = $SWLAT"
logit "SW LONGITUDE = $SWLON (Spherical Coord = $SWLONCIRC)"
logit "GEOGRAPH. RESOLUTION = $RES KM"
logit "WAVE MODEL OUTPUT TIME STEP = $TSTEP HR"
logit " "
if [ $NUMSPC -gt "0" ]
then
logit "$NUMSPC Locations for 1D-Spectra"
if [ $hspyorn == "y" ]; then
logit "and Wave Tracking information"
fi
logit "LONGITUDES: ${spclons[*]} "
logit "LATITUDES : ${spclats[*]} "
logit "LOC. NAMES: ${spcnames[*]} "
else
logit " 1D-Spectra Information not required"
fi
# logit " "
# logit "This script is being ran from this directory: $WD"
logit " "
logit "Please check that the above information is correct before continuing"
logit "---------------------------------------------------------------------"
logit " "
read -p "Press ENTER to continue with installation or Ctrl-C to exit: " BLAH
BLAH=""
}
function auto_run()
{
logit ""
logit "Starting automatic domain setup "
date -u | tee -a ${LOGFILE}
if [ ! -e ${DOMAINFILE} ]
then
logit "ERROR - Missing ${DOMAINFILE}"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
# The domain setup must contain
# export SITEID="XXX"
# export REGIONID="XX"
# export NELAT="value"
# export NELON="value"
# export SWLAT="value"
# export SWLON="value"
# export RES="value"
# export TSTEP="value"
# Optional domain setup for specta points
# export SEPCPOINTS="name1:lat:lon name2:lat:lon name3:lat:lon name4:lat:lon"
NESTGRIDS=0
source ${DOMAINFILE}
echo " ${DOMAINFILE} "
if [ ${NESTGRIDS} -eq 0 ] && [ ${NESTCG} == "Yes" ]; then
echo " *************************************************************"
echo " * - - - - - - - - - - - WARNING - - - - - - - - - - - - - "
echo " * NESTGRIDS=${NESTGRIDS} NESTCG=${NESTCG} "
echo " * --nest GIVEN AS AN ARGUMENT "
echo " * BUT "
echo " * NESTED GRID INFO NOT IN $DOMAINFILE "
echo " * RUN WILL PROCEED WITH NO NESTED GRIDS "
#export err=1; err_chk
export NESTCG="NO"
export NESTS="NO"
echo " now : NESTGRIDS=${NESTGRIDS} NESTCG=${NESTCG} NESTS=${NESTS}"
echo " *************************************************************"
fi
if [[ -z $SITEID ]]
then
logit "ERROR - SITEID is not present. Please correct this problem."
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
LSID=$(echo ${SITEID} | tr [:upper:] [:lower:])
USID=$(echo ${SITEID} | tr [:lower:] [:upper:])
if [[ -z $REGIONID ]]
then
logit "ERROR - REGIONID is not present. Please correct this problem."
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
LRID=$(echo ${REGIONID} | tr [:upper:] [:lower:])
URID=$(echo ${REGIONID} | tr [:lower:] [:upper:])
if [[ -z $MODELTYPE ]]
then
logit "ERROR - MODELTYPE is not present. Please correct this problem."
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
LRMODEL=$(echo ${MODELCORE} | tr [:upper:] [:lower:])
URMODEL=$(echo ${MODELCORE} | tr [:lower:] [:upper:])
NELAT=$(echo "$NELAT + 0.0" | bc | tr -d "-")
NELAT=$(printf "%.02f" $NELAT)
if [[ $NELAT == "0.00" ]]
then
logit "ERROR - Cannot determine NELAT to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
NELON=$(echo "$NELON + 0.0" | bc | tr -d "-")
NELON=$(printf "%.02f" $NELON)
NELONCIRC=$(echo "360.00 - $NELON" | bc)
if [[ $NELON == "0.00" ]]
then
logit "ERROR - Cannot determine NELON to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
SWLAT=$(echo "$SWLAT + 0.0" | bc | tr -d "-")
SWLAT=$(printf "%.02f" $SWLAT)
if [[ $SWLAT == "0.00" ]]
then
logit "ERROR - Cannot determine SWLAT to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
SWLON=$(echo "$SWLON + 0.0" | bc | tr -d "-")
SWLON=$(printf "%.02f" $SWLON)
SWLONCIRC=$(echo "360.00 - $SWLON" | bc)
if [[ $SWLON == "0.00" ]]
then
logit "ERROR - Cannot determine SWLON to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
RES=$(echo "$RES + 0.0" | bc | tr -d "-")
RES=$(printf "%.02f" $RES)
if [[ $RES == "0.00" ]]
then
logit "ERROR - Cannot determine RES to be a valid entry"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
if [[ $TSTEP == "0" ]]
then
logit "ERROR - Cannot determine TSTEP to be a valid entry"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
# FOR NESTED GRID NUMBER 1 (COMUTATIONAL GRID NUMBER 2 -> CG2)
if [ $NESTGRIDS -gt 0 ] && [ ${NESTCG} == "Yes" ]
then
for (( j = 1 ; j < ${NESTGRIDS}+1 ; j++ ))
do
if [ $j -eq 1 ]
then
NELATN[$j]=${NELATN1}
NELONN[$j]=${NELONN1}
SWLATN[$j]=${SWLATN1}
SWLONN[$j]=${SWLONN1}
RESN[$j]=${RESN1}
TSTEPN[$j]=${TSTEPN1}
STATN[$j]=${STATN1}
elif [ $j -eq 2 ]
then
NELATN[$j]=${NELATN2}
NELONN[$j]=${NELONN2}
SWLATN[$j]=${SWLATN2}
SWLONN[$j]=${SWLONN2}
RESN[$j]=${RESN2}
TSTEPN[$j]=${TSTEPN2}
STATN[$j]=${STATN2}
elif [ $j -eq 3 ]
then
NELATN[$j]=${NELATN3}
NELONN[$j]=${NELONN3}
SWLATN[$j]=${SWLATN3}
SWLONN[$j]=${SWLONN3}
RESN[$j]=${RESN3}
TSTEPN[$j]=${TSTEPN3}
STATN[$j]=${STATN3}
elif [ $j -eq 4 ]
then
NELATN[$j]=${NELATN4}
NELONN[$j]=${NELONN4}
SWLATN[$j]=${SWLATN4}
SWLONN[$j]=${SWLONN4}
RESN[$j]=${RESN4}
TSTEPN[$j]=${TSTEPN4}
STATN[$j]=${STATN4}
elif [ $j -eq 5 ]
then
NELATN[$j]=${NELATN5}
NELONN[$j]=${NELONN5}
SWLATN[$j]=${SWLATN5}
SWLONN[$j]=${SWLONN5}
RESN[$j]=${RESN5}
TSTEPN[$j]=${TSTEPN5}
STATN[$j]=${STATN5}
elif [ $j -eq 6 ]
then
NELATN[$j]=${NELATN6}
NELONN[$j]=${NELONN6}
SWLATN[$j]=${SWLATN6}
SWLONN[$j]=${SWLONN6}
RESN[$j]=${RESN6}
TSTEPN[$j]=${TSTEPN6}
STATN[$j]=${STATN6}
elif [ $j -eq 7 ]
then
NELATN[$j]=${NELATN7}
NELONN[$j]=${NELONN7}
SWLATN[$j]=${SWLATN7}
SWLONN[$j]=${SWLONN7}
RESN[$j]=${RESN7}
TSTEPN[$j]=${TSTEPN7}
STATN[$j]=${STATN7}
elif [ $j -eq 8 ]
then
NELATN[$j]=${NELATN8}
NELONN[$j]=${NELONN8}
SWLATN[$j]=${SWLATN8}
SWLONN[$j]=${SWLONN8}
RESN[$j]=${RESN8}
TSTEPN[$j]=${TSTEPN8}
STATN[$j]=${STATN8}
elif [ $j -eq 9 ]
then
NELATN[$j]=${NELATN9}
NELONN[$j]=${NELONN9}
SWLATN[$j]=${SWLATN9}
SWLONN[$j]=${SWLONN9}
RESN[$j]=${RESN9}
TSTEPN[$j]=${TSTEPN9}
STATN[$j]=${STATN9}
elif [ $j -eq 10 ]
then
NELATN[$j]=${NELATN10}
NELONN[$j]=${NELONN10}
SWLATN[$j]=${SWLATN10}
SWLONN[$j]=${SWLONN10}
RESN[$j]=${RESN10}
TSTEPN[$j]=${TSTEPN10}
STATN[$j]=${STATN10}
fi
echo "${STATN[$j]}"
if [[ ${STATN[$j]} == "STA" ]]
then
STATorNON="STATIONARY"
else
STATorNON="NONSTATIONARY"
fi
echo " "
echo " "
echo " NESTED GRID: $j "
echo " ${NELATN[$j]} ------------------- "
echo " | | "
echo " | | "
echo " | | "
echo " | | "
echo " ${SWLATN[$j]}-------------------- ="
echo " | | "
echo " ${SWLONN[$j]} ${NELONN[$j]} "
echo " "
echo " RESOLUTION: ${RESN[$j]} KM "
echo " RUN : ${STATorNON} "
echo " "
echo " "
NELATN[j]=$(echo "${NELATN[j]} + 0.0" | bc | tr -d "-")
NELATN[j]=$(printf "%.02f" ${NELATN[j]})
if [[ ${NELATN[j]} == "0.00" ]]
then
logit "ERROR - For nested grid: $j Cannot determine NELATN to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
NELONN[$j]=$(echo "${NELONN[$j]} + 0.0" | bc | tr -d "-")
NELONN[$j]=$(printf "%.02f" ${NELONN[$j]})
NELONCIRCN[$j]=$(echo "360.00 - ${NELONN[$j]}" | bc)
if [[ ${NELONN[$j]} == "0.00" ]]
then
logit "ERROR - Cannot determine NELONN1 to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
SWLATN[$j]=$(echo "${SWLATN[$j]} + 0.0" | bc | tr -d "-")
SWLATN[$j]=$(printf "%.02f" ${SWLATN[$j]})
if [[ ${SWLATN[$j]} == "0.00" ]]
then
logit "ERROR - Cannot determine SWLATN1 to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
SWLONN[$j]=$(echo "${SWLONN[$j]} + 0.0" | bc | tr -d "-")
SWLONN[$j]=$(printf "%.02f" ${SWLONN[$j]})
SWLONCIRCN[$j]=$(echo "360.00 - ${SWLONN[$j]}" | bc)
if [[ ${SWLONN[$j]} == "0.00" ]]
then
logit "ERROR - Cannot determine SWLONN1 to be a valid lat/lon point"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
RESN[$j]=$(echo "${RESN[$j]} + 0.0" | bc | tr -d "-")
RESN[$j]=$(printf "%.02f" ${RESN[$j]})
if [[ ${RESN[$j]} == "0.00" ]]
then
logit "ERROR - Cannot determine RESN1 to be a valid entry"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
if [[ ${TSTEPN[$j]} == "0" ]]
then
logit "ERROR - Cannot determine TSTEPN1 to be a valid entry"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi
done
fi
# END NESTED GRID NUMBER 1
NUMSPC=0
spclons=""
spclats=""
spcnames=""
x=1
if [ "${SPECPOINTS}" != "" ]
then
###hspyorn="y"
for p in ${SPECPOINTS}
do
spname=$(echo ${p} | awk -F: '{ print $1 }')
splat=$(echo ${p} | awk -F: '{ print $2 }')
splat=$(echo "${splat} + 0.0" | bc | tr -d "-")
splat=$(printf "%.03f" ${splat})
splon=$(echo ${p} | awk -F: '{ print $3 }')
splon=$(echo "${splon} + 0.0" | bc | tr -d "-")
splon=$(printf "%.03f" ${splon})
if [ "${spname}" == "" ] || [ "$splat" == " 0.000" ] || [ "$splon" == " 0.000" ]
then
logit "ERROR - Bad specta point name:lat:lon value"
logit "No automatic Setup was performed!"
export err=1; err_chk
fi