#!/bin/bash
#
#  $Header: /u/gcmpack/MITgcm/tools/build_options/linux_ia32_ifort+mpi2_aces,v 1.1 2009/06/23 22:54:32 jmc Exp $
#
#  build options used with the Intel compiler, version 8 and 9,
#  for thedaily testing on ACES (which are initiated by cron jobs 
#  on the "ao" head node).
#
#  Needs the appropriate module commands,
#  and DON'T FORGET to set environment variable MPI_INC_DIR to the include
#  directory of the selected MPI implementation
#
#-- using default intel (v8.1) and default mpich/intel:
#    module add mpich/intel
#    module add netcdf/3.6.1/icc
#   e.g.(sh,bash): 
#    export MPI_INC_DIR='/usr/local/pkg/mpich/mpich-intel/include/'
#   (and run using mpirun -machinefile my_list_of_nodes)
#   
#-- using intel v9.0 and mpich2-intel, in this order:
#    module add ifc/9.0.021 icc/9.0.021 intel/9.0
#    module add mpich2/1.0.3/intel
#    module add netcdf/3.6.1/icc
#    module add mpiexec             (<-- to run with mpiexec)
#   e.g.(sh,bash): 
#    export MPI_INC_DIR='/usr/local/pkg/mpich2/mpich2-1.0.3/intel/include/'
#   (and run using mpiexec)

# Notes: the PBS -V option for exporting environment variables does not work
#        so need to set all env var on compute nodes

FC='mpif77'
CC='mpicc'
F90C='mpif90 -fixed -c '
LINK='mpif77'

#-- for NetCDF: 
INCLUDES="-I$NETCDF_INCDIR"
INCLUDEDIRS=$NETCDF_INCDIR
LIBS="-L$NETCDF_LIBDIR"

#- for MPI:
INCLUDES="$INCLUDES -I$MPI_INC_DIR"
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR"
MPIINCLUDEDIR="$MPI_INC_DIR"
MPI_HEADER_FILES='mpif.h mpiof.h'
MPI_HEADER_FILES_INC='./mpi_headers/mpif.h ./mpi_headers/mpiof.h'

DEFINES='-DALLOW_USE_MPI -DALWAYS_USE_MPI -DWORDLENGTH=4'
CPP='cpp  -traditional -P'
EXTENDED_SRC_FLAG='-132'
OMPFLAG='-openmp'

NOOPTFLAGS='-O0'
NOOPTFILES='mds_byteswapr8.F mds_byteswapr4.F mds_byteswapi4.F'

#  Note that the -mp switch is for ieee "maintain precision" and is
#  roughly equivalent to -ieee
if test "x$IEEE" = x ; then
    FOPTIM='-O3 -align'
    #P3 FOPTIM=$FOPTIM' -tpp6 -xWKM'
    #P4 FOPTIM=$FOPTIM' -tpp7 -xWKM'
    FFLAGS='-r8 -i4 -w95 -W0 -WB -assume byterecl -convert big_endian'
else
    # FOPTIM='-O0 -noalign -CA -CB -CU -CV -CS'
    FOPTIM='-O0 -noalign -CB -CU -CV'
    FFLAGS='-r8 -i4 -w95 -W0 -WB -pc64 -xW -assume byterecl -convert big_endian'
    # FLAGS='-mp -r8 -i4 -w95 -W0 -WB -assume byterecl -convert big_endian'
fi
F90FLAGS=$FFLAGS
F90OPTIM=$FOPTIM

NOOPTFILES=$NOOPTFILES' mitcplr_char2real.F mitcplr_real2char.F'
NOOPTFILES=$NOOPTFILES' mitcplr_char2int.F mitcplr_int2char.F mds_byteswap.F'

