@@ -85,8 +85,21 @@ extern "C" void generatecavity_cpp(int * maxts, int * maxsph, int * maxvert,
8585 double * xe, double * ye, double * ze, double * rin, double * masses,
8686 double * avgArea, double * rsolv, double * ret,
8787 int * nr_gen, int * gen1, int * gen2, int * gen3,
88- int * nvert, double * vert, double * centr, const char * pedra, const char * off);
88+ int * nvert, double * vert, double * centr, char * pedra, char * off);
8989
90+ void convertToFortran (char * fstring, size_t fstring_len, const char * cstring)
91+ {
92+ size_t inlen = std::strlen (cstring);
93+ size_t cpylen = std::min (inlen, fstring_len);
94+
95+ if (inlen > fstring_len)
96+ {
97+ // TODO: truncation error or warning
98+ }
99+
100+ std::copy (cstring, cstring + cpylen, fstring);
101+ std::fill (fstring + cpylen, fstring + fstring_len, ' ' );
102+ }
90103
91104void GePolCavity::build (const std::string & suffix, int maxts, int maxsph, int maxvert)
92105{
@@ -169,8 +182,12 @@ void GePolCavity::build(const std::string & suffix, int maxts, int maxsph, int m
169182
170183 std::stringstream pedra;
171184 pedra << " PEDRA.OUT_" << suffix << " _" << ::getpid ();
185+ char f_pedra[std::strlen (pedra.str ().c_str ()) -1 ];
186+ convertToFortran (f_pedra, std::strlen (pedra.str ().c_str ()) -1 , pedra.str ().c_str ());
172187 std::stringstream off;
173188 off << " cavity.off_" << suffix << " _" << ::getpid ();
189+ char f_off[std::strlen (off.str ().c_str ()) -1 ];
190+ convertToFortran (f_off, std::strlen (off.str ().c_str ()) -1 , off.str ().c_str ());
174191 // Go PEDRA, Go!
175192 TIMER_ON (" GePolCavity::generatecavity_cpp" );
176193 generatecavity_cpp (&maxts, &maxsph, &maxvert,
@@ -179,7 +196,7 @@ void GePolCavity::build(const std::string & suffix, int maxts, int maxsph, int m
179196 xe, ye, ze, rin, mass,
180197 &averageArea, &probeRadius, &minimalRadius,
181198 &nr_gen, &gen1, &gen2, &gen3,
182- nvert, vert, centr, pedra. str (). c_str (), off. str (). c_str () );
199+ nvert, vert, centr, f_pedra, f_off );
183200 TIMER_OFF (" GePolCavity::generatecavity_cpp" );
184201
185202 // The "intensive" part of updating the spheres related class data members will be of course
0 commit comments