#
# Included makefile for Intel ifort compiler and ifort-built openmpi on 64-bit HAO machines.
#
# Example machines and their unames:
#   - HAO 64-bit Linux system iris.hao.ucar.edu (one quad-core)
#     Linux iris 2.6.18-194.11.1.el5 #1 SMP Tue Aug 10 19:05:06 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
#   - HAO 64-bit Linux system arc.hao.ucar.edu (two quad-cores)
#     Linux arc 2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12:54:20 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
#
# Compilers and flags:
# Using intel 2011 Cluster Studio, w/ built-in mpi
#
F90      = /opt/local/intel2011/composerxe-2011.0.084/bin/intel64/ifort
MPIF90   = /opt/local/intel2011/impi/4.0.1.007/intel64/bin/mpif90 -fc=ifort
MPIRUN   = /opt/local/intel2011/impi/4.0.1.007/intel64/bin/mpirun -l
FFLAGS   = -r8 -heap-arrays
DBGFLAGS = -debug full -traceback 
DBGFLAGS += -check bounds -check format -check output_conversion -check pointers -check uninit
#
# Makefile will use OPTIM = -g if set debug=TRUE in job script.
OPTIM    = -O3
LIBS     = -lcurl
HOST     = $(shell hostname)

# kameleon libraries
KAMELEON_LIB_DIR=/home/emery/kameleon/fortran_test_24mar14/
KAMELEON_LIB_PLUS=${KAMELEON_LIB_DIR}/kameleon_drivers/build/interpolator_wrapper.a
CDF_LIB=${KAMELEON_LIB_DIR}/cdf35_0-dist/src/lib/libcdf.a
KAMELEON_LIB=${KAMELEON_LIB_PLUS} ${CDF_LIB}
LIBS    += -lm -lstdc++ ${KAMELEON_LIB}
#
# Library and Include file paths:
#
LIB_NETCDF = /home/tgcm/intel/netcdf-4.1.1/lib
INC_NETCDF = /home/tgcm/intel/netcdf-4.1.1/include
#
# Make machines.ini file for MPI execution: 
#
prereq: machines.ini mpirun.command
machines.ini: export HN=$(HOST)
machines.ini: export NP=$(NPROC)
machines.ini: FORCE
	@echo "Making machines.ini.."
	@echo `hostname` > machines.ini
	@awk 'BEGIN{ for (i=2; i <= ENVIRON["NP"]; i++) print ENVIRON["HN"] }' >> machines.ini

mpirun.command: FORCE
	@echo "Making mpirun.command: MPIRUN=$(MPIRUN)"
	@echo $(MPIRUN) > mpirun.command

FORCE:
