void sim_md(struct state *state) { msg("MOLECULAR DYNAMICS JOB\n\n\n"); struct md *md = md_create(state); if (cfg_get_bool(state->cfg, "velocitize")) velocitize(md); remove_system_drift(md); compute_forces(md); msg(" INITIAL STATE\n\n"); print_status(md); for (int i = 1; i <= cfg_get_int(state->cfg, "max_steps"); i++) { md->update_step(md); if (i % cfg_get_int(state->cfg, "print_step") == 0) { msg(" STATE AFTER %d STEPS\n\n", i); print_status(md); } } md_shutdown(md); msg("MOLECULAR DYNAMICS JOB COMPLETED SUCCESSFULLY\n"); }
// signal handler for SIGINT, SIGTERM void die_handler(int param) { if( g_running ) { g_running = false; sem_post( &reload_sem ); if( g_conf->md_pidfile_path ) unlink( g_conf->md_pidfile_path ); if( g_conf->md_logfile ) fclose( g_conf->md_logfile ); google::protobuf::ShutdownProtobufLibrary(); http_shutdown( &http ); validator_shutdown(); md_shutdown(); if( g_config_file ) free( g_config_file ); if( g_secrets_file ) free( g_secrets_file ); exit(0); } }
// tear down RG // return 0 on success // return -errno on failure int RG_shutdown( struct RG_core* rg ) { int rc = 0; if( rg->running ) { // ask the SG to die SG_gateway_signal_main( rg->gateway ); pthread_join( rg->thread, NULL ); rg->running = false; } // shut down the core gateway rc = SG_gateway_shutdown( rg->gateway ); if( rc != 0 ) { SG_error("SG_gateway_shutdown rc = %d\n", rc ); } SG_safe_free( rg->gateway ); pthread_rwlock_destroy( &rg->lock ); md_shutdown(); memset( rg, 0, sizeof(struct RG_core) ); return 0; }