From e6996e2b342bcffaa3dbe23f14ea1c509a6dc371 Mon Sep 17 00:00:00 2001
From: yurkin <yurkin@45a4d0da-b139-11dd-ba98-ad202adc45ad>
Date: Wed, 8 Feb 2012 06:52:44 +0000
Subject: [PATCH] Further work to improve handling of string literals
 throughout the code (continuation of r 1105). A few string functions in
 param.c were changed accordingly. Filenames, etc. now do not require
 additional storage but just point to respective parts of 'argv'.

Automatic directory name was slightly changed, e.g., from '...g16m1_5[id...]' to '...g16_m1.5[_id...]'.

Line in the beginning of stdout with a lot of "meaningless" numbers was removed (it was especially annoying in MPI mode). Now it is only produced in FULLDEBUG. Instead, box dimensions were added to stdout.

Fixed minor bug in saving DDSCAT 7 format, introduced by original implementation of r1100.

Minor changes in Stop() (comm.c) in parallel mode.
---
 src/GenerateB.c       |   4 +-
 src/calculator.c      |   4 +-
 src/comm.c            |  11 +++--
 src/cpp/fft_setup.cpp |   2 +-
 src/iterative.c       |   3 ++
 src/make_particle.c   |  35 ++++++++------
 src/param.c           | 103 ++++++++++++++++++++++--------------------
 src/vars.c            |  10 ++--
 src/vars.h            |   4 +-
 9 files changed, 95 insertions(+), 81 deletions(-)

diff --git a/src/GenerateB.c b/src/GenerateB.c
index 2529be00..6ab60e53 100644
--- a/src/GenerateB.c
+++ b/src/GenerateB.c
@@ -43,8 +43,8 @@
 // defined and initialized in param.c
 extern const int beam_Npars;
 extern const double beam_pars[];
-extern const char beam_fnameY[];
-extern const char beam_fnameX[];
+extern const char *beam_fnameY;
+extern const char *beam_fnameX;
 extern opt_index opt_beam;
 
 
diff --git a/src/calculator.c b/src/calculator.c
index 54b39812..24b0a98b 100644
--- a/src/calculator.c
+++ b/src/calculator.c
@@ -3,7 +3,7 @@
  * Descr: all the initialization is done here before actually calculating internal fields; includes
  *        calculation of couple constants
  *
- * Copyright (C) 2006-2010 ADDA contributors
+ * Copyright (C) 2006-2010,2012 ADDA contributors
  * This file is part of ADDA.
  *
  * ADDA is free software: you can redistribute it and/or modify it under the terms of the GNU
@@ -39,7 +39,7 @@ extern const Parms_1D parms[2],parms_alpha;
 extern const angle_set beta_int,gamma_int,theta_int,phi_int;
 // defined and initialized in param.c
 extern const int avg_inc_pol;
-extern const char alldir_parms[],scat_grid_parms[];
+extern const char *alldir_parms,*scat_grid_parms;
 // defined and initialized in timing.c
 extern TIME_TYPE Timing_Init;
 extern size_t TotalEval;
diff --git a/src/comm.c b/src/comm.c
index f08371be..7686519f 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -3,7 +3,7 @@
  * Descr: incorporates all parallelization related code, so most of it is directly involved in or
  *        closely related to interprocess communication
  *
- * Copyright (C) 2006-2011 ADDA contributors
+ * Copyright (C) 2006-2012 ADDA contributors
  * This file is part of ADDA.
  *
  * ADDA is free software: you can redistribute it and/or modify it under the terms of the GNU
@@ -30,6 +30,7 @@
 #include "function.h"
 #include "parbas.h"
 #include "cmplx.h"
+#include "debug.h"
 
 #ifdef ADDA_MPI
 MPI_Datatype mpi_dcomplex,mpi_double3,mpi_dcomplex3;  // combined datatypes
@@ -294,9 +295,6 @@ void Stop(const int code)
 		MPI_Abort(MPI_COMM_WORLD,code);
 	}
 	else { // regular termination
-		// wait for all processors
-		fflush(stdout);
-		Synchronize();
 		// clean MPI constructs and some memory
 		MPI_Type_free(&mpi_dcomplex);
 		MPI_Type_free(&mpi_double3);
@@ -305,6 +303,9 @@ void Stop(const int code)
 			Free_general(recvcounts);
 			Free_general(displs);
 		}
