{"id":13686412,"url":"https://github.com/cwebster2/ingest_cm1","last_synced_at":"2026-01-17T01:21:51.193Z","repository":{"id":11399656,"uuid":"13845745","full_name":"cwebster2/ingest_cm1","owner":"cwebster2","description":"A Fortran library to read CM1 output files.","archived":false,"fork":false,"pushed_at":"2015-11-06T04:56:58.000Z","size":464,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T15:05:17.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"FORTRAN","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cwebster2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-24T22:13:55.000Z","updated_at":"2021-09-24T20:47:14.000Z","dependencies_parsed_at":"2022-08-22T08:50:53.445Z","dependency_job_id":null,"html_url":"https://github.com/cwebster2/ingest_cm1","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwebster2%2Fingest_cm1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwebster2%2Fingest_cm1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwebster2%2Fingest_cm1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwebster2%2Fingest_cm1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwebster2","download_url":"https://codeload.github.com/cwebster2/ingest_cm1/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224250215,"owners_count":17280522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T15:00:31.910Z","updated_at":"2026-01-17T01:21:51.162Z","avatar_url":"https://github.com/cwebster2.png","language":"FORTRAN","funding_links":[],"categories":["Numerical Model"],"sub_categories":[],"readme":"# Ingest_cm1 #\n\n[![Build Status](https://travis-ci.org/cwebster2/ingest_cm1.svg?branch=master)](https://travis-ci.org/cwebster2/ingest_cm1)\n[![DOI](https://zenodo.org/badge/3899/cwebster2/ingest_cm1.svg)](https://zenodo.org/badge/latestdoi/3899/cwebster2/ingest_cm1)\n\n\n## README ##\n\nIngest_cm1 is a Fortran module to abstract access to model output \nfiles from George Bryan's CM1 cloud model.  \n\nThe current version of this module supports access to GrADS style files\nwith one output file per timestep or one output file per timestep per\nMPI node; HDF5 output. \n\nThese represent files created by the following options in the\nCM1 namelist.input file (GRADS, GRADSMPI):\n\n    output_format = 1\n    output_filetpe = 2 or 3\n\nAnd for HDF data:\n\n    output_format = 3, 4, 5\n    output_filetype = 3\n\nNOTE: Support for the native tiled output is not yet implemented.  You must untile the output with the included python script.\n\nFuture output format support is expected for NetCDF4 and native MPI tiled HDF output.\n\n\n* [Getting](#getting-the-software)\n* [Installing](#installing)\n* [Using](#using)\n  - [The cm1_dataset front-end](#The-cm1_dataset-front-end)\n    + [Open_dataset](#open_dataset)\n    + [Close_dataset](#close_dataset)\n    + [Reading data](#reading-data)\n      * [read_3d](#read_3d)\n      * [read_3d_slice](#read_3d_slice)\n      * [read_2d](#read_2d)\n    + [Accessing grid information](#accessing-grid-information)\n  - [Example](#example)\n  - [The backend classes](#the-backend-classes)\n* [Contributing](#contributing)\n* [Author](#author)\n* [License](#license)\n\n\n# GETTING THE SOFTWARE #\n\nDownload a current snapshot of ingest_cm1 with:\n\n    git clone https://github.com/cwebster2/ingest_cm1.git\n\n\n# INSTALLING #\n\nA Fortran 2003 compiler is required to build this software.  If using GNU `gfortran`, \nuse of version 4.8 or later is required due to the use of allocatable arrays of \npolymorphic types.  Intel `ifort` should work but is untested, as are other fortran compilers.\n\nIngestCM1 uses cmake to generate makefiles and you have a few options when building.  The default\noptions are to build a static library without HDF5 support and install into ingest_cm1's directory.\nTo use this default, from the ingest_cm1 directory, do:\n\n    cmake .\n\nTo enable HDF5 support, use:\n\n    cmake . -DWITH_HDF5=1\n\nIf your HDF5 library is not found, you can specify a search path with the `HDF5_ROOT` environment variable.\n\n    HDF5_ROOT=\"/path/to/hdf5\" cmake . -DWITH_HDF5=1\n\nIf your HDF5 library is built with cmake support, you can try this instead:\n\n    cmake . -DWITH_HDF5_CMAKE\n\nTo build a shared library instead of a static library, add the flag `-DBUILD_SHARED_LIBS=1` flag to cmake and\nto change the installation location, e.g. /usr/local, use `-DCMAKE_INSTALL_PREFIX:PATH=/usr/local`.  An example\nof all of the above is:\n\n    HDF5_ROOT=\"/path/to/hdf5\" cmake . -DWITH_HDF5=1 -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX:PATH=/usr\n\nwhich will generate makefiles to build a shared library, install into /usr/lib and /usr/include and\ninclude HDF5 support.\n\nTo build and install ingest_cm1 do:\n\n    make\n    make install\n\n# USING #\n\n## The cm1_dataset front end ##\n\nThe cm1_dataset front-end is able to load a dataset with multiple grids spread across multiple files.\nThis paradigm assumes the output style of CM1 where there are 4 grids each for scalar, u, v, and w\nvariables. Within each grid the output may be a single file per timestep, a single file for all timesteps\nor a file for each MPI rank at each timestep.  This is defined by the `dsettype` variable below.\n\nThe procedures below are all part of the `cm1_dataset` derived type in module `ingest_cm1`.\n\n### open_dataset ###\n\n```fortran\ninteger function open_dataset(self, dsetpath, dsetbasename, dsettype, grids, nodex, nodey)\n   class(cm1_dataset) :: self\n   character(len=*), intent(in) :: dsetpath\n   character(len=*), intent(in) :: dsetbasename\n   integer, intent(in)          :: dsettype\n   character, dimension(:)      :: grids\n   integer, optional :: nodex, nodey\n```\nThis opens the dataset located at `dsetpath` with basename `dsetbasename`.  \n`dsettype` is one of `GRADS`, `GRADSMPI`, `GRADSSINGLE`, or `HDF`.\n`grids` is an array of grids to open, e.g. `['s', 'u', 'v', 'w']` for a full dataset or `['s']` if only the scalar grid is desired.\nThe variables `nodex` and `nodey` are only used for the `GRADSMPI` dsettype.  These are the same values used in the namelist.input for the MPI run.\n\n### close_dataset ###\n\n```fortran\ninteger function close_dataset(self)\n   class(cm1_dataset) :: self\n```\nThis closes the dataset.\n\n### Reading data ###\n\nThere are three versions of `read` that return 2d, 3d and slices of 3d fields.\n\n#### read_3d\n\n```fortran\ninteger function read(self, time, grid, varname, Field3D)\n   implicit none\n   class(cm1_dataset) :: self\n   integer            :: time, gridno\n   character          :: grid\n   character(len=*)   :: varname\n   real, dimension(:,:,:) :: Field3D\n```\nThis function returns the 3d variable `Field3D` for the variable `varname` on grid `grid` at time `time`.  It returns 1 on success and 0 on failure.\n\n#### read_3d_slice\n\n```fortran\ninteger function read(self, time, grid, varname, Field3D, ib, ie, jb, je, kb, ke)\n   implicit none\n   class(cm1_dataset) :: self\n   integer            :: time, gridno, ib, ie, jb, je, kb, ke\n   character          :: grid\n   character(len=*)   :: varname\n   real, dimension(:,:,:) :: Field3D\n```\n\nThis function works just as `read_3d` but returns a slice of the full variable.  If the full 3D variable is `FullField3D`, then this returns `Field3D = FullField3D(ib:ie, jb:je, kb:ke)`.  Returns 1 on sucess and 0 on failure.\n\n#### read_2d\n\n```fortran\ninteger function read(self, time, grid, varname, Field2D)\n   implicit none\n   class(cm1_dataset) :: self\n   integer            :: time, gridno\n   character          :: grid\n   character(len=*)   :: varname\n   real, dimension(:,:) :: Field2D\n```\nThis function returns the 2d variable `Field2D` for the variable `varname` on grid `grid` at time `time`.  It returns 1 on success and 0 on failure.\n\n### Accessing grid information ###\n#### get_nx, get_ny, get_nz, get_nt ####\n\n```fortran\ninteger function get_nx(self, grid)\n   implicit none\n   class(cm1_dataset) :: self\n   character          :: grid\n```\nThese get dimensions of the specified grid `grid`.\n\n#### get_x, get_y, get_z, get_t ####\n\n```fortran\nfunction get_x(self, grid, cm1err) result(x)\n   implicit none\n   class(cm1_dataset) :: self\n   character          :: grid\n   integer            :: gridno\n   logical, optional  :: cm1err\n   real, dimension(:), allocatable :: x\n```\nThese get the mesh of grid `grid` along the specified dimension\n\n\n## Example\n\n```fortran\nuse ingest_cm1\nimplicit none\ntype(cm1_dataset) :: cm1\ninteger :: status, nx, ny, nz\nreal, allocatable :: theta(:,:,:)\n\n! this opens a GRADS dataset with variables at u, v, w and s points.\nstatus = cm1%open_dataset('/path/to/dataset', 'cm1out', GRADS, ['s','u','v','w'])\n\n! get array dimensions for the s grid\nnx = cm1%get_nx('s')\nny = cm1%get_ny('s')\nnz = cm1%get_nz('s')\n\n! get a variable theta on grid 's' at time 900\nallocate(theta(nx,ny,nz)\nstatus = cm1%read_3d(900, 's', 'th', theta)\n\n! do stuff here\n\nstatus = cm1%close_dataset()\n```\n\n## The backend classes\n\nYou may also use the backend classes directly.  These all derive from type `cm1_base` and each\nimplements a specific file backend.  The interface is similar to that of `ingest_cm1`.  See the\nderived type and the base type for details.\n\n\n# Contributing\nThe easiest way to contribute is to fork the repository on github and submit\npull requests.  I'm open to all contributions from bugfixes to enhacements specific\nto your workflow use-case.  Contributed code is licensed under the BSD license and\nyou will attributed.\n\n# Author\nContributors as of 26 Oct 2015\n\n- Casey Webster (cwebster2)\n\n# License\nCopyright (c) 2015, Casey Webster\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n1 Redistributions of source code must retain the above copyright notice, this\n  list of conditions and the following disclaimer.\n\n2 Redistributions in binary form must reproduce the above copyright notice, this\n  list of conditions and the following disclaimer in the documentation and/or\n  other materials provided with the distribution.\n\n3 Neither the name of the copyright holder nor the names of its contributors may\n  be used to endorse or promote products derived from this software without \n  specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwebster2%2Fingest_cm1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwebster2%2Fingest_cm1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwebster2%2Fingest_cm1/lists"}