Skip to content

Commit

Permalink
Merge branch 'master' into dmd
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Jan 10, 2025
2 parents 1d09a8a + 8a2358b commit 46aac74
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 17 deletions.
4 changes: 4 additions & 0 deletions f2py/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include expro/expro.f90
include expro/expro_util.f90
include expro/expro_pycomm.f90
include geo/geo.f90
2 changes: 1 addition & 1 deletion f2py/pygacode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def gapystr_set(s, l=10, n=200):
__all__.extend(list(tmp.keys()))
except:
# Not using pygacode
pass
pass
21 changes: 13 additions & 8 deletions f2py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[build-system]
requires = ['setuptools','wheel','numpy']
requires = [
'setuptools>=41.2.0', 'wheel',
'oldest-supported-numpy; python_version=="3.8"',
'numpy>=2.0.2; python_version>="3.9"',
'numpy>=2.1.3; python_version>="3.10"',
'meson; python_version>="3.12"',
]
build-backend = 'setuptools.build_meta'

[project]
name = 'pygacode'
version = '1.0.1'
version = '1.0.2'
description = 'Python-GACODE'
license = {text = 'MIT'}
requires-python = ">=3.8"

[project.urls]
Homepage = "https://gacode.io"

license = { text = 'MIT' }
requires-python = '>=3.8'
urls = { Homepage = 'https://gacode.io' }
dependencies = ['numpy']
52 changes: 44 additions & 8 deletions f2py/setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
from numpy.distutils.core import setup,Extension
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
from importlib.machinery import EXTENSION_SUFFIXES
import os
import shutil
import sys
import subprocess
import sysconfig


class F2PyExtension(Extension):
def __init__(self, name, fortran_sources, **kwargs):
super().__init__(name, sources=[], **kwargs)
self.fortran_sources = fortran_sources


class BuildF2PyExtension(build_ext):
def build_extension(self, ext):
output_module = ext.name
env = os.environ.copy()
if sys.version_info < (3, 12):
env["SETUPTOOLS_USE_DISTUTILS"] = "1"
subprocess.check_call([
"f2py", "-c", "-m", output_module, *ext.fortran_sources
], env=env)

ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
lib_name = f"{output_module}{ext_suffix}"

ext_path = self.get_ext_fullpath(ext.name)
ext_dir = os.path.dirname(ext_path)
if not os.path.exists(ext_dir):
os.makedirs(ext_dir)

shutil.move(lib_name, ext_path)


ext = F2PyExtension('gacode_ext',
fortran_sources=['expro/expro.f90',
'expro/expro_util.f90',
'expro/expro_pycomm.f90',
'geo/geo.f90'])

ext = Extension('gacode_ext',
sources=['expro/expro.f90',
'expro/expro_util.f90',
'expro/expro_pycomm.f90',
'geo/geo.f90'])

setup(py_modules=['pygacode.gacodefuncs',
'pygacode.gacodeinput'],
Expand All @@ -16,6 +52,6 @@
'pygacode.neo',
'pygacode.profiles_gen'],
package_data={'pygacode.test': ['input.gacode']},
ext_modules=[ext]
ext_modules=[ext],
cmdclass={'build_ext': BuildF2PyExtension},
)

37 changes: 37 additions & 0 deletions platform/build/make.inc.GFORTRAN_OSX_BREW
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#---------------------------------------------------
# OSX,gfortran+openmpi from Homebrew
#
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# brew install gcc open-mpi netcdf netcdf-fortran fftw
#---------------------------------------------------

IDENTITY="OSX gfortran+openmpi from Homebrew"

MAKE = make

MF90 = mpif90

# Compilers and flags

FC = ${MF90} -std=f2008 -fall-intrinsics -I$(FFTW_INC) -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -I/opt/local/include -fPIC
F77 = ${MF90} -w -fallow-argument-mismatch

FOMP = -fopenmp
FMATH = -fdefault-real-8 -fdefault-double-8
FOPT = -O3 -m64 -framework Accelerate
FDEBUG = -Wall -g -fcheck=all -fbacktrace -fbounds-check -O0 -Wextra -finit-real=nan -Wunderflow -ffpe-trap=invalid,zero,overflow
#F2PY = f2py-2.7

# System libraries

LMATH = -L$(BREW_LIB) -lfftw3
NETCDF = -L$(BREW_LIB) -lnetcdff -lnetcdf

# Archive

ARCH = ar cr

ifdef FANN_ROOT
# neural net libraries
NN_LIB=-L$(GACODE_ROOT)/../neural/ -I$(GACODE_ROOT)/../neural/ -lbrainfuse -lfann
endif
6 changes: 6 additions & 0 deletions platform/env/env.GFORTRAN_OSX_BREW
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export BREW_LIB=$(brew --prefix)/lib
export LD_LIBRARY_PATH=$(brew --prefix)/lib:$LD_LIBRARY_PATH
export FFTW_INC=$(brew --prefix fftw)/include
export NETCDF_INC=$(brew --prefix netcdf)/include
17 changes: 17 additions & 0 deletions platform/exec/exec.GFORTRAN_OSX_BREW
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# GACODE Parallel execution script (GFORTRAN_OSX_MACPORTS)
#
# NOTES:
# Used mpich2-1.0.3, so use mpirun rather than mpiexec

simdir=${1}
nmpi=${2}
exec=${3}
nomp=${4}
numa=${5}
mpinuma=${6}

echo $simdir

cd $simdir
export OMP_NUM_THREADS=$nomp ; mpiexec --oversubscribe -np $nmpi $exec

0 comments on commit 46aac74

Please sign in to comment.