Git Product home page Git Product logo

Comments (2)

schaefed avatar schaefed commented on July 19, 2024

Hello milancurcic,

the main purpose of this module is to hide bookkeeping of identifiers and error checking behind a simple API, without sacrificing control over file creation and modification.

Reducing verbosity was never a design goal, but I would argue, mo_netcdf has a lot to offer in this respect too.

Let's have a look at some code:

  1. A (slightly modified) minimal example from the official docs.
use netcdf
implicit none
                                                                                                                                                                       
integer :: status, ncid
integer :: LonDimId, LatDimId, TimeDimId
integer :: RhVarId

status = nf90_create("foo.nc", nf90_NoClobber, ncid)
if(status /= nf90_NoErr) stop 1                                                                                                                                            
                                                                                                                                                                             
! Define the dimensions
status = nf90_def_dim(ncid, "lat", 5, LatDimId)
if(status /= nf90_NoErr) stop 1
                                                                                                                                                                             
status = nf90_def_dim(ncid, "lon", 10, LonDimId)
if(status /= nf90_NoErr) stop 1
                                                                                                                                                                             
status = nf90_def_dim(ncid, "time", nf90_unlimited, TimeDimId)
if(status /= nf90_NoErr) stop 1
                                                                                                                                            
! Define the variable
status = nf90_def_var(ncid, "rh", nf90_double, &
                (/LonDimId, LatDimID, TimeDimID /), RhVarId)         
if(status /= nf90_NoErr) stop 1

status = nf90_close(ncid)
if(status /= nf90_NoErr) stop 1                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  1. The very same functionality using mo_netcdf
use mo_netcdf
implicit none

type(NcDataset) :: nc                                                                                                                                                      
type(NcVariable) :: var   

nc = NcDataset("bar.nc", "w")              
                                                                                                                                
var = nc%setVariable("rh", "f64",       &                                                                                                                                  
              (/nc%setDimension("lat", 5),   &                                                                                                                                  
                nc%setDimension("lon", 10), &                                                                                                                                  
                nc%setDimension("time")/))         
                                                                                                                            
call nc%close()            

Cheers, David

from mo_netcdf.

milancurcic avatar milancurcic commented on July 19, 2024

Thanks, this example shows the difference clearly. I suggest you emphasize these points (bookkeeping, exception handling etc.) near the top of your README.

Great work with the library!

from mo_netcdf.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.