Rev 2 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/bin/csh
# -----------------------------------------------------------------------------
# Set some general parameters
# -----------------------------------------------------------------------------
# Usage
if ( $#argv == 0 ) then
echo "install.sh [lib|core|goodies|links|all|clean] "
exit 0
endif
# Set the mode
set mode = $1
# Set paths for development
set path_devel = "/home/michaesp/project/lagranto.wrf/"
# Init Fortran compiler and set netCDF acccordingly
setenv FORTRAN pgf90
# Init netCDF library depending on the Fortran compiler
if ( "${FORTRAN}" == "pgf90" ) then
module load pgi/9.0-1
module load netcdf/4.1.1-pgf90
else if ( "${FORTRAN}" == "gfortran" ) then
module load gfortran
module load netcdf/4.1.1
else if ( "${FORTRAN}" == "ifort" ) then
module load ifort/10.1.017
module load netcdf/4.1.1-ifort
else
echo "Fortran Compiler ${FORTRAN} not supported... Exit"
exit 1
endif
# -----------------------------------------------------------------------------
# Set internal parameters and detailed installation mode
# -----------------------------------------------------------------------------
# Set LAGRANTO environment variable
setenv LAGRANTO ${path_devel}
# Set netCDF paths
setenv NETCDF_LIB ${NETCDF}/lib/
setenv NETCDF_INC ${NETCDF}/include/
# Set list of core programs
set core = "caltra trace select"
# Set list of goodies
set tools = "extract gettidiff getvars list2lsl lsl2list mergetra newtime reformat timeres trainfo difference datelist tracal wrfmap"
# Set list of libraries
set libs = "iotra inter times libcdfio libcdfplus libwrf"
# Core programs
foreach prog ( $core )
if ( "${prog}" == "${mode}" ) then
set core = ${prog}
set mode = "core"
endif
end
# Goodies
foreach tool ( $tools )
if ( "${tool}" == "${mode}" ) then
set tools = ${tool}
set mode = "goodies"
endif
end
# Libraries
foreach lib ( $libs )
if ( "${lib}" == "${mode}" ) then
set libs = ${lib}
set mode = "lib"
endif
end
# -----------------------------------------------------------------------------
# Make clean
# -----------------------------------------------------------------------------
if ( "${mode}" == "clean" ) then
\rm -f caltra/caltra caltra/caltra.o
\rm -f select/select select/select.o select/special.o
\rm -f trace/trace trace/trace.o
foreach tool ( $tools )
\rm -f goodies/${tool} goodies/${tool}.o
end
\rm -f goodies/*.mod
\rm lib/*.a lib/*.o
\rm -f bin/caltra bin/caltra.sh
\rm -f bin/select bin/select.sh bin/seltra bin/seltra.sh
\rm -f bin/trace bin/trace.sh
foreach tool ( $tools )
\rm -f bin/${tool} bin/${tool}.sh
end
\rm -f bin/lagrantohelp.sh
exit 0
endif
# -----------------------------------------------------------------------------
# Install libraries
# -----------------------------------------------------------------------------
if ( ("${mode}" == "lib") | ("${mode}" == "all" ) ) then
echo "-----------------------------------------------------------------"
echo "Installing libraries"
echo "-----------------------------------------------------------------"
echo
# Change to library directory
cd ${LAGRANTO}/lib
# Loop over all libraries - compile and make library
foreach lib ( $libs )
\rm -f ${lib}.a
\rm -f ${lib}.o
echo ${FORTRAN} -c -O ${lib}.f
${FORTRAN} -c -O -I ${NETCDF_INC} ${lib}.f
ar r ${lib}.a ${lib}.o
\rm -f ${lib}.l ${lib}.o
ranlib ${lib}.a
if ( ! -f ${lib}.a ) then
echo "Problem in compiling ${lib} ... Stop"
exit 1
endif
end
endif
# -----------------------------------------------------------------------------
# Check that libraries are ok
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Check that all libraries are available"
echo "-----------------------------------------------------------------"
echo
# Change to library directory
cd ${LAGRANTO}/lib
# Check whether all libraries are available
foreach lib ( $libs )
if ( ! -f ${lib}.a ) then
echo "Library ${lib} missing... Stop"
exit 1
else
ls -l ${lib}.a
endif
end
# Exit if only libraries shoudl be installed
if ( "${mode}" == "lib" ) exit 0
# -----------------------------------------------------------------------------
# Compile Lagrango core programs
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "core" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Installing Lagranto core programs"
echo "-----------------------------------------------------------------"
foreach prog ( $core )
echo
echo "----- $prog"
echo
cd ${LAGRANTO}/${prog}
\rm -f ${prog}.o
\rm -f ${prog}
if ( "${prog}" == "select" ) \rm special.o
\rm -f ${prog}
make -f ${prog}.make
if ( ! -f ${prog} ) then
echo "Problem in compiling ${prog} ... Stop"
exit 1
endif
end
endif
# -----------------------------------------------------------------------------
# Check that all Lagranto core programs are available
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Check that all Lagranto core programs are available"
echo "-----------------------------------------------------------------"
echo
foreach prog ( $core )
cd ${LAGRANTO}/${prog}
if ( ! -f ${prog} ) then
echo "${prog} is missing... Stop"
exit 1
else
ls -l ${prog}
endif
end
# Exit if only core programs shoudl be installed
if ( "${mode}" == "core" ) exit 0
# -----------------------------------------------------------------------------
# Compile Lagrango goodies
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "goodies" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Installing Lagranto goodies"
echo "-----------------------------------------------------------------"
cd ${LAGRANTO}/goodies
foreach tool ( $tools )
echo
echo "----- ${tool}"
echo
\rm -f ${tool}.o
\rm -f ${tool}
if ( -f ${tool}.make ) then
make -f ${tool}.make
else if ( -f ${tool}.install ) then
./${tool}.install
endif
if ( ! -f ${tool} ) then
echo "Problem in compiling ${tool} ... Stop"
exit 1
endif
end
endif
# -----------------------------------------------------------------------------
# Check that all Lagranto goodies are available
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Check that all Lagranto goodies are available"
echo "-----------------------------------------------------------------"
echo
cd ${LAGRANTO}/goodies
foreach tool ( $tools )
if ( ! -f ${tool} ) then
echo "${tool} is missing... Stop"
exit 1
else
ls -l ${tool}
endif
end
endif
# Exit if only goodies should be installed
if ( "${mode}" == "goodies" ) exit 0
# -----------------------------------------------------------------------------
# Create links to programs
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "links" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Create links in ${LAGRANTO}/bin/"
echo "-----------------------------------------------------------------"
echo
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
cd ${LAGRANTO}/bin
ln -svf ${LAGRANTO}/bin/lagrantohelp lagrantohelp.sh
ln -svf ${LAGRANTO}/caltra/caltra.sh caltra.sh
ln -svf ${LAGRANTO}/select/select.sh select.sh
ln -svf ${LAGRANTO}/trace/trace.sh trace.sh
ln -svf ${LAGRANTO}/caltra/caltra.sh caltra
ln -svf ${LAGRANTO}/select/select.sh select
ln -svf ${LAGRANTO}/trace/trace.sh trace
foreach tool ( $tools )
ln -svf ${LAGRANTO}/goodies/${tool}.sh ${tool}.sh
ln -svf ${LAGRANTO}/goodies/${tool}.sh ${tool}
end
# Set extra name for <select> to avoid conflict in BASH
ln -svf ${LAGRANTO}/select/select.sh seltra
ln -svf ${LAGRANTO}/select/select.sh seltra.sh
endif
# -----------------------------------------------------------------------------
# Final tasks
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Installation complete"
echo "-----------------------------------------------------------------"
echo
echo "Please set the environmental variable LAGRANTO"
echo
echo " setenv LAGRANTO ${LAGRANTO}"
echo