Converting V2 Fortran Files

 

User-written EMTDC source code must be converted before being used in later versions of PSCAD.  This process has been automated through the use of a utility known as the Fortran Filter ('ffilter.exe').  This file is located in a sub-directory called '.../bin/ffilter', which can be found under the PSCAD installation directory.

NOTE:  The PSCAD installation script modifies the PATH setting so that access to this directory is possible from other directories.

The Fortran Filter

Essentially, this program is used to convert code to a format, which will be compatible with either Fortran 90 or with the older Fortran 77 standard formats.  The Fortran Filter performs the following functions:

NOTE:  The new INCLUDE statements are necessary to allow user-written code to function with either Fortran 77 or the new dynamic dimensioning Fortran 90.

NOTE: The Fortran Filter is no longer provided with PSCAD versions X4 and onward. To obtain a copy, contact the PSCAD Support Desk (support@mhi.ca).

Command Line and Options

The Fortran Filter command line can be used with one of the following formats:

 

ffilter -[options] <filename>

 

or

 

ffilter -d[options] <directoryname>

 

The Fortran Filter comes with several options, which are described as follows in Table 9-1:

 

 

Option

 

Description

 

t[number]

Converts all tabs to a sequence of characters, where [number] is size of tab. The Default is 8

u

Converts all keywords to uppercase

l

Converts all keywords to lowercase

c

Converts comments

n

Converts continuation characters

i

Replaces inclusion of ’r;emt.d’ and ’r;emt.e’ with new style Include Files

b

Converts common blocks

v

Converts common blocks even in the case of incomplete declaration. This needs to be specified together with -a or -b options. (eg. -av or -bv)

a

Runs with options: t8ucnhib

d

Run on multiple files in directory

r

Remove lines commented by filter

e

Empty working directory from intermediate files generated by the Fortran Filter

h

Print help

 

Table 9-1 - Fortran Filter Options

NOTE:  This list of options can also be obtained by typing 'ffilter' at a DOS prompt.

Using the Fortran Filter

In order to use the Fortran Filter to convert your V2 Fortran files, you must first open a command prompt and navigate to the directory where your V2 style Fortran file (or the directory containing a set of files) is located.  Then, simply type in the command line with the required options.

 

The Fortran Filter creates a directory called 'temp' inside the directory in which it is run.  The original file will be copied into this directory and saved with the postfix 'oryg'.  The whole filtering process is conducted in this directory.

 

 

 

EXAMPLE 9-1:

 

Consider a V2 style Fortran source file located in a directory 'c:\temp\test', called 'file1.f'.  To convert the file, open a DOS prompt in 'c:\temp\test' and type:

 

ffilter -ar file1.f

 

The new filtered source code file will be placed in the 'c:\temp\test' directory described above (the original files are untouched). Check the '*.log' file for error messages.

 

 

 

 

EXAMPLE 9-2:

 

Consider a directory, containing many V2 style Fortran source files, called 'c:\temp\dir1'.  To convert the entire directory, open a DOS prompt in 'c:\temp' and type:

 

ffilter -dar dir1

 

The new filtered source code file will be placed in the 'temp' described above (the original files are untouched).  Check the '*.log' file for error messages.

 

 

 

The Fortran Filter should handle all code, with the exception of code that does not comply with the standard common block or variable names.  An example of this is a non-standard STOR name, by specifying the COMMON block with:

 

COMMON /S2/ MYSTOR(ND10), MYNEXC

 

This is a particularly nasty problem, because all code in this subroutine must be manually edited to replace MYSTOR with the standard STOR name.

 

Another example is if you fail to declare variables used in COMMON blocks:

 

REAL STOR

...

COMMON /S2/ STOR(ND10), NEXC

 

This will fail because NEXC was not declared as an INTEGER.