C+ C NAME: C Write3D_bb_XC C PURPOSE: C Write magnetic field output to b3d* file C CATEGORY: C I/O C CALLING SEQUENCE: subroutine Write3D_bb_XC(cWild,XCbegMAT,XCendMAT,XCbegROI,XCendROI,XC3D,VV3D,BR3D,BT3D,BRSS,BTSS) C INPUTS: C cWild*(*) character wild card for locating magnetic field files C in the format processed by href=ForeignFile=. C XCbegMAT(nTim) real start Carrington variable of matrix (- NCoff) C XCendMAT(nTim) real end Carrington variable of matrix (- NCoff) C (range of matrix typically is three Carrington rotations) C XCbegROI(nTim) real start Carrington variable of region of interest C XCendROI(nTim) real end Carrington variable of region of interest C (the region of interest typically covers one whole C Carrington rotation C VV3D(nLng,nLat,nRad,nTim) C real 3D velocity array C XC3D(3,nLng,nLat,nRad,nTim) C real shift from source surface (in Carrington variable) C BR3D(nLng,nLat,nRad) real scratch array C BT3D(nLng,nLat,nRad) real scratch array C BRSS(nLng,nLat,nTim) real scratch array to read Br C BTSS(nLng,nLat,nTim) real scratch array to read Bt (not used) C OUTPUTS: C (to file) C RESTRICTIONS: C nRad must be larger/equal 3. C CALLS: C T3D_set, T3D_iset, T3D_iget, T3D_get_grid, BadR4, ArrR4TimesConstant, Str2Str, Int2Str C Flt2Str, WR2DARR, FLINT C INCLUDE: include 'sun.h' include 't3d_param.h' include 't3d_array.h' include 't3d_index.h' C include 't3d_grid_fnc.h' C include 't3d_loc_fnc.h' C EXTERNAL: C PROCEDURE: 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 The Stanford source surface maps at RR = 2.5 Rsun give the radial magnetic field BB in muT. C We are mostly interested in magnetic field at Earth, i.e. about r0=1 AU. We expect magnetic C fields of order (RR/r0)^2*BB ~ 10^-4*BB ~ 0.1 nT. This extra factor of 10^4 is included in the C output i.e. output is in units of 0.1 nT. C (In situ magnetic fields at Earth are typically in the nT range, at least one order of C magnitude larger than predicted from the Stanford maps, probably indicating that the Stanford C potential field maps underestimate the magnetic field near the current sheet by that much.) C MODIFICATION HISTORY: C SEP-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- character cWild*(*) real XCbegMAT(*) real XCendMAT(*) real XCbegROI(*) real XCendROI(*) real XC3D (*) real VV3D (*) real BR3D (*) real BT3D (*) real BRSS (*) real BTSS (*) integer NDSS(3) integer ND3D(4) real PPSS(3) real PP3D(4) real Scale(4) /0.0,1.0, 0.0,1.0/ real R_pwr(2) /2.0,1.0/ character cFile*120 character cSay*13 /'Write3D_bb_XC'/ logical bMod logical BField_Get logical bOK real Tiny /0.0/ include 't3d_grid_fnc.h' include 't3d_loc_fnc.h' call T3D_set(T3D__SCALE,4,Scale) ! Conversion to units of 0.1 nT call T3D_set(T3D__R_PWR,2,R_pwr) !------- ! Get source surface map. ! Source surface arrays have dimensions [nLng,nLat,nTim] ! BTSS is not used (yet), and is filled with zeros. call T3D_iget(T3D__NRAD,0,nRad) call T3D_iset(T3D__NRAD,0, 1) ! Will be reset after reading magnetic field !------- ! The magnetic field is returned in nano Tesla (nT). ! If source surface magnetic field found, normalize by multiplying ! the radial component BR3D by RR*RR. bOK = BField_Get(cWild,TT,XCbegMAT,XCendMAT,BRSS) call T3D_iset(T3D__NRAD,0,nRad) if (.not. bOK) return call T3D_iget(T3D__MODE,0,MODE) bMod = iand(MODE,TOM__MOD ) .ne. 0 call T3D_get_grid(TT,dTT,RR,dRR, nLng,nLat,nRad,nTim,dTTi,nLng1,nLat1) NDSS(1) = nLng ! Dimensions of source surface arrays NDSS(2) = nLat NDSS(3) = nTim ND3D(1) = nLng ! Dimensions of heliospheric arrays ND3D(2) = nLat ND3D(3) = nRad ND3D(4) = nTim ! May be degenerate (=1) Bad = BadR4() !------- ! Convert radial component to r^2*Br. ! The division by Scale(2) is used to change magnetic units. ! ! For the magnetic field extraction we assume that the tomography source ! surface is the same as the magnetic field source surface. call ArrR4TimesConstant(-nLng*nLat*nTim,BRSS,RR*RR/Scale(2),BRSS) VT = 100*SUN__OMEGA*SUN__AU do L=1,nTim call T3D_iset(T3D__ITIME ,0,L) call T3D_set (T3D__TIME ,0,TTtime(L)) call T3D_set (T3D__XCMAT ,0,XCbegMAT(L)) call T3D_set (T3D__XCMAT+1,0,XCendMAT(L)) call T3D_set (T3D__XCROI ,0,XCbegROI(L)) call T3D_set (T3D__XCROI+1,0,XCendROI(L)) do K=1,nRad do J=1,nLat XL = cosd(XLdeg(J)) do I=1,nLng !------- ! Find the Carrington variable of origin at the source ! surface of grid point I,J,K,L. Note that XCbeg and XCrange ! are set to the values at time L. XCbeg = XCbegMAT(L) ! Needed for statement fnc XCvar XCend = XCendMAT(L) XCrange = XCend-XCbeg iloc = locSHFT(0,I,J,K,L) PPSS(1) = XCvar(I)+XC3D(iloc+PRJ__XC)! Carrington variable at source surface !------- ! Find the time of origin at the source surface of grid point I,J,K,L, PPSS(3) = TTtime(L)+XC3D(iloc+PRJ__TT)! Time at source surface PPSS(3) = TTindx(PPSS(3)) ! Index for time in source surface array !------- ! To convert the Carrington longitude to an array index, the ! values of XCbeg and XCrange need to be set to the proper values ! at time PP3D(4) (the time of origin at the source surface). ! This is done by interpolation on the XCbegMAT and XCendMAT arrays. XCbeg = FLINT(1,nTim,XCbegMAT,PPSS(3),Tiny)! Needed for statement fncs XCindx, XCmod XCend = FLINT(1,nTim,XCendMAT,PPSS(3),Tiny) if (XCbeg .eq. Bad .or. XCend .eq. Bad) then BR = Bad VV = Bad else XCrange = XCend-XCbeg if (bMod) PPSS(1) = XCmod(PPSS(1)) ! Map to [XCbeg, XCend] if bMod is set PPSS(1) = XCindx(PPSS(1)) ! Index for longitude in source surface array PPSS(2) = float(J) ! Index for latitude PP3D(1) = PPSS(1) PP3D(2) = PPSS(2) PP3D(3) = 1.0 ! Index for radius (= source surface) PP3D(4) = PPSS(3) !------- ! The velocity at the source surface is calculated by 4-dim ! linear interpolation at PP3D BR = FLINT(-3,NDSS,BRSS,PPSS,Tiny) ! r^2*Br at source surface VV = FLINT(-4,ND3D,VV3D,PP3D,Tiny) ! Velocity at source surface if (BR .ne. Bad .and. VV .ne. Bad) then iloc = locVOL(I,J,K,L) if (VV3D(iloc) .eq. Bad) call Say(cSay,'E','OOPS','should not have happened') VV = 0.5*(VV+VV3D(iloc)) VV = -BR*(VT*XL/VV) ! r*Bt end if end if iloc = locVOL(I,J,K,1) BR3D(iloc) = BR BT3D(iloc) = VV end do end do end do call T3D_write_bb('bb3d',t3d, BR3D, BT3D, 0, ' ', cFile) ! Arg t3d is not used end do return end