Loading .gitignore +1 −0 Original line number Diff line number Diff line build/include build/cluster/* build/sphere/* build/trapping/* Loading src/sphere/List.h→src/include/List.h +0 −0 File moved. View file src/include/file_io.h 0 → 100644 +6 −0 Original line number Diff line number Diff line extern "C" void open_file_(int*, const char*, const char*, const char*); extern "C" void close_file_(int*); extern "C" void read_int_(int*, int*); extern "C" void write_complex_(int*, double*, double*); extern "C" void write_double_(int*, double*); extern "C" void write_int_(int*, int*); src/sphere/edfb.cpp +19 −16 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ #include <cstring> #include <iostream> #include <fstream> #include "List.h" #include "../include/file_io.h" #include "../include/List.h" using namespace std; Loading Loading @@ -391,24 +392,27 @@ int main(int argc, char **argv) { // The FORTRAN code writes an auxiliary file in binary format. This should // be avoided or possibly replaced with the use of standard file formats for // scientific use (e.g. FITS). ofstream tedf_file; tedf_file.open("c_TEDF", ofstream::binary); tedf_file.write(reinterpret_cast<char *>(&nsph), sizeof(nsph)); int uid = 27; string bin_file_name = "c_TEDF"; string status = "UNKNOWN"; string mode = "UNFORMATTED"; open_file_(&uid, bin_file_name.c_str(), status.c_str(), mode.c_str()); write_int_(&uid, &nsph); for (int iogi = 0; iogi < nsph; iogi++) tedf_file.write(reinterpret_cast<char *>(iog + iogi), sizeof(iog[iogi])); tedf_file.write(reinterpret_cast<char *>(&exdc), sizeof(exdc)); tedf_file.write(reinterpret_cast<char *>(&wp), sizeof(wp)); tedf_file.write(reinterpret_cast<char *>(&xip), sizeof(xip)); tedf_file.write(reinterpret_cast<char *>(&idfc), sizeof(idfc)); tedf_file.write(reinterpret_cast<char *>(&nxi), sizeof(nxi)); write_int_(&uid, (iog + iogi)); write_double_(&uid, &exdc); write_double_(&uid, &wp); write_double_(&uid, &xip); write_int_(&uid, &idfc); write_int_(&uid, &nxi); for (int i115 = 1; i115 <= nsph; i115++) { if (iog[i115 - 1] < i115) continue; tedf_file.write(reinterpret_cast<char *>(nshl + i115 - 1), sizeof(nshl[i115 - 1])); tedf_file.write(reinterpret_cast<char *>(ros + i115 - 1), sizeof(ros[i115 - 1])); write_int_(&uid, (nshl + i115 -1)); write_double_(&uid, (ros + i115 - 1)); nsh = nshl[i115 - 1]; if (i115 == 1) nsh += ies; for (int ins = 0; ins < nsh; ins++) tedf_file.write(reinterpret_cast<char *>(rcf[i115 - 1] + ins), sizeof(rcf[i115 - 1][ins])); write_double_(&uid, (rcf[i115 - 1] + ins)); } // Remake the dc0m matrix. dc0m = new complex<double>**[max_nsh]; Loading @@ -435,12 +439,11 @@ int main(int argc, char **argv) { // The FORTRAN code writes the complex numbers as a 16-byte long binary stream. // Here we assume that the 16 bytes are equally split in 8 bytes to represent the // real part and 8 bytes to represent the imaginary one. tedf_file.write(reinterpret_cast<char *>(&dc0_real), sizeof(dc0_real)); tedf_file.write(reinterpret_cast<char *>(&dc0_img), sizeof(dc0_img)); write_complex_(&uid, &dc0_real, &dc0_img); } } } tedf_file.close(); close_file_(&uid); if (idfc != 0) { fprintf(output, " DIELECTRIC CONSTANTS\n"); for (int i473 = 1; i473 <= nsph; i473++) { Loading Loading
.gitignore +1 −0 Original line number Diff line number Diff line build/include build/cluster/* build/sphere/* build/trapping/* Loading
src/include/file_io.h 0 → 100644 +6 −0 Original line number Diff line number Diff line extern "C" void open_file_(int*, const char*, const char*, const char*); extern "C" void close_file_(int*); extern "C" void read_int_(int*, int*); extern "C" void write_complex_(int*, double*, double*); extern "C" void write_double_(int*, double*); extern "C" void write_int_(int*, int*);
src/sphere/edfb.cpp +19 −16 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ #include <cstring> #include <iostream> #include <fstream> #include "List.h" #include "../include/file_io.h" #include "../include/List.h" using namespace std; Loading Loading @@ -391,24 +392,27 @@ int main(int argc, char **argv) { // The FORTRAN code writes an auxiliary file in binary format. This should // be avoided or possibly replaced with the use of standard file formats for // scientific use (e.g. FITS). ofstream tedf_file; tedf_file.open("c_TEDF", ofstream::binary); tedf_file.write(reinterpret_cast<char *>(&nsph), sizeof(nsph)); int uid = 27; string bin_file_name = "c_TEDF"; string status = "UNKNOWN"; string mode = "UNFORMATTED"; open_file_(&uid, bin_file_name.c_str(), status.c_str(), mode.c_str()); write_int_(&uid, &nsph); for (int iogi = 0; iogi < nsph; iogi++) tedf_file.write(reinterpret_cast<char *>(iog + iogi), sizeof(iog[iogi])); tedf_file.write(reinterpret_cast<char *>(&exdc), sizeof(exdc)); tedf_file.write(reinterpret_cast<char *>(&wp), sizeof(wp)); tedf_file.write(reinterpret_cast<char *>(&xip), sizeof(xip)); tedf_file.write(reinterpret_cast<char *>(&idfc), sizeof(idfc)); tedf_file.write(reinterpret_cast<char *>(&nxi), sizeof(nxi)); write_int_(&uid, (iog + iogi)); write_double_(&uid, &exdc); write_double_(&uid, &wp); write_double_(&uid, &xip); write_int_(&uid, &idfc); write_int_(&uid, &nxi); for (int i115 = 1; i115 <= nsph; i115++) { if (iog[i115 - 1] < i115) continue; tedf_file.write(reinterpret_cast<char *>(nshl + i115 - 1), sizeof(nshl[i115 - 1])); tedf_file.write(reinterpret_cast<char *>(ros + i115 - 1), sizeof(ros[i115 - 1])); write_int_(&uid, (nshl + i115 -1)); write_double_(&uid, (ros + i115 - 1)); nsh = nshl[i115 - 1]; if (i115 == 1) nsh += ies; for (int ins = 0; ins < nsh; ins++) tedf_file.write(reinterpret_cast<char *>(rcf[i115 - 1] + ins), sizeof(rcf[i115 - 1][ins])); write_double_(&uid, (rcf[i115 - 1] + ins)); } // Remake the dc0m matrix. dc0m = new complex<double>**[max_nsh]; Loading @@ -435,12 +439,11 @@ int main(int argc, char **argv) { // The FORTRAN code writes the complex numbers as a 16-byte long binary stream. // Here we assume that the 16 bytes are equally split in 8 bytes to represent the // real part and 8 bytes to represent the imaginary one. tedf_file.write(reinterpret_cast<char *>(&dc0_real), sizeof(dc0_real)); tedf_file.write(reinterpret_cast<char *>(&dc0_img), sizeof(dc0_img)); write_complex_(&uid, &dc0_real, &dc0_img); } } } tedf_file.close(); close_file_(&uid); if (idfc != 0) { fprintf(output, " DIELECTRIC CONSTANTS\n"); for (int i473 = 1; i473 <= nsph; i473++) { Loading