SUBROUTINE NXTEDR (ANS,JTB,JDATA,JNE,LSTAT,JTLMOD,JCLK,TEMPER * ,IEOF,ITLMP, TPTYPE ) c c John Belcher c c this is a new version of nxtedr written specifically c for VIM-5 (see Voyager Memo 182) c See Voyager Memo 191 for the format of the VIM-5 edr c We have a version of nxtedr.f written for Solaris and also for CentOS c see Voyager Memo 192 c IMPLICIT character*1(W), INTEGER*2(H) COMMON/JPLHED/WPID(3),W2N3,HNUM,WMODE,W6N7,HERT,HSEC,HMSEC,WYR, 2 W12N13,HEERT,HESEC,HEMSEC,WEYR,WVERS,HSCET,HSCSEC,HSMSEC,WSCYR, 3 W23,HMOD16,WMOD60,WLCNT1,WLCNT2,WDLTR,WEDLTR,WFID,WBET,WDSNEQ, 4 HAGC,WDSNN,WSPAR,HBER,HSNR,HDSNR,HPRN,HDQSW(10),WDRGC(162),WDRS, 5 WGCBER,HGBES,HLCNT,HDISC,MYMODE,IDSC COMMON/CMODE/IYR,IDOY,IHR,IMIN,SEC integer ilast,jlast character*1 cwyr c the next four lines are to get the correct value of character*1 last(4) character*1 nlast(4) equivalence (ilast,last) equivalence (jlast,nlast) integer IYR,count,nrecread,e1le2m,LSTAT,IPRT,idata(512),mstart integer np1,np2 integer kmod16 integer MWMOD60, MHMOD16, IHMOD16, IWMOD60 data IPRT/0/ character*1 c(16384) INTEGER*2 JTB(6),JNE,JDATA(512),JTLMOD,JCLK,JTLMAT(4) data jtlmat /3,1,4,2/ real ANS(200),temper(3), DT, DTMAT(4) data dtmat /-63.34, -42.2275, -21.10, 0.0125/ integer IEOD, ITLMP character*4 edr, tptype data IEOD /0/ DATA EDR /'EDR '/ TPTYPE=EDR data NRECREAD /0/ data n672 /0/ c NRECREAD is the number of data records read c c loop reading in edr file one record at a time c we only read in a new record based on the nrecrecord we have already read c To read a new record that number has to be a multiple of four c because each record we c read has four modes: L, E1, E2, and part of an M c and we return one mode at a time, so nxtedr.f has to be called c four times before we read another data record c 10 continue do 71 k = 1,512 idata(k) = 0 71 continue modrec = mod(nrecread,4) c write(6,5544) modrec,nrecread 5544 format("first modrec nrecread ",2i5) c if modrec is zero, we are either just starting or we have returned all the c data (E1,L,E2,M) associated with the data record read in, and we read in more if (modrec .ne. 0) go to 1122 call newreadbat(count,c,ieod) ieof = ieod if(IEOD == 1 ) go to 20 c write(6,8143) count 8143 format(" count from nxtedr ",i10) if(count .ne. 672) go to 10 c write(6,9970) n672 9970 format(" n672 = ",i6) c print out the 672 bytes of c data if desired do 1123 k = 1,672 k1 = k-1 c write(6,1134) k1,c(k) 1123 continue 1134 format(I5,z10) 1122 continue c unless this is a data record of the correct length c ignore the data read in and read in some more c if the E1 mode status word is zero c ignore the data read in and read in some more call l1xnew(c(274),intez) c write(6,9988) intez 9988 format(" intez = ",i10) if(intez .eq. 0 ) go to 10 c at this point we have a data record with a good status word in E1 c and we will start returning data back up to the calling routine c Set the mode which we are going to return for this call to nxtedr c E1LE2M = 1,2,3,4 for E1, L, E2, M NOTE the order is NOT jtlmod c reset the entire idata array do 1001 k = 1,512 1001 idata(k) = -1 JCLK = 3 c we have data we are going to return, what mode? E1LE2M = modrec +1 JTLMOD = JTLMAT(E1LE2M) c write(6,1099) modrec,jtlmod 1099 format('modrec jtlmod ', 2i10) DT = DTMAT(E1LE2M) c go to (1000,2000,3000,4000), jtlmod 1000 continue c we are returning an L mode c lstat = istnew(c(291)) jne = 16 call istnew(c(291),lstat) c put the approprate dn values in idata do 1002 l = 1,4 do 1002 m = 1,16 np1 = m + (l-1)*16 np2 = 291 + l + (m-1)*4 call l1xnew(c(np2),idata(np1)) c write(6,7790) l,m,np1,np2,idata(np1),c(np2) 7790 format("L ",5I5,z15) c idata(np1) = l1xnew(c(np2)) 1002 continue go to 5000 2000 continue c c we are returning an M mode c lstat = istnew(c(375)) jne = 128 call istnew(c(375),lstat) c determine the mstart value c IWMOD60 = l1xnew(WMOD60) c CALL MVC5 (HMOD16, kMOD16, 2, 0, 2) c instead of above statment, do all sorts of screwy things c to get the proper value of MHMOD16 ilast = hmod16 nlast(1) = last(2) nlast(2) = last(1) c kmod16 must be integer for mod(kmod16,2) to work right kmod16 = jlast MHMOD16 = mod(kmod16,2) c write(6,1923) last,nlast,ilast,jlast,ilast,jlast 1923 format(8z8,4I10) call l1xnew(WMOD60,IWMOD60) MWMOD60 = MOD(IWMOD60,8) mstart = 0 if(iwmod60.eq.4.and.mhmod16.eq.0) mstart = 54 c write(6,9914) wmod60,c(33),c(34),kmod16,kmod16 9914 format('wmod60 ',z9,' HMOD16_1 ',z9,' HMOD16_2 ',2z9,i9) c write(6,9911) iwmod60, mhmod16, mstart c write(6,9912) iwmod60, mhmod16, mstart 9911 format('iwmod60 ',i9,' mhmod16 ', i9,' mstart ',i12) 9912 format('iwmod60 ',z9,' mhmod16 ', z9,' mstart ',z9) c put the approprate dn values in idata do 1006 l = 1,4 do 1006 m = 1,74 np1 = mstart + m + (l-1)*128 np2 = 375 + l + (m-1)*4 call l1xnew(c(np2),idata(np1)) c idata(np1) = l1xnew(c(np2)) c write(6,7789) mstart,l,m,np1,np2,idata(np1),c(np2) 7789 format("M ",6I5,z15) 1006 continue c write(6,7782) 7782 format("finished the M") go to 5000 3000 continue c we are returning an E1 c lstat = istnew(c(274)) jne = 16 call istnew(c(274),lstat) c put the appropriate dn values in idata do 1003 m = 1,16 np2 = 274 + m c idata(m) = l1xnew(c(np2)) call l1xnew(c(np2),idata(m)) 1200 format(z8,I8,z9,z9) c write(6,7788) m,np2,idata(m),c(np2) 7788 format("E1 ",3I5,z15) 1003 continue go to 5000 4000 continue c we are returning an E2 c lstat = istnew(c(356)) jne = 16 call istnew(c(356),lstat) do 1004 m = 1,16 np2 = 356 + m call l1xnew(c(np2),idata(m)) c idata(m) = l1xnew(c(np2)) c write(6,7791) m,np2,idata(m),c(np2) 7791 format("E2 ",3I5,z15) 1004 continue c 5000 continue c fill jdata (integer*2) from idata (integer*4) do 1005 k = 1,512 1005 jdata(k) = idata(k) c c find the time associated with the SCET of this record c call mvc(c(274),wtest,1) CALL MVC(c(1),WPID(1),240) c 1/25/2023 c FIX ERT VS SCET PROBLEM HERE, WAS USING WYR BEFORE call l1xnew(wscyr,IYR) c IYR = l1xnew(wyr)+2000 IYR = IYR +2000 c reverse the byte order in the three integter*2 time variables c for running on centos (big endian little endian problem) call int2(hscet,h1) call int2(hscsec,h2) call int2(hsmsec,h3) CALL TIME(h1,h2,h3,IDOY,IHR,IMIN,SEC) c write(6,2415) IYR, hscet,h1,hscsec,h2,hsmsec,h3 2415 format(' this is centos nxtedr ',7z10) c write(6,2415) IDOY,IHR,IMIN c CALL TIME(HSCET,HSCSEC,HSMSEC,IDOY,IHR,IMIN,SEC) C DETERMINE TIME FOR THIS MODE USING THE PROPER OFFSET C FROM THE SCET TIME FOR THE RECOR D. DT IS THE OFFSET SEC = SEC+DT 2001 IF (SEC.GE.0.0) GO TO 2002 SEC = SEC + 60 IMIN = IMIN - 1 GO TO 2001 2002 IMIN = IMIN+IFIX(SEC/60.0) SEC = AMOD(SEC,60.0) 2005 IF (IMIN.GE.0) GO TO 2003 IMIN = IMIN + 60 IHR = IHR - 1 GO TO 2005 2003 IHR = IHR+IMIN/60 IMIN = MOD(IMIN,60) 2006 IF (IHR.GE.0) GO TO 2004 IHR = IHR + 24 IDOY = IDOY - 1 GO TO 2006 2004 IDOY = IDOY+IHR/24 IHR = MOD(IHR,24) 2008 IF ( IDOY.GT.0 ) GO TO 2007 IYR = IYR - 1 IDOY = 365 + ( 3 - MOD(IYR,4) ) / 3 + IDOY GO TO 2008 2007 IF (IDOY.LE.365+(3-MOD(IYR,4))/3) GO TO 2010 IDOY = IDOY-365-(3-MOD(IYR,4))/3 IYR = IYR+1 GO TO 2007 2010 IF (IYR.LT.1900) IYR=IYR+1900 JTB(1) = IYR JTB(2) = IDOY JTB(3) = IHR JTB(4) = IMIN JTB(5) = SEC JTB(6) = MOD(IFIX(SEC*1000.0),1000) c write(6,1209) jtb,jtlmod,modrec,iprt,nrecread 1209 format(" finished this mode ",10i5) c c CALL MVC(LRAY(1),WPID(1),240) c CALL MVC (LRAY(61),SUBRAY(1),88) c CALL MVC(SUBRAY(57),I,4) c SEC = I c if (modrec .ne. 0 .or. iprt .eq. 0) go to 50 c print out the 672 bytes of c data if desired do 60 m = 1,84 m1 = (m-1)*8+1 m2 = m*8 c write(6,2391) (n,c(n),n=m1,m2) 2391 format(8(I4,Z6)) 60 continue 50 continue c if we are here we have returned data back upstairs for one of the four c modes, and we increment nrecread nrecread = nrecread+1 c write(6,2392) nrecread 2392 format("have returned data back upstairs for one of 4 ",i5) 20 continue return end SUBROUTINE TIME(HOUR,HSEC,HMISEC,IDAY,IHOUR,IMIN,SEC) INTEGER*2 HOUR,HSEC,HMISEC MHOUR = HOUR MSEC = HSEC RMISEC = HMISEC IDAY = 0 IF (MHOUR .GE. 24) IDAY = MHOUR/24 IHOUR = MOD(MHOUR,24) IMIN = 0 IF (MSEC .GE. 60) IMIN = MSEC/60 JSEC = MOD(MSEC,60) SEC = JSEC IF (RMISEC .GT. 0) SEC = JSEC + RMISEC / 1000 RETURN end