无法使用 c++ 中的 nc_open() 函数打开 netcdf 文件(.nc)
nc_open(input_file.c_str(), NC_NOWRITE , &ncid)
这里的 input_file 是文件路径。仅当 netcdf 文件放置在可执行文件所在的 bin 文件夹中时,该文件才会打开。 当 netcdf 文件 (.nc) 未放置在 bin 文件夹中时,netcdf 文件不会打开。 为什么会发生这种情况?
nc_open(input_file.c_str(), NC_NOWRITE , &ncid)
Here the input_file is the file path. The file is opening only when the netcdf file is placed in the bin folder where the executable is present.
When the netcdf file(.nc) is not placed in the bin folder then the netcdf file does not open.
why is this happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/bin
文件夹代表二进制文件,您编译的程序通常位于该文件夹中。如果您传入“file.txt”作为文件名,程序将在程序本身所在的文件夹中查找文件“file.txt”。如果您想访问某个位置的文件,您应该在
input_file
中传入绝对路径(例如C:\test.txt
)The
/bin
folder stand for binary and your complied program is usually located in this folder. If you passes in "file.txt" as the file name, the program will find the file "file.txt" in the folder where the program itself locates.If you want to access the file at a location, you should pass in the absolute path (eg.
C:\test.txt
) in theinput_file