Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28441 Discussions

Fortran makefile circular dependency dropped

josieecon
Beginner
1,578 Views

So I am trying to run a Fortran code from someone else with the Intel Fortran compiler on a mac. But when I try to run the corresponding makefile, I get the error messages "make[1]: Circular release.makefile out <- release.makefile dependency dropped." and so on.

I have little knowledge of Fortran, so I would appreciate any help. I already tested to run some simple helloworld.f90 files and makefiles, to rule out that it is a compiler problem, and those work. However, the code I am trying to run is downloaded from a reputable scientific journal, so I assume the code (makefiles and Fortran files) should be correct too, leaving me at loss. This is my first post here, so if I forgot something please let me know.

The makefile is:

release:
    # ENV = /opt/intel/oneapi/setvars.sh intel64
    make -f release.makefile

debug:
    # ENV = /opt/intel/oneapi/setvars.sh intel64
    make -f debug.makefile
    dsymutil $(OUT).out

hpcrelease:
    make -f hpcrelease.makefile

pbs:
    make -f pbs.makefile

compilesubmit:
    make -f hpcrelease.makefile
    make -f pbs.makefile
    qsub $(OUT).pbs

.PHONY: clean

clean:
    rm -f *.o *.mod *.MOD *genmod* *~ 
    rm -fr *.dSYM

and the file release.makefile writes:

FC = ifort
FCFLAGS = -m64 -traceback -O3 -qopenmp -implicitnone  -Wl,-stack_size,0x100000000 -L/Users/josie/Desktop/Uni/Economics/Moll/SuiteSparse-master/lib -lumfpack -lamd -lcholmod -lcolamd -lsuitesparseconfig -lblas 
LDFLAFS = -m64 -traceback -O3 -qopenmp -implicitnone  -Wl,-stack_size,0x100000000 -L/Users/josie/Desktop/Uni/Economics/Moll/SuiteSparse-master/lib -lumfpack -lamd -lcholmod -lcolamd -lsuitesparseconfig -lblas 
# -O3

PROG = $(OUT)

MOD = Parameters.o Globals.o umfpack.o Procedures.o 

SUBR =  AllocateArrays.o SetParameters.o Grids.o IterateBellman.o HJBUpdate.o cumnor.o rtsec.o StationaryDistribution.o SaveSteadyStateOutput.o DistributionStatistics.o rtbis.o rtflsp.o InitialSteadyState.o FinalSteadyState.o SolveSteadyStateEqum.o Calibration.o MomentConditions.o dfovec.o newuoa-h.o newuob-h.o update.o trsapp-h.o biglag.o bigden.o mnbrak.o golden.o sort2.o  CumulativeConsumption.o  FnDiscountRate.o  OptimalConsumption.o FnHoursBC.o  ImpulseResponses.o IRFSequence.o Transition.o  SaveIRFOutput.o IterateTransitionStickyRb.o IterateTransOneAssetStickyRb.o FnCapitalEquity.o CumulativeConsTransition.o DiscountedMPC.o DiscountedMPCTransition.o


OBJ = $(MOD) $(SUBR)

$(PROG).out: $(OBJ) Main.o
    $(FC) $(FCFLAGS) -o $@ $^ $(LDFLAGS)
Main.o: $(MOD)

%: %.o
    $(FC) $(FCFLAGS) -o $@ $^ $(LDFLAGS)

%.o: %.f90
    $(FC) $(FCFLAGS) -c $<

the error I get is

