C+ C NAME: C T3D_Read_B C PURPOSE: C Get RTN magnetic field components at source surface C (currently we only worry about the radial component) C CATEGORY: C I/O C CALLING SEQUENCE: logical function T3D_Read_B(cWild,BListFnc,BReadFnc,TTime,XCbeg,XCend,BR) C INPUTS: C cWild*(*) character wild card specification for locating magnetic field files C either a straightforward wildcard spec or specified in C the format used by href=ForeignFile=. C C BListFnc external name of integer function ued by MapReadSingle and MapReadTimes C BReadFnc external name of integer function used to read individual files C C TTime(nTim) real (time-dependent tomography only) C Times at which magnetic field is required C XCbeg(nTim) real start Carrington variable of matrix (- NCoff) C XCend(nTim) real end Carrington variable of matrix (- NCoff) C (range of matrix typically is three Carrington rotations) C OUTPUTS: C BR(nLng,nLat,nTim) real radial magnetic field C CALLS: C T3D_get_grid, T3D_get, T3D_iget, T3D_get_mode, MapReadSingle, MapReadTimes, ArrR4Zero C Int2Str, Str2Str, XCvarFormat, Say, ArrR4GetMinMax, ArrR4Bad C INCLUDE: include 'sun.h' include 't3d_array.h' C EXTERNAL: external BListFnc external BReadFnc C PROCEDURE: C The main program should indicate whether magnetic fields are to C be retrieved for corotating or time-dependent tomography by adding the C following two lines, including a call to href=T3D_set_mode=: C C For corotating tomography: C C include 't3d_array.h' C call T3D_set_mode(T3D__MODE_TIME,0) C C For time-dependent tomography: C C include 't3d_array.h' C call T3D_set_mode(T3D__MODE_TIME,1) C C This information is retrieved by a href=T3D_get_mode= call. Depending C on the retrieved setting MapReadSingle or MapReadTimes is called for C corotating and time-dependent tomography, respectively. C MODIFICATION HISTORY: C MAY-2002, Paul Hick (UCSD/CASS) C SEP-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Made argument names consistent with MapReadSingle C and MapReadTimes. C- character cWild*(*) real TTime(*) real XCbeg(*) real XCend(*) real BR(*) character cSay*10 /'T3D_Read_B'/ real Tiny /2.0e-5/ character cInt2Str*14 character cXCvarFormat*9 call T3D_get_grid(TT,dTT,RR,dRR,nLng,nLat,nRad,nTim, dTTi,nLng1,nLat1) nMap = nLng*nLat*nTim ! # bins at source surface call T3D_iget(T3D__NCOFF,0,NCoff) !------- ! Check whether corotating or time-dependent tomography is run call T3D_get_mode(T3D__MODE_TIME,I) if (I .eq. 0) then ! Corotating tomography call Say(cSay,'I','Corotating','CR-range is ['// & cXCvarFormat(NCoff,XCbeg)//'-'//cXCvarFormat(NCoff,XCend)//']') if (nTim .ne. 1) stop 'T3D_Read_B: oops' !------- ! All magnetic data in the range [XCbeg,XCend] are combined ! using a weighted mean. T3D_Read_B = MapReadSingle(cWild,BListFnc,BReadFnc, & NCoff,XCbeg,XCend,nLng,nLat,BR,R0) .eq. 1 else ! Time-dependent tomography !------- ! If only a single time is fed to MapReadTimes, the time must be ! bracketed by two files, or an array filled with bad values is ! returned. The spline interpolation in this case reduces to a ! linear interpolation. nRad = 1 call ArrR4GetMinMax(nTim,XCbeg,XCbegMin,XCbegMax) call ArrR4GetMinMax(nTim,XCend,XCendMin,XCendMax) call Say(cSay,'I','Time-dependent','Number of times in ['// & cXCvarFormat(NCoff,TTime(1))//'-'//cXCvarFormat(NCoff,TTime(nTim))//']: '//cInt2Str(nTim)) if (XCbegMin .eq. XCbegMax .and. XCendMin .eq. XCendMax) then !------- ! If all values in XCbeg and XCend are the same the interpolation ! can be done in one shot. T3D_Read_B = MapReadTimes(cWild,BListFnc,BReadFnc, & NCoff,nTim,TTime,XCbeg,XCend,nLng,nLat,nRad, BR,R0) .eq. 1 else call Say(cSay,'W','The hard way','varying matrix limits') nBin = nLng*nLat*nRad T3D_Read_B = .TRUE. do iTim=1,nTim iP = (iTim-1)*nBin+1 T3D_Read_B = T3D_Read_B .and. MapReadTimes(cWild,BListFnc,BReadFnc, & NCoff,1,TTime(iTim),XCbeg(iTim),XCend(iTim),nLng,nLat,nRad, BR(iP),R0) .eq. 1 end do end if end if !------- ! MapReadSingle and MapReadTimes will NOT return a bad array when the return ! status is .FALSE. Do this here. Also make sure the tomography source ! surface is the same as the magnetic source surface. if (T3D_Read_B .and. abs(RR-R0) .gt. Tiny) & call Say(cSay,'E','Inconsistent','tomography and magnetic source surfaces') T3D_Read_B = T3D_Read_B .and. abs(RR-R0) .le. Tiny if (.not. T3D_Read_B) then call Say(cSay,'W','B-field','no magnetic field data found') call ArrR4Bad(nMap,BR) end if return end