85 CHARACTER(len = *),
INTENT(IN) :: file
86 INTEGER,
INTENT(IN) :: unit
87 LOGICAL,
INTENT(IN),
OPTIONAL :: quiet
92 if (
present(quiet)) iquiet = quiet
95 if (.not. iquiet)
CALL message(
' This is namelist ', trim(file))
96 OPEN (
nunitnml, file = file, iostat = istat, status =
'old', action =
'read', delim =
'apostrophe')
98 IF (istat .ne. 0)
THEN
99 CALL error_message(
'OPEN_NML: Could not open namelist file ', trim(file))
134 INTEGER,
INTENT(IN),
OPTIONAL :: unit
136 INTEGER :: istat, nnml
139 if (
present(unit)) nnml = unit
141 IF (nnml .lt. 0)
CALL error_message(
'CLOSE_NML: No namelist file opened.')
143 CLOSE(nnml, iostat = istat)
145 IF (istat .ne. 0)
CALL error_message(
'CLOSE_NML: Could not close namelist file.')
147 if (.not.
present(unit))
nunitnml = -1
186 CHARACTER(len = *),
INTENT(in) :: name
187 INTEGER,
INTENT(in),
OPTIONAL :: unit
188 INTEGER(i4),
INTENT(out),
OPTIONAL :: status
189 LOGICAL,
INTENT(in),
OPTIONAL :: first
191 CHARACTER(len = 256) :: yline
192 CHARACTER(len = 256) :: test
197 INTEGER(i4) :: len_name
199 CHARACTER(len = 12) :: code
204 IF (
PRESENT(first)) lrew = first
206 IF (
PRESENT(unit)) iunit = unit
210 len_name = len_trim(name)
212 IF (len_name .gt. len(test))
THEN
214 code =
'LENGTH_ERROR'
218 write(test,
'(A,A)')
'&',
tolower(name)
221 IF (lrew) rewind(iunit)
229 READ (iunit, *, iostat = ios) yline
232 ELSE IF (ios .gt. 0)
THEN
240 ind = index(yline, trim(test))
242 IF (ind .eq. 0) cycle
244 indc = index(yline,
'!')
246 IF (indc .gt. 0 .AND. indc .lt. ind) cycle
249 ytest = yline(ind + len_name + 1 : ind + len_name + 1)
251 IF ((lge(ytest,
'0') .AND. lle(ytest,
'9')) .OR. &
252 (lge(ytest,
'a') .AND. lle(ytest,
'z')) .OR. &
253 ytest .eq.
'_' .OR. &
254 (lge(ytest,
'A') .AND. lle(ytest,
'Z')))
THEN
263 IF (
PRESENT(status)) status = stat
268 IF (
PRESENT(status))
RETURN
272 CALL error_message(
'POSITION_NML: namelist /', trim(name) ,
'/ ', trim(code))
Define number representations.
integer, parameter i4
4 Byte Integer Kind
Write out concatenated strings.
subroutine, public error_message(t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, uni, advance, show, raise, reset_format)
Write out an error message to stderr and call stop 1.
subroutine, public message(t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, uni, advance, show, reset_format)
Write out an error message to stdout.
Deal with namelist files.
integer, save, public nunitnml
default namelist unit
subroutine, public position_nml(name, unit, status, first)
Position a namlist file.
integer(i4), parameter, public positioned
Information: file pointer set to namelist group.
integer(i4), parameter, public missing
Error: namelist group is missing.
subroutine, public close_nml(unit)
Close a namelist file.
subroutine, public open_nml(file, unit, quiet)
Open a namelist file.
integer(i4), parameter, public read_error
Error occured during read of namelist file.
integer(i4), parameter, public length_error
Error: namelist group name too long.
character(len=len_trim(upper)) function, public tolower(upper)
Convert to lower case.