1#
2# Copyright (C) 1996-2016	The SIESTA group
3#  This file is distributed under the terms of the
4#  GNU General Public License: see COPYING in the top directory
5#  or http://www.gnu.org/copyleft/gpl.txt.
6# See Docs/Contributors.txt for a list of contributors.
7#
8# Makefile for MPI tests
9#
10.SUFFIXES:
11.SUFFIXES: .f .F .o .a  .f90 .F90
12
13.PHONY: MPI clean
14
15default: pi3 blacs_prb pblas_prb # mpi_test
16
17OBJDIR=Obj
18VPATH=$(shell pwd)/../../Src
19ARCH_MAKE=../../$(OBJDIR)/arch.make
20include $(ARCH_MAKE)
21
22# Remove timings
23FFLAGS := $(filter-out -DMPI_TIMING, $(FFLAGS))
24FPPFLAGS := $(filter-out -DMPI_TIMING, $(FPPFLAGS))
25
26MPI_INTERFACE= libmpi_f90.a
27
28pi3: $(MPI_INTERFACE) pi3.o timer_stub.o
29	$(FC) -o pi3 $(LDFLAGS) pi3.o $(MPI_INTERFACE) timer_stub.o
30
31newcomm:    MPI newcomm.o
32	$(FC) -o newcomm $(LDFLAGS) newcomm.o $(MPI_INTERFACE_LIB) $(MPI_LIBS)
33DISTOBJS=class_BlockCyclicDist.o class_PEXSIDist.o class_Dist.o \
34         m_matrix.o m_transfers.o m_redist.o m_uuid.o \
35         dielocal.o object_debug.o pxf.o dist.o
36dist:    MPI $(DISTOBJS)
37	$(FC) -o $@ $(LDFLAGS) $(DISTOBJS) $(MPI_INTERFACE_LIB) $(MPI_LIBS)
38#
39# Blacs test
40#
41blacs_prb: blacs_prb.o
42	$(FC) -o blacs_prb $(LDFLAGS) blacs_prb.o $(LIBS)
43
44#
45# Pblas test. You might need to uncomment the following line
46# in those systems where pdlaprnt is not in the standard library.
47#
48EXTRA_ROUTINE=pdlaprnt.o
49#
50pblas_prb: pblas_prb.o $(EXTRA_ROUTINE)
51	@echo
52	@echo --Attempting to build Pblas test.
53	@echo --You might need to enable compilation of pdlaprnt.f in the Makefile
54	@echo --if that routine is not in the standard library on your system...
55	@echo --..or if its interface is not compatible, i.e., segfaults
56	@echo
57	$(FC) -o pblas_prb $(LDFLAGS) pblas_prb.o $(EXTRA_ROUTINE) $(LIBS)
58
59#
60# Siesta-specific MPI test --- iffy on some systems
61#----------------------------------------------------------------------------
62MT_OBJS=precision.o m_mpi_utils.o sys.o parallel.o pxf.o
63mpi_test: $(MPI_INTERFACE) $(MT_OBJS) mpi_test.o
64	$(FC) -o mpi_test \
65	       $(LDFLAGS) mpi_test.o $(MT_OBJS) $(MPI_INTERFACE) $(LIBS)
66
67
68# Note that -DMPI_TIMING might not be removed here in some systems,
69# hence the timer_stub routine.
70#
71MPI_MAKEFILE=$(VPATH)/MPI/Makefile
72libmpi_f90.a:
73	-mkdir -p MPI
74	(cd MPI ; \
75	$(MAKE) -f $(MPI_MAKEFILE) -j 1 "VPATH=$(VPATH)/MPI" \
76	"MAKEFILES=$(MPI_MAKEFILE)" "ARCH_MAKE=../$(ARCH_MAKE)" \
77	"FPPFLAGS=$(FPPFLAGS)" \
78	"FFLAGS=$(FFLAGS:$(IPO_FLAG)=)" module_built)
79
80
81#----------------------------------------------------------------------------
82#
83clean:
84	rm -f *.o *.*d
85	rm -f pi3 blacs_prb pblas_prb newcomm
86	rm -rf MPI $(MPI_INTERFACE)
87
88# Manual dependencies
89m_mpi_utils.o: sys.o
90sys.o: parallel.o
91