[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 980717: Running make test: problem with netCDF f77 library routines



David,

> From: David T Price <address@hidden>
> Subject: Running make test -= problem with netCDF f77 library routines
> Organization: Canadian Forest Service
> Keywords: 199807172240.QAA24824 netCDF 3.3.1 g77

In the above message, you wrote:

> We have been trying to install NetCDF 3.3.1 on our system. It is a Sun
> Ultra 30 running Solaris 5.6. We are trying to compile using gcc and 
> g77. Following the instructions in INSTALL we were able to run make, but 
> it reported some errors while linking. After this, "make test" reported 
> successful tests on the C function calls, but failures with the F77
> calls. 
> 
> After trying to figure out the problem with the linking for a while, we 
> gave up. We concluded that the failure of "make test" on the F77
> routines 
> indicated a problem with the libnetcdf.a library file. I decided to 
> check your website again for further info, and discovered that I could 
> download a binary for Solaris 5.6. I did this and after copying the
> libnetcdf.a file (into both ../lib and libsrc directories) we tried
> running "make test" again. Although the downloaded library files are of 
> different sizes to the ones we created with make, "make test" seems to
> be 
> reporting the same errors -- i.e., the linker is able to find all the C 
> library routines and the tests all pass OK, but none of the F77 symbols
> are recognised.  
> 
> The following is a portion of the output generated by "make test" when
> using the libnetcdf.a binary downloaded from
> ftp://ftp.unidata.ucar.edu/pub/ .
> 
> ===========================================================================================
> ....
> *** Testing nc_put_att_double ...  27 good comparisons. ok
> *** Testing nc_copy_att ...  34 good comparisons. ok
> *** Testing nc_rename_att ...  34 good comparisons. ok
> *** Testing nc_del_att ... ok
> *** Testing nc_set_fill ...  2796 good comparisons. ok
> 
> Total number of failures: 0
> *** Success ***
> make[2]: Leaving directory
> `/data/climate1/netcdf2/netcdf-3.3.1/src/nc_test'
> 
> Returning to directory /data/climate1/netcdf2/netcdf-3.3.1/src
> 
> make[1]: Leaving directory `/data/climate1/netcdf2/netcdf-3.3.1/src'
> make[1]: Entering directory `/data/climate1/netcdf2/netcdf-3.3.1/src'
> 
> Making `test' in directory
> /data/climate1/netcdf2/netcdf-3.3.1/src/fortran
> 
> make[2]: Entering directory
> `/data/climate1/netcdf2/netcdf-3.3.1/src/fortran'
> ar cru         ../libsrc/libnetcdf.a fort-attio.o fort-control.o fort-dim.o
> fort-genatt.o fort-geninq.o fort-genvar.o fort-lib.o fort-misc.o
> fort-v2compat.o fort-vario.o fort-var1io.o fort-varaio.o fort-varmio.o
> fort-varsio.o
> ranlib ../libsrc/libnetcdf.a
> f77 -o ftest -O   ftest.o ../libsrc/libnetcdf.a 
> ./ftest
> *** Testing nccre ...
> *** Testing ncddef ...
> *** Testing ncvdef ...
> *** Testing ncapt, ncaptc ...
> *** Testing ncclos ...
> *** Testing ncvpt1 ...
> *** Testing ncvgt1 ...
> *** Testing ncvpt ...
> *** Testing ncopn, ncinq, ncdinq, ncvinq, ncanam, ncainq ...
> *** Testing ncvgt, ncvgtc ...
> *** Testing ncagt, ncagtc ...
> *** Testing ncredf, ncdren, ncvren, ncaren, ncendf ...
> *** Testing ncacpy ...
> *** Testing ncadel ...
> *** Testing fill values ...
> make[2]: Leaving directory
> `/data/climate1/netcdf2/netcdf-3.3.1/src/fortran'
> 
> Returning to directory /data/climate1/netcdf2/netcdf-3.3.1/src
> 
> make[1]: Leaving directory `/data/climate1/netcdf2/netcdf-3.3.1/src'
> make[1]: Entering directory `/data/climate1/netcdf2/netcdf-3.3.1/src'
> 
> Making `test' in directory
> /data/climate1/netcdf2/netcdf-3.3.1/src/nf_test
> 
> make[2]: Entering directory
> `/data/climate1/netcdf2/netcdf-3.3.1/src/nf_test'
> f77 -o nf_test -O   test_get.o test_put.o nf_error.o nf_test.o
> test_read.o test_write.o util.o fortlib.o ../libsrc/libnetcdf.a   
> Undefined                     first referenced
>  symbol                           in file
> nf_get_vars_double__                test_get.o
> nf_inq_varnatts__                   test_read.o
> nf_get_vars_real__                  test_get.o
> nf_get_vars_text__                  test_get.o
> nf_get_var_double__                 test_get.o
> nf_put_varm_real__                  test_put.o
> nf_put_varm_text__                  test_put.o
> nf_put_var_int2__                   test_put.o
> nf_inq_varname__                    test_read.o
> nf_put_vars_double__                test_put.o
> nf_get_vara_double__                test_get.o
> nf_get_att_real__                   test_get.o
> nf_put_varm_double__                test_put.o
> nf_put_var_text__                   test_put.o
> nf_strerror__                       test_get.o
> nf_put_vara_double__                test_put.o
> nf_issyserr__                       test_read.o
> nf_get_vara_int2__                  test_get.o
> nf_inq_unlimdim__                   test_read.o
> 
> ...... /* and so on until */ .....
> 
> nf_inq__                            test_read.o
> nf_get_vara_real__                  test_get.o
> nf_get_vara_text__                  test_get.o
> nf_del_att__                        test_write.o
> nf_put_var1_double__                test_put.o
> nf_put_varm_int1__                  test_put.o
> ld: fatal: Symbol referencing errors. No output written to nf_test
> make[2]: *** [nf_test] Error 1
> make[2]: Leaving directory
> `/data/climate1/netcdf2/netcdf-3.3.1/src/nf_test'
> make[1]: *** [subdir_target] Error 1
> make[1]: Leaving directory `/data/climate1/netcdf2/netcdf-3.3.1/src'
> make: *** [nf_test/test] Error 2
> 
> ===========================================================================================
> 
> The puzzle to us is that the linker is obviously having no trouble
> finding
> the C routines, but does not seem to locate the Fortran -- judging by
> the 
> list of undefined symbols. Yet these are presumably all in the same
> file.
> 
> Can you offer any suggestions?

Interesting.  Apparently, g77(1) is adding an additional underscore (_)
to the routine names (e.g. the call to "nf_get_vara_real" becomes a call
to "nf_get_vara_real__" rather than the expected "nf_get_vara_real_").
This is similar to what f2c(1) does.

I suggest tricking the environment into thinking you're using the f2c(1)
compiler.  Do the following:

    1.  Go to the top-level source directory.

    2.  Execute the command "make distclean".

    3.  Remove the file "config.cache" if it exists.

    4.  Set your environment variables as before.

    5.  Ensure that the environment variables "CPPFLAGS" and "FFLAGS" contain
        the string "-Df2cFortran".

    6.  Continue with step 6 in the INSTALL file.

Unfortunately, we don't have a working g77 on our Solaris 5.6 system, so
I can't reproduce the error.  Please let me know how the above turns
out.

--------
Steve Emmerson   <http://www.unidata.ucar.edu>