ここでは、Mac(M1, 2020)上で DCPAM 動かすための方法を紹介する。
dcpam5 インストールガイド に載っている必要なソフトウェアをインストールする。
gtool5, ispack, spml は arm ようバイナリが公開されていないため、ソースからビルドする。 また、公開されている netcdf のライブラリを使用してもうまくビルドできないため、こちらもソースからビルドする。
apt install -y make gcc g++ gfortran libxml2-dev m4 libcurl4-openssl-dev unzip
wget https://www.zlib.net/zlib-1.3.1.tar.gz
tar zxvf zlib-1.3.1.tar.gz
cd zlib-1.3.1
ZDIR=/usr/local
./configure --prefix=${ZDIR}
make check
make install # or sudo make install, if root permissions required
wget https://support.hdfgroup.org/releases/hdf5/v1_14/v1_14_5/downloads/hdf5-1.14.5.tar.gz
tar zxvf hdf5-1.14.5.tar.gz
cd hdf5-1.14.5
H5DIR=/usr/local
./configure --with-zlib=${ZDIR} --prefix=${H5DIR} --enable-hl
make check
make install # or sudo make install, if root permissions required
export PATH=$PATH:${H5DIR}/bin
wget https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netcdf-c-4.9.2.tar.gz
tar zxvf netcdf-c-4.9.2.tar.gz
cd netcdf-c-4.9.2
export NCDIR=/usr/local
export CPPFLAGS="-I${H5DIR}/include -I${ZDIR}/include"
export LDFLAGS="-L${H5DIR}/lib -L${ZDIR}/lib"
./configure --prefix=${NCDIR}
make check
make install
export PATH=$PATH:${NCDIR}/bin
wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.1/netcdf-fortran-4.6.1.tar.gz
tar zxvf netcdf-fortran-4.6.1.tar.gz
cd netcdf-fortran-4.6.1
export NFDIR=/usr/local
export CC=gcc
export FC=gfortran
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NCDIR}/lib
export CPPFLAGS=-I${NCDIR}/include
export LDFLAGS=-L${NCDIR}/lib
./configure --prefix=${NFDIR}
make check
make install
export PATH=$PATH:${NFDIR}/bin
wget https://www.gfd-dennou.org/library/gtool/gtool5/gtool5_current.tgz
tar xzvf gtool5_current.tgz
cd gtool5-20160613
export G5DIR=/usr/local
export FFLAGS=\
-I${ZDIR}/include:\
-I${H5DIR}/include:\
-I${NCDIR}/include:\
-I${NFDIR}/include
export LD_LIBRARY_PATH=\
-I${ZDIR}/lib:\
-I${H5DIR}/lib:\
-I${NCDIR}/lib:\
-I${NFDIR}/lib
./configure \
--prefix=${G5DIR} \
--with-netcdf=${NCDIR}/lib/libnetcdf.a \
--with-netcdff=${NCDIR}/lib/libnetcdff.a \
--with-netcdf-include=${NCDIR}/include/netcdf.inc \
--build=arm
make
make install
make test-installed
export PATH=$PATH:${G5DIR}/bin
https://www.gfd-dennou.org/library/ispack/ispack-1.0.4.tar.gz
tar xzvf gtool5_current.tgz
cd ispack-1.0.4
export ISPDIR=/usr/local
make
cp libisp.a ${ISPDIR}/lib
wget https://www.gfd-dennou.org/arch/spmodel/spml_current.tar.gz\
tar zxvf spml_current.tar.gz
cd spml-0.8.0
export SPMDIR=/usr/local
export LD_LIBRARY_PATH=\
-I${ZDIR}/lib:\
-I${H5DIR}/lib:\
-I${NCDIR}/lib:\
-I${NFDIR}/lib:\
-I${G5DIR}/lib:\
-I${ISPDIR}/lib
./configure \
--prefix=${SPMDIR} \
--build=arm \
--with-netcdf=${NCDIR}/lib/libnetcdf.a \
--with-netcdff=${NCDIR}/lib/libnetcdff.a \
--with-netcdf-include=${NCDIR}/include/netcdf.inc \
--with-gtool5=${G5DIR}/lib/libgtool5.a \
--with-ispack=${ISPDIR}/lib/libisp.a
cp libsrc/Makefile libsrc/Makefile.bak \
&& awk 'NR != 149 && NR != 524 { gsub(/ef_module\ /, ""); print }' "libsrc/Makefile" > "libsrc/Makefile.tmp" \
&& mv libsrc/Makefile.tmp libsrc/Makefile
cp test/Makefile test/Makefile.bak \
&& awk '{ gsub(/ef_module\ /, ""); print }' "test/Makefile" > "test/Makefile.tmp" \
&& mv test/Makefile.tmp test/Makefile
make
make check
make install
export PATH=$PATH:${SPMDIR}/bin
dcpam5 インストールガイド の「ビルドの手引き」や inex実習資料 - 地球惑星情報実習(2024.07.19) を参考に行うとよい。