dnl ieee big endian double and float compliancy dnl Enrico Fucile 12-2008 AC_DEFUN([AC_IEEE_BE], [ AC_MSG_CHECKING([if double and float are ieee big endian]) AC_LANG(C) AC_RUN_IFELSE( [ AC_LANG_SOURCE([ int compare(unsigned char* a,unsigned char* b) { while(*a != 0) if (*(b++)!=*(a++)) return 1; return 0; } int main(int argc,char** argv) { unsigned char dc[[]]={0x30,0x61,0xDE,0x80,0x93,0x67,0xCC,0xD9,0}; double da=1.23456789e-75; unsigned char* ca; unsigned char fc[[]]={0x05,0x83,0x48,0x22,0}; float fa=1.23456789e-35; if (sizeof(double)!=8) return 1; ca=(unsigned char*)&da; if (compare(dc,ca)) return 1; if (sizeof(float)!=4) return 1; ca=(unsigned char*)&fa; if (compare(fc,ca)) return 1; return 0; } ]) ], [AS_VAR_SET(IS_IEEE_BE, 1)], [AS_VAR_SET(IS_IEEE_BE, 0)], []) if test $IS_IEEE_BE = 0 then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi ] ) dnl ieee little endian double and float compliancy dnl Enrico Fucile 12-2008 AC_DEFUN([AC_IEEE_LE], [ AC_MSG_CHECKING([if double and float are ieee little endian]) AC_LANG(C) AC_RUN_IFELSE( [ AC_LANG_SOURCE([ int compare(unsigned char* a,unsigned char* b) { while(*a != 0) if (*(b++)!=*(a++)) return 1; return 0; } int main(int argc,char** argv) { unsigned char dc[[]]={0xD9,0xCC,0x67,0x93,0x80,0xDE,0x61,0x30,0}; double da=1.23456789e-75; unsigned char* ca; unsigned char fc[[]]={0x22,0x48,0x83,0x05,0}; float fa=1.23456789e-35; if (sizeof(double)!=8) return 1; ca=(unsigned char*)&da; if (compare(dc,ca)) return 1; if (sizeof(float)!=4) return 1; ca=(unsigned char*)&fa; if (compare(fc,ca)) return 1; return 0; } ]) ], [AS_VAR_SET(IS_IEEE_LE, 1)], [AS_VAR_SET(IS_IEEE_LE, 0)], []) if test $IS_IEEE_LE = 0 then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi ] ) dnl pthreads dnl Enrico Fucile 06-2008 AC_DEFUN([AC_GRIB_PTHREADS], [ AC_MSG_CHECKING([if pthreads available]) AC_LANG(C) OLDLIBS=$LIBS LIBS="$LIBS -lpthread" AC_RUN_IFELSE( [ AC_LANG_SOURCE([ #include #include #define NUMTHRDS 4 static int count; static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t callThd[[NUMTHRDS]]; static void init() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&mutex,&attr); pthread_mutexattr_destroy(&attr); } void* increment(void* arg); int main(int argc,char** argv){ long i; void* status=0; pthread_attr_t attr; pthread_attr_init(&attr); count=0; pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for (i=0;i #include #define NUMTHRDS 4 static int count; #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr,int type); static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t callThd[[NUMTHRDS]]; static void init() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&mutex,&attr); pthread_mutexattr_destroy(&attr); } void* increment(void* arg); int main(int argc,char** argv){ long i; void* status=0; pthread_attr_t attr; pthread_attr_init(&attr); count=0; pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for (i=0;iconftest.f90 module conftest end module conftest EOF ac_try='$FC $FCFLAGS -c conftest.f90 >&AS_MESSAGE_LOG_FD' if AC_TRY_EVAL(ac_try) && test -f CONFTEST.mod ; then ac_cv_prog_f90_uppercase_mod=yes rm -f CONFTEST.mod else ac_cv_prog_f90_uppercase_mod=no fi AC_MSG_RESULT($ac_cv_prog_f90_uppercase_mod) #rm -f conftest* AC_LANG_POP(Fortran) ]) # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_f90_module_flag.html # =========================================================================== # # SYNOPSIS # # AX_F90_MODULE_FLAG # # DESCRIPTION # # Find Fortran 90 modules inclusion flag. The module inclusion flag is # stored in the cached variable ax_f90_modflag. An error is triggered if # the flag cannot be found. Supported are the -I GNU compilers flag, the # -M SUN compilers flag, and the -p Absoft Pro Fortran compiler flag. # # LICENSE # # Copyright (c) 2009 Luc Maisonobe # Copyright (c) 2009 Julian C. Cummings # Copyright (c) 2009 Alexander Pletzer # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. ##serial 12 AC_DEFUN([AX_F90_MODULE_FLAG],[ AC_CACHE_CHECK([fortran 90 modules inclusion flag], ax_cv_f90_modflag, [AC_LANG_PUSH(Fortran) i=0 while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do i=`expr $i + 1` done mkdir tmpdir_$i cd tmpdir_$i AC_COMPILE_IFELSE([ !234567 module conftest_module contains subroutine conftest_routine write(*,'(a)') 'gotcha!' end subroutine conftest_routine end module conftest_module ],[],[]) cd .. ax_cv_f90_modflag="not found" for ax_flag in "-I" "-M" "-p"; do if test "$ax_cv_f90_modflag" = "not found" ; then ax_save_FCFLAGS="$FCFLAGS" FCFLAGS="$ax_save_FCFLAGS ${ax_flag}tmpdir_$i" AC_COMPILE_IFELSE([ !234567 program conftest_program use conftest_module call conftest_routine end program conftest_program ],[ax_cv_f90_modflag="$ax_flag"],[]) FCFLAGS="$ax_save_FCFLAGS" fi done rm -fr tmpdir_$i #if test "$ax_cv_f90_modflag" = "not found" ; then # AC_MSG_ERROR([unable to find compiler flag for modules inclusion]) #fi AC_LANG_POP(Fortran) ])]) dnl AC_PROG_FC_DEBUG_IN_MODULE dnl Daniel Varela 2011-03-25 dnl --------------- AC_DEFUN([AC_PROG_FC_DEBUG_IN_MODULE], [ AC_LANG_PUSH(Fortran) AC_MSG_CHECKING([if Fortran 90 can resolve debug symbols in modules]) cat <conftest-module.f90 module conftest end module conftest EOF cat <conftest.f90 program f90usemodule use CONFTEST end program f90usemodule EOF ac_compile_module='$FC -g -c conftest-module.f90 >&AS_MESSAGE_LOG_FD' ac_link_program='$FC -g -o conftest -I. conftest.f90 >&AS_MESSAGE_LOG_FD' if AC_TRY_EVAL(ac_compile_module) && AC_TRY_EVAL(ac_link_program) && test -f conftest ; then ac_cv_prog_f90_debug_in_module=yes rm -f conftest else ac_cv_prog_f90_debug_in_module=no fi AC_MSG_RESULT($ac_cv_prog_f90_debug_in_module) #rm -f conftest* AC_LANG_POP(Fortran) ])