g S ys Te t -F o llo w i r rai n ng O R es e a rc h C o mm u ni ty ce m em g M o d e li n Re io ean l Oc na an Op & ROMS: NetCDF and Matlab David Robertson and Hernan Arango New Brunswick, NJ, USA te y e r ati n it o n al C o m m u ROMS/TOMS Web Sites IMCS, Rutgers University M o d e lin g S y s Web Statistics 100 90 80 70 60 50 40 30 20 10 0 2004 2005 2004 2005 2006 2007 2008 2009 2006 2007 new new new new new new users: users: users: users: users: users: 2008 204 267 288 367 533 131 2009 Web Statistics Oct. ‘08 Users Mar. ‘09 Oct. ‘08 Mar. ‘09 Country Country Use rs 1 1 United States 502 11 10 Canada 39 2 2 China 161 12 12 Germany 32 3 6 Australia 70 13 14 Mexico 29 3 Spain 70 14 13 Portugal 28 5 5 Japan 64 6 7 South Korea 62 16 15 Norway 26 7 8 India 61 17 17 Chile 21 8 4 France 60 18 18 Taiwan 19 9 9 Italy 53 19 19 Russia 18 48 20 20 Ireland 14 10 11 Brazil 16 United Kingdom 28 Overview • Daily Update Email • Forum Posts • Trac Ticket Activity (New & Resolved) • Revisions • Forum Search • Trac Website • ROMS Documentation Projects WikiROMS Tutorial Movies and Animations NetCDF-4/HDF5 Capabilities: • Allows for multiple unlimited dimensions • Data compression • Parallel file access • Grouping Caveats: • Compression cannot be used to write in parallel (PARALLEL_IO) • Parallel I/O only in MPI (not shared memory) • Separate compilation for every combination of I/0 (parallel v. serial), compiler (PGI, Intel, etc.), and MPI implementation (MPICH2, OpenMPI, etc.) • Parallel I/O is slower than serial in ROMS NetCDF and Matlab® Considerations Interfaces: • mexcdf • mexnc • snctools • NetCDF-java • Native Matlab (R2008b and newer) NetCDF Version: • NetCDF-3 • NetCDF-4/HDF5 (must be linked staticly, no shared libraries) NetCDF File Type: • Classic (NetCDF-3) • HDF5 (NetCDF-4) Misc: • File compression (NetCDF-4/HDF5 only) • OpenDAP URLs mexnc Flowchart Matlab® Version mexnc.mex exists? R2008b or newer No R2008a or older Yes mexnc 2.9.4 – 2.9.7 mexnc.mex capabilities NetCDF-4/HDF5 NetCDF-3 mexnc.mex Native Matlab® NetCDF mexnc Flowchart Matlab® Version USE_TMW on? R2008b or newer Yes R2008a or older No mexnc 2.9.10 mexnc.mex Native Matlab® NetCDF snctools Flowchart (line colors indicate file type) NetCDF file type NetCDF-4/HDF5 snctools 2.9.4 – 2.9.7 Java Available? Java ToolsUI.jar NetCDF-4/HDF5 NetCDF-3 URL (read only) Error, no method available to read file. mexnc.mex capabilities NetCDF-3 Matlab® Version No R2008a or older Yes R2008b or newer Native Matlab NetCDF mexnc.mex snctools Flowchart: Reading (grey lines indicate Matlab version line colors indicate file type) Matlab® Version R2008b or newer snctools 2.9.10 NetCDF file type NetCDF-3 R2008a or older NetCDF-4/HDF5 URL USE_JAVA on? Yes Java ToolsUI.jar No mexnc.mex Native Matlab® NetCDF snctools Flowchart: Writing (grey lines indicate Matlab version line color indicates file type) Matlab Version R2008b or newer snctools 2.9.10 R2008a or older NetCDF file type NetCDF-3 NetCDF-4/HDF5 mexnc.mex Native Matlab NetCDF ROMS Matlab Pre- and Post-Processing Scripts NetCDF Interface: • snctools users should be aware that mexnc, native Matlab NetCDF, and these scripts return arrays with the indices in the order in which the variable is written to the NetCDF file. snctools will give you the array with the indices in the opposite order. • Since ROMS is a Fortran code, ROMS arrays in output files are stored in (i, j, k) order. • These scripts use mexnc for the backend • mexnc.m is required regardless of Matlab version • For NetCDF-4/HDF5 capability you need to compile the mexnc mex file yourself • mexnc does not use the java ToolsUI.jar file so no OpenDAP • NetCDF v4.1 will have build-in OpenDAP capabilities NetCDF Operator Comparison Dataset Functions NetCDF Native Matlab mexnc snctools nc_create(…); netcdf.create(…); mexnc(‘create’,…); nc_create_empty(…); nc_open(…); netcdf.open(…); mexnc(‘open’,…); ---------- nc_redef(…); netcdf.reDef(…); mexnc(‘redef’,…); ---------- nc_endef(…); netcdf.endDef(…); mexnc(‘endef’,…); ---------- nc_close(…); netcdf.close(…); mexnc(‘close’,…); ---------- nc_sync(…); netcdf.sync(…); mexnc(‘sync’,…); ---------- nc_abort(…); netcdf.abort(…); mexnc(‘abort’,…); ---------- Dataset Inquiry Functions NetCDF Native Matlab mexnc snctools nc_inq(…); netcdf.inq(…); mexnc(‘inq’,…); nc_info(…); nc_inq_ndims(…); ---------- mexnc(‘inq_ndims’,…); ---------- nc_inq_nvars(…); ---------- mexnc(‘inq_nvars’,…); ---------- nc_inq_natts(…); ---------- mexnc(‘inq_natts’,…); ---------- nc_inq_unlimdim(…); ---------- mexnc(‘inq_unlimdim’,…); ---------- NetCDF Operator Comparison (cont.) Dimension Functions NetCDF Native Matlab mexnc snctools nc_def_dim(…); netcdf.defDim(…); mexnc(‘def_dim’,…); nc_add_dimension(…); nc_inq_dimid(…); netcdf.inqDimID(…); mexnc(‘inq_dimid’,…); nc_inq_dim(…); netcdf.inqDim(…); mexnc(‘inq_dim’,…); ---------nc_getdiminfo(…); nc_inq_dimname(…); ---------- mexnc(‘inq_dimname’,…); ---------- nc_inq_dimlen(…); ---------- mexnc(‘inq_dimlen’,…); ---------- mexnc(‘rename_dim’,…); ---------- nc_rename_dim(…); netcdf.renameDim(…); Attribute Functions NetCDF Native Matlab mexnc snctools nc_put_att_*(…); netcdf.putAtt(…); mexnc(‘put_att_*’,…); nc_attput(…); nc_inq_att(…); netcdf.inqAtt(…); mexnc(‘inq_att’,…); nc_info(…); nc_inq_atttype(…); ---------- mexnc(‘inq_atttype’,…); ---------- nc_inq_attlen(…); ---------- mexnc(‘inq_attlen’,…); ---------- nc_inq_attname(…); netcdf.inqAttName(…); mexnc(‘inq_attname’,…); ---------- nc_inq_attid(…); netcdf.inqAttID(…); mexnc(‘inq_attid’,…); ---------- nc_get_att_*(…); netcdf.getAtt(…); mexnc(‘get_att_*’,…); nc_copy_att(…); netcdf.copyAtt(…); mexnc(‘copy_att’,…); ---------- nc_rename_att(…); netcdf.renameAtt(…); mexnc(‘rename_att’,…); ---------- nc_del_att(…); netcdf.delAtt(…); mexnc(‘del_att’,…); ---------- nc_attget(…); NetCDF Operator Comparison (cont.) General Variable Functions NetCDF Native Matlab mexnc snctools nc_def_var(…); netcdf.defVar(…); mexnc(‘def_var’,…); nc_addvar(…); nc_inq_varid(…); netcdf.inqVarID(…); mexnc(‘inq_varid’,…); nc_inq_var(…); netcdf.inqVar(…); mexnc(‘inq_var’,…); ---------nc_getvarinfo(…); nc_inq_varname(…); ---------- mexnc(‘inq_varname’,…); ---------- nc_inq_vartype(…); ---------- mexnc(‘inq_vartype’,…); ---------- nc_inq_vardims(…); ---------- mexnc(‘inq_varndims’,…); ---------- nc_inq_vardimid(…); ---------- mexnc(‘inq_vardimid’,…); ---------- nc_inq_varnatts(…); ---------- mexnc(‘inq_varnatts’,…); ---------- mexnc(‘rename_var’,…); nc_varrename(…); nc_rename_var(…); nc_copy_var(…); netcdf.renameVar(…); ---------- ----------- NetCDF Operator Comparison (cont.) Variable I/O Functions (read) NetCDF Native Matlab mexnc snctools nc_get_var_*(…); netcdf.getVar(…); mexnc(‘get_var_*’,…); nc_varget(…); nc_get_var1_*(…); ---------- mexnc(‘get_var1_*’,…); ---------- nc_get_vara_*(…); ---------- mexnc(‘get_vara_*’,…); ---------- nc_get_vars_*(…); ---------- mexnc(‘get_vars_*’,…); ---------- nc_get_varm_*(…); ---------- mexnc(‘get_varm_*’,…); ---------- Variable I/O Functions (write) NetCDF Native Matlab mexnc snctools nc_put_var_*(…); netcdf.putVar(…); mexnc(‘put_var_*’,…); nc_varput(…); nc_put_var1_*(…); ---------- mexnc(‘put_var1_*’,…); ---------- nc_put_vara_*(…); ---------- mexnc(‘put_vara_*’,…); ---------- nc_put_vars_*(…); ---------- mexnc(‘put_vars_*’,…); ---------- nc_put_varm_*(…); ---------- mexnc(‘put_varm_*’,…); ----------
© Copyright 2026 Paperzz