0

In continuation with my earlier question Makefile - compiling back and forth

I made an attempt in creating a single Makefile. The two subdirectories are HAM-src and GFS-src. However, I am still unable to build it. I paste my Makefile below:

export
SHELL = /bin/sh

top_srcdir=./Temp
objdir=$(top_srcdir)/obj
bindir=${exec_prefix}/bin
cfssrcdir=${top_srcdir}/GFS-src
hamsrcdir=${top_srcdir}/HAM-src
incdir=${top_srcdir}/include
exec=${bindir}/esm_gfs-ham_v0
PROG=$(exec)

LDR = mpxlf90_r -qsmp=noauto
FFLAG90  = $(OPTS90) $(FINCS) -qfree=f90 -NS2048 -qmoddir=$(objdir) -I$(objdir)
FFLAGM = -NS2048 -qfixed -qmoddir=$(objdir) -I$(objdir)

F77     = mpxlf95
F90     = mpxlf95
F90_x   = xlf90_r
F90_r   = mpxlf95_r

SRCHAM = $(hamsrcdir)/ham_control.f90 $(hamsrcdir)/mo_filename.f90 \
         $(hamsrcdir)/ham_namelist.f90 $(hamsrcdir)/ham_submodel.f90 \
         $(hamsrcdir)/ham_submodel_diag.f90 $(hamsrcdir)/ham_ham.f90

SRCGFS_MOD=$(cfssrcdir)/machine.f $(cfssrcdir)/resol_def.f \
           $(cfssrcdir)/omegas.f $(cfssrcdir)/cnvcld_v.f

OBJGFS_MOD = $(patsubst $(cfssrcdir)/%.f,$(objdir)/%.o,$(SRCGFS_MOD))
OBJHAM = $(patsubst $(hamsrcdir)/%.f90,$(objdir)/%.o,$(SRCHAM))

.SUFFIXES: $(SUFFIXES) .f90 .f .o

all: $(PROG)

$(PROG): $(OBJHAM) $(OBJGFS_MOD)
    $(LDR) $(CFS_LDFLAGS) -o $@ $(OBJGFS_MOD) $(OBJHAM) $(CFS_LIBS) -L$(LDFLAGS)

$(objdir)/%.o: $(cfssrcdir)/%.f
    $(F77) $(FFLAGS) -c $< -o $@

$(objdir)/%.o: $(hamsrcdir)/%.f90
    $(F90_r) $(F90FLAGS) -c $< -o $@
########## dependencies for $(hamsrcdir) ###########
ham_filename.o: ham_control.o
ham_namelist.o: ham_control.o ham_filename.o
ham_submodel.o: ham_control.o ham_namelist.o $(objdir)/resol_def.o
ham_submodel_diag.o: ham_submodel.o
########## dependencies for $(cfssrcdir) ###########
$(objdir)/omegas.o:    $(cfssrcdir)/omegas.f
        $(F77) $(FFLAGM) -c $(cfssrcdir)/omegas.f -o $@

$(objdir)/cnvcld_v.o:    $(cfssrcdir)/cnvcld_v.f
        $(F77) $(FFLAGM) -c $(cfssrcdir)/cnvcld_v.f -o $@

The error:

mpxlf95_r -q64 -O3 -qstrict -qMAXMEM=-1 -qarch=auto -qtune=auto -qcache=auto -qfloat=fltint -qsuffix=cpp=f90 -lessl_r -lmass -lmassv -I./Temp/include -I./Temp/HAM-src -qmoddir=./Temp/obj -I./Temp/obj -c ./Temp/HAM-src/ham_namelist.f90 -o ./Temp/obj/ham_namelist.o
** ham_namelist   === End of Compilation 1 ===
1501-510  Compilation successful for file ham_namelist.f90.

mpxlf95_r -q64 -O3 -qstrict -qMAXMEM=-1 -qarch=auto -qtune=auto -qcache=auto -qfloat=fltint -qsuffix=cpp=f90 -lessl_r -lmass -lmassv -I./Temp/include -./Temp/HAM-src -qmoddir=./Temp/obj -I./Temp/obj -c ./Temp/HAM-src/ham_submodel.f90 -o ./Temp/obj/ham_submodel.o
"./Temp/HAM-src/ham_submodel.f90", line 425.7: 1514-219 (S) Unable to access module symbol file for module resol_def. Check path and file permissions of file. Use association not done for this module.
1501-511  Compilation failed for file ham_submodel.f90.
gmake: *** [/gpfs1/home/cccrmod/ham_expt_dec11/regrid_test/CFS-HAM/SORC_CFS-HAM/Temp/obj/ham_submodel.o] Error 1

Why makefile does not compile the resol_def.f module on encountering the dependency?

Another issue - my makefile is not working properly. It goes in a sequence in which the sources are defined.

Community
  • 1
  • 1
jkp
  • 155
  • 2
  • 7

1 Answers1

0

This is difficult to untangle (a minimal, complete example really would help), but I'd suggest you change this

ham_submodel.o: ham_control.o ham_namelist.o $(objdir)/resol_def.o

to this

$(objdir)/ham_submodel.o: ham_control.o ham_namelist.o $(objdir)/resol_def.o

and see if that solves the first problem. I don't understand the last line of your question ("Another issue...").

Beta
  • 96,650
  • 16
  • 149
  • 150
  • No, it did not worked. Infact, .o files for the rest of the codes are found in the objdir. Please see the link - http://stackoverflow.com/questions/1139271/makefiles-with-source-files-in-different-directories?rq=1 The method given by RC - will it help in my case??? – jkp Oct 31 '12 at 05:18
  • I've progressed in my task and would like to show you. Can I've your email-id so that I can give you more specific details? Thanks! – jkp Nov 02 '12 at 11:50