forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Could someone please lend a hand?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Thu Sep 21, 2006 8:50 am    Post subject: Could someone please lend a hand? Reply with quote

Hello folks,
If someone could lend a hand with this problem then I'd be very grateful. The problem is something to do with the way I'm using fortran (or perhaps a problem with the compiler?) .

Recently I've been working on a code to do some calculations on fluid flow around an airfoil. To simplify things, lets say that I have 2 arrays: 'upper' and 'lower' which are (1x100) double precision arrays. The code works out the flowspeeds on the upper and lower surfaces and then stores the results in the appropriate array.

The trial flow is symmetrical; the equations used to find the 'upper' values are absolutely identical to those used to find the 'lower' values. Essentially the same equations are solved twice to give two answers that are identical. In the end I have 2 identical arrays (subtracting one from the other gives zeros everywhere - i have tested this).

My problem comes when I try to store these variables to a file. I use a homemade subroutine that takes all the information from my main program and stores the important stuff into files for post-processing. The storage codes look something like this:

Code:
filename=trim(output_folder)//'/results.dat'
OPEN(UNIT=20,FILE=trim(filename))
DO I=1,100
WRITE(20,*) lower(I), upper(I)
ENDDO
CLOSE(UNIT=20)


The code should produce a data file with 2 colums of data, each containing 100 values. The arrays 'upper' and 'lower' are identical so the columns should both be the same. The problem is that they are not!!! Sad(

If, however, I enter an extra line into my storage subroutine (the 'write(*,*)' line at the top) :

Code:
write(*,*) lower
filename=trim(output_folder)//'/results.dat'
OPEN(UNIT=20,FILE=trim(filename))
DO I=1,100
WRITE(20,*) lower(I), upper(I)
ENDDO
CLOSE(UNIT=20)


Then I find that the contents of 'lower' are displayed to the screen (as expected) and the resulting data file is stored correctly. The 'write' line doesn't change the contents of either array but it does lead mean that the results are correctly stored into the data-file. I can't think why this woud be the case. Removing the write line means that the data-file is incorrect.

Could someone please point me in the right direction as to where I might be going wrong? This problem seems so silly - I'm running, essentially, the same code twice but getting 2 different data files.

Cheers,
Bren

P.S. I've checked that the arguments for the subroutine match the call statement; and that all the arguments of the subroutine are of the correct sizes etc.
Back to top
Anonymous
Guest





PostPosted: Thu Sep 21, 2006 9:02 am    Post subject: Could someone please lend a hand? Reply with quote

Sorry folks,
I should have also mentioned that when I remove the storage subroutine altogether and add the file-creation lines to the end of the main program then this problem doesn't seem to occur. The use of the subroutine makes life a lot easier for me (and I understand it's considered better programming to use subroutines) but seems to cause the problem of incorrect data being written to files.

The problem, it seems, is something to do with the way that information is passed from the main program to the subroutine. I have double checked the CALL statement and all array sizes and they seem fine.

Cheers,
Bren
Back to top
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7926
Location: Salford, UK

PostPosted: Thu Sep 21, 2006 4:05 pm    Post subject: Could someone please lend a hand? Reply with quote

Bren

I think that you need to give some more information before the cause of your problem can be easily identified.

Can you contruct (and post) a small working main program with a subroutine call that illustrates the problem? This would make it a relatively simple problem to solve.
Back to top
View user's profile Send private message AIM Address
Bren



Joined: 26 Sep 2006
Posts: 1

PostPosted: Tue Sep 26, 2006 4:11 pm    Post subject: Could someone please lend a hand? Reply with quote

Thanks Paul,

I removed the subroutine and simply added the storage routines into the main program - this seemed to fix the problem. I have no idea why this happened - to be honest I've been having a few problems with fortran recently and am beginning to wonder whether some of the fortran files have somehow become corrupted. I'll have a bash at re-installing it and see how everything goes.

Thanks for your help,
Bren
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group