Fortran Package Manager

Haskell mode, 3

.

The goal of this blog post is to set up an integrated programming environment for Fortran.

.

1. Read and follow the exact steps of my post titled “Haskell mode“.

2. Read and follow the exact steps of my post titled “Haskell mode, 2“.

3. Install the package manager Anaconda.

4. Use Anaconda to install the Fortran Package Manager (fpm), by following the fpm installation guide.

4.1. Add the additional channel mentioned in the fpm installation guide.

4.2. Install the fpm itself:

conda create -n fpm_env fpm

conda activate fpm_env

5. Install the Fortran language server:

conda install fortls

6. Install the Emacs plugin:

sudo apt-get install elpa-pyvenv

7. Open Emacs’ initialization file, whose location should be

~/.emacs

8. Add the following code to the file.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun gfortran-run ()

  (interactive)

  (save-buffer)

  (unless visual-line-mode
    (visual-line-mode 1))

  (universal-argument)

  (compile "fpm run"))

(global-set-key (kbd "C-x C-r") 'gfortran-run)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setenv "WORKON_HOME" "~/anaconda3/envs")

(pyvenv-mode 1)

(pyvenv-workon "fpm_env")

;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-hook 'f90-mode-hook #'lsp)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

— Me@2022-12-01 09:18:59 AM

.

.

2022.12.04 Sunday (c) All rights reserved by ACHK