libsim Versione 7.2.1

◆ get_package_filepath()

character(len=512) function get_package_filepath ( character(len=*), intent(in)  filename,
integer, intent(in)  filetype 
)
private

Looks for a specific file for the libsim package.

It searches in different directories in the following order:

  • current working directory
  • directory specified by the environmental variabile LIBSIM_DATA for data files or LIBSIM_CONFIG for configuration files, if defined
  • directory /usr/local/share/libsim for data files or /usr/local/etc/libsim for configuration files
  • directory /usr/share/libsim for data files or /etc/libsim for configuration files. filename prefixed by "cwd:" or "share:" force search in current working directory or other package paths respectively default is everywhere for data files and package paths only for config files It returns the full path to the existing file or an empty string if not found.
    Parametri
    [in]filenamename of the file to be searched, it must be a relative path name
    [in]filetypetype of file, the constants filetype_data or filetype_config have to be used

Definizione alla linea 353 del file file_utilities.F90.

354this%cursor = 0
355this%nfield = 0
356
357END SUBROUTINE csv_record_rewind
358
359
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
380ELSE 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 ! 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
Index method.

Generated with Doxygen.