Home > fvcom_prepro > example_FVCOM_wind_ts.m

example_FVCOM_wind_ts

PURPOSE ^

example file for FVCOM, time-varying/spatially constant wind forcing as stress

SYNOPSIS ^

function example_FVCOM_wind_ts

DESCRIPTION ^

 example file for FVCOM, time-varying/spatially constant wind forcing as stress

 function example_FVCOM_wind_ts

 DESCRIPTION:
    Write a time-varying, spatially constant wind file
    This is TEMPLATE program to be used as an example
    Do not commit your user-defined programs to the repository
    It requires USER Modification to work 

 INPUT
   
 OUTPUT:
    NetCDF WindFile

 EXAMPLE USAGE
    example_FVCOM_wind_ts

 Author(s):  
    Geoff Cowles (University of Massachusetts Dartmouth)

 Revision history
   
==============================================================================
warning off

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function example_FVCOM_wind_ts
0002 
0003 % example file for FVCOM, time-varying/spatially constant wind forcing as stress
0004 %
0005 % function example_FVCOM_wind_ts
0006 %
0007 % DESCRIPTION:
0008 %    Write a time-varying, spatially constant wind file
0009 %    This is TEMPLATE program to be used as an example
0010 %    Do not commit your user-defined programs to the repository
0011 %    It requires USER Modification to work
0012 %
0013 % INPUT
0014 %
0015 % OUTPUT:
0016 %    NetCDF WindFile
0017 %
0018 % EXAMPLE USAGE
0019 %    example_FVCOM_wind_ts
0020 %
0021 % Author(s):
0022 %    Geoff Cowles (University of Massachusetts Dartmouth)
0023 %
0024 % Revision history
0025 %
0026 %==============================================================================
0027 %warning off
0028 subname = 'example_FVCOM_wind_ts';
0029 global ftbverbose;
0030 if(ftbverbose);
0031 fprintf('\n')
0032 fprintf(['begin : ' subname '\n'])
0033 end;
0034 
0035 %------------------------------------------------------------------------------
0036 % create a dataset
0037 %------------------------------------------------------------------------------
0038 
0039 % make a timeframe
0040 % tbeg = greg2julian(2009,1,1,0,0,0)-2400000.5;
0041 % tend = greg2julian(2010,1,1,0,0,0)-2400000.5;
0042 tbeg = 0;
0043 tend = 31;
0044 time = tbeg:(1./24.):tend;
0045 nTimes = prod(size(time));
0046 
0047 % make up a fake time varying wind
0048 taux = 0.25*(cos( ((time-time(1))*2*pi)/7)) + .15*(cos( ((time-time(1))*2*pi)/360));
0049 tauy = 0.25*(sin( ((time-time(1))*2*pi)/7)) + .15*(sin( ((time-time(1))*2*pi)/360));
0050 
0051 % plot the wind
0052 subplot(2,1,1)
0053 plot(time-time(1),taux,'k'); 
0054 subplot(2,1,2)
0055 plot(time-time(1),tauy,'r');
0056 
0057 %------------------------------------------------------------------------------
0058 % write output to time-varying, spatially constant FVCOM wind file
0059 %------------------------------------------------------------------------------
0060 fvcom_forcing_file = 'tst_wind.nc'; 
0061 nc = netcdf(fvcom_forcing_file, 'clobber');            
0062 nc.references = 'http://fvcom.smast.umassd.edu'; 
0063 nc.source = 'single-point time-dependent surface forcing'; 
0064 nc.institution = 'School for Marine Science and Technology' ;
0065 nc.history = 'generated using the fvcom-toolbox';
0066 
0067 
0068   
0069 % dimensions
0070 nc('time') = 0;
0071 
0072 % time vars
0073 nc{'time'} = ncfloat('time');
0074 nc{'time'}.long_name = 'time';
0075 nc{'time'}.units = 'days since 1858-11-17 00:00:00';
0076 nc{'time'}.format = 'modified julian day (MJD)';
0077 nc{'time'}.time_zone = 'UTC';
0078   
0079 nc{'Itime'} = ncint('time');
0080 nc{'Itime'}.units = 'days since 1858-11-17 00:00:00';
0081 nc{'Itime'}.format = 'modified julian day (MJD)';
0082 nc{'Itime'}.time_zone = 'UTC';
0083 
0084 nc{'Itime2'} = ncint('time');
0085 nc{'Itime2'}.units = 'msec since 00:00:00';
0086 nc{'Itime2'}.time_zone = 'UTC';
0087 
0088 
0089 nc{'uwind_stress'} = ncfloat('time');
0090 nc{'uwind_stress'}.long_name = 'Eastward Wind Stress'; 
0091 nc{'uwind_stress'}.standard_name = 'Wind Stress'; 
0092 nc{'uwind_stress'}.units = 'Pa';
0093 nc{'uwind_stress'}.type = 'data';
0094 
0095 nc{'vwind_stress'} = ncfloat('time');
0096 nc{'vwind_stress'}.long_name = 'Northward Wind Stress'; 
0097 nc{'vwind_stress'}.standard_name = 'Wind Stress'; 
0098 nc{'vwind_stress'}.units = 'Pa';
0099 nc{'vwind_stress'}.type = 'data';
0100 
0101 % dump time
0102 nc{'time'}(1:nTimes) = time; 
0103 nc{'Itime'}(1:nTimes) = floor(time); 
0104 nc{'Itime2'}(1:nTimes) = mod(time,1)*24*3600*1000.;
0105 
0106 nc{'uwind_stress'}(1:nTimes) = taux; 
0107 nc{'vwind_stress'}(1:nTimes) = tauy; 
0108 
0109 ierr = close(nc);
0110 
0111 if(ftbverbose);
0112 fprintf(['end   : ' subname '\n'])
0113 end;
0114 
0115 
0116

Generated on Thu 19-Mar-2015 12:20:56 by m2html © 2005