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

Fortran 77 problem

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   February 16, 2009, 17:01
Default Fortran 77 problem
  #1
CFD_nerd
Guest
 
Posts: n/a
Hi Guys, I'm working on a CFD code my predecessor developed and it's written in fortran 77. I have extensive experience in fortran 90 but am having a few teething troubles with his code. If someone could shed some light on these issues I'd be very grateful.

The code uses a common file which stores all the global variables, this file is "included" in every subroutine. There is only one common file and it contains many variables. In order to introduce some changes to the code (it's massive and a re-write would take weeks) I have had to introduce some new variables, two of these are common to the whole program so I added them to the common file, lets call them Array1 and Array2. When doing this I remembered to declare their type as double precision and allocated the correct array size, of 10,10; they were also initialised at the start of the program so that all their array elements are equal to 0.0. In this prototype code Array1 and Array2 are not altered in any way (in other words they should be maintained at 0.0; when I get this bit working Array1 and Array2 will be read from a file - that's the next step).

There are two subroutines in the program, lets call them Asub and Bsub. Asub calculates the variables A, B and C and passes them to Bsub, Bsub them performs some calculations and returns an answer. The data passed between the two routines are local variables and are not required at any other point in the program - so I didn't add them to the 'common' file. The code looks something like:

-------------------------------------

Subroutine Asub

Include Codecommon.cmn

Double Precision A,B,C

A = Array1(1,1)

B = Array2(1,1)

C = 5

CALL Bsub(A,B,C,D)

-------------------------------------

Subroutine Bsub

Include Codecommon.cmn

Double Precision A,B,C

D = function(A,B,C)

-------------------------------------

My problem is that the solutions coming out of Bsub aren't what I expect. They seem to indicate that Array1 and Array2 have had their values changed - I'm not sure how this is possible since they are not used at any other point in the program. To verify this I ran searches for every mention of the variable names - they only appear where I expect them to. I also wrote a line into Bsub that printed the values A and B to a file every time the subroutine was accessed; I found several non-zero values (magnitude around 4e-4).

Once Array1 and Array2 have their values initiated to 0.0 I expect them to stay that way, they are not altered at any point in the code. I suspect this is something to do with the use of "include" and common files but I'm rather unfamiliar with these concepts. When I use global variables I always put them in modules.

If someone could please help - you may just save my sanity CFD nerd

  Reply With Quote

 


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
User fortran error when running CFX-10 in parallel CFDworker CFX 3 September 22, 2015 08:59
Fortran compiler problem Luke Siemens 2 September 18, 2008 03:43
Problem with Fortran installation. skarp CFX 0 August 4, 2007 07:09
natural convection problem for a CHT problem Se-Hee CFX 2 June 10, 2007 06:29
'C' or FORTRAN or 'C++' Yogesh Talekar Main CFD Forum 20 October 21, 1999 04:00


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