next up previous 86
Next: An Example of Data Type Conversion
Up: Data Type Conversions the DCV Routines
Previous: Data Type Conversions the DCV Routines

Introduction

Occasionally, it may be necessary to convert data passed into a generic routine in a generic variable into another data type. A general set of conversion functions was originally provided within GENERIC to make this possible. However, new code requiring such conversions should invoke the PRIMDAT  library of functions. PRIMDAT also provides many other instrinsic functions that are amenable to inclusion in generic code. This section remains only to interpret legacy code that still calls DCV routines.

A naming convention is used so that the function DCV_<T1>TO<T2> converts data type <T1> into <T2>.

The functions which can be are defined using Fortran statement functions in a file which may be included in a program by

INCLUDE 'DCV_FUN'

which should come after any data type definitions, but before any DATA initialisation or executable code. In the standard prologue of SGP/16, it should go in the ``Internal References'' section.

Conversions which cannot be defined as statement functions are provided as external functions in an object library (/star/lib/dcv.a on a Starlink system). Programs requiring these functions should be compiled

% f77 prog.f -L/star/lib `dcv_link`

on Unix.

The types of these functions can be declared in a program by including

INCLUDE 'DCV_EXT'

(in the ``External References'' section of the standard prologue).

NOTE: Statement functions are considerably faster than external functions, so programs which use the common conversions defined in `DCV_FUN' will execute a lot faster.

Only numeric conversions are supported at present, and there are no DCV_ functions for conversions involving CHARACTER and LOGICAL data types. A full list of the functions, the conversion performed, and their location and restrictions, is given in the conversion functions.


next up previous 86
Next: An Example of Data Type Conversion
Up: Data Type Conversions the DCV Routines
Previous: Data Type Conversions the DCV Routines

GENERIC --- A Utility for Preprocessing Generic Fortran and C Subroutines
Starlink User Note 7
S M Beard
P M Allan
Malcolm J. Currie
Peter W. Draper
2006 May 8
E-mail:starlink@jiscmail.ac.uk

Copyright © 2013 Science and Technology Facilities Council