nichollsh / SOCRATES

Redistributed on GitHub from the original TRAC repository, with modifications and additions.
https://code.metoffice.gov.uk/trac/socrates
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Make the code more portable #7

Open stefsmeets opened 1 month ago

stefsmeets commented 1 month ago

The portable builds fail on my machine (Fedora) with Program received signal SIGSEGV: Segmentation fault - invalid memory reference. It appears that the code is not statically compiled

Currently the code is compiled with -march=native, if we want portable builds we should change this to -march=x86-64.

nichollsh commented 1 month ago

So will we need to generate 3 different builds? Linux x86, MacOS x86, and MacOS ARM.

stefsmeets commented 1 month ago

Yeah, if you want to have builds for Mac we should set up separate workflow steps. Do you have installation instructions for macos?

I don't have access to macos, so I cannot test it.

nichollsh commented 1 month ago

The installation steps for MacOS are mostly the same as Linux, as long as gfortran is being used. I have gfortran and the NetCDF libraries installed via brew.

brew install netcdf netcdf-fortran gfortran

The only other difference versus Linux is the location of the NetCDF library, which is located automatically with the nf-config command used by the configure script. This tool is downloaded by brew alongside the NetCDF libraries themselves.

(Note that this is just from memory, since I don't have my Mac available to me at the moment).

stefsmeets commented 1 month ago

I changed the compiler flags to -march=x86-64 -fbacktrace -g -static.

I had to install these libraries: sudo dnf install netcdf-fortran-static netcdf-static glibc-static libgfortran-static.

But the compilation is giving some errors of this kind:

...
(.text+0x257): undefined reference to `nc_insert_array_compound'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/libnetcdff.a(nf_lib.o): in function `nc_inq_compound_field_ndims':
(.text+0x2a4): undefined reference to `nc_inq_compound_field'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/libnetcdff.a(nf_lib.o): in function `nc_inq_compound_field_f':
(.text+0x2ff): undefined reference to `nc_inq_compound_field'
/usr/bin/ld: (.text+0x349): undefined reference to `nc_inq_compound_field'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/libnetcdff.a(nf_lib.o): in function `nc_inq_varnparams':
(.text+0x3d9): undefined reference to `nc_inq_var_filter'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/libnetcdff.a(nf_lib.o): in function `nc_inq_numgrps':
(.text+0x397): undefined reference to `nc_inq_grps'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/libnetcdff.a(nf_lib.o): in function `nc_inq_numtypes':
(.text+0x3a7): undefined reference to `nc_inq_typeids'

I'm not entirely sure how these can be solved.

stefsmeets commented 1 month ago

Seems like it can no longer find the netcdf-fortran library.