NetCDF data is become more and more important for my research, thus it's necessary to work with it with my own program, in Fortran (F90). The compilation anyway, a little bit tricky and slightly different with ordinary Fortran compilation. Here are the simple steps to compile it, using Intel Fortran compiler:
1. Make sure NetCDF module has been installed and declared in the system path.
The path for NetCDF module is : $NETCDF/include
If the path has not yet existed, make a soft link of the module file to current directory:
ln -sf $NETCDF/include/netcdf.mod
2. Compile the Fortran code to make an object file
Let's say the code file name is 'test.f90', then execute:
$ ifort -c test.f90 -I$NETCDF/include
Or, if the path of NetCDF module has existed, just simply:
$ ifort -c test.f90
Make sure no problems occur.
3. Finally, link the object file to an executable file:
$ ifort -o test.exe test.o -I$NETCDF/include -L$NETCDF/lib -lnetcdff -lnetcdf
Same as step 2, if the module path has existed:
$ ifort -o test.exe test.o -L$NETCDF/lib -lnetcdff -lnetcdf
If everything's OK, then an exe file will be created in the current directory. The most important thing, don forget to include '-lnetcdff', because since release 4.1.3, the Fortran library is no longer combined with C library. One hint is by checking if there are file named 'libnetcdff' in the $NETCDF/lib directory. If they are there, the argument '-lnetcdff' should be added in the compile command.
No comments:
Post a Comment