[cig-commits] [commit] rajesh-petsc-schur: Removed caps_per_proc for loops from Output_gzdir.c (10850c6)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Nov 5 19:07:29 PST 2014
Repository : https://github.com/geodynamics/citcoms
On branch : rajesh-petsc-schur
Link : https://github.com/geodynamics/citcoms/compare/464e1b32299b15819f93efd98d969cddb84dfe51...f97ae655a50bdbd6dac1923a3471ee4dae178fbd
>---------------------------------------------------------------
commit 10850c654917a82470dea04c62be1430a9667643
Author: Rajesh Kommu <rajesh.kommu at gmail.com>
Date: Wed Sep 17 10:35:11 2014 -0700
Removed caps_per_proc for loops from Output_gzdir.c
>---------------------------------------------------------------
10850c654917a82470dea04c62be1430a9667643
lib/Output_gzdir.c | 89 ++++++++----------------------------------------------
1 file changed, 12 insertions(+), 77 deletions(-)
diff --git a/lib/Output_gzdir.c b/lib/Output_gzdir.c
index e7586b9..ba3f772 100644
--- a/lib/Output_gzdir.c
+++ b/lib/Output_gzdir.c
@@ -202,7 +202,6 @@ void gzdir_output(struct All_variables *E, int out_cycles)
if(E->output.heating && E->control.disptn_number != 0)
gzdir_output_heating(E, out_cycles);
- return;
}
@@ -284,7 +283,6 @@ void gzdir_output_coord(struct All_variables *E)
}
out = 0;
/* write nodal coordinate to file, big endian */
- for(j=1;j <= E->sphere.caps_per_proc;j++) {
for(i=1;i <= E->lmesh.nno;i++) {
/* cartesian coordinates */
x[0]=E->x[CPPR][1][i];x[1]=E->x[CPPR][2][i];x[2]=E->x[CPPR][3][i];
@@ -292,7 +290,6 @@ void gzdir_output_coord(struct All_variables *E)
BE_WERROR;
out++;
}
- }
if(E->output.gzdir.vtk_io == 2){ /* serial output, close and have
next one write */
fclose(fp1);fflush(fp1); /* close file and flush buffer */
@@ -334,7 +331,6 @@ void gzdir_output_coord(struct All_variables *E)
offset = -1;
}
ix[0] = enodes[E->mesh.nsd];
- for(j=1;j <= E->sphere.caps_per_proc;j++) {
for(i=1;i <= E->lmesh.nel;i++) {
/*
need to add offset according to the processor for global
@@ -347,7 +343,6 @@ void gzdir_output_coord(struct All_variables *E)
if(be_write_int_to_file(ix,9,fp1)!=9)
BE_WERROR;
}
- }
if(E->output.gzdir.vtk_io == 2){ /* serial IO */
fclose(fp1);fflush(fp1); /* close file and flush buffer */
if(E->parallel.me < E->parallel.nproc-1)
@@ -385,12 +380,10 @@ void gzdir_output_coord(struct All_variables *E)
gz1 = gzdir_output_open(output_file,"w");
/* nodal coordinates */
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(gz1,"%3d %7d\n",CPPR,E->lmesh.nno);
for(i=1;i<=E->lmesh.nno;i++)
gzprintf(gz1,"%.6e %.6e %.6e\n",
E->sx[CPPR][1][i],E->sx[CPPR][2][i],E->sx[CPPR][3][i]);
- }
gzclose(gz1);
if(E->output.gzdir.vtk_io == 1){
@@ -406,12 +399,10 @@ void gzdir_output_coord(struct All_variables *E)
snprintf(output_file,255,"%s/vtk_ecor.%d.gz",
E->control.data_dir,E->parallel.me);
gz1 = gzdir_output_open(output_file,"w");
- for(j=1;j <= E->sphere.caps_per_proc;j++) {
for(i=1;i <= E->lmesh.nno;i++) {
gzprintf(gz1,"%9.6f %9.6f %9.6f\n", /* cartesian nodal coordinates */
E->x[CPPR][1][i],E->x[CPPR][2][i],E->x[CPPR][3][i]);
}
- }
gzclose(gz1);
/*
connectivity for all elements
@@ -420,7 +411,6 @@ void gzdir_output_coord(struct All_variables *E)
snprintf(output_file,255,"%s/vtk_econ.%d.gz",
E->control.data_dir,E->parallel.me);
gz1 = gzdir_output_open(output_file,"w");
- for(j=1;j <= E->sphere.caps_per_proc;j++) {
for(i=1;i <= E->lmesh.nel;i++) {
gzprintf(gz1,"%2i\t",enodes[E->mesh.nsd]);
if(enodes[E->mesh.nsd] != 8){
@@ -437,12 +427,10 @@ void gzdir_output_coord(struct All_variables *E)
E->ien[CPPR][i].node[5]+offset,E->ien[CPPR][i].node[6]+offset,
E->ien[CPPR][i].node[7]+offset,E->ien[CPPR][i].node[8]+offset);
}
- }
gzclose(gz1);
} /* end vtkio = 1 (pre VTK) */
}
- return;
}
/*
@@ -474,12 +462,10 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
if(!E->output.gzdir.vtk_base_init) /* init space */
E->output.gzdir.vtk_base = (float *)safe_malloc(sizeof(float)*os*E->sphere.caps_per_proc);
/* compute */
- for(k=0,j=1;j <= E->sphere.caps_per_proc;j++,k += os) {
- for(i=1;i <= E->lmesh.nno;i++,k += 9){
+ for(i=1,k=0;i <= E->lmesh.nno;i++,k += 9){
/* cartesian basis vectors at theta, phi */
calc_cbase_at_node(CPPR,i,(E->output.gzdir.vtk_base+k),E);
}
- }
E->output.gzdir.vtk_base_init = 1;
}
}
@@ -534,7 +520,6 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
/* open for append */
fp1 = output_open(output_file,"a");
}
- for(j=1; j<= E->sphere.caps_per_proc;j++) /* print the temperatures */
for(i=1;i<=E->lmesh.nno;i++){
cvec[0] = E->T[CPPR][i];
if(be_write_float_to_file(cvec,1,fp1)!=1)
@@ -561,10 +546,9 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
mpi_rc = MPI_Recv(&mpi_inmsg, 1, MPI_INT, (E->parallel.me-1), 5, E->parallel.world, &mpi_stat);
fp1 = output_open(output_file,"a");
}
- for(k=0,j=1;j <= E->sphere.caps_per_proc;j++,k += os) {
if(E->output.gzdir.rnr){
/* remove NR */
- for(i=1;i<=E->lmesh.nno;i++,k += 9) {
+ for(i=1,k=0;i<=E->lmesh.nno;i++,k += 9) {
vcorr[0] = E->sphere.cap[CPPR].V[1][i]; /* vtheta */
vcorr[1] = E->sphere.cap[CPPR].V[2][i]; /* vphi */
/* remove the velocity that corresponds to a net rotation of omega[0..2] at location
@@ -578,13 +562,12 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
}
}else{
/* regular output */
- for(i=1;i<=E->lmesh.nno;i++,k += 9) {
+ for(i=1,k=0;i<=E->lmesh.nno;i++,k += 9) {
convert_pvec_to_cvec(E->sphere.cap[CPPR].V[3][i],E->sphere.cap[CPPR].V[1][i],E->sphere.cap[CPPR].V[2][i],
(E->output.gzdir.vtk_base+k),cvec);
if(be_write_float_to_file(cvec,3,fp1)!=3)BE_WERROR;
}
}
- }
fclose(fp1);fflush(fp1); /* close file and flush buffer */
if(E->output.gzdir.vtk_io == 2){
if(E->parallel.me < E->parallel.nproc-1){
@@ -629,7 +612,6 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
gzout = gzdir_output_open(output_file,"w");
gzprintf(gzout,"%d %d %.5e\n",
cycles,E->lmesh.nno,E->monitor.elapsed_time);
- for(j=1; j<= E->sphere.caps_per_proc;j++) {
gzprintf(gzout,"%3d %7d\n",CPPR,E->lmesh.nno);
if(E->output.gzdir.vtk_io){
/* VTK */
@@ -656,7 +638,6 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
E->sphere.cap[CPPR].V[3][i],E->T[CPPR][i]);
}
}
- }
gzclose(gzout);
if(E->output.gzdir.vtk_io){
/*
@@ -665,10 +646,9 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
snprintf(output_file,255,"%s/%d/vtk_v.%d.%d.gz",
E->control.data_dir,cycles,E->parallel.me,cycles);
gzout = gzdir_output_open(output_file,"w");
- for(k=0,j=1;j <= E->sphere.caps_per_proc;j++,k += os) {
if(E->output.gzdir.rnr){
/* remove NR */
- for(i=1;i<=E->lmesh.nno;i++,k += 9) {
+ for(i=1,k=0;i<=E->lmesh.nno;i++,k += 9) {
vcorr[0] = E->sphere.cap[CPPR].V[1][i];
vcorr[1] = E->sphere.cap[CPPR].V[2][i];
sub_netr(E->sx[CPPR][3][i],E->sx[CPPR][1][i],E->sx[CPPR][2][i],(vcorr+0),(vcorr+1),omega);
@@ -678,7 +658,7 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
}
}else{
/* regular output */
- for(i=1;i<=E->lmesh.nno;i++,k += 9) {
+ for(i=1,k=0;i<=E->lmesh.nno;i++,k += 9) {
/* convert r,theta,phi vector to x,y,z at base location */
convert_pvec_to_cvec(E->sphere.cap[CPPR].V[3][i],
E->sphere.cap[CPPR].V[1][i],
@@ -689,7 +669,6 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
cvec[0],cvec[1],cvec[2]);
}
}
- }
gzclose(gzout);
}
@@ -699,7 +678,6 @@ void gzdir_output_velo_temp(struct All_variables *E, int cycles)
if(!E->output.gzdir.vtk_base_save)
free(E->output.gzdir.vtk_base);
}
- return;
}
/*
@@ -724,11 +702,9 @@ void gzdir_output_visc(struct All_variables *E, int cycles)
"%s/%d/visc.%d.%d.gz", E->control.data_dir,
cycles,E->parallel.me, cycles);
gz1 = gzdir_output_open(output_file,"w");
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(gz1,"%3d %7d\n",CPPR,E->lmesh.nno);
for(i=1;i<=E->lmesh.nno;i++)
gzprintf(gz1,"%.4e\n",E->VI[lev][CPPR][i]);
- }
gzclose(gz1);
}else{
@@ -746,7 +722,6 @@ void gzdir_output_visc(struct All_variables *E, int cycles)
/* open for append */
fp1 = output_open(output_file,"a");
}
- for(j=1; j<= E->sphere.caps_per_proc;j++)
for(i=1;i<=E->lmesh.nno;i++){
ftmp = log10(E->VI[lev][CPPR][i]);
if(fabs(ftmp) < 5e-7)ftmp = 0.0;
@@ -758,7 +733,6 @@ void gzdir_output_visc(struct All_variables *E, int cycles)
mpi_rc = MPI_Send(&mpi_success_message, 1, MPI_INT, (E->parallel.me+1), 0, E->parallel.world);
}
}
- return;
}
#ifdef CITCOM_ALLOW_ANISOTROPIC_VISC
@@ -785,11 +759,9 @@ void gzdir_output_avisc(struct All_variables *E, int cycles)
"%s/%d/avisc.%d.%d.gz", E->control.data_dir,
cycles,E->parallel.me, cycles);
gz1 = gzdir_output_open(output_file,"w");
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(gz1,"%3d %7d\n",CPPR,E->lmesh.nno);
for(i=1;i<=E->lmesh.nno;i++)
gzprintf(gz1,"%.4e %.4e %.4e %.4e\n",E->VI2[lev][CPPR][i],E->VIn1[lev][CPPR][i],E->VIn2[lev][CPPR][i],E->VIn3[lev][CPPR][i]);
- }
gzclose(gz1);
}else{
@@ -807,7 +779,6 @@ void gzdir_output_avisc(struct All_variables *E, int cycles)
/* open for append */
fp1 = output_open(output_file,"a");
}
- for(j=1; j<= E->sphere.caps_per_proc;j++)
for(i=1;i<=E->lmesh.nno;i++){
ftmp = E->VI2[lev][CPPR][i];
if(be_write_float_to_file(&ftmp,1,fp1)!=1)
@@ -820,7 +791,6 @@ void gzdir_output_avisc(struct All_variables *E, int cycles)
}
}
}
- return;
}
#endif
@@ -849,7 +819,6 @@ void gzdir_output_surf_botm(struct All_variables *E, int cycles)
cycles,E->parallel.me, cycles);
fp2 = gzdir_output_open(output_file,"w");
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
/* choose either STD topo or pseudo-free-surf topo */
if(E->control.pseudo_free_surf)
topo = E->slice.freesurf[CPPR];
@@ -862,7 +831,6 @@ void gzdir_output_surf_botm(struct All_variables *E, int cycles)
gzprintf(fp2,"%.4e %.4e %.4e %.4e\n",
topo[i],E->slice.shflux[CPPR][i],E->sphere.cap[CPPR].V[1][s],E->sphere.cap[CPPR].V[2][s]);
}
- }
gzclose(fp2);
}
@@ -872,18 +840,15 @@ void gzdir_output_surf_botm(struct All_variables *E, int cycles)
cycles,E->parallel.me, cycles);
fp2 = gzdir_output_open(output_file,"w");
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(fp2,"%3d %7d\n",CPPR,E->lmesh.nsf);
for(i=1;i<=E->lmesh.nsf;i++) {
s = (i-1)*E->lmesh.noz + 1;
gzprintf(fp2,"%.4e %.4e %.4e %.4e\n",
E->slice.tpgb[CPPR][i],E->slice.bhflux[CPPR][i],E->sphere.cap[CPPR].V[1][s],E->sphere.cap[CPPR].V[2][s]);
}
- }
gzclose(fp2);
}
- return;
}
@@ -951,7 +916,6 @@ void gzdir_output_stress(struct All_variables *E, int cycles)
gzprintf(fp1,"%d %d %.5e\n",cycles,E->lmesh.nno,E->monitor.elapsed_time);
- for(m=1;m<=E->sphere.caps_per_proc;m++) {
gzprintf(fp1,"%3d %7d\n",CPPR,E->lmesh.nno);
for (node=1;node<=E->lmesh.nno;node++)
gzprintf(fp1, "%.4e %.4e %.4e %.4e %.4e %.4e\n",
@@ -961,7 +925,6 @@ void gzdir_output_stress(struct All_variables *E, int cycles)
E->gstress[CPPR][(node-1)*6+4], /* stp */
E->gstress[CPPR][(node-1)*6+5], /* str */
E->gstress[CPPR][(node-1)*6+6]); /* srp */
- }
gzclose(fp1);
}
@@ -997,7 +960,6 @@ void gzdir_output_horiz_avg(struct All_variables *E, int cycles)
gzclose(fp1);
}
- return;
}
@@ -1011,13 +973,11 @@ void gzdir_output_mat(struct All_variables *E)
snprintf(output_file,255,"%s/mat.%d.gz", E->control.data_dir,E->parallel.me);
fp = gzdir_output_open(output_file,"w");
- for (m=1;m<=E->sphere.caps_per_proc;m++)
- for(el=1;el<=E->lmesh.nel;el++)
- gzprintf(fp,"%d %d %f\n", el,E->mat[CPPR][el],E->VIP[CPPR][el]);
+ for(el=1;el<=E->lmesh.nel;el++)
+ gzprintf(fp,"%d %d %f\n", el,E->mat[CPPR][el],E->VIP[CPPR][el]);
gzclose(fp);
- return;
}
@@ -1039,11 +999,9 @@ void gzdir_output_pressure(struct All_variables *E, int cycles)
E->parallel.me, cycles);
gz1 = gzdir_output_open(output_file,"w");
gzprintf(gz1,"%d %d %.5e\n",cycles,E->lmesh.nno,E->monitor.elapsed_time);
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(gz1,"%3d %7d\n",CPPR,E->lmesh.nno);
for(i=1;i<=E->lmesh.nno;i++)
gzprintf(gz1,"%.6e\n",E->NP[CPPR][i]);
- }
gzclose(gz1);
}else{/* new legacy VTK */
if(E->output.gzdir.vtk_io == 2)
@@ -1057,7 +1015,6 @@ void gzdir_output_pressure(struct All_variables *E, int cycles)
mpi_rc = MPI_Recv(&mpi_inmsg, 1, MPI_INT, (E->parallel.me-1), 0, E->parallel.world, &mpi_stat);
fp1 = output_open(output_file,"a");
}
- for(j=1; j<= E->sphere.caps_per_proc;j++)
for(i=1;i<=E->lmesh.nno;i++){
ftmp = E->NP[CPPR][i];
if(be_write_float_to_file(&ftmp,1,fp1)!=1)BE_WERROR;
@@ -1068,7 +1025,6 @@ void gzdir_output_pressure(struct All_variables *E, int cycles)
mpi_rc = MPI_Send(&mpi_success_message, 1, MPI_INT, (E->parallel.me+1), 0, E->parallel.world);
}
}
- return;
}
@@ -1086,9 +1042,7 @@ void gzdir_output_tracer(struct All_variables *E, int cycles)
ncolumns = 3 + E->trace.number_of_extra_quantities;
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
- gzprintf(fp1,"%d %d %d %.5e\n", cycles, E->trace.ntracers[CPPR],
- ncolumns, E->monitor.elapsed_time);
+ gzprintf(fp1,"%d %d %d %.5e\n", cycles, E->trace.ntracers[CPPR], ncolumns, E->monitor.elapsed_time);
for(n=1;n<=E->trace.ntracers[CPPR];n++) {
/* write basic quantities (coordinate) */
@@ -1104,10 +1058,7 @@ void gzdir_output_tracer(struct All_variables *E, int cycles)
gzprintf(fp1, "\n");
}
- }
-
gzclose(fp1);
- return;
}
@@ -1128,7 +1079,6 @@ void gzdir_output_comp_nd(struct All_variables *E, int cycles)
E->control.data_dir,cycles,
E->parallel.me, cycles);
gz1 = gzdir_output_open(output_file,"w");
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(gz1,"%3d %7d %.5e %.5e %.5e\n",
CPPR, E->lmesh.nel,
E->monitor.elapsed_time,
@@ -1139,7 +1089,6 @@ void gzdir_output_comp_nd(struct All_variables *E, int cycles)
gzprintf(gz1,"%.6e ",E->composition.comp_node[CPPR][k][i]);
gzprintf(gz1,"\n");
}
- }
gzclose(gz1);
}else{/* new legacy VTK */
if(E->output.gzdir.vtk_io == 2)
@@ -1156,7 +1105,6 @@ void gzdir_output_comp_nd(struct All_variables *E, int cycles)
mpi_rc = MPI_Recv(&mpi_inmsg, 1, MPI_INT, (E->parallel.me-1), 0, E->parallel.world, &mpi_stat);
fp1 = output_open(output_file,"a");
}
- for(j=1; j<= E->sphere.caps_per_proc;j++)
for(i=1;i<=E->lmesh.nno;i++){
for(k=0;k<E->composition.ncomp;k++){
ftmp = E->composition.comp_node[CPPR][k][i];
@@ -1169,7 +1117,6 @@ void gzdir_output_comp_nd(struct All_variables *E, int cycles)
mpi_rc = MPI_Send(&mpi_success_message, 1, MPI_INT, (E->parallel.me+1), 0, E->parallel.world);
}
}
- return;
}
@@ -1183,7 +1130,6 @@ void gzdir_output_comp_el(struct All_variables *E, int cycles)
cycles,E->parallel.me, cycles);
fp1 = gzdir_output_open(output_file,"w");
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
gzprintf(fp1,"%3d %7d %.5e %.5e %.5e\n",
CPPR, E->lmesh.nel,
E->monitor.elapsed_time,
@@ -1195,10 +1141,8 @@ void gzdir_output_comp_el(struct All_variables *E, int cycles)
gzprintf(fp1,"%.6e ",E->composition.comp_el[CPPR][k][i]);
gzprintf(fp1,"\n");
}
- }
gzclose(fp1);
- return;
}
@@ -1214,15 +1158,11 @@ void gzdir_output_heating(struct All_variables *E, int cycles)
gzprintf(fp1,"%.5e\n",E->monitor.elapsed_time);
- for(j=1;j<=E->sphere.caps_per_proc;j++) {
- gzprintf(fp1,"%3d %7d\n", CPPR, E->lmesh.nel);
- for(e=1; e<=E->lmesh.nel; e++)
- gzprintf(fp1, "%.4e %.4e %.4e\n", E->heating_adi[CPPR][e],
- E->heating_visc[CPPR][e], E->heating_latent[CPPR][e]);
- }
+ gzprintf(fp1,"%3d %7d\n", CPPR, E->lmesh.nel);
+ for(e=1; e<=E->lmesh.nel; e++)
+ gzprintf(fp1, "%.4e %.4e %.4e\n", E->heating_adi[CPPR][e],
+ E->heating_visc[CPPR][e], E->heating_latent[CPPR][e]);
gzclose(fp1);
-
- return;
}
@@ -1276,7 +1216,6 @@ void restart_tic_from_gzdir_file(struct All_variables *E)
switch(E->output.gzdir.vtk_io) {
case 1: /* VTK */
- for(m=1;m <= E->sphere.caps_per_proc;m++) {
if(fscanf(fp,"%i %i",&ll,&mm) != 2)
myerror(E,"restart vtkl read error 1");
for(i=1;i<=E->lmesh.nno;i++){
@@ -1288,10 +1227,8 @@ void restart_tic_from_gzdir_file(struct All_variables *E)
}
E->T[CPPR][i] = g;
}
- }
break;
default: /* old style velo */
- for(m=1;m <= E->sphere.caps_per_proc;m++) {
fscanf(fp,"%i %i",&ll,&mm);
for(i=1;i<=E->lmesh.nno;i++) {
if(fscanf(fp,"%f %f %f %f",&v1,&v2,&v3,&g) != 4)
@@ -1303,7 +1240,6 @@ void restart_tic_from_gzdir_file(struct All_variables *E)
//E->T[m][i] = max(0.0,min(g,1.0));
E->T[CPPR][i] = g;
}
- }
break;
}
fclose (fp);
@@ -1312,7 +1248,6 @@ void restart_tic_from_gzdir_file(struct All_variables *E)
temperatures_conform_bcs(E);
- return;
}
More information about the CIG-COMMITS
mailing list