Open OrbitalMechanic opened 1 year ago
gfortran: error: missing argument to '-d'
error: Command "/usr/local/bin/gfortran -d -arch x86_64 -fPIC -O3 -funroll-loops -I/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpbtg3sti3/src.macosx-10.9-x86_64-3.9 -I/Users/user/opt/anaconda3/lib/python3.9/site-packages/numpy/core/include -I/Users/user/opt/anaconda3/include/python3.9 -c -c /Users/user/.cache/ipython/fortran/_fortran_magic_553c13c268582acb90e6b36e15d4b416.f90 -o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpbtg3sti3/Users/user/.cache/ipython/fortran/_fortran_magic_553c13c268582acb90e6b36e15d4b416.o" failed with exit status 1
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_ipython().run_cell_magic('fortran', '-vvv --fcompiler gnu95 --compiler unix --f90flags "-d" --noarch', '\nsubroutine f1(x, y, z)\n real, intent(in) :: x,y\n real, intent(out) :: z\n\n z = sin(x+y)\n\nend subroutine f1\n')
You have erroneous arguments cell magic %%fortran -vvv --fcompiler gnu95 --compiler unix --f90flags "-d" --noarch
.
Under macOS, cell magic %%fortran
should work fine without any arguments.
It is recommended to reset the saved configuration by line magic %fortran_config --defaults
Thank you for responding to my post.
I added the line %fortran_config --defaults
only to get an error from f2py as shown in the attached screen-snap.
Any suggestions?
Please print detailed output by %%fortran -vvv
and details software versions lists. Unfortunately, fortran-magic
without the -vvv
key does not print build error diagnostics.
Perhaps the errors are related to the fact that numpy
, python
, etc. are run from the anaconda
hierarchy, but GNU fortran
from `/usr/local/bin'. Compiler flags, library locations, etc., may be incompatible.
You can try creating a minimal environment with fortran compiler by conda env create --name minfm --file minimal-jupyter-enviroment.yml.txt
(or mamba env create --name minfm --file minimal-jupyter-enviroment.yml.txt
). And then run Jupyter Lab with (cd ~/<test dir> && conda run --name minfm jupyter lab )
.
minimal-jupyter-enviroment.yml.txt
file see attachment.
minimal-jupyter-enviroment.yml.txt
Below is a screen snap where %%fortran -vvv was used. Where can I find the "output" that f2py refers to in the screen snap?
Below are the messages from the run I made with %%fortran -vvv:
Running...
/Users/user/opt/anaconda3/bin/python -m numpy.f2py -m _fortran_magic_985da1e7b396b6f4badbb368d62bfa08 -c /Users/user/.cache/ipython/fortran/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.f90
running build
running config_cc
INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
INFO: build_src
INFO: building extension "_fortran_magic_985da1e7b396b6f4badbb368d62bfa08" sources
INFO: f2py options: []
INFO: f2py:> /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08module.c
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9
Reading fortran codes...
Reading file '/Users/user/.cache/ipython/fortran/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.f90' (format:free)
Post-processing...
Block: _fortran_magic_985da1e7b396b6f4badbb368d62bfa08
Block: f1
Applying post-processing hooks...
character_backward_compatibility_hook
Post-processing (stage 2)...
Building modules...
Building module "_fortran_magic_985da1e7b396b6f4badbb368d62bfa08"...
Generating possibly empty wrappers"
Maybe empty "_fortran_magic_985da1e7b396b6f4badbb368d62bfa08-f2pywrappers.f"
Constructing wrapper function "f1"...
z = f1(x,y)
Wrote C/API module "_fortran_magic_985da1e7b396b6f4badbb368d62bfa08" to file "/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08module.c"
INFO: adding '/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/fortranobject.c' to sources.
INFO: adding '/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9' to include_dirs.
copying /Users/user/opt/anaconda3/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.c -> /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9
copying /Users/user/opt/anaconda3/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.h -> /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9
INFO: adding '/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08-f2pywrappers.f' to sources.
INFO: build_src: building npy-pkg config files
running build_ext
INFO: customize UnixCCompiler
INFO: customize UnixCCompiler using build_ext
INFO: get_default_fcompiler: matching types: '['gnu95', 'nag', 'nagfor', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg']'
INFO: customize Gnu95FCompiler
INFO: Found executable /usr/local/bin/gfortran
INFO: customize Gnu95FCompiler
INFO: customize Gnu95FCompiler using build_ext
INFO: building '_fortran_magic_985da1e7b396b6f4badbb368d62bfa08' extension
INFO: compiling C sources
INFO: C compiler: clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/user/opt/anaconda3/include -arch x86_64 -I/Users/user/opt/anaconda3/include -fPIC -O2 -isystem /Users/user/opt/anaconda3/include -arch x86_64 -ftrapping-math
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9
INFO: compile options: '-DNPY_DISABLE_OPTIMIZATION=1 -I/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9 -I/Users/user/opt/anaconda3/lib/python3.9/site-packages/numpy/core/include -I/Users/user/opt/anaconda3/include/python3.9 -c'
INFO: clang: /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08module.c
INFO: clang: /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/fortranobject.c
INFO: compiling Fortran sources
INFO: Fortran f77 compiler: /usr/local/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -arch x86_64 -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/local/bin/gfortran -Wall -g -fno-second-underscore -arch x86_64 -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/local/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -arch x86_64 -fPIC -O3 -funroll-loops
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user/.cache
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user/.cache/ipython
creating /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user/.cache/ipython/fortran
INFO: compile options: '-I/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9 -I/Users/user/opt/anaconda3/lib/python3.9/site-packages/numpy/core/include -I/Users/user/opt/anaconda3/include/python3.9 -c'
INFO: gfortran:f90: /Users/user/.cache/ipython/fortran/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.f90
INFO: gfortran:f77: /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08-f2pywrappers.f
INFO: /usr/local/bin/gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08module.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/fortranobject.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user/.cache/ipython/fortran/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08-f2pywrappers.o -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13 -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13/../../.. -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13/../../.. -lgfortran -o ./_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.cpython-39-darwin.so
/Users/user/opt/anaconda3/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
error: Command "/usr/local/bin/gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08module.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/fortranobject.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user/.cache/ipython/fortran/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08-f2pywrappers.o -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13 -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13/../../.. -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13/../../.. -lgfortran -o ./_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.cpython-39-darwin.so" failed with exit status 1
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_ipython().run_cell_magic('fortran', '-vvv', '\nsubroutine f1(x, y, z)\n real, intent(in) :: x,y\n real, intent(out) :: z\n\n z = sin(x+y)\n\nend subroutine f1\n')
File ~/opt/anaconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2475, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2473 with self.builtin_trap:
2474 args = (magic_arg_s, cell)
-> 2475 result = fn(*args, **kwargs)
2477 # The code below prevents the output from being displayed
2478 # when using magics with decodator @output_can_be_silenced
2479 # when the last Python token in the expression is a ';'.
2480 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~/opt/anaconda3/lib/python3.9/site-packages/fortranmagic.py:368, in FortranMagics.fortran(self, line, cell)
365 res = self._run_f2py(f2py_args + ['-m', module_name, '-c', f90_file],
366 verbosity=args.verbosity)
367 if res != 0:
--> 368 raise RuntimeError("f2py failed, see output")
370 self._code_cache[key] = module_name
371 module = imp.load_dynamic(module_name, module_path)
RuntimeError: f2py failed, see output
Any further thoughts?
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
error: Command "/usr/local/bin/gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08module.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/fortranobject.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/Users/user/.cache/ipython/fortran/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.o /var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/tmpj1od4m5k/src.macosx-10.9-x86_64-3.9/_fortran_magic_985da1e7b396b6f4badbb368d62bfa08-f2pywrappers.o -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13 -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13/../../.. -L/usr/local/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin22/13/../../.. -lgfortran -o ./_fortran_magic_985da1e7b396b6f4badbb368d62bfa08.cpython-39-darwin.so" failed with exit status 1
I have not encountered such an error, but a Yandex search says that the error is related to gfortran
configuration errors. Probably after the macOS
update.
Open Terminal
for Environments base
by anaconda-navigator
(or use conda activate base
by macOS Terminal.app
):
gfortran
;python -m numpy.f2py -c fib1.f -m fib1
;python -c 'import fib1, numpy as np; a=np.zeros(8,"d"); fib1.fib(a); print(a)'
.P.S.
Of course, it is good practice to create a separate environment for each big project, and use the base
environment only for managing environments, installing packages and updates. But since you have a problem in the base
environment, you have to use it.
Attempting to run an example for fortranmagic on a Mac Pro (2019) running Mac OSX ver. 13.3.1 (a) Ventura. I'm running
When running the example hosted on https://github.com/mgaitan/fortran_magic:
The message I get is
Any suggestions?