fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

COMPILE PRIMARY FILES IN SITU

Syntax:

COMPILE [PRIMARY] FILES IN SITU COMPILE [PRIMARY] FILES IN PLACE COMPILE [PRIMARY] FILES IN CURRENT DIRECTORY

Function:

The command MAKE MAKEFILE directs fpt to write a Makefile for every main program in the project. The command COMPILE PRIMARY FILES IN CURRENT DIRECTORY creates Makefiles where all objects, .mod files and the exectable are written to the directory in which the make command is executed. This directory is assumed to be parallel to the directory containing the fsp file. The command COMPILE PRIMARY FILES IN SITU creates Makefiles where the object, .mod and executables are written in the same directories as the primary input files.

Editing of file names in Makefiles is suppressed when COMPILE PRIMARY FILES IN SITU is specified.

For example, in the small project with the directory structure:

build fpt    compile_in_build.fsp    compile_in_situ.fsp    compiler.make    files.fsp fpt_output    prog    subs original_source prog    main.f90 subs module_hello.f90 world.f90

where the Fortran sources are:

! File main.f90 PROGRAM main USE module_hello IMPLICIT NONE CALL hello CALL world END PROGRAM main

! File module_hello.f90 MODULE module_hello IMPLICIT NONE CONTAINS ! ======== SUBROUTINE hello WRITE(*,'(/,"Hello ",$)') END SUBROUTINE hello END MODULE module_hello

and

SUBROUTINE world IMPLICIT NONE WRITE(*,'("World!",/)') END SUBROUTINE world

The fsp files are:

! files.fsp % primary input file name extension: ".f90" % free format % lower case symbols % no column format % keep output directories % keep file name extensions % edit output file names: replace "original_source" by "fpt_output" % overwrite changed files % input directory "../original_source/prog" main.f90 % input directory "../original_source/subs" module_hello.f90 world.f90 ! End of files.fsp

! compile_in_build.fsp files.fsp % make makefile % edit file names in makefiles: use relative paths ! End of compile_in_build.fsp

and

! compile_in_situ.fsp files.fsp % make makefile % compile files in situ ! End of compile_in_situ.fsp

If fpt is run with either the command:

fpt compile_in_build.fsp

or the command:

fpt compile_in_situ.fsp

New files are written in the fpt and fpt_output directories:

build fpt    compile_in_*.fpl    compile_in_*.fsp    compile_in_situ.fsp    compiler.make    files.fsp    Makefile_main fpt_output    prog       main.f90    subs    module_hello.f90    world.f90 original_source prog    main.f90 subs module_hello.f90 world.f90

When fpt is executed on compile_in_build.fsp the Makefile written is:

# ***************************************************************************** # File: Makefile_main # Output by fpt 4.2-f Intel-Linux On 31:Dec:50 At 00:00:00 # Licensee: SimCon: Development version. # ***************************************************************************** include compiler.make main.exe: \ main.o \ module_hello.o \ world.o $(LN) -o 'main.exe' \ 'main.o' \ 'module_hello.o' \ 'world.o' \ $(ADDITIONAL_OBJECTS) main.o: \ ../fpt_output/prog/main.f90 \ module_hello.mod $(FC) $(FCFLAGS) \ -I '../fpt_output/prog' \ '$<' module_hello.o: \ ../fpt_output/subs/module_hello.f90 $(FC) $(FCFLAGS) \ -I '../fpt_output/subs' \ '$<' world.o: \ ../fpt_output/subs/world.f90 $(FC) $(FCFLAGS) \ -I '../fpt_output/subs' \ '$<' module_hello.mod: \ ../fpt_output/subs/module_hello.f90 $(FC) $(FCFLAGS) \ -I ../fpt_output/subs \ '$<' # End of Makefile *************************************************************

The make command is issued in the build directory. compiler.make is copied to this directory:

john@gemsbok:~/tests/makefiles/build$ make -f ../fpt/Makefile_main

The directory build then received all of the object, .mod and exectable files:

build compiler.make main.exe main.o module_hello.mod module_hello.o world.o

The Makefile generated using compile_in_situ.fsp is:

# ***************************************************************************** # File: Makefile_main # Output by fpt 4.2-f Intel-Linux On 31:Dec:50 At 00:00:00 # Licensee: SimCon: Development version. # ***************************************************************************** include compiler.make /home/john/tests/makefiles/fpt_output/prog/main.exe: \ /home/john/tests/makefiies/fpt_output/prog/main.o \ /home/john/tests/makefiies/fpt_output/subs/module_hello.o \ /home/john/tests/makefiies/fpt_output/subs/world.o $(LN) -o '/home/john/tests/makefiies/fpt_output/prog/main.exe' \ '/home/john/tests/makefiies/fpt_output/prog/main.o' \ '/home/john/tests/makefiies/fpt_output/subs/module_hello.o' \ '/home/john/tests/makefiies/fpt_output/subs/world.o' \ $(ADDITIONAL_OBJECTS) /home/john/tests/makefiies/fpt_output/prog/main.o: \ /home/john/tests/fpt_output/prog/main.f90 \ /home/john/tests/fpt_output/module_hello.mod $(FC) $(FCFLAGS) \ -o '/home/john/tests/makefiies/fpt_output/prog/main.o' \ -I '/home/john/tests/fpt_output/prog' \ -I '/home/john/tests/fpt_output/subs' \ '$<' /home/john/tests/makefiies/fpt_output/subs/module_hello.o: \ /home/john/tests/fpt_output/subs/module_hello.f90 $(FC) $(FCFLAGS) \ -o '/home/john/tests/makefiies/fpt_output/subs/module_hello.o' \ -I '/home/john/tests/fpt_output/subs' \ '$<' /home/john /tests/makefiies/fpt_output/subs/world.o: \ /home/john/tests/fpt_output/subs/world.f90 $(FC) $(FCFLAGS) \ -o '/home/john/tests/makefiies/fpt_output/subs/world.o' \ -I '/home/john/tests/fpt_output/subs' \ '$<' module_hello.mod: \ /home/john/tests/fpt_output/subs/module_hello.f90 $(FC) $(FCFLAGS) \ -I /home/john/tests/fpt_output/subs \ '$<' # End of Makefile *************************************************************

This Makefile can be used in any directory. The files are specified with complete paths. When the make command is made, the resulting directory structure is:

build fpt    compile_in_build.fsp    compile_in_situ.fpl    compile_in_situ.fsp    compiler.make    files.fsp    Makefile_main fpt_output    prog       main.exe       main.f90       main.o    subs    module_hello.f90    module_hello.mod    module_hello.o    world.f90    world.o original_source prog    main.f90 subs module_hello.f90 world.f90

Note that the objects, .mod file and executable are created in the same directories as the primary compilation files. For example, main.exe and main.o are in the same directory as main.f90.

Where to Use this Command

Operating system command line Yes
Configuration file, config.fsp Yes
Specification (fsp) files, *.fsp Yes
Interactively, to FPT> prompt Yes
Interactive command files Yes
Embedded in the Fortran code Yes

Default

COMPILE PRIMARY FILES IN CURRENT DIRECTORY (Note that defaults may be changed in the configuration file).

Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.