#!/bin/sh arg1=$1 CORE_DIR=`pwd` echo "$CORE_DIR" export CORE_DIR while [ $# -ge 1 ]; do case $1 in library) HWRF_LIBRARY=1 ; break ;; esac shift done # Look for netcdf if test -z "$NETCDF" ; then for p in /usr/local/netcdf do if test -d $p ; then NETCDF=$p break fi done fi if test -z "$NETCDF" ; then bedone="" if [ -d ./netcdf_links ] ; then echo '** There is an existing ./netcdf_links file. Should I use? [y]' read resp if [ "$resp" = "y" ] ; then NETCDF=`pwd`/netcdf_links bedone="yes" else echo 'Removing existing ./netcdf_links directory' /bin/rm -fr ./netcdf_links fi else echo '** WARNING: No path to NETCDF and environment variable NETCDF not set.' echo '** would you like to try to fix? [y]' fi netcdfipath="" netcdflpath="" while [ -z "$bedone" ] ; do read resp if [ "$resp" = "y" -o -z "$resp" ] ; then if [ -d ./netcdf_links ] ; then echo 'There is already a ./netcdf_links directory. Okay to use links' echo 'in this directory for NetCDF include and lib dirs? [y]' read resp if [ "$resp" = "y" ] ; then NETCDF=`pwd`/netcdf_links export NETCDF bedone="yes" continue fi fi if [ -z "$netcdfipath" ] ; then echo 'Enter full path to NetCDF include directory on your system' read resp if [ ! -d "$resp" ] ; then echo "invalid path: $resp. Try again? [y]" ; continue fi netcdfipath=$resp fi if [ -z "$netcdflpath" ] ; then echo 'Enter full path to NetCDF library directory on your system' read resp if [ ! -d "$resp" ] ; then echo "invalid path: $resp. Try again? [y]" ; continue fi netcdflpath=$resp fi if [ -n "$netcdflpath" -a -n "$netcdfipath" ] ; then if [ -d ./netcdf_links ] ; then echo 'Existing ./netcdf_links directory. Okay to remove. [y]' read resp if [ "$resp" = "y" ] ; then /bin/rm -fr ./netcdf_links fi fi mkdir ./netcdf_links cd ./netcdf_links ln -s "$netcdfipath" include ln -s "$netcdflpath" lib cd .. echo created new ./netcdf_links directory /bin/ls -lF ./netcdf_links NETCDF=`pwd`/netcdf_links export NETCDF bedone="yes" fi else bedone="yes" fi done fi USENETCDFF="" # see below if [ -n "$NETCDF" ] ; then echo "Will use NETCDF in dir: $NETCDF" # for 3.6.2 and greater there might be a second library, libnetcdff.a . Check for # this and use if available if [ -f "$NETCDF/lib/libnetcdff.a" ] ; then USENETCDFF="-lnetcdff" fi else echo "NETCDF is required to compile hwrf-utilities; please re-configure and try again" exit fi # Look for wrf libs if test -z "$WRF_DIR" ; then for p in `pwd`/../WRFV3 do if test -d $p ; then WRF_DIR=$p break fi done fi # Set $MKL and $MKLROOT if one is set. This is needed because system # admins choose randomly as to which variable to set. if [[ -z "$MKLROOT" && ! -z "$MKL" ]] ; then export MKLROOT="$MKL" elif [[ ! -z "$MKLROOT" && -z "$MKL" ]] ; then export MKL="$MKLROOT" fi if [[ ! -z "$JASPERINC" && ! -z "$JASPERLIB" ]] ; then export CONFIGURE_WRF_GRIB2="-L\$(WRF_DIR)/external/io_grib2 -lio_grib2 -L$JASPERLIB -ljasper" export CONFIGURE_C_GRIB2="-I$JASPERINC" if [[ ! -z "$PNG_LDFLAGS" ]] ; then export CONFIGURE_WRF_GRIB2="$CONFIGURE_WRF_GRIB2 $PNG_LDFLAGS" else export CONFIGURE_WRF_GRIB2="$CONFIGURE_WRF_GRIB2 -lpng" fi if [[ ! -z "$PNG_CFLAGS" ]] ; then export CONFIGURE_C_GRIB2="$CONFIGURE_C_GRIB2 $PNG_CFLAGS" fi if [[ ! -z "$Z_LDFLAGS" ]] ; then export CONFIGURE_WRF_GRIB2="$CONFIGURE_WRF_GRIB2 $Z_LDFLAGS" else export CONFIGURE_WRF_GRIB2="$CONFIGURE_WRF_GRIB2 -lz" fi if [[ ! -z "$Z_CFLAGS" ]] ; then export CONFIGURE_C_GRIB2="$CONFIGURE_C_GRIB2 $Z_CFLAGS" fi fi if [[ ! -z "$PNETCDF" ]] ; then export CONFIGURE_WRF_PNETCDF="-L\$(WRF_DIR)/external/io_pnetcdf -lwrfio_pnf -L$PNETCDF/lib -lpnetcdf" fi # need the directory to the WRF build unless only building the libs if [ "$HWRF_LIBRARY" != "1" ]; then if test -z "$WRF_DIR" ; then bedone="" echo '** WARNING: No path to WRF_DIR and environment variable WRF_DIR not set.' echo '** would you like to try to fix? [y]' wrfpath="" while [ -z "$bedone" ] ; do read resp if [ "$resp" = "y" -o -z "$resp" ] ; then if [ -z "$wrfpath" ] ; then echo 'Enter full path to WRF install directory on your system (i.e. $HOME/WRFV3) ' read resp if [ ! -d "$resp" ] ; then echo "invalid path: $resp. Try again? [y]" ; continue fi wrfpath=$resp fi if [ -n "$wrfpath" ] ; then WRF_DIR=$wrfpath export WRF_DIR bedone="yes" fi else bedone="yes" fi done fi if [ -n "$WRF_DIR" ] ; then echo "Will use WRF in dir: $WRF_DIR" else echo "WRF is required to compile hwrf-utilities; please re-configure and try again" exit fi fi #================================================================= # HWRF doesn't need any external support libraries. It builds W3 (LIBW3), # sp (LIBSP), and sfcio (LIBSFCIO) # if the uname command exists, give it a shot and see if # we can narrow the choices; otherwise, spam 'em os="ARCH" mach="ARCH" type uname > /dev/null if [ $? -eq 0 ] ; then os=`uname` if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX" -o "$os" = "Darwin" ] ; then mach="ARCH" else if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" ] ; then mach=`uname -m` else os="ARCH" mach="ARCH" fi fi fi # so proceed with configuration perl arch/Config.pl -corepath=$CORE_DIR -wrfpath=$WRF_DIR -netcdf=$NETCDF -USENETCDFF=$USENETCDFF -os=$os -mach=$mach