Convert Fortran 77 to C ++

I have a Fortran 77 application that uses Common declarations to share memory files. On the same day, when the memory was expensive and inaccessible, it was around her.

Managed equipment sets status flags. These flags are in these common variables.

Any suggestions on how to implement common functionality in C ++?

A class, possibly with all public variables. Thus, any program that creates an instance of this class will have access to the contents of shared variables.

Are there any guides / recommendations for converting Fortran to C or C ++?

thank

+3
source share
6 answers

, , Fortran 90.

++, / .

, , .

- Scientific and Engineering ++: . , . ++ , , / .

+2

Fortran C/++ :

      FORTRAN:
           DOUBLE PRECISION X
           INTEGER A, B, C
           COMMON/ABC/ X, A, B, C

      C:
           extern struct{
               double x;
               int a, b, c;
           } abc_;

      C++:
         extern "C" {
           extern struct{
               double x;
               int a, b, c;
           } abc_;
         }

extern struct .h, C/++ #include, .c .cpp , .h, "extern" .

, , , , ++ , .

+2

"" common ++. ++, .

, ++ fortran, , - .

+1

, , , , , - .

" " , , , , . , . C extern should, , , .

, , . , , , "get" s "set" s .

+1

, .

0

, , c .

, , , , .

A structure with correctly laid out bit fields (specific to the compiler) with a pointer of this type pointing to the correct address can do the trick.

Since field values ​​may change without warning, unacceptable qualifications may be required.

This will help if the interlocutor provides more information about the layout of the general block, and the interpretation of the data inside it.

0
source

Source: https://habr.com/ru/post/1777566/


All Articles