Hello,
I’m trying to work one of the example files in MKL, namely pardiso_sym_f90.f90. I obtained a c makefile from someone else, modified it for Intel fortran compiler. I am able to get this code working with that. To use the pgi compiler, I only changed the ifort command to pgfortran. The current makefile I’m using is:
#-------------------------------------------------------------------#
#Define executable
#-------------------------------------------------------------------#
EXEC := exp
#-------------------------------------------------------------------#
#Define constant
#-------------------------------------------------------------------#
RM := rm -f
#-------------------------------------------------------------------#
#Define directories
#-------------------------------------------------------------------#
SRCDIR := ./
HDRDIR :=
SRCEXT := f90
#-------------------------------------------------------------------#
#Define directories for object and dependency files
#-------------------------------------------------------------------#
OBJDIR := .o
DEPDIR = .d
#-------------------------------------------------------------------#
#Generate source files list
#-------------------------------------------------------------------#
SRCS := $(wildcard $(SRCDIR)/*.$(SRCEXT))
#-------------------------------------------------------------------#
#Generate object and dependency files
#-------------------------------------------------------------------#
OBJS := $(patsubst %,$(OBJDIR)/%.o,$(basename $(SRCS)))
DEPS := $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))
$(shell mkdir -p $(dir $(OBJS)) >/dev/null)
$(shell mkdir -p $(dir $(DEPS)) >/dev/null)
#-------------------------------------------------------------------#
#Define compiler and library flags
#-------------------------------------------------------------------#
FC := pgfortran
LD := pgfortran
FFLAGS := -warn all -O2 -i8 -I${MKLROOT}/include
LDFLAGS := -L${MKLROOT}/lib/intel64
LDLIBS = -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl
#-------------------------------------------------------------------#
#Define dependencies
#-------------------------------------------------------------------#
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
#-------------------------------------------------------------------#
#Define compiling and linking commands
#-------------------------------------------------------------------#
COMPILE.f90 = $(FC) $(DEPFLAGS) $(FFLAGS) $(TARGET_ARCH) -c -o $@
LINK.o = $(LD) $(LDFLAGS) $(TARGET_ARCH) -o $@
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
#-------------------------------------------------------------------#
#Define rules
#-------------------------------------------------------------------#
all: $(EXEC)
.PHONY: clean
clean:
$(RM) -r $(OBJDIR) $(DEPDIR)
.PHONY: distclean
distclean: clean
$(RM) $(EXEC)
$(EXEC): $(OBJS)
#$(LD) $(LDFLAGS) $(TARGET_ARCH) -o $@ $^ $(LDLIBS)
$(LINK.o) $^ $(LDLIBS)
$(OBJDIR)/%.o: %.f90
$(OBJDIR)/%.o: %.f90 $(DEPDIR)/%.d
$(COMPILE.f90) $<
$(POSTCOMPILE)
.PRECIOUS: $(DEPDIR)/%.d
$(DEPDIR)/%.d: ;
-include $(DEPS)
The error I get:
pgfortran -MT .o/.//pardiso_sym_f90.o -MMD -MP -MF .d/.//pardiso_sym_f90.Td -warn all -O2 -i8 -I/home/kaan/intel/compilers_and_libraries_2019.3.199/linux/mkl/include -c -o .o/.//pardiso_sym_f90.o pardiso_sym_f90.f90
pgfortran-Error-Unknown switch: -MT
pgfortran-Error-Unknown switch: -MMD
pgfortran-Error-Unknown switch: -MP
pgfortran-Error-Unknown switch: -MF
pgfortran-Error-Unknown switch: -warn
Makefile:97: recipe for target ‘.o/.//pardiso_sym_f90.o’ failed
make: *** [.o/.//pardiso_sym_f90.o] Error 1
When I close the unknown switches; makefile becomes:
#-------------------------------------------------------------------#
#Define executable
#-------------------------------------------------------------------#
EXEC := exp
#-------------------------------------------------------------------#
#Define constant
#-------------------------------------------------------------------#
RM := rm -f
#-------------------------------------------------------------------#
#Define directories
#-------------------------------------------------------------------#
SRCDIR := ./
HDRDIR :=
SRCEXT := f90
#-------------------------------------------------------------------#
#Define directories for object and dependency files
#-------------------------------------------------------------------#
OBJDIR := .o
DEPDIR = .d
#-------------------------------------------------------------------#
#Generate source files list
#-------------------------------------------------------------------#
SRCS := $(wildcard $(SRCDIR)/*.$(SRCEXT))
#-------------------------------------------------------------------#
#Generate object and dependency files
#-------------------------------------------------------------------#
OBJS := $(patsubst %,$(OBJDIR)/%.o,$(basename $(SRCS)))
DEPS := $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))
$(shell mkdir -p $(dir $(OBJS)) >/dev/null)
$(shell mkdir -p $(dir $(DEPS)) >/dev/null)
#-------------------------------------------------------------------#
#Define compiler and library flags
#-------------------------------------------------------------------#
FC := pgfortran
LD := pgfortran
#FFLAGS := -warn all -O2 -i8 -I${MKLROOT}/include
LDFLAGS := -L${MKLROOT}/lib/intel64
LDLIBS = -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl
#-------------------------------------------------------------------#
#Define dependencies
#-------------------------------------------------------------------#
#DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
#-------------------------------------------------------------------#
#Define compiling and linking commands
#-------------------------------------------------------------------#
COMPILE.f90 = $(FC) $(DEPFLAGS) $(FFLAGS) $(TARGET_ARCH) -c -o $@
LINK.o = $(LD) $(LDFLAGS) $(TARGET_ARCH) -o $@
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
#-------------------------------------------------------------------#
#Define rules
#-------------------------------------------------------------------#
all: $(EXEC)
.PHONY: clean
clean:
$(RM) -r $(OBJDIR) $(DEPDIR)
.PHONY: distclean
distclean: clean
$(RM) $(EXEC)
$(EXEC): $(OBJS)
#$(LD) $(LDFLAGS) $(TARGET_ARCH) -o $@ $^ $(LDLIBS)
$(LINK.o) $^ $(LDLIBS)
$(OBJDIR)/%.o: %.f90
$(OBJDIR)/%.o: %.f90 $(DEPDIR)/%.d
$(COMPILE.f90) $<
$(POSTCOMPILE)
.PRECIOUS: $(DEPDIR)/%.d
$(DEPDIR)/%.d: ;
-include $(DEPS)
The error I get:
pgfortran -c -o .o/.//pardiso_sym_f90.o pardiso_sym_f90.f90
PGF90-S-0017-Unable to open include file: mkl_pardiso.f90 (pardiso_sym_f90.f90: 22)
PGF90-F-0004-Unable to open MODULE file mkl_pardiso.mod (pardiso_sym_f90.f90: 24)
PGF90/x86-64 Linux 18.10-1: compilation aborted
Makefile:97: recipe for target ‘.o/.//pardiso_sym_f90.o’ failed
make: *** [.o/.//pardiso_sym_f90.o] Error 2
I’m fairly new to makefile concept, any help with this specific problem or in general is appreciated.
Thank you in advance.