C+ C NAME: C iReadG C PURPOSE: C Read G values from unedited G*. files containing Cambridge IPS data C CATEGORY: C Data processing C CALLING SEQUENCE: function iReadG(cDat,iEdt,MJD,XG) C INPUTS: C cDat character*(*) logical name for data directory C iEdt integer 0 : read unedited files g*. C 1 : read edited files e*.dat C MJD integer (read-only) C modified Julian day (JD-2400000.5) for C the requested file C OUTPUTS: (NTIME=72,NDEC=14) C iReadG integer = 0 if file was not opened succesfully C = 1 if file was opened C = 3 if file contained no valid points C XG(NTIME,NDEC) real G-factors C Each observation XG refers to a line of sight extending from Earth. C CALLS: C iFilePath, bOpenFile, iFreeLun, ReadGHD C INCLUDE: include 'dirspec.h' include 'openfile.h' C RESTRICTIONS: C > Input files are searched for in the directory assigned to logical $CAM C > Make sure to test iOK before using the output arrays (the arrays are C not always cleared before returning; you may end up using the values C from a previous call to iReadG) C PROCEDURE: C See ReadG C MODIFICATION HISTORY: C SEPT-1992, Paul Hick (UCSD), stripped version of ReadG. C- parameter (NTIME = 72) parameter (NDEC = 14) character cDat*(*) integer iEdt integer MJD real XG(NTIME,NDEC) ! G-factors character cZEdt(0:1)*8 /'(14Z2.0)','(14F8.3)'/ character cEdt (0:1) /'g','e'/ character cExt (0:1)*4 /'. ','.dat'/ character cFile*80 character cDum*5 integer IG(NDEC) real GG(NDEC) equivalence (IG,GG) logical bEOH logical bOpenFile I = iFilePath(cDat,0,' ',cEdt(iEdt)//cFile(:Int2Str(MJD,cFile))//cExt(iEdt),cFile) iReadG = 0 if (.not. bOpenFile(OPN__REOPEN+OPN__TEXT+OPN__READONLY,iU,cFile,iRecl)) return! Open data file iReadG = 3 ! File opened, but may be empty if (iEdt .eq. 1) then read (iU,'(A)',iostat=I) cDum bEOH = I .eq. 0 else ! Read file header section call ReadGHD(MJD,iU,cFile, bEOH,GMAX,G0) end if if (.not. bEOH) then iU = iFreeLun(iU) return ! Return with iOK=3 (empty file) end if NP = 0 if (iEdt .eq. 0) then do I=1,NTIME ! Read NTIME records from data file read (iU,cZEdt(iEdt)) IG ! Read rec of hex nrs from file do J=1,NDEC XG(I,J) = -1. ! If no G-value available if (IG(J) .gt. 0) then XG(I,J) = GMAX**(IG(J)/G0-1.) ! G-factor NP = NP+1 end if end do end do else do I=1,NTIME ! Read NTIME records from data file read (iU,cZEdt(iEdt)) GG do J=1,NDEC XG(I,J) = -1. ! If no G-value available if (GG(J) .gt. 0) then XG(I,J) = GG(J) NP = NP+1 end if end do end do end if iU = iFreeLun(iU) ! Close data file if (NP .ne. 0) iReadG = 1 ! File contains valid data return end