岐阜大学 流域圏科学研究センター
水系動態研究分野
水文気象学研究室
(玉川研究室)
NCAR LSM のサンプルを動作させるには
2006.10.4 の玉川のメールから
研究室の皆さん (特に扇本君 [と斎藤君かな])
玉川です。NCAR LSM のサンプルの実行ができなかった件について
解決した (と思う) ので、連絡します
最初から説明すると
http://www.cgd.ucar.edu/tss/lsm/availability.html
ここから、datasets.tar.Z model.tar.Z technote.tar.Z unix_scripts.tar.Z を
ダウンロードします。
例えば、LSM というディレクトリにダウンロードしたとして
次に、全てを展開します。
cd LSM
tar zxvf datasets.tar.Z
tar zxvf model.tar.Z
tar zxvf technote.tar.Z
tar zxvf unix_scripts.tar.Z
あるいは tcsh を使っているなら
cd LSM
foreach t (*tar.Z)
tar zxvf $t
end
その次に、unix_scripts の下にあるコンパイルとテスト実行のスクリプト run_lsmv1.s
を
編集します。
cpp と f77 を使うようになっているので、
which cpp
which f77
として、それぞれのコマンドの場所を確認します。
多分 /usr/bin/cpp /usr/bin/f77 となっていると思います。
run_lsmv1.s の 15行目から20行目のを以下のように変更します。
----- もとのファイル ----
# compile code using cpp to build single source file
alias cpp '/usr/lang/SC2.0.1/cpp'
alias f77 '/usr/lang/SC2.0.1/f77'
cpp -I../../model ../../model/lsmsrc.h src.f
f77 -o src.x src.f
-----
----- 変更後のファイル ----
# compile code using cpp to build single source file
# alias cpp '/usr/lang/SC2.0.1/cpp'
# alias f77 '/usr/lang/SC2.0.1/f77'
alias cpp '/usr/bin/cpp'
alias f77 '/usr/bin/f77 -O3'
f77 -I../../model ../../model/*.F -o src.x
-----
更に、下から3行目
src.x < nl.dat > output &
の最初に、./ を追加して
./src.x < nl.dat > output &
とします。
この2点の変更で、コンパイルと実行が可能です。
実行は、
unix_scripts に移動して、( cd unix_scripts など )
./run_lsmv1.s
です。 結果等は、unix_scripts の下の LSMV1 に書かれます。
* 解説を入れると、拡張子 .F のファイルは、フォートランコンパイラからは
プリプロセッサ cpp (あるいは fpp) で処理された後コンパイルされるファイルと
扱われます。また -I は、インクルードされるファイルの標準の置き場所を指定する
オプションです。
* 実行時のさまざまな設定は、cat 〜 end までに書かれているようです。
P.S. これなら Cygwin でも動きそうですね。。。
取り急ぎ。
追加: Cygwin で動きました。もちろん g95 や gfortran でも動きます
gfortran の場合 バイト並びを逆にする 以下のオプションもあります。
man gfortran から
These options affect the runtime behavior of gfortran.
-fconvert=conversion
Specify the representation of data for unformatted files. Valid
values for conversion are: native, the default; swap, swap between
big- and little-endian; big-endian, use big-endian representation
for unformatted files; little-endian, use little-endian representa-
tion for unformatted files.
This option has an effect only when used in the main program. The
"CONVERT" specifier and the GFORTRAN_CONVERT_UNIT environment vari-
able override the default specified by -fconvert.
Info のページへ戻る
研究室のTOPへ戻る