A common requirement in science is to store and share large sets of simulation data in an efficient, nested, flexible and human-readable way. Such datasets contain number counts and distributions, i.e. histograms and maps, of arbitrary dimension and variable type, e.g. floating-point number, integer or character string. Modern high-level programming languages like Perl and Python have associated arrays, knowns as dictionaries or hashes, respectively, to fulfil this storage need. Low-level languages used more commonly for fast computational simulations, such as C and Fortran, lack this functionality. We present libcdict, a C dictionary library, to solve this problem. Libcdict provides C and Fortran application programming interfaces (APIs) to native dictionaries, called cdicts, and functions for cdicts to load and save these as JSON and hence for easy interpretation in other software and languages like Perl, Python and R.
翻译:科学研究中常见需求是以高效、嵌套、灵活且人类可读的方式存储和共享大规模模拟数据集。此类数据集包含任意维度和变量类型(如浮点数、整数或字符串)的数量计数与分布,即直方图和映射图。现代高级编程语言(如Perl和Python)通过关联数组(分别称为字典或哈希表)满足这一存储需求。而常用于快速计算模拟的低级语言(如C和Fortran)则缺乏此类功能。我们提出libcdict——一个C语言字典库,以解决这一问题。Libcdict为原生字典(称为cdicts)提供C和Fortran应用编程接口(API),并支持cdicts以JSON格式加载和保存这些字典,从而便于在Perl、Python和R等其他软件和语言中进行解析。