static void call_error_handler(const char *key, const char *file, int line, const char *msg) { if (msg == NULL) { msg = "Empty gmx_fatal message (bug)."; } tMPI_Thread_mutex_lock(&error_mutex); gmx_error_handler(gmx_strerror(key), msg, file, line); tMPI_Thread_mutex_unlock(&error_mutex); }
void _gmx_error(const char *key,const char *msg,const char *file,int line) { char buf[10240],tmpbuf[1024]; int cqnum; /* protect the audience from suggestive discussions */ char *lines = "-------------------------------------------------------"; cool_quote(tmpbuf,1023,&cqnum); sprintf(buf,"\n%s\nProgram %s, %s\n" "Source code file: %s, line: %d\n\n" "%s:\n%s\n%s\n\n%s\n", lines,ShortProgram(),GromacsVersion(),file,line, gmx_strerror(key),msg ? msg : warn_buf,lines,tmpbuf); gmx_error_handler(buf); }
void _gmx_error(const char *key,const char *msg,const char *file,int line) { char buf[10240],tmpbuf[1024]; int cqnum; /* protect the audience from suggestive discussions */ const char *lines = "-------------------------------------------------------"; cool_quote(tmpbuf,1023,&cqnum); sprintf(buf,"\n%s\nProgram %s, %s\n" "Source code file: %s, line: %d\n\n" "%s:\n%s\nFor more information and tips for trouble shooting please check the GROMACS Wiki at\n" "http://wiki.gromacs.org/index.php/Errors\n%s\n\n%s\n", lines,ShortProgram(),GromacsVersion(),file,line, gmx_strerror(key),msg ? msg : warn_buf,lines,tmpbuf); gmx_error_handler(buf); }
void gmx_tng_open(const char *filename, char mode, tng_trajectory_t *tng) { #ifdef GMX_USE_TNG /* First check whether we have to make a backup, * only for writing, not for read or append. */ if (mode == 'w') { #ifndef GMX_FAHCORE /* only make backups for normal gromacs */ make_backup(filename); #endif } /* tng must not be pointing at already allocated memory. * Memory will be allocated by tng_util_trajectory_open() and must * later on be freed by tng_util_trajectory_close(). */ if (TNG_SUCCESS != tng_util_trajectory_open(filename, mode, tng)) { /* TNG does return more than one degree of error, but there is no use case for GROMACS handling the non-fatal errors gracefully. */ gmx_fatal(FARGS, "%s while opening %s for %s", gmx_strerror("file"), filename, modeToVerb(mode)); } if (mode == 'w' || mode == 'a') { /* FIXME in TNG: When adding data to the header, subsequent blocks might get * overwritten. This could be solved by moving the first trajectory * frame set(s) to the end of the file. Could that cause other problems, * e.g. when continuing a simulation? */ char hostname[256]; gmx_gethostname(hostname, 256); if (mode == 'w') { tng_first_computer_name_set(*tng, hostname); } /* TODO: This should be implemented when the above fixme is done (adding data to * the header). */ // else // { // tng_last_computer_name_set(*tng, hostname); // } char programInfo[256]; const char *precisionString = ""; #ifdef GMX_DOUBLE precisionString = " (double precision)"; #endif sprintf(programInfo, "%.100s, %.128s%.24s", gmx::getProgramContext().displayName(), GromacsVersion(), precisionString); if (mode == 'w') { tng_first_program_name_set(*tng, programInfo); } /* TODO: This should be implemented when the above fixme is done (adding data to * the header). */ // else // { // tng_last_program_name_set(*tng, programInfo); // } #ifdef HAVE_UNISTD_H char username[256]; getlogin_r(username, 256); if (mode == 'w') { tng_first_user_name_set(*tng, username); } /* TODO: This should be implemented when the above fixme is done (adding data to * the header). */ // else // { // tng_last_user_name_set(*tng, username); // } #endif } #else gmx_file("GROMACS was compiled without TNG support, cannot handle this file type"); GMX_UNUSED_VALUE(filename); GMX_UNUSED_VALUE(mode); GMX_UNUSED_VALUE(tng); #endif }