> > Yes, you definitely needed to use -lnetcdff -lnetcdf, because the netCDF > > Fortran library is > > separate from the netCDF C library and needs to call functions in the C > > library. > > I understood what you are saying but I have a simple question. > I could compile our program, wrf_to_gmt without -lnetcdff option on > the our linux machine. Maybe your linux machine had netCDF version 4.1.3 or earlier and was installed as static libraries rather than shared libraries. If you use version 4.2 or later or you install shared libraries (now the default), the Fortran library is separate from the C library. If you install the Fortran library as shared, you can link applications with just -lnetcdff, because the Fortran shared library "knows" the location of the C library. > > That looks like a problem that could occur if the gfortran you are using is > > not > > working with the C runtime library that the gcc compiler uses. Since > > MacOS-X > > doesn't come with a gfortran compiler, but does come with a special version > > of > > gcc, you either have to use a gcc compatible with the gfortran you > > downloaded, > > or you have to use a gfortran built specifically for use with the gcc that > > comes > > with the Apple XTools. > > > > You might try downloading or building gfortran from source, as described > > here: > > Are saying to install gfortran-4.6.2-x86_64-Lion.dmg? > I did use it but I tried it again. However, I got same results. > > As matter of facts, I am upgraded my gcc to gcc 4.7. > > Are you suggesting reinstall gfortran and gcc again? Maybe that's not the problem, but the missing _iargc_ function, which should be in the runtime library that the compiler knows about, indicates some problem with the way gfortran is configured that is independent of netCDF. You can check this by trying to build a Fortran main program that takes an argument from the command line and that also calls a C function, and see if you get the same error. I've just checked the MacPorts package system (www.macports.org), and it has a "netcdf-fortran" package that seems to work. It builds everything it needs from source. You first have to install the "port" command, but then when I ran the command sudo port install netcdf-fortran it eventually installed everything, including versions 4.5.4 of gfortran-mp-4.5 and gcc-mp-4.5 configured for OSX Lion. I just tested that it also installs the program nf-config, which shows the flags needed for compiling a Fortran program that calls netCDF: $ nf-config --all This netCDF-Fortran 4.2 has been built with the following features: --cc -> /opt/local/bin/gcc-mp-4.5 --cflags -> -I/opt/local/include -I/opt/local/include -DNDEBUG -DpgiFortran --libs -> -L/opt/local/lib -L/opt/local/lib -lnetcdf -lnetcdf --fc -> /opt/local/bin/gfortran-mp-4.5 --fflags -> -pipe -O2 -I/opt/local/include --flibs -> -L/opt/local/lib -lnetcdff -L/opt/local/lib -lnetcdf -lnetcdf --has-f90 -> yes --has-nc2 -> yes --has-nc4 -> yes --prefix -> /opt/local --includedir-> /opt/local/include --version -> netCDF-Fortran 4.2 Using nf-config, I can see what's needed to compile and link a Fortran program: $ nf-config --fc --fflags --flibs /opt/local/bin/gfortran-mp-4.5 -pipe -O2 -I/opt/local/include -L/opt/local/lib -lnetcdff -L/opt/local/lib -lnetcdf -lnetcdf I can even use nf-confg inside `` (backquotes) to compile an example netCDF program to see that it works: $ `nf-config --fc` sfc_pres_temp_wr.f90 -o sfc_pres_tmp_wr `nf-config --fflags --flibs` $ ./sfc_pres_tmp_wr *** SUCCESS writing example file sfc_pres_temp.nc! so you could do the same with wrf_to_gmt. Alternatively, you could try to get and install gcc and gfortran 4.5, but using "port" is definitely easier on OSX. In any case, you need to get compatible versions of gcc and gfortran, because gfortran is a "front-end" for gcc. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: BVS-485205 Department: Support netCDF Priority: Normal Status: Closed
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.