magic-sph / magic

MagIC is a high-performance code that solves the magneto-hydrodynamics equations in rotating spherical shells
https://magic-sph.github.io/
80 stars 25 forks source link

Fortran Libs not importing properly #32

Closed ghost closed 3 years ago

ghost commented 3 years ago

With build_lib set to true, from magic import * fails. Specifically, it has trouble import magic.legendre as leg which leads me to believe that the fortran libraries are not importing correctly. Any help would be greatly appreciated! Traceback:

Please wait: building greader_single... Please wait: building greader_double... Please wait: building lmrreader_single... Please wait: building Legendre transforms... Please wait: building vtklib...

ModuleNotFoundError Traceback (most recent call last)

in ----> 1 from magic import * ~/magic/python/magic/__init__.py in 14 from .checker import * 15 from .thHeat import * ---> 16 from .coeff import * 17 from .radialSpectra import * 18 from .checkpoint import * ~/magic/python/magic/coeff.py in 4 import numpy as np 5 import matplotlib.pyplot as plt ----> 6 from .spectralTransforms import SpectralTransforms 7 from magic.setup import labTex 8 import copy ~/magic/python/magic/spectralTransforms.py in 4 5 if buildSo: ----> 6 import magic.legendre as leg 7 8 ModuleNotFoundError: No module named 'magic.legendre'
AnkitBarik commented 3 years ago

Hi, I've typically seen this occur while using python2. Do you have both python versions (2 and 3) installed on your computer? One way to force it to use python3 might be to explicitly set f2pyexec = f2py3. Can you set that in the magic.cfg, remove the *.so files and try again?

ghost commented 3 years ago

Hi, thank you for the reply. It doesn't even look like the .so files are created. They are supposed to be in $MAGIC_HOME/python/magic correct?

AnkitBarik commented 3 years ago

I see. It's the compiler then. Could you send the following information?

ghost commented 3 years ago

Local computer, CC=gcc, FC=gfortran, CXX=mpicxx magic.cfg:

[plots] Adapt your backend to your machine: 'TkAgg', 'GTKAgg', 'Qt4Agg', ... backend = TkAgg In case you don't have LaTeX installed switch to False labTex = False Default colormap defaultCm = seismic Default number of levels defaultLevels = 65 [libraries] adapt this value if you don't want libraries buildLib = True f2py executable, can be f2py, f2py2 or f2py3 (python 3) f2pyexec = f2py3 fortran compiler: f2py -c --help-fcompiler, frequently 'intelem' or 'gnu95' fcompiler = gfortran c compiler: f2py -c --help-compiler No need to touch this one except on gwdg, change it to intelem ccompiler = gcc ~

AnkitBarik commented 3 years ago

You need to set fcompiler=gnu95 and leave the ccompiler to the default value of unix. Edit: These should get set automatically if you source the sourceme.sh script: source /path/to/magic/sourceme.sh

ghost commented 3 years ago

Ah, that worked! Thought I had already tried gnu95 as my fortran compiler but apparently not. Thank you!