Skip to content
This repository was archived by the owner on Nov 18, 2026. It is now read-only.
This repository was archived by the owner on Nov 18, 2026. It is now read-only.

[Bug] Error linking with PnetCDF #22

Closed

Description

@ytremolet

Current behavior (describe the bug)

Trying to build MPAS in a bundle with JEDI. I am getting the following error (in verbose mode):

/usr/local/bin/gfortran -O3 -DNDEBUG -funroll-all-loops -finline-functions -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15 -dynamiclib -Wl,-headerpad_max_install_names -Wl,-flat_namespace -Wl,-commons,use_dylibs -L/usr/local/Cellar/libevent/2.1.12/lib -o ../../../lib/libmpas_framework.dylib -install_name @rpath/libmpas_framework.dylib CMakeFiles/framework.dir/mpas_abort.F.o CMakeFiles/framework.dir/mpas_attlist.F.o CMakeFiles/framework.dir/mpas_block_creator.F.o CMakeFiles/framework.dir/mpas_block_decomp.F.o CMakeFiles/framework.dir/mpas_bootstrapping.F.o CMakeFiles/framework.dir/mpas_c_interfacing.F.o CMakeFiles/framework.dir/mpas_constants.F.o CMakeFiles/framework.dir/mpas_decomp.F.o CMakeFiles/framework.dir/mpas_derived_types.F.o CMakeFiles/framework.dir/mpas_dmpar.F.o CMakeFiles/framework.dir/mpas_domain_routines.F.o CMakeFiles/framework.dir/mpas_field_accessor.F.o CMakeFiles/framework.dir/mpas_field_routines.F.o CMakeFiles/framework.dir/mpas_forcing.F.o CMakeFiles/framework.dir/mpas_framework.F.o CMakeFiles/framework.dir/mpas_hash.F.o CMakeFiles/framework.dir/mpas_io.F.o CMakeFiles/framework.dir/mpas_io_streams.F.o CMakeFiles/framework.dir/mpas_io_units.F.o CMakeFiles/framework.dir/mpas_kind_types.F.o CMakeFiles/framework.dir/mpas_log.F.o CMakeFiles/framework.dir/mpas_pool_routines.F.o CMakeFiles/framework.dir/mpas_sort.F.o CMakeFiles/framework.dir/mpas_stream_list.F.o CMakeFiles/framework.dir/mpas_stream_manager.F.o CMakeFiles/framework.dir/mpas_threading.F.o CMakeFiles/framework.dir/mpas_timekeeping.F.o CMakeFiles/framework.dir/mpas_timer.F.o CMakeFiles/framework.dir/pool_hash.c.o CMakeFiles/framework.dir/random_id.c.o CMakeFiles/framework.dir/regex_matching.c.o CMakeFiles/framework.dir/xml_stream_parser.c.o   -L/usr/local/Cellar/pnetcdf/1.12.2_1/lib  -Wl,-rpath,"\$ORIGIN/../lib" -Wl,-rpath,/usr/local/Cellar/pnetcdf/1.12.2_1/lib ../../../lib/libesmf.dylib ../../../lib/libezxml.dylib /usr/local/lib/libnetcdff.dylib /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempif08.dylib /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempi_ignore_tkr.dylib /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_mpifh.dylib /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib /opt/modules/clang-12.0.0/openmpi-4.1.1/pio/2.5.1-debug/lib/libpiof.a /usr/local/lib/libnetcdf.dylib -L/usr/local/Cellar/netcdf/4.8.0_1/lib -lnetcdf /opt/modules/clang-12.0.0/openmpi-4.1.1/pio/2.5.1-debug/lib/libpioc.a -L/usr/local/Cellar/netcdf/4.8.0_1/lib -lnetcdff -lnetcdf 
Undefined symbols for architecture x86_64:
  "_ncmpi_begin_indep_data", referenced from:
      _PIOc_get_vars_tc in libpioc.a(pio_getput_int.c.o)
      _PIOc_put_vars_tc in libpioc.a(pio_getput_int.c.o)
  "_ncmpi_bput_vars_double", referenced from:
      _PIOc_put_vars_tc in libpioc.a(pio_getput_int.c.o)
  "_ncmpi_bput_vars_float", referenced from:
      _PIOc_put_vars_tc in libpioc.a(pio_getput_int.c.o)

MANY lines like this so I'm skipping some here.

  "_ncmpi_set_fill", referenced from:
      _PIOc_set_fill in libpioc.a(pio_nc.c.o)
  "_ncmpi_strerror", referenced from:
      _PIOc_strerror in libpioc.a(pioc_support.c.o)
  "_ncmpi_wait_all", referenced from:
      _flush_output_buffer in libpioc.a(pio_darray_int.c.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libmpas_framework.dylib] Error 1
make[1]: *** [MPAS/src/framework/CMakeFiles/framework.dir/all] Error 2

Looking carefully at the arguments passed to gfortran, I can see the path to find PnetCDF, but there is no -lpnetcdf.
If I add -lpnetcdf manually to the gfortran command it works.

I am building on a mac with clang and gfortran but it's not a compiler issue. It has to do with cmake (I'm using 3.20.5). I don't know how to modify the cmake configurations to add -lpnetcdf to the gfortran arguments. Does somebody know? And does it work on other platforms?

Activity

  1. added
    bug
    on Jul 2, 2021
  2. mmiesch commented on Jul 2, 2021

    @mmiesch

    you could try adding this to mpas-jedi/src/mpasjedi/CMakeLists.txt

    target_link_libraries( ${PROJECT_NAME}  PUBLIC pnetcdf )
  3. mmiesch commented on Jul 2, 2021

    @mmiesch

    Or, maybe that's needed in the MPAS-Model repo..

  4. ytremolet commented on Jul 2, 2021

    @ytremolet
    Author

    I've tried adding it in a few different places, not luck so far but I'm shooting in the dark because I have no idea where it should be.
    It's that or something is missing in FindPnetCDF.

  5. mmiesch commented on Jul 2, 2021

    @mmiesch

    I can give it a try. Maybe the best is to use jedi-cmake. We have a FindPnetCDF there that defines targets like PnetCDF::PnetCDF_Fortran which can then be linked. Maybe that would work better than the native Find package.

  6. ytremolet commented on Jul 2, 2021

    @ytremolet
    Author

    Thanks. I'm using jedi-cmake in my bundle, and there is also a FindPnetCDF in this repo (in cmake/Modules), not sure which one gets used but they seem to be the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions