Converting type from FORTRAN to C #

I have in F2008

module mod_Blood
use mod_liquid
implicit none
type, public :: typ_BloodComponents
    character(len=5) :: name
    real(DP):: salt
    real(DP):: RBC
end type typ_BloodComponents

type, public :: typ_BloodWork
    real(DP) :: DrugConc
    real(DP) :: Dilution
    real(DP) :: volume  
    type(typ_BloodComponents) :: vein, artery

    contains
          procedure :: SetParameters => blood_SetParameters
          procedure :: BloodProteinParams  => blood_BloodProteinParams   
end type typ_BloodWork
end mod_Blood

I know that the vein and artery have the variable veins% name, vein% salt, vein% RBC and artery% name, artery% salt and artery% RBC.

How to pass this to C #? Is a module a namespace? And is FORTRAN a “type” class in C #?

It would be wise if I did something like:

class BloodComponents
{
string name;
double salt;
double RBC;
}

class BloodWork
{
    double drugConc
    double dil
    double volume

    class Vein : BloodComponents
    {}
    class Artery : BloodComponents
    {}

    void SetParameters()
    {...}
    void BloodComponentParameter()
    {...}
}

Or am I misinterpreting FORTRAN?

0
source share
1 answer

I think this is what you want:

namespace Blood
{
    public struct BloodComponents
    {
        public string name;
        public double salt, RBC;
    }

    public struct BloodWork
    {
        public double drugConc, dilution, volume;
        public BloodComponents vein, artery;

        public void SetParameters()
        {
        }
        public void BloodProteintParams()
        {
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var work=new BloodWork()
            {
                drugConc=0.1,
                dilution=0.2,
                volume=0.3,
                vein=new BloodComponents() { name="A", RBC=0.2, salt=0.6 },
                artery=new BloodComponents() { name="B", RBC=0.5, salt=0.9 }
            };
        }
    }
}

Everything is there struct, so the values ​​are copied only. If you want to refer to the same point in time BloodWork, for example, in several places, you need to change the type to class.

0
source

All Articles