program specint implicit none character*80 fl,s,fn integer*4 i,j,k,n,nf,nl,np,iargc real*8 x,y real*8,allocatable:: a(:),b(:),ai(:) write(6,6000) 6000 format(/,' Integral of spectra in several ranges',/,/, 1 ' Usage: speave n a1 b1 ... an bn') 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' open(9,file=fl) open(8,file='t.prn') do 1 i=1,nf read(9,80)fn open(10,file=fn) ai=0.0d0 do 2 j=1,np read(10,*)x,y do 2 k=1,n 2 if(a(k).le.x.and.x.le.b(k))ai(k)=ai(k)+y 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,*) write(8,*) 1 close(10) 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