-
-
Save jmcarthur/1187906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ncInq :: NCID -> IO (Int, Int, Int, Int) | |
ncInq ncid = | |
alloca $ \ndims_ptr -> | |
alloca $ \nvars_ptr -> | |
alloca $ \natts_ptr -> | |
alloca $ \unlimdimid_ptr -> do | |
status <- nc_inq ncid ndims_ptr nvars_ptr natts_ptr unlimdimid_ptr | |
ndims <- peek ndims_ptr | |
nvars <- peek nvars_ptr | |
natts <- peek natts_ptr | |
unlimdimid <- peek unlimdimid_ptr | |
return (fromEnum ndims, fromEnum nvars, fromEnum natts, fromEnum unlimdimid) | |
ncInq :: NCID -> IO (Int, Int, Int, Int) | |
ncInq ncid = (`runContT` return) $ do | |
ndims_ptr <- newPtr | |
nvars_ptr <- newPtr | |
natts_ptr <- newPtr | |
unlimdimid_ptr <- newPtr | |
liftIO $ do | |
status <- nc_inq ncid ndims_ptr nvars_ptr natts_ptr unlimdimid_ptr | |
ndims <- peek ndims_ptr | |
nvars <- peek nvars_ptr | |
natts <- peek natts_ptr | |
unlimdimid <- peek unlimdimid_ptr | |
return (fromEnum ndims, fromEnum nvars, fromEnum natts, fromEnum unlimdimid) | |
where newPtr = ContT alloca |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment