fotran2cpp
Automatic Fortran to C++ conversion
1. 安装fable环境
Pre-requisites:
Please have a Linux environment, bash shell.
Please create a working directory
1
2export WORK=<new working directory>
cd ${WORK}Download source code:
1
2wget https://raw.githubusercontent.com/cctbx/cctbx_project/master/libtbx/auto_build/bootstrap.py --no-check-certificate
python bootstrap.py hot update --builder=cctbx
Create and configure a conda environment:
1 | wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh --no-check-certificate |
Create and configure FABLE:
1 | mkdir build36 |
Test FABLE in a new login shell (bash, cd ${WORK}):
1 | source miniconda2/etc/profile.d/conda.sh |
[!NOTE]
Not yet tested with MacOSX
Also works with Python 2.7 (change 3.6 to 2.7)
2. 使用fable
[!IMPORTANT]
fable comes with the C++ fem Fortran EMulation library. The entire fem library is inlined and therefore very easy to use: simply add
-I/actual/path/fableor similar to the compilation command.
先启动上面创建好的python环境
1 | source miniconda2/etc/profile.d/conda.sh |
之后开始转换代码
1 | fable.cout your_fortran_code.f --namespace=example > example.cpp |
编译新生成的C++代码
1 | g++ example.cpp -I ${WORK}/fable -I ${WORK}/fable/modules/cctbx_project |
[!NOTE]
其他问题可以参阅 https://cci.lbl.gov/fable/