[Dart-dev] [4012] DART/trunk/models/POP/matlab/Check_ud.m: Better output format for reporting differences.

nancy at ucar.edu nancy at ucar.edu
Tue Aug 25 17:22:31 MDT 2009


An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20090825/a2e73222/attachment.html 
-------------- next part --------------
Modified: DART/trunk/models/POP/matlab/Check_ud.m
===================================================================
--- DART/trunk/models/POP/matlab/Check_ud.m	2009-08-25 23:04:35 UTC (rev 4011)
+++ DART/trunk/models/POP/matlab/Check_ud.m	2009-08-25 23:22:31 UTC (rev 4012)
@@ -1,14 +1,24 @@
-function [dart pop] = Check_ud(dartfile,popfile)
-% Check_ud : check the conversion of a POP restart to a DART state vector.
+function [dart pop] = Check_ud(popfile,dartfile)
+% Check_ud : check pop_to_dart.f90 ... the conversion of a POP restart to a DART state vector file.
+%
+%  popfile = 'pop.r.nc' 
 % dartfile = 'assim_model_state_ud';
-%  popfile = 'pop.r.nc' 
-% x        = Check_ud(dartfile,popfile);
+% x        = Check_ud(popfile, dartfile);
 %
-%
-% dartfile = '/fs/image/home/thoar/SVN/DART/models/POP/work/assim_model_state_ud';
 %  popfile = '/fs/image/home/thoar/SVN/DART/models/POP/work/cx3.dart.001.pop.r.0002-01-01-00000.nc';
-% [dart pop] = Check_ud(dartfile,popfile);
+% dartfile = '/fs/image/home/thoar/SVN/DART/models/POP/work/perfect_ics';
+% [dart pop] = Check_ud(popfile, dartfile);
+
+% Data Assimilation Research Testbed -- DART
+% Copyright 2004-2007, Data Assimilation Research Section
+% University Corporation for Atmospheric Research
+% Licensed under the GPL -- www.gpl.org/licenses/gpl.html
 %
+% <next few lines under version control, do not edit>
+% $URL$
+% $Id$
+% $Revision$
+% $Date$
 
 % Read the original POP file values.
 % The nc_varget() function returns the variables with the fastest 
@@ -80,13 +90,47 @@
 
 % Find the range of the mismatch
 
-Sdiff     = pop.S     - dart.S;     [min(    Sdiff(:)) max(    Sdiff(:))]
-Tdiff     = pop.T     - dart.T;     [min(    Tdiff(:)) max(    Tdiff(:))]
-Udiff     = pop.U     - dart.U;     [min(    Udiff(:)) max(    Udiff(:))]
-Vdiff     = pop.V     - dart.V;     [min(    Vdiff(:)) max(    Vdiff(:))]
-PSURFdiff = pop.PSURF - dart.PSURF; [min(PSURFdiff(:)) max(PSURFdiff(:))]
+d = pop.S     - dart.S;     disp(sprintf('S     diffs are %0.8g %0.8g',min(d(:)),max(d(:))))
+d = pop.T     - dart.T;     disp(sprintf('T     diffs are %0.8g %0.8g',min(d(:)),max(d(:))))
+d = pop.U     - dart.U;     disp(sprintf('U     diffs are %0.8g %0.8g',min(d(:)),max(d(:))))
+d = pop.V     - dart.V;     disp(sprintf('V     diffs are %0.8g %0.8g',min(d(:)),max(d(:))))
+d = pop.PSURF - dart.PSURF; disp(sprintf('PSURF diffs are %0.8g %0.8g',min(d(:)),max(d(:))))
 
+% As an added bonus, we create an 'assim_model_state_ic' file with an 
+% advance-to-time one day in the future.
 
+% Open and read timetag for state
+fid     = fopen(dartfile,'rb','ieee-le');
+trec1   = fread(fid,1,'int32');
+seconds = fread(fid,1,'int32');
+days    = fread(fid,1,'int32');
+trecN   = fread(fid,1,'int32');
+
+% read state vector variables.
+rec1     = fread(fid,     1,  'int32');
+datvec   = fread(fid, n3ditems+n2ditems, 'float64');
+recN     = fread(fid,     1,  'int32');
+fclose(fid);
+
+% Open and write advance_to_time
+fid     = fopen('test.ic','wb','ieee-le');
+fwrite(fid,  trec1,'int32');
+fwrite(fid,seconds,'int32');
+fwrite(fid,   days,'int32');
+fwrite(fid,  trecN,'int32');
+
+fwrite(fid,  trec1,'int32');
+fwrite(fid,seconds,'int32');
+fwrite(fid,   days+1,'int32');
+fwrite(fid,  trecN,'int32');
+
+% read state vector variables.
+fwrite(fid,   rec1, 'int32');
+fwrite(fid, datvec, 'float64');
+fwrite(fid,   recN, 'int32');
+fclose(fid);
+
+
 function C = get_3D_permuted(fid, shape, typestr)
 datasize = prod(shape);
 A = fread(fid, prod(shape), typestr);


More information about the Dart-dev mailing list