/* * Open the netcdf file, read all dimension and variable IDs, close. * Return the number of frames in the file. */ int Traj_AmberNetcdf::setupTrajin(std::string const& fname, Topology* trajParm) { filename_.SetFileNameWithExpansion( fname ); if (openTrajin()) return TRAJIN_ERR; // Sanity check - Make sure this is a Netcdf trajectory if ( GetNetcdfConventions() != NC_AMBERTRAJ ) { mprinterr("Error: Netcdf file %s conventions do not include \"AMBER\"\n",filename_.base()); return TRAJIN_ERR; } // Get global attributes std::string attrText = GetAttrText("ConventionVersion"); if ( attrText != "1.0") mprintf("Warning: Netcdf file %s has ConventionVersion that is not 1.0 (%s)\n", filename_.base(), attrText.c_str()); // Get title SetTitle( GetAttrText("title") ); // Get Frame info if ( SetupFrame()!=0 ) return TRAJIN_ERR; // Setup Coordinates/Velocities if ( SetupCoordsVelo()!=0 ) return TRAJIN_ERR; SetVelocity( HasVelocities() ); // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF file %s (%i) does not\n", filename_.base(),Ncatom()); mprinterr(" match number in associated parmtop (%i)!\n",trajParm->Natom()); return TRAJIN_ERR; } // Setup Time if ( SetupTime()!=0 ) return TRAJIN_ERR; // Box info double boxcrd[6]; if (SetupBox(boxcrd, NC_AMBERTRAJ) == 1) // 1 indicates an error return TRAJIN_ERR; SetBox( boxcrd ); // Replica Temperatures - Allowed to fail silently if (SetupTemperature() == 0) SetTemperature( true ); // Replica Dimensions if ( SetupMultiD() == -1 ) return TRAJIN_ERR; // NOTE: TO BE ADDED // labelDID; //int cell_spatialDID, cell_angularDID; //int spatialVID, cell_spatialVID, cell_angularVID; // Amber Netcdf coords are float. Allocate a float array for converting // float to/from double. if (Coord_ != 0) delete[] Coord_; Coord_ = new float[ Ncatom3() ]; if (Veloc_ != 0) delete[] Veloc_; if (velocityVID_ != -1) Veloc_ = new float[ Ncatom3() ]; else Veloc_ = 0; if (debug_>1) NetcdfDebug(); closeTraj(); // NetCDF files are always seekable SetSeekable( true ); return Ncframe(); }
/* * Open the netcdf file, read all dimension and variable IDs, close. * Return the number of frames in the file. */ int Traj_AmberNetcdf::setupTrajin(FileName const& fname, Topology* trajParm) { filename_ = fname; if (openTrajin()) return TRAJIN_ERR; readAccess_ = true; // Sanity check - Make sure this is a Netcdf trajectory if ( GetNetcdfConventions() != NC_AMBERTRAJ ) { mprinterr("Error: Netcdf file %s conventions do not include \"AMBER\"\n",filename_.base()); return TRAJIN_ERR; } // Get global attributes std::string attrText = GetAttrText("ConventionVersion"); if ( attrText != "1.0") mprintf("Warning: Netcdf file %s has ConventionVersion that is not 1.0 (%s)\n", filename_.base(), attrText.c_str()); // Get title SetTitle( GetAttrText("title") ); // Get Frame info if ( SetupFrameDim()!=0 ) return TRAJIN_ERR; if ( Ncframe() < 1 ) { mprinterr("Error: Netcdf file is empty.\n"); return TRAJIN_ERR; } // Setup Coordinates/Velocities if ( SetupCoordsVelo( useVelAsCoords_ )!=0 ) return TRAJIN_ERR; // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF file %s (%i) does not\n" "Error: match number in associated parmtop (%i)!\n", filename_.base(), Ncatom(), trajParm->Natom()); return TRAJIN_ERR; } // Setup Time - FIXME: Allowed to fail silently SetupTime(); // Box info double boxcrd[6]; if (SetupBox(boxcrd, NC_AMBERTRAJ) == 1) // 1 indicates an error return TRAJIN_ERR; // Replica Temperatures - FIXME: Allowed to fail silently SetupTemperature(); // Replica Dimensions ReplicaDimArray remdDim; if ( SetupMultiD(remdDim) == -1 ) return TRAJIN_ERR; // Set traj info: FIXME - no forces yet SetCoordInfo( CoordinateInfo(remdDim, Box(boxcrd), HasVelocities(), HasTemperatures(), HasTimes(), false) ); // NOTE: TO BE ADDED // labelDID; //int cell_spatialDID, cell_angularDID; //int spatialVID, cell_spatialVID, cell_angularVID; // Amber Netcdf coords are float. Allocate a float array for converting // float to/from double. if (Coord_ != 0) delete[] Coord_; Coord_ = new float[ Ncatom3() ]; if (debug_>1) NetcdfDebug(); closeTraj(); return Ncframe(); }
void main(void) //------------ Main Program --------------------------------------------------------------- { ADCON1 = 0x0F; CMCON = 0x07; lcd_init(); TRISA = 0b00110000; //Set PORTAs as outputs and inputs version();//Show version number Startup();//Startup SetupTime(); //Get Time SetupAlarmTimeA(); //Get Alarm Time for Subject A SetupAlarmTimeB(); //Get Alarm Time for Subject B SetupAlarmTimeC(); //Get Alarm Time for Subject C SetupTimerInterruptRegisters(); while(1) { if(hour==hourA && minute==minuteA && AlarmAOff == 0) { //On Buzzer RA0 and LED RA1 PORTAbits.RA0 = 1; PORTAbits.RA1 = 1; while (PORTAbits.RA5 == 1); //when mute is pressed AlarmAOff = 1; } else if(hour==hourB && minute==minuteB && AlarmBOff == 0) { //On Buzzer RA0 and LED RA2 PORTAbits.RA0 = 1; PORTAbits.RA2 = 1; while (PORTAbits.RA5 == 1); //when mute is pressed AlarmBOff = 1; } else if(hour==hourC && minute==minuteC && AlarmC2Off == 0) { //On Buzzer RA0 and LED RA3 PORTAbits.RA0 = 1; PORTAbits.RA3 = 1; while (PORTAbits.RA5 == 1); //when mute is pressed AlarmC2Off = 1; } else { PORTA = 0b00000000; //Off Buzzer and All LEDS at start } } }
/** Set up netcdf restart file for reading, get all variable and dimension IDs. * Also check number of atoms against associated parmtop. */ int Traj_AmberRestartNC::setupTrajin(std::string const& fname, Topology* trajParm) { filename_.SetFileNameWithExpansion( fname ); if (openTrajin()) return TRAJIN_ERR; // Sanity check - Make sure this is a Netcdf restart if ( GetNetcdfConventions() != NC_AMBERRESTART ) { mprinterr("Error: Netcdf restart file %s conventions do not include \"AMBERRESTART\"\n", filename_.base()); return TRAJIN_ERR; } // Get global attributes std::string attrText = GetAttrText("ConventionVersion"); if (attrText!="1.0") mprintf("Warning: Netcdf restart file %s has ConventionVersion that is not 1.0 (%s)\n", filename_.base(), attrText.c_str()); // Get title SetTitle( GetAttrText("title") ); // Setup Coordinates/Velocities if ( SetupCoordsVelo()!=0 ) return TRAJIN_ERR; SetVelocity( HasVelocities() ); // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF restart file %s (%i) does not\n", filename_.base(), Ncatom()); mprinterr(" match number in associated parmtop (%i)!\n",trajParm->Natom()); return TRAJIN_ERR; } // Setup Time if ( SetupTime()!=0 ) return TRAJIN_ERR; // Box info double boxcrd[6]; if (SetupBox(boxcrd, NC_AMBERRESTART) == 1) // 1 indicates an error return TRAJIN_ERR; SetBox( boxcrd ); // Replica Temperatures - allowed to fail silently if (SetupTemperature() == 0) SetTemperature( true ); if ( SetupMultiD() == -1 ) return TRAJIN_ERR; // NOTE: TO BE ADDED // labelDID; //int cell_spatialDID, cell_angularDID; //int spatialVID, cell_spatialVID, cell_angularVID; closeTraj(); // Only 1 frame for NC restarts return 1; }
// Traj_NcEnsemble::setupTrajin() int Traj_NcEnsemble::setupTrajin(FileName const& fname, Topology* trajParm) { # ifdef MPI if (NoPnetcdf()) return TRAJIN_ERR; # endif readAccess_ = true; filename_ = fname; //if (openTrajin()) return TRAJIN_ERR; // Open single thread for now if (NC_openRead( filename_.Full() )) return TRAJIN_ERR; // Sanity check - Make sure this is a Netcdf ensemble trajectory if ( GetNetcdfConventions() != NC_AMBERENSEMBLE ) { mprinterr("Error: Netcdf file %s conventions do not include \"AMBERENSEMBLE\"\n", filename_.base()); return TRAJIN_ERR; } // This will warn if conventions are not 1.0 CheckConventionsVersion(); // Get title SetTitle( GetNcTitle() ); // Get Frame info if ( SetupFrameDim()!=0 ) return TRAJIN_ERR; if ( Ncframe() < 1 ) { mprinterr("Error: Netcdf file is empty.\n"); return TRAJIN_ERR; } // Get ensemble info int ensembleSize = SetupEnsembleDim(); if (ensembleSize < 1) { mprinterr("Error: Could not get ensemble dimension info.\n"); return TRAJIN_ERR; } // Setup Coordinates/Velocities if ( SetupCoordsVelo( useVelAsCoords_, useFrcAsCoords_ )!=0 ) return TRAJIN_ERR; // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF file %s (%i) does not\n" "Error: match number in associated parmtop (%i)!\n", filename_.base(), Ncatom(), trajParm->Natom()); return TRAJIN_ERR; } // Setup Time - FIXME: Allowed to fail silently SetupTime(); // Box info Box nc_box; if (SetupBox(nc_box, NC_AMBERENSEMBLE) == 1) // 1 indicates an error return TRAJIN_ERR; // Replica Temperatures - FIXME: Allowed to fail silently SetupTemperature(); // Replica Dimensions ReplicaDimArray remdDim; if ( SetupMultiD(remdDim) == -1 ) return TRAJIN_ERR; // Set traj info: FIXME - no forces yet SetCoordInfo( CoordinateInfo(ensembleSize, remdDim, nc_box, HasVelocities(), HasTemperatures(), HasTimes(), false) ); if (debug_>1) NetcdfDebug(); //closeTraj(); // Close single thread for now NC_close(); // Set up local ensemble parameters # ifdef MPI ensembleStart_ = Parallel::World().Rank(); ensembleEnd_ = Parallel::World().Rank() + 1; # else ensembleStart_ = 0; ensembleEnd_ = ensembleSize; # endif // DEBUG: Print info for all ranks WriteVIDs(); // Allocate float array if (Coord_ != 0) delete[] Coord_; Coord_ = new float[ Ncatom3() ]; return Ncframe(); }
void main(void) { #ifdef CAN_OPEN_ENABLE BYTE i; #endif //=================================== //#if ((BUFFER_LEN_UART>1000)||(COUNT_UART_BUF>4)) InitWatchDog(); //#endif I2C_Init(0); I2C_Init(1); InitUART(0); SetupTime(); InitReloadTimer0(); InitServiceUart0(); InitIrqLevels(); __set_il(7); /* allow all levels */ __EI(); /* globally enable interrupts */ //=================================== InitProgrammVar(); //=================================== if(INIT_BLOK!=NULL) INIT_BLOK(); //=================================== #ifdef CAN_OPEN_ENABLE setState(Initialisation); #else SetupCAN(SPEED_CAN_0, SPEED_CAN_1, SPEED_CAN_2); #endif //=================================== #ifdef EN_SR_ZN_CYKL add_timer(&TimerSrZnC); #endif #ifdef CASH_PDO_DATA add_timer(&TimerCashCan); #endif puts((BYTE *)"===============================================================================\r\n"); puts((BYTE *)" Terminal Fujitsu MB96F338 \r\n"); puts((BYTE *)"===============================================================================\r\n$>"); while(1) { //======================================== clrwdt; // обнуление WatchDog таймера //======================================== CyclicModules(); // цикличные операции выполняемые в каждом блоке //======================================== if(DRIVER_BLOK!=NULL) // Функционал конкретного блока DRIVER_BLOK(); //======================================== #ifdef CAN_OPEN_ENABLE receiveMsgHandler(0); receiveMsgHandler(1); receiveMsgHandler(2); DriverCanOpen(); #ifdef CASH_PDO_DATA if(getTimer(&TimerCashCan)==0) { setTimer(&TimerCashCan, 30); // обновляем данные в объектном словаре 1 раз в 30 мс for(i=0;i<30;i++) buildPDO_CASH(0x1800+i); if(program.Cnt1WareDev == 0) GetDataWare(0); } #endif #endif //======================================== #ifdef TERMINAL_EN Terminal(); #endif //======================================== // подсчёт среднего времени цикла в мкс #ifdef EN_SR_ZN_CYKL program.CountCikl_1s++; if(getTimer(&TimerSrZnC)==0) { program.SrCikl_mks = 1000000/program.CountCikl_1s; // среднее значение цикла в мкс program.CountCikl_1s = 0; setTimer(&TimerSrZnC, 1000); } #endif //======================================== } }