Home > fvcom_prepro > write_FVCOM_cor.m

write_FVCOM_cor

PURPOSE ^

Write coriolis to FVCOM format coriolis file

SYNOPSIS ^

function write_FVCOM_cor(Mobj,filename)

DESCRIPTION ^

 Write coriolis to FVCOM format coriolis file

 function write_FVCOM_cor(Mobj,filename)

 DESCRIPTION:
    Generate an ascii FVCOM 3.x format coriolis from Mesh object

 INPUT 
   Mobj     = Mesh object
   filename = FVCOM coriolis file name

 OUTPUT:
    FVCOM coriolis file: filename

 EXAMPLE USAGE
    write_FVCOM_cor(Mobj, 'tst_cor.dat')   

 Author(s):  
    Geoff Cowles (University of Massachusetts Dartmouth)
    Rory O'Hara Murray (Marine Scotland Science)
    Pierre Cazenave (Plymouth Marine Laboratory)

 Revision history
    2014-10-07 Removed loops to speed up writing the file
    2016-08-08 Remove tabs and clean up syntax.
   
==============================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function write_FVCOM_cor(Mobj,filename) 
0002 % Write coriolis to FVCOM format coriolis file
0003 %
0004 % function write_FVCOM_cor(Mobj,filename)
0005 %
0006 % DESCRIPTION:
0007 %    Generate an ascii FVCOM 3.x format coriolis from Mesh object
0008 %
0009 % INPUT
0010 %   Mobj     = Mesh object
0011 %   filename = FVCOM coriolis file name
0012 %
0013 % OUTPUT:
0014 %    FVCOM coriolis file: filename
0015 %
0016 % EXAMPLE USAGE
0017 %    write_FVCOM_cor(Mobj, 'tst_cor.dat')
0018 %
0019 % Author(s):
0020 %    Geoff Cowles (University of Massachusetts Dartmouth)
0021 %    Rory O'Hara Murray (Marine Scotland Science)
0022 %    Pierre Cazenave (Plymouth Marine Laboratory)
0023 %
0024 % Revision history
0025 %    2014-10-07 Removed loops to speed up writing the file
0026 %    2016-08-08 Remove tabs and clean up syntax.
0027 %
0028 %==============================================================================
0029 
0030 [~, subname] = fileparts(mfilename('fullpath'));
0031 global ftbverbose
0032 if ftbverbose
0033     fprintf('\nbegin : %s\n', subname);
0034 end
0035 
0036 %------------------------------------------------------------------------------
0037 % Parse input arguments
0038 %------------------------------------------------------------------------------
0039 if exist('Mobj')*exist('filename') == 0
0040     error('arguments to write_FVCOM_cor are incorrect')
0041 end
0042 
0043 %------------------------------------------------------------------------------
0044 % Dump the file
0045 %------------------------------------------------------------------------------
0046 if lower(Mobj.nativeCoords(1:3)) == 'car'
0047     x = Mobj.x;
0048     y = Mobj.y;
0049 else
0050     x = Mobj.lon;
0051     y = Mobj.lat;
0052 end
0053 
0054 if Mobj.have_cor
0055     if(ftbverbose); fprintf('writing FVCOM coriolis file %s\n',filename); end;
0056     fid = fopen(filename,'w');
0057     fprintf(fid,'Node Number = %d\n',Mobj.nVerts);
0058     fprintf(fid, '%f %f %f\n', [x, y, Mobj.f]');
0059     fclose(fid);
0060 else
0061     error('can''t write coriolis to file, coriolis is not setup, see add_coriolis')
0062 end
0063 
0064 if ftbverbose
0065     fprintf('end   : %s\n', subname)
0066 end
0067 
0068

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005