Open anserwei opened 4 years ago
Try using -I/Users/Jim/anaconda3/include as an argument in gfortran.
Try using -I/Users/Jim/anaconda3/include as an argument in gfortran.
Thank you. Could you tell me more details about how to use -I/Users/Jim/anaconda3/include as an argument in gfortran
.
When you run make, you'll specify FFLAGS="-I/Users/Jim/anaconda3/include
on the command line, or alternatively you can set the FFLAGS
environmental variable.
When you run make, you'll specify
FFLAGS="-I/Users/Jim/anaconda3/include
on the command line, or alternatively you can set theFFLAGS
environmental variable.
Hi, thanks for your response. But, the error is still there.
MacOS: Catalina 10.15 Gfortran: GNU Fortran (GCC). 6.3.0 Xcode 11.1
I have installed ''netcdf-fortran'' through conda. conda install -c conda-forge netcdf-fortran
In my Mac, I find 'netcdf.mod, ... , netcdf_nf_interfaces.mod, etc.'
in
''/Users/Jim/anaconda3/include".
And, nothing is related to netcdf in ''/usr/local/include".
export F90FLAGS="-I/Users/jim/anaconda3/include"
on the command line;
I also run export FFLAGS="-I/Users/jim/anaconda3/include"
.
Thus, so frustrated...... Could you help me more? Thank you so much.
Try:
gfortran -I/Users/Jim/anaconda3/include -L/Users/Jim/anaconda3/lib simple_xy_nc4_wr.f90
But I believe you will also need some additional arguments to make that work. Run nf_config to get more information about what arguments you need to set.
Frustration will continue until you learn about the -I and the -L options of your compiler. There is ample documentation online. For example, from https://linux.die.net/man/1/gfortran.
-Idir
These affect interpretation of the "INCLUDE" directive (as well as of the "#include" directive of the cpp preprocessor).
Also note that the general behavior of -I and "INCLUDE" is pretty much the same as of -I with "#include" in the cpp preprocessor, with regard to looking for header.gcc files and other such things.
This path is also used to search for .mod files when previously compiled modules are required by a "USE" statement.
Most users do not compile using gfortran from the command line, but using make, or (if they're extra-clever) automake/autoconf/libtool. Within such systems you will find respect for environmental flags like FCFLAGS, FFLAGS, CPPFLAGS, etc. More info is available on-line.
Thank you! I read Unidata NetCDF Fortran Library on website:
https://www.unidata.ucar.edu/software/netcdf/docs-fortran/
And, I also read some information about how to set env variables
.
After trying many times, I can successfully read/write netCDF files with fortran90.
Seems like this issue can be closed now.
My problem was solved with the following command, I hope it paves the way for you too. sudo apt-get install netcdf-bin
Hi, I am a beginner who is learning how to read and write a netcdf file with Fortran 90. I got some problems. Could someone help me?
I have installed ''netcdf-fortran'' through conda. (https://anaconda.org/conda-forge/netcdf-fortran)
conda install -c conda-forge netcdf-fortran
When I run a program named simple_xy_wr.f90 on Mac terminal. I got an error:
Fatal Error: Can't open module file ‘netcdf.mod’ for reading at (1): No such file or directory compilation terminated.
I am confused. I don't know how to fix this.
I check the directory of ‘netcdf.mod’, which locates in ''/Users/Jim/anaconda3/include". I also find: netcdf.h; netcdf.inc .......; netcdf_nf_interfaces.mod, etc.
But, in the directory "/usr/local/include", nothing is related to netcdf.
Actually, I use
gfortran
to run the program.So, could someone help me? I appreciate it. Thank you so much.