Two issues in make file, g++, gfortran


 
Thread Tools Search this Thread
Top Forums Programming Two issues in make file, g++, gfortran
# 8  
Old 03-17-2011
What I have done is to try to clean up my src location by moving some files into sub-folders. The files I moved don't get changed very often, and when I port to linux, it helps some to only have to deal with files that have been changed.

I took my src directory, and added some sub directories,

src/
src/src_server/
src/src_main/

I moved some cpp files from src/ to src/src_server/ and then added the compile rule,
Code:
# compile src c++ server objects
$(BDIR)/%.o: $(SOURCELOC)/src_server/%.cpp
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

This is what "worked fine". The src files in src/src_server/ got compiled and the objects placed in BDIR.

I tried the same thing with some fortran files, moving them to src/src_main/ and adding the compile rule,
Code:
# compile src gfortran main function objects
# compile src g77 objects
$(BDIR)/%.o: $(SOURCELOC)/src_main/%.FOR \
                      $(SOURCELOC)/src_main/COMMON.BLK \
                      $(SOURCELOC)/src_main/PARAM.DAT \
                      $(SOURCELOC)/src_main/ATSYMB.DAT
    $(FCOMP) $(FCFLAGS) -c -o $@ $<

When I run the make, I get a message that there is no rule to compile the object for the first src file and it quits. I need to reproduce the message and then I will post the output. Under cygwin, I am using make 3.81. I am also doing this in ubuntu, so I will have to boot into that to get the version that is installed there.

At first, I thought the issue may have been with COMMON.BLK, PARAM.DAT, etc, but I thought that would generate a compiler error, not a message about a missing rule. I am not sure why these files need to be included in the compile rule like they are, since they are included in the src, but I don't remember where I got the syntax for this and it's harder to find good information about Fortran make files than other languages.

LMHmedchem

---------- Post updated at 07:44 PM ---------- Previous update was at 07:23 PM ----------

I made the changes in my cygwin make file, and everything worked fine. I need to go back over to linux and see if the problem persists there or not. I'm not sure if I did anything differently this time or not.
# 9  
Old 03-17-2011
Hi.

My brief experiments suggest that targets in the first rule with syntax "%.o" will get compiled and the subsequent targets will be ignored. If this is true, then I assume your cpp rule comes before the fortran rule.

If this is the case with your makefile, you should be able to edit the makefile to place the fortran rule before the cpp rule and run make. I'm guessing that with that, the fortran will be compiled and the cpp ignored.

If my theory is true, then we can talk about how to solve the problem ... cheers, drl

( Edit 1: fixed typo )

Last edited by drl; 03-18-2011 at 12:11 AM..
# 10  
Old 03-17-2011
Thank you so much for your help. I was able to get it to compile, but there are all kinds of problems in the output. I think this has nothing to do with the changes in the make, but rather with some size limits I have exceeded. These limits are not in a part of the code that I wrote, so I will have to dig in and try to locate the issue. I am going to temporarily go back to a previous version just in case any of my recent changes are part of the problem. Hopefully I can get it working properly with my old make and then I can look at restructuring the build directory again. I hope that will be tomorrow sometime, but I will post back when I get it working again.

LMHmedchem
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Make and gmake issues

Hello I am working on a CPP code written for SUN CC 5.5 and make we used make to compile the code then it compilation went smooth now i am using gmake: I have a make file like this WSROOT=.. include $(WSROOT)/etc/wsmkinclude.common all: @for subdir in */Makefile; \ do \... (1 Reply)
Discussion started by: Revathi R
1 Replies

2. Programming

Make and gmake issues

Hello I am working on a CPP code written for SUN CC 5.5 and make we used make to compile the code then it compilation went smooth now i am using gmake: I have a make file like this WSROOT=.. include $(WSROOT)/etc/wsmkinclude.common all: @for subdir in */Makefile; \ do \... (1 Reply)
Discussion started by: Revathi R
1 Replies

3. Programming

gfortran 4.7, no support for qfloat?

I have code that works fine in ifort. But when trying to run on gfortran 4.7.1 (which does support quads and has no problem with real * 16) I can't cast an integer variable to a quad precision float (real*16) using something like: factq(i) = factq(i-1) * qfloat(i) Finding a list of the new... (2 Replies)
Discussion started by: vibrantcascade
2 Replies

4. Programming

Compilation problem with gfortran

Hello everyone, I'm trying since a few days to compile a f90 program with gfortran (on Ubuntu) with a makefile. The fortran program calls 2 routines written in C. Here is my makefile: FC = gfortran SFC = gfortran FFLAGS = -ffree-form -O... (21 Replies)
Discussion started by: leroygr
21 Replies

5. Programming

Gfortran compiler options.

I am a INTEL fortran user recently migrated to linux and installed gfortran on my system. I run numerical models as part of my research. my question is on optimization of the fortran code. I used the - vectorize option to compile for reducing the run time considerably and was happy. But... (1 Reply)
Discussion started by: schamarthi1
1 Replies

6. Programming

f77 program on gfortran

Hi, I am trying to run a simple f77 program on gfortran. Program is as follows. program trial implicit real*8 (a-h,o-z) common/var/a(2),b,c(4),d a=(/0,0/) b=0 c=(/0,0,0,0/) d=0 call add(a,b,c,d) ... (1 Reply)
Discussion started by: anshulfy
1 Replies

7. Programming

gfortran not connecting to system libraries

Hi ! I have one program made of several sub programs which I am trying to compile with gfortran on Fedora 14 in my system. The program was originally written in Fortran 77 and compilation command used to be - fort77 -O2 -f -w -o life life_com.f lifetime.f minuit.f tek_life.f utilities.f... (0 Replies)
Discussion started by: cylab123
0 Replies

8. Programming

Fortran 77 and gfortran

Hi! I have a program in fortran77. This program was compiled with pgf90, but now, I need compiled it with gfortran. I show a bit of code. program hello PARAMETER(a=100) integer a write(*,*)'value ', a end program hello What's the problem? Thanks (2 Replies)
Discussion started by: kekaes
2 Replies

9. Programming

makeutility: how to get the make-file name inside of the make-file?

How I can get the current make-file name in a make-file So, if I run make with specified file:make -f target.mak is it possible to have the 'target' inside of the that 'target.mak' from the file name? (2 Replies)
Discussion started by: alex_5161
2 Replies

10. Red Hat

AMBER md/g95/gfortran issue

Hi, i am trying to install AMBER10 which is a molecular dynamcis package onto two linux red hat pcs. I can successfully install the tools that comes with which uses gcc to compile, however AMBER10 requires either g95 or gfortran to compile. This is where the issue lies, i have installed both... (0 Replies)
Discussion started by: olifu02
0 Replies
Login or Register to Ask a Question