0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

gitbashやCygwinでifortコマンド(Intel Fortran Compiler)を使う

Posted at

Windowsで開発するプログラマはコマンドプロンプトなどPowerShell系環境よりWSLやCygwinやgitbashなどのLinux系環境を使う人々が多いでしょう
参考:Windows でシェル スクリプトを実行する方法

ところがIntel Fortran Compilerはsetvars.batというバッチファイルでコンパイル環境を用意するためPowerShell系環境を使うことを強制させられるという問題があります。

その解決のためifortコマンドのように動作するシェルスクリプトを作りました。
あなたの御用のためにお使いください

ifort.sh
#!/usr/bin/env sh
# これはgitbashでコマンドプロンプトのようにifortを起動するためのスクリプトです
# ./ifort.sh -Qmkl -openmp hello.f90
# のようにコマンドプロンプトとの差異を感じずに使えます。
set -eux
# この変数にインストールしたIntel Fortranの環境変数設定バッチファイルの起動コマンドを入れる
readonly IFORT_SETVARS_BAT='"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 vs2022'
# IFORTを起動
echo "%ComSpec% /E:ON /C \" $IFORT_SETVARS_BAT & ifort $@\"" | cmd

IFORT_SETVARS_BATに適切なsetvars.batの起動コマンドを入れてください
みればわかる通り、内部でcmd.exeを起動しています。

./ifort.sh -Qmkl -openmp hello.f90
のようにopenmpやmklを使うプログラムも通常のifortコマンドと同様に使用可能です。

よいBash生活 on Windowsを

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?