请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

新浪微博登陆

只需一步, 快速开始

QQ登录

只需一步,快速开始

搜索
查看: 42932|回复: 991

netcdf4.2及以上版本的安装:For C and Fortran

  [复制链接] |关注本帖

新浪微博达人勋

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 andrewsoong 于 2017-2-13 10:50 编辑

截止netcdf4.1.3版本,C lib和fortran lib没有分开。从4.2版本开始分开。这就导致了netcdf-fortran-4.2的安装麻烦了一点。先安装zlib和hdf5.
1,确保安装了netcdf C 库:
CPPFLAGS=-I/path/netcdf4.3-C/include LDFLAGS=-L/path/netcdf4.3-C/lib ./configure --prefix=/path/netcdf4.3-C CC=icc FC=ifort
--with-zlib=。。。。。
make
make check
sudo make install


2,For fortran-netcdf


export LD_LIBRARY_PATH=/path/netcdf4.3-all/lib:${LD_LIBRARY_PATH}(重要)


CPPFLAGS=-I/path/netcdf4.3-C/include LDFLAGS=-L/path/netcdf4.3-C/lib ./configure --prefix=/path/netcdf4.3-C CC=icc FC=ifort


make
make check
sudo make install

make install check


在.bashrc中设置一下就好了~~~


详细可参考:http://www.unidata.ucar.edu/soft ... ortran-install.html

推荐一种简易方法:哈佛大学GEOS_CHEM研究小组比较好~~~他把这些都集成了~~~你需要的话,可以去下载安装,一个命令,netcdf4.2-c,netcdf4.2-fortran和hdf5等等都安装好了~~~
-------+---------+-------------------------------------  
Config | Install |             Package  
-------+---------+-------------------------------------
  ok   |   ok    | zlib-1.2.6     
  ok   |   ok    | hdf5-1.8.8     
  ok   |   ok    | netcdf-4.2     
  ok   |   ok    | netcdf-fortran-4.2
-------+---------+-------------------------------------

http://acmg.seas.harvard.edu/geos/doc/man/index.html or  
http://acmg.seas.harvard.edu/geos/doc/man/


安装方法如下:
游客,如果您要查看本帖隐藏内容请回复


这是我安装的步骤。没出现问题。
PS:天道酬勤也安装了,按照我的方法,没问题。







评分

参与人数 1金钱 +8 贡献 +2 收起 理由
mofangbao + 8 + 2

查看全部评分

已有2人关注本帖

向烨打破砂锅纹到底
密码修改失败请联系qq:937062711

新浪微博达人勋

 楼主| 发表于 2013-11-11 16:55:44 | 显示全部楼层 |取消关注该作者的回复

这类问题太坑了~~~还是哈佛大学GEOS_CHEM研究小组比较好~~~他把这些都集成了~~~你需要的话,可以去下载安装,一个命令,netcdf4.2-c,netcdf-fortran和hdf5等等都安装好了~~~
http://acmg.seas.harvard.edu/geos/doc/man/index.html


2.5.1 Downloading the GEOS-Chem-Libraries installer package

You can use the Git source-code management software to download the GEOS-Chem-Libraries installer package onto your system. Type:

git clone git://git.as.harvard.edu/bmy/GEOS-Chem-Libraries
and then change into the GEOS-Chem-Libraries directory:

cd GEOS-Chem-Libraries
In this directory you will find the following files and subdirectories:

File or Directory        Description
README        File describing the contents of GEOS-Chem-Libraries and how to build the netCDF libraries
GNUmakefile        Main-level makefile. This calls down to the master GNUmakefile in the src/ sub-directory.
opt/        Default directory where libraries will be installed (if you do not choose an alternate directory)
src/        Directory containing netCDF and related library distributions.
2.5.2 Installing netCDF–4.2

Follow these instructions to install the netCDF–4.2 library and the libraries on which it depends.

2.5.2.1 Building the netCDF–4.2 library

To build the netCDF-4.2 library (and the dependent ZLIB and HDF5 libraries) using the Intel Fortran Compiler (ifort), type one of the following commands:

