C+ C NAME: C T3D_get_grid C PURPOSE: C Retrieve grid related constants from t3d array C CATEGORY: C Tomography C CALLING SEQUENCE: subroutine T3D_get_grid(TT,dTT,RR,dRR,nLng,nLat,nRad,nTim, dTTi,nLng1,nLat1) C OUTPUTS: C TT, dTT real time and time increment C RR, dRR real source surface distance and radial increment C nLng,nLat,nRad,nTim C integer # elements in each dimension of the numerical grid C C A few auxiliary variables: C C dTTi real 1./dTT; will be zero if dTT=0.0 C nLng1 integer nLng-1 C nLat1 integer nLat-1 C SEE ALSO: C T3D_iget, T3D_iset, T3D_get, T3D_set C INCLUDE: include 't3d_array.h' include 'str2str_inc.h' C PROCEDURE: C The array t3d stores all the information about a specific reconstruction. C Typically most of the entries are filled in the main program and are C updated/extracted as needed using the subroutines lister under SEE ALSO above C C The entries are roughly divided in 'global' entries (applying to the C reconstruction in general) and 'time-dependent' entries (different for every C time step in a time-dependent reconstruction). C C I__MODE integer several bits are used to control program execution C C NL_V integer # velocity lines of sight C NL_G integer # g-level lines of sight C dLOS real step size along line of sight (AU) C NLOS integer # steps along line of sight C BINX_V real Min. # los crossings in bin at source surface for V C BINX_D real Min. # los crossings in bin at source surface for G C C kIter integer iteration number C nIter integer max. # iterations C C NCoff integer Carrington variable offset C This value needs to be added to XCbeg, XCend, XCbegROI, C XCendROI and XCTime to get the actual Carrington variable. C C TT real start time as Carrington variable (- NCoff) C dTT real time resolution as Carrington variable C (if nTim=1 then the values of TT and dTT do not matter) C If the time-dependent reconstruction is not in equal C steps set TT and dTT to href=BadR4= C C RR real radial distance of source surface (AU) C dRR real radial resolution (AU) C C nLng integer # longitudes covering [0,360] degrees C nLat integer # latitudes covering [-90,90] degrees C nRad integer # radial distance covering [RR,RR+(nRad-1)*dRR] C nTim integer # times covering [TT,TT+(nTim-1)*dTT] C C PWN_V,PWN_G real power determining density dependence of g-level C PWR_V,PWN_G real power determining dependence on radial dependence of g-level C C D1AU real density at 1 AU (cm^-3) C C SMOOTH_V, SMOOTH_D C real width for smoothing velocity and density maps C FILL_V, FILL_D real width for filling holes in velicity and density maps C SMOOTH_TIME_V, SMOOTH_TIME_D C real width for smoothing over time for velocity and density C C ClipLng real clip longitude (argument for GridSphere) C C Scale(4) real extra scaling factor for data arrays C These are pairs of y-intercept and slope values C for each of data sets output to file. C (set these to 0,1 or href=BadR4= if no scaling is required) C R_PWR(2) real power of r applied when writing data to file C (typically 0 for velocity, 2 for density, 2 for C radial magnetic field, 1 for azimuthal magnetic field). C MODIFICATION HISTORY: C JAN-2001, Paul Hick (UCSD/CASS) C AUG-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added arguments NL_V, NL_G, dLOS, NLOS. C- character cFile*(*) character cType*(*) character cStr(*)*(*) !------- ! Used by entry points T3D_get and T3D_set real V (*) ! Used by entry point T3D_header integer itt(2) integer rtt(4) /0,0,1,0/ integer Time2Str integer tsave(3) !------- ! Used by entry points T3D_iget and T3D_iset integer IV(*) !------- integer Str2Str integer Flt2Str integer T3D_marker integer XCvarFormat real Scale(2) real t3dx(T3D__NELEMENTS) real t3d (T3D__NELEMENTS) /T3D__NELEMENTS*0.0/ save t3d TT = t3d( T3D__TT ) dTT = t3d( T3D__DTT) RR = t3d( T3D__RR ) dRR = t3d( T3D__DRR) nLng = nint( t3d(T3D__NLNG) ) nLat = nint( t3d(T3D__NLAT) ) nRad = nint( t3d(T3D__NRAD) ) nTim = nint( t3d(T3D__NTIM) ) dTTi = 0.0 if (dTT .ne. 0.0) dTTi = 1.0/dTT nLng1 = nLng-1 nLat1 = nLat-1 return C+ C NAME: C T3D_get C PURPOSE: C Retrieves real entry in t3d array C CALLING SEQUENCE: entry T3D_get(ID, IOFF, V) C INPUTS: C ID integer identified position in t3d array to be retrieved C This should be the name of one of the parameters C defined in href=t3d_array= C IOFF integer =0: only t3d(ID) is retrieved C >0: t3d(ID..ID-1+IOFF) are retrieved C V(*) real value(s) retrieved from t3d array C PROCEDURE: C Entry point in href=T3D_get_grid= C- do I=1,max(1,IOFF) V(I) = t3d(ID-1+I) end do return C+ C NAME: C T3D_set C PURPOSE: C Sets real entry in t3d array C CALLING SEQUENCE: entry T3D_set(ID, IOFF, V) C INPUTS: C ID integer identified position in t3d array to be updated C This should be the name of one of the parameters C defined in href=t3d_array= C IOFF integer =0: only t3d(ID) is updated C >0: t3d(ID..ID-1+IOFF) are updated C V real value(s) updated in t3d array C PROCEDURE: C Entry point in href=T3D_get_grid= C- do I=1,max(1,IOFF) t3d(ID-1+I) = V(I) end do return C+ C NAME: C T3D_iget C PURPOSE: C Retrieves integer entry in t3d array C CALLING SEQUENCE: entry T3D_iget(ID, IOFF, IV) C INPUTS: C ID integer identified position in t3d array to be retrieved C This should be the name of one of the parameters C defined in href=t3d_array= C IOFF integer =0: only t3d(ID) is retrieved C >0: t3d(ID...ID-1+IOFF) are retrieved C IV integer value(s) retrieved from t3d array (converted to C nearest integer) C PROCEDURE: C Entry point in href=T3D_get_grid= C- do I=1,max(1,IOFF) IV(I) = nint( t3d(ID-1+I) ) end do return C+ C NAME: C T3D_iset C PURPOSE: C Sets integer entry in t3d array C CALLING SEQUENCE: entry T3D_iset(ID, IOFF, IV) C INPUTS: C ID integer identified position in t3d array to be updated C This should be the name of one of the parameters C defined in href=t3d_array= C IOFF integer =0: only t3d(ID) is updated C >0: t3d(ID...ID-1+IOFF) are updated C IV integer value(s) updated in t3d array C PROCEDURE: C Entry point in href=T3D_get_grid= C- do I=1,max(1,IOFF) t3d(ID-1+I) = float( IV(I) ) end do return C+ C NAME: C T3D_get_mode C CALLING SEQUENCE entry T3D_get_mode(IB,ION) C INPUTS: C IB integer integer between 0 and 31 identifying C a bit in t3d(T3D__MODE) C OUTPUTS: C ION integer 0 if bit is not set C 1 if bit is set C PROCEDURE: C Entry point in href=T3D_get_grid= C- ION = nint( t3d(T3D__MODE) ) ION = min( iand(ION,2**IB ), 1) return C+ C NAME: C T3D_set_mode C CALLING SEQUENCE entry T3D_set_mode(IB,ION) C INPUTS: C IB integer integer between 0 and 31 identifying C a bit in t3d(T3D__MODE) C ION integer 0 if bit should be cleared C 1 if bit should be set C OUTPUTS: C none C PROCEDURE: C Entry point in href=T3D_get_grid= C- N = nint( t3d(T3D__MODE) ) I2 = 2**IB t3d(T3D__MODE) = N-iand(N,I2)+ION*I2 return C+ C NAME: C T3D_get_all C PURPOSE: C Retrieves whole t3d array C CALLING SEQUENCE: entry T3D_get_all(t3dx) C OUTPUTS: C t3dx(T3D__NELEMENTS) real received content of t3d_array C (the size T3D__NELEMENTS is defined in C include file href=t3d_array= C PROCEDURE: C Entry point in href=T3D_get_grid= C- do I=1,T3D__NELEMENTS t3dx(I) = t3d(I) end do return C+ C NAME: C T3D_fill_global C PURPOSE: C Fill 'global' section of t3d array. C CALLING SEQUENCE: entry T3D_fill_global(t3dx, I__MODE, kIter,nIter,NCoff,TT,dTT,RR,dRR, & nLng,nLat,nRad,nTim,PWN_V,PWN_G,PWR_V,PWR_G,D1AU, & SMOOTH_V,SMOOTH_D, FILL_V,FILL_D,SMOOTH_TIME_V,SMOOTH_TIME_D,ClipLng, Scale) C PROCEDURE: C Entry point in href=T3D_get_grid=. C Still in use in some time-dependent tomography versions. C Probably should be replaced by calls to T3D_get, etc. C- !t3d(T3D__MODE ) = I__MODE t3d(T3D__ITERATION ) = kIter t3d(T3D__ITERATIONS) = nIter t3d(T3D__NCOFF ) = NCoff t3d(T3D__TT ) = TT t3d(T3D__DTT ) = dTT t3d(T3D__LAT ) = -90.0 t3d(T3D__LAT+1 ) = 90.0 t3d(T3D__RR ) = RR t3d(T3D__DRR ) = dRR t3d(T3D__NLNG ) = nLng t3d(T3D__NLAT ) = nLat t3d(T3D__NRAD ) = nRad t3d(T3D__NTIM ) = nTim t3d(T3D__PWN_V ) = PWN_V t3d(T3D__PWN_G ) = PWN_G t3d(T3D__PWR_V ) = PWR_V t3d(T3D__PWR_G ) = PWR_G t3d(T3D__D1AU ) = D1AU t3d(T3D__SMOOTH_V) = SMOOTH_V t3d(T3D__SMOOTH_D) = SMOOTH_D t3d(T3D__FILL_V ) = FILL_V t3d(T3D__FILL_D ) = FILL_D t3d(T3D__SMOOTH_TIME_V) = SMOOTH_TIME_V t3d(T3D__SMOOTH_TIME_D) = SMOOTH_TIME_D t3d(T3D__CLIPLNG ) = ClipLng t3d(T3D__SCALE ) = Scale(1) t3d(T3D__SCALE+1) = Scale(2) t3d(T3D__SCALE+2) = Scale(1) t3d(T3D__SCALE+3) = Scale(2) return C+ C NAME: C T3D_fill_time C PURPOSE: C Fill 'global' section of t3d array. C CALLING SEQUENCE: entry T3D_fill_time(t3dx, iTime, TT, XCbegMAT,XCendMAT,XCbegROI,XCendROI) C PROCEDURE: C Entry point in href=T3D_get_grid=. C Still in use in some time-dependent tomography versions. C Probably should be replaced by calls to T3D_get, etc. C- t3d(T3D__ITIME ) = iTime t3d(T3D__TIME ) = TT t3d(T3D__XCMAT ) = XCbegMAT t3d(T3D__XCMAT+1) = XCendMAT t3d(T3D__XCROI ) = XCbegROI t3d(T3D__XCROI+1) = XCendROI return C+ C NAME: C T3D_header C PURPOSE: C Creates array of strings from t3d array C CALLING SEQUENCE: entry T3D_header(cType, cFile, nStr, cStr, nLen) C INPUTS: C cType*(*) character used as prefix for output file name C (e.g. 'nv3d') C OUTPUTS: C cFile*(*) character name for output file C starts with cType, appended is the time assigned to the C matrix in F9.4 format. C For time-dependent tomography (t3d(T3D__DTT) > 0) an C integer marker is added (see href=T3D_marker=). C Finally, the iteration number is added if the C iteration number t3d(T3D__ITERATION) is less/equal C than the total number of iterations t3d(T3D__INTERATIONS). C The resulting file name looks like: C nv3d1234.5678 (corotating tomography) C nv3d1234.5678_12345 (time-dependent tomography) C C nv3d1234.5678_123 (corotating tomography) C nv3d1234.5678_12345_123 (time-dependent tomography) C nStr integer max. # header strings available (this should be set C by the caller to T3D__NELEMENTS defined in include file C t3d_array.h. C cStr*(nStr) character character array used to store header strings C nLen integer actual # header strings used C CALLS: C Str2Str, XCvarFormat, T3D_marker, Int2StrSet, Int2Str, Flt2Str C Time2Round, Time2GetOrigin, Time2SetOrigin2000, Time2Carrington C Time2Str, Time2PutOrigin C PROCEDURE: C Entry point in href=T3D_get_grid=. C MODIFICATION HISTORY: C SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added separate entry to header for the file name prefix cType C Now XCvarFormat is used to write Carrington variables C Now T3D__MODE_TIME instead of T3D__DTT is used to determine whether C corotating or time-dependent tomography is run (this determines C whether or not a marker value is added to the file names). C- !integer itt(2) !integer rtt(4) /0,0,1,0/ !integer Time2Str !integer tsave(3) !------- ! Construct output file name. ! Set up file name using prefix cType and Carrington variable in t3d. I = 0 I = I+Str2Str(cType,cFile(I+1:)) ! Prefix, e.g. 'nv3d' I = I+XCvarFormat(nint(t3d(T3D__NCOFF)),t3d(T3D__TIME),cFile(I+1:)) ! Add a marker value for time-dependent tomography if ( iand( nint(t3d(T3D__MODE)) ,2**T3D__MODE_TIME ) .eq. 0) then icount = 0 ! Corotating tomography else I = T3D_marker(cFile,icount) ! Time-dependent tomography end if t3d(T3D__MARKER) = icount !------- ! Add iteration counter to file name if not the final result iT = nint( t3d(T3D__ITERATION ) ) nT = nint( t3d(T3D__ITERATIONS) ) if (iT .gt. 0 .and. iT .le. nT) then I = I+Str2Str('_',cFile(I+1:)) J = alog10(float(nT))+1 L = Int2StrSet(STR__ZERORIGHTADJUST) I = I+Int2Str(iT,cFile(I+1:I+J)) L = Int2StrSet(L) end if !------- ! Set up header strings J = 0 J = J+1 I = 0 I = I+Str2Str('T3D_header, v1.04 FOR',cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('File name prefix:' ,cStr(J)(I+1:))+1 I = I+Str2Str(cType ,cStr(J)(I+1:)) call Time2GetOrigin(tsave) call Time2SetOrigin2000(0) call Time2Carrington(1,itt,nint(t3d(T3D__NCOFF)),dble(t3d(T3D__TIME))) call Time2Round(rtt,itt,itt) J = J+1 I = 0 I = I+Str2Str('Universal time:', cStr(J)(I+1:))+1 I = I+Time2Str('YYYY:DOY:hh:mm:ss.fff',itt,cStr(J)(I+1:)) call Time2PutOrigin(tsave) J = J+1 I = 0 I = I+Str2Str('Carrington offset:' ,cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__NCOFF)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Carrington time:' ,cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__TIME),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Carrington limits of array (start/end):',cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__XCMAT ),cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__XCMAT+1),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Carrington limits of region of interest (start/end):',cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__XCROI ),cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__XCROI+1),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Carrington start time:',cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__TT),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Carrington time resolution:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__DTT),6,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Carrington forecast time:',cStr(J)(I+1:))+1 I = I+XCvarFormat(0,t3d(T3D__TNOW),cStr(J)(I+1:)) !I = I+Flt2Str(t3d(T3D__TNOW),4,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Latitude range (degrees):',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__LAT ),4,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__LAT+1),4,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Radial reference distance (AU):',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__RR),5,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Radial resolution (AU):',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__DRR),5,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Power index of density dependence of density fluctuations (V-data,G-data):',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__PWN_V),3,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__PWN_G),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Power index of radial dependence of density fluctuations (V-data,G-data):',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__PWR_V),3,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__PWR_G),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Density at 1 AU (cm^-3):',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__D1AU),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Spatial filters for smoothing velocity and density (degrees):', cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SMOOTH_V),3,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SMOOTH_D),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Spatial filters for filling velocity and density (degrees):', cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__FILL_V),3,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__FILL_D),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Temporal filters for velocity and density (days):', cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SMOOTH_TIME_V),3,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SMOOTH_TIME_D),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Clip longitude (degrees):', cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__CLIPLNG),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Dimensions (nLng,nLat,nRad,nTim):',cStr(J)(I+1:))+1 I = I+Int2Str(nint( t3d(T3D__NLNG) ),cStr(J)(I+1:))+1 I = I+Int2Str(nint( t3d(T3D__NLAT) ),cStr(J)(I+1:))+1 I = I+Int2Str(nint( t3d(T3D__NRAD) ),cStr(J)(I+1:))+1 I = I+Int2Str(nint( t3d(T3D__NTIM) ),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Iteration:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__ITERATION )),cStr(J)(I+1:))+1 I = I+Str2Str('/',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__ITERATIONS)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Time index:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__ITIME)),cStr(J)(I+1:)) I = I+Str2Str('/',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__NTIM)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('# Velocity lines of sight:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__NL_V)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('# G-level lines of sight:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__NL_G)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('# Line-of-sight segments for velocity:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__NLOS_V)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('# Line-of-sight segments for g-level:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__NLOS_G)),cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Line-of-sight resolution for velocity:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__DLOS_V),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Line-of-sight resolution for g-level:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__DLOS_G),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('# segments/bin for velocity:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__BINX_V),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('# segments/bin for density:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__BINX_D),3,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Linear scaling constants:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SCALE ),5,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SCALE+1),5,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SCALE+2),5,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__SCALE+3),5,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Power for radial normalization:',cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__R_PWR ),5,cStr(J)(I+1:))+1 I = I+Flt2Str(t3d(T3D__R_PWR+1),5,cStr(J)(I+1:)) J = J+1 I = 0 I = I+Str2Str('Rotation counter:',cStr(J)(I+1:))+1 I = I+Int2Str(nint(t3d(T3D__MARKER)),cStr(J)(I+1:)) nLen = J return end