+		// wait for all processors
+		fflush(stdout);
+		Synchronize();
 		// finalize MPI communications
 		MPI_Finalize();
 	}
@@ -581,7 +582,7 @@ void ParSetup(void)
 	local_Nx=local_x1-local_x0;
 	boxXY=boxX*(size_t)boxY; // overflow check is covered by gridYZ above
 	local_Ndip=MultOverflow(boxXY,local_z1_coer-local_z0,ALL_POS,"local_Ndip");
-	printf("%i :  %i %i %i %zu %zu \n",ringid,local_z0,local_z1_coer,local_z1,local_Ndip,local_Nx);
+	D("%i :  %i %i %i %zu %zu \n",ringid,local_z0,local_z1_coer,local_z1,local_Ndip,local_Nx);
 }
 
 //============================================================
diff --git a/src/cpp/fft_setup.cpp b/src/cpp/fft_setup.cpp
index 57afe8e1..d623ea88 100644
--- a/src/cpp/fft_setup.cpp
+++ b/src/cpp/fft_setup.cpp
@@ -74,7 +74,7 @@
 using namespace std;
 
 extern void getKernelWorkDimensions(cl_fft_plan *plan, cl_fft_kernel_info *kernelInfo, cl_int *batchSize, size_t *gWorkItems, size_t *lWorkItems);
-extern const char coptions[];
+extern const char *coptions;
 
 static void 
 getBlockConfigAndKernelString(cl_fft_plan *plan)
diff --git a/src/iterative.c b/src/iterative.c
index f525e2ca..2f75f075 100644
--- a/src/iterative.c
+++ b/src/iterative.c
@@ -50,6 +50,9 @@ extern doublecomplex * restrict vec1,* restrict vec2,* restrict vec3,* restrict
 extern const double iter_eps;
 extern const enum init_field InitField;
 extern const bool recalc_resid;
+extern const time_t chp_time;
+extern const char *chp_dir;
+
 // defined and initialized in timing.c
 extern TIME_TYPE Timing_OneIter,Timing_OneIterComm,Timing_InitIter,Timing_InitIterComm,
 	Timing_IntFieldOneComm;
diff --git a/src/make_particle.c b/src/make_particle.c
index 57c7f9e1..56a0433a 100644
--- a/src/make_particle.c
+++ b/src/make_particle.c
@@ -47,9 +47,9 @@ extern const enum sym sym_type;
 extern const double lambda;
 extern double sizeX,dpl,a_eq;
 extern const int jagged;
-extern const char shape_fname[];
-extern char shapename[];
-extern char save_geom_fname[];
+extern const char *shape_fname;
+extern const char *shapename;
+extern const char *save_geom_fname;
 extern const bool volcor,save_geom;
 extern opt_index opt_sh;
 extern const double gr_vf;
@@ -154,12 +154,16 @@ static void SaveGeometry(void)
 
 	// create save_geom_fname if not specified, by adding extension to the shapename
 	if (save_geom_fname[0]==0) {
-		if (sg_format==SF_TEXT || sg_format==SF_TEXT_EXT)
-			sprintf(save_geom_fname,"%s.geom",shapename);
-		else if (sg_format==SF_DDSCAT6 || sg_format==SF_DDSCAT7)
-			sprintf(save_geom_fname,"%s.dat",shapename);
+		const char *ext;
+		char *buf; // actual storage for save_geom_fname
+		// choose extension
+		if (sg_format==SF_TEXT || sg_format==SF_TEXT_EXT) ext="geom";
+		else if (sg_format==SF_DDSCAT6 || sg_format==SF_DDSCAT7) ext="dat";
+		else LogError(ONE_POS,"Unknown format for saved geometry file (%d)",sg_format);
+		MALLOC_VECTOR(buf,char,strlen(shapename)+strlen(ext)+2,ALL);
+		sprintf(buf,"%s.%s",shapename,ext);
+		save_geom_fname=buf;
 	}
