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

  • Fortran
  • Thread starter zakynthos
  • Start date
  • Tags
    Fortran
In summary, the programmer is trying to cross-reference data in a four column array. The program matches data in column A to Column D by referencing the matching values in columns B and C.
  • #1
zakynthos
2
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
  • #2
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.
 
  • #3
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!
 

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

What is the main reason for converting VBA code to Fortran?

The main reason for converting VBA (Visual Basic for Applications) code to Fortran is to improve the performance and efficiency of the code. Fortran is a high-level programming language specifically designed for scientific and engineering applications, making it more suitable for complex calculations and data manipulation.

Is it difficult to convert VBA code to Fortran?

Converting VBA code to Fortran can be challenging, especially for those who are not familiar with Fortran syntax and programming principles. However, with some understanding of both languages and proper planning, the conversion process can be manageable.

Can all VBA code be converted to Fortran?

No, not all VBA code can be converted to Fortran. VBA is a scripting language used primarily for automating tasks in Microsoft Office applications, while Fortran is a general-purpose programming language. Some VBA functions and features may not have direct equivalents in Fortran, making it impossible to convert certain code.

What are the benefits of converting VBA code to Fortran?

Converting VBA code to Fortran can result in improved performance, increased efficiency, and better portability. Fortran is a compiled language, meaning the code is converted to machine code before execution, resulting in faster execution compared to VBA's interpreted code. Fortran is also highly optimized for mathematical and scientific applications, making it more efficient for complex calculations. Additionally, Fortran code can be easily run on different platforms without the need for specialized software.

Are there any tools or resources available to assist in the conversion process?

Yes, there are several tools and resources available to assist in the conversion process, such as online converters, code translators, and documentation on VBA to Fortran conversion techniques. However, it is important to note that these tools may not be able to convert all VBA code accurately, and manual adjustments may be necessary.

Similar threads

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