-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCFML_GlobalDeps.f90
More file actions
191 lines (161 loc) · 7.07 KB
/
CFML_GlobalDeps.f90
File metadata and controls
191 lines (161 loc) · 7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
!!-------------------------------------------------------
!!---- Crystallographic Fortran Modules Library (CrysFML)
!!-------------------------------------------------------
!!---- The CrysFML project is distributed under LGPL. In agreement with the
!!---- Intergovernmental Convention of the ILL, this software cannot be used
!!---- in military applications.
!!----
!!---- Copyright (C) 1999-2022 Institut Laue-Langevin (ILL), Grenoble, FRANCE
!!---- Universidad de La Laguna (ULL), Tenerife, SPAIN
!!---- Laboratoire Leon Brillouin(LLB), Saclay, FRANCE
!!----
!!---- Authors: Juan Rodriguez-Carvajal (ILL)
!!---- Javier Gonzalez-Platas (ULL)
!!---- Nebil Ayape Katcho (ILL)
!!----
!!---- Contributors: Laurent Chapon (ILL)
!!---- Marc Janoschek (Los Alamos National Laboratory, USA)
!!---- Oksana Zaharko (Paul Scherrer Institute, Switzerland)
!!---- Tierry Roisnel (CDIFX,Rennes France)
!!---- Eric Pellegrini (ILL)
!!---- Ross Angel (University of Pavia)
!!----
!!---- This library is free software; you can redistribute it and/or modify
!!---- it under the terms of the GNU Lesser General Public License as
!!---- published by the Free Software Foundation; either version 3.0 of the
!!---- License, or (at your option) any later version.
!!----
!!---- This library is distributed in the hope that it will be useful, but
!!---- WITHOUT ANY WARRANTY; without even the implied warranty of
!!---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
!!---- Lesser General Public License for more details.
!!----
!!---- You should have received a copy of the GNU Lesser General Public
!!---- License along with this library; if not, see
!!---- <http://www.gnu.org/licenses/>.
!!----
!!---- MODULE: CFML_GlobalDeps (Windows version)
!!---- INFO:Precision for CrysFML library and Operating System information
!!---- All the global variables defined in this module are implicitly
!!---- public.
!!----
!!----
!!
Module CFML_GlobalDeps
!---- Variables ----!
Implicit None
public
!--------------------!
!---- PARAMETERS ----!
!--------------------!
!---- Operating System ----!
character(len=3), parameter :: OPS_NAME = "LIN" ! O.S. Name
character(len=1), parameter :: OPS_SEP = "/" ! O.S. directory separator character
character(len=2), parameter :: line_term = char(13)//char(10) ! O.S. line terminator character
integer, parameter :: OPS = 2 ! O.S. Flag -> 1:Win 2:Lin 3:Mac
!---- Compiler ----!
!character(len=4), parameter :: COMPILER = "IFOR" ! Intel Compiler
character(len=4), parameter :: COMPILER = "GFOR" ! GFortran Compiler
!---- Precision ----!
integer, parameter :: DP = selected_real_kind(14,150) ! Double precision
integer, parameter :: SP = selected_real_kind(6,30) ! Simple precision
integer, parameter :: LI = selected_int_kind(16) ! Long Integer
integer, parameter :: CP = SP ! Current precision
!---- Trigonometric ----!
real(kind=DP), parameter :: PI = 3.141592653589793238463_DP ! PI value
real(kind=DP), parameter :: TO_DEG = 180.0_DP/PI ! Conversion from Radians to Degrees
real(kind=DP), parameter :: TO_RAD = PI/180.0_DP ! Conversion from Degrees to Radians
real(kind=DP), parameter :: TPI = 6.283185307179586476925_DP ! 2*PI
!---- Numeric ----!
real(kind=DP), parameter :: DEPS=0.00000001_DP ! Epsilon value use for comparison of real numbers (DOUBLE)
real(kind=CP), parameter :: EPS=0.00001_CP ! Epsilon value use for comparison of real numbers
real(kind=CP), parameter :: V_EPSI=epsilon(1.0_CP) ! Epsilon value for Current precision
real(kind=CP), parameter :: V_HUGE=huge(1.0_CP) ! Huge value for current precision
real(kind=CP), parameter :: V_TINY=tiny(1.0_CP) ! Tiny value for current precision
!---- Special Characters ----!
character(len=*), parameter :: NEWLINE = char(10) ! Newline character
character(len=1), parameter :: TAB = char(9) ! TAB character
Type :: Err_Type
logical :: Flag = .False. ! Flag
integer :: IErr = 0 ! =0: No error, < 0: Warning, > 0: Error
character(len=180) :: Msg = " " ! Text for Message
integer :: nl = 0 ! number of lines
character(len=180),dimension(5) :: Txt = " " ! Extra Message information
End Type Err_Type
Type (Err_Type) :: Err_CFML ! Error Information for CFML
!---- Error Flags ----!
logical :: CFML_DEBUG=.false. ! For checking test
Contains
!!----
!!---- FUNCTION DIRECTORY_EXISTS
!!----
!!---- Generic function dependent of the compiler that return
!!---- a logical value if a directory exists or not.
!!----
!!---- Update: 11/07/2015
!!
Function Directory_Exists(DirName) Result(info)
!---- Argument ----!
character(len=*), intent(in) :: DirName ! Directory name
logical :: info ! Return Value
!---- Local Variables ----!
character(len=:), allocatable :: linea
integer :: nlong
!> Init value
info=.false.
!> Check
if (len_trim(dirname)<= 0) return
linea=adjustl(dirname)
nlong=len_trim(linea)
if (linea(nlong:nlong) /= OPS_SEP) linea=trim(linea)//OPS_SEP
!> Compiler
select case (trim(compiler))
case ('IFOR')
!inquire(directory=trim(linea), exist=info)
case default
inquire(file=trim(linea)//'.' , exist=info)
end select
End Function Directory_Exists
!!----
!!---- CLEAR_ERROR
!!---- Reset information on Error Variables for CFML
!!----
!!---- 19/10/2021
!!
Subroutine Clear_Error()
Err_CFML%Flag=.False.
Err_CFML%IErr=0
Err_CFML%Msg =" "
Err_CFML%nl=0
Err_CFML%Txt=" "
End Subroutine Clear_Error
!!----
!!---- SET_ERROR
!!---- Set Error/Warning variables
!!----
!!---- 19/10/2021
!!
Subroutine Set_Error(Ierr, Msg)
!---- Arguments ----!
integer, intent(in) :: Ierr
character(len=*), intent(in) :: Msg
if (IErr /=0 ) then
Err_CFML%IErr=Ierr
Err_CFML%Msg=trim(adjustl(Msg))
Err_CFML%Flag=.True.
else
call clear_error()
end if
End Subroutine Set_Error
!!----
!!---- SET_CFML_DEBUG
!!---- Set .true. or .false. for CFML_DEBUG global variable
!!----
!!---- 26/04/2019
!!
Subroutine Set_CFML_DEBUG(state)
!---- Arguments ----!
logical, intent(in) :: state
CFML_DEBUG=state
End Subroutine Set_CFML_DEBUG
End Module CFML_GlobalDeps