- #1

- 14

- 0

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Fortran
- Thread starter abdulsulo
- Start date

- #1

- 14

- 0

- #2

DrClaude

Mentor

- 7,627

- 4,068

- #3

- 14

- 0

Fortran:

```
Do I=2,N,1
X1=(Yr(I)/R)
X2=X1**(1/7)
Ua(I)=Um*X2
END DO
```

X1 and X2 are both double precision. I decided to divide the equation and take power but still it didn't work for me.

On first iteration I am giving you the values of variables there;

R=0.05

Um=2

Yr= 2.85E-05

Whatever I do it gives X1**(1/7) as 1 which is not correct.

- #4

- 14

- 0

Your hint gave me an idea and I think I solved the problem. I put 1./7. to the equation and problem solved. Didn't notice it would roll it down to 0. Thank you very much.

- #5

DrClaude

Mentor

- 7,627

- 4,068

- #6

Mark44

Mentor

- 35,433

- 7,297

The most commonly used CPUs for personal computers these days are those produced by Intel and AMD. Both types of CPU have one op code for integer division (DIV) and another for floating-point division (FDIV), which gives more precise results, but takes longer to calculate. Compilers for Fortran and C and C++ choose the type of division to perform based on the code you write.

- #7

jedishrfu

Mentor

- 13,180

- 7,079

1) implicit/explict variable naming conventions where variables starting with i thru n are integers and all others are reals unless you say otherwise with explicit statements.

2) format statement errors where the description is too small for displaying the number.

3) for free-form fortran typing a C in column 1 created a comment line so you had to make sure that "character" or "common" statements were indented otherwise you got all sorts of compile-time errors.

I added all of these to my personal collection of errors made list more than forty years ago give or take but more take than give.

and there are many more subtle ones too.

- #8

- 706

- 154

- #9

Mark44

Mentor

- 35,433

- 7,297

I use integer division often. This operation and the modulus operation are useful in converting days to weeks and days, ounces to pounds and ounces, making change, and many other applications.

Last edited:

- #10

jtbell

Mentor

- 15,829

- 4,219

- #11

- 706

- 154

Share: