question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

porting scipy's Fortran code to NAG's nagfor compiler

See original GitHub issue

After the recently merged numpy’s https://github.com/numpy/numpy/pull/17950 nagfor still cannot compile all of scipy’s Fortran code.

Using numpy’s master with the PR just mentioned in, one still gets:

$ python3 setup.py build -j 1 config_fc --fcompiler=nagfor install --prefix $HOME/.local
...
nagfor:f77: scipy/integrate/odepack/srcma.f
Option warning: -c option specified twice, continuing
NAG Fortran Compiler Release 7.0(Yurakucho) Build 7036
Evaluation trial version of NAG Fortran Compiler Release 7.0(Yurakucho) Build 7036
Obsolescent: scipy/integrate/odepack/srcma.f, line 1: Fixed source form
Obsolescent: scipy/integrate/odepack/srcma.f, line 27: DO 10 ends neither with CONTINUE nor ENDDO
Obsolescent: scipy/integrate/odepack/srcma.f, line 29: DO 15 ends neither with CONTINUE nor ENDDO
Obsolescent: scipy/integrate/odepack/srcma.f, line 32: DO 20 ends neither with CONTINUE nor ENDDO
Obsolescent: scipy/integrate/odepack/srcma.f, line 34: DO 25 ends neither with CONTINUE nor ENDDO
Error: scipy/integrate/odepack/srcma.f, line 36: First subscript (49) is greater than upper bound (1) for array ISAV
Error: scipy/integrate/odepack/srcma.f, line 37: First subscript (50) is greater than upper bound (1) for array ISAV
Obsolescent: scipy/integrate/odepack/srcma.f, line 42: DO 110 ends neither with CONTINUE nor ENDDO
Obsolescent: scipy/integrate/odepack/srcma.f, line 44: DO 115 ends neither with CONTINUE nor ENDDO
Obsolescent: scipy/integrate/odepack/srcma.f, line 47: DO 120 ends neither with CONTINUE nor ENDDO
Obsolescent: scipy/integrate/odepack/srcma.f, line 49: DO 125 ends neither with CONTINUE nor ENDDO
Error: scipy/integrate/odepack/srcma.f, line 51: First subscript (49) is greater than upper bound (1) for array ISAV
Error: scipy/integrate/odepack/srcma.f, line 52: First subscript (50) is greater than upper bound (1) for array ISAV
[NAG Fortran Compiler error termination, 4 errors, 9 warnings]

This one is easy to fix (apparently natfor does not grok dimension?):

diff --git a/scipy/integrate/odepack/srcma.f b/scipy/integrate/odepack/srcma.f
index 62c07a571..aa3ba1e22 100644
--- a/scipy/integrate/odepack/srcma.f
+++ b/scipy/integrate/odepack/srcma.f
@@ -11,12 +11,11 @@ c        job  = 1 if common is to be saved (written to rsav/isav)
 c        job  = 2 if common is to be restored (read from rsav/isav)
 c        a call with job = 2 presumes a prior call with job = 1.
 c-----------------------------------------------------------------------
-      integer isav, job
+      integer isav(*), job
       integer ieh, ils, ilsa
       integer i, lenrls, lenils, lenrla, lenila
-      double precision rsav
+      double precision rsav(*)
       double precision rls, rlsa
-      dimension rsav(1), isav(1)
       common /ls0001/ rls(218), ils(39)
       common /lsa001/ rlsa(22), ilsa(9)
       common /eh0001/ ieh(2)

After this fix, the next error, not very clear either:

nagfor:f77: scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.f
Option warning: -c option specified twice, continuing
NAG Fortran Compiler Release 7.0(Yurakucho) Build 7036
Evaluation trial version of NAG Fortran Compiler Release 7.0(Yurakucho) Build 7036
Warning: scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.f, line 850: Unused dummy variable NB
Obsolescent: scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.f, line 208: Fixed source form
Error: scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.f, line 666: Inconsistent structure for arg 3 in call to SVOUT
Error: scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.f, line 737: Inconsistent structure for arg 3 in call to SVOUT
[NAG Fortran Compiler error termination, 2 errors, 2 warnings]
error: Command "/usr/local/bin/nagfor -fixed -O4 -Iscipy/sparse/linalg/eigen/arpack/ARPACK/SRC -I/home/dimpase/.local/lib/python3.7/site-packages/numpy-1.21.0.dev0+137.g91d9bbebc-py3.7-linux-x86_64.egg/numpy/core/include -c -c scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.f -o build/temp.linux-x86_64-3.7/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/cnaitr.o" failed with exit status 2

Any ideas for this latter?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:73 (55 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Sep 30, 2021

And it probably needs to only be done for the NAG compiler, so you need something like this as a guard inside the hook:

if fc.compiler_type == 'nagfor':
1reaction
dimpasecommented, Sep 29, 2021

So -dusty is not desired it looks like? Without it, how much sloppy code needs cleaning up? It seems that it’s mostly (only?) sloppy handling of complex data type in scipy/linalg/src/id_dist/src/id_rtrans.f which I mention above. At this point I gave up and switched to using -dusty, so perhaps there is more to it than that.


I’d get nagfor installed on Linux, to have more coverage, and also test my branches with gfortran

Read more comments on GitHub >

github_iconTop Results From Across the Web

NAG Fortran Compiler Release 7.0
Compile code to produce a traceback when a runtime error message is generated. Only routines compiled with this option will appear in such...
Read more >
Why abandon Fortran for Linear Algebra?
I spent some time expaining to NAG people why they should provide few nagfor licences to scipy for testing purposes. (I tried to...
Read more >
Fortran for Apple Silicon | Apple Developer Forums
This impacts a lot of scientific code, and in particular Python libraries that rely ... I have not heard anything from Apple but...
Read more >
User's Guide to the HECToR Service Version 2.0
User Guide to the HECToR Service (Version 2.0) · Compiling Fortran code · Compiling C code · Compiling C++ code · Selecting compiler...
Read more >
What Fortran compilers and IDEs are people using in Windows?
Our 800K lines of F77, C, and C++ code is compiled using the Open Watcom F77, C, ... NAG Fortran Builder exists for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found