conversions.f90 1.28 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
2
3
4
5
6
7
8
9
10
11
12
13
!
! Copyright (C) 2015-2019 M. Govoni 
! This file is distributed under the terms of the
! GNU General Public License. See the file `LICENSE'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! This file is part of WEST.
!
! Contributors to this file: 
! Marco Govoni
!
!-----------------------------------------------------------------------
Marco Govoni's avatar
Marco Govoni committed
14
MODULE conversions 
Marco Govoni's avatar
Marco Govoni committed
15
   !-----------------------------------------------------------------------
Marco Govoni's avatar
Marco Govoni committed
16
17
18
19
20
   USE kinds, ONLY : DP
   IMPLICIT NONE 
   CONTAINS
    !
    FUNCTION ltoa(l) RESULT(res)
Victor Yu's avatar
Victor Yu committed
21
       IMPLICIT NONE
Marco Govoni's avatar
Marco Govoni committed
22
23
24
25
26
27
28
29
30
31
32
33
       CHARACTER(:),ALLOCATABLE :: res
       LOGICAL,INTENT(IN) :: l
       CHARACTER(4) :: t="true"
       CHARACTER(5) :: f="false"
       IF( l ) THEN 
          res = t
       ELSE 
          res =f 
       ENDIF
    END FUNCTION
    !
    FUNCTION itoa(i) RESULT(res)
Victor Yu's avatar
Victor Yu committed
34
       IMPLICIT NONE
Marco Govoni's avatar
Marco Govoni committed
35
36
37
38
39
40
41
42
       CHARACTER(:),ALLOCATABLE :: res
       INTEGER,INTENT(IN) :: i
       CHARACTER(RANGE(i)+2) :: tmp
       WRITE(tmp,'(I0)') i
       res = TRIM(tmp)
    END FUNCTION
    !
    FUNCTION dtoa(d) RESULT(res)
Victor Yu's avatar
Victor Yu committed
43
       IMPLICIT NONE
Marco Govoni's avatar
Marco Govoni committed
44
45
46
47
48
49
50
       CHARACTER(:),ALLOCATABLE :: res
       REAL(DP),INTENT(IN) :: d
       CHARACTER(14) :: tmp
       WRITE(tmp,'(ES14.6)') d
       res = TRIM(tmp)
    END FUNCTION
END MODULE