Octopus
loct.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch, M. Oliveira
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module loct_oct_m
22
23 implicit none
24
26 private
27 public :: &
28 loct_clock, &
37 loct_mkdir, &
38 loct_stat, &
39 loct_rm, &
49
50 ! ---------------------------------------------------------
52
53 interface loct_strerror
54 subroutine oct_strerror(errno, res)
55 implicit none
56 integer, intent(in) :: errno
57 character(len=*), intent(out) :: res
58 end subroutine oct_strerror
59 end interface loct_strerror
60
61 interface loct_clock
62 function oct_clock()
63 use, intrinsic :: iso_fortran_env
64 implicit none
65 real(real64) :: oct_clock
66 end function oct_clock
67 end interface loct_clock
68
69 interface loct_gettimeofday
70 subroutine oct_gettimeofday(sec, usec)
71 implicit none
72 integer, intent(out) :: sec, usec
73 end subroutine oct_gettimeofday
74 end interface loct_gettimeofday
75
76 interface loct_nanosleep
77 subroutine oct_nanosleep(sec, nsec)
78 implicit none
79 integer, intent(in) :: sec
80 integer, intent(in) :: nsec
81 end subroutine oct_nanosleep
82 end interface loct_nanosleep
83
84 interface loct_sysname
85 subroutine oct_sysname(name)
86 implicit none
87 character(len=*), intent(out) :: name
88 end subroutine oct_sysname
89 end interface loct_sysname
90
91 interface loct_getcwd
92 subroutine oct_getcwd(name)
93 implicit none
94 character(len=*), intent(out) :: name
95 end subroutine oct_getcwd
96 end interface loct_getcwd
97
98 interface loct_realpath
99 subroutine oct_realpath(fnam, rnam)
100 character(len=*), intent(in) :: fnam
101 character(len=*), intent(out) :: rnam
102 end subroutine oct_realpath
103 end interface
104
105 interface loct_dirname
106 subroutine oct_dirname(fnam, dnam)
107 character(len=*), intent(in) :: fnam
108 character(len=*), intent(out) :: dnam
109 end subroutine oct_dirname
110 end interface
111
112 interface loct_basename
113 subroutine oct_basename(fnam, dnam)
114 character(len=*), intent(in) :: fnam
115 character(len=*), intent(out) :: dnam
116 end subroutine oct_basename
117 end interface
118
119
120 ! ---------------------------------------------------------
122 interface loct_mkdir
123 subroutine oct_mkdir(name)
124 implicit none
125 character(len=*), intent(in) :: name
126 end subroutine oct_mkdir
127 end interface loct_mkdir
128
129 interface loct_stat
130 subroutine oct_stat(ierr, name, mod_time)
131 implicit none
132 integer, intent(out) :: ierr
133 character(len=*), intent(in) :: name
134 character(len=*), intent(out) :: mod_time
135 end subroutine oct_stat
136 end interface loct_stat
137
138 interface loct_rm
139 subroutine oct_rm(name)
140 implicit none
141 character(len=*), intent(in) :: name
142 end subroutine oct_rm
143 end interface loct_rm
144
145 interface loct_number_of_lines
146 integer function oct_number_of_lines(filename)
147 implicit none
148 character(len=*), intent(in) :: filename
149 end function oct_number_of_lines
150 end interface loct_number_of_lines
151
152 interface loct_break_c_string
153 subroutine oct_break_c_string(str, s, line)
154 use iso_c_binding
155 implicit none
156 type(c_ptr), intent(in) :: str
157 type(c_ptr), intent(inout) :: s
158 character(len=*), intent(out) :: line
159 end subroutine oct_break_c_string
160 end interface loct_break_c_string
161
162 interface loct_search_file_lr
163 subroutine oct_search_file_lr(freq, tag, ierr, dirname)
164 use, intrinsic :: iso_fortran_env
165 implicit none
166 real(real64), intent(inout) :: freq
167 integer, intent(in) :: tag
168 integer, intent(out) :: ierr
169 character(len=*), intent(in) :: dirname
170 end subroutine oct_search_file_lr
173 ! ---------------------------------------------------------
175 interface loct_getenv
176 subroutine oct_getenv(var, val)
177 implicit none
178 character(len=*), intent(in) :: var
179 character(len=*), intent(out) :: val
180 end subroutine oct_getenv
181 end interface loct_getenv
182
183 interface loct_progress_bar
184 subroutine oct_progress_bar(a, maxcount)
185 implicit none
186 integer, intent(in) :: a, maxcount
187 end subroutine oct_progress_bar
188 end interface loct_progress_bar
189
190 interface loct_printrecipe
191 subroutine oct_printrecipe(dir, filename)
192 implicit none
193 character(len=*), intent(in) :: dir
194 character(len=*), intent(out) :: filename
195 end subroutine oct_printrecipe
196 end interface loct_printrecipe
197
198 interface loct_wfs_list
199 subroutine oct_wfs_list(str, l)
200 implicit none
201 character(len=*), intent(in) :: str
202 integer, intent(out) :: l
203 end subroutine oct_wfs_list
204 end interface loct_wfs_list
205
206 interface loct_get_memory_usage
207 integer(c_intptr_t) function oct_get_memory_usage()
208 use iso_c_binding, only: c_intptr_t
209 implicit none
210 end function oct_get_memory_usage
211 end interface loct_get_memory_usage
212
213contains
214
215 logical function loct_isinstringlist(a, s) result(inlist)
216 integer, intent(in) :: a
217 character(len=*), intent(in) :: s
219 integer, allocatable :: list(:)
220
221 allocate(list(2**14))
222
223 call loct_wfs_list(s, list(1))
224 inlist = .false.
225 if (list(a) == 1) inlist = .true.
226
227 deallocate(list)
228
229 end function loct_isinstringlist
230
231
232 logical function loct_dir_exists(dirname) result(exists)
233 character(len=*), intent(in) :: dirname
235 interface oct_dir_exists
236 integer function oct_dir_exists(dirname)
237 implicit none
238 character(len=*), intent(in) :: dirname
239 end function oct_dir_exists
240 end interface oct_dir_exists
242 exists = oct_dir_exists(dirname) /= 0
243
244 end function loct_dir_exists
245
246end module loct_oct_m
248!! Local Variables:
249!! mode: f90
250!! coding: utf-8
251!! End:
File-handling.
Definition: loct.F90:217
Define which routines can be seen from the outside.
Definition: loct.F90:148
logical function, public loct_isinstringlist(a, s)
Definition: loct.F90:311
logical function, public loct_dir_exists(dirname)
Definition: loct.F90:328
int true(void)