libsim  Versione 7.2.6

◆ get_package_filepath()

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

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 363 del file file_utilities.F90.

364 TYPE(csv_record),INTENT(INOUT) :: this
365 CHARACTER(len=*),INTENT(IN) :: field
366 LOGICAL, INTENT(in), OPTIONAL :: force_quote
367 
368 INTEGER :: i
369 LOGICAL :: lquote
370 
371 lquote = optio_log(force_quote)
372 IF (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
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 ! 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)
389 ELSE ! 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
397 ENDIF
398 
399 this%nfield = this%nfield + 1
400 
401 CONTAINS
402 
403 ! add a character, doubling it if it's a quote
404 SUBROUTINE add_char(char)
405 CHARACTER(len=1) :: char
406 
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 ! double the quote
410  this%cursor = this%cursor+1
411  this%record(this%cursor) = this%cquote
412 ENDIF
413 
414 END SUBROUTINE add_char
415 
416 END SUBROUTINE csv_record_addfield_char
417 
418 
419 ! Reallocate record if necessary
420 SUBROUTINE checkrealloc(this, enlarge)
421 TYPE(csv_record),INTENT(INOUT) :: this
422 INTEGER, INTENT(in) :: enlarge
423 
424 INTEGER(KIND=int_b), POINTER :: tmpptr(:)
425 
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
431 ENDIF
432 
433 END SUBROUTINE checkrealloc
434 
435 
436 ! add a byte
437 SUBROUTINE add_byte(this, char)
438 TYPE(csv_record),INTENT(INOUT) :: this
439 INTEGER(kind=int_b) :: char
440 
441 this%cursor = this%cursor+1
442 this%record(this%cursor) = char
443 
444 END SUBROUTINE add_byte
445 
446 
Index method.

Generated with Doxygen.