Octopus
io_csv_f.F90
Go to the documentation of this file.
1!! Copyright (C) 2009 X. Andrade
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#include "io_binary.h"
21
22module io_csv_oct_m
23 use debug_oct_m
24 use global_oct_m
25 use iso_c_binding
26 use string_oct_m
27
28 implicit none
29
30 private
31
32 public :: &
33 dread_csv, &
35
36
37 interface
38 subroutine read_csv(np, f, output_type, ierr, fname) bind(C)
39 use iso_c_binding
40 implicit none
41 integer(c_int64_t), intent(in) :: np
42 type(c_ptr), value :: f
43 integer(C_INT), intent(in) :: output_type
44 integer(C_INT), intent(out) :: ierr
45 character(kind=c_char), intent(in) :: fname(*)
46 end subroutine read_csv
47
48 subroutine get_info_csv(dims, ierr, filename) bind(C)
49 use iso_c_binding
50 implicit none
51 type(c_ptr), value :: dims
52 integer(C_INT), intent(out) :: ierr
53 character(kind=c_char), intent(in) :: filename(*)
54 end subroutine get_info_csv
55
56 end interface
57
58contains
59
60 subroutine dread_csv(fname, np, ff, ierr)
61 character(len=*), intent(in) :: fname
62 integer(c_int64_t), intent(in) :: np
63 real(real64), target, intent(out) :: ff(:)
64 integer, intent(out) :: ierr
65
66 push_sub(dread_csv)
67
68 call read_csv(np, c_loc(ff(1)), type_double, ierr, string_f_to_c(fname))
69
70 pop_sub(dread_csv)
71 end subroutine dread_csv
72
73 subroutine io_csv_get_info(fname, dims, ierr)
74 character(len=*), intent(in) :: fname
75 integer(c_int64_t), target, intent(out) :: dims(:)
76 integer, intent(out) :: ierr
77
78 push_sub(io_csv_get_info)
79
80 call get_info_csv(c_loc(dims(1)), ierr, string_f_to_c(fname))
81
82 pop_sub(io_csv_get_info)
83 end subroutine io_csv_get_info
84
85end module io_csv_oct_m
86
87!! Local Variables:
88!! mode: f90
89!! coding: utf-8
90!! End:
subroutine, public dread_csv(fname, np, ff, ierr)
Definition: io_csv_f.F90:155
subroutine, public io_csv_get_info(fname, dims, ierr)
Definition: io_csv_f.F90:168
character(kind=c_char, len=1) function, dimension(c_str_len(f_string)), public string_f_to_c(f_string)
convert a Fortran string to a C string
Definition: string.F90:268