make PREFIX=root_library_dir                         # If you have the Intel C compilers

make PREFIX=root_library_dir GCC=yes                 # If you don't have the Intel C compilers
To build the libraries for the PGI compiler, type one of the following commands:

make COMPILER=pgi PREFIX=root_library_dir            # If you have the PGI C compilers

make COMPILER=pgi PREFIX=root_library_dir GCC=yes    # If you don't have the PGI C compilers
Makefile options:

Option        Description
COMPILER       
This option is used to pick the compiler that you wish to use to build netCDF-4.2 and the related libraries. At present, you may select either ifort or pgi. If you omit the COMPILER option, the default value of ifort will be selected.

PREFIX       
This option is used to set root_library_dir, which is the full path name of the directory into which the netCDF-4.2 and related libraries will be installed. If you omit the PREFIX option, then root_library_dir will be automatically set to one of these default values:

GEOS-Chem-Libraries/opt/ifort/nc4/  # If COMPILER=ifort
GEOS-Chem-Libraries/opt/pgi/nc4/    # If COMPILER=pgi
If you do not have sysadmin privileges, then you can use the PREFIX option to set root_library_dir to a directory in your home space, such as /home/YOUR_USER_ID/lib (or you may install them in one of the default paths listed above). You can then ask your sysadmin to move the libraries to a common space on your machine (or cluster) where all users may access them.

GCC        If you do not have the Intel C/C++ compilers (icc, icpc) or PGI C/C++ compilers (pgcc, pgcpp) installed on your system, then you can tell the GEOS-Chem-Libraries installer to use the GNU C/C++ compilers (gcc, g++) instead. Otherwise, you can omit this option.
The libraries take approximately 20 minutes (or longer) to build. If the library installation process is successful, you will see this confirmation screen:

-------+---------+-------------------------------------  
Config | Install |             Package  
-------+---------+-------------------------------------
  ok   |   ok    | zlib-1.2.6     
  ok   |   ok    | hdf5-1.8.8     
  ok   |   ok    | netcdf-4.2     
  ok   |   ok    | netcdf-fortran-4.2
-------+---------+-------------------------------------
This tells you that the netCDF-4.2 and its related libraries were installed properly.

2.5.2.2 netCDF-4.2 library paths

The netCDF-4.2 (and related libraries) will be installed into the following paths. As described above, you may use the PREFIX=root_library_dir option to set the value of root_library_dir.

root_library_dir/bin           # nc-config, nf-config, ncdump, ncgen, etc.  
root_library_dir/include       # Include files (*.h)  
root_library_dir/lib           # Library file (libz.a)  
root_library_dir/share         # Manual pages & documentation
Now that you have installed netCDF–4.2, you may skip ahead to Chapter 2.5.4: Telling GEOS–Chem where to find the netCDF libraries.

2.5.3 Installing netCDF CLASSIC

If you have problems installing the netCDF–4.2 libraries on your system, try installing netCDF classic instead. Follow these instructions:

2.5.3.1 Building netCDF CLASSIC

To build the netCDF CLASSIC libraries (which lacks the advanced features of netCDF-4.2) using the Intel Fortran Compiler (ifort), type one of the following commands:

make CLASSIC=yes PREFIX=root_library_dir                        # If you have the Intel C compilers

make CLASSIC=yes PREFIX=root_library_dir GCC=yes                # If you don't have the Intel C compilers
To build the netCDF "CLASSIC" libraries for the PGI compiler, type:

make CLASSIC=yes COMPILER=pgi PREFIX=root_library_dir           # If you have the PGI C compilers:

make CLASSIC=yes COMPILER=pgi PREFIX=root_library_dir GCC=yes   # If you don't have the PGI C compilers
Makefile options:

Option        Description
COMPILER       
This option is used to pick the compiler that you wish to use to build netCDF CLASSIC. At present, you may select either ifort or pgi. If you omit the COMPILER option, the default value of ifort will be selected.