Fortran % make -f makefile
# ENV = /opt/intel/oneapi/setvars.sh intel64
make -f release.makefile
make[1]: Circular release.makefile.out <- release.makefile dependency dropped.
make[1]: Circular Main.f90.out <- Main.f90 dependency dropped.
make[1]: Circular Parameters.f90.out <- Parameters.f90 dependency dropped.
make[1]: Circular Globals.f90.out <- Globals.f90 dependency dropped.
make[1]: Circular umfpack.f90.out <- umfpack.f90 dependency dropped.
make[1]: Circular Procedures.f90.out <- Procedures.f90 dependency dropped.
make[1]: `Main.o' is up to date.

Since the error already occurs with the release.makefile, I refer from giving the other files since I believe the error is the same for all scripts? Correct me if I am wrong and those are necessary.

0 Kudos
1 Solution
David_Billinghurst
New Contributor III
1,555 Views

Josie,

This doesn't look like a Fortran problem.  I think your issue is that the make variable OUT is undefined.

What do you get with the command

make -f release.makefile OUT=foo

I would hope the compiler would generate all the named .o files and a foo.out executable.

View solution in original post

0 Kudos
5 Replies
David_Billinghurst
New Contributor III
1,556 Views

Josie,

This doesn't look like a Fortran problem.  I think your issue is that the make variable OUT is undefined.

What do you get with the command

make -f release.makefile OUT=foo

I would hope the compiler would generate all the named .o files and a foo.out executable.

0 Kudos
josieecon
Beginner
1,523 Views

Hi David, 

thank you so much! It works and does exactly as you say. I get o.files and foo.out, which I can then execute.

0 Kudos
David_Billinghurst
New Contributor III
1,504 Views

Excellent.  Now that we understand it is worth explaining.  (I didn't want to add to the confusion if I was wrong.)

The problem is that the make variable OUT is empty.  Similarly PROG = $(OUT).  This expands part of your release.makefile (above) into

MOD = Parameters.o Globals.o umfpack.o Procedures.o 

SUBR =  AllocateArrays.o SetParameters.o Grids.o IterateBellman.o HJBUpdate.o cumnor.o rtsec.o StationaryDistribution.o \
  SaveSteadyStateOutput.o DistributionStatistics.o rtbis.o rtflsp.o InitialSteadyState.o FinalSteadyState.o \
  SolveSteadyStateEqum.o Calibration.o MomentConditions.o dfovec.o newuoa-h.o newuob-h.o update.o trsapp-h.o biglag.o bigden.o \
  mnbrak.o golden.o sort2.o CumulativeConsumption.o  FnDiscountRate.o  OptimalConsumption.o FnHoursBC.o  \
  ImpulseResponses.o IRFSequence.o Transition.o SaveIRFOutput.o IterateTransitionStickyRb.o \
  IterateTransOneAssetStickyRb.o FnCapitalEquity.o CumulativeConsTransition.o DiscountedMPC.o DiscountedMPCTransition.o

OBJ = $(MOD) $(SUBR)

.out: $(OBJ) Main.o
    $(FC) $(FCFLAGS) -o $@ $^ $(LDFLAGS)

%.o: %.f90
    $(FC) $(FCFLAGS) -c $<

This defines an implicit rule for files with the .out suffix and is the ultimate cause of your problems.

You could:

  • add a line OUT = foo or similar to your Makefile as an immediate fix
  • add some "Usage: ..." comments to the Makefile for the next developer (which could be you)
  • consult a local make guru if you have one to hand.  They don't need to know much/any Fortran
  • do some reading

I am am big fan of make.  It can be a blunt object, but used with sufficient force it makes a decent hammer.  There are more sophisticated tools but will they work in the long term?

I have used make to capture complex workflows for running suites of numerical models, including build, pre- and post-processing.  A former employer recently asked me to revisit modelling from 20+ years ago.  They still had my old Makefiles and we were able to exactly reproduce prior work (despite a change of platform).  Three cheers for portable, in-house code written in standard-conforming Fortran 77/90, version control, documented procedures, archiving, and all those other software engineering practices that we waste project time on.

0 Kudos
JohnNichols
Valued Contributor III
1,494 Views

"I am a big fan of make.  It can be a blunt object, but used with sufficient force it makes a decent hammer.  There are more sophisticated tools but will they work in the long term?"

Thanks for the humour.  Although F. N. Davids' said something similar about Lancaster Bombers during WW2 in her still classified statistical paper.  It made an excellent but dry read.  

Her side effects were a bit more obvious.  

0 Kudos
josieecon
Beginner
1,478 Views

Thanks for the extra explanation and the fun read! Always happy to obtain some new insights. 

It indeed sounds like makefiles are made for eternity, so I might allow myself a little read in that area. Unfortunately cannot say that about some of my Julia files from a few years anymore  

0 Kudos
Reply