Skip to content

Commit

Permalink
Fix inconsistency of structure names
Browse files Browse the repository at this point in the history
  • Loading branch information
hiromatsui committed Apr 8, 2024
1 parent e80edc6 commit e1e4f50
Show file tree
Hide file tree
Showing 82 changed files with 2,844 additions and 1,723 deletions.
144 changes: 74 additions & 70 deletions src/C_libraries/BASE/read_image_2_png.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,41 +144,42 @@ void read_png_file_c(const char *fhead, int *num_x, int *num_y, int *iflag_rgba)
return;
}

void copy_rgb_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage)
void copy_rgb_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage)
{
int k, j, l;

if(*iflag_rgba == RGBA_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
if(iflag_rgba == RGBA_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[3*k ] = bimage[j][4*l ];
cimage[3*k+1] = bimage[j][4*l+1];
cimage[3*k+2] = bimage[j][4*l+2];
}
};
} else if(*iflag_rgba == RGB_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == RGB_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[3*k ] = bimage[j][3*l ];
cimage[3*k+1] = bimage[j][3*l+1];
cimage[3*k+2] = bimage[j][3*l+2];
}
};
} else if(*iflag_rgba == BW_ALPHA){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == BW_ALPHA){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[3*k ] = bimage[j][2*l];
cimage[3*k+1] = bimage[j][2*l];
cimage[3*k+2] = bimage[j][2*l];
}
};
} else if(*iflag_rgba == B_AND_W){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == B_AND_W){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[3*k ] = bimage[j][l];
cimage[3*k+1] = bimage[j][l];
cimage[3*k+2] = bimage[j][l];
Expand All @@ -189,44 +190,45 @@ void copy_rgb_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char
free(bimage);
};

void copy_rgba_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage)
void copy_rgba_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage)
{
int i, k, j, l;

if(*iflag_rgba == RGBA_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
if(iflag_rgba == RGBA_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[4*k ] = bimage[j][4*l ];
cimage[4*k+1] = bimage[j][4*l+1];
cimage[4*k+2] = bimage[j][4*l+2];
cimage[4*k+3] = bimage[j][4*l+3];
}
};
} else if(*iflag_rgba == RGB_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == RGB_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[4*k ] = bimage[j][3*l ];
cimage[4*k+1] = bimage[j][3*l+1];
cimage[4*k+2] = bimage[j][3*l+2];
cimage[4*k+3] = (unsigned char) 255;
}
};
} else if(*iflag_rgba == BW_ALPHA){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == BW_ALPHA){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[4*k ] = bimage[j][2*l ];
cimage[4*k+1] = bimage[j][2*l ];
cimage[4*k+2] = bimage[j][2*l ];
cimage[4*k+3] = bimage[j][2*l+1];
}
};
} else if(*iflag_rgba == B_AND_W){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == B_AND_W){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[4*k ] = bimage[j][l];
cimage[4*k+1] = bimage[j][l];
cimage[4*k+2] = bimage[j][l];
Expand All @@ -235,41 +237,42 @@ void copy_rgba_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char
};
};

for (i = 0; i < *num_y; i++) free(bimage[i]);
for (i = 0; i < num_y; i++) free(bimage[i]);
free(bimage);
};

void copy_grayscale_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage)
void copy_grayscale_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage)
{
int k, j, l, mixed;

if(*iflag_rgba == RGBA_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
if(iflag_rgba == RGBA_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
mixed = ((int) bimage[j][4*l ] + (int) bimage[j][4*l+1] + (int) bimage[j][4*l+2]) / 3;
cimage[k ] = (unsigned char) mixed;
}
};
} else if(*iflag_rgba == RGB_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == RGB_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
mixed = ((int) bimage[j][3*l ] + (int) bimage[j][3*l+1] + (int) bimage[j][3*l+2]) / 3;
cimage[k ] = (unsigned char) mixed;
}
};
} else if(*iflag_rgba == BW_ALPHA){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == BW_ALPHA){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[k ] = bimage[j][2*l ];
}
};
} else if(*iflag_rgba == B_AND_W){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == B_AND_W){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[k ] = bimage[j][l];
}
};
Expand All @@ -278,46 +281,47 @@ void copy_grayscale_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned
free(bimage);
};

void copy_grayalpha_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage)
void copy_grayalpha_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage)
{
int i, k, j, l, mixed;

if(*iflag_rgba == RGBA_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
if(iflag_rgba == RGBA_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
mixed = ((int) bimage[j][4*l ] + (int) bimage[j][4*l+1] + (int) bimage[j][4*l+2]) / 3;
cimage[2*k ] = (unsigned char) mixed;
cimage[2*k+1] = bimage[j][2*l+1];
}
};
} else if(*iflag_rgba == RGB_COLOR){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == RGB_COLOR){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
mixed = ((int) bimage[j][3*l ] + (int) bimage[j][3*l+1] + (int) bimage[j][3*l+2]) / 3;
cimage[2*k ] = (unsigned char) mixed;
cimage[2*k+3] = (unsigned char) 255;
}
};
} else if(*iflag_rgba == BW_ALPHA){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == BW_ALPHA){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[2*k ] = bimage[j][2*l ];
cimage[2*k+1] = bimage[j][2*l+1];
}
};
} else if(*iflag_rgba == B_AND_W){
for (l = 0; l < *num_x; l++) {
for (j = 0; j < *num_y; j++) {
k = (*num_y-j-1) * (*num_x) + l;
} else if(iflag_rgba == B_AND_W){
for (l = 0; l < num_x; l++) {
for (j = 0; j < num_y; j++) {
k = (num_y-j-1) * num_x + l;
cimage[2*k ] = bimage[j][l];
cimage[2*k+3] = (unsigned char) 255;
}
};
};

for (i = 0; i < *num_y; i++) free(bimage[i]);
for (i = 0; i < num_y; i++) free(bimage[i]);
free(bimage);
};
12 changes: 8 additions & 4 deletions src/C_libraries/BASE/read_image_2_png.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

void read_png_file_c(const char *fhead, int *num_x, int *num_y, int *iflag_rgba);

void copy_rgb_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage);
void copy_rgba_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage);
void copy_grayscale_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage);
void copy_grayalpha_from_png_c(int *num_x, int *num_y, int *iflag_rgba, unsigned char *cimage);
void copy_rgb_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage);
void copy_rgba_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage);
void copy_grayscale_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage);
void copy_grayalpha_from_png_c(const int num_x, const int num_y,
const int iflag_rgba, unsigned char *cimage);

#endif
2 changes: 1 addition & 1 deletion src/Fortran_libraries/MHD_src/IO/Makefile.depends
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bcast_ctl_data_mhd_time_rst.o: $(MHD_IO_DIR)/bcast_ctl_data_mhd_time_rst.f90 m_p
$(F90) -c $(F90OPTFLAGS) $<
bcast_dynamo_sect_control.o: $(MHD_IO_DIR)/bcast_dynamo_sect_control.f90 m_precision.o calypso_mpi.o m_machine_parameter.o t_control_data_dynamo_sects.o bcast_control_arrays.o bcast_section_control_data.o bcast_control_sph_MHD.o calypso_mpi_int.o calypso_mpi_char.o transfer_to_long_integers.o
$(F90) -c $(F90OPTFLAGS) $<
bcast_dynamo_viz_control.o: $(MHD_IO_DIR)/bcast_dynamo_viz_control.f90 m_precision.o calypso_mpi.o m_machine_parameter.o t_control_data_dynamo_vizs.o bcast_section_control_data.o bcast_maps_control_data.o bcast_control_sph_MHD.o
bcast_dynamo_viz_control.o: $(MHD_IO_DIR)/bcast_dynamo_viz_control.f90 m_precision.o calypso_mpi.o m_machine_parameter.o t_control_data_dynamo_vizs.o calypso_mpi_int.o calypso_mpi_char.o transfer_to_long_integers.o bcast_section_control_data.o bcast_maps_control_data.o bcast_control_sph_MHD.o
$(F90) -c $(F90OPTFLAGS) $<
bcast_monitor_data_ctl.o: $(MHD_IO_DIR)/bcast_monitor_data_ctl.f90 m_precision.o m_machine_parameter.o t_ctl_data_node_monitor.o calypso_mpi.o transfer_to_long_integers.o calypso_mpi_char.o calypso_mpi_int.o bcast_control_arrays.o
$(F90) -c $(F90OPTFLAGS) $<
Expand Down
8 changes: 8 additions & 0 deletions src/Fortran_libraries/MHD_src/IO/bcast_dynamo_viz_control.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ module bcast_dynamo_viz_control
subroutine s_bcast_dynamo_viz_control(zm_ctls)
!
use t_control_data_dynamo_vizs
!
use calypso_mpi_int
use calypso_mpi_char
use transfer_to_long_integers
use bcast_section_control_data
use bcast_maps_control_data
use bcast_control_sph_MHD
Expand All @@ -46,6 +50,10 @@ subroutine s_bcast_dynamo_viz_control(zm_ctls)
call bcast_files_4_psf_ctl(zm_ctls%zRMS_psf_ctls)
call bcast_files_4_map_ctl(zm_ctls%zm_map_ctls)
call bcast_files_4_map_ctl(zm_ctls%zRMS_map_ctls)
!
call calypso_mpi_bcast_character &
& (zm_ctls%block_name, cast_long(kchara), 0)
call calypso_mpi_bcast_one_int(zm_ctls%i_viz_ctl, 0)
!
end subroutine s_bcast_dynamo_viz_control
!
Expand Down
Loading

0 comments on commit e1e4f50

Please sign in to comment.