/[MITgcm]/MITgcm_contrib/mitgcm_tools/loadgrid.m
ViewVC logotype

Diff of /MITgcm_contrib/mitgcm_tools/loadgrid.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.1.1 by adcroft, Thu Sep 25 13:42:11 2003 UTC revision 1.2 by adcroft, Tue Dec 2 16:08:39 2003 UTC
# Line 5  function [GRID] = loadgrid(varargin) Line 5  function [GRID] = loadgrid(varargin)
5  %Reads MITgcm output files and input "data" file to create a GRID structure  %Reads MITgcm output files and input "data" file to create a GRID structure
6  %If DIRECTORY is not specified the current working directory is used.  %If DIRECTORY is not specified the current working directory is used.
7  %  %
8    %The following files are expected to be in the directory:
9    % data XC.* YC.* XG.* YG.* DXG.* DYG.* RAC.* hFacC.* hFacW.* hFacS.*
10    %
11  %e.g.  %e.g.
12  %>> GRID=loadgrid  %>> GRID=loadgrid
13  %GRID =  %GRID =
# Line 60  if fid==-1 Line 63  if fid==-1
63  end  end
64  fclose(fid);  fclose(fid);
65  drf=evalc([ ...  drf=evalc([ ...
66        '!awk ''/[dD[eE][lL][rRzZpP]/,/XXX/ {printf "%s",$0}'' ' datafile ...        '! grep -v ''#'' ' datafile ...
67        '| sed ''s/[dD][eE][lL][zZrRpP][ ]*=\([0-9,. ]*\).*/\1/''  ' ...        '| awk ''/[dD[eE][lL][rRzZpP]/,/XXX/ {printf "%s",$0}'' ' ...
68          '| sed ''s/[dD][eE][lL][zZrRpP][ ]*=\([0-9Ee,\. +\-]*\).*/\1/''  ' ...
69        '| sed ''s/[ ]//g''  ' ...        '| sed ''s/[ ]//g''  ' ...
70        '| sed ''s/,/ /g''  ' ...        '| sed ''s/,/ /g''  ' ...
71        ';'        ';'
# Line 91  GRID.drc=drc; Line 95  GRID.drc=drc;
95  GRID.rf=rf;  GRID.rf=rf;
96  GRID.rc=rc;  GRID.rc=rc;
97    
98  xc=rdmds([Dir 'XC']); GRID.xc=xc;  msg1='Error: Grid data written by the model is needed. The following files are needed: XC.* YC.* XG.* YG.* DXG.* DYG.* RAC.* hFacC.* hFacW.* hFacS.*';
99  yc=rdmds([Dir 'YC']); GRID.yc=yc;  msg2='Error: The appropriate model output files are not present. If the following files were not written by the model check that you have version 1.11 or greater of ini_grid.F: DXG.* DYG.* RAC.*';
100  xg=rdmds([Dir 'XG']); GRID.xg=xg;  
101  yg=rdmds([Dir 'YG']); GRID.yg=yg;  xc=locrdmds([Dir 'XC'],msg1); GRID.xc=xc;
102    yc=locrdmds([Dir 'YC'],msg1); GRID.yc=yc;
103  dxg=rdmds([Dir 'DXG']); GRID.dxg=dxg;  xg=locrdmds([Dir 'XG'],msg1); GRID.xg=xg;
104  dyg=rdmds([Dir 'DYG']); GRID.dyg=dyg;  yg=locrdmds([Dir 'YG'],msg1); GRID.yg=yg;
105    dxg=locrdmds([Dir 'DXG'],msg2); GRID.dxg=dxg;
106  rac=rdmds([Dir 'RAC']); GRID.rac=rac;  dyg=locrdmds([Dir 'DYG'],msg2); GRID.dyg=dyg;
107    rac=locrdmds([Dir 'RAC'],msg2); GRID.rac=rac;
108  hfacc=rdmds([Dir 'hFacC']); GRID.hfacc=hfacc;  hfacc=locrdmds([Dir 'hFacC'],msg1); GRID.hfacc=hfacc;
109  hfacw=rdmds([Dir 'hFacW']); GRID.hfacw=hfacw;  hfacw=locrdmds([Dir 'hFacW'],msg1); GRID.hfacw=hfacw;
110  hfacs=rdmds([Dir 'hFacS']); GRID.hfacs=hfacs;  hfacs=locrdmds([Dir 'hFacS'],msg1); GRID.hfacs=hfacs;
111    
112  mskc=hfacc; mskc(find(hfacc~=0))=1; GRID.mskc=mskc;  mskc=hfacc; mskc(find(hfacc~=0))=1; GRID.mskc=mskc;
113    
# Line 152  j=[]; Line 156  j=[];
156  j=[j find( yc<0 )'];  j=[j find( yc<0 )'];
157  GRID.msoc=msoc.*mskc.*(1-mpac).*(1-matl);  GRID.msoc=msoc.*mskc.*(1-mpac).*(1-matl);
158    
159    function [A] = locrdmds(fname,errmsg)
160    [fid,msg]=fopen([fname '.001.001.meta'],'r');
161    if fid == -1
162     A=[];
163     disp(errmsg);
164     error(['The error occured while trying to open ' fname '.001.001.meta'])
165    else
166     fclose(fid);
167     A=rdmds(fname);
168    end

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.22