This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Hi, > > I am new to compiling fortran codes with netcdf, I have been trying to > run a fortran 90 code that makes use of netcdf to create a .nc file.For > it I use the following command to first create an object file > > ifort -c > -I/glade/proj2/fis/contrib/pwr5.aix-5/netcdf/deprecated/netcdf-4.1.3b1_seq/include > prog.f90 > > which runs fine and creates a prog.o, then I try creating an executable > file by using the following command, > > ifort -o prog.x prog.o > -L/glade/proj2/fis/contrib/pwr5.aix-5/netcdf/deprecated/netcdf-4.1.3b1_seq/lib > -lnetcdff > > and I have also tried using -lnetcdf after -lnetcdff, but I keep getting > the following message: > > /glade/proj2/fis/contrib/pwr5.aix-5/netcdf/deprecated/netcdf-4.1.3b1_seq/lib/libnetcdff.a: > file not recognized: File format not recognized > > I am not sure how to figure out what exactly to change. May I kindly > ask for some help, It's possible that the netCDF Fortran library was not built with the ifort Fortran compiler. If that's the problem, you will either have to use the same Fortran compiler as was used in building the netCDF Fortran library, or rebuild the netCDF library using ifort and icc and install the library again. Another possibility is that the libnetcdff.a library is for a different architecture than the platform on which you're running. To see if this is the problem, you'll need tp use the "ar" command to extract an object file from libnetcdff.a, as in: ar x /glade/proj2/fis/contrib/pwr5.aix-5/netcdf/deprecated/netcdf-4.1.3b1_seq/lib/libnetcdff.a nf_dim.o then use the "file" command on the extracted object file to see whether it was built for a 32-bit architecture or a 64-bit architecture: file nf_dim.o Then run file on your prog.o, to see if it's for the same architecture. If they don't match, you'll either have to rebuild netCDF for the machine on which you're running, or use the right ifort flags (such as -m32 or -m64) to match the architecture of the library. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: NWL-557256 Department: Support netCDF Priority: Normal Status: Closed