Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have been tasked with converting several Fortran files over to C#. I really do not have a choice and in this situation cannot use a Dot net driver to read Fortran. I am an amateur when it comes to C# and used Fortran in 1983 as my one and only time.

I have a couple of clauses which I can't seem to figure out how to relate in C#, if someone could get me pointed in the right direction please.

What I have tried:

I have a lot of instances in Fortran where an array is Allocated using an ALLOCATABLE command. I do not know how to do similar in C#, later on, in code, I need to reference this allocation as a check as well.

I have a Type declaration:

TYPE Cell
      DOUBLE PRECISION, POINTER :: column(:)
END TYPE Cell


How do I convert this Declaration to C#?

I have assignments using the above declaration:

TYPE(Cell), POINTER           :: PMAT(:)
	TYPE(Cell), POINTER           :: PMATD(:) 
	TYPE(Cell), POINTER           :: NMATD(:)     


How do I declare these variables in C#?
Posted
Updated 3-Jul-18 3:56am

Don't translate them: they are very different languages and you will not end up with good quality code in C#. What you are trying to do is translate Shakespeare's plays to Korean using Google translate to look up each word:
To be or not to be, that is the question

에 있다 또는 아니 에 있다 그 ~이다. 그만큼 문제
Which translates back as:
It is in or is not in. That problem
Whereas translating the whole phrase gives this:
존재하거나 존재하지 않기 위해서, 그것은 질문입니다.
Which at least comes back with something a little more poetic!
To exist or not exist, it is a question.
But I'm sure that a person fluent in both languages could produce a much better result. :laugh:

Your best solution is to rewrite the code using the original application as a specification, not translate the existing code, particularly if you are unfamiliar with the source language!
 
Share this answer
 
Comments
Maciej Los 3-Jul-18 4:00am    
Interesting... Try the same with polish equivalent: "Być albo nie być. Oto jest pytanie." Translation back returning the same ;) What's conclusion?
5ed!
OriginalGriff 3-Jul-18 9:50am    
Then your first task is to completely learn Fortran 90 - because if you don't fully understand both source and target languages you stand no chance. And even then, what you produce will be very poor quality C# that is going to be barely maintainable ... good luck - you are going to need it because you are going to responsible for fixing and updating the "New" software for a very long time.

And don't expect it to be a quick process to translate it either!
it is apparent that there was no point in asking this question here.
 
Share this answer
 
Comments
Richard Deeming 3-Jul-18 11:17am    
It is even more apparent that there was no need to post this passive-agressive comment as a "solution".

If you don't want advice from other programmers, then don't bother asking for it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900