Newer
Older
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! ||===\\ |
! || \\ |
! || || //==\\ || || //==|| ||/==\\ |
! || || || || || || || || || || |
! || // || || || || || || || |
! ||===// \\==// \\==\\ \\==\\ || |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! ISCANFILE Nov. 2006 |
! DSCANFILE Nov. 2006 |
! CSCANFILE Nov. 2006 |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
subroutine iscanfile (fnme,text,res,ires)
!------------------------------------------------------------------------------|
!(((((((((((((((( Purpose of the routine ))))))))))))))))))))))))))))))))))))))
!---------------------------------------------------------------------------
! subroutine to read the value of an integer parameter whose name is stored in
! text from file fnme the result is stored in res and the flag ires is set
! to 1 if all went well.
Dave Whipp
committed
use mpi
implicit none
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine arguments ))))))))))))))))))))
!------------------------------------------------------------------------------|
character*(*) fnme,text
integer,intent(out)::res,ires
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine internal variables )))))))))))))
!------------------------------------------------------------------------------|
character line*256,record*256
integer ios
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
call mpi_comm_size (mpi_comm_world,nproc,ierr)
call mpi_comm_rank (mpi_comm_world,iproc,ierr)
ires=0
open (7,file=fnme(1:len_trim(fnme)),status='old',iostat=ios)
if (ios/=0) write(*,*) 'pb opening <',fnme(1:len_trim(fnme)),'> in iscanfile'
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
111 continue
read (7,'(a)',end=112) line
ieq=scan(line,'=')
if (ieq/=0) then
if (trim(adjustl(line(1:ieq-1))).eq.text(1:len_trim(text))) then
nrec=len_trim(adjustl(line(ieq+1:len_trim(line))))
record(1:nrec)=trim(adjustl(line(ieq+1:len_trim(line))))
read (record(1:nrec),*) res
if (iproc.eq.0) write (8,*) 'Non-default value for '//text//': '//record(1:nrec)
ires=1
end if
end if
goto 111
112 close (7)
return
end subroutine iscanfile
!---------------------------------------------------------------------------
!---------------------------------------------------------------------------
subroutine dscanfile (fnme,text,res,ires)
!------------------------------------------------------------------------------|
!(((((((((((((((( Purpose of the routine ))))))))))))))))))))))))))))))))))))))
!------------------------------------------------------------------------------|
! subroutine to read the value of a double precision parameter whose name
! is stored in text from file fnme the result is stored in res and the flag
! ires is set to 1 if all went well.
Dave Whipp
committed
use mpi
implicit none
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine arguments ))))))))))))))))))))
!------------------------------------------------------------------------------|
character*(*) fnme,text
double precision res
integer ires
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine internal variables )))))))))))))
!------------------------------------------------------------------------------|
character line*256,record*256
integer ios
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
call mpi_comm_size (mpi_comm_world,nproc,ierr)
call mpi_comm_rank (mpi_comm_world,iproc,ierr)
ires=0
open (7,file=fnme(1:len_trim(fnme)),status='old',iostat=ios)
if (ios/=0) write(*,*) 'pb opening <',fnme(1:len_trim(fnme)),'> in dscanfile'
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
111 continue
read (7,'(a)',end=112) line
ieq=scan(line,'=')
if (ieq/=0) then
if (trim(adjustl(line(1:ieq-1))).eq.text(1:len_trim(text))) then
nrec=len_trim(adjustl(line(ieq+1:len_trim(line))))
record(1:nrec)=trim(adjustl(line(ieq+1:len_trim(line))))
read (record(1:nrec),*) res
if (iproc.eq.0) write (8,*) 'Non-default value for '//text//': '//record(1:nrec)
ires=1
endif
end if
goto 111
112 close (7)
return
end subroutine dscanfile
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
subroutine cscanfile (fnme,text,res,ires)
!------------------------------------------------------------------------------|
!(((((((((((((((( Purpose of the routine ))))))))))))))))))))))))))))))))))))))
!------------------------------------------------------------------------------|
! subroutine to read the value of a character string parameter whose name
! is stored in text from file fnme the result is stored in res and the flag
! ires is set to 1 if all went well.
Dave Whipp
committed
use mpi
implicit none
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine arguments ))))))))))))))))))))
!------------------------------------------------------------------------------|
character*(*) fnme,text,res
integer ires
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine internal variables )))))))))))))
!------------------------------------------------------------------------------|
character line*256,record*256
integer ios
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
call mpi_comm_size (mpi_comm_world,nproc,ierr)
call mpi_comm_rank (mpi_comm_world,iproc,ierr)
ires=0
open (7,file=fnme(1:len_trim(fnme)),status='old',iostat=ios)
if (ios/=0) write(*,*) 'pb opening <',fnme(1:len_trim(fnme)),'> in cscanfile'
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
111 continue
read (7,'(a)',end=112) line
ieq=scan(line,'=')
if (ieq/=0) then
if (trim(adjustl(line(1:ieq-1))).eq.text(1:len_trim(text))) then
nrec=len_trim(adjustl(line(ieq+1:len_trim(line))))
record(1:nrec)=trim(adjustl(line(ieq+1:len_trim(line))))
res=record(1:nrec)
if (iproc.eq.0) write (8,*) 'Non-default value for '//text//': '//record(1:nrec)
ires=1
endif
end if
goto 111
112 close (7)
return
end subroutine cscanfile
!---------------------------------------------------------------------------
!---------------------------------------------------------------------------