netcdf and SCAM - uses netcdf

We are attempting to compile a program called SCAM (Single Column Atmospheric Model) using PGI Workstation 7.0-4 .

The program requires netcdf (v4.0 we’re using) and NCAR Graphics (v5.0.0 we’re using).

So I have built both netcdf and ncarg using PGI, and both appear to install cleanly.

However when we attempt to compile SCAM, we are seeing some of the errors referred to in another post from PGI ("Known Issues at bottom):

So, I try recompiling netcdf with the same environment variable options listed on the above site. Netcdf seems to install ok.

But when attempting to compile SCAM again, we see the same errors:

/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x79): In function NC_fill_schar': : undefined reference to __c_mset1’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0xd2): In function NC_fill_char': : undefined reference to __c_mzero1’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x148): In function NC_fill_short': : undefined reference to __c_mset2’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x1bd): In function NC_fill_int': : undefined reference to __c_mset4’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x22b): In function NC_fill_float': : undefined reference to __c_mset4’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x2a1): In function NC_fill_double': : undefined reference to __c_mset8’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x7e46): In function nc_put_vara_text': : undefined reference to __builtin_alloca’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x7e59): In function nc_put_vara_text': : undefined reference to __builtin_alloca’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x81a6): In function nc_put_vara_uchar': : undefined reference to __builtin_alloca’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x81b9): In function nc_put_vara_uchar': : undefined reference to __builtin_alloca’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x8506): In function nc_put_vara_schar': : undefined reference to __builtin_alloca’
/usr/local/netcdf/lib/libnetcdf.a(putget.o)(.text+0x8519): more undefined references to __builtin_alloca' follow collect2: ld returned 1 exit status gmake[1]: *** [../scamgui] Error 1 gmake[1]: Leaving directory /usr/local/cam1/models/atm/cam/tools/scam/ui’
gmake: *** [all] Error 2

I would appreciate any ideas on how to fix this. It still seems like a Netcdf problem.

Below is environment config from .bashrc for use compiling netcdf, ncarg, and scam:

SCAM pre-reqs

export CSMDATA=/usr/local/cam1/models/atm/cam/tools/scam/data
export QTDIR=/usr/local/qt
export LD_LIBRARY_PATH=/usr/local/qt/lib/:/usr/local/ncarg/lib:/usr/local/netcdf/lib:/usr/lib/gcc/x86_64-redhat-linux/3.4.3:/usr/lib64:/usr/X11R6/lib64:/usr/lib64:/lib64:/opt/pgi/linux86-64/7.0-4/lib
export PGI=/opt/pgi/linux86-64/7.0-4/
export PATH=/usr/local/netcdf/bin:/usr/local/qt/bin/:/usr/local/ncarg/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/opt/pgi/linux86-64/7.0-4/bin
export NCARG_ROOT=/usr/local/ncarg

COMPILER pre-reqs

export CC=/opt/pgi/linux86-64/7.0-4/bin/pgcc
export CFLAGS="-O2 -Msignextend -V"
export CXX=/opt/pgi/linux86-64/7.0-4/bin/pgCC
export CPPFLAGS="-DNDEBUG -DpgiFortran"
export FC=/opt/pgi/linux86-64/7.0-4/bin/pgf90
export F77=/opt/pgi/linux86-64/7.0-4/bin/pgf77
export F90=/opt/pgi/linux86-64/7.0-4/bin/pgf90
export FFLAGS="-O2 -w -V"

Thanks for any ideas.

Hi Mark,

The missing symbols are found in libpgc library which leads me to believe that you are not linking SCAM with either pgf90 or pgcc or there is an ordering problem. Can you please post the link command for SCAM?


Hi Mat,
Sorry to be obtuse, but where do I find the link command…? There are several Makefile (s) in the SCAM directory structure:


I just tried adding “-lpgc” to:
CFLAGS=-O2 -Msignextend -V -lpgc
FFLAGS=-O2 -w -V -lpgc
CPPFLAGS=-DNDEBUG -DpgiFortran -lpgc

…but same missing function errors. My LD_LIBRARY_PATH is:



Hi Mark,

Do you have a complete log of the build? If so, look for a line above the undefined reference errors where all the object files are. Something like “gcc -o scam -O2 obj1.o obj2.o …etc.”. This should be the link command.


It does appear that -lpgc is missing… How would I add that if not to my environment variables?


gcc ChangeAxisScaleDlg.moc.o ChangeAxisScaleDlg.o ChangeAxisScaleDlgImpl.moc.o ChangeAxisScaleDlgImpl.o IOPSelectDateDlg.moc.o IOPSelectDateDl
g.o IOPSelectDateDlgImpl.moc.o IOPSelectDateDlgImpl.o LoadData.moc.o LoadData.o LoadDataImpl.moc.o LoadDataImpl.o MainWnd.moc.o MainWnd.o Main
WndImpl.moc.o MainWndImpl.o OptionsDlg.moc.o OptionsDlg.o OptionsDlgImpl.moc.o OptionsDlgImpl.o PlistDlg.moc.o PlistDlg.o PlistDlgImpl.moc.o P
listDlgImpl.o PlotDlg.moc.o PlotDlg.o PlotDlgImpl.moc.o PlotDlgImpl.o PostPlottingDlg.moc.o PostPlottingDlg.o PostPlottingDlgImpl.moc.o PostPl
ottingDlgImpl.o SelectGlobalDataDlg.moc.o SelectGlobalDataDlg.o SelectGlobalDataDlgImpl.moc.o SelectGlobalDataDlgImpl.o crm.o dataset.o dbgmod
el.o defaults.o field.o fieldlistbox.o fifomodel.o history.o main.o manager.o map.o model.o msgdlg.o ncarg.o ncarg_stubs.o ncfile.o plot.moc.o
plot.o rpcmodel.o sicfile.o timeconvert.o utils.o
-o …/scamgui -L/usr/local/netcdf/lib -lnetcdf -L/usr/local/ncarg/lib -lncarg -lncarg_gks -lncarg_c -lg2c -L/usr/lib64/qt-3.3/lib
-lqt-mt -lqui -L/usr/X11R6/lib -lX11 -lm -lXext -ldl

Look for something like “LDFLAG” in the makefile and add "-L/usr/pgi/linux86-64/7.2-5/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc ". This will include all of PGI’s F90 and C runtime libraries. Please change the “-L” to the actual location of you PGI library directory.

  • Mat

Thanks for the help. I got it to compile with the path and library information you provided. There are some font problems with the gui but at least I got this far.

For anyone else who may encounter similar problems, this is what I had to do to get to this point.

I tried defining an environment variable:

export LDFLAG=-L/opt/pgi/linux86-64/7.0-4/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc

…but the “gcc -o” command still could not find the PGI libs. I tried editing the “Makefile in /usr/local/cam1/models/atm/cam/tools/scam/obj/Makefile” and adding "-L/usr/pgi/linux86-64/7.2-5/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc " to the “gcc -o” command but same result.

Only after going into:


…and editing “configure”:

LINK_LIBS="-L$NETCDF_LIB -lnetcdf $NCARG_LIBS $QTLIB -L/usr/X11R6/lib -lX11 -lm -lXext -ldl -L/opt/pgi/linux86-64/7.0-4/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -ln
spgc -lpgc"

…and re-running "gmake in:


…did the build complete completely.

When running the compiled program “scam”, there are fonts missing from the gui so I think I need to similarly edit other “configure” files in the directory tree to correctly reference the PGI libs, but I am now farther than I’ve been able to get for a while.

Thanks a lot.