function OUT = swan_shortname2keyword(IN)
%SWAN_SHORTNAME2KEYWORD   get SWAN SWAN code (OVKEYW) from associated short name (OVSNAM)
%
% OUT = swan_shortname2keyword(IN) finds short name equivalents of SWAN 
%                               output parameters based on 1st characters
%                               via conversion table.
%
% 1) Case-insensitive to input name, output name is UPPER CASE.
% 2) If name is not in table, input name is returned
% 3) In can be a cell array, output is a cell array.
%
%See also: SWAN_IO_SPECTRUM, SWAN_IO_INPUT, SWAN_IO_TABLE, SWAN_IO_GRD, SWAN_IO_BOT, 
%          SWAN_QUANTITY, SWAN_DEFAULTS,
%          SWAN_KEYWORD2SHORTNAME, SWAN_KEYWORD2LONGNAME, SWAN_KEYWORD2TEXNAME, 

%   --------------------------------------------------------------------
%   Copyright (C) 2006 Deltares
%       Gerben de Boer
%
%       gerben.deboer@deltares.nl	
%
%       Deltares
%       P.O. Box 177
%       2600 MH Delft
%       The Netherlands
%
%   This library is free software: you can redistribute it and/or
%   modify it under the terms of the GNU Lesser General Public
%   License as published by the Free Software Foundation, either
%   version 2.1 of the License, or (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%   Lesser General Public License for more details.
%
%   You should have received a copy of the GNU Lesser General Public
%   License along with this library. If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$

%% 2009 mar 13 renamed this function from SWAN_NAME2SHORTNAME to SWAN_SHORTNAME2KEYWORD [Gerben de Boer]
%%             added links to new SWAN_KEYWORD2* [Gerben de Boer]

%% to do: use table in swan_quantity to make conversion

if ischar(IN)
   IN = cellstr(IN);
end

for iname = 1:length(IN)

   longname = pad(IN{iname},6,' '); % make sure it's long enought to adress longname(1:6) BELOW
   
   if strcmpi(longname(1:4),'hswe'  ); OUT{iname}  = 'HSWE'  ;elseif ... % before HS !!!
      strcmpi(longname(1:2),'hs'    ); OUT{iname}  = 'HS'    ;elseif ...
                                                                     ...     
      strcmpi(longname(1:3),'dir'   ); OUT{iname}  = 'DIR'   ;elseif ...
      strcmpi(longname(1:4),'pdir'  ); OUT{iname}  = 'PDIR'  ;elseif ...
      strcmpi(longname(1:4),'tdir'  ); OUT{iname}  = 'TDIR'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:4),'tm01'  ); OUT{iname}  = 'TM01'  ;elseif ...
      strcmpi(longname(1:5),'rtm01' ); OUT{iname}  = 'RTM01' ;elseif ...
      strcmpi(longname(1:3),'rtp'   ); OUT{iname}  = 'RTP'   ;elseif ...
      strcmpi(longname(1:3),'per'   ); OUT{iname}  = 'PER'   ;elseif ...
      strcmpi(longname(1:4),'rper'  ); OUT{iname}  = 'RPER'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:4),'tm01'  ); OUT{iname}  = 'TM01'  ;elseif ...
      strcmpi(longname(1:5),'rtm01' ); OUT{iname}  = 'RTM01' ;elseif ...
      strcmpi(longname(1:3),'rtp'   ); OUT{iname}  = 'RTP'   ;elseif ...
      strcmpi(longname(1:3),'tps'   ); OUT{iname}  = 'TPS'   ;elseif ...
      strcmpi(longname(1:3),'per'   ); OUT{iname}  = 'PER'   ;elseif ...
      strcmpi(longname(1:4),'rper'  ); OUT{iname}  = 'RPER'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:5),'tmm01' ); OUT{iname}  = 'TMM01' ;elseif ...
      strcmpi(longname(1:6),'rtmm01'); OUT{iname}  = 'RTMM01';elseif ...
      strcmpi(longname(1:4),'tm02'  ); OUT{iname}  = 'TM02'  ;elseif ...
      strcmpi(longname(1:4),'fspr'  ); OUT{iname}  = 'FSPR'  ;elseif ...
      strcmpi(longname(1:4),'dspr'  ); OUT{iname}  = 'DSPR'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:2),'qp'    ); OUT{iname}  = 'QP'    ;elseif ...
      strcmpi(longname(1:3),'dep'   ); OUT{iname}  = 'DEP'   ;elseif ...
      strcmpi(longname(1:4),'watl'  ); OUT{iname}  = 'WATL'  ;elseif ...
      strcmpi(longname(1:4),'botl'  ); OUT{iname}  = 'BOTL'  ;elseif ...
      strcmpi(longname(1:3),'vel'   ); OUT{iname}  = 'VEL'   ;elseif ...
      strcmpi(longname(1:3),'frc'   ); OUT{iname}  = 'FRC'   ;elseif ...
      strcmpi(longname(1:4),'wind'  ); OUT{iname}  = 'WIND'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:5),'propa' ); OUT{iname}  = 'PROPA' ;elseif ...
      strcmpi(longname(1:6),'propxy'); OUT{iname}  = 'PROPX' ;elseif ...
      strcmpi(longname(1:5),'PROPT' ); OUT{iname}  = 'PROPT' ;elseif ...
      strcmpi(longname(1:5),'PROPS' ); OUT{iname}  = 'PROPS' ;elseif ...
      strcmpi(longname(1:4),'GENE'  ); OUT{iname}  = 'GENE'  ;elseif ...
      strcmpi(longname(1:4),'GENW'  ); OUT{iname}  = 'GENW'  ;elseif ...
      strcmpi(longname(1:4),'REDI'  ); OUT{iname}  = 'REDI'  ;elseif ...
      strcmpi(longname(1:4),'REDQ'  ); OUT{iname}  = 'REDQ'  ;elseif ...
      strcmpi(longname(1:4),'REDT'  ); OUT{iname}  = 'REDT'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:4),'mudl'  ); OUT{iname}  = 'MUDL'  ;elseif ... % mud special
      strcmpi(longname(1:6),'wlenmr'); OUT{iname}  = 'WLENMR';elseif ... % before WLEN !!!
      strcmpi(longname(1:6),'wlenmi'); OUT{iname}  = 'WLENMI';elseif ... % before WLEN !!!
      strcmpi(longname(1:6),'ki'    ); OUT{iname}  = 'KI'    ;elseif ... % before WLEN !!!
                                                                     ...     
      strcmpi(longname(1:4),'wlen'  ); OUT{iname}  = 'WLEN'  ;elseif ...
      strcmpi(longname(1:5),'steep' ); OUT{iname}  = 'STEEP' ;elseif ...
      strcmpi(longname(1:3),'dhs'   ); OUT{iname}  = 'DHS'   ;elseif ...
      strcmpi(longname(1:6),'drtm01'); OUT{iname}  = 'DRTM01';elseif ...
      strcmpi(longname(1:4),'leak'  ); OUT{iname}  = 'LEAK'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:2),'xp'    ); OUT{iname}  = 'XP'    ;elseif ...
      strcmpi(longname(1:2),'yp'    ); OUT{iname}  = 'YP'    ;elseif ...
      strcmpi(longname(1:4),'dist'  ); OUT{iname}  = 'DIST'  ;elseif ...
      strcmpi(longname(1:5),'setup' ); OUT{iname}  = 'SETUP' ;elseif ...
                                                                     ...     
      strcmpi(longname(1:5),'dissu' ); OUT{iname}  = 'DISSU' ;elseif ... % before DISS !!!
      strcmpi(longname(1:4),'diss'  ); OUT{iname}  = 'DISS'  ;elseif ...
      strcmpi(longname(1:4),'disb'  ); OUT{iname}  = 'DISB'  ;elseif ...
      strcmpi(longname(1:4),'disw'  ); OUT{iname}  = 'DISW'  ;elseif ...
      strcmpi(longname(1:4),'disv'  ); OUT{iname}  = 'DISV'  ;elseif ...
      strcmpi(longname(1:4),'dism'  ); OUT{iname}  = 'DISM'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:2),'qb'    ); OUT{iname}  = 'QB'    ;elseif ...
      strcmpi(longname(1:3),'tra'   ); OUT{iname}  = 'TRA'   ;elseif ...
      strcmpi(longname(1:3),'for'   ); OUT{iname}  = 'FOR'   ;elseif ...
      strcmpi(longname(1:4),'ubot'  ); OUT{iname}  = 'UBOT'  ;elseif ...
      strcmpi(longname(1:4),'urms'  ); OUT{iname}  = 'URMS'  ;elseif ...
                                                                     ...     
      strcmpi(longname(1:5),'TMBOT' ); OUT{iname}  = 'TMBOT' ;elseif ...
      strcmpi(longname(1:4),'WLEN'  ); OUT{iname}  = 'WLEN'  ;elseif ...
      strcmpi(longname(1:5),'LWAVP' ); OUT{iname}  = 'LWAVP' ;elseif ...
      strcmpi(longname(1:4),'STEE'  ); OUT{iname}  = 'STEE'  ;elseif ...
      strcmpi(longname(1:3),'BFI'   ); OUT{iname}  = 'BFI'   ;elseif ...
      strcmpi(longname(1:3),'NPL'   ); OUT{iname}  = 'NPL'   ;elseif ...
      strcmpi(longname(1:3),'DHS'   ); OUT{iname}  = 'DHS'   ;elseif ...
      strcmpi(longname(1:5),'DRTM01'); OUT{iname}  = 'DRTM01';elseif ...
      strcmpi(longname(1:4),'LEAK'  ); OUT{iname}  = 'LEAK'  ;elseif ...
      strcmpi(longname(1:4),'TIME'  ); OUT{iname}  = 'TIME'  ;elseif ...
      strcmpi(longname(1:4),'TSEC'  ); OUT{iname}  = 'TSEC'  ;elseif ...
      strcmpi(longname(1:2),'XP'    ); OUT{iname}  = 'XP'    ;elseif ...
      strcmpi(longname(1:2),'YP'    ); OUT{iname}  = 'YP'    ;elseif ...
      strcmpi(longname(1:4),'DIST'  ); OUT{iname}  = 'DIST'  ;elseif ...
      strcmpi(longname(1:5),'SETUP' ); OUT{iname}  = 'SETUP' ;else   ...
                                                                     ...     

      OUT{iname} = strtrim(longname); % remove whites added by padding to length=6
   
   end

end

%% EOF