feat(fortran): initial addition of ifort functions
This commit is contained in:
parent
ece4a74a9b
commit
81dc9af008
3 changed files with 43 additions and 14 deletions
|
@ -6,22 +6,44 @@
|
|||
;;;###autoload
|
||||
(defun +fortran/build ()
|
||||
"Compile a Fortran project or file.
|
||||
If the current file is detected to be within an fpm project,
|
||||
then building will occur with fpm. Otherwise it will default to gfortran."
|
||||
|
||||
If the current file is detected to be within an fpm project, then
|
||||
building will occur with fpm. Otherwise it will default to ifort
|
||||
or gfortran, depending on what feature flags are set."
|
||||
(interactive)
|
||||
(if (+fortran--fpm-toml)
|
||||
(+fortran/fpm-build)
|
||||
(+fortran/gfortran-compile)))
|
||||
(cond ((+fortran--fpm-toml) (+fortran/fpm-build))
|
||||
((featurep! +intel) (+fortran/ifort-compile))
|
||||
(t (+fortran/gfortran-compile))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +fortran/run ()
|
||||
"Run a Fortran project or file.
|
||||
If the current file is detected to be within an fpm project,
|
||||
then building will occur with fpm. Otherwise it will default to gfortran."
|
||||
|
||||
If the current file is detected to be within an fpm project, then
|
||||
building will occur with fpm. Otherwise it will default to ifort
|
||||
or gfortran, depending on what feature flags are set."
|
||||
(interactive)
|
||||
(if (+fortran--fpm-toml)
|
||||
(+fortran/fpm-run)
|
||||
(+fortran/gfortran-run)))
|
||||
(cond ((+fortran--fpm-toml) (+fortran/fpm-run))
|
||||
((featurep! +intel) (+fortran/ifort-run))
|
||||
(t (+fortran/gfortran-run))))
|
||||
|
||||
;; Intel Fortran
|
||||
;;;###autoload
|
||||
(defun +fortran/ifort-compile ()
|
||||
"Compile the current buffer using ifort."
|
||||
(interactive)
|
||||
(compile (format "ifort %s"
|
||||
(buffer-file-name))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +fortran/ifort-run ()
|
||||
"Run the current buffer using ifort."
|
||||
(interactive)
|
||||
(delete-file "./a.out")
|
||||
(+fortran/ifort-compile)
|
||||
(while (not (file-exists-p "./a.out"))
|
||||
(sleep-for 1))
|
||||
(compile "./a.out"))
|
||||
|
||||
;;
|
||||
;;; GFortran
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
:config
|
||||
;; --- Compilation --- ;;
|
||||
;; Used by `compile' (SPC c c)
|
||||
(let ((cmd (cond ((featurep! +intel) "ifort ")
|
||||
(t "gfortran "))))
|
||||
(setq-hook! 'f90-mode-hook
|
||||
compile-command "gfortran "
|
||||
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn)
|
||||
compile-command cmd
|
||||
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn))
|
||||
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
|
||||
|
||||
;; --- LSP Configuration --- ;;
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
(featurep! :tools lsp))
|
||||
"This module requires (:tools lsp)")
|
||||
|
||||
(when (not (executable-find "gfortran"))
|
||||
(when (and (featurep! +intel)
|
||||
(not (executable-find "ifort")))
|
||||
(warn! "Couldn't find Intel ifort - compilation will not work."))
|
||||
|
||||
(when (and (not (featurep! +intel))
|
||||
(not (executable-find "gfortran")))
|
||||
(warn! "Couldn't find gfortran - compilation will not work."))
|
||||
|
||||
(unless (executable-find "fpm")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue