ROMS
Loading...
Searching...
No Matches
get_env_mod Module Reference

Data Types

interface  get_env
 

Functions/Subroutines

integer function get_env_i (name, value)
 
integer function get_env_l (name, value)
 
integer function get_env_s (name, value)
 

Function/Subroutine Documentation

◆ get_env_i()

integer function get_env_mod::get_env_i ( character (len=*), intent(in) name,
integer, intent(out) value )

Definition at line 30 of file get_env.F.

31!
32!***********************************************************************
33! !
34! Reads and decodes environmental variable with an integer value. !
35! !
36!***********************************************************************
37!
38! Imported variable declarations.
39!
40 integer, intent(out) :: value
41 character (len=*), intent(in ) :: name
42!
43! Local variable declaration.
44!
45 integer :: Lstr, status
46 character (len=40) :: string
47 character (len=512) :: msg
48!
49!-----------------------------------------------------------------------
50! Read and decode environmental variable. Return "value=-1" if not
51! found.
52!-----------------------------------------------------------------------
53!
54 CALL get_environment_variable (name, string, lstr, status)
55!
56! Convert to integer.
57!
58 IF ((lstr.gt.0).and.(status.eq.0)) THEN
59 READ (string, *, iostat=status, iomsg=msg) value
60 IF (master.and.(status.ne.0)) THEN
61 WRITE (stdout,10) trim(name), trim(string), trim(msg)
62 END IF
63 ELSE
64 status=1
65 value=-1
66 IF (master) THEN
67 WRITE (stdout,20) trim(name)
68 END IF
69 END IF
70!
71 10 FORMAT (/,' GET_ENV_I - Error while converting string to', &
72 & ' integer, name = ',a,', value = ',a,/,13x,'ErrMsg: ',a)
73 20 FORMAT (/,' GET_ENV_I - Cannot find environmental variable', &
74 & ', name = ',a)
75!
76 RETURN

◆ get_env_l()

integer function get_env_mod::get_env_l ( character (len=*), intent(in) name,
logical, intent(out) value )

Definition at line 79 of file get_env.F.

80!
81!***********************************************************************
82! !
83! Reads and decodes environmental variable with an logical value. !
84! !
85!***********************************************************************
86!
87! Imported variable declarations.
88!
89 logical, intent(out) :: value
90 character (len=*), intent(in ) :: name
91!
92! Local variable declaration.
93!
94 integer :: Lstr, status
95 character (len=40) :: string
96!
97!-----------------------------------------------------------------------
98! Read and decode environmental variable. Return value=.FALSE. if not
99! found.
100!-----------------------------------------------------------------------
101!
102 CALL get_environment_variable (name, string, lstr, status)
103!
104! Convert to logical.
105!
106 value=.false.
107!
108 IF ((lstr.gt.0).and.(status.eq.0)) THEN
109 IF ((string(1:1).eq.'0') .or. &
110 & (string(1:1).eq.'F') .or. &
111 & (string(1:1).eq.'f')) THEN
112 value=.false.
113 ELSE
114 value=.true.
115 END IF
116 END IF
117!
118 RETURN

◆ get_env_s()

integer function get_env_mod::get_env_s ( character (len=*), intent(in) name,
character (len=*), intent(out) value )

Definition at line 121 of file get_env.F.

122!
123!***********************************************************************
124! !
125! Reads string environmental variable. !
126! !
127!***********************************************************************
128!
129! Imported variable declarations.
130!
131 character (len=*), intent(in) :: name
132 character (len=*), intent(out) :: value
133!
134! Local variable declaration.
135!
136 integer :: Lstr1, Lstr2, status
137 character (len=1024) :: string
138!
139!-----------------------------------------------------------------------
140! Read environmental variable. Return a blank space, value=CHAR(32),
141! if not found.
142!-----------------------------------------------------------------------
143!
144 CALL get_environment_variable (name, string, lstr1, status)
145!
146! Load string value.
147!
148 lstr2=len(value)
149!
150 IF (lstr1.gt.lstr2) THEN
151 value=string(1:lstr2)
152 IF (master) THEN
153 WRITE (stdout,10) trim(name), trim(string), lstr2, lstr1
154 END IF
155 ELSE
156 value=string(1:lstr1)
157 END IF
158!
159 10 FORMAT (/,' GET_ENV_S - Error while retrieving enviromental ', &
160 & 'variable, name = ',a,/,13x,"string = '",a,"'",/,13x, &
161 & 'value variable length = ',i0, &
162 & ' is less than the required length = ',i0)
163!
164 RETURN