Нынче фортран уже не тот
2023-06-05 12:00Фортран доразвился до современного менеджера пакетов: называется fpm. Напоминает утилиту cargo из Rust. Устанавливаем на маке:
Создаём простой пример:$ brew tap fortran-lang/fortran
$ brew install fpm
Появится проект из нескольких файлов:$ fpm new first_steps
Компилируем и запускаем:$ tree first_steps
first_steps
├── README.md
├── app
│ └── main.f90
├── fpm.toml
├── src
│ └── first_steps.f90
└── test
└── check.f90
4 directories, 5 files
Смотрим содержимое файлов. Современный фортран, поддержка модулей, все дела.$ cd first_steps
$ fpm run
+ mkdir -p build/dependencies
first_steps.f90 done.
libfirst_steps.a done.
main.f90 done.
first_steps done.
[100%] Project compiled successfully.
Hello, first_steps!
$ fpm test
check.f90 done.
check done.
[100%] Project compiled successfully.
Put some tests in here!
$ cat app/main.f90
program main
use first_steps, only: say_hello
implicit none
call say_hello()
end program main
$ cat src/first_steps.f90
module first_steps
implicit none
private
public :: say_hello
contains
subroutine say_hello
print *, "Hello, first_steps!"
end subroutine say_hello
end module first_steps
$ cat test/check.f90
program check
implicit none
print *, "Put some tests in here!"
end program check
