check if USENETCDFPAR is empty first (#1743)
[WRF.git] / hydro / configure
blobce896c95fe08d0faf74d8ae45781edaae04906a2
1 #!/bin/bash
3 theArgument=$1
5 ###################################
6 ## Setup the HOSTNAME if not set
8 if [ -z ${HOSTNAME+x} ]; then
9 HOSTNAME=`hostname`
10 echo "Configured: hostname=$HOSTNAME"
13 ###################################
14 ## Setup the NetCDF include and LIB variables.
15 ## If Neither is set and neither $NETCDF nor $NETCDF_DIR is not set,
16 ## then try nc-config. If that fails, all fails.
18 if [[ -z $NETCDF ]]; then
19 if [[ -n $NETCDF_DIR ]]; then
20 NETCDF=$NETCDF_DIR
24 if [[ -z $NETCDF_INC ]]; then
25 if [[ -z $NETCDF ]]; then
26 NETCDF_INC=`nc-config --includedir 2> /dev/null`
27 else
28 NETCDF_INC=${NETCDF}/include
30 if [[ -z $NETCDF_INC ]]; then
31 echo "Error: environment variable NETCDF_INC not defined."
32 exit 1
34 echo "NETCDF_INC = ${NETCDF_INC}" > macros.tmp
37 if [[ -z $NETCDF_LIB ]]; then
38 if [[ -z $NETCDF ]]; then
39 NETCDF_LIB=`nc-config --libs | cut -c3- | cut -d' ' -f1`
40 else
41 NETCDF_LIB=${NETCDF}/lib
43 if [[ -z $NETCDF_LIB ]]; then
44 echo "Error: environment variable NETCDF_LIB not defined."
45 exit 1
47 echo "NETCDF_LIB = ${NETCDF_LIB}" >> macros.tmp
50 if [[ ! -e ${NETCDF_LIB}/libnetcdff.a ]]; then
51 echo "NETCDFLIB = -L${NETCDF_LIB} -lnetcdf" >> macros.tmp
54 ###################################
55 ## File/dir setups
56 if [[ -e macros ]]; then rm -f macros; fi
57 if [[ ! -e lib ]]; then mkdir lib; fi
58 if [[ ! -e mod ]]; then mkdir mod; fi
61 ###################################
62 ## If no argument was supplied, get all interactive.
63 if [[ -z $theArgument ]]; then
64 echo "Please select from following supported linux compilers"
65 echo "using either the number or key (not case sensitive):"
66 echo
67 echo "Number Key Description"
68 echo "---------------------------------------------------"
69 echo " 1 pgi PGI parallel"
70 echo " 2 gfort gfortran parallel"
71 echo " 3 ifort intel parallel (incl. Theia, Gordon, Summit)"
72 echo " 4 luna intel parallel (WCOSS Luna)"
73 echo " 5 ifort_omp intel openmp"
74 echo " 6 intel.cray_xc intel parallel (cray_xc)"
75 echo " 7 cray_fortran Cray Fortran PE (ftn)"
76 echo " 0 exit exit"
77 echo
78 read -p "Enter selection: " theArgument
79 echo
82 ## remove case sensitivity
83 theArgument=`echo $theArgument | tr '[:upper:]' '[:lower:]'`
86 ###################################
87 ## What to do with the choice
89 if [[ "$theArgument" == "1" ]] || [[ "$theArgument" == "pgi" ]]; then
90 cp arc/macros.mpp.linux macros
91 cp arc/Makefile.mpp Makefile.comm
92 echo "Configured: PGI"
95 if [[ "$theArgument" == "2" ]] || [[ "$theArgument" == "gfort" ]]; then
96 cp arc/macros.mpp.gfort macros
97 cp arc/Makefile.mpp Makefile.comm
98 echo "Configured: gfort"
101 if [[ "$theArgument" == "3" ]] || [[ "$theArgument" == "ifort" ]]; then
103 ## theia login machines self identify as "tfe" and have
104 ## their own intel macros. We handle luna more explicitly...
105 if [[ $HOSTNAME = *tfe* ]]; then
106 cp arc/macros.mpp.ifort.theia macros
107 echo "Configured: ifort on Theia"
109 elif [[ $HOSTNAME = *gordon* ]]; then
110 cp arc/macros.mpp.intel.cray_xc macros
111 echo "Configured: ifort on Gordon"
113 elif [[ $HOSTNAME = *shas* ]]; then
114 cp arc/macros.mpp.ifort.summit_has macros
115 echo "Configured: ifort on Summit haswell"
117 else
118 cp arc/macros.mpp.ifort macros
119 echo "Configured: ifort"
121 cp arc/Makefile.mpp Makefile.comm
124 if [[ "$theArgument" == "4" ]] || [[ "$theArgument" == "luna" ]]; then
125 cp arc/macros.mpp.ifort.luna macros
126 cp arc/Makefile.mpp Makefile.comm
127 echo "Configured: ifort on Luna"
130 if [[ "$theArgument" == "5" ]] || [[ "$theArgument" == "ifort_omp" ]]; then
131 ## theia login machines self identify as "tfe" and have
132 ## their own intel macros. We handle luna more explicitly...
133 if [[ $HOSTNAME != *tfe* ]]; then
134 cp arc/macros.mpp.ifort.omp macros
135 echo "Configured: ifort with OpenMP"
136 else
137 cp arc/macros.mpp.ifort.theia macros
138 echo "Configured: ifort on Theia"
140 cp arc/Makefile.mpp Makefile.comm
143 if [[ "$theArgument" == "6" ]] || [[ "$theArgument" == "intel.cray_xc" ]]; then
144 cp arc/macros.mpp.intel.cray_xc macros
145 cp arc/Makefile.mpp Makefile.comm
146 echo "Configured: ifort on cray_xc"
149 if [[ "$theArgument" == "7" ]] || [[ "$theArgument" == "cray_fortran" ]]; then
150 cp arc/macros.mpp.cray_fortran macros
151 cp arc/Makefile.mpp Makefile.comm
152 echo "Configured: Cray Fortran PrgEnv"
156 ## The above result in a new macros file which was
157 ## previously deleted. If it does not exist, none
158 ## were chosen.
159 if [[ ! -e macros ]]; then
160 echo "No compiler selected. Exiting"
161 if [[ -e macros.tmp ]]; then rm -f macros.tmp; fi
162 # failure
163 exit 1
166 # PGI sequential
167 # cp arc/macros.seq.linux macros
168 # cp arc/Makefile.seq Makefile.comm
169 # gfortran sequential
170 #zystem "cp arc/macros.seq.gfort macros
171 #cp arc/Makefile.seq Makefile.comm
172 # ifort sequential
173 #cp arc/macros.seq.ifort macros
174 #cp arc/Makefile.seq Makefile.comm
176 if [[ -e macros.tmp ]]; then
177 cat macros macros.tmp > macros.a
178 rm -f macros.tmp
179 mv macros.a macros
182 ## success
183 exit 0