#!/bin/csh -f

#  %W% %P% %G% %U%

#  Determine operating system for compiling SMOKE

source $SMK_SUBSYS/scripts/platform

if ( $status != 0 ) then
    exit( $status )
endif

source $SMK_SUBSYS/edss_tools/setup/set_dirs.scr
source $SMK_SUBSYS/filesetapi/Setup

# Make directories for library, object files, and executables
setenv    SMK_BIN "$SMKROOT/$SMOKE_EXE"
setenv    IOAPIDIR $SMK_SUBSYS/ioapi
setenv    NETCDFLIB /usr/local/apps/netcdf-4.4.0/intel-15.0/lib
setenv    IOAPILIB  /usr/local/apps/ioapi-3.2/intel-15.0/lib
setenv    HDFLIB    /usr/local/apps/hdf5-1.8.16/intel-15.0/lib
setenv    PVMLIB    /usr/local/apps/pvm3/lib/LINUX64
if( ! -e $SMK_BIN ) mkdir -p $SMK_BIN
if( ! -e $MD_SRC/$SMOKE_EXE ) mkdir -p $MD_SRC/$SMOKE_EXE
#if( ! -e $IOAPIDIR ) mkdir -p $IOAPIDIR
#if( ! -e $NETCDFDIR ) mkdir -p $NETCDFDIR

setenv LIBS_COMPILE " "
switch ( $SMOKE_EXE )
case Linux2_ia64ifort:
    setenv FFLAGS   "$FFLAG -I${ETINC} -I${IOINC} -I${INC} -I${FS_ROOT} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_BIN}"
    setenv DBGFLAGS "$DBGFLAG -I${ETINC} -I${IOINC} -I${INC} -I${FS_ROOT} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_BIN}"
    setenv LDIRS    "-L${SMK_BIN} -L${TOOLS_BIN} -L${FS_BIN} -L${IOAPIDIR} -L${NETCDFDIR}"
# org    setenv LIBS_SYS     "-lsmoke -lfileset -ledsstools -lioapi -lnetcdf -lunwind"
    setenv LIBS_SYS     "-lsmoke -lfileset -ledsstools -lioapi -lnetcdf" 
    setenv LIBS_DEBUG_SYS "-lsmoke.debug -lfileset.debug -ledsstools.debug -lioapi.debug -lnetcdf.debug"
    setenv LIBS_COMPILE ""
    breaksw 
case Linux2_x86ifc:
    setenv FFLAGS   "$FFLAG -I${ETINC} -I${IOINC} -I${INC} -I${FS_ROOT} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_BIN}"
    setenv DBGFLAGS "$DBGFLAG -I${ETINC} -I${IOINC} -I${INC} -I${FS_ROOT} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_BIN}"
    setenv LDIRS    "-L${SMK_BIN} -L${TOOLS_BIN} -L${FS_BIN} -L${IOAPIDIR} -L${NETCDFDIR}"
    setenv LIBS_SYS     "-lsmoke -lfileset -ledsstools -lioapi -lnetcdf -lunwind"
    setenv LIBS_DEBUG_SYS "-lsmoke.debug -lfileset.debug -ledsstools.debug -lioapi.debug -lnetcdf.debug"
    setenv LIBS_COMPILE ""
    breaksw 
case Linux2_x86_64ifort:
    setenv FFLAGS   "$FFLAG -I${ETINC} -I${IOINC} -I${INC} -I${FS_ROOT} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_BIN}"
    setenv DBGFLAGS "$DBGFLAG -I${ETINC} -I${IOINC} -I${INC} -I${FS_ROOT} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_BIN}"
    setenv LDIRS    "-L${SMK_BIN} -L${TOOLS_BIN} -L${FS_BIN} -L${IOAPILIB} -L${NETCDFLIB} -L${HDFLIB} -L${PVMLIB} -L/usr/lib64"
#    setenv LIBS_SYS     "-lsmoke -lfileset -ledsstools -lioapi -lnetcdf -lunwind"
    setenv LIBS_SYS     "-lsmoke -lfileset -ledsstools -lioapi -lnetcdff -lnetcdf -lhdf5 -lcurl -lpvm3"
    setenv LIBS_DEBUG_SYS "-lsmoke.debug -lfileset.debug -ledsstools.debug -lioapi.debug -lnetcdf.debug"
    setenv LIBS_COMPILE ""
    breaksw 
case  Linux2_x86pg:
    setenv FFLAGS   "$FFLAG  -module ${MD_SRC}/${SMOKE_EXE} -module ${ETDSRC}/${SMOKE_EXE} -module ${FS_BIN} -I${ETINC} -I${IOINC} -I${INC} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_ROOT} -I${FS_BIN}"
    setenv DBGFLAGS "$DBGFLAG  -module ${MD_SRC}/${SMOKE_EXE} -module ${ETDSRC}/${SMOKE_EXE} -module ${FS_BIN} -I${ETINC} -I${IOINC} -I${INC} -I${MD_SRC}/${SMOKE_EXE} -I${ETDSRC}/${SMOKE_EXE} -I${FS_ROOT} -I${FS_BIN}"
    setenv LDIRS    "-L${SMK_BIN} -L${TOOLS_BIN} -L${FS_BIN} -L${IOAPIDIR} -L${NETCDFDIR}"
    setenv LIBS_SYS     "-lsmoke -lfileset -ledsstools -lioapi -lnetcdf"
    setenv LIBS_DEBUG_SYS "-lsmoke.debug -lfileset.debug -ledsstools.debug -lioapi.debug -lnetcdf.debug"
    breaksw
default:
    echo "The sysflags file in the ASSIGNS directory does not have compiler"
    echo "    settings for executable format "$SMOKE_EXE
    echo "Pleae edit the sysflags file and add this exectuable format and the"
    echo "    appropriate compiler settings."
    exit( 2 )
endsw


echo " "
echo "Host name:              "`hostname`
echo "Platform type:          $SMOKE_EXE"
echo "Main SMOKE directory:   $SMKROOT"
echo "Executable directory:   $SMK_BIN"
echo "Intermediate data dir:  $INTERMED"
echo "Output data directory:  $OUTPUT"
echo " "
