program specint implicit none character*80 fl,s,fn integer*4 i,j,k,n,nf,nl,np,iargc real*8 v real*8,allocatable:: a(:),b(:),ai(:),x(:),y(:) write(6,6000) 6000 format(/,' Integral of spectra in several ranges',/,/, 1 ' Usage: specint n a1 b1 ... an bn',/) if(iargc().lt.4)stop call getarg(1,fl) call getarg(2,s) read(s,*)n allocate(a(n),b(n),ai(n)) do 3 i=1,n call getarg(2*i+1,s) read(s,*)a(i) call getarg(2*i+2,s) 3 read(s,*)b(i) c how many lines in fl: nf=nl(fl) write(6,*)nf,' files' c how many points in the first: open(9,file=fl) read(9,80)fn 80 format(a80) close(9) np=nl(fn) write(6,*)np,' points' allocate(x(np),y(np)) open(9,file=fl) open(8,file='t.prn') do 1 i=1,nf read(9,80)fn open(10,file=fn) do 2 j=1,np 2 read(10,*)x(j),y(j) close(10) ai=0.0d0 do 5 j=2,np-1 v=dabs((x(j+1)-x(j-1))/2.0d0) do 5 k=1,n 5 if(a(k).le.x(j).and.x(j).le.b(k))ai(k)=ai(k)+y(j)*v write(6,600)i write(8,600)i 600 format(i6,$) do 4 k=1,n write(6,601)ai(k) 4 write(8,601)ai(k) 601 format(E14.4,$) write(6,*) 1 write(8,*) close(9) close(8) end function nl(f) implicit none character*(*) f integer*4 nl,n open(9,file=f) n=0 1 read(9,*,end=99,err=99) n=n+1 goto 1 99 close(9) nl=n return end