source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/lib/mct/mpeu/m_chars.F90 @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 4 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

File size: 2.8 KB
Line 
1!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
3!-----------------------------------------------------------------------
4! CVS m_chars.F90,v 1.3 2004-04-21 22:54:46 jacob Exp
5! CVS MCT_2_8_0 
6!-----------------------------------------------------------------------
7!BOP
8!
9! !MODULE: m_chars - a module for character class object operations
10!
11! !DESCRIPTION:
12!
13! !INTERFACE:
14
15        module m_chars
16        implicit none
17        private
18
19        public  :: operator (.upper.)   ! convert a string to uppercase
20        public  :: uppercase
21
22        public  :: operator (.lower.)   ! convert a string to lowercase
23        public  :: lowercase
24
25        interface operator (.upper.)
26          module procedure upper_case
27        end interface
28        interface uppercase
29          module procedure upper_case
30        end interface
31
32        interface operator (.lower.)
33          module procedure lower_case
34        end interface
35        interface lowercase
36          module procedure lower_case
37        end interface
38
39! !REVISION HISTORY:
40!       16Jul96 - J. Guo        - (to do)
41!EOP
42!_______________________________________________________________________
43  character(len=*),parameter :: myname='MCT(MPEU)::m_chars'
44
45contains
46!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
48!-----------------------------------------------------------------------
49!BOP
50!
51! !IROUTINE: upper_case - convert lowercase letters to uppercase.
52!
53! !DESCRIPTION:
54!
55! !INTERFACE:
56
57  function upper_case(str) result(ustr)
58    implicit none
59  character(len=*), intent(in) :: str
60  character(len=len(str))      :: ustr
61
62! !REVISION HISTORY:
63!       13Aug96 - J. Guo        - (to do)
64!EOP
65!_______________________________________________________________________
66    integer i
67    integer,parameter :: il2u=ichar('A')-ichar('a')
68
69    ustr=str
70    do i=1,len_trim(str)
71      if(str(i:i).ge.'a'.and.str(i:i).le.'z')   &
72        ustr(i:i)=char(ichar(str(i:i))+il2u)
73    end do
74  end function upper_case
75
76!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
78!-----------------------------------------------------------------------
79!BOP
80!
81! !IROUTINE: lower_case - convert uppercase letters to lowercase.
82!
83! !DESCRIPTION:
84!
85! !INTERFACE:
86
87  function lower_case(str) result(lstr)
88    implicit none
89    character(len=*), intent(in) :: str
90    character(len=len(str))      :: lstr
91
92! !REVISION HISTORY:
93!       13Aug96 - J. Guo        - (to do)
94!EOP
95!_______________________________________________________________________
96    integer i
97    integer,parameter :: iu2l=ichar('a')-ichar('A')
98
99    lstr=str
100    do i=1,len_trim(str)
101      if(str(i:i).ge.'A'.and.str(i:i).le.'Z')   &
102        lstr(i:i)=char(ichar(str(i:i))+iu2l)
103    end do
104  end function lower_case
105
106end module m_chars
107!.
Note: See TracBrowser for help on using the repository browser.