-
Notifications
You must be signed in to change notification settings - Fork 24
/
WRF_Master_Script.sh
11634 lines (9097 loc) · 409 KB
/
WRF_Master_Script.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
start=`date`
START=$(date +"%s")
############################### System Architecture Type #################
# 32 or 64 bit
##########################################################################
export SYS_ARCH=$(uname -m)
if [ "$SYS_ARCH" = "x86_64" ]; then
export SYSTEMBIT="64"
else
export SYSTEMBIT="32"
fi
############################# System OS Version #############################
# Macos or linux
# Make note that this script only works for Debian Linux kernals
#############################################################################
export SYS_OS=$(uname -s)
if [ "$SYS_OS" = "Darwin" ]; then
export SYSTEMOS="MacOS"
elif [ "$SYS_OS" = "Linux" ]; then
export SYSTEMOS="Linux"
fi
########## Centos Test #############
if [ "$SYSTEMOS" = "Linux" ]; then
export YUM=$(command -v yum)
if [ "$YUM" != "" ]; then
echo " yum found"
read -p "Your system is a CentOS based system which is not compatible with this script"
exit ;
fi
fi
############################### Intel or GNU Compiler Option #############
if [ "$SYSTEMBIT" = "32" ] && [ "$SYSTEMOS" = "Darwin" ]; then
echo "Your system is not compatibile with this script."
exit ;
fi
if [ "$SYSTEMBIT" = "64" ] && [ "$SYSTEMOS" = "Darwin" ]; then
echo "Your system is a 64bit version of MacOS"
echo " "
echo "Intel compilers are not compatibile with this script"
echo " "
echo "Setting compiler to GNU"
export macos_64bit_GNU=1
echo " "
echo "Xcode Command Line Tools & Homebrew are required for this script."
echo " "
echo "Installing Homebrew and Xcode Command Line Tools now"
echo " "
echo "Please enter password when prompted"
chsh -s /bin/bash
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
if [ "$SYSTEMBIT" = "64" ] && [ "$SYSTEMOS" = "Linux" ];
then
echo "Your system is 64bit version of Debian Linux Kernal"
echo " "
while read -p "Which compiler do you want to use?
-Intel
--Please note that Hurricane WRF (HWRF) is on compatibile with Intel Compilers.
-GNU
Please answer Intel or GNU (case sensative).
" yn; do
case $yn in
Intel)
echo "-------------------------------------------------- "
echo " "
echo "Intel is selected for installation"
export Ubuntu_64bit_Intel=1
break
;;
GNU)
echo "-------------------------------------------------- "
echo " "
echo "GNU is selected for installation"
export Ubuntu_64bit_GNU=1
break
;;
* )
echo " "
echo "Please answer Intel or GNU (case sensative).";;
esac
done
fi
if [ "$SYSTEMBIT" = "32" ] && [ "$SYSTEMOS" = "Linux" ]; then
echo "Your system is not compatibile with this script."
exit ;
fi
################### System Information Tests ##############################
export HOME=`cd;pwd`
export Storage_Space_Size=$(df -h --output=avail ${HOME} | awk 'NR==2 {print $1}' | tr -cd '[:digit:]')
export Storage_Space_Units=$(df -h --output=avail ${HOME} | awk 'NR==2 {print $1}' | tr -cd '[:alpha:]')
export Storage_Space_Required="350"
echo "-------------------------------------------------- "
echo " "
echo " Testing for Storage Space for installation"
echo " "
case $Storage_Space_Units in
[Pp]* )
echo " "
echo "Sufficient storage space for installation found"
echo "-------------------------------------------------- " ;;
[Tt]* )
echo " "
echo "Sufficient storage space for installation found"
echo "-------------------------------------------------- " ;;
[Gg]* )
if [[ ${Storage_Space_Size} -lt ${Storage_Space_Required} ]]; then
echo " "
echo "Not enough storage space for installation"
echo "-------------------------------------------------- "
exit
else
echo " "
echo "Sufficient storage space for installation found."
echo "-------------------------------------------------- "
fi ;;
[MmKk]* )
echo " "
echo "Not enough storage space for installation."
echo "-------------------------------------------------- "
exit ;;
* )
echo " "
echo "Not enough storage space for installation."
echo "-------------------------------------------------- "
exit ;;
esac
echo " "
############################# Chose GrADS or OpenGrADS #########################
while read -p "Which graphic display software should be install?
-OpenGrADS
-GrADS
Please answer with either OpenGrADS or GrADS
" yn; do
case $yn in
OpenGrADS)
echo "-------------------------------------------------- "
echo " "
echo "OpenGrADS selected for installation"
export GRADS_PICK=1 #variable set for grads or opengrads choice
break
;;
GrADS)
echo " "
echo "GrADS selected for installation"
export GRADS_PICK=2 #variable set for grads or opengrads choice
break
;;
* )
echo " "
echo "Please answer OpenGrADS or GrADS (case sensative).";;
esac
done
echo " "
################################# Auto Configuration Test ##################
while true; do
read -p "
Would you like the script to select all the configure options for you?
Please note, that you should not have to type anything else in the terminal.
(Y/N) " yn
case $yn in
[Yy]* )
export auto_config=1 #variable set for one click config and installation
break
;;
[Nn]* )
export auto_config=0 #variable set for manual config and installation
break
;;
* ) echo "Please answer yes or no.";;
esac
done
echo " "
################################# GEOG WPS Geographical Input Data Mandatory for Specific Applications ##################
while true; do
echo "-------------------------------------------------- "
echo " "
echo "Would you like to download the WPS Geographical Input Data for Specific Applications?"
echo " "
echo "Specific Applicaitons files can be viewed here: "
echo " "
echo "https://www2.mmm.ucar.edu/wrf/users/download/get_sources_wps_geog.html"
read -p "(Y/N) " yn
case $yn in
[Yy]* )
export WPS_Specific_Applications=1 #variable set for "YES" for specific application data
break
;;
[Nn]* )
export WPS_Specific_Applications=0 #variable set for "NO" for specific application data
break
;;
* ) echo "Please answer yes or no.";;
esac
done
echo " "
################################# GEOG Optional WPS Geographical Input Data ##################
while true; do
echo "-------------------------------------------------- "
echo " "
echo "Would you like to download the GEOG Optional WPS Geographical Input Data?"
echo " "
echo "Optional Geogrpahical files can be viewed here: "
echo " "
echo "https://www2.mmm.ucar.edu/wrf/users/download/get_sources_wps_geog.html"
read -p "(Y/N) " yn
echo " "
case $yn in
[Yy]* )
export Optional_GEOG=1 #variable set for "YES" for Optional GEOG Data
break
;;
[Nn]* )
export Optional_GEOG=0 #variable set for "NO" for Optional GEOG Data
break
;;
* ) echo "Please answer yes or no.";;
esac
done
echo " "
############################## Choice for which version of WRF to Install ############
while read -p "Which version of WRF would you like to install?
-WRF
-WRFCHEM
-WRFHYDRO_COUPLED
-WRFHYDRO_STANDALONE
-HURRICANE_WRF
Please enter one of the above options (Case Sensative):
" yn; do
case $yn in
HURRICANE_WRF)
echo " "
echo "Hurricane WRF (HWRF) selected for installation"
echo "HWRF is only compatible with Intel Compilers"
echo "All geography files are downloaded and must be installed on system."
export HWRF_PICK=1 #variable set for grads or opengrads choice
break
;;
WRF)
echo " "
echo "WRF selected for installation"
export WRF_PICK=1 #variable set for grads or opengrads choice
break
;;
WRFCHEM)
echo " "
echo "WRFCHEM selected for installation"
export WRFCHEM_PICK=1 #variable set for grads or opengrads choice
break
;;
WRFHYDRO_COUPLED)
echo " "
echo "WRFHYDRO_COUPLED selected for installation"
export WRFHYDRO_COUPLED_PICK=1 #variable set for grads or opengrads choice
break
;;
WRFHYDRO_STANDALONE)
echo " "
echo "WRFHYDRO_STANDALONE selected for installation"
export WRFHYDRO_STANDALONE_PICK=1 #variable set for grads or opengrads choice
break
;;
* )
echo " "
echo "Please answer WRF, WRFCHEM, WRFHYDRO_COUPLED, WRFHYDRO_STANDALONE (All Upper Case).";;
esac
done
echo " "
echo "Beginning Installation"
echo " "
############################ DTC's MET & METPLUS ##################################################
###################################################################################################
if [ "$Ubuntu_64bit_Intel" = "1" ]; then
sudo apt -y update
sudo apt -y upgrade
# download the key to system keyring; this and the following echo command are
# needed in order to install the Intel compilers
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
# add signed entry to apt sources and configure the APT client to use Intel repository:
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
# this update should get the Intel package info from the Intel repository
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install python3 python3-dev emacs flex bison libpixman-1-dev libjpeg-dev pkg-config libpng-dev unzip python2 python2-dev python3-pip pipenv gcc gfortran g++ libtool automake autoconf make m4 default-jre default-jdk csh ksh git libncurses5 libncurses6 mlocate pkg-config build-essential curl libcurl4-openssl-dev
# install the Intel compilers
sudo apt -y install intel-basekit intel-hpckit intel-aikit
sudo apt -y update
# make sure some critical packages have been installed
which cmake pkg-config make gcc g++
# add the Intel compiler file paths to various environment variables
source /opt/intel/oneapi/setvars.sh
# some of the libraries we install below need one or more of these variables
export CC=icc
export CXX=icpc
export FC=ifort
export F77=ifort
export F90=ifort
export MPIFC=mpiifort
export MPIF77=mpiifort
export MPIF90=mpiifort
export MPICC=mpiicc
export MPICXX=mpiicpc
export CFLAGS="-fPIC -fPIE -O3 -diag-disable=10441"
export FFLAGS="-m64"
export FCFLAGS="-m64"
#########################
#Downloading latest dateutil due to python3.8 running old version.
pip3 install python-dateutil==2.8
#Directory Listings
if [ "$WRFCHEM_PICK" = "1" ]; then
mkdir $HOME/WRFCHEM_Intel
export WRF_FOLDER=$HOME/WRFCHEM_Intel
fi
if [ "$WRFHYDRO_PICK" = "1" ]; then
mkdir $HOME/WRFHYDRO_COUPLED_Intel
export WRF_FOLDER=$HOME/WRFHYDRO_COUPLED_Intel
fi
if [ "$WRF_PICK" = "1" ]; then
mkdir $HOME/WRF_Intel
export WRF_FOLDER=$HOME/WRF_Intel
fi
if [ "$HWRF_PICK" = "1" ]; then
mkdir $HOME/HWRF
export WRF_FOLDER=$HOME/HWRF
fi
mkdir $WRF_FOLDER/MET-11.0.0
mkdir $WRF_FOLDER/MET-11.0.0/Downloads
mkdir $WRF_FOLDER/METplus-5.0.0
mkdir $WRF_FOLDER/METplus-5.0.0/Downloads
#Downloading MET and untarring files
#Note weblinks change often update as needed.
cd $WRF_FOLDER/MET-11.0.0/Downloads
wget -c -4 https://raw.githubusercontent.com/dtcenter/MET/main_v11.0/internal/scripts/installation/compile_MET_all.sh
wget -c -4 https://dtcenter.ucar.edu/dfiles/code/METplus/MET/installation/tar_files.tgz
wget -c -4 https://github.com/dtcenter/MET/archive/refs/tags/v11.0.0.tar.gz
cp compile_MET_all.sh $WRF_FOLDER/MET-11.0.0
tar -xvzf tar_files.tgz -C $WRF_FOLDER/MET-11.0.0
cp v11.0.0.tar.gz $WRF_FOLDER/MET-11.0.0/tar_files
cd $WRF_FOLDER/MET-11.0.0
cd $WRF_FOLDER/MET-11.0.0
export PYTHON_VERSION=$(/opt/intel/oneapi/intelpython/latest/bin/python3 -V 2>&1|awk '{print $2}')
export PYTHON_VERSION_MAJOR_VERSION=$(echo $PYTHON_VERSION | awk -F. '{print $1}')
export PYTHON_VERSION_MINOR_VERSION=$(echo $PYTHON_VERSION | awk -F. '{print $2}')
export PYTHON_VERSION_COMBINED=$PYTHON_VERSION_MAJOR_VERSION.$PYTHON_VERSION_MINOR_VERSION
export CC=icc
export CXX=icpc
export FC=ifort
export F77=ifort
export F90=ifort
export gcc_version=$(icc -dumpversion -diag-disable=10441)
export TEST_BASE=$WRF_FOLDER/MET-11.0.0
export COMPILER=intel_$gcc_version
export MET_SUBDIR=${TEST_BASE}
export MET_TARBALL=v11.0.0.tar.gz
export USE_MODULES=FALSE
export MET_PYTHON=/opt/intel/oneapi/intelpython/python${PYTHON_VERSION_COMBINED}
export MET_PYTHON_CC=-I${MET_PYTHON}/include/python${PYTHON_VERSION_COMBINED}
export MET_PYTHON_LD=-L${MET_PYTHON}/lib/python${PYTHON_VERSION_COMBINED}/config-${PYTHON_VERSION_COMBINED}-x86_64-linux-gnu\ -L${MET_PYTHON}/lib\ -lpython${PYTHON_VERSION_COMBINED}\ -lcrypt\ -lpthread\ -ldl\ -lm\ -lm #investigate -lutil
export SET_D64BIT=FALSE
chmod 775 compile_MET_all.sh
# SED statement needed to fix bug in MET compile script. Can be removed after bugfix
sed -i '426s|fi|export LIB_Z=${LIB_DIR}/lib \nfi|g' $WRF_FOLDER/MET-11.0.0/compile_MET_all.sh
./compile_MET_all.sh
export PATH=$WRF_FOLDER/MET-11.0.0/bin:$PATH #Add MET executables to path
#Basic Package Management for Model Evaluation Tools (METplus)
sudo apt-get -y update
sudo apt-get -y upgrade
#Directory Listings for Model Evaluation Tools (METplus
mkdir $WRF_FOLDER/METplus-5.0.0
mkdir $WRF_FOLDER/METplus-5.0.0/Sample_Data
mkdir $WRF_FOLDER/METplus-5.0.0/Output
mkdir $WRF_FOLDER/METplus-5.0.0/Downloads
#Downloading METplus and untarring files
cd $WRF_FOLDER/METplus-5.0.0/Downloads
wget -c -4 https://github.com/dtcenter/METplus/archive/refs/tags/v5.0.0.tar.gz
tar -xvzf v5.0.0.tar.gz -C $WRF_FOLDER
# Insatlllation of Model Evaluation Tools Plus
cd $WRF_FOLDER/METplus-5.0.0/parm/metplus_config
sed -i "s|MET_INSTALL_DIR = /path/to|MET_INSTALL_DIR = $WRF_FOLDER/MET-11.0.0|" defaults.conf
sed -i "s|INPUT_BASE = /path/to|INPUT_BASE = $WRF_FOLDER/METplus-5.0.0/Sample_Data|" defaults.conf
sed -i "s|OUTPUT_BASE = /path/to|OUTPUT_BASE = $WRF_FOLDER/METplus-5.0.0/Output|" defaults.conf
# Downloading Sample Data
cd $WRF_FOLDER/METplus-5.0.0/Downloads
wget -c -4 https://dtcenter.ucar.edu/dfiles/code/METplus/METplus_Data/v5.0/sample_data-met_tool_wrapper-5.0.tgz
tar -xvzf sample_data-met_tool_wrapper-5.0.tgz -C $WRF_FOLDER/METplus-5.0.0/Sample_Data
# Testing if installation of MET & METPlus was sucessfull
# If you see in terminal "METplus has successfully finished running."
# Then MET & METPLUS is sucessfully installed
echo 'Testing MET & METPLUS Installation.'
$WRF_FOLDER/METplus-5.0.0/ush/run_metplus.py -c $WRF_FOLDER/METplus-5.0.0/parm/use_cases/met_tool_wrapper/GridStat/GridStat.conf
export PATH=$WRF_FOLDER/METplus-5.0.0/ush:$PATH
echo " "
read -t 5 -p "MET and METPLUS sucessfully installed with intel compilers"
fi
if [ "$Ubuntu_64bit_GNU" = "1" ]; then
export HOME=`cd;pwd`
#Basic Package Management for Model Evaluation Tools (MET)
#############################basic package managment############################
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install python3 python3-dev emacs flex bison libpixman-1-dev libjpeg-dev pkg-config libpng-dev unzip python2 python2-dev python3-pip pipenv gcc gfortran g++ libtool automake autoconf make m4 default-jre default-jdk csh ksh git libncurses5 libncurses6 mlocate pkg-config build-essential curl libcurl4-openssl-dev
#Downloading latest dateutil due to python3.8 running old version.
pip3 install python-dateutil==2.8
#Directory Listings
if [ "$WRFCHEM_PICK" = "1" ]; then
mkdir $HOME/WRFCHEM
export WRF_FOLDER=$HOME/WRFCHEM
fi
if [ "$WRFHYDRO_PICK" = "1" ]; then
mkdir $HOME/WRFHYDRO_COUPLED
export WRF_FOLDER=$HOME/WRFHYDRO_COUPLED
fi
if [ "$WRF_PICK" = "1" ]; then
mkdir $HOME/WRF
export WRF_FOLDER=$HOME/WRF
fi
mkdir $WRF_FOLDER/MET-11.0.0
mkdir $WRF_FOLDER/MET-11.0.0/Downloads
mkdir $WRF_FOLDER/METplus-5.0.0
mkdir $WRF_FOLDER/METplus-5.0.0/Downloads
#Downloading MET and untarring files
#Note weblinks change often update as needed.
cd $WRF_FOLDER/MET-11.0.0/Downloads
wget -c -4 https://raw.githubusercontent.com/dtcenter/MET/main_v11.0/internal/scripts/installation/compile_MET_all.sh
wget -c -4 https://dtcenter.ucar.edu/dfiles/code/METplus/MET/installation/tar_files.tgz
wget -c -4 https://github.com/dtcenter/MET/archive/refs/tags/v11.0.0.tar.gz
cp compile_MET_all.sh $WRF_FOLDER/MET-11.0.0
tar -xvzf tar_files.tgz -C $WRF_FOLDER/MET-11.0.0
cp v11.0.0.tar.gz $WRF_FOLDER/MET-11.0.0/tar_files
cd $WRF_FOLDER/MET-11.0.0
# Installation of Model Evaluation Tools
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
export FC=/usr/bin/gfortran
export F77=/usr/bin/gfortran
export CFLAGS="-fPIC -fPIE -O3"
cd $WRF_FOLDER/MET-11.0.0
export GCC_VERSION=$(/usr/bin/gcc -dumpfullversion | awk '{print$1}')
export GFORTRAN_VERSION=$(/usr/bin/gfortran -dumpfullversion | awk '{print$1}')
export GPLUSPLUS_VERSION=$(/usr/bin/g++ -dumpfullversion | awk '{print$1}')
export GCC_VERSION_MAJOR_VERSION=$(echo $GCC_VERSION | awk -F. '{print $1}')
export GFORTRAN_VERSION_MAJOR_VERSION=$(echo $GFORTRAN_VERSION | awk -F. '{print $1}')
export GPLUSPLUS_VERSION_MAJOR_VERSION=$(echo $GPLUSPLUS_VERSION | awk -F. '{print $1}')
export version_10="10"
if [ $GCC_VERSION_MAJOR_VERSION -lt $version_10 ] || [ $GFORTRAN_VERSION_MAJOR_VERSION -lt $version_10 ] || [ $GPLUSPLUS_VERSION_MAJOR_VERSION -lt $version_10 ]
then
sed -i 's/-fno-second-underscore -fallow-argument-mismatch/-fno-second-underscore -Wno-argument-mismatch/g' compile_MET_all.sh
fi
export PYTHON_VERSION=$(/usr/bin/python3 -V 2>&1|awk '{print $2}')
export PYTHON_VERSION_MAJOR_VERSION=$(echo $PYTHON_VERSION | awk -F. '{print $1}')
export PYTHON_VERSION_MINOR_VERSION=$(echo $PYTHON_VERSION | awk -F. '{print $2}')
export PYTHON_VERSION_COMBINED=$PYTHON_VERSION_MAJOR_VERSION.$PYTHON_VERSION_MINOR_VERSION
export FC=/usr/bin/gfortran
export F77=/usr/bin/gfortran
export F90=/usr/bin/gfortran
export gcc_version=$(gcc -dumpfullversion)
export TEST_BASE=$WRF_FOLDER/MET-11.0.0
export COMPILER=gnu_$gcc_version
export MET_SUBDIR=${TEST_BASE}
export MET_TARBALL=v11.0.0.tar.gz
export USE_MODULES=FALSE
export MET_PYTHON=/usr
export MET_PYTHON_CC=-I${MET_PYTHON}/include/python${PYTHON_VERSION_COMBINED}
export MET_PYTHON_LD=-L${MET_PYTHON}/lib/python${PYTHON_VERSION_COMBINED}/config-${PYTHON_VERSION_COMBINED}-x86_64-linux-gnu\ -L${MET_PYTHON}/lib\ -lpython${PYTHON_VERSION_COMBINED}\ -lcrypt\ -lpthread\ -ldl\ -lutil\ -lm
export SET_D64BIT=FALSE
chmod 775 compile_MET_all.sh
#SED statement needed to fix bug in MET compile script. Can be removed after bugfix
sed -i '426s|fi|export LIB_Z=${LIB_DIR}/lib \nfi|g' $WRF_FOLDER/MET-11.0.0/compile_MET_all.sh
./compile_MET_all.sh |& tee compile_MET_all.log
export PATH=$WRF_FOLDER/MET-11.0.0/bin:$PATH
#basic Package Management for Model Evaluation Tools (METplus)
sudo apt-get -y update
sudo apt-get -y upgrade
#Directory Listings for Model Evaluation Tools (METplus
mkdir $WRF_FOLDER/METplus-5.0.0
mkdir $WRF_FOLDER/METplus-5.0.0/Sample_Data
mkdir $WRF_FOLDER/METplus-5.0.0/Output
mkdir $WRF_FOLDER/METplus-5.0.0/Downloads
#Downloading METplus and untarring files
cd $WRF_FOLDER/METplus-5.0.0/Downloads
wget -c -4 https://github.com/dtcenter/METplus/archive/refs/tags/v5.0.0.tar.gz
tar -xvzf v5.0.0.tar.gz -C $WRF_FOLDER
# Insatlllation of Model Evaluation Tools Plus
cd $WRF_FOLDER/METplus-5.0.0/parm/metplus_config
sed -i "s|MET_INSTALL_DIR = /path/to|MET_INSTALL_DIR = $WRF_FOLDER/MET-11.0.0|" defaults.conf
sed -i "s|INPUT_BASE = /path/to|INPUT_BASE = $WRF_FOLDER/METplus-5.0.0/Sample_Data|" defaults.conf
sed -i "s|OUTPUT_BASE = /path/to|OUTPUT_BASE = $WRF_FOLDER/METplus-5.0.0/Output|" defaults.conf
# Downloading Sample Data
cd $WRF_FOLDER/METplus-5.0.0/Downloads
wget -c -4 https://dtcenter.ucar.edu/dfiles/code/METplus/METplus_Data/v5.0/sample_data-met_tool_wrapper-5.0.tgz
tar -xvzf sample_data-met_tool_wrapper-5.0.tgz -C $WRF_FOLDER/METplus-5.0.0/Sample_Data
# Testing if installation of MET & METPlus was sucessfull
# If you see in terminal "METplus has successfully finished running."
# Then MET & METPLUS is sucessfully installed
echo 'Testing MET & METPLUS Installation.'
$WRF_FOLDER/METplus-5.0.0/ush/run_metplus.py -c $WRF_FOLDER/METplus-5.0.0/parm/use_cases/met_tool_wrapper/GridStat/GridStat.conf
export PATH=$WRF_FOLDER/METplus-5.0.0/ush:$PATH
read -t 5 -p "MET and METPLUS sucessfully installed with GNU compilers."
fi
##################################### WRFCHEM Tools ###############################################
# This script will install the WRFCHEM pre-processor tools.
# Information on these tools can be found here:
# https://www2.acom.ucar.edu/wrf-chem/wrf-chem-tools-community#download
#
# Addtional information on WRFCHEM can be found here:
# https://ruc.noaa.gov/wrf/wrf-chem/
#
# We ask users of the WRF-Chem preprocessor tools to include in any publications the following acknowledgement:
# "We acknowledge use of the WRF-Chem preprocessor tool {mozbc, fire_emiss, etc.} provided by the Atmospheric Chemistry Observations and Modeling Lab (ACOM) of NCAR."
#
#
# This script installs the WRFCHEM Tools with gnu or intel compilers.
####################################################################################################
if [ "$Ubuntu_64bit_GNU" = "1" ] && [ "$WRFCHEM_PICK" = "1" ]; then
# Basic Package Management for WRF-CHEM Tools and Processors
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt -y install python3 python3-dev emacs flex bison libpixman-1-dev libjpeg-dev pkg-config libpng-dev unzip python2 python2-dev python3-pip pipenv gcc gfortran g++ libtool automake autoconf make m4 default-jre default-jdk csh ksh git libncurses5 libncurses6 mlocate pkg-config build-essential curl libcurl4-openssl-dev byacc flex
#Directory Listings
export HOME=`cd;pwd`
mkdir $HOME/WRFCHEM
export WRFCHEM_FOLDER=$HOME/WRFCHEM
cd $HOME/WRFCHEM
mkdir Downloads
mkdir Libs
mkdir Libs/grib2
mkdir Libs/NETCDF
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/Libs
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/Libs/grib2
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/Libs/NETCDF
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/mozbc
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/megan_bio_emiss
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/megan_bio_data
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/wes_coldens
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/ANTHRO_EMIS
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/EDGAR_HTAP
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/EPA_ANTHRO_EMIS
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/UBC
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/Aircraft
mkdir $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN
##############################Downloading Libraries############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
wget -c -4 https://github.com/madler/zlib/archive/refs/tags/v1.2.13.tar.gz
wget -c -4 https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_13_2.tar.gz
wget -c -4 https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.0.tar.gz
wget -c -4 https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.0.tar.gz
wget -c -4 https://download.sourceforge.net/libpng/libpng-1.6.39.tar.gz
wget -c -4 https://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.1.zip
wget -c -4 https://github.com/pmodels/mpich/releases/download/v4.0.3/mpich-4.0.3.tar.gz
#############################Core Management####################################
export CPU_CORE=$(nproc) # number of available threads on system
export CPU_6CORE="6"
export CPU_HALF=$(($CPU_CORE / 2)) #half of availble cores on system
export CPU_HALF_EVEN=$(( $CPU_HALF - ($CPU_HALF % 2) )) #Forces CPU cores to even number to avoid partial core export. ie 7 cores would be 3.5 cores.
if [ $CPU_CORE -le $CPU_6CORE ] #If statement for low core systems. Forces computers to only use 1 core if there are 4 cores or less on the system.
then
export CPU_HALF_EVEN="2"
else
export CPU_HALF_EVEN=$(( $CPU_HALF - ($CPU_HALF % 2) ))
fi
echo "##########################################"
echo "Number of threads being used $CPU_HALF_EVEN"
echo "##########################################"
echo " "
#############################Compilers############################
export DIR=$WRFCHEM_FOLDER/WRF_CHEM_Tools/Libs
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
export CFLAGS="-fPIC -fPIE -O3"
#IF statement for GNU compiler issue
export GCC_VERSION=$(/usr/bin/gcc -dumpfullversion | awk '{print$1}')
export GFORTRAN_VERSION=$(/usr/bin/gfortran -dumpfullversion | awk '{print$1}')
export GPLUSPLUS_VERSION=$(/usr/bin/g++ -dumpfullversion | awk '{print$1}')
export GCC_VERSION_MAJOR_VERSION=$(echo $GCC_VERSION | awk -F. '{print $1}')
export GFORTRAN_VERSION_MAJOR_VERSION=$(echo $GFORTRAN_VERSION | awk -F. '{print $1}')
export GPLUSPLUS_VERSION_MAJOR_VERSION=$(echo $GPLUSPLUS_VERSION | awk -F. '{print $1}')
export version_10="10"
if [ $GCC_VERSION_MAJOR_VERSION -ge $version_10 ] || [ $GFORTRAN_VERSION_MAJOR_VERSION -ge $version_10 ] || [ $GPLUSPLUS_VERSION_MAJOR_VERSION -ge $version_10 ]
then
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz
else
export fallow_argument=
export boz_argument=
fi
export FFLAGS="$fallow_argument -m64"
export FCFLAGS="$fallow_argument -m64"
echo "##########################################"
echo "FFLAGS = $FFLAGS"
echo "FCFLAGS = $FCFLAGS"
echo "##########################################"
#############################zlib############################
#Uncalling compilers due to comfigure issue with zlib1.2.13
#With CC & CXX definied ./configure uses different compiler Flags
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
tar -xvzf v1.2.13.tar.gz
cd zlib-1.2.13/
./configure --prefix=$DIR/grib2
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install
#make check
##############################MPICH############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
tar -xvzf mpich-4.0.3.tar.gz
cd mpich-4.0.3/
F90= ./configure --prefix=$DIR/MPICH --with-device=ch3 FFLAGS="$fallow_argument -m64" FCFLAGS="$fallow_argument -m64"
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
export PATH=$DIR/MPICH/bin:$PATH
export MPIFC=$DIR/MPICH/bin/mpifort
export MPIF77=$DIR/MPICH/bin/mpifort
export MPIF90=$DIR/MPICH/bin/mpifort
export MPICC=$DIR/MPICH/bin/mpicc
export MPICXX=$DIR/MPICH/bin/mpicxx
echo " "
#############################libpng############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include
tar -xvzf libpng-1.6.39.tar.gz
cd libpng-1.6.39/
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/grib2
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install
#make check
#############################JasPer############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
unzip jasper-1.900.1.zip
cd jasper-1.900.1/
autoreconf -i
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/grib2
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
#############################hdf5 library for netcdf4 functionality############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
tar -xvzf hdf5-1_13_2.tar.gz
cd hdf5-hdf5-1_13_2
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/grib2 --with-zlib=$DIR/grib2 --enable-hl --enable-fortran --enable-parallel
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install
#make check
export HDF5=$DIR/grib2
export PHDF5=$DIR/grib2
export LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH
echo " "
#############################Install Parallel-netCDF##############################
#Make file created with half of available cpu cores
#Hard path for MPI added
##################################################################################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
wget -c -4 https://parallel-netcdf.github.io/Release/pnetcdf-1.12.3.tar.gz
tar -xvzf pnetcdf-1.12.3.tar.gz
cd pnetcdf-1.12.3
./configure --prefix=$DIR/grib2 --enable-shared --enable-static
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install
#make check
export PNETCDF=$DIR/grib2
##############################Install NETCDF C Library############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
tar -xzvf v4.9.0.tar.gz
cd netcdf-c-4.9.0/
export CPPFLAGS=-I$DIR/grib2/include
export LDFLAGS=-L$DIR/grib2/lib
export LIBS="-lhdf5_hl -lhdf5 -lz -lcurl -lgfortran -lgcc -lm -ldl"
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/NETCDF --with-zlib=$DIR/grib2 --disable-dap --enable-netcdf-4 --enable-netcdf4 --enable-shared --enable-pnetcdf --enable-cdf5 --enable-parallel-tests
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install
#make check
export PATH=$DIR/NETCDF/bin:$PATH
export NETCDF=$DIR/NETCDF
##############################NetCDF fortran library############################
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
tar -xvzf v4.6.0.tar.gz
cd netcdf-fortran-4.6.0/
export LD_LIBRARY_PATH=$DIR/NETCDF/lib:$LD_LIBRARY_PATH
export CPPFLAGS="-I$DIR/NETCDF/include -I$DIR/grib2/include"
export LDFLAGS="-L$DIR/NETCDF/lib -L$DIR/grib2/lib"
export LIBS="-lnetcdf -lpnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -ldl"
CC=$MPICC FC=$MPIFC CXX=$MPICXX F90=$MPIF90 F77=$MPIF77 ./configure --prefix=$DIR/NETCDF --enable-netcdf-4 --enable-netcdf4 --enable-shared --enable-parallel-tests --enable-hdf5
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
echo " "
# Downloading WRF-CHEM Tools and untarring files
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads
wget -c -4 https://www.acom.ucar.edu/wrf-chem/mozbc.tar
wget -c -4 https://www.acom.ucar.edu/wrf-chem/UBC_inputs.tar
wget -c -4 https://www.acom.ucar.edu//wrf-chem/megan_bio_emiss.tar
wget -c -4 https://www.acom.ucar.edu/wrf-chem/megan.data.tar.gz
wget -c -4 https://www.acom.ucar.edu/wrf-chem/wes-coldens.tar
wget -c -4 https://www.acom.ucar.edu/wrf-chem/ANTHRO.tar
wget -c -4 https://www.acom.ucar.edu/webt/wrf-chem/processors/EDGAR-HTAP.tgz
wget -c -4 https://www.acom.ucar.edu/wrf-chem/EPA_ANTHRO_EMIS.tgz
wget -c -4 https://www2.acom.ucar.edu/sites/default/files/documents/aircraft_preprocessor_files.tar
# Downloading FINN
wget -c -4 https://www.acom.ucar.edu/Data/fire/data/finn2/FINNv2.4_MOD_MOZART_2020_c20210617.txt.gz
wget -c -4 https://www.acom.ucar.edu/Data/fire/data/finn2/FINNv2.4_MOD_MOZART_2013_c20210617.txt.gz
wget -c -4 https://www.acom.ucar.edu/Data/fire/data/finn2/FINNv2.4_MODVRS_MOZART_2019_c20210615.txt.gz
wget -c -4 https://www.acom.ucar.edu/Data/fire/data/fire_emis.tgz
wget -c -4 https://www.acom.ucar.edu/Data/fire/data/fire_emis_input.tar
wget -c -4 https://www.acom.ucar.edu/Data/fire/data/TrashEmis.zip
echo ""
echo "Unpacking Mozbc."
tar -xvf mozbc.tar -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/mozbc
echo ""
echo "Unpacking MEGAN Bio Emission."
tar -xvf megan_bio_emiss.tar -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/megan_bio_emiss
echo ""
echo "Unpacking MEGAN Bio Emission Data."
tar -xzvf megan.data.tar.gz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/megan_bio_data
echo ""
echo "Unpacking Wes Coldens"
tar -xvf wes-coldens.tar -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/wes_coldens
echo ""
echo "Unpacking Unpacking ANTHRO Emission."
tar -xvf ANTHRO.tar -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/ANTHRO_EMIS
echo ""
echo "Unpacking EDGAR-HTAP."
tar -xzvf EDGAR-HTAP.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/EDGAR_HTAP
echo ""
echo "Unpacking EPA ANTHRO Emission."
tar -xzvf EPA_ANTHRO_EMIS.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/EPA_ANTHRO_EMIS
echo ""
echo "Unpacking Upper Boundary Conditions."
tar -xvf UBC_inputs.tar -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/UBC
echo ""
echo "Unpacking Aircraft Preprocessor Files."
echo ""
tar -xvf aircraft_preprocessor_files.tar -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/Aircraft
echo ""
echo "Unpacking Fire INventory from NCAR (FINN)"
tar -xzvf fire_emis.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN
tar -xvf fire_emis_input.tar
tar -zxvf grass_from_img.nc.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN/grid_finn_fire_emis_v2020/src
tar -zxvf tempfor_from_img.nc.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN/grid_finn_fire_emis_v2020/src
tar -zxvf shrub_from_img.nc.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN/grid_finn_fire_emis_v2020/src
tar -zxvf tropfor_from_img.nc.tgz -C $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN/grid_finn_fire_emis_v2020/src
mv $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads/FINNv2.4_MOD_MOZART_2020_c20210617.txt.gz $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN
mv $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads/FINNv2.4_MOD_MOZART_2013_c20210617.txt.gz $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN
mv $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads/FINNv2.4_MODVRS_MOZART_2019_c20210615.txt.gz $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN
unzip TrashEmis.zip
mv $WRFCHEM_FOLDER/WRF_CHEM_Tools/Downloads/ALL_Emiss_04282014.nc $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN/grid_finn_fire_emis_v2020/src
cd $WRFCHEM_FOLDER/WRF_CHEM_Tools/FINN