001 import java.io.*; 002 003 import cnslab.cnsmath.*; 004 import cnslab.cnsnetwork.*; 005 006 /*********************************************************************** 007 * @version 008 * $Date: 2011-09-10 20:48:53 -0500 (Sat, 10 Sep 2011) $ 009 * $Rev: 226 $ 010 * $Author: croft $ 011 * @author 012 * Yi Dong 013 * @author 014 * David Wallace Croft 015 ***********************************************************************/ 016 public final class starter 017 //////////////////////////////////////////////////////////////////////// 018 //////////////////////////////////////////////////////////////////////// 019 { 020 021 public static void main ( final String [ ] args ) 022 throws Exception 023 //////////////////////////////////////////////////////////////////////// 024 { 025 if ( args.length > 4 026 || args.length < 1 027 || args [ 0 ].equals ( "-help" ) 028 || args [ 0 ].equals ( "--help" ) ) 029 { 030 System.out.println ( 031 "Usage: java starter xmlfile.xml [seednum] [heapsize]megabyte" ); 032 033 System.out.println ( 034 " default seednum -3, default heapsize 512m" ); 035 036 System.out.println ( 037 " java --help to show this help information" ); 038 } 039 else 040 { 041 final File filename = new File ( "model/" + args [ 0 ] ); 042 043 if ( !filename.exists ( ) ) 044 { 045 System.out.println ( "xml file doesn't exist, " 046 + "please put it in the model directory" ); 047 048 System.exit ( 0 ); 049 } 050 051 int seed = -3; 052 053 int heapsize = 512; 054 055 if ( args.length >= 2 ) 056 { 057 seed = Integer.parseInt ( args [ 1 ] ); 058 059 if ( seed > 0 ) 060 { 061 seed = -seed; 062 } 063 } 064 065 if ( args.length == 3 ) 066 { 067 heapsize = Integer.parseInt ( args [ 2 ] ); 068 069 if ( heapsize < 0 ) 070 { 071 heapsize = -heapsize; 072 } 073 } 074 075 System.out.println ( 076 "file:" 077 + args [ 0 ] 078 + " seed:" 079 + seed 080 + " heapsize:" 081 + heapsize ); 082 083 final Seed idum = new Seed ( seed ); 084 085 MainSimulator main; 086 087 if ( args.length == 4 088 && args [ 3 ].equals ( "-a" ) ) 089 { 090 main = new AMainSimulator ( 091 idum, 092 args [ 0 ], 093 heapsize ); 094 } 095 else 096 { 097 main = new MainSimulator ( 098 idum, 099 args [ 0 ], 100 heapsize ); 101 } 102 103 main.run ( ); 104 } 105 } 106 107 //////////////////////////////////////////////////////////////////////// 108 //////////////////////////////////////////////////////////////////////// 109 }