FTN95 from the Command Line

Command line operation

For many (many) years Fortran has been used from batch jobs and the command-line. With all the fuss about Visual Studio and Microsoft .NET some programmers worry whether FTN95 can be easily used the 'natural' way. Let us put that worry to bed: FTN95 is as conforable to use from the command line as it as ever been. The whole development team use FTN95 from the command line al the time -- it was (and still is) developed from the command line with a set of batch files. It wasn't broke, so we did not fix it!

It is fairly easy to get FTN95 to work with your text-editor of choice, its command line options are clear and comprehensive. One option you might like to look at is /vs, it was designed so that Visual Studio could easily parse FTN95 error messages, you may find it helps with any integration you have to do. Fo example, in the above image, if the command had the /vs switch the output would be:

C:\fortran>ftn95 z9.f90 /ignore 242 /vs
C:\fortran\z9.F90(18) : comment - Specifying the kind of the type LOGICAL with t
he constant '2' is non-portable - 'SELECTED_INT_KIND(4)' would be better
C:\fortran\z9.F90(23) : comment - Specifying the kind of the type COMPLEX with t
he constant '2' is non-portable - 'SELECTED_REAL_KIND(15,307)' would be better
C:\fortran\z9.F90(1) : warning - Variable III has been declared but not used
C:\fortran\z9.F90(3) : warning - Variable UNALOC has been used without being giv
C:\fortran\z9.F90(16) : warning - Variable R4P has been declared but not used
C:\fortran\z9.F90(19) : warning - Variable L4A has been declared but not used

The other tool you will need to know something about is Slink the FTN95 linker. When you compile a file, z9.f90 for example, you produce a file with the same name but having a .obj extension (z9.obj in this case). This is called the object file. Slink's job is to take all your object files and link them all together to produce an executable that you can run. For programs that have more than a couple object files the easiest solution is use a linker response file -- a command file that slink loads and follows. Using a response file is much easier than it sounds! For example. say we have three objects files (z9, z8 and z7) and we want to produce a program called 'simul.exe' we would do:

C:\fortran>slink simul.inf

simul.inf is a text file that contains slink commands:

lo z9.obj
lo z8.obj
lo z7.obj
file simul.exe

There is full documentation of FTN95 and Slink in the help file installed with FTN95. You can read an online copy here: FTN95 Online Help

More to Explore

FTN95: Documentation
Fortran 95 for Windows - Features
Copyright © 1999-2024 Silverfrost Limited