function writeWW3Shell(inpfile,tstart,toutstart,tstop,dt,trststart,trststop,dtrst,rid,x,y)

tstart=datestr(tstart,'yyyymmdd HHMMSS');
toutstart=datestr(toutstart,'yyyymmdd HHMMSS');
tstop=datestr(tstop,'yyyymmdd HHMMSS');
trststart=datestr(trststart,'yyyymmdd HHMMSS');
trststop=datestr(trststop,'yyyymmdd HHMMSS');

dt=num2str(dt);
dtrst=num2str(dtrst);

fid=fopen(inpfile,'wt');

fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');
fprintf(fid,'%s\n','$ WAVEWATCH III shell input file                                       $');
fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');
fprintf(fid,'%s\n','$ Define input to be used with flag for use and flag for definition');
fprintf(fid,'%s\n','$ as a homogeneous field (first three only); seven input lines.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','   F F     Water levels');
fprintf(fid,'%s\n','   F F     Currents');
fprintf(fid,'%s\n','   T F     Winds');
fprintf(fid,'%s\n','   F       Ice concentrations');
fprintf(fid,'%s\n','   F       Assimilation data : Mean parameters');
fprintf(fid,'%s\n','   F       Assimilation data : 1-D spectra');
fprintf(fid,'%s\n','   F       Assimilation data : 2-D spectra.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Time frame of calculations ----------------------------------------- $');
fprintf(fid,'%s\n','$ - Starting time in yyyymmdd hhmmss format.');
fprintf(fid,'%s\n','$ - Ending time in yyyymmdd hhmmss format.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' tstart]);
fprintf(fid,'%s\n',['   ' tstop]);
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Define output data ------------------------------------------------- $');
fprintf(fid,'%s\n','$ ');
fprintf(fid,'%s\n','$ Define output server mode. This is used only in the parallel version');
fprintf(fid,'%s\n','$ of the model. To keep the input file consistent, it is always needed.');
fprintf(fid,'%s\n','$ IOSTYP = 1 is generally recommended. IOSTYP > 2 may be more efficient');
fprintf(fid,'%s\n','$ for massively parallel computations. Only IOSTYP = 0 requires a true');
fprintf(fid,'%s\n','$ parallel file system like GPFS.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ IOSTYP = 0 : No data server processes, direct access output from');
fprintf(fid,'%s\n','$ each process (requirese true parallel file system).');
fprintf(fid,'%s\n','$ 1 : No data server process. All output for each type');
fprintf(fid,'%s\n','$ performed by process that performes computations too.');
fprintf(fid,'%s\n','$ 2 : Last process is reserved for all output, and does no');
fprintf(fid,'%s\n','$ computing.');
fprintf(fid,'%s\n','$ 3 : Multiple dedicated output processes.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','   0');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Five output types are available (see below). All output types share');
fprintf(fid,'%s\n','$ a similar format for the first input line:');
fprintf(fid,'%s\n','$ - first time in yyyymmdd hhmmss format, output interval (s), and ');
fprintf(fid,'%s\n','$   last time in yyyymmdd hhmmss format (all integers).');
fprintf(fid,'%s\n','$ Output is disabled by setting the output interval to 0.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Type 1 : Fields of mean wave parameters');
fprintf(fid,'%s\n','$          Standard line and line with flags to activate output fields');
fprintf(fid,'%s\n','$          as defined in section 2.4 of the manual. The second line is');
fprintf(fid,'%s\n','$          not supplied if no output is requested.');
fprintf(fid,'%s\n','$                               The raw data file is out_grd.ww3, ');
fprintf(fid,'%s\n','$                               see w3iogo.ftn for additional doc.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' toutstart '   ' dt '  ' tstop]);
fprintf(fid,'%s\n','     F F T F F  T F F F F  T T F F F  F F F F F  F F F F F  F F F F F   F');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Type 2 : Point output');
fprintf(fid,'%s\n','$          Standard line and a number of lines identifying the ');
fprintf(fid,'%s\n','$          longitude, latitude and name (C*10) of output points.');
fprintf(fid,'%s\n','$          The list is closed by defining a point with the name');
fprintf(fid,'%s\n','$          ''STOPSTRING''. No point info read if no point output is');
fprintf(fid,'%s\n','$          requested (i.e., no ''STOPSTRING'' needed).');
fprintf(fid,'%s\n','$          Example for spherical grid.');
fprintf(fid,'%s\n','$                               The raw data file is out_pnt.ww3, ');
fprintf(fid,'%s\n','$                               see w3iogo.ftn for additional doc.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$   NOTE : Spaces may be included in the name, but this is not');
fprintf(fid,'%s\n','$          advised, because it will break the GrADS utility to ');
fprintf(fid,'%s\n','$          plots spectra and source terms, and will make it more');
fprintf(fid,'%s\n','$          diffucult to use point names in data files.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' tstart '   ' dt '  ' tstop]);
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$');
for i=1:length(rid)
    for j=1:length(x{i})
        r=['''' rid{i} num2str(j,'%0.3i') ''''];
        fprintf(fid,'%s\n',['     ' num2str(x{i}(j),'%12.5f') ' ' num2str(y{i}(j),'%12.5f') ' ' r]);
    end
end
fprintf(fid,'%s\n','     0.0   0.0  ''STOPSTRING'' ');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Type 3 : Output along  track.');
fprintf(fid,'%s\n','$          Flag for formatted input file.');
fprintf(fid,'%s\n','$                         The data files are track_i.ww3 and');
fprintf(fid,'%s\n','$                         track_o.ww3, see w3iotr.ftn for ad. doc.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' tstart '   0  ' tstop]);
fprintf(fid,'%s\n','$     F');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Type 4 : Restart files (no additional data required).');
fprintf(fid,'%s\n','$                               The data file is restartN.ww3, see');
fprintf(fid,'%s\n','$                               w3iors.ftn for additional doc.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' trststart '   ' dtrst '  ' trststop]);
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Type 5 : Boundary data (no additional data required).');
fprintf(fid,'%s\n','$                               The data file is nestN.ww3, see');
fprintf(fid,'%s\n','$                               w3iobp.ftn for additional doc.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' tstart '   ' dt '  ' tstop]);
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Type 6 : Separated wave field data (dummy for now).');
fprintf(fid,'%s\n','$          First, last step IX and IY, flag for formatted file');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ' toutstart '   0  ' tstop]);
fprintf(fid,'%s\n','      0 999 1 0 999 1 T');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Testing of output through parameter list (C/TPAR) ------------------ $');
fprintf(fid,'%s\n','$    Time for output and field flags as in above output type 1.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$  19680606 014500');
fprintf(fid,'%s\n','$    T T T T T  T T T T T  T T T T T  T');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Homogeneous field data --------------------------------------------- $');
fprintf(fid,'%s\n','$ Homogeneous fields can be defined by a list of lines containing an ID');
fprintf(fid,'%s\n','$ string ''LEV'' ''CUR'' ''WND'', date and time information (yyyymmdd');
fprintf(fid,'%s\n','$ hhmmss), value (S.I. units), direction (current and wind, oceanographic');
fprintf(fid,'%s\n','$ convention degrees)) and air-sea temparature difference (degrees C).');
fprintf(fid,'%s\n','$ ''STP'' is mandatory stop string.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$   ''WND'' 19680606 000000    10.0    20.0    20.0');
fprintf(fid,'%s\n','$   ''LEV'' 19680606 000000    0.0');
fprintf(fid,'%s\n','$   ''CUR'' 19680606 000000    0.0    0.0');
fprintf(fid,'%s\n','   ''STP''');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');
fprintf(fid,'%s\n','$ End of input file                                                    $');
fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');

fclose(fid);
