# SPDX-License-Identifier: CC0-1.0 # Fortran(gfortran-14.2) インストールスクリプト # OS: Ubuntu 24.04.1 # カレントディレクトリ: /judge # 環境変数: HOME=/home/runner # LANG=C.UTF-8 # PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # ATCODER=1 language = 'Fortran' display = 'Fortran2023 (GCC 14.2.0)' license = [{ name = 'GPL-3.0-or-later', url = 'https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Copying.html' }] library.stdlib = { license = [ { name = 'MIT', url = 'https://stdlib.fortran-lang.org/page/License.html' }, ], version = 'v0.7.0' } library.ac-library-fortran = { license = [ { name = 'MIT', url = 'https://github.com/ue1221/ac-library-fortran/blob/main/LICENSE' } ] } filename = 'Main.f90' install = ''' sudo apt update -y sudo apt upgrade -y sudo apt install -y gfortran gfortran-14 sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-14 0 sudo apt install -y wget git # fpm をインストール. wget -O fpm https://github.com/fortran-lang/fpm/releases/download/v0.10.1/fpm-0.10.1-linux-x86_64 chmod +x fpm mkdir -p $HOME/.local/bin export PATH="$HOME/.local/bin:$PATH" mv fpm $HOME/.local/bin export FPM_FC="gfortran" export FPM_FFLAGS="-O2 -cpp -std=f2023" # stdlib-0.7.0 をインストール. # 静的ライブラリは $HOME/.local/lib へ # モジュールは $HOME/.local/include へ cd /tmp wget https://github.com/fortran-lang/stdlib/archive/refs/tags/v0.7.0.tar.gz tar xvf v0.7.0.tar.gz cd stdlib-0.7.0 cat << EOF >> fpm.toml [install] library = true EOF sudo apt install -y python3 fypp python3-joblib libstdc++-14-dev python3 config/fypp_deployment.py fpm build --profile release fpm test --profile release fpm install --prefix="$HOME/.local" --profile release export LD_LIBRARY_PATH="$HOME/.local/lib" # ac-library-fortran cd /judge git clone https://github.com/ue1221/ac-library-fortran.git mv ac-library-fortran acl # コンパイルできるか試す. cd /judge cat << EOF > Main.f90 include "acl/atcoder/union_find.f08" program test_stdlib use, intrinsic :: iso_fortran_env use stdlib_version use stdlib_sorting use mod_union_find implicit none integer(int32) :: arr(10) = [10, 2, 1, 5, 7, 8, 3, 9, 6, 4] type(union_find) :: uf write(output_unit, '(a)') stdlib_version_string call sort(arr) write(error_unit, '(*(i0, 1x))') arr(:) if (any(arr(:) /= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) & & error stop "Something error" uf = newuf(10) call unite(uf, 1, 2) write(error_unit, '(*(L, 1x))') same(uf, 1, 2), same(uf, 1, 3) end program EOF gfortran -L$HOME/.local/lib -I$HOME/.local/include -O2 -cpp -ffree-line-length-none -std=f2023 Main.f90 -lstdlib ./a.out # 要らないものを消す. rm Main.f90 a.out mod_union_find.mod rm -f $HOME/.local/bin/fpm rm -rf $HOME/fortran sudo apt purge -y git fypp python3-joblib sudo apt autoremove -y ''' compile = ''' export PATH="$HOME/.local/bin:$PATH" export LD_LIBRARY_PATH="$HOME/.local/lib" gfortran -L$HOME/.local/lib -I$HOME/.local/include -O2 -cpp -ffree-line-length-none -std=f2023 Main.f90 -lstdlib ''' object = 'a.out' execution = [ './a.out' ]