1

So I am writing a script to build and install Netcdf, but when I source it, it seems like some of the lines just are not running or are being skipped and I am unsure why. When I run the code line by line manually however, it works fine. Here is the script:

module purge
module load gnu/5.1.0
module load mvapich2/2.1
module load hdf5/1.8.9

export SRC_DIR=/usr/local/src/netcdf/netcdf-4.3.3.1
export BUILD_DIR=$SRC_DIR/build-gnu
export INSTALL_DIR=/usr/local/netcdf/gnu/5.1/mvapich2/2.1/4.3.3.1/

mkdir -p $INSTALL_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR

CC=mpicc CXX=mpicxx FC=mpif90 CFLAGS='-DpgiFortran -fPIC' CPPFLAGS=-I$HDF5_HOME/include \
 FCFLAGS='-DpgiFortran -fPIC' LDFLAGS=-L$HDF5_HOME/lib \
../configure --prefix=$INSTALL_DIR --enable-shared --with-hdf5=$HDF5_HOME

make
make check
make install
make clean

It seems to just skip straight to the configure command. I run the script by sourcing it using the following command:

. build-netcdf-gnu-5.1 |& tee build-netcdf-gnu-5.1.log

but when I run it none of the modules have been loaded and I am still in the directory where I started the script when I should have changed to the build directory. The weird thing is if i copy and paste the code line by line it works fine. Why isn't this script running as expected? Is there anything simple I am just overlooking? thanks for any help, it is greatly appreciated.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.