Как написать make-файл для Фортрана с несколькими исполняемыми файлами - PullRequest
0 голосов
/ 27 июня 2018

на основе этого вопроса Makefile с несколькими исполняемыми файлами Я пытаюсь написать версию на фортране.

Исходный код разделен на несколько файлов * .f90. Поэтому я попытался использовать приведенную выше идею, вот отрывок из моего make-файла:

PROGRAM := Mpois Mkvz

# Definitions
COMPILER := gfortran -O3 -ffast-math
LIBS := -fbounds-check -lm

# Directories of object code
OBJDIR = objects

SOURCES_pois  := BORDERS.f90  CONVERGENCE.f90  FILESIO.f90  LBM.f90 Main_pois.f90
OBJECTS_pois  := BORDERS.o  CONVERGENCE.o  FILESIO.o  LBM.o Main_pois.o

SOURCES_kvz  := BORDERS.f90  CONVERGENCE.f90  FILESIO.f90  LBM.f90 Main_KVZ.f90
OBJECTS_kvz  := BORDERS.o  CONVERGENCE.o  FILESIO.o  LBM.o Main_KVZ.o

#   Linking
Mpois: $(OBJECTS_pois)
    $(COMPILER) $^ -o $@ $(LIBS)

#   Compiling
$(OBJECTS_pois): $(OBJDIR)/%.o: %.f90
    $(COMPILER) -c $< -o $@

#   Linking
Mkvz: $(OBJECTS_kvz)
    $(COMPILER) $^ -o $@ $(LIBS)

#   Compiling
$(OBJECTS_kvz): $(OBJDIR)/%.o: %.f90
    $(COMPILER) -c $< -o $@

clean:
    rm -f $(OBJDIR)/*.o

Идея заключалась в том, что при вызове

make

в терминале linux результаты должны быть в двух разных исполняемых файлах. Тем не менее я получаю следующее сообщение:

makefile:21: target `BORDERS.o' doesn't match the target pattern
makefile:21: target `CONVERGENCE.o' doesn't match the target pattern
makefile:21: target `FILESIO.o' doesn't match the target pattern
makefile:21: target `LBM.o' doesn't match the target pattern
makefile:21: target `Main_pois.o' doesn't match the target pattern
makefile:29: target `BORDERS.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `BORDERS.o'
makefile:22: warning: ignoring old commands for target `BORDERS.o'
makefile:29: target `CONVERGENCE.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `CONVERGENCE.o'
makefile:22: warning: ignoring old commands for target `CONVERGENCE.o'
makefile:29: target `FILESIO.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `FILESIO.o'
makefile:22: warning: ignoring old commands for target `FILESIO.o'
makefile:29: target `LBM.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `LBM.o'
makefile:22: warning: ignoring old commands for target `LBM.o'
makefile:29: target `Main_KVZ.o' doesn't match the target pattern
gfortran -O3 -ffast-math -c  -o BORDERS.o
gfortran: fatal error: no input files; unwilling to write output files
compilation terminated.
make: *** [BORDERS.o] Error 4

Прислушиваясь к советам и советам, я приветствую вас .-

...