Environment
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)
This article is related to ADDA (light scattering simulator based on the discrete dipole approximation).
The iterative.c
was modified to save an auxiliary file and a coordinate file, named as followings under chpoint/
:
- aux.0
- coord.0
$ git diff 4829ebe HEAD iterative.c > log_170409
log_170409
diff --git a/iterative.c b/iterative.c
index f12ce4f..7702370 100644
--- a/iterative.c
+++ b/iterative.c
@@ -1,3 +1,14 @@
+/*
+v0.4 Apr. 09, 2017 by okada
+ save [local_nvoid_Ndip] with DipoleCoord[]
+ fix bug > DipoleCoord[] was saved in [int] not in [double]
+v0.3 Apr. 03, 2017 by okada
+ modified to output DipoleCoord[]
+v0.2 Dec. 03, 2016 by okada
+ modified to output auxiliary information such as params[ind_m].sc_N
+*/
+
+
/* File: iterative.c
* $Date:: $
* Descr: a few iterative techniques to solve DDA equations
@@ -179,6 +190,20 @@ static inline void SwapPointers(doublecomplex **a,doublecomplex **b)
* to describe its state, this information should be specified in structure arrays 'scalars' and 'vectors'.
*/
+#define OUTPUT_AUX_FILE // to output auxiliary values (Dec. 03, 2016 by okada)
+#ifdef OUTPUT_AUX_FILE
+const bool output_auxfile = true;
+#else
+const bool output_auxfile = false;
+#endif
+
+#define OUTPUT_COORD_FILE // to output DipoleCoord[] (Apr. 03, 2017 by okada)
+#ifdef OUTPUT_COORD_FILE
+const bool output_coordfile = true;
+#else
+const bool output_coordfile = false;
+#endif
+
static void SaveIterChpoint(void)
/* save a binary checkpoint; only limitedly foolproof - user should take care to load checkpoints on the same machine
* (number of processors) and with the same command line.
@@ -189,6 +214,13 @@ static void SaveIterChpoint(void)
FILE * restrict chp_file;
TIME_TYPE tstart;
+ // to store auxiliary values required to read Chpoint file by tools (okada)
+ FILE * restrict aux_file;
+ char fauxName[MAX_FNAME];
+ // to store Coord values (okada)
+ FILE * restrict coord_file;
+ char fcoordName[MAX_FNAME];
+
tstart=GET_TIME();
if (IFROOT) {
// create directory "chp_dir" if needed and open info file
@@ -206,6 +238,16 @@ static void SaveIterChpoint(void)
// open output file; writing errors are checked only for vectors
SnprintfErr(ALL_POS,fname,MAX_FNAME,"%s/"F_CHP,chp_dir,ringid);
chp_file=FOpenErr(fname,"wb",ALL_POS);
+ if (output_auxfile) {
+ SnprintfErr(ALL_POS,fauxName,MAX_FNAME,"%s/aux.0",chp_dir);
+ fprintf(stdout, "\r\n[DEBUG] Line220>SaveIterChpoint: %s\r\n", fauxName);
+ aux_file=FOpenErr(fauxName,"wb",ALL_POS);
+ }
+ if (output_coordfile) {
+ SnprintfErr(ALL_POS,fcoordName,MAX_FNAME,"%s/coord.0",chp_dir);
+ fprintf(stdout, "\r\n[DEBUG] Line245>SaveIterChpoint: %s\r\n", fcoordName);
+ coord_file=FOpenErr(fcoordName,"wb",ALL_POS);
+ }
// write common scalars
fwrite(&ind_m,sizeof(int),1,chp_file);
fwrite(&local_nRows,sizeof(size_t),1,chp_file);
@@ -226,8 +268,40 @@ static void SaveIterChpoint(void)
// write specific vectors
for (i=0;i<params[ind_m].vec_N;i++) if (fwrite(vectors[i].ptr,vectors[i].size,local_nRows,chp_file)!=local_nRows)
LogError(ALL_POS,"Failed writing to file '%s'",fname);
+
+ if (output_auxfile) {
+ fwrite(&(params[ind_m].sc_N), sizeof(int), 1, aux_file);
+ for (i=0;i<params[ind_m].sc_N;i++) {
+ fwrite(&(scalars[i].size), sizeof(int), 1, aux_file);
+ }
+ fwrite(&(params[ind_m].vec_N), sizeof(int), 1, aux_file);
+ for (i=0;i<params[ind_m].vec_N;i++) {
+ fwrite(&(vectors[i].size), sizeof(int), 1, aux_file);
+ }
+ fprintf(stdout, "[DEBUG] Line254>SaveIterChpoint: sc_N=%d\r\n", params[ind_m].sc_N);
+ for (i=0;i<params[ind_m].sc_N;i++) {
+ fprintf(stdout, "[DEBUG] Line256>SaveIterChpoint: scalars.size=%d\r\n", scalars[i].size);
+ }
+ fprintf(stdout, "[DEBUG] Line258>SaveIterChpoint: vec_N=%d\r\n", params[ind_m].vec_N);
+ for (i=0;i<params[ind_m].vec_N;i++) {
+ fprintf(stdout, "[DEBUG] Line260>SaveIterChpoint: vectors.size=%d\r\n", vectors[i].size);
+ }
+ }
+ if (output_coordfile) {
+ fprintf(stdout, "[DEBUG] Line289: local_nvoid_Ndip:%d\r\n", local_nvoid_Ndip);
+ fwrite(&local_nvoid_Ndip, sizeof(int), 1, coord_file);
+ fwrite(DipoleCoord, sizeof(double), local_nvoid_Ndip * 3L, coord_file);
+ }
+
// close file
FCloseErr(chp_file,fname,ALL_POS);
+ if (output_auxfile) {
+ FCloseErr(aux_file,fauxName,ALL_POS);
+ }
+ if (output_coordfile) {
+ FCloseErr(coord_file,fcoordName,ALL_POS);
+ }
+
// write info to logfile after everyone is finished
Synchronize();
if (IFROOT) PrintBoth(logfile,"Checkpoint (iteration) saved\n");