CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   colon in Fortran77 (https://www.cfd-online.com/Forums/main/164376-colon-fortran77.html)

jollage December 19, 2015 15:34

colon in Fortran77
 
Hi,

I'm writing a Fortran77 code and it would be complied by gfortran or mpif90 (I have gcc 5.2.0 installed). I sometimes used colon for indicating the interested range of an array, is it a good practice for a Fortran77 code? For example, I have

do i=1,Ny
(some subroutine generates a new solu for every i)
a(i,1:Ny) = solu
end do

where a is a 2D matrix of size (Nx,Ny) and solu is a 1D array of size Ny. I tested it and it seems to work good, but I'm concerned with any bug it might generate. The code is much more complicated than these lines. Do you have any suggestions? Thanks in advance.

flotus1 December 19, 2015 17:39

That will do. You might as well use
Code:

a(i,:)
instead if you do not want to give the lower and upper limits explicitly.
I guess it is just a typo, but I think the first line should read "do i=1, Nx"

Edit:
However since Fortran is column-major, this part of the code might be quite inefficient and it could be a good idea to have the loops for both dimensions of the array explicitly or change their order.

jollage December 20, 2015 14:46

Quote:

Originally Posted by flotus1 (Post 578170)
That will do. You might as well use
Code:

a(i,:)
instead if you do not want to give the lower and upper limits explicitly.
I guess it is just a typo, but I think the first line should read "do i=1, Nx"

Edit:
However since Fortran is column-major, this part of the code might be quite inefficient and it could be a good idea to have the loops for both dimensions of the array explicitly or change their order.

Thanks. I see.

jollage December 23, 2015 04:05

Quote:

Originally Posted by flotus1 (Post 578170)
That will do. You might as well use
Code:

a(i,:)
instead if you do not want to give the lower and upper limits explicitly.
I guess it is just a typo, but I think the first line should read "do i=1, Nx"

Edit:
However since Fortran is column-major, this part of the code might be quite inefficient and it could be a good idea to have the loops for both dimensions of the array explicitly or change their order.

Hi,

Can I ask another question? I use gfortran for compiling my F77 scripts. But sometimes I do use intrinsic functions which are introduced for F95 or even later. Will this potentially cause any problems? I did experience that it's of no problem, but need someone to confirm that. Thanks.

flotus1 December 23, 2015 04:55

I guess only few people out there are still sticking to pure FORTRAN 77 standards.
Gfortran is constantly developing and the features of the newer fortran standards are implemented.
So any recent version of gfortran is able to handle features introduced after the FORTRAN 77 standard. For functions not jet implemented you will get compiler warnings and errors.


All times are GMT -4. The time now is 19:37.