Fortran Can Fortran handle cross-referencing on a large array of data?

  • Thread starter Thread starter zakynthos
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
The discussion revolves around the use of Fortran to perform a cross-referencing function on a large dataset organized in a four-column array with one million rows. The user seeks to match data in column A with column D by referencing values in columns B and C. They provide a VBA program that currently takes approximately 12.93 hours to run on a typical office PC. Feedback suggests that the algorithm is inefficient and that sorting the data before matching could significantly reduce the runtime to about one second. The user acknowledges this improvement and mentions switching to a VLOOKUP method, which has proven to be much faster. Despite this, there remains an interest in how the original VBA code could be translated into Fortran, indicating a desire to explore the capabilities of Fortran for handling such data processing tasks efficiently, potentially on high-performance computing systems like Fujitsu's K computer.
zakynthos
Messages
2
Reaction score
0
Hi, I've no knowledge of Fortran but am researching its (theoretical) use to perform a 'cross- referencing' function on data in a four column array of one million rows. The program matches data in column A to Column D by referencing the matching values in columns B and C.

Here's the program I'm using - could anyone convert this to Fortran and could this in, in practice, run on Fujitsu's K (10 teraflops) computer. If so, how long would it take the K to perform this task - I've calculated 12.93 hrs from tests on a typical office PC? With thanks.

Sub AddCodes()

Dim x As Long, LastRow As Long, UB As Long, BList As Variant

Const StartRow As Long = 1
LastRow = Cells(Rows.Count, "A").End(xlUp).Row

BList = Join(WorksheetFunction.Transpose(Cells(StartRow, "B").Resize(LastRow - StartRow + 1)), "/")
' Application.ScreenUpdating = False

For x = StartRow To LastRow
UB = UBound(Split(Split(BList, Cells(x, "C").Value)(0), "/"))
If UB >= 0 Then
With Cells(x, "D")
.Value = .Value & "," & Range("A1").Offset(UB).Value
If Left(.Value, 1) = "," Then .Value = Mid(.Value, 2)
.Interior.ColorIndex = 6
.Font.Bold = True
End With
End If
Next

Application.ScreenUpdating = True

End With

End Sub
 
Technology news on Phys.org
If it takes 12 hours on a PC your algorithm is hopelessly inefficient.

If you first sorted the table on the relevant columns and then did the matching, I would expect the run time to be of the order of 1 second not 12 hours.

Relational database operations are a good way to describe what you want to do, but they are often a bad way to actually do it.
 
Many thanks for your answer - your advice made me re-think the code and I've processed the array with vlookup instead and yes, you're right of course, about a second!

However, I'm still interested to knnow how my original code qwould translate into Fortran.

Thanks once again!
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
13
Views
4K
Replies
11
Views
3K
Replies
4
Views
11K
Replies
10
Views
25K
Replies
2
Views
3K
Replies
6
Views
6K
Back
Top