[Wrf-users] Compile WPS with gfortran and gcc

Huber, David dbh409 at ku.edu
Tue Feb 1 14:24:36 MST 2011


Thanks for the recipe!  This resulted in different erros, so I tried adding the flags -DIO_BINARY and -DIO_GRIB1 to CPPFLAGS, but that didn't change anything.  Also, in LDFLAGS, I tried explicitly adding the library directory with -L/home/dbh409/WRFV3/external/iogrib1 to no avail.  I'm getting the same "undefined reference" errors but also

/usr/bin/ld: cannot find -lio_grib1
collect2: ld returned 1 exit status

From: Dmitry N. Mikushin [maemarcus at gmail.com]
Sent: Tuesday, February 01, 2011 2:38 PM
To: Huber, David
Cc: wrf-users at ucar.edu
Subject: Re: [Wrf-users] Compile WPS with gfortran and gcc


Here's a common recipe to lookup for missing symbols. Navigate to the
project dir and grep for particular symbol you have issue with, for

marcusmae at msiwind:~$ cd Programming/wrfv3/
marcusmae at msiwind:~/Programming/wrfv3$ grep ext_gr1_put_dom_ti_char * -R
arch/md_calls.inc:           CALL ext_gr1_put_dom_ti_char ( Hndl,
Element,   Data, &
external/io_grib1/io_grib1.f90:SUBROUTINE ext_gr1_put_dom_ti_char (
DataHandle,Element,   Data,  &
external/io_grib1/io_grib1.f90:  call wrf_debug ( DEBUG , 'Entering
external/io_grib1/io_grib1.f90:END SUBROUTINE ext_gr1_put_dom_ti_char
Binary file external/io_grib1/libio_grib1.a matches
external/io_grib1/io_grib1.F:SUBROUTINE ext_gr1_put_dom_ti_char (
DataHandle,Element,   Data,  &
external/io_grib1/io_grib1.F:  call wrf_debug ( DEBUG , 'Entering
external/io_grib1/io_grib1.F:END SUBROUTINE ext_gr1_put_dom_ti_char
Binary file external/io_grib1/io_grib1.o matches
frame/module_io.f90:           CALL ext_gr1_put_dom_ti_char ( Hndl,
Element, Data, &
frame/md_calls.inc:           CALL ext_gr1_put_dom_ti_char ( Hndl,
Element,   Data, &
Binary file frame/module_io.o matches
frame/module_io_quilt.F:                    CALL
ext_gr1_put_dom_ti_char ( handle(DataHandle), TRIM(Element),
TRIM(CData), Status)
Binary file main/wrf.exe matches
Binary file main/libwrflib.a matches
Binary file main/ideal.exe matches

So, we've found some sources define target symbol, and some libraries
incorporate either its references or definitions. Now we can look
which libraries just use the symbol, and where is it really defined.
The nm tool can help:

marcusmae at msiwind:~/Programming/wrfv3$ nm main/libwrflib.a | grep
         U ext_gr1_put_dom_ti_char_

"U" means libwrflib.a references, but does not define. It could be in
some other library:

marcusmae at msiwind:~/Programming/wrfv3$ nm
external/io_grib1/libio_grib1.a | grep ext_gr1_put_dom_ti_char
0000df30 T ext_gr1_put_dom_ti_char_
00d63600 b ext_gr1_put_dom_ti_char_$TMPSTR.0.56

- aha, "T" - means function body defined here, in libio_grib1.

So my guess would be to check if your app is linked with -lio_grib1,
and if not, adding -lio_grib1 to LDFLAGS should help.

Hope it helps,
- D.

2011/2/1 Huber, David <dbh409 at ku.edu>:
> Dmitry,
> Primarily "undefined reference" errors.  For instance,
> module_debug.o: In function `__module_debug__mprintf':
> module_debug.f90:(.text+0xfe): undefined reference to `cio_set_log_filename'
> module_debug.f90:(.text+0x1cb): undefined reference to `cio_set_log_filename'
> module_debug.f90:(.text+0x2a4): undefined reference to `cio_set_log_filename'
> module_debug.f90:(.text+0x7b5): undefined reference to `cio_prints'
> module_debug.f90:(.text+0xbe9): undefined reference to `cio_prints'
> module_debug.f90:(.text+0xc93): undefined reference to `cio_prints'
> module_debug.f90:(.text+0x10c8): undefined reference to `cio_prints'
> module_debug.f90:(.text+0x1185): undefined reference to `cio_prints'
> module_debug.o:module_debug.f90:(.text+0x11a0): more undefined references to `cio_prints' follow
> output_module.o: In function `__output_module__output_close':
> output_module.f90:(.text+0x3f): undefined reference to `ext_int_ioclose'
> output_module.f90:(.text+0x58): undefined reference to `ext_ncd_ioclose'
> output_module.f90:(.text+0x71): undefined reference to `ext_gr1_ioclose'
> output_module.f90:(.text+0x1e2): undefined reference to `ext_int_ioexit'
> output_module.f90:(.text+0x1f6): undefined reference to `ext_ncd_ioexit'
> output_module.f90:(.text+0x20a): undefined reference to `ext_gr1_ioexit'
> output_module.o: In function `__output_module__ext_put_dom_ti_char':
> output_module.f90:(.text+0x3fd): undefined reference to `ext_int_put_dom_ti_char'
> output_module.f90:(.text+0x47e): undefined reference to `ext_ncd_put_dom_ti_char'
> output_module.f90:(.text+0x4ff): undefined reference to `ext_gr1_put_dom_ti_char'
> Dave

More information about the Wrf-users mailing list