function ww3_write_prep_inp(fname,xx,yy,fld)

fid=fopen(fname,'wt');

fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');
fprintf(fid,'%s\n','$ WAVEWATCH III Field preprocessor input file                          $');
fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');
fprintf(fid,'%s\n','$ Mayor types of field and time flag');
fprintf(fid,'%s\n','$   Field types  :  ICE   Ice concentrations.');
fprintf(fid,'%s\n','$                   LEV   Water levels.');
fprintf(fid,'%s\n','$                   WND   Winds.');
fprintf(fid,'%s\n','$                   WNS   Winds (including air-sea temp. dif.)');
fprintf(fid,'%s\n','$                   CUR   Currents.');
fprintf(fid,'%s\n','$                   DAT   Data for assimilation.');
fprintf(fid,'%s\n','$   Format types :  AI    Transfer field "as is".');
fprintf(fid,'%s\n','$                   LL    Field defined on regular longitude-latitude');
fprintf(fid,'%s\n','$                         or Cartesian grid.');
fprintf(fid,'%s\n','$                   F1    Arbitrary grid, longitude and latitude of');
fprintf(fid,'%s\n','$                         each grid point given in separate file.');
fprintf(fid,'%s\n','$                   F2    Like F1, composite of 2 fields.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$   NOTE : Options F1 and F2 have not yet been set up or tested for the');
fprintf(fid,'%s\n','$          Cartesian version of the model.');
fprintf(fid,'%s\n','$        - Format type not used for field type "DAT".');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$   Time flag    : If true, time is included in file.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['   ''' fld ''' ''LL'' T T']);
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Additional time input ---------------------------------------------- $');
fprintf(fid,'%s\n','$ If time flag is .FALSE., give time of field in yyyymmdd hhmmss format.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$   19680606 053000');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Additional input format type "LL" ---------------------------------- $');
fprintf(fid,'%s\n','$ Grid range (degr. or m) and number of points for axes, respectively.');
fprintf(fid,'%s\n','$ Example for longitude-latitude grid.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n',['    ' num2str(xx(1)) ' ' num2str(xx(end)) ' ' num2str(length(xx)) ' ' num2str(yy(1)) ' ' num2str(yy(end)) ' ' num2str(length(yy))]);
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Additional input format type "F1" or "F2" -------------------------- $');
fprintf(fid,'%s\n','$ Three or four additional input lines, to define the file(s) with');
fprintf(fid,'%s\n','$ the grid information :');
fprintf(fid,'%s\n','$ 1) Discrete size of input grid (NXI,NYI).');
fprintf(fid,'%s\n','$ 2) Define type of file using the parameters FROM, IDLA, IDFM (see');
fprintf(fid,'%s\n','$    input for grid preprocessor), and a format');
fprintf(fid,'%s\n','$ 3) Unit number and (dummy) name of first file.');
fprintf(fid,'%s\n','$ 4) Unit number and (dummy) name of second file (F2 only).');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ 15  3                                              ');
fprintf(fid,'%s\n','$ ''UNIT'' 3 1 ''(.L.L.)''');
fprintf(fid,'%s\n','$ 20 ''ll_file.1'' ');
fprintf(fid,'%s\n','$ 10 ''ll_file.2'' ');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Additional input for data ------------------------------------------ $');
fprintf(fid,'%s\n','$ Dimension of data (0,1,2 for mean pars, 1D or 2D spectra), "record');
fprintf(fid,'%s\n','$ length" for data, data value for missing data');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$  0  4  -999.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ Define data files -------------------------------------------------- $');
fprintf(fid,'%s\n','$ The first input line identifies the file format with FROM, IDLA and');
fprintf(fid,'%s\n','$ IDFM, the second (third) lines give the file unit number and name.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','  ''NAME'' 3 1 ''(..T..)'' ''(..F..)'' ');
fprintf(fid,'%s\n','  20 ''ww3.wnd''');
fprintf(fid,'%s\n','$  20 ''data_file.2''');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ If the above unit numbers are 10, data is read from this file');
fprintf(fid,'%s\n','$ (no intermediate comment lines allowed),');
fprintf(fid,'%s\n','$ This example is an ice concentration field.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$   1. 1. 1. 1. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0.');
fprintf(fid,'%s\n','$   1. 1. .5 .5 .5 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.');
fprintf(fid,'%s\n','$   0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.');
fprintf(fid,'%s\n','$   0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ This example is mean parameter assimilation data');
fprintf(fid,'%s\n','$ First record gives number of data records, data are read as as');
fprintf(fid,'%s\n','$ individual records of reals with recored length as given above');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$  3');
fprintf(fid,'%s\n','$ 1.5  1.6 0.70 10.3');
fprintf(fid,'%s\n','$ 1.7  1.5 0.75  9.8');
fprintf(fid,'%s\n','$ 1.9  1.4 0.77 11.1');
fprintf(fid,'%s\n','$');
fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');
fprintf(fid,'%s\n','$ End of input file                                                    $');
fprintf(fid,'%s\n','$ -------------------------------------------------------------------- $');

fclose(fid);
