Skip to content

Cannot compile on Mac with Nag 6.2 #7583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pbrady opened this issue Mar 31, 2020 · 16 comments · Fixed by #7584
Closed

Cannot compile on Mac with Nag 6.2 #7583

pbrady opened this issue Mar 31, 2020 · 16 comments · Fixed by #7584

Comments

@pbrady
Copy link

pbrady commented Mar 31, 2020

I'm on MacOS Catalina and attempting to use Nag6.2 as the fortran compiler to build Open MPI v4.0.3 (source tarball). I have tried using the system clang compilers as well as gcc/g++ 9.3 from homebrew. If I use gfortran from homebrew then open mpi compiles without issue so Nag appears to be the culprit here.

The configure step appears to be successful and I've attached the config.log.

make is able to run for quite some time but I keep getting the following error:

Making all in mpi/fortran/use-mpi-tkr
  PPFC     mpi.lo
NAG Fortran Compiler Release 6.2(Chiyoda) Build 6255
Error: ../../../../../ompi/mpi/fortran/use-mpi-tkr/mpi.F90, line 23: Invalid #line directive
Error: ../../../../../ompi/mpi/fortran/use-mpi-tkr/mpi.F90, line 25: Syntax error
       detected at <invalid token>@MODULE
Error: ../../../../../ompi/mpi/fortran/use-mpi-tkr/mpi.F90, line 46: Invalid #line directive
Error: ../../../../../ompi/mpi/fortran/use-mpi-tkr/mpi.F90, line 47: Invalid #line directive
Error: ../../../../../ompi/mpi/fortran/use-mpi-tkr/mpi.F90, line 47: Syntax error
Error: ../../../../../ompi/mpi/fortran/use-mpi-tkr/mpi-f90-interfaces.h, line 27: Syntax error
       detected at END@FUNCTION

I get the same errors when trying to compile Open MPI v3.1.5.

Any advice on how to fix this would be greatly appreciated.

@pbrady
Copy link
Author

pbrady commented Mar 31, 2020

This may be due to nag needing the -fpp flag to run its preprocessor. It may only be automatically invoked for .ff90 files rather than .F90 files. I may not get to this today but will report soon

@pbrady
Copy link
Author

pbrady commented Mar 31, 2020

I should say this appears to be mac specific since our group hasn't had issues with this on linux. Maybe there are some issues with case-sensitivity and Mac filesystems so .F90 looks like .f90?

@ggouaillardet
Copy link
Contributor

On Linux, .f90 files are compiled with the "standard" flags, but .F90 files are preprocessed before being compiled.
Both error message and the OS X case insensitive filesystem points to the .F90 not being preprocessed on OS X.

Assuming any fortran file can be preprocessed by NAG compiler via the -fpp flag, I would suggest you try

configure FCFLAGS=-fpp ...

and see if it helps

@pbrady
Copy link
Author

pbrady commented Apr 1, 2020

Was able to compile and successfully run make check with the added -fpp option. I'll leave this issue open because this seems like something that should be handled by the build system. Feel free to close if you disagree.

@ggouaillardet
Copy link
Contributor

I agree this is something that should be handled automatically.

Do you have any possibility to run the same test on Linux?
On second thought, I am not sure OSX case insensitive filesystem is involved here.

ggouaillardet added a commit to ggouaillardet/ompi that referenced this issue Apr 1, 2020
.F90 files are preprocessed by gfortran and other compilers.
NAG compilers only preprocess .{ff,ff90,ff95} files, and the -fpp
flag is required to process .F90 files.

Fixes open-mpi#7583

Signed-off-by: Gilles Gouaillardet <[email protected]>
@ggouaillardet
Copy link
Contributor

@pbrady could you please give a try to #7584?

you can manually download the patch at https://github.com/open-mpi/ompi/pull/7584.patch and apply it vs the 4.0.3 sources, and then run ./autogen.pl --force (note this requires recent autotools)

This should automatically add the -fpp flag to nagfor.

@pbrady
Copy link
Author

pbrady commented Apr 1, 2020

@ggouaillardet I tested the patch and was able to compile successfully with the following config:

../configure FC=nagfor

Your patch is correctly adding -fpp and fixes my issues.

On linux we build with nagfor without explicitly specifying FCFLAGS so this is mac related. However, gfortran does the expected thing on mac (as it does on linux) while nag behaves differently.

@nncarlson
Copy link

Let's make sure it doesn't screw up x86_64 platforms. There NAG passes '.F90' source files through the preprocessor automatically

@pbrady
Copy link
Author

pbrady commented Apr 1, 2020

@nncarlson Are you going to test the patch on a linux box?

@nncarlson
Copy link

@nncarlson Are you going to test the patch on a linux box?

I was going to let you test it :-) but I guess I can. What exactly should I apply the patch to? Is the latest 4.0.x release good enough, or do I need to clone the repo?

@pbrady
Copy link
Author

pbrady commented Apr 1, 2020

Autotools builds character and I think I acquired enough yesterday to last awhile. I used the 4.0.3 src tarball and applied the patch via git apply at the top level directory after unpacking.

@nncarlson
Copy link

Uh, actually would you mind testing it? Is the VPN usable for you to the petaca machines? I'd test with both NAG 6.2 and 7.0 just to be sure.

@pbrady
Copy link
Author

pbrady commented Apr 1, 2020

I appear to be cursed with a decent VPN connection today... I'll report back in a bit

@jsquyres
Copy link
Member

jsquyres commented Apr 1, 2020

everything-is-fine

@pbrady
Copy link
Author

pbrady commented Apr 1, 2020

I applied the patch and was able to successfully configure, compile and check openmpi with nag6.2 and 7.0 on linux.

@ggouaillardet This patch fixes my issues on mac and does not cause any problems on linux.

jsquyres pushed a commit to jsquyres/ompi that referenced this issue Apr 1, 2020
.F90 files are preprocessed by gfortran and other compilers.
NAG compilers only preprocess .{ff,ff90,ff95} files, and the -fpp
flag is required to process .F90 files.

Fixes open-mpi#7583

Signed-off-by: Gilles Gouaillardet <[email protected]>
(cherry picked from commit a2c711b)
@ggouaillardet
Copy link
Contributor

FWIW, the patch is not NAG nor OSX specific, and was designed not to break existing environments.

  • compile a .F90 files that fails if not preprocessed
    • if success, then no change
    • if fail, then try to compile the same .F90 file with the -fpp flag
      • if success, add the -fpp flag to FCFLAGS
      • if fail, then abort

cniethammer pushed a commit to cniethammer/ompi that referenced this issue May 10, 2020
.F90 files are preprocessed by gfortran and other compilers.
NAG compilers only preprocess .{ff,ff90,ff95} files, and the -fpp
flag is required to process .F90 files.

Fixes open-mpi#7583

Signed-off-by: Gilles Gouaillardet <[email protected]>
(cherry picked from commit a2c711b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants