C C+ C NAME: C get_bbtm_3 C PURPOSE: C Get magnetic field output in three coordinates at the cadence of the tomography program C CATEGORY: C I/O C CALLING SEQUENCE: subroutine get_bbtm_3(XCbeGG,nLng,nLat,nT,RR,BFACTORRR,BFACTORRC,BFACTORTC,BFACTORNC,FALLOFFBN, & TT3D,BRss,BRCs,BTCs,BNCs,iBflag) C INPUTS: C XCbeGG(2,nT+1) real Somehow related to the tomography times C Only XCbeGG(1,1) and XCbeGG(2,1) are used C internally as the last valid time in TT3D) C nLng integer # of longitude steps C nLat integer # of latitude steps C nT integer # of time steps C RR real Source surface height of magnetic maps C C BFACTORRR real A multiplicative factor used to provide a magnetic field enhancement over the CSSS C as suggested by T. Hoeksema (Fall AGU 2013) C BFACTORRC real A multiplicative factor used to provide a closed r field enhancement over the usual C C BFACTORTC real A multiplicative factor used to provide a closed t field enhancement over the usual C C BFACTORNC real A multiplicative factor used to provide a closed n field enhancement C C FALLOFFBN real Normal Field fall-off. This was found from the Helios spacecraft to be 1.34 C C TT3D(nT3D) real Carrington times - XCintG C These will most likely will be ttimes spaced at the regular intervals C of the tomography cadence in UT converted to Carrington times. C BRss(nLng,nLat,nT+1) real scratch array; CSSS radial source surface magnetic field C C BRCs(nLng,nLat,nT+1) real scratch array; Closed radial source surface magnetic field C C BTCs(nLng,nLat,nT+1) real scratch array; Closed tangential source surface magnetic field C C BNCs(nLng,nLat,nT+1) real scratch array; Closed normal source surface magnetic field C C iBflag integer The number of the magnetic maps found as in b3d_param_3.h as B3D__PREFIX(B3D__N) C OUTPUTS: C (to file) C INCLUDE: include 'sun.h' include 't3d_array_3.h' include 'b3d_param_3.h' C CALLS: C FLINT, T3D_write_bb_3, T3D_get, T3D_set, T3D_iget, T3D_iset, T3D_get_grid_3 C ArrR4Step, ArrR4Constant, ArrR4Interpolate, BadR4, BField_Get_3, Say C ArrR4TimesConstant C PROCEDURE: C C > The radial dependence of Br follows from flux conservation: C Br = BB*(RR/r)^2 C The tangential component follows from geometrical considerations C by assuming that the magnetic field lies along the Parker spiral: C (Omega is angular velocity of Sun): C Bt/Br = r*cos(Lat)*Omega/V C Bt = BB*(Omega*RR*cos(Lat)/V)*(RR/r) C Output are 'normalized' magnetic field components (making the C values independent of radial distance): C r^2*Br = RR^2*BB C r *Bt = RR^2*BB *Omega*cos(Lat)/V C Expressing radial distances in units of r0 = 1 AU): C (r/r0)^2*Br = (RR/r0)^2*BB C (r/r0) *Bt = (RR/r0)^2*BB * r0*Omega*cos(Lat)/V C In terms of quantities defined in include file sun.h: C r0*Omega/V = Sun__AU*10^13*Sun__Omega*10^-6/(V[km/s]*10^5) = 100*Sun__AU*Sun__Omega/V[km/s] C C We are mostly interested in magnetic field at Earth, i.e. about r0=1 AU. C Insitu magnetic field are usually expressed in nT, so we use the same units here. C We write 'normalized magnetic fields' in units of nT to file: (RR/r0)^2*Br for the radial C and (RR/r0)*Bt for the tangential component. These quantities should be more or less C constant across the heliosphere, since the radial dropoff has been taken out. At 1 AU C (RR/r0 = 1) it should reproduce the insitu values. C C *TJD*'s unit troubles C X's output is in mT or 10^-2G. to bring to nT: C (15/215)^2 * (10^-6 T / mT) (10^9 nT/ T) C C MODIFICATION HISTORY: C SEP-1999, Paul Hick (UCSD/CASS) C ???-2002, Tamsen Dunn (UCSD/CASS; tdunn@ucsd.edu) Made time dep., fleshed out. C JUL-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Valid magnetic fields are returned only in grid points where the C source surface Br and V are valid. Previously Br would be valid C if only the source surface Br was valid (even if V was bad). C AUG-2002, Tamsen Dunn (UCSD/CASS; tdunn@ucsd.edu) C Altered Bt component to depend entirely on V3D. If V3D is bad, use VSS. C This revealed bug below: C SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Fixed big error in use of XC3D (did not take into account that the time dimension C was different from the V3D array). Now three pieces of information are expected C that are calculated by Write3D_info: TT3D, times at which magnetic fields are C required; XC3D and V3D: shifts and velocity at times TT3D. XC3D and V3D now have C the same dimensions. C JUN-2003, Paul Hick (UCSD/CASS) C Added processing of multiple magnetic field types C OCT-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added extra arguments iT3D and jT3D C JUN-2016, B Jackson converted this to get 4 components of field at the cadence of the tomography program: C (1) the usual (open-field) CSSS model radial fields C (2) closed-fields from a model (usually CSSS) C (3) tangential closed-fields from a model (usually CSSS) C (4) normal closed-fields from a model (usually CSSS) C- real XCbeGG(*) ! (2,nT+1) integer iT3D integer nT3D real TT3D(*) real BRss(*) real BRCs(*) real BTCs(*) real BNCs(*) character cSay*10 /'Get_bbtm_3'/ real eps /0.00002/ integer iBBFlag(4) logical BField_Get_3 integer iB parameter (nMaxT = 600) real XCbegMAT(nMaxT) real XCendMAT(nMaxT) include 't3d_grid_fnc.h' nTp1 = nT+1 !------- ! Update T3D structure. Storing nT3D is essential because BField_Get_3 will use this ! to determine the dimension of the TT3D array. call T3D_iset(T3D__NTIM , 0, nTp1) if (nTp1 .gt. nMaxT) call Say(cSay,'E','nMaxT','parameter too small') call ArrR4Constant(nTp1,XCbeGG(1),XCbegMAT) call ArrR4Constant(nTp1,XCbeGG(2),XCendMAT) FIXBRCs = ((1.0/RR)**(2.0-FALLOFFBN)) ! Fixes the components to comply with Parker falloff (BVJ 2/2/2016) FIXBTCs = ((1.0/RR)**(1.0-FALLOFFBN)) FIXBNCs = -((1.0/RR)**(-FALLOFFBN)) ! Fixes the normal component to comply with a -RR**-1.34 fall-off (BVJ 5/5/2016) do iB=1,B3D__N ! there are four types of magnetic field data possible so far: B3D__N = 4 do iBB=1,4 ! Set flags for all component maps zero at begining iBBFlag(iBB) = 0 end do do iBB=1,4 ! there are four possible component maps for each magnetic field !------- ! The magnetic field is returned in nano Tesla (nT). if (iBB .eq. 1) then if (BField_Get_3(iB,iBB,TT3D,XCbegMAT,XCendMAT,BRss)) then iBBFlag(IBB) = 1 print *, 'Out of BField_Get_3 iBB = ', IBB go to 22 ! rr field end if else if (iBB .eq. 2) then if (BField_Get_3(iB,iBB,TT3D,XCbegMAT,XCendMAT,BRCs)) then iBBFlag(IBB) = 1 print *, 'Out of BField_Get_3 iBB = ', IBB go to 22 ! rc field end if else if (iBB .eq. 3) then if (BField_Get_3(iB,iBB,TT3D,XCbegMAT,XCendMAT,BTCs)) then iBBFlag(IBB) = 1 print *, 'Out of BField_Get_3 iBB = ', IBB go to 22 ! rt field end if else if (iBB .eq. 4) then if (BField_Get_3(iB,iBB,TT3D,XCbegMAT,XCendMAT,BNCs)) then iBBFlag(IBB) = 1 print *, 'Out of BField_Get_3 iBB = ', IBB go to 22 ! rn field end if end if if((iBBFlag(1)+iBBFlag(2)+iBBFlag(3)+iBBFlag(4)).eq.0) go to 23 ! no rr, rc, rt, or rn field data 22 continue if(iBB.eq.1) Write(*,'(A,2I3,2F10.5)') 'Get_bbtm 3 got CSSS regular fields ',iBB,iB,RR*RR,BFACTORRR if(iBB.eq.2) Write(*,'(A,2I3,2F10.5)') 'Get_bbtm_3 got radial closed fields ',iBB,iB,FIXBRCs,BFACTORRC if(iBB.eq.3) Write(*,'(A,2I3,2F10.5)') 'Get_bbtm_3 got tangential closed fields',iBB,iB,FIXBTCs,BFACTORTC if(iBB.eq.4) Write(*,'(A,2I3,2F10.5)') 'Get_bbtm_3 got normal closed fields ',iBB,iB,FIXBNCs,BFACTORNC !------- ! Distance normalization: multiply radial component BR3D by RR*RR. ! The resulting r^2*Br should be in the range 1-10 nT. if(iBB.eq.1) call ArrR4TimesConstant(-nLng*nLat*nTp1,BRss,RR*RR*BFACTORRR,BRss) if(iBB.eq.2) call ArrR4TimesConstant(-nLng*nLat*nTp1,BRCs,RR*RR*FIXBRCs*BFACTORRC,BRCs) !((RR/1.3)**(2.0-1.34)) if(iBB.eq.3) call ArrR4TimesConstant(-nLng*nLat*nTp1,BTCs,RR*FIXBTCs*BFACTORTC,BTCs) if(iBB.eq.4) call ArrR4TimesConstant(-nLng*nLat*nTp1,BNCs,FIXBNCs*BFACTORNC,BNCs) print *, ' ' if(iBB.eq.1) write (*,'(A,100(I4,E12.5))') 'BRss ', (L,BRss(10*4*L),L=1,nTp1) print *, ' ' end do C This begins the Output of the Magnetic field maps. iBflag = iB print *, 'In get_bbtm_3 iBB, iB, iBFlag',iBB, iB, iBFlag 23 continue end do ! now new BVJ return end