CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   from c to fortran (https://www.cfd-online.com/Forums/main/125989-c-fortran.html)

Rawnak November 5, 2013 15:09

from c to fortran
 
please I need a help to understand this c-code (two phase flow), which I try to write it using fortran
for( subs=0; subs<NUM_FLUID_COMPONENTS; subs++)
for( j=0; j<LY; j++)
for( i=0; i<LX; i++)
{
rhoij[subs] = 0.;
u_xij[subs] = 0.;
u_yij[subs] = 0.;
if( !is_solid_node[j][i]) {
for( a=0; a<9; a++) {
rhoij[subs] += ftemp_ij[a];
u_xij[subs] += ex[a]*ftemp_ij[a];
u_yij[subs] += ey[a]*ftemp_ij[a]; } }
}

well here the code in fortran:

do l=1,2
do j=0,m
do i=0,n
rho(i,j,l)=0.0
u(i,j,l)=0.0
v(i,j,l)=0.0

do k=0,8
rho(i,j,l)=rho(i,j,l)+f(k,i,j,l)
u(i,j,l)=u(i,j,l)+f(k,i,j,l)*cx(k)
u(i,j,l)=v(i,j,l)+f(k,i,j,l)*cy(k)
end do
enddo
end do
end do

the thing that I don't understant how to write if( !is_solid_node[j][i])

Thank you


cfdnewbie November 5, 2013 15:29

It is a NOT IF, so the way in FORTRAN to do this is : IF (.NOT.somelogical) THEN


Cheers
:)

Rawnak November 5, 2013 15:40

Thank you for your reply,

Well, here we have two fluids sub=0 and 1
why we put if not solid, what do they mean?

cfdnewbie November 5, 2013 15:44

That is something only you can answer, as you are the one who works with the codes... from the snippet you posted, there is no way to understand the whole issue....
You first should make sure you understand the equations, assumptions and schemes that are involved fully before you try to rewrite the program. without understanding what is going on, there's no chance!

Rawnak November 5, 2013 15:54

You're totally right, thanks alot:)

Rawnak November 6, 2013 14:47

question
 
what does i++ mean in the following sentence
i=0; i<LX; i++
and what does this mean
( i<LX-1)?( i+1):( 0 );
because I know fortran and not c programming

Thanks

cfdnewbie November 6, 2013 16:28

The first one does just mean i=i+1. I can't read the second one due to the smiley. You should consult a C manual for your questions or use google, as they can be answered very easily that way.

Cheers,


All times are GMT -4. The time now is 02:05.