C+ C NAME: C ReadGHD C PURPOSE: C Read file header from unedited G*. file or edited E*.DAT file, C containing Cambridge IPS data C CATEGORY: C Data processing C CALLING SEQUENCE: subroutine ReadGHD(MJD,iU,cFile, bEOH,GMAX,G0) C INPUTS: C MJD integer (read-only) C modified Julian day (JD-2400000.5) for C the requested file C iU integer file logical unit number C cFile character*(*) file name C OUTPUTS: C bEOH logical .TRUE. if header read C .FALSE. if error in header C GMAX,G0 real scaling factors for G values C CALLS: C Say, Julian, DATE_DOY, itrim, Str2Flt, Str2Flt_Crumbs C INCLUDE: include 'sun.h' C PROCEDURE: C Reads header and checks for consistency. Inconsistencies result C in a program abort or return with bEOH=.FALSE. C MODIFICATION HISTORY: C SEP-1992, Paul Hick (UCSD), extracted from READG.FOR C- integer MJD integer iU character cFile*(*) ! Input file name logical bEOH real GMAX real G0 parameter (NTIME=72) parameter (NDEC=14) character cMon*3 character cSay*100 character cRec*100 ! Buffer for reading input files character cRecs(5)*20 equivalence (cRec,cRecs) real DEC_LIST(NDEC) real DEC_REF(14) /-7.8, 1.9, 9.8,16.9,23.4,29.5,35.4, & 41.0,46.6,52.1,57.7,63.2,68.9,74.8/ real RVEC(6) real*8 JD real*8 JEpoch cSay = cFile iSay = itrim(cFile) !------- ! Read header section of data file (for unedited data only): ! UT start time, list of declinations, # records/day, scaling factors GMAX ! and G0 for calculation of G-factors bEOH = .FALSE. ! bEOH = End Of Header read (iU,'(A)',iostat=I) cRec do while (I .eq. 0 .and. .not. bEOH) if (index(cRec,'UTSTART: ') .ne. 0) then N = 5 call Str2Flt(cRec,N,RVEC) if (N .eq. 5) then ! Date in form 01-JAN-1978 00:00:00 iDay = RVEC(1) N = 5 call Str2Flt_Crumbs(I,N,cRecs) cMon = cRecs(2)(2:4) iYr = -RVEC(2) else ! Date in form 01/01/78 iDay = RVEC(1) iMon = RVEC(2) cMon = ' ' ! Make sure to use iMon iYr = 1900+RVEC(3) end if call DATE_DOY(0,iYr,cMon,iMon,iDay,iDoy) Doy = iDoy call Julian(0,iYr,Doy,JD,JEpoch) if (nint(JD-SUN__MJDtoJD) .ne. MJD) then cSay(iSay+1:) = ' : inconsistent file date' call Say('ReadGHD','E','ERRJD',cSay) end if end if if (index(cRec,'NDEC:') .ne. 0) then N = 1 call Str2Flt(cRec,N,RVEC) if (int(RVEC(1)) .ne. NDEC) then cSay(iSay+1:) = ' : funny # declinations' call Say('ReadGHD','E','ERRDECL',cSay) end if read (iU,'(A)') cRec if (index(cRec,'DEC_LIST:') .eq. 0) then cSay(iSay+1:) = ' : NDEC record not followed by DEC_LIST record' call Say('ReadGHD','E','ERRDECL',cSay) end if N = NDEC call Str2Flt(cRec,N,DEC_LIST) if (N .ne. NDEC) then cSay(iSay+1:) = ' : incorrect number of declinations read' call Say('ReadGHD','E','ERRDECL',cSay) end if do I=1,NDEC if (DEC_LIST(I) .ne. DEC_REF(I)) then cSay(iSay+1:) = ' : unexpected declination found' call Say('ReadGHD','E','ERRDECL',cSay) end if end do end if if (index(cRec,'NTIME:') .ne. 0) then N = 1 call Str2Flt(cRec,N,RVEC) ITIME = RVEC(1) if (ITIME .ne. NTIME) then cSay(iSay+1:) = ' : funny # times' call Say('ReadGHD','E','ERRTIME',cSay) end if end if if (index(cRec,'MAP_PARAMS:') .ne. 0) then N = 6 call Str2Flt(cRec,N,RVEC) GMAX = RVEC(3) G0 = RVEC(4) end if bEOH = index(cRec,'MAP:') .ne. 0 ! Get next header record if (.not. bEOH) read (iU,'(A)',iostat=I) cRec end do if (.not. bEOH) then cSay(iSay+1:) = ' : no proper end of header identified' call Say('ReadGHD','W','ERRHEADER',cSay) end if return end