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
|
;;;###autoload
|
||||||
(defun +fortran/build ()
|
(defun +fortran/build ()
|
||||||
"Compile a Fortran project or file.
|
"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)
|
(interactive)
|
||||||
(if (+fortran--fpm-toml)
|
(cond ((+fortran--fpm-toml) (+fortran/fpm-build))
|
||||||
(+fortran/fpm-build)
|
((featurep! +intel) (+fortran/ifort-compile))
|
||||||
(+fortran/gfortran-compile)))
|
(t (+fortran/gfortran-compile))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +fortran/run ()
|
(defun +fortran/run ()
|
||||||
"Run a Fortran project or file.
|
"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)
|
(interactive)
|
||||||
(if (+fortran--fpm-toml)
|
(cond ((+fortran--fpm-toml) (+fortran/fpm-run))
|
||||||
(+fortran/fpm-run)
|
((featurep! +intel) (+fortran/ifort-run))
|
||||||
(+fortran/gfortran-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
|
;;; GFortran
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
:config
|
:config
|
||||||
;; --- Compilation --- ;;
|
;; --- Compilation --- ;;
|
||||||
;; Used by `compile' (SPC c c)
|
;; Used by `compile' (SPC c c)
|
||||||
(setq-hook! 'f90-mode-hook
|
(let ((cmd (cond ((featurep! +intel) "ifort ")
|
||||||
compile-command "gfortran "
|
(t "gfortran "))))
|
||||||
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn)
|
(setq-hook! 'f90-mode-hook
|
||||||
|
compile-command cmd
|
||||||
|
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn))
|
||||||
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
|
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
|
||||||
|
|
||||||
;; --- LSP Configuration --- ;;
|
;; --- LSP Configuration --- ;;
|
||||||
|
|
|
@ -5,7 +5,12 @@
|
||||||
(featurep! :tools lsp))
|
(featurep! :tools lsp))
|
||||||
"This module requires (: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."))
|
(warn! "Couldn't find gfortran - compilation will not work."))
|
||||||
|
|
||||||
(unless (executable-find "fpm")
|
(unless (executable-find "fpm")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue