Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_binary_io.F90
Go to the documentation of this file.
1 !**************************************************************
2 ! Copyright INRIA
3 ! Authors :
4 ! Pierre Navaro
5 !
6 ! This code SeLaLib (for Semi-Lagrangian-Library)
7 ! is a parallel library for simulating the plasma turbulence
8 ! in a tokamak.
9 !
10 ! This software is governed by the CeCILL-B license
11 ! under French law and abiding by the rules of distribution
12 ! of free software. You can use, modify and redistribute
13 ! the software under the terms of the CeCILL-B license as
14 ! circulated by CEA, CNRS and INRIA at the following URL
15 ! "http://www.cecill.info".
16 !**************************************************************
17 
28 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29 #include "sll_assert.h"
30 #include "sll_working_precision.h"
31 
32  implicit none
33 
34  public :: &
43 
44  private
45 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46 
52  module procedure sll_s_binary_write_array_1d
53  module procedure sll_s_binary_write_array_2d
54  module procedure sll_s_binary_write_array_3d
55  end interface
56 
57 contains
58 
60  subroutine sll_s_binary_file_create(filename, file_id, error)
61  character(len=*), intent(in) :: filename
62  sll_int32, intent(out) :: file_id
63  sll_int32, intent(out) :: error
64  logical :: lopen
65 
66  error = 0
67 
68  do 100 file_id = 20, 99
69  inquire (unit=file_id, opened=lopen)
70  if (lopen) then
71  cycle
72  else
73  open (file_id, status='SCRATCH', err=100)
74  close (file_id, status='DELETE', err=100)
75  goto 200
76  end if
77 
78 100 continue
79  error = 1
80 200 continue
81  error = 0
82 
83  ! Create a new file using default properties
84  inquire (file=filename, opened=lopen)
85  sll_assert_always(.not. lopen)
86 
87  open (file_id, &
88  file=filename, &
89  access="STREAM", &
90  form='UNFORMATTED', &
91  iostat=error)
92 
93  end subroutine sll_s_binary_file_create
94 
96 !subroutine sll_binary_file_open(file_id,error)
97 !sll_int32, intent(in) :: file_id !<file unit number
98 !sll_int32, intent(out) :: error !<error code
99 
100 !open(file_id, IOSTAT=error)
101 
102 !end subroutine sll_binary_file_open
103 
105  subroutine sll_s_binary_file_close(file_id, error)
106  sll_int32, intent(in) :: file_id
107  sll_int32, intent(out) :: error
108 
109  close (file_id, iostat=error)
110 
111  end subroutine sll_s_binary_file_close
112 
114  subroutine sll_s_binary_write_array_0d(file_id, array, error)
115  sll_int32, intent(in) :: file_id
116  sll_int32, intent(out) :: error
117  sll_real64, intent(in) :: array
118  write (file_id, iostat=error) array
119  end subroutine
120 
122  subroutine sll_s_binary_write_array_1d(file_id, array, error)
123  sll_int32, intent(in) :: file_id
124  sll_int32, intent(out) :: error
125  sll_real64, intent(in) :: array(:)
126  write (file_id, iostat=error) array
127  end subroutine
128 
130  subroutine sll_s_binary_write_array_2d(file_id, array, error)
131  sll_int32, intent(in) :: file_id
132  sll_int32, intent(out) :: error
133  sll_real64, intent(in) :: array(:, :)
134  write (file_id, iostat=error) array
135  end subroutine
136 
138  subroutine sll_s_binary_write_array_3d(file_id, array, error)
139  sll_int32, intent(in) :: file_id
140  sll_int32, intent(out) :: error
141  sll_real64, intent(in) :: array(:, :, :)
142  write (file_id, iostat=error) array
143  end subroutine
144 
146  subroutine sll_s_binary_read_array_0d(file_id, array, error)
147  sll_int32, intent(in) :: file_id
148  sll_int32, intent(out) :: error
149  sll_real64, intent(out) :: array
150  read (file_id, iostat=error) array
151  end subroutine
152 
154  subroutine sll_s_binary_read_array_2d(file_id, array, error)
155  sll_int32, intent(in) :: file_id
156  sll_int32, intent(out) :: error
157  sll_real64, intent(out) :: array(:, :)
158  read (file_id, iostat=error) array
159  end subroutine
160 
161  end module sll_m_binary_io
Write a nD array in a binary file.
Implements the functions to write binary file to store heavy data.
subroutine, public sll_s_binary_write_array_1d(file_id, array, error)
Write a 1D array in the binary file file_id.
subroutine, public sll_s_binary_read_array_0d(file_id, array, error)
Read a 0D array in the binary file file_id.
subroutine sll_s_binary_write_array_3d(file_id, array, error)
Write a 3D array in the binary file file_id.
subroutine, public sll_s_binary_write_array_2d(file_id, array, error)
Write a 2D array in the binary file file_id.
subroutine, public sll_s_binary_write_array_0d(file_id, array, error)
Write a 0D array in the binary file file_id.
subroutine, public sll_s_binary_read_array_2d(file_id, array, error)
Read a 2D array in the binary file file_id.
subroutine, public sll_s_binary_file_close(file_id, error)
Open binary file.
subroutine, public sll_s_binary_file_create(filename, file_id, error)
Create binary file.
    Report Typos and Errors