Changeset d3482a for pcp/src/perturbed.c


Ignore:
Timestamp:
Apr 23, 2008, 4:03:13 PM (18 years ago)
Author:
Frederik Heber <heber@…>
Children:
4f9fe2
Parents:
d52fb5
Message:

various suffix...[255] or filename[255] were changed from arrays to pointers

Instead of having fixed array length that are fully represented in the code switched to Malloc/Free.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pcp/src/perturbed.c

    rd52fb5 rd3482a  
    28942894  double eta, delta_chi, S, A, iso;
    28952895  int cross_lookup[4];
     2896  char *suffixchi;
     2897  FILE *ChiFile;
     2898  time_t seconds;
    28962899
    28972900  if(P->Call.out[NormalOut]) fprintf(stderr,"(%i)Calculating Magnetic Susceptibility \n", P->Par.me); 
     
    29502953    }
    29512954  }
     2955
     2956  suffixchi = (char *) Malloc(sizeof(char)*255, "CalculateMagneticSusceptibility: *suffixchi");
    29522957  // store symmetrized matrix
    29532958  for (in=0;in<NDIM;in++)
     
    29562961  // output tensor to file
    29572962  if (P->Par.me == 0) {
    2958     FILE *ChiFile;
    2959     char suffixchi[255];
    2960     time_t seconds;
    2961      
    29622963    time(&seconds); // get current time
    29632964    sprintf(&suffixchi[0], ".chi.L%i.csv", Lev0->LevelNo);
     
    30043005  // output PAS tensor to file
    30053006  if (P->Par.me == 0) {
    3006     FILE *ChiFile;
    3007     char suffixchi[255];
    3008     time_t seconds;
    3009      
    30103007    time(&seconds); // get current time
    30113008    sprintf(&suffixchi[0], ".chi_PAS.csv");
     
    30263023  gsl_vector_free(eval);
    30273024  gsl_matrix_complex_free(H);
     3025  Free(suffixchi, "CalculateMagneticSusceptibility: *suffixchi");
    30283026}
    30293027
     
    30693067  gsl_matrix_complex *H = gsl_matrix_complex_calloc(NDIM,NDIM);
    30703068  FILE *SigmaFile;
    3071   char suffixsigma[255];
     3069  char *suffixsigma = (char *) Malloc(sizeof(char)*255, "CalculateChemicalShieldingByReciprocalCurrentDensity: *suffixsigma");
    30723070 
    30733071  time_t seconds; 
     
    31603158  // output tensor to file
    31613159  if (P->Par.me == 0) {
    3162     sprintf(&suffixsigma[0], ".sigma_chi_rezi.L%i.csv", Lev0->LevelNo);
     3160    sprintf(suffixsigma, ".sigma_chi_rezi.L%i.csv", Lev0->LevelNo);
    31633161    OpenFile(P, &SigmaFile, suffixsigma, "a", P->Call.out[ReadOut]);
    31643162    fprintf(SigmaFile,"# chemical shielding tensor sigma_rezi[01,02,03,10,11,12,20,21,22], seed %i, config %s, run on %s", R->Seed, P->Files.default_path, ctime(&seconds));
     
    31863184      // output tensor to file
    31873185      if (P->Par.me == 0) {
    3188         sprintf(&suffixsigma[0], ".sigma_i%i_%s_rezi.L%i.csv", ion, I->I[it].Symbol, Lev0->LevelNo);
     3186        sprintf(suffixsigma, ".sigma_i%i_%s_rezi.L%i.csv", ion, I->I[it].Symbol, Lev0->LevelNo);
    31893187        OpenFile(P, &SigmaFile, suffixsigma, "a", P->Call.out[ReadOut]);
    31903188        fprintf(SigmaFile,"# chemical shielding tensor sigma_rezi[01,02,03,10,11,12,20,21,22], seed %i, config %s, run on %s", R->Seed, P->Files.default_path, ctime(&seconds));
     
    32323230      }
    32333231      if (P->Par.me == 0) {
    3234         FILE *SigmaFile;
    3235         char suffixsigma[255];
    3236         sprintf(&suffixsigma[0], ".sigma_i%i_%s_PAS.csv", ion, I->I[it].Symbol);
     3232        sprintf(suffixsigma, ".sigma_i%i_%s_PAS.csv", ion, I->I[it].Symbol);
    32373233        if (Lev0->LevelNo == Lat->MaxLevel-2) {
    32383234          OpenFile(P, &SigmaFile, suffixsigma, "w", P->Call.out[ReadOut]);
     
    33043300  gsl_vector_free(eval);
    33053301  gsl_matrix_complex_free(H);
     3302  Free(suffixsigma, "CalculateChemicalShieldingByReciprocalCurrentDensity: *suffixsigma");
    33063303}
    33073304
     
    33373334  const int N0 = Lev0->Plan0.plan->local_nx;
    33383335  FILE *MomentFile;
    3339   char suffixmoment[255];
     3336  char *suffixmoment = (char *) Malloc(sizeof(char)*255, "CalculateMagneticMoment: *suffixmoment");
    33403337  time_t seconds; 
    33413338  time(&seconds); // get current time
     
    34443441
    34453442  gsl_matrix_complex_free(H);
     3443  Free(suffixmoment, "CalculateMagneticMoment: *suffixmoment");
    34463444}
    34473445
     
    37763774  struct LatticeLevel *Lev0 = R->Lev0;
    37773775  struct Density *Dens0 = Lev0->Dens;
    3778   char filename[255];
     3776  char *filename;
    37793777  char *suchpointer;
    37803778  FILE *PlotFile = NULL;
     
    37953793  if (!myPE) { // only process 0 writes to file
    37963794    // open file
     3795    filename = (char *) Malloc(sizeof(char)*255, "PlotVectorPlane: *filename");
    37973796    sprintf(&filename[0], ".current.L%i.csv", Lev0->LevelNo);
    37983797    OpenFile(P, &PlotFile, filename, "w", P->Call.out[ReadOut]);
     
    38053804      fprintf(PlotFile,"\n");
    38063805    } else { Error(SomeError, "PlotVectorPlane: Opening Plot File"); }
     3806    Free(filename, "PlotVectorPlane: *filename");
    38073807  }
    38083808
Note: See TracChangeset for help on using the changeset viewer.