[UP]


Manual Reference Pages  - add (3)

NAME

add(3f) - [M_list] insert entry into an allocatable sorted string array if it is not present

CONTENTS

Synopsis
Description
Options
Examples

SYNOPSIS

subroutine add(varname,dictionary)

character(len=*),intent=(in) :: VARNAME character(len=*),allocatable :: DICTIONARY(:)

DESCRIPTION

Find if a string is in a sorted array, and insert the string into the dictionary if it is not present.

OPTIONS

VARNAME
  the string value to place in the array.
DICTIONARY
  is the dictionary array. It must be sorted in descending order.

EXAMPLES

If string is not found in a sorted array, insert the string

    program demo_add
    use M_sort, only : sort_shell
    use M_list, only : add
    implicit none
    character(len=20),allocatable :: arr(:)
    integer                       :: i

arr=[character(len=20) :: ’ZZZ’, ’aaa’, ’b’, ’xxx’ ] ! make sure sorted in descending order call sort_shell(arr,order=’d’)

write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’b’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’^’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’ ’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’c’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’ZZ’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’ZZZZ’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array call add(’z’, arr); write(*,101)(trim(arr(i)),i=1,size(arr)) ! show array 101 format (1x,*("[",a,"]",:,",")) end program demo_add

Results:

    [xxx],[b],[aaa],[ZZZ]
    [xxx],[b],[aaa],[ZZZ]
    [xxx],[b],[aaa],[^],[ZZZ]
    [xxx],[b],[aaa],[^],[ZZZ],[]
    [xxx],[c],[b],[aaa],[^],[ZZZ],[]
    [xxx],[c],[b],[aaa],[^],[ZZZ],[ZZ],[]
    [xxx],[c],[b],[aaa],[^],[ZZZZ],[ZZZ],[ZZ],[]
    [z],[xxx],[c],[b],[aaa],[^],[ZZZZ],[ZZZ],[ZZ],[]


add (3) June 16, 2019
Generated by manServer 1.08 from 53f0f42f-eafc-4216-90b2-276208cbd5e5 using man macros.