bv_uintah.sh 11.4 KB
Newer Older
1 2
function bv_uintah_initialize
{
3
export FORCE_UINTAH="no"
4 5 6 7 8 9 10 11
export DO_UINTAH="no"
export ON_UINTAH="off"
export USE_SYSTEM_UINTAH="no"
add_extra_commandline_args "uintah" "alt-uintah-dir" 1 "Use alternative directory for uintah"
}

function bv_uintah_enable
{
12 13 14 15 16 17
    if [[ "$1" == "force" ]]; then
        FORCE_UINTAH="yes"
    fi

    DO_UINTAH="yes"
    ON_UINTAH="on"
18 19 20 21
}

function bv_uintah_disable
{
22 23
    DO_UINTAH="no"
    ON_UINTAH="off"
24 25 26 27
}

function bv_uintah_alt_uintah_dir
{
28 29 30 31 32
    echo "Using alternate Uintah directory"

    # Check to make sure the directory or a particular include file exists.
    [ ! -e "$1/../src/StandAlone/tools/uda2vis/udaData.h" ] && error "Uintah not found in $1"

33 34 35 36 37 38 39 40 41
    bv_uintah_enable
    USE_SYSTEM_UINTAH="yes"
    UINTAH_INSTALL_DIR="$1"
}

function bv_uintah_depends_on
{
    if [[ "$USE_SYSTEM_UINTAH" == "yes" ]]; then
        echo ""
42 43
    else
        echo ""
44 45 46 47 48
    fi
}

function bv_uintah_initialize_vars
{
49 50 51 52 53 54
    if [[ "$FORCE_UINTAH" == "no" && "$parallel" == "no" ]]; then
        bv_uintah_disable
        warn "Uintah requested by default but the parallel flag has not been set. Uintah will not be built."
        return
    fi

55
    if [[ "$USE_SYSTEM_UINTAH" == "no" ]]; then
allens's avatar
allens committed
56
        UINTAH_INSTALL_DIR="${VISITDIR}/uintah/$UINTAH_VERSION/$VISITARCH"
57 58 59 60 61
    fi
}

function bv_uintah_info
{
allens's avatar
allens committed
62 63 64
export UINTAH_VERSION=${UINTAH_VERSION:-"1.6.0beta"}
export UINTAH_FILE=${UINTAH_FILE:-"Uintah-${UINTAH_VERSION}.tar.gz"}
export UINTAH_COMPATIBILITY_VERSION=${UINTAH_COMPATIBILITY_VERSION:-"1.6"}
allens's avatar
allens committed
65
export UINTAH_BUILD_DIR=${UINTAH_BUILD_DIR:-"Uintah-${UINTAH_VERSION}/optimized"}
allens's avatar
allens committed
66
#export UINTAH_URL=${UINTAH_URL:-"http://www.sci.utah.edu/releases/uintah_v${UINTAH_VERSION}/${UINTAH_FILE}"}
allens's avatar
allens committed
67
export UINTAH_URL=${UINTAH_URL:-"http://www.sci.utah.edu/devbuilds/icse/uintah/${UINTAH_VERSION}"}
allens's avatar
allens committed
68

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
export UINTAH_MD5_CHECKSUM=""
export UINTAH_SHA256_CHECKSUM=""
}

function bv_uintah_print
{
  printf "%s%s\n" "UINTAH_FILE=" "${UINTAH_FILE}"
  printf "%s%s\n" "UINTAH_VERSION=" "${UINTAH_VERSION}"
  printf "%s%s\n" "UINTAH_COMPATIBILITY_VERSION=" "${UINTAH_COMPATIBILITY_VERSION}"
  printf "%s%s\n" "UINTAH_BUILD_DIR=" "${UINTAH_BUILD_DIR}"
}

function bv_uintah_print_usage
{
printf "%-15s %s [%s]\n" "--uintah" "Build UINTAH" "${DO_UINTAH}"
84
printf "%-15s %s [%s]\n" "--alt-uintah-dir"  "Use Uintah" "Use Uintah from alternative directory"
85 86 87 88 89 90 91 92 93 94 95 96 97
}

