Looks for a specific file for the libsim package.
364 TYPE(csv_record),
INTENT(INOUT) :: this
365 CHARACTER(len=*),
INTENT(IN) :: field
366 LOGICAL,
INTENT(in),
OPTIONAL :: force_quote
371 lquote = optio_log(force_quote)
372 IF (len(field) == 0)
THEN
373 CALL checkrealloc(this, 1)
374 IF (this%nfield > 0)
THEN
375 CALL add_byte(this, this%csep)
377 CALL add_byte(this, this%cquote)
378 CALL add_byte(this, this%cquote)
380 ELSE IF (
index(field, transfer(this%csep,field(1:1))) == 0 &
381 .AND.
index(field, transfer(this%cquote,field(1:1))) == 0 &
382 .AND. .NOT.is_space_c(field(1:1)) &
383 .AND. .NOT.is_space_c(field(len(field):len(field))) &
384 .AND. .NOT.lquote)
THEN
385 CALL checkrealloc(this, len(field)+1)
386 IF (this%nfield > 0)
CALL add_byte(this, this%csep)
387 this%record(this%cursor+1:this%cursor+len(field)) = transfer(field, this%record)
388 this%cursor = this%cursor + len(field)
390 CALL checkrealloc(this, 2*len(field)+3)
391 IF (this%nfield > 0)
CALL add_byte(this, this%csep)
392 CALL add_byte(this, this%cquote)
394 CALL add_char(field(i:i))
396 CALL add_byte(this, this%cquote)
399 this%nfield = this%nfield + 1
404 SUBROUTINE add_char(char)
405 CHARACTER(len=1) :: char
407 this%cursor = this%cursor+1
408 this%record(this%cursor) = transfer(char, this%record(1))
409 IF (this%record(this%cursor) == this%cquote)
THEN
410 this%cursor = this%cursor+1
411 this%record(this%cursor) = this%cquote
414 END SUBROUTINE add_char
416 END SUBROUTINE csv_record_addfield_char
420 SUBROUTINE checkrealloc(this, enlarge)
421 TYPE(csv_record),
INTENT(INOUT) :: this
422 INTEGER,
INTENT(in) :: enlarge
424 INTEGER(KIND=int_b),
POINTER :: tmpptr(:)
426 IF (this%cursor+enlarge+1 >
SIZE(this%record))
THEN
427 ALLOCATE(tmpptr(
SIZE(this%record)+max(csv_basereclen, enlarge)))
428 tmpptr(1:
SIZE(this%record)) = this%record(:)
429 DEALLOCATE(this%record)
430 this%record => tmpptr
433 END SUBROUTINE checkrealloc
437 SUBROUTINE add_byte(this, char)
438 TYPE(csv_record),
INTENT(INOUT) :: this
439 INTEGER(kind=int_b) :: char
441 this%cursor = this%cursor+1
442 this%record(this%cursor) = char
444 END SUBROUTINE add_byte