43 program twotanksmacroscopicproblemfortran
49 integer,
parameter ::dp=selected_real_kind(15)
51 real(dp),
parameter :: d = 0.01_dp;
54 real(dp) :: p1 = 10000;
55 real(dp) :: v0 = 0.1_dp;
57 real(dp) :: temp = 300;
59 real(dp) :: t = 0.0_dp;
60 real(dp),
parameter :: deltat = 1e-3_dp;
61 real(dp),
parameter ::
tend = 5.5_dp;
73 type(c_ptr) :: client = c_null_ptr
74 type(c_ptr) :: model = c_null_ptr
75 type(c_ptr) :: inputs = c_null_ptr
76 type(c_ptr) :: outputs = c_null_ptr
78 integer(c_size_t) :: dpos
79 integer(c_size_t) :: rho0pos
80 integer(c_size_t) :: p0pos
81 integer(c_size_t) :: p1byp0pos
83 m0 = p0*v0/287.1_dp/temp;
84 m1 = p1*v1/287.1_dp/temp;
95 dpos = modena_model_inputs_argpos(model, c_char_
"D"//c_null_char);
96 rho0pos = modena_model_inputs_argpos(model, c_char_
"rho0"//c_null_char);
97 p0pos = modena_model_inputs_argpos(model, c_char_
"p0"//c_null_char);
98 p1byp0pos = modena_model_inputs_argpos(model, c_char_
"p1Byp0"//c_null_char);
102 call modena_model_argpos_check(model);
104 do while(t + deltat <
tend + 1e-10_dp)
131 m0 = m0 - mdot*deltat;
132 m1 = m1 + mdot*deltat;
158 m0 = m0 + mdot*deltat;
159 m1 = m1 - mdot*deltat;
164 p0 = m0/v0*287.1_dp*temp;
165 p1 = m1/v1*287.1_dp*temp;
167 write(*,*)
"t = ",t,
" rho0 = ",rho0,
" p0 = ",p0,
" p1 = ",p1
175 end program twotanksmacroscopicproblemfortran