Question: Fortran code: The data collected from one run of this rig is given in the file HW05_02_SpringData.txt, which is available on CatCourses. Look over that
Fortran code:
The data collected from one run of this rig is given in the file HW05_02_SpringData.txt, which is available on CatCourses. Look over that file to see how the headers are set up and note the numerical formats. The last line is blank. Note that the file could have any number of data rows in it, not just the 10 shown. Your program should accommodate different sizes of data files without changing the code. You may assume that there will be 4 header lines before the first data line. You should read the header lines to know what to write to the output file's headers.
Write a Fortran program that reads in theheaders anddata from that file. The program should be ableto accommodate any size of file. The technique discussed in class using IOSTAT will be useful for this. Use dynamic arrays to store the force and displacement data.
For each data point in the file, calculate a spring constant k for the given weight and displacement. This should be in N/m (not N/mm). Keep track of these values in a dynamic array.
Create a file called HW05_02_out.txt that looks just like the input file (including formats and headers), except that it has 3 columns of data, with the third being the spring constant calculated for each row (use 3 digits to the right of the decimal place for k). Use the header lines that were read from the original file (do not assume that they will not change) in the output file and add to them appropriate text for the third column.
As an example, a data file with 5 data lines is shown below file: HW05_ExampleSpringData.txt
Spring Test Data,
weight displacement
(N) (mm)
0.968 0.6520
2.022 1.3066
2.997 2.0459
3.965 2.5755
4.984 3.4614
And the resulting output file
Spring Test Data, February, 2018
weight displacement stiffness
(N) (mm) (N/m)
0.968 ,0.6520, 1484.663
2.022, 1.3066, 1547.528
2.997, 2.0459,1464.881
3.965, 2.5755, 1539.507
4.984, 3.4614, 1439.880
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
