Dear all,
I have a grid based data which is a 3-D array
data(N1,N2,N3)
where
N1 = (x_max - x_min + step_x) / step_x
N2 = (y_max - y_min + step_y) / step_y
N3 = (z_max - z_min + step_z) / step_z
x_min is the minimum value for the x-coordinate
x_max is the maximum value for the x-coordinate
step_x is the step size along x
and so on (all these values are integers).
The data which I have is from an output file where the data is printed 'possibly' using the following code. I only have the binary and this is a guess.
N_data = 0
do x = x_min, x_max, step_x ! one can also use do 1 : N1
do y = y_min, y_max, step_y
do z = z_min, z_max, step_z
if ( data(x,y,z) .ne. 0) then
N_data = N_data + 1
print *, x, y, z, data(x,y,z)
endif
enddo
enddo
enddo
when data(x,y,z) = 0, the value is not printed. Currently I am simply reading the grid data as a 2-D array
grid_data(N_data, 4) ! 4 columns for x, y, z, data(x,y,z)
I am trying to implement an expression where I need the full 3-D array (data) including the zero values with proper array indices. So I have to back transform the grid_data to the original data(N1, N2, N3). This I have been doing as shown below
ii = 0
do ind_x = x_min, x_max, stepx
ii = ii + 1
jj = 0
do ind_y = y_min, y_max, stepy
jj = jj + 1
kk = 0
do ind_z = z_min, z_max, stepz
kk = kk + 1
do ind_g = 1, N_grids
if( (ind_x .eq. grid_data(ind_g, 1) ) .and. ( (ind_y .eq. grid_data(ind_g, 2) ) .and. ( (ind_z .eq. grid_data(ind_g, 3) ) ) then
data(ii,jj,kk) = grid_data(ind_g, 4)
endif
enddo
enddo
enddo
enddo
The code works, but for large number of grids it runs for ever. Is there a way to do it efficiently. Any help is greatly appreciated. Thank you in advance.
regards,
Raghu
I have a grid based data which is a 3-D array
data(N1,N2,N3)
where
N1 = (x_max - x_min + step_x) / step_x
N2 = (y_max - y_min + step_y) / step_y
N3 = (z_max - z_min + step_z) / step_z
x_min is the minimum value for the x-coordinate
x_max is the maximum value for the x-coordinate
step_x is the step size along x
and so on (all these values are integers).
The data which I have is from an output file where the data is printed 'possibly' using the following code. I only have the binary and this is a guess.
N_data = 0
do x = x_min, x_max, step_x ! one can also use do 1 : N1
do y = y_min, y_max, step_y
do z = z_min, z_max, step_z
if ( data(x,y,z) .ne. 0) then
N_data = N_data + 1
print *, x, y, z, data(x,y,z)
endif
enddo
enddo
enddo
when data(x,y,z) = 0, the value is not printed. Currently I am simply reading the grid data as a 2-D array
grid_data(N_data, 4) ! 4 columns for x, y, z, data(x,y,z)
I am trying to implement an expression where I need the full 3-D array (data) including the zero values with proper array indices. So I have to back transform the grid_data to the original data(N1, N2, N3). This I have been doing as shown below
ii = 0
do ind_x = x_min, x_max, stepx
ii = ii + 1
jj = 0
do ind_y = y_min, y_max, stepy
jj = jj + 1
kk = 0
do ind_z = z_min, z_max, stepz
kk = kk + 1
do ind_g = 1, N_grids
if( (ind_x .eq. grid_data(ind_g, 1) ) .and. ( (ind_y .eq. grid_data(ind_g, 2) ) .and. ( (ind_z .eq. grid_data(ind_g, 3) ) ) then
data(ii,jj,kk) = grid_data(ind_g, 4)
endif
enddo
enddo
enddo
enddo
The code works, but for large number of grids it runs for ever. Is there a way to do it efficiently. Any help is greatly appreciated. Thank you in advance.
regards,
Raghu