psmile_char2buf.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: PSMILe_Char2buf
00008 !
00009 ! !INTERFACE:
00010 !
00011       subroutine psmile_char2buf (ilubuf, ndibuf, ipos, string)
00012 !
00013 ! !USES:
00014 !
00015       use psmile_common, dummy_interface => PSMILe_Char2buf
00016 
00017       implicit none
00018 !
00019 ! !INPUT PARAMETERS:
00020 !
00021       character (len=*), Intent(in) :: string
00022 
00023 !     Character string, to be written to buffer.
00024 
00025       integer, Intent(in)           :: ndibuf
00026 
00027 !     Dimension of buffer 'ILUBUF'.
00028 
00029 !
00030 ! !INPUT/OUTPUT PARAMETERS:
00031 !
00032       integer, Intent(inout)        :: ipos
00033 
00034 !     Pointer to the last used index in 'ILUBUF'
00035 !     Length of 'ILUBUF' currently used.
00036 
00037       integer, Intent(inout)        :: ilubuf (ndibuf)
00038 
00039 !     Integer buffer.
00040 !
00041 ! !LOCAL VARIABLES
00042 !
00043       character (len=12)      :: form
00044       integer                 :: i, ilen, irest, lav, lenstr
00045 !
00046 ! !DESCRIPTION:
00047 !
00048 !  Write Character String to Buffer
00049 !
00050 !  Subroutine "PSMILe_Char2buf" writes the character string 'STRING'
00051 !  to buffer 'ILUBUF(IPOS+1:)' and 'IPOS' is updated to point to the
00052 !  last index used in buffer 'ILUBUF'.
00053 !
00054 !  If character string 'STRING' is too long to be stored entirely in
00055 !  the buffer, the storable length is stored in vector 'ILUBUF' and
00056 !  'IPOS' points to the last or first index which corresponds to
00057 !  the index in 'ILUBUF' necessary to store the string entirely.
00058 !
00059 ! !REVISION HISTORY:
00060 !
00061 !   Date      Programmer   Description
00062 ! ----------  ----------   -----------
00063 ! 01.12.03    H. Ritzdorf  created
00064 !
00065 !EOP
00066 !-----------------------------------------------------------------------
00067 !
00068 !  $Id: psmile_char2buf.F90 2325 2010-04-21 15:00:07Z valcke $
00069 !  $Autor$
00070 
00071    Character(len=len_cvs_string), save :: mycvs = 
00072        '$Id: psmile_char2buf.F90 2325 2010-04-21 15:00:07Z valcke $'
00073 !
00074 !-----------------------------------------------------------------------
00075 !
00076 !===> Initialization
00077 !
00078       lenstr = len (string)
00079       ilen = (lenstr-1) / length_of_integer
00080 !
00081       lav = ndibuf - ipos
00082 !
00083 !===> Create format ``form''
00084 !
00085       irest = lenstr - ilen*length_of_integer
00086 !
00087       if (ilen .gt. 0) then
00088          write (form, 9990) ilen, length_of_integer, irest
00089       else
00090          write (form, 9980) irest
00091       endif
00092 !
00093 !===> Write to buffer ``ilubuf''
00094 !
00095       read (string, form) (ilubuf(ipos+i), i= 1, min (ilen+1, lav))
00096 !
00097       ipos = ipos + (ilen+1)
00098 !
00099       return
00100 !
00101 !  Formats:
00102 !
00103 9990  format ('(', i4, 'a', i1, ', a', i1, ')')
00104 9980  format ('(a', i1, ')')
00105       end

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1