[mpas-developers] improved Makefile
Michael Duda
duda at ucar.edu
Mon Dec 21 13:46:18 MST 2009
Hi, Folks,
With more than just a couple people now compiling the MPAS code on
various platforms, I was thinking of ways to make the build process
friendlier (especially in the sense of removing the need to manually
edit the Makefile for a particular system after checking out the
code). I've attached a new Makefile that has specific targets for
different platforms, where compiling is now accomplished by typing,
for example, 'make pgi' or 'make xlf'. I'm not claiming that this is
necessarily the way in which we will want to manage building on
different platforms in future, but it is a simple modification to the
existing Makefile that will hopefully make our lives easier in the
present.
If what I've attached looks reasonable to everyone, I'll go ahead and
commit the new Makefile. Of course, if anyone has any suggestions,
they would be most welcome, too.
Cheers,
Michael
-------------- next part --------------
#MODEL_FORMULATION = -DNCAR_FORMULATION
MODEL_FORMULATION = -DLANL_FORMULATION
#EXPAND_LEVELS = -DEXPAND_LEVELS=32
#FILE_OFFSET = -DOFFSET64BIT
dummy:
@( echo "try one of:"; \
echo " make xlf"; \
echo " make pgi"; \
echo " make ifort"; \
echo " make gfortran"; \
)
xlf:
( make all \
"FC = mpxlf90" \
"CC = mpcc" \
"SFC = xlf90" \
"SCC = xlc" \
"FFLAGS = -qrealsize=8 -g -C " \
"CFLAGS = -g" \
"LDFLAGS = -g -C" \
"CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI $(FILE_OFFSET)" )
pgi:
( make all \
"FC = mpif90" \
"CC = mpicc" \
"SFC = pgf90" \
"SCC = pgcc" \
"FFLAGS = -r8 -O3" \
"CFLAGS = -O3" \
"LDFLAGS = -O3" \
"CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE $(FILE_OFFSET)" )
ifort:
( make all \
"FC = mpif90" \
"CC = gcc" \
"SFC = ifort" \
"SCC = gcc" \
"FFLAGS = -real-size 64 -O3" \
"CFLAGS = -O3 -m64" \
"LDFLAGS = -O3" \
"CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE -m64 $(FILE_OFFSET)" )
gfortran:
( make all \
"FC = mpif90" \
"CC = mpicc" \
"SFC = gfortran" \
"SCC = gcc" \
"FFLAGS = -O3 -m64 -ffree-line-length-none" \
"CFLAGS = -O3 -m64" \
"LDFLAGS = -O3 -m64" \
"CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE -m64 $(FILE_OFFSET)" )
CPPINCLUDES = -I../inc -I$(NETCDF)/include
FCINCLUDES = -I../inc -I$(NETCDF)/include
LIBS = -L$(NETCDF)/lib -lnetcdf
RM = rm -f
CPP = cpp -C -P -traditional
RANLIB = ranlib
#########################
# Section for Zoltan TPL
#########################
ifdef ZOLTAN_HOME
FFLAGS += -DHAVE_ZOLTAN
CFLAGS += -DHAVE_ZOLTAN
CPPFLAGS += -DHAVE_ZOLTAN
ifdef ZOLTAN_INC_PATH
FCINCLUDES += -I$(ZOLTAN_INC_PATH)
else
FCINCLUDES += -I$(ZOLTAN_HOME)/include
endif
ifdef ZOLTAN_LIB_PATH
LIBS += -L$(ZOLTAN_LIB_PATH) -lzoltan
else
LIBS += -L$(ZOLTAN_HOME)/lib -lzoltan
endif
endif
#########################
all: reg_includes externals swmodel_main
reg_includes:
cd Registry; make CC="$(SCC)"
cd Registry; ./parse Registry; mv *.inc ../inc
externals:
cd external; make FC="$(FC)" SFC="$(SFC)" CC="$(CC)" SCC="$(SCC)" FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" RANLIB="$(RANLIB)" NETCDF="$(NETCDF)"
swmodel_main:
cd src; make FC="$(FC)" CC="$(CC)" CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" LDFLAGS="$(LDFLAGS)" RM="$(RM)" CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" LIBS="$(LIBS)" CPPINCLUDES="$(CPPINCLUDES)" FCINCLUDES="$(FCINCLUDES)"
if [ ! -e swmodel ]; then ln -s src/swmodel .; fi
clean:
cd Registry; make clean
cd external; make clean
cd src; make clean RM="$(RM)"
$(RM) inc/*.inc
$(RM) swmodel
More information about the mpas-developers
mailing list