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 Jason, > Description of problem: I am attempting to make a build based on Fortran > code. During the make process, I encounter the error: Can't open module file > 'netcdf.mod' for reading at (1). > > I can confirm that the "netcdf.mod" file does not exist in any directory. > Evidently, it was not made during the configuration process. Installing the netCDF Fortran software should install the netcdf.mod file in the right include directory, assuming you have the necessary permissions to copy files there. Maybe you need to set CPPFLAGS or provide an equivalent configure option for the software you're building to tell it in which include directory to look for the netcdf.mod file. My Spotlight says it's installed in several places, including /opt/local/include/NETCDF.mod installed by MacPorts when I ran "port install netcdf-fortran" last summer. I also see the all lower-case netcdf.mod file in various other "include/" directories from testing other versions in the past. Here are the instructions that work for me out-of-the-box, using CPPFLAGS and LDFLAGS environment variables, with either of the current releases of netCDF Fortran (version 4.2 or 4.4-beta1), after the netCDF C library is installed: http://www.unidata.ucar.edu/netcdf/docs/building_netcdf_fortran.html I can see from your config.log that the compile line generated to test for netcdf.mod didn't specify a directory in which to search for that file: configure:15807: checking the Fortran 90 module netcdf is available configure:15815: mpif90 -c -g -O2 conftest.f90 conftest.f90:2.4: use netcdf 1 Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory That mpif90 invocation, in your case, should have been something like mpif90 -c -g -O2 -I/usr/local/Cellar/netcdf/4.3.1.1/include conftest.f90 so try setting CPPFLAGS=-I/usr/local/Cellar/netcdf/4.3.1.1/include before running configure. --Russ > Netcdf was installed using fink. After fink failed, tried using macports and > homebrew, which also failed to install the netcdf.mod file. After > uninstalling the ports and brew netcdf, I reinstalled fink, to no avail. Here > are the installed netcdf packages: > > netcdf-bin 4.3.2-1 Array-based data access, user programs > netcdf-c7 4.3.2-1 Array-based data access, C headers and docs > netcdf-c7-shlib 4.3.2-1 Array-based data access, C library > netcdf-cxx4 4.2.1-1 Array-based data access, C++ headers and ... > netcdf-cxx4-shl 4.2.1-1 Array-based data access, C++ library > netcdf-fortran5 4.2-9 Array-based data access, Fortran headers/doc > netcdf-fortran5 4.2-9 Array-based data access, Fortran library > netcdf-oct343 1.0.2-1 MATLAB compatible NetCDF interface for Oc... > netcdf-oct360 1.0.2-1 MATLAB compatible NetCDF interface for Oc... > netcdf-oct361 1.0.2-1 MATLAB compatible NetCDF interface for Oc... > netcdf-oct362 1.0.2-1 MATLAB compatible NetCDF interface for Oc... > netcdf-oct363 1.0.2-1 MATLAB compatible NetCDF interface for Oc... > netcdf-oct364 1.0.2-1 MATLAB compatible NetCDF interface for Oc... > > Compiling fortran code in command line encounters no problems. Other forums > on a similar topic have failed to help me. Can post more information if > necessary; I have also attached the relevant config.log file. I also > previously installed netcdf from the source code, and encountered the same > problem. Any assistance much appreciated, > > Many thanks, > > Jason > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: MZG-331133 Department: Support netCDF Priority: Normal Status: Closed