Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling gotm lake branch under macOS #4

Open
robertladwig opened this issue Feb 28, 2020 · 6 comments
Open

Compiling gotm lake branch under macOS #4

robertladwig opened this issue Feb 28, 2020 · 6 comments

Comments

@robertladwig
Copy link

robertladwig commented Feb 28, 2020

I'm currently trying to compile GOTM lake v5.3-673 under macOS (Catalina v10.15.3) after having no problems in compiling it under Ubuntu (18.04). I added the line -DGOTM_USE_STIM=on \ to gotm_configure.sh to include ice dynamics.

Now, running gotm_configure.sh works without problems and creates a gfortran directory, but gotm_build.sh reaches 100% and then fails in building the executable:

[100%] Linking Fortran executable gotm
Undefined symbols for architecture x86_64:
  "___netcdf_MOD_nf90_close", referenced from:
      ___netcdf_output_MOD_finalize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_create", referenced from:
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_def_dim", referenced from:
      _get_dim_id.4982 in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_def_var_manydims", referenced from:
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_enddef", referenced from:
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_get_att_text", referenced from:
      ___input_netcdf_MOD_check_restart_time in libinput_manager.a(input_netcdf.F90.o)
  "___netcdf_MOD_nf90_get_var_1d_eightbytereal", referenced from:
      ___input_netcdf_MOD_read_restart_data in libinput_manager.a(input_netcdf.F90.o)
  "___netcdf_MOD_nf90_get_var_eightbytereal", referenced from:
      ___input_netcdf_MOD_read_restart_data in libinput_manager.a(input_netcdf.F90.o)
  "___netcdf_MOD_nf90_inq_libvers", referenced from:
      _print_version_ in libgotm.a(print_version.F90.o)
  "___netcdf_MOD_nf90_inq_varid", referenced from:
      ___input_netcdf_MOD_read_restart_data in libinput_manager.a(input_netcdf.F90.o)
      ___input_netcdf_MOD_check_restart_time in libinput_manager.a(input_netcdf.F90.o)
  "___netcdf_MOD_nf90_open", referenced from:
      ___input_netcdf_MOD_read_restart_data in libinput_manager.a(input_netcdf.F90.o)
      ___input_netcdf_MOD_check_restart_time in libinput_manager.a(input_netcdf.F90.o)
  "___netcdf_MOD_nf90_put_att_one_eightbytereal", referenced from:
      ___netcdf_output_MOD_put_att_typed_real in liboutput_manager.a(netcdf_output.F90.o)
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_att_one_fourbyteint", referenced from:
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_att_one_fourbytereal", referenced from:
      ___netcdf_output_MOD_put_att_typed_real in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_att_text", referenced from:
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_var_1d_eightbytereal", referenced from:
      ___netcdf_output_MOD_save in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_var_2d_eightbytereal", referenced from:
      ___netcdf_output_MOD_save in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_var_3d_eightbytereal", referenced from:
      ___netcdf_output_MOD_save in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_put_var_eightbytereal", referenced from:
      ___netcdf_output_MOD_save in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_strerror", referenced from:
      ___input_netcdf_MOD_handle_err in libinput_manager.a(input_netcdf.F90.o)
      ___netcdf_output_MOD_save in liboutput_manager.a(netcdf_output.F90.o)
      ___netcdf_output_MOD_finalize in liboutput_manager.a(netcdf_output.F90.o)
      _get_dim_id.4982 in liboutput_manager.a(netcdf_output.F90.o)
      ___netcdf_output_MOD_initialize in liboutput_manager.a(netcdf_output.F90.o)
  "___netcdf_MOD_nf90_sync", referenced from:
      ___netcdf_output_MOD_save in liboutput_manager.a(netcdf_output.F90.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [gotm] Error 1
make[1]: *** [CMakeFiles/gotm_exe.dir/all] Error 2
make: *** [all] Error 2

Any recommendations/ideas why it's failing during the last step? Both my systems (macOS and Ubuntu) are 64bit.

edit: It seems all errors are somehow related to netcdf. When running check_netcdf.sh, I get

robertladwig$ ./check_netcdf.sh 

Checking if CMake can find NetCDF compile and link information ...

-- Found NetCDF: -L/usr/local/Cellar/netcdf/4.7.3_1/lib  
CMake Error at extern/flexout/cmake/Modules/FindNetCDF.cmake:86 (add_library):
  add_library command is not scriptable


The above MUST include - Found NetCDF - to successfully continue

Thanks
Robert

@bolding
Copy link
Collaborator

bolding commented Feb 28, 2020 via email

@lexiemerk
Copy link

Hi! Was this ever resolved? I have run into the same issue.

@bolding
Copy link
Collaborator

bolding commented Sep 28, 2023

Hello

I'm not sure if it was resolved - but I do remember that the NetCDF link information was not included properly on Mac. Whether this has been solved or not - I don't know. It is also outside what can be fixed in GOTM. I've have an old Mac for testing purposes - and I don't have the problem.

Karsten

@bolding bolding reopened this Sep 28, 2023
@robertladwig
Copy link
Author

I did solve my issues back then by specifying the cmake command:
cmake ~/GOTM/code -DCMAKE_EXE_LINKER_FLAGS="-lnetcdff -lnetcdf"

Here's the link to the google groups thread: https://groups.google.com/g/gotm-users/c/I5ApEpqt6YA/m/STUl4DGoBgAJ

@bolding
Copy link
Collaborator

bolding commented Sep 29, 2023

Hi

The two errors are related but not quite the same. Anyway the solution for the first problem can be used to solve the other.

Try:
nc-config --libs
-L/usr/local/Cellar/netcdf/4.9.2_1/lib -lnetcdf

The first is the folder where the netcdf C library is.

cmake -B ./build -S . -DGOTM_USE_FABM=off -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/Cellar/netcdf/4.9.2_1/lib

will create the build environment in the build folder.

For me compilation passes the issue with -lnetcdf. Unfortunately, another error comes up.

Undefined symbols for architecture x86_64:
"report_error", referenced from:
___settings_MOD_type_input_create in libconfig.a(settings.F90.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

I'm not sure what to do with this one.

Karsten

@bolding
Copy link
Collaborator

bolding commented Sep 29, 2023

thanks to Robert for digging up the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants