1dnl This program is free software; you can redistribute it and/or modify 2dnl it under the terms of the GNU General Public License as published by 3dnl the Free Software Foundation; either version 2, or (at your option) 4dnl any later version. 5dnl 6dnl This program is distributed in the hope that it will be useful, 7dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 8dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9dnl GNU General Public License for more details. 10dnl 11dnl You should have received a copy of the GNU General Public License 12dnl along with this program; if not, write to the Free Software 13dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 14dnl 02111-1307, USA. 15dnl 16dnl As a special exception, the Free Software Foundation gives unlimited 17dnl permission to copy, distribute and modify the configure scripts that 18dnl are the output of Autoconf. You need not follow the terms of the GNU 19dnl General Public License when using or distributing such scripts, even 20dnl though portions of the text of Autoconf appear in them. The GNU 21dnl General Public License (GPL) does govern all other use of the material 22dnl that constitutes the Autoconf program. 23dnl 24dnl Certain portions of the Autoconf source text are designed to be copied 25dnl (in certain cases, depending on the input) into the output of 26dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 27dnl source text consists of comments plus executable code that decides which 28dnl of the data portions to output in any given case. We call these 29dnl comments and executable code the "non-data" portions. Autoconf never 30dnl copies any of the non-data portions into its output. 31dnl 32dnl This special exception to the GPL applies to versions of Autoconf 33dnl released by the Free Software Foundation. When you make and 34dnl distribute a modified version of Autoconf, you may extend this special 35dnl exception to the GPL to apply to your modified version as well, *unless* 36dnl your modified version has the potential to copy into its output some 37dnl of the text that was the non-data portion of the version that you started 38dnl with. (In other words, unless your change moves or copies text from 39dnl the non-data portions to the data portions.) If your modification has 40dnl such potential, you must delete any notice of this special exception 41dnl to the GPL from your modified version. 42dnl 43dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 44 45dnl @synopsis TW_CHECK_ASSOCIATED_BUG([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 46dnl 47dnl Checks whether the currently selected Fortran compiler has a bug 48dnl forbidding the use of ASSOCIATED in restricted expressions 49dnl (versions of gfortran, pathscale & xlf have been found which do) 50dnl 51dnl 52dnl @version 1.0 53dnl @author <tow@uszla.me.uk> 54dnl 55AC_DEFUN([TW_CHECK_ASSOCIATED_BUG],[ 56dnl 57AC_MSG_CHECKING([for ASSOCIATED in restricted expression bug]) 58dnl 59AC_LANG_PUSH(Fortran) 60dnl 61AC_COMPILE_IFELSE( 62dnl The program is written in fixed-form source to avoid worrying 63dnl about filename extensions. 64 AC_LANG_SOURCE([[ 65 function test_bug(a) result(b) 66 integer, pointer :: a 67 integer, dimension(merge(1, 2, associated(a))) :: b 68 b = 0 69 end function test_bug 70 ]]), 71 [AC_MSG_RESULT([no]) 72 m4_default([$1],[:]) 73 ], 74 [AC_MSG_RESULT([yes]) 75 m4_default([$2],[:] 76 [AC_MSG_ERROR([This Fortran compiler does not understand ASSOCIATED in restricted expressions.])]) 77 ] 78) 79AC_LANG_POP(Fortran) 80dnl 81]) 82dnl This program is free software; you can redistribute it and/or modify 83dnl it under the terms of the GNU General Public License as published by 84dnl the Free Software Foundation; either version 2, or (at your option) 85dnl any later version. 86dnl 87dnl This program is distributed in the hope that it will be useful, 88dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 89dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 90dnl GNU General Public License for more details. 91dnl 92dnl You should have received a copy of the GNU General Public License 93dnl along with this program; if not, write to the Free Software 94dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 95dnl 02111-1307, USA. 96dnl 97dnl As a special exception, the Free Software Foundation gives unlimited 98dnl permission to copy, distribute and modify the configure scripts that 99dnl are the output of Autoconf. You need not follow the terms of the GNU 100dnl General Public License when using or distributing such scripts, even 101dnl though portions of the text of Autoconf appear in them. The GNU 102dnl General Public License (GPL) does govern all other use of the material 103dnl that constitutes the Autoconf program. 104dnl 105dnl Certain portions of the Autoconf source text are designed to be copied 106dnl (in certain cases, depending on the input) into the output of 107dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 108dnl source text consists of comments plus executable code that decides which 109dnl of the data portions to output in any given case. We call these 110dnl comments and executable code the "non-data" portions. Autoconf never 111dnl copies any of the non-data portions into its output. 112dnl 113dnl This special exception to the GPL applies to versions of Autoconf 114dnl released by the Free Software Foundation. When you make and 115dnl distribute a modified version of Autoconf, you may extend this special 116dnl exception to the GPL to apply to your modified version as well, *unless* 117dnl your modified version has the potential to copy into its output some 118dnl of the text that was the non-data portion of the version that you started 119dnl with. (In other words, unless your change moves or copies text from 120dnl the non-data portions to the data portions.) If your modification has 121dnl such potential, you must delete any notice of this special exception 122dnl to the GPL from your modified version. 123dnl 124dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 125 126dnl @synopsis TW_CHECK_FC_90([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 127dnl 128dnl Checks whether the currently selected Fortran compiler is fully 129dnl compliant with Fortran 90 (ISO/IEC-1539:1991) 130dnl If so, ACTION_IF_TRUE is performed; if not, ACTION_IF_FALSE 131dnl 132dnl It currently tests for: 133dnl 134dnl Modules 135dnl Private 136dnl New-style variable declarations. 137dnl 138dnl @version 1.0 139dnl @author Toby White <tow21@cam.ac.uk> 140dnl 141AC_DEFUN([TW_CHECK_FC_90],[ 142dnl 143AC_LANG_PUSH(Fortran) 144dnl 145AC_MSG_CHECKING([for Fortran 90 compliance]) 146dnl 147AC_COMPILE_IFELSE( 148dnl The program is written in fixed-form source to avoid worrying 149dnl about filename extensions. 150 AC_LANG_SOURCE([[ 151 Module test_module 152 153 Implicit None 154 Private 155 156 Contains 157 158 Function test_function() Result(out) 159 Integer :: out 160 out = 0 161 End Function test_function 162 163 End Module test_module 164 ]]), 165 [AC_MSG_RESULT([yes]) 166 m4_default([$1],[]) 167 ], 168 [AC_MSG_RESULT([no]) 169 m4_default([$2], 170 [AC_MSG_ERROR([ A fully Fortran-90-compliant compiler is required.])]) 171 ] 172) 173AC_LANG_POP(Fortran) 174dnl 175]) 176dnl This program is free software; you can redistribute it and/or modify 177dnl it under the terms of the GNU General Public License as published by 178dnl the Free Software Foundation; either version 2, or (at your option) 179dnl any later version. 180dnl 181dnl This program is distributed in the hope that it will be useful, 182dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 183dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 184dnl GNU General Public License for more details. 185dnl 186dnl You should have received a copy of the GNU General Public License 187dnl along with this program; if not, write to the Free Software 188dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 189dnl 02111-1307, USA. 190dnl 191dnl As a special exception, the Free Software Foundation gives unlimited 192dnl permission to copy, distribute and modify the configure scripts that 193dnl are the output of Autoconf. You need not follow the terms of the GNU 194dnl General Public License when using or distributing such scripts, even 195dnl though portions of the text of Autoconf appear in them. The GNU 196dnl General Public License (GPL) does govern all other use of the material 197dnl that constitutes the Autoconf program. 198dnl 199dnl Certain portions of the Autoconf source text are designed to be copied 200dnl (in certain cases, depending on the input) into the output of 201dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 202dnl source text consists of comments plus executable code that decides which 203dnl of the data portions to output in any given case. We call these 204dnl comments and executable code the "non-data" portions. Autoconf never 205dnl copies any of the non-data portions into its output. 206dnl 207dnl This special exception to the GPL applies to versions of Autoconf 208dnl released by the Free Software Foundation. When you make and 209dnl distribute a modified version of Autoconf, you may extend this special 210dnl exception to the GPL to apply to your modified version as well, *unless* 211dnl your modified version has the potential to copy into its output some 212dnl of the text that was the non-data portion of the version that you started 213dnl with. (In other words, unless your change moves or copies text from 214dnl the non-data portions to the data portions.) If your modification has 215dnl such potential, you must delete any notice of this special exception 216dnl to the GPL from your modified version. 217dnl 218dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 219 220dnl @synopsis TW_CHECK_FC_95([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 221dnl 222dnl Checks whether the currently selected Fortran compiler is fully 223dnl compliant with Fortran 95 (ISO-IEC 1539-1:1997) 224dnl 225dnl It currently tests for: 226dnl 227dnl Named End Interface 228dnl Derived type initialization 229dnl The Null() intrinsic 230dnl The Forall statement 231dnl The Cpu_Time intrinsic 232dnl Pure functions 233dnl Elemental functions 234dnl 235dnl @version 1.0 236dnl @author <tow21@cam.ac.uk> 237dnl 238AC_DEFUN([TW_CHECK_FC_95],[ 239dnl 240AC_MSG_CHECKING([for Fortran 95 compliance]) 241dnl 242AC_LANG_PUSH(Fortran) 243dnl 244AC_COMPILE_IFELSE( 245dnl The program is written in fixed-form source to avoid worrying 246dnl about filename extensions. 247 AC_LANG_SOURCE([[ 248 Program test_f95 249 250! Interface test_interface 251! End Interface test_interface 252 253 Type test_type 254 Integer :: i = 1 255 End Type test_type 256 257 Integer, Pointer :: j => Null() 258 259 Integer :: i 260 Real :: a 261 262 Forall (i=1:50) 263 End Forall 264 265 Call CPU_TIME(a) 266 267 Contains 268 269 Pure Integer Function test_pure() 270 test_pure = 0 271 End Function test_pure 272 273 Elemental Integer Function test_elemental(in) 274 Integer, Intent(In) :: in 275 test_elemental = 0 276 End Function test_elemental 277 278 End Program test_f95 279 ]]), 280 [AC_MSG_RESULT([yes]) 281 m4_default([$1],[:]) 282 ], 283 [AC_MSG_RESULT([no]) 284 m4_default([$2], 285 [AC_MSG_ERROR([A fully Fortran-95-compliant compiler is required.])]) 286 ] 287) 288AC_LANG_POP(Fortran) 289dnl 290]) 291dnl This program is free software; you can redistribute it and/or modify 292dnl it under the terms of the GNU General Public License as published by 293dnl the Free Software Foundation; either version 2, or (at your option) 294dnl any later version. 295dnl 296dnl This program is distributed in the hope that it will be useful, 297dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 298dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 299dnl GNU General Public License for more details. 300dnl 301dnl You should have received a copy of the GNU General Public License 302dnl along with this program; if not, write to the Free Software 303dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 304dnl 02111-1307, USA. 305dnl 306dnl As a special exception, the Free Software Foundation gives unlimited 307dnl permission to copy, distribute and modify the configure scripts that 308dnl are the output of Autoconf. You need not follow the terms of the GNU 309dnl General Public License when using or distributing such scripts, even 310dnl though portions of the text of Autoconf appear in them. The GNU 311dnl General Public License (GPL) does govern all other use of the material 312dnl that constitutes the Autoconf program. 313dnl 314dnl Certain portions of the Autoconf source text are designed to be copied 315dnl (in certain cases, depending on the input) into the output of 316dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 317dnl source text consists of comments plus executable code that decides which 318dnl of the data portions to output in any given case. We call these 319dnl comments and executable code the "non-data" portions. Autoconf never 320dnl copies any of the non-data portions into its output. 321dnl 322dnl This special exception to the GPL applies to versions of Autoconf 323dnl released by the Free Software Foundation. When you make and 324dnl distribute a modified version of Autoconf, you may extend this special 325dnl exception to the GPL to apply to your modified version as well, *unless* 326dnl your modified version has the potential to copy into its output some 327dnl of the text that was the non-data portion of the version that you started 328dnl with. (In other words, unless your change moves or copies text from 329dnl the non-data portions to the data portions.) If your modification has 330dnl such potential, you must delete any notice of this special exception 331dnl to the GPL from your modified version. 332dnl 333dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 334 335dnl @synopsis TW_CHECK_FC_FPP([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 336dnl 337dnl Checks whether the currently selected Fortran compiler supports 338dnl cpp-like functionality when called on a suitable fixed-format file. 339dnl If so, ACTION_IF_TRUE is performed; if not, ACTION_IF_FALSE 340dnl 341dnl @version 1.0 342dnl @author Toby White <tow21@cam.ac.uk> 343dnl 344AC_DEFUN([TW_CHECK_FC_FPP],[ 345dnl 346AC_LANG_PUSH(Fortran) 347dnl 348AC_FC_SRCEXT(F) 349dnl 350AC_MSG_CHECKING([whether $FC has an integrated Fortran cpp-style preprocessor for fixed-form source]) 351dnl 352AC_COMPILE_IFELSE( 353dnl The program is written in fixed-form source to avoid worrying 354dnl about filename extensions. 355 AC_LANG_SOURCE([[ 356 Program test_cpp 357#if 1 358 Integer i 359#else 360 Integer j 361#endif 362 End Program 363 ]]), 364 [AC_MSG_RESULT([yes]) 365 m4_ifval([$1],[$1],[]) 366 ], 367 [AC_MSG_RESULT([no]) 368 m4_ifval([$2],[$2], 369 [AC_MSG_ERROR([A Fortran compiler with integrated cpp-style preprocessor for fixed-form source is required.])]) 370 ] 371) 372AC_LANG_POP(Fortran) 373dnl 374]) 375dnl This program is free software; you can redistribute it and/or modify 376dnl it under the terms of the GNU General Public License as published by 377dnl the Free Software Foundation; either version 2, or (at your option) 378dnl any later version. 379dnl 380dnl This program is distributed in the hope that it will be useful, 381dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 382dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 383dnl GNU General Public License for more details. 384dnl 385dnl You should have received a copy of the GNU General Public License 386dnl along with this program; if not, write to the Free Software 387dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 388dnl 02111-1307, USA. 389dnl 390dnl As a special exception, the Free Software Foundation gives unlimited 391dnl permission to copy, distribute and modify the configure scripts that 392dnl are the output of Autoconf. You need not follow the terms of the GNU 393dnl General Public License when using or distributing such scripts, even 394dnl though portions of the text of Autoconf appear in them. The GNU 395dnl General Public License (GPL) does govern all other use of the material 396dnl that constitutes the Autoconf program. 397dnl 398dnl Certain portions of the Autoconf source text are designed to be copied 399dnl (in certain cases, depending on the input) into the output of 400dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 401dnl source text consists of comments plus executable code that decides which 402dnl of the data portions to output in any given case. We call these 403dnl comments and executable code the "non-data" portions. Autoconf never 404dnl copies any of the non-data portions into its output. 405dnl 406dnl This special exception to the GPL applies to versions of Autoconf 407dnl released by the Free Software Foundation. When you make and 408dnl distribute a modified version of Autoconf, you may extend this special 409dnl exception to the GPL to apply to your modified version as well, *unless* 410dnl your modified version has the potential to copy into its output some 411dnl of the text that was the non-data portion of the version that you started 412dnl with. (In other words, unless your change moves or copies text from 413dnl the non-data portions to the data portions.) If your modification has 414dnl such potential, you must delete any notice of this special exception 415dnl to the GPL from your modified version. 416dnl 417dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 418 419dnl @synopsis TW_CHECK_FC_FPP_90([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 420dnl 421dnl Checks whether the currently selected Fortran compiler supports 422dnl cpp-like functionality when called on a suitable fixed-format file. 423dnl If so, ACTION_IF_TRUE is performed; if not, ACTION_IF_FALSE 424dnl 425dnl @version 1.0 426dnl @author Toby White <tow21@cam.ac.uk> 427dnl 428AC_DEFUN([TW_CHECK_FC_FPP_90],[ 429dnl 430AC_LANG_PUSH(Fortran) 431dnl 432AC_FPP_SRCEXT(F90) 433ac_ext=F90 434dnl 435AC_MSG_CHECKING([whether $FC has an integrated Fortran cpp-style preprocessor for free-form source]) 436dnl 437FCFLAGS_save=$FCFLAGS 438FCFLAGS="$FCFLAGS $FPPFLAGS_F90 $FCFLAGS_free" 439AC_COMPILE_IFELSE( 440dnl The program is written in fixed-form source to avoid worrying 441dnl about filename extensions. 442 AC_LANG_SOURCE([[ 443Program test_cpp 444#if 1 445 Integer i 446#else 447 Integer j 448#endif 449End Program 450 ]]), 451 [AC_MSG_RESULT([yes]) 452 m4_ifval([$1],[$1],[]) 453 ], 454 [AC_MSG_RESULT([no]) 455 m4_ifval([$2],[$2], 456 [AC_MSG_ERROR([A Fortran compiler with integrated cpp-style preprocessor for free-from source is required.])]) 457 ] 458) 459AC_LANG_POP(Fortran) 460 461FCFLAGS=$FCFLAGS_save 462dnl 463]) 464dnl This program is free software; you can redistribute it and/or modify 465dnl it under the terms of the GNU General Public License as published by 466dnl the Free Software Foundation; either version 2, or (at your option) 467dnl any later version. 468dnl 469dnl This program is distributed in the hope that it will be useful, 470dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 471dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 472dnl GNU General Public License for more details. 473dnl 474dnl You should have received a copy of the GNU General Public License 475dnl along with this program; if not, write to the Free Software 476dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 477dnl 02111-1307, USA. 478dnl 479dnl As a special exception, the Free Software Foundation gives unlimited 480dnl permission to copy, distribute and modify the configure scripts that 481dnl are the output of Autoconf. You need not follow the terms of the GNU 482dnl General Public License when using or distributing such scripts, even 483dnl though portions of the text of Autoconf appear in them. The GNU 484dnl General Public License (GPL) does govern all other use of the material 485dnl that constitutes the Autoconf program. 486dnl 487dnl Certain portions of the Autoconf source text are designed to be copied 488dnl (in certain cases, depending on the input) into the output of 489dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 490dnl source text consists of comments plus executable code that decides which 491dnl of the data portions to output in any given case. We call these 492dnl comments and executable code the "non-data" portions. Autoconf never 493dnl copies any of the non-data portions into its output. 494dnl 495dnl This special exception to the GPL applies to versions of Autoconf 496dnl released by the Free Software Foundation. When you make and 497dnl distribute a modified version of Autoconf, you may extend this special 498dnl exception to the GPL to apply to your modified version as well, *unless* 499dnl your modified version has the potential to copy into its output some 500dnl of the text that was the non-data portion of the version that you started 501dnl with. (In other words, unless your change moves or copies text from 502dnl the non-data portions to the data portions.) If your modification has 503dnl such potential, you must delete any notice of this special exception 504dnl to the GPL from your modified version. 505dnl 506dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 507 508dnl @synopsis TW_CHECK_FC_TR15580([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 509dnl 510dnl Checks whether the currently selected Fortran compiler is fully 511dnl compliant with the Fortran 95 Floating Point Exception Handling 512dnl Extension, ISO TR15580. 513dnl 514dnl @version 1.0 515dnl @author <tow21@cam.ac.uk> 516dnl 517AC_DEFUN([TW_CHECK_FC_TR15580],[ 518dnl 519AC_MSG_CHECKING([$FC for compliance to the Floating Point Exception Handling Extension]) 520dnl 521AC_LANG_PUSH(Fortran) 522dnl 523AC_COMPILE_IFELSE( 524dnl The program is written in fixed-form source to avoid worrying 525dnl about filename extensions. 526 AC_LANG_SOURCE([[ 527 Program test_tr15580 528 529 Use, Intrinsic :: IEEE_Arithmetic 530 Use, Intrinsic :: IEEE_Exceptions 531 Use, Intrinsic :: IEEE_Features 532 533 End Program test_tr15580 534 ]]), 535 [AC_MSG_RESULT([yes]) 536 m4_ifval([$1],[$1],[]) 537 ], 538 [AC_MSG_RESULT([no]) 539 m4_ifval([$2],[$2], 540 [AC_MSG_ERROR([A fully TR15580-compliant compiler is required.])]) 541 ] 542) 543AC_LANG_POP(Fortran) 544dnl 545]) 546dnl This program is free software; you can redistribute it and/or modify 547dnl it under the terms of the GNU General Public License as published by 548dnl the Free Software Foundation; either version 2, or (at your option) 549dnl any later version. 550dnl 551dnl This program is distributed in the hope that it will be useful, 552dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 553dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 554dnl GNU General Public License for more details. 555dnl 556dnl You should have received a copy of the GNU General Public License 557dnl along with this program; if not, write to the Free Software 558dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 559dnl 02111-1307, USA. 560dnl 561dnl As a special exception, the Free Software Foundation gives unlimited 562dnl permission to copy, distribute and modify the configure scripts that 563dnl are the output of Autoconf. You need not follow the terms of the GNU 564dnl General Public License when using or distributing such scripts, even 565dnl though portions of the text of Autoconf appear in them. The GNU 566dnl General Public License (GPL) does govern all other use of the material 567dnl that constitutes the Autoconf program. 568dnl 569dnl Certain portions of the Autoconf source text are designed to be copied 570dnl (in certain cases, depending on the input) into the output of 571dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 572dnl source text consists of comments plus executable code that decides which 573dnl of the data portions to output in any given case. We call these 574dnl comments and executable code the "non-data" portions. Autoconf never 575dnl copies any of the non-data portions into its output. 576dnl 577dnl This special exception to the GPL applies to versions of Autoconf 578dnl released by the Free Software Foundation. When you make and 579dnl distribute a modified version of Autoconf, you may extend this special 580dnl exception to the GPL to apply to your modified version as well, *unless* 581dnl your modified version has the potential to copy into its output some 582dnl of the text that was the non-data portion of the version that you started 583dnl with. (In other words, unless your change moves or copies text from 584dnl the non-data portions to the data portions.) If your modification has 585dnl such potential, you must delete any notice of this special exception 586dnl to the GPL from your modified version. 587dnl 588dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 589 590dnl @synopsis TW_CHECK_FC_TR15581([ACTION_IF_TRUE],[ACTION_IF_FALSE]) 591dnl 592dnl Checks whether the currently selected Fortran compiler is fully 593dnl compliant with the Fortran 95 Enhanced Datatype Facilities 594dnl Extension, ISO TR15581. 595dnl 596dnl @version 1.0 597dnl @author <tow21@cam.ac.uk> 598dnl 599AC_DEFUN([TW_CHECK_FC_TR15581],[ 600dnl 601AC_MSG_CHECKING([$FC for compliance to the Enhanced Datatype Facilities Extension]) 602dnl 603AC_LANG_PUSH(Fortran) 604dnl 605AC_COMPILE_IFELSE( 606dnl The program is written in fixed-form source to avoid worrying 607dnl about filename extensions. 608 AC_LANG_SOURCE([[ 609 Program test_tr15581 610 611 Type test_type 612 Integer, Allocatable :: array(:) 613 End Type test_type 614 615 End Program test_tr15581 616 617 Function test_function 618 Integer, Allocatable :: test_function(:) 619 620 Allocate(test_function(5)) 621 End Function test_function 622 623 Subroutine test_subroutine(array) 624 Integer, Allocatable :: array(:) 625 626 Allocate(array(5)) 627 End Subroutine test_subroutine 628 ]]), 629 [AC_MSG_RESULT([yes]) 630 m4_ifval([$1],[$1],[]) 631 ], 632 [AC_MSG_RESULT([no]) 633 m4_ifval([$2],[$2], 634 [AC_MSG_ERROR([A fully TR15581-compliant compiler is required.])]) 635 ] 636) 637AC_LANG_POP(Fortran) 638dnl 639]) 640dnl This program is free software; you can redistribute it and/or modify 641dnl it under the terms of the GNU General Public License as published by 642dnl the Free Software Foundation; either version 2, or (at your option) 643dnl any later version. 644dnl 645dnl This program is distributed in the hope that it will be useful, 646dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 647dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 648dnl GNU General Public License for more details. 649dnl 650dnl You should have received a copy of the GNU General Public License 651dnl along with this program; if not, write to the Free Software 652dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 653dnl 02111-1307, USA. 654dnl 655dnl As a special exception, the Free Software Foundation gives unlimited 656dnl permission to copy, distribute and modify the configure scripts that 657dnl are the output of Autoconf. You need not follow the terms of the GNU 658dnl General Public License when using or distributing such scripts, even 659dnl though portions of the text of Autoconf appear in them. The GNU 660dnl General Public License (GPL) does govern all other use of the material 661dnl that constitutes the Autoconf program. 662dnl 663dnl Certain portions of the Autoconf source text are designed to be copied 664dnl (in certain cases, depending on the input) into the output of 665dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 666dnl source text consists of comments plus executable code that decides which 667dnl of the data portions to output in any given case. We call these 668dnl comments and executable code the "non-data" portions. Autoconf never 669dnl copies any of the non-data portions into its output. 670dnl 671dnl This special exception to the GPL applies to versions of Autoconf 672dnl released by the Free Software Foundation. When you make and 673dnl distribute a modified version of Autoconf, you may extend this special 674dnl exception to the GPL to apply to your modified version as well, *unless* 675dnl your modified version has the potential to copy into its output some 676dnl of the text that was the non-data portion of the version that you started 677dnl with. (In other words, unless your change moves or copies text from 678dnl the non-data portions to the data portions.) If your modification has 679dnl such potential, you must delete any notice of this special exception 680dnl to the GPL from your modified version. 681dnl 682dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 683 684dnl Check how to get at the abort intrinsic. 685 686AC_DEFUN([_TW_TRY_ABORT_BARE], 687[ 688 PROGRAM TESTABORT 689 CALL ABORT 690 END PROGRAM TESTABORT 691]) 692AC_DEFUN([_TW_TRY_ABORT_NAG], 693[ 694 PROGRAM TESTABORT 695 USE F90_UNIX_PROC, ONLY:ABORT 696 CALL ABORT 697 END PROGRAM TESTABORT 698]) 699AC_DEFUN([_TW_TRY_ABORT_INTEL], 700[ 701 PROGRAM TESTABORT 702 CALL ABORT("") 703 END PROGRAM TESTABORT 704]) 705AC_DEFUN([_TW_TRY_ABORT_XLF], 706[ 707 PROGRAM TESTABORT 708 CALL ABORT_ 709 END PROGRAM TESTABORT 710]) 711 712AC_DEFUN([TW_FC_CHECK_ABORT], [ 713AC_REQUIRE([AC_PROG_FC])dnl 714dnl 715AC_MSG_CHECKING([how to compile a call to ABORT]) 716dnl 717dnl Try first with nothing 718dnl 719tw_abort_ok=no 720dnl 721dnl First check with one arg (this will fail if no args are necessary; testing 722dnl in the opposite order will succeed when it shouldnt) 723dnl 724if test $tw_abort_ok = no; then 725 AC_LINK_IFELSE( 726 [AC_LANG_SOURCE([_TW_TRY_ABORT_INTEL])], 727 [tw_abort_ok=yes; tw_method="with argument";DEFS="$DEFS FC_HAVE_ABORT FC_ABORT_ARG"], 728 []) 729fi 730dnl 731if test $tw_abort_ok = no; then 732 AC_LINK_IFELSE( 733 [AC_LANG_SOURCE([_TW_TRY_ABORT_XLF])], 734 [tw_abort_ok=yes; tw_method="with underscore";DEFS="$DEFS FC_HAVE_ABORT FC_ABORT_UNDERSCORE"], 735 []) 736fi 737dnl 738if test $tw_abort_ok = no; then 739 AC_LINK_IFELSE( 740 [AC_LANG_SOURCE([_TW_TRY_ABORT_BARE])], 741 [tw_abort_ok=yes; tw_method=default;DEFS="$DEFS FC_HAVE_ABORT"], 742 []) 743fi 744dnl 745if test $tw_abort_ok = no; then 746 AC_LINK_IFELSE( 747 [AC_LANG_SOURCE([_TW_TRY_ABORT_NAG])], 748 [tw_abort_ok=yes; tw_method="with f90_unix_proc";DEFS="$DEFS FC_HAVE_ABORT"], 749 []) 750fi 751dnl 752dnl Cant get it to compile alone - need a compiler flag. 753dnl Now try with -Vaxlib for intel: 754dnl 755if test $tw_abort_ok = no; then 756 save_LDFLAGS=$LDFLAGS 757 LDFLAGS="$LDFLAGS -Vaxlib" 758 AC_LINK_IFELSE( 759 [AC_LANG_SOURCE([_TW_TRY_ABORT_BARE])], 760 [tw_abort_ok=yes; tw_method="with -Vaxlib";DEFS="$DEFS FC_HAVE_ABORT"], 761 []) 762 if test $tw_abort_ok = no; then 763 LDFLAGS=$save_LDFLAGS 764 fi 765fi 766AC_MSG_RESULT([$tw_method]) 767dnl 768AS_IF([test $tw_abort_ok = yes], 769 [$1], 770 [m4_default([$2],[AC_MSG_ERROR([Cannot compile call to ABORT ])])] 771 ) 772dnl 773])# TW_FC_CHECK_ABORT 774dnl This program is free software; you can redistribute it and/or modify 775dnl it under the terms of the GNU General Public License as published by 776dnl the Free Software Foundation; either version 2, or (at your option) 777dnl any later version. 778dnl 779dnl This program is distributed in the hope that it will be useful, 780dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 781dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 782dnl GNU General Public License for more details. 783dnl 784dnl You should have received a copy of the GNU General Public License 785dnl along with this program; if not, write to the Free Software 786dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 787dnl 02111-1307, USA. 788dnl 789dnl As a special exception, the Free Software Foundation gives unlimited 790dnl permission to copy, distribute and modify the configure scripts that 791dnl are the output of Autoconf. You need not follow the terms of the GNU 792dnl General Public License when using or distributing such scripts, even 793dnl though portions of the text of Autoconf appear in them. The GNU 794dnl General Public License (GPL) does govern all other use of the material 795dnl that constitutes the Autoconf program. 796dnl 797dnl Certain portions of the Autoconf source text are designed to be copied 798dnl (in certain cases, depending on the input) into the output of 799dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 800dnl source text consists of comments plus executable code that decides which 801dnl of the data portions to output in any given case. We call these 802dnl comments and executable code the "non-data" portions. Autoconf never 803dnl copies any of the non-data portions into its output. 804dnl 805dnl This special exception to the GPL applies to versions of Autoconf 806dnl released by the Free Software Foundation. When you make and 807dnl distribute a modified version of Autoconf, you may extend this special 808dnl exception to the GPL to apply to your modified version as well, *unless* 809dnl your modified version has the potential to copy into its output some 810dnl of the text that was the non-data portion of the version that you started 811dnl with. (In other words, unless your change moves or copies text from 812dnl the non-data portions to the data portions.) If your modification has 813dnl such potential, you must delete any notice of this special exception 814dnl to the GPL from your modified version. 815dnl 816dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 817 818 819# TW_FC_CHECK_EOL() 820# ------------------- 821# 822# This macro checks what kind of line ending the Fortran compiler 823# writes out, and expects to read in. (Checking reading explicitly really doesnt work) 824 825 826AC_DEFUN([TW_FC_CHECK_EOL], [dnl 827AC_REQUIRE([AC_PROG_FC]) 828AC_LANG_PUSH([Fortran]) 829FCFLAGS_save="$FCFLAGS" 830FCFLAGS="$FCFLAGS $FCFLAGS_free_f90" 831AC_MSG_CHECKING([for EOR character used by $FC]) 832AC_RUN_IFELSE([ 833 program output_eol 834 open(unit=10, file="conf_eol.out") 835 write(10,"(a)") "" 836 end program 837], 838[ 839if ! test -f conf_eol.out; then 840AC_MSG_ERROR([Could not find test output]) 841elif od -b conf_eol.out | grep 5015 >/dev/null; then 842 ac_cv_FC_check_output_eol=CRLF 843elif od -b conf_eol.out | grep 15 >/dev/null; then 844 ac_cv_FC_check_output_eol=CR 845elif od -b conf_eol.out | grep 12 >/dev/null; then 846 ac_cv_FC_check_output_eol=LF 847else 848 ac_cv_FC_check_output_eol=UNKNOWN 849fi 850rm -rf conf_eol.out 851if test $ac_cv_FC_check_output_eol = UNKNOWN; then 852 AC_MSG_ERROR([Could not determine line-ending convention]) 853fi 854], 855[AC_MSG_ERROR([Could not execute compiled program])], 856[ac_cv_FC_check_output_eol=EOL_CR] dnl take a wild guess at Unix if x-compiling 857) 858AC_MSG_RESULT([$ac_cv_FC_check_output_eol]) 859]) 860dnl output EOL 861dnl 862AC_DEFUN([_TW_FC_CHECK_INPUT_EOL], [ 863AC_MSG_CHECKING([for input EOL character produced by $FC]) 864touch conf_empty.txt 865# Surely there must be a better way to create a CRLF file than this! 866echo 12 | tr -d "\012\015" | tr 12 "\015\012" > conf_crlf.txt 867AC_RUN_IFELSE([ 868 program input_eol 869 integer :: i, io_eof 870 integer :: s1, result 871 character :: c 872 open(unit=10, file="conf_empty.txt") 873 open(unit=11, file="conf_crlf.txt") 874 open(unit=12, file="conf_result.txt") 875 ! Pick up eof first 876 read(10, "(a1)", iostat=io_eof) c 877 i = 0 878 n = 1 879 s = 0 880 result = 0 881 read(11, "(a1)", iostat=i) c 882 ! If we are on an LF-EOL machine, 883 ! then we should get CR followed by EOR 884 if (i==0) then 885 if (iachar(c)==13) then 886 s1 = 13 887 elseif (iachar(c)==32) then 888 ! some compilers translate it into a space, unhelpfully 889 s1 = 32 890 else 891 write(12, *) "UNKNOWN" 892 stop 893 endif 894 else 895 s1 = -1 ! End of Record, we assume 896 endif 897 read(11, "(a1)", iostat=i) c 898 if (i==0) then 899 if (iachar(c)==10.and.s1==-1) then 900 ! Sequence was EOR, LF, therefore EOR=CR. 901 ! Next must be EOF 902 read(11, "(a1)", iostat=i) 903 if (i==io_eof) result = 1 ! EOR_CR 904 endif 905 elseif (i==io_eof) then 906 if (s1==-1) then 907 ! Sequence was EOR, EOF, therefore EOR=CRLF 908 result = 2 ! EOR_CRLF 909 elseif (s1==32) then 910 ! Sequence was SPACE, EOF. Empirically, this seems to happen on PPC Macs, so: 911 result = 3 ! EOR_LF 912 endif 913 elseif (s1==13) then 914 ! We assume this non-zero iostat is EOR 915 ! Sequence was CR, EOR, therefore EOR=LF 916 ! Next must be EOF 917 read(11, "(a1)", iostat=i) 918 if (i==io_eof) result = 3 ! EOR_LF 919 endif 920 select case(result) 921 case (1) 922 write(12,*) "CR" 923 case (2) 924 write(12,*) "CRLF" 925 case (3) 926 write(12,*) "LF" 927 case default 928 write(12,*) "UNKNOWN" 929 end select 930 end program 931], 932[ 933rm -f conf_empty.txt conf_crlf.txt 934if ! test -f conf_result.txt; then 935 AC_MSG_ERROR([Could not find test output]) 936elif grep CRLF conf_result.txt >/dev/null; then 937 ac_cv_FC_check_input_eol=CRLF 938elif grep CR conf_result.txt >/dev/null; then 939 ac_cv_FC_check_input_eol=CR 940elif grep LF conf_result.txt >/dev/null; then 941 ac_cv_FC_check_input_eol=LF 942else 943 ac_cv_FC_check_input_eol=UNKNOWN 944fi 945dnl rm -f conf_result.txt 946if test $ac_cv_FC_check_input_eol = UNKNOWN; then 947 AC_MSG_ERROR([Could not determine input line-ending convention]) 948fi 949], 950[AC_MSG_ERROR([Could not execute compiled program])], 951[ac_cv_FC_check_input_eol=CR] dnl take a wild guess at Unix if x-compiling 952) 953AC_MSG_RESULT([$ac_cv_FC_check_output_eol]) 954dnl check input_eol 955dnl 956FCFLAGS="$FCFLAGS_save" 957])])dnl This program is free software; you can redistribute it and/or modify 958dnl it under the terms of the GNU General Public License as published by 959dnl the Free Software Foundation; either version 2, or (at your option) 960dnl any later version. 961dnl 962dnl This program is distributed in the hope that it will be useful, 963dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 964dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 965dnl GNU General Public License for more details. 966dnl 967dnl You should have received a copy of the GNU General Public License 968dnl along with this program; if not, write to the Free Software 969dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 970dnl 02111-1307, USA. 971dnl 972dnl As a special exception, the Free Software Foundation gives unlimited 973dnl permission to copy, distribute and modify the configure scripts that 974dnl are the output of Autoconf. You need not follow the terms of the GNU 975dnl General Public License when using or distributing such scripts, even 976dnl though portions of the text of Autoconf appear in them. The GNU 977dnl General Public License (GPL) does govern all other use of the material 978dnl that constitutes the Autoconf program. 979dnl 980dnl Certain portions of the Autoconf source text are designed to be copied 981dnl (in certain cases, depending on the input) into the output of 982dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 983dnl source text consists of comments plus executable code that decides which 984dnl of the data portions to output in any given case. We call these 985dnl comments and executable code the "non-data" portions. Autoconf never 986dnl copies any of the non-data portions into its output. 987dnl 988dnl This special exception to the GPL applies to versions of Autoconf 989dnl released by the Free Software Foundation. When you make and 990dnl distribute a modified version of Autoconf, you may extend this special 991dnl exception to the GPL to apply to your modified version as well, *unless* 992dnl your modified version has the potential to copy into its output some 993dnl of the text that was the non-data portion of the version that you started 994dnl with. (In other words, unless your change moves or copies text from 995dnl the non-data portions to the data portions.) If your modification has 996dnl such potential, you must delete any notice of this special exception 997dnl to the GPL from your modified version. 998dnl 999dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 1000 1001dnl Check how to get at the flush intrinsic. 1002 1003AC_DEFUN([_TW_TRY_FLUSH_BARE], 1004[ 1005 PROGRAM TESTFLUSH 1006 PRINT* 1007 CALL FLUSH(5) 1008 END PROGRAM TESTFLUSH 1009]) 1010AC_DEFUN([_TW_TRY_FLUSH_NAG], 1011[ 1012 PROGRAM TESTFLUSH 1013 USE F90_UNIX_IO, ONLY:FLUSH 1014 PRINT* 1015 CALL FLUSH(5) 1016 END PROGRAM TESTFLUSH 1017]) 1018AC_DEFUN([_TW_TRY_FLUSH_XLF], 1019[ 1020 PROGRAM TESTFLUSH 1021 PRINT* 1022 CALL FLUSH_(5) 1023 END PROGRAM TESTFLUSH 1024]) 1025 1026AC_DEFUN([TW_FC_CHECK_FLUSH], [ 1027AC_REQUIRE([AC_PROG_FC])dnl 1028dnl 1029AC_MSG_CHECKING([how to compile a call to FLUSH]) 1030dnl 1031dnl Try first with nothing 1032dnl 1033tw_flush_ok=no 1034dnl 1035AC_LINK_IFELSE( 1036 [AC_LANG_SOURCE([_TW_TRY_FLUSH_BARE])], 1037 [tw_flush_ok=yes; TW_FLUSH=bare;tw_method=default;DEFS="$DEFS FC_HAVE_FLUSH"], 1038 []) 1039if test $tw_flush_ok = no; then 1040 save_LDFLAGS=$LDFLAGS 1041 LDFLAGS="$LDFLAGS -Vaxlib" 1042 AC_LINK_IFELSE( 1043 [AC_LANG_SOURCE([_TW_TRY_FLUSH_BARE])], 1044 [tw_flush_ok=yes; TW_FLUSH=INTEL;tw_method="with -Vaxlib";DEFS="$DEFS FC_HAVE_FLUSH"], 1045 []) 1046 if test $tw_flush_ok = no; then 1047 LDFLAGS=$save_LDFLAGS 1048 fi 1049fi 1050if test $tw_flush_ok = no; then 1051 AC_LINK_IFELSE( 1052 [AC_LANG_SOURCE([_TW_TRY_FLUSH_NAG])], 1053 [tw_flush_ok=yes; TW_FLUSH=NAG;tw_method="with f90_unix_io";DEFS="$DEFS FC_HAVE_FLUSH"], 1054 []) 1055fi 1056if test $tw_flush_ok = no; then 1057 AC_LINK_IFELSE( 1058 [AC_LANG_SOURCE([_TW_TRY_FLUSH_XLF])], 1059 [tw_flush_ok=yes; TW_FLUSH=XLF;tw_method="with underscore"], 1060 []) 1061fi 1062AC_MSG_RESULT([$tw_method]) 1063dnl 1064AS_IF([test $tw_flush_ok = yes], 1065 [$1], 1066 [m4_default([$2],[AC_MSG_ERROR([Cannot compile FLUSH statement])])] 1067 ) 1068dnl 1069])# TW_FC_CHECK_FLUSH 1070dnl This program is free software; you can redistribute it and/or modify 1071dnl it under the terms of the GNU General Public License as published by 1072dnl the Free Software Foundation; either version 2, or (at your option) 1073dnl any later version. 1074dnl 1075dnl This program is distributed in the hope that it will be useful, 1076dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 1077dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1078dnl GNU General Public License for more details. 1079dnl 1080dnl You should have received a copy of the GNU General Public License 1081dnl along with this program; if not, write to the Free Software 1082dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 1083dnl 02111-1307, USA. 1084dnl 1085dnl As a special exception, the Free Software Foundation gives unlimited 1086dnl permission to copy, distribute and modify the configure scripts that 1087dnl are the output of Autoconf. You need not follow the terms of the GNU 1088dnl General Public License when using or distributing such scripts, even 1089dnl though portions of the text of Autoconf appear in them. The GNU 1090dnl General Public License (GPL) does govern all other use of the material 1091dnl that constitutes the Autoconf program. 1092dnl 1093dnl Certain portions of the Autoconf source text are designed to be copied 1094dnl (in certain cases, depending on the input) into the output of 1095dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 1096dnl source text consists of comments plus executable code that decides which 1097dnl of the data portions to output in any given case. We call these 1098dnl comments and executable code the "non-data" portions. Autoconf never 1099dnl copies any of the non-data portions into its output. 1100dnl 1101dnl This special exception to the GPL applies to versions of Autoconf 1102dnl released by the Free Software Foundation. When you make and 1103dnl distribute a modified version of Autoconf, you may extend this special 1104dnl exception to the GPL to apply to your modified version as well, *unless* 1105dnl your modified version has the potential to copy into its output some 1106dnl of the text that was the non-data portion of the version that you started 1107dnl with. (In other words, unless your change moves or copies text from 1108dnl the non-data portions to the data portions.) If your modification has 1109dnl such potential, you must delete any notice of this special exception 1110dnl to the GPL from your modified version. 1111dnl 1112dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 1113 1114dnl A macro to determine which compiler is being used, in order that 1115dnl different flags can be set 1116 1117AC_DEFUN([TW_FC_ID], [ 1118AC_REQUIRE([AC_PROG_FC]) 1119 1120FC_ID= 1121 1122dnl Firstly go by compiler name. 1123 1124case $FC in 1125 1126 g77*) 1127 FC_ID=G77 1128 ;; 1129 1130 g95*) 1131 FC_ID=G95 1132 ;; 1133 1134 gfortran*) 1135 FC_ID=Gfortran 1136 ;; 1137 1138 if*) 1139 FC_ID=Intel 1140 ;; 1141 1142 lf9*) 1143 FC_ID=Lahey 1144 ;; 1145 1146 path*) 1147 FC_ID=Pathscale 1148 ;; 1149 1150 pgf*) 1151 FC_ID=Portland 1152 ;; 1153 1154 xlf*) 1155 FC_ID=Xlf 1156 1157esac 1158 1159dnl then try and disambiguate all f77, f90, and f95 types. 1160dnl We should have a choice between 1161dnl nag. absoft. sun. sgi. digital. hp. cray. ...? 1162 1163if test x$FC_ID = x; then 1164 tw_fc_v_output=$($FC -V 2>&1 ) 1165 if test $?; then 1166 case $tw_fc_v_output in 1167 *NAG*) 1168 FC_ID=Nag 1169 ;; 1170 *Sun*) 1171 FC_ID=Sun # there's more than one compiler here ... 1172 ;; 1173 *Absoft*) 1174 FC_ID=Absoft # there's more than one compiler here ... 1175 ;; 1176 esac 1177 fi 1178fi 1179 if test x$FC_ID = x; then 1180 tw_fc_v_output=$($FC -version 2>&1) 1181 if test $?; then 1182 case $tw_fc_v_output in 1183 *Compaq*) 1184 FC_ID=Digital 1185 ;; 1186 *Digital*) 1187 FC_ID=Digital 1188 ;; 1189 *SGI*) 1190 FC_ID=SGI 1191 ;; 1192 esac 1193 fi 1194fi 1195 1196AS_IF([test x$FC_ID != x], 1197 [AC_MSG_NOTICE([$FC seems to be a $FC_ID compiler])], 1198 [FC_ID=unknown; AC_MSG_NOTICE([Could not determine type of compiler])]) 1199 1200dnl for more fun, try and get the version number now ... 1201 1202 1203])# TW_FC_ID 1204dnl This program is free software; you can redistribute it and/or modify 1205dnl it under the terms of the GNU General Public License as published by 1206dnl the Free Software Foundation; either version 2, or (at your option) 1207dnl any later version. 1208dnl 1209dnl This program is distributed in the hope that it will be useful, 1210dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 1211dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1212dnl GNU General Public License for more details. 1213dnl 1214dnl You should have received a copy of the GNU General Public License 1215dnl along with this program; if not, write to the Free Software 1216dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 1217dnl 02111-1307, USA. 1218dnl 1219dnl As a special exception, the Free Software Foundation gives unlimited 1220dnl permission to copy, distribute and modify the configure scripts that 1221dnl are the output of Autoconf. You need not follow the terms of the GNU 1222dnl General Public License when using or distributing such scripts, even 1223dnl though portions of the text of Autoconf appear in them. The GNU 1224dnl General Public License (GPL) does govern all other use of the material 1225dnl that constitutes the Autoconf program. 1226dnl 1227dnl Certain portions of the Autoconf source text are designed to be copied 1228dnl (in certain cases, depending on the input) into the output of 1229dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 1230dnl source text consists of comments plus executable code that decides which 1231dnl of the data portions to output in any given case. We call these 1232dnl comments and executable code the "non-data" portions. Autoconf never 1233dnl copies any of the non-data portions into its output. 1234dnl 1235dnl This special exception to the GPL applies to versions of Autoconf 1236dnl released by the Free Software Foundation. When you make and 1237dnl distribute a modified version of Autoconf, you may extend this special 1238dnl exception to the GPL to apply to your modified version as well, *unless* 1239dnl your modified version has the potential to copy into its output some 1240dnl of the text that was the non-data portion of the version that you started 1241dnl with. (In other words, unless your change moves or copies text from 1242dnl the non-data portions to the data portions.) If your modification has 1243dnl such potential, you must delete any notice of this special exception 1244dnl to the GPL from your modified version. 1245dnl 1246dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 1247 1248dnl A macro to set various compiler-dependent things that can't be sensibly 1249dnl deduced. 1250 1251AC_DEFUN([TW_FC_ID_FLAGS], [ 1252AC_REQUIRE([TW_FC_ID]) 1253 1254case $FC_ID in 1255 1256 Absoft) 1257 FFLAGS_DEBUG="-et -g -Rb -Rc -Rp -Rs" 1258 ;; 1259 1260 Digital) 1261 FFLAGS_FAST=-O2 1262 FFLAGS_DEBUG="-g -Rabc -ei" 1263 ;; 1264 1265 G77) 1266 ;; 1267 1268 G95) 1269 FFLAGS_FAST=-O2 1270 FFLAGS_DEBUG="-ggdb3 -ftrace=full -fbounds-check -flogical=false -freal=nan -fpointer=invalid -finteger=-1" 1271 ;; 1272 1273 Gfortran) 1274 ;; 1275 1276 Intel) 1277 FFLAGS_DEBUG="-C -g -inline_debug_info" 1278 ;; 1279 1280 Lahey) 1281 FFLAGS_DEBUG="--chk aesux --chkglobal -g --trace" 1282 FFLAGS_FAST="-O --warn --quiet --tpp --ntrace" 1283 ;; 1284 1285 Nag) 1286 FFLAGS_DEBUG="-C=all -g -gline -nan" 1287 DEFS="$DEFS __NAG__" 1288 ;; 1289 1290 Pathscale) 1291 ;; 1292 1293 Portland) 1294 FFLAGS_DEBUG="-g -Mbounds" 1295 FFLAGS_FAST="-fast" 1296 DEFS="$DEFS PGF90" 1297 ;; 1298 1299 SGI) 1300 FFLAGS_DEBUG="-g -O0" 1301 FFLAGS_FAST="-O3 -OPT:Olimit=0" 1302 ;; 1303 1304 Sun) 1305 FFLAGS_DEBUG="-C -g" 1306 FFLAGS_FAST="-fast" 1307 ;; 1308 1309 Xlf) 1310 FFLAGS_DEBUG="-g -C -qinitauto -qsave -qmaxmem=16000 -qnolm" 1311 FFLAGS_FAST="-O3 -qarch=auto -qtune=auto -qcache=auto -qnolm" 1312 ;; 1313 1314esac 1315 1316AC_SUBST(FFLAGS_MPI) 1317 1318]) 1319dnl This program is free software; you can redistribute it and/or modify 1320dnl it under the terms of the GNU General Public License as published by 1321dnl the Free Software Foundation; either version 2, or (at your option) 1322dnl any later version. 1323dnl 1324dnl This program is distributed in the hope that it will be useful, 1325dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 1326dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1327dnl GNU General Public License for more details. 1328dnl 1329dnl You should have received a copy of the GNU General Public License 1330dnl along with this program; if not, write to the Free Software 1331dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 1332dnl 02111-1307, USA. 1333dnl 1334dnl As a special exception, the Free Software Foundation gives unlimited 1335dnl permission to copy, distribute and modify the configure scripts that 1336dnl are the output of Autoconf. You need not follow the terms of the GNU 1337dnl General Public License when using or distributing such scripts, even 1338dnl though portions of the text of Autoconf appear in them. The GNU 1339dnl General Public License (GPL) does govern all other use of the material 1340dnl that constitutes the Autoconf program. 1341dnl 1342dnl Certain portions of the Autoconf source text are designed to be copied 1343dnl (in certain cases, depending on the input) into the output of 1344dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 1345dnl source text consists of comments plus executable code that decides which 1346dnl of the data portions to output in any given case. We call these 1347dnl comments and executable code the "non-data" portions. Autoconf never 1348dnl copies any of the non-data portions into its output. 1349dnl 1350dnl This special exception to the GPL applies to versions of Autoconf 1351dnl released by the Free Software Foundation. When you make and 1352dnl distribute a modified version of Autoconf, you may extend this special 1353dnl exception to the GPL to apply to your modified version as well, *unless* 1354dnl your modified version has the potential to copy into its output some 1355dnl of the text that was the non-data portion of the version that you started 1356dnl with. (In other words, unless your change moves or copies text from 1357dnl the non-data portions to the data portions.) If your modification has 1358dnl such potential, you must delete any notice of this special exception 1359dnl to the GPL from your modified version. 1360dnl 1361dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 1362 1363 1364# AC_FC_REAL_KIND([KIND_DECLARATION], [VARIABLE_SUFFIX], [ACTION_IF_SUCCESS], [ACTION_IF_FAIL]) 1365# ------------------- 1366# 1367# This macro checks what integer is produced by the kind 1368# declaration KIND_DECLARATION. This integer is placed in 1369# AC_FC_KIND_<VARIABLE_SUFFIX>. If we successfully find a 1370# kind integer, ACTION_IF_SUCCESS is performed; otherwise 1371# ACTION_IF_FAIL. 1372 1373AC_DEFUN([AC_FC_REAL_KIND], [dnl 1374AC_REQUIRE([AC_PROG_FC]) 1375AC_CACHE_CHECK([for kind number produced by $1], 1376 ac_cv_fc_real_kind_[]$2[], 1377[dnl 1378AC_LANG_PUSH([Fortran]) 1379FCFLAGS_save="$FCFLAGS" 1380FCFLAGS="$FCFLAGS $FCFLAGS_free_f90" 1381ac_fc_kind_test=1 1382ac_fc_kind_found=no 1383while test $ac_fc_kind_test -lt 100 1384do 1385 cat > conftest.$ac_ext << ACEOF 1386dnl The program below will fail to compile if 1387dnl sp != mysp; ie if the kind produced by the 1388dnl supplied kind declaration ($1) is not the same 1389dnl same as $ac_fc_kind_test. This is because Fortran 1390dnl pointers & targets must be of the same kind. 1391dnl All conforming compilers must fail to compile the 1392dnl subroutine otherwise. 1393dnl 1394dnl This approach is taken since it enables us to 1395dnl test for kind numbers at compile time rather 1396dnl than run time, which means the macro will support 1397dnl crosss-compilation. 1398dnl 1399dnl However, note that kind numbers can theoretically 1400dnl be anything from 1 to the largest default integer 1401dnl supported by the compiler. Here we only test up to 1402dnl 99, which is more than enough on all compilers tried 1403dnl so far 1404dnl 1405 subroutine kind_explorer 1406 integer, parameter :: sp = $1 1407 integer, parameter :: mysp = $ac_fc_kind_test 1408 real(kind=sp), target :: x 1409 real(kind=mysp), pointer :: y 1410 y=>x 1411 end subroutine kind_explorer 1412ACEOF 1413dnl 1414 if eval $ac_compile 2>&5 1415 then 1416 ac_fc_kind_found=yes 1417 break 1418 fi 1419 ac_fc_kind_test=`expr $ac_fc_kind_test + 1` 1420done 1421if test "$ac_fc_kind_found" = yes; then 1422 ac_cv_fc_real_kind_[]$2[]=$ac_fc_kind_test 1423else 1424 ac_cv_fc_real_kind_[]$2[]=none 1425fi 1426 1427FCFLAGS="$FCFLAGS_save" 1428AC_LANG_POP([Fortran]) 1429]) 1430AS_IF([test $ac_cv_fc_real_kind_[]$2[] != no], 1431 [ac_fc_real_kind_[]$2[]=$ac_cv_fc_real_kind_[]$2[]; m4_default([$3],[:])], 1432 [m4_default([$4],[AC_MSG_ERROR([Could not find Fortran real kind number for $1])])] 1433 ) 1434]) # AC_FC_REAL_KIND 1435 1436# AC_FC_INT_KIND([KIND_DECLARATION], [VARIABLE_SUFFIX], [ACTION_IF_SUCCESS], [ACTION_IF_FAIL]) 1437# ------------------- 1438# 1439# This macro checks what integer is produced by the kind 1440# declaration KIND_DECLARATION. This integer is placed in 1441# AC_FC_KIND_<VARIABLE_SUFFIX>. If we successfully find a 1442# kind integer, ACTION_IF_SUCCESS is performed; otherwise 1443# ACTION_IF_FAIL. 1444 1445AC_DEFUN([AC_FC_INT_KIND], [dnl 1446AC_REQUIRE([AC_PROG_FC]) 1447AC_CACHE_CHECK([for kind number produced by $1], 1448 ac_cv_fc_int_kind_[]$2[], 1449[dnl 1450AC_LANG_PUSH([Fortran]) 1451FCFLAGS_save="$FCFLAGS" 1452FCFLAGS="$FCFLAGS $FCFLAGS_free_f90" 1453ac_fc_kind_test=1 1454ac_fc_kind_found=no 1455while test $ac_fc_kind_test -lt 100 1456do 1457 cat > conftest.f90 << ACEOF 1458dnl The program below will fail to compile if 1459dnl sp != mysp; ie if the kind produced by the 1460dnl supplied kind declaration ($1) is not the same 1461dnl same as $ac_fc_kind_test. This is because Fortran 1462dnl pointers & targets must be of the same kind. 1463dnl All conforming compilers must fail to compile the 1464dnl subroutine otherwise. 1465dnl 1466dnl This approach is taken since it enables us to 1467dnl test for kind numbers at compile time rather 1468dnl than run time, which means the macro will support 1469dnl crosss-compilation. 1470dnl 1471dnl However, note that kind numbers can theoretically 1472dnl be anything from 1 to the largest default integer 1473dnl supported by the compiler. Here we only test up to 1474dnl 99, which is more than enough on all compilers tried 1475dnl so far 1476dnl 1477 subroutine kind_explorer 1478 integer, parameter :: sp = $1 1479 integer, parameter :: mysp = $ac_fc_kind_test 1480 integer(kind=sp), target :: x 1481 integer(kind=mysp), pointer :: y 1482 y=>x 1483 end subroutine kind_explorer 1484ACEOF 1485dnl 1486 if eval $ac_compile 2>&5 1487 then 1488 ac_fc_kind_found=yes 1489 break 1490 fi 1491 ac_fc_kind_test=`expr $ac_fc_kind_test + 1` 1492done 1493if test "$ac_fc_kind_found" = yes; then 1494 ac_cv_fc_int_kind_[]$2[]=$ac_fc_kind_test 1495else 1496 ac_cv_fc_int_kind_[]$2[]=none 1497fi 1498 1499FCFLAGS="$FCFLAGS_save" 1500AC_LANG_POP([Fortran]) 1501]) 1502AS_IF([test $ac_cv_fc_int_kind_[]$2[] != no], 1503 [ac_fc_int_kind_[]$2[]=$ac_cv_fc_int_kind_[]$2[]; m4_default([$3],[:])], 1504 [m4_default([$4],[AC_MSG_ERROR([Could not find Fortran integer kind number for $1])])] 1505 ) 1506]) # AC_FC_INT_KIND 1507 1508 1509# AC_FC_GET_REAL_KINDS([ACTION_IF_SUCCESS], [ACTION_IF_FAIL]) 1510# ------------------- 1511# 1512# This macro attempts to find the Fortran compiler's kinds 1513# for the following four types of real number: 1514# Compiler default (single) precision 1515# Compiler double precision 1516# IEEE single precision 1517# IEEE double precision 1518# The first two are guaranteed to exist; the second two may 1519# or may not. 1520# If all 4 are succesfully found,. ACTION_IF_SUCCESS is 1521# performed. 1522# Otherwise, ACTION_IF_FAIL is performed 1523# 1524AC_DEFUN([AC_FC_GET_REAL_KINDS], [dnl 1525AC_REQUIRE([AC_PROG_FC]) 1526 1527ac_fc_got_kinds=yes 1528 1529AC_FC_REAL_KIND([[kind(1.0)]], [sp], 1530 [], [ac_got_kinds=no]) 1531AC_FC_REAL_KIND([[kind(1.0d0)]], [dp], 1532 [], [ac_got_kinds=no]) 1533AC_FC_REAL_KIND([[selected_real_kind(6,34)]], [ieee_sp], 1534 [], [ac_got_kinds=no]) 1535AC_FC_REAL_KIND([[selected_real_kind(15,300)]], [ieee_dp], 1536 [], [ac_got_kinds=no]) 1537 1538AS_IF([test $ac_fc_got_kinds != no], 1539 [m4_default([$1],[:])], 1540 [m4_default([$2],[AC_MSG_ERROR([Could not find all Fortran real kinds])])] 1541 ) 1542]) dnl AC_FC_GET_REAL_KINDS 1543 1544dnl This program is free software; you can redistribute it and/or modify 1545dnl it under the terms of the GNU General Public License as published by 1546dnl the Free Software Foundation; either version 2, or (at your option) 1547dnl any later version. 1548dnl 1549dnl This program is distributed in the hope that it will be useful, 1550dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 1551dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1552dnl GNU General Public License for more details. 1553dnl 1554dnl You should have received a copy of the GNU General Public License 1555dnl along with this program; if not, write to the Free Software 1556dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 1557dnl 02111-1307, USA. 1558dnl 1559dnl As a special exception, the Free Software Foundation gives unlimited 1560dnl permission to copy, distribute and modify the configure scripts that 1561dnl are the output of Autoconf. You need not follow the terms of the GNU 1562dnl General Public License when using or distributing such scripts, even 1563dnl though portions of the text of Autoconf appear in them. The GNU 1564dnl General Public License (GPL) does govern all other use of the material 1565dnl that constitutes the Autoconf program. 1566dnl 1567dnl Certain portions of the Autoconf source text are designed to be copied 1568dnl (in certain cases, depending on the input) into the output of 1569dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 1570dnl source text consists of comments plus executable code that decides which 1571dnl of the data portions to output in any given case. We call these 1572dnl comments and executable code the "non-data" portions. Autoconf never 1573dnl copies any of the non-data portions into its output. 1574dnl 1575dnl This special exception to the GPL applies to versions of Autoconf 1576dnl released by the Free Software Foundation. When you make and 1577dnl distribute a modified version of Autoconf, you may extend this special 1578dnl exception to the GPL to apply to your modified version as well, *unless* 1579dnl your modified version has the potential to copy into its output some 1580dnl of the text that was the non-data portion of the version that you started 1581dnl with. (In other words, unless your change moves or copies text from 1582dnl the non-data portions to the data portions.) If your modification has 1583dnl such potential, you must delete any notice of this special exception 1584dnl to the GPL from your modified version. 1585dnl 1586dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 1587 1588dnl autoconf macros for detecting NetCDF (fortan implementation only) 1589dnl 1590AC_DEFUN([_TW_TRY_NETCDF], [ 1591ac_ext=f 1592AC_LINK_IFELSE( 1593 [AC_LANG_SOURCE([[ 1594 PROGRAM NETCDF 1595 CALL NF_CLOSE() 1596 END PROGRAM 1597 ]])], 1598 [m4_ifval([$1],[$1],[])], 1599 [m4_ifval([$2],[$2],[])] 1600) 1601]) 1602dnl 1603AC_DEFUN([TW_PATH_NETCDF],[ 1604tw_netcdf_ok=no 1605dnl 1606AC_LANG_PUSH([Fortran]) 1607dnl 1608case $with_netcdf in 1609 yes | "") ;; 1610 no) tw_netcdf_ok=disable ;; 1611 -* | */* | *.a | *.so | *.so.* | *.o) NETCDF_LIBS="$with_netcdf" ;; 1612 *) NETCDF_LIBS="-l$with_netcdf" ;; 1613esac 1614dnl 1615if test $tw_netcdf_ok != disable; then 1616 if test "x$NETCDF_LIBS" = x; then 1617 NETCDF_LIBS="-lnetcdf" 1618 fi 1619dnl 1620 AC_MSG_CHECKING([for netcdf]) 1621 save_LIBS="$LIBS" 1622 LIBS="$LIBS $NETCDF_LIBS" 1623 _TW_TRY_NETCDF([tw_netcdf_ok=yes],[]) 1624 AC_MSG_RESULT([$tw_netcdf_ok]) 1625 LIBS="$save_LIBS" 1626fi 1627dnl 1628dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: 1629AS_IF([test $tw_netcdf_ok = yes], 1630 [ifelse([$1],,AC_DEFINE(HAVE_NETCDF,1,[Define if you have NetCDF library.]),[$1])], 1631 [NETCDF_LIBS="";tw_netcdf_ok=no;$2]) 1632AC_LANG_POP 1633]) 1634dnl This program is free software; you can redistribute it and/or modify 1635dnl it under the terms of the GNU General Public License as published by 1636dnl the Free Software Foundation; either version 2, or (at your option) 1637dnl any later version. 1638dnl 1639dnl This program is distributed in the hope that it will be useful, 1640dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 1641dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1642dnl GNU General Public License for more details. 1643dnl 1644dnl You should have received a copy of the GNU General Public License 1645dnl along with this program; if not, write to the Free Software 1646dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 1647dnl 02111-1307, USA. 1648dnl 1649dnl As a special exception, the Free Software Foundation gives unlimited 1650dnl permission to copy, distribute and modify the configure scripts that 1651dnl are the output of Autoconf. You need not follow the terms of the GNU 1652dnl General Public License when using or distributing such scripts, even 1653dnl though portions of the text of Autoconf appear in them. The GNU 1654dnl General Public License (GPL) does govern all other use of the material 1655dnl that constitutes the Autoconf program. 1656dnl 1657dnl Certain portions of the Autoconf source text are designed to be copied 1658dnl (in certain cases, depending on the input) into the output of 1659dnl Autoconf. We call these the "data" portions. The rest of the Autoconf 1660dnl source text consists of comments plus executable code that decides which 1661dnl of the data portions to output in any given case. We call these 1662dnl comments and executable code the "non-data" portions. Autoconf never 1663dnl copies any of the non-data portions into its output. 1664dnl 1665dnl This special exception to the GPL applies to versions of Autoconf 1666dnl released by the Free Software Foundation. When you make and 1667dnl distribute a modified version of Autoconf, you may extend this special 1668dnl exception to the GPL to apply to your modified version as well, *unless* 1669dnl your modified version has the potential to copy into its output some 1670dnl of the text that was the non-data portion of the version that you started 1671dnl with. (In other words, unless your change moves or copies text from 1672dnl the non-data portions to the data portions.) If your modification has 1673dnl such potential, you must delete any notice of this special exception 1674dnl to the GPL from your modified version. 1675dnl 1676dnl Copyright Toby White <tow21@cam.ac.uk> 2004-2006 1677 1678dnl Macro to check for cygpath PATH-substitution utility. 1679dnl compilation with BLACS. Only works with Fortran at the moment. 1680 1681AC_DEFUN([TW_PROG_CYGPATH_W], [ 1682 1683 # test whether we have cygpath 1684 if test -z "$CYGPATH_W"; then 1685 if (cygpath --version) >/dev/null 2>/dev/null; then 1686 CYGPATH_W='cygpath -w' 1687 else 1688 CYGPATH_W=echo 1689 fi 1690 fi 1691 AC_SUBST([CYGPATH_W]) 1692]) 1693# This file is part of Autoconf. -*- Autoconf -*- 1694# Fortran languages support. 1695# Copyright (C) 2001, 2003-2005 1696# Free Software Foundation, Inc. 1697# 1698# This program is free software; you can redistribute it and/or modify 1699# it under the terms of the GNU General Public License as published by 1700# the Free Software Foundation; either version 2, or (at your option) 1701# any later version. 1702# 1703# This program is distributed in the hope that it will be useful, 1704# but WITHOUT ANY WARRANTY; without even the implied warranty of 1705# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1706# GNU General Public License for more details. 1707# 1708# You should have received a copy of the GNU General Public License 1709# along with this program; if not, write to the Free Software 1710# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 1711# 02111-1307, USA. 1712# 1713# As a special exception, the Free Software Foundation gives unlimited 1714# permission to copy, distribute and modify the configure scripts that 1715# are the output of Autoconf. You need not follow the terms of the GNU 1716# General Public License when using or distributing such scripts, even 1717# though portions of the text of Autoconf appear in them. The GNU 1718# General Public License (GPL) does govern all other use of the material 1719# that constitutes the Autoconf program. 1720# 1721# Certain portions of the Autoconf source text are designed to be copied 1722# (in certain cases, depending on the input) into the output of 1723# Autoconf. We call these the "data" portions. The rest of the Autoconf 1724# source text consists of comments plus executable code that decides which 1725# of the data portions to output in any given case. We call these 1726# comments and executable code the "non-data" portions. Autoconf never 1727# copies any of the non-data portions into its output. 1728# 1729# This special exception to the GPL applies to versions of Autoconf 1730# released by the Free Software Foundation. When you make and 1731# distribute a modified version of Autoconf, you may extend this special 1732# exception to the GPL to apply to your modified version as well, *unless* 1733# your modified version has the potential to copy into its output some 1734# of the text that was the non-data portion of the version that you started 1735# with. (In other words, unless your change moves or copies text from 1736# the non-data portions to the data portions.) If your modification has 1737# such potential, you must delete any notice of this special exception 1738# to the GPL from your modified version. 1739# 1740# Written by David MacKenzie, with help from 1741# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, 1742# Roland McGrath, Noah Friedman, david d zuhn, and many others. 1743# 1744# Fortran preprocessing support written by Martin Wilck, adapted and 1745# extended by Norman Gray and Toby White. 1746 1747 1748# Fortran vs. Fortran 77: 1749# This file contains macros for both "Fortran 77" and "Fortran", where 1750# the former is the "classic" autoconf Fortran interface and is intended 1751# for legacy F77 codes, while the latter is intended to support newer Fortran 1752# dialects. Fortran 77 uses environment variables F77, FFLAGS, and FLIBS, 1753# while Fortran uses FC, FCFLAGS, and FCLIBS. For each user-callable AC_* 1754# macro, there is generally both an F77 and an FC version, where both versions 1755# share the same _AC_*_FC_* backend. This backend macro requires that 1756# the appropriate language be AC_LANG_PUSH'ed, and uses _AC_LANG_ABBREV and 1757# _AC_LANG_PREFIX in order to name cache and environment variables, etc. 1758 1759 1760# _AC_LIST_MEMBER_IF(ELEMENT, LIST, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 1761# --------------------------------------------------------------------------- 1762# 1763# Processing the elements of a list is tedious in shell programming, 1764# as lists tend to be implemented as space delimited strings. 1765# 1766# This macro searches LIST for ELEMENT, and executes ACTION-IF-FOUND 1767# if ELEMENT is a member of LIST, otherwise it executes 1768# ACTION-IF-NOT-FOUND. 1769AC_DEFUN([_AC_LIST_MEMBER_IF], 1770[dnl Do some sanity checking of the arguments. 1771m4_if([$1], , [AC_FATAL([$0: missing argument 1])])dnl 1772m4_if([$2], , [AC_FATAL([$0: missing argument 2])])dnl 1773 ac_exists=false 1774 for ac_i in $2; do 1775 if test x"$1" = x"$ac_i"; then 1776 ac_exists=true 1777 break 1778 fi 1779 done 1780 1781 AS_IF([test x"$ac_exists" = xtrue], [$3], [$4])[]dnl 1782])# _AC_LIST_MEMBER_IF 1783 1784 1785# _AC_LINKER_OPTION(LINKER-OPTIONS, SHELL-VARIABLE) 1786# ------------------------------------------------- 1787# 1788# Specifying options to the compiler (whether it be the C, C++ or 1789# Fortran 77 compiler) that are meant for the linker is compiler 1790# dependent. This macro lets you give options to the compiler that 1791# are meant for the linker in a portable, compiler-independent way. 1792# 1793# This macro take two arguments, a list of linker options that the 1794# compiler should pass to the linker (LINKER-OPTIONS) and the name of 1795# a shell variable (SHELL-VARIABLE). The list of linker options are 1796# appended to the shell variable in a compiler-dependent way. 1797# 1798# For example, if the selected language is C, then this: 1799# 1800# _AC_LINKER_OPTION([-R /usr/local/lib/foo], foo_LDFLAGS) 1801# 1802# will expand into this if the selected C compiler is gcc: 1803# 1804# foo_LDFLAGS="-Xlinker -R -Xlinker /usr/local/lib/foo" 1805# 1806# otherwise, it will expand into this: 1807# 1808# foo_LDFLAGS"-R /usr/local/lib/foo" 1809# 1810# You are encouraged to add support for compilers that this macro 1811# doesn't currently support. 1812# FIXME: Get rid of this macro. 1813AC_DEFUN([_AC_LINKER_OPTION], 1814[if test "$ac_compiler_gnu" = yes; then 1815 for ac_link_opt in $1; do 1816 $2="[$]$2 -Xlinker $ac_link_opt" 1817 done 1818else 1819 $2="[$]$2 $1" 1820fi[]dnl 1821])# _AC_LINKER_OPTION 1822 1823 1824 1825## ----------------------- ## 1826## 1. Language selection. ## 1827## ----------------------- ## 1828 1829 1830# -------------------------- # 1831# 1d. The Fortran language. # 1832# -------------------------- # 1833 1834 1835# AC_LANG(Fortran 77) 1836# ------------------- 1837m4_define([AC_LANG(Fortran 77)], 1838[ac_ext=f 1839ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD' 1840ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD' 1841ac_compiler_gnu=$ac_cv_f77_compiler_gnu 1842]) 1843 1844 1845# AC_LANG(Fortran) 1846# ---------------- 1847m4_define([AC_LANG(Fortran)], 1848[ac_ext=${FC_SRCEXT-f} 1849ac_compile='$FC -c $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext >&AS_MESSAGE_LOG_FD' 1850ac_link='$FC $ac_link_obj_flag""conftest$ac_exeext $FCFLAGS $LDFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD' 1851ac_compiler_gnu=$ac_cv_fc_compiler_gnu 1852]) 1853 1854# AC_LANG(Preprocessed Fortran) 1855# -------------------------------- 1856# We need a separate `preprocessed' language, because not all Fortran 1857# compilers have a preprocessor built in. Therefore we may need to 1858# resort to an `indirect' compilation, .F->.f->.o, including the 1859# generation of a suitable extra build rule. The language extension 1860# is set in macro AC_PROG_FPP, to $FPP_SRC_EXT. 1861m4_define([AC_LANG(Preprocessed Fortran)], 1862[ac_ext=$FPP_SRC_EXT 1863# We need to use variables because compilation depends on whether 1864# $F77 supports direct compilation of source with cpp directives 1865ac_compile=$ac_fpp_compile 1866ac_link=$ac_fpp_link 1867ac_compiler_gnu=$ac_cv_fc_compiler_gnu 1868]) 1869 1870 1871# AC_LANG_FORTRAN77 1872# ----------------- 1873AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)]) 1874 1875 1876# _AC_FORTRAN_ASSERT 1877# ------------------ 1878# Current language must be Fortran, Fortran 77, or preprocessed Fortran. 1879# FIXME: is there any reason why this can't be AC_LANG_CASE? 1880m4_defun([_AC_FORTRAN_ASSERT], 1881[m4_if(_AC_LANG, [Fortran], [], 1882 [m4_if(_AC_LANG, [Fortran 77], [], 1883 [m4_if(_AC_LANG, [Preprocessed Fortran], [] 1884 [m4_fatal([$0: current language is not Fortran: ] _AC_LANG)])])])]) 1885 1886 1887# _AC_LANG_ABBREV(Fortran 77) 1888# --------------------------- 1889m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77]) 1890 1891# _AC_LANG_ABBREV(Fortran) 1892# ------------------------ 1893m4_define([_AC_LANG_ABBREV(Fortran)], [fc]) 1894 1895# _AC_LANG_ABBREV(Preprocessed Fortran) 1896# ------------------------------------- 1897m4_define([_AC_LANG_ABBREV(Preprocessed Fortran)], [fpp]) 1898 1899 1900# _AC_LANG_PREFIX(Fortran 77) 1901# --------------------------- 1902m4_define([_AC_LANG_PREFIX(Fortran 77)], [F]) 1903 1904# _AC_LANG_PREFIX(Fortran) 1905# ------------------------ 1906m4_define([_AC_LANG_PREFIX(Fortran)], [FC]) 1907 1908# _AC_LANG_PREFIX(Preprocessed Fortran) 1909# ------------------------------------- 1910m4_define([_AC_LANG_PREFIX(Preprocessed Fortran)], [FPP]) 1911 1912 1913# _AC_FC 1914# ------ 1915# Return F77, FC or PPFC, depending upon the language. 1916AC_DEFUN([_AC_FC], 1917[_AC_FORTRAN_ASSERT()dnl 1918AC_LANG_CASE([Fortran 77], [F77], 1919 [Fortran], [FC], 1920 [Preprocessed Fortran], [PPFC])]) 1921 1922 1923## ---------------------- ## 1924## 2.Producing programs. ## 1925## ---------------------- ## 1926 1927 1928# --------------------- # 1929# 2d. Fortran sources. # 1930# --------------------- # 1931 1932# AC_LANG_SOURCE(Fortran 77)(BODY) 1933# AC_LANG_SOURCE(Fortran)(BODY) 1934# -------------------------------- 1935# FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP 1936# directives must not be included. But AC_TRY_RUN_NATIVE was not 1937# avoiding them, so? 1938m4_define([AC_LANG_SOURCE(Fortran 77)], 1939[$1]) 1940m4_define([AC_LANG_SOURCE(Fortran)], 1941[$1]) 1942m4_define([AC_LANG_SOURCE(Preprocessed Fortran)], 1943[$1]) 1944 1945 1946# AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY]) 1947# ----------------------------------------------- 1948# Yes, we discard the PROLOGUE. 1949m4_define([AC_LANG_PROGRAM(Fortran 77)], 1950[m4_ifval([$1], 1951 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl 1952 program main 1953$2 1954 end]) 1955 1956 1957# AC_LANG_PROGRAM(Fortran)([PROLOGUE], [BODY]) 1958# ----------------------------------------------- 1959# FIXME: can the PROLOGUE be used? 1960m4_define([AC_LANG_PROGRAM(Fortran)], 1961[m4_ifval([$1], 1962 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl 1963 program main 1964$2 1965 end]) 1966 1967 1968# AC_LANG_PROGRAM(Preprocessed Fortran)([PROLOGUE], [BODY]) 1969# --------------------------------------------------------- 1970# FIXME: can the PROLOGUE be used? 1971m4_define([AC_LANG_PROGRAM(Preprocessed Fortran)], 1972[$1 1973 program main 1974$2 1975 end]) 1976 1977 1978# AC_LANG_CALL(Fortran 77)(PROLOGUE, FUNCTION) 1979# -------------------------------------------- 1980# FIXME: This is a guess, help! 1981# FIXME: ...but it's a good guesss -- what's the problem? 1982m4_define([AC_LANG_CALL(Fortran 77)], 1983[AC_LANG_PROGRAM([$1], 1984[ call $2])]) 1985 1986 1987# AC_LANG_CALL(Fortran)(PROLOGUE, FUNCTION) 1988# -------------------------------------------- 1989# FIXME: This is a guess, help! 1990m4_define([AC_LANG_CALL(Fortran)], 1991[AC_LANG_PROGRAM([$1], 1992[ call $2])]) 1993 1994 1995# AC_LANG_CALL(Preprocessed Fortran)(PROLOGUE, FUNCTION) 1996# ------------------------------------------------------ 1997# FIXME: This is a guess, help! 1998m4_define([AC_LANG_CALL(Preprocessed Fortran)], 1999[AC_LANG_PROGRAM([$1], 2000[ call $2])]) 2001 2002 2003# AC_LANG_FUNC_LINK_TRY(Fortran)(FUNCTION) 2004# ---------------------------------------- 2005# Produce a source which links correctly iff the Fortran FUNCTION exists. 2006# Note that the generic AC_LANG_FUNC_LINK_TRY macro is deemed severely 2007# broken, and is deprecated. The macro still currently exists, however, 2008# and so if macros like AC_CHECK_FUNCS are to work with 2009# AC_LANG(Fortran) (and friends), then these macros have to be 2010# defined. 2011# 2012# FIXME: This is a severely broken implementation. 2013# It does not distinguish between functions and subroutines, and it 2014# ignores any arguments. We don't attempt to cope with argument $1 2015# being somethine weird -- either already declared as a Fortran keyword 2016# or something needing quoting -- if the user wants to ask dumb 2017# questions, they'll get dumb answers. 2018m4_define([AC_LANG_FUNC_LINK_TRY(Fortran)], 2019[AC_LANG_SOURCE( 2020[ Program Test 2021 External $1 2022 Call $1 2023 End 2024])]) 2025 2026 2027# AC_LANG_FUNC_LINK_TRY(Fortran 77)(FUNCTION) 2028# ------------------------------------------- 2029# Ditto, for language `Fortran 77' 2030m4_define([AC_LANG_FUNC_LINK_TRY(Fortran 77)], 2031[AC_LANG_SOURCE( 2032[ Program Test 2033 External $1 2034 Call $1 2035 End 2036])]) 2037 2038 2039# AC_LANG_FUNC_LINK_TRY(Preprocessed Fortran)(FUNCTION) 2040# ----------------------------------------------------- 2041# Ditto, for language `Preprocessed Fortran' 2042m4_define([AC_LANG_FUNC_LINK_TRY(Preprocessed Fortran)], 2043[AC_LANG_SOURCE( 2044[ Program Test 2045 External $1 2046 Call $1 2047 End 2048])]) 2049 2050 2051 2052## -------------------------------------------- ## 2053## 3. Looking for Compilers and Preprocessors. ## 2054## -------------------------------------------- ## 2055 2056 2057# -------------------------- # 2058# 3d. The Fortran compiler. # 2059# -------------------------- # 2060 2061 2062# AC_LANG_PREPROC(Fortran 77) 2063# --------------------------- 2064# Find the Fortran 77 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able. 2065AC_DEFUN([AC_LANG_PREPROC(Fortran 77)], 2066[m4_warn([syntax], 2067 [$0: No preprocessor defined for ]_AC_LANG)]) 2068 2069# AC_LANG_PREPROC(Fortran) 2070# --------------------------- 2071# Find the Fortran preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able. 2072AC_DEFUN([AC_LANG_PREPROC(Fortran)], 2073[m4_warn([syntax], 2074 [$0: No preprocessor defined for ]_AC_LANG)]) 2075 2076# AC_LANG_PREPROC(Preprocessed Fortran) 2077# ------------------------------------- 2078# Find the Fortran preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able. 2079AC_DEFUN([AC_LANG_PREPROC(Preprocessed Fortran)], 2080[AC_REQUIRE([AC_PROG_FPP])]) 2081 2082 2083# AC_LANG_COMPILER(Fortran 77) 2084# ---------------------------- 2085# Find the Fortran 77 compiler. Must be AC_DEFUN'd to be 2086# AC_REQUIRE'able. 2087AC_DEFUN([AC_LANG_COMPILER(Fortran 77)], 2088[AC_REQUIRE([AC_PROG_F77])]) 2089 2090# AC_LANG_COMPILER(Fortran) 2091# ------------------------- 2092# Find the Fortran compiler. Must be AC_DEFUN'd to be 2093# AC_REQUIRE'able. 2094AC_DEFUN([AC_LANG_COMPILER(Fortran)], 2095[AC_REQUIRE([AC_PROG_FC])]) 2096 2097# AC_LANG_COMPILER(Preprocessed Fortran) 2098# -------------------------------------- 2099# Find the Fortran compiler. Must be AC_DEFUN'd to be 2100# AC_REQUIRE'able. 2101AC_DEFUN([AC_LANG_COMPILER(Preprocessed Fortran)], 2102[AC_REQUIRE([AC_PROG_FC])]) 2103 2104 2105# ac_cv_prog_g77 2106# -------------- 2107# We used to name the cache variable this way. 2108AU_DEFUN([ac_cv_prog_g77], 2109[ac_cv_f77_compiler_gnu]) 2110 2111 2112# _AC_FC_DIALECT_YEAR([DIALECT]) 2113# ------------------------------ 2114# Given a Fortran DIALECT, which is Fortran [YY]YY or simply [YY]YY, 2115# convert to a 4-digit year. The dialect must be one of Fortran 77, 2116# 90, 95, or 2000, currently. If DIALECT is simply Fortran or the 2117# empty string, returns the empty string. 2118AC_DEFUN([_AC_FC_DIALECT_YEAR], 2119[m4_case(m4_bpatsubsts(m4_tolower([$1]), [fortran],[], [ *],[]), 2120 [77],[1977], [1977],[1977], 2121 [90],[1990], [1990],[1990], 2122 [95],[1995], [1995],[1995], 2123 [2000],[2000], 2124 [],[], 2125 [m4_fatal([unknown Fortran dialect])])]) 2126 2127 2128# _AC_PROG_FC([DIALECT], [COMPILERS...]) 2129# -------------------------------------- 2130# DIALECT is a Fortran dialect, given by Fortran [YY]YY or simply [YY]YY, 2131# and must be one of those supported by _AC_FC_DIALECT_YEAR 2132# 2133# If DIALECT is supplied, then we search for compilers of that dialect 2134# first, and then later dialects. Otherwise, we search for compilers 2135# of the newest dialect first, and then earlier dialects in increasing age. 2136# This search order is necessarily imperfect because the dialect cannot 2137# always be inferred from the compiler name. 2138# 2139# Known compilers: 2140# f77/f90/f95: generic compiler names 2141# g77: GNU Fortran 77 compiler 2142# gfortran: putative GNU Fortran 95+ compiler (in progress) 2143# fort77: native F77 compiler under HP-UX (and some older Crays) 2144# frt: Fujitsu F77 compiler 2145# pgf77/pgf90/pgf95: Portland Group F77/F90/F95 compilers 2146# xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers 2147# lf95: Lahey-Fujitsu F95 compiler 2148# fl32: Microsoft Fortran 77 "PowerStation" compiler 2149# af77: Apogee F77 compiler for Intergraph hardware running CLIX 2150# epcf90: "Edinburgh Portable Compiler" F90 2151# fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha 2152# ifc: Intel Fortran 95 compiler for Linux/x86 2153# efc: Intel Fortran 95 compiler for IA64 2154# 2155# Must check for lf95 before f95 - some Lahey versions ship an f95 binary 2156# in the default path that must be avoided. 2157# 2158# Let's emphasise this: the test here is only whether a program with 2159# the given name exists -- there's no test at this point of whether 2160# the found program is actually a Fortran compiler, and if the first 2161# program named f77 (say) in your path is a script which deletes all 2162# your files, that's nothing to do with us.... 2163# 2164# A proper fix would involve being able to go back and try another compiler 2165# if the first one fails, but that requires a major reworking of much of 2166# autoconf. The same problem arises (with no easy solution) on some Digital 2167# compilers: f95 fails on .F files, f90 succeeds. 2168# 2169# Also, in case it's not obvious, this macro can be called only once: we 2170# presume that multiple Fortran variants can be handled by a compiler which 2171# can handle the most recent one. If this is not the case -- either you need 2172# to give special flags to enable and disable the language features you use 2173# in different modules, or in the extreme case use different compilers for 2174# different files -- you're going to have to do something clever. 2175# 2176# FIXME At some point gfortran (as the official Gnu Fortran compiler) 2177# should be moved up to be the first choice. 2178# However, I don't think it's mature enough at the moment. 2179# 2180m4_define([_AC_F95_FC], [xlf95 lf95 f95 fort ifort ifc efc pgf95 pathf90 gfortran g95]) 2181m4_define([_AC_F90_FC], [f90 xlf90 pgf90 epcf90]) 2182m4_define([_AC_F77_FC], [g77 f77 xlf frt pgf77 fort77 fl32 af77]) 2183AC_DEFUN([_AC_PROG_FC], 2184[_AC_FORTRAN_ASSERT()dnl 2185AC_CHECK_TOOLS([]_AC_FC[], 2186 m4_default([$2], 2187 m4_case(_AC_FC_DIALECT_YEAR([$1]), 2188 [1995], [_AC_F95_FC], 2189 [1990], [_AC_F90_FC _AC_F95_FC], 2190 [1977], [_AC_F77_FC _AC_F90_FC _AC_F95_FC], 2191 [_AC_F95_FC _AC_F90_FC _AC_F77_FC]))) 2192 2193# Provide some information about the compiler. 2194echo "$as_me:__oline__:" \ 2195 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD 2196ac_compiler=`set X $ac_compile; echo $[2]` 2197_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD]) 2198_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD]) 2199_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD]) 2200rm -f a.out 2201 2202m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl 2203m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl 2204# If we don't use `.F' as extension, the preprocessor is not run on the 2205# input file. (Note that this only needs to work for GNU compilers.) 2206ac_save_ext=$ac_ext 2207ac_ext=F 2208_AC_LANG_COMPILER_GNU 2209ac_ext=$ac_save_ext 2210_AC_PROG_FC_G 2211])# _AC_PROG_FC 2212 2213# AC_FC_MOD_SUFFIX 2214# ----------------- 2215# Determines the form of the filename of modules produced 2216# by the Fortran compiler. 2217# Tests for all forms of file extension I've (TOHW) found in the 2218# wild. Note that at least one compiler (PGI??) changes the 2219# case of the basename as well. Whether this happens is 2220# encoded in the variable ac_fc_mod_uppercase. 2221# 2222# This macro depends, of course, on the Fortran compiler producing 2223# module files. See comment to AC_FC_MOD_PATH_FLAG. 2224# 2225# FIXME: This will fail if an F77-only compiler is used. 2226# Currently we warn and continue. We should maybe error out. 2227# 2228AC_DEFUN([AC_FC_MOD_SUFFIX], 2229[ 2230cat > conftest.$ac_ext << \_ACEOF 2231 module conftest 2232 implicit none 2233 integer :: i 2234 end module conftest 2235_ACEOF 2236_AC_EVAL_STDERR($ac_compile) 2237AC_MSG_CHECKING([for suffix of module files]) 2238for ac_mod_file in conftest.mod conftest.MOD conftest.M CONFTEST.MOD CONFTEST.mod none 2239do 2240 if test -f $ac_mod_file; then 2241 break; 2242 fi 2243done 2244rm -f conftest.$ac_ext conftest.$ac_exe_ext conftest.mod conftest.MOD conftest.M CONFTEST.MOD CONFTEST.mod 2245# 2246FC_MODEXT= 2247FC_MODUPPERCASE=no 2248case $ac_mod_file in 2249 conftest.mod) 2250 FC_MODEXT=mod 2251 ;; 2252 conftest.MOD) 2253 FC_MODEXT=MOD 2254 ;; 2255 conftest.M) 2256 FC_MODEXT=M 2257 ;; 2258 CONFTEST.MOD) 2259 FC_MODEXT=MOD 2260 FC_MODUPPERCASE=yes 2261 ;; 2262 CONFTEST.mod) 2263 FC_MODEXT=mod 2264 FC_MODUPPERCASE=yes 2265 ;; 2266 none) 2267 AC_MSG_WARN([Could not find Fortran module file extension.]) 2268 ;; 2269esac 2270 2271AC_MSG_RESULT([$FC_MODEXT]) 2272AC_MSG_CHECKING([whether module filenames are uppercased]) 2273AC_MSG_RESULT([$FC_MODUPPERCASE]) 2274 2275AC_SUBST(FC_MODEXT) 2276AC_SUBST(FC_MODUPPERCASE) 2277])# AC_FC_MOD_SUFFIX 2278 2279 2280# AC_PROG_F77([COMPILERS...]) 2281# --------------------------- 2282# COMPILERS is a space separated list of Fortran 77 compilers to search 2283# for. See also _AC_PROG_FC. 2284AC_DEFUN([AC_PROG_F77], 2285[AC_LANG_PUSH(Fortran 77)dnl 2286AC_ARG_VAR([F77], [Fortran 77 compiler command])dnl 2287AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl 2288_AC_ARG_VAR_LDFLAGS()dnl 2289_AC_PROG_FC([Fortran 77], [$1]) 2290G77=`test $ac_compiler_gnu = yes && echo yes` 2291AC_LANG_POP(Fortran 77)dnl 2292])# AC_PROG_F77 2293 2294 2295# AC_PROG_FC([COMPILERS...], [DIALECT]) 2296# ------------------------------------- 2297# COMPILERS is a space separated list of Fortran 77 compilers to search 2298# for, and [DIALECT] is an optional dialect. See also _AC_PROG_FC. 2299AC_DEFUN([AC_PROG_FC], 2300[AC_BEFORE([$0], [AC_PROG_FPP])dnl 2301AC_LANG_PUSH(Fortran)dnl 2302AC_ARG_VAR([FC], [Fortran compiler command])dnl 2303AC_ARG_VAR([FCFLAGS], [Fortran compiler flags])dnl 2304_AC_ARG_VAR_LDFLAGS()dnl 2305_AC_PROG_FC([$2], [$1]) 2306AC_LANG_POP(Fortran)dnl 2307])# AC_PROG_FC 2308 2309 2310# _AC_PROG_FC_G 2311# ------------- 2312# Check whether -g works, even if F[C]FLAGS is set, in case the package 2313# plays around with F[C]FLAGS (such as to build both debugging and normal 2314# versions of a library), tasteless as that idea is. 2315m4_define([_AC_PROG_FC_G], 2316[_AC_FORTRAN_ASSERT()dnl 2317ac_test_FFLAGS=${[]_AC_LANG_PREFIX[]FLAGS+set} 2318ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS 2319_AC_LANG_PREFIX[]FLAGS= 2320AC_CACHE_CHECK(whether $[]_AC_FC[] accepts -g, ac_cv_prog_[]_AC_LANG_ABBREV[]_g, 2321[_AC_LANG_PREFIX[]FLAGS=-g 2322_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 2323[ac_cv_prog_[]_AC_LANG_ABBREV[]_g=yes], 2324[ac_cv_prog_[]_AC_LANG_ABBREV[]_g=no]) 2325]) 2326if test "$ac_test_FFLAGS" = set; then 2327 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS 2328elif test $ac_cv_prog_[]_AC_LANG_ABBREV[]_g = yes; then 2329 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then 2330 _AC_LANG_PREFIX[]FLAGS="-g -O2" 2331 else 2332 _AC_LANG_PREFIX[]FLAGS="-g" 2333 fi 2334else 2335 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then 2336 _AC_LANG_PREFIX[]FLAGS="-O2" 2337 else 2338 _AC_LANG_PREFIX[]FLAGS= 2339 fi 2340fi[]dnl 2341])# _AC_PROG_FC_G 2342 2343 2344# _AC_PROG_FC_C_O 2345# --------------- 2346# Test if the Fortran compiler accepts the options `-c' and `-o' 2347# simultaneously, and define `[F77/FC]_NO_MINUS_C_MINUS_O' if it does not. 2348# 2349# The usefulness of this macro is questionable, as I can't really see 2350# why anyone would use it. The only reason I include it is for 2351# completeness, since a similar test exists for the C compiler. 2352# 2353# FIXME: it seems like we could merge the C/Fortran versions of this. 2354AC_DEFUN([_AC_PROG_FC_C_O], 2355[_AC_FORTRAN_ASSERT()dnl 2356AC_CACHE_CHECK([whether $[]_AC_FC[] understands -c and -o together], 2357 [ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o], 2358[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) 2359# We test twice because some compilers refuse to overwrite an existing 2360# `.o' file with `-o', although they will create one. 2361ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD' 2362if AC_TRY_EVAL(ac_try) && 2363 test -f conftest.$ac_objext && 2364 AC_TRY_EVAL(ac_try); then 2365 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=yes 2366else 2367 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=no 2368fi 2369rm -f conftest*]) 2370if test $ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o = no; then 2371 AC_DEFINE([]_AC_FC[]_NO_MINUS_C_MINUS_O, 1, 2372 [Define to 1 if your Fortran compiler doesn't accept 2373 -c and -o together.]) 2374fi 2375])# _AC_PROG_FC_C_O 2376 2377 2378# AC_PROG_F77_C_O 2379# --------------- 2380AC_DEFUN([AC_PROG_F77_C_O], 2381[AC_REQUIRE([AC_PROG_F77])dnl 2382AC_LANG_PUSH(Fortran 77)dnl 2383_AC_PROG_FC_C_O 2384AC_LANG_POP(Fortran 77)dnl 2385])# AC_PROG_F77_C_O 2386 2387 2388# AC_PROG_FC_C_O 2389# --------------- 2390AC_DEFUN([AC_PROG_FC_C_O], 2391[AC_REQUIRE([AC_PROG_FC])dnl 2392AC_LANG_PUSH(Fortran)dnl 2393_AC_PROG_FC_C_O 2394AC_LANG_POP(Fortran)dnl 2395])# AC_PROG_FC_C_O 2396 2397 2398## ------------------------------- ## 2399## 4. Compilers' characteristics. ## 2400## ------------------------------- ## 2401 2402 2403# ---------------------------------------- # 2404# 4d. Fortran 77 compiler characteristics. # 2405# ---------------------------------------- # 2406 2407 2408# _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v]) 2409# ------------------------------------------------- 2410# Link a trivial Fortran program, compiling with a verbose output FLAG 2411# (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by 2412# _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output. This 2413# output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS, 2414# so that any link flags that are echoed by the compiler appear as 2415# space-separated items. 2416AC_DEFUN([_AC_PROG_FC_V_OUTPUT], 2417[_AC_FORTRAN_ASSERT()dnl 2418AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) 2419 2420# Compile and link our simple test program by passing a flag (argument 2421# 1 to this macro) to the Fortran compiler in order to get 2422# "verbose" output that we can then parse for the Fortran linker 2423# flags. 2424ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS 2425_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])" 2426(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD 2427ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'` 2428echo "$ac_[]_AC_LANG_ABBREV[]_v_output" >&AS_MESSAGE_LOG_FD 2429_AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS 2430 2431rm -f conftest* 2432 2433# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where 2434# /foo, /bar, and /baz are search directories for the Fortran linker. 2435# Here, we change these into -L/foo -L/bar -L/baz (and put it first): 2436ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output | 2437 grep 'LPATH is:' | 2438 sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output" 2439 2440case $ac_[]_AC_LANG_ABBREV[]_v_output in 2441 # If we are using xlf then replace all the commas with spaces. 2442 *xlfentry*) 2443 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'` ;; 2444 2445 # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted 2446 # $LIBS confuse us, and the libraries appear later in the output anyway). 2447 *mGLOB_options_string*) 2448 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/\"-mGLOB[[^\"]]*\"/ /g'` ;; 2449 2450 # If we are using Cray Fortran then delete quotes. 2451 # Use "\"" instead of '"' for font-lock-mode. 2452 # FIXME: a more general fix for quoted arguments with spaces? 2453 *cft90*) 2454 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "s/\"//g"` ;; 2455esac 2456 2457])# _AC_PROG_FC_V_OUTPUT 2458 2459 2460# _AC_PROG_FC_V 2461# -------------- 2462# 2463# Determine the flag that causes the Fortran compiler to print 2464# information of library and object files (normally -v) 2465# Needed for _AC_FC_LIBRARY_FLAGS 2466# Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###) 2467AC_DEFUN([_AC_PROG_FC_V], 2468[_AC_FORTRAN_ASSERT()dnl 2469AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]], 2470 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v], 2471[AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 2472[ac_cv_prog_[]_AC_LANG_ABBREV[]_v= 2473# Try some options frequently used verbose output 2474for ac_verb in -v -verbose --verbose -V -\#\#\#; do 2475 _AC_PROG_FC_V_OUTPUT($ac_verb) 2476 # look for -l* and *.a constructs in the output 2477 for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do 2478 case $ac_arg in 2479 [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*) 2480 ac_cv_prog_[]_AC_LANG_ABBREV[]_v=$ac_verb 2481 break 2 ;; 2482 esac 2483 done 2484done 2485if test -z "$ac_cv_prog_[]_AC_LANG_ABBREV[]_v"; then 2486 AC_MSG_WARN([cannot determine how to obtain linking information from $[]_AC_FC[]]) 2487fi], 2488 [AC_MSG_WARN([compilation failed])]) 2489])])# _AC_PROG_FC_V 2490 2491 2492# _AC_FC_LIBRARY_LDFLAGS 2493# ---------------------- 2494# 2495# Determine the linker flags (e.g. "-L" and "-l") for the Fortran 2496# intrinsic and run-time libraries that are required to successfully 2497# link a Fortran program or shared library. The output variable 2498# FLIBS/FCLIBS is set to these flags. 2499# 2500# This macro is intended to be used in those situations when it is 2501# necessary to mix, e.g. C++ and Fortran, source code into a single 2502# program or shared library. 2503# 2504# For example, if object files from a C++ and Fortran compiler must 2505# be linked together, then the C++ compiler/linker must be used for 2506# linking (since special C++-ish things need to happen at link time 2507# like calling global constructors, instantiating templates, enabling 2508# exception support, etc.). 2509# 2510# However, the Fortran intrinsic and run-time libraries must be 2511# linked in as well, but the C++ compiler/linker doesn't know how to 2512# add these Fortran libraries. Hence, the macro 2513# "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran 2514# libraries. 2515# 2516# This macro was packaged in its current form by Matthew D. Langston. 2517# However, nearly all of this macro came from the "OCTAVE_FLIBS" macro 2518# in "octave-2.0.13/aclocal.m4", and full credit should go to John 2519# W. Eaton for writing this extremely useful macro. Thank you John. 2520AC_DEFUN([_AC_FC_LIBRARY_LDFLAGS], 2521[_AC_FORTRAN_ASSERT()dnl 2522_AC_PROG_FC_V 2523AC_CACHE_CHECK([for Fortran libraries of $[]_AC_FC[]], ac_cv_[]_AC_LANG_ABBREV[]_libs, 2524[if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then 2525 ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test. 2526else 2527 2528_AC_PROG_FC_V_OUTPUT 2529 2530ac_cv_[]_AC_LANG_ABBREV[]_libs= 2531 2532# Save positional arguments (if any) 2533ac_save_positional="$[@]" 2534 2535set X $ac_[]_AC_LANG_ABBREV[]_v_output 2536while test $[@%:@] != 1; do 2537 shift 2538 ac_arg=$[1] 2539 case $ac_arg in 2540 [[\\/]]*.a | ?:[[\\/]]*.a) 2541 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, , 2542 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg") 2543 ;; 2544 -bI:*) 2545 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, , 2546 [_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)]) 2547 ;; 2548 # Ignore these flags. 2549 -lang* | -lcrt*.o | -lc | -lgcc | -libmil | -LANG:=*) 2550 ;; 2551 -lkernel32) 2552 test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg" 2553 ;; 2554 -[[LRuY]]) 2555 # These flags, when seen by themselves, take an argument. 2556 # We remove the space between option and argument and re-iterate 2557 # unless we find an empty arg or a new option (starting with -) 2558 case $[2] in 2559 "" | -*);; 2560 *) 2561 ac_arg="$ac_arg$[2]" 2562 shift; shift 2563 set X $ac_arg "$[@]" 2564 ;; 2565 esac 2566 ;; 2567 -YP,*) 2568 for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do 2569 _AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, , 2570 [ac_arg="$ac_arg $ac_j" 2571 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"]) 2572 done 2573 ;; 2574 -[[lLR]]*) 2575 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, , 2576 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg") 2577 ;; 2578 # Ignore everything else. 2579 esac 2580done 2581# restore positional arguments 2582set X $ac_save_positional; shift 2583 2584# We only consider "LD_RUN_PATH" on Solaris systems. If this is seen, 2585# then we insist that the "run path" must be an absolute path (i.e. it 2586# must begin with a "/"). 2587case `(uname -sr) 2>/dev/null` in 2588 "SunOS 5"*) 2589 ac_ld_run_path=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | 2590 sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'` 2591 test "x$ac_ld_run_path" != x && 2592 _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs) 2593 ;; 2594esac 2595fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x" 2596]) 2597[]_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs" 2598AC_SUBST([]_AC_LANG_PREFIX[]LIBS) 2599])# _AC_FC_LIBRARY_LDFLAGS 2600 2601 2602# AC_F77_LIBRARY_LDFLAGS 2603# ---------------------- 2604AC_DEFUN([AC_F77_LIBRARY_LDFLAGS], 2605[AC_REQUIRE([AC_PROG_F77])dnl 2606AC_LANG_PUSH(Fortran 77)dnl 2607_AC_FC_LIBRARY_LDFLAGS 2608AC_LANG_POP(Fortran 77)dnl 2609])# AC_F77_LIBRARY_LDFLAGS 2610 2611 2612# AC_FC_LIBRARY_LDFLAGS 2613# ---------------------- 2614AC_DEFUN([AC_FC_LIBRARY_LDFLAGS], 2615[AC_REQUIRE([AC_PROG_FC])dnl 2616AC_LANG_PUSH(Fortran)dnl 2617_AC_FC_LIBRARY_LDFLAGS 2618AC_LANG_POP(Fortran)dnl 2619])# AC_FC_LIBRARY_LDFLAGS 2620 2621 2622# _AC_FC_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 2623# ----------------------------------------------------------- 2624# 2625# Detect name of dummy main routine required by the Fortran libraries, 2626# (if any) and define {F77,FC}_DUMMY_MAIN to this name (which should be 2627# used for a dummy declaration, if it is defined). On some systems, 2628# linking a C program to the Fortran library does not work unless you 2629# supply a dummy function called something like MAIN__. 2630# 2631# Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C 2632# program with the {F77,FC} libs is found; default to exiting with an error 2633# message. Execute ACTION-IF-FOUND if a dummy routine name is needed 2634# and found or if it is not needed (default to defining {F77,FC}_DUMMY_MAIN 2635# when needed). 2636# 2637# What is technically happening is that the Fortran libraries provide 2638# their own main() function, which usually initializes Fortran I/O and 2639# similar stuff, and then calls MAIN__, which is the entry point of 2640# your program. Usually, a C program will override this with its own 2641# main() routine, but the linker sometimes complain if you don't 2642# provide a dummy (never-called) MAIN__ routine anyway. 2643# 2644# Of course, programs that want to allow Fortran subroutines to do 2645# I/O, etcetera, should call their main routine MAIN__() (or whatever) 2646# instead of main(). A separate autoconf test (_AC_FC_MAIN) checks 2647# for the routine to use in this case (since the semantics of the test 2648# are slightly different). To link to e.g. purely numerical 2649# libraries, this is normally not necessary, however, and most C/C++ 2650# programs are reluctant to turn over so much control to Fortran. =) 2651# 2652# The name variants we check for are (in order): 2653# MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional) 2654# MAIN_, __main (SunOS) 2655# MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too) 2656AC_DEFUN([_AC_FC_DUMMY_MAIN], 2657[_AC_FORTRAN_ASSERT()dnl 2658m4_define(_AC_LANG_PROGRAM_C_[]_AC_FC[]_HOOKS, 2659[#ifdef ]_AC_FC[_DUMMY_MAIN 2660]AC_LANG_CASE([Fortran], [#ifndef FC_DUMMY_MAIN_EQ_F77]) 2661[# ifdef __cplusplus 2662 extern "C" 2663# endif 2664 int ]_AC_FC[_DUMMY_MAIN() { return 1; } 2665]AC_LANG_CASE([Fortran], [#endif]) 2666[#endif 2667]) 2668AC_CACHE_CHECK([for dummy main to link with Fortran libraries], 2669 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main, 2670[ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS=$LIBS 2671 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS" 2672 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN 2673 AC_LANG_PUSH(C)dnl 2674 2675 # First, try linking without a dummy main: 2676 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], 2677 [ac_cv_fortran_dummy_main=none], 2678 [ac_cv_fortran_dummy_main=unknown]) 2679 2680 if test $ac_cv_fortran_dummy_main = unknown; then 2681 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do 2682 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@define $ac_fortran_dm_var $ac_func]])], 2683 [ac_cv_fortran_dummy_main=$ac_func; break]) 2684 done 2685 fi 2686 AC_LANG_POP(C)dnl 2687 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main=$ac_cv_fortran_dummy_main 2688 rm -f conftest* 2689 LIBS=$ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS 2690]) 2691[]_AC_FC[]_DUMMY_MAIN=$ac_cv_[]_AC_LANG_ABBREV[]_dummy_main 2692AS_IF([test "$[]_AC_FC[]_DUMMY_MAIN" != unknown], 2693 [m4_default([$1], 2694[if test $[]_AC_FC[]_DUMMY_MAIN != none; then 2695 AC_DEFINE_UNQUOTED([]_AC_FC[]_DUMMY_MAIN, $[]_AC_FC[]_DUMMY_MAIN, 2696 [Define to dummy `main' function (if any) required to 2697 link to the Fortran libraries.]) 2698 if test "x$ac_cv_fc_dummy_main" = "x$ac_cv_f77_dummy_main"; then 2699 AC_DEFINE([FC_DUMMY_MAIN_EQ_F77], 1, 2700 [Define if F77 and FC dummy `main' functions are identical.]) 2701 fi 2702fi])], 2703 [m4_default([$2], 2704 [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])]) 2705])# _AC_FC_DUMMY_MAIN 2706 2707 2708# AC_F77_DUMMY_MAIN 2709# ---------------------- 2710AC_DEFUN([AC_F77_DUMMY_MAIN], 2711[AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl 2712AC_LANG_PUSH(Fortran 77)dnl 2713_AC_FC_DUMMY_MAIN 2714AC_LANG_POP(Fortran 77)dnl 2715])# AC_F77_DUMMY_MAIN 2716 2717 2718# AC_FC_DUMMY_MAIN 2719# ---------------------- 2720AC_DEFUN([AC_FC_DUMMY_MAIN], 2721[AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl 2722AC_LANG_PUSH(Fortran)dnl 2723_AC_FC_DUMMY_MAIN 2724AC_LANG_POP(Fortran)dnl 2725])# AC_FC_DUMMY_MAIN 2726 2727 2728# _AC_FC_MAIN 2729# ----------- 2730# Define {F77,FC}_MAIN to name of alternate main() function for use with 2731# the Fortran libraries. (Typically, the libraries may define their 2732# own main() to initialize I/O, etcetera, that then call your own 2733# routine called MAIN__ or whatever.) See _AC_FC_DUMMY_MAIN, above. 2734# If no such alternate name is found, just define {F77,FC}_MAIN to main. 2735# 2736AC_DEFUN([_AC_FC_MAIN], 2737[_AC_FORTRAN_ASSERT()dnl 2738AC_CACHE_CHECK([for alternate main to link with Fortran libraries], 2739 ac_cv_[]_AC_LANG_ABBREV[]_main, 2740[ac_[]_AC_LANG_ABBREV[]_m_save_LIBS=$LIBS 2741 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS" 2742 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN 2743 AC_LANG_PUSH(C)dnl 2744 ac_cv_fortran_main="main" # default entry point name 2745 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do 2746 AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@ifdef FC_DUMMY_MAIN_EQ_F77 2747@%:@ undef F77_DUMMY_MAIN 2748@%:@ undef FC_DUMMY_MAIN 2749@%:@else 2750@%:@ undef $ac_fortran_dm_var 2751@%:@endif 2752@%:@define main $ac_func])], 2753 [ac_cv_fortran_main=$ac_func; break]) 2754 done 2755 AC_LANG_POP(C)dnl 2756 ac_cv_[]_AC_LANG_ABBREV[]_main=$ac_cv_fortran_main 2757 rm -f conftest* 2758 LIBS=$ac_[]_AC_LANG_ABBREV[]_m_save_LIBS 2759]) 2760if test "$ac_cv_[]_AC_LANG_ABBREV[]_main" = main; then 2761 AC_DEFINE([]_AC_FC[]_MAIN_IS_MAIN, 1, [True when Fortran main is C main]) 2762fi 2763AC_DEFINE_UNQUOTED([]_AC_FC[]_MAIN, $ac_cv_[]_AC_LANG_ABBREV[]_main, 2764 [Define to alternate name for `main' routine that is 2765 called from a `main' in the Fortran libraries.]) 2766])# _AC_FC_MAIN 2767 2768 2769# AC_F77_MAIN 2770# ----------- 2771AC_DEFUN([AC_F77_MAIN], 2772[AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl 2773AC_LANG_PUSH(Fortran 77)dnl 2774_AC_FC_MAIN 2775AC_LANG_POP(Fortran 77)dnl 2776])# AC_F77_MAIN 2777 2778 2779# AC_FC_MAIN 2780# ---------- 2781AC_DEFUN([AC_FC_MAIN], 2782[AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl 2783AC_LANG_PUSH(Fortran)dnl 2784_AC_FC_MAIN 2785AC_LANG_POP(Fortran)dnl 2786])# AC_FC_MAIN 2787 2788 2789# __AC_FC_NAME_MANGLING 2790# --------------------- 2791# Test for the name mangling scheme used by the Fortran compiler. 2792# 2793# Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated 2794# by commas: 2795# 2796# lower case / upper case: 2797# case translation of the Fortran symbols 2798# underscore / no underscore: 2799# whether the compiler appends "_" to symbol names 2800# extra underscore / no extra underscore: 2801# whether the compiler appends an extra "_" to symbol names already 2802# containing at least one underscore 2803# 2804AC_DEFUN([__AC_FC_NAME_MANGLING], 2805[_AC_FORTRAN_ASSERT()dnl 2806AC_CACHE_CHECK([for Fortran name-mangling scheme], 2807 ac_cv_[]_AC_LANG_ABBREV[]_mangling, 2808[AC_COMPILE_IFELSE( 2809[ subroutine foobar() 2810 return 2811 end 2812 subroutine foo_bar() 2813 return 2814 end], 2815[mv conftest.$ac_objext cfortran_test.$ac_objext 2816 2817 ac_save_LIBS=$LIBS 2818 LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS" 2819 2820 AC_LANG_PUSH(C)dnl 2821 ac_success=no 2822 for ac_foobar in foobar FOOBAR; do 2823 for ac_underscore in "" "_"; do 2824 ac_func="$ac_foobar$ac_underscore" 2825 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])], 2826 [ac_success=yes; break 2]) 2827 done 2828 done 2829 AC_LANG_POP(C)dnl 2830 2831 if test "$ac_success" = "yes"; then 2832 case $ac_foobar in 2833 foobar) 2834 ac_case=lower 2835 ac_foo_bar=foo_bar 2836 ;; 2837 FOOBAR) 2838 ac_case=upper 2839 ac_foo_bar=FOO_BAR 2840 ;; 2841 esac 2842 2843 AC_LANG_PUSH(C)dnl 2844 ac_success_extra=no 2845 for ac_extra in "" "_"; do 2846 ac_func="$ac_foo_bar$ac_underscore$ac_extra" 2847 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])], 2848 [ac_success_extra=yes; break]) 2849 done 2850 AC_LANG_POP(C)dnl 2851 2852 if test "$ac_success_extra" = "yes"; then 2853 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case" 2854 if test -z "$ac_underscore"; then 2855 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore" 2856 else 2857 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore" 2858 fi 2859 if test -z "$ac_extra"; then 2860 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore" 2861 else 2862 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore" 2863 fi 2864 else 2865 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown" 2866 fi 2867 else 2868 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown" 2869 fi 2870 2871 LIBS=$ac_save_LIBS 2872 rm -f cfortran_test* conftest*], 2873 [AC_MSG_FAILURE([cannot compile a simple Fortran program])]) 2874]) 2875])# __AC_FC_NAME_MANGLING 2876 2877# The replacement is empty. 2878AU_DEFUN([AC_F77_NAME_MANGLING], []) 2879 2880 2881# _AC_F77_NAME_MANGLING 2882# ---------------------- 2883AC_DEFUN([_AC_F77_NAME_MANGLING], 2884[AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl 2885AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl 2886AC_LANG_PUSH(Fortran 77)dnl 2887__AC_FC_NAME_MANGLING 2888AC_LANG_POP(Fortran 77)dnl 2889])# _AC_F77_NAME_MANGLING 2890 2891 2892# _AC_FC_NAME_MANGLING 2893# ---------------------- 2894AC_DEFUN([_AC_FC_NAME_MANGLING], 2895[AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl 2896AC_REQUIRE([AC_FC_DUMMY_MAIN])dnl 2897AC_LANG_PUSH(Fortran)dnl 2898__AC_FC_NAME_MANGLING 2899AC_LANG_POP(Fortran)dnl 2900])# _AC_FC_NAME_MANGLING 2901 2902 2903# _AC_FC_WRAPPERS 2904# --------------- 2905# Defines C macros {F77,FC}_FUNC(name,NAME) and {F77,FC}_FUNC_(name,NAME) to 2906# properly mangle the names of C identifiers, and C identifiers with 2907# underscores, respectively, so that they match the name mangling 2908# scheme used by the Fortran compiler. 2909AC_DEFUN([_AC_FC_WRAPPERS], 2910[_AC_FORTRAN_ASSERT()dnl 2911AH_TEMPLATE(_AC_FC[_FUNC], 2912 [Define to a macro mangling the given C identifier (in lower and upper 2913 case), which must not contain underscores, for linking with Fortran.])dnl 2914AH_TEMPLATE(_AC_FC[_FUNC_], 2915 [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl 2916case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in 2917 "lower case, no underscore, no extra underscore") 2918 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name]) 2919 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;; 2920 "lower case, no underscore, extra underscore") 2921 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name]) 2922 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;; 2923 "lower case, underscore, no extra underscore") 2924 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _]) 2925 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;; 2926 "lower case, underscore, extra underscore") 2927 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _]) 2928 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;; 2929 "upper case, no underscore, no extra underscore") 2930 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME]) 2931 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;; 2932 "upper case, no underscore, extra underscore") 2933 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME]) 2934 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;; 2935 "upper case, underscore, no extra underscore") 2936 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _]) 2937 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;; 2938 "upper case, underscore, extra underscore") 2939 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _]) 2940 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;; 2941 *) 2942 AC_MSG_WARN([unknown Fortran name-mangling scheme]) 2943 ;; 2944esac 2945])# _AC_FC_WRAPPERS 2946 2947 2948# AC_F77_WRAPPERS 2949# --------------- 2950AC_DEFUN([AC_F77_WRAPPERS], 2951[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl 2952AC_LANG_PUSH(Fortran 77)dnl 2953_AC_FC_WRAPPERS 2954AC_LANG_POP(Fortran 77)dnl 2955])# AC_F77_WRAPPERS 2956 2957 2958# AC_FC_WRAPPERS 2959# -------------- 2960AC_DEFUN([AC_FC_WRAPPERS], 2961[AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl 2962AC_LANG_PUSH(Fortran)dnl 2963_AC_FC_WRAPPERS 2964AC_LANG_POP(Fortran)dnl 2965])# AC_FC_WRAPPERS 2966 2967 2968# _AC_FC_FUNC(NAME, [SHELLVAR = NAME]) 2969# ------------------------------------ 2970# For a Fortran subroutine of given NAME, define a shell variable 2971# $SHELLVAR to the Fortran-mangled name. If the SHELLVAR 2972# argument is not supplied, it defaults to NAME. 2973AC_DEFUN([_AC_FC_FUNC], 2974[_AC_FORTRAN_ASSERT()dnl 2975case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in 2976 upper*) ac_val="m4_toupper([$1])" ;; 2977 lower*) ac_val="m4_tolower([$1])" ;; 2978 *) ac_val="unknown" ;; 2979esac 2980case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac 2981m4_if(m4_index([$1],[_]),-1,[], 2982[case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac 2983]) 2984m4_default([$2],[$1])="$ac_val" 2985])# _AC_FC_FUNC 2986 2987 2988# AC_F77_FUNC(NAME, [SHELLVAR = NAME]) 2989# ------------------------------------ 2990AC_DEFUN([AC_F77_FUNC], 2991[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl 2992AC_LANG_PUSH(Fortran 77)dnl 2993_AC_FC_FUNC([$1],[$2]) 2994AC_LANG_POP(Fortran 77)dnl 2995])# AC_F77_FUNC 2996 2997 2998# AC_FC_FUNC(NAME, [SHELLVAR = NAME]) 2999# ----------------------------------- 3000AC_DEFUN([AC_FC_FUNC], 3001[AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl 3002AC_LANG_PUSH(Fortran)dnl 3003_AC_FC_FUNC([$1],[$2]) 3004AC_LANG_POP(Fortran)dnl 3005])# AC_FC_FUNC 3006 3007 3008# AC_FC_SRCEXT(EXT, [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE]) 3009# ----------------------------------------------------------- 3010# Set the source-code extension used in Fortran (FC) tests to EXT (which 3011# defaults to f). Also, look for any necessary additional FCFLAGS needed 3012# to allow this extension, and store them in the output variable 3013# FCFLAGS_<EXT> (e.g. FCFLAGS_f90 for EXT=f90). If successful, 3014# call ACTION-IF-SUCCESS. If unable to compile source code with EXT, 3015# call ACTION-IF-FAILURE, which defaults to failing with an error 3016# message. 3017# 3018# (The flags for the current source-code extension, if any, are stored 3019# in the FCFLAGS_SRCEXT variable and are automatically used in subsequent 3020# autoconf tests.) 3021# 3022# For ordinary extensions like f90, etcetera, the modified FCFLAGS 3023# are currently needed for IBM's xlf* and Intel's ifc (grrr). Unfortunately, 3024# xlf* will only take flags to recognize one extension at a time, so if the 3025# user wants to compile multiple extensions (.f90 and .f95, say), she 3026# will need to use the FCFLAGS_F90 and FCFLAGS_F95 individually rather 3027# than just adding them all to FCFLAGS, for example. 3028# 3029# Also, for Intel's ifc compiler (which does not accept .f95 by default in 3030# some versions), the $FCFLAGS_<EXT> variable *must* go immediately before 3031# the source file on the command line, unlike other $FCFLAGS. Ugh. 3032AC_DEFUN([AC_FC_SRCEXT], 3033[AC_LANG_PUSH([Fortran])dnl 3034AC_MSG_WARN([AC@&t@_FC@&t@_SRCEXT is deprecated. Use AC@&t@_FC_FIXEDFORM([srcext]) or AC@&t@_FC_FREEFORM([srcext]) as appropriate.]) 3035AC_CACHE_CHECK([for Fortran flag to compile .$1 files], 3036 ac_cv_fc_srcext_$1, 3037[ac_ext=$1 3038ac_fc_srcext_FCFLAGS_SRCEXT_save=$FCFLAGS_SRCEXT 3039FCFLAGS_SRCEXT="" 3040ac_cv_fc_srcext_$1=unknown 3041for ac_flag in none -qsuffix=f=$1 -Tf; do 3042 test "x$ac_flag" != xnone && FCFLAGS_SRCEXT="$ac_flag" 3043 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_fc_srcext_$1=$ac_flag; break]) 3044done 3045rm -f conftest.$ac_objext conftest.$1 3046FCFLAGS_SRCEXT=$ac_fc_srcext_FCFLAGS_SRCEXT_save 3047]) 3048if test "x$ac_cv_fc_srcext_$1" = xunknown; then 3049 m4_default([$3],[AC_MSG_ERROR([Fortran could not compile .$1 files])]) 3050else 3051 FC_SRCEXT=$1 3052 if test "x$ac_cv_fc_srcext_$1" = xnone; then 3053 FCFLAGS_SRCEXT="" 3054 FCFLAGS_[]$1[]="$FCFLAGS_[]$1[]" 3055 else 3056 FCFLAGS_SRCEXT=$ac_cv_fc_srcext_$1 3057 FCFLAGS_[]$1[]="$FCFLAGS_[]$1[] $ac_cv_fc_srcext_$1" 3058 fi 3059 AC_SUBST(FCFLAGS_[]$1) 3060 $2 3061fi 3062AC_LANG_POP([Fortran])dnl 3063])# AC_FC_SRCEXT 3064 3065 3066# -------------- # 3067# Utility macros # 3068# -------------- # 3069 3070# AC_FC_FIXEDFORM([SRCEXT], [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE]) 3071# ------------------------------------------------------------------- 3072# Look for compiler flags to make the Fortran (FC) compiler accept 3073# fixed-format source code, with a source extension of SRCEXT, 3074# and puts any necessary flags in FCFLAGS_fixed_<SRCEXT>. Call 3075# ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can 3076# compile fixed-format code using new extension) and ACTION-IF-FAILURE 3077# (defaults to failing with an error message) if not. 3078# 3079# The known flags are: 3080# -FI: Intel compiler (icc, ecc) 3081# -qfixed: IBM compiler (xlf) 3082# -fixed: NAG compiler 3083# -Mnofree: PGI compiler 3084# We try to test the "more popular" flags first, by some prejudiced 3085# notion of popularity. 3086AC_DEFUN([AC_FC_FIXEDFORM], 3087[AC_REQUIRE([AC_PROG_FC]) 3088AC_LANG_PUSH([Fortran])dnl 3089AC_CACHE_CHECK([for Fortran flag needed to allow fixed-form source for .$1 suffix], 3090 ac_cv_fc_fixedform_$1, 3091[ac_cv_fc_fixedform_$1=unknown 3092ac_ext=$1 3093ac_fc_fixedform_FCFLAGS_save=$FCFLAGS 3094for ac_flag in none -FI "-qfixed -qsuffix=cpp=$ac_ext" -fixed --fix -Mnofree 3095do 3096 test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_fixedform_FCFLAGS_save $ac_flag" 3097 AC_COMPILE_IFELSE([ 3098 PROGRAM FIXEDFORM 3099C THIS COMMENT SHOULD CONFUSE FREEFORM COMPILERS 3100 PRI NT*, 'HELLO '// 3101 . 'WORLD.' 3102 ENDP ROGRAM 3103], 3104 [ac_cv_fc_fixedform_$1=$ac_flag; break]) 3105done 3106rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 3107FCFLAGS=$ac_fc_fixedform_FCFLAGS_save 3108]) 3109if test "x$ac_cv_fc_fixedform_$1" = xunknown; then 3110 m4_default([$3], 3111 [AC_MSG_ERROR([Cannot compile fixed-form source with .$1 suffix], 77)]) 3112else 3113 if test "x$ac_cv_fc_fixedform_$1" != xnone; then 3114 AC_SUBST(FCFLAGS_fixed_[]$1, "$ac_cv_fc_fixedform_$1") 3115 fi 3116 $2 3117fi 3118AC_LANG_POP([Fortran])dnl 3119])# AC_FC_FIXEDFORM 3120 3121 3122# AC_FC_FREEFORM([SRCEXT], [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE]) 3123# ------------------------------------------------------------------ 3124# Look for compiler flags to make the Fortran (FC) compiler accept 3125# free-format source code, with a source extension of SRCEXT, 3126# and puts any necessary flags in FCFLAGS_free_<SRCEXT>. Call 3127# ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can 3128# compile fixed-format code using new extension) and ACTION-IF-FAILURE 3129# (defaults to failing with an error message) if not. 3130# 3131# For backwards compatibility, this macro may be called without 3132# specifying SRCEXT, in which case, a default extension of f90 3133# is used. This usage is deprecated. 3134# 3135# The known flags are: 3136# -ffree-form: GNU g77 3137# -FR: Intel compiler (icc, ecc) 3138# -free: Compaq compiler (fort), NAG compiler 3139# -qfree -qsuffix=f=<SRCEXT>: IBM compiler (xlf) (generates a warning 3140# with recent versions) 3141# -qfree=f90 -qsuffix=f=<SRCEXT>: Newer xlf versions 3142# --nfix: Lahey compiler 3143# -Mfree, -Mfreeform: Portland Group compiler 3144# -freeform: SGI compiler 3145# -f free: Absoft Fortran 3146# We try to test the "more popular" flags first, by some prejudiced 3147# notion of popularity. 3148AC_DEFUN([AC_FC_FREEFORM], 3149[AC_REQUIRE([AC_PROG_FC]) 3150AC_LANG_PUSH([Fortran])dnl 3151dnl default _AC_EXT to 'f90', if no argument is given. 3152m4_define([_AC_EXT], m4_if($1, [], f90, $1))dnl 3153AC_CACHE_CHECK([for Fortran flag needed to allow free-form source for .]_AC_EXT[ suffix], 3154 ac_cv_fc_freeform_[]_AC_EXT, 3155[ac_cv_fc_freeform_[]_AC_EXT=unknown 3156ac_ext=_AC_EXT 3157ac_fc_freeform_FCFLAGS_save=$FCFLAGS 3158for ac_flag in none -ffree-form -FR -free "-qfree=f90" "-qfree=f90 -qsuffix=f=$ac_ext"\ 3159 -qfree "-qfree -qsuffix=f=$ac_ext" -Mfree -Mfreeform \ 3160 -freeform "-f free" --nfix 3161do 3162 test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag" 3163 AC_COMPILE_IFELSE([ 3164program freeform 3165! FIXME: how to best confuse non-freeform compilers? 3166print *, 'Hello ', & 3167'world.' 3168end program], 3169 [ac_cv_fc_freeform_[]_AC_EXT=$ac_flag; break]) 3170done 3171rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 3172FCFLAGS=$ac_fc_freeform_FCFLAGS_save 3173]) 3174if test "x$ac_cv_fc_freeform_[]_AC_EXT" = xunknown; then 3175 m4_default([$3], 3176 [AC_MSG_ERROR([Cannot compile free-form source with .]_AC_EXT[ suffix], 77)]) 3177else 3178 if test "x$ac_cv_fc_freeform_[]_AC_EXT" != xnone; then 3179dnl if the first argument was absent, then implement the old behaviour, 3180dnl and simply append to variable FCFLAGS 3181 m4_if($1, [], 3182 [FCFLAGS="$FCFLAGS $ac_cv_fc_freeform_[]_AC_EXT"], 3183 [AC_SUBST(FCFLAGS_free_[]_AC_EXT, "$ac_cv_fc_freeform_[]_AC_EXT")]) 3184 fi 3185 $2 3186fi 3187AC_LANG_POP([Fortran])dnl 3188])# AC_FC_FREEFORM 3189 3190 3191# _AC_FPP_FIXEDFORM_F 3192# ------------------- 3193# Related to AC_FPP_FIXEDFORM, but used only from _AC_PROG_FC_FPP. 3194# How do we directly compile a preprocessable .F file? 3195# This should be a no-op on all systems except those with case-sensitive 3196# filenames, and those which can't do direct compilation anyway. 3197# Do not put result into cached variable if it fails. 3198AC_DEFUN([_AC_FPP_FIXEDFORM_F],[ 3199ac_ext=F 3200ac_fpp_fixedform_FCFLAGS_save=$FCFLAGS 3201for ac_flag in none "/fpp" "-x f77-cpp-input" "-FI -cpp" "-qfixed -qsuffix=cpp=F" "-fixed -fpp" "-lfe \"-Cpp\" --fix" 3202do 3203 test "x$ac_flag" != xnone && FCFLAGS="$ac_fpp_fixedform_FCFLAGS_save $ac_flag" 3204 AC_COMPILE_IFELSE([ 3205 PROGRAM FIXEDFORM 3206C THIS COMMENT SHOULD CONFUSE FREEFORM COMPILERS 3207 PRI NT*, 'HELLO '// 3208 . 'WORLD.' 3209#ifdef OK2 3210 choke me 3211#endif 3212#ifndef OK 3213 ENDP ROGRAM 3214#endif 3215 ], 3216 [ac_cv_fpp_fixedform_F=$ac_flag; break]) 3217done 3218rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 3219FCFLAGS=$ac_fpp_fixedform_FCFLAGS_save 3220if test "x$ac_cv_fpp_fixedform_F" = x; then 3221 AC_MSG_WARN([Cannot compile fixed-form preprocessable Fortran with a .F extension.]) 3222else 3223 if test "$ac_cv_fpp_fixedform_F" != none; then 3224 FPPFLAGS_fixed_F="$ac_cv_fpp_fixedform_F" 3225 AC_SUBST(FPPFLAGS_fixed_F, "$ac_cv_fpp_fixedform_F") 3226 fi 3227fi 3228])# _AC_FPP_FIXEDFORM_F 3229 3230 3231# AC_FPP_FIXEDFORM([SRCEXT], [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE]) 3232# -------------------------------------------------------------------- 3233# Look for compiler flags to make the Fortran (FC) compiler accept 3234# preprocessed fixed-format source code, with a source extension of 3235# SRCEXT, and puts any necessary flags in FPPFLAGS_fixed_<SRCEXT>. 3236# Call ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can 3237# compile fixed-format code using new extension) and ACTION-IF-FAILURE 3238# (defaults to failing with an error message) if not. 3239# 3240# Mostly, this is applicable only when using direct compilation. 3241# However the macro also sets FPP_PREPROCESS_EXT and FPP_COMPILE_EXT, 3242# based on SRCEXT. SRCEXT can be either 'EXT' or 'EXT1:ext2'; in the 3243# first case, the preprocessor extension is 'EXT', and the compile 3244# extension 'ext' (ie, the preprocessor extension, lowercased); in the 3245# second, the preprocessor extension is 'EXT1' and the compile 3246# extension 'ext2'. 3247# 3248# The known flags are: 3249# -x f77-cpp-input: g77 3250# -FI -cpp: Intel compiler (ifort) 3251# -qfixed -qsuffix=cpp=<SRCEXT>: IBM compiler (xlf) 3252# -fixed -fpp: NAG compiler 3253# -lfe "-Cpp" --fix: Lahey compiler 3254# -Mnofree: PGI (no flag for preprocessing available) 3255# We try to test the "more popular" flags first, by some prejudiced 3256# notion of popularity. 3257# NB when updating this list of flags, also update those of the previous 3258# macro. 3259AC_DEFUN([AC_FPP_FIXEDFORM], 3260[AC_REQUIRE([AC_PROG_FPP]) 3261AC_LANG_PUSH([Fortran])dnl 3262dnl Extract preprocessor extension _ac_ppext from $1, part preceding any ':' 3263m4_define([_ac_ppext], m4_bpatsubst([$1], [:.*]))dnl 3264AC_CACHE_CHECK([for Fortran flag needed to allow preprocessed fixed-form source for ._ac_ppext suffix], 3265 ac_cv_fpp_fixedform_[]_ac_ppext, 3266[if test $ac_cv_fpp_build_rule = direct; then 3267 ac_cv_fpp_fixedform_[]_ac_ppext=unknown 3268 ac_ext=_ac_ppext 3269 ac_fpp_fixedform_FCFLAGS_save=$FCFLAGS 3270 for ac_flag in none "-x f77-cpp-input" "-FI -cpp" "-qfixed -qsuffix=cpp=_ac_ppext" "-fixed -fpp" "-lfe \"-Cpp\" --fix" 3271 do 3272 test "x$ac_flag" != xnone && FCFLAGS="$ac_fpp_fixedform_FCFLAGS_save $ac_flag" 3273 AC_COMPILE_IFELSE([ 3274 PROGRAM FIXEDFORM 3275C THIS COMMENT SHOULD CONFUSE FREEFORM COMPILERS 3276 PRI NT*, 'HELLO '// 3277 . 'WORLD.' 3278#ifndef OK 3279 ENDP ROGRAM 3280#endif 3281 ], 3282 [ac_cv_fpp_fixedform_[]_ac_ppext=$ac_flag; break]) 3283 done 3284 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 3285 FCFLAGS=$ac_fpp_fixedform_FCFLAGS_save 3286else 3287 ac_cv_fpp_fixedform_[]_ac_ppext=none 3288fi # test $ac_cv_fpp_build_rule = direct 3289]) 3290if test "x$ac_cv_fpp_fixedform_[]_ac_ppext" = xunknown; then 3291 m4_default([$3], 3292 [AC_MSG_ERROR([Cannot compile fixed-form source with ._ac_ppext suffix], 77)]) 3293else 3294 if test "x$ac_cv_fpp_fixedform_[]_ac_ppext" != xnone; then 3295 AC_SUBST(FPPFLAGS_fixed_[]_ac_ppext, "$ac_cv_fpp_fixedform_[]_ac_ppext") 3296 fi 3297 $2 3298fi 3299 3300FPP_PREPROCESS_EXT=_ac_ppext 3301FPP_COMPILE_EXT=m4_if(m4_index([$1], :), -1, 3302 m4_tolower([$1]), 3303 m4_bpatsubst([$1], [.*:])) 3304 3305AC_LANG_POP([Fortran])dnl 3306])# AC_FPP_FIXEDFORM 3307 3308 3309# AC_FPP_FREEFORM([SRCEXT], [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE]) 3310# ------------------------------------------------------------------ 3311# Look for compiler flags to make the Fortran (FC) compiler accept 3312# preprocessed free-format source code, with a source extension of SRCEXT, 3313# and puts any necessary flags in FPPFLAGS_free_<SRCEXT>. Call 3314# ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can 3315# compile fixed-format code using new extension) and ACTION-IF-FAILURE 3316# (defaults to failing with an error message) if not. 3317# 3318# Mostly, this is applicable only when using direct compilation. 3319# However the macro also sets FPP_PREPROCESS_EXT and FPP_COMPILE_EXT, 3320# based on SRCEXT. SRCEXT can be either 'EXT' or 'EXT1:ext2'; in the 3321# first case, the preprocessor extension is 'EXT', and the compile 3322# extension 'ext' (ie, the preprocessor extension, lowercased); in the 3323# second, the preprocessor extension is 'EXT1' and the compile 3324# extension 'ext2'. 3325# 3326# The known flags are: 3327# -ffree-form -x f77-cpp-input: GNU g77 3328# -FR -cpp: Intel compiler (ifort) on unix 3329# /FR /fpp: Intel compiler (ifort) on windows 3330# -free -cpp: Compaq compiler (fort), NAG compiler 3331# -qfree -qsuffix=cpp=<SRCEXT>: IBM compiler (xlf) (generates a warning 3332# with recent versions) 3333# -qfree=f90 -qsuffix=cpp=<SRCEXT>: Newer xlf versions 3334# --nfix -lfe="Cpp": Lahey compiler 3335# -Mfree, -Mfreeform: PGI (no flag for preprocessing available) 3336# -freeform: SGI compiler 3337# -f free: Absoft Fortran 3338# -fpp -free: NAG Fortran 3339# We try to test the "more popular" flags first, by some prejudiced 3340# notion of popularity. Also, Intel/Windows must be first or it gets 3341# confused 3342AC_DEFUN([AC_FPP_FREEFORM], 3343[AC_REQUIRE([AC_PROG_FPP]) 3344AC_LANG_PUSH([Fortran])dnl 3345dnl Extract preprocessor extension _ac_ppext from $1, part preceding any ':' 3346m4_define([_ac_ppext], m4_bpatsubst([$1], [:.*]))dnl 3347AC_CACHE_CHECK([for Fortran flag needed to allow free-form preprocessed source for ._ac_ppext suffix], 3348 ac_cv_fpp_freeform_[]_ac_ppext, 3349[if test $ac_cv_fpp_build_rule = direct; then 3350 ac_cv_fpp_freeform_[]_ac_ppext=unknown 3351 ac_ext=_ac_ppext 3352 ac_fpp_freeform_FCFLAGS_save=$FCFLAGS 3353 for ac_flag in none "/FR /fpp" "-ffree-form -x f77-cpp-input" \ 3354 "-FR -cpp" "-free -cpp" "-qfree=f90 -qsuffix=cpp=_ac_ppext"\ 3355 "-qfree -qsuffix=cpp=_ac_ppext" -Mfree -Mfreeform \ 3356 -freeform "-f free" --nfix "-fpp -free" 3357 do 3358 test "x$ac_flag" != xnone && FCFLAGS="$ac_fpp_freeform_FCFLAGS_save $ac_flag" 3359 AC_COMPILE_IFELSE([ 3360program freeform 3361! FIXME: how to best confuse non-freeform compilers? 3362print *, 'Hello ', & 3363'world.' 3364#ifdef OK2 3365 choke me 3366#endif 3367#ifndef OK 3368end program 3369#endif 3370 ], 3371 [ac_cv_fpp_freeform_[]_ac_ppext=$ac_flag; break]) 3372 done 3373 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 3374 FCFLAGS=$ac_fpp_freeform_FCFLAGS_save 3375else 3376 ac_cv_fpp_freeform_[]_ac_ppext=none 3377fi # test $ac_cv_fpp_build_rule = direct 3378]) 3379if test "x$ac_cv_fpp_freeform_[]_ac_ppext" = xunknown; then 3380 m4_default([$3], 3381 [AC_MSG_ERROR([Cannot compile free-form source with ._ac_ppext suffix], 77)]) 3382else 3383 if test "x$ac_cv_fpp_freeform_[]_ac_ppext" != xnone; then 3384 AC_SUBST(FPPFLAGS_free_[]_ac_ppext, "$ac_cv_fpp_freeform_[]_ac_ppext") 3385 fi 3386 $2 3387fi 3388 3389FPP_PREPROCESS_EXT=_ac_ppext 3390FPP_COMPILE_EXT=m4_if(m4_index([$1], :), -1, 3391 m4_tolower([$1]), 3392 m4_bpatsubst([$1], [.*:])) 3393 3394AC_LANG_POP([Fortran])dnl 3395])# AC_FPP_FREEFORM 3396 3397 3398# AC_FC_OPEN_SPECIFIERS(specifier ...) 3399# ------------------------------------ 3400# 3401# The Fortran OPEN statement is a rich source of portability problems, 3402# since there are numerous common extensions which consiste of extra 3403# specifiers, several of which are useful when they are available. 3404# For each of the specifiers in the (whitespace-separated) argument 3405# list, define HAVE_FC_OPEN_mungedspecifier if the specifier may be 3406# given as argument to the OPEN statement. The `mungedspecifier' is the 3407# `specifier' converted to uppercase and with all characters outside 3408# [a-zA-Z0-9_] deleted. Note that this may include `specifiers' such 3409# as "access='append'" and "[access='sequential',recl=1]" (note quoting of 3410# comma) to check combinations of specifiers. You may not include a 3411# space in the `specifier', even quoted. Each argument must be a 3412# maximum of 65 characters in length (to abide by Fortran 77 3413# line-length limits). 3414# 3415dnl Multiple m4_quote instances are necessary in case specifier includes comma. 3416dnl In the Fortran OPEN line, include status='scratch' unless status=??? 3417dnl is in the specifier being tested. 3418dnl Put specifier on continuation line, in case it's long. 3419AC_DEFUN([AC_FC_OPEN_SPECIFIERS], 3420 [AC_REQUIRE([AC_PROG_FC])dnl 3421 AC_LANG_PUSH([Fortran]) 3422 AC_FOREACH([Specifier], 3423 m4_quote(m4_toupper([$1])), 3424 [m4_define([mungedspec], 3425 m4_bpatsubst(m4_quote(Specifier), [[^a-zA-Z0-9_]], [])) 3426 AC_CACHE_CHECK([whether ${FC} supports OPEN specifier ]m4_quote(Specifier), 3427 [ac_cv_fc_spec_]mungedspec, 3428 [AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], 3429 [ OPEN(UNIT=99,]m4_if(m4_bregexp(m4_quote(Specifier), [\<STATUS *=]), -1, [STATUS='SCRATCH'[,]], []) 3430 :m4_quote(Specifier)[)]), 3431 [ac_cv_fc_spec_]mungedspec=yes, 3432 [ac_cv_fc_spec_]mungedspec=no)]) 3433 if test $ac_cv_fc_spec_[]mungedspec = yes; then 3434 AC_DEFINE([HAVE_FC_OPEN_]mungedspec, 1, 3435 [Define to 1 if the Fortran compiler supports OPEN specifier ]m4_quote(Specifier)) 3436 fi]) 3437 AC_LANG_POP([Fortran]) 3438])# AC_FC_OPEN_SPECIFIERS 3439 3440 3441# AC_FC_CHECK_INTRINSICS(intrinsic-function ...) 3442# ---------------------------------------------- 3443# 3444# Like AC_CHECK_FUNCS, but instead determine the intrinsics available 3445# to the Fortran compiler. For each intrinsic in the 3446# (whitespace-separated and case-insensitive) argument list, define 3447# HAVE_INTRINSIC_intrinsic-function (uppercased) if it is available. 3448# For example, AC_FC_CHECK_INTRINSICS(sin) would define 3449# HAVE_INTRINSIC_SIN if the `sin' intrinsic function were available 3450# (there are probably rather few Fortrans which don't have this 3451# function). The macro works for both intrinsic functions and 3452# intrinsic subroutines. 3453AC_DEFUN([AC_FC_CHECK_INTRINSICS], 3454 [AC_REQUIRE([AC_PROG_FC])dnl 3455 AC_LANG_PUSH([Fortran]) 3456 AC_FOREACH([IntrinsicName], 3457 dnl In case the user is mad, escape impossible names 3458 m4_bpatsubst(m4_toupper([$1]), [[^a-zA-Z0-9_ ]], [_]), 3459 [AC_CACHE_CHECK([whether ${FC} supports intrinsic ]IntrinsicName, 3460 [ac_cv_fc_has_]IntrinsicName, 3461 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3462dnl All we need do is attempt to declare the thing as an intrinsic, 3463dnl since it is an error to thus declare a symbol which is not 3464dnl in fact an intrinsic function. 3465 intrinsic IntrinsicName 3466])], 3467 ac_cv_fc_has_[]IntrinsicName=yes, 3468 ac_cv_fc_has_[]IntrinsicName=no)]) 3469 if test $ac_cv_fc_has_[]IntrinsicName = yes; then 3470 AC_DEFINE([HAVE_INTRINSIC_]IntrinsicName, 1, 3471 [Define to 1 if the Fortran compiler supports intrinsic ]IntrinsicName) 3472 fi 3473 ]) 3474 AC_LANG_POP([Fortran]) 3475])# AC_FC_CHECK_INTRINSICS 3476 3477 3478# AC_FC_RECL_UNIT 3479# ---------------- 3480# 3481# When opening a file for direct access, you must specify 3482# the record length with the @samp{OPEN} specifier @samp{RECL}; 3483# however in the case of unformatted direct access files, the 3484# @emph{units} of this specifier are processor dependent, and may be 3485# words or bytes. This macro determines the units and defines 3486# @samp{FC_RECL_UNIT} to contain the number of bytes (1, 2, 4, 8, ...) in 3487# the processor's unit of measurement. 3488# 3489# Note that unformatted files are not themselves portable, and should 3490# only be used as either temporary files, or as data files which will 3491# be read by a program or library compiled with the same Fortran 3492# processor. With this macro, however, you can read and write such 3493# files in a portable way. 3494AC_DEFUN([AC_FC_RECL_UNIT], 3495 [AC_REQUIRE([AC_PROG_FC])dnl 3496 AC_CACHE_CHECK([units for Fortran OPEN RECL], 3497 [ac_cv_fc_recl_unit], 3498 [AC_LANG_PUSH([Fortran]) 3499 AC_RUN_IFELSE([AC_LANG_SOURCE([dnl 3500 PROGRAM TESTRECL 3501 IMPLICIT NONE 3502 INTEGER NBYTES 3503* Make sure these values agree 3504 PARAMETER ( NBYTES = 8 ) 3505 REAL * 8 TOFILE, FROMFILE 3506 3507 INTEGER RECLEN,UNITLEN,OUTUNIT 3508 3509 TOFILE = 123456789D56 3510 OUTUNIT = 10 3511 3512* Record length to try 3513 RECLEN = 1 3514* Unitlen is the result -- zero indicates that no value was successful 3515 UNITLEN = 0 3516 3517* Keep on increasing the record length until we hit a 3518* size that allows us to write a number and read it back correctly. 3519 DO WHILE (RECLEN .LE. 8) 3520 3521 OPEN(UNIT = OUTUNIT, 3522 : FILE = 'conftest.rcl1', 3523 : STATUS = 'NEW', 3524 : FORM = 'UNFORMATTED', 3525 : ACCESS = 'DIRECT', 3526 : RECL = RECLEN, 3527 : ERR = 101) 3528 3529* Write two records to the output file, so that the second will stomp 3530* on the end of the first if the record length is too short. 3531 WRITE(UNIT=OUTUNIT,REC=1,ERR=101) TOFILE 3532 WRITE(UNIT=OUTUNIT,REC=2,ERR=101) TOFILE 3533 READ(UNIT=OUTUNIT,REC=1,ERR=101) FROMFILE 3534 IF (TOFILE .EQ. FROMFILE) THEN 3535 UNITLEN = NBYTES/RECLEN 3536 GOTO 102 3537 END IF 3538 3539* Error opening unit; close and delete the file 3540 101 CONTINUE 3541 3542 CLOSE(UNIT=OUTUNIT, STATUS='DELETE') 3543 3544 RECLEN = RECLEN * 2 3545 END DO 3546 3547* Got a match 3548 102 CONTINUE 3549 3550 OPEN(UNIT = OUTUNIT, 3551 : FILE = 'conftest.rcl2', 3552 : STATUS = 'NEW', 3553 : ERR = 103) 3554 WRITE(OUTUNIT,'(I3)') UNITLEN 3555 CLOSE(UNIT = OUTUNIT) 3556 103 CONTINUE 3557 3558 END 3559])], 3560 [], 3561 AC_MSG_FAILURE([Can't test for RECL length]), 3562 AC_MSG_FAILURE([Can't cross-compile: can't test for RECL length])) 3563 AC_LANG_POP([Fortran]) 3564 if test -r conftest.rcl2; then 3565 ac_cv_fc_recl_unit=`cat conftest.rcl2` 3566 else 3567 ac_cv_fc_recl_unit=0 3568 fi 3569 rm -f conftest*]) 3570 if test -n "$ac_cv_fc_recl_unit" -a $ac_cv_fc_recl_unit -gt 0; then 3571 AC_DEFINE_UNQUOTED([FC_RECL_UNIT], $ac_cv_fc_recl_unit, 3572 [Define to the length in bytes of the unit that OPEN RECL expects]) 3573 fi 3574])# AC_FC_RECL_UNIT 3575 3576 3577# AC_FC_CHECK_HEADERS(include-file...) 3578# ------------------------------------ 3579# Fortran analogue of AC_CHECK_HEADERS, though it only takes the 3580# first argument, giving the list of include files to check. For 3581# each include file, defines HAVE_include-file (in all capitals) if the 3582# include file is found. Respects the current value of FCFLAGS. 3583AC_DEFUN([AC_FC_CHECK_HEADERS], 3584 [AC_REQUIRE([AC_PROG_FC])dnl 3585 m4_ifval([$1], , [AC_FATAL([$0: missing argument])])dnl 3586 AC_LANG_PUSH([Fortran]) 3587 AC_FOREACH([IncludeName], 3588 dnl In case the user is mad, escape impossible names 3589 m4_bpatsubst(m4_toupper([$1]), [[^a-zA-Z0-9_ ]], [_]), 3590 [AC_CACHE_CHECK([whether ${FC} supports include ]IncludeName, 3591 [ac_cv_fc_has_]IncludeName, 3592 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3593 include 'IncludeName' 3594 i=0 3595])], 3596 [ac_cv_fc_has_]IncludeName=yes, 3597 [ac_cv_fc_has_]IncludeName=no)]) 3598 if test $ac_cv_fc_has_[]IncludeName = yes; then 3599 AC_DEFINE([HAVE_]IncludeName, 1, 3600 [Define to 1 if the we have Fortran include ]IncludeName) 3601 fi 3602 ]) 3603 AC_LANG_POP([Fortran]) 3604])# AC_FC_CHECK_HEADERS 3605 3606 3607# AC_FC_HAVE_PERCENTVAL 3608# --------------------- 3609# Test whether the FC compiler has the %VAL extension. If so, define 3610# the preprocessor variable HAVE_PERCENTVAL to be 1. 3611AC_DEFUN([AC_FC_HAVE_PERCENTVAL], 3612 [AC_REQUIRE([AC_PROG_FC])dnl 3613 AC_CACHE_CHECK([whether ${FC} has the %VAL extension], 3614 [ac_cv_fc_have_percentval], 3615 [AC_LANG_PUSH([Fortran]) 3616 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3617 i=1 3618 call t1(%val(i)) 3619])], 3620 ac_cv_fc_have_percentval=yes, 3621 ac_cv_fc_have_percentval=no) 3622 AC_LANG_POP([Fortran])]) 3623 if test $ac_cv_fc_have_percentval = yes; then 3624 AC_DEFINE([HAVE_PERCENTVAL], 1, 3625 [Define to 1 if the Fortran compiler supports the VAX %VAL extension]) 3626 fi 3627])# AC_FC_HAVE_PERCENTVAL 3628 3629 3630# AC_FC_HAVE_PERCENTLOC 3631# --------------------- 3632# Test whether the FC compiler has the %LOC extension. If so, define 3633# the preprocessor variable HAVE_PERCENTLOC to be 1. 3634AC_DEFUN([AC_FC_HAVE_PERCENTLOC], 3635 [AC_REQUIRE([AC_PROG_FC])dnl 3636 AC_CACHE_CHECK([whether ${FC} has the %LOC extension], 3637 [ac_cv_fc_have_percentloc], 3638 [AC_LANG_PUSH([Fortran]) 3639 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3640 INTEGER I, ADDR 3641 I = 1 3642 ADDR = %LOC( I ) 3643])], 3644 ac_cv_fc_have_percentloc=yes, 3645 ac_cv_fc_have_percentloc=no) 3646 AC_LANG_POP([Fortran])]) 3647 if test $ac_cv_fc_have_percentloc = yes; then 3648 AC_DEFINE([HAVE_PERCENTLOC], 1, 3649 [Define to 1 if the Fortran compiler supports the VAX %LOC extension]) 3650 fi 3651])# AC_FC_HAVE_PERCENTLOC 3652 3653 3654# AC_FC_HAVE_BOZ 3655# -------------- 3656# Test whether the FC compiler supports BOZ constants in the Fortran 3657# 95 style. These are integer constants written in the format 3658# B'xxx', O'xxx' and Z'xxx'. If so set the preprocessor variable 3659# HAVE_BOZ to be 1. 3660AC_DEFUN([AC_FC_HAVE_BOZ], 3661 [AC_REQUIRE([AC_PROG_FC])dnl 3662 AC_CACHE_CHECK([whether ${FC} supports F95 BOZ constants], 3663 [ac_cv_fc_have_boz], 3664 [AC_LANG_PUSH([Fortran]) 3665 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3666 INTEGER J, K, L 3667 PARAMETER ( J = B'1111111111111111' ) 3668 PARAMETER ( K = O'7777' ) 3669 PARAMETER ( L = Z'FF' ) 3670])], 3671 ac_cv_fc_have_boz=yes, 3672 ac_cv_fc_have_boz=no) 3673 AC_LANG_POP([Fortran])]) 3674 if test $ac_cv_fc_have_boz = yes; then 3675 AC_DEFINE([HAVE_BOZ], 1, 3676 [Define to 1 if the Fortran compiler supports F95 boz constants]) 3677 fi 3678])# AC_FC_HAVE_BOZ 3679 3680 3681# AC_FC_HAVE_TYPELESS_BOZ 3682# --------------------------- 3683# Test whether the FC compiler supports typeless BOZ constants in the Fortran 3684# 95 style. These are (usually integer) constants written in the format 3685# X'xxx', but may also be typeless, which allows the initialisation of any type 3686# to a specific bit pattern. If so set the preprocessor variable 3687# HAVE_TYPELESS_BOZ to be 1. 3688# 3689# A problem with this test is that it may compile but the assignments are not 3690# actually typeless and have been done as integer casts. To stop this we need 3691# to run the program and check if an integer equals a floating point value, by 3692# value, they shouldn't for a bit pattern assignment. Uses a "EXIT(1)" to 3693# signal a problem. This is non-standard, so the test may fail for that reason. 3694AC_DEFUN([AC_FC_HAVE_TYPELESS_BOZ], 3695 [AC_REQUIRE([AC_PROG_FC])dnl 3696 AC_CACHE_CHECK([whether ${FC} supports F95 typeless BOZ constants], 3697 [ac_cv_fc_have_typeless_boz], 3698 [AC_LANG_PUSH([Fortran]) 3699 AC_RUN_IFELSE([AC_LANG_SOURCE([ 3700 PROGRAM TMP 3701 INTEGER I 3702 PARAMETER ( I = X'FF7FFFFF' ) 3703 REAL D 3704 PARAMETER ( D = X'FF7FFFFF' ) 3705 LOGICAL L 3706 PARAMETER ( L = X'A55A5AA5' ) 3707 IF ( D .EQ. I ) THEN 3708 CALL EXIT( 1 ) 3709 END IF 3710 END 3711])], 3712 ac_cv_fc_have_typeless_boz=yes, 3713 ac_cv_fc_have_typeless_boz=no) 3714 AC_LANG_POP([Fortran])]) 3715 if test $ac_cv_fc_have_typeless_boz = yes; then 3716 AC_DEFINE([HAVE_TYPELESS_BOZ], 1, 3717 [Define to 1 if the Fortran compiler supports F95 typeless boz constants]) 3718 fi 3719])# AC_FC_HAVE_TYPELESS_BOZ 3720 3721 3722# AC_FC_HAVE_OLD_TYPELESS_BOZ 3723# --------------------------- 3724# Test whether the FC compiler supports typeless BOZ constants in the OLD (VMS 3725# and g77) Fortran style. These are constants written in the format 'xxx'X, 3726# which allows the initialisation of any type to a specific bit pattern. If so 3727# set the preprocessor variable HAVE_OLD_TYPELESS_BOZ to be 1. 3728AC_DEFUN([AC_FC_HAVE_OLD_TYPELESS_BOZ], 3729 [AC_REQUIRE([AC_PROG_FC])dnl 3730 AC_CACHE_CHECK([whether ${FC} supports OLD style typeless BOZ constants], 3731 [ac_cv_fc_have_old_typeless_boz], 3732 [AC_LANG_PUSH([Fortran]) 3733 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3734 INTEGER I 3735 PARAMETER ( I = 'FF'X ) 3736 DOUBLE PRECISION D 3737 PARAMETER ( D = 'FFEFFFFFFFFFFFFF'X ) 3738])], 3739 ac_cv_fc_have_old_typeless_boz=yes, 3740 ac_cv_fc_have_old_typeless_boz=no) 3741 AC_LANG_POP([Fortran])]) 3742 if test $ac_cv_fc_have_old_typeless_boz = yes; then 3743 AC_DEFINE([HAVE_OLD_TYPELESS_BOZ], 1, 3744 [Define to 1 if the Fortran compiler supports OLD style typeless boz constants]) 3745 fi 3746])# AC_FC_HAVE_OLD_TYPELESS_BOZ 3747 3748 3749# AC_FC_HAVE_VOLATILE 3750# ------------------- 3751# Test whether the FC compiler supports the VOLATILE statement. VOLATILE 3752# is used to stop the optimisation of a variable, so that it can be modified 3753# outside of the program itself. If supported set HAVE_VOLATILE to be 1. 3754AC_DEFUN([AC_FC_HAVE_VOLATILE], 3755 [AC_REQUIRE([AC_PROG_FC])dnl 3756 AC_CACHE_CHECK([whether ${FC} supports VOLATILE], 3757 [ac_cv_fc_have_volatile], 3758 [AC_LANG_PUSH([Fortran]) 3759 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 3760 INTEGER I 3761 VOLATILE I 3762])], 3763 ac_cv_fc_have_volatile=yes, 3764 ac_cv_fc_have_volatile=no) 3765 AC_LANG_POP([Fortran])]) 3766 if test $ac_cv_fc_have_volatile = yes; then 3767 AC_DEFINE([HAVE_VOLATILE], 1, 3768 [Define to 1 if the Fortran compiler supports VOLATILE]) 3769 fi 3770])# AC_FC_HAVE_VOLATILE 3771 3772 3773# AC_FC_LITERAL_BACKSLASH 3774# ----------------------- 3775# 3776# Check whether the compiler regards the backslash character as an escape 3777# character. The Standard doesn't say anything about this, but many Unix 3778# Fortran compilers interpret '\n', for example, as a newline, and '\\' as 3779# a single backslash. 3780# 3781# Test the behaviour of the currently selected compiler, and define 3782# FC_LITERAL_BACKSLASH to 1 if backslashes are treated literally -- that is 3783# if '\\' is interpreted as a _pair_ of backslashes and thus that '\n' is 3784# interpreted as a pair of characters. 3785AC_DEFUN([AC_FC_LITERAL_BACKSLASH], 3786 [AC_REQUIRE([AC_PROG_FC])dnl 3787 AC_CACHE_CHECK([whether ${FC} interprets backslashes literally], 3788 ac_cv_fc_literal_backslash, 3789 [AC_LANG_PUSH([Fortran]) 3790 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 3791dnl Four backslashes here -- this is expanded by the shell in writing 3792dnl the text to the file. We want to end up with TEST\\TEST in the source. 3793[ 3794 write(*,'("TEST\\\\TEST")') 3795])], 3796## 'strings' is portable, yes? 3797 [if strings conftest.$ac_objext | grep 'TEST\\\\TEST' >/dev/null; then 3798 ac_cv_fc_literal_backslash=yes 3799 else 3800 ac_cv_fc_literal_backslash=no 3801 fi], 3802 [AC_MSG_WARN([cannot compile a program with backslashes!]) 3803 ac_cv_fc_literal_backslash=unknown]) 3804 AC_LANG_POP([Fortran])]) 3805 if test $ac_cv_fc_literal_backslash = yes; then 3806 AC_DEFINE([FC_LITERAL_BACKSLASH], 1, 3807 [Define to 1 if the Fortran compiler interprets '\\' as a pair of characters, not one]) 3808 fi 3809])# AC_FC_LITERAL_BACKSLASH 3810 3811# AC_FC_MOD_PATH_FLAG 3812# ------------------------- 3813# Check which flag is necessary to alter the compiler's search path 3814# for module files. 3815# This obviously requires that the compiler has some notion of 3816# module files as separate from object files and some sensible 3817# method of altering its search path. This will therefore not work 3818# on early Cray F90 compilers, or on v5 (and 6?) of ifc. 3819# 3820# Nearly every compiler I have found uses -Ipath for this purpose; 3821# Sun F95 v7.1 (at least), uses -Mpath 3822# Lahey uses -mod, but it needs to be called as -mod .\; in order 3823# to work properly. (so that module files still get written to 3824# the current directory. 3825# Absoft uses -p (with compulsory space after) 3826# 3827AC_DEFUN([AC_FC_MOD_PATH_FLAG],[ 3828 _AC_FORTRAN_ASSERT 3829 AC_REQUIRE([AC_PROG_FC]) 3830 ac_cv_fc_mod_path_flag=no 3831 AC_MSG_CHECKING([for flag to alter module search path]) 3832 mkdir conftestdir 3833 cd conftestdir 3834 cat > conftest.$ac_ext << \_ACEOF 3835 module conftest 3836 implicit none 3837 integer :: i 3838 end module conftest 3839_ACEOF 3840 _AC_EVAL_STDERR($ac_compile) 3841 cd .. 3842 for i in /I -I -M "-mod .\;" "-p "; do 3843 if test "$ac_cv_fc_mod_path_flag" = "no"; then 3844 FCFLAGS_save=$FCFLAGS 3845 FCFLAGS="$FCFLAGS ${i}conftestdir" 3846 AC_COMPILE_IFELSE([ 3847 subroutine test 3848 use conftest 3849 implicit none 3850 i = 0 3851 end subroutine test 3852], 3853 [FC_MOD_FLAG=$i; ac_cv_fc_mod_path_flag=$i], 3854 [:]) 3855 fi 3856 FCFLAGS=$FCFLAGS_save 3857 done 3858 AC_MSG_RESULT([$ac_cv_fc_mod_path_flag]) 3859 rm -rf conftestdir 3860 AS_IF([test "$ac_cv_fc_mod_path_flag" != "no"], 3861 [$1], 3862 [m4_default([$2],[AC_MSG_ERROR([Cannot find flag to alter module search path])])]) 3863 AC_SUBST(FC_MOD_FLAG) 3864])# AC_FC_MOD_PATH_FLAG 3865 3866# -------------------------------------- # 3867# Feature tests for Preprocessed Fortran # 3868# -------------------------------------- # 3869 3870 3871# ------------------------------------------# 3872# Some test programs for different features # 3873# ------------------------------------------# 3874 3875# _AC_LANG_PROGRAM_FPP_SIMPLE 3876# --------------------------- 3877# The minimum test program - any compiler supporting 3878# preprocessing should handle this 3879AC_DEFUN([_AC_LANG_PROGRAM_FPP_SIMPLE], 3880 [AC_LANG_PROGRAM([@%:@define OK], [dnl 3881#ifndef OK 3882 syntax error 3883#endif 3884])])#_AC_LANG_PROGRAM_FPP_SIMPLE 3885 3886 3887# _AC_LANG_PROGRAM_FPP_ONLY 3888# --------------------------- 3889# Test program for pure preprocessing 3890# Note that other macros test for literal strings within this, so check 3891# for those if you have to change anything here. 3892AC_DEFUN([_AC_LANG_PROGRAM_FPP_ONLY], 3893 [AC_LANG_PROGRAM([@%:@define OK], [dnl 3894#ifdef OK 3895 REAL A 3896#else 3897 syntax error 3898#endif 3899])])#_AC_LANG_PROGRAM_FPP_ONLY 3900 3901 3902# _AC_LANG_PROGRAM_FPP_D 3903# --------------------------- 3904# Like _AC_LANG_PROGRAM_FPP_SIMPLE, but OK is passed via -D switch 3905AC_DEFUN([_AC_LANG_PROGRAM_FPP_D], 3906[AC_LANG_PROGRAM([],[ 3907#ifndef OK 3908 syntax error 3909#endif 3910])])#_AC_LANG_PROGRAM_FPP_D 3911 3912 3913# _AC_LANG_PROGRAM_FPP_I 3914# --------------------------- 3915# Test for #include statement 3916# If unsupported, this should give a type error 3917AC_DEFUN([_AC_LANG_PROGRAM_FPP_I], 3918[AC_LANG_PROGRAM([],[ 3919 IMPLICIT CHARACTER (c) 3920! Comments in test programs should be freeform compliant just in case. 3921! conftest.inc contains the Fortran statement "REAL cc" 3922#include "conftest.inc" 3923 cc=1. 3924])])#_AC_LANG_PROGRAM_FPP_I 3925 3926 3927# _AC_LANG_PROGRAM_FPP_SUBS 3928# --------------------------- 3929# Test whether cpp symbols are expanded in Fortran code lines 3930# If not, this should give a type error 3931AC_DEFUN([_AC_LANG_PROGRAM_FPP_SUBS], 3932[AC_LANG_PROGRAM([ 3933#define NM xxxx 3934], [ IMPLICIT CHARACTER (n) 3935 REAL xxxx 3936 NM=1. 3937])])#_AC_LANG_PROGRAM_FPP_SUBS 3938 3939 3940# _AC_LANG_PROGRAM_FPP_WRAP 3941# --------------------------- 3942# Test whether preprocessor breaks lines that become too long due 3943# to macro substitution. 3944# If not, this gives an "unterminated character constant" error 3945AC_DEFUN([_AC_LANG_PROGRAM_FPP_WRAP], 3946[AC_LANG_PROGRAM([ 3947#define LONG '901234567890123456789012345678901234567890123456789012345678901234567890' 3948],[ CHARACTER*80 A 3949 A=LONG 3950])])#_AC_LANG_PROGRAM_FPP_WRAP 3951 3952 3953# _AC_LANG_PROGRAM_FPP_CSTYLE 3954# --------------------------- 3955# Test program for C style comments 3956AC_DEFUN([_AC_LANG_PROGRAM_FPP_CSTYLE], 3957[AC_LANG_PROGRAM([],[ 3958 A=1. /* C-style comment */ 3959])])#_AC_LANG_PROGRAM_FPP_CSTYLE 3960 3961# _AC_LANG_PROGRAM_FPP_CXXSTYLE 3962# --------------------------- 3963# Test program for C++ style comments 3964AC_DEFUN([_AC_LANG_PROGRAM_FPP_CXXSTYLE], 3965[ 3966 PROGRAM MAIN 3967 CHARACTER*10 C 3968 C = "abcde" // "fghij"; END PROGRAM 3969] 3970)#_AC_LANG_PROGRAM_FPP_CXXSTYLE 3971 3972# ----------------# 3973# Internal macros # 3974# ----------------# 3975 3976 3977# _AC_PROG_FPP_FEATURES ([feature list]) 3978# -------------------------------------- 3979# Parse the feature list from configure.in 3980AC_DEFUN([_AC_PROG_FPP_FEATURES], 3981[# defaults for needed features 3982ac_fpp_need_d=yes 3983ac_fpp_need_i=yes 3984ac_fpp_need_subs=no 3985ac_fpp_need_wrap=no 3986ac_fpp_need_cstyle=no 3987ac_fpp_need_CSTYLE=no 3988ac_fpp_need_cxxstyle=yes 3989ac_fpp_need_CXXSTYLE=no 3990for _t in $1 nil 3991do 3992 case $_t in 3993 define) ac_fpp_need_d=yes ;; 3994 nodefine) ac_fpp_need_d=no ;; 3995 include) ac_fpp_need_i=yes ;; 3996 noinclude) ac_fpp_need_i=no ;; 3997 substitute) ac_fpp_need_subs=yes ;; 3998 nosubstitute) ac_fpp_need_subs=no ;; 3999 wrap) ac_fpp_need_wrap=yes ;; 4000 nowwrap) ac_fpp_need_wrap=no ;; 4001 cstyle) ac_fpp_need_cstyle=yes ;; 4002 nocstyle) ac_fpp_need_cstyle=no ;; 4003 CSTYLE) ac_fpp_need_CSTYLE=yes ;; 4004 noCSTYLE) ac_fpp_need_CSTYLE=no ;; 4005 cxxstyle) ac_fpp_need_cxxstyle=yes ;; 4006 nocxxstyle) ac_fpp_need_cxxstyle=no ;; 4007 CXXSTYLE) ac_fpp_need_CXXSTYLE=yes ;; 4008 noCXXSTYLE) ac_fpp_need_CXXSTYLE=no ;; 4009 nil) ;; 4010 esac 4011done 4012# Wrapping requires substitution 4013test $ac_fpp_need_wrap = yes && ac_fpp_need_subs=yes 4014# Both CSTYLE and cstyle cannot be requested 4015# CSTYLE has precedence, since if it is not fulfilled, 4016# compile errors may arise 4017test $ac_fpp_need_CSTYLE = yes && ac_fpp_need_cstyle=no 4018dnl Similarly for cxxstyle 4019test $ac_fpp_need_CXXSTYLE = yes && ac_fpp_need_cxxstyle=no 4020])# _AC_PROG_FPP_FEATURES 4021 4022 4023# _AC_TEST_FPP_FIXED ([command]) 4024# ------------------------ 4025# A helper macro to test correct fpp behaviour 4026# It sets ac_cv_prog_fpp and ac_fpp_out 4027AC_DEFUN([_AC_TEST_FPP_FIXED], 4028[rm -f conftest* 4029cat >conftest.$ac_ext << \_ACEOF 4030_AC_LANG_PROGRAM_FPP_ONLY 4031_ACEOF 4032ac_fpp_command=$1 4033if eval '$ac_fpp_command conftest.$ac_ext > conftest.log 2>/dev/null'; then 4034 if test -f conftest.f; then 4035 if diff conftest.$ac_ext conftest.f >/dev/null 2>&1; then 4036 # ooops -- these two are the same file, indicating that this is a 4037 # case-insensitive filesystem. So ignore this file. 4038 ac_tmp= 4039 else 4040 ac_tmp=conftest.f 4041 ac_fpp_fixed_out= 4042 fi 4043 fi 4044 if test -z "$ac_tmp"; then 4045 ac_tmp=conftest.log 4046 ac_fpp_fixed_out=' > conftest.f' 4047 fi 4048 if grep '^ REAL A' $ac_tmp >/dev/null 2>&1; then 4049 # we have Fortran! That worked... 4050 ac_cv_prog_fpp_fixed=$ac_fpp_command 4051 fi 4052 if grep 'syntax error' $ac_tmp >/dev/null 2>&1; then 4053 # ...oh no it didn't: this line should have been skipped 4054 ac_cv_prog_fpp_free= 4055 fi 4056fi 4057rm -f conftest* 4058])# _AC_TEST_FPP_FIXED 4059 4060# _AC_TEST_FPP_FREE ([command]) 4061# ------------------------ 4062# A helper macro to test correct fpp behaviour 4063# It sets ac_cv_prog_fpp and ac_fpp_out 4064AC_DEFUN([_AC_TEST_FPP_FREE], 4065[rm -f conftest* 4066ac_ext_tmp=$ac_ext 4067ac_ext=F90 4068cat >conftest.$ac_ext << \_ACEOF 4069_AC_LANG_PROGRAM_FPP_ONLY 4070_ACEOF 4071ac_fpp_command=$1 4072if eval '$ac_fpp_command conftest.$ac_ext > conftest.log 2>/dev/null'; then 4073 if test -f conftest.f; then 4074 if diff conftest.$ac_ext conftest.f90 >/dev/null 2>&1; then 4075 # ooops -- these two are the same file, indicating that this is a 4076 # case-insensitive filesystem. So ignore this file. 4077 ac_tmp= 4078 else 4079 ac_tmp=conftest.f90 4080 ac_fpp_free_out= 4081 ac_fpp_out= 4082 fi 4083 fi 4084 if test -z "$ac_tmp"; then 4085 ac_tmp=conftest.log 4086 ac_fpp_free_out=' > conftest.f90' 4087# Note that the CPP tests only use fixed format 4088# so we need to use a .f extension to make the tests 4089# work. 4090 ac_fpp_out=' > conftest.f' 4091 fi 4092 if grep '^ REAL A' $ac_tmp >/dev/null 2>&1; then 4093 # we have Fortran! That worked... 4094 ac_cv_prog_fpp_free=$ac_fpp_command 4095 ac_cv_prog_fpp=$ac_fpp_command 4096 fi 4097 if grep 'syntax error' $ac_tmp >/dev/null 2>&1; then 4098 # ...oh no it didn't: this line should have been skipped 4099 ac_cv_prog_fpp_free= 4100 ac_cv_prog_fpp= 4101 fi 4102fi 4103rm -f conftest* 4104ac_ext=$ac_ext_tmp 4105])# _AC_TEST_FPP_FREE 4106 4107 4108# _AC_PROG_FPP 4109# ------------ 4110# Try to figure out how to preprocess .F files for use with the selected 4111# Fortran compiler 4112# 4113# Must be run after _AC_PROG_FC_CPP 4114AC_DEFUN([_AC_PROG_FPP], 4115[AC_REQUIRE([_AC_PROG_FC_CPP])dnl 4116AC_CACHE_CHECK([how to preprocess Fortran files], ac_cv_prog_fpp, 4117[ac_cv_prog_fpp= 4118AC_LANG_ASSERT(Preprocessed Fortran) 4119 4120# Let the user specify FPP 4121if test -n "$FPP"; then 4122 _AC_TEST_FPP_FREE([$FPP]) 4123 if test -z "$ac_cv_prog_fpp"; then 4124 AC_MSG_WARN([user-specified \$FPP ($FPP) does not work]) 4125 FPP= 4126 fi 4127fi # test -n "$FPP" 4128 4129# This next should never happen. We don't call this macro 4130# if we can already preprocess. If we do find ourselves here, then 4131# something has gone badly wrong -- fail before we do some damage. 4132if test -z "$ac_cv_prog_fpp" && test $ac_fpp_ok = yes; then 4133 # Ooops... 4134 AC_MSG_ERROR([Assertion failure: in _A@&t@C_PROG_FPP when we shouldn't be!]) 4135fi 4136 4137# FIXME: should we bother testing for FC+flag preprocessing? 4138 4139if test -z "$ac_cv_prog_fpp"; then 4140# Either the Fortran compiler can't handle cpp, or doesn't have all the 4141# features, or can't be used for pure preprocessing. 4142# We must find another way for preprocessing. 4143# We try the "best" preprocessors first. We know that $FC can't preprocess 4144# by itself, but there is a small chance that F77 can be persuaded to 4145# preprocess, so we try that. 4146# FIXME: The comment above does not agree with the code below - $FC etc. 4147# is being checked late, not early? 4148 for ac_j in 'fpp' "$CPP -x f95-cpp-input" "$CPP -x f77-cpp-input" \ 4149 "$CPP -C -x c" "$CPP -x c" "$CPP" 'cpp' '/lib/cpp' '/usr/ccs/lib/cpp' \ 4150 'g77 -E' '$CC -E -x f95-cpp-input' '$CC -E -x f77-cpp-input' \ 4151 '$CC -E -x c -C' '$CC -E -x c' '$CC -E' \ 4152 "$FC -F" "$FC -E" "$F77 -F" "$F77 -E" ; do 4153 _AC_TEST_FPP_FREE([$ac_j]) 4154 test -n "$ac_cv_prog_fpp" && break; 4155 done 4156fi # test -z "$ac_cv_prog_fpp" 4157 4158if test -z "$ac_cv_prog_fpp"; then 4159 # This is only fatal if direct compilation doesn't work either 4160 # but we're only here if direct compilation didn't work. 4161 AC_MSG_ERROR([cannot find a working Fortran preprocessor]) 4162fi 4163]) 4164AC_CACHE_CHECK([how to redirect $ac_cv_prog_fpp output], 4165 ac_cv_fpp_out, 4166 [ac_cv_fpp_out=$ac_fpp_out]) 4167FPP=$ac_cv_prog_fpp 4168ac_fpp_out=$ac_cv_fpp_out 4169])# _AC_PROG_FPP 4170 4171 4172# _AC_PROG_FPP_P 4173# -------------- 4174# Check whether we need to give FPP the -P option, to get it to 4175# produce code which FC can read. 4176AC_DEFUN([_AC_PROG_FPP_P], 4177[AC_CACHE_CHECK([whether $FPP needs the -P option], 4178ac_cv_prog_fpp_p, 4179[ac_cv_prog_fpp_p=unknown 4180AC_LANG_ASSERT(Preprocessed Fortran) 4181# This will only be called from AC_PROG_FPP, and as such, the 4182# extension *will* be .F90. 4183ac_ext=F90 4184cat > conftest.$ac_ext << \_ACEOF 4185_AC_LANG_PROGRAM_FPP_ONLY 4186_ACEOF 4187 4188AC_LANG_PUSH(Fortran) 4189ac_ext=F90 # previous line will have reset this 4190# We must not fail, here, in the case where the filesystem is 4191# case-insensitive, so that conftest.F and conftest.f are the same 4192# file. 4193if test -n "$ac_fpp_out"; then 4194 # If $ac_fpp_out is non-null, then preprocessor output goes to 4195 # stdout, which we send to conftest.f _without_ immediately clobbering 4196 # the input file as it is being read. We do clobber it in the 4197 # end, however, which is why we copy .FPP_SRC_EXT to .$FPP_SRC_EXT 4198 # each time. 4199 ac_tmp='>conftest.tmp && mv conftest.tmp conftest.f90' 4200else 4201 # conftest.F is preprocessed directly to conftest.f. We can 4202 # assume that the filesystem is case-sensitive, since otherwise 4203 # this compiler/preprocessor would be simply non-functional on 4204 # this platform. 4205 ac_tmp= 4206fi 4207ac_cmd='$FPP $FPPFLAGS conftest.$ac_ext '"$ac_tmp" 4208ac_link='$FC $ac_link_obj_flag""conftest$ac_exeext $FCFLAGS $LDFLAGS $FCFLAGS_SRCEXT conftest.f90 $LIBS' 4209 4210if AC_TRY_EVAL(ac_cmd) && 4211 AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then 4212 ac_cv_prog_fpp_p= 4213else 4214 ac_save_FPPFLAGS=$FPPFLAGS 4215 FPPFLAGS="$FPPFLAGS -P" 4216 if AC_TRY_EVAL(ac_cmd) && 4217 AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then 4218 ac_cv_prog_fpp_p=-P 4219 fi 4220 FPPFLAGS=$ac_save_FPPFLAGS 4221fi 4222rm -f conftest* 4223AC_LANG_POP(Fortran)dnl 4224]) 4225if test "x$ac_cv_prog_fpp_p" = "xunknown"; then 4226 AC_MSG_ERROR([$FPP cannot produce code that $FC compiles]) 4227else 4228 FPPFLAGS="$FPPFLAGS $ac_cv_prog_fpp_p" 4229fi 4230])# _AC_PROG_FPP_P 4231 4232# _AC_PROG_FPP_CSTYLE 4233# ------------------- 4234# Check whether FPP lets C-style comments through to FC 4235AC_DEFUN([_AC_PROG_FPP_CSTYLE], 4236[AC_CACHE_CHECK([how to pass C-style comments to $FC], 4237 ac_cv_prog_fpp_cstyle, 4238[ac_cv_prog_fpp_cstyle=unknown 4239AC_LANG_ASSERT(Preprocessed Fortran) 4240cat > conftest.$ac_ext << \_ACEOF 4241_AC_LANG_PROGRAM_FPP_CSTYLE 4242_ACEOF 4243 4244AC_LANG_PUSH(Fortran) 4245ac_cmd='$FPP $FPPFLAGS conftest.$ac_ext '"$ac_fpp_out" 4246if AC_TRY_EVAL(ac_cmd) && 4247 cat conftest.f | grep '[[*]]/.*[[*]]/' >/dev/null 2>&1; then 4248 ac_cv_prog_fpp_cstyle= 4249else 4250 ac_save_FPPFLAGS=$FPPFLAGS 4251 ac_name=`expr "x$FPP" : 'x\(fpp\)'` 4252 if test "x$ac_name" = xfpp; then 4253 ac_flag="-c_com=no" 4254 else 4255 ac_flag="-C" 4256 fi 4257 FPPFLAGS="$FPPFLAGS $ac_flag" 4258 ac_cmd='$FPP $FPPFLAGS conftest.$ac_ext '"$ac_fpp_out" 4259 if AC_TRY_EVAL(ac_cmd) && 4260 cat conftest.f | grep '/[[*]].*[[*]]/' >/dev/null 2>&1; then 4261 ac_cv_prog_fpp_cstyle=$ac_flag 4262 fi 4263 FPPFLAGS=$ac_save_FPPFLAGS 4264fi 4265rm -f conftest* 4266AC_LANG_POP(Fortran)dnl 4267]) 4268if test "x$ac_cv_prog_fpp_cstyle" = "xunknown"; then 4269 AC_MSG_WARN([cannot find a way to make $FPP pass C-style comments]) 4270else 4271 FPPFLAGS="$FPPFLAGS $ac_cv_prog_fpp_cstyle" 4272fi 4273])# _AC_PROG_FPP_CSTYLE 4274 4275 4276# _AC_PROG_FC_CPP 4277# --------------- 4278# This macro checks whether the chosen preprocessing method 4279# has all the requested features. 4280# 4281# This macro must be called with $ac_fc_testing_fpp set to either 4282# direct or indirect; it behaves differently accordingly. 4283# 4284#FIXME: this is only for fixed form code. Need a separate check for free-form. 4285# 4286# NB We are definitely using a suffix of .F in this case. If the filesystem 4287# is case-insensitive, we may need to force preprocessing. 4288# 4289# Sets ac_fpp_ok to "no" if a requested feature is unavailable 4290# 4291AC_DEFUN([_AC_PROG_FC_CPP], 4292[ac_fpp_ok=yes 4293ac_prog_fc_cpp=no 4294ac_prog_fc_cpp_d=no 4295ac_prog_fc_cpp_i=no 4296ac_prog_fc_cpp_subs=no 4297ac_prog_fc_cpp_wrap=no 4298ac_prog_fc_cpp_CSTYLE=no 4299ac_prog_fc_cpp_cxxstyle=no 4300 4301AC_LANG_ASSERT(Preprocessed Fortran) 4302AC_MSG_CHECKING([for fixed form Fortran preprocessor features]) 4303 4304if test $ac_fc_testing_fpp = direct; then 4305# On nearly all systems where direct compilation is possible, a .F file will 4306# compile a preprocessable fixed-form file automatically. However, 4307# case-insensitive filesystems (eg HFS+ on MacOSX) may get confused. 4308# Therefore, we must check for cpp flags. 4309 _AC_FPP_FIXEDFORM_F 4310 if test "x$ac_cv_fpp_fixedform_F" != x; then 4311 ac_prog_fc_cpp=yes 4312 else 4313 ac_fpp_ok=no 4314 fi 4315 4316# It is possible we've failed the previous test because of a 4317# Tru64 bug where the compiler fails when called as 'f95' on 4318# a .F file. It works when called as f90. 4319#FIXME: this does not protect the user's setting of FC, though 4320# we set it back if senesible. 4321 if test $ac_prog_fc_cpp = no && test $FC = f95; then 4322 FC=f90 4323 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_SIMPLE], 4324 [ac_prog_fc_cpp=yes], 4325 []) 4326 if test $ac_prog_fc_cpp = no; then 4327 FC=f95 4328 ac_fpp_ok=no 4329 fi 4330 fi 4331 4332 ac_first_save_FPPFLAGS=$FPPFLAGS 4333 FPPFLAGS="$FPPFLAGS $FPPFLAGS_fixed_F" 4334fi 4335 4336# We need to skip the following tests if we're trying direct compilation 4337# and FC won't preprocess. 4338if test $ac_prog_fc_cpp = yes || test $ac_fc_testing_fpp = indirect; then 4339 4340 if test $ac_fpp_need_d = yes; then 4341# Nearly everyone uses -D. XLF uses -WF,-D. Ifort on Windows uses /D 4342 ac_prog_fc_cpp_d=no 4343 ac_save_FPPFLAGS=$FPPFLAGS 4344 for fpp_flag_try in "-D" "-WF,-D" "/D"; do 4345 FPPFLAGS="$FPPFLAGS $fpp_flag_try""OK" 4346 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_D], 4347 [ac_prog_fc_cpp_d=yes; FPPFLAGS_DEF="$fpp_flag_try"], 4348 [:]) 4349 FPPFLAGS=$ac_save_FPPFLAGS 4350 done 4351 if test $ac_prog_fc_cpp_d = no; then 4352 ac_fpp_ok=no 4353 fi 4354 fi 4355#FIXME we should probably do the AC_SUBST somewhere else. 4356 AC_SUBST(FPPFLAGS_DEF) 4357 4358 if test $ac_fpp_need_i = yes; then 4359 rm -rf conftst 4360 mkdir conftst 4361 cat > conftst/conftest.inc << \_ACEOF 4362! This statement overrides the IMPLICIT statement in the program 4363 REAL cc 4364_ACEOF 4365 ac_save_FPPFLAGS=$FPPFLAGS 4366 FPPFLAGS="$FPPFLAGS -Iconftst" 4367 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_I], 4368 [ac_prog_fc_cpp_i=yes], 4369 [ac_fpp_ok=no]) 4370 rm -rf conftst 4371 FPPFLAGS=$ac_save_FPPFLAGS 4372 fi 4373 4374 if test $ac_fpp_need_subs = yes; then 4375 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_SUBS], 4376 [ac_prog_fc_cpp_subs=yes], 4377 [ac_fpp_ok=no]) 4378 fi 4379 4380 if test $ac_fpp_need_wrap = yes; then 4381 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_WRAP], 4382 [ac_prog_fc_cpp_wrap=yes], 4383 [ac_fpp_ok=no]) 4384 fi 4385 4386 if test $ac_fpp_need_CSTYLE = yes; then 4387 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_CSTYLE], 4388 [ac_prog_fc_cpp_CSTYLE=yes], 4389 [ac_fpp_ok=no]) 4390 fi 4391 4392 if test $ac_fpp_need_cxxstyle = yes; then 4393 AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_CXXSTYLE], 4394 [ac_prog_fc_cpp_cxxstyle=yes], 4395 [ac_fpp_ok=no]) 4396 fi 4397 4398fi 4399if test $ac_fc_testing_fpp = direct; then 4400 FPPFLAGS=$ac_first_save_FPPFLAGS 4401fi 4402 4403rm -f conftest.* 4404 4405AC_MSG_RESULT([done.]) 4406])#_AC_PROG_FC_CPP 4407 4408 4409# _AC_FPP_BUILD_RULE 4410# ------------------ 4411# Figure out how to build from cpp/Fortran sources 4412# 4413# If we need to use a separate preprocessor, we must override make's 4414# `direct' .F.o rule in order to do `indirect' compilation 4415# (.F -> .f then .f -> .o). 4416# 4417# Configure variables set here are as follows. The items in this list 4418# are suffixed with `[direct]', `[indirect]' or `[both]'. In the 4419# first two cases, the variable has a useful value only in the given 4420# mode, and an unspecified, and therefore unreliable, value in the 4421# other; in the last, it has a value in both modes. 4422# 4423# FPP [indirect] 4424# The name of a suitable preprocessor. 4425# 4426# FPP_COMPILE_EXT [both] 4427# This contains the file extension which the Fortran compiler will 4428# accept as containing source not to be preprocessed. It is most 4429# typically 'f' (the default), but could be different if set by a 4430# call to AC_FPP_(FIXED|FREE)FORM. 4431# 4432# FPP_PREPROCESS_EXT [both] 4433# The partner of FPP_COMPILE_EXT, containing the file extension 4434# which is taken to indicate Fortran source to be preprocessed. 4435# The default is 'F', but could be different if set by a 4436# call to AC_FPP_(FIXED|FREE)FORM. 4437# 4438# FPP_MAKE_FLAGS [direct] 4439# This is used to include CPP/FPP related flags into the compiler 4440# call if we compile directly, and leave them out otherwise. 4441# 4442# FPP_OUTPUT [both] 4443# This is used to redirect FPP output to the .f file in those 4444# cases where FPP writes to stdout rather than to a file. It is 4445# defined as either "" or ">$@". 4446# 4447# FPPDIRECT_TRUE, FPPDIRECT_FALSE [both] 4448# If the macro decides that we must use `direct' mode, then it 4449# sets FPPDIRECT_TRUE to be blank, and FPPDIRECT_FALSE to be '#', 4450# or vice versa if we are to use `indirect' mode. These may be 4451# used within a Makefile.in as follows: 4452# @FPPDIRECT_TRUE@.@FPP_PREPROCESS_EXT@.o: 4453# @FPPDIRECT_TRUE@ $(PPFCCOMPILE) -c -o $@ $< 4454# @FPPDIRECT_FALSE@.@FPP_PREPROCESS_EXT@.@FPP_COMPILE_EXT: 4455# @FPPDIRECT_FALSE@ $(FPP) $(DEFS) ... $< @FPP_OUTPUT@ 4456# If you use automake, then you may possibly recognise that as an 4457# automake conditional (which is predeclared, so you do not need 4458# to include AM_CONDITIONAL(FPPDIRECT, ???) in your configure.ac), 4459# which might be used more straightforwardly in your Makefile.am 4460# as follows: 4461# if FPPDIRECT 4462# .@FPP_PREPROCESS_EXT@.o: 4463# $(PPFCCOMPILE) -c -o $@ $< 4464# else !FPPDIRECT 4465# .@FPP_PREPROCESS_EXT@.@FPP_COMPILE_EXT: 4466# $(FPP) $(DEFS) ... $< @FPP_OUTPUT@ 4467# endif !FPPDIRECT 4468# 4469# These are used in Automake's lang_ppfc_finish subroutine. 4470# 4471# NOTE 1: There would seem to be a problem here with the use of .F as 4472# the extension for preprocessed files. On case-insensitive 4473# filesystems such as HFS+, as used on MacOS X, foo.F and foo.f are 4474# the same file. This means that indirect compilation would lose badly, since 4475# converting foo.F to foo.f would clobber the original. This is 4476# probably not a problem in practice, since the compilers (g77, gfortran, 4477# nag, and xlf) actually likely to be used on OS X -- which is a 4478# recent platform, and thus with only recent Fortrans on it -- can all 4479# do direct compilation of preprocessable Fortran. Just in case, we 4480# check below whether we are in this fatal situation, and collapse 4481# noisily if necessary. 4482# 4483# NOTE 2: Martin Wilck's original version of these macros noted that it 4484# was necessary to generate explicit rules for .F -> .o compilations 4485# in order to override make's builtin rules in a portable manner 4486# (i.e. without using make extensions). Not all makes do chains of 4487# implicit rules, so we cannot depend on .F.f, .f.o rules generating 4488# a .f file. We need unified .F.o and .F.lo rules, but that's 4489# complicated, an alternative is to name the intermediary .f files in 4490# the Makefiles. Again, this may not be much of a problem in fact, 4491# since the main culprit seems to be Solaris make, but Solaris f77 4492# can do direct compilation, so that the issue of chaining rules 4493# doesn't arise. 4494# 4495# NOTE 3: POSIX/Single-Unix states that inference rules can be 4496# redefined, and there's no warning against this in Autoconf's section 4497# on `Limitations of Make'. 4498# 4499# NOTE 4: FPP_OUTPUT is set to either "" or ">$@". The latter is OK 4500# in an implicit rule, but will potentially lose in an explicit rule, 4501# since POSIX does not require that $@ is defined in such a rule, and 4502# there are still a few makes which do not define it in that context. 4503# As with Note 1, however, this is probably more a theoretical problem 4504# than a practical one. 4505# 4506AC_DEFUN([_AC_FPP_BUILD_RULE], 4507[# FPP is defined by this stage. If the processing mode is 'direct', then 4508# this will almost certainly be defined as blank, but we should make no 4509# committments to this in the documentation, in case we want to change 4510# our minds about that in future. 4511AC_SUBST(FPP) 4512 4513# Default the FPP_PREPROCESS_EXT and FPP_COMPILE_EXT to the most usual ones 4514FPP_PREPROCESS_EXT=F 4515FPP_COMPILE_EXT=f 4516 4517# Switch on the processing mode, direct/indirect, which has been determined 4518# in AC_PROG_FPP before this macro is called. The FPPDIRECT_(TRUE|FALSE) 4519# variables implement an automake (configure-time) conditional, which is 4520# created, not through an invocation of AM_CONDITIONAL, but implicitly 4521# within automake.in (qv). 4522if test $ac_cv_fpp_build_rule = direct; then 4523 # The simple case: the chosen Fortran compiler can handle preprocessing, 4524 # so we don't need a separate preprocessing stage. 4525 FPPDIRECT_TRUE= 4526 FPPDIRECT_FALSE='#' 4527 # The flags here are those included in the 'compile' field of the 4528 # 'ppfc' language in automake.in, minus the {AM_,}FCFLAGS variables. 4529 # It's not _absolutely_ guaranteed that these are the correct ones, 4530 # and I (NG) would be open to argument about adding both {AM_,}CPPFLAGS and 4531 # {AM_,}FCFLAGS, but this set appears to work. 4532 FPP_MAKE_FLAGS='$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS)' 4533else 4534 FPPDIRECT_TRUE='#' 4535 FPPDIRECT_FALSE= 4536 FPP_MAKE_FLAGS= 4537fi 4538 4539if test -z "$ac_fpp_out"; then 4540 FPP_OUTPUT=" " 4541else 4542 FPP_OUTPUT=">\[$]@" 4543fi 4544 4545AC_SUBST(FPPDIRECT_TRUE) 4546AC_SUBST(FPPDIRECT_FALSE) 4547AC_SUBST(FPP_MAKE_FLAGS) 4548AC_SUBST(FPP_PREPROCESS_EXT) 4549AC_SUBST(FPP_COMPILE_EXT) 4550AC_SUBST(FPP_OUTPUT) 4551])# _AC_FPP_BUILD_RULE 4552 4553 4554# _AC_FC_CHECK_CIFS 4555# ----------------- 4556# Check whether the filesystem is case-insensitive (eg, HFS+ on 4557# MacOS X). Set ac_cv_fc_cifs=yes if so. 4558AC_DEFUN([_AC_FC_CHECK_CIFS], 4559 [AC_CACHE_CHECK([whether the filesystem is case-insensitive], 4560 ac_cv_fc_cifs, 4561 [rm -f conftest.* 4562 echo wibble >conftest.F 4563 if test -f conftest.f && test "`cat conftest.f`" = wibble; then 4564 ac_cv_fc_cifs=yes 4565 else 4566 ac_cv_fc_cifs=no 4567 fi 4568])])# _AC_FC_CHECK_CIFS 4569 4570 4571 4572# ----------------------- 4573# User macros 4574# ----------------------- 4575 4576# AC_PROG_FPP([required features]) 4577# -------------------------------------------------- 4578# 4579# [required features] is a space-separated list of features that the Fortran 4580# preprocessor must have for the code to compile. 4581# It is up to the package maintainer to properly set these requirements. 4582# 4583# This macro will find out how to compile a preprocessable fixed-form 4584# file, with a .F file extension. To the best of my knowledge, such a 4585# file is compilable everywhere (albeit flags may be needed on 4586# case-insensitive filesystems) 4587# 4588# This macro should be followed by calling AC_FPP_FIXEDFORM([.srcext]) 4589# and AC_FPP_FREEFORM([.srcext]) as appropriate for whichever source 4590# extensions are used in the user's project. 4591# 4592# This will fail to give the correct result when fixed-format files may be 4593# preprocessed directly by the compiler, but free-format ones 4594# may not. 4595# 4596# Supported features are: 4597# 4598# include : correctly process #include directives and -I 4599# define : correctly process -D 4600# substitute: substitute macros in Fortran code 4601# (some preprocessors touch only lines starting with #) 4602# wrap : wrap lines that become too long through macro substitution 4603# fpp is probably the only preprocessor that does this. 4604# cstyle : Do not suppress C style comments (-C option in cpp) 4605# CSTYLE : *Do* suppress C style comments 4606# (e.g. code contains C-style comments, and compiler may not 4607# know how to handle them) 4608# cxxstyle : Do not suppress C++ style comments (default) 4609# CXXSTYLE : *Do* suppress C++ style comments (seems unlikely, but in here 4610# for completeness 4611# 4612# Features can be abbreviated: i, in, inc etc. are equivalent to include. 4613# Features can be deselected (feature not needed) by prepending "no", 4614# e.g. nodef (=nodefine), now (=nowrap). 4615# 4616# Default for the feature list is 4617# [include define substitute nowrap nocstyle noCSTYLE cxxstyle] 4618# Feature requirements corresponding to the defaults may be omitted 4619# 4620# Note that "wrap" implies "substitute", and CSTYLE and cstyle cannot 4621# be requested at the same time. The macro adjusts this automatically. 4622# 4623# This macro sets and substitutes the variables FPP and FPPFLAGS, and 4624# causes to be set FPP_OUTPUT, FPP_MAKE_FLAGS, and FPP_COMPILE_EXT 4625# (actually set in macro _AC_FPP_BUILD_RULE) 4626# 4627# The macro depends on both FC and CPP, because we must possibly fall 4628# back on CPP for preprocessing. 4629# 4630# We presume that there is no preprocessing dependence on the language 4631# variant, so that a preprocessor will handle free-form F9x as happily as 4632# fixed-form F77. 4633# 4634AC_DEFUN([AC_PROG_FPP], 4635[AC_REQUIRE([AC_PROG_FC])dnl 4636dnl We are not going to use AC_REQUIRE(AC_PROG_CPP) here for 4637dnl two reasons: 4638dnl 1) we don't really need to if FC will preprocess itself 4639dnl 2) we can't pass in an optional parameter to change the 4640dnl default CPP search order, which we need to. 4641dnl AC_REQUIRE([AC_PROG_CPP([cpp])])dnl 4642 4643# Prefer AC_PROG_FC to AC_PROG_F77 4644if test "X$F77" != X; then 4645 AC_MSG_WARN([Use A@&t@C_PROG_FC with A@&t@C_PROG_FPP, instead of A@&t@C_PROG_F77]) 4646fi 4647 4648AC_ARG_VAR([FPP], [Command to preprocess Fortran code]) 4649AC_ARG_VAR([FPPFLAGS], [Flags for the Fortran preprocessor]) 4650# Set up ac_fpp_need_* flags based on features in $1 4651_AC_PROG_FPP_FEATURES([$1]) 4652 4653# We first try to use FC for compiling the source directly 4654# into object files 4655ac_fpp_compile='${FC-fc} -c $FPPFLAGS $FPPFLAGS_SRCEXT $FCFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD' 4656ac_fpp_link='${FC-fc} $ac_link_obj_flag""conftest${ac_exeext} $FPPFLAGS $FPPFLAGS_SRCEXT $FCFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD' 4657 4658AC_LANG_PUSH(Preprocessed Fortran) 4659FPP_SRC_EXT=F 4660 4661# _AC_PROG_FC_CPP does the actual feature tests, storing results of the 4662# checks in non-cv variables like ac_prog_fc_cpp_*, which we copy to cv 4663# variables afterwards. This allows this macro to be reusable for other 4664# cv variables (see below) 4665ac_fc_testing_fpp=direct 4666_AC_PROG_FC_CPP 4667 4668AC_CACHE_CHECK([whether $FC compiles programs with cpp directives], 4669 ac_cv_prog_fc_cpp, 4670 [ac_cv_prog_fc_cpp=$ac_prog_fc_cpp]) 4671 4672if test $ac_prog_fc_cpp = yes; then 4673 4674 if test $ac_fpp_need_d = yes; then 4675 AC_CACHE_CHECK([whether $FC accepts -D], 4676 ac_cv_prog_fc_cpp_d, 4677 [ac_cv_prog_fc_cpp_d=$ac_prog_fc_cpp_d]) 4678 fi 4679 4680 if test $ac_fpp_need_i = yes; then 4681 AC_CACHE_CHECK([whether $FC accepts -I], 4682 ac_cv_prog_fc_cpp_i, 4683 [ac_cv_prog_fc_cpp_i=$ac_prog_fc_cpp_i]) 4684 fi 4685 4686 if test $ac_fpp_need_subs = yes; then 4687 AC_CACHE_CHECK([whether $FC substitutes macros in Fortran code], 4688 ac_cv_prog_fc_cpp_subs, 4689 [ac_cv_prog_fc_cpp_subs=$ac_prog_fc_cpp_subs]) 4690 fi 4691 4692 if test $ac_fpp_need_wrap = yes; then 4693 AC_CACHE_CHECK([whether $FC wraps long lines automatically], 4694 ac_cv_prog_fc_cpp_wrap, 4695 [ac_cv_prog_fc_cpp_wrap=$ac_prog_fc_cpp_wrap]) 4696 fi 4697 4698# Don't need to test if $FC removes C++ comments - that 4699# way madness lies. 4700 4701fi # test $ac_prog_fc_cpp = yes 4702 4703AC_CACHE_CHECK([whether $FC fulfils requested features], 4704 ac_cv_prog_fc_cpp_ok, 4705 [ac_cv_prog_fc_cpp_ok=$ac_fpp_ok]) 4706 4707# Keep the user informed 4708AC_MSG_CHECKING([preprocessing mode we may therefore use]) 4709 4710# If so, we don't need to go any further. 4711if test $ac_fpp_ok = yes; then 4712 ac_cv_fpp_build_rule=direct 4713 AC_MSG_RESULT([direct]) 4714else 4715# indirect compilation 4716 AC_MSG_RESULT([indirect]) 4717 4718# Now we check how to invoke a preprocessor that outputs Fortran code 4719# that FC can understand 4720#FIXME: in a joint C/Fortran project, CPP might have already 4721# been defined. Here we are potentially (probably) redefining it. 4722# I don't think this matters. Not sure, though. 4723# In that case, AC_SUBST has already been called on CPP. 4724# We don't want to fail if we can't find cpp - we might be able 4725# to fall back on fpp. 4726#FIXME: actually, we should just prefer cpp to $CPP 4727 AC_PROG_CPP([cpp],[],[]) 4728# The next macro sets FPP (unless already set by the user) 4729_AC_PROG_FPP 4730_AC_PROG_FPP_P 4731 4732# Before we go any further, check that we're not courting disaster, 4733# here, by using indirect compilation (.F -> .f -> .o) on a 4734# case-insensitive filesystem. If we are, there's nothing we can do 4735# other than fail noisily. 4736_AC_FC_CHECK_CIFS 4737# Redefine the compile and link commands for indirect compilation 4738if test $ac_cv_fc_cifs = yes; then 4739 if test "x$ac_fpp_out" = x ; then 4740 AC_MSG_ERROR([Confused in preprocessing on case-insensitive FS - please report to tow@uszla.me.uk]) 4741 fi 4742 ac_fpp_compile='${FPP-fpp} $FPPFLAGS $FPPFLAGS_SRCEXT conftest.$ac_ext > conftest.cpp.f && ${FC-fc} -c $FCFLAGS -o conftest.o conftest.cpp.f >&AS_MESSAGE_LOG_FD; rm conftest.cpp.f' 4743 ac_fpp_link='${FPP-fpp} $FPPFLAGS conftest.$ac_ext $FPPFLAGS_SRCEXT > conftest.cpp.f && ${FC-fc} $ac_link_obj_flag""conftest${ac_exeext} $FCFLAGS $LDFLAGS conftest.cpp.f $LIBS >&AS_MESSAGE_LOG_FD; rm conftest.cpp.f' 4744else 4745 ac_fpp_compile='${FPP-fpp} $FPPFLAGS $FPPFLAGS_SRCEXT conftest.$ac_ext '"$ac_fpp_out"' && ${FC-fc} -c $FCFLAGS conftest.f >&AS_MESSAGE_LOG_FD; rm conftest.f' 4746 ac_fpp_link='${FPP-fpp} $FPPFLAGS conftest.$ac_ext $FPPFLAGS_SRCEXT '"$ac_fpp_out"' && ${FC-fc} $ac_link_obj_flag""conftest${ac_exeext} $FCFLAGS $LDFLAGS conftest.f $LIBS >&AS_MESSAGE_LOG_FD; rm conftest.f' 4747fi 4748 4749 ac_compile=$ac_fpp_compile 4750 ac_link=$ac_fpp_link 4751# Redo all the feature checks for indirect compilation. 4752 ac_fc_testing_fpp=indirect 4753 _AC_PROG_FC_CPP 4754 4755if test $ac_fpp_need_d = yes; then 4756 AC_CACHE_CHECK([whether $FPP accepts -D], 4757 ac_cv_prog_fpp_d, 4758 [ac_cv_prog_fpp_d=$ac_prog_fc_cpp_d]) 4759fi 4760 4761if test $ac_fpp_need_i = yes; then 4762 AC_CACHE_CHECK([whether $FPP accepts -I], 4763 ac_cv_prog_fpp_i, 4764 [ac_cv_prog_fpp_i=$ac_prog_fc_cpp_i]) 4765fi 4766 4767if test $ac_fpp_need_subs = yes; then 4768 AC_CACHE_CHECK([whether $FPP substitutes macros in Fortran code], 4769 ac_cv_prog_fpp_subs, 4770 [ac_cv_prog_fpp_subs=$ac_prog_fc_cpp_subs]) 4771fi 4772 4773if test $ac_fpp_need_wrap = yes; then 4774 AC_CACHE_CHECK([whether $FPP wraps long lines automatically], 4775 ac_cv_prog_fpp_wrap, 4776 [ac_cv_prog_fpp_wrap=$ac_prog_fc_cpp_wrap]) 4777fi 4778 4779if test $ac_fpp_need_CSTYLE = yes; then 4780 AC_CACHE_CHECK([whether $FPP suppresses C-style comments], 4781 ac_cv_prog_fpp_CSTYLE, 4782 [ac_cv_prog_fpp_CSTYLE=$ac_prog_fc_cpp_CSTYLE]) 4783 4784elif test $ac_fpp_need_cstyle = yes; then 4785# It only makes sense to test this for indirect compilation, 4786# i.e., if .f files are generated 4787 _AC_PROG_FPP_CSTYLE 4788fi 4789 4790if test $ac_fpp_need_cxxstyle = yes; then 4791 AC_CACHE_CHECK([whether $FPP preserves C++-style comments], 4792 ac_cv_prog_fpp_cxxstyle, 4793 [ac_cv_prog_fpp_cxxstyle=$ac_prog_fc_cpp_cxxstyle]) 4794fi 4795 4796AC_CACHE_CHECK([whether $FPP fulfils requested features], 4797 ac_cv_prog_fpp_ok, 4798 [ac_cv_prog_fpp_ok=$ac_fpp_ok]) 4799 4800 ac_cv_fpp_build_rule=indirect 4801 4802if test ac_fpp_ok = no; then 4803 AC_MSG_ERROR([Cannot find a Fortran preprocessor with the requested features]) 4804fi 4805 4806fi # test ac_fpp_ok != yes 4807 4808# We have all necessary information. 4809# It remains to construct optimal build rules 4810# (direct: .F.o or indirect: .F.f) 4811# and carry out the substitutions. 4812# 4813# This is the crucial bit: we switch on ac_cv_fpp_build_rule=direct/indirect, 4814# setting and AC_SUBSTing the variables documented in _AC_FPP_BUILD_RULE. 4815# 4816# Do we actually have all the required information yet, or do we need 4817# to look at AC_FC_(FIXED|FREE)FORM results also? I think we're OK: 4818# if the compiler can do all the preprocessing itself, then we don't 4819# have to do anything (ie, the `direct' branch should be trivial), and 4820# if we have to do separate preprocessing, the processor is probably 4821# (?) independent of the source language variant. 4822_AC_FPP_BUILD_RULE 4823 4824AC_LANG_POP(Preprocessed Fortran) 4825 4826])# AC_PROG_FPP 4827# _AC_COMPILER_EXEEXT_DEFAULT 4828# --------------------------- 4829# Check for the extension used for the default name for executables. 4830# 4831# We do this in order to find out what is the extension we must add for 4832# creating executables (see _AC_COMPILER_EXEEXT's comments). 4833# 4834# Beware of `expr' that may return `0' or `'. Since this macro is 4835# the first one in touch with the compiler, it should also check that 4836# it compiles properly. 4837# 4838# On OpenVMS 7.1 system, the DEC C 5.5 compiler when called through a 4839# GNV (gnv.sourceforge.net) cc wrapper, produces the output file named 4840# `a_out.exe'. 4841m4_define([_AC_COMPILER_EXEEXT_DEFAULT], 4842[# First try to determine the flag needed to name the executable 4843# It is nearly always "-o" but Lahey Fortran wants "-out" 4844AC_MSG_CHECKING([for linker flag to name executables]) 4845for ac_link_obj_flag in "/exe:" "-out " "-o "; do 4846AS_IF([_AC_DO_VAR(ac_link)], 4847[ac_link_obj_flag_found=yes; break], 4848[:]) 4849done 4850if test x$ac_link_obj_flag_found = x ; then 4851AC_MSG_FAILURE([Could not determine flag to name executables]) 4852fi 4853AC_MSG_RESULT([$ac_link_obj_flag]) 4854 4855# Try to create an executable without -o first, disregard a.out. 4856# It will help us diagnose broken compilers, and finding out an intuition 4857# of exeext. 4858AC_MSG_CHECKING([for _AC_LANG compiler default output file name]) 4859ac_link_default=`echo "$ac_link" | sed ['s/ $ac_link_obj_flag *conftest[^ ]*//']` 4860# 4861# List of possible output files, starting from the most likely. 4862# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) 4863# only as a last resort. b.out is created by i960 compilers. 4864ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' 4865# 4866# The IRIX 6 linker writes into existing files which may not be 4867# executable, retaining their permissions. Remove them first so a 4868# subsequent execution test works. 4869ac_rmfiles= 4870for ac_file in $ac_files 4871do 4872 case $ac_file in 4873 _AC_COMPILER_EXEEXT_REJECT ) ;; 4874 * ) ac_rmfiles="$ac_rmfiles $ac_file";; 4875 esac 4876done 4877rm -f $ac_rmfiles 4878 4879AS_IF([_AC_DO_VAR(ac_link_default)], 4880[# Autoconf-2.13 could set the ac_cv_exeext variable to `no'. 4881# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' 4882# in a Makefile. We should not override ac_cv_exeext if it was cached, 4883# so that the user can short-circuit this test for compilers unknown to 4884# Autoconf. 4885for ac_file in $ac_files 4886do 4887 test -f "$ac_file" || continue 4888 case $ac_file in 4889 _AC_COMPILER_EXEEXT_REJECT ) 4890 ;; 4891 [[ab]].out ) 4892 # We found the default executable, but exeext='' is most 4893 # certainly right. 4894 break;; 4895 *.* ) 4896 if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; 4897 then :; else 4898 ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']` 4899 fi 4900 # We set ac_cv_exeext here because the later test for it is not 4901 # safe: cross compilers may not add the suffix if given an `-o' 4902 # argument, so we may need to know it at that point already. 4903 # Even if this section looks crufty: it has the advantage of 4904 # actually working. 4905 break;; 4906 * ) 4907 break;; 4908 esac 4909done 4910test "$ac_cv_exeext" = no && ac_cv_exeext= 4911], 4912 [_AC_MSG_LOG_CONFTEST 4913AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)]) 4914ac_exeext=$ac_cv_exeext 4915AC_MSG_RESULT([$ac_file]) 4916])# _AC_COMPILER_EXEEXT_DEFAULT 4917