当出现此类问题的时候 光靠 gfortran -o test w02.f90 -I/usr/local/netcdf/include -L/usr/local/netcdf/lib -lnetcdf 不能解决的,可以尝试gfortran -o test w02.f90 -I/usr/local/netcdf/include -L/usr/local/netcdf/lib -lnetcdf -lnetcdff 或gfortran -o test w02.f90 -I/usr/local/netcdf/include -L/usr/local/netcdf/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz
附上错误的提示,供以后参考 /tmp/ccKcBo4F.o: In function `MAIN__': w02.f90:(.text+0x39): undefined reference to `nf_create_' w02.f90:(.text+0x71): undefined reference to `nf_def_dim_' w02.f90:(.text+0xa9): undefined reference to `nf_def_dim_' w02.f90:(.text+0xfc): undefined reference to `nf_def_var_' w02.f90:(.text+0x115): undefined reference to `nf_enddef_' w02.f90:(.text+0x14e): undefined reference to `nf_close_' /tmp/ccKcBo4F.o: In function `write_data_0_': w02.f90:(.text+0x1a7): undefined reference to `nf_put_vara_int_' /tmp/ccKcBo4F.o: In function `check_err_': w02.f90:(.text+0x21d): undefined reference to `nf_strerror_' collect2: ld 返回 1