13 integer,
parameter,
private ::
maxrec=32768
19 integer(4),
allocatable :: dat(:)
24 character(len=:),
allocatable :: fname
25 type(
rec_t),
allocatable :: rec(:)
42 if (
allocated(
file))
return 53 character(*),
intent(in) :: fname
54 integer,
intent(out) :: fnum
57 if (.not.
allocated(
file))
then 59 write(*,
'("Error(findfile): RAM disk not initialised")')
65 if (
file(i)%fname == fname)
then 75 character(*),
intent(in) :: fname
76 integer,
intent(out) :: fnum
84 if (
file(i)%fname ==
'')
then 94 write(*,
'("Error(openfile): too many RAM disk files open : ",I8)')
maxfiles 103 character(*),
intent(in) :: fname
109 if (fnum == 0)
return 114 if (
allocated(
file(fnum)%rec(i)%dat))
deallocate(
file(fnum)%rec(i)%dat)
116 deallocate(
file(fnum)%rec)
119 subroutine putrd(fname,irec,n1,n2,n3,v1,v2,nrv,rva,nzv,zva)
123 character(*),
intent(in) :: fname
124 integer,
intent(in) :: irec
125 integer,
optional,
intent(in) :: n1,n2,n3
126 real(8),
optional,
intent(in) :: v1(3),v2(3)
127 integer,
optional,
intent(in) :: nrv
128 real(8),
optional,
intent(in) :: rva(*)
129 integer,
optional,
intent(in) :: nzv
130 complex(8),
optional,
intent(in) :: zva(*)
141 if (
present(n1)) n=n+1
142 if (
present(n2)) n=n+1
143 if (
present(n3)) n=n+1
144 if (
present(v1)) n=n+6
145 if (
present(v2)) n=n+6
146 if (
present(rva))
then 147 if (
present(nrv))
then 151 write(*,
'("Error(putrd): missing argument nrv")')
156 if (
present(zva))
then 157 if (
present(nzv))
then 161 write(*,
'("Error(putrd): missing argument nzv")')
169 if (
allocated(
file(fnum)%rec(irec)%dat))
then 170 if (
size(
file(fnum)%rec(irec)%dat) < n)
then 171 deallocate(
file(fnum)%rec(irec)%dat)
174 if (.not.
allocated(
file(fnum)%rec(irec)%dat))
then 175 allocate(
file(fnum)%rec(irec)%dat(n))
178 if (
present(n1))
then 179 file(fnum)%rec(irec)%dat(i)=n1
182 if (
present(n2))
then 183 file(fnum)%rec(irec)%dat(i)=n2
186 if (
present(n3))
then 187 file(fnum)%rec(irec)%dat(i)=n3
190 if (
present(v1))
then 192 file(fnum)%rec(irec)%dat(i:j)=transfer(v1(1:3),
file(fnum)%rec(irec)%dat(i:j))
195 if (
present(v2))
then 197 file(fnum)%rec(irec)%dat(i:j)=transfer(v2(1:3),
file(fnum)%rec(irec)%dat(i:j))
200 if (
present(rva))
then 202 file(fnum)%rec(irec)%dat(i:j)=transfer(rva(1:nrv), &
203 file(fnum)%rec(irec)%dat(i:j))
206 if (
present(zva))
then 208 file(fnum)%rec(irec)%dat(i:j)=transfer(zva(1:nzv), &
209 file(fnum)%rec(irec)%dat(i:j))
213 subroutine getrd(fname,irec,tgs,n1,n2,n3,v1,v2,nrv,rva,nzv,zva)
216 character(*),
intent(in) :: fname
217 integer,
intent(in) :: irec
218 logical,
intent(out) :: tgs
219 integer,
optional,
intent(out) :: n1,n2,n3
220 real(8),
optional,
intent(out) :: v1(3),v2(3)
221 integer,
optional,
intent(in) :: nrv
222 real(8),
optional,
intent(out) :: rva(*)
223 integer,
optional,
intent(in) :: nzv
224 complex(8),
optional,
intent(out) :: zva(*)
227 if (
present(rva))
then 228 if (.not.
present(nrv))
then 230 write(*,
'("Error(getrd): missing argument nrv")')
235 if (
present(zva))
then 236 if (.not.
present(nzv))
then 238 write(*,
'("Error(getrd): missing argument nzv")')
248 if (fnum == 0)
return 249 if (.not.
allocated(
file(fnum)%rec(irec)%dat))
return 250 n=
size(
file(fnum)%rec(irec)%dat)
252 if (
present(n1))
then 254 n1=
file(fnum)%rec(irec)%dat(i)
258 if (
present(n2))
then 260 n2=
file(fnum)%rec(irec)%dat(i)
264 if (
present(n3))
then 266 n3=
file(fnum)%rec(irec)%dat(i)
270 if (
present(v1))
then 272 v1(1:3)=transfer(
file(fnum)%rec(irec)%dat(i:i+5),v1(1:3))
276 if (
present(v2))
then 278 v2(1:3)=transfer(
file(fnum)%rec(irec)%dat(i:i+5),v2(1:3))
282 if (
present(rva))
then 283 if (n < 2*nrv)
return 284 rva(1:nrv)=transfer(
file(fnum)%rec(irec)%dat(i:i+2*nrv-1),rva(1:nrv))
288 if (
present(zva))
then 289 if (n < 4*nzv)
return 290 zva(1:nzv)=transfer(
file(fnum)%rec(irec)%dat(i:i+4*nzv-1),zva(1:nzv))
303 write(*,
'("Info(rdstatus):")')
304 if (.not.
allocated(
file))
then 305 write(*,
'(" RAM disk not initialised")')
311 if (
file(i)%fname /=
'')
then 313 write(*,
'(" Filename : ",A)')
file(i)%fname
318 if (
allocated(
file(i)%rec(j)%dat))
then 320 m=m+
size(
file(i)%rec(j)%dat)
324 write(*,
'(" number of records : ",I8)') nr
325 write(*,
'(" total number of bytes : ",I14)') 4*m
329 write(*,
'(" Number of files on RAM disk : ",I4)') nf
330 write(*,
'(" Total number of bytes used by RAM disk : ",I14)') 4*n
subroutine putrd(fname, irec, n1, n2, n3, v1, v2, nrv, rva, nzv, zva)
type(file_t), dimension(:), allocatable, private file
subroutine getrd(fname, irec, tgs, n1, n2, n3, v1, v2, nrv, rva, nzv, zva)
subroutine, private findfile(fname, fnum)
subroutine, private openfile(fname, fnum)
integer, parameter, private maxfiles
integer, parameter, private maxrec