ESPUTR
calculation of sputtering yields
esputr.f90
Go to the documentation of this file.
1 
5 
6 ! Copyright (c) 2016 Forschungszentrum Juelich GmbH
7 ! Markus Brenneis, Vladislav Kotov
8 !
9 ! This file is part of ESPUTR.
10 !
11 ! ESPUTR is free software: you can redistribute it and/or modify
12 ! it under the terms of the GNU General Public License as published by
13 ! the Free Software Foundation, either version 3 of the License, or
14 ! (at your option) any later version.
15 !
16 ! ESPUTR is distributed in the hope that it will be useful,
17 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ! GNU General Public License for more details.
20 !
21 ! You should have received a copy of the GNU General Public License
22 ! along with ESPUTR. If not, see <http://www.gnu.org/licenses/>.
23 !
24 
64 
65 module esputr
66 
67 !***********************************************************************************
68 ! DEFINITION OF PARAMETRS AND GLOBAL VARIABLES
69 !***********************************************************************************
70  implicit none
71  public numberoflines
73  integer, public, save :: esputr_unit = 6
77  integer, public, parameter :: esputr_dp=8
79  real(ESPUTR_DP), public, parameter :: esputr_pi = 4*atan(1.)
81  real(ESPUTR_DP), public, parameter :: esputr_pi2 = esputr_pi/2
83  integer, public, parameter :: esputr_max_line_length = 256
84  private
86  character(*), public, parameter :: esputr_comment_start = '#'
87 
88  contains
89 
90 !***********************************************************************************
91 ! UTILITY FUNCTIONS
92 !***********************************************************************************
94  integer function numberoflines(fileName, ignoreComments,err)
95 
96  character(*), intent(in) :: fileName
102  logical, intent(in), optional :: ignoreComments
103  integer, intent(out) :: err
104  integer, parameter :: UNIT = 1337
105  character(1) :: line
106  character(100) :: msg
107  intrinsic trim
108 
109  err = 0
110  open(unit, iostat=err, iomsg=msg, file=filename, status='old', action='read')
111 
112  numberoflines = 0
113  if(err == 0) then
114  do
115  read(unit, *, iostat=err,end=100) line
116  if(err /= 0) then
117  write(esputr_unit,*), "ERROR in numberOfLines while reading "//trim(filename)
118  close(unit)
119  err = 300
120  return
121  end if
122  if(line /= esputr_comment_start) then
124  else if(present(ignorecomments)) then
125  if(.not.ignorecomments) numberoflines = numberoflines + 1
126  else if(.not.present(ignorecomments)) then
128  end if
129  end do
130  else
131  write(esputr_unit,*), "ERROR in numberOfLines: cannot open file "//trim(filename)
132  err = 300
133  return
134  end if
135 100 err = 0
136  close(unit)
137  end function numberoflines
138 
139 end module esputr
integer function, public numberoflines(fileName, ignoreComments, err)
Return number of lines in the file, without blank lines and comment lines (started with #) ...
Definition: esputr.f90:95
real(esputr_dp), parameter, public esputr_pi
Pi number.
Definition: esputr.f90:79
real(esputr_dp), parameter, public esputr_pi2
Pi divided by 2.
Definition: esputr.f90:81
character(*), parameter, public esputr_comment_start
chracter which is used to start comments in the data files
Definition: esputr.f90:86
integer, parameter, public esputr_dp
Kind number for real numbers.
Definition: esputr.f90:77
integer, parameter, public esputr_max_line_length
Maximum length of the line in the input data files.
Definition: esputr.f90:83
integer, save, public esputr_unit
Index of the unit for standard output, default value 6.
Definition: esputr.f90:73