You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

f_check 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #!/usr/bin/perl
  2. #
  3. # 1. Not specified
  4. # 1.1 Automatically detect, then check compiler
  5. # 1.2 If no fortran compiler is detected, g77 is default with NOFORTRAN definition
  6. # 2. Specified
  7. # 2.1 If path is correct, check compiler
  8. # 2.2 If path is not correct, but still valid compiler name, force setting
  9. # 2.2.2 Path is not correct, invalid compiler name, then g77 is default with NOFORTRAN definition
  10. #
  11. $makefile = shift(@ARGV);
  12. $config = shift(@ARGV);
  13. $nofortran = 0;
  14. $compiler = join(" ", @ARGV);
  15. # f77 is too ambiguous
  16. $compiler = "" if $compiler eq "f77";
  17. @path = split(/:/, $ENV{"PATH"});
  18. if ($compiler eq "") {
  19. @lists = ("f77", "g77", "g95", "gfortran", "frt", "fort", "openf90", "openf95",
  20. "sunf77", "sunf90", "sunf95",
  21. "xlf95", "xlf90", "xlf",
  22. "ppuf77", "ppuf95", "ppuf90", "ppuxlf",
  23. "pathf90", "pathf95",
  24. "pgf95", "pgf90", "pgf77",
  25. "ifort");
  26. foreach $lists (@lists) {
  27. foreach $path (@path) {
  28. if (-f $path . "/" . $lists) {
  29. $compiler = $lists;
  30. break;
  31. }
  32. }
  33. }
  34. }
  35. if ($compiler eq "") {
  36. $nofortran = 1;
  37. $compiler = "g77";
  38. $vendor = G77;
  39. $bu = "_";
  40. } else {
  41. $data = `which $compiler > /dev/null 2> /dev/null`;
  42. $vendor = "";
  43. if (!$?) {
  44. $data = `$compiler -O2 -S ftest.f > /dev/null 2>&1 && cat ftest.s && rm -f ftest.s`;
  45. if ($data =~ /zhoge_/) {
  46. $bu = "_";
  47. }
  48. if ($data =~ /GNU/) {
  49. $data =~ /(\d)\.(\d).(\d)/;
  50. $major = $1;
  51. $minor = $2;
  52. if ($major >= 4) {
  53. $vendor = GFORTRAN;
  54. $openmp = "-fopenmp";
  55. } else {
  56. $vendor = G77;
  57. $openmp = "";
  58. }
  59. }
  60. if ($data =~ /g95/) {
  61. $vendor = G95;
  62. $openmp = "";
  63. }
  64. if ($data =~ /Intel/) {
  65. $vendor = INTEL;
  66. $openmp = "-openmp";
  67. }
  68. if ($data =~ /Sun Fortran/) {
  69. $vendor = SUN;
  70. $openmp = "-xopenmp=parallel";
  71. }
  72. if ($data =~ /PathScale/) {
  73. $vendor = PATHSCALE;
  74. $openmp = "-openmp";
  75. }
  76. if ($data =~ /Open64/) {
  77. $vendor = OPEN64;
  78. $openmp = "-mp";
  79. }
  80. if ($data =~ /PGF/) {
  81. $vendor = PGI;
  82. $openmp = "-mp";
  83. }
  84. if ($data =~ /IBM/) {
  85. $vendor = IBM;
  86. $openmp = "-openmp";
  87. }
  88. }
  89. if ($vendor eq "") {
  90. if ($compiler =~ /g77/) {
  91. $vendor = G77;
  92. $bu = "_";
  93. $openmp = "";
  94. }
  95. if ($compiler =~ /g95/) {
  96. $vendor = G95;
  97. $bu = "_";
  98. $openmp = "";
  99. }
  100. if ($compiler =~ /gfortran/) {
  101. $vendor = GFORTRAN;
  102. $bu = "_";
  103. $openmp = "-fopenmp";
  104. }
  105. if ($compiler =~ /ifort/) {
  106. $vendor = INTEL;
  107. $bu = "_";
  108. $openmp = "-openmp";
  109. }
  110. if ($compiler =~ /pathf/) {
  111. $vendor = PATHSCALE;
  112. $bu = "_";
  113. $openmp = "-mp";
  114. }
  115. if ($compiler =~ /pgf/) {
  116. $vendor = PGI;
  117. $bu = "_";
  118. $openmp = "-mp";
  119. }
  120. if ($compiler =~ /ftn/) {
  121. $vendor = PGI;
  122. $bu = "_";
  123. $openmp = "-openmp";
  124. }
  125. if ($compiler =~ /frt/) {
  126. $vendor = FUJITSU;
  127. $bu = "_";
  128. $openmp = "-openmp";
  129. }
  130. if ($compiler =~ /sunf77|sunf90|sunf95/) {
  131. $vendor = SUN;
  132. $bu = "_";
  133. $openmp = "-xopenmp=parallel";
  134. }
  135. if ($compiler =~ /ppuf/) {
  136. $vendor = IBM;
  137. $openmp = "-openmp";
  138. }
  139. if ($compiler =~ /xlf/) {
  140. $vendor = IBM;
  141. $openmp = "-openmp";
  142. }
  143. if ($compiler =~ /open64/) {
  144. $vendor = OPEN64;
  145. $openmp = "-mp";
  146. }
  147. if ($vendor eq "") {
  148. $nofortran = 1;
  149. $compiler = "g77";
  150. $vendor = G77;
  151. $bu = "_";
  152. $openmp = "";
  153. }
  154. }
  155. }
  156. $data = `which $compiler > /dev/null 2> /dev/null`;
  157. if (!$?) {
  158. $binary = $ENV{"BINARY"};
  159. $openmp = "" if $ENV{USE_OPENMP} != 1;
  160. if ($binary == 32) {
  161. $link = `$compiler $openmp -m32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
  162. if ($?) {
  163. $link = `$compiler $openmp -q32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
  164. }
  165. $binary = "" if ($?);
  166. }
  167. if ($binary == 64) {
  168. $link = `$compiler $openmp -m64 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
  169. if ($?) {
  170. $link = `$compiler $openmp -q64 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
  171. }
  172. $binary = "" if ($?);
  173. }
  174. if ($binary eq "") {
  175. $link = `$compiler $openmp -v ftest2.f 2>&1 && rm -f a.out a.exe`;
  176. }
  177. }
  178. $linker_L = "";
  179. $linker_l = "";
  180. $linker_a = "";
  181. if ($link ne "") {
  182. $link =~ s/\-Y\sP\,/\-Y/g;
  183. $link =~ s/\-rpath\s+/\-rpath\@/g;
  184. @flags = split(/[\s\,\n]/, $link);
  185. foreach $flags (@flags) {
  186. if (
  187. ($flags =~ /^\-L/)
  188. && ($flags !~ /^-LIST:/)
  189. && ($flags !~ /^-LANG:/)
  190. ) {
  191. if ($vendor eq "PGI") {
  192. $flags =~ s/lib$/libso/;
  193. }
  194. $linker_L .= $flags . " ";
  195. }
  196. if ($flags =~ /^\-Y/) {
  197. $linker_L .= "-Wl,". $flags . " ";
  198. }
  199. if ($flags =~ /^\-rpath/) {
  200. $flags =~ s/\@/\,/g;
  201. if ($vendor eq "PGI") {
  202. $flags =~ s/lib$/libso/;
  203. }
  204. $linker_L .= "-Wl,". $flags . " " ;
  205. }
  206. if (
  207. ($flags =~ /^\-l/)
  208. && ($flags !~ /gfortranbegin/)
  209. && ($flags !~ /frtbegin/)
  210. && ($flags !~ /pathfstart/)
  211. && ($flags !~ /numa/)
  212. && ($flags !~ /crt[0-9]/)
  213. && ($flags !~ /gcc/)
  214. && ($flags !~ /user32/)
  215. && ($flags !~ /kernel32/)
  216. && ($flags !~ /advapi32/)
  217. && ($flags !~ /shell32/)
  218. ) {
  219. $linker_l .= $flags . " ";
  220. }
  221. $linker_a .= $flags . " " if $flags =~ /\.a$/;
  222. }
  223. }
  224. open(MAKEFILE, ">> $makefile") || die "Can't append $makefile";
  225. open(CONFFILE, ">> $config" ) || die "Can't append $config";
  226. print MAKEFILE "F_COMPILER=$vendor\n";
  227. print MAKEFILE "FC=$compiler\n";
  228. print MAKEFILE "BU=$bu\n" if $bu ne "";
  229. print MAKEFILE "NOFORTRAN=1\n" if $nofortran == 1;
  230. print CONFFILE "#define BUNDERSCORE\t$bu\n" if $bu ne "";
  231. print CONFFILE "#define NEEDBUNDERSCORE\t1\n" if $bu ne "";
  232. if (($linker_l ne "") || ($linker_a ne "")) {
  233. print MAKEFILE "FEXTRALIB=$linker_L $linker_l $linker_a\n";
  234. }
  235. close(MAKEFILE);
  236. close(CONFFILE);

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.