function bv_uintah_graphical
{
local graphical_out="UINTAH     $UINTAH_VERSION($UINTAH_FILE)      $ON_UINTAH"
echo $graphical_out
}

function bv_uintah_host_profile
{
    if [[ "$DO_UINTAH" == "yes" ]] ; then
        echo >> $HOSTCONF
        echo "##" >> $HOSTCONF
allens's avatar
allens committed
98
        echo "## Uintah" >> $HOSTCONF
99 100 101
        echo "##" >> $HOSTCONF

        if [[ "$USE_SYSTEM_UINTAH" == "yes" ]]; then
allens's avatar
allens committed
102
            echo "VISIT_OPTION_DEFAULT(VISIT_UINTAH_DIR $UINTAH_INSTALL_DIR)" >> $HOSTCONF 
103
            echo "SET(VISIT_USE_SYSTEM_UINTAH TRUE)" >> $HOSTCONF
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
        else
            echo \
            "VISIT_OPTION_DEFAULT(VISIT_UINTAH_DIR \${VISITHOME}/uintah/$UINTAH_VERSION/\${VISITARCH})" \
            >> $HOSTCONF 
        fi
    fi
}

function bv_uintah_ensure
{
    if [[ "$DO_UINTAH" == "yes" && "$USE_SYSTEM_UINTAH" == "no" ]] ; then
        ensure_built_or_ready "uintah" $UINTAH_VERSION $UINTAH_BUILD_DIR $UINTAH_FILE $UINTAH_URL 
        if [[ $? != 0 ]] ; then
            ANY_ERRORS="yes"
            DO_UINTAH="no"
            error "Unable to build UINTAH.  ${UINTAH_FILE} not found."
        fi
    fi
}

function bv_uintah_dry_run
{
  if [[ "$DO_UINTAH" == "yes" ]] ; then
    echo "Dry run option not set for uintah."
  fi
}

# *************************************************************************** #
#                          Function 8.1, build_uintah                           #
# *************************************************************************** #

