Difference between revisions of "Documentation/Nightly/Developers/Fortran"

From Slicer Wiki
Jump to: navigation, search
Tag: 2017 source edit
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
 +
__TOC__
 +
 
=== Linux ===
 
=== Linux ===
 
Install a fortran compiler with the package manager, like ''gfortran''.
 
Install a fortran compiler with the package manager, like ''gfortran''.
Line 5: Line 8:
  
 
- Install Miniconda - See https://conda.io/miniconda.html
 
- Install Miniconda - See https://conda.io/miniconda.html
   ./Miniconda3-latest-MacOSX-x86_64.sh -p /Volumes/Dashboards/Support/miniconda3/
+
   ./Miniconda3-latest-MacOSX-x86_64.sh -p /Volumes/D/Support/miniconda3/
 
   Do you wish the installer to prepend the Miniconda3 install location
 
   Do you wish the installer to prepend the Miniconda3 install location
 
   Answered NO
 
   Answered NO
 
- To activate of base env.
 
- To activate of base env.
   source /Volumes/Dashboards/Support/miniconda3/bin/activate
+
   source /Volumes/D/Support/miniconda3/bin/activate
  
 
- Add conda-forge
 
- Add conda-forge
Line 18: Line 21:
 
   conda activate gfortran-env
 
   conda activate gfortran-env
 
   conda install gfortran_osx-64
 
   conda install gfortran_osx-64
 +
 +
- Create <tt>cc1</tt> wrapper script to workaround issue https://github.com/NIRALUser/SPHARM-PDM/issues/55:
 +
 +
<pre>
 +
#
 +
# Create gfortran wrapper script to ensure cc1
 +
#
 +
 +
fake_bin_dir="fake-bin-to-workaround-cc1-issue"
 +
 +
if [[ ! -f /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran-real ]]; then
 +
  mv /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran-real
 +
fi
 +
 +
cat << EOF > /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran
 +
#!/usr/bin/env bash
 +
 +
script_dir=\$(cd \$(dirname \$0) || exit 1; pwd)
 +
 +
export PATH=\$script_dir/../$fake_bin_dir/:\$PATH
 +
 +
\$script_dir/gfortran-real "\$@"
 +
EOF
 +
 +
chmod u+x /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran
 +
 +
#
 +
# Create cc1 wrapper script into "fake-bin" directory
 +
#
 +
mkdir -p /Volumes/D/Support/miniconda3/envs/gfortran-env/$fake_bin_dir
 +
 +
cat << EOF > /Volumes/D/Support/miniconda3/envs/gfortran-env/$fake_bin_dir/cc1
 +
#!/usr/bin/env bash
 +
 +
# See https://github.com/NIRALUser/SPHARM-PDM/issues/55
 +
# Script adapted from https://github.com/conda-forge/ambertools-feedstock/blob/04e4327e6a3cffdfda36158755ffe00c565fe08c/recipe/fake-bin/cc1
 +
 +
script_dir=\$(cd \$(dirname \$0) || exit 1; pwd)
 +
 +
ARGS=()
 +
for var in "\$@"; do
 +
    # Ignore known bad arguments
 +
    [ "\$var" != '-quiet' ] && ARGS+=("\$var")
 +
done
 +
 +
\$script_dir/../bin/clang "\${ARGS[@]}"
 +
EOF
 +
 +
chmod u+x /Volumes/D/Support/miniconda3/envs/gfortran-env/$fake_bin_dir/cc1
 +
</pre>
 +
 +
