fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

HIDE CPP   EMULATE CPP   SHOW CPP

Syntax:

HIDE CPP EMULATE CPP SHOW CPP

cpp in Fortran

Some Fortran codes must be pre-processed before they can be built. Pre-processing is carried out, for example, to select facilities supported by some but not all compilers, or to configure the code for different parallel configurations. The most widely used pre-processor is the C pre-processor, cpp. cpp is usually used to process free format Fortran code. cpp changes the code layout, and this may disrupt the organisation of fixed format code.

The fpt implementation of cpp

WinFPT and fpt handle cpp macros and constructs in the same way as cpp itself, with the following exceptions:

fpt processes the cpp macros and commands and then analyses and re-engineers the resulting Fortran code. Therefore fpt cannot analyse and re-engineer the unused branches of #if constructs. These are reproduced as text exactly as they are written in the original code. Operatons like rename symbol must therefore be used with care when cpp contructs are present.

Function of the Commands:

HIDE CPP commands fpt to analyse and re-engineer the Fortran code generated from the cpp commands, but to re-write the code with the commands and macros in place. The code produced may therefore be built by the original build procedure for the program, with the cpp operations unchanged. Care must be taken to avoid unexpected side effects from renumbering labels, renaming variables and changing file names.

EMULATE CPP commands fpt to write the code which would be generated by cpp. Any engineering changes made by fpt, and any diagnostic messages, are also written in the output files. This code is expected to be fully compilable. The cpp commands are removed and processing by cpp is no longer necessary in the build. However it is not possible to rebuild with different cpp options. This command is particularly useful when code is inspected interactively. It is possible to toggle between the three cpp handling options in interactive mode.

SHOW CPP commands fpt to show both the macros and the macro expansions in the code. Any engineering changes made by fpt, and any diagnostic messages, are also written in the output. This code will not compile. The facility is useful when code is examined interactively.

The command SHOW CPP MACROS displays and alphabetical list of the cpp macros defined in the program.

Where to use these commands:

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

HIDE CPP

Examples

The same code fragment is displayed interactively with the three different cpp command settings:

FPT> hide cpp FPT> type 21 14 ! 15 #define FTYPE yield 16 #define ROUTINE set_components 17 CALL ROUTINE(FTYPE%name,val_name,FTYPE%value,val_val, & 18 FTYPE%description,val_description) 19 #undef ROUTINE 20 ! 21 >>#define ROUTINE get_components 22 CALL ROUTINE(FTYPE%name,val_name,FTYPE%value,val_val, & 23 FTYPE%description,val_description) 24 #undef ROUTINE 25 ! 26 #define ROUTINE show_components 27 CALL ROUTINE(FTYPE%name,val_name,FTYPE%value,val_val, & 28 FTYPE%description,val_description) 29 #undef ROUTINE FPT> FPT> emulate cpp FPT> type 21 14 ! 15 16 17 CALL set_components(yield%name,val_name,yield%value,val_val, & 18 yield%description,val_description) 19 20 ! 21 >> 22 CALL get_components(yield%name,val_name,yield%value,val_val, & 23 yield%description,val_description) 24 25 ! 26 27 CALL show_components(yield%name,val_name,yield%value,val_val, & 28 yield%description,val_description) 29 ! FPT> FPT> show cpp FPT> type 21 14 ! 15 !CPP! #define FTYPE yield 16 !CPP! #define ROUTINE set_components 17 CALL ROUTINE << set_components >> (FTYPE << yield >> %name, & 18 val_name,FTYPE << yield >> %value,val_val,FTYPE << yield >> % & 18 description,val_description) 19 !CPP! #undef ROUTINE 20 ! 21 >>!CPP! #define ROUTINE get_components 22 CALL ROUTINE << get_components >> (FTYPE << yield >> %name, & 23 val_name,FTYPE << yield >> %value,val_val,FTYPE << yield >> % & 23 description,val_description) 24 !CPP! #undef ROUTINE 25 ! 26 !CPP! #define ROUTINE show_components 27 CALL ROUTINE << show_components >> (FTYPE << yield >> %name, & 28 val_name,FTYPE << yield >> %value,val_val,FTYPE << yield >> % & 28 description,val_description) 29 !CPP! #undef ROUTINE

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