function build_uintah
{
allens's avatar
allens committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    PAR_INCLUDE_STRING=""
    if [[ "$PAR_INCLUDE" != "" ]] ; then
        PAR_INCLUDE_STRING=$PAR_INCLUDE
    fi

    if [[ "$PAR_COMPILER" != "" ]] ; then
        if [[ "$OPSYS" == "Darwin" && "$PAR_COMPILER" == "/usr/bin/mpicc" ]]; then
            PAR_INCLUDE_STRING="-I/usr/include/"
        elif [[ "$OPSYS" == "Linux" && "$PAR_COMPILER" == "mpixlc" ]]; then
            PAR_INCLUDE_STRING=`$PAR_COMPILER -show`
        else
            if [[ -z "$PAR_INCLUDE_STRING" ]]; then
                PAR_INCLUDE_STRING=`$PAR_COMPILER --showme:compile`
                if [[ $? != 0 ]] ; then
                    PAR_INCLUDE_STRING=`$PAR_COMPILER -show`
                fi
            fi
        fi
    fi

    if [[ "$PAR_INCLUDE_STRING" == "" ]] ; then
158
       warn "You must set either the PAR_COMPILER or PAR_INCLUDE environment variable to be Uintah."
allens's avatar
allens committed
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
       warn "PAR_COMPILER should be of the form \"/path/to/mpi/bin/mpicc\""
       warn "PAR_INCLUDE should be of the form \"-I/path/to/mpi/include\""
       warn "Giving Up!"
       return 1
    fi

    # Uintah's config doesn't take the compiler options, but rather the
    # paths to the root, and then it tries to build all of the appropriate
    # options itself.  Because we only have the former, we need to guess at the
    # latter.
    # Our current guess is to take the first substring in PAR_INCLUDE, assume
    # it's the appropriate -I option, and use it with the "-I" removed.  This
    # is certainly not ideal -- for example, it will break if the user's
    # MPI setup requires multiple include directories.

    # Search all of the -I directories and take the first one containing mpi.h
    PAR_INCLUDE_DIR=""
    for arg in $PAR_INCLUDE_STRING ; do
        if [[ "$arg" != "${arg#-I}" ]] ; then
            if test -e "${arg#-I}/mpi.h" ; then
                PAR_INCLUDE_DIR=${arg#-I}
                break
            fi
        fi
    done
    # If we did not get a valid include directory, take the first -I directory.
    if test -z "${PAR_INCLUDE_DIR}"  ; then
        for arg in $PAR_INCLUDE_STRING ; do
            if [[ "$arg" != "${arg#-I}" ]] ; then
                PAR_INCLUDE_DIR=${arg#-I}
                break
            fi
        done
    fi

    if test -z "${PAR_INCLUDE_DIR}"  ; then
        if test -n "${PAR_INCLUDE}" ; then
            warn "This script believes you have defined PAR_INCLUDE as: $PAR_INCLUDE"
197
            warn "However, to build Uintah, this script expects to parse a -I/path/to/mpi out of PAR_INCLUDE"
allens's avatar
allens committed
198
        fi
199
        warn "Could not determine the MPI include information which is needed to compile Uintah."
allens's avatar
allens committed
200 201 202 203 204 205 206 207 208
        if test -n "${PAR_INCLUDE}" ; then
            error "Please re-run with the required \"-I\" option included in PAR_INCLUDE"
        else
            error "You need to specify either PAR_COMPILER or PAR_INCLUDE variable.  On many "
                  " systems, the output of \"mpicc -showme\" is good enough."
            error ""
        fi
    fi

209 210 211 212 213 214 215 216 217 218 219 220 221
    if [[ "$FC_COMPILER" == "no" ]] ; then

      if [[ "$OPSYS" != "Darwin" ]]; then
        warn "Uintah may require fortran to be enabled. It does not appear that the --fortran "
        warn "agrument was set. If Uintah fails to build try adding the --fortranargument"
        FORTRANARGS=""
#       return 1
      fi

    else
        FORTRANARGS="FC=\"$FC_COMPILER\" F77=\"$FC_COMPILER\" FCFLAGS=\"$FCFLAGS\" FFLAGS=\"$FCFLAGS\" --enable-fortran"
    fi

222 223 224 225 226 227 228 229 230 231 232
    #
    # Prepare build dir
    #
    prepare_build_dir $UINTAH_BUILD_DIR $UINTAH_FILE
    untarred_uintah=$?
    if [[ $untarred_uintah == -1 ]] ; then
       warn "Unable to prepare UINTAH Build Directory. Giving Up"
       return 1
    fi

    #
allens's avatar
allens committed
233
    mkdir $UINTAH_BUILD_DIR
234
    cd $UINTAH_BUILD_DIR || error "Can't cd to UINTAH build dir."
allens's avatar
allens committed
235

236 237 238 239 240 241 242 243 244 245 246
    info "Configuring UINTAH . . ."
    cf_darwin=""
    if [[ "$DO_STATIC_BUILD" == "yes" ]]; then
            cf_build_type="--disable-shared --enable-static"
        else
            cf_build_type="--enable-shared --disable-static"
    fi

    # In order to ensure $FORTRANARGS is expanded to build the arguments to
    # configure, we wrap the invokation in 'sh -c "..."' syntax
    info "Invoking command to configure UINTAH"
allens's avatar
allens committed
247
    info "../src/configure CXX=\"$CXX_COMPILER\" CC=\"$C_COMPILER\" \
248 249 250
        CFLAGS=\"$CFLAGS $C_OPT_FLAGS\" CXXFLAGS=\"$CXXFLAGS $CXX_OPT_FLAGS\" \
        $FORTRANARGS \
        --prefix=\"$VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH\" \
allens's avatar
allens committed
251 252 253 254 255 256
        ${cf_darwin} \
        --enable-optimize="-O2" \
        --enable-assertion-level=0
        --enable-64bit
        --with-mpi="${PAR_INCLUDE_DIR}/.." "
    sh -c "../src/configure CXX=\"$CXX_COMPILER\" CC=\"$C_COMPILER\" \
257 258 259
        CFLAGS=\"$CFLAGS $C_OPT_FLAGS\" CXXFLAGS=\"$CXXFLAGS $CXX_OPT_FLAGS\" \
        $FORTRANARGS \
        --prefix=\"$VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH\" \
allens's avatar
allens committed
260 261 262 263 264
        ${cf_build_type} \
        --enable-optimize="-O2" \
        --enable-assertion-level=0 \
        --enable-64bit \
        --with-mpi="${PAR_INCLUDE_DIR}/.." "
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
    if [[ $? != 0 ]] ; then
       warn "UINTAH configure failed.  Giving up"
       return 1
    fi

    #
    # Build UINTAH
    #
    info "Making UINTAH . . ."
    $MAKE $MAKE_OPT_FLAGS
    if [[ $? != 0 ]] ; then
       warn "UINTAH build failed.  Giving up"
       return 1
    fi
    #
    # Install into the VisIt third party location.
    #
    info "Installing UINTAH . . ."

allens's avatar
allens committed
284 285 286 287 288
    mkdir $VISITDIR/uintah/ || error "Can't make UINTAH install dir."
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/ || error "Can't make UINTAH install dir."
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH || error "Can't make UINTAH install dir."
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/lib || error "Can't make UINTAH install dir."
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/include || error "Can't make UINTAH install dir."
allens's avatar
allens committed
289 290 291
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/include/StandAlone || error "Can't make UINTAH install dir."
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/include/StandAlone/tools || error "Can't make UINTAH install dir."
    mkdir $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/include/StandAlone/tools/uda2vis || error "Can't make UINTAH install dir."
allens's avatar
allens committed
292 293

    cp lib/* $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/lib
allens's avatar
allens committed
294
    cp ../src/StandAlone/tools/uda2vis/udaData.h $VISITDIR/uintah/$UINTAH_VERSION/$VISITARCH/include/StandAlone/tools/uda2vis
allens's avatar
allens committed
295 296

#    $MAKE install
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
    if [[ $? != 0 ]] ; then
       warn "UINTAH install failed.  Giving up"
       return 1
    fi

    if [[ "$DO_STATIC_BUILD" == "no" && "$OPSYS" == "Darwin" ]]; then
        #
        # Make dynamic executable, need to patch up the install path and
        # version information.
        #
        info "Creating dynamic libraries for UINTAH . . ."
    fi

    if [[ "$DO_GROUP" == "yes" ]] ; then
       chmod -R ug+w,a+rX "$VISITDIR/uintah"
       chgrp -R ${GROUP} "$VISITDIR/uintah"
    fi
    cd "$START_DIR"
    info "Done with UINTAH"
    return 0
}

function bv_uintah_is_enabled
{
    if [[ $DO_UINTAH == "yes" ]]; then
        return 1    
    fi
    return 0
}

function bv_uintah_is_installed
{
    if [[ "$USE_SYSTEM_UINTAH" == "yes" ]]; then
        return 1
    fi

    check_if_installed "uintah" $UINTAH_VERSION
    if [[ $? == 0 ]] ; then
        return 1
    fi
    return 0
}

function bv_uintah_build
{
cd "$START_DIR"

if [[ "$DO_UINTAH" == "yes" && "$USE_SYSTEM_UINTAH" == "no" ]] ; then
    check_if_installed "uintah" $UINTAH_VERSION
    if [[ $? == 0 ]] ; then
        info "Skipping UINTAH build.  UINTAH is already installed."
    else
allens's avatar
allens committed
349
        info "Building UINTAH (~10 minutes)"
350 351 352 353 354 355 356 357
        build_uintah
        if [[ $? != 0 ]] ; then
            error "Unable to build or install UINTAH.  Bailing out."
        fi
        info "Done building UINTAH"
    fi
fi
}