Reputation: 73
I have a large Fortran code for HPC where several equations are solved over a computational grid. So in many places in the source code are placed nested do cycle to loop over the entair computational domain, shuch as
do k = 1,number_of_point_in_z
do j = 1,number_of_point_in_y
do i = 1,number_of_point_in_x
... some operations ...
end do
end do
end do
I would like to replace these lines with a single statment and I found the only solution to be the use of include statment, as
include 'start_domain_cycle'
... some operations ...
include 'end_domain_cycle'
with two files named start_domain_cycle and end_domain_cycle defined as follow
block
integer :: i, j, k
do k = 1,number_of_point_in_z
do j = 1,number_of_point_in_y
do i = 1,number_of_point_in_x
and
end do
end do
end do
end block
My questions are:
Upvotes: 0
Views: 93
Reputation: 2689
The source code present in the include files is first inserted where the include
are, then the complete code is compiled. So from an optimisation point of view it makes no difference.
A matter of personal preference... I find it more readable to have the whole code together, but this is just my opinion. You could also append the 3 do
on a single line (with shorter variable names for readability)
do k = 1,nz ; do j = 1,ny ; do i = 1,nx
Upvotes: 1