File: llnl_f90_pointer_size.m4

package info (click to toggle)
babel 0.10.2-1
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 43,932 kB
  • ctags: 29,707
  • sloc: java: 74,695; ansic: 73,142; cpp: 40,649; sh: 18,411; f90: 10,062; fortran: 6,727; python: 6,406; makefile: 3,866; xml: 118; perl: 48
file content (79 lines) | stat: -rw-r--r-- 2,196 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# LLNL_F90_POINTER_SIZE
# ---------------------
# Try to determine the size of a F90 pointer to a derived type
# Note the size of a pointer may depend on the type of thing
# it is pointing to. :-(
#
AC_DEFUN([LLNL_F90_POINTER_SIZE],
[AC_REQUIRE([AC_PROG_FC])dnl
AC_REQUIRE([LLNL_F90_LIBRARY_LDFLAGS])dnl
AC_CACHE_CHECK([for Fortran 90 pointer to derived type size],
	ac_cv_f90_pointer_size,
[AC_LANG_PUSH(C)dnl
  case $ac_cv_f90_mangling in
    "lower case, no underscore"*)
       ac_cv_f90_pointer_func="pointerdiff";;
    "lower case, underscore"*)
       ac_cv_f90_pointer_func="pointerdiff_";;
    "upper case, no underscore"*)
       ac_cv_f90_pointer_func="POINTERDIFF";;
    "upper case, underscore"*)
       ac_cv_f90_pointer_func="POINTERDIFF_";;
    "mixed case, no underscore"*)
       ac_cv_f90_pointer_func="pointerdiff";;
    "mixed case, underscore"*)
       ac_cv_f90_pointer_func="pointerdiff_";;
     *)
  	AC_MSG_ERROR([unknown Fortran 90 name-mangling scheme])
	;;
  esac
  AC_COMPILE_IFELSE(
   [#include <stdio.h>
#ifdef __cplusplus
extern "C" 
#endif
void $ac_cv_f90_pointer_func(char *p1, char *p2)
{
  printf("%ld\n", (long)(p2 - p1));
  fflush(stdout); /* needed for gfortran */
}
],
   [mv conftest.$ac_objext cf90_test.$ac_objext

    AC_LANG_PUSH(Fortran)dnl
    ac_save_LIBS=$LIBS
    LIBS="cf90_test.$ac_objext $LIBS"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
  implicit none
  type foo 
    sequence
    integer :: data
  end type foo

  type foowrap
    sequence
    type(foo), pointer :: foop
  end type foowrap

  external pointerdiff
  type(foowrap), dimension(2) :: fooa
  call pointerdiff(fooa(1), fooa(2))
]])],[dnl
      ac_cv_f90_pointer_size=`./conftest$ac_exeext`
      if test -z "$ac_cv_f90_pointer_size"; then
	AC_MSG_ERROR([Unable to determine pointer size (running ./conftest$ac_exeext produced no output)])
      fi
],[
      AC_MSG_ERROR([Unable to determine pointer size])
    ])
    LIBS=$ac_save_LIBS
    AC_LANG_POP(Fortran)dnl
    rm -f cf90_test* conftest*
   ])
  AC_LANG_POP(C)dnl
  ])

AC_DEFINE_UNQUOTED(SIDL_F90_POINTER_SIZE, $ac_cv_f90_pointer_size,
[Size in bytes for a F90 pointer to a derived type])
])
# LLNL_F90_POINTER_SIZE