I/O API installation with apple M1

Hello everyone,

Disclaimer: I am completely inexperienced when it comes to software.

I am trying to install I/O API on my M1 mac, but I just can’t seem to compile it successfully. I have tried in the regular zsh and in rosetta. I think a big problem is I don’t know how to write the Makeinclude file for my machine type. I also am relying on GCC and gfortran, which I understand can be kind of fickle.

If anyone has successfully installed I/O API on a mac M1 and could walk me through it, I would really really appreciate it.

Here is the Makeinclude.OSX_x86_gfortran file that I tried:

VERSION “Id: Makeinclude.OSX_x86 100 2015-01-16 16:52:16Z coats

03/2016 by CJC for MAC OSX gfortran/gcc.

12/2013 by CJC: Conditional preprocessor-code “-DNEED_ARGS=1”

to implement IARGC() and GETARG() for compilers

(“gfortran” version 4.8 or later to be exact) that insist on

enforcing F2003-only with no backwards nor industry-standards compatibility.

Remove “-DNEED_ARGS=1” from ARCHFLAGS for gfortran-4.7.x and earlier

Use “-march=native -mtune=native” if compile-platform and compute-platform

are the same, for processor specific instruction-set and optimization.

Use “-Wall -Wsurprising” for full diagnostics.

AR = ar
CC = gcc -arch x86_64
FC = gfortran -arch x86_64
M4 = m4
CPP = cpp
LINK = gcc -arch x86_64

MODI = -I ## Module-include-directory command
E132 = -ffixed-line-length-132

MFLAGS = -ffast-math -funroll-loops -m64 -Wall -Wsurprising -march=x86-64 -mtune=generic

OMPFLAGS = -fopenmp
OMPLIBS = -fopenmp
COPTFLAGS = -O3 -fno-common {MFLAGS} FOPTFLAGS = -O3 {MFLAGS}
FPPFLAGS = -DF90=1
FSFLAGS = -fno-automatic
ARCHFLAGS = -DF90=1 -DAUTO_ARRAYS=1 -DMACH=1 -DFLDMN=1 -DNEED_ARGS=1
PARFLAGS =
ARCHLIB =

M4DEFFILE =
PVMLIBS =

And the current error I get when I try to run make is something like this:
~/build/ioapi-3.2/ioapi/modncfio.F90:2323:58:

2323 | ISTAT = NF_GET_VARA_REAL( FID, VID, DIMS, DELS, GRID )
| 1

13424 | ISTAT = NF_GET_VARA_REAL( FID, VID, DIMS, DELS, GRID )
| 2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
make: *** [modncfio.o] Error 1

See ioapi/Makeinclude.Linux2_x86_64gfort10: you need also to add the flag “-fallow-argument-mismatch” to deal with version-10-and-later gfortran’s idiosyncratic interpretation of the Fortran-2018 Standard.

Thank you! That allowed me to make but I’m not sure that it completed successfully. I get messages that say files have no symbols, for example:

/opt/anaconda3/bin/arm64-apple-darwin20.0.0-ranlib: file: libioapi.a(ddtvar3v.o) has no symbols

/opt/anaconda3/bin/arm64-apple-darwin20.0.0-ranlib: file: libioapi.a(iocpl.o) has no symbols

/opt/anaconda3/bin/arm64-apple-darwin20.0.0-ranlib: file: libioapi.a(iocplf2c.o) has no symbols

This should be OK, since these are only used with PVM based coupling-mode (which you’re not using); it’s another “gotcha” that they need to be defined (but empty) anyway…

Ok I see. I can’t run make install nor can I compile m3tools, however.

make install
make: *** No rule to make target $HOME/build/ioapi-3.2/lib’, needed by install'. Stop.

m3tools $ make

cd $HOME/build/ioapi-3.2/OSX_x86_gfortran; gfortran -arch x86_64 airs2m3.o -L/$HOME/build/ioapi-3.2/OSX_x86_gfortran -lioapi -lnetcdff -lnetcdf -fopenmp -o airs2m3
ld: can’t re-map file, errno=22 file ‘/usr/local/Cellar/gcc/14.2.0/lib/gcc/current/libgcc_s.1.1.dylib’ for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [airs2m3] Error 1

That -arch x86_64 is a problem. Try removing it from the flags.

I am still getting the same result after removing -arch x86_64 from the flags in the Makeinclude file.