2014年9月16日火曜日

failed to cmake, but succeeded with make

cmake -L ~/GOTM/gotm-git/src 
.
.
.
NetCDF_INCLUDE_DIRS:PATH=/usr/include
NetCDF_LIBRARIES:STRING=-lnetcdf

"make" produces an error (not locating the appropriate netcdf directory).

head /usr/include/netcdf.inc 
!     NetCDF-3.
!
! netcdf version 3 fortran interface:
.
.
.

Thus, by the current (default) setting, cmake is choosing netcdf3, which cannot be used in FABM-GOTM (we need netcdf4). We need to manually set the location of netcdf libraries (and include as well?).

cmake -L -DNetCDF_LIBRARIES=/usr/local/netcdf-4.3.0_GF/lib ~/GOTM/gotm-git/src
-- Found NetCDF: /usr/local/netcdf-4.3.0_GF/lib
-- Configuring done
WARNING: Target "gotm_exe" requests linking to directory "/usr/local/netcdf-4.3.0_GF/lib".  Targets may link only to libraries.  CMake is dropping the item.
.
.
.
NetCDF_INCLUDE_DIRS:PATH=/usr/include

NetCDF_LIBRARIES:STRING=/usr/local/netcdf-4.3.0_GF/lib

"make" still produces an error. probably /usr/include is not right and I need to specify the path for it as well.

cmake -L -DNetCDF_LIBRARIES=/usr/local/netcdf-4.3.0_GF/lib -DNetCDF_INCLUDE_DIRS=/usr/local/netcdf-4.3.0_GF/include ~/GOTM/gotm-git/src
.
.
.
NetCDF_INCLUDE_DIRS:PATH=/usr/local/netcdf-4.3.0_GF/include

NetCDF_LIBRARIES:STRING=/usr/local/netcdf-4.3.0_GF/lib

make
.
.
.
gotm_fabm_output.F90:(.text+0x217a): undefined reference to `__netcdf_MOD_nf90_put_att_one_fourbyteint'
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

Still the same error...

I gave up on "cmake" for now. Instead I tried the good old "make" compilation in ~/GOTM/gotm-git/src.

and I was able to do compile with the following script:

doit.sh
#! /bin/sh
export PATH=/usr/local/netcdf-4.3.0_GF/bin:$PATH
export FORTRAN_COMPILER=GFORTRAN
export NETCDF_VERSION=NETCDF4

make

Providing the path to netcdf bin folder helped.

This can be coupled to FABM which is built using the new cmake system:

doit_couple.sh
#! /bin/sh
export PATH=/usr/local/netcdf-4.3.0_GF/bin:$PATH
export FABMDIR=$HOME/FABM/fabm-git
export FORTRAN_COMPILER=GFORTRAN
export FABM=true
export FABM_PREFIX=$HOME/local/fabm/gotm
export NETCDF_VERSION=NETCDF4

make

For now, this is sufficient to couple FABM and GOTM.

0 件のコメント:

コメントを投稿