C ***** Program to Convert a discrete time ***** C ***** sampled data file into a frequency ***** C ***** spectrum file. C ***** The input file is assumed to be ***** C ***** a list, "TotSamples" long, of ***** C ***** evenly time sampled points. ***** C ***** This is fixed point data that is ***** C ***** 4 characters per sample with ***** C ***** values ranging 0 : 4095. ***** C ***** The program also asks for the ***** C ***** time between samples in seconds. ***** C ***** The output file is "TotSamples/2" ***** C ***** records long. It is frequency ***** C ***** amplitude pairs. ***** C ***** This is floating point data ***** C ***** and the amplitudes have been ***** C ***** normalized to 1.0 The upper half ***** C ***** points of the transform, the ***** C ***** aliased points are not written to ***** C ***** the output file. C ***** 2-AUG-1997 MSU PHYSICS ***** C ***** Modified for use with the DK data ***** C ***** input file. 17-Mar-2026 ***** PROGRAM CONVERT_1 C ***************************************** C DEFINE ALL VARIABLES AND ARRAYS C ***************************************** IMPLICIT NONE C This is the number of samples, and must be a power of 2 INTEGER*4 TotSamples PARAMETER ( TotSamples = 16384 ) REAL*8 CDB(1:2*TotSamples) INTEGER*4 ICDB(1:TotSamples) COMMON ICDB, CDB INTEGER*4 Index, IOSTATUS REAL*8 Temp CHARACTER FileName*50 INTEGER*4 Column_0, Column_1, Column_2, Column_3 INTEGER*4 Column_4, Column_5, Column_6, Column_7 INTEGER*4 Column_8, Column_9, Column_10, Column_11 INTEGER*4 Column_12, Column_13, Column_14, Column_15 C *********************************************************** C Get the name of the fixed point input raw data file. C *********************************************************** WRITE ( 6, 30 ) 30 FORMAT ( ////////////////////////// & ' ****************************************** '/ & ' * * '/ & ' * This is the Convert_1 Program * '/ & ' * * '/ & ' * Revision 1 AUGUST 1997 * '/ & ' ****************************************** '// ) 40 WRITE ( 6, 50 ) 50 FORMAT ( // & ' To quit this program enter just a Carriage Return ', // & ' or else, to Convert a discrete time sampled raw ', / & ' data file to frequency space enter the filename ', / & ' of the raw data file ', / & ' DEVC:[DIR]NAME.EXT;VER: ', $ ) READ ( 5, 55 ) FileName 55 FORMAT ( A ) IF ( FileName .EQ. ' ' ) THEN GOTO 998 END IF WRITE ( 6, 60 ) FileName 60 FORMAT ( // & ' The raw data file Filename ' / & ' specification is: ', A & // ) C ************************** C Open the raw data file C ************************** OPEN ( UNIT=10, FILE=FileName, STATUS='OLD', & FORM='FORMATTED', READONLY, ACCESS='SEQUENTIAL', & ERR=950, IOSTAT=IOSTATUS ) C ************************************** C ***** Read the raw data file ***** C ************************************** WRITE ( 6, 215 ) 215 FORMAT ( // & ' ***** Now reading the raw data file. ***** ' & // ) READ ( 10, 220, ERR=970, IOSTAT=IOSTATUS ) & Column_0, Column_1, Column_2, Column_3, & Column_4, Column_5, Column_6, Column_7, & Column_8, Column_9, Column_10, Column_11, & Column_12, Column_13, Column_14, Column_15 220 FORMAT ( I6, I7, I7, I7, I7, I7, I7, I7, & I7, I7, I7, I7, I7, I7, I7, I7 ) CLOSE ( UNIT=10 ) WRITE ( 6, 580 ) Column_0 580 FORMAT ( ' Value in Column 0 = ', I4, / ) WRITE ( 6, 581 ) Column_1 581 FORMAT ( ' Value in Column 1 = ', I4, / ) WRITE ( 6, 582 ) Column_2 582 FORMAT ( ' Value in Column 2 = ', I4, / ) WRITE ( 6, 583 ) Column_3 583 FORMAT ( ' Value in Column 3 = ', I4, / ) WRITE ( 6, 584 ) Column_4 584 FORMAT ( ' Value in Column 4 = ', I4, / ) WRITE ( 6, 585 ) Column_5 585 FORMAT ( ' Value in Column 5 = ', I4, / ) WRITE ( 6, 586 ) Column_6 586 FORMAT ( ' Value in Column 6 = ', I4, / ) WRITE ( 6, 587 ) Column_7 587 FORMAT ( ' Value in Column 7 = ', I4, / ) WRITE ( 6, 588 ) Column_8 588 FORMAT ( ' Value in Column 8 = ', I4, / ) WRITE ( 6, 589 ) Column_9 589 FORMAT ( ' Value in Column 9 = ', I4, / ) WRITE ( 6, 590 ) Column_10 590 FORMAT ( ' Value in Column 10 = ', I4, / ) WRITE ( 6, 591 ) Column_11 591 FORMAT ( ' Value in Column 11 = ', I4, / ) WRITE ( 6, 592 ) Column_12 592 FORMAT ( ' Value in Column 12 = ', I4, / ) WRITE ( 6, 593 ) Column_13 593 FORMAT ( ' Value in Column 13 = ', I4, / ) WRITE ( 6, 594 ) Column_14 594 FORMAT ( ' Value in Column 14 = ', I4, / ) WRITE ( 6, 595 ) Column_15 595 FORMAT ( ' Value in Column 15 = ', I4, / ) C ***** Findout if there should be an output file ***** C ***** and get its FileName ***** WRITE ( 6, 250 ) 250 FORMAT ( // ' To build an ASCII file of frequency ' / & ' amplitude pairs, ' / & ' Enter the FileName of the Output File ' / & ' or else ' / & ' to Quit enter just a carriage return. ' // ) WRITE ( 6, 251 ) 251 FORMAT ( ' Enter carriage return or ' / $ ' DEVC:[DIR]NAME.EXT;VER: ',$ ) READ ( 5, 255 ) FileName 255 FORMAT ( A ) IF ( FileName .EQ. ' ' ) THEN WRITE ( 6, 257 ) 257 FORMAT (// ' NO ASCII Output File Will Be Written. ' // ) WRITE ( 6, 80 ) GOTO 40 END IF 80 FORMAT ( / ' ***************************************** '/ & ' * * '/ & ' * RESTARTING THE CONVERT_1 PROGRAM * '/ & ' * * '/ & ' ***************************************** '// ) WRITE ( 6, 270 ) FileName 270 FORMAT (// ' The specification of the output file is: ', A //) OPEN ( UNIT=15, FILE=FileName, STATUS='NEW', & FORM='FORMATTED', & ACCESS='SEQUENTIAL', ERR=960, IOSTAT=IOSTATUS ) C ***** Now call the routine to transform the discrete ***** C ***** time sampled data into frequency space. ***** CALL Forward_Fourier C ***** Now write the ASCII Frequency Amplitude ***** C ***** Pair Output File ***** C C ***** If the total sweep of input data is over ***** C ***** T seconds then the output points are at ***** C ***** 0 Hz, 1/T Hz, 2/T Hz, 3/T Hz, ... ***** C ***** for 2MHz ADC Clock and 1024 points use 51.15 C ***** output in 100 KHz. C C ***** for 6MHz ADC Clock and 1024 points use 17.05 for C ***** output in 100 KHz. C C ***** for 5.058 MHz ADC Clk and 2048 points use 404.889 for C ***** output in MHz C C ***** for 30.35 MHz ADC Clk and 16,384 points this is a C ***** record length of 539.92 usec so use 539.92 for C ***** output in MHz DO Index=1,TotSamples,2 Temp = ( FLOAT( (Index-1) / 2 ) ) / 539.92 WRITE ( 15, 300 ) Temp,CDB(Index) END DO 300 FORMAT ( ' ', F7.3, ' ', F8.6 ) CLOSE ( UNIT = 15 ) WRITE ( 6, 280 ) 280 FORMAT ( ' The ASCII output file ', & 'has been successfully written. ', // ) WRITE ( 6, 80 ) GOTO 40 C ************************************************************ C THIS IS THE SECTION FOR HANDLING IO ERRORS AND ALL EXITS C ***********************************---------*********-----** 950 WRITE ( 6, 951 ) IOSTATUS 951 FORMAT ( //, ' THERE HAS BEEN AN IO SYSTEM ERROR TRYING ', / & ' TO OPEN THE SPECIFIED RAW DATA FILE. ', // & ' DID YOU TYPE THE FILENAME CORRECTLY? ', // & ' FORTRAN OPEN IOSTAT = ', I3, / ) WRITE ( 6, 80 ) GOTO 40 960 WRITE ( 6, 961 ) IOSTATUS 961 FORMAT ( //, ' THERE HAS BEEN AN IO SYSTEM ERROR TRYING ', / & ' TO OPEN THE SPECIFIED ASCII OUTPUT FILE. ', // & ' DID YOU TYPE THE FILENAME CORRECTLY? ', // & ' FORTRAN OPEN IOSTAT = ', I3, / ) WRITE ( 6, 80 ) GOTO 40 970 WRITE ( 6, 971 ) IOSTATUS 971 FORMAT ( //, ' THERE HAS BEEN AN IO SYSTEM ERROR TRYING ', / & ' TO READ THE RAW DATA FILE. ', / & ' DID YOU TYPE THE FILENAME CORRECTLY? ', // & ' FORTRAN READ IOSTAT = ', I3, / ) WRITE ( 6, 80 ) GOTO 40 998 WRITE ( 6, 999 ) 999 FORMAT ( // ' Convert_1 Program Is Exiting. ', // ) STOP ' ' END