- update <tt>@rpath<tt> from gfortran libraries
  
 
Before packaging, we have to fix the installed gfortran libraries with the following script: [https://gist.github.com/phcerdan/146de9398052335d8a76c5b0070715a6 fix_gfortran_lib_rpath.sh].
 
Before packaging, we have to fix the installed gfortran libraries with the following script: [https://gist.github.com/phcerdan/146de9398052335d8a76c5b0070715a6 fix_gfortran_lib_rpath.sh].
  
 
The script substitutes ''@rpath'' with the needed full paths. Requires ''atool'' and ''install_name_tool''.
 
The script substitutes ''@rpath'' with the needed full paths. Requires ''atool'' and ''install_name_tool''.
 +
 +
<pre>
 +
cd /tmp
 +
 +
curl -L# https://gist.githubusercontent.com/phcerdan/146de9398052335d8a76c5b0070715a6/raw/e698a724a22c09055f75f7f221c8a3f1f59c5488/fix_gfortran_lib_rpaths.sh -o fix_gfortran_lib_rpaths.sh
 +
 +
chmod u+x /tmp/fix_gfortran_lib_rpaths.sh
 +
 +
/tmp/fix_gfortran_lib_rpaths.sh /Volumes/D/Support/miniconda3/envs/gfortran-env/lib
 +
</pre>
  
 
=== Windows ===
 
=== Windows ===
  
- Install Miniconda - See https://conda.io/miniconda.html
+
- Install Miniconda - See https://scikit-ci-addons.readthedocs.io/en/latest/addons.html#install-miniconda3-4-5-4-ps1
  
 
- Install Flang, a fortran compiler targeting llvm: [https://scikit-ci-addons.readthedocs.io/en/latest/addons.html#install-flang-ps1 scikit-ci-addons]
 
- Install Flang, a fortran compiler targeting llvm: [https://scikit-ci-addons.readthedocs.io/en/latest/addons.html#install-flang-ps1 scikit-ci-addons]

Latest revision as of 15:52, 10 September 2020

Home < Documentation < Nightly < Developers < Fortran

Linux

Install a fortran compiler with the package manager, like gfortran.

macOS

- Install Miniconda - See https://conda.io/miniconda.html

 ./Miniconda3-latest-MacOSX-x86_64.sh -p /Volumes/D/Support/miniconda3/
 Do you wish the installer to prepend the Miniconda3 install location
 Answered NO

- To activate of base env.

 source /Volumes/D/Support/miniconda3/bin/activate

- Add conda-forge

 conda config --add channels conda-forge

-Then create gfortran-env and install gfortran

 conda create -n gfortran-env
 conda activate gfortran-env
 conda install gfortran_osx-64

- Create cc1 wrapper script to workaround issue https://github.com/NIRALUser/SPHARM-PDM/issues/55:

#
# Create gfortran wrapper script to ensure cc1
#

fake_bin_dir="fake-bin-to-workaround-cc1-issue"

if [[ ! -f /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran-real ]]; then
  mv /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran-real
fi

cat << EOF > /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran
#!/usr/bin/env bash

script_dir=\$(cd \$(dirname \$0) || exit 1; pwd)

export PATH=\$script_dir/../$fake_bin_dir/:\$PATH

\$script_dir/gfortran-real "\$@"
EOF

chmod u+x /Volumes/D/Support/miniconda3/envs/gfortran-env/bin/gfortran

#
# Create cc1 wrapper script into "fake-bin" directory
#
mkdir -p /Volumes/D/Support/miniconda3/envs/gfortran-env/$fake_bin_dir

cat << EOF > /Volumes/D/Support/miniconda3/envs/gfortran-env/$fake_bin_dir/cc1
#!/usr/bin/env bash

# See https://github.com/NIRALUser/SPHARM-PDM/issues/55
# Script adapted from https://github.com/conda-forge/ambertools-feedstock/blob/04e4327e6a3cffdfda36158755ffe00c565fe08c/recipe/fake-bin/cc1

script_dir=\$(cd \$(dirname \$0) || exit 1; pwd)

ARGS=()
for var in "\$@"; do
    # Ignore known bad arguments
    [ "\$var" != '-quiet' ] && ARGS+=("\$var")
done

\$script_dir/../bin/clang "\${ARGS[@]}"
EOF

chmod u+x /Volumes/D/Support/miniconda3/envs/gfortran-env/$fake_bin_dir/cc1

- update @rpath from gfortran libraries

Before packaging, we have to fix the installed gfortran libraries with the following script: fix_gfortran_lib_rpath.sh.

The script substitutes @rpath with the needed full paths. Requires atool and install_name_tool.

cd /tmp

curl -L# https://gist.githubusercontent.com/phcerdan/146de9398052335d8a76c5b0070715a6/raw/e698a724a22c09055f75f7f221c8a3f1f59c5488/fix_gfortran_lib_rpaths.sh -o fix_gfortran_lib_rpaths.sh

chmod u+x /tmp/fix_gfortran_lib_rpaths.sh

/tmp/fix_gfortran_lib_rpaths.sh /Volumes/D/Support/miniconda3/envs/gfortran-env/lib

Windows

- Install Miniconda - See https://scikit-ci-addons.readthedocs.io/en/latest/addons.html#install-miniconda3-4-5-4-ps1

- Install Flang, a fortran compiler targeting llvm: scikit-ci-addons