Date: Fri, 19 Sep 1997 13:35:00 -0400
Message-Id: <97091913350028@briaxa.bartol.udel.edu>
From: chuck@briaxa.bartol.udel.edu
To: Z1SBK@lepvgr.gsfc.nasa.gov
Subject: query_level1_file.for
X-VMS-To: SKRAMER

c... query_Level1_file.for..............................................
c
c  Routine to scan a Level-1 file and return basic statistics.
c  Statistics include:
c	(1)  Number of records (spacecraft major frames) in file,
c	(2)  Begin and end ACE frame count,
c	(3)  Begin and end MAG frame count,
c
c  Link to hdf library and decode_MAG_status.
c
c  C.W.S. -- 9/17/97, 9/19/97.
c.......................................................................
c
	Program query_Level1_file
c
      parameter (MAGNUMVCT=96)
      parameter (MAGVECDIM=3)
      parameter (FFTBIN=32)
      parameter (MJ_FFT_CYC=5)
      parameter (SNPVAL=21)
      parameter (SNAPCYCLELEN=340)
      character string*100
      integer*4 istat
c
      include '[chuck.acecodes.hdftools]maghskpset.inc'
      record /maghskpset/ hskpdat(5500)
      include '[chuck.acecodes.hdftools]magvectorset.inc'
      record /magvectorset/ vecdat(5500)
      include '[chuck.acecodes.hdftools]magfftset.inc'
      record /magfftset/ fftdat(1100)
      include '[chuck.acecodes.hdftools]magsnapset.inc'
      record /magsnapset/ snapdat(1100)
c
	integer*4 hskp_last_record, vec_last_record
	integer*4 fft_last_record, snap_last_record
	character*40 acedisk
	character*60 idget
	character*100 fileopen
c
	integer*4 first_MAG_frame_count, last_MAG_frame_count
      integer*4 status_frame_count, istatus(0:15), ST
	integer*4 Fs_SnapFreeze_FirstHalf, S_swap_FirstHalf
	integer*4 A_automan_B_FirstHalf, Range_B_FirstHalf
	integer*4 C_cal_B_FirstHalf, EF_flip_B_FirstHalf
	integer*4 M10_mode_FirstHalf, A_automan_A_FirstHalf
	integer*4 Range_A_FirstHalf, C_cal_A_FirstHalf
	integer*4 EF_flip_A_FirstHalf
	integer*4 CMD_comver, CM10_lastcom, STR210_snaptrig
	integer*4 EVT_snapevent, RS_snapstart
	integer*4 C3210_errorcnt, E3210_errortype
	integer*4 RP_snappage, S210_snapenable, Fb_FFTFramebit
	integer*4 Rg_FFTrangechange, Rf_ROMbit, CH_C10checksum
	integer*4 Ov_FFToverflow, Z_FFTzerosub, F5_FFTcomptype
	integer*4 F4_FFTfreqaversum, F3_FFTdiffenable
	integer*4 F2_FFTwindow, F1_FFTdespinmatrix, F0_despin
	integer*4 PCTEMP, CMON
	integer*4 Fs_SnapFreeze_ScndHalf, S_swap_ScndHalf
	integer*4 A_automan_B_ScndHalf, Range_B_ScndHalf
	integer*4 C_cal_B_ScndHalf, EF_flip_B_ScndHalf
	integer*4 M10_mode_ScndHalf, A_automan_A_Scndhalf
	integer*4 Range_A_ScndHalf, C_cal_A_ScndHalf
	integer*4 EF_flip_A_ScndHalf
	integer*4 HK1_softwarecntr, HK2_DEFTHRS
	integer*4 HK345_majorframecntr, ST_snapstatus
	integer*4 SYNC
	common /magframe_status_in/ status_frame_count, istatus, ST
	common /magframe_status_out/ Fs_SnapFreeze_FirstHalf, 	! ST1
     .	S_swap_FirstHalf, A_automan_B_FirstHalf, 
     .	Range_B_FirstHalf, C_cal_B_FirstHalf, 
     .	EF_flip_B_FirstHalf,
     .	M10_mode_FirstHalf, A_automan_A_FirstHalf, 		! ST2
     .	Range_A_FirstHalf, C_cal_A_FirstHalf, 
     .	EF_flip_A_FirstHalf,
     .	CMD_verify, CM10_lastcom, STR210_snaptrig, 		! ST3
     .	EVT_snapevent, RS_snapstart,
     .	C3210_errorcnt, E3210_errortype,				! ST4
     .	RP_snappage, S210_snapenable, Fb_FFTFramebit,		! ST5
     .	Rg_FFTrangechange, Rf_ROMbit, CH_C10checksum,
     .	Ov_FFToverflow, Z_FFTzerosub, F5_FFTcomptype,		! ST6
     .	F4_FFTfreqaversum, F3_FFTdiffenable, 
     .	F2_FFTwindow, F1_FFTdespinmatrix, F0_despin,
     .	PCTEMP, 								! PCTEMP
     .	CMON, 								! CMON
     .	Fs_SnapFreeze_ScndHalf, S_swap_ScndHalf, 			! ST1
     .	A_automan_B_ScndHalf, Range_B_ScndHalf, 
     .	C_cal_B_ScndHalf, EF_flip_B_ScndHalf,
     .	M10_mode_ScndHalf, A_automan_A_Scndhalf, 			! ST2
     .	Range_A_ScndHalf, C_cal_A_ScndHalf, 
     .	EF_flip_A_ScndHalf,
     .	HK1_softwarecntr, 						! HK1
     .	HK2_DEFTHRS,							! HK2
     .	HK345_majorframecntr, 						! HK3-5
     .	SYNC,									! SYNC
     .	ST_snapstatus 							! ST
