main.C

Go to the documentation of this file.
00001 
00008 #ifdef WIN32
00009 #ifndef NO_SOCKET
00010 #define NO_SOCKET
00011 #endif
00012 #endif
00013 
00014 #ifndef NO_SOCKET
00015 
00016 // to track usage, define target host and port in compile line, e.g.:
00017 //    -DTBSOFT_TRACK_HOST=\"127.0.0.1\" -DTBSOFT_TRACK_PORT=3141
00018 // #define TBSOFT_TRACK_HOST   "127.0.0.1"
00019 // #define TBSOFT_TRACK_PORT   3141
00020 
00021 #ifndef TBSOFT_TRACK_MAXLEN
00022 #define TBSOFT_TRACK_MAXLEN 1024              /* maximum message length */
00023 #endif
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <sys/types.h>
00029 #include <unistd.h>
00030 #include <arpa/inet.h>
00031 #include <fcntl.h>
00032 #include <sys/socket.h>
00033 #include <netinet/in.h>
00034 #include <pwd.h>
00035 
00036 #endif
00037 
00038 #include "InfoStream.h"
00039 #include "memusage.h"
00040 
00041 #include "Lattice.h"
00042 #include "ComputeMsmMsa.h"  // needed for MsmMsaData definition
00043 #include "main.decl.h"
00044 #include "main.h"
00045 
00046 #ifndef NO_SOCKET
00047 
00048 int send_dgram(const char *host_addr, int port, const char *buf, int buflen) {
00049   struct sockaddr_in addr;
00050   int sockfd;
00051 
00052 #ifndef NOHOSTNAME
00053   if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
00054     return -1;
00055   } 
00056 
00057   memset(&addr, 0, sizeof(addr));
00058   addr.sin_family = AF_INET;
00059   addr.sin_port = htons(port);
00060   addr.sin_addr.s_addr = inet_addr(host_addr);
00061 
00062   sendto(sockfd, buf, buflen, 0, (struct sockaddr *)&addr, sizeof(addr));
00063 
00064   close(sockfd);
00065 #endif
00066 
00067   return 0;
00068 }                     
00069 
00070 
00071 int tbsoft_sendusage(const char *program, 
00072                      const char *versionnum,
00073                      const char *platform,
00074                      const char *numcpus,
00075                      const char *miscinfo) {
00076 
00077 #ifndef NOHOSTNAME
00078 #ifdef TBSOFT_TRACK_HOST
00079   iout << iINFO
00080     << "Sending usage information to " << TBSOFT_TRACK_HOST
00081     << ":" << TBSOFT_TRACK_PORT << " via UDP.  Sent data is:\n";
00082 #endif
00083 
00084   char sendbuf[TBSOFT_TRACK_MAXLEN];
00085   char host[128];
00086   struct passwd *pw;
00087   char user[128];
00088 
00089   memset(sendbuf, 0, sizeof(sendbuf));
00090 
00091   gethostname(host, 128);  host[127] = 0;
00092   pw = getpwuid(getuid());
00093   if ( pw && pw->pw_name ) {
00094     strncpy(user, pw->pw_name, 127);  user[127] = 0;
00095   } else {
00096     sprintf(user,"%d",getuid());
00097   }
00098 
00099   sprintf(sendbuf, "1 %s  %s  %s  %s  %s  %s  %s", 
00100     program, versionnum, platform, numcpus, miscinfo, host, user);
00101   iout << iINFO << sendbuf << "\n" << endi;
00102 #ifdef TBSOFT_TRACK_HOST
00103   send_dgram(TBSOFT_TRACK_HOST, TBSOFT_TRACK_PORT, sendbuf, strlen(sendbuf));
00104 #endif
00105 
00106 #endif
00107   return 0;
00108 }
00109 
00110 #endif
00111 
00112 extern const char *namd_build_date;
00113 extern const char *namd_build_user;
00114 extern const char *namd_build_machine;
00115 
00116 class main : public Chare
00117 {
00118 public:
00119   main(CkArgMsg *)
00120   {
00121 
00122     // print banner
00123     iout << iINFO << "NAMD " << NAMD_VERSION << " for " << NAMD_PLATFORM
00124          << "\n"
00125 #ifdef MEM_OPT_VERSION
00126          << iWARN << "\n"
00127          << iWARN << "       ***  EXPERIMENTAL MEMORY OPTIMIZED VERSION  ***\n"
00128          << iWARN << "\n"
00129 #endif
00130 #if 0
00131          << iWARN << "\n"
00132          << iWARN << "          ***  UNRELEASED EXPERIMENTAL VERSION  ***\n"
00133          << iWARN << "\n"
00134 #endif
00135 #ifdef SPEC_DISABLED_VERSION
00136 
00137          << iINFO << "\n"
00138          << iINFO << "NAMD is a parallel, object-oriented molecular dynamics\n"
00139          << iINFO << "code designed for high-performance simulation of large\n"
00140          << iINFO << "biomolecular systems.  NAMD is distributed free of\n"
00141          << iINFO << "charge and includes source code.  For more information\n" 
00142          << iINFO << "please visit http://www.ks.uiuc.edu/Research/namd/\n"
00143          << iINFO << "\n"
00144          << iINFO << "*********************************************************\n"
00145          << iINFO << "This version of NAMD may be distributed only as a part of\n"
00146          << iINFO << "the SPEC Workstation Benchmark and all other distribution\n"
00147          << iINFO << "is prohibited.  Any use of this software is bound by\n"
00148          << iINFO << "the terms of the NAMD License, which is available at\n"
00149          << iINFO << "http://www.ks.uiuc.edu/Research/namd/license.html\n"
00150          << iINFO << "The NAMD development team will not provide support for\n"
00151          << iINFO << "any version of NAMD unless you have first registered\n"
00152          << iINFO << "and downloaded the latest version of NAMD available at\n"
00153          << iINFO << "http://www.ks.uiuc.edu/Research/namd/\n"
00154          << iINFO << "*********************************************************\n"
00155 #else
00156          << iINFO << "\n"
00157          << iINFO << "Please visit http://www.ks.uiuc.edu/Research/namd/\n"
00158          << iINFO << "for updates, documentation, and support information.\n"
00159 #endif
00160 << iINFO << "\n"
00161 << iINFO << "Please cite Phillips et al., J. Comp. Chem. 26:1781-1802 (2005)\n"
00162 << iINFO << "in all publications reporting results obtained with NAMD.\n"
00163 << iINFO << "\n"
00164          << endi;
00165 
00166     char charm_version[64];
00167     sprintf(charm_version,"%d",CHARM_VERSION);
00168 
00169 #if CHARM_VERSION < 60500
00170 #error "Charm++ 6.5.1 or later is required to build NAMD"
00171 #endif
00172 
00173     iout << iINFO << "Based on Charm++/Converse " << charm_version
00174          << " for " << CMK_MACHINE_NAME << "\n" << endi;
00175 
00176     iout << iINFO << "Built " << namd_build_date << " by "
00177          << namd_build_user << " on " << namd_build_machine << "\n"
00178          << endi;
00179 #ifndef NO_SOCKET
00180     char numcpus[512];
00181     sprintf(numcpus,"%d",CkNumPes());
00182     tbsoft_sendusage("NAMD",NAMD_VERSION,NAMD_PLATFORM,numcpus,"");
00183 #endif
00184 
00185 #if CMK_BLUEGENE_CHARM
00186     iout << iINFO << "Running on BigSim using " << CmiNumPes() << " real processors.\n" << endi;
00187 #endif
00188     iout << iINFO << "Running on " << CkNumPes() << " processors, "
00189          << CmiNumNodes() << " nodes, "
00190          << CmiNumPhysicalNodes() << " physical nodes.\n" << endi;
00191     iout << iINFO << "CPU topology information " << (CmiCpuTopologyEnabled()?"available":"unavailable") << ".\n" << endi;
00192     iout << iINFO << "Charm++/Converse parallel runtime startup completed at "
00193          << CmiWallTimer() << " s\n"<< endi;
00194     const char* memsource;
00195     memusage(&memsource);
00196     iout << iINFO << memusage_MB() << " MB of memory in use"
00197          << " based on " << memsource << "\n";
00198 
00199 #if CMK_SMP
00200     if ( CmiNumNodes() > 1 && CkNumPes() == CmiNumNodes() ) {
00201       NAMD_die("SMP build launched as multiple single-thread processes.  Use ++ppn to set number of worker threads per process to match available cores, reserving one core per process for communication thread.");
00202     }
00203 #endif
00204   }
00205 };
00206 
00207 #include "main.def.h"
00208 

Generated on Wed Nov 22 01:17:15 2017 for NAMD by  doxygen 1.4.7