My setup is different. I have an intel based machine to run Matlab (Ubuntu), and an M1 (ARM Architecture) to run the C/C++ backend code. I also use matlab R2022a on the M1 machine. R2022a still runs on Rosetta, but is more stable and runs faster than previous versions. R2023 should run natively on M1 based machines. My R2022a is is only for testing; but I think they also released it to the public today.
There are limited virtual machines that can run on M1, but they all handle only ARM architecture, meaning ubuntu running on it will still not be able to handle matlab.
My suggestion is not install Matlab on the M1; or install it before ISSM has been installed. Matlab needs its own version of libraries. So after gcc and Xcode are installed, those libraries will have to be fixed.They are easy fixes, as soon as Matalb is run, it will give errors, and only symbolic links to Matlabβs own libraries will need to be created (in the Matlab path). But if it is installed after gcc, then gcc libraries will need to be fixed which is more complex (I ended up reseting my Mac - because fixing the libraries for gcc became impossible).
The new macOS also uses zsh as the default shell which would be best to change it to bash.
Here are the steps that I followed:
1) Switched the default shell to bash: chsh -s /bin/bash
2) Installed XCode from the App Store (this can be done from the command line β but it is easier to install to entire package from the app store.
3) Insalled homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
4) Installed svn: brew install subversion
5) Even though I had XCode, I needed to isntall gcc to get gFortran: (brew install gcc)
6) Got the latest ISSM code from the repo.
7) I installed autotools, cmake, petsc, triangle, chaco, and m1qn3 (in this order)
Petsc ran with no errors. But triangle gave me some errors that I had to go through trial and error to find the missing libraries and install them separately. Unfortunately, i didn't document those.
8) Then I created this configure file:
./configure \
--prefix="${ISSM_DIR}" \
--disable-static \
--enable-development \
--enable-debugging \
--with-numthreads=8 \
--with-fortran-lib="-L/opt/homebrew/Cellar/gcc/11.2.0_2/lib/gcc/11 -lgfortran" \
--with-mpi-include="${ISSM_DIR}/externalpackages/petsc/install/include" \
--with-mpi-libflags="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lmpi -lmpicxx -lmpifort" \
--with-metis-dir="${ISSM_DIR}/externalpackages/petsc/install" \
--with-parmetis-dir="${ISSM_DIR}/externalpackages/petsc/install" \
--with-blas-lapack-dir="${ISSM_DIR}/externalpackages/petsc/install" \
--with-scalapack-dir="${ISSM_DIR}/externalpackages/petsc/install" \
--with-mumps-dir="${ISSM_DIR}/externalpackages/petsc/install" \
--with-petsc-dir="${ISSM_DIR}/externalpackages/petsc/install" \
--with-triangle-dir="${ISSM_DIR}/externalpackages/triangle/install" \
--with-chaco-dir="${ISSM_DIR}/externalpackages/chaco/install" \
--with-m1qn3-dir="${ISSM_DIR}/externalpackages/m1qn3/install"
I did "make" and then "make install". I got many warnings, but no fatal error. Then, I tested the code by manually calling Issm.exe to analyze a model. The result was the same as the result from Ubuntu. But the residuals were slightly different (delta of about 1*10^-16).
My ISSM folders are shared between ubuntu and Mac, so now these two machines are talking and while Ubuntu runs matlab, Mac runs the C/C++ code.
To make ubuntu and Mac work together, I used the easiest and the most non-standard quick and dirty way. So, there are better ways. For this I use Putty on ubuntu and changed the generic.m and solve.m and added a few lines. It is very unsecure (password and locations are being hardcoded). A small disclaimer. These are dangerous changes that could break your code so please proceed with caution and obviously I take no responsibility if it breaks. For me, it is okay because I'm on a secure network. And please do not put these changes back into the repo.
Some preliminary work:
1) I made the trunk-jpl folder on Ubuntu a shared folder
2) I mapped the above shared folder on the Mac as ISSM
3) Made the following changes to the matlab code.
In generic.m line 107: - added these (because I do not want to check the permission of the files every time, I enforce chmod). What is happening here is that the queue file will have the call to putty to establish a connection to Mac; once the connection is established, putty will launch the queue1 file. This second file launches issm.exe from Mac to read and analyze the model file from ubuntu. No download or transfer of files is happening, but if network is slow, the files can be copied to Mac in the same file before launching the issm.exe.
fid1=fopen([modelname '.queue1'],'w');
fprintf(fid1,'#!%s\n',cluster.shell);
launchText = ['mpiexec -np 20 <<location of issm.exe on the mac machine>>issm.exe ' solution ' /volumes/ISSM/trunk-jpl//execution/' dirname '/' modelname];
fprintf(fid1, launchText);
fclose(fid1);
launchText = ['chmod ugo=rw <<location of the execution folder on the ubuntu machine>> /execution/' dirname '/' modelname '.* && putty -ssh <<username>>@<<IP address of Mac>> -pw <<MacPassword>> -m <<location of the execution folder on the ubuntu machine>> execution/' dirname '/' modelname '.queue1 -v -sessionlog <<location of the execution folder on the ubuntu machine>> /execution/' dirname '/' modelname '.Maclog']
fprintf(fid1, launchText);
Then, in solve.m in line 142 I added:
Filelist{end+1}=[modelname β.queue1β];
Now, when I run matlab on ubuntu, it uses Mac to solve the model; and if I save the model I can open the model on Mac as well. 2022a offers some support of ISSM as long as Mex is not needed.