static int set_report(unsigned char* data, int len) { unsigned char *type = data; int val; val = 0x300 | *type; return (usb_control_msg(get_ir(), USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 9, val, 0, (char*) data, len, 1000) != len); }
static void reattach(void) { usb_dev_handle *ir; ir = get_ir(); if (ir) { usb_release_interface(ir, 0); /* attach fails if we still have the file descriptor open */ usb_close(ir); usb_attach_kernel_driver_np(ir, 0, "usbhid"); } }
int main(int argc, char **argv) { struct ir_command command; struct ir_command timeoutCommand; int c; int led_brightness = 1; while ((c = getopt (argc, argv, "mBi:b:s:H:hd")) != -1) switch (c) { case 'm': multi_mode = 1; break; case 'i': idle_mode = atol(optarg); break; case 'b': button_mode = atol(optarg); break; case 's': special_mode = atol(optarg); break; case 'H': hold_mode = atol(optarg); break; case 'd': debug = 1; break; case 'h': usage(argc,argv); exit(0); break; case 'B': led_brightness = 0; break; case '?': switch(optopt) { case 'i': case 'b': case 's': case 'H': fprintf (stderr, "Option -%c requires an argument.\n", optopt); break; default: if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); } return 1; default: abort(); } set_led_brightness(led_brightness); memset(&timeoutCommand, 0, sizeof(timeoutCommand)); if(debug) printf("Creating socket...\n"); sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { printf("Error creating socket\n"); return -1; } if(debug) printf("Preparing button map...\n"); button_map[EVENT_UP] = new CPacketBUTTON(EVENT_UP, "JS0:AppleRemote", BTN_DOWN); button_map[EVENT_DOWN] = new CPacketBUTTON(EVENT_DOWN, "JS0:AppleRemote", BTN_DOWN); button_map[EVENT_LEFT] = new CPacketBUTTON(EVENT_LEFT, "JS0:AppleRemote", BTN_DOWN); button_map[EVENT_RIGHT] = new CPacketBUTTON(EVENT_RIGHT, "JS0:AppleRemote", BTN_DOWN); button_map[EVENT_PLAY] = new CPacketBUTTON(EVENT_PLAY, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_MENU] = new CPacketBUTTON(EVENT_MENU, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_HOLD_PLAY] = new CPacketBUTTON(EVENT_HOLD_PLAY, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_HOLD_MENU] = new CPacketBUTTON(EVENT_HOLD_MENU, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_UP | EVENT_RELEASE ] = new CPacketBUTTON(EVENT_UP, "JS0:AppleRemote", BTN_UP); button_map[EVENT_DOWN | EVENT_RELEASE ] = new CPacketBUTTON(EVENT_DOWN, "JS0:AppleRemote", BTN_UP); button_map[EVENT_LEFT | EVENT_RELEASE ] = new CPacketBUTTON(EVENT_LEFT, "JS0:AppleRemote", BTN_UP); button_map[EVENT_RIGHT | EVENT_RELEASE ] = new CPacketBUTTON(EVENT_RIGHT, "JS0:AppleRemote", BTN_UP); button_map[EVENT_EXTRA_PLAY] = new CPacketBUTTON(EVENT_EXTRA_PLAY, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_PAUSE] = new CPacketBUTTON(EVENT_EXTRA_PAUSE, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_STOP] = new CPacketBUTTON(EVENT_EXTRA_STOP, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_REPLAY] = new CPacketBUTTON(EVENT_EXTRA_REPLAY, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_SKIP] = new CPacketBUTTON(EVENT_EXTRA_SKIP, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_REWIND] = new CPacketBUTTON(EVENT_EXTRA_REWIND, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_FORWARD] = new CPacketBUTTON(EVENT_EXTRA_FORWARD, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_PAGEUP] = new CPacketBUTTON(EVENT_EXTRA_PAGEUP, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); button_map[EVENT_EXTRA_PAGEDOWN] = new CPacketBUTTON(EVENT_EXTRA_PAGEDOWN, "JS0:AppleRemote", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_UP] = new CPacketBUTTON(EVENT_HARMONY_UP, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_UP | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_UP, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_DOWN] = new CPacketBUTTON(EVENT_HARMONY_DOWN, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_DOWN | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_DOWN, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_LEFT] = new CPacketBUTTON(EVENT_HARMONY_LEFT, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_LEFT | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_LEFT, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_RIGHT] = new CPacketBUTTON(EVENT_HARMONY_RIGHT, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_RIGHT | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_RIGHT, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_OK] = new CPacketBUTTON(EVENT_HARMONY_OK, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_MENU] = new CPacketBUTTON(EVENT_HARMONY_MENU, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_HOLD_OK] = new CPacketBUTTON(EVENT_HARMONY_HOLD_OK, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_HOLD_MENU] = new CPacketBUTTON(EVENT_HARMONY_HOLD_MENU, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_PLAY] = new CPacketBUTTON(EVENT_HARMONY_PLAY, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_STOP] = new CPacketBUTTON(EVENT_HARMONY_STOP, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_PAUSE] = new CPacketBUTTON(EVENT_HARMONY_PAUSE, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_REPLAY] = new CPacketBUTTON(EVENT_HARMONY_REPLAY, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_SKIP] = new CPacketBUTTON(EVENT_HARMONY_SKIP, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_REWIND] = new CPacketBUTTON(EVENT_HARMONY_REWIND, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_REWIND | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_REWIND, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_FORWARD] = new CPacketBUTTON(EVENT_HARMONY_FORWARD, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_FORWARD | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_FORWARD, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_RECORD] = new CPacketBUTTON(EVENT_HARMONY_RECORD, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_PREV] = new CPacketBUTTON(EVENT_HARMONY_PREV, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_GUIDE] = new CPacketBUTTON(EVENT_HARMONY_GUIDE, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_INFO] = new CPacketBUTTON(EVENT_HARMONY_INFO, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_EXIT] = new CPacketBUTTON(EVENT_HARMONY_EXIT, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_VOLUP] = new CPacketBUTTON(EVENT_HARMONY_VOLUP, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_VOLUP | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_VOLUP, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_VOLDOWN] = new CPacketBUTTON(EVENT_HARMONY_VOLDOWN, "JS0:Harmony", BTN_DOWN); multi_map[EVENT_HARMONY_VOLDOWN | EVENT_RELEASE] = new CPacketBUTTON(EVENT_HARMONY_VOLDOWN, "JS0:Harmony", BTN_UP); multi_map[EVENT_HARMONY_1] = new CPacketBUTTON(EVENT_HARMONY_1, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_2] = new CPacketBUTTON(EVENT_HARMONY_2, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_3] = new CPacketBUTTON(EVENT_HARMONY_3, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_4] = new CPacketBUTTON(EVENT_HARMONY_4, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_5] = new CPacketBUTTON(EVENT_HARMONY_5, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_6] = new CPacketBUTTON(EVENT_HARMONY_6, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_7] = new CPacketBUTTON(EVENT_HARMONY_7, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_8] = new CPacketBUTTON(EVENT_HARMONY_8, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_9] = new CPacketBUTTON(EVENT_HARMONY_9, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_0] = new CPacketBUTTON(EVENT_HARMONY_0, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_CLEAR] = new CPacketBUTTON(EVENT_HARMONY_CLEAR, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_ENTER] = new CPacketBUTTON(EVENT_HARMONY_ENTER, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_MUTE] = new CPacketBUTTON(EVENT_HARMONY_MUTE, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_ASPECT] = new CPacketBUTTON(EVENT_HARMONY_ASPECT, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F1] = new CPacketBUTTON(EVENT_HARMONY_F1, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F2] = new CPacketBUTTON(EVENT_HARMONY_F2, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F3] = new CPacketBUTTON(EVENT_HARMONY_F3, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F4] = new CPacketBUTTON(EVENT_HARMONY_F4, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F5] = new CPacketBUTTON(EVENT_HARMONY_F5, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F6] = new CPacketBUTTON(EVENT_HARMONY_F6, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F7] = new CPacketBUTTON(EVENT_HARMONY_F7, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F8] = new CPacketBUTTON(EVENT_HARMONY_F8, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F9] = new CPacketBUTTON(EVENT_HARMONY_F9, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F10] = new CPacketBUTTON(EVENT_HARMONY_F10, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F11] = new CPacketBUTTON(EVENT_HARMONY_F11, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F12] = new CPacketBUTTON(EVENT_HARMONY_F12, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F13] = new CPacketBUTTON(EVENT_HARMONY_F13, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_F14] = new CPacketBUTTON(EVENT_HARMONY_F14, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_CHANUP] = new CPacketBUTTON(EVENT_HARMONY_CHANUP, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_CHANDOWN] = new CPacketBUTTON(EVENT_HARMONY_CHANDOWN, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_LRGDOWN] = new CPacketBUTTON(EVENT_HARMONY_LRGDOWN, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_LRGUP] = new CPacketBUTTON(EVENT_HARMONY_LRGUP, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_PWRTOGGLE] = new CPacketBUTTON(EVENT_HARMONY_PWRTOGGLE, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_QUEUE] = new CPacketBUTTON(EVENT_HARMONY_QUEUE, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_SLEEP] = new CPacketBUTTON(EVENT_HARMONY_SLEEP, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_RED] = new CPacketBUTTON(EVENT_HARMONY_RED, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_GREEN] = new CPacketBUTTON(EVENT_HARMONY_GREEN, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_YELLOW] = new CPacketBUTTON(EVENT_HARMONY_YELLOW, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); multi_map[EVENT_HARMONY_BLUE] = new CPacketBUTTON(EVENT_HARMONY_BLUE, "JS0:Harmony", BTN_DOWN | BTN_NO_REPEAT | BTN_QUEUE); pairedRemoteId = readPairedAddressId(); if(debug) printf("Paired to: %x\n", pairedRemoteId); if(debug) printf("Ready!\n"); set_led(LEDMODE_WHITE); int keydown = 0; set_led(idle_mode); while(1){ int result = usb_interrupt_read(get_ir(), 0x82, (char*) &command, sizeof(command), keydown ? BUTTON_TIMEOUT : 0); if(result > 0) { // we have an IR code! unsigned long start = millis(); if(debug) dumphex((unsigned char*) &command, result); if(command.flags == 0x26) { // set command.event = 0xee; } switch(command.event) { case 0xee: case 0xe5: if(pairedRemoteId == 0 || command.address == pairedRemoteId || (is_multi_candidate(command))) { set_led(button_mode); handle_button(command); } break; case 0xe0: set_led(special_mode); handle_special(command); break; default: if(debug) printf("Unknown event %x\n", command.event); } keydown = 1; } else if(result == -110) { // timeout, reset led keydown = 0; set_led(idle_mode); handle_button(timeoutCommand); handle_special(timeoutCommand); } else { // something else keydown = 0; if(debug) printf("Got nuffing: %d\n", result); } } reattach(); }
int main (int argc, char *argv[]) { static const char *desc[] = { "The gromacs preprocessor", "reads a molecular topology file, checks the validity of the", "file, expands the topology from a molecular description to an atomic", "description. The topology file contains information about", "molecule types and the number of molecules, the preprocessor", "copies each molecule as needed. ", "There is no limitation on the number of molecule types. ", "Bonds and bond-angles can be converted into constraints, separately", "for hydrogens and heavy atoms.", "Then a coordinate file is read and velocities can be generated", "from a Maxwellian distribution if requested.", "grompp also reads parameters for the mdrun ", "(eg. number of MD steps, time step, cut-off), and others such as", "NEMD parameters, which are corrected so that the net acceleration", "is zero.", "Eventually a binary file is produced that can serve as the sole input", "file for the MD program.[PAR]", "grompp uses the atom names from the topology file. The atom names", "in the coordinate file (option [TT]-c[tt]) are only read to generate", "warnings when they do not match the atom names in the topology.", "Note that the atom names are irrelevant for the simulation as", "only the atom types are used for generating interaction parameters.[PAR]", "grompp calls a preprocessor to resolve includes, macros ", "etcetera. By default we use the cpp in your path. To specify a " "different macro-preprocessor (e.g. m4) or alternative location", "you can put a line in your parameter file specifying the path", "to that program. Specifying [TT]-pp[tt] will get the pre-processed", "topology file written out.[PAR]", "If your system does not have a c-preprocessor, you can still", "use grompp, but you do not have access to the features ", "from the cpp. Command line options to the c-preprocessor can be given", "in the [TT].mdp[tt] file. See your local manual (man cpp).[PAR]", "When using position restraints a file with restraint coordinates", "can be supplied with [TT]-r[tt], otherwise restraining will be done", "with respect to the conformation from the [TT]-c[tt] option.", "For free energy calculation the the coordinates for the B topology", "can be supplied with [TT]-rb[tt], otherwise they will be equal to", "those of the A topology.[PAR]", "Starting coordinates can be read from trajectory with [TT]-t[tt].", "The last frame with coordinates and velocities will be read,", "unless the [TT]-time[tt] option is used.", "Note that these velocities will not be used when [TT]gen_vel = yes[tt]", "in your [TT].mdp[tt] file. An energy file can be supplied with", "[TT]-e[tt] to have exact restarts when using pressure and/or", "Nose-Hoover temperature coupling. For an exact restart do not forget", "to turn off velocity generation and turn on unconstrained starting", "when constraints are present in the system.", "If you want to continue a crashed run, it is", "easier to use [TT]tpbconv[tt].[PAR]", "Using the [TT]-morse[tt] option grompp can convert the harmonic bonds", "in your topology to morse potentials. This makes it possible to break", "bonds. For this option to work you need an extra file in your $GMXLIB", "with dissociation energy. Use the -debug option to get more information", "on the workings of this option (look for MORSE in the grompp.log file", "using less or something like that).[PAR]", "By default all bonded interactions which have constant energy due to", "virtual site constructions will be removed. If this constant energy is", "not zero, this will result in a shift in the total energy. All bonded", "interactions can be kept by turning off [TT]-rmvsbds[tt]. Additionally,", "all constraints for distances which will be constant anyway because", "of virtual site constructions will be removed. If any constraints remain", "which involve virtual sites, a fatal error will result.[PAR]" "To verify your run input file, please make notice of all warnings", "on the screen, and correct where necessary. Do also look at the contents", "of the [TT]mdout.mdp[tt] file, this contains comment lines, as well as", "the input that [TT]grompp[tt] has read. If in doubt you can start grompp", "with the [TT]-debug[tt] option which will give you more information", "in a file called grompp.log (along with real debug info). Finally, you", "can see the contents of the run input file with the [TT]gmxdump[tt]", "program." }; t_gromppopts *opts; gmx_mtop_t *sys; int nmi; t_molinfo *mi; gpp_atomtype_t atype; t_inputrec *ir; int natoms,nvsite,comb,mt; t_params *plist; t_state state; matrix box; real max_spacing,fudgeQQ; double reppow; char fn[STRLEN],fnB[STRLEN],*mdparin; int nerror,ntype; bool bNeedVel,bGenVel; bool have_radius,have_vol,have_surftens,have_gb_radius,have_S_hct; bool have_atomnumber; int n12,n13,n14; t_params *gb_plist = NULL; gmx_genborn_t *born = NULL; t_filenm fnm[] = { { efMDP, NULL, NULL, ffOPTRD }, { efMDP, "-po", "mdout", ffWRITE }, { efSTX, "-c", NULL, ffREAD }, { efSTX, "-r", NULL, ffOPTRD }, { efSTX, "-rb", NULL, ffOPTRD }, { efNDX, NULL, NULL, ffOPTRD }, { efTOP, NULL, NULL, ffREAD }, { efTOP, "-pp", "processed", ffOPTWR }, { efTPX, "-o", NULL, ffWRITE }, { efTRN, "-t", NULL, ffOPTRD }, { efEDR, "-e", NULL, ffOPTRD } }; #define NFILE asize(fnm) /* Command line options */ static bool bVerbose=TRUE,bRenum=TRUE; static bool bRmVSBds=TRUE,bZero=FALSE; static int i,maxwarn=0; static real fr_time=-1; t_pargs pa[] = { { "-v", FALSE, etBOOL, {&bVerbose}, "Be loud and noisy" }, { "-time", FALSE, etREAL, {&fr_time}, "Take frame at or first after this time." }, { "-rmvsbds",FALSE, etBOOL, {&bRmVSBds}, "Remove constant bonded interactions with virtual sites" }, { "-maxwarn", FALSE, etINT, {&maxwarn}, "Number of allowed warnings during input processing" }, { "-zero", FALSE, etBOOL, {&bZero}, "Set parameters for bonded interactions without defaults to zero instead of generating an error" }, { "-renum", FALSE, etBOOL, {&bRenum}, "Renumber atomtypes and minimize number of atomtypes" } }; CopyRight(stdout,argv[0]); /* Initiate some variables */ nerror=0; snew(ir,1); snew(opts,1); init_ir(ir,opts); /* Parse the command line */ parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa, asize(desc),desc,0,NULL); init_warning(maxwarn); /* PARAMETER file processing */ mdparin = opt2fn("-f",NFILE,fnm); set_warning_line(mdparin,-1); get_ir(mdparin,opt2fn("-po",NFILE,fnm),ir,opts,&nerror); if (bVerbose) fprintf(stderr,"checking input for internal consistency...\n"); check_ir(mdparin,ir,opts,&nerror); if (ir->ld_seed == -1) { ir->ld_seed = make_seed(); fprintf(stderr,"Setting the LD random seed to %d\n",ir->ld_seed); } bNeedVel = EI_STATE_VELOCITY(ir->eI); bGenVel = (bNeedVel && opts->bGenVel); snew(plist,F_NRE); init_plist(plist); snew(sys,1); atype = init_atomtype(); if (debug) pr_symtab(debug,0,"Just opened",&sys->symtab); strcpy(fn,ftp2fn(efTOP,NFILE,fnm)); if (!gmx_fexist(fn)) gmx_fatal(FARGS,"%s does not exist",fn); new_status(fn,opt2fn_null("-pp",NFILE,fnm),opt2fn("-c",NFILE,fnm), opts,ir,bZero,bGenVel,bVerbose,&state, atype,sys,&nmi,&mi,plist,&comb,&reppow,&fudgeQQ, opts->bMorse, &nerror); if (debug) pr_symtab(debug,0,"After new_status",&sys->symtab); if (count_constraints(sys,mi) && (ir->eConstrAlg == econtSHAKE)) { if (ir->eI == eiCG || ir->eI == eiLBFGS) { fprintf(stderr, "ERROR: Can not do %s with %s, use %s\n", EI(ir->eI),econstr_names[econtSHAKE],econstr_names[econtLINCS]); nerror++; } if (ir->bPeriodicMols) { fprintf(stderr, "ERROR: can not do periodic molecules with %s, use %s\n", econstr_names[econtSHAKE],econstr_names[econtLINCS]); nerror++; } } /* If we are doing GBSA, check that we got the parameters we need * This checking is to see if there are GBSA paratmeters for all * atoms in the force field. To go around this for testing purposes * comment out the nerror++ counter temporarliy */ have_radius=have_vol=have_surftens=have_gb_radius=have_S_hct=TRUE; for(i=0;i<get_atomtype_ntypes(atype);i++) { have_radius=have_radius && (get_atomtype_radius(i,atype) > 0); have_vol=have_vol && (get_atomtype_vol(i,atype) > 0); have_surftens=have_surftens && (get_atomtype_surftens(i,atype) > 0); have_gb_radius=have_gb_radius && (get_atomtype_gb_radius(i,atype) > 0); have_S_hct=have_S_hct && (get_atomtype_S_hct(i,atype) > 0); } if(!have_radius && ir->implicit_solvent==eisGBSA) { fprintf(stderr,"Can't do GB electrostatics; the forcefield is missing values for\n" "atomtype radii, or they might be zero\n."); /* nerror++; */ } /* if(!have_surftens && ir->implicit_solvent!=eisNO) { fprintf(stderr,"Can't do implicit solvent; the forcefield is missing values\n" " for atomtype surface tension\n."); nerror++; } */ /* If we are doing QM/MM, check that we got the atom numbers */ have_atomnumber = TRUE; for (i=0; i<get_atomtype_ntypes(atype); i++) { have_atomnumber = have_atomnumber && (get_atomtype_atomnumber(i,atype) >= 0); } if (!have_atomnumber && ir->bQMMM) { fprintf(stderr,"\n" "It appears as if you are trying to run a QM/MM calculation, but the force\n" "field you are using does not contain atom numbers fields. This is an\n" "optional field (introduced in Gromacs 3.3) for general runs, but mandatory\n" "for QM/MM. The good news is that it is easy to add - put the atom number as\n" "an integer just before the mass column in ffXXXnb.itp.\n" "NB: United atoms have the same atom numbers as normal ones.\n\n"); nerror++; } if (nerror) { print_warn_num(FALSE); gmx_fatal(FARGS,"There were %d error(s) processing your input",nerror); } if (opt2bSet("-r",NFILE,fnm)) sprintf(fn,"%s",opt2fn("-r",NFILE,fnm)); else sprintf(fn,"%s",opt2fn("-c",NFILE,fnm)); if (opt2bSet("-rb",NFILE,fnm)) sprintf(fnB,"%s",opt2fn("-rb",NFILE,fnm)); else strcpy(fnB,fn); if (nint_ftype(sys,mi,F_POSRES) > 0) { if (bVerbose) { fprintf(stderr,"Reading position restraint coords from %s",fn); if (strcmp(fn,fnB) == 0) { fprintf(stderr,"\n"); } else { fprintf(stderr," and %s\n",fnB); if (ir->efep != efepNO && ir->n_flambda > 0) { fprintf(stderr,"ERROR: can not change the position restraint reference coordinates with lambda togther with foreign lambda calculation.\n"); nerror++; } } } gen_posres(sys,mi,fn,fnB, ir->refcoord_scaling,ir->ePBC, ir->posres_com,ir->posres_comB); } nvsite = 0; /* set parameters for virtual site construction (not for vsiten) */ for(mt=0; mt<sys->nmoltype; mt++) { nvsite += set_vsites(bVerbose, &sys->moltype[mt].atoms, atype, mi[mt].plist); } /* now throw away all obsolete bonds, angles and dihedrals: */ /* note: constraints are ALWAYS removed */ if (nvsite) { for(mt=0; mt<sys->nmoltype; mt++) { clean_vsite_bondeds(mi[mt].plist,sys->moltype[mt].atoms.nr,bRmVSBds); } } /* If we are using CMAP, setup the pre-interpolation grid */ if(plist->ncmap>0) { init_cmap_grid(&sys->cmap_grid, plist->nc, plist->grid_spacing); setup_cmap(plist->grid_spacing, plist->nc, plist->cmap,&sys->cmap_grid); } set_wall_atomtype(atype,opts,ir); if (bRenum) { renum_atype(plist, sys, ir->wall_atomtype, atype, bVerbose); ntype = get_atomtype_ntypes(atype); } /* PELA: Copy the atomtype data to the topology atomtype list */ copy_atomtype_atomtypes(atype,&(sys->atomtypes)); if (debug) pr_symtab(debug,0,"After renum_atype",&sys->symtab); if (bVerbose) fprintf(stderr,"converting bonded parameters...\n"); ntype = get_atomtype_ntypes(atype); convert_params(ntype, plist, mi, comb, reppow, fudgeQQ, sys); if(ir->implicit_solvent) { printf("Constructing Generalized Born topology...\n"); /* Check for -normvsbds switch to grompp, necessary for gb together with vsites */ if(bRmVSBds && nvsite) { fprintf(stderr, "ERROR: Must use -normvsbds switch to grompp when doing Generalized Born\n" "together with virtual sites\n"); nerror++; } if (nerror) { print_warn_num(FALSE); gmx_fatal(FARGS,"There were %d error(s) processing your input",nerror); } generate_gb_topology(sys,mi); } if (debug) pr_symtab(debug,0,"After convert_params",&sys->symtab); /* set ptype to VSite for virtual sites */ for(mt=0; mt<sys->nmoltype; mt++) { set_vsites_ptype(FALSE,&sys->moltype[mt]); } if (debug) { pr_symtab(debug,0,"After virtual sites",&sys->symtab); } /* Check velocity for virtual sites and shells */ if (bGenVel) { check_vel(sys,state.v); } /* check masses */ check_mol(sys); for(i=0; i<sys->nmoltype; i++) { check_cg_sizes(ftp2fn(efTOP,NFILE,fnm),&sys->moltype[i].cgs); } check_warning_error(FARGS); if (bVerbose) fprintf(stderr,"initialising group options...\n"); do_index(mdparin,ftp2fn_null(efNDX,NFILE,fnm), sys,bVerbose,ir, bGenVel ? state.v : NULL); /* Init the temperature coupling state */ init_gtc_state(&state,ir->opts.ngtc); if (bVerbose) fprintf(stderr,"Checking consistency between energy and charge groups...\n"); check_eg_vs_cg(sys); if (debug) pr_symtab(debug,0,"After index",&sys->symtab); triple_check(mdparin,ir,sys,&nerror); close_symtab(&sys->symtab); if (debug) pr_symtab(debug,0,"After close",&sys->symtab); /* make exclusions between QM atoms */ if (ir->bQMMM) { generate_qmexcl(sys,ir); } if (ftp2bSet(efTRN,NFILE,fnm)) { if (bVerbose) fprintf(stderr,"getting data from old trajectory ...\n"); cont_status(ftp2fn(efTRN,NFILE,fnm),ftp2fn_null(efEDR,NFILE,fnm), bNeedVel,bGenVel,fr_time,ir,&state,sys); } if (ir->ePBC==epbcXY && ir->nwall!=2) clear_rvec(state.box[ZZ]); if (EEL_FULL(ir->coulombtype)) { /* Calculate the optimal grid dimensions */ copy_mat(state.box,box); if (ir->ePBC==epbcXY && ir->nwall==2) svmul(ir->wall_ewald_zfac,box[ZZ],box[ZZ]); max_spacing = calc_grid(stdout,box,opts->fourierspacing, &(ir->nkx),&(ir->nky),&(ir->nkz),1); if ((ir->coulombtype == eelPPPM) && (max_spacing > 0.1)) { set_warning_line(mdparin,-1); sprintf(warn_buf,"Grid spacing larger then 0.1 while using PPPM."); warning_note(NULL); } } if (ir->ePull != epullNO) set_pull_init(ir,sys,state.x,state.box,opts->pull_start); /* reset_multinr(sys); */ if (EEL_PME(ir->coulombtype)) { float ratio = pme_load_estimate(sys,ir,state.box); fprintf(stderr,"Estimate for the relative computational load of the PME mesh part: %.2f\n",ratio); if (ratio > 0.5) warning_note("The optimal PME mesh load for parallel simulations is below 0.5\n" "and for highly parallel simulations between 0.25 and 0.33,\n" "for higher performance, increase the cut-off and the PME grid spacing"); } { double cio = compute_io(ir,sys->natoms,&sys->groups,F_NRE,1); sprintf(warn_buf,"This run will generate roughly %.0f Mb of data",cio); if (cio > 2000) { set_warning_line(mdparin,-1); warning_note(NULL); } else { printf("%s\n",warn_buf); } } if (bVerbose) fprintf(stderr,"writing run input file...\n"); print_warn_num(TRUE); state.lambda = ir->init_lambda; write_tpx_state(ftp2fn(efTPX,NFILE,fnm),ir,&state,sys); thanx(stderr); return 0; }