ftnsplit

Date:

04-22-2016

NAME

ftnsplit - Invokes the Fortran file splitter

SYNOPSIS

ftnsplit[-a]
[-b]
[-d]
[-k]
[-m]
[-o]
[-r]
[-s]
[-u]
[-x]
[files]

IMPLEMENTATION

Cray Linux Environment (CLE)

DESCRIPTION

The ftnsplit utility splits named Fortran files into separate files, with one unit per file, and lists the resultant files. Each unit includes the following program segments: blockdata, function, main program, module, submodule, and subroutine. If you do not specify files, data is read from standard input (stdin).

The following naming conventions apply:

  • The segment X is put in file X.extension. ftnsplit preserves the file extension of the original file.

  • Fortran source files on Cray systems may have any of these extensions: .f, .F, .for, .FOR, .f90, .F90, .f95, .F95, .f03, .F03, .f08, .F08, .ftn, or .FTN. File names having the following extensions are generated by the preprocessor: .F, .FOR, .F90, .F95, .F03, .F08, or .FTN.

  • Files with a suffix of .f, .F, .for, or .FOR are assumed to be in fixed format. If they use free format, use the -o’-ffree’ option.

  • Files with a suffix of .f90, .F90, .f95, .F95, .f03, .F03, .f08, .F08, .ftn, or .FTN are assumed to be in free format. If they use fixed format, specify the -o’-ffixed’ option.

  • Duplicate segments X are put into file Xn.extension, where n represents a unique integer value for each duplicate file that exists. The -r option overrides this convention and replaces the file X.extension.

  • Unnamed blockdata segments are put into files blockdataN.extension.

The ftnsplit utility accepts the following options:

-a

Lists file-based dependencies, that is, those external module files and include files, which if modified would require recompilation of the current file.

-b

Separates modules and submodules in CIFs.

-d

Creates a subdirectory (inputfile.d) for each input file and creates the required output files within that subdirectory.

-k

Keeps any created CIFs.

-m

Lists include files referenced and modules used. See the EXAMPLES section of this man page for sample output produced by using the -m option.

-o

Specifies ftn(1) compiler options. If options are specified, they must be enclosed in apostrophes. For example, you can specify ftnsplit -o’-ffree’.

-r

Replaces existing files as required. Creates file unit001.f or unit001.f90 if file unit.f or unit.f90 already exists.

-s

Strips trailing blanks from the generated output files.

-u

Specifies that make program unit file names are in uppercase characters. Default is lowercase characters.

-x

Lists units; source is not expanded.

files

Specifies names of files to be split. Default is stdin.

NOTES

ftnsplit typically preserves the file extension of the original file. However, if a # character appears in column one of an input file, ftnsplit gives the output file the uppercase version of the extension (.F, .FOR, .F90, .F95, .F03, .F08, or .FTN), to indicate that the preprocessor must be executed on the output file.

The ftnsplit utility uses the Fortran compiler to produce CIFs in order to generate output.

The operation of ftnsplit may be verified using cat() to send the output files to wc() and comparing the result to the size of the input file to ftnsplit.

If you use the !DIR$ FREE directive to indicate free source form within the body of the source code, this directive must be hand duplicated into each of the split-out files, or specify the -f free option when using ftn(1) to compile the files. For example:

:

file.f:

!DIR$ FREE PROGRAM MAIN PRINT *, “MAIN” END PROGRAM MAIN

SUBROUTINE TEST PRINT *, “TEST” END SUBROUTINE TEST

When the ftnsplit command is used, compiling the resulting test.f file produces compilation errors unless !DIR$ FREE is added to the top of the file. For free-form source files that end in .f and do not contain the !DIR$ FREE directive, use ftnsplit -o’-ffree’ to instruct the compiler to assume free-form source.

EXAMPLES

The following example shows sample program fred and the output returned when the -m option is used as an argument to the ftnsplit command:

program fred
include "abc.h"

end program fred
subroutine jim
use harry

end subroutine jim

% ftnsplit -m file.f
fred
   abc.h
jim
   module harry

FILES

file*.replaceable

Fortran source code files of a named program segment can have any of the following extensions: .f, .F, .for, .FOR, .f90, .F90, .f95, .F95, .f03, .F03, .f08, .F08, .ftn, or .FTN.

blockdata*.replaceable

Source code files of a blockdata segment.

SEE ALSO

cat(1), csplit(1), expand(1), crayftn(1), split(1), wc(1)