c
	write(6,10)
   10	format(/' Routine query_Level1_file returns basic parameters',
     .	  ' of a Level-1 file.')
	idir = -1
	write(6,20)
   20	format(/' Give directory where file is stored:',
     .	 /5x,' [chuck.acedata.temporary] (response = 0)',
     .	 /5x,' [chuck.acedata.incoming]  (response = 1)',
     .	 /5x,' [chuck.acedata.level1]    (response = 2)')
	read(5,30) idir
   30	format(i2)
   40	continue
	if(idir .eq. 0) then
	    acedisk = 'bartol$user1:[chuck.acedata.temporary]'
	  else
	    if(idir .eq. 1) then
		  acedisk = 'bartol$user1:[chuck.acedata.incoming]'
		else
		  if(idir .eq. 2) then
		  	acedisk = 'bartol$user1:[chuck.acedata.level1]'
		    else
			write(6,50)
   50			format(' Not an acceptable response -- try again.')
			go to 40
		  endif
	    endif
	endif
	write(6,60)
   60	format(/' Give name of Level-1 dsname to fetch (a80):')
	read(5,70)idget
   70	format(a60)
	fileopen = acedisk//idget
c
	string = fileopen
      call hskpcall(istat,string,hskpdat,irec)
	hskp_last_record = irec
	if(irec .gt. 5500) then
	    write(6,81) irec
   81	    format(/' Housekeeping record = ',i6,' too long -- STOP!')
	    stop
	endif
c
      call veccall(istat,string,vecdat,irec)
	vec_last_record = irec
	if(irec .gt. 5500) then
	    write(6,82) irec
   82	    format(/' Vector record = ',i6,' too long -- STOP!')
	    stop
	endif
c
      call fftcall(istat,string,fftdat,irec)
	fft_last_record = irec
	if(irec .gt. 1100) then
	    write(6,83) irec
   83	    format(/' FFT record = ',i6,' too long -- STOP!')
	    stop
	endif
c
      call snapcall(istat,string,snapdat,irec)
	snap_last_record = irec
	if(irec .gt. 1100) then
	    write(6,84) irec
   84	    format(/' Snapshot record = ',i6,' too long -- STOP!')
	    stop
	endif
c
	write(6,100) hskp_last_record
  100	format(/' Number of housekeeping records is: ',i5)
	write(6,110) vec_last_record
  110	format(/' Number of vector records is: ',i5)
	write(6,120) fft_last_record
  120	format(/' Number of FFT records is: ',i5)
	write(6,130) snap_last_record
  130	format(/' Number of Snapshot records is: ',i5)
c
	write(6,200) hskpdat(1).sctime_collection, 
     .		 hskpdat(hskp_last_record).sctime_collection
  200	format(/' Span of spacecraft frame count in housekeeping is:',
     .	 /3x,i11,1x,' -- ',i11)
	write(6,210) vecdat(1).sctime_collection, 
     .		 vecdat(vec_last_record).sctime_collection
  210	format(/' Span of spacecraft major frame count in vectors is:',
     .	 /3x,i11,1x,' -- ',i11)
	write(6,220) fftdat(1).sctime_collection, 
     .		 fftdat(fft_last_record).sctime_collection
  220	format(/' Span of spacecraft major frame count in FFT is:',
     .	 /3x,i11,1x,' -- ',i11)
	write(6,230) snapdat(1).sctime_collection, 
     .		 snapdat(snap_last_record).sctime_collection
  230	format(/' Span of spacecraft major frame count in Snapshot is:',
     .	 /3x,i11,1x,' -- ',i11)
c
	istatus(0) = hskpdat(1).st1a
	istatus(1) = hskpdat(1).st2a
	istatus(2) = hskpdat(1).st3
	istatus(3) = hskpdat(1).st4
	istatus(4) = hskpdat(1).st5
	istatus(5) = hskpdat(1).st6
	istatus(6) = hskpdat(1).pctemp
	istatus(7) = hskpdat(1).cmon
	istatus(8) = hskpdat(1).st1b
	istatus(9) = hskpdat(1).st2b
	istatus(10) = hskpdat(1).hk1
	istatus(11) = hskpdat(1).hk2
	istatus(12) = hskpdat(1).hk3
	istatus(13) = hskpdat(1).hk4
	istatus(14) = hskpdat(1).hk5
	istatus(15) = hskpdat(1).sync
	call decode_MAG_status
	first_MAG_frame_count = HK345_majorframecntr
c
	istatus(0) = hskpdat(hskp_last_record).st1a
	istatus(1) = hskpdat(hskp_last_record).st2a
	istatus(2) = hskpdat(hskp_last_record).st3
	istatus(3) = hskpdat(hskp_last_record).st4
	istatus(4) = hskpdat(hskp_last_record).st5
	istatus(5) = hskpdat(hskp_last_record).st6
	istatus(6) = hskpdat(hskp_last_record).pctemp
	istatus(7) = hskpdat(hskp_last_record).cmon
	istatus(8) = hskpdat(hskp_last_record).st1b
	istatus(9) = hskpdat(hskp_last_record).st2b
	istatus(10) = hskpdat(hskp_last_record).hk1
	istatus(11) = hskpdat(hskp_last_record).hk2
	istatus(12) = hskpdat(hskp_last_record).hk3
	istatus(13) = hskpdat(hskp_last_record).hk4
	istatus(14) = hskpdat(hskp_last_record).hk5
	istatus(15) = hskpdat(hskp_last_record).sync
	call decode_MAG_status
	last_MAG_frame_count = HK345_majorframecntr
	write(6,300) first_MAG_frame_count, last_MAG_frame_count
  300	format(/' MAG frame count spans from ',i8,' to ',i8)
c
	stop
	end
