Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran coding issues

Status
Not open for further replies.

Newbie911

Technical User
Jul 27, 2014
2
AU
[pre][/pre]

Hi,

In the following piece of code, I want to vary lambda and Gamma but in such a way that the product of lambda and gamma remains 2, ie Lambda*gamma=2

I am unsure how to do this,

The program also reads in an initial value of gamma and lambda from an input file which I can specify.

do ll = 1, 7
! gam=1.0e-3*facg
gam = 1/1024.*2.0**(ll - 1)
do mm = 1, 7
! lambda=1.0e+3*facl
lambda = 64*2.0**(mm - 1)
 
Well...you cannot have 2 do-loops and one nested inside the other...this way, you will be generated all 7 values of the inner variable (lambda) for every 1 value of the outer one (gam).

You said it yourself, lambda*gamma=2...that's one equation, two unknowns...as soon as 1 variables is defined, the other one is determinable...given gamma =.125 ==> lambda = 2.0/gamma = 8.0

 
Thank you for your reply salgerman,

So how should I change the code to vary them both automatically but keep the product 2?

 
Get rid of the inner loop, just use the outer one where you define gamma, then, simply define lambda as showed above: lambda = 2.0/gamma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top