The very basic "Hello Feat" example

Releated files:

  • tutorials/tutorial00/src/hellofeat.f90
  • tutorials/tutorial00/configure

Hello FEAT

The very basic "Hello feat" example hellofeat.f90 in the Feat2 package reads as follows:

program HelloFeat

  use fsystem
  use genoutput

  ! Initialisation
  call system_init()
  call output_init("")

  ! Print a message
  call output_line ("Hello world. This is FEAT-2.")

  ! Cleanup
  call output_done()

end program

In the very beginning, the modules "fsystem" and "genoutput" are included and initialised:

  use fsystem
  use genoutput

The module fsystem contains basic system-wide definitions and specifications. It has to be initialised with call system_init() in the very beginning of every program.

Similarly, the module genoutput (abbrev. for "general output") provides basic output routines for printing text to the terminal. It has to be initialised by one of the output_init routines - for very basic use, a simple call output_init("") is enough.

Afterwards, the command

  call output_line ("Hello world. This is FEAT-2.")

prints a message to the terminal. The command output_line the basic text output command for messages to the terminal and a replacement for print and write (*,*). Without any parameters, it just prints the text message to the terminal. However, it provides additional output features like printing the text to a log file, adding a time stamp to the text, preventing line breaks etc. We come to this in a later tutorial.

The final call

  call output_done()

cleans up the output subsystem. Afterwards, the program is finished.

Note that there is currently no cleanup command like system_done. This is currently not necessary but might change in the future.

Configuration script

Compiling the "Hello FEAT" example involves the configuration script configure in the main directory of tutorial00. This script creates a makefile which compiles the application as soon as the command make is invoked.

The script reads as follows:


export LC_ALL

../../bin/configure \
    --appname=hellofeat \
    --programfile=src/hellofeat.f90 \
        --srclist_app="`ls src/*.f90`" \

It performs as follows:

  • An additional configuration script "../../bin/configure" is called which writes the actual makefile

  • The executable is named "hellofeat", set by the --appname parameter.

  • The main program is in the file "src/hellofeat.f90", set by the --programfile parameter.

  • The parameter --srclist_app= is a list of all source files. By default, all ".f90" files from the directory src/ are included into the project.

The "Hello FEAT" example can be used as a template for new applications written from the scratch. In this case, the two above parameters specified by --appname and --programfile have to be modified in the configure script to get it to work - that's all.

Compiling and starting the application

For compiling and starting the application, the following steps are necessary:

  1. The configure script has to be invoked. This has to be done only once in advance (or after an "SVN update" or to switch the compiler configuration). The script generates a makefile.

  2. The make command has to be invoked. This compiles the application and all necessary libraries.

  3. The application can be started by ./hellofeat

On a terminal, ths reads as follows.

.../Featflow2> cd tutorials/tutorial00

.../Featflow2/tutorials/tutorial00> ./configure

This is the FEAT2 custom configuration program.
It is not GNU Configure.
There are a couple of optional arguments to this program,
use '--help' command line option to learn about them.
checking whether environment sets $MAKE... no

.../Featflow2/tutorials/tutorial00> make

# Building FEAT2.0 application <hellofeat>
make[1]: Entering directory `.../Featflow2/tutorials/tutorial00'
... -lumfpack -lamd -lsplib -llapack -lblas -o hellofeat

.../Featflow2/tutorials/tutorial00> ./hellofeat

 Hello world. This is FEAT-2.