C+ C NAME: C XCvarFormat C PURPOSE: C Provides format specification for Carrington variables. C CATEGORY: C I/O C CALLING SEQUENCE: integer function XCvarFormat(NCoff,XC,cFile) C INPUTS: C NCoff integer Carrington rotation offset C XC real*4 Carrington variable with NCoff subtracted C iMark integer Marker value is used only if > 0 C OUTPUTS: C cFile character*(*) file name C CALLS: C Int2StrSet, Int2Str, Flt2Str, LocFirst, Str2Str C INCLUDE: include 'str2str_inc.h' C PROCEDURE: C The Carrington time in nv3d files is written into the file C name in F9.4 format. The time and marker are appended to the C content of cFile. If the input value of cFile is 'nv3d' then C the output will be of the form 'nv3d1999.9999'. C MODIFICATION HISTORY: C SEP-2002, Paul Hick (UCSD/CASS) C NOV-2002, Paul Hick (UCSD/CASS) C Minor modification in handling of fraction. C APR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Bug fix. For XC values with a fraction very close to 1 C (i.e. 0.9999....) the fraction was truncated to zero. C- integer NCoff real XC character cFile*(*) character cTime*9 integer Flt2Str integer Str2Str IC = int(XC) ! Integer rotation number ! Really small fractions would be printed by Flt2Str in exponential format ! i.e. 0.003 would become 3.0000E-2, resulting in the wrong fraction. ! To avoid this add one so that the number printed is always bigger than one. J = Flt2Str(1+(XC-IC),-4,cTime) ! 1 <= 1+(XC-IC) < 2 L = LocFirst('.',cTime) ! If 1+(XC-IC) = 2-delta then Flt2Str may roundup to 2.0000 ! Check for the starting '2' and fix the problem. if (cTime(L-1:L-1) .eq. '2') then ! If cTime='2.0000' IC = IC+1 ! Increment rotation number cTime(L-1:L-1) = '1' ! Modify to cTime='1.0000' end if I = itrim(cFile) if (NCoff .ne. 0) J = Int2StrSet(STR__ZERORIGHTADJUST) I = I+Int2Str(NCoff+IC, cFile(I+1:I+4)) ! 4-digit integer rotation number if (NCoff .ne. 0) J = Int2StrSet(J) I = I+Str2Str(cTime(L:),cFile(I+1:)) ! Add 4-digit fraction XCvarFormat = I return end C+ C NAME: C cXCvarFormat C PURPOSE: C Provides format specification for Carrington variables. C CATEGORY: C I/O C CALLING SEQUENCE: character*9 function cXCvarFormat(NCoff,XC) C INPUTS: C NCoff integer Carrington rotation offset C XC real Carrington variable with NCoff subtracted C OUTPUTS: C cXCvarFormat character*9 string of type 1234.5678 (i.e. F9.4 format) C CALLS: C XCvarFormat C MODIFICATION HISTORY: C OCT-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- integer NCoff real XC integer XCvarFormat cXCvarFormat = ' ' I = XCvarFormat(NCoff,XC,cXCvarFormat) return end