What the command means: gfortran -c -03 $

1

Well, I'm trying to understand a program here that I'm using in my scientific initiation, but with a doubt in a make file.

# makefile for code
OBJ1 = main.o derivs.o filter.o

code: $(OBJ1)
    gfortran $(OBJ1) -o prg

.f.o:
    gfortran -c -O3 $<

clean:
    rm *~ *.o *.dat prg

The "code:", ". f.o" and "clean:" are the commands that I have to use with make to be able to execute the line that is just below them, from what I understand. What does this line mean? gfortran -c -03 $

Ahh, and just to see if I'm getting it right, -o is to compile the code into a file, already -c does that too, but it's used when we have to join one or more codes that are in different files, is this?

Thanks for the help right away.

    
asked by anonymous 27.03.2017 / 19:40

1 answer

1

Well, this is Makefile . For more details, GNU staff provides an online manual: link

In parts:

  • you are using a syntax of implicit rules
  • It is said that any Fortan ( .f ) file will be transformed into an object file of the same root ( .o )
  • gfortran -c -O3 $< is a command line:
    • gfortran is the name of the command to execute
    • -c indicates that it is a partial compilation (the output will be an object file .o )
    • -O3 is the build flag that indicates the optimization level 3
    • $< is a automatic variable of Makefile ; its value is the name of the first dependency of the called target, in this case it can be main.f (target main.o ), derivs.f (target derivs.o ) or filter.f (target filter.o )
  • EDIT

    Note that the -o option is distinct from the -O option. -o (lowercase) indicates output file in GCC, and -O is optimization level.

        
    27.03.2017 / 20:33