Home > atmlab > gformat > gf_get_grid.m

gf_get_grid

PURPOSE ^

GF_GET_GRID Gets gformat grid data

SYNOPSIS ^

function [grid,name,unit] = gf_get_grid( G, dim )

DESCRIPTION ^

 GF_GET_GRID   Gets gformat grid data

    The fields GRIDx, GRIDx_NAME and GRIDx_UNIT can be extracted with the
    function, where x is *dim*.

 FORMAT   [grid,name,unit] = gf_get_grid( G, dim )
        
 OUT   grid  Grid.
       name  Grid name.
       unit  Grid unit.
 IN    G     A gformat structure.
       dim   Dimension.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gf_get_grid.m

SOURCE CODE ^

0001 % GF_GET_GRID   Gets gformat grid data
0002 %
0003 %    The fields GRIDx, GRIDx_NAME and GRIDx_UNIT can be extracted with the
0004 %    function, where x is *dim*.
0005 %
0006 % FORMAT   [grid,name,unit] = gf_get_grid( G, dim )
0007 %
0008 % OUT   grid  Grid.
0009 %       name  Grid name.
0010 %       unit  Grid unit.
0011 % IN    G     A gformat structure.
0012 %       dim   Dimension.
0013 
0014 % 2010-01-06   Created by Patrick Eriksson.
0015 
0016 function [grid,name,unit] = gf_get_grid( G, dim )
0017 
0018 strict_assert = atmlab('STRICT_ASSERT');
0019 
0020   
0021 if strict_assert
0022   rqre_nargin( 2, nargin );
0023   rqre_datatype( G, @isstruct );
0024   rqre_alltypes( dim, {@istensor0,@iswhole} );
0025   rqre_in_range( dim, 1 );
0026 end
0027 
0028 bname = sprintf( 'GRID%d', dim );
0029 if strict_assert
0030   rqre_field( G, bname );
0031 end
0032 grid = G.(bname);
0033   
0034 if nargout >= 2
0035   fname = [ bname, '_NAME' ]; 
0036   if strict_assert
0037     rqre_field( G, fname );
0038   end
0039   name = G.(fname);
0040   if nargout >= 3
0041     fname = [ bname, '_UNIT' ]; 
0042     if strict_assert
0043       rqre_field( G, fname );
0044     end
0045     unit = G.(fname);
0046   end
0047 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005