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

Please help me on my fortran subroutine

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 20, 2016, 08:02
Default Please help me on my fortran subroutine
  #1
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
Hi

I have written a fortran subroutine.

subroutine write_surfaces(n_loc,nn_loc)
use mainvar_module
integer n_loc,nn_loc

if(nn_loc.eq.3)then
a=max(nint(writ_inc/dt),1)
if(myrank.eq.0)then
write(90,*) a, num_levels, nprocs
close(90)
endif
endif

if(myrank.eq.0)then
write(9,*) t(nn_loc)
endif
CCCC WANTS TO MAKE CHANGE BELOW
write(UNIT=7000+myrank) bl_hor_wall(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge),
- nut(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc),
- h(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc)

CCCC WANT TO MAKE CHANGE ABOVE

write(UNIT=10000+myrank) tmp_mat(1:endx,
- 1:endy)
cZZZZZZZZZZ
do cur_level=1,num_levels
cZZZZZZZZZZ

do j=2,endy-1
do i=2,endx-1
call calc_vel_DA(n_loc,u_DA,v_DA,w_DA)

u_z(i,j)=u_DA
v_z(i,j)=v_DA
enddo
enddo


write(UNIT=3000+myrank) zeta(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc,cur_level)

write(UNIT=6000+myrank) u_z(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge),v_z(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge)

if(dim.eq.2)then
do j=2,endy-1
do i=2,endx-1

z=zeta(i,j,4,cur_level)
call calc_vel_z(4,z,u_z1,v_z1,w_z1)

u_z(i,j)=u_z1
v_z(i,j)=v_z1
enddo
enddo

do j=3,endy-2
do i=3,endx-2
dvdx(i,j,cur_level)=(v_z(i+1,j)
- -v_z(i-1,j))/(2.*dx)

dudy(i,j,cur_level)=(u_z(i,j+1)
- -u_z(i,j-1))/(2.*dy)
enddo
enddo


do j=1,endy
do i=1,endx
vort(i,j)=dvdx(i,j,cur_level)
- -dudy(i,j,cur_level)
enddo
enddo
endif

write(UNIT=8000+myrank) vort(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge),u_z(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge),v_z(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge)

cZZZZZZZZZZ
enddo
cZZZZZZZZZZ

return
end ! end subroutine
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC


In the above subroutine

I want to make changes in the particular section

"
write(UNIT=7000+myrank) bl_hor_wall(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge),
- nut(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc),
- h(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc)
"

by writing data of another variable tmp in the file so I made the following changes

"
write(UNIT=7000+myrank) bl_hor_wall(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge),
- nut(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc),
- h(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc),
- tmp(
- startx_sponge:endx_sponge,
- starty_sponge:endy_sponge,n_loc)
"

where as values of tmp , h, nut and bl_hor_wall were alloted in the main program.

When I make the change as specified below, firstly it doesn't writes the actual value of tmp and secondly it corrupts the values of bl_hor_wall, nut, h also.

Please suggest where am I going wrong.
KaranG is offline   Reply With Quote

Old   December 20, 2016, 08:34
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
This is only one part of the output. Without knowing how the single pieces are assembled, is difficult to say what the main problem is.

Also, all the details about how the file is opened and accessed are also missing.

Moreover, does this work in serial?
sbaffini is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 19 Air Conditioning Simulation (Error in Compiling the Fortran Subroutine) xyq916 CFX 0 April 24, 2016 06:21
Fortran subroutine using <Particle Type>.Temperature christoph.h CFX 0 November 12, 2014 10:44
Fortran Subroutine Error sergiorbrett CFX 12 September 3, 2012 07:40
Fortran subroutine (Perl not found) gillou_sk8@hotmail.com CFX 0 June 20, 2008 09:59
FORTRAN Subroutine Neser25 CFX 3 October 20, 2005 14:55


All times are GMT -4. The time now is 03:14.