compiling gotm lake branch under macOS

116 views
Skip to first unread message

Robert

unread,
Feb 28, 2020, 2:38:43 PM2/28/20
to GOTM-users
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

```
I had hoped that I could continue without problems as CMake had found netcdf.

Thanks
Robert

Karsten Bolding

unread,
Feb 28, 2020, 2:43:50 PM2/28/20
to gotm-...@googlegroups.com
Hi Robert

I had hoped the check_netcdf.sh would have revealed something.

Try and go into the build directory and type:

make VERBOSE=1 >& log 

and send the logfile

Karsten

--
You received this message because you are subscribed to the Google Groups "GOTM-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gotm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gotm-users/f834592a-b5e7-48a6-91ea-988f163cdb35%40googlegroups.com.


--

Robert

unread,
Feb 28, 2020, 3:56:02 PM2/28/20
to GOTM-users
Hi Karsten,

Here's the log file.

Thank you
Robert
log

Karsten Bolding

unread,
Feb 29, 2020, 1:44:06 AM2/29/20
to gotm-...@googlegroups.com
when you execute the configure script - can you see if Unix Makefiles or Xcode is selected?



--
You received this message because you are subscribed to the Google Groups "GOTM-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gotm-users+...@googlegroups.com.

Robert

unread,
Mar 3, 2020, 12:53:29 PM3/3/20
to GOTM-users
Unfortunately I can't see it in the terminal if Makesfiles or XCode were selected. Do you reckon the problem could be related to the difference of using Makesfiles or Makesfiles in XCode?
To unsubscribe from this group and stop receiving emails from it, send an email to gotm-...@googlegroups.com.

Robert

unread,
Mar 26, 2020, 10:19:36 AM3/26/20
to GOTM-users
I tried again several times, also compiled ncdf with gfortran again, but it still fails at 100% when linking to ncdf. Compiling the master branch also failed. Also configure.sh seems to be using Xcode. When I try running it with make it complains that lines are missing tabs. I checked that ('cat -e -t -v gotm_configure.sh'), but couldn't get it to work as my knowledge about make is limited.

 Did anyone successfully compile GOTM under macOS and could share his/her steps please?

Running nf-config gives me this, what should show that gfortran and ncdf are linked (?):
```
This  4.5.2 has been built with the following features: 

  --cc        -> /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang
  --cflags    -> -I/usr/local/Cellar/netcdf/4.7.3_1/include  -fPIC -g -Wall -Wno-unused-variable -Wno-unused-parameter -O2 

  --fc        -> /usr/local/bin/gfortran
  --fflags    -> /usr/local/Cellar/netcdf/4.7.3_1/include
  --flibs     -> -L/usr/local/Cellar/netcdf/4.7.3_1/lib 
  --has-f90   -> TRUE
  --has-f03   -> FALSE

  --has-nc2   -> TRUE
  --has-nc4   -> TRUE

  --prefix    -> /usr/local/Cellar/netcdf/4.7.3_1
  --includedir-> /usr/local/Cellar/netcdf/4.7.3_1/include
  --version   ->  4.5.2
```
Thanks,
Robert

Karsten Bolding

unread,
Mar 26, 2020, 10:36:39 AM3/26/20
to gotm-...@googlegroups.com
everything is working until linking the executable - even the NetCDF directory is listed in the link command - but the actual NetCDF libraries are missing.

I can't understand why this is the case - as nf-config is used to pick up the information

can you send the output  of the CMake configuration

Den fre. 28. feb. 2020 kl. 21.56 skrev Robert <ladwi...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "GOTM-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gotm-users+...@googlegroups.com.

Karsten Bolding

unread,
Mar 26, 2020, 10:40:44 AM3/26/20
to gotm-...@googlegroups.com
now I seee the error:

--flibs only show the folder and not the actual libraries

I get:

  --flibs     -> -L/opt/apps/software/intel20.0/netcdf-fortran/4.5.2/lib -lnetcdff -Wl,--disable-new-dtags -lnetcdf -lnetcdf -lm 

on my linux machine - and similar on the Mac


To unsubscribe from this group and stop receiving emails from it, send an email to gotm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gotm-users/b2f0ed3e-baa9-49a7-9ca2-235e721d0541%40googlegroups.com.

Adolf Stips

unread,
Mar 26, 2020, 1:06:01 PM3/26/20
to gotm-...@googlegroups.com

I guess nf-config should show something similar to this:

nf-config --flibs
-L/opt/local/lib -lnetcdff -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -lnetcdf -lnetcdf

because, I can compile gotm on my mac ( may be it should not be twice there,..)

so -lnetcdf  with the actual library is missing

Adolf


Robert

unread,
Mar 28, 2020, 3:54:28 PM3/28/20
to GOTM-users
Thanks Karsten and Adolf!

I've checked my nf-config under Linux, and there the libraries are also explicitly linked. Now that I know what the problem is, I'm still at loss on how to fix it. I reinstalled it on macOS using brew, but the libraries are still not listed. At the moment I'm not sure why brew isn't linking the ncdf libraries to gcc by default. Also googling revealed that nf-config seems to be working slightly different between Linux and Mac. I know that this problem is out of the scope of the gotm forum, but does anyone know how I can force my ncdf configuration to read in these flibs?

Thanks,
Robert


--

--
You received this message because you are subscribed to the Google Groups "GOTM-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gotm-...@googlegroups.com.

Knut

unread,
Mar 28, 2020, 6:22:38 PM3/28/20
to gotm-...@googlegroups.com

Hi Robert,

try -DCMAKE_EXE_LINKER_FLAGS="-lnetcdff -lnetcdf" (never used this so far), or -DCMAKE_Fortran_FLAGS="-lnetcdff -lnetcdf" when you call the cmake command.

Cheers, Knut

To unsubscribe from this group and stop receiving emails from it, send an email to gotm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gotm-users/e9a2faec-8f42-43ae-b41c-00f2b631d9a1%40googlegroups.com.

Robert

unread,
Mar 30, 2020, 3:35:09 PM3/30/20
to GOTM-users
Thanks Knut!
I've finally managed to compile GOTM now under macOS. Weirdly my fortran compiler installations were a mess (thanks to ifort with expired license and many brew options). At the end switching from gotm_configure.sh to cmake ~/GOTM/code -DCMAKE_EXE_LINKER_FLAGS="-lnetcdff -lnetcdf" did the trick.

Thanks,
Robert
Reply all
Reply to author
Forward
0 new messages