CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

from c to fortran

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 5, 2013, 15:09
Default from c to fortran
  #1
New Member
 
RAWNAK.h
Join Date: Oct 2013
Posts: 7
Rep Power: 2
Rawnak is on a distinguished road
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

Rawnak is offline   Reply With Quote

Old   November 5, 2013, 15:29
Default
  #2
Senior Member
 
cfdnewbie
Join Date: Mar 2010
Posts: 546
Rep Power: 10
cfdnewbie is on a distinguished road
It is a NOT IF, so the way in FORTRAN to do this is : IF (.NOT.somelogical) THEN


Cheers
cfdnewbie is offline   Reply With Quote

Old   November 5, 2013, 15:40
Default
  #3
New Member
 
RAWNAK.h
Join Date: Oct 2013
Posts: 7
Rep Power: 2
Rawnak is on a distinguished road
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?
Rawnak is offline   Reply With Quote

Old   November 5, 2013, 15:44
Default
  #4
Senior Member
 
cfdnewbie
Join Date: Mar 2010
Posts: 546
Rep Power: 10
cfdnewbie is on a distinguished road
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!
cfdnewbie is offline   Reply With Quote

Old   November 5, 2013, 15:54
Default
  #5
New Member
 
RAWNAK.h
Join Date: Oct 2013
Posts: 7
Rep Power: 2
Rawnak is on a distinguished road
You're totally right, thanks alot
Rawnak is offline   Reply With Quote

Old   November 6, 2013, 14:47
Default question
  #6
New Member
 
RAWNAK.h
Join Date: Oct 2013
Posts: 7
Rep Power: 2
Rawnak is on a distinguished road
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
Rawnak is offline   Reply With Quote

Old   November 6, 2013, 16:28
Default
  #7
Senior Member
 
cfdnewbie
Join Date: Mar 2010
Posts: 546
Rep Power: 10
cfdnewbie is on a distinguished road
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,
cfdnewbie is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Fortran with CFX: How to connect Fortran to CFX? l.te CFX 0 October 21, 2012 11:42
Fortran Compiler-CFX12.1 Araz CFX 11 February 14, 2012 07:36
Intrinsic Procedure 'ISNAN' in GNU FORTRAN 77 hawk Main CFD Forum 1 April 12, 2005 22:13
visual fortran Monica Main CFD Forum 1 August 28, 2004 20:45
Fortran77 or Fortran 90 Swapnil CFX 2 November 26, 2002 15:16


All times are GMT -4. The time now is 20:00.