Apple M3 install support

Hi,

I am attempting to install sw4 on a Macbook with an Apple M3 Pro chip by following the installation instructions. I installed gcc13 via Macports, and the lapack and blas libraries came preinstalled. I modified make.inc from make.osx for my particular setup

etree = no
proj = no
FC = /opt/local/bin/mpifort
CXX = /opt/local/bin/mpicxx
EXTRA_FORT_FLAGS =
EXTRA_LINK_FLAGS = -framework Accelerate -L/opt/local/lib/gcc13 -lgfortran

I verified that the gfortran library is available in /opt/local/lib/gcc13. When I attempt to compile I get a linker error.


cd optimize_mp; /opt/local/bin/mpicxx -O3 -I…/src -std=c++11 -Xpreprocessor -fopenmp -I…/src/double -o sw4 main.o EW.o Sarray.o version.o parseInputFile.o ForcingTwilight.o curvilinearGrid.o parallelStuff.o Source.o MaterialProperty.o MaterialData.o material.o setupRun.o solve.o Parallel_IO.o Image.o GridPointSource.o MaterialBlock.o TimeSeries.o sacsubc.o SuperGrid.o TestRayleighWave.o MaterialPfile.o Filter.o Polynomial.o SecondOrderSection.o time_functions.o Qspline.o MaterialIfile.o GeographicProjection.o Image3D.o ESSI3D.o ESSI3DHDF5.o MaterialVolimagefile.o MaterialRfile.o MaterialSfile.o AnisotropicMaterialBlock.o sacutils.o DataPatches.o addmemvarforcing2.o consintp.o oddIoddJinterp.o evenIoddJinterp.o oddIevenJinterp.o evenIevenJinterp.o CheckPoint.o geodyn.o AllDims.o Patch.o RandomizedMaterial.o MaterialInvtest.o sw4-prof.o sachdf5.o readhdf5.o TestTwilight.o TestPointSource.o curvilinear4sgwind.o TestEcons.o GridGenerator.o GridGeneratorGeneral.o GridGeneratorGaussianHill.o CurvilinearInterface2.o SfileOutput.o pseudohess.o fastmarching.o solveTT.o rhs4th3point.o MaterialGMG.o rayleighfort.o lamb_exact_numquad.o addsgdc.o bcfortc.o bcfortanisgc.o bcfreesurfcurvanic.o boundaryOpc.o energy4c.o checkanisomtrlc.o computedtanisoc.o curvilinear4sgc.o gradientsc.o randomfield3dc.o innerloop-ani-sgstr-vcc.o ilanisocurvc.o rhs4curvilinearc.o rhs4curvilinearsgc.o rhs4th3fortc.o solerr3c.o testsrcc.o rhs4th3windc.o tw_aniso_forcec.o tw_aniso_force_ttc.o velsumc.o twilightfortc.o twilightsgfortc.o tw_ani_stiffc.o anisomtrltocurvilinearc.o scalar_prodc.o updatememvarc.o addsg4windc.o bndryOpNoGhostc.o rhs4th3windc2.o dqags.o dqagse.o dqaws.o dqawse.o dqc25s.o dqcheb.o dqelg.o dqk15w.o dqk21.o dqmomo.o dqpsrt.o dqwgts.o qaws.o qawse.o qc25s.o qcheb.o qk15w.o qmomo.o qpsrt.o qwgts.o xerror.o d1mach.o r1mach.o -framework Accelerate -L/opt/local/lib/gcc13 -lgfortran
Undefined symbols for architecture arm64:
“_GOMP_atomic_end”, referenced from:
__ZNK2EW13printPreambleERSt6vectorIP6SourceSaIS2_EEi._omp_fn.0 in EW.o
__ZN2EW26extractTopographyFromRfileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE._omp_fn.0 in EW.o
__ZN2EW15check_materialsEv._omp_fn.5 in material.o
__ZN2EW17preprocessSourcesERSt6vectorIS0_IP6SourceSaIS2_EESaIS4_EE._omp_fn.4 in setupRun.o
_ZN13MaterialBlock23set_material_propertiesERSt6vectorI6SarraySaIS1_EES4_S4_S4_S4._omp_fn.0 in MaterialBlock.o
_ZN13MaterialBlock23set_material_propertiesERSt6vectorI6SarraySaIS1_EES4_S4_S4_S4._omp_fn.1 in MaterialBlock.o
_Z6scmxmnPfiS_S_S._omp_fn.0 in sacsubc.o

“_GOMP_atomic_start”, referenced from:
__ZNK2EW13printPreambleERSt6vectorIP6SourceSaIS2_EEi._omp_fn.0 in EW.o
__ZN2EW26extractTopographyFromRfileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE._omp_fn.0 in EW.o
__ZN2EW15check_materialsEv._omp_fn.5 in material.o
__ZN2EW17preprocessSourcesERSt6vectorIS0_IP6SourceSaIS2_EESaIS4_EE._omp_fn.4 in setupRun.o
_ZN13MaterialBlock23set_material_propertiesERSt6vectorI6SarraySaIS1_EES4_S4_S4_S4._omp_fn.0 in MaterialBlock.o
_ZN13MaterialBlock23set_material_propertiesERSt6vectorI6SarraySaIS1_EES4_S4_S4_S4._omp_fn.1 in MaterialBlock.o
_Z6scmxmnPfiS_S_S._omp_fn.0 in sacsubc.o

