13 integer,
parameter,
private ::
maxrec=32768
19 integer(4),
allocatable :: dat(:)
24 character(:),
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 : ",I0)')
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),[1_4])
195 if (
present(v2))
then 197 file(fnum)%rec(irec)%dat(i:j)=transfer(v2(1:3),[1_4])
200 if (
present(rva))
then 202 file(fnum)%rec(irec)%dat(i:j)=transfer(rva(1:nrv),[1_4])
205 if (
present(zva))
then 207 file(fnum)%rec(irec)%dat(i:j)=transfer(zva(1:nzv),[1_4])
211 subroutine getrd(fname,irec,tgs,n1,n2,n3,v1,v2,nrv,rva,nzv,zva)
214 character(*),
intent(in) :: fname
215 integer,
intent(in) :: irec
216 logical,
intent(out) :: tgs
217 integer,
optional,
intent(out) :: n1,n2,n3
218 real(8),
optional,
intent(out) :: v1(3),v2(3)
219 integer,
optional,
intent(in) :: nrv
220 real(8),
optional,
intent(out) :: rva(*)
221 integer,
optional,
intent(in) :: nzv
222 complex(8),
optional,
intent(out) :: zva(*)
225 if (
present(rva))
then 226 if (.not.
present(nrv))
then 228 write(*,
'("Error(getrd): missing argument nrv")')
233 if (
present(zva))
then 234 if (.not.
present(nzv))
then 236 write(*,
'("Error(getrd): missing argument nzv")')
246 if (fnum == 0)
return 247 if (.not.
allocated(
file(fnum)%rec(irec)%dat))
return 248 n=
size(
file(fnum)%rec(irec)%dat)
250 if (
present(n1))
then 252 n1=
file(fnum)%rec(irec)%dat(i)
256 if (
present(n2))
then 258 n2=
file(fnum)%rec(irec)%dat(i)
262 if (
present(n3))
then 264 n3=
file(fnum)%rec(irec)%dat(i)
268 if (
present(v1))
then 270 v1(1:3)=transfer(
file(fnum)%rec(irec)%dat(i:i+5),v1(1:3))
274 if (
present(v2))
then 276 v2(1:3)=transfer(
file(fnum)%rec(irec)%dat(i:i+5),v2(1:3))
280 if (
present(rva))
then 281 if (n < 2*nrv)
return 282 rva(1:nrv)=transfer(
file(fnum)%rec(irec)%dat(i:i+2*nrv-1),rva(1:nrv))
286 if (
present(zva))
then 287 if (n < 4*nzv)
return 288 zva(1:nzv)=transfer(
file(fnum)%rec(irec)%dat(i:i+4*nzv-1),zva(1:nzv))
301 write(*,
'("Info(rdstatus):")')
302 if (.not.
allocated(
file))
then 303 write(*,
'(" RAM disk not initialised")')
309 if (
file(i)%fname /=
'')
then 311 write(*,
'(" Filename : ",A)')
file(i)%fname
316 if (
allocated(
file(i)%rec(j)%dat))
then 318 m=m+
size(
file(i)%rec(j)%dat)
322 write(*,
'(" number of records : ",I0)') nr
323 write(*,
'(" total number of bytes : ",I0)') 4*m
327 write(*,
'(" Number of files on RAM disk : ",I0)') nf
328 write(*,
'(" Total number of bytes used by RAM disk : ",I0)') 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