forked from pierrehirel/atomsk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadconf.f90
139 lines (139 loc) · 4.68 KB
/
readconf.f90
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
MODULE readconf
!
!**********************************************************************************
!* READCONF *
!**********************************************************************************
!* This module reads a configuration file containing default parameters *
!* for the atomsk program. This config file is usually found in the home *
!* directory of the user, i.e. ~/.atomsk, however this module does not make *
!* any assumption as the absolute path is passed through the 'conffile' variable. *
!**********************************************************************************
!* (C) Dec. 2010 - Pierre Hirel *
!* Université de Lille, Sciences et Technologies *
!* UMR CNRS 8207, UMET - C6, F-59655 Villeneuve D'Ascq, France *
!* [email protected] *
!* Last modification: P. Hirel - 14 June 2019 *
!**********************************************************************************
!* This program is free software: you can redistribute it and/or modify *
!* it under the terms of the GNU General Public License as published by *
!* the Free Software Foundation, either version 3 of the License, or *
!* (at your option) any later version. *
!* *
!* This program 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 General Public License for more details. *
!* *
!* You should have received a copy of the GNU General Public License *
!* along with this program. If not, see <http://www.gnu.org/licenses/>. *
!**********************************************************************************
!
!Load modules
USE comv
USE constants
USE files
USE messages
!
!
!
CONTAINS
!
SUBROUTINE READ_CONF(conffile)
!
!
!Declare variables
IMPLICIT NONE
CHARACTER(LEN=5):: ext
CHARACTER(LEN=5),DIMENSION(:),ALLOCATABLE:: outfileformats !list of formats to write
CHARACTER(LEN=128):: conffile, msg, temp
INTEGER:: Nthreads
!
!
Nthreads = 0
!
!
msg = "reading conffile = "//TRIM(conffile)
CALL ATOMSK_MSG(999,(/TRIM(msg)/),(/0.d0/))
!
OPEN(UNIT=19,FILE=conffile,FORM='FORMATTED',ERR=800)
!
DO
READ(19,'(a128)',END=1000,ERR=800) temp
temp = TRIM(ADJUSTL(temp))
!
IF( LEN_TRIM(temp)>0 .AND. temp(1:1).NE.'#' ) THEN
!
IF(temp(1:9)=='verbosity') THEN
!read level of verbosity
READ(temp(10:),*,END=800,ERR=800) verbosity
!
ELSEIF(temp(1:6)=='format') THEN
!read formats that will always be activated for output
READ(temp(7:),*,END=800,ERR=800) ext
CALL SET_OUTPUT(outfileformats,ext,.TRUE.)
!
ELSEIF(temp(1:5)=='overw') THEN
!if true, file will always be overwritten without prompt
READ(temp(6:),*,END=800,ERR=800) temp
CALL STR2BOOL(temp,overw)
!
ELSEIF(temp(1:6)=='ignore') THEN
!if true, existing file will always be ignored without prompt
READ(temp(7:),*,END=800,ERR=800) temp
CALL STR2BOOL(temp,ignore)
!
ELSEIF(temp(1:4)=='lang') THEN
!read language for messages
READ(temp(5:),*,END=800,ERR=800) msg
msg = ADJUSTL(msg)
IF( INDEX(msg,"fr")>0 .OR. INDEX(msg,"FR")>0 ) THEN
lang="fr"
ELSEIF( INDEX(msg,"de")>0 .OR. INDEX(msg,"DE")>0 ) THEN
lang="de"
ELSE
lang="en"
ENDIF
!
ELSEIF(temp(1:8)=='Nthreads' .OR. temp(1:8)=='nthreads') THEN
!read max. number of OpenMP threads to use
READ(temp(9:),*,END=800,ERR=800) Nthreads
#if defined(OPENMP)
IF( Nthreads>0 ) THEN
CALL OMP_SET_NUM_THREADS(Nthreads)
ENDIF
#else
Nthreads=0
CALL ATOMSK_MSG(751,(/conffile/),(/0.d0/))
#endif
!
ELSE
nwarn = nwarn+1
CALL ATOMSK_MSG(1702,(/temp,conffile/),(/0.d0/))
ENDIF
ENDIF
ENDDO
!
CLOSE(19)
GOTO 1000
!
!
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! ERROR MESSAGES
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
800 CONTINUE
CALL ATOMSK_MSG(1703,(/conffile/),(/0.d0/))
nwarn = nwarn+1
!
!
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! TERMINATE MODULE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1000 CONTINUE
!
!
END SUBROUTINE READ_CONF
!
!
END MODULE readconf