APP下载

NetCDF格式在Windows及Linux平台下的读写

2014-10-21李继祥于立陈龙泉姚仁太郝宏伟范丹吕明华

安徽农业科学 2014年33期

李继祥 于立 陈龙泉 姚仁太 郝宏伟 范丹 吕明华

摘要 使用Linux平台的NetCDF3.6.1源代码程序包,利用hdf提供的Windows平台NetCDF的库,分别编写Windows平台和Linux平台下读写NetCDF的C语言程序及Fortran语言程序。在Windows平台只需要netcdf.dll、libcurl.dll、zlib1.dll和netcdf.lib这4个文件就可以用C和Fortran读写NetCDF格式文件,在Linux平台下只需要libnetcdf.a这1个文件就可以用C和Fortran读写,在不安装NetCDF软件包的情况下就可以使用,并且程序语言均很简单,读写起来很方便,还对比了Windows和Linux平台下C和Fortran的读写精度及速度。该研究对使用NetCDF格式数据的人员有指导和参考价值。

关键词 NetCDF格式;Windows平台;Linux平台;读写速度与精度

中图分类号 P49;S126 文献标识码

A 文章编号 0517-6611(2014)33-11942-04

Read and Write NetCDF Format Files on Windows and Linux Platform

LI Ji-xiang1, YU Li2,3, CHEN Long-quan1 et al (1. Atmospheric Boundary Layer Wind Tunnel Laboratory of China Institute for Radiation Protection, Taiyuan, Shanxi 030006; 2. Taiyuan Satellite Launch Center, Taiyuan, Shanxi 030006; 3. College of Atmospheric Sciences, Lanzhou University, Lanzhou, Gansu 730000)

Abstract Based on the NetCDF3.6.1 source code package on Linux platform, with NetCDF library on Windows platform provided by HDF, we compiled programs to read and write NetCDF files in C language and Fortran language on Windows platform and Linux platform. On Windows platform we only need netcdf. dll, libcurl. dll, zlib1. dll and netcdf.lib to read and write netcdf format files in C and Fortran languages, and we only need libnetcdf.a file to do that on Linux platform, in the case of not installing NetCDF package and the program is very simple, it is convenient to read and write, at last we compared the Windows and Linux platforms read and write speed and accuracy of C and Fortran languages.This paper has certainguidance and reference value on the use of NetCDF format data.

Key words NetCDF format; Windows platform; Linux platform; Read and write speed and accuracy

基金项目 国家自然科学基金项目(11175161)。

作者简介 李继祥(1987- ),男,甘肃秦安人,实习研究员,从事大气边界层和空气污染数值模拟研究。

收稿日期 2014-10-13

NetCDF(Network Common Data Form)是一種网络通用的数据格式,文件最初应用于贮存气象数据,由于其灵活性,能够传输海量的面向阵列(Array-oriented)数据,目前广泛应用于大气科学、水文、海洋学、环境模拟、地球物理等诸多领域。已被国内外许多行业和组织采用,例如NCEP(美国国家环境预报中心)发布的再分析资料及NOAA的CDC(气候数据中心)发布的海洋与大气综合数据集(COADS)均采用NetCDF作为标准。

目前大部分的气象资料均为NetCDF格式,例如广泛使用的中尺度天气预报模式WRF,其输出数据模式即为NetCDF,因此,准确、快速的读写该类型数据是一项有意义的工作。查石祥探讨了在Unix平台下用Fortran读取该类型数据的方法,但未讨论写成NetCDF的方法,而且该方法对系统环境依赖性大[1]。孙建伟等介绍了在Windows下用Fortran读写NetCDF格式的方法,但也需要创建NetCDF环境,读写需要依赖于NetCDF环境[2]。……

登录APP查看全文