# AC_FC_LINE_LENGTH([LENGTH], [ACTION-IF-SUCCESS], # [ACTION-IF-FAILURE = FAILURE]) # ------------------------------------------------ # Look for a compiler flag to make the Fortran (FC) compiler accept long lines # in the current (free- or fixed-format) source code, and adds it to FCFLAGS. # The optional LENGTH may be 80, 132 (default), or `unlimited' for longer # lines. Note that line lengths above 254 columns are not portable, and some # compilers (hello ifort) do not accept more than 132 columns at least for # fixed format. Call ACTION-IF-SUCCESS (defaults to nothing) if successful # (i.e. can compile code using new extension) and ACTION-IF-FAILURE (defaults # to failing with an error message) if not. (Defined via DEFUN_ONCE to # prevent flag from being added to FCFLAGS multiple times.) # You should call AC_FC_FREEFORM or AC_FC_FIXEDFORM to set the desired format # prior to using this macro. # # The known flags are: # -f{free,fixed}-line-length-N with N 72, 80, 132, or 0 or none for none. # -ffree-line-length-none: GNU gfortran # -qfixed=132 80 72: IBM compiler (xlf) # -Mextend: Cray # -132 -80 -72: Intel compiler (ifort) # Needs to come before -extend_source because ifort # accepts that as well with an optional parameter and # doesn't fail but only warns about unknown arguments. # -extend_source: SGI compiler # -W NN (132, 80, 72): Absoft Fortran # +extend_source: HP Fortran (254 in either form, default is 72 fixed, # 132 free) # -wide: Lahey/Fujitsu Fortran (255 cols in fixed form) # -e: Sun Fortran compiler (132 characters) AC_DEFUN([AC_FC_LINE_LENGTH], [AC_LANG_PUSH([Fortran])dnl m4_case(m4_default([$1], [132]), [unlimited], [ac_fc_line_len_string=unlimited ac_fc_line_len=0 ac_fc_line_length_test=' subroutine longer_than_132(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,'\ 'arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19)'], [132], [ac_fc_line_len=132 ac_fc_line_length_test=' subroutine longer_than_80(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,'\ 'arg10)'], [80], [ac_fc_line_len=80 ac_fc_line_length_test=' subroutine longer_than_72(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)'], [m4_warning([Invalid length argument `$1'])]) : ${ac_fc_line_len_string=$ac_fc_line_len} AC_CACHE_CHECK( [for Fortran flag needed to accept $ac_fc_line_len_string column source lines], [ac_cv_fc_line_length], [ac_cv_fc_line_length=unknown ac_fc_line_length_FCFLAGS_save=$FCFLAGS for ac_flag in none \ -ffree-line-length-none -ffixed-line-length-none \ -ffree-line-length-$ac_fc_line_len \ -ffixed-line-length-$ac_fc_line_len \ -qfixed=$ac_fc_line_len -Mextend \ -$ac_fc_line_len -extend_source \ "-W $ac_fc_line_len" +extend_source -wide -e do test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_line_length_FCFLAGS_save $ac_flag" AC_COMPILE_IFELSE([[$ac_fc_line_length_test end subroutine]], [ac_cv_fc_line_length=$ac_flag; break]) done rm -f conftest.err conftest.$ac_objext conftest.$ac_ext FCFLAGS=$ac_fc_line_length_FCFLAGS_save ]) if test "x$ac_cv_fc_line_length" = xunknown; then m4_default([$3], [AC_MSG_ERROR([Fortran does not accept long source lines], 77)]) else if test "x$ac_cv_fc_line_length" != xnone; then FCFLAGS="$FCFLAGS $ac_cv_fc_line_length" fi $2 fi AC_LANG_POP([Fortran])dnl ])# AC_FC_LINE_LENGTH