“_GOMP_barrier”, referenced from:
__ZN2EW17enforceBCfreeAtt2ERSt6vectorI6SarraySaIS1_EES4_S4_RS0_IPS1_SaIS5_EERS0_IPPdSaISA_EE._omp_fn.1 in solve.o
_ZN24AnisotropicMaterialBlock23set_material_propertiesERSt6vectorI6SarraySaIS1_EES4._omp_fn.0 in AnisotropicMaterialBlock.o
_ZN24AnisotropicMaterialBlock23set_material_propertiesERSt6vectorI6SarraySaIS1_EES4._omp_fn.1 in AnisotropicMaterialBlock.o
__ZN2EW8consintpER6SarrayS1_S1_S1_S1_S1_dS1_S1_S1_S1_S1_S1_ddiiPi._omp_fn.3 in consintp.o
__ZN2EW8consintpER6SarrayS1_S1_S1_S1_S1_dS1_S1_S1_S1_S1_S1_ddiiPi._omp_fn.2 in consintp.o
_Z20oddIoddJinterpJacobiPdR6SarrayS1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_PiS2_S2_S2_S2_S2_S2_S2_S2_S2_iiidddddS_S._omp_fn.1 in oddIoddJinterp.o
_Z23oddIoddJinterpJacobiOptPdS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_S_PiS0_S0_S0_S0_S0_S0_S0_S0_S0_iiidddddS_S._omp_fn.1 in oddIoddJinterp.o

“_GOMP_parallel”, referenced from:
_main in main.o
__ZN2EW22get_exact_point_sourceEPddiR6SourcePi in EW.o
__ZN2EW14get_exact_lambERSt6vectorI6SarraySaIS1_EEdR6Source in EW.o
__ZN2EW5ForceEdRSt6vectorI6SarraySaIS1_EES0_IP15GridPointSourceSaIS6_EES0_IiSaIiEE in EW.o
__ZN2EW8Force_ttEdRSt6vectorI6SarraySaIS1_EES0_IP15GridPointSourceSaIS6_EES0_IiSaIiEE in EW.o
__ZN2EW34extractTopographyFromCartesianFileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in EW.o
__ZN2EW30extractTopographyFromImageFileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in EW.o

“_omp_get_num_threads”, referenced from:
_main._omp_fn.0 in main.o
__ZNK2EW13printPreambleERSt6vectorIP6SourceSaIS2_EEi._omp_fn.0 in EW.o
__ZN2EW5ForceEdRSt6vectorI6SarraySaIS1_EES0_IP15GridPointSourceSaIS6_EES0_IiSaIiEE._omp_fn.0 in EW.o
__ZN2EW8Force_ttEdRSt6vectorI6SarraySaIS1_EES0_IP15GridPointSourceSaIS6_EES0_IiSaIiEE._omp_fn.0 in EW.o
__ZN2EW13update_imagesEidRSt6vectorI6SarraySaIS1_EES4_S4_S4_S4_S4_RS0_IP6SourceSaIS6_EEii._omp_fn.0 in EW.o
__ZN2EW34extractTopographyFromCartesianFileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE._omp_fn.0 in EW.o
__ZN2EW30extractTopographyFromImageFileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE._omp_fn.0 in EW.o

“_omp_get_thread_num”, referenced from:
_main._omp_fn.0 in main.o
__ZNK2EW13printPreambleERSt6vectorIP6SourceSaIS2_EEi._omp_fn.0 in EW.o
__ZN2EW5ForceEdRSt6vectorI6SarraySaIS1_EES0_IP15GridPointSourceSaIS6_EES0_IiSaIiEE._omp_fn.0 in EW.o
__ZN2EW8Force_ttEdRSt6vectorI6SarraySaIS1_EES0_IP15GridPointSourceSaIS6_EES0_IiSaIiEE._omp_fn.0 in EW.o
__ZN2EW13update_imagesEidRSt6vectorI6SarraySaIS1_EES4_S4_S4_S4_S4_RS0_IP6SourceSaIS6_EEii._omp_fn.0 in EW.o
__ZN2EW34extractTopographyFromCartesianFileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE._omp_fn.0 in EW.o
__ZN2EW30extractTopographyFromImageFileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE._omp_fn.0 in EW.o

ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make: *** [sw4] Error 1

I also tried the spack installation instructions. On that front I get a message saying “Error: InstallError: OpenMPI requires both C and Fortran compilers!” I wasnt sure how to proceed here either.

Thank you!

Amanda

Amanda:
I have nothing to do with the SW4 project, but anyone who does and wants to help will likely need to know what the linker error is. Can you provide the complete error message?
Best
W.

We got a fix over on the Github. It was and OpenMP issue, not a chip/compiler issue.
Building without OpenMP works

make sw4 openmp=no

SW4 LIVES,
Kate