PREFIX       
This option is used to set root_library_dir, which is the full path name of the directory into which netCDF CLASSIC will be installed. If you omit the PREFIX option, then root_library_dir will be automatically set to one of these default values:

GEOS-Chem-Libraries/opt/ifort/nc_classic/  # If COMPILER=ifort
GEOS-Chem-Libraries/opt/pgi/nc_classic/    # If COMPILER=pgi
If you do not have sysadmin privileges, then you can use the PREFIX option to set root_library_dir to a directory in your home space, such as /home/YOUR_USER_ID/lib (or you may install them in one of the default paths listed above). You can then ask your sysadmin to move the libraries to a common space on your machine (or cluster) where all users may access them.

GCC        If you do not have the Intel C/C++ compilers (icc, icpc) or PGI C/C++ compilers (pgcc, pgcpp) installed on your system, then you can tell the GEOS-Chem-Libraries installer to use the GNU C/C++ compilers (gcc, g++) instead. Otherwise, you can omit this option.
The netCDF CLASSIC library takes several minutes to build. If the library installation process is successful, you will see this confirmation screen:

-------+---------+-------------------------------------
Config | Install |             Package
-------+---------+-------------------------------------
  --   |   --    | zlib-1.2.6
  --   |   --    | hdf5-1.8.8
  ok   |   ok    | netcdf-4.2 (netCDF classic)
  ok   |   ok    | netcdf-fortran-4.2 (netCDF classic)
-------+---------+-------------------------------------
This tells you that the netCDF CLASSIC library was installed properly. The ZLIB and HDF5 libraries are not needed for netCDF CLASSIC, and are therefore not built.

点评

32个赞  发表于 2014-3-12 16:34
密码修改失败请联系qq:937062711
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2013-10-14 00:56:42 | 显示全部楼层 |取消关注该作者的回复
非常实用,感谢楼主!先谢过啦!
密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2013-10-14 00:57:29 | 显示全部楼层 |取消关注该作者的回复
对了,如何查询自己机器上面的netcdf lib 是C还是fortran的?
密码修改失败请联系qq:937062711

新浪微博达人勋

 楼主| 发表于 2013-10-14 08:34:42 | 显示全部楼层 |取消关注该作者的回复
fascism 发表于 2013-10-14 00:56
非常实用,感谢楼主!先谢过啦!

密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2013-11-11 16:29:39 | 显示全部楼层 |取消关注该作者的回复
楼主大大 我尝试安装最新netcdf的时候 zlib一切ok 就是我在make hdf5 的时候总是有 warning: will never be executed 出现 是什么原因呢
密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2013-11-17 14:31:33 | 显示全部楼层 |取消关注该作者的回复
andrewsoong 发表于 2013-11-11 16:55
这类问题太坑了~~~还是哈佛大学GEOS_CHEM研究小组比较好~~~他把这些都集成了~~~你需要的话,可以去下载安 ...

你好,我执行git://git.as.harvard.edu/bmy/GEOS-Chem-Libraries,
Cloning into 'GEOS-Chem-Libraries'...
fatal: Unable to look up git.as.harvard.edu (port 9418) (Temporary failure in name resolution)
请问这个是什么问题呀,非常感谢
密码修改失败请联系qq:937062711

新浪微博达人勋

 楼主| 发表于 2013-11-17 15:22:40 | 显示全部楼层 |取消关注该作者的回复
iap123 发表于 2013-11-17 14:31
你好,我执行git://git.as.harvard.edu/bmy/GEOS-Chem-Libraries,
Cloning into 'GEOS-Chem-Libraries' ...

域名解析错误吧~~~我没遇到过~~~
密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2013-12-1 22:47:22 | 显示全部楼层 |取消关注该作者的回复
学习啦!
密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2013-12-3 07:45:39 | 显示全部楼层 |取消关注该作者的回复
楼主是用来做wrf的么?在wrf中不是用不到netcdf3.6.1以后的版本功能么?
Screenshot.png
密码修改失败请联系qq:937062711
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表