subroutine cmpopn(fnam,form,nflds,z,xflg) c c subroutine to open a new format composite file (or a conventional c time series file). If a new formatted file, depths will be returned c in z. File will be positioned at first data record. Bad value c flags will be returned in xflg. (if there isn't any FLAGS c header record, the values in xflg on entry will still be in c xflg on return. c dimension z(*),xflg(*) character fnam*(*),form*(*),formh*120,rest*30,head*160,idhd*5 COMMON/NAME/PROJ(2),MOOR,VNAM,ID,DELT,DEPTH,REST logical lflg c call fopen(1,fnam,'old') read(1,100,err=200)proj,moor,vnam,id,delt,depth,ihd 100 format(4a4,1x,i1,2f6.0,10x,i2) go to 300 c c read error assumed to be something odd in conventional time c series file, in the field we now use for number of following c headers c 200 ihd=0 c 300 do j=1,nflds z(j)=depth enddo c if(ihd.gt.0)then call formhr(form,nflds,formh,0) write(6,'(1x,a)')formh do I=1,ihd read(1,400)head 400 format(a) idhd=head(1:5) call caplyze(idhd) if(idhd.eq.'DEPTH')then read(head,formh)(z(j),j=1,nflds) depth=z(1) else if(idhd.eq.'FLAGS')then read(head,formh)(xflg(j),j=1,nflds) endif enddo endif c c check for possible unfilled flags c lflg=.false. do i=1,nflds if(xflg(i).ne.0.0)lflg=.true. enddo if(.not.lflg)write(6,500)fnam 500 format(//' **********WARNING from CMPOPN**********'/ - ' The bad value flags for ',A/ - ' are all equal to 0.0'/1x,39('*')) c return end