teuben / nemo

a Stellar Dynamics Toolbox (Not Everybody Must Observe)
https://astronemo.readthedocs.io
GNU General Public License v2.0
58 stars 43 forks source link

Pgplot compilation : a workaround #110

Open jcldc opened 1 year ago

jcldc commented 1 year ago

Since gcc 10.x Pgplot does not compile. The workaround is just to add compilation flag -fallow-argument-mismatch to the pgplot makefile and the it compiles flawlessly. It would be necessary to patch pgplot makefile during nemo configuration/installation

teuben commented 1 year ago

Is this the 'mknemo pgplot' method? I don't recall i needed flags with either gcc 12 or 11

On Sun, Nov 27, 2022, 13:06 Jean-Charles Lambert @.***> wrote:

Since gcc 10.x Pgplot does not compile. The workaround is just to add compilation flag -fallow-argument-mismatch to the pgplot makefile and the it compiles flawlessly. It would be necessary to patch pgplot makefile during nemo configuration/installation

— Reply to this email directly, view it on GitHub https://github.com/teuben/nemo/issues/110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ4MGLBGAYTCHVWNP62BJLWKOPJ5ANCNFSM6AAAAAASMUGOGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jcldc commented 1 year ago

well... I am confused.... I was working on a old branch and pgplot was not compiling without this flag..... should not work on sunday...

teuben commented 1 year ago

I do remember I needed this flag in a few fortran codes, sellwood maybe, and also the io_nemo Makefile now has:

  FFLAGS = -O -fno-second-underscore -fallow-argument-mismatch

working on Sunday, as long as it's in moderation, can be entertaining

jcldc commented 1 year ago

Ok, on monday my brain works better :)

Well, I confirm that this flag -fallow-argument-mismatch is actually mandatory, since gcc 10.x, IF gif driver is requested.

The following pgplot installation :

$NEMO/src/scripts/pgplot.install png=0 gif=1

fails without this flag added into $NEMO/lib/makefile

And by default, https://teuben.github.io/nemo/install_nemo script has by default set gif =1, then pgplot fails to compile. It should be necessary to set gif=0 in this script or/and to add -fallow-argument-mismatch to the pgplot makefile (for gcc >= 10.x)

teuben commented 1 year ago

I always use PNG now, but I guess for making animated GIF's there might be a reason to keep this. I will add this to the configure procedure

But I should note that this particular install_nemo script is deprecated in favor of the install_nemo.sh counter part. More cleanly written. The old csh version is - shall we say - organically grown and is messy to look at.

jcldc commented 1 year ago

The pb with PNG is that the libpng-devel package needs to be installed on the server. Then if it's not installed what happens with pgplot installation/compilation ?

teuben commented 1 year ago

it should fail. Somehow I seem to have it by default in ubuntu, I didn't put it in my default "packages to install" in $NEMO/src/scripts/linux/ubuntu20.04. If you have own favorite OS, you should add your packages to a list in that directory, it will be useful for me too.

jcldc commented 1 year ago

I am encountering all these issues because I am building nemo inside manylinux_2xxx docker images which are centos base distributions. (the purpose is too build python-unsio and python-unsiotools and upload to pypi.org)

jcldc commented 1 year ago

it should fail. Somehow I seem to have it by default in ubuntu, I didn't put it in my default "packages to install" in $NEMO/src/scripts/linux/ubuntu20.04. If you have own favorite OS, you should add your packages to a list in that directory, it will be useful for me too.

it should be good to check if png package is present

teuben commented 1 year ago

btw, are you are we need to add it to makedefs, and not to the pgplot install script. They have their own peculiar method to set compiler specific flags.

jcldc commented 1 year ago

Do you mean compilation flag for pgplot ? Well, it might be a good idea to put it in $NEMOLIB/makedefs but during pgplot installation, the file $NEMOLIB/makefile is created and the pgplot's compilation is based on it... Entry FFLAGC=-u -Wall -fPIC -O should be modified with something like FFLAGC=-u -Wall -fPIC -O ${NEMOFORTFLAGS} and an include of makefedfs (with NEMOFORTFLAGS set) should be present in $NEMOLIB/makefile

teuben commented 1 year ago

Looking at the code in $NEMO/local/pgplot (where "mknemo pgplot" dumps the code) I see that in

   $NEMO/local/pgplot/sys_linux/gfortran_gcc.conf

one needs to modify

   FFLAGC="-u -Wall -fPIC -O -fallow-argument-mismatch"

but my programs then coredump'd when using the /gif driver. I forgot to add the int8=1 fix to the pgplot build script. After this i got good gif files.

The int8=1 changes

  -      INTEGER*4 PIXMAP, WORK
  +      INTEGER*8 PIXMAP, WORK

in gidriv, ppdriv and wddriv

teuben commented 1 year ago

I'm also willing to make gif=0 the default, but that csh script has been deprecated. The new install_nemo.sh script already had gif=0 by default, if you use the yapp=pglocal (which uses our source code). But that new one also has png=1 as default, so you need the png development library. So what's better for your docker usage?

\

jcldc commented 1 year ago

The better would be to have no png and no gif. So far, I install nemo like this (from Dockerfile), see : https://gitlab.lam.fr/infrastructure/unsio/-/blob/master/CI/docker/manylinux2014/Dockerfile

wget https://teuben.github.io/nemo/install_nemo &&\
chmod +x install_nemo                 &&\
export NO_ARCH_NATIVE=1         &&\
./install_nemo png=0 gif=0
teuben commented 1 year ago

thanks, it's good to see such a dockerfile so I can see how you do this.

If you don't really care about the drivers in pgplot and just want a compilation, you should use the yapp=ps driver. Much easier and doesn't need another library. Even yapp=null should work. I can also "advertise" the install_nemo.sh script, try

 docs/install_nemo.sh -h

to see the options. I would like to argue you can now do it in two steps. Or does dockerfile not support the prefix?

  wget   https://teuben.github.io/nemo/install_nemo.sh   &&\
  NO_ARCH_NATIVE=1   bash   ./install_nemo.sh   yapp=ps

some of the options in install_nemo haven't been ported to install_nemo.sh, but I'll add some if you argue in their favor :-)

jcldc commented 1 year ago

OK I will try yapp=ps

teuben commented 1 year ago

I think we can close this issue, barring hearing from you if you're happy with using the bash script instead (and with yapp=ps)

jcldc commented 1 year ago

Sure, yes you can close it. THANKS for your help !