From c1e0bec7f6d6530766ac934e7f3cc4b0e235249c Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 20 Jun 2012 14:29:20 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8352 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/compute_atom_molecule.cpp | 8 +++++--- src/fix_ave_histo.cpp | 14 ++++++++------ src/variable.cpp | 36 +++++++++++++++++++++++------------ 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/compute_atom_molecule.cpp b/src/compute_atom_molecule.cpp index 8e665ff803..1e204f2a07 100644 --- a/src/compute_atom_molecule.cpp +++ b/src/compute_atom_molecule.cpp @@ -267,8 +267,9 @@ void ComputeAtomMolecule::compute_array() } } - MPI_Allreduce(&aone[0][0],&array[0][0],nvalues*nmolecules, - MPI_DOUBLE,MPI_SUM,world); + if (array) + MPI_Allreduce(&aone[0][0],&array[0][0],nvalues*nmolecules, + MPI_DOUBLE,MPI_SUM,world); } /* ---------------------------------------------------------------------- @@ -296,7 +297,8 @@ void ComputeAtomMolecule::compute_one(int m) peratom = compute->vector_atom; nstride = 1; } else { - peratom = &compute->array_atom[0][aidx-1]; + if (compute->array_atom) peratom = &compute->array_atom[0][aidx-1]; + else peratom = NULL; nstride = compute->size_array_cols; } diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index d29b7756b4..c3498f4193 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -627,8 +627,9 @@ void FixAveHisto::end_of_step() compute->compute_array(); compute->invoked_flag |= INVOKED_ARRAY; } - bin_vector(compute->size_array_rows,&compute->array[0][j-1], - compute->size_array_cols); + if (compute->array) + bin_vector(compute->size_array_rows,&compute->array[0][j-1], + compute->size_array_cols); } } else if (kind == PERATOM) { @@ -638,7 +639,7 @@ void FixAveHisto::end_of_step() } if (j == 0) bin_atoms(compute->vector_atom,1); - else + else if (compute->array_atom) bin_atoms(compute->array_atom[j-1], compute->size_peratom_cols); @@ -649,7 +650,7 @@ void FixAveHisto::end_of_step() } if (j == 0) bin_vector(compute->size_local_rows,compute->vector_local,1); - else + else if (compute->array_local) bin_vector(compute->size_local_rows,&compute->array_local[0][j-1], compute->size_local_cols); } @@ -675,11 +676,12 @@ void FixAveHisto::end_of_step() } else if (kind == PERATOM) { if (j == 0) bin_atoms(fix->vector_atom,1); - else bin_atoms(fix->array_atom[j-1],fix->size_peratom_cols); + else if (fix->array_atom) + bin_atoms(fix->array_atom[j-1],fix->size_peratom_cols); } else if (kind == LOCAL) { if (j == 0) bin_vector(fix->size_local_rows,fix->vector_local,1); - else + else if (fix->array_local) bin_vector(fix->size_local_rows,&fix->array_local[0][j-1], fix->size_local_cols); } diff --git a/src/variable.cpp b/src/variable.cpp index 839f6dd093..4f63b1806a 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -871,9 +871,10 @@ double Variable::evaluate(char *str, Tree **tree) compute->invoked_flag |= INVOKED_PERATOM; } - peratom2global(1,NULL,&compute->array_atom[0][index2-1], - compute->size_peratom_cols,index1, - tree,treestack,ntreestack,argstack,nargstack); + if (compute->array_atom) + peratom2global(1,NULL,&compute->array_atom[0][index2-1], + compute->size_peratom_cols,index1, + tree,treestack,ntreestack,argstack,nargstack); // c_ID = vector from per-atom vector @@ -921,7 +922,10 @@ double Variable::evaluate(char *str, Tree **tree) Tree *newtree = new Tree(); newtree->type = ATOMARRAY; - newtree->array = &compute->array_atom[0][index1-1]; + if (compute->array_atom) + newtree->array = &compute->array_atom[0][index1-1]; + else + newtree->array = NULL; newtree->nstride = compute->size_peratom_cols; newtree->left = newtree->middle = newtree->right = NULL; treestack[ntreestack++] = newtree; @@ -1048,9 +1052,10 @@ double Variable::evaluate(char *str, Tree **tree) update->ntimestep % fix->peratom_freq) error->all(FLERR,"Fix in variable not computed at compatible time"); - peratom2global(1,NULL,&fix->array_atom[0][index2-1], - fix->size_peratom_cols,index1, - tree,treestack,ntreestack,argstack,nargstack); + if (fix->array_atom) + peratom2global(1,NULL,&fix->array_atom[0][index2-1], + fix->size_peratom_cols,index1, + tree,treestack,ntreestack,argstack,nargstack); // f_ID = vector from per-atom vector @@ -1086,7 +1091,10 @@ double Variable::evaluate(char *str, Tree **tree) Tree *newtree = new Tree(); newtree->type = ATOMARRAY; - newtree->array = &fix->array_atom[0][index1-1]; + if (fix->array_atom) + newtree->array = &fix->array_atom[0][index1-1]; + else + newtree->array = NULL; newtree->nstride = fix->size_peratom_cols; newtree->left = newtree->middle = newtree->right = NULL; treestack[ntreestack++] = newtree; @@ -2883,7 +2891,8 @@ int Variable::special_function(char *word, char *contents, Tree **tree, "is accessed out-of-range"); if (update->whichflag == 0) { if (compute->invoked_array != update->ntimestep) - error->all(FLERR,"Compute used in variable between runs is not current"); + error->all(FLERR, + "Compute used in variable between runs is not current"); } else if (!(compute->invoked_flag & INVOKED_ARRAY)) { compute->compute_array(); compute->invoked_flag |= INVOKED_ARRAY; @@ -2910,7 +2919,8 @@ int Variable::special_function(char *word, char *contents, Tree **tree, nstride = 1; } else if (index && fix->array_flag) { if (index > fix->size_array_cols) - error->all(FLERR,"Variable formula fix array is accessed out-of-range"); + error->all(FLERR, + "Variable formula fix array is accessed out-of-range"); if (update->whichflag > 0 && update->ntimestep % fix->global_freq) error->all(FLERR,"Fix in variable not computed at compatible time"); nvec = fix->size_array_rows; @@ -2925,8 +2935,10 @@ int Variable::special_function(char *word, char *contents, Tree **tree, if (compute) { double *vec; - if (index) vec = &compute->array[0][index-1]; - else vec = compute->vector; + if (index) { + if (compute->array) vec = &compute->array[0][index-1]; + else vec = NULL; + } else vec = compute->vector; int j = 0; for (int i = 0; i < nvec; i++) {