c******************************************************** SUBROUTINE csv_write_char( lun, value, advance ) ! csv_write_char -- ! write a single CHARACTER string to the CSV-file ! Arguments: ! lun LU-number of the CSV-file ! value Value to write ! advance Advance (.true.) or not, so that more items can be ! written to the same record ! Result: ! The value is written to the current record of the CSV-file ! ! write a single CHARACTER string to the CSV-file c Auteurs: T.Guillot, P.Morel (adaptation à CESAM2k) Laboratoire Lagrange, OCA c------------------------------------------------------- USE mod_kind IMPLICIT NONE INTEGER, INTENT(in) :: lun CHARACTER(len=*), INTENT(in) :: value LOGICAL, INTENT(in) :: advance INTEGER :: k, pos, posb CHARACTER(len=2*len(value)) :: buffer c------------------------------------------------------------ buffer = value ! Check for nasty CHARACTERs (") k = index( value,'"') pos = 1 posb = 1 DO WHILE ( k >= 1 ) buffer(posb:) = value(pos:) buffer(posb+k:) = '"' // value(pos+k:) pos = pos + k + 1 posb = posb + k + 2 k = index( value(pos:),'"') ENDDO IF ( advance ) THEN WRITE(lun,'(3a)') '"',trim(buffer),'"' ELSE WRITE(lun,'(3a,a)',advance='no') '"',trim(buffer), '"', ',' ENDIF RETURN END SUBROUTINE csv_WRITE_char