Код: Выделить всё
subroutine read_params(filename, params)
implicit none
! Argument Declarations !
character(len=*), intent(in) :: filename
integer, dimension(4), intent(out) :: params
! Variable Declarations
integer :: i
open (unit=1,status="unknown",file=filename,form="unformatted")
rewind 1
read(1) (params(i), i=1, 4)
end subroutine read_params
Код: Выделить всё
python -m numpy.f2py -c -m parse parse.f90
Код: Выделить всё
from pathlib import Path
import numpy as np
from .parse import read_params
def do_stuff_with_params(path: Path):
params = read_params(path)
# do something with the parameters
return
Код: Выделить всё
def do_stuff_with_params(path: Path):
if not path.exists():
raise FileNotFoundError(f'{path} does not exist ')
params = read_params(path)
# do something with the parameters
return
Подробнее здесь: https://stackoverflow.com/questions/792 ... ith-python
Мобильная версия