-
 	// automatically change format if needed
 	if (sg_format==SF_TEXT && Nmat>1) sg_format=SF_TEXT_EXT;
 	// choose filename
@@ -179,16 +183,18 @@ static void SaveGeometry(void)
 			             "#box size: %dx%dx%d\n",shapename,boxX,boxY,boxZ);
 			if (sg_format==SF_TEXT_EXT) fprintf(geom,"Nmat=%d\n",Nmat);
 		}
-		else if (sg_format==SF_DDSCAT6 || sg_format==SF_DDSCAT7)
+		else if (sg_format==SF_DDSCAT6 || sg_format==SF_DDSCAT7) {
 			fprintf(geom,"shape: '%s'; box size: %dx%dx%d; generated by ADDA v."ADDA_VERSION"\n"
 			             "%zu = NAT\n"
 			             "1 0 0 = A_1 vector\n"
 			             "0 1 0 = A_2 vector\n"
-			             "1 1 1 = lattice spacings (d_x,d_y,d_z)/d\n"
-			             "JA  IX  IY  IZ ICOMP(x,y,z)\n",shapename,boxX,boxY,boxZ,nvoid_Ndip);
+			             "1 1 1 = lattice spacings (d_x,d_y,d_z)/d\n",
+			             shapename,boxX,boxY,boxZ,nvoid_Ndip);
 			if (sg_format==SF_DDSCAT7) fprintf(geom,
 				"%g %g %g = coordinates (x0,y0,z0)/d of the zero dipole (IX=IY=IZ=0)\n",
 				(1-boxX)/2.0,(1-boxY)/2.0,(1-boxZ)/2.0);
+			fprintf(geom,"JA  IX  IY  IZ ICOMP(x,y,z)\n");
+		}
 #ifdef PARALLEL
 	} // end of if
 #endif
@@ -397,7 +403,6 @@ static void InitDipFile(const char * restrict fname,int *bX,int *bY,int *bZ,int
 	 */
 	fseek(dipfile,0,SEEK_SET);
 	SkipNLines(dipfile,skiplines);
-
 }
 
 //===========================================================
@@ -1769,7 +1774,11 @@ void InitShape(void)
 			PrintError("Specified domain number to be granulated (%d) is larger than total number "
 				"of domains (%d) for the given shape (%s)",gr_mat+1,Nmat_need,shapename);
 		else Nmat_need++;
