Parent Directory
|
Revision Log
|
Revision Graph
|
Patch
--- MITgcm_contrib/mitgcm_tools/loadgrid.m 2003/09/25 13:42:11 1.1
+++ MITgcm_contrib/mitgcm_tools/loadgrid.m 2003/12/02 16:08:39 1.2
@@ -5,6 +5,9 @@
%Reads MITgcm output files and input "data" file to create a GRID structure
%If DIRECTORY is not specified the current working directory is used.
%
+%The following files are expected to be in the directory:
+% data XC.* YC.* XG.* YG.* DXG.* DYG.* RAC.* hFacC.* hFacW.* hFacS.*
+%
%e.g.
%>> GRID=loadgrid
%GRID =
@@ -60,8 +63,9 @@
end
fclose(fid);
drf=evalc([ ...
- '!awk ''/[dD[eE][lL][rRzZpP]/,/XXX/ {printf "%s",$0}'' ' datafile ...
- '| sed ''s/[dD][eE][lL][zZrRpP][ ]*=\([0-9,. ]*\).*/\1/'' ' ...
+ '! grep -v ''#'' ' datafile ...
+ '| awk ''/[dD[eE][lL][rRzZpP]/,/XXX/ {printf "%s",$0}'' ' ...
+ '| sed ''s/[dD][eE][lL][zZrRpP][ ]*=\([0-9Ee,\. +\-]*\).*/\1/'' ' ...
'| sed ''s/[ ]//g'' ' ...
'| sed ''s/,/ /g'' ' ...
';'
@@ -91,19 +95,19 @@
GRID.rf=rf;
GRID.rc=rc;
-xc=rdmds([Dir 'XC']); GRID.xc=xc;
-yc=rdmds([Dir 'YC']); GRID.yc=yc;
-xg=rdmds([Dir 'XG']); GRID.xg=xg;
-yg=rdmds([Dir 'YG']); GRID.yg=yg;
-
-dxg=rdmds([Dir 'DXG']); GRID.dxg=dxg;
-dyg=rdmds([Dir 'DYG']); GRID.dyg=dyg;
-
-rac=rdmds([Dir 'RAC']); GRID.rac=rac;
-
-hfacc=rdmds([Dir 'hFacC']); GRID.hfacc=hfacc;
-hfacw=rdmds([Dir 'hFacW']); GRID.hfacw=hfacw;
-hfacs=rdmds([Dir 'hFacS']); GRID.hfacs=hfacs;
+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.*';
+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.*';
+
+xc=locrdmds([Dir 'XC'],msg1); GRID.xc=xc;
+yc=locrdmds([Dir 'YC'],msg1); GRID.yc=yc;
+xg=locrdmds([Dir 'XG'],msg1); GRID.xg=xg;
+yg=locrdmds([Dir 'YG'],msg1); GRID.yg=yg;
+dxg=locrdmds([Dir 'DXG'],msg2); GRID.dxg=dxg;
+dyg=locrdmds([Dir 'DYG'],msg2); GRID.dyg=dyg;
+rac=locrdmds([Dir 'RAC'],msg2); GRID.rac=rac;
+hfacc=locrdmds([Dir 'hFacC'],msg1); GRID.hfacc=hfacc;
+hfacw=locrdmds([Dir 'hFacW'],msg1); GRID.hfacw=hfacw;
+hfacs=locrdmds([Dir 'hFacS'],msg1); GRID.hfacs=hfacs;
mskc=hfacc; mskc(find(hfacc~=0))=1; GRID.mskc=mskc;
@@ -152,3 +156,13 @@
j=[j find( yc<0 )'];
GRID.msoc=msoc.*mskc.*(1-mpac).*(1-matl);
+function [A] = locrdmds(fname,errmsg)
+[fid,msg]=fopen([fname '.001.001.meta'],'r');
+if fid == -1
+ A=[];
+ disp(errmsg);
+ error(['The error occured while trying to open ' fname '.001.001.meta'])
+else
+ fclose(fid);
+ A=rdmds(fname);
+end
| ViewVC Help | |
| Powered by ViewVC 1.1.22 |