I use Cygwin.
When I build OA package.This error occur:detail in the attached file
Any suggestion would be appreciated.
g77 -c -DNO_EXIT -g -O2 def_oa.F
g77 -DNO_EXIT -g -O2 -o /home/Sun/bin/oa oamain.o acor.o asm.o atg.o bcintrp.o bcucof.o caldate.o day_code.o def_oa.o dhlev.o diagn.o down_shift.o dynht.o exitus.o filter.o geodesic_dist.o get_date.o get_clima.o get_grid.o get_dynht.o get_obs.o gregorian.o hindices.o ierinv.o indepen.o inside.o invmtx.o lintrp.o lenstr.o locate.o lubksb.o ludcmp.o oamean.o oapar.o objan.o outlier.o ptem.o press.o qtrap.o readhydro.o remove.o se_grid.o selectclm.o selectobs.o sort.o svafunc.o svan.o svel.o trapzd.o trend.o trendcoef.o try_range.o xclima.o xhydro.o -lnetcdf
oamain.o: In function `MAIN__':
/home/Sun/roms/oa/oamain.F:267: undefined reference to `_nf_put_var1_double__'
....
/home/Sun/roms/oa/oamain.F:286: undefined reference to `_nf_put_vara_double__'
/home/Sun/roms/oa/oamain.F:294: undefined reference to `_nf_sync__'
def_oa.o: In function `def_oa__':
/home/Sun/roms/oa/def_oa.F:58: undefined reference to `_nf_create__'
/home/Sun/roms/oa/def_oa.F:70: undefined reference to `_nf_def_dim__'
.....
exitus.o: In function `exitus_':
/home/Sun/roms/oa/exitus.F:41: undefined reference to `_nf_close__'
/home/Sun/roms/oa/exitus.F:50: undefined reference to `_nf_strerror__'
/home/Sun/roms/oa/exitus.F:42: undefined reference to `_nf_close__'
get_grid.o: In function `get_grid__':
/home/Sun/roms/oa/get_grid.F:49: undefined reference to `_nf_open__'
/home/Sun/roms/oa/get_grid.F:60: undefined reference to `_nf_inq__'
.....
collect2: ld returned 1 exit status
make: *** [oa] Error 1
where do I need to difine the netcdf path? I use Makefile.Gnu and define
"CDFLIB = -L/usr/local/lib -lnetcdf"where the netcdf lib is installed.
My Error Building OA package
My Error Building OA package
- Attachments
-
- log.txt
- (18.62 KiB) Downloaded 244 times
- m.hadfield
- Posts: 521
- Joined: Tue Jul 01, 2003 4:12 am
- Location: NIWA
Re: My Error Building OA package
Your problem might be an inconsistency in the naming convention for Fortran subroutines.
Like many other Fortran compilers, G77 appends underscores to the names of subroutines (and other symbols) to distinguish them from C functions. By default, G77 adopts the rather peculiar convention of appending two underscores to subroutine names that contain underscores and one underscore to subroutine names that do not. G77 is now obsolete and its successor, Gfortran, (which is bundled with GCC 4) appends just one underscore. In both cases, the default behaviour can be overridden with the -fsecond-underscore option.
You would get the message you described if your netCDF library had been built with Gfortran. If this is the case, you could solve the problem by building the OA package with Gfortran or, if you must use G77, pass it the -fnosecond-underscore option.
Like many other Fortran compilers, G77 appends underscores to the names of subroutines (and other symbols) to distinguish them from C functions. By default, G77 adopts the rather peculiar convention of appending two underscores to subroutine names that contain underscores and one underscore to subroutine names that do not. G77 is now obsolete and its successor, Gfortran, (which is bundled with GCC 4) appends just one underscore. In both cases, the default behaviour can be overridden with the -fsecond-underscore option.
You would get the message you described if your netCDF library had been built with Gfortran. If this is the case, you could solve the problem by building the OA package with Gfortran or, if you must use G77, pass it the -fnosecond-underscore option.
Re: My Error Building OA package
Thanks for your guide.
I had a try.
When use G95 or Gfortran :
g95 -DNO_EXIT -g -O2 -I /usr/local/include -L/usr/local/lib -lnetcdf -o /h
oamain.o: In function `MAIN_':
/home/Sun/roms/oa/oamain.F:268: undefined reference to `nf_put_var1_double__'
...
/home/Sun/roms/oa/oamain.F:79: undefined reference to `nccre_'
/home/Sun/roms/oa/oamain.F:79: undefined reference to `ncdid_'
This should not happen.It was right when I use G77
when use G77 with -fno-second-underscore/-fsecond-underscore option.
.......... undefined reference to `_nf_put_var1_double_‘
g77 with -fno-underscoring ,(result below with leading-underscore,how to remove this?)
...........undefined reference to `_nf_put_var1_double‘
But when I grep nf_put_var1_double ./* as follow:
netcdf.inc: integer nf_put_var1_double
netcdf.inc: external nf_put_var1_double
Do I need to rebuild the netCDF library an "-fno-second-underscore" option(which G95 supports )
More advice ?
I had a try.
When use G95 or Gfortran :
g95 -DNO_EXIT -g -O2 -I /usr/local/include -L/usr/local/lib -lnetcdf -o /h
oamain.o: In function `MAIN_':
/home/Sun/roms/oa/oamain.F:268: undefined reference to `nf_put_var1_double__'
...
/home/Sun/roms/oa/oamain.F:79: undefined reference to `nccre_'
/home/Sun/roms/oa/oamain.F:79: undefined reference to `ncdid_'
This should not happen.It was right when I use G77
when use G77 with -fno-second-underscore/-fsecond-underscore option.
.......... undefined reference to `_nf_put_var1_double_‘
g77 with -fno-underscoring ,(result below with leading-underscore,how to remove this?)
...........undefined reference to `_nf_put_var1_double‘
But when I grep nf_put_var1_double ./* as follow:
netcdf.inc: integer nf_put_var1_double
netcdf.inc: external nf_put_var1_double
Do I need to rebuild the netCDF library an "-fno-second-underscore" option(which G95 supports )
More advice ?
Re: My Error Building OA package
You can't find out about the underscores from looking in netcdf.inc. You need to look in the library file:
For me, this gives:
Whatever you do, your oamain.o and your libnetcdf.a have to match on this.
Code: Select all
nm libnetcdf.a | grep nf_put_var1_double
Code: Select all
0000000000000621 T nf_put_var1_double_
U nf_put_var1_double_