libsim Versione 7.1.11
|
◆ get_package_filepath()
Looks for a specific file for the libsim package. It searches in different directories in the following order:
Definizione alla linea 359 del file file_utilities.F90. 360
363SUBROUTINE csv_record_addfield_char(this, field, force_quote)
364TYPE(csv_record),INTENT(INOUT) :: this
365CHARACTER(len=*),INTENT(IN) :: field
366LOGICAL, INTENT(in), OPTIONAL :: force_quote
367
368INTEGER :: i
369LOGICAL :: lquote
370
371lquote = optio_log(force_quote)
372IF (len(field) == 0) THEN ! Particular case to be handled separately
373 CALL checkrealloc(this, 1)
374 IF (this%nfield > 0) THEN
375 CALL add_byte(this, this%csep) ! add separator if necessary
376 ELSE
377 CALL add_byte(this, this%cquote) ! if first record is empty it should be quoted
378 CALL add_byte(this, this%cquote) ! in case it is the only one
379 ENDIF
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 ! quote not required
385 CALL checkrealloc(this, len(field)+1)
386 IF (this%nfield > 0) CALL add_byte(this, this%csep) ! add separator if necessary
387 this%record(this%cursor+1:this%cursor+len(field)) = transfer(field, this%record)
388 this%cursor = this%cursor + len(field)
389ELSE ! quote required
390 CALL checkrealloc(this, 2*len(field)+3) ! worst case """""""""
391 IF (this%nfield > 0) CALL add_byte(this, this%csep) ! add separator if necessary
392 CALL add_byte(this, this%cquote) ! add quote
393 DO i = 1, len(field)
394 CALL add_char(field(i:i))
395 ENDDO
396 CALL add_byte(this, this%cquote) ! add quote
397ENDIF
398
399this%nfield = this%nfield + 1
400
401CONTAINS
402
403! add a character, doubling it if it's a quote
404SUBROUTINE add_char(char)
405CHARACTER(len=1) :: char
406
407this%cursor = this%cursor+1
408this%record(this%cursor) = transfer(char, this%record(1))
409IF (this%record(this%cursor) == this%cquote) THEN ! double the quote
410 this%cursor = this%cursor+1
411 this%record(this%cursor) = this%cquote
412ENDIF
413
414END SUBROUTINE add_char
415
416END SUBROUTINE csv_record_addfield_char
417
418
419! Reallocate record if necessary
420SUBROUTINE checkrealloc(this, enlarge)
421TYPE(csv_record),INTENT(INOUT) :: this
422INTEGER, INTENT(in) :: enlarge
423
424INTEGER(KIND=int_b), POINTER :: tmpptr(:)
425
426IF (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
431ENDIF
432
433END SUBROUTINE checkrealloc
434
435
436! add a byte
437SUBROUTINE add_byte(this, char)
438TYPE(csv_record),INTENT(INOUT) :: this
439INTEGER(kind=int_b) :: char
440
441this%cursor = this%cursor+1
442this%record(this%cursor) = char
443
444END SUBROUTINE add_byte
445
|