Debasish Das
Debasish Das

Reputation: 11

Gfortran compiling error after replacing with f77

QI need to compile some files using gfortran. I went to the makefile and replaced all the "f77" with "gfortran". However I get this error when I do "make"

gfortran -c verbal.f 
gfortran -c trgl6_octa.f 
gfortran -c trgl6_icos.f 
gfortran -c gauss_trgl.f 
gfortran -c gauss_leg.f 
gfortran -c sgf_3d_fs.f 
gfortran -c sgf_3d_w.f 
f77   -c -o sgf_3d_2p_w.o sgf_3d_2p_w.f
make: f77: Command not found
make: *** [sgf_3d_2p_w.o] Error 127

I do not understand where in the make file (pasted below) there is a hidden f77 that did not get replaced. I checked all the sources files for "f77" and there was none. I am very confused.

#
# Objects
# -------
#
OBJ0 = verbal.o
OBJ1 = trgl6_octa.o trgl6_icos.o gauss_trgl.o gauss_leg.o 
OBJ2 = sgf_3d_fs.o sgf_3d_w.o sgf_3d_2p_w.o
OBJ2A = sgf_3d_3p.o sgf_3d_3p_ewald.o sgf_3d_3p_qqq.o
OBJ3 = prtcl_3d_mob.o
OBJ30 = elm_geom.o abc.o interp_p.o printel.o
OBJ33 = slp_trgl6.o slp_trgl6_sing.o slp_trgl3_sing.o
OBJ4 = gel.o gel_inv.o
OBJ  = $(OBJ0) $(OBJ1) $(OBJ2) $(OBJ2A) $(OBJ3) $(OBJ30) $(OBJ33) $(OBJ4)
#
# link
# ----
#
prtcl_3d_mob: $(OBJ)
    gfortran -c prtcl_3d_mob $(OBJ)
#
# compile
# ------
#
prtcl_3d_mob.o: prtcl_3d_mob.f 
    gfortran -c prtcl_3d_mob.f 
trgl6_octa.o: trgl6_octa.f 
    gfortran -c trgl6_octa.f 
trgl6_icos.o: trgl6_icos.f 
    gfortran -c trgl6_icos.f 
verbal.o: verbal.f
    gfortran -c verbal.f 
sgf_3d_fs.o: sgf_3d_fs.f 
    gfortran -c sgf_3d_fs.f 
sgf_3d_w.o: sgf_3d_w.f 
    gfortran -c sgf_3d_w.f 
sgf_3d_3p.o: sgf_3d_3p.f 
    gfortran -c sgf_3d_3p.f 
sgf_3d_3p_ewald.o: sgf_3d_3p_ewald.f 
    gfortran -c sgf_3d_3p_ewald.f 
sgf_3d_3p_qqq.o: sgf_3d_3p_qqq.f 
    gfortran -c sgf_3d_3p_qqq.f 
gel.o: gel.f 
    gfortran -c gel.f 
gel_inv.o: gel_inv.f 
    gfortran -c gel_inv.f 
prtcl_3d_geo.o: prtcl_3d_geo.f 
    gfortran -c prtcl_3d_geo.f 
interp_p.o: interp_p.f
    gfortran -c interp_p.f
abc.o: abc.f
    gfortran -c abc.f
printel.o: printel.f
    gfortran -c printel.f
elm_geom.o: elm_geom.f
    gfortran -c elm_geom.f
slp_trgl6.o: slp_trgl6.f
    gfortran -c  slp_trgl6.f 
slp_trgl6_sing.o: slp_trgl6_sing.f
    gfortran -c  slp_trgl6_sing.f 
slp_trgl3_sing.o: slp_trgl3_sing.f
    gfortran -c  slp_trgl3_sing.f 
gauss_leg.o: gauss_leg.f 
    gfortran -c gauss_leg.f 
gauss_trgl.o: gauss_trgl.f 
    gfortran -c gauss_trgl.f 
#
# clean
# -----
#
clean:
    rm -f core
    rm -f $(OBJ) prtcl_3d_mob
    rm -f prtcl_3d_mob.net prtcl_3d_mob.out
    rm -f matrix_inverse.out
    rm -f particle_elements.out
#
# purge
# ---
#
purge:
    rm -f core 
    rm -f $(OBJ) prtcl_3d_mob
    rm -f prtcl_3d_mob.net prtcl_3d_mob.out
    rm -f matrix_inverse.out
    rm -f particle_elements.out
#
# clobber
# ---
#
clobber:
    rm *
#
# all
# ---
#
all:
    make prtcl_3d_mob

Upvotes: 0

Views: 1090

Answers (1)

Pierre de Buyl
Pierre de Buyl

Reputation: 7293

GNU make has a number of implicit rules https://www.gnu.org/software/make/manual/make.html#Catalogue-of-Rules

By default, it will compile .f files with the rule $(FC) $(FFLAGS) -c where by default FC is set to f77 (see link above for all of this).

As an explicit rule ("from .f to .o") is not found for a file, make invokes the default rule.

Solutions: either one of the two

  1. Set FC to gfortran
  2. add an explicit rule for sgf_3d_2p_w.o

In general, I write the rule myself as

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

in the Makefile. It makes it obvious that I need to define FC and FFLAGS.

Also, you can then remove all of the individual rules for compiling your files.

Upvotes: 3

Related Questions