-		strcat(shapename,"_gran");
+		// update shapename; use new storage
+		char *buf;
+		MALLOC_VECTOR(buf,char,strlen(shapename)+6,ALL);
+		sprintf(buf,"%s_gran",shapename);
+		shapename=buf;
 	}
 	// check if enough refractive indices or extra
 	if (Nmat<Nmat_need) {
diff --git a/src/param.c b/src/param.c
index b8c0c71e..6d58e552 100644
--- a/src/param.c
+++ b/src/param.c
@@ -93,8 +93,8 @@ bool store_ampl;      // Write amplitude matrix to file
 int phi_int_type;
 // used in calculator.c
 bool avg_inc_pol;                 // whether to average CC over incident polarization
-char alldir_parms[MAX_FNAME];     // name of file with alldir parameters
-char scat_grid_parms[MAX_FNAME];  // name of file with parameters of scattering grid
+const char *alldir_parms;         // name of file with alldir parameters
+const char *scat_grid_parms;      // name of file with parameters of scattering grid
 // used in crosssec.c
 double prop_0[3];                 // initial incident direction (in laboratory reference frame)
 double incPolX_0[3],incPolY_0[3]; // initial incident polarizations (in lab RF)
@@ -106,14 +106,17 @@ double igt_eps; // relative error of integration in IGT
 int beam_Npars;
 double beam_pars[MAX_N_BEAM_PARMS]; // beam parameters
 opt_index opt_beam;                 // option index of beam option used
-char beam_fnameY[MAX_FNAME];        // names of files, defining the beam (for two polarizations)
-char beam_fnameX[MAX_FNAME];
+const char *beam_fnameY;            // names of files, defining the beam (for two polarizations)
+const char *beam_fnameX;
 // used in io.c
 char logfname[MAX_FNAME]=""; // name of logfile
 // used in iterative.c
 double iter_eps;           // relative error to reach
 enum init_field InitField; // how to calculate initial field for the iterative solver
 bool recalc_resid;         // whether to recalculate residual at the end of iterative solver
+time_t chp_time;           // time of checkpoint (in sec)
+char const *chp_dir;       // directory name to save/load checkpoint
+
 // used in make_particle.c
 enum sh shape;                   // particle shape definition
 int sh_Npars;                    // number of shape parameters
@@ -123,9 +126,9 @@ double sizeX;                    // size of particle along x-axis
 double dpl;                      // number of dipoles per lambda (wavelength)
 double lambda;                   // incident wavelength (in vacuum)
 int jagged;                      // size of big dipoles, used to construct a particle
-char shape_fname[MAX_FNAME];     // name of file, defining the shape
-char save_geom_fname[MAX_FNAME]; // geometry file name to save dipole configuration
-char shapename[MAX_LINE];        // name of the used shape
+const char *shape_fname;         // name of file, defining the shape
+const char *save_geom_fname;     // geometry file name to save dipole configuration
+const char *shapename;           // name of the used shape
 bool volcor;                     // whether to use volume correction
 bool save_geom;                  // whether to save dipole configuration in .geom file
 opt_index opt_sh;                // option index of shape option used
@@ -140,10 +143,10 @@ bool store_grans;                // whether to save granule positions to file
 
 #define GFORM_RI_DIRNAME "%.4g" // format for refractive index in directory name
 
-static char run_name[MAX_WORD];   // first part of the dir name ('run' or 'test')
-static char avg_parms[MAX_FNAME]; // name of file with orientation averaging parameters
-static char *exename;             // name of executable (adda, adda.exe, adda_mpi,...)
-static int Nmat_given;            // number of refractive indices given in the command line
+static const char *run_name;    // first part of the dir name ('run' or 'test')
+static const char *avg_parms;   // name of file with orientation averaging parameters
+static const char *exename;     // name of executable (adda, adda.exe, adda_mpi,...)
+static int Nmat_given;          // number of refractive indices given in the command line
 
 /* TO ADD NEW COMMAND LINE OPTION
  * If you need new variables or flags to implement effect of the new command line option, define
@@ -726,7 +729,7 @@ static void ATT_NORETURN NotSupported(const char * restrict type,const char * re
 
 //============================================================
 
-INLINE void ScanStrError(const char * restrict str,const unsigned int size,char * restrict dest)
+INLINE const char *ScanStrError(const char * restrict str,const unsigned int size)
 /* check if string fits in buffer of size 'size', otherwise produces error message
  * then content of str is copied into dest
  */
@@ -734,7 +737,7 @@ INLINE void ScanStrError(const char * restrict str,const unsigned int size,char
 	if (strlen(str)>=size)
 		PrintErrorHelp("Too long argument to '-%s' option (only %ud chars allowed). If you really "
 			"need it you may increase MAX_DIRNAME in const.h and recompile",OptionName(),size-1);
-	strcpy(dest,str);
+	return str;
 }
 
 //============================================================
@@ -767,8 +770,8 @@ INLINE void ScanIntError(const char * restrict str,int *res)
 
 //============================================================
 
-INLINE bool ScanFnamesError(const int Narg,const int need,char **argv,char * restrict fname1,
-	char * restrict fname2)
+INLINE bool ScanFnamesError(const int Narg,const int need,char **argv,const char **fname1,
+	const char **fname2)
 /* If 'need' corresponds to one of FNAME_ARG, scan Narg<=2 filenames from argv into fname1 and
  * fname2. All consistency checks are left to the caller (in particular, whether Narg corresponds
  * to need). argv should be shifted to contain only filenames. fname2 can be NULL, but it will
@@ -780,11 +783,11 @@ INLINE bool ScanFnamesError(const int Narg,const int need,char **argv,char * res
 	bool res=false;
 
 	if (IS_FNAME_ARG(need)) {
-		ScanStrError(argv[0],MAX_FNAME,fname1);
+		*fname1=ScanStrError(argv[0],MAX_FNAME);
 		if (Narg==2) {
 			if (fname2==NULL) // consistency check e.g. for reading shape filename
 				PrintError("Failed to store the second filename in function ScanFnamesError");
-			else ScanStrError(argv[1],MAX_FNAME,fname2);
+			else *fname2=ScanStrError(argv[1],MAX_FNAME);
 		}
 		res=true;
 	}
@@ -859,7 +862,7 @@ static void PrintTime(char * restrict s,const time_t *time_ptr)
 
 PARSE_FUNC(alldir_inp)
 {
-	ScanStrError(argv[1],MAX_FNAME,alldir_parms);
+	alldir_parms=ScanStrError(argv[1],MAX_FNAME);
 }
 PARSE_FUNC(anisotr)
 {
@@ -899,7 +902,7 @@ PARSE_FUNC(beam)
 		 * NargError function similarly as done in existing tests.
 		 */
 		// either parse filename or parse all parameters as float; consistency is checked later
-		if (!ScanFnamesError(Narg,need,argv+2,beam_fnameY,beam_fnameX))
+		if (!ScanFnamesError(Narg,need,argv+2,&beam_fnameY,&beam_fnameX))
 			for (j=0;j<Narg;j++) ScanDoubleError(argv[j+2],beam_pars+j);
 		// stop search
 		found=true;
@@ -909,7 +912,7 @@ PARSE_FUNC(beam)
 }
 PARSE_FUNC(chp_dir)
 {
-	ScanStrError(argv[1],MAX_DIRNAME,chp_dir);
+	chp_dir=ScanStrError(argv[1],MAX_DIRNAME);
 }
 PARSE_FUNC(chp_load)
 {
@@ -941,7 +944,7 @@ PARSE_FUNC(Csca)
 }
 PARSE_FUNC(dir)
 {
-	ScanStrError(argv[1],MAX_DIRNAME,directory);
+	directory=ScanStrError(argv[1],MAX_DIRNAME);
 }
 PARSE_FUNC(dpl)
 {
@@ -1152,7 +1155,7 @@ PARSE_FUNC(orient)
 		if (Narg>2) PrintErrorHelp(
 			"Illegal number of arguments (%d) to '-orient avg' option (0 or 1 expected)",Narg-1);
 		orient_avg=true;
-		if (Narg==2) ScanStrError(argv[2],MAX_FNAME,avg_parms);
+		if (Narg==2) avg_parms=ScanStrError(argv[2],MAX_FNAME);
 	}
 	else {
 		if (Narg!=3) NargError(Narg,"3");
@@ -1192,7 +1195,7 @@ PARSE_FUNC(pol)
 PARSE_FUNC(prognosis)
 {
 	prognosis=true;
-	strcpy(run_name,"test");
+	run_name="test";
 }
 PARSE_FUNC(prop)
 {
@@ -1216,7 +1219,7 @@ PARSE_FUNC(save_geom)
 {
 	if (Narg>1) NargError(Narg,"0 or 1");
 	save_geom=true;
-	if (Narg==1) ScanStrError(argv[1],MAX_FNAME,save_geom_fname);
+	if (Narg==1) save_geom_fname=ScanStrError(argv[1],MAX_FNAME);
 }
 PARSE_FUNC(scat)
 {
@@ -1228,7 +1231,7 @@ PARSE_FUNC(scat)
 }
 PARSE_FUNC(scat_grid_inp)
 {
-	ScanStrError(argv[1],MAX_FNAME,scat_grid_parms);
+	scat_grid_parms=ScanStrError(argv[1],MAX_FNAME);
 }
 PARSE_FUNC(scat_matr)
 {
@@ -1290,7 +1293,7 @@ PARSE_FUNC(shape)
 		 * NargError function similarly as done in existing tests.
 		 */
 		// either parse filename or parse all parameters as float; consistency is checked later
-		if (!ScanFnamesError(Narg,need,argv+2,shape_fname,NULL))
+		if (!ScanFnamesError(Narg,need,argv+2,&shape_fname,NULL))
 			for (j=0;j<Narg;j++) ScanDoubleError(argv[j+2],sh_pars+j);
 		// stop search
 		found=true;
@@ -1298,7 +1301,7 @@ PARSE_FUNC(shape)
 	}
 	if (!found) NotSupported("Shape type",argv[1]);
 	// set shape name; takes place only if shape name was matched above
-	strcpy(shapename,argv[1]);
+	shapename=argv[1];
 }
 PARSE_FUNC(size)
 {
@@ -1338,7 +1341,7 @@ PARSE_FUNC(sym)
 }
 PARSE_FUNC(test)
 {
-	strcpy(run_name,"test");
+	run_name="test";
 }
 PARSE_FUNC(V)
 {
@@ -1591,7 +1594,7 @@ void InitVariables(void)
 	prop_0[0]=0; // by default beam propagates along z-axis
 	prop_0[1]=0;
 	prop_0[2]=1;
-	directory[0]=0;
+	directory="";
 	lambda=TWO_PI;
 	// initialize ref_index of scatterer
 	Nmat=Nmat_given=1;
@@ -1604,11 +1607,11 @@ void InitVariables(void)
 	sizeX=UNDEF;
 	a_eq=UNDEF;
 	dpl=UNDEF;
-	strcpy(run_name,"run");
+	run_name="run";
 	nTheta=UNDEF;
 	iter_eps=1E-5;
 	shape=SH_SPHERE;
-	strcpy(shapename,"sphere");
+	shapename="sphere";
 	store_int_field=false;
 	store_dip_pol=false;
 	PolRelation=POL_LDR;
@@ -1621,10 +1624,10 @@ void InitVariables(void)
 	maxiter=UNDEF;
 	jagged=1;
 	beamtype=B_PLANE;
-	strcpy(alldir_parms,FD_ALLDIR_PARMS);
-	strcpy(avg_parms,FD_AVG_PARMS);
-	strcpy(scat_grid_parms,FD_SCAT_PARMS);
-	strcpy(chp_dir,FD_CHP_DIR);
+	alldir_parms=FD_ALLDIR_PARMS;
+	avg_parms=FD_AVG_PARMS;
+	scat_grid_parms=FD_SCAT_PARMS;
+	chp_dir=FD_CHP_DIR;
 	chp_time=UNDEF;
 	chp_type=CHP_NONE;
 	orient_avg=false;
@@ -1632,7 +1635,7 @@ void InitVariables(void)
 	volcor=true;
 	reduced_FFT=true;
 	save_geom=false;
-	save_geom_fname[0]=0;
+	save_geom_fname="";
 	yzplane=false;
 	all_dir=false;
 	scat_grid=false;
@@ -1850,15 +1853,10 @@ void DirectoryLog(const int argc,char **argv)
 {
 	int i,Nexp;
 	FILE * restrict Nexpfile;
-	char sbuffer[MAX_LINE];
-	char *ptmp,*compname;
+	char *compname;
 	FILEHANDLE lockid;
 #ifdef PARALLEL
-	char *ptmp2;
-#endif
-#ifdef WINDOWS // for obtaining computer name
-	TCHAR cname[MAX_COMPUTERNAME_LENGTH+1];
-	DWORD cname_size=MAX_COMPUTERNAME_LENGTH+1;
+	char *ptmp,*ptmp2;
 #endif
 
 	// devise directory name (for output files)
@@ -1882,20 +1880,24 @@ void DirectoryLog(const int argc,char **argv)
 		}
 		// cast Nexp to all processors
 		MyBcast(&Nexp,int_type,1,NULL);
-		// create directory name
-		sprintf(sbuffer,"m"GFORM_RI_DIRNAME,ref_index[0][RE]);
-		ptmp=strchr(sbuffer,'.');
-		if (ptmp!=NULL) *ptmp='_';
-		sprintf(directory,"%s%03i_%s_g%i%s",run_name,Nexp,shapename,boxX,sbuffer);
+		/* create automatic directory name
+		 * It is stored in the following buffer. MAX_LINE should be enough for auto-name, however
+		 * up to MAX_DIRNAME can be obtained from '-dir ...'. So the latter size is considered in
+		 * all relevant buffers (for filenames or messages).
+		 */
+		static char sbuffer[MAX_LINE];
+		sprintf(sbuffer,"%s%03i_%s_g%i_m"GFORM_RI_DIRNAME,run_name,Nexp,shapename,boxX,
+			ref_index[0][RE]);
 #ifdef PARALLEL
 		// add PBS, SGE or SLURM job id to the directory name if available
 		if ((ptmp=getenv("PBS_JOBID"))!=NULL || (ptmp=getenv("JOB_ID"))!=NULL
 			|| (ptmp=getenv("SLURM_JOBID"))!=NULL) {
 				// job ID is truncated at first ".", probably can happen only for PBS
 				if ((ptmp2=strchr(ptmp,'.'))!=NULL) *ptmp2=0;
-				sprintf(directory+strlen(directory),"id%s",ptmp);
+				sprintf(sbuffer+strlen(sbuffer),"_id%s",ptmp);
 		}
 #endif
+		directory=sbuffer;
 	}
 	// make new directory and print info
 	if (IFROOT) {
@@ -1913,6 +1915,8 @@ void DirectoryLog(const int argc,char **argv)
 		fprintf(logfile,"Generated by ADDA v."ADDA_VERSION"\n");
 		// get computer name
 #ifdef WINDOWS
+		TCHAR cname[MAX_COMPUTERNAME_LENGTH+1];
+		DWORD cname_size=MAX_COMPUTERNAME_LENGTH+1;
 		GetComputerName(cname,&cname_size);
 		compname=cname;
 #else // POSIX and others
@@ -1949,6 +1953,7 @@ void PrintInfo(void)
 
 	if (IFROOT) {
 		// print basic parameters
+		printf("box dimensions: %ix%ix%i\n",boxX,boxY,boxZ);
 		printf("lambda: "GFORM"   Dipoles/lambda: "GFORMDEF"\n",lambda,dpl);
 		printf("Required relative residual norm: "GFORMDEF"\n",iter_eps);
 		printf("Total number of occupied dipoles: %zu\n",nvoid_Ndip);
diff --git a/src/vars.c b/src/vars.c
index 0457fbad..dda89222 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -78,9 +78,9 @@ double box_origin_unif[3];    /* coordinates of the center of the first dipole i
                                */
 
 // file info
-char directory[MAX_DIRNAME]; // directory to save data in
-FILE *  restrict logfile;    // file where all the information about the run is saved
-int term_width;              // width of the terminal to which ADDA produces output
+const char * restrict directory; // directory to save data in
+FILE *  restrict logfile;        // file where all the information about the run is saved
+int term_width;                  // width of the terminal to which ADDA produces output
 
 // refractive index
 int Nmat;                           /* number of different domains (for each either scalar or
@@ -116,9 +116,7 @@ doublecomplex * restrict EgridX,* restrict EgridY;
 double * restrict Egrid_buffer;    // buffer to accumulate Egrid
 
 // checkpoint
-enum chpoint chp_type;             // type of checkpoint (to save)
-time_t chp_time;           // time of checkpoint (in sec)
-char chp_dir[MAX_DIRNAME]; // directory name to save/load checkpoint
+enum chpoint chp_type; // type of checkpoint (to save)
 
 // auxiliary grids and their partition over processors
 size_t gridX,gridY,gridZ;          /* sizes of the 'matrix' X, size_t - to remove type conversions
diff --git a/src/vars.h b/src/vars.h
index 36948642..0b7a19da 100644
--- a/src/vars.h
+++ b/src/vars.h
@@ -51,7 +51,7 @@ extern bool prognosis,yzplane,all_dir,scat_grid,phi_integr,sh_granul,reduced_FFT
 extern double prop[3],incPolX[3],incPolY[3],beam_center[3],box_origin_unif[3];
 
 // file info
-extern char directory[];
+extern const char * restrict directory;
 extern FILE * restrict logfile;
 extern int term_width;
 
@@ -77,8 +77,6 @@ extern double *Egrid_buffer;
 
 // checkpoint
 extern enum chpoint chp_type;
-extern time_t chp_time;
-extern char chp_dir[];
 
 // auxiliary grids and their partition over processors
 extern size_t gridX,gridY,gridZ;