flexoutput(n) 1.0 "flibs"

Name

flexoutput - Output facility with flexible substitution

Table Of Contents

Synopsis

Description

The flexoutput module allows you to output strings with arguments substituted via simple codes within the string. For example:

    call write_items( 10, 'The value of {2} is {1}, as expected', [ item(1), item('Name') ] )

would produce the string: The value of Name is 1, as expected

The function item returns a value of the type item_t, so that in the above statement an array is constructed with integer and string values. These are then substituted using default formatting specific to the data type. The result is written to a file.

ROUTINES

There are two public routines:

call write_items( lun, format, item_array, advance )

This subroutine writes the string contained in the argument format to the file at LU-number lun. Substrings like "{1}", "{2}", etc. are substitued by the corresponding element from the array item_array. Use the function item to construct the array of items.

integer, intent(in) lun

LU-number of the file to write to.

character(len=*), intent(in) format

Format string to be used.

type(item_t), dimension(:), intent(in) item_array

Array specifying the variables. COnstruct it using the item function.

logical, optional, intent(in) advance

Explicitly advance or not at the end of writing the string. By default advance, so that the next write statement starts on a new line.

arg = item( var )

This function returns a value of type item_t, so that an array can be formed to be passed to write_items. The argument var is one of the basic types: integer, single and double precision real or a character string of any length.

scalar var

The variable to be assigned a value from the input file.