At the very heart of FTN95 is the Fortran 95 compiler. It is a console program which means that it runs without any windows, menus or dialogs. It just starts, compiles and then exits.
Plato makes it appear as if it contains the compiler but it does not. The compiler is held within FTN95.EXE and compilation whether it is done from a command prompt, Plato or Visual Studio is
essentially the same: FTN95.EXE is run with some command-line arguments. Although Plato may guide the running of FTN95.EXE for you it will be worth reading below how it can be done manually.
Single Source File
If you have a single file Fortran program, probably a bit more complicated than this:
do i=1,10
print *, i, ' squared is ', i*i
end do
end
and if it is placed in the folder c:\ftn then you can compile it, link and run by (user entry in green)
c:\ftn >dir
18/01/11 18:16 <DIR> .
18/01/11 18:16 <DIR> ..
18/01/11 18:10 57 test.f90
57 bytes in 1 file and 2 dirs 8,192 bytes allocated
879,168,688,128 bytes free
c:\ftn >ftn95 test /link
[FTN95/Win32 Ver. 5.40 Copyright (c) Silverfrost Ltd 1993-2010]
NO ERRORS [<main program> FTN95/Win32 v5.40]
Creating executable: test.EXE
c:\ftn >test
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25
6 squared is 36
7 squared is 49
8 squared is 64
9 squared is 81
10 squared is 100
If you wanted to debug the program, just do:
c:\ftn >ftn95 test /break
You will be taken directly into sdbg the debugger. If you press the <F7> key a few times you will see it step through your code.
Using this compile/debug cycle you can very quickly make changes and test your programs.
Multiple Source Files
In the example above there was only one source file. When we compiled we used the command "ftn95 test /link". Although it is only one
command it actually does two things: compile and link. Linking is the process of taking the compiled code and combining it with the
run-time system to produce an executable. Within the FTN95 system the linker is called Slink. If we have more than one source file we have to compile
each separately and then link them.
If you have a main program in prog.f90, and two other source files: utils.f90 and model.f90, then to compile them we would do (user entry in green):
c:\ftn >ftn95 prog /debug
[FTN95/Win32 Ver. 5.40 Copyright (c) Silverfrost Ltd 1993-2010]
NO ERRORS [<main program> FTN95/Win32 v5.40]
c:\ftn >ftn95 utils /debug
[FTN95/Win32 Ver. 5.40 Copyright (c) Silverfrost Ltd 1993-2010]
NO ERRORS [<GETDIR> FTN95/Win32 v5.40]
NO ERRORS [<REFORMAT> FTN95/Win32 v5.40]
c:\ftn >ftn95 model /debug
[FTN95/Win32 Ver. 5.40 Copyright (c) Silverfrost Ltd 1993-2010]
NO ERRORS [<INIT> FTN95/Win32 v5.40]
NO ERRORS [<CALC> FTN95/Win32 v5.40]
NO ERRORS [<BLDATA> FTN95/Win32 v5.40]
If you look at the FTN folder you will see three extra files: prog.obj, utils.obj and model.obj. These are 'object files' and it is what
FTN95.EXE produces - it is the result of the compilation. Object files contain the compiled code plus some other information that will allow
the linker to produce the final executable. Also notice that we have also given a '/debug' switch to each command. This switch adds information
to the object files so that sdbg can debug the final executable.
Now we have our 'object files' we can link them. To do this we use Slink and give it a series of commands:
c:\ftn >slink
[SLINK/Win32 v1.44 Copyright (c) Silverfrost Ltd. 1995-2010]
* lo prog
* lo utils
* lo model
* file
Creating executable: C:\ftn\prog.exe
Although a little bit of typing is required to compile and link several files you can easily automate it with simple
batch files.
In addition you can give slink commands by passing it a script. For example: