1include(head.m4)dnl
2dnl
3dnl This file contains the specific functions that are not handled in the
4dnl m4/specific.m4 file.
5
6#include "config.h"
7#include "kinds.inc"
8
9dnl This is from GNU m4 examples file foreach.m4:
10divert(-1)
11# foreach(x, (item_1, item_2, ..., item_n), stmt)
12define(`foreach', `pushdef(`$1', `')_foreach(`$1', `$2',
13`$3')popdef(`$1')')
14define(`_arg1', `$1')
15define(`_foreach',
16        `ifelse(`$2', `()', ,
17                `define(`$1', _arg1$2)$3`'_foreach(`$1', (shift$2),
18`$3')')')
19# traceon(`define', `foreach', `_foreach', `ifelse')
20divert
21
22dnl   NINT specifics
23foreach(`ikind', `(4, 8, 16)', `foreach(`rkind', `(4, 8, 10, 16)', `
24`#if defined (HAVE_GFC_REAL_'rkind`) && defined (HAVE_GFC_INTEGER_'ikind`)'
25elemental function _gfortran_specific__nint_`'ikind`_'rkind (parm)
26   real (kind=rkind) , intent (in) :: parm
27   integer (kind=ikind) :: _gfortran_specific__nint_`'ikind`_'rkind
28   _gfortran_specific__nint_`'ikind`_'rkind = nint (parm)
29end function
30#endif
31')')
32
33dnl   CHAR specifics
34foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
35`#if defined (HAVE_GFC_INTEGER_'ikind`)'
36elemental function _gfortran_specific__char_`'ckind`_i'ikind (parm)
37   integer (kind=ikind) , intent (in) :: parm
38   character (kind=ckind,len=1) :: _gfortran_specific__char_`'ckind`_i'ikind
39   _gfortran_specific__char_`'ckind`_i'ikind` = char (parm, kind='ckind`)'
40end function
41#endif
42')')
43
44dnl   LEN specifics
45foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
46`#if defined (HAVE_GFC_INTEGER_'ikind`)'
47elemental function _gfortran_specific__len_`'ckind`_i'ikind (parm)
48   character (kind=ckind,len=*) , intent (in) :: parm
49   integer (kind=ikind) :: _gfortran_specific__len_`'ckind`_i'ikind
50   _gfortran_specific__len_`'ckind`_i'ikind` = len (parm)'
51end function
52#endif
53')')
54
55dnl   INDEX specifics
56foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
57`#if defined (HAVE_GFC_INTEGER_'ikind`)'
58elemental function _gfortran_specific__index_`'ckind`_i'ikind (parm1, parm2)
59   character (kind=ckind,len=*) , intent (in) :: parm1, parm2
60   integer (kind=ikind) :: _gfortran_specific__index_`'ckind`_i'ikind
61   _gfortran_specific__index_`'ckind`_i'ikind` = index (parm1, parm2)'
62end function
63#endif
64')')
65