C+ C NAME: C HOSUpdate C PURPOSE: C Update Helios data file C CATEGORY: C I/O: Helios C CALLING SEQUENCE: subroutine HOSUpdate(iD,cFile,nT,iT,NN,TT,PP,CC,FF,RR,LL,nS,ZZ) C INPUTS: C iD integer identifies data properties C each bit identifies a property defined in include file hos_e9.h C Bits are set by summing parameters defined in the include file. C C Bits used are: C HOS__SWAP_SECT: if set sectors are assumed to be ordered by C modified sector number (see PROCEDURE). C HOS__NONORM: the color is set to 1,2 or 3 if this bit is not set; C and to 101,102,103 if this bit is set C HOS__OS_*: passed to iHOSRead C C cFile character*(*) name of file to be updated C nT integer (not used) C iT integer number of records C N(iT) integer record number C Only record numbers which have the C sign bit set will be updated C T(iT) real times (day of year) C P(iT) integer photometer (1/2/3) C C(iT) integer colors (1/2/3) C F(iT) integer filters (1/2/3/4/5) C R(iT) real heliocentric distance (AU) C L(iT) real ecliptic longitude of Sun C nS integer # sectors C Z(nS,iT) real intensities C OUTPUTS: C Output to existing Helios file C CALLS: C bOpenFile, iHOSRead, iHOSWrite, ArrR4Copy, cInt2Str, Say, iwhitespace C INCLUDE: include 'openfile.h' include 'hos_e9.h' C SIDE EFFECTS: C > The sign bit of all NN elements are cleared again. C > Argument nT is not used C > Each record is read by iHOSRead. This defines the no-normalization bit passed C to the subsequenc write by iHOSWrite. C RESTRICTIONS: C The setting of the swap bit (HOS__SWAP_SECT) in iD should be the same as used C in the call to HOSRead used to fill the original arrays. C PROCEDURE: C > The arrays are usually read using HOSRead (the argument lists C of HOSUpdate, HOSWrite and HOSRead are identical). The record number array C NN refers to the file read by HOSRead C > A record number can be marked for update by setting the sign bit C using: NN(I) = IBSET(NN(I),31) C > By default (HOS__SWAP_SECT not set) the nS sectors of the intensity C array are assumed to refer to sectors 1..nS/2,33-nS/2,..32, and are C written to file in that order. C > If the swap bit (HOS__SWAP_SECT) is set in iD, then the sectors are assumed C to be ordered by modified sector number: 1-nS/2,...nS/2, corresponding to normal C sector numbers: 33-nS/2,..32,1,..,nS/2, i.e. the first and second C half are swapped. The sectors will be swapped back into normal order C before being written to file by iHOSWrite C MODIFICATION HISTORY: C SEP-1998, Paul Hick (UCSD/CASS) C MAY-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu), updated handling of data properties in iD C- integer iD character cFile*(*) integer nT integer iT integer NN(*) real TT(*) integer PP(*) integer CC(*) integer FF(*) real RR(*) real LL(*) integer nS real ZZ(*) character cStr*80 character cInt2Str*14 character cSay*9 /'HOSUpdate'/ logical bOpenFile logical bSwap integer P integer C integer F real L real Z(32) if (bOpenFile(OPN__HOS+OPN__REOPEN,iU,cFile,iRecl)) then !------- ! We will access the record by explicitly specifying record number. ! To do this we need to clear data selection bits for iHOSRead and iHOSWrite. ! Note that the architecture bits are copied for the benefit of iHOSRead. iDW = iD-iand(iD,HOS__PCF_ALL) iDR = iDW ! iHOSRead modifies the un-normalized bit bSwap = iand(iD,HOS__SWAP_SECT) .ne. 0 iS = nS/2 iW = 0 do I=1,iT if (BTEST(NN(I),31)) then ! Check sign bit iR = IBCLR(NN(I),31) ! Get record # by removing sign if (iHOSRead(iDR,iU,iRecl,iR,T,P,C,F,R,L,32,Z) .eq. 0) then if (T .ne. TT(I) .or. P .ne. PP(I) .or. C .ne. CC(I) .or. & (P .ne. 3 .and. F .ne. FF(I))) call Say(cSay,'E','Oops','oops') iZt = (I-1)*nS+1 if (PP(I) .ne. 3 .and. bSwap) then call ArrR4Copy(nS,ZZ(iZt),Z) ! Copy nS sectors into Z call ArrR4Copy(iS,Z ,ZZ(iZt+iS))! Swap 1st and last nS/2 sectors .. call ArrR4Copy(iS,Z(iS+1),ZZ(iZt ))! .. in reverse order end if if (iHOSWrite(iDW,iU,iRecl,iR, & TT(I),PP(I),CC(I),FF(I),RR(I),LL(I),nS,ZZ(iZt)) .eq. 0) iW = iW+1 end if NN(I) = iR end if end do iU = iFreeLun(iU) end if cStr = cInt2Str(iW)//' out of '//cInt2Str(iT)//' records updated' I = iwhitespace(cStr) if (iW .gt. 0) call Say(cSay,'I',cFile,cStr) return end