Set up python-fabm

Table of Contents

インストール

Linux上において,python-fabmのセットアップを行った備忘録です.ホームディレクトリ[cci]~/[/cci]直下にインストールすることを想定します.また,Python 2.7が必要です.[cci]miniconda[/cci]でPython 2.7の仮想環境[cci]pyfabm[/cci]を作成し,activateしておきます.さらに,jupyter notebookをはじめ,一通りのパッケージが[cci]pyfabm[/cci]環境でインストールされている必要があります.

ソースコードの入手

Githubから最新のソースコードを入手します.展開すると,[cci]~/fabm/[/cci]が作成されます.
[cc lang='bash']
~/$ git clone https://github.com/fabm-model/fabm.git
[/cc]

インストールスクリプトの準備

ビルド用のディレクトリ[cci]~/fabm/build/[/cci]を作成しておきます.
[cci]~/fabm/scripts/linux/[/cci]に存在するconfigureとbuild用のスクリプト,[cci]fabm_configure_python.sh[/cci]と[cci]fabm_build_python.sh[/cci]を[cci]~/fabm/build/[cci]にコピーします.[cci]fabm_configure_python.sh[/cci]を適切に編集します.ifortでコンパイルする場合の例を以下に示します.
[cc lang='bash']
#!/bin/sh

# if not set use the suggested source code installation directories
FABM_BASE=${FABM_BASE:=~/fabm}

# default Fortran compiler is gfortran - overide by setting compuiler like:
export compiler=ifort
compiler=${compiler:=gfortran}

host=python
# ready to configure
mkdir -p $host/$compiler
cd $host/$compiler
cmake $FABM_BASE/src/drivers/python \
-DFABM_EMBED_VERSION=on \
-DCMAKE_Fortran_COMPILER=$compiler
cd ../..
[/cc]
次に,[cci]fabm_build_python.sh[/cci]を以下のように編集します.
[cc lang='bash']
#!/bin/bash

if [ "$1" != "" ]; then
action=$1
echo "doing a "$action
else
action=install
fi

# default Fortran compiler is gfortran - overide by setting compuiler like:
export compiler=ifort
compiler=${compiler:=gfortran}

host=python

np=-j8
cd $host/$compiler
make $np $action
cd ../..
[/cc]

ビルド

用意したスクリプトを用いてconfigureおよびbuildしインストールします.[cci]~/fabm/build/[/cci]に移動します.
[cc lang='bash']
~/fabm/build$ ./fabm_configure_python.sh
-- The Fortran compiler identification is Intel 18.0.3.20180410
-- Check for working Fortran compiler: /opt/intel/compilers_and_libraries_2018.3.222/linux/bin/intel64/ifort
-- Check for working Fortran compiler: /opt/intel/compilers_and_libraries_2018.3.222/linux/bin/intel64/ifort -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /opt/intel/compilers_and_libraries_2018.3.222/linux/bin/intel64/ifort supports Fortran 90
-- Checking whether /opt/intel/compilers_and_libraries_2018.3.222/linux/bin/intel64/ifort supports Fortran 90 -- yes
-- Found PythonInterp: /home/username/miniconda3/envs/pyfabm/bin/python (found version "2.7.15")
-- Installation prefix: /home/username/.local/lib/python2.7/site-packages
-- Configuring done
-- Generating done
-- Build files have been written to: /home/username/fabm/build/python/ifort
[/cc]
[cc lang='bash']
~/fabm/build$ ./fabm_build_python.sh
Scanning dependencies of target fabm_version
Scanning dependencies of target yaml
Scanning dependencies of target fabm_base
[ 1%] Retrieving description of last FABM commit...
[ 2%] Building Fortran object fabm/yaml/CMakeFiles/yaml.dir/yaml_types.F90.o
[ 3%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_driver.F90.o
[ 5%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_properties.F90.o
[ 5%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_standard_variables.F90.o
[ 5%] Built target fabm_version
[ 6%] Building Fortran object fabm/yaml/CMakeFiles/yaml.dir/yaml.F90.o
[ 7%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_types.F90.o
[ 7%] Built target yaml
[ 8%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_builtin_models.F90.o
[ 11%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_particle.F90.o
[ 11%] Building Fortran object fabm/CMakeFiles/fabm_base.dir/fabm_expressions.F90.o
[ 11%] Built target fabm_base
Scanning dependencies of target fabm_models_aed
Scanning dependencies of target fabm_models_bb
Scanning dependencies of target fabm_models_iow
Scanning dependencies of target fabm_models_hzg
Scanning dependencies of target fabm_models_klimacampus
Scanning dependencies of target fabm_models_au
Scanning dependencies of target fabm_models_metu
Scanning dependencies of target fabm_models_msi
[ 12%] Building Fortran object fabm/models/metu/CMakeFiles/fabm_models_metu.dir/mnemiopsis/mnemiopsis.F90.o
[ 13%] Building Fortran object fabm/models/bb/CMakeFiles/fabm_models_bb.dir/filter_feeder/filter_feeder.F90.o
[ 14%] Building Fortran object fabm/models/iow/CMakeFiles/fabm_models_iow.dir/age/iow_age.F90.o
[ 15%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_core.F90.o
[ 16%] Building Fortran object fabm/models/klimacampus/CMakeFiles/fabm_models_klimacampus.dir/phy_feedback/phy_feedback.F90.o
[ 17%] Building Fortran object fabm/models/au/CMakeFiles/fabm_models_au.dir/prey_predator/jacob_monod.F90.o
[ 20%] Building Fortran object fabm/models/msi/CMakeFiles/fabm_models_msi.dir/ergom1/ergom1.F90.o
[ 20%] Building Fortran object fabm/models/hzg/CMakeFiles/fabm_models_hzg.dir/omexdia_p/omexdia_p.F90.o
[ 20%] Built target fabm_models_metu
[ 20%] Built target fabm_models_hzg
[ 21%] Building Fortran object fabm/models/iow/CMakeFiles/fabm_models_iow.dir/ergom/ergom_cgt.F90.o
[ 22%] Building Fortran object fabm/models/au/CMakeFiles/fabm_models_au.dir/prey_predator/lotka_volterra.F90.o
[ 23%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_util.F90.o
[ 23%] Built target fabm_models_klimacampus
[ 24%] Building Fortran object fabm/models/bb/CMakeFiles/fabm_models_bb.dir/lorenz63/lorenz63.F90.o
Scanning dependencies of target fabm_models_examples
Scanning dependencies of target fabm_models_gotm
Scanning dependencies of target fabm_models_jrc
[ 24%] Built target fabm_models_msi
[ 25%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/benthic_predator.F90.o
[ 26%] Building Fortran object fabm/models/gotm/CMakeFiles/fabm_models_gotm.dir/ergom/ergom.F90.o
[ 27%] Building Fortran object fabm/models/jrc/CMakeFiles/fabm_models_jrc.dir/bsem/bsem.F90.o
Scanning dependencies of target fabm_models_pml
[ 28%] Building Fortran object fabm/models/pml/CMakeFiles/fabm_models_pml.dir/carbonate/carbonate.F90.o
[ 30%] Building Fortran object fabm/models/au/CMakeFiles/fabm_models_au.dir/prey_predator/prey_predator.F90.o
[ 31%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_chlorophylla.F90.o
[ 32%] Building Fortran object fabm/models/bb/CMakeFiles/fabm_models_bb.dir/passive/passive.F90.o
[ 33%] Building Fortran object fabm/models/iow/CMakeFiles/fabm_models_iow.dir/spm/spm.F90.o
[ 34%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/duplicator.F90.o
[ 35%] Building Fortran object fabm/models/gotm/CMakeFiles/fabm_models_gotm.dir/fasham/fasham.F90.o
[ 36%] Building Fortran object fabm/models/jrc/CMakeFiles/fabm_models_jrc.dir/med_ergom/med_ergom.F90.o
[ 37%] Building Fortran object fabm/models/pml/CMakeFiles/fabm_models_pml.dir/pml_model_library.F90.o
[ 38%] Building Fortran object fabm/models/au/CMakeFiles/fabm_models_au.dir/model_library.F90.o
[ 40%] Building Fortran object fabm/models/bb/CMakeFiles/fabm_models_bb.dir/bb_model_library.F90.o
[ 41%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_iron.F90.o
[ 42%] Building Fortran object fabm/models/iow/CMakeFiles/fabm_models_iow.dir/iow_model_library.F90.o
[ 43%] Building Fortran object fabm/models/pml/CMakeFiles/fabm_models_pml.dir/carbonate/co2_dyn.F90.o
[ 44%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/light_cycle.F90.o
[ 45%] Building Fortran object fabm/models/gotm/CMakeFiles/fabm_models_gotm.dir/light/light.F90.o
[ 46%] Building Fortran object fabm/models/jrc/CMakeFiles/fabm_models_jrc.dir/jrc_model_library.F90.o
[ 46%] Built target fabm_models_au
[ 46%] Built target fabm_models_bb
Scanning dependencies of target fabm_models_niva
[ 47%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_nitrogen.F90.o
Scanning dependencies of target fabm_models_akvaplan
[ 48%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/brom/brom_bio.F90.o
[ 50%] Building Fortran object fabm/models/akvaplan/CMakeFiles/fabm_models_akvaplan.dir/plume_injection.F90.o
[ 50%] Built target fabm_models_iow
[ 50%] Built target fabm_models_pml
[ 51%] Building Fortran object fabm/models/akvaplan/CMakeFiles/fabm_models_akvaplan.dir/tracer.F90.o
[ 52%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/mean.F90.o
[ 53%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/npzd/det.F90.o
[ 54%] Building Fortran object fabm/models/gotm/CMakeFiles/fabm_models_gotm.dir/npzd/npzd.F90.o
[ 54%] Built target fabm_models_jrc
[ 55%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/npzd/nut.F90.o
[ 56%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_organic_matter.F90.o
[ 57%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_phosphorus.F90.o
[ 58%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/brom/brom_carb.F90.o
[ 60%] Building Fortran object fabm/models/akvaplan/CMakeFiles/fabm_models_akvaplan.dir/akvaplan_model_library.F90.o
[ 61%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/npzd/phy.F90.o
[ 62%] Building Fortran object fabm/models/gotm/CMakeFiles/fabm_models_gotm.dir/gotm_model_library.F90.o
[ 63%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/npzd/zoo.F90.o
[ 64%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/nonlocal.F90.o
[ 65%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_sedflux.F90.o
[ 66%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_silica.F90.o
[ 67%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/brom/brom_eqconst.F90.o
[ 67%] Built target fabm_models_akvaplan
[ 68%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_sulfur.F90.o
[ 68%] Built target fabm_models_gotm
[ 70%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_totals.F90.o
[ 71%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/npzd/examples_npzd_model_library.F90.o
[ 72%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/brom/brom_redox.F90.o
[ 73%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/brom/brom_salt.F90.o
[ 74%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_tracer.F90.o
[ 75%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_zoop_utils.F90.o
[ 76%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/oxydep/oxydep.F90.o
[ 77%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_carbon.F90.o
[ 78%] Building Fortran object fabm/models/examples/CMakeFiles/fabm_models_examples.dir/examples_model_library.F90.o
[ 80%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_oxygen.F90.o
[ 81%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_pathogens.F90.o
[ 82%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_phyto_utils.F90.o
[ 83%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_zooplankton.F90.o
[ 84%] Building Fortran object fabm/models/niva/CMakeFiles/fabm_models_niva.dir/niva_model_library.F90.o
[ 84%] Built target fabm_models_examples
[ 85%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_phytoplankton.F90.o
[ 85%] Built target fabm_models_niva
[ 86%] Building Fortran object fabm/models/aed/CMakeFiles/fabm_models_aed.dir/aed_models.F90.o
[ 86%] Built target fabm_models_aed
Scanning dependencies of target fabm
[ 87%] Building Fortran object fabm/CMakeFiles/fabm.dir/fabm_coupling.F90.o
[ 88%] Building Fortran object fabm/CMakeFiles/fabm.dir/fabm_library.F90.o
[ 90%] Building Fortran object fabm/CMakeFiles/fabm.dir/fabm_version.F90.o
[ 91%] Building Fortran object fabm/CMakeFiles/fabm.dir/fabm.F90.o
[ 92%] Building Fortran object fabm/CMakeFiles/fabm.dir/fabm_config.F90.o
[ 93%] Linking Fortran static library libfabm.a
[ 93%] Built target fabm
Scanning dependencies of target python_fabm
[ 94%] Building Fortran object CMakeFiles/python_fabm.dir/c_helper.F90.o
[ 95%] Building Fortran object CMakeFiles/python_fabm.dir/helper.F90.o
[ 98%] Building Fortran object CMakeFiles/python_fabm.dir/variable.F90.o
[ 98%] Building Fortran object CMakeFiles/python_fabm.dir/link_list.F90.o
[ 98%] Building Fortran object CMakeFiles/python_fabm.dir/python_fabm.F90.o
[100%] Linking Fortran shared library libpython_fabm.so
[100%] Built target python_fabm
Install the project...
-- Install configuration: "Release"
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/libpython_fabm.so
-- Up-to-date: /home/username/.local/lib/python2.7/site-packages/pyfabm
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/complete_yaml.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/gui_qt.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils/fabm_complete_yaml.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils/fabm_configuration_gui.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils/fabm_describe_model.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils/fabm_evaluate.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils/fabm_stress_test.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/utils/__init__.py
-- Installing: /home/username/.local/lib/python2.7/site-packages/pyfabm/__init__.py
[/cc]

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください