File: winconfigure.wsf

package info (click to toggle)
mpich2 1.2.1.1-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 73,904 kB
  • ctags: 65,947
  • sloc: ansic: 343,583; makefile: 55,174; java: 34,959; sh: 27,558; perl: 17,355; cpp: 10,472; python: 9,649; f90: 5,753; fortran: 5,128; cs: 4,019; csh: 152; xml: 91; php: 8
file content (7676 lines) | stat: -rwxr-xr-x 319,450 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
<package>
<job id="winconfigure">
    <runtime>
        <description>This script generates files for building MPICH2</description>
        <unnamed
            name = "--force"
            helpstring = "Force the creation of new files, overwriting the old"
            required = "false"
        />
        <unnamed
            name = "--force=no"
            helpstring = "Only create files that do not already exist"
            required = "false"
        />
        <unnamed
            name = "--enable-timer-type=x86cycle"
            helpstring = "Use the Pentium rdtsc instruction for timing"
            required = "false"
        />
        <unnamed
            name = "--enable-timer-type=queryperformancecounter"
            helpstring = "Use QueryPerformanceCounter for timing"
            required = "false"
        />
<!--        <unnamed
			name = "--with-mcxx"
			helpstring = "Generate the managed C++ interface"
			required = "false"
		/>
-->
		<unnamed
			name = "--defmsg"
			helpstring = "Generate defmsg.h"
			required = "false"
		/>
		<unnamed
			name = "--genstates"
			helpstring = "Generate mpiallstates.h and describe_states.c"
			required = "false"
		/>
		<unnamed
			name = "--mpicc"
			helpstring = "Generate mpicc.wsf"
			required = "false"
		/>
		<unnamed
			name = "--ifaces"
			helpstring = "Generate the interfaces (c++,f77,f90,etc)"
			required = "false"
		/>
		<unnamed
			name = "--remove-fortran"
			helpstring = "Remove fortran code and interfaces"
			required = "false"
		/>
		<unnamed
			name = "--use-ib-rdma"
			helpstring = "Use the rdma interface in the infiniband channel"
			required = "false"
		/>
		<unnamed
			name = "--cleancode"
			helpstring = "Clean up the c++ header file"
			required = "false"
		/>
		<unnamed
			name = "--dlldec"
			helpstring = "Add dll decoration to the mpi function prototypes"
			required = "false"
		/>
		<unnamed
			name = "--testdir"
			helpstring = "Configure the test directory only"
			require = "false"
		/>
		<unnamed
			name = "--gen-mpi"
			helpstring = "Generate the stub MPI functions"
			require = "false"
		/>
<!--
		<unnamed
			name = "--vs05"
			helpstring = "apply settings to the Visual Studio 2005 project files"
			require = "false"
		/>
-->
		<unnamed
			name = "--genbuild"
			helpstring = "generate a build script and nmake file"
			require = "false"
		/>
		<unnamed
			name = "--genbuildfiles"
			helpstring = "generate the DIRS, SOURCES, etc files necessary for the build tool"
			require = "false"
		/>
		<unnamed
			name = "--rmbuildfiles"
			helpstring = "delete the DIRS, SOURCES, etc files created by --genbuildfiles"
			require = "false"
		/>
<!--
		<named
			name = "channel"
			helpstring = "specify the channel for --genbuildfiles (sock,shm,sshm,ssm,essm,ib)"
			type = "string"
			require = "false"
		/>
-->
		<named
			name = "channel"
			helpstring = "specify the channel for --genbuildfiles (sock,shm,sshm,ssm)"
			type = "string"
			require = "false"
		/>
		<unnamed
			name = "--smpd_version"
			helpstring = "update the smpd version in smpd.h"
			require = "false"
		/>
		<unnamed
			name = "--ia64"
			helpstring = "use definitions for Win64 IA64 instead of X64"
			require = "false"
		/>
		<unnamed
			name = "--verbose"
			helpstring = "Use verbose option for verbose output"
			require = "false"
		/>
        <example>Example: winconfigure.wsf --cleancode</example>
    </runtime>
<script language="VBScript">

' check if we are running cscript or wscript
isCScript = false
If InStr(1, LCase(WScript.FullName), "cscript") > 0 Then
	isCscript = true
End If

' Use cEcho to echo information to the command line only.
' The output is truncated to 4096 characters.
Function cEcho(str)
	On Error Resume Next
	WScript.Echo str
	if err <> 0 then
		num_chars = Len(str) / 2
		if num_chars > 4096 then
			num_chars = 4096
		end if
		WScript.Echo Left(str, num_chars) & vbCrLf & "..." & vbCrLf
		WScript.Echo Right(str, num_chars)
	end if
End Function

wEchoMsgBoxStr=""
Function wEcho(str)
	wEchoMsgBoxStr = wEchoMsgBoxStr & str & vbCrLf
End Function

Function wEchoFlush()
	MsgBox wEchoMsgBoxStr
End Function

Function gEcho(str)
	If isCscript Then
		cEcho(str)
	Else
		wEcho(str)
	End If
End Function

' print Error msgs with ERROR - output by default
echoErrorMsgs = true
' print status msgs with STATUS - output by default
echoStatusMsgs = true
' print debug & non-status msgs with VERBOSE - suppressed by default
' use "--verbose" option to enable
echoVerboseMsgs = false

Function printMsgFlush()
	If(Not isCscript) Then
		wEchoFlush()
	End If
End Function

Function printMsg(level, str)
	Select Case level
		Case "ERROR"
			If echoErrorMsgs Then
				gEcho(str)
			End If
		Case "STATUS"
			If echoStatusMsgs Then
				gEcho(str)
			End If
		Case "VERBOSE"
			If echoVerboseMsgs Then
				gEcho(str)
			End If
		Case Else
			WScript.Echo "ERROR: INVALID USAGE OF PRINTMSG"
	End Select	
End Function

printMsg "STATUS", "Configuring MPICH2 for windows..."

x64 = True
bVS2005 = False
bUseIbRDMA = False
bUsePinCache = False
bRemoveFortran = False
bUseCycleCounter = False
bForce = True
bCleanCode = False
bAddDllDecoration = False
bMcxx = False
bf77_name_lower = False
bf77_name_lower_uscore = False
bf77_name_lower_2uscore = False
bf77_name_upper = False
bf77_name_mixed = False
bf77_name_mixed_uscore = False
unhandled_definitions = ""
unhandled_definitions_count = 0
unhandled_definitions_instances = 0
unhandled_ats = ""
unhandled_ats_count = 0
unhandled_ats_instances = 0
' variables for creating the nmake file
Dim bfile
Dim mfile
creating_rules = false
files_found = false
cxx_files_found = false
fortran_files_found = false
outdir = "OUTDIR"
cxxflags = "impl_cxxflags"
extra_flags = ""
fort_prefix = ""
remove_buildfiles = false
buildfiles_channel = "sock"
'
' Miscellaneous settings
'
MPI_MAX_PROCESSOR_NAME = "128"
MPI_AINT64               = "__int64"
MPI_AINT64_FMT_DEC_SPEC  = "%I64d"
MPI_AINT64_FMT_HEX_SPEC  = "%I64x"
BSEND_OVERHEAD64         = "95"
MPI_AINT32               = "int"
MPI_AINT32_FMT_DEC_SPEC  = "%d"
MPI_AINT32_FMT_HEX_SPEC  = "%x"
BSEND_OVERHEAD32         = "59"
MPI_FINT               = "int"
'MPI_OFFSET             = "long long"
MPI_OFFSET             = "__int64"
'MPI_OFFSET_TYPEDEF     = "typedef __int64 MPI_Offset;"
'MPI_OFFSET_TYPEDEF     = "typedef long long MPI_Offset;"
MPI_OFFSET_TYPEDEF     = "#if defined(USE_GCC) || defined(__GNUC__)" + vbCrLf + "typedef long long MPI_Offset;" + vbCrLf + "#else" + vbCrLf + "typedef __int64 MPI_Offset;" + vbCrLf + "#endif"
EXTRA_STATUS_DECL      = ""
HAVE_ROMIO             = "#include ""mpio.h"""
mpi_dll_spec_definition = "#ifdef USE_MPI_STATIC_LIBRARY" + vbCrLf + "# define MPIU_DLL_SPEC" + vbCrLf + "#else" + vbCrLf + "# ifdef MPI_EXPORTS" + vbCrLf + "#  define MPIU_DLL_SPEC __declspec(dllexport)" + vbCrLf + "# else" + vbCrLf + "#  define MPIU_DLL_SPEC __declspec(dllimport)" + vbCrLf + "# endif" + vbCrLf + "#endif" + vbCrLf + "#define MPI_CALL __cdecl" + vbCrLf

set f = WScript.CreateObject("Scripting.FileSystemObject")

Set fin = f.OpenTextFile("src\mpid\common\thread\mpe_types.i")
mpid_thread_typedefs = fin.ReadAll()
fin.Close()
Set fin = f.OpenTextFile("src\mpid\common\thread\mpe_funcs.i")
mpid_thread_funcs = fin.ReadAll()
fin.Close()

' Process arguments
If WScript.Arguments.Named.Exists("channel") Then
	buildfiles_channel = WScript.Arguments.Named.Item("channel")
End If
argCount = WScript.Arguments.Count
For arg = 0 To argCount - 1
  argValue = WScript.Arguments(arg)
  If argValue = "--enable-timer-type=x86cycle" Then
    bUseCycleCounter = True
  ElseIf argValue = "--enable-timer-type=queryperformancecounter" Then
    bUseCycleCounter = False
  ElseIf argValue = "--enable-hptiming" Then
    bUseCycleCounter = True
  ElseIf argValue = "--enable-hptiming=yes" Then
    bUseCycleCounter = True
  ElseIf argValue = "--enable-hptiming=no" Then
    bUseCycleCounter = False
  ElseIf argValue = "--force" Then
    bForce = True
  ElseIf argValue = "--force=yes" Then
    bForce = True
  ElseIf argValue = "--force=no" Then
    bForce = False
  ElseIf argValue = "--cleancode" Then
    bCleanCode = True
  ElseIf argValue = "--dlldec" Then
    bAddDllDecoration = True
  ElseIf argValue = "--with-mcxx" Then
	bMcxx = True
  ElseIf argValue = "--f77_name_lower" Then
	bf77_name_lower = True
  ElseIf argValue = "--f77_name_lower_uscore" Then
	bf77_name_lower_uscore = True
  ElseIf argValue = "--f77_name_lower_2uscore" Then
	bf77_name_loser_2uscore = True
  ElseIf argValue = "--f77_name_upper" Then
	bf77_name_upper = True
  ElseIf argValue = "--f77_name_mixed" Then
	bf77_name_mixed = True
  ElseIf argValue = "--f77_name_mixed_uscore" Then
	bf77_name_mixed_uscore = True
  ElseIf argValue = "--defmsg" Then
    GenerateDefmsg()
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--genstates" Then
    GenerateStatesFiles()
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--mpicc" Then
	GenerateMPICC()
	printMsgFlush()
	WScript.Quit
  ElseIf argValue = "--ifaces" Then
	printMsg "ERROR", "Option not implemented, run the entire script to generate the interfaces"
	' BuildIFaces needs the dictionary object to replace the @xxx@s in mpif.h
	'BuildIFaces()
	printMsgFlush()
	WScript.Quit
  ElseIf argValue = "--remove-fortran" Then
    bRemoveFortran = True
  ElseIf argValue = "--use-ib-rdma" Then
	bUseIbRDMA = True
  ElseIf argValue = "--use_ib_rdma" Then
	bUseIbRDMA = True
  ElseIf argValue = "--use-pin-cache" Then
    bUsePinCache = True
  ElseIf argValue = "--use_pin_cache" Then
    bUsePinCache = True
  ElseIf argValue = "--testdir" Then
    ConfigureTestDir()
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--gen-mpi" Then
	FindMPIFuncs()
	printMsgFlush()
	WScript.Quit
  ElseIf argValue = "--gen-sfort" Then
	CreateStdcallFortranInterface()
	printMsgFlush()
	WScript.Quit
  ElseIf argValue = "--vs05" Then
    bVS2005 = True
  ElseIf argValue = "--genbuild" Then
    GenBuild()
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--genbuildfiles" Then
    GenBuildFiles(".")
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--rmbuildfiles" Then
    remove_buildfiles = true
    GenBuildFiles(".")
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--smpd_version" Then
    UpdateSMPDVersion()
	printMsgFlush()
    WScript.Quit
  ElseIf argValue = "--ia64" Then
    x64 = False
  ElseIf argValue = "--verbose" Then
    echoVerboseMsgs = True
  ElseIf argValue = "--help" Then
    WScript.Arguments.ShowUsage
	printMsgFlush()
    WScript.Quit
  End If
Next

'
' datatype sizes
'
  len_short           = "02"
  len_int             = "04"
  len_long            = "04"
  len_long_long       = "08"
  len_float           = "04"
  len_double          = "08"
  len_long_double     = "08"
  len_wchar           = "02"
  len_wchar_t         = "02"
  len_float_int       = "08"
  len_double_int      = "10"
  len_long_int        = "08"
  len_short_int       = "08"
  len_two_int         = "08"
  len_long_double_int = "10"
' Fortran datatype sizes
  len_integer64         = "08"
  len_integer32         = "04"
  len_doublecplx      = "10"
  len_2dc             = "20"

' Special C++ Datatypes to support Fortran datatypes within C++ 
  len_bool			= "01"
  len_complex			= "08"
  len_double_complex		= "10"
  len_long_double_complex	= "20"

' C99 types - These types are not supported by VS, however
' C++ pgms use the same types. So we use the C++ type sizes here
' Also since _Complex is an alias for float _Complex we don't need
' to handle it here
  len__Bool                 = "01"
  len_float__Complex         = "08"
  len_double__Complex        = "10"
  len_long_double__Complex   = "10"

  len_mpi_aint64        = "08"
  len_mpi_aint32        = "04"

  len_mpi_offset        = "08"

Function CreateDtypeDictionary(byref types, str, b64)
	dim regEx, Match, Matches
	set regEx = New RegExp
	'set types = WScript.CreateObject("Scripting.Dictionary")
	' remove all dnl lines to prevent false matches
	regEx.Pattern = "dnl .*"
	regEx.IgnoreCase = True
	regEx.Global = True
	str = regEx.Replace(str, "")
	' find the datatype handles
	regEx.Pattern = "MPI_.*=""?0x4c00.*[0-9a-f][0-9a-f]"
	regEx.IgnoreCase = False
	regEx.Global = True
	Set Matches = regEx.Execute(str)
	For Each Match in Matches
		size_str = RegExpFind("\$\{len.*\}", Match.Value)
		dtype_str = RegExpFind("MPI_[^=]*", Match.Value)
		dtype_val_str = RegExpFind("0x4c00.*[0-9a-f][0-9a-f]", Match.Value)
                ' If size_str is empty then the datatype handle is hardcoded
		if size_str <> "" then
			Select Case size_str
				Case "${len_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_int)
				Case "${len_short}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_short)
				Case "${len_long}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_long)
				Case "${len_long_long}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_long_long)
				Case "${len_float_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_float_int)
				Case "${len_double_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_double_int)
				Case "${len_long_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_long_int)
				Case "${len_short_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_short_int)
				Case "${len_two_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_two_int)
				Case "${len_long_double_int}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_long_double_int)
				Case "${len_double}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_double)
				Case "${len_doublecplx}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_doublecplx)
				Case "${len_2dc}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_2dc)
				Case "${len_float}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_float)
				Case "${len_long_double}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_long_double)
				Case "${len_integer}"
					if b64 then
						dtype_val_str = Replace(dtype_val_str, size_str, len_integer64)
					else
						dtype_val_str = Replace(dtype_val_str, size_str, len_integer32)
					end if
				Case "${len_wchar_t}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_wchar_t)
				Case "${len_wchar}"
					dtype_val_str = Replace(dtype_val_str, size_str, len_wchar)
                                Case "${len__Bool}"
                                        dtype_val_str = Replace(dtype_val_str, size_str, len__Bool)
                                Case "${len_float__Complex}"
                                        dtype_val_str = Replace(dtype_val_str, size_str, len_float__Complex)
                                Case "${len_double__Complex}"
                                        dtype_val_str = Replace(dtype_val_str, size_str, len_double__Complex)
                                Case "${len_long_double__Complex}"
                                        dtype_val_str = Replace(dtype_val_str, size_str, len_long_double__Complex)
                                Case "${len_mpi_aint}"
                                        If b64 Then
                                            dtype_val_str = Replace(dtype_val_str, size_str, len_mpi_aint64)
                                        Else
                                            dtype_val_str = Replace(dtype_val_str, size_str, len_mpi_aint32)
                                        End If
                                Case "${len_mpi_offset}"
                                        dtype_val_str = Replace(dtype_val_str, size_str, len_mpi_offset)
				Case Else
					unmatched_size_strs = unmatched_size_strs & " " & size_str & vbCrLf
			End Select
		end if
		if types.Exists(dtype_str) then
			if types.Item(dtype_str) <> dtype_val_str then
				temp_str = dtype_str & " = " & types.Item(dtype_str) & " or " & dtype_val_str
				MsgBox temp_str
			end if
		else
			types.Add dtype_str, dtype_val_str
		end if
	Next
	if unmatched_size_strs <> "" then
		MsgBox unmatched_size_strs
	end if
	'CreateDtypeDictionary = types
End Function

'
' Create a dictionary of all the datatype handles
'
unmatched_size_strs = ""
set fin = f.OpenTextFile("configure.in")
contents = fin.ReadAll()
fin.Close()
'set fin = f.OpenTextFile("src\binding\f77\configure.in")
'contents = contents + fin.ReadAll()
'fin.Close()
'set dtypes = CreateDtypeDictionary(contents, false)
'set dtypes64 = CreateDtypeDictionary(contents, true)
set dtypes = WScript.CreateObject("Scripting.Dictionary")
CreateDtypeDictionary dtypes, contents, false
set dtypes64 = WScript.CreateObject("Scripting.Dictionary")
CreateDtypeDictionary dtypes64, contents, false

'mpi_datatype_prefix = "4c00"

'MPI_CHAR              = "0x" + mpi_datatype_prefix                 + "0101"
'MPI_SIGNED_CHAR       = "0x" + mpi_datatype_prefix                 + "0118"
'MPI_UNSIGNED_CHAR     = "0x" + mpi_datatype_prefix                 + "0102"
'MPI_BYTE              = "0x" + mpi_datatype_prefix                 + "010d"
'MPI_WCHAR             = "0x" + mpi_datatype_prefix + len_wchar       + "0e"
'MPI_WCHAR_T           = "0x" + mpi_datatype_prefix + len_wchar_t     + "0e"
'MPI_SHORT             = "0x" + mpi_datatype_prefix + len_short       + "03"
'MPI_UNSIGNED_SHORT    = "0x" + mpi_datatype_prefix + len_short       + "04"
'MPI_INT               = "0x" + mpi_datatype_prefix + len_int         + "05"
'MPI_UNSIGNED          = "0x" + mpi_datatype_prefix + len_int         + "06"
'MPI_LONG              = "0x" + mpi_datatype_prefix + len_long        + "07"
'MPI_UNSIGNED_LONG     = "0x" + mpi_datatype_prefix + len_long        + "08"
'MPI_LONG_LONG         = "0x" + mpi_datatype_prefix + len_long_long   + "09"
'MPI_LONG_LONG_INT     = "0x" + mpi_datatype_prefix + len_long_long   + "09"
'MPI_UNSIGNED_LONG_LONG ="0x" + mpi_datatype_prefix + len_long_long   + "19"
'MPI_FLOAT             = "0x" + mpi_datatype_prefix + len_float       + "0a"
'MPI_DOUBLE            = "0x" + mpi_datatype_prefix + len_double      + "0b"
'MPI_LONG_DOUBLE       = "0x" + mpi_datatype_prefix + len_long_double + "0c"
'MPI_PACKED            = "0x" + mpi_datatype_prefix                 + "010f"
'MPI_LB                = "0x" + mpi_datatype_prefix                 + "0010"
'MPI_UB                = "0x" + mpi_datatype_prefix                 + "0011"
'MPI_REAL4             = "0x" + mpi_datatype_prefix                 + "0427"
'MPI_REAL8             = "0x" + mpi_datatype_prefix                 + "0829"
'MPI_REAL16            = "0x" + mpi_datatype_prefix                 + "1029"
'MPI_COMPLEX8          = "0x" + mpi_datatype_prefix                 + "0828"
'MPI_COMPLEX16         = "0x" + mpi_datatype_prefix                 + "102b"
'MPI_COMPLEX32         = "0x" + mpi_datatype_prefix                 + "2030"
'MPI_INTEGER1          = "0x" + mpi_datatype_prefix                 + "012d"
'MPI_INTEGER2          = "0x" + mpi_datatype_prefix                 + "022f"
'MPI_INTEGER4          = "0x" + mpi_datatype_prefix                 + "0430"
'MPI_INTEGER8          = "0x" + mpi_datatype_prefix                 + "082a"
'MPI_INTEGER16         = "0x" + mpi_datatype_prefix                 + "102f"
'MPI_FLOAT_INT         = "0x" + mpi_datatype_prefix + len_float_int       + "12"
'MPI_DOUBLE_INT        = "0x" + mpi_datatype_prefix + len_double_int      + "13"
'MPI_LONG_INT          = "0x" + mpi_datatype_prefix + len_long_int        + "14"
'MPI_SHORT_INT         = "0x" + mpi_datatype_prefix + len_short_int       + "15"
'MPI_2INT              = "0x" + mpi_datatype_prefix + len_two_int           + "16"
'MPI_LONG_DOUBLE_INT   = "0x" + mpi_datatype_prefix + len_long_double_int + "17"
'MPI_CHARACTER         = "0x" + mpi_datatype_prefix                + "011a"
'MPI_INTEGER           = "0x" + mpi_datatype_prefix + len_integer    + "1b"
'MPI_REAL              = "0x" + mpi_datatype_prefix + len_integer    + "1c"
'MPI_LOGICAL           = "0x" + mpi_datatype_prefix + len_integer    + "1d"
'MPI_COMPLEX           = "0x" + mpi_datatype_prefix + len_double     + "1e"
'MPI_DOUBLE_PRECISION  = "0x" + mpi_datatype_prefix + len_double     + "1f"
'MPI_2INTEGER          = "0x" + mpi_datatype_prefix + len_double     + "20"
'MPI_2REAL             = "0x" + mpi_datatype_prefix + len_double     + "21"
'MPI_DOUBLE_COMPLEX    = "0x" + mpi_datatype_prefix + len_doublecplx + "22"
'MPI_2DOUBLE_PRECISION = "0x" + mpi_datatype_prefix + len_doublecplx + "23"
'MPI_2COMPLEX          = "0x" + mpi_datatype_prefix + len_doublecplx + "24"
'MPI_2DOUBLE_COMPLEX   = "0x" + mpi_datatype_prefix + len_2dc        + "25"

'F77_MPI_COMPLEX           = "1275070494"
'F77_MPI_DOUBLE_COMPLEX    = "1275072546"
'F77_MPI_LOGICAL           = "1275069469"
'F77_MPI_REAL              = "1275069468"
'F77_MPI_DOUBLE_PRECISION  = "1275070495"
'F77_MPI_INTEGER           = "1275069467"
'F77_MPI_2INTEGER          = "1275070496"
'F77_MPI_2COMPLEX          = "1275072548"
'F77_MPI_2DOUBLE_COMPLEX   = "1275076645"
'F77_MPI_2REAL             = "1275070497"
'F77_MPI_2DOUBLE_PRECISION = "1275072547"
'F77_MPI_CHARACTER         = "1275068698"
'F77_MPI_LB                = "1275068432"
'F77_MPI_PACKED            = "1275068687"
'F77_MPI_UB                = "1275068433"
'F77_COMPLEX8              = "1275070504"
'F77_COMPLEX16             = "1275072554"
'F77_COMPLEX32             = "MPI_DATATYPE_NULL"
'F77_INTEGER1              = "1275068717"
'F77_INTEGER2              = "1275068975"
'F77_INTEGER4              = "1275069488"
'F77_INTEGER8              = "1275070507"
'F77_INTEGER16             = "MPI_DATATYPE_NULL"
'F77_REAL4                 = "1275069479"
'F77_REAL8                 = "1275070505"
'F77_REAL16                = "MPI_DATATYPE_NULL"

'
' Set the datatype variables from the dictionary
'
mpi_datatype_prefix = "4c00"
missing_datatypes = ""

if dtypes.Exists("MPI_CHAR") then
	MPI_CHAR = dtypes.Item("MPI_CHAR")
else
	missing_datatypes = missing_datatypes & "MPI_CHAR" & vbCrLf
	MPI_CHAR              = "0x" + mpi_datatype_prefix                 + "0101"
end if
if dtypes.Exists("MPI_SIGNED_CHAR") then
	MPI_SIGNED_CHAR = dtypes.Item("MPI_SIGNED_CHAR")
else
	missing_datatypes = missing_datatypes & "MPI_SIGNED_CHAR" & vbCrLf
	MPI_SIGNED_CHAR       = "0x" + mpi_datatype_prefix                 + "0118"
end if
if dtypes.Exists("MPI_UNSIGNED_CHAR") then
	MPI_UNSIGNED_CHAR = dtypes.Item("MPI_UNSIGNED_CHAR")
else
	missing_datatypes = missing_datatypes & "MPI_UNSIGNED_CHAR" & vbCrLf
	MPI_UNSIGNED_CHAR     = "0x" + mpi_datatype_prefix                 + "0102"
end if
if dtypes.Exists("MPI_BYTE") then
	MPI_BYTE = dtypes.Item("MPI_BYTE")
else
	missing_datatypes = missing_datatypes & "MPI_BYTE" & vbCrLf
	MPI_BYTE              = "0x" + mpi_datatype_prefix                 + "010d"
end if
if dtypes.Exists("MPI_WCHAR") then
	MPI_WCHAR = dtypes.Item("MPI_WCHAR")
else
	missing_datatypes = missing_datatypes & "MPI_WCHAR" & vbCrLf
	MPI_WCHAR             = "0x" + mpi_datatype_prefix + len_wchar       + "0e"
end if
if dtypes.Exists("MPI_WCHAR_T") then
	MPI_WCHAR_T = dtypes.Item("MPI_WCHAR_T")
else
	'missing_datatypes = missing_datatypes & "MPI_WCHAR_T" & vbCrLf
	'MPI_WCHAR_T           = "0x" + mpi_datatype_prefix + len_wchar_t     + "0e"
        if dtypes.Exists("MPI_WCHAR") then
            MPI_WCHAR_T = dtypes.Item("MPI_WCHAR")
            dtypes.Add "MPI_WCHAR_T", MPI_WCHAR_T
        else
            missing_datatypes = missing_datatypes & "MPI_WCHAR_T" & vbCrLf
            MPI_WCHAR_T       = "0x" + mpi_datatype_prefix + len_wchar       + "0e"
        end if
end if
if dtypes.Exists("MPI_SHORT") then
	MPI_SHORT = dtypes.Item("MPI_SHORT")
else
	missing_datatypes = missing_datatypes & "MPI_SHORT" & vbCrLf
	MPI_SHORT             = "0x" + mpi_datatype_prefix + len_short       + "03"
end if
if dtypes.Exists("MPI_UNSIGNED_SHORT") then
	MPI_UNSIGNED_SHORT = dtypes.Item("MPI_UNSIGNED_SHORT")
else
	missing_datatypes = missing_datatypes & "MPI_UNSIGNED_SHORT" & vbCrLf
	MPI_UNSIGNED_SHORT    = "0x" + mpi_datatype_prefix + len_short       + "04"
end if
if dtypes.Exists("MPI_INT") then
	MPI_INT = dtypes.Item("MPI_INT")
else
	missing_datatypes = missing_datatypes & "MPI_INT" & vbCrLf
	MPI_INT               = "0x" + mpi_datatype_prefix + len_int         + "05"
end if
if dtypes.Exists("MPI_UNSIGNED_INT") then
	MPI_UNSIGNED_INT = dtypes.Item("MPI_UNSIGNED_INT")
else
	missing_datatypes = missing_datatypes & "MPI_UNSIGNED_INT" & vbCrLf
	MPI_UNSIGNED_INT      = "0x" + mpi_datatype_prefix + len_int         + "06"
end if
if dtypes.Exists("MPI_UNSIGNED") then
	MPI_UNSIGNED = dtypes.Item("MPI_UNSIGNED")
else
	'missing_datatypes = missing_datatypes & "MPI_UNSIGNED" & vbCrLf
	'MPI_UNSIGNED          = "0x" + mpi_datatype_prefix + len_int         + "06"
        if dtypes.Exists("MPI_UNSIGNED_INT") then
            MPI_UNSIGNED = dtypes.Item("MPI_UNSIGNED_INT")
            dtypes.Add "MPI_UNSIGNED", MPI_UNSIGNED
        else
            missing_datatypes = missing_datatypes & "MPI_UNSIGNED" & vbCrLf
            MPI_UNSIGNED      = "0x" + mpi_datatype_prefix + len_int         + "06"
        end if
end if
if dtypes.Exists("MPI_LONG") then
	MPI_LONG = dtypes.Item("MPI_LONG")
else
	missing_datatypes = missing_datatypes & "MPI_LONG" & vbCrLf
	MPI_LONG              = "0x" + mpi_datatype_prefix + len_long        + "07"
end if
if dtypes.Exists("MPI_UNSIGNED_LONG") then
	MPI_UNSIGNED_LONG = dtypes.Item("MPI_UNSIGNED_LONG")
else
	missing_datatypes = missing_datatypes & "MPI_UNSIGNED_LONG" & vbCrLf
	MPI_UNSIGNED_LONG     = "0x" + mpi_datatype_prefix + len_long        + "08"
end if
if dtypes.Exists("MPI_LONG_LONG") then
	MPI_LONG_LONG = dtypes.Item("MPI_LONG_LONG")
else
	missing_datatypes = missing_datatypes & "MPI_LONG_LONG" & vbCrLf
	MPI_LONG_LONG         = "0x" + mpi_datatype_prefix + len_long_long   + "09"
end if
if dtypes.Exists("MPI_LONG_LONG_INT") then
	MPI_LONG_LONG_INT = dtypes.Item("MPI_LONG_LONG_INT")
else
	'missing_datatypes = missing_datatypes & "MPI_LONG_LONG_INT" & vbCrLf
	'MPI_LONG_LONG_INT     = "0x" + mpi_datatype_prefix + len_long_long   + "09"
        if dtypes.Exists("MPI_LONG_LONG") then
            MPI_LONG_LONG_INT = dtypes.Item("MPI_LONG_LONG")
            dtypes.Add "MPI_LONG_LONG_INT", MPI_LONG_LONG_INT
        else
            missing_datatypes = missing_datatypes & "MPI_LONG_LONG_INT" & vbCrLf
            MPI_LONG_LONG_INT = "0x" + mpi_datatype_prefix + len_long_long   + "09"
        end if
end if
if dtypes.Exists("MPI_UNSIGNED_LONG_LONG") then
	MPI_UNSIGNED_LONG_LONG = dtypes.Item("MPI_UNSIGNED_LONG_LONG")
else
	missing_datatypes = missing_datatypes & "MPI_UNSIGNED_LONG_LONG" & vbCrLf
	MPI_UNSIGNED_LONG_LONG ="0x" + mpi_datatype_prefix + len_long_long   + "19"
end if
if dtypes.Exists("MPI_FLOAT") then
	MPI_FLOAT = dtypes.Item("MPI_FLOAT")
else
	missing_datatypes = missing_datatypes & "MPI_FLOAT" & vbCrLf
	MPI_FLOAT             = "0x" + mpi_datatype_prefix + len_float       + "0a"
end if
if dtypes.Exists("MPI_DOUBLE") then
	MPI_DOUBLE = dtypes.Item("MPI_DOUBLE")
else
	missing_datatypes = missing_datatypes & "MPI_DOUBLE" & vbCrLf
	MPI_DOUBLE            = "0x" + mpi_datatype_prefix + len_double      + "0b"
end if
if dtypes.Exists("MPI_LONG_DOUBLE") then
	MPI_LONG_DOUBLE = dtypes.Item("MPI_LONG_DOUBLE")
else
	missing_datatypes = missing_datatypes & "MPI_LONG_DOUBLE" & vbCrLf
	MPI_LONG_DOUBLE       = "0x" + mpi_datatype_prefix + len_long_double + "0c"
end if
if dtypes.Exists("MPI_PACKED") then
	MPI_PACKED = dtypes.Item("MPI_PACKED")
else
	missing_datatypes = missing_datatypes & "MPI_PACKED" & vbCrLf
	MPI_PACKED            = "0x" + mpi_datatype_prefix                 + "010f"
end if
if dtypes.Exists("MPI_LB") then
	MPI_LB = dtypes.Item("MPI_LB")
else
	missing_datatypes = missing_datatypes & "MPI_LB" & vbCrLf
	MPI_LB                = "0x" + mpi_datatype_prefix                 + "0010"
end if
if dtypes.Exists("MPI_UB") then
	MPI_UB = dtypes.Item("MPI_UB")
else
	missing_datatypes = missing_datatypes & "MPI_UB" & vbCrLf
	MPI_UB                = "0x" + mpi_datatype_prefix                 + "0011"
end if
if dtypes.Exists("MPI_REAL4") then
	MPI_REAL4 = dtypes.Item("MPI_REAL4")
else
	missing_datatypes = missing_datatypes & "MPI_REAL4" & vbCrLf
	MPI_REAL4             = "0x" + mpi_datatype_prefix                 + "0427"
end if
if dtypes.Exists("MPI_REAL8") then
	MPI_REAL8 = dtypes.Item("MPI_REAL8")
else
	missing_datatypes = missing_datatypes & "MPI_REAL8" & vbCrLf
	MPI_REAL8             = "0x" + mpi_datatype_prefix                 + "0829"
end if
if dtypes.Exists("MPI_REAL16") then
	MPI_REAL16 = dtypes.Item("MPI_REAL16")
else
	missing_datatypes = missing_datatypes & "MPI_REAL16" & vbCrLf
	MPI_REAL16            = "0x" + mpi_datatype_prefix                 + "1029"
end if
if dtypes.Exists("MPI_COMPLEX8") then
	MPI_COMPLEX8 = dtypes.Item("MPI_COMPLEX8")
else
	missing_datatypes = missing_datatypes & "MPI_COMPLEX8" & vbCrLf
	MPI_COMPLEX8          = "0x" + mpi_datatype_prefix                 + "0828"
end	if
if dtypes.Exists("MPI_COMPLEX16") then
	MPI_COMPLEX16 = dtypes.Item("MPI_COMPLEX16")
else
	missing_datatypes = missing_datatypes & "MPI_COMPLEX16" & vbCrLf
	MPI_COMPLEX16         = "0x" + mpi_datatype_prefix                 + "102b"
end if
if dtypes.Exists("MPI_COMPLEX32") then
	MPI_COMPLEX32 = dtypes.Item("MPI_COMPLEX32")
else
	missing_datatypes = missing_datatypes & "MPI_COMPLEX32" & vbCrLf
	MPI_COMPLEX32         = "0x" + mpi_datatype_prefix                 + "2030"
end if
if dtypes.Exists("MPI_INTEGER1") then
	MPI_INTEGER1 = dtypes.Item("MPI_INTEGER1")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER1" & vbCrLf
	MPI_INTEGER1          = "0x" + mpi_datatype_prefix                 + "012d"
end if
if dtypes.Exists("MPI_INTEGER2") then
	MPI_INTEGER2 = dtypes.Item("MPI_INTEGER2")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER2" & vbCrLf
	MPI_INTEGER2          = "0x" + mpi_datatype_prefix                 + "022f"
end if
if dtypes.Exists("MPI_INTEGER4") then
	MPI_INTEGER4 = dtypes.Item("MPI_INTEGER4")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER4" & vbCrLf
	MPI_INTEGER4          = "0x" + mpi_datatype_prefix                 + "0430"
end if
if dtypes.Exists("MPI_INTEGER8") then
	MPI_INTEGER8 = dtypes.Item("MPI_INTEGER8")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER8" & vbCrLf
	MPI_INTEGER8          = "0x" + mpi_datatype_prefix                 + "082a"
end if
if dtypes.Exists("MPI_INTEGER16") then
	MPI_INTEGER16 = dtypes.Item("MPI_INTEGER16")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER16" & vbCrLf
	MPI_INTEGER16         = "0x" + mpi_datatype_prefix                 + "102f"
end if
if dtypes.Exists("MPI_FLOAT_INT") then
	MPI_FLOAT_INT = dtypes.Item("MPI_FLOAT_INT")
else
	'missing_datatypes = missing_datatypes & "MPI_FLOAT_INT" & vbCrLf
	'MPI_FLOAT_INT         = "0x" + mpi_datatype_prefix + len_float_int       + "12"
	MPI_FLOAT_INT         = "0x8c000000"
        dtypes.Add "MPI_FLOAT_INT", MPI_FLOAT_INT
end if
if dtypes.Exists("MPI_DOUBLE_INT") then
	MPI_DOUBLE_INT = dtypes.Item("MPI_DOUBLE_INT")
else
	'missing_datatypes = missing_datatypes & "MPI_DOUBLE_INT" & vbCrLf
	'MPI_DOUBLE_INT        = "0x" + mpi_datatype_prefix + len_double_int      + "13"
	MPI_DOUBLE_INT        = "0x8c000001"
        dtypes.Add "MPI_DOUBLE_INT", MPI_DOUBLE_INT
end if
if dtypes.Exists("MPI_LONG_INT") then
	MPI_LONG_INT = dtypes.Item("MPI_LONG_INT")
else
	'missing_datatypes = missing_datatypes & "MPI_LONG_INT" & vbCrLf
	'MPI_LONG_INT          = "0x" + mpi_datatype_prefix + len_long_int        + "14"
	MPI_LONG_INT          = "0x8c000002"
        dtypes.Add "MPI_LONG_INT", MPI_LONG_INT
end if
if dtypes.Exists("MPI_SHORT_INT") then
	MPI_SHORT_INT = dtypes.Item("MPI_SHORT_INT")
else
	'missing_datatypes = missing_datatypes & "MPI_SHORT_INT" & vbCrLf
	'MPI_SHORT_INT         = "0x" + mpi_datatype_prefix + len_short_int       + "15"
	MPI_SHORT_INT         = "0x8c000003"
        dtypes.Add "MPI_SHORT_INT", MPI_SHORT_INT
end if
if dtypes.Exists("MPI_2INT") then
	MPI_2INT = dtypes.Item("MPI_2INT")
else
	missing_datatypes = missing_datatypes & "MPI_2INT" & vbCrLf
	MPI_2INT              = "0x" + mpi_datatype_prefix + len_two_int          + "16"
end if
if dtypes.Exists("MPI_LONG_DOUBLE_INT") then
	MPI_LONG_DOUBLE_INT = dtypes.Item("MPI_LONG_DOUBLE_INT")
else
	'missing_datatypes = missing_datatypes & "MPI_LONG_DOUBLE_INT" & vbCrLf
	'MPI_LONG_DOUBLE_INT   = "0x" + mpi_datatype_prefix + len_long_double_int + "17"
	MPI_LONG_DOUBLE_INT   = "0x8c000004"
        dtypes.Add "MPI_LONG_DOUBLE_INT", MPI_LONG_DOUBLE_INT
end if
if dtypes.Exists("MPI_CHARACTER") then
	MPI_CHARACTER = dtypes.Item("MPI_CHARACTER")
else
	missing_datatypes = missing_datatypes & "MPI_CHARACTER" & vbCrLf
	MPI_CHARACTER         = "0x" + mpi_datatype_prefix                + "011a"
end if
' Win32 versions
if dtypes.Exists("MPI_INTEGER") then
	MPI_INTEGER_W32 = dtypes.Item("MPI_INTEGER")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER" & vbCrLf
	MPI_INTEGER_W32           = "0x" + mpi_datatype_prefix + len_integer    + "1b"
end if
if dtypes.Exists("MPI_REAL") then
	MPI_REAL_W32 = dtypes.Item("MPI_REAL")
else
	missing_datatypes = missing_datatypes & "MPI_REAL" & vbCrLf
	MPI_REAL_W32              = "0x" + mpi_datatype_prefix + len_integer    + "1c"
end if
if dtypes.Exists("MPI_LOGICAL") then
	MPI_LOGICAL_W32 = dtypes.Item("MPI_LOGICAL")
else
	missing_datatypes = missing_datatypes & "MPI_LOGICAL" & vbCrLf
	MPI_LOGICAL_W32           = "0x" + mpi_datatype_prefix + len_integer    + "1d"
end if
' Win64 versions
if dtypes64.Exists("MPI_INTEGER") then
	MPI_INTEGER_W64 = dtypes64.Item("MPI_INTEGER")
else
	missing_datatypes = missing_datatypes & "MPI_INTEGER" & vbCrLf
	MPI_INTEGER_W64           = "0x" + mpi_datatype_prefix + len_integer    + "1b"
end if
if dtypes64.Exists("MPI_REAL") then
	MPI_REAL_W64 = dtypes64.Item("MPI_REAL")
else
	missing_datatypes = missing_datatypes & "MPI_REAL" & vbCrLf
	MPI_REAL_W64              = "0x" + mpi_datatype_prefix + len_integer    + "1c"
end if
if dtypes64.Exists("MPI_LOGICAL") then
	MPI_LOGICAL_W64 = dtypes64.Item("MPI_LOGICAL")
else
	missing_datatypes = missing_datatypes & "MPI_LOGICAL" & vbCrLf
	MPI_LOGICAL_W64           = "0x" + mpi_datatype_prefix + len_integer    + "1d"
end if
' end versions
if dtypes.Exists("MPI_COMPLEX") then
	MPI_COMPLEX = dtypes.Item("MPI_COMPLEX")
else
	missing_datatypes = missing_datatypes & "MPI_COMPLEX" & vbCrLf
	MPI_COMPLEX           = "0x" + mpi_datatype_prefix + len_double     + "1e"
end if
if dtypes.Exists("MPI_DOUBLE_PRECISION") then
	MPI_DOUBLE_PRECISION = dtypes.Item("MPI_DOUBLE_PRECISION")
else
	missing_datatypes = missing_datatypes & "MPI_DOUBLE_PRECISION" & vbCrLf
	MPI_DOUBLE_PRECISION  = "0x" + mpi_datatype_prefix + len_double     + "1f"
end if
if dtypes.Exists("MPI_2INTEGER") then
	MPI_2INTEGER = dtypes.Item("MPI_2INTEGER")
else
	missing_datatypes = missing_datatypes & "MPI_2INTEGER" & vbCrLf
	MPI_2INTEGER          = "0x" + mpi_datatype_prefix + len_double     + "20"
end if
if dtypes.Exists("MPI_2REAL") then
	MPI_2REAL = dtypes.Item("MPI_2REAL")
else
	missing_datatypes = missing_datatypes & "MPI_2REAL" & vbCrLf
	MPI_2REAL             = "0x" + mpi_datatype_prefix + len_double     + "21"
end if
if dtypes.Exists("MPI_DOUBLE_COMPLEX") then
	MPI_DOUBLE_COMPLEX = dtypes.Item("MPI_DOUBLE_COMPLEX")
else
	missing_datatypes = missing_datatypes & "MPI_DOUBLE_COMPLEX" & vbCrLf
	MPI_DOUBLE_COMPLEX    = "0x" + mpi_datatype_prefix + len_doublecplx + "22"
end if
if dtypes.Exists("MPI_2DOUBLE_PRECISION") then
	MPI_2DOUBLE_PRECISION = dtypes.Item("MPI_2DOUBLE_PRECISION")
else
	missing_datatypes = missing_datatypes & "MPI_2DOUBLE_PRECISION" & vbCrLf
	MPI_2DOUBLE_PRECISION = "0x" + mpi_datatype_prefix + len_doublecplx + "23"
end if
if dtypes.Exists("MPI_2COMPLEX") then
	MPI_2COMPLEX = dtypes.Item("MPI_2COMPLEX")
else
	missing_datatypes = missing_datatypes & "MPI_2COMPLEX" & vbCrLf
	MPI_2COMPLEX          = "0x" + mpi_datatype_prefix + len_doublecplx + "24"
end if
if dtypes.Exists("MPI_2DOUBLE_COMPLEX") then
	MPI_2DOUBLE_COMPLEX = dtypes.Item("MPI_2DOUBLE_COMPLEX")
else
	missing_datatypes = missing_datatypes & "MPI_2DOUBLE_COMPLEX" & vbCrLf
	MPI_2DOUBLE_COMPLEX   = "0x" + mpi_datatype_prefix + len_2dc        + "25"
end if

' Special C++ Datatypes to support Fortran datatypes within C++ 
MPIR_CXX_BOOL 			= "0x" + mpi_datatype_prefix + len_bool 		+ "33"
MPIR_CXX_COMPLEX		= "0x" + mpi_datatype_prefix + len_complex		+ "34"
MPIR_CXX_DOUBLE_COMPLEX 	= "0x" + mpi_datatype_prefix + len_double_complex	+ "35"
MPIR_CXX_LONG_DOUBLE_COMPLEX	= "0x" + mpi_datatype_prefix + len_long_double_complex	+ "36"

' Fixed width types
if dtypes.Exists("MPI_INT8_T") then
    MPI_INT8_T = dtypes.Item("MPI_INT8_T")
else
    missing_datatypes = missing_datatypes & "MPI_INT8_T" & vbCrLf
    MPI_INT8_T = "0x" + mpi_datatype_prefix + "01" + "37"
end if
if dtypes.Exists("MPI_INT16_T") then
    MPI_INT16_T = dtypes.Item("MPI_INT16_T")
else
    missing_datatypes = missing_datatypes & "MPI_INT16_T" & vbCrLf
    MPI_INT16_T = "0x" + mpi_datatype_prefix + "02" + "38"
end if
if dtypes.Exists("MPI_INT32_T") then
    MPI_INT32_T = dtypes.Item("MPI_INT32_T")
else
    missing_datatypes = missing_datatypes & "MPI_INT32_T" & vbCrLf
    MPI_INT32_T = "0x" + mpi_datatype_prefix + "04" + "39"
end if
if dtypes.Exists("MPI_INT64_T") then
    MPI_INT64_T = dtypes.Item("MPI_INT64_T")
else
    missing_datatypes = missing_datatypes & "MPI_INT64_T" & vbCrLf
    MPI_INT64_T = "0x" + mpi_datatype_prefix + "08" + "3a"
end if
if dtypes.Exists("MPI_UINT8_T") then
    MPI_UINT8_T = dtypes.Item("MPI_UINT8_T")
else
    missing_datatypes = missing_datatypes & "MPI_UINT8_T" & vbCrLf
    MPI_UINT8_T = "0x" + mpi_datatype_prefix + "01" + "3b"
end if
if dtypes.Exists("MPI_UINT16_T") then
    MPI_UINT16_T = dtypes.Item("MPI_UINT16_T")
else
    missing_datatypes = missing_datatypes & "MPI_UINT16_T" & vbCrLf
    MPI_UINT16_T = "0x" + mpi_datatype_prefix + "02" + "3c"
end if
if dtypes.Exists("MPI_UINT32_T") then
    MPI_UINT32_T = dtypes.Item("MPI_UINT32_T")
else
    missing_datatypes = missing_datatypes & "MPI_UINT32_T" & vbCrLf
    MPI_UINT32_T = "0x" + mpi_datatype_prefix + "04" + "3d"
end if
if dtypes.Exists("MPI_UINT64_T") then
    MPI_UINT64_T = dtypes.Item("MPI_UINT64_T")
else
    missing_datatypes = missing_datatypes & "MPI_UINT64_T" & vbCrLf
    MPI_UINT64_T = "0x" + mpi_datatype_prefix + "08" + "3e"
end if
' C99 types
if dtypes.Exists("MPI_C_BOOL") then
    MPI_C_BOOL = dtypes.Item("MPI_C_BOOL")
else
    missing_datatypes = missing_datatypes & "MPI_C_BOOL" & vbCrLf
    MPI_C_BOOL = "0x" + mpi_datatype_prefix + len__Bool + "3f"
end if
if dtypes.Exists("MPI_C_FLOAT_COMPLEX") then
    MPI_C_FLOAT_COMPLEX = dtypes.Item("MPI_C_FLOAT_COMPLEX")
else
    missing_datatypes = missing_datatypes & "MPI_C_FLOAT_COMPLEX" & vbCrLf
    MPI_C_FLOAT_COMPLEX = "0x" + mpi_datatype_prefix + len_float__Complex + "40"
end if
if dtypes.Exists("MPI_C_COMPLEX") then
    MPI_C_COMPLEX = dtypes.Item("MPI_C_COMPLEX")
else
    if dtypes.Exists("MPI_C_FLOAT_COMPLEX") then
        MPI_C_COMPLEX = dtypes.Item("MPI_C_FLOAT_COMPLEX")
        dtypes.Add "MPI_C_COMPLEX", MPI_C_COMPLEX
    else
        missing_datatypes = missing_datatypes & "MPI_C_COMPLEX" & vbCrLf
        MPI_C_COMPLEX = "0x" + mpi_datatype_prefix + len_float__Complex + "40"
    end if
end if
if dtypes.Exists("MPI_C_DOUBLE_COMPLEX") then
    MPI_C_DOUBLE_COMPLEX = dtypes.Item("MPI_C_DOUBLE_COMPLEX")
else
    missing_datatypes = missing_datatypes & "MPI_C_DOUBLE_COMPLEX" & vbCrLf
    MPI_C_DOUBLE_COMPLEX = "0x" + mpi_datatype_prefix + len_double__Complex + "41"
end if
if dtypes.Exists("MPI_C_LONG_DOUBLE_COMPLEX") then
    MPI_C_LONG_DOUBLE_COMPLEX = dtypes.Item("MPI_C_LONG_DOUBLE_COMPLEX")
else
    missing_datatypes = missing_datatypes & "MPI_C_LONG_DOUBLE_COMPLEX" & vbCrLf
    MPI_C_LONG_DOUBLE_COMPLEX = "0x" + mpi_datatype_prefix + len_long_double__Complex + "42"
end if
' Note that in configure.in MPI_AINT is named as MPI_AINT_DATATYPE - due to name collision
if dtypes.Exists("MPI_AINT_DATATYPE") then
    MPI_AINT_W32 = dtypes.Item("MPI_AINT_DATATYPE")
else
    missing_datatypes = missing_datatypes & "MPI_AINT" & vbCrLf
    MPI_AINT_W32 = "0x" + mpi_datatype_prefix + len_mpi_aint32 + "43"
end if
dtypes.Add "MPI_AINT_W32", MPI_AINT_W32

if dtypes64.Exists("MPI_AINT_DATATYPE") then
    MPI_AINT_W64 = dtypes64.Item("MPI_AINT_DATATYPE")
else
    missing_datatypes = missing_datatypes & "MPI_AINT" & vbCrLf
    MPI_AINT_W64 = "0x" + mpi_datatype_prefix + len_mpi_aint64 + "43"
end if
dtypes64.Add "MPI_AINT_W64", MPI_AINT_W64

' Note that in configure.in MPI_OFFSET is named as MPI_OFFSET_DATATYPE - due to name collision
if dtypes.Exists("MPI_OFFSET_DATATYPE") then
    MPI_OFFSET_W64 = dtypes.Item("MPI_OFFSET_DATATYPE")
else
    missing_datatypes = missing_datatypes & "MPI_OFFSET" & vbCrLf
    MPI_OFFSET_W64 = "0x" + mpi_datatype_prefix + len_mpi_offset + "44"
end if
dtypes.Add "MPI_OFFSET_W64", MPI_OFFSET_W64
dtypes64.Add "MPI_OFFSET_W64", MPI_OFFSET_W64


if missing_datatypes <> "" then
	printMsg "ERROR", "Missing datatypes:" & vbCrLf & missing_datatypes
	printMsgFlush()
	WScript.Quit
end if

Function ToInteger(c)
	Dim i
	i = 0
	if c = "0" then i = 0 end if
	if c = "1" then i = 1 end if
	if c = "2" then i = 2 end if
	if c = "3" then i = 3 end if
	if c = "4" then i = 4 end if
	if c = "5" then i = 5 end if
	if c = "6" then i = 6 end if
	if c = "7" then i = 7 end if
	if c = "8" then i = 8 end if
	if c = "9" then i = 9 end if
	if c = "a" then i = 10 end if
	if c = "b" then i = 11 end if
	if c = "c" then i = 12 end if
	if c = "d" then i = 13 end if
	if c = "e" then i = 14 end if
	if c = "f" then i = 15 end if
	ToInteger = i
End Function

'first = true
Function HexToInt(str)
	Dim i, multiplier, index
	i = 0
	multiplier = 1
	for index = len(str) to 3 step -1
		i = i + (ToInteger(Mid(str, index, 1)) * multiplier)
		multiplier = multiplier * 16
		'if first then
		'	MsgBox "char " & Mid(str, index, 1) & ", i = " & i
		'end if
	next
	'first = false
	HexToInt = i
End Function

F77_MPI_DOUBLE_COMPLEX    = HexToInt(dtypes.Item("MPI_DOUBLE_COMPLEX"))
F77_MPI_COMPLEX           = HexToInt(dtypes.Item("MPI_COMPLEX"))
F77_MPI_LOGICAL_W32           = HexToInt(dtypes.Item("MPI_LOGICAL"))
F77_MPI_LOGICAL_W64           = HexToInt(dtypes64.Item("MPI_LOGICAL"))
F77_MPI_REAL_W32              = HexToInt(dtypes.Item("MPI_REAL"))
F77_MPI_REAL_W64              = HexToInt(dtypes64.Item("MPI_REAL"))
F77_MPI_DOUBLE_PRECISION  = HexToInt(dtypes.Item("MPI_DOUBLE_PRECISION"))
F77_MPI_INTEGER_W32           = HexToInt(dtypes.Item("MPI_INTEGER"))
F77_MPI_INTEGER_W64           = HexToInt(dtypes64.Item("MPI_INTEGER"))
F77_MPI_2INTEGER          = HexToInt(dtypes.Item("MPI_2INTEGER"))
F77_MPI_2COMPLEX          = HexToInt(dtypes.Item("MPI_2COMPLEX"))
F77_MPI_2DOUBLE_COMPLEX   = HexToInt(dtypes.Item("MPI_2DOUBLE_COMPLEX"))
F77_MPI_2REAL             = HexToInt(dtypes.Item("MPI_2REAL"))
F77_MPI_2DOUBLE_PRECISION = HexToInt(dtypes.Item("MPI_2DOUBLE_PRECISION"))
F77_MPI_CHARACTER         = HexToInt(dtypes.Item("MPI_CHARACTER"))
F77_MPI_BYTE              = HexToInt(dtypes.Item("MPI_BYTE"))
F77_MPI_LB                = HexToInt(dtypes.Item("MPI_LB"))
F77_MPI_PACKED            = HexToInt(dtypes.Item("MPI_PACKED"))
F77_MPI_UB                = HexToInt(dtypes.Item("MPI_UB"))
F77_COMPLEX8              = HexToInt(dtypes.Item("MPI_COMPLEX8"))
F77_COMPLEX16             = HexToInt(dtypes.Item("MPI_COMPLEX16"))
F77_COMPLEX32             = HexToInt(dtypes.Item("MPI_COMPLEX32"))
F77_INTEGER1              = HexToInt(dtypes.Item("MPI_INTEGER1"))
F77_INTEGER2              = HexToInt(dtypes.Item("MPI_INTEGER2"))
F77_INTEGER4              = HexToInt(dtypes.Item("MPI_INTEGER4"))
F77_INTEGER8              = HexToInt(dtypes.Item("MPI_INTEGER8"))
F77_INTEGER16             = HexToInt(dtypes.Item("MPI_INTEGER16"))
F77_REAL4                 = HexToInt(dtypes.Item("MPI_REAL4"))
F77_REAL8                 = HexToInt(dtypes.Item("MPI_REAL8"))
F77_REAL16                = HexToInt(dtypes.Item("MPI_REAL16"))
F77_CHAR					= HexToInt(dtypes.Item("MPI_CHAR"))
F77_SIGNED_CHAR				= HexToInt(dtypes.Item("MPI_SIGNED_CHAR"))
F77_UNSIGNED_CHAR			= HexToInt(dtypes.Item("MPI_UNSIGNED_CHAR"))
F77_WCHAR					= HexToInt(dtypes.Item("MPI_WCHAR"))
F77_SHORT					= HexToInt(dtypes.Item("MPI_SHORT"))
F77_UNSIGNED_SHORT			= HexToInt(dtypes.Item("MPI_UNSIGNED_SHORT"))
F77_INT						= HexToInt(dtypes.Item("MPI_INT"))
F77_UNSIGNED				= HexToInt(dtypes.Item("MPI_UNSIGNED"))
F77_LONG					= HexToInt(dtypes.Item("MPI_LONG"))
F77_UNSIGNED_LONG			= HexToInt(dtypes.Item("MPI_UNSIGNED_LONG"))
F77_FLOAT					= HexToInt(dtypes.Item("MPI_FLOAT"))
F77_DOUBLE					= HexToInt(dtypes.Item("MPI_DOUBLE"))
F77_LONG_DOUBLE				= HexToInt(dtypes.Item("MPI_LONG_DOUBLE"))
F77_LONG_LONG_INT			= HexToInt(dtypes.Item("MPI_LONG_LONG_INT"))
F77_UNSIGNED_LONG_LONG		= HexToInt(dtypes.Item("MPI_UNSIGNED_LONG_LONG"))
F77_LONG_LONG				= HexToInt(dtypes.Item("MPI_LONG_LONG"))
F77_FLOAT_INT				= HexToInt(dtypes.Item("MPI_FLOAT_INT"))
F77_DOUBLE_INT				= HexToInt(dtypes.Item("MPI_DOUBLE_INT"))
F77_LONG_INT				= HexToInt(dtypes.Item("MPI_LONG_INT"))
F77_SHORT_INT				= HexToInt(dtypes.Item("MPI_SHORT_INT"))
F77_2INT					= HexToInt(dtypes.Item("MPI_2INT"))
F77_LONG_DOUBLE_INT			= HexToInt(dtypes.Item("MPI_LONG_DOUBLE_INT"))
F77_INT8_T              = HexToInt(dtypes.Item("MPI_INT8_T"))
F77_INT16_T             = HexToInt(dtypes.Item("MPI_INT16_T"))
F77_INT32_T             = HexToInt(dtypes.Item("MPI_INT32_T"))
F77_INT64_T             = HexToInt(dtypes.Item("MPI_INT64_T"))
F77_UINT8_T             = HexToInt(dtypes.Item("MPI_UINT8_T"))
F77_UINT16_T            = HexToInt(dtypes.Item("MPI_UINT16_T"))
F77_UINT32_T            = HexToInt(dtypes.Item("MPI_UINT32_T"))
F77_UINT64_T            = HexToInt(dtypes.Item("MPI_UINT64_T"))
F77_C_BOOL              = HexToInt(dtypes.Item("MPI_C_BOOL"))
F77_C_FLOAT_COMPLEX     = HexToInt(dtypes.Item("MPI_C_FLOAT_COMPLEX"))
F77_C_COMPLEX           = HexToInt(dtypes.Item("MPI_C_COMPLEX"))
F77_C_DOUBLE_COMPLEX    = HexToInt(dtypes.Item("MPI_C_DOUBLE_COMPLEX"))
F77_C_LONG_DOUBLE_COMPLEX      = HexToInt(dtypes.Item("MPI_C_LONG_DOUBLE_COMPLEX"))
F77_AINT_W32                = HexToInt(dtypes.Item("MPI_AINT_W32"))
F77_AINT_W64                = HexToInt(dtypes64.Item("MPI_AINT_W64"))
F77_OFFSET_W64              = HexToInt(dtypes.Item("MPI_OFFSET_W64"))

if false then
foo = ""
foo = "F77_MPI_COMPLEX = " &                F77_MPI_COMPLEX          & vbCrLf
foo = foo & "F77_MPI_DOUBLE_COMPLEX = " &   F77_MPI_DOUBLE_COMPLEX   & vbCrLf
foo = foo & "F77_MPI_LOGICAL = " &          F77_MPI_LOGICAL          & vbCrLf
foo = foo & "F77_MPI_REAL = " &             F77_MPI_REAL             & vbCrLf
foo = foo & "F77_MPI_DOUBLE_PRECISION = " & F77_MPI_DOUBLE_PRECISION & vbCrLf
foo = foo & "F77_MPI_INTEGER = " &          F77_MPI_INTEGER          & vbCrLf
foo = foo & "F77_MPI_2INTEGER = " &         F77_MPI_2INTEGER         & vbCrLf
foo = foo & "F77_MPI_2COMPLEX = " &         F77_MPI_2COMPLEX         & vbCrLf
foo = foo & "F77_MPI_2DOUBLE_COMPLEX = " &  F77_MPI_2DOUBLE_COMPLEX  & vbCrLf
foo = foo & "F77_MPI_2REAL = " &            F77_MPI_2REAL            & vbCrLf
foo = foo & "F77_MPI_2DOUBLE_PRECISION = " & F77_MPI_2DOUBLE_PRECISION & vbCrLf
foo = foo & "F77_MPI_CHARACTER = " &        F77_MPI_CHARACTER        & vbCrLf
foo = foo & "F77_MPI_LB = " &               F77_MPI_LB               & vbCrLf
foo = foo & "F77_MPI_PACKED = " &           F77_MPI_PACKED           & vbCrLf
foo = foo & "F77_MPI_UB = " &               F77_MPI_UB               & vbCrLf
foo = foo & "F77_COMPLEX8 = " &             F77_COMPLEX8             & vbCrLf
foo = foo & "F77_COMPLEX16 = " &            F77_COMPLEX16            & vbCrLf
foo = foo & "F77_COMPLEX32 = " &            F77_COMPLEX32            & vbCrLf
foo = foo & "F77_INTEGER1 = " &             F77_INTEGER1             & vbCrLf
foo = foo & "F77_INTEGER2 = " &             F77_INTEGER2             & vbCrLf
foo = foo & "F77_INTEGER4 = " &             F77_INTEGER4             & vbCrLf
foo = foo & "F77_INTEGER8 = " &             F77_INTEGER8             & vbCrLf
foo = foo & "F77_INTEGER16 = " &            F77_INTEGER16            & vbCrLf
foo = foo & "F77_REAL4 = " &                F77_REAL4                & vbCrLf
foo = foo & "F77_REAL8 = " &                F77_REAL8                & vbCrLf
foo = foo & "F77_REAL16 = " &               F77_REAL16               & vbCrLf
'WScript.Echo foo
end if

Function DecorateMPIFuncs(str)
	' uncomment out the HAVE_EXPORTS_MPI_API block
	'str = ReplaceBetweenTags(str, "/*", "HAVE_EXPORT_MPI_API", "*/", "#ifdef MPICH2_STATIC_LIBRARY" & vbCrLf & "#define EXPORT_MPI_API" & vbCrLf & "#else" & vbCrLf & "#ifdef MPICH2_EXPORTS" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllexport)" & vbCrLf & "#else" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllimport)" & vbCrLf & "#endif" & vbCrLf & "#endif" & vbCrLf & "#ifndef MPI_CALL" & vbCrLf & "#define MPI_CALL __cdecl" & vbCrLf & "#endif" & vbCrLf)
	str = Replace(str, "/* --Insert Additional Definitions Here-- */", "#ifdef MPICH2_STATIC_LIBRARY" & vbCrLf & "#define EXPORT_MPI_API" & vbCrLf & "#else" & vbCrLf & "#ifdef MPICH2_EXPORTS" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllexport)" & vbCrLf & "#else" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllimport)" & vbCrLf & "#endif" & vbCrLf & "#endif" & vbCrLf & "#ifndef MPI_CALL" & vbCrLf & "#define MPI_CALL __cdecl" & vbCrLf & "#endif" & vbCrLf)
	' add dllspec and calling convention to the MPI api
	first_index = InStr(str, "#ifndef MPICH_SUPPRESS_PROTOTYPES")
	last_index = InStr(str, "#endif /* MPICH_SUPPRESS_PROTOTYPES */")
	if first_index <> 0 and last_index <> 0 then
		prototypes = Mid(str, first_index, last_index - first_index)
		prototypes = Replace(prototypes, "int MPI_", "EXPORT_MPI_API int MPI_CALL MPI_")
		prototypes = Replace(prototypes, "double PMPI_Wtime", "EXPORT_MPI_API double MPI_CALL PMPI_Wtime")
		prototypes = Replace(prototypes, "double PMPI_Wtick", "EXPORT_MPI_API double MPI_CALL PMPI_Wtick")
		prototypes = Replace(prototypes, "double MPI_Wtime", "EXPORT_MPI_API double MPI_CALL MPI_Wtime")
		prototypes = Replace(prototypes, "double MPI_Wtick", "EXPORT_MPI_API double MPI_CALL MPI_Wtick")
		str = ReplaceBetweenTags(str, "#ifndef MPICH_SUPPRESS_PROTOTYPES", "MPI_Send", "#endif /* MPICH_SUPPRESS_PROTOTYPES */", prototypes & "#endif /* MPICH_SUPPRESS_PROTOTYPES */")
	end if
	' add dllspec and calling convention to the PMPI api
	first_index = InStr(str, "#if !defined(MPI_BUILD_PROFILING)")
	last_index = InStr(str, "#endif  /* MPI_BUILD_PROFILING */")
	if first_index <> 0 and last_index <> 0 then
		prototypes = Mid(str, first_index, last_index - first_index)
		prototypes = Replace(prototypes, "int PMPI_", "EXPORT_MPI_API int MPI_CALL PMPI_")
		prototypes = Replace(prototypes, "double PMPI_Wtime", "EXPORT_MPI_API double MPI_CALL PMPI_Wtime")
		prototypes = Replace(prototypes, "double PMPI_Wtick", "EXPORT_MPI_API double MPI_CALL PMPI_Wtick")
		str = ReplaceBetweenTags(str, "#if", "MPI_BUILD_PROFILING", "#endif  /* MPI_BUILD_PROFILING */", prototypes & "#endif  /* MPI_BUILD_PROFILING */")
	end if
	DecorateMPIFuncs = str
End Function

'
' Get MPICH2 Version & ABI Version
'
Function GetMPICH2Versions(ByRef mpich2Version, ByRef mpich2ABIVersion)
    mpich2Version = "0.0"
    mpich2ABIVersion = "0.0"
    if f.FileExists("maint\Version") then
        Dim fin, str
        Set fin = f.OpenTextFile("maint\Version")
        Do Until fin.AtEndOfStream
            Dim strTokenArr
            str = fin.ReadLine()
            Trim(str)
            strTokenArr = Split(str, " ", -1 , 1)
            If UBound(strTokenArr, 1) = 1 Then
                If(StrComp(Left(strTokenArr(0), 14), "MPICH2_VERSION") = 0) Then
                    mpich2Version = strTokenArr(1)
                ElseIf(StrComp(Left(strTokenArr(0), 17), "MPICH2_ABIVERSION") = 0) Then
                    mpich2ABIVersion = Replace(strTokenArr(1), ":", ".")
                Else
                    printMsg "ERROR", "Invalid String """ & str & """ found in mpich2 Version file"
                End If
            Else
                printMsg "ERROR", "Invalid format in mpich2 Version file. Expected: ""MPICH2_VERSION_NAME MPICH2_VERSION"" format"
            End If
        Loop
        fin.Close()
    end if
    If (StrComp(mpich2Version, "0.0") <> 0) AND (StrComp(mpich2ABIVersion, "0.0") <> 0) Then
        GetMPICH2Versions = True
    Else
        GetMPICH2Versions = False
    End If
End Function

' Does the string contain only ints ?
Function IsIntString(str)
	Dim regExpObj, matchesCollection
	Set regExpObj = New regexp

	if IsNull(str) then
		IsIntString = False
		Exit Function
	end if
	if IsEmpty(str) then
		IsIntString = False
		Exit Function
	end if

	regExpObj.Pattern = "[^0-9]+"
	regExpObj.Global = True
	regExpObj.IgnoreCase = True
	Set matchesCollection = regExpObj.Execute(str)
	if matchesCollection.Count > 0 then
		IsIntString = False		
	else
		IsIntString = True
	end if
End Function

' Produce a numeric version assuming the following format:
' Version: [MAJ].[MIN].[REV][EXT][EXT_NUMBER]
'                 or
' Version: [MAJ].[MIN].[REV] 
' Example: 1.0.7rc1 has
'          MAJ = 1
'          MIN = 0
'          REV = 7
'          EXT = rc
'          EXT_NUMBER = 1
'
'			1.0.7 has EXT converted to 0 and EXT_NUMBER = 0
'
' Converting to numeric version will convert EXT to a format number:
'          ALPHA (a) = 0
'          BETA (b)  = 1
'          RC (rc)   = 2
'          PATCH (p) = 3
' Regular releases are treated as patch 0
'
' Numeric version will have 1 digit for MAJ, 2 digits for MIN,
' 2 digits for REV, 1 digit for EXT and 2 digits for EXT_NUMBER.
' eg: 1.0.7rc2 = 10007202
' We also support version numbers with a missing REV number like
'   [MAJ].[MIN][EXT][EXT_NUMBER]

Function GetMPICH2NumVersion(ver)
	Dim verTokenArray, numVer, majorVer, minorVer, revNum, ext, extNum, tmpStr
	Dim verTokenArrayIndex, verTokenArrayLastIndex, minorOrRevNum
	Dim regExpObj, matchesCollection, verHasRev, verHasExt
	Set regExpObj = New regexp
	regExpObj.Global = True
	regExpObj.IgnoreCase = True

	GetMPICH2NumVersion = 0
	verTokenArrayIndex = 0
	verTokenArray = Split(ver, ".", -1, 1)
        verTokenArrayLastIndex = UBound(verTokenArray, 1)
	if((verTokenArrayLastIndex > 2) Or (verTokenArrayLastIndex < 1)) then
		printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1/1.0rc1"
		Exit Function
	end if 
'       Initially we assume all versions have [REV] & [EXT] and then verify as we parse the version
'       All valid versions have [MAJ] & [MIN] numbers so we don't need to track them
        verHasRev = True
        verHasExt = True

	majorVer = verTokenArray(verTokenArrayIndex)
	verTokenArrayIndex = verTokenArrayIndex + 1
	if (Len(majorVer) = 1) then
		if Not IsIntString(majorVer) then
			printMsg "ERROR","Error: " & ver & " not in expected format - eg: 1.0.7rc1"
			printMsg "ERROR", "Major version :" & majorVer & " is not an int"
			GetMPICH2NumVersion = 0
			Exit Function
		end if
	else
		printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
		printMsg "ERROR", "Major ver not in range [0-9]"
		GetMPICH2NumVersion = 0
		Exit Function
	end if
	
	minorVer = verTokenArray(verTokenArrayIndex)
'   The field for minorVer also could contain the EXT/EXT_NUM in case revNum is not present
	if Not ((Len(minorVer) < 0) Or (Len(minorVer) > 6)) then
		if IsIntString(minorVer) then
'                       The field for minor version does not contain [EXT]
			if(minorVer <= 9) then
				minorVer = "0" & Right(minorVer, 1)
			end if 
			verTokenArrayIndex = verTokenArrayIndex + 1
                        if(verTokenArrayIndex > verTokenArrayLastIndex) then
'                           The MPICH2 version only has a [MAJ] & [MIN] version numbers
                            verHasRev = False
                            verHasExt = False
                        else
'                           Something more in verTokenArray to parse...there has to be the [REV] number
			    verHasRev = True
                        end if
		else
'                       The MPICH2 version has no rev number, the field for minor ver contains [EXT]
			verHasRev = False
                        verHasExt = True
		end if
	else
		printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
		printMsg "ERROR", "Minor ver not in range [0-99]"
		Exit Function
	end if


        if(verHasExt) then
            regExpObj.Pattern = "[^0-9]+"
            Set matchesCollection = regExpObj.Execute(verTokenArray(verTokenArrayIndex))
            if(matchesCollection.Count = 1) then
                    tmpStr = matchesCollection(0)
                    verHasExt = True			
                    select case tmpStr
                            case "a"
                                    ext = 0
                            case "b"
                                    ext = 1
                            case "rc"
                                    ext = 2
                            case "p"
                                    ext = 3
                            case Else
                                    verHasExt = False
                    end select
            else
                    verHasExt = False
            end if 
        end if

        if(verHasRev Or verHasExt) then
            regExpObj.Pattern = "[0-9]+"
            Set matchesCollection = regExpObj.Execute(verTokenArray(verTokenArrayIndex))
            if matchesCollection.Count = 0 then
                    printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
                    printMsg "ERROR", "No revision num specified"
                    Exit Function
            end if

'           If MPICH2 ver has [REV] we are parsing [REV][EXT][EXT_NUM]
'           If MPICH2 ver does not have [REV], but has [EXT], we are parsing [MIN][EXT][EXT_NUM]
            minorOrRevNum = matchesCollection(0)
            if Not ((Len(minorOrRevNum) < 0) Or (Len(minorOrRevNum) > 2)) then
                    if IsIntString(minorOrRevNum) then
                            if( minorOrRevNum <= 9) then
                                    minorOrRevNum = "0" & Right(minorOrRevNum, 1)
                            end if
                    else
                            printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
                            printMsg "ERROR", "Revision number: " & minorOrRevNum & " not an int"
                            Exit Function
                    end if
            else
                    printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
                    printMsg "ERROR", "Rev no not in range [0-99]"
                    Exit Function
            end if
            if verHasRev then
                    revNum = minorOrRevNum
            else
                    minorVer = minorOrRevNum
                    revNum = "00"
            end if	
        else
            if Not verHasRev then
                revNum = "00"
            end if
        end if
	
	if verHasExt then
'		There has to be an extension number
		if(matchesCollection.Count = 2) then
			extNum = matchesCollection(1)
			if (Len(extNum) > 0) And (Len(extNum) < 3) then
				if Not IsIntString(extNum) then
					printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
					printMsg "ERROR", "Extension number : " & extNum & " is not an int"
					Exit Function
				else
					if(extNum <= 9) then
						extNum = "0" & Right(extNum, 1)
					end if
				end if
			else
				printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
				printMsg "ERROR", "Extension number no in range [0-99]"
				Exit Function
			end if 
		else
			printMsg "ERROR", "Error: " & ver & " not in expected format - eg: 1.0.7rc1"
			printMsg "ERROR", "No version extension number provided"
			Exit Function
		end if
        else
            ext = "0"
            extNum = "00"
	end if

	numVer = majorVer & minorVer & revNum & ext & extNum
	GetMPICH2NumVersion = 0 + numVer
	printMsg "VERBOSE", " MPICH2 NUM VERSION " & numVer
End Function

GetMPICH2Versions mpich2Version, mpich2ABIVersion
printMsg "VERBOSE", "MPICH2_VERSION = " & mpich2Version & " MPICH2_ABIVERSION = " & mpich2ABIVersion
mpich2NumVersion = GetMPICH2NumVersion(mpich2Version)

Function RegExpFind(pattern, str)
   Dim regEx, Match, Matches           ' Create variable.
   Set regEx = New RegExp              ' Create a regular expression.
   regEx.Pattern = pattern             ' Set pattern.
   regEx.IgnoreCase = True             ' Set case insensitivity.
   regEx.Global = True                 ' Set global applicability.
   Set Matches = regEx.Execute(str)    ' Execute search.
   For Each Match in Matches           ' Return the first match
      RegExpFind = Match.Value
      Exit For
   Next
End Function

' Append appendString to origString only if appendString is not
' already present in origString

Function appendUniqueString(ByRef origString, ByVal appendString) 
	Dim regExpObj, matchesCollection
	Set regExpObj = New regexp
	regExpObj.Pattern = Trim(appendString) & vbNewLine
	regExpObj.Global  = True
	regExpObj.IgnoreCase = False
	
	Set matchesCollection = regExpObj.Execute(origString)
	If(matchesCollection.Count = 0) Then
		origString = origString & appendString & vbNewLine
		appendUniqueString = True
	Else
		appendUniqueString = False
	End If
End Function

Function ReplaceAts( str, use_f77, b64 )
	Dim regEx, Match, Matches
	Set regEx = New RegExp
	regEx.Pattern = "@.[0-9a-z_]*@"
	regEx.IgnoreCase = True
	regEx.Global = True
	Set Matches = regEx.Execute(str)
	For Each Match in Matches
		Select Case Match
			Case "@MPI_CHAR@"
				str = Replace(str, "@MPI_CHAR@", MPI_CHAR)
			Case "@MPI_SIGNED_CHAR@"
				str = Replace(str, "@MPI_SIGNED_CHAR@", MPI_SIGNED_CHAR)
			Case "@MPI_WCHAR@"
				str = Replace(str, "@MPI_WCHAR@", MPI_WCHAR)
			Case "@MPI_UNSIGNED_CHAR@"
				str = Replace(str, "@MPI_UNSIGNED_CHAR@", MPI_UNSIGNED_CHAR)
			Case "@MPI_SHORT@"
				str = Replace(str, "@MPI_SHORT@", MPI_SHORT)
			Case "@MPI_UNSIGNED_SHORT@"
				str = Replace(str, "@MPI_UNSIGNED_SHORT@", MPI_UNSIGNED_SHORT)
			Case "@MPI_INT@"
				str = Replace(str, "@MPI_INT@", MPI_INT)
			Case "@MPI_UNSIGNED@"
				str = Replace(str, "@MPI_UNSIGNED@", MPI_UNSIGNED)
			Case "@MPI_UNSIGNED_INT@"
				str = Replace(str, "@MPI_UNSIGNED_INT@", MPI_UNSIGNED)
			Case "@MPI_LONG@"
				str = Replace(str, "@MPI_LONG@", MPI_LONG)
			Case "@MPI_UNSIGNED_LONG@"
				str = Replace(str, "@MPI_UNSIGNED_LONG@", MPI_UNSIGNED_LONG)
			Case "@MPI_LONG_LONG@"
				str = Replace(str, "@MPI_LONG_LONG@", MPI_LONG_LONG)
			Case "@MPI_UNSIGNED_LONG_LONG@"
				str = Replace(str, "@MPI_UNSIGNED_LONG_LONG@", MPI_UNSIGNED_LONG_LONG)
			Case "@MPI_FLOAT@"
				str = Replace(str, "@MPI_FLOAT@", MPI_FLOAT)
			Case "@MPI_DOUBLE@"
				str = Replace(str, "@MPI_DOUBLE@", MPI_DOUBLE)
			Case "@MPI_LONG_DOUBLE@"
				str = Replace(str, "@MPI_LONG_DOUBLE@", MPI_LONG_DOUBLE)
			Case "@MPI_BYTE@"
				If use_f77 Then
					str = Replace(str, "@MPI_BYTE@", F77_MPI_BYTE)
				Else
					str = Replace(str, "@MPI_BYTE@", MPI_BYTE)
				End If
			Case "@MPI_WCHAR_T@"
				str = Replace(str, "@MPI_WCHAR_T@", MPI_WCHAR_T)
			Case "@MPI_PACKED@"
				If use_f77 Then
					str = Replace(str, "@MPI_PACKED@", F77_MPI_PACKED)
				Else
					str = Replace(str, "@MPI_PACKED@", MPI_PACKED)
				End If
			Case "@MPI_LB@"
				If use_f77 Then
					str = Replace(str, "@MPI_LB@", F77_MPI_LB)
				Else
					str = Replace(str, "@MPI_LB@", MPI_LB)
				End If
			Case "@MPI_UB@"
				If use_f77 Then
					str = Replace(str, "@MPI_UB@", F77_MPI_UB)
				Else
					str = Replace(str, "@MPI_UB@", MPI_UB)
				End If
			Case "@MPI_FLOAT_INT@"
				str = Replace(str, "@MPI_FLOAT_INT@", MPI_FLOAT_INT)
			Case "@MPI_DOUBLE_INT@"
				str = Replace(str, "@MPI_DOUBLE_INT@", MPI_DOUBLE_INT)
			Case "@MPI_LONG_INT@"
				str = Replace(str, "@MPI_LONG_INT@", MPI_LONG_INT)
			Case "@MPI_SHORT_INT@"
				str = Replace(str, "@MPI_SHORT_INT@", MPI_SHORT_INT)
			Case "@MPI_2INT@"
				str = Replace(str, "@MPI_2INT@", MPI_2INT)
			Case "@MPI_LONG_DOUBLE_INT@"
				str = Replace(str, "@MPI_LONG_DOUBLE_INT@", MPI_LONG_DOUBLE_INT)
			Case "@MPI_CHARACTER@"
				If use_f77 Then
					str = Replace(str, "@MPI_CHARACTER@", F77_MPI_CHARACTER)
				Else
					str = Replace(str, "@MPI_CHARACTER@", MPI_CHARACTER)
				End If
			Case "@MPI_INTEGER@"
				If b64 then
					If use_f77 Then
						str = Replace(str, "@MPI_INTEGER@", F77_MPI_INTEGER_W64)
					Else
						str = Replace(str, "@MPI_INTEGER@", MPI_INTEGER_W64)
					End If
				Else
					If use_f77 Then
						str = Replace(str, "@MPI_INTEGER@", F77_MPI_INTEGER_W32)
					Else
						str = Replace(str, "@MPI_INTEGER@", MPI_INTEGER_W32)
					End If
				End If
			Case "@MPI_REAL@"
				If b64 Then
					If use_f77 Then
						str = Replace(str, "@MPI_REAL@", F77_MPI_REAL_W64)
					Else
						str = Replace(str, "@MPI_REAL@", MPI_REAL_W64)
					End If
				Else
					If use_f77 Then
						str = Replace(str, "@MPI_REAL@", F77_MPI_REAL_W32)
					Else
						str = Replace(str, "@MPI_REAL@", MPI_REAL_W32)
					End If
				End If
			Case "@MPI_LOGICAL@"
				If b64 Then
					If use_f77 Then
						str = Replace(str, "@MPI_LOGICAL@", F77_MPI_LOGICAL_W64)
					Else
						str = Replace(str, "@MPI_LOGICAL@", MPI_LOGICAL_W64)
					End If
				Else
					If use_f77 Then
						str = Replace(str, "@MPI_LOGICAL@", F77_MPI_LOGICAL_W32)
					Else
						str = Replace(str, "@MPI_LOGICAL@", MPI_LOGICAL_W32)
					End If
				End If
			Case "@MPI_COMPLEX@"
				If use_f77 Then
					str = Replace(str, "@MPI_COMPLEX@", F77_MPI_COMPLEX)
				Else
					str = Replace(str, "@MPI_COMPLEX@", MPI_COMPLEX)
				End If
			Case "@MPI_DOUBLE_PRECISION@"
				If use_f77 Then
					str = Replace(str, "@MPI_DOUBLE_PRECISION@", F77_MPI_DOUBLE_PRECISION)
				Else
					str = Replace(str, "@MPI_DOUBLE_PRECISION@", MPI_DOUBLE_PRECISION)
				End If
			Case "@MPI_2INTEGER@"
				If use_f77 Then
					str = Replace(str, "@MPI_2INTEGER@", F77_MPI_2INTEGER)
				Else
					str = Replace(str, "@MPI_2INTEGER@", MPI_2INTEGER)
				End If
			Case "@MPI_2REAL@"
				If use_f77 Then
					str = Replace(str, "@MPI_2REAL@", F77_MPI_2REAL)
				Else
					str = Replace(str, "@MPI_2REAL@", MPI_2REAL)
				End If
			Case "@MPI_DOUBLE_COMPLEX@"
				If use_f77 Then
					str = Replace(str, "@MPI_DOUBLE_COMPLEX@", F77_MPI_DOUBLE_COMPLEX)
				Else
					str = Replace(str, "@MPI_DOUBLE_COMPLEX@", MPI_DOUBLE_COMPLEX)
				End If
			Case "@MPI_2DOUBLE_PRECISION@"
				If use_f77 Then
					str = Replace(str, "@MPI_2DOUBLE_PRECISION@", F77_MPI_2DOUBLE_PRECISION)
				Else
					str = Replace(str, "@MPI_2DOUBLE_PRECISION@", MPI_2DOUBLE_PRECISION)
				End If
			Case "@MPI_2COMPLEX@"
				If use_f77 Then
					str = Replace(str, "@MPI_2COMPLEX@", F77_MPI_2COMPLEX)
				else
					str = Replace(str, "@MPI_2COMPLEX@", MPI_2COMPLEX)
				End If
			Case "@MPI_2DOUBLE_COMPLEX@"
				if use_f77 Then
					str = Replace(str, "@MPI_2DOUBLE_COMPLEX@", F77_MPI_2DOUBLE_COMPLEX)
				Else
					str = Replace(str, "@MPI_2DOUBLE_COMPLEX@", MPI_2DOUBLE_COMPLEX)
				End If
			Case "@MPI_MAX_PROCESSOR_NAME@"
				str = Replace(str, "@MPI_MAX_PROCESSOR_NAME@", MPI_MAX_PROCESSOR_NAME)
			Case "@BSEND_OVERHEAD@"
				if b64 then
					str = Replace(str, "@BSEND_OVERHEAD@", BSEND_OVERHEAD64)
				else
					str = Replace(str, "@BSEND_OVERHEAD@", BSEND_OVERHEAD32)
				end if
			Case "@MPI_AINT@"
				if b64 then
					str = Replace(str, "@MPI_AINT@", MPI_AINT64)
				else
					str = Replace(str, "@MPI_AINT@", MPI_AINT32)
				end if
			Case "@MPI_AINT_DATATYPE@"
				if b64 then
					str = Replace(str, "@MPI_AINT_DATATYPE@", MPI_AINT_W64)
				else
					str = Replace(str, "@MPI_AINT_DATATYPE@", MPI_AINT_W32)
				end if
			Case "@MPI_AINT_FMT_DEC_SPEC@"
				if b64 then
					str = Replace(str, "@MPI_AINT_FMT_DEC_SPEC@", MPI_AINT64_FMT_DEC_SPEC)
				else
					str = Replace(str, "@MPI_AINT_FMT_DEC_SPEC@", MPI_AINT32_FMT_DEC_SPEC)
				end if
			Case "@MPI_AINT_FMT_HEX_SPEC@"
				if b64 then
					str = Replace(str, "@MPI_AINT_FMT_HEX_SPEC@", MPI_AINT64_FMT_HEX_SPEC)
				else
					str = Replace(str, "@MPI_AINT_FMT_HEX_SPEC@", MPI_AINT32_FMT_HEX_SPEC)
				end if
			Case "@MPI_FINT@"
				str = Replace(str, "@MPI_FINT@", MPI_FINT)
			Case "@MPI_OFFSET@"
				str = Replace(str, "@MPI_OFFSET@", MPI_OFFSET)
			Case "@MPI_OFFSET_DATATYPE@"
				str = Replace(str, "@MPI_OFFSET_DATATYPE@", MPI_OFFSET_W64)
			Case "@MPI_OFFSET_TYPEDEF@"
				str = Replace(str, "@MPI_OFFSET_TYPEDEF@", MPI_OFFSET_TYPEDEF)
                        Case "@MPI_INT8_T@"
                                str = Replace(str, "@MPI_INT8_T@", MPI_INT8_T)
                        Case "@MPI_INT16_T@"
                                str = Replace(str, "@MPI_INT16_T@", MPI_INT16_T)
                        Case "@MPI_INT32_T@"
                                str = Replace(str, "@MPI_INT32_T@", MPI_INT32_T)
                        Case "@MPI_INT64_T@"
                                str = Replace(str, "@MPI_INT64_T@", MPI_INT64_T)
                        Case "@MPI_UINT8_T@"
                                str = Replace(str, "@MPI_UINT8_T@", MPI_UINT8_T)
                        Case "@MPI_UINT16_T@"
                                str = Replace(str, "@MPI_UINT16_T@", MPI_UINT16_T)
                        Case "@MPI_UINT32_T@"
                                str = Replace(str, "@MPI_UINT32_T@", MPI_UINT32_T)
                        Case "@MPI_UINT64_T@"
                                str = Replace(str, "@MPI_UINT64_T@", MPI_UINT64_T)
                        Case "@MPI_C_BOOL@"
                                str = Replace(str, "@MPI_C_BOOL@", MPI_C_BOOL)
                        Case "@MPI_C_FLOAT_COMPLEX@"
                                str = Replace(str, "@MPI_C_FLOAT_COMPLEX@", MPI_C_FLOAT_COMPLEX)
                        Case "@MPI_C_DOUBLE_COMPLEX@"
                                str = Replace(str, "@MPI_C_DOUBLE_COMPLEX@", MPI_C_DOUBLE_COMPLEX)
                        Case "@MPI_C_LONG_DOUBLE_COMPLEX@"
                                str = Replace(str, "@MPI_C_LONG_DOUBLE_COMPLEX@", MPI_C_LONG_DOUBLE_COMPLEX)
			Case "@EXTRA_STATUS_DECL@"
				str = Replace(str, "@EXTRA_STATUS_DECL@", EXTRA_STATUS_DECL)
			Case "@HAVE_ROMIO@"
				str = Replace(str, "@HAVE_ROMIO@", HAVE_ROMIO)
			Case "@MPI_REAL4@"
				str = Replace(str, "@MPI_REAL4@", MPI_REAL4)
			Case "@MPI_REAL8@"
				str = Replace(str, "@MPI_REAL8@", MPI_REAL8)
			Case "@MPI_REAL16@"
				str = Replace(str, "@MPI_REAL16@", MPI_REAL16)
			Case "@MPI_COMPLEX8@"
				str = Replace(str, "@MPI_COMPLEX8@", MPI_COMPLEX8)
			Case "@MPI_COMPLEX16@"
				str = Replace(str, "@MPI_COMPLEX16@", MPI_COMPLEX16)
			Case "@MPI_COMPLEX32@"
				str = Replace(str, "@MPI_COMPLEX32@", MPI_COMPLEX32)
			Case "@MPI_INTEGER1@"
				str = Replace(str, "@MPI_INTEGER1@", MPI_INTEGER1)
			Case "@MPI_INTEGER2@"
				str = Replace(str, "@MPI_INTEGER2@", MPI_INTEGER2)
			Case "@MPI_INTEGER4@"
				str = Replace(str, "@MPI_INTEGER4@", MPI_INTEGER4)
			Case "@MPI_INTEGER8@"
				str = Replace(str, "@MPI_INTEGER8@", MPI_INTEGER8)
			Case "@MPI_INTEGER16@"
				str = Replace(str, "@MPI_INTEGER16@", MPI_INTEGER16)
			Case "@MPICH_TIMER_KIND@"
				If bUseCycleCounter Then
					str = Replace(str, "@MPICH_TIMER_KIND@", "USE_WIN86_CYCLE")
				Else
					str = Replace(str, "@MPICH_TIMER_KIND@", "USE_QUERYPERFORMANCECOUNTER")
				End If
			Case "@MPID_TIMER_TYPE@"
				If bUseCycleCounter Then
					str = Replace(str, "@MPID_TIMER_TYPE@", "unsigned __int64")
				Else
					str = Replace(str, "@MPID_TIMER_TYPE@", "LARGE_INTEGER")
				End If
			Case "@DEFINE_MPI_OFFSET@"
				'str = Replace(str, "@DEFINE_MPI_OFFSET@", "typedef __int64 MPI_Offset;")
				'str = Replace(str, "@DEFINE_MPI_OFFSET@", "#if defined(USE_GCC) || defined(__GNUC__)" + vbCrLf + "typedef long long MPI_Offset;" + vbCrLf + "#else" + vbCrLf + "typedef __int64 MPI_Offset;" + vbCrLf + "#endif")
				'str = Replace(str, "@DEFINE_MPI_OFFSET@", "typedef long long MPI_Offset;")
				str = Replace(str, "@DEFINE_MPI_OFFSET@", MPI_OFFSET_TYPEDEF)
			Case "@NEEDS_MPI_FINT@"
				str = Replace(str, "@NEEDS_MPI_FINT@", "")
			Case "@HAVE_MPI_INFO@"
				str = Replace(str, "@HAVE_MPI_INFO@", "#define HAVE_MPI_INFO")
			Case "@HAVE_MPI_DARRAY_SUBARRAY@"
				str = Replace(str, "@HAVE_MPI_DARRAY_SUBARRAY@", "")
			Case "@DEFINE_HAVE_MPI_GREQUEST@"
				str = Replace(str, "@DEFINE_HAVE_MPI_GREQUEST@", "#define HAVE_MPI_GREQUEST 1")
				'str = Replace(str, "@DEFINE_HAVE_MPI_GREQUEST@", "")
			Case "@ADDRESS_KIND@"
				If b64 then
					str = Replace(str, "@ADDRESS_KIND@", "8")
				Else
					str = Replace(str, "@ADDRESS_KIND@", "4")
				End If
			Case "@OFFSET_KIND@"
				str = Replace(str, "@OFFSET_KIND@", "8")
			Case "@F77_COMPLEX16@"
				str = Replace(str, "@F77_COMPLEX16@", F77_COMPLEX16)
			Case "@F77_COMPLEX32@"
				str = Replace(str, "@F77_COMPLEX32@", F77_COMPLEX32)
			Case "@F77_COMPLEX8@"
				str = Replace(str, "@F77_COMPLEX8@", F77_COMPLEX8)
			Case "@F77_INTEGER1@"
				str = Replace(str, "@F77_INTEGER1@", F77_INTEGER1)
			Case "@F77_INTEGER2@"
				str = Replace(str, "@F77_INTEGER2@", F77_INTEGER2)
			Case "@F77_INTEGER4@"
				str = Replace(str, "@F77_INTEGER4@", F77_INTEGER4)
			Case "@F77_INTEGER8@"
				str = Replace(str, "@F77_INTEGER8@", F77_INTEGER8)
			Case "@F77_INTEGER16@"
				str = Replace(str, "@F77_INTEGER16@", F77_INTEGER16)
			Case "@F77_REAL4@"
				str = Replace(str, "@F77_REAL4@", F77_REAL4)
			Case "@F77_REAL8@"
				str = Replace(str, "@F77_REAL8@", F77_REAL8)
			Case "@F77_REAL16@"
				str = Replace(str, "@F77_REAL16@", F77_REAL16)
			Case "@MPI_F77_BYTE@"
				str = Replace(str, "@MPI_F77_BYTE@", F77_MPI_BYTE)
			Case "@MPI_F77_UB@"
				str = Replace(str, "@MPI_F77_UB@", F77_MPI_UB)
			Case "@MPI_F77_LB@"
				str = Replace(str, "@MPI_F77_LB@", F77_MPI_LB)
			Case "@MPI_F77_PACKED@"
				str = Replace(str, "@MPI_F77_PACKED@", F77_MPI_PACKED)
			Case "@MPI_F77_CHAR@"
				str = Replace(str, "@MPI_F77_CHAR@", F77_CHAR)
			Case "@MPI_F77_SIGNED_CHAR@"
				str = Replace(str, "@MPI_F77_SIGNED_CHAR@", F77_SIGNED_CHAR)
			Case "@MPI_F77_UNSIGNED_CHAR@"
				str = Replace(str, "@MPI_F77_UNSIGNED_CHAR@", F77_UNSIGNED_CHAR)
			Case "@MPI_F77_WCHAR@"
				str = Replace(str, "@MPI_F77_WCHAR@", F77_WCHAR)
			Case "@MPI_F77_SHORT@"
				str = Replace(str, "@MPI_F77_SHORT@", F77_SHORT)
			Case "@MPI_F77_UNSIGNED_SHORT@"
				str = Replace(str, "@MPI_F77_UNSIGNED_SHORT@", F77_UNSIGNED_SHORT)
			Case "@MPI_F77_INT@"
				str = Replace(str, "@MPI_F77_INT@", F77_INT)
			Case "@MPI_F77_UNSIGNED@"
				str = Replace(str, "@MPI_F77_UNSIGNED@", F77_UNSIGNED)
			Case "@MPI_F77_LONG@"
				str = Replace(str, "@MPI_F77_LONG@", F77_LONG)
			Case "@MPI_F77_UNSIGNED_LONG@"
				str = Replace(str, "@MPI_F77_UNSIGNED_LONG@", F77_UNSIGNED_LONG)
			Case "@MPI_F77_FLOAT@"
				str = Replace(str, "@MPI_F77_FLOAT@", F77_FLOAT)
			Case "@MPI_F77_DOUBLE@"
				str = Replace(str, "@MPI_F77_DOUBLE@", F77_DOUBLE)
			Case "@MPI_F77_LONG_DOUBLE@"
				str = Replace(str, "@MPI_F77_LONG_DOUBLE@", F77_LONG_DOUBLE)
			Case "@MPI_F77_LONG_LONG_INT@"
				str = Replace(str, "@MPI_F77_LONG_LONG_INT@", F77_LONG_LONG_INT)
			Case "@MPI_F77_UNSIGNED_LONG_LONG@"
				str = Replace(str, "@MPI_F77_UNSIGNED_LONG_LONG@", F77_UNSIGNED_LONG_LONG)
			Case "@MPI_F77_LONG_LONG@"
				str = Replace(str, "@MPI_F77_LONG_LONG@", F77_LONG_LONG)
			Case "@MPI_F77_FLOAT_INT@"
				str = Replace(str, "@MPI_F77_FLOAT_INT@", F77_FLOAT_INT)
			Case "@MPI_F77_DOUBLE_INT@"
				str = Replace(str, "@MPI_F77_DOUBLE_INT@", F77_DOUBLE_INT)
			Case "@MPI_F77_LONG_INT@"
				str = Replace(str, "@MPI_F77_LONG_INT@", F77_LONG_INT)
			Case "@MPI_F77_SHORT_INT@"
				str = Replace(str, "@MPI_F77_SHORT_INT@", F77_SHORT_INT)
			Case "@MPI_F77_2INT@"
				str = Replace(str, "@MPI_F77_2INT@", F77_2INT)
			Case "@MPI_F77_LONG_DOUBLE_INT@"
				str = Replace(str, "@MPI_F77_LONG_DOUBLE_INT@", F77_LONG_DOUBLE_INT)
			Case "@MPI_F77_INT8_T@"
				str = Replace(str, "@MPI_F77_INT8_T@", F77_INT8_T)
			Case "@MPI_F77_INT16_T@"
				str = Replace(str, "@MPI_F77_INT16_T@", F77_INT16_T)
			Case "@MPI_F77_INT32_T@"
				str = Replace(str, "@MPI_F77_INT32_T@", F77_INT32_T)
			Case "@MPI_F77_INT64_T@"
				str = Replace(str, "@MPI_F77_INT64_T@", F77_INT64_T)
			Case "@MPI_F77_UINT8_T@"
				str = Replace(str, "@MPI_F77_UINT8_T@", F77_UINT8_T)
			Case "@MPI_F77_UINT16_T@"
				str = Replace(str, "@MPI_F77_UINT16_T@", F77_UINT16_T)
			Case "@MPI_F77_UINT32_T@"
				str = Replace(str, "@MPI_F77_UINT32_T@", F77_UINT32_T)
			Case "@MPI_F77_UINT64_T@"
				str = Replace(str, "@MPI_F77_UINT64_T@", F77_UINT64_T)
			Case "@MPI_F77_C_BOOL@"
				str = Replace(str, "@MPI_F77_C_BOOL@", F77_C_BOOL)
			Case "@MPI_F77_C_FLOAT_COMPLEX@"
				str = Replace(str, "@MPI_F77_C_FLOAT_COMPLEX@", F77_C_FLOAT_COMPLEX)
			Case "@MPI_F77_C_COMPLEX@"
				str = Replace(str, "@MPI_F77_C_COMPLEX@", F77_C_COMPLEX)
			Case "@MPI_F77_C_DOUBLE_COMPLEX@"
				str = Replace(str, "@MPI_F77_C_DOUBLE_COMPLEX@", F77_C_DOUBLE_COMPLEX)
			Case "@MPI_F77_C_LONG_DOUBLE_COMPLEX@"
				str = Replace(str, "@MPI_F77_C_LONG_DOUBLE_COMPLEX@", F77_C_LONG_DOUBLE_COMPLEX)
			Case "@MPI_F77_AINT@"
                                If b64 Then
                                    str = Replace(str, "@MPI_F77_AINT@", F77_AINT_W64)
                                Else
                                    str = Replace(str, "@MPI_F77_AINT@", F77_AINT_W32)
                                End If
			Case "@MPI_F77_OFFSET@"
				str = Replace(str, "@MPI_F77_OFFSET@", F77_OFFSET_W64)
			Case "@MPI_STATUS_SIZE@"
				str = Replace(str, "@MPI_STATUS_SIZE@", "5")
			Case "@HAVE_CXX_EXCEPTIONS@"
				str = Replace(str, "@HAVE_CXX_EXCEPTIONS@", "1")
			Case "@F77_MPI_ADDRESS@"
				If b64 then
					str = Replace(str, "@F77_MPI_ADDRESS@", "INTEGER*8")
				Else
					str = Replace(str, "@F77_MPI_ADDRESS@", "INTEGER")
				End If
			Case "@F77_MPI_OFFSET@"
				If b64 then
					str = Replace(str, "@F77_MPI_OFFSET@", "INTEGER*8")
				Else
					str = Replace(str, "@F77_MPI_OFFSET@", "INTEGER (KIND=8)")
				End If
			' FIXME: The size of int,... could depend on compiler options
                        ' These defns, *F90*, are specific to the Intel Fortran Compiler on Windows.
                        ' These values may not work for say gfortran
                        ' We should have a way to override these values
			Case "@SIZEOF_F90_INTEGER@"
				If b64 then
					str = Replace(str, "@SIZEOF_F90_INTEGER@", "4")
				Else
					str = Replace(str, "@SIZEOF_F90_INTEGER@", "4")
				End If
			Case "@SIZEOF_F90_REAL@"
				If b64 then
					str = Replace(str, "@SIZEOF_F90_REAL@", "4")
				Else
					str = Replace(str, "@SIZEOF_F90_REAL@", "4")
				End If
			Case "@SIZEOF_F90_CHARACTER@"
				If b64 then
					str = Replace(str, "@SIZEOF_F90_CHARACTER@", "1")
				Else
					str = Replace(str, "@SIZEOF_F90_CHARACTER@", "1")
				End If
			Case "@SIZEOF_F90_DOUBLE_PRECISION@"
				If b64 then
					str = Replace(str, "@SIZEOF_F90_DOUBLE_PRECISION@", "8")
				Else
					str = Replace(str, "@SIZEOF_F90_DOUBLE_PRECISION@", "8")
				End If
                        ' Fortran real model in "precision, range" format
                        Case "@F90_REAL_MODEL@"
                            str = Replace(str, "@F90_REAL_MODEL@", "6 , 37")
                        ' Fortran double model in "precision, range" format
                        Case "@F90_DOUBLE_MODEL@"
                            str = Replace(str, "@F90_DOUBLE_MODEL@", "15 , 307")
                        ' Fortran integer model in "range1, kind1, range2, kind2, ..." format
                        Case "@F90_INTEGER_MODEL@"
                            str = Replace(str, "@F90_INTEGER_MODEL@", "2 , 1 , 4 , 2 , 9 , 4 , 18 , 8 ,")
                        ' Fortran integer model map in "{range1, kind1, size1}, {range2, kind2, size2}..." format
                        Case "@F90_INTEGER_MODEL_MAP@"
                            str = Replace(str, "@F90_INTEGER_MODEL_MAP@", "{ 2 , 1 , 1 }, { 4 , 2 , 2 }, { 9 , 4 , 4 }, { 18 , 8 , 8 },")
			' REQD = (Real EQuals Double precision) ? "!" : ""
			Case "@REQD@"
				str = Replace(str, "@REQD@", "")
			' REQI1 = (Real EQuals Integer*1) ? "!" : ""
			Case "@REQI1@"
				str = Replace(str, "@REQI1@", "")
			' REQI2 = (Real EQuals Integer*2) ? "!" : ""
			Case "@REQI2@"
				str = Replace(str, "@REQI2@", "")
			' REQI8 = (Real EQuals Integer*8) ? "!" : ""
			Case "@REQI8@"
				str = Replace(str, "@REQI8@", "")
			Case "@PCONTROL_LIST@"
				'str = Replace(str, "@PCONTROL_LIST@", "")
			Case "@configure_input@"
				'str = Replace(str, "@configure_input@", "")
			Case "@DLLIMPORT@"
				str = Replace(str, "@DLLIMPORT@", "CDEC$ ATTRIBUTES DLLIMPORT::/MPIPRIV1/" & vbNewLine & "CDEC$ ATTRIBUTES DLLIMPORT::/MPIPRIV2/" & vbNewLine & "CDEC$ ATTRIBUTES DLLIMPORT::/MPIPRIVC/")
			Case "@MPID_THREAD_TYPEDEFS@"
				str = Replace(str, "@MPID_THREAD_TYPEDEFS@", mpid_thread_typedefs)
			Case "@MPID_THREAD_FUNCS@"
				str = Replace(str, "@MPID_THREAD_FUNCS@", mpid_thread_funcs)
			Case "@MPIU_DLL_SPEC_DEF@"
				str = Replace(str, "@MPIU_DLL_SPEC_DEF@", mpi_dll_spec_definition)
			Case "@INCLUDE_MPICXX_H@"
				str = Replace(str, "@INCLUDE_MPICXX_H@", "#include ""mpicxx.h""")
			Case "@FORTRAN_BINDING@"
				str = Replace(str, "@FORTRAN_BINDING@", "1")
			Case "@INCLUDE_MPIDDEFS_H@"
				str = Replace(str, "@INCLUDE_MPIDDEFS_H@", "/* No device specific defs */")
			Case "@GNUC_VERSION@"
				str = Replace(str, "@GNUC_VERSION@", "0")
			Case "@GNUC_MINORVERSION@"
				str = Replace(str, "@GNUC_MINORVERSION@", "0")
			Case "@GNUCXX_VERSION@"
				str = Replace(str, "@GNUCXX_VERSION@", "0")
			Case "@GNUCXX_MINORVERSION@"
				str = Replace(str, "@GNUCXX_MINORVERSION@", "0")
			Case "@MPIR_CXX_BOOL@"
				str = Replace(str, "@MPIR_CXX_BOOL@", MPIR_CXX_BOOL)
			Case "@MPIR_CXX_COMPLEX@"
				str = Replace(str, "@MPIR_CXX_COMPLEX@", MPIR_CXX_COMPLEX)
			Case "@MPIR_CXX_DOUBLE_COMPLEX@"
				str = Replace(str, "@MPIR_CXX_DOUBLE_COMPLEX@", MPIR_CXX_DOUBLE_COMPLEX)
			Case "@MPIR_CXX_LONG_DOUBLE_COMPLEX@"
				str = Replace(str, "@MPIR_CXX_LONG_DOUBLE_COMPLEX@", MPIR_CXX_LONG_DOUBLE_COMPLEX)
			Case "@FORTRAN_MPI_OFFSET@"
				str = Replace(str, "@FORTRAN_MPI_OFFSET@", "INTEGER *8")
			Case "@mpe_c99_stdint_inc@"
				str = Replace(str, "@mpe_c99_stdint_inc@", "/* #include <stdint.h> */")
			Case "@mpe_c99_pridxx_inc@"
				str = Replace(str, "@mpe_c99_pridxx_inc@", "/* #include <inttypes.h> */")
			Case "@mpe_int8_t@"
				str = Replace(str, "@mpe_int8_t@", "__int8")
			Case "@mpe_int16_t@"
				str = Replace(str, "@mpe_int16_t@", "__int16")
			Case "@mpe_int32_t@"
				str = Replace(str, "@mpe_int32_t@", "__int32")
			Case "@mpe_int64_t@"
				str = Replace(str, "@mpe_int64_t@", "__int64")
			Case "@mpe_int8_fmt@"
				str = Replace(str, "@mpe_int8_fmt@", """%hhd""")
			Case "@mpe_int16_fmt@"
				str = Replace(str, "@mpe_int16_fmt@", """%hd""")
			Case "@mpe_int32_fmt@"
				str = Replace(str, "@mpe_int32_fmt@", """%ld""")
			Case "@mpe_int64_fmt@"
				str = Replace(str, "@mpe_int64_fmt@", """%lld""")
			Case "@CLOG_PINT@"
				If b64 Then
					str = Replace(str, "@CLOG_PINT@", "__int64")
				Else
					str = Replace(str, "@CLOG_PINT@", "__int32")
				End If
			Case "@PTHREAD_IN_MPI_DEF@"
				str = Replace(str, "@PTHREAD_IN_MPI_DEF@", "#undef HAVE_PTHREAD_IN_MPI")
			Case "@mpe_callstack_impl_type@"
				str = Replace(str, "@mpe_callstack_impl_type@", "/* MPE CALLSTACK NOT IMPLEMENTED IN WINDOWS */")
			Case "@mpe_callstack_string_h@"
				str = Replace(str, "@mpe_callstack_string_h@", "/* MPE CALLSTACK NOT IMPLEMENTED IN WINDOWS */")
			Case "@mpe_callstack_unistd_h@"
				str = Replace(str, "@mpe_callstack_unistd_h@", "/* MPE CALLSTACK NOT IMPLEMENTED IN WINDOWS */")
			' Config options 
			Case "@CONFIGURE_ARGS_CLEAN@"
				str = Replace(str, "@CONFIGURE_ARGS_CLEAN@", "Check winconfigure.wsf for config options")
			Case "@RELEASE_DATE@"
				str = Replace(str, "@RELEASE_DATE@", Date)
			Case "@DEVICE@"
				str = Replace(str, "@DEVICE@", "ch3")
			Case "@CC@"
				str = Replace(str, "@CC@", "cl.exe")
			Case "@CFLAGS@"
				' FIXME: Not the complete list of CFLAGS --- only some listed
				str = Replace(str, "@CFLAGS@", "/O2 /Ob1 /Oi /Oy /W4")
			Case "@CXX@"
				str = Replace(str, "@CXX@", "cl.exe")
			Case "@CXXFLAGS@" 
				' FIXME: Not the complete list of CXXFLAGS --- only some listed
				str = Replace(str, "@CXXFLAGS@", "/O2 /Ob1 /Oi /Oy /W4")
			Case "@F77@"
				str = Replace(str, "@F77@", "ifort.exe")
			Case "@FFLAGS@"
				' FIXME: Not the complete list of FFLAGS --- only some listed
				str = Replace(str, "@FFLAGS@", "/names:lowercase /iface:cref /assume:underscore")
			Case "@F90@"
				str = Replace(str, "@F90@", "ifort.exe")
			Case "@F90FLAGS@"
				' FIXME: Not the complete list of F90FLAGS --- only some listed
				str = Replace(str, "@F90FLAGS@", "/names:lowercase /iface:cref /assume:underscore")
			Case "@MPICH2_VERSION@"
				str = Replace(str, "@MPICH2_VERSION@", mpich2Version)
			Case "@MPICH2_NUMVERSION@"
				str = Replace(str, "@MPICH2_NUMVERSION@", mpich2NumVersion)
			Case "@nemesis_nets_macro_defs@"
				str = Replace(str, "@nemesis_nets_macro_defs@", "#define MPIDI_NEM_NEWTCP_MODULE 0")
			Case "@nemesis_nets_func_decl@"
				str = Replace(str, "@nemesis_nets_func_decl@", "MPIDI_nem_newtcp_module_funcs")
			Case "@nemesis_nets_array_sz@"
				str = Replace(str, "@nemesis_nets_array_sz@", "1")
			Case "@nemesis_nets_func_array@"
				str = Replace(str, "@nemesis_nets_func_array@", "&MPIDI_nem_newtcp_module_funcs")
			Case "@nemesis_nets_strings@"
				str = Replace(str, "@nemesis_nets_strings@", """newtcp""")
			Case Else
			'	unhandled_ats = unhandled_ats & Match & vbNewLine
			'	unhandled_ats_count = unhandled_ats_count + 1
				If appendUniqueString(unhandled_ats, Match) Then
					unhandled_ats_count = unhandled_ats_count + 1
				End If	
				unhandled_ats_instances = unhandled_ats_instances + 1
		End Select
	Next
	ReplaceAts = str
End Function


' FIXME: We should add functionality to add prefixes to AddDefinitions and get rid
' of common code in AddOPADefinitions
Sub AddOPADefinitions( fout, filename, b64 )
    If f.FileExists( filename ) Then
    Set f2 = f.OpenTextFile( filename )
    Dim regEx, Match, Matches, define, comment, macroname

    contents = f2.ReadAll()

    Set regEx = New RegExp
    regEx.Pattern = "/\*([^\*]|\*(?!/))*\*/[\r\n]*#undef(\b).+[\r\n]*"
    regEx.IgnoreCase = True
    regEx.Global = True
    Set Matches = regEx.Execute(contents)

    For Each Match in Matches
        comment = RegExpFind("/\*(.|[\r\n])*\*/", Match.Value)
        define = RegExpFind("#undef.*", Match.Value)
        macroname = RegExpFind("(\s).+", define)
        macroname = RegExpFind("(\S)+", macroname)
        fout.WriteLine(comment)
        Select Case macroname
            Case "HAVE_ATOMIC_H"
                fout.WriteLine("/* #undef HAVE_ATOMIC_H */")
            Case "HAVE_GCC_AND_IA64_ASM"
                fout.WriteLine("/* #undef HAVE_GCC_AND_IA64_ASM */")
            Case "HAVE_GCC_AND_POWERPC_ASM"
                fout.WriteLine("/* #undef HAVE_GCC_AND_POWERPC_ASM */")
            Case "HAVE_GCC_AND_SICORTEX_ASM"
                fout.WriteLine("/* #undef HAVE_GCC_AND_SICORTEX_ASM */")
            Case "HAVE_GCC_ATTRIBUTE"
                fout.WriteLine("/* #undef HAVE_GCC_ATTRIBUTE */")
            Case "HAVE_GCC_INTRINSIC_ATOMICS"
                fout.WriteLine("/* #undef HAVE_GCC_INTRINSIC_ATOMICS */")
            Case "HAVE_GCC_X86_32_64"
                fout.WriteLine("/* #undef HAVE_GCC_X86_32_64 */")
            Case "HAVE_GCC_X86_32_64_P3"
                fout.WriteLine("/* #undef HAVE_GCC_X86_32_64_P3 */")
            Case "HAVE_INTRIN_H"
                fout.WriteLine("/* #undef HAVE_INTRIN_H */")
            Case "HAVE_INTTYPES_H"
                fout.WriteLine("/* #undef HAVE_INTTYPES_H */")
            Case "HAVE_LIBPTHREAD"
                fout.WriteLine("/* #undef HAVE_LIBPTHREAD */")
            Case "HAVE_MEMORY_H"
                fout.WriteLine("/* #undef HAVE_MEMORY_H */")
            Case "HAVE_NT_INTRINSICS"
                fout.WriteLine("#define OPA_HAVE_NT_INTRINSICS 1")
            Case "USE_UNSAFE_PRIMITIVES"
                fout.WriteLine("/* #undef USE_UNSAFE_PRIMITIVES */")
            Case "HAVE_PTHREAD_H"
                fout.WriteLine("/* #undef HAVE_PTHREAD_H */")
            Case "HAVE_PTHREAD_YIELD"
                fout.WriteLine("/* #undef HAVE_PTHREAD_YIELD */")
            Case "HAVE_SCHED_YIELD"
                fout.WriteLine("/* #undef HAVE_SCHED_YIELD */")
            Case "HAVE_STDINT_H"
                fout.WriteLine("/* #undef HAVE_STDINT_H */")
            Case "HAVE_STDLIB_H"
                fout.WriteLine("#define OPA_HAVE_STDLIB_H 1")
            Case "HAVE_STRINGS_H"
                fout.WriteLine("/* #undef HAVE_STRINGS_H */")
            Case "HAVE_STRING_H"
                fout.WriteLine("#define OPA_HAVE_STRING_H 1")
            Case "STDC_HEADERS"
                fout.WriteLine("#define OPA_STDC_HEADERS 1")
            Case "HAVE_SUN_ATOMIC_OPS"
                fout.WriteLine("/* #undef HAVE_SUN_ATOMIC_OPS */")
            Case "HAVE_SYS_STAT_H"
                fout.WriteLine("/* #undef HAVE_SYS_STAT_H */")
            Case "HAVE_SYS_TYPES_H"
                fout.WriteLine("#define OPA_HAVE_SYS_TYPES_H 1")
            Case "HAVE_UNISTD_H"
                fout.WriteLine("/* #undef HAVE_UNISTD_H */")
            Case "LIMIT_THREADS"
                fout.WriteLine("/* #undef LIMIT_THREADS */")
            ' Just using the default value in the unix build for max nthreads
            Case "MAX_NTHREADS"
                fout.WriteLine("#define MAX_NTHREADS 100")
            Case "NDEBUG"
                fout.WriteLine("/* #undef NDEBUG */")
            ' By default allow threads to yield
            ' FIXME: However OPA_TEST_YIELD() is not defined on windows...
            Case "HAVE_STRICT_FAIRNESS_CHECKS"
                fout.WriteLine("/* #undef HAVE_STRICT_FAIRNESS_CHECKS */")
            Case "PACKAGE"
                fout.WriteLine("#define OPA_PACKAGE ""openpa""")
            Case "PACKAGE_TARNAME"
                fout.WriteLine("#define OPA_PACKAGE ""openpa""")
            Case "PACKAGE_BUGREPORT"
                fout.WriteLine("#define OPA_PACKAGE_BUGREPORT ""https://trac.mcs.anl.gov/projects/openpa/tickets""")
            Case "PACKAGE_NAME"
                fout.WriteLine("#define OPA_PACKAGE_NAME ""OpenPA""")
            ' FIXME: Find a better way to update the version of OpenPA package
            Case "PACKAGE_STRING"
                fout.WriteLine("#define OPA_PACKAGE_STRING ""OpenPA 0.0.1""")
            Case "PACKAGE_VERSION"
                fout.WriteLine("#define OPA_PACKAGE_VERSION ""0.0.1""")
            Case "VERSION"
                fout.WriteLine("#define OPA_VERSION ""0.0.1""")
            Case "SIZEOF_INT"
                fout.WriteLine("#define OPA_SIZEOF_INT 4")
            Case "SIZEOF_VOID_P"
                If b64 Then
                    fout.WriteLine("#define OPA_SIZEOF_VOID_P 8")
                Else
                    fout.WriteLine("#define OPA_SIZEOF_VOID_P 4")
                End If
            Case "inline"
                fout.WriteLine("#define inline __inline")
            Case "restrict"
                fout.WriteLine("#define restrict")
            Case "USE_LOCK_BASED_PRIMITIVES"
                fout.WriteLine("/* #undef USE_LOCK_BASED_PRIMITIVES */")
            Case Else
                'MsgBox("Unhandled definition <" & define & ">")
                If appendUniqueString(unhandled_definitions, macroname) Then
                    unhandled_definitions_count = unhandled_definitions_count + 1
                End If
                unhandled_definitions_instances = unhandled_definitions_instances + 1
                fout.WriteLine("/* unknown definition: " & macroname & " */")
            End Select
            fout.WriteLine("")
        Next
    End If
End Sub

Sub AddDefinitions( fout, filename, b64 )
	If f.FileExists( filename ) Then
		Set f2 = f.OpenTextFile( filename )
		Dim regEx, Match, Matches, define, comment, macroname
		Set regEx = New RegExp
		contents = f2.ReadAll()
        regEx.Pattern = "/\*([^\*]|\*(?!/))*\*/[\r\n]*#undef(\b).+[\r\n]*"
		regEx.IgnoreCase = True
		regEx.Global = True
		Set Matches = regEx.Execute(contents)
		For Each Match in Matches
			comment = RegExpFind("/\*(.|[\r\n])*\*/", Match.Value)
			define = RegExpFind("#undef.*", Match.Value)
			macroname = RegExpFind("(\s).+", define)
			macroname = RegExpFind("(\S)+", macroname)
			fout.WriteLine(comment)
			Select Case macroname
				Case "HAVE_INT8_T"
					fout.WriteLine("/* #undef HAVE_INT8_T */")
				Case "HAVE_INT16_T"
					fout.WriteLine("/* #undef HAVE_INT16_T */")
				Case "HAVE_INT32_T"
					fout.WriteLine("/* #undef HAVE_INT32_T */")
				Case "HAVE_INT64_T"
					fout.WriteLine("/* #undef HAVE_INT64_T */")
				Case "HAVE_UINT8_T"
					fout.WriteLine("/* #undef HAVE_INT8_T */")
				Case "HAVE_UINT16_T"
					fout.WriteLine("/* #undef HAVE_INT16_T */")
				Case "HAVE_UINT32_T"
					fout.WriteLine("/* #undef HAVE_INT32_T */")
				Case "HAVE_UINT64_T"
					fout.WriteLine("/* #undef HAVE_INT64_T */")
                                Case "HAVE__BOOL"
                                        fout.WriteLine("/* #undef HAVE__BOOL */")
                                Case "HAVE__COMPLEX"
                                        fout.WriteLine("/* #undef HAVE__COMPLEX */")
                                Case "HAVE_FLOAT__COMPLEX"
                                        fout.WriteLine("/* #undef HAVE_FLOAT__COMPLEX */")
                                Case "HAVE_DOUBLE__COMPLEX"
                                        fout.WriteLine("/* #undef HAVE_DOUBLE__COMPLEX */")
                                Case "HAVE_LONG_DOUBLE__COMPLEX"
                                        fout.WriteLine("/* #undef HAVE_LONG_DOUBLE__COMPLEX */")
				Case "int8_t"
					fout.WriteLine("#define int8_t __int8")
				Case "int16_t"
					fout.WriteLine("#define int16_t __int16")
				Case "int32_t"
					fout.WriteLine("#define int32_t __int32")
				Case "int64_t"
					fout.WriteLine("#define int64_t __int64")
				Case "uint8_t"
					fout.WriteLine("#define uint8_t unsigned __int8")
				Case "_UINT8_T"
					' Needed only for SOLARIS machines
					fout.WriteLine("/* #undef _UINT8_T */")
				Case "uint16_t"
					fout.WriteLine("#define uint16_t unsigned __int16")
				Case "_UINT16_T"
					' Needed only for SOLARIS machines
					fout.WriteLine("/* #undef _UINT16_T */")
				Case "uint32_t"
					fout.WriteLine("#define uint32_t unsigned __int32")
				Case "_UINT32_T"
					' Needed only for SOLARIS machines
					fout.WriteLine("/* #undef _UINT32_T */")
				Case "uint64_t"
					fout.WriteLine("#define uint64_t unsigned __int64")
				Case "_UINT64_T"
					' Needed only for SOLARIS machines
					fout.WriteLine("/* #undef _UINT64_T */")
				Case "u_char"
                                        ' Needed only on unix builds where --enable-strict
                                        ' option removes these types
                                        fout.WriteLine("/* #undef u_char */")
				Case "u_int"
                                        ' Needed only on unix builds where --enable-strict
                                        ' option removes these types
                                        fout.WriteLine("/* #undef u_int */")
				Case "u_long"
                                        ' Needed only on unix builds where --enable-strict
                                        ' option removes these types
                                        fout.WriteLine("/* #undef u_long */")
				Case "u_short"
                                        ' Needed only on unix builds where --enable-strict
                                        ' option removes these types
                                        fout.WriteLine("/* #undef u_short */")
				Case "POINTERINT_t"
					If b64 Then
						fout.WriteLine("#define POINTERINT_t __int64")
					Else
						fout.WriteLine("#define POINTERINT_t __int32")
					End If
				Case "MPIR_Pint"
					If b64 Then
						fout.WriteLine("#define MPIR_Pint __int64")
					Else
						fout.WriteLine("#define MPIR_Pint __int32")
					End If
				Case "MPIR_Upint"
					If b64 Then
						fout.WriteLine("#define MPIR_Upint unsigned __int64")
					Else
						fout.WriteLine("#define MPIR_Upint unsigned __int32")
					End If
				Case "const"
					fout.WriteLine("/* #undef const */")
				Case "inline"
					fout.WriteLine("#define inline __inline")
				Case "STDC_HEADERS"
					fout.WriteLine("#define STDC_HEADERS 1")
				Case "SIZEOF_DOUBLE"
					fout.WriteLine("#define SIZEOF_DOUBLE 8")
				Case "SIZEOF_FLOAT"
					fout.WriteLine("#define SIZEOF_FLOAT 4")
				Case "SIZEOF_INT"
					fout.WriteLine("#define SIZEOF_INT 4")
				Case "SIZEOF_LONG"
					fout.WriteLine("#define SIZEOF_LONG 4")
				Case "SIZEOF_LONG_DOUBLE"
					fout.WriteLine("#define SIZEOF_LONG_DOUBLE 12")
				Case "SIZEOF_LONG_LONG"
					fout.WriteLine("#define SIZEOF_LONG_LONG 8")
				Case "SIZEOF_SHORT"
					fout.WriteLine("#define SIZEOF_SHORT 2")
				Case "SIZEOF_UNSIGNED_CHAR"
					fout.WriteLine("#define SIZEOF_UNSIGNED_CHAR 1")
				Case "SIZEOF_UNSIGNED_INT"
					fout.WriteLine("#define SIZEOF_UNSIGNED_INT 4")
				Case "SIZEOF_UNSIGNED_LONG"
					fout.WriteLine("#define SIZEOF_UNSIGNED_LONG 4")
				Case "SIZEOF_UNSIGNED_LONG_LONG"
					fout.WriteLine("#define SIZEOF_UNSIGNED_LONG_LONG 8")
				Case "SIZEOF_UNSIGNED_SHORT"
					fout.WriteLine("#define SIZEOF_UNSIGNED_SHORT 2")
				Case "SIZEOF_VOID_P"
					If b64 Then
						fout.WriteLine("#define SIZEOF_VOID_P 8")
					Else
						fout.WriteLine("#define SIZEOF_VOID_P 4")
					End If
				Case "SIZEOF_WCHAR_T"
					fout.WriteLine("#define SIZEOF_WCHAR_T 2")
                                ' Now autoconf handles non-built-in types too. So we need to
                                ' define the sizeof these types here
                                Case "SIZEOF_DOUBLE_INT"
                                        fout.WriteLine("#define SIZEOF_DOUBLE_INT " + len_double_int)
                                Case "SIZEOF_FLOAT_INT"
                                        fout.WriteLine("#define SIZEOF_FLOAT_INT " + len_float_int)
                                Case "SIZEOF_LONG_DOUBLE_INT"
                                        fout.WriteLine("#define SIZEOF_LONG_DOUBLE_INT " + len_long_double_int)
                                Case "SIZEOF_LONG_INT"
                                        fout.WriteLine("#define SIZEOF_LONG_INT " + len_long_int)
                                Case "SIZEOF_SHORT_INT"
                                        fout.WriteLine("#define SIZEOF_SHORT_INT " + len_short_int)
                                Case "SIZEOF_TWO_INT"
                                        fout.WriteLine("#define SIZEOF_TWO_INT " + len_two_int)
                                Case "SIZEOF__BOOL"
                                        fout.WriteLine("#define SIZEOF__BOOL " + len__Bool)
                                Case "SIZEOF_FLOAT__COMPLEX"
                                        fout.WriteLine("#define SIZEOF__COMPLEX " + len_float__Complex)
                                Case "SIZEOF_DOUBLE__COMPLEX"
                                        fout.WriteLine("#define SIZEOF_DOUBLE__COMPLEX " + len_double__Complex)
                                Case "SIZEOF_LONG_DOUBLE__COMPLEX"
                                        fout.WriteLine("#define SIZEOF_LONG_DOUBLE__COMPLEX " + len_long_double__Complex)
                                ' FIXME: Ugly hack - the sizeof MPIR_Bsend_data_t can change !
                                Case "SIZEOF_MPIR_BSEND_DATA_T"
                                        If b64 Then
                                            fout.WriteLine("#define SIZEOF_MPIR_BSEND_DATA_T " + BSEND_OVERHEAD64)
                                        Else
                                            fout.WriteLine("#define SIZEOF_MPIR_BSEND_DATA_T " + BSEND_OVERHEAD32)
                                        End If
				Case "HAVE_GETCWD"
					fout.WriteLine("#define HAVE_GETCWD 1")
				Case "HAVE_GETHOSTNAME"
					fout.WriteLine("#define HAVE_GETHOSTNAME 1")
				Case "HAVE_PUTENV"
					fout.WriteLine("#define HAVE_PUTENV 1")
				Case "HAVE_SETENV"
					fout.WriteLine("/* #undef HAVE_SETENV */")
				Case "HAVE_SELECT"
					fout.WriteLine("#define HAVE_SELECT 1")
				Case "HAVE_SLEEP"
					fout.WriteLine("#define HAVE_SLEEP 1")
				Case "HAVE_SOCKET"
					fout.WriteLine("#define HAVE_SOCKET 1")
				Case "HAVE_STRDUP"
					fout.WriteLine("#define HAVE_STRDUP 1")
				Case "HAVE_STRNCASECMP"
					fout.WriteLine("/* #undef HAVE_STRNCASECMP */")
				Case "HAVE_ERRNO_H"
					fout.WriteLine("#define HAVE_ERRNO_H 1")
                                Case "HAVE_MATH_H"
                                        fout.WriteLine("#define HAVE_MATH_H 1")
				Case "HAVE_FCNTL_H"
					fout.WriteLine("#define HAVE_FCNTL_H 1")
				Case "HAVE_STDLIB_H"
					fout.WriteLine("#define HAVE_STDLIB_H 1")
				Case "HAVE_STDIO_H"
					fout.WriteLine("#define HAVE_STDIO_H")
				Case "HAVE_ERROR_CHECKING"
					fout.WriteLine("#define HAVE_ERROR_CHECKING MPID_ERROR_LEVEL_ALL")
					fout.WriteLine("/*#undef HAVE_ERROR_CHECKING*/")
				Case "HAVE_TIMING MPID_TIMING_KIND_LOG"
					fout.WriteLine("/*#define HAVE_TIMING MPID_TIMING_KIND_LOG*/")
				Case "HAVE_TIMING MPID_TIMING_KIND_ALL"
					fout.WriteLine("/*#define HAVE_TIMING MPID_TIMING_KIND_ALL*/")
				Case "USE_LOGGING MPID_LOGGING_RLOG"
					fout.WriteLine("/*#define USE_LOGGING MPID_LOGGING_RLOG*/")
				Case "USE_LOGGING MPID_LOGGING_DLOG"
					fout.WriteLine("/*#define USE_LOGGING MPID_LOGGING_DLOG*/")
				Case "MPICH_SINGLE_THREADED"
					fout.WriteLine("#define MPICH_SINGLE_THREADED ")
				Case "USE_MEMORY_TRACING"
					fout.WriteLine("/* #undef USE_MEMORY_TRACING */")
				Case "restrict"
					fout.WriteLine("#define restrict")
				Case "CHAR_PTR_IS_BYTE"
					fout.WriteLine("/* #undef CHAR_PTR_IS_BYTE */")
				Case "HAVE_GCC_AND_PENTIUM_ASM"
					fout.WriteLine("/* #undef HAVE_GCC_AND_PENTIUM_ASM */")
				Case "HAVE_INTTYPES_H"
					fout.WriteLine("/* #undef HAVE_INTTYPES_H */")
				Case "HAVE_MEMORY_H"
					fout.WriteLine("/* #undef HAVE_MEMORY_H */")
				Case "HAVE_PRAGMA_CRI_DUP"
					fout.WriteLine("/* #undef HAVE_PRAGMA_CRI_DUP */")
				Case "HAVE_PRAGMA_HP_SEC_DEF"
					fout.WriteLine("/* #undef HAVE_PRAGMA_HP_SEC_DEF */")
				Case "HAVE_PRAGMA_WEAK"
					fout.WriteLine("/* #undef HAVE_PRAGMA_WEAK */")
                                Case "HAVE_SIGACTION"
                                        fout.WriteLine("/* #undef HAVE_SIGACTION */")
				Case "HAVE_PTHREAD_CREATE"
					fout.WriteLine("/* #undef HAVE_PTHREAD_CREATE */")
                                Case "HAVE_PTHREAD_BARRIER_INIT"
					fout.WriteLine("/* #undef HAVE_PTHREAD_BARRIER_INIT */")
                                Case "HAVE_PTHREAD_BARRIER_WAIT"
					fout.WriteLine("/* #undef HAVE_PTHREAD_BARRIER_WAIT */")
				Case "USE_PTHREAD_STDIN_REDIRECTION"
					fout.WriteLine("/* #undef USE_PTHREAD_STDIN_REDIRECTION */")
                                Case "HAVE_TERMIOS_H"
                                        fout.WriteLine("/* #undef HAVE_TERMIOS_H */")
				Case "HAVE_STDINT_H"
					fout.WriteLine("/* #undef HAVE_STDINT_H */")
				Case "HAVE_STRINGS_H"
					fout.WriteLine("/* #undef HAVE_STRINGS_H */")
				Case "HAVE_STRING_H"
					fout.WriteLine("#define HAVE_STRING_H")
				Case "HAVE_SYS_STAT_H"
					fout.WriteLine("/* #undef HAVE_SYS_STAT_H */")
				Case "HAVE_SYS_TYPES_H"
					fout.WriteLine("#define HAVE_SYS_TYPES_H 1")
				Case "HAVE_SYS_ATTR_H"
					fout.WriteLine("/* #undef HAVE_SYS_ATTR_H */")
				Case "HAVE_THR_CREATE"
					fout.WriteLine("/* #undef HAVE_THR_CREATE */")
				Case "HAVE_TIMING"
					fout.WriteLine("/* #undef HAVE_TIMING */")
				Case "HAVE_UNISTD_H"
					fout.WriteLine("/* #undef HAVE_UNISTD_H */")
				Case "SIZEOF_INT_IS_AINT"
					If b64 then
						fout.WriteLine("/* #undef SIZEOF_INT_IS_AINT */")
					Else
						fout.WriteLine("#define SIZEOF_INT_IS_AINT")
					End If
				Case "volatile"
					fout.WriteLine("/* #undef volatile */")
				Case "HAVE_GETTIMEOFDAY"
					fout.WriteLine("/*#define HAVE_GETTIMEOFDAY 1*/")
				Case "HAVE_MUTEX_INIT"
					fout.WriteLine("/* #undef HAVE_MUTEX_INIT */")
				Case "HAVE_PTHREAD_MUTEXATTR_INIT"
					fout.WriteLine("/*#define HAVE_PTHREAD_MUTEXATTR_INIT 1*/")
				Case "HAVE_PTHREAD_MUTEXATTR_SETPSHARED"
					fout.WriteLine("/*#define HAVE_PTHREAD_MUTEXATTR_SETPSHARED 1*/")
                                Case "PTHREAD_MUTEX_ERRORCHECK_VALUE"
                                        fout.WriteLine("/* #undef PTHREAD_MUTEX_ERRORCHECK_VALUE */")
				Case "HAVE_SCHED_YIELD"
					fout.WriteLine("/*#define HAVE_SCHED_YIELD 1*/")
				Case "HAVE_SHMAT"
					fout.WriteLine("/* #undef HAVE_SHMAT */")
				Case "HAVE_SHMCTL"
					fout.WriteLine("/* #undef HAVE_SHMCTL */")
				Case "HAVE_SHMDT"
					fout.WriteLine("/* #undef HAVE_SHMDT */")
				Case "HAVE_SHMGET"
					fout.WriteLine("/* #undef HAVE_SHMGET */")
				Case "HAVE_USLEEP"
					fout.WriteLine("/*#define HAVE_USLEEP 1*/")
				Case "HAVE_YIELD"
					fout.WriteLine("/* #undef HAVE_YIELD */")
				Case "HAVE_LINUX_UNISTD_H"
					fout.WriteLine("/* #undef HAVE_LINUX_UNISTD_H */")
				Case "HAVE_NETDB_H"
					fout.WriteLine("/*#define HAVE_NETDB_H 1*/")
				Case "HAVE_NETINET_IN_H"
					fout.WriteLine("/*#define HAVE_NETINET_IN_H 1*/")
				Case "HAVE_NETINET_TCP_H"
					fout.WriteLine("/*#define HAVE_NETINET_TCP_H 1*/")
				Case "HAVE_PTHREAD_H"
					fout.WriteLine("/*#define HAVE_PTHREAD_H 1*/")
				Case "HAVE_SCHED_H"
					fout.WriteLine("/*#define HAVE_SCHED_H 1*/")
				Case "HAVE_SYS_FILIO_H"
					fout.WriteLine("/* #undef HAVE_SYS_FILIO_H */")
				Case "HAVE_SYS_IOCTL_H"
					fout.WriteLine("/*#define HAVE_SYS_IOCTL_H 1*/")
				Case "HAVE_SYS_IPC_H"
					fout.WriteLine("/* #undef HAVE_SYS_IPC_H */")
				Case "HAVE_SYS_PARAM_H"
					fout.WriteLine("/*#define HAVE_SYS_PARAM_H 1*/")
				Case "HAVE_SYS_PTRACE_H"
					fout.WriteLine("/* #undef HAVE_SYS_PTRACE_H */")
				Case "HAVE_SYS_SELECT_H"
					fout.WriteLine("/*#define HAVE_SYS_SELECT_H 1*/")
				Case "HAVE_SYS_SEM_H"
					fout.WriteLine("/* #undef HAVE_SYS_SEM_H */")
				Case "HAVE_SYS_SHM_H"
					fout.WriteLine("/* #undef HAVE_SYS_SHM_H */")
				Case "HAVE_SYS_SOCKET_H"
					fout.WriteLine("/*#define HAVE_SYS_SOCKET_H 1*/")
				Case "HAVE_SYS_TIME_H"
					fout.WriteLine("/*#define HAVE_SYS_TIME_H 1*/")
				Case "HAVE_SYS_UIO_H"
					fout.WriteLine("/*#define HAVE_SYS_UIO_H 1*/")
				Case "HAVE_SYS_WAIT_H"
					fout.WriteLine("/*#define HAVE_SYS_WAIT_H 1*/")
				Case "HAVE_VALUES_H"
					fout.WriteLine("/* #undef HAVE_VALUES_H */")
				Case "HAVE_LIBTHREAD"
					fout.WriteLine("/* #undef HAVE_LIBTHREAD */")
				Case "HAVE_ASSERT_H"
					fout.WriteLine("#define HAVE_ASSERT_H 1")
				Case "HAVE_LIMITS_H"
					fout.WriteLine("#define HAVE_LIMITS_H")
				Case "COLLECT_STATS"
					fout.WriteLine("/* #undef COLLECT_STATS */")
				Case "FILE_NAMEPUB_BASEDIR"
					fout.WriteLine("/* #undef FILE_NAMEPUB_BASEDIR */")
				Case "HAVE_CXX_BINDING"
					fout.WriteLine("#define HAVE_CXX_BINDING 1")
				Case "HAVE_DEBUGGER_SUPPORT"
					fout.WriteLine("/* #undef HAVE_DEBUGGER_SUPPORT */")
				Case "HAVE_DGETTEXT"
					fout.WriteLine("/* #undef HAVE_DGETTEXT */")
				Case "HAVE_FORTRAN_BINDING"
					fout.WriteLine("/* #undef HAVE_FORTRAN_BINDING */")
				Case "HAVE_GCC_ATTRIBUTE"
					fout.WriteLine("/* #undef HAVE_GCC_ATTRIBUTE */")
				Case "HAVE_GETTEXT"
					fout.WriteLine("/* #undef HAVE_GETTEXT */")
				Case "HAVE_LIBINTL_H"
					fout.WriteLine("/* #undef HAVE_LIBINTL_H */")
				Case "HAVE_LONG_DOUBLE"
					fout.WriteLine("#define HAVE_LONG_DOUBLE 1")
				Case "HAVE_LONG_LONG_INT"
					fout.WriteLine("#define HAVE_LONG_LONG_INT 1")
				Case "HAVE_MAX_STRUCT_ALIGNMENT"
					'fout.WriteLine("/* #undef HAVE_MAX_STRUCT_ALIGNMENT */")
					'If bWin64 Then
					'	fout.WriteLine("#define HAVE_MAX_STRUCT_ALIGNMENT 8")
					'Else
					'	fout.WriteLine("#define HAVE_MAX_STRUCT_ALIGNMENT 4")
					'End If
					fout.WriteLine("#define HAVE_MAX_STRUCT_ALIGNMENT 8")
				Case "HAVE_MAX_FP_ALIGNMENT"
					fout.WriteLine("#define HAVE_MAX_FP_ALIGNMENT 8")
				Case "HAVE_MAX_INTEGER_ALIGNMENT"
					fout.WriteLine("#define HAVE_MAX_INTEGER_ALIGNMENT 4")
				Case "HAVE_LARGEST_STRUCT_ALIGNMENT"
					fout.WriteLine("/* #undef HAVE_LARGEST_STRUCT_ALIGNMENT */")
				Case "HAVE_DOUBLE_POS_ALIGNMENT"
					fout.WriteLine("/* #undef HAVE_DOUBLE_POS_ALIGNMENT */")
				Case "HAVE_LLINT_POS_ALIGNMENT"
					fout.WriteLine("/* #undef HAVE_LLINT_POS_ALIGNMENT */")
				Case "HAVE_NAMEPUB_SERVICE"
					fout.WriteLine("#define HAVE_NAMEPUB_SERVICE 1")
				Case "HAVE_NO_FORTRAN_MPI_TYPES_IN_C"
					fout.WriteLine("/* #undef HAVE_NO_FORTRAN_MPI_TYPES_IN_C */")
				Case "HAVE_ROMIO"
					fout.WriteLine("/* #undef HAVE_ROMIO */")
				Case "HAVE_SEARCH"
					fout.WriteLine("/* #undef HAVE_SEARCH */")
				Case "HAVE_SNPRINTF"
					fout.WriteLine("#define HAVE_SNPRINTF")
				Case "HAVE_STDARG_H"
					fout.WriteLine("#define HAVE_STDARG_H")
				Case "HAVE_SYS_BITYPES_H"
					fout.WriteLine("/* #undef HAVE_SYS_BITYPES_H */")
				Case "HAVE_THREAD_H"
					fout.WriteLine("/* #undef HAVE_THREAD_H */")
				Case "HAVE_THR_YIELD"
					fout.WriteLine("/* #undef HAVE_THR_YIELD */")
				Case "HAVE_TSEARCH"
					fout.WriteLine("/* #undef HAVE_TSEARCH */")
				Case "HAVE_VA_COPY"
					fout.WriteLine("/* #undef HAVE_VA_COPY */")
				Case "HAVE_VSNPRINTF"
					fout.WriteLine("#define HAVE_VSNPRINTF")
				Case "HAVE_VSPRINTF"
					fout.WriteLine("#define HAVE_VSPRINTF")
				Case "HAVE_PVFS2_CREATE_WITHOUT_LAYOUT"
					fout.WriteLine("/* #undef HAVE_PVFS2_CREATE_WITHOUT_LAYOUT */")
				Case "MPICH_DEBUG_HANDLES"
					fout.WriteLine("/* #undef HAVE_MPICH_DEBUG_HANDLES */")
				Case "MPICH_DEBUG_INTERNAL"
					fout.WriteLine("/* #undef MPICH_DEBUG_INTERNAL */")
				Case "MPICH_DEBUG_NESTING"
					fout.WriteLine("/* #undef MPICH_DEBUG_NESTING */")
				Case "MPICH_ERROR_MSG_LEVEL"
					fout.WriteLine("#define MPICH_ERROR_MSG_LEVEL MPICH_ERROR_MSG_ALL")
				Case "MPICH_INFODLL_LOC"
					fout.WriteLine("/* #undef MPICH_INFODLL_LOC */")
				' After migrating to autoconf 2.62 we no longer use MPIU_[U]INT*
				'Case "MPIU_INT8_T"
				'	fout.WriteLine("#define MPIU_INT8_T __int8")
				'Case "MPIU_INT16_T"
				'	fout.WriteLine("#define MPIU_INT16_T __int16")
				'Case "MPIU_INT32_T"
				'	fout.WriteLine("#define MPIU_INT32_T __int32")
				'Case "MPIU_INT64_T"
				'	fout.WriteLine("#define MPIU_INT64_T __int64")
				'Case "MPIU_UINT8_T"
				'	fout.WriteLine("#define MPIU_UINT8_T unsigned __int8")
				'Case "MPIU_UINT16_T"
				'	fout.WriteLine("#define MPIU_UINT16_T unsigned __int16")
				'Case "MPIU_UINT32_T"
				'	fout.WriteLine("#define MPIU_UINT32_T unsigned __int32")
				'Case "MPIU_UINT64_T"
				'	fout.WriteLine("#define MPIU_UINT64_T unsigned __int64")
				Case "MPIU_SIZE_T"
					fout.WriteLine("#define MPIU_SIZE_T unsigned int")
				Case "NDEBUG"
					fout.WriteLine("/* #undef NDEBUG */")
				Case "NEEDS_POINTER_ALIGNMENT_ADJUST"
					fout.WriteLine("/* #undef NEEDS_POINTER_ALIGNMENT_ADJUST */")
				Case "NEEDS_SNPRINTF_DECL"
					fout.WriteLine("/* #undef NEEDS_SNPRINTF_DECL */")
				Case "NEEDS_STRDUP_DECL"
					fout.WriteLine("/* #undef NEEDS_STRDUP_DECL */")
				Case "NEEDS_PUTENV_DECL"
					fout.WriteLine("/* #undef NEEDS_PUTENV_DECL */")
				Case "PACKAGE_BUGREPORT"
					fout.WriteLine("/* #undef PACKAGE_BUGREPORT */")
				Case "PACKAGE_NAME"
					fout.WriteLine("/* #undef PACKAGE_NAME */")
				Case "PACKAGE_STRING"
					fout.WriteLine("/* #undef PACKAGE_STRING */")
				Case "PACKAGE_TARNAME"
					fout.WriteLine("/* #undef PACKAGE_TARNAME */")
				Case "PACKAGE_VERSION"
					fout.WriteLine("/* #undef PACKAGE_VERSION */")
				Case "USE_COVERAGE"
					fout.WriteLine("/* #undef USE_COVERAGE */")
				Case "USE_FILE_FOR_NAMEPUB"
					fout.WriteLine("/* #undef USE_FILE_FOR_NAMEPUB */")
				Case "USE_GETTEXT"
					fout.WriteLine("/* #undef USE_GETTEXT */")
				Case "USE_LDAP_FOR_NAMEPUB"
					fout.WriteLine("/* #undef USE_LDAP_FOR_NAMEPUB */")
				Case "USE_LOGGING"
					fout.WriteLine("/* #undef USE_LOGGING */")
				Case "USE_TSEARCH_WITH_CHARP"
					fout.WriteLine("/* #undef USE_TSEARCH_WITH_CHARP */")
				Case "USE_WEAK_SYMBOLS"
					fout.WriteLine("/* #undef USE_WEAK_SYMBOLS */")
				Case "HAVE_CPP_VARARGS"
					fout.WriteLine("/* #undef HAVE_CPP_VARARGS */")
				Case "HAVE_CLOCK_GETRES"
					fout.WriteLine("/* #undef HAVE_CLOCK_GETRES */")
				Case "HAVE_CLOCK_GETTIME"
					fout.WriteLine("/* #undef HAVE_CLOCK_GETTIME */")
				Case "HAVE_GETHRTIME"
					fout.WriteLine("/* #undef HAVE_GETHRTIME */")
				Case "HAVE_MPI_WIN_CREATE"
					fout.WriteLine("#define HAVE_MPI_WIN_CREATE 1")
				Case "HAVE_COMPARE_AND_SWAP"
					fout.WriteLine("/* #undef HAVE_COMPARE_AND_SWAP */")
				Case "HAVE_DLFCN_H"
					fout.WriteLine("/* #undef HAVE_DLFCN_H */")
				Case "HAVE_UUID_UUID_H"
					fout.WriteLine("/* #undef HAVE_UUID_UUID_H */")
				Case "HAVE_GCC_ASM_AND_X86_LFENCE"
					fout.WriteLine("/* #undef HAVE_GCC_ASM_AND_X86_LFENCE */")
				Case "HAVE_GCC_ASM_AND_X86_MFENCE"
					fout.WriteLine("/* #undef HAVE_GCC_ASM_AND_X86_MFENCE */")
				Case "HAVE_GCC_ASM_AND_X86_SFENCE"
					fout.WriteLine("/* #undef HAVE_GCC_ASM_AND_X86_SFENCE */")
				Case "HAVE_MMAP"
					fout.WriteLine("/* #undef HAVE_MMAP */")
				Case "HAVE_MPP_SHMEM_H"
					fout.WriteLine("/* #undef HAVE_MPP_SHMEM_H */")
				Case "HAVE_SHM_OPEN"
					fout.WriteLine("/* #undef HAVE_SHM_OPEN */")
				Case "HAVE_SHM_UNLINK"
					fout.WriteLine("/* #undef HAVE_SHM_UNLINK */")
				Case "HAVE_SYS_MMAN_H"
					fout.WriteLine("/* #undef HAVE_SYS_MMAN_H */")
				Case "HAVE_SYSCONF"
					fout.WriteLine("/* #undef HAVE_SYSCONF */")
				Case "HAVE_NET_IF_H"
					fout.WriteLine("/* #undef HAVE_NET_IF_H */")
				Case "HAVE_SYS_SOCKIO_H"
					fout.WriteLine("/* #undef HAVE_SYS_SOCKIO_H */")
				Case "HAVE_ARPA_INET_H"
					fout.WriteLIne("/* #undef HAVE_ARPA_INET_H */")
				Case "HAVE_CTYPE_H"
					fout.WriteLine("#define HAVE_CTYPE_H")
				Case "HAVE_GETPAGESIZE"
					fout.WriteLine("/* #undef HAVE_GETPAGESIZE */")
				Case "HAVE_MQUEUE_H"
					fout.WriteLine("/* #undef HAVE_MQUEUE_H */")
				Case "HAVE_MQ_OPEN"
					fout.WriteLine("/* #undef HAVE_MQ_OPEN */")
				Case "HAVE_MSGGET"
					fout.WriteLine("/* #undef HAVE_MSGGET */")
				Case "HAVE_PROCESS_H"
					fout.WriteLine("#define HAVE_PROCESS_H")
				Case "HAVE_MULTIPLE_PRAGMA_WEAK"
					fout.WriteLine("/* #undef HAVE_MULTIPLE_PRAGMA_WEAK */")
				Case "MPICH_CPU_TICK_TYPE"
					fout.WriteLine("#define MPICH_CPU_TICK_TYPE USE_WIN_X86_CYCLE_ASM")
				Case "USE_BUSY_LOCKS"
					fout.WriteLine("/* #undef USE_BUSY_LOCKS */")
				Case "USE_MQSHM"
					fout.WriteLine("/* #undef USE_MQSHM */")
				Case "USE_ATOMIC_UPDATES"
					fout.WriteLine("/* #undef USE_ATOMIC_UPDATES */")
				Case "F77_FALSE_VALUE"
					fout.WriteLine("#define F77_FALSE_VALUE 0")
				Case "F77_TRUE_VALUE"
					' Intel Fotran uses -1
					' Compaq Visual Fortran uses 1
					fout.WriteLine("#define F77_TRUE_VALUE -1")
				Case "F77_TRUE_VALUE_SET"
					fout.WriteLine("#define F77_TRUE_VALUE_SET 1")
				Case "F77_RUNTIME_VALUES"
					fout.WriteLine("/* #undef F77_RUNTIME_VALUES */")
				Case "HAVE_AINT_LARGER_THAN_FINT"
					fout.WriteLine("/* #undef HAVE_AINT_LARGER_THAN_FINT */")
				Case "HAVE_FINT_IS_INT"
					fout.WriteLine("/* #undef HAVE_FINT_IS_INT */")
				Case "HAVE_LONG_LONG"
					fout.WriteLine("/* #undef HAVE_LONG_LONG */")
				Case "HAVE_WEAK_SYMBOLS"
					fout.WriteLine("/* #undef HAVE_WEAK_SYMBOLS */")
				Case "SIZEOF_CHAR"
					fout.WriteLine("#define SIZEOF_CHAR 1")
				Case "SIZEOF_F77_DOUBLE_PRECISION"
					fout.WriteLine("#define SIZEOF_F77_DOUBLE_PRECISION 8")
				Case "SIZEOF_F77_INTEGER"
					fout.WriteLine("#define SIZEOF_F77_INTEGER 4")
				Case "SIZEOF_F77_REAL"
					fout.WriteLine("#define SIZEOF_F77_REAL 4")
				Case "SIZEOF_VOIDP"
					If b64 Then
						fout.WriteLine("#define SIZEOF_VOIDP 8")
					Else
						fout.WriteLine("#define SIZEOF_VOIDP 4")
					End If
				Case "USE_GCC_G77_DECLS"
					fout.WriteLine("/* #undef USE_GCC_G77_DECLS */")
				Case "USE_POINTER_FOR_BOTTOM"
					fout.WriteLine("/* #undef USE_POINTER_FOR_BOTTOM */")
				Case "_TWO_WORD_FCD"
					fout.WriteLine("/* #undef _TWO_WORD_FCD */")
				Case "FORTRAN_SPECIAL_FUNCTION_PTR"
					fout.WriteLine("/* #undef FORTRAN_SPECIAL_FUNCTION_PTR */")
				Case "F77_NAME_LOWER"
					If bf77_name_lower Then
						fout.WriteLine("#define F77_NAME_LOWER")
					Else
						fout.WriteLine("/* #undef F77_NAME_LOWER */")
					End If
				Case "F77_NAME_LOWER_USCORE"
					If bf77_name_lower_uscore Then
						fout.WriteLine("#define F77_NAME_LOWER_USCORE")
					Else
						fout.WriteLine("/* #undef F77_NAME_LOWER_USCORE */")
					End If
				Case "F77_NAME_LOWER_2USCORE"
					If bf77_name_lower_2uscore Then
						fout.WriteLine("#define F77_NAME_LOWER_2USCORE 1")
					Else
						fout.WriteLine("/* #undef F77_NAME_LOWER_2USCORE */")
					End If
				Case "F77_NAME_UPPER"
					if bf77_name_upper Then
						fout.WriteLine("#define F77_NAME_UPPER")
					Else
						fout.WriteLine("/* #undef F77_NAME_UPPER */")
					End If
				Case "F77_NAME_MIXED"
					if bf77_name_mixed Then
						fout.WriteLine("#define F77_NAME_MIXED 1")
					Else
						fout.WriteLine("/* #undef F77_NAME_MIXED */")
					End If
				Case "F77_NAME_MIXED_USCORE"
					if bf77_name_mixed_uscore Then
						fout.WriteLine("#define F77_NAME_MIXED_USCORE 1")
					Else
						fout.WriteLine("/* #undef F77_NAME_MIXED_USCORE */")
					End If
				Case "HAVE_NSLINKMODULE"
					fout.WriteLine("/* #undef HAVE_NSLINKMODULE */")
				Case "HAVE_DLOPEN"
					fout.WriteLine("/* #undef HAVE_DLOPEN */")
				Case "HAVE_MACH_O_DYLD_H"
					fout.WriteLine("/* #undef HAVE_MACH_O_DYLD_H */")
				Case "USE_HUMAN_READABLE_TOKENS"
					fout.WriteLine("#define USE_HUMAN_READABLE_TOKENS 1")
				Case "HAVE_STRERROR"
					fout.WriteLine("#ifndef HAVE_STRERROR")
					fout.WriteLine("#define HAVE_STRERROR 1")
					fout.WriteLine("#endif")
				Case "HAVE_ASM_AND_X86_LFENCE"
					fout.WriteLine("/* #undef HAVE_ASM_AND_X86_LFENCE */")
				Case "HAVE_ASM_AND_X86_MFENCE"
					fout.WriteLine("/* #undef HAVE_ASM_AND_X86_MFENCE */")
				Case "HAVE_ASM_AND_X86_SFENCE"
					fout.WriteLine("/* #undef HAVE_ASM_AND_X86_SFENCE */")
				Case "HAVE___ASM_AND_X86_LFENCE"
					fout.WriteLine("/* #undef HAVE___ASM_AND_X86_LFENCE */")
				Case "HAVE___ASM_AND_X86_MFENCE"
					fout.WriteLine("/* #undef HAVE___ASM_AND_X86_MFENCE */")
				Case "HAVE___ASM_AND_X86_SFENCE"
					fout.WriteLine("/* #undef HAVE___ASM_AND_X86_SFENCE */")
				Case "HAVE__INTERLOCKEDEXCHANGE"
					fout.WriteLine("/* #undef HAVE__INTERLOCKEDEXCHANGE */")
				Case "HAVE_GCC_AND_X86_64_ASM"
					fout.WriteLine("/* #undef HAVE_GCC_AND_X86_64_ASM */")
				Case "HAVE_GCC_AND_IA64_ASM"
					fout.WriteLine("/* #undef HAVE_GCC_AND_IA64_ASM */")
				Case "HAVE_GCC_AND_SICORTEX_ASM"
					fout.WriteLine("/* #undef HAVE_GCC_AND_SICORTEX_ASM */")
				Case "HAVE_GCC_INTRINSIC_ATOMICS"
					fout.WriteLine("/* #undef HAVE_GCC_INTRINSIC_ATOMICS */")
				Case "HAVE_SUN_ATOMIC_OPS"
					fout.WriteLine("/* #undef HAVE_SUN_ATOMIC_OPS */")
				Case "SYNC_LOCK_TEST_AND_SET_IS_SWAP"
					fout.WriteLine("/* #undef SYNC_LOCK_TEST_AND_SET_IS_SWAP */")
				Case "NEEDS_SYS_TIME_H"
					fout.WriteLine("/* #undef NEEDS_SYS_TIME_H */")
				Case "HAVE_ALARM"
					fout.WriteLine("/* #undef HAVE_ALARM */")
				Case "HAVE_SETITIMER"
					fout.WriteLine("/* #undef HAVE_SETITIMER */")
				Case "USE_MPI_FOR_NMPI"
					fout.WriteLine("/* #undef USE_MPI_FOR_NMPI */")
				Case "USE_MACROS_FOR_WTIME"
					fout.WriteLine("/* #undef USE_MACROS_FOR_WTIME */")
				Case "HAVE_CSHARP_BINDING"
					fout.WriteLine("/* #undef HAVE_CSHARP_BINDING */")
				Case "MPIR_REAL4_CTYPE"
					fout.WriteLine("/* #undef MPIR_REAL4_CTYPE */")
				Case "MPIR_REAL8_CTYPE"
					fout.WriteLine("/* #undef MPIR_REAL8_CTYPE */")
				Case "MPIR_REAL16_CTYPE"
					fout.WriteLine("/* #undef MPIR_REAL16_CTYPE */")
				Case "MPIR_INTEGER1_CTYPE"
					fout.WriteLine("/* #undef MPIR_INTEGER1_CTYPE */")
				Case "MPIR_INTEGER2_CTYPE"
					fout.WriteLine("/* #undef MPIR_INTEGER2_CTYPE */")
				Case "MPIR_INTEGER4_CTYPE"
					fout.WriteLine("/* #undef MPIR_INTEGER4_CTYPE */")
				Case "MPIR_INTEGER8_CTYPE"
					fout.WriteLine("/* #undef MPIR_INTEGER8_CTYPE */")
				Case "MPIR_INTEGER16_CTYPE"
					fout.WriteLine("/* #undef MPIR_INTEGER16_CTYPE */")
				Case "MPIR_CXX_COMPLEX_VALUE"
					fout.WriteLIne("#define MPIR_CXX_COMPLEX_VALUE "+ MPIR_CXX_COMPLEX)
				Case "MPIR_CXX_DOUBLE_COMPLEX_VALUE"
					fout.WriteLIne("#define MPIR_CXX_DOUBLE_COMPLEX_VALUE "+ MPIR_CXX_DOUBLE_COMPLEX)
				Case "MPIR_CXX_LONG_DOUBLE_COMPLEX_VALUE"
					fout.WriteLIne("#define MPIR_CXX_LONG_DOUBLE_COMPLEX_VALUE "+ MPIR_CXX_LONG_DOUBLE_COMPLEX)
				Case "HAVE___VA_COPY"
					fout.WriteLine("/* #undef HAVE___VA_COPY */")
				Case "HAVE_IOSTREAM"
					fout.WriteLine("#define HAVE_IOSTREAM 1")
				Case "HAVE_NAMESPACES"
					fout.WriteLine("#define HAVE_NAMESPACES 1")
				Case "HAVE_NAMESPACE_STD"
					fout.WriteLine("#define HAVE_NAMESPACE_STD 1")
				Case "HAVE_STDDEF_H"
					fout.WriteLine("#define HAVE_STDDEF_H 1")
				Case "HAVE_RUNTIME_THREADCHECK"
					fout.WriteLine("#ifdef MPICH_MULTITHREADED")
					fout.WriteLine("#define HAVE_RUNTIME_THREADCHECK 1")
					fout.WriteLine("#else")
					fout.WriteLine("/* #undef HAVE_RUNTIME_THREADCHECK */")
					fout.WriteLine("#endif")
				Case "MPICH_THREAD_LEVEL"
					fout.WriteLine("#ifdef MPICH_MULTITHREADED")
					fout.WriteLine("#define MPICH_THREAD_LEVEL MPI_THREAD_MULTIPLE")
					fout.WriteLine("#else")
					fout.WriteLine("#define MPICH_THREAD_LEVEL MPI_THREAD_SINGLE")
					fout.WriteLine("#endif")
                                Case "USE_THREAD_IMPL"
                                        fout.WriteLine("#ifdef MPICH_MULTITHREADED")
                                        fout.WriteLine("#define USE_THREAD_IMPL MPICH_THREAD_IMPL_GLOBAL_MUTEX")
                                        fout.WriteLine("#else")
                                        fout.WriteLine("#define USE_THREAD_IMPL MPICH_THREAD_IMPL_NONE")
                                        fout.WriteLine("#endif")
                                Case "MPIU_THREAD_PACKAGE_NAME"
                                        fout.WriteLine("#define MPIU_THREAD_PACKAGE_NAME MPIU_THREAD_PACKAGE_WIN")
				Case "MPIU_THREAD_REFCOUNT"
					fout.WriteLine("#define MPIU_THREAD_REFCOUNT MPIU_REFCOUNT_NONE")
				Case "MPIU_THREAD_GRANULARITY"
					fout.WriteLine("#ifdef MPICH_MULTITHREADED")
					fout.WriteLine("#define MPIU_THREAD_GRANULARITY MPIU_THREAD_GRANULARITY_GLOBAL")
					fout.WriteLine("#else")
					fout.WriteLine("#define MPIU_THREAD_GRANULARITY MPIU_THREAD_GRANULARITY_SINGLE")
					fout.WriteLine("#endif")
                                Case "MPIU_THREAD_SUPPRESS_PREDEFINED_REFCOUNTS"
                                        ' Currently we only build MPICH2 with global lock 
                                        ' -Introduce this option when building lock-free version
                                        fout.WriteLine("/* #undef MPIU_THREAD_SUPPRESS_PREDEFINED_REFCOUNTS */")
				Case "MPIU_HANDLE_ALLOCATION_METHOD"
					fout.WriteLine("#define MPIU_HANDLE_ALLOCATION_METHOD MPIU_HANDLE_ALLOCATION_MUTEX")
				Case "MPIU_MUTEX_WAIT_TIME"
					fout.WriteLine("/* #undef MPIU_MUTEX_WAIT_TIME */")
				Case "_REENTRANT"
					fout.WriteLine("/* #undef _REENTRANT */")
				Case "_THREAD_SAFE"
					fout.WriteLine("/* #undef _THREAD_SAFE */")
				Case "HAVE_SYS_POLL_H"
					fout.WriteLine("/* #undef HAVE_SYS_POLL_H */")
				Case "USE_IB_IBAL"
					fout.WriteLine("/* #undef USE_IB_IBAL */")
					fout.WriteLine("/* This is set in the project settings */")
				Case "USE_IB_VAPI"
					fout.WriteLine("/* #define USE_IB_VAPI */")
					fout.WriteLine("/* This is set in the project settings */")
				Case "MPID_IBU_TYPE_UNIX"
					fout.WriteLine("/* #undef MPID_IBU_TYPE_UNIX */")
					'fout.WriteLine("#define MPID_IBU_TYPE_WINDOWS 1")
				Case "HAVE_MALLOC_H"
					fout.WriteLine("#define HAVE_MALLOC_H 1")
				Case "MPICH_DEBUG_MEMINIT"
					fout.WriteLine("/* #undef MPICH_DEBUG_MEMINIT */")
				Case "C_ALLOCA"
					fout.WriteLine("/* #undef C_ALLOCA */")
				Case "HAVE_ALLOCA"
					fout.WriteLine("#define HAVE_ALLOCA 1")
					fout.WriteLine("#define alloca _alloca")
				Case "HAVE_ALLOCA_H"
					fout.WriteLine("/* #undef HAVE_ALLOCA_H */")
				Case "HAVE_PTHREAD_YIELD"
					fout.WriteLine("/* #undef HAVE_PTHREAD_YIELD */")
				Case "HAVE_PTHREAD_MUTEX_RECURSIVE"
					fout.WriteLine("/* #undef HAVE_PTHREAD_MUTEX_RECURSIVE */")
				Case "HAVE_PTHREAD_MUTEX_RECURSIVE_NP"
					fout.WriteLine("/* #undef HAVE_PTHREAD_MUTEX_RECURSIVE_NP */")
				Case "HAVE_MKSTEMP"
					fout.WriteLine("/* #undef HAVE_MKSTEMP */")
				Case "HAVE_O_BINARY"
					fout.WriteLine("#define HAVE_O_BINARY 1")
				Case "_FILE_OFFSET_BITS"
					fout.WriteLine("/* #undef _FILE_OFFSET_BITS */")
				Case "_LARGEFILE64_SOURCE"
					fout.WriteLine("/* #undef _LARGEFILE64_SOURCE */")
				Case "HAVE_MPI_COMM_F2C"
					fout.WriteLine("#define HAVE_MPI_COMM_F2C 1")
				Case "HAVE_MPI_ERRHANDLER_F2C"
					fout.WriteLine("#define HAVE_MPI_ERRHANDLER_F2C 1")
				Case "HAVE_MPI_GROUP_F2C"
					fout.WriteLine("#define HAVE_MPI_GROUP_F2C 1")
				Case "HAVE_MPI_IO"
					fout.WriteLine("#define HAVE_MPI_IO 1")
				Case "HAVE_MPI_OP_F2C"
					fout.WriteLine("#define HAVE_MPI_OP_F2C 1")
				Case "HAVE_MPI_REQUEST_F2C"
					fout.WriteLine("#define HAVE_MPI_REQUEST_F2C 1")
				Case "HAVE_MPI_RMA"
					fout.WriteLine("#define HAVE_MPI_RMA 1")
				Case "HAVE_MPI_STATUSES_IGNORE"
					fout.WriteLine("#define HAVE_MPI_STATUSES_IGNORE 1")
				Case "HAVE_MPI_STATUS_BROKEN_ON_PROC_NULL"
					fout.WriteLine("/* #undef HAVE_MPI_STATUS_BROKEN_ON_PROC_NULL */")
				Case "HAVE_MPI_STATUS_F2C"
					fout.WriteLine("#define HAVE_MPI_STATUS_F2C 1")
				Case "HAVE_MPI_STATUS_IGNORE"
					fout.WriteLine("#define HAVE_MPI_STATUS_IGNORE 1")
				Case "HAVE_MPI_TYPE_F2C"
					fout.WriteLine("#define HAVE_MPI_TYPE_F2C 1")
                                Case "HAVE_MPI_F_INIT_WORKS_WITH_C"
                                        fout.WriteLine("/* #undef HAVE_MPI_F_INIT_WORKS_WITH_C */")
				Case "HAVE_NO_MPIO_REQUEST"
					fout.WriteLine("/* #undef HAVE_NO_MPIO_REQUEST */")
				Case "HAVE_PROTOTYPES"
					fout.WriteLine("#define HAVE_PROTOTYPES 1")
				Case "MPE_F77_FALSE_VALUE"
					fout.WriteLine("#define MPE_F77_FALSE_VALUE 0")
				Case "MPE_F77_TRUE_VALUE"
					fout.WriteLine("#define MPE_F77_TRUE_VALUE -1")
				Case "MPI_Fint"
					fout.WriteLine("/* #undef MPI_Fint */")
				Case "MPI_STATUS_SIZE"
					fout.WriteLine("#define MPI_STATUS_SIZE 5")
				Case "USE_STDARG"
					fout.WriteLine("/* #undef USE_STDARG */")
				Case "HAVE_MPI_WTIME"
					fout.WriteLine("#define HAVE_MPI_WTIME 1")
				Case "STDCALL"
					fout.WriteLine("/* #undef STDCALL */")
				Case "MPICH_DEBUG_FINE_GRAIN_NESTING"
					fout.WriteLine("/* #undef MPICH_DEBUG_FINE_GRAIN_NESTING */")
				Case "HAVE_SPARC_INLINE_PROCESS_LOCKS"
					fout.WriteLine("/* #undef HAVE_SPARC_INLINE_PROCESS_LOCKS */")
				Case "HAVE_IOSTREAM_H"
					fout.WriteLine("/* #undef HAVE_IOSTREAM_H */")
				Case "HAVE_CXX_EXCEPTIONS"
					fout.WriteLine("#define HAVE_CXX_EXCEPTIONS 1")
				Case "bool"
					fout.WriteLine("/* bool */")
				Case "HAVE_ENDIAN_H"
					fout.WriteLine("/* HAVE_ENDIAN_H */")
				Case "WORDS_UNIVERSAL_ENDIAN"
					fout.WriteLine("#undef WORDS_UNIVERSAL_ENDIAN")
				Case "NEEDS_VSNPRINTF_DECL"
					fout.WriteLine("/* NEEDS_VSNPRINTF_DECL */")
				Case "NEEDS_GETHOSTNAME_DECL"
					fout.WriteLine("/* NEEDS_GETHOSTNAME_DECL */")
				Case "NEEDS_MKSTEMP_DECL"
					fout.WriteLine("/* NEEDS_MKSTEMP_DECL */")
				Case "HAVE_MPI_RMA_LOCK"
					fout.WriteLine("#define HAVE_MPI_RMA_LOCK 1")
				Case "HAVE_MPI_RMA_TEST"
					fout.WriteLine("#define HAVE_MPI_RMA_TEST 1")
				Case "HAVE_MPI_F_STATUS_IGNORE"
					fout.WriteLine("#define HAVE_MPI_F_STATUS_IGNORE 1")
				Case "HAVE_MPI_F_STATUSES_IGNORE"
					fout.WriteLine("#define HAVE_MPI_F_STATUSES_IGNORE 1")
				Case "AIO_SIGNOTIFY_NONE"
					fout.WriteLine("/* #undef AIO_SIGNOTIFY_NONE */")
				Case "AIX"
					fout.WriteLine("/* #undef AIX */")
				Case "CRAY"
					fout.WriteLine("/* #undef CRAY */")
				Case "HAVE_AIO_H"
					fout.WriteLine("/* #undef HAVE_AIO_H */")
				Case "HAVE_FSYNC"
					fout.WriteLine("/* #undef HAVE_FSYNC */")
				Case "HAVE_FTRUNCATE"
					fout.WriteLine("/* #undef HAVE_FTRUNCATE */")
				Case "HAVE_LONG_LONG_64"
					fout.WriteLine("/* #undef HAVE_LONG_LONG_64 */")
				Case "HAVE_LSTAT"
					fout.WriteLine("/* #undef HAVE_LSTAT */")
				Case "HAVE_MEMALIGN"
					fout.WriteLine("/* #undef HAVE_MEMALIGN */")
				Case "HAVE_MPI_COMBINERS"
					fout.WriteLine("/* #undef HAVE_MPI_COMBINERS */")
				Case "HAVE_MPI_DARRAY_SUBARRAY"
					fout.WriteLine("#define HAVE_MPI_DARRAY_SUBARRAY 1")
				Case "HAVE_MPI_GREQUEST"
					fout.WriteLine("#define HAVE_MPI_GREQUEST 1")
				Case "HAVE_MPI_INFO"
					fout.WriteLine("#define HAVE_MPI_INFO 1")
				Case "HAVE_MPI_LONG_LONG_INT"
					fout.WriteLine("/* #undef HAVE_MPI_LONG_LONG_INT */")
				Case "HAVE_PREAD64"
					fout.WriteLine("/* #undef HAVE_PREAD64 */")
				Case "HAVE_PVFS2_H"
					fout.WriteLine("/* #undef HAVE_PVFS2_H */")
				Case "HAVE_PVFS2_SUPER_MAGIC"
					fout.WriteLine("/* #undef HAVE_PVFS2_SUPER_MAGIC */")
				Case "HAVE_PVFS_H"
					fout.WriteLine("/* #undef HAVE_PVFS_H */")
				Case "HAVE_PVFS_SUPER_MAGIC"
					fout.WriteLine("/* #undef HAVE_PVFS_SUPER_MAGIC */")
				Case "HAVE_READLINK"
					fout.WriteLine("/* #undef HAVE_READLINK */")
				Case "HAVE_SIGNAL_H"
					fout.WriteLine("/* #undef HAVE_SIGNAL_H */")
				Case "HAVE_STAT"
					fout.WriteLine("/* #undef HAVE_STAT */")
				Case "HAVE_STATUS_SET_BYTES"
					fout.WriteLine("#define HAVE_STATUS_SET_BYTES 1")
				Case "HAVE_STATVFS"
					fout.WriteLine("/* #undef HAVE_STATVFS */")
				Case "HAVE_STRUCT_STATFS"
					fout.WriteLine("/* #undef HAVE_STRUCT_STATFS */")
				Case "HAVE_SYS_AIO_H"
					fout.WriteLine("/* #undef HAVE_SYS_AIO_H */")
				Case "HAVE_SYS_MOUNT_H"
					fout.WriteLine("/* #undef HAVE_SYS_MOUNT_H */")
				Case "HAVE_SYS_STATVFS_H"
					fout.WriteLine("/* #undef HAVE_SYS_STATVFS_H */")
				Case "HAVE_SYS_VFS_H"
					fout.WriteLine("/* #undef HAVE_SYS_VFS_H */")
				Case "HPUX"
					fout.WriteLine("/* #undef HPUX */")
				Case "INT_LT_POINTER"
					fout.WriteLine("/* #undef INT_LT_POINTER */")
				Case "IRIX"
					fout.WriteLine("/* #undef IRIX */")
				Case "MPICH"
					fout.WriteLine("/* #undef MPICH */")
				Case "MPIHP"
					fout.WriteLine("/* #undef MPIHP */")
				Case "MPILAM"
					fout.WriteLine("/* #undef MPILAM */")
				Case "MPISGI"
					fout.WriteLine("/* #undef MPISGI */")
				Case "MPI_OFFSET_IS_INT"
					fout.WriteLine("/* #undef MPI_OFFSET_IS_INT */")
				Case "NEEDS_FSYNC_DECL"
					fout.WriteLine("/* #undef NEEDS_FSYNC_DECL */")
				Case "NEEDS_FTRUNCATE_DECL"
					fout.WriteLine("/* #undef NEEDS_FTRUNCATE_DECL */")
				Case "NEEDS_INT_CAST_WITH_FLOCK"
					fout.WriteLine("/* #undef NEEDS_INT_CAST_WITH_FLOCK */")
				Case "NEEDS_LSTAT_DECL"
					fout.WriteLine("/* #undef NEEDS_LSTAT_DECL */")
				Case "NEEDS_MPI_TEST"
					fout.WriteLine("/* #undef NEEDS_MPI_TEST */")
				Case "NEEDS_READLINK_DECL"
					fout.WriteLine("/* #undef NEEDS_READLINK_DECL */")
				Case "NO_MPI_SGI_type_is_contig"
					fout.WriteLine("/* #undef NO_MPI_SGI_type_is_contig */")
				Case "PRINT_ERR_MSG"
					fout.WriteLine("/* #undef PRINT_ERR_MSG */")
				Case "ROMIO_GRIDFTP"
					fout.WriteLine("/* #undef ROMIO_GRIDFTP */")
				Case "ROMIO_HAVE_AIO_CALLS_NEED_FILEDES"
					fout.WriteLine("/* #undef ROMIO_HAVE_AIO_CALLS_NEED_FILEDES */")
				Case "ROMIO_HAVE_AIO_SUSPEND_TWO_ARGS"
					fout.WriteLine("/* #undef ROMIO_HAVE_AIO_SUSPEND_TWO_ARGS */")
				Case "ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_FILDES"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_FILDES */")
				Case "ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_HANDLE"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_HANDLE */")
				Case "ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_REQPRIO"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_REQPRIO */")
				Case "ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_SIGEVENT"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_SIGEVENT */")
				Case "ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_WHENCE"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_WHENCE */")
				Case "ROMIO_HAVE_STRUCT_STATFS_WITH_F_FSTYPENAME"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_STATFS_WITH_F_FSTYPENAME */")
				Case "ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE */")
				Case "ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE"
					fout.WriteLine("/* #undef ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE */")
				Case "ROMIO_HAVE_WORKING_AIO"
					fout.WriteLine("/* #undef ROMIO_HAVE_WORKING_AIO */")
				Case "ROMIO_HFS"
					fout.WriteLine("/* #undef ROMIO_HFS */")
				Case "ROMIO_INSIDE_MPICH2"
					fout.WriteLine("#define ROMIO_INSIDE_MPICH2 1")
				Case "ROMIO_NFS"
					fout.WriteLine("/* #undef ROMIO_NFS */")
				Case "ROMIO_PANFS"
					fout.WriteLine("/* #undef ROMIO_PANFS */")
				Case "ROMIO_PFS"
					fout.WriteLine("/* #undef ROMIO_PFS */")
				Case "ROMIO_PVFS"
					fout.WriteLine("/* #undef ROMIO_PVFS */")
				Case "ROMIO_PVFS2"
					fout.WriteLine("/* #undef ROMIO_PVFS2 */")
				Case "ROMIO_PVFS_NEEDS_INT64_DEFINITION"
					fout.WriteLine("/* #undef ROMIO_PVFS_NEEDS_INT64_DEFINITION */")
				Case "ROMIO_SFS"
					fout.WriteLine("/* #undef ROMIO_SFS */")
				Case "ROMIO_TESTFS"
					fout.WriteLine("/* #undef ROMIO_TESTFS */")
				Case "ROMIO_UFS"
					fout.WriteLine("/* #undef ROMIO_UFS */")
				Case "ROMIO_XFS"
					fout.WriteLine("/* #undef ROMIO_XFS */")
				Case "SPPUX"
					fout.WriteLine("/* #undef SPPUX */")
				Case "SX4"
					fout.WriteLine("/* #undef SX4 */")
                                Case "HAVE_LSEEK64"
                                        ' lseeki64 is available on windows
                                        fout.WriteLine("/* #undef HAVE_LSEEK64 */")
                                Case "NEEDS_LSEEK64_DECL"
                                        fout.WriteLine("/* #undef NEEDS_LSEEK64_DECL */")
				Case "USE_DBG_LOGGING"
					fout.WriteLine("/* #undef USE_DBG_LOGGING */")
				Case "HAVE_CFUUIDCREATE"
					fout.WriteLine("/* #undef HAVE_CFUUIDCREATE */")
				Case "HAVE_TIME"
					fout.WriteLine("#define HAVE_TIME 1")
				Case "HAVE_TIME_H"
					fout.WriteLine("#define HAVE_TIME_H 1")
				Case "HAVE_UUID_GENERATE"
					fout.WriteLine("/* #undef HAVE_UUID_GENERATE */")
				Case "HAVE_LRAND48"
					fout.WriteLine("/* #undef HAVE_LRAND48 */")
				Case "HAVE_SRAND48"
					fout.WriteLine("/* #undef HAVE_SRAND48 */")
				Case "NEEDS_LRAND48_DECL"
					fout.WriteLine("/* #undef NEEDS_LRAND48_DECL */")
				Case "NEEDS_SRAND48_DECL"
					fout.WriteLine("/* #undef NEEDS_SRAND48_DECL */")
				Case "HAVE_SHM_RW"
					fout.WriteLine("/* #undef HAVE_SHM_RW */")
				Case "HAVE_WORKING_SHMGET"
					fout.WriteLine("/* #undef HAVE_WORKING_SHMGET */")
				Case "HAVE_PMPI_COMM_CREATE_KEYVAL"
					fout.WriteLine("#define HAVE_PMPI_COMM_CREATE_KEYVAL 1")
				Case "HAVE_PMPI_COMM_FREE_KEYVAL"
					fout.WriteLine("#define HAVE_PMPI_COMM_FREE_KEYVAL 1")
				Case "HAVE_PMPI_COMM_GET_ATTR"
					fout.WriteLine("#define HAVE_PMPI_COMM_GET_ATTR 1")
				Case "HAVE_PMPI_COMM_SET_ATTR"
					fout.WriteLine("#define HAVE_PMPI_COMM_SET_ATTR 1")
				Case "_XOPEN_SOURCE"
					fout.WriteLine("/* #undef _XOPEN_SOURCE */")
				Case "HAVE_SYS_MSG_H"
					fout.WriteLine("/* #undef HAVE_SYS_MSG_H */")
				Case "HAVE_INET_PTON"
					fout.WriteLine("/* #undef HAVE_INET_PTON */")
				Case "_LARGE_FILES"
					fout.WriteLine("/* #undef _LARGE_FILES */")
				Case "HAVE_MAX_DOUBLE_FP_ALIGNMENT"
					fout.WriteLine("#define HAVE_MAX_DOUBLE_FP_ALIGNMENT 8")
				Case "HAVE_MAX_LONG_DOUBLE_FP_ALIGNMENT"
					fout.WriteLine("#define HAVE_MAX_LONG_DOUBLE_FP_ALIGNMENT 8")
				Case "SIZEOF_BOOL"
					fout.WriteLine("#define SIZEOF_BOOL 1")
				Case "SIZEOF_COMPLEX"
					fout.WriteLine("#define SIZEOF_COMPLEX 8")
				Case "SIZEOF_DOUBLECOMPLEX"
					fout.WriteLine("#define SIZEOF_DOUBLECOMPLEX 16")
				Case "SIZEOF_LONGDOUBLECOMPLEX"
					fout.WriteLine("#define SIZEOF_LONGDOUBLECOMPLEX 16")
				Case "size_t"
					fout.WriteLine("/* #define size_t unsigned */")
				Case "HAVE_UTIL_SHM"
					fout.WriteLine("#undef HAVE_UTIL_SHM")
				Case "HAVE_UTIL_SOCK"
					fout.WriteLine("#undef HAVE_UTIL_SOCK")
				Case "MPI_AINT_IS_LONG_INT"
					fout.WriteLine("#define MPI_AINT_IS_LONG_INT 1")
				Case "MPI_AINT_IS_LONG_LONG_INT"
					fout.WriteLine("#define MPI_AINT_IS_LONG_LONG_INT 0")
				Case "pid_t"
					fout.WriteLine("#define pid_t int")
				Case "CLOG_IMPL"
					fout.WriteLine("#undef CLOG_IMPL")
				Case "FIX_STDINT_ORDER"
					fout.WriteLine("#undef FIX_STDINT_ORDER")
				Case "HAVE_CRAY_FCD_STRING"
					fout.WriteLine("#undef HAVE_CRAY_FCD_STRING")
				Case "HAVE_CRAY_FCD_LOGICAL"
					fout.WriteLine("#undef HAVE_CRAY_FCD_LOGICAL")
				Case "HAVE_MPI_SPAWN"
					fout.WriteLine("#undef HAVE_MPI_SPAWN")
				Case "MAKE_SAFE_PMPI_CALL"
					fout.WriteLine("#undef MAKE_SAFE_PMPI_CALL")
				Case "HAVE_MPI_NAMING"
					fout.WriteLine("#undef HAVE_MPI_NAMING")
				Case "HAVE_INT_LT_POINTER"
					If b64 Then
						fout.WriteLine("#define HAVE_INT_LT_POINTER 1")
					Else
						fout.WriteLine("#undef HAVE_INT_LT_POINTER")
					End If
				Case "HAVE_ANY_INT32_T_ALIGNMENT"
					fout.WriteLine("#define HAVE_ANY_INT32_T_ALIGNMENT 1")
				Case "HAVE_ANY_INT64_T_ALIGNMENT"
					fout.WriteLine("#define HAVE_ANY_INT64_T_ALIGNMENT 1")
				Case "WORDS_LITTLEENDIAN"
					fout.WriteLine("#define WORDS_LITTLEENDIAN 1")
				Case "HAVE_STRUCT_IFCONF"
					fout.WriteLine("#undef HAVE_STRUCT_IFCONF")
				Case "USE_SVIDSOURCE_FOR_IFCONF"
					fout.WriteLine("#undef USE_SVIDSOURCE_FOR_IFCONF")
                                Case "USE_ALL_SOURCE_FOR_IFCONF"
                                        fout.WriteLine("/* #undef USE_ALL_SOURCE_FOR_IFCONF */")
				Case "HAVE_SYSCTL"
					fout.WriteLine("#undef HAVE_SYSCTL")
				Case "HAVE_SYS_SYSCTL_H"
					fout.WriteLine("#undef HAVE_SYS_SYSCTL_H")
				' Define to enable nemesis checkpointing
				Case "ENABLED_CHECKPOINTING"
					fout.WriteLine("/* #undef ENABLED_CHECKPOINTING */")
				' Define to disable shm communicn in nemesis 
				' - for debugging
				Case "ENABLED_NO_LOCAL"
					fout.WriteLine("/* #undef ENABLED_NO_LOCAL */")
				' Define to enable shm communicn btw even procs or
				' odd procs in nemesis - for debugging
				Case "ENABLED_ODD_EVEN_CLIQUES"
					fout.WriteLine("/* #undef ENABLED_ODD_EVEN_CLIQUES */")
				' Define to enable shared memory collectives in nemesis
				Case "ENABLED_SHM_COLLECTIVES"
					fout.WriteLine("/* #undef ENABLED_SHM_COLLECTIVES */")
				Case "ENABLE_COMM_OVERRIDES"
					fout.WriteLine("/* #undef ENABLE_COMM_OVERRIDES */")
				Case "USE_PIPE_COLLECTIVES"
					fout.WriteLine("#define USE_PIPE_COLLECTIVES")
				' Define to remove SwithToThread in polling loops in nemesis
				'Case "ENABLE_NO_SCHED_YIELD"
				'	fout.WriteLine("/* #undef ENABLE_NO_SCHED_YIELD */")
				Case "ENABLE_NO_YIELD"
					fout.WriteLine("/* #undef ENABLE_NO_YIELD */")
				' Define for lfence within _asm{} in nemesis
				Case "HAVE_ASM_AND_X86_LFENCE"
					fout.WriteLIne("/* #undef HAVE_ASM_AND_X86_LFENCE */")
				' Define for mfence within _asm{} in nemesis
				Case "HAVE_ASM_AND_X86_MFENCE"
					fout.WriteLIne("/* #undef HAVE_ASM_AND_X86_MFENCE */")
				' Define for sfence within _asm{} in nemesis
				Case "HAVE_ASM_AND_X86_SFENCE"
					fout.WriteLIne("/* #undef HAVE_ASM_AND_X86_SFENCE */")
				' Define for lfence within _asm{} +gcc in nemesis
				Case "HAVE_GCC_ASM_AND_X86_LFENCE"
					fout.WriteLIne("/* #undef HAVE_GCC_ASM_AND_X86_LFENCE */")
				' Define for mfence within _asm{} +gcc in nemesis
				Case "HAVE_GCC_ASM_AND_X86_MFENCE"
					fout.WriteLIne("/* #undef HAVE_GCC_ASM_AND_X86_MFENCE */")
				' Define for sfence within _asm{} in nemesis
				Case "HAVE_GCC_ASM_AND_X86_SFENCE"
					fout.WriteLIne("/* #undef HAVE_GCC_ASM_AND_X86_SFENCE */")
				' Define to turn on inline opt in nemesis
				Case "MPID_NEM_INLINE"
					fout.WriteLine("#define MPID_NEM_INLINE 1")
				' Choosing the net module in nemesis
				Case "MPID_NEM_NET_MODULE"
					fout.WriteLine("#define MPID_NEM_NET_MODULE MPID_NEM_NEWTCP_MODULE")
				Case "MPID_MAD_MODULE_MULTIRAIL"
					fout.WriteLine("/* #undef MPID_MAD_MODULE_MULTIRAIL */")
				' Define if SYSV shm available 
				Case "HAVE_SYSV_SHARED_MEM"
					fout.WriteLine("/* #undef HAVE_SYSV_SHARED_MEM */")
				' Define to turn on prefetching opt in nemesis
				Case "PREFETCH_CELL"
					fout.WriteLine("#define PREFETCH_CELL 1")
				' Define to use fastboxes in nemesis
				Case "USE_FASTBOX"
					fout.WriteLine("#define USE_FASTBOX 1")
				Case "HAVE_LIBCKPT"
					fout.WriteLine("/* #undef HAVE_LIBCKPT */")
				Case "HAVE_LIBCLI"
					fout.WriteLine("/* #undef HAVE_LIBCLI */")
				Case "HAVE_LIBELAN"
					fout.WriteLine("/* #undef HAVE_LIBELAN */")
				Case "HAVE_LIBGM"
					fout.WriteLine("/* #undef HAVE_LIBGM */")
				Case "HAVE_LIBIBVERBS"
					fout.WriteLine("/* #undef HAVE_LIBIBVERBS */")
				Case "HAVE_LIBMYRIEXPRESS"
					fout.WriteLine("/* #undef HAVE_LIBMYRIEXPRESS */")
				Case "HAVE_LIBPSM_INFINIPATH"
					fout.WriteLine("/* #undef HAVE_LIBPSM_INFINIPATH */")
				Case "HAVE_LIBSCTP"
					fout.WriteLine("/* #undef HAVE_LIBSCTP */")
				Case "HAVE_LIBNMAD"
					fout.WriteLine("/* #undef HAVE_LIBNMAD */")
				Case "HAVE_MUNMAP"
					fout.WriteLine("/* #undef HAVE_MUNMAP */")
				Case "HAVE_RAND"
					fout.WriteLIne("/* #undef HAVE_RAND */")
				Case "HAVE_SRAND"
					fout.WriteLine("/* #undef HAVE_SRAND */")
				Case "HAVE_STRTOLL"
					fout.WriteLine("/* #undef HAVE_STRTOLL */")
				Case "HAVE_ZOIDFS_H"
					fout.WriteLine("#undef HAVE_ZOIDFS_H")
				Case "HAVE_MPIU_FUNCS"
					fout.WriteLine("#define HAVE_MPIU_FUNCS 1")
				Case "ROMIO_BGL"
					fout.WriteLine("#undef ROMIO_BGL")
				Case "ROMIO_BGLOCKLESS"
					fout.WriteLine("#undef ROMIO_BGLOCKLESS")
				Case "ROMIO_LUSTRE"
					fout.WriteLine("#undef ROMIO_LUSTRE")
                                Case "HAVE_LUSTRE_LUSTRE_USER_H"
                                        fout.WriteLine("/* #undef HAVE_LUSTRE_LUSTRE_USER_H */")
				Case "ROMIO_ZOIDFS"
					fout.WriteLine("#undef ROMIO_ZOIDFS")
				Case "CRAY_STACKSEG_END"
					fout.WriteLine("#undef CRAY_STACKSEG_END")
				Case "HAVE_BINDPROCESSOR"
					fout.WriteLine("#undef HAVE_BINDPROCESSOR")
				Case "HAVE_CPU_SET_MACROS"
					fout.WriteLine("#undef HAVE_CPU_SET_MACROS")
				Case "HAVE_CPU_SET_T"
					fout.WriteLine("#undef HAVE_CPU_SET_T")
				Case "HAVE_CXX_COMPLEX"
					fout.WriteLine("#define HAVE_CXX_COMPLEX 1")
				Case "HAVE_DLSYM"
					fout.WriteLine("#undef HAVE_DLSYM")
				Case "HAVE_DOUBLE_ALIGNMENT_EXCEPTION"
					' FIXME: Doesn't windows 64-bit have alignment exception ? 
					fout.WriteLine("#undef HAVE_DOUBLE_ALIGNMENT_EXCEPTION")
				Case "HAVE_F90_TYPE_ROUTINES"
					fout.WriteLine("#define HAVE_F90_TYPE_ROUTINES")
				Case "HAVE_GETPID"
					fout.WriteLine("#undef HAVE_GETPID")
				Case "HAVE_MPICHCONF"
					fout.WriteLine("#define HAVE_MPICHCONF 1")
				Case "HAVE_OSX_THREAD_AFFINITY"
					fout.WriteLine("#undef HAVE_OSX_THREAD_AFFINITY")
				Case "HAVE_PTHREAD_CLEANUP_PUSH"
					fout.WriteLine("#undef HAVE_PTHREAD_CLEANUP_PUSH")
				Case "HAVE_PTHREAD_CLEANUP_PUSH_MACRO"
					fout.WriteLine("#undef HAVE_PTHREAD_CLEANUP_PUSH_MACRO")
				Case "HAVE_RUNTIME_THREADCHECK"
					fout.WriteLine("#define HAVE_RUNTIME_THREADCHECK 1")
				Case "HAVE_SCHED_GETAFFINITY"
					fout.WriteLine("#undef HAVE_SCHED_GETAFFINITY")
				Case "HAVE_SCHED_SETAFFINITY"
					fout.WriteLine("#undef HAVE_SCHED_SETAFFINITY")
				Case "HAVE_THREAD_POLICY_SET"
					fout.WriteLine("#undef HAVE_THREAD_POLICY_SET")
				Case "LINUX86_CYCLE_CPUID_RDTSC"
					fout.WriteLine("#undef LINUX86_CYCLE_CPUID_RDTSC")
				Case "LINUX86_CYCLE_RDTSC"
					fout.WriteLine("#undef LINUX86_CYCLE_RDTSC")
				Case "LINUX86_CYCLE_RDTSCP"
					fout.WriteLine("#undef LINUX86_CYCLE_RDTSCP")
                                Case "LINUX86_CYCLE_CPUID_RDTSC32"
                                        fout.WriteLine("/* #undef LINUX86_CYCLE_CPUID_RDTSC32 */")
                                Case "LINUX86_CYCLE_CPUID_RDTSC64"
                                        fout.WriteLine("/* #undef LINUX86_CYCLE_CPUID_RDTSC64 */")
				Case "MPICH2_LIBDIR"
					fout.WriteLine("#undef MPICH2_LIBDIR")
                                Case "MPICH_DEBUG_MUTEXNESTING"
                                        fout.WriteLine("/* #undef MPICH_DEBUG_MUTEXNESTING */")
				Case "MPICH_DEBUG_MEMARENA"
					fout.WriteLine("#undef MPICH_DEBUG_MEMARENA")
				Case "MPICH_DEBUG_MUTEX"
					fout.WriteLine("#undef MPICH_DEBUG_MUTEX")
				Case "MPICH_DEBUG_HANDLEALLOC"
					fout.WriteLine("/* #undef MPICH_DEBUG_HANDLEALLOC */")
				Case "STACK_DIRECTION"
					fout.WriteLine("#undef STACK_DIRECTION")
				Case "USE_ALLOCA"
					fout.WriteLine("#undef USE_ALLOCA")
				Case "USE_DYNAMIC_LIBRARIES"
					fout.WriteLine("#undef USE_DYNAMIC_LIBRARIES")
				Case "HAVE_MPIDI_CH3_CONF"
					fout.WriteLine("#define HAVE_MPIDI_CH3_CONF 1")
				Case "USE_NOPOSIX_FOR_IFCONF"
					fout.WriteLine("#undef USE_NOPOSIX_FOR_IFCONF")
				Case "HAVE_MPIDI_CH3SOCKCONF"
					fout.WriteLine("#define HAVE_MPIDI_CH3SOCKCONF")
				Case "HAVE_GCC_ASM_SPARC_MEMBAR"
					fout.WriteLine("#undef HAVE_GCC_ASM_SPARC_MEMBAR")
				Case "HAVE_GCC_ASM_SPARC_STBAR"
					fout.WriteLine("#undef HAVE_GCC_ASM_SPARC_STBAR")
				Case "HAVE_SOLARIS_ASM_SPARC_MEMBAR"
					fout.WriteLine("#undef HAVE_SOLARIS_ASM_SPARC_MEMBAR")
				Case "HAVE_SOLARIS_ASM_SPARC_STBAR"
					fout.WriteLine("#undef HAVE_SOLARIS_ASM_SPARC_STBAR")
				Case "GCC_X86_CYCLE_CPUID_RDTSC"
					fout.WriteLine("/* #undef GCC_X86_CYCLE_CPUID_RDTSC */")
				Case "GCC_X86_CYCLE_RDTSC"
					fout.WriteLine("/* #undef GCC_X86_CYCLE_RDTSC */")
				Case "GCC_X86_CYCLE_RDTSCP"
					fout.WriteLine("/* #undef GCC_X86_CYCLE_RDTSCP */")
				Case "HAVE_LIBPTHREAD"
					fout.WriteLine("#undef HAVE_LIBPTHREAD")
				Case "HAVE_O_LARGEFILE"
					fout.WriteLine("#undef HAVE_O_LARGEFILE")
				Case "HAVE_MPI_INIT_THREAD"
					fout.WriteLine("#define HAVE_MPI_INIT_THREAD 1")
				Case "HAVE_EXECINFO_H"
					fout.WriteLine("#undef HAVE_EXECINFO_H")
				Case "HAVE_FDOPEN"
					fout.WriteLine("#undef HAVE_FDOPEN")
				Case "HAVE_UCONTEXT_H"
					fout.WriteLine("#undef HAVE_UCONTEXT_H")
				Case "NEEDS_FDOPEN_DECL"
					fout.WriteLine("/* #undef NEEDS_FDOPEN_DECL */")
				Case "HAVE_H_ADDR_LIST"
					fout.WriteLine("#define HAVE_H_ADDR_LIST 1")
				Case "HAVE_CAP__FUNC__"
					fout.WriteLine("/* #undef HAVE_CAP__FUNC__ */")
				Case "HAVE__FUNC__"
					fout.WriteLine("/* #undef HAVE__FUNC__ */")
				Case "HAVE__FUNCTION__"
					fout.WriteLine("#define HAVE__FUNCTION__ 1")
				Case "HAVE_MEMCHECK_H"
					fout.WriteLine("/* #undef HAVE_MEMCHECK_H */")
                                Case "HAVE_VALGRIND_MEMCHECK_H"
                                        fout.WriteLine("/* #undef HAVE_VALGRIND_MEMCHECK_H */")
				Case "HAVE_VALGRIND_H"
					fout.WriteLine("/* #undef HAVE_VALGRIND_H */")
                                Case "HAVE_VALGRIND_VALGRIND_H"
                                        fout.WriteLine("/* #undef HAVE_VALGRIND_VALGRIND_H */")
				Case "USE_SMP_COLLECTIVES"
					fout.WriteLine("#define USE_SMP_COLLECTIVES 1")
				Case "CH3_RANK_BITS"
					fout.WriteLine("#define CH3_RANK_BITS 16")
                                Case "NEEDS_STRNCASECMP_DECL"
                                        fout.WriteLine("/* #undef NEEDS_STRNCASECMP_DECL */")
                                Case "HAVE_KNEM_IO_H"
                                        fout.WriteLine("/* #undef HAVE_KNEM_IO_H */")
                                Case "MPID_NEM_LOCAL_LMT_IMPL"
                                        fout.WriteLine("#define MPID_NEM_LOCAL_LMT_IMPL MPID_NEM_LOCAL_LMT_SHM_COPY")
                                Case "MPID_NEM_USE_LOCK_FREE_QUEUES"
                                        fout.WriteLine("#define MPID_NEM_USE_LOCK_FREE_QUEUES 1")
                                Case "USE_MMAP_SHM"
                                        fout.WriteLine("/* #undef USE_MMAP_SHM */")
                                Case "USE_SYSV_SHM"
                                        fout.WriteLine("/* #undef USE_SYSV_SHM */")
                                Case "HAVE_MPI_2DOUBLE_COMPLEX"
                                        fout.WriteLine("#define HAVE_MPI_2DOUBLE_COMPLEX 1")
                                Case "HAVE_MPI_INTEGER16"
                                        fout.WriteLine("#define HAVE_MPI_INTEGER16 1")
                                Case "MPIO_USES_MPI_REQUEST"
                                        fout.WriteLine("#define MPIO_USES_MPI_REQUEST 1")
                                Case "USE_STRICT_MPI"
                                        fout.WriteLine("/* #undef USE_STRICT_MPI */")
                                Case "USE_PMI2_API"
                                        ' SMPD does not support PMI2
                                        fout.WriteLine("/* #undef USE_PMI2_API */")
                                Case "HAVE_MD5_H"
                                        fout.WriteLine("/* #undef HAVE_MD5_H */")
                                Case "HAVE_OPENSSL_MD5_H"
                                        fout.WriteLine("/* #undef HAVE_OPENSSL_MD5_H */")
                                Case "HAVE_MD5"
                                        fout.WriteLine("/* #undef HAVE_MD5 */")
                                Case "HAVE_MD5_CALC"
                                        fout.WriteLine("/* #undef HAVE_MD5_CALC */")
                                Case "HAVE_MACRO_VA_ARGS"
                                        fout.WriteLine("#define HAVE_MACRO_VA_ARGS")
                                ' On windows sizeof(void *p) == sizeof(aint) . So we don't
                                '  have to rely on aint to store attrval
                                Case "USE_AINT_FOR_ATTRVAL"
                                        fout.WriteLine("/* #undef USE_AINT_FOR_ATTRVAL */")
                                Case "AC_APPLE_UNIVERSAL_BUILD"
                                        fout.WriteLine("/* #undef AC_APPLE_UNIVERSAL_BUILD */")
                                ' The following option is related to unix build system, whether
                                '  it accepts -c -o
                                ' Not applicable on windows
                                Case "NO_MINUS_C_MINUS_O"
                                        fout.WriteLine("/* #undef NO_MINUS_C_MINUS_O */")
                                ' Disable falut tolerance code on windows
                                Case "ENABLE_FTB"
                                        fout.WriteLine("/* #undef ENABLE_FTB */")
                                Case "HAVE_LIBFTB"
                                        fout.WriteLine("/* #undef HAVE_LIBFTB */")
                                ' FIXME: The size of openpa ptr should not be hardcoded...
                                Case "SIZEOF_OPA_PTR_T"
                                        If b64 Then
                                            fout.WriteLine("#define SIZEOF_OPA_PTR_T 8")
                                        Else
                                            fout.WriteLine("#define SIZEOF_OPA_PTR_T 4")
                                        End if
                                Case "USE_ASYNC_PROGRESS"
                                        fout.WriteLine("/* #undef USE_ASYNC_PROGRESS */")
				Case Else
					'MsgBox("Unhandled definition <" & define & ">")
					If appendUniqueString(unhandled_definitions, macroname) Then
						unhandled_definitions_count = unhandled_definitions_count + 1
					End If
					unhandled_definitions_instances = unhandled_definitions_instances + 1
					fout.WriteLine("/* unknown definition: " & macroname & " */")
			End Select
			fout.WriteLine("")
		Next
	End If
End Sub

printMsg "STATUS", "Creating MPICH2 header files..."
printMsg "STATUS", "Creating generic header files..."

'
' Generate mpi.h
'
if not f.FolderExists("src\include\win64") then
	f.CreateFolder("src\include\win64")
end if
printMsg "VERBOSE", "Creating src\include\win64\mpi.h"
set fout64 = f.CreateTextFile("src\include\win64\mpi.h")
if not f.FolderExists("src\include\win32") then
	f.CreateFolder("src\include\win32")
end if
printMsg "VERBOSE", "Creating src\include\win32\mpi.h"
set fout32 = f.CreateTextFile("src\include\win32\mpi.h")
set fin = f.OpenTextFile("src\include\mpi.h.in")

contents32 = fin.ReadAll()
contents64 = contents32
fin.Close()
contents32 = ReplaceAts(contents32, false, false)
contents64 = ReplaceAts(contents64, false, true)
if bAddDllDecoration then
	contents32 = DecorateMPIFuncs(contents32)
	contents64 = DecorateMPIFuncs(contents64)
'	' uncomment out the HAVE_EXPORTS_MPI_API block
'	'contents = ReplaceBetweenTags(contents, "/*", "HAVE_EXPORT_MPI_API", "*/", "#ifdef MPICH2_STATIC_LIBRARY" & vbCrLf & "#define EXPORT_MPI_API" & vbCrLf & "#else" & vbCrLf & "#ifdef MPICH2_EXPORTS" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllexport)" & vbCrLf & "#else" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllimport)" & vbCrLf & "#endif" & vbCrLf & "#endif" & vbCrLf & "#ifndef MPI_CALL" & vbCrLf & "#define MPI_CALL __cdecl" & vbCrLf & "#endif" & vbCrLf)
'	contents = Replace(contents, "/* --Insert Additional Definitions Here-- */", "#ifdef MPICH2_STATIC_LIBRARY" & vbCrLf & "#define EXPORT_MPI_API" & vbCrLf & "#else" & vbCrLf & "#ifdef MPICH2_EXPORTS" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllexport)" & vbCrLf & "#else" & vbCrLf & "#define EXPORT_MPI_API __declspec(dllimport)" & vbCrLf & "#endif" & vbCrLf & "#endif" & vbCrLf & "#ifndef MPI_CALL" & vbCrLf & "#define MPI_CALL __cdecl" & vbCrLf & "#endif" & vbCrLf)
'	' add dllspec and calling convention to the MPI api
'	first_index = InStr(contents, "#ifndef MPICH_SUPPRESS_PROTOTYPES")
'	last_index = InStr(contents, "#endif /* MPICH_SUPPRESS_PROTOTYPES */")
'	if first_index <> 0 and last_index <> 0 then
'		prototypes = Mid(contents, first_index, last_index - first_index)
'		prototypes = Replace(prototypes, "int MPI_", "EXPORT_MPI_API int MPI_CALL MPI_")
'		prototypes = Replace(prototypes, "double PMPI_Wtime", "EXPORT_MPI_API double MPI_CALL PMPI_Wtime")
'		prototypes = Replace(prototypes, "double PMPI_Wtick", "EXPORT_MPI_API double MPI_CALL PMPI_Wtick")
'		prototypes = Replace(prototypes, "double MPI_Wtime", "EXPORT_MPI_API double MPI_CALL MPI_Wtime")
'		prototypes = Replace(prototypes, "double MPI_Wtick", "EXPORT_MPI_API double MPI_CALL MPI_Wtick")
'		contents = ReplaceBetweenTags(contents, "#ifndef MPICH_SUPPRESS_PROTOTYPES", "MPI_Send", "#endif /* MPICH_SUPPRESS_PROTOTYPES */", prototypes & "#endif /* MPICH_SUPPRESS_PROTOTYPES */")
'	end if
'	' add dllspec and calling convention to the PMPI api
'	first_index = InStr(contents, "#if !defined(MPI_BUILD_PROFILING)")
'	last_index = InStr(contents, "#endif  /* MPI_BUILD_PROFILING */")
'	if first_index <> 0 and last_index <> 0 then
'		prototypes = Mid(contents, first_index, last_index - first_index)
'		prototypes = Replace(prototypes, "int PMPI_", "EXPORT_MPI_API int MPI_CALL PMPI_")
'		prototypes = Replace(prototypes, "double PMPI_Wtime", "EXPORT_MPI_API double MPI_CALL PMPI_Wtime")
'		prototypes = Replace(prototypes, "double PMPI_Wtick", "EXPORT_MPI_API double MPI_CALL PMPI_Wtick")
'		contents = ReplaceBetweenTags(contents, "#if", "MPI_BUILD_PROFILING", "#endif  /* MPI_BUILD_PROFILING */", prototypes & "#endif  /* MPI_BUILD_PROFILING */")
'	end if
end if
fout32.Write(contents32)
fout64.Write(contents64)
fout32.Close()
fout64.Close()

Function internalFindCFiles(ByRef key, ByRef files, folder)
	For Each sub_folder in folder.SubFolders
		internalFindCFiles key, files, sub_folder
	Next
	For Each file in folder.Files
		If Right(file.Name, 2) = ".c" Then
			files.Add key, file.Path
			key = key + 1
		End If
	Next
End Function
Function FindCFiles(ByRef files, folder)
	files.RemoveAll()
	key = 0
	internalFindCFiles key, files, folder
End Function

' Add the dll decorations to the source files
if bAddDllDecoration then
	set c_files = CreateObject("Scripting.Dictionary")
	FindCFiles c_files, f.GetFolder("src\mpi")
	' replace "int MPI_" with "EXPORT_MPI_API int MPI_CALL MPI_"
	' fixup MPI_Fint MPI_
	a = c_files.Items
	If c_files.Count > 0 Then
		For i = 0 to c_files.Count - 1
			'cEcho a(i)
			set fin = f.OpenTextFile(a(i))
			contents = fin.ReadAll()
			fin.Close()
			new_contents = Replace(contents, "int MPI_", "EXPORT_MPI_API int MPI_CALL MPI_")
			new_contents = Replace(new_contents, "MPI_FEXPORT_MPI_API int", "EXPORT_MPI_API MPI_Fint")
			if new_contents <> contents then
				'cEcho new_contents
				'cEcho "Modifying file: " & a(i)
				gEcho "Modifying file: " & a(i)
				set fout = f.CreateTextFile(a(i))
				fout.Write(new_contents)
				fout.Close()
			end if
		Next
	End If
end if

Function FindMPIFuncs()
	Dim index, index2, right_str, result
	set c_files = CreateObject("Scripting.Dictionary")
	FindCFiles c_files, f.GetFolder("src\mpi")
	' replace "int MPI_" with "EXPORT_MPI_API int MPI_CALL MPI_"
	' fixup MPI_Fint MPI_
	a = c_files.Items
	If c_files.Count > 0 Then
		For i = 0 to c_files.Count - 1
			'cEcho a(i)
			set fin = f.OpenTextFile(a(i))
			contents = fin.ReadAll()
			fin.Close()
			index = InStr(contents, "int MPI_")
			If index <> 0 Then
				right_str = Right(contents, Len(contents) - index + 1)
				index2 = InStr(right_str, ")")
				If index2 <> 0 Then
					If Mid(contents, index-5, 5) = "MPI_F" then
						result = "MPI_F"
					else
						result = ""
					end if
					result = result & Left(right_str, index2) & vbCrLf & "{" & vbCrLf & "    return MPI_SUCCESS;" & vbCrLf & "}" & vbCrLf
					gEcho result
				End If
			End If
		Next
	End If	
End Function

Function internalPrintFortranInterface(dir)
	Dim index, index2, right_str, result
	set c_files = CreateObject("Scripting.Dictionary")
	FindCFiles c_files, f.GetFolder(dir)
	' replace "int MPI_" with "EXPORT_MPI_API int MPI_CALL MPI_"
	' fixup MPI_Fint MPI_
	a = c_files.Items
	If c_files.Count > 0 Then
		For i = 0 to c_files.Count - 1
			'cEcho a(i)
			set fin = f.OpenTextFile(a(i))
			contents = fin.ReadAll()
			fin.Close()
			index = InStr(contents, "int MPI_")
			If index <> 0 Then
				right_str = Right(contents, Len(contents) - index + 1)
				index2 = InStr(right_str, ")")
				If index2 <> 0 Then
					If Mid(contents, index-5, 5) = "MPI_F" then
						result = "MPI_F"
					else
						result = ""
					end if
					result = result & Left(right_str, index2)' & vbCrLf & "{" & vbCrLf & "    return MPI_SUCCESS;" & vbCrLf & "}" & vbCrLf
					'cEcho result
					gEcho result
				End If
			End If
		Next
	End If	
End Function

Function PrintFortranInterface()
	internalPrintFortranInterface("src\mpi\coll")
	internalPrintFortranInterface("src\mpi\pt2pt")
	internalPrintFortranInterface("src\mpi\rma")
End Function

'Function PrintFortranInterface()
'	Dim index, index2, right_str, result
'	set c_files = CreateObject("Scripting.Dictionary")
'	FindCFiles c_files, f.GetFolder("src\binding\f77")
'	a = c_files.Items
'	If c_files.Count > 0 Then
'		For i = 0 to c_files.Count - 1
'			set fin = f.OpenTextFile(a(i))
'			contents = fin.ReadAll()
'			fin.Close()
'			index = InStrRev(contents, "FORT_DLL_SPEC void FORT_CALL mpi_")
'			If index <> 0 Then
'				right_str = Right(contents, Len(contents) - index + 1)
'				index2 = InStr(right_str, ")")
'				If index2 <> 0 Then
'					result = Left(right_str, index2)' & vbCrLf & "{" & vbCrLf & "    return MPI_SUCCESS;" & vbCrLf & "}" & vbCrLf
'					cEcho result
'				End If
'			End If
'		Next
'	End If	
'End Function

Function internalFindFCFiles(ByRef key, ByRef files, folder)
	For Each sub_folder in folder.SubFolders
		internalFindFCFiles key, files, sub_folder
	Next
	For Each file in folder.Files
		If Right(file.Name, 3) = "f.c" Then
			files.Add key, file.Path
			key = key + 1
		End If
	Next
End Function
Function FindFCFiles(ByRef files, folder)
	files.RemoveAll()
	key = 0
	internalFindFCFiles key, files, folder
End Function

Function FindStr(pattern, str)
   Dim regEx, Match, Matches           ' Create variable.
   Set regEx = New RegExp              ' Create a regular expression.
   regEx.Pattern = pattern             ' Set pattern.
   regEx.IgnoreCase = True             ' Set case insensitivity.
   regEx.Global = True                 ' Set global applicability.
   Set Matches = regEx.Execute(str)    ' Execute search.
   For Each Match in Matches           ' Return the first match
      FindStr = Match.Value
      Exit Function
   Next
   FindStr = ""
End Function

Function AddStringLengthParameters(str)
	Dim result, index, cur_arg, match, end_str
	cur_arg = 1
	result = ""
	end_str = ""
	match = FindStr("void\s*\*\s*\w+,", str)
	while match <> ""
		index = InStr(str, match)
		result = result & Left(str, index + Len(match) - 2) & " FORT_MIXED_LEN(d" & cur_arg & ")"
		end_str = end_str & " FORT_END_LEN(d" & cur_arg & ")"
		cur_arg = cur_arg + 1
		str = Right(str, Len(str) - index - Len(match) + 2)
		match = FindStr("void\s*\*\s*\w+,", str)
	wend
	AddStringLengthParameters = result & str & end_str
End Function

Function CreateStdcallFortranInterface()
	Dim index, index2, right_str, result, prototype, filename
	set c_files = CreateObject("Scripting.Dictionary")
	printMsg "VERBOSE", "Creating src\binding\f77\fprotos.h"
	set fprotos = f.CreateTextFile("src\binding\f77\fprotos.h")
	fprotos.WriteLine( "/* -*- Mode: C; c-basic-offset:4 ; -*- */" & vbNewLine & "/*" & vbNewLine & " *  (C) 2001 by Argonne National Laboratory." & vbNewLine & " *      See COPYRIGHT in top-level directory." & vbNewLine & " */" )
	fprotos.WriteLine("")
	fprotos.WriteLine("#ifndef FPROTOS_H")
	fprotos.WriteLine("#define FPROTOS_H")
	fprotos.WriteLine("")
	fprotos.WriteLine("/* fprotos.h.  Generated automatically by winconfigure.  */")
	fprotos.WriteLine("")
	'fnames = Split("MPI_Allgather MPI_Allgatherv MPI_Allreduce MPI_Alltoall MPI_Alltoallv MPI_Alltoallw MPI_Bcast MPI_Exscan MPI_Gather MPI_Gatherv MPI_Reduce MPI_Reduce_scatter MPI_Scan MPI_Scatter MPI_Scatterv MPI_Bsend MPI_Bsend_init MPI_Buffer_attach MPI_Buffer_detach MPI_Ibsend MPI_Irecv MPI_Irsend MPI_Isend MPI_Issend MPI_Recv MPI_Recv_init MPI_Rsend MPI_Rsend_init MPI_Send MPI_Sendrecv MPI_Sendrecv_replace MPI_Send_init MPI_Ssend MPI_Ssend_init MPI_Accumulate MPI_Get MPI_Put MPI_Win_create")
	fnames = Split("mpi_allgather_ +mpi_allgatherv_ +mpi_allreduce_ +mpi_alltoall_ +mpi_alltoallv_ +mpi_alltoallw_ +mpi_bcast_ +mpi_exscan_ +mpi_gather_ +mpi_gatherv_ +mpi_reduce_ +mpi_reduce_scatter_ +mpi_scan_ +mpi_scatter_ +mpi_scatterv_ +mpi_bsend_ +mpi_bsend_init_ +mpi_buffer_attach_ +mpi_buffer_detach_ +mpi_ibsend_ +mpi_irecv_ +mpi_irsend_ +mpi_isend_ +mpi_issend_ +mpi_recv_ +mpi_recv_init_ +mpi_rsend_ +mpi_rsend_init_ +mpi_send_ +mpi_sendrecv_ +mpi_sendrecv_replace_ +mpi_send_init_ +mpi_ssend_ +mpi_ssend_init_ +mpi_accumulate_ +mpi_get_ +mpi_put_ +mpi_win_create_ ", "+")
	FindFCFiles c_files, f.GetFolder("src\binding\f77")
	a = c_files.Items
	If c_files.Count > 0 Then
		For i = 0 to c_files.Count - 1
			set fin = f.OpenTextFile(a(i))
			contents = fin.ReadAll()
			fin.Close()
			found = false
			for each name in fnames
				if InStr(contents, name) then
					'cEcho "found " & name & " in: " & vbCrLf & contents
					found = true
					exit for
				end if
			next
			if found = true then
				index = InStrRev(contents, "FORT_DLL_SPEC void FORT_CALL mpi_")
				If index <> 0 Then
					result = Left(contents, index - 1)
					right_str = Right(contents, Len(contents) - index + 1)
					index2 = InStr(right_str, ")")
					If index2 <> 0 Then
						result = result & AddStringLengthParameters(Left(right_str, index2 - 1)) & Right(right_str, Len(right_str) - index2 + 1)
						result = Replace(result, "fproto.h", "fprotos.h")
						index = InStrRev(result, "FORT_DLL_SPEC void FORT_CALL mpi_")
						right_str = Right(result, Len(result) - index + 1)
						index2 = InStr(right_str, "))")
						prototype = "extern " & Left(right_str, index2 + 1) & ";"
						'prototype = Replace(prototype, "FORT_MIXED_LEN", "FORT_MIXED_LEN_DECL")
						'prototype = Replace(prototype, "FORT_END_LEN", "FORT_END_LEN_DECL")
						filename = Replace(a(i), ".c", "s.c")
						'cEcho "filename: " & filename
						'cEcho "prototype: " & prototype
						'cEcho result
						printMsg "VERBOSE", "Creating file: " & filename
						set file = f.CreateTextFile(filename)
						file.Write(result)
						file.Close()
						fprotos.WriteLine(prototype)
					End If
				End If
			End If
		Next
	End If
	fprotos.WriteLine("")
	fprotos.WriteLine("#endif")
	fprotos.Close()
End Function

'
' Generate mpichtimer.h
'

printMsg "VERBOSE", "Creating src\include\win32\mpichtimer.h"
set fout = f.CreateTextFile("src\include\win32\mpichtimer.h")
'set fin = f.OpenTextFile("src\mpi\timer\mpichtimer.h.in")
set fin = f.OpenTextFile("src\include\mpichtimer.h.in")

contents = fin.ReadAll()
contents = ReplaceAts(contents, false, false)
fout.Write(contents)
fin.Close()
fout.Close()

printMsg "VERBOSE", "Creating src\include\win64\mpichtimer.h"
set fout = f.CreateTextFile("src\include\win64\mpichtimer.h")
'set fin = f.OpenTextFile("src\mpi\timer\mpichtimer.h.in")
set fin = f.OpenTextFile("src\include\mpichtimer.h.in")


contents = fin.ReadAll()
contents = ReplaceAts(contents, false, true)
fout.Write(contents)
fin.Close()
fout.Close()

'
' Generate mpich2info.h
'
printMsg "VERBOSE", "Creating src\include\mpich2info.h"
set fout = f.CreateTextFile("src\include\mpich2info.h")
set fin  = f.OpenTextFile("src\include\mpich2info.h.in")
contents = fin.ReadAll()
contents = ReplaceAts(contents, false, false)
fout.Write(contents)
fin.Close()
fout.Close()

'
' mpid_thread.h
'
If f.FileExists("src\mpid\common\thread\mpid_thread.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpid_thread.h"
	Set fout = f.CreateTextFile("src\include\win32\mpid_thread.h")
	Set fin = f.OpenTextFile("src\mpid\common\thread\mpid_thread.h.in")
	contents = fin.ReadAll()
	contents = ReplaceAts(contents, false, false)
	fout.Write(contents)
	fin.Close()
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpid_thread.h"
	Set fout = f.CreateTextFile("src\include\win64\mpid_thread.h")
	Set fin = f.OpenTextFile("src\mpid\common\thread\mpid_thread.h.in")
	contents = fin.ReadAll()
	contents = ReplaceAts(contents, false, true)
	fout.Write(contents)
	fin.Close()
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpid_thread.h"
End If

'
' trace_impl.h
'
printMsg "VERBOSE", "Creating src\util\logging\rlog\trace_impl.h"
Set fout = f.CreateTextFile("src\util\logging\rlog\trace_impl.h")
Call WriteHeader(fout, "trace_impl")
'Call AddDefinitions(fout, "src\util\logging\rlog\trace_impl.h.in", false)
fout.WriteLine("#define HAVE_CTYPE_H")
fout.WriteLine("#define HAVE_STDLIB_H")
fout.WriteLine("#define HAVE_STRING_H")
Call WriteFooter(fout)
fout.Close()

printMsg "STATUS", "Creating MPE header files..."
'
' Generate mpe_log_thread.h
'
printMsg "VERBOSE", "Creating src\mpe2\src\logging\include\mpe_log_thread.h"
set fout = f.CreateTextFile("src\mpe2\src\logging\include\mpe_log_thread.h")
set fin  = f.OpenTextFile("src\mpe2\src\logging\include\mpe_log_thread.h.in")
contents = fin.ReadAll()
contents = ReplaceAts(contents, false, false)
fout.Write(contents)
fin.Close()
fout.Close()

'
' Generate mpe_callstack.h
'
printMsg "VERBOSE", "Creating src\mpe2\src\callstack\include\mpe_callstack.h"
set fout = f.CreateTextFile("src\mpe2\src\callstack\include\mpe_callstack.h")
set fin  = f.OpenTextFile("src\mpe2\src\callstack\include\mpe_callstack.h.in")
contents = fin.ReadAll()
contents = ReplaceAts(contents, false, false)
fout.Write(contents)
fin.Close()
fout.Close()

If f.FolderExists("src\mpe2\src\logging\include") Then
        '
        ' clog_inttypes.h
        ' 

	If f.FileExists("src\mpe2\src\logging\include\clog_inttypes.h.in") Then
		printMsg "VERBOSE", "Creating src\mpe2\src\logging\include\clog_inttypes.h"
		Set fin = f.OpenTextFile("src\mpe2\src\logging\include\clog_inttypes.h.in")
		Set fout = f.CreateTextFile("src\mpe2\src\logging\include\clog_inttypes.h")
		contents = fin.ReadAll()
		contents = ReplaceAts(contents, false, false)
		fout.Write(contents)
		fin.Close()
		fout.Close()	
	End If
End If

printMsg "STATUS", "Creating IO header files..."
'
' Generate mpio.h
'

printMsg "VERBOSE", "Creating src\include\mpio.h"
set fout = f.CreateTextFile("src\include\mpio.h")
set fin = f.OpenTextFile("src\mpi\romio\include\mpio.h.in")

contents = fin.ReadAll()
contents = ReplaceAts(contents, false, false)
if bAddDllDecoration then
	contents = ReplaceBetweenTags(contents, "/* MPI-IO function prototypes */", "HAVE_PRAGMA_HP_SEC_DEF", "#if defined(__cplusplus)", "#if defined(__cplusplus)")
end if
fout.Write(contents)
fin.Close()
fout.Close()


'cEcho "Creating src\include\win64\mpio.h"
'set fout = f.CreateTextFile("src\include\win64\mpio.h")
'set fin = f.OpenTextFile("src\mpi\romio\include\mpio.h.in")
'
'contents = fin.ReadAll()
'contents = ReplaceAts(contents, false, true)
'if bAddDllDecoration then
'	contents = ReplaceBetweenTags(contents, "/* MPI-IO function prototypes */", "HAVE_PRAGMA_HP_SEC_DEF", "#if defined(__cplusplus)", "#if defined(__cplusplus)")
'end if
'fout.Write(contents)
'fin.Close()
'fout.Close()

'
' Generate romioconf.h
'

If f.FileExists("src\mpi\romio\adio\include\romioconf.h.in") Then

	printMsg "VERBOSE", "Creating src\mpi\romio\adio\include\romioconf.h"
	set fout = f.CreateTextFile("src\mpi\romio\adio\include\romioconf.h")
	Call WriteHeader(fout, "romio")
	Call AddDefinitions(fout, "src\mpi\romio\adio\include\romioconf.h.in", false)
	fout.WriteLine("#ifndef ROMIO_NTFS")
	fout.WriteLine("#define ROMIO_NTFS 1")
	fout.WriteLine("#endif")
	fout.WriteLine("#ifndef HAVE_INT64")
	fout.WriteLine("#define HAVE_INT64 1")
	fout.WriteLine("#endif")
	fout.WriteLine("#ifndef FORTRANDOUBLEUNDERSCORE")
	fout.WriteLine("#define FORTRANCAPS")
	fout.WriteLine("#endif")
	fout.WriteLine("#define HAVE_IO_H 1")
	fout.WriteLine("#define snprintf _snprintf")
    fout.WriteLine("#define strtok_r strtok_s")
	Call WriteFooter(fout)
	fout.Close()

Else

	printMsg "VERBOSE", "Creating src\mpi\romio\adio\include\romioconf.h"
	set fout = f.CreateTextFile("src\mpi\romio\adio\include\romioconf.h")

	fout.WriteLine("/* -*- Mode: C; c-basic-offset:4 ; -*- */")
	fout.WriteLine("/*")
	fout.WriteLine(" *  (C) 2001 by Argonne National Laboratory.")
	fout.WriteLine(" *      See COPYRIGHT in top-level directory.")
	fout.WriteLine(" */")
	fout.WriteLine("#ifndef ROMIOCONF_H")
	fout.WriteLine("#define ROMIOCONF_H")
	fout.WriteLine("")
	fout.WriteLine("/* Define if `sys_siglist' is declared by <signal.h>.  */")
	fout.WriteLine("#undef SYS_SIGLIST_DECLARED")
	fout.WriteLine("")
	fout.WriteLine("#undef AIO_HANDLE_IN_AIOCB")
	fout.WriteLine("#undef AIO_PRIORITY_DEFAULT")
	fout.WriteLine("#undef AIO_SIGNOTIFY_NONE")
	fout.WriteLine("#undef AIO_SUN")
	fout.WriteLine("#undef FREEBSD")
	fout.WriteLine("#undef HAVE_LONG_LONG_64")
	fout.WriteLine("#undef HAVE_MOUNT_NFS")
	fout.WriteLine("#undef HAVE_MPI_COMBINERS")
	fout.WriteLine("#undef HAVE_MPI_DARRAY_SUBARRAY")
	fout.WriteLine("#ifndef HAVE_MPI_INFO")
	fout.WriteLine("#define HAVE_MPI_INFO")
	fout.WriteLine("#endif")
	fout.WriteLine("#undef HAVE_MPI_LONG_LONG_INT")
	fout.WriteLine("#undef HAVE_PRAGMA_CRI_DUP")
	fout.WriteLine("#undef HAVE_PRAGMA_HP_SEC_DEF")
	fout.WriteLine("#undef HAVE_PRAGMA_WEAK")
	fout.WriteLine("#undef HAVE_PREAD64")
	fout.WriteLine("#ifndef HAVE_STATUS_SET_BYTES")
	fout.WriteLine("#define HAVE_STATUS_SET_BYTES")
	fout.WriteLine("#endif")
	fout.WriteLine("#ifndef HAVE_STRERROR")
	fout.WriteLine("#define HAVE_STRERROR")
	fout.WriteLine("#endif")
	fout.WriteLine("#undef HAVE_SYSERRLIST")
	fout.WriteLine("#undef HAVE_WEAK_SYMBOLS")
	fout.WriteLine("#undef HFS")
	fout.WriteLine("#undef HPUX")
	fout.WriteLine("#undef INT_LT_POINTER")
	fout.WriteLine("#undef IRIX")
	fout.WriteLine("#undef LINUX")
	fout.WriteLine("#ifndef MPICH")
	fout.WriteLine("#define MPICH")
	fout.WriteLine("#endif")
	fout.WriteLine("#undef MPIHP")
	fout.WriteLine("#undef MPILAM")
	fout.WriteLine("#undef MPISGI")
	fout.WriteLine("#undef MPI_OFFSET_IS_INT")
	fout.WriteLine("#undef NEEDS_MPI_TEST")
	fout.WriteLine("#undef NFS")
	fout.WriteLine("#undef NO_AIO")
	fout.WriteLine("#undef NO_FD_IN_AIOCB")
	fout.WriteLine("#undef NO_MPI_SGI_type_is_contig")
	fout.WriteLine("#undef PARAGON")
	fout.WriteLine("#undef PFS")
	fout.WriteLine("#undef PIOFS")
	fout.WriteLine("#undef PRINT_ERR_MSG")
	fout.WriteLine("#undef ROMIO_PVFS")
	fout.WriteLine("#undef ROMIO_TESTFS")
	fout.WriteLine("#undef SFS")
	fout.WriteLine("#undef SOLARIS")
	fout.WriteLine("#undef SPPUX")
	fout.WriteLine("#undef SX4")
	fout.WriteLine("#undef UFS")
	fout.WriteLine("#undef XFS")
	fout.WriteLine("")
	fout.WriteLine("#ifndef ROMIO_NTFS")
	fout.WriteLine("#define ROMIO_NTFS")
	fout.WriteLine("#endif")
	fout.WriteLine("#ifndef HAVE_INT64")
	fout.WriteLine("#define HAVE_INT64 1")
	fout.WriteLine("#endif")
	fout.WriteLine("")
	fout.WriteLine("#ifndef HAS_MPIR_ERR_SETMSG")
	fout.WriteLine("#define HAS_MPIR_ERR_SETMSG")
	fout.WriteLine("#endif")
	fout.WriteLine("")
	fout.WriteLine("#ifndef FORTRANDOUBLEUNDERSCORE")
	fout.WriteLine("#define FORTRANCAPS")
	fout.WriteLine("#endif")
	fout.WriteLine("")
	fout.WriteLine("#define restrict")
	fout.WriteLine("")
	fout.WriteLine("#define HAVE_IO_H 1")
	fout.WriteLine("#define snprintf _snprintf")
    fout.WriteLine("#define strtok_r strtok_s")
	fout.WriteLine("#endif")

	fout.Close()

End If

'   Convert mpif.h - F77 header to F90 header
Function ConvertF77HeaderToF90(headerFileName)
	set fs = CreateObject("Scripting.FileSystemObject")
	set headerFileObj = fs.OpenTextFile(headerFileName)
	tmpFileName = fs.GetTempName()
	set tmpFileObj = fs.CreateTextFile(tmpFileName, true)
	Do Until headerFileObj.AtEndOfStream = True
		contents = headerFileObj.ReadLine()
		posCommentChar = InStr(1, contents, "C", 1)
		If posCommentChar = 1 Then
			contents = Replace(contents, "C", "!", 1, 1, 1)
		End If
		tmpFileObj.WriteLine(contents)
	Loop
	headerFileObj.Close()
	tmpFileObj.Close()

	set headerFileObj = fs.GetFile(headerFileName)
	set tmpFileObj = fs.GetFile(tmpFileName)
	headerFileObj.Delete(True)
	tmpFileObj.Move(headerFileName)
	ConvertF77HeaderToF90 = True
End Function 

Function BuildIFaces()

	Dim WshShell
	set f = WScript.CreateObject("Scripting.FileSystemObject")

	'
	' Generate mpicxx.h
	'
	If bForce Or Not f.FileExists("src\binding\cxx\mpicxx.h.in") Then

		Set WshShell = CreateObject("WScript.Shell")
		WshShell.CurrentDirectory = "src\binding\cxx"
		printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl buildiface -nosep"
		WshShell.Run "perl buildiface -nosep", 0, true
		WshShell.CurrentDirectory = "..\..\.."
	
	End If

	If f.FileExists("src\binding\cxx\mpicxx.h.in") Then
	
	  set fin = f.OpenTextFile("src\binding\cxx\mpicxx.h.in")
	  printMsg "VERBOSE", "Creating src\include\mpicxx.h"
	  set fout = f.CreateTextFile("src\include\mpicxx.h")
	  contents = fin.ReadAll()
	  contents = ReplaceAts(contents, false, false)
	  if bCleanCode then
		printMsg "VERBOSE", "modifying the comm, win datatype classes to handle unreferenced variables."
		' Comm class
		contents = ReplaceBetweenTags(contents, "int", "NULL_COPY_FN( const Comm &oldcomm", "}", "int NULL_COPY_FN( const Comm &oldcomm, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldcomm; keyval; ex; attr_in; attr_out; flag = 1; return 0; }")
		contents = ReplaceBetweenTags(contents, "int", "NULL_DELETE_FN( Comm &comm", "}", "int NULL_DELETE_FN( Comm &comm, int keyval, void * attr, void *ex ) { comm; keyval; attr; ex; return 0; }")
		contents = ReplaceBetweenTags(contents, "int", "DUP_FN( const Comm &oldcomm", "}", "int DUP_FN( const Comm &oldcomm, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldcomm; keyval; ex; flag = 1; *(void **)attr_out = attr_in; return 0; }")
		' Win class
		contents = ReplaceBetweenTags(contents, "int", "NULL_COPY_FN( const Win &oldwin", "}", "int NULL_COPY_FN( const Win &oldwin, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldwin; keyval; ex; attr_in; attr_out; flag = 1; return 0; }")
		contents = ReplaceBetweenTags(contents, "int", "NULL_DELETE_FN( Win &win", "}", "int NULL_DELETE_FN( Win &win, int keyval, void * attr, void *ex ) { win; keyval; attr; ex; return 0; }")
		contents = ReplaceBetweenTags(contents, "int", "DUP_FN( const Win &oldwin", "}", "int DUP_FN( const Win &oldwin, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldwin; keyval; ex; flag = 1; *(void **)attr_out = attr_in; return 0; }")
		' Datatype class
		contents = ReplaceBetweenTags(contents, "int", "NULL_COPY_FN( const Datatype &oldtype", "}", "int NULL_COPY_FN( const Datatype &oldtype, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldtype; keyval; ex; attr_in; attr_out; flag = 1; return 0; }")
		contents = ReplaceBetweenTags(contents, "int", "NULL_DELETE_FN( Datatype &type", "}", "int NULL_DELETE_FN( Datatype &type, int keyval, void * attr, void *ex ) { type; keyval; attr; ex; return 0; }")
		contents = ReplaceBetweenTags(contents, "int", "DUP_FN( const Datatype &oldtype", "}", "int DUP_FN( const Datatype &oldtype, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldtype; keyval; ex; flag = 1; *(void **)attr_out = attr_in; return 0; }")
	  end if	
	  fout.Write(contents)
	  fin.Close()
	  fout.Close()
	
'	  set fin = f.OpenTextFile("src\binding\cxx\mpicxx.h.in")
'	  cEcho "Creating src\include\win64\mpicxx.h"
'	  set fout = f.CreateTextFile("src\include\win64\mpicxx.h")
'	  contents = fin.ReadAll()
'	  contents = ReplaceAts(contents, false, true)
'	  if bCleanCode then
'		' Comm class
'		contents = ReplaceBetweenTags(contents, "int", "NULL_COPY_FN( const Comm &oldcomm", "}", "int NULL_COPY_FN( const Comm &oldcomm, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldcomm; keyval; ex; attr_in; attr_out; flag = 1; return 0; }")
'		contents = ReplaceBetweenTags(contents, "int", "NULL_DELETE_FN( Comm &comm", "}", "int NULL_DELETE_FN( Comm &comm, int keyval, void * attr, void *ex ) { comm; keyval; attr; ex; return 0; }")
'		contents = ReplaceBetweenTags(contents, "int", "DUP_FN( const Comm &oldcomm", "}", "int DUP_FN( const Comm &oldcomm, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldcomm; keyval; ex; flag = 1; *(void **)attr_out = attr_in; return 0; }")
'		' Win class
'		contents = ReplaceBetweenTags(contents, "int", "NULL_COPY_FN( const Win &oldwin", "}", "int NULL_COPY_FN( const Win &oldwin, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldwin; keyval; ex; attr_in; attr_out; flag = 1; return 0; }")
'		contents = ReplaceBetweenTags(contents, "int", "NULL_DELETE_FN( Win &win", "}", "int NULL_DELETE_FN( Win &win, int keyval, void * attr, void *ex ) { win; keyval; attr; ex; return 0; }")
'		contents = ReplaceBetweenTags(contents, "int", "DUP_FN( const Win &oldwin", "}", "int DUP_FN( const Win &oldwin, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldwin; keyval; ex; flag = 1; *(void **)attr_out = attr_in; return 0; }")
'		' Datatype class
'		contents = ReplaceBetweenTags(contents, "int", "NULL_COPY_FN( const Datatype &oldtype", "}", "int NULL_COPY_FN( const Datatype &oldtype, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldtype; keyval; ex; attr_in; attr_out; flag = 1; return 0; }")
'		contents = ReplaceBetweenTags(contents, "int", "NULL_DELETE_FN( Datatype &type", "}", "int NULL_DELETE_FN( Datatype &type, int keyval, void * attr, void *ex ) { type; keyval; attr; ex; return 0; }")
'		contents = ReplaceBetweenTags(contents, "int", "DUP_FN( const Datatype &oldtype", "}", "int DUP_FN( const Datatype &oldtype, int keyval, void *ex, void *attr_in, void *attr_out, bool &flag ) { oldtype; keyval; ex; flag = 1; *(void **)attr_out = attr_in; return 0; }")
'	  end if	
'	  fout.Write(contents)
'	  fin.Close()
'	  fout.Close()

	Else
	
	  printMsg "ERROR", "Run ""perl buildiface -nosep"" from the src\binding\cxx directory before running winconfigure"
	  
	End IF
	
	
	'
	' Generate mpimcxx.h
	'
	If bMcxx Then
	
		If bForce Or Not f.FileExists("src\binding\mcxx\mpimcxx.h.in") Then
	
			Set WshShell = CreateObject("WScript.Shell")
			WshShell.CurrentDirectory = "src\binding\mcxx"
			printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl buildiface -nosep"
			WshShell.Run "perl buildiface -nosep", 0, true
			WhShell.CurrentDirectory = "..\..\.."
	
		End If
	
		If f.FileExists("src\binding\mcxx\mpimcxx.h.in") Then

			set fin = f.OpenTextFile("src\binding\mcxx\mpimcxx.h.in")
			printMsg "VERBOSE", "Creating src\include\mpimcxx.h"
			set fout = f.CreateTextFile("src\include\mpimcxx.h")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

'			set fin = f.OpenTextFile("src\binding\mcxx\mpimcxx.h.in")
'			cEcho "Creating src\include\mpimcxx64.h"
'			set fout = f.CreateTextFile("src\include\mpimcxx64.h")
'			contents = fin.ReadAll()
'			contents = ReplaceAts(contents, false, true)
'			fout.Write(contents)
'			fin.Close()
'			fout.Close()

		Else
	
			printMsg "ERROR", "Run ""perl buildiface -nosep"" from the src\binding\mcxx directory before running winconfigure"
	  
		End If
		
	End If

	If Not bRemoveFortran Then
		'
		' Generate mpif.h
		'
		If bForce Or Not f.FileExists("src\binding\f77\mpif.h.in") Then

			Set WshShell = CreateObject("WScript.Shell")
			WshShell.CurrentDirectory = "src\binding\f77"
			printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl buildiface"
			WshShell.Run "perl buildiface", 0, true
			WshShell.CurrentDirectory = "..\..\.."

		End If

		If f.FileExists("src\binding\f77\mpif.h.in") Then

			set fin = f.OpenTextFile("src\binding\f77\mpif.h.in")
			printMsg "VERBOSE", "Creating src\include\win32\mpif.h"
			set fout = f.CreateTextFile("src\include\win32\mpif.h")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, true, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()
			' Assume all windows fortran compilers are F90 compilers
			retVal = ConvertF77HeaderToF90("src\include\win32\mpif.h")

			set fin = f.OpenTextFile("src\binding\f77\mpif.h.in")
			printMsg "VERBOSE", "Creating src\include\win64\mpif.h"
			set fout = f.CreateTextFile("src\include\win64\mpif.h")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, true, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
			' Assume all windows fortran compilers are F90 compilers
			retVal = ConvertF77HeaderToF90("src\include\win64\mpif.h")

		Else
	
			printMsg "ERROR", "Run ""perl buildiface"" from the src\binding\f77 directory before running winconfigure"
	
		End If

		'
		' Create the string versions of the fortran interface necessitated by the stdcall calling convention
		'
		CreateStdcallFortranInterface()
		
		'
		' Generate setbotf.f
		'
		If f.FileExists("src\binding\f77\setbotf.f.in") Then

			set fin = f.OpenTextFile("src\binding\f77\setbotf.f.in")
			printMsg "VERBOSE", "Creating src\binding\f77\setbotf.f"
			set fout = f.CreateTextFile("src\binding\f77\setbotf.f")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, true, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

'			set fin = f.OpenTextFile("src\binding\f77\setbotf.f.in")
'			cEcho "Creating src\binding\f77\setbotf64.f"
'			set fout = f.CreateTextFile("src\binding\f77\setbotf64.f")
'			contents = fin.ReadAll()
'			contents = ReplaceAts(contents, true, true)
'			fout.Write(contents)
'			fin.Close()
'			fout.Close()
			
		Else
			printMsg "VERBOSE", "Skipping file: src\binding\f77\setbotf.f"
		End If

		'
		' Generate F90 module files
		'
		If bForce Or Not f.FileExists("src\binding\f90\mpi.f90") Then

			Set WshShell = CreateObject("WScript.Shell")
			WshShell.CurrentDirectory = "src\binding\f90"
			printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl buildiface"
			WshShell.Run "perl buildiface", 0, true

			' Generate mpifnoext.h
			' - Remove EXTERNAL, DOUBLE PRECISION from mpif.h
			' - Change comment style in mpif.h from "C ..." to "! ..."
			printMsg "VERBOSE", "Creating src\include\win32\mpifnoext.h"
			set fs = CreateObject("Scripting.FileSystemObject")
			set fout = fs.CreateTextFile("..\..\include\win32\mpifnoext.h")
			set fin = fs.OpenTextFile("..\..\include\win32\mpif.h")
			Do Until fin.AtEndOfStream = True
				contents = fin.ReadLine()
				posExternal = InStr(1, contents, "EXTERNAL", 1)
				posDoubleP = InStr(1, contents, "DOUBLE PRECISION", 1)
				posCommentChar = InStr(1, contents, "C", 1)
				If posCommentChar = 1 Then
					contents = Replace(contents, "C", "!", 1, 1, 1)
				End If
				If (posExternal < 1) And (posDoubleP < 1) Then
					fout.WriteLine(contents)
				End If
			Loop
			fin.Close()
			fout.Close()
			printMsg "VERBOSE", "Creating src\include\win64\mpifnoext.h"
			set fout = fs.CreateTextFile("..\..\include\win64\mpifnoext.h")
			set fin = fs.OpenTextFile("..\..\include\win64\mpif.h")
			Do Until fin.AtEndOfStream = True
				contents = fin.ReadLine()
				posExternal = InStr(1, contents, "EXTERNAL", 1)
				posDoubleP = InStr(1, contents, "DOUBLE PRECISION", 1)
				posCommentChar = InStr(1, contents, "C", 1)
				If posCommentChar = 1 Then
					contents = Replace(contents, "C", "!", 1, 1, 1)
				End If
				If (posExternal < 1) And (posDoubleP < 1) Then
					fout.WriteLine(contents)
				End If
			Loop
			fin.Close()
			fout.Close()

			' Create mpi_sizeofs.f90 in arch dependent dirs
			If Not fs.FolderExists("win32") Then
				fs.CreateFolder("win32")
			End If
			printMsg "VERBOSE", "Creating src\binding\f90\win32\mpi_sizeofs.f90"
			set fout = fs.CreateTextFile("win32\mpi_sizeofs.f90" , True)
			set fin  = fs.OpenTextFile("mpi_sizeofs.f90.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			If Not fs.FolderExists("win64") Then
				fs.CreateFolder("win64")
			End If
			printMsg "VERBOSE", "Creating src\binding\f90\win64\mpi_sizeofs.f90"
			set fout = fs.CreateTextFile("win64\mpi_sizeofs.f90", True)
			set fin  = fs.OpenTextFile("mpi_sizeofs.f90.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
			
			' Create mpif90model.h in arch dependent dirs
			printMsg "VERBOSE", "Creating src\binding\f90\mpif90model.h"
			set fout = fs.CreateTextFile("mpif90model.h" , True)
			set fin  = fs.OpenTextFile("mpif90model.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			WshShell.CurrentDirectory = "..\..\.."

		End If

		If Not f.FileExists("src\binding\f90\mpi.f90") Then

			printMsg "ERROR", "Run ""perl buildiface"" from the src\binding\f90 directory to generate the F90 modules"

		End If
	
	End If

End Function

printMsg "STATUS", "Building C++ and Fortran interfaces..."
BuildIFaces()


'
' Generate defmsg.h
'
'Function RunCmd(cmd_line)
'	Set oExec = WshShell.Exec("cmd /C " & cmd_line & " 2>&1")
'	cmd_output = oExec.StdOut.ReadAll()
'	RunCmd = cmd_output
'End Function
'Function RunCmd(cmd_line)
'	Dim results(2), runcmd_done
'	Set WshShell = CreateObject("WScript.Shell")
'	cEcho WshShell.CurrentDirectory & ">" & cmd_line
'	Set oExec = WshShell.Exec(cmd_line)
'	cmd_output = ""
'	err_output = ""
'	runcmd_more = true
'	Do While runcmd_more
'		runcmd_more = false
'		If Not oExec.StdOut.AtEndOfStream Then
'			runcmd_more = true
'			cmd_output = cmd_output & oExec.StdOut.ReadLine & vbCrLf
'		End If
'		If Not oExec.StdErr.AtEndOfStream Then
'			runcmd_more = true
'			err_output = err_output & oExec.StdErr.ReadLine & vbCrLf
'		End If
'	Loop
'	Do While oExec.Status <> 1
'		WScript.Sleep 10
'	Loop
'	results(0) = cmd_output
'	results(1) = err_output
'	RunCmd = results
'End Function
Function RunCmd(cmd_line)
	Dim results(2)
	Set WshShell = CreateObject("WScript.Shell")
	printMsg "VERBOSE", WshShell.CurrentDirectory & ">" & cmd_line
	Set oExec = WshShell.Exec(cmd_line)
	cmd_output = ""
    err_output = ""
	If Not oExec.StdOut.AtEndOfStream Then
		cmd_output = cmd_output & oExec.StdOut.ReadAll
	End If
    If Not oExec.StdErr.AtEndOfStream Then
		err_output = err_output & oExec.StdErr.ReadAll
	End If
    Do While oExec.Status <> 1
        WScript.Sleep 10
    Loop
    results(0) = cmd_output
    results(1) = err_output
    RunCmd = results
End Function

Function RemoveWarnings(str)
	lines = Split(str, vbCrLf)
	result = ""
	for each line in lines
		line = Trim(line)
		if Len(line) > 0 and (not Left(line, 7) = "Warning") then
			result = result & line & vbCrLf
		end if
	next
	RemoveWarnings = result
End Function

Function GenerateDefmsg()
	set f = WScript.CreateObject("Scripting.FileSystemObject")
	set fin = f.OpenTextFile("maint\errmsgdirs")
	contents = fin.ReadAll()
	fin.Close()
	contents = Trim(contents)
	contents = Replace(contents, "/", "\")
	contents = Replace(contents, vbCrLf, "")
	cmd_line = "perl maint\extracterrmsgs -skip=src\util/multichannel/mpi.c " & contents
	'WScript.Echo(cmd_line)
	output = RunCmd(cmd_line)
	output(1) = RemoveWarnings(output(1))
	If Len(output(1)) > 0 Then
		printMsg "ERROR", output(1)
		printMsg "ERROR", "Because of errors in extracting error messages, the file src\mpi\errhan\defmsg.h was not updated."
	Else
		set fout = f.OpenTextFile("src\mpi\errhan\defmsg.h", 2, True)
		fout.Write(output(0))
		fout.Close()
	End If
End Function

If bForce Then
	GenerateDefmsg()
End If

'
' Generate mpiallstates.h and describe_states.c
'
'Function GenerateStatesFiles()
'	set f = WScript.CreateObject("Scripting.FileSystemObject")
'	If f.FileExists("maint\genstates.in") Then
'
'		set fin = f.OpenTextFile("maint\genstates.in")
'		cEcho "Creating maint\genstates"
'		set fout = f.CreateTextFile("maint\genstates")
'		contents = fin.ReadAll()
'		contents = Replace(contents, "@PERL@", "perl")
'		fout.Write(contents)
'		fin.Close()
'		fout.Close()
'		Set WshShell = CreateObject("WScript.Shell")
'		cEcho WshShell.CurrentDirectory & ">perl maint\genstates"
'		WshShell.Run "perl maint\genstates", 0, true
'
'	Else
'
'		If InStr(1, LCase(WScript.FullName), "cscript") > 0 Then
'			WScript.Echo("Missing file: maint\genstates.in")
'		End If
' 
'	End If
'
'End Function

'
' Generate state_names.h
'
Function GenerateStatesFiles()
	set f = WScript.CreateObject("Scripting.FileSystemObject")
	If f.FileExists("maint\extractstates.in") Then

		set fin = f.OpenTextFile("maint\extractstates.in")
		printMsg "VERBOSE", "Creating maint\extractstates"
		set fout = f.CreateTextFile("maint\extractstates")
		contents = fin.ReadAll()
		contents = Replace(contents, "@PERL@", "perl")
		fout.Write(contents)
		fin.Close()
		fout.Close()
	
	End If
	
	If f.FileExists("maint\extractstrings.in") Then

		set fin = f.OpenTextFile("maint\extractstrings.in")
		printMsg "VERBOSE", "Creating maint\extractstrings"
		set fout = f.CreateTextFile("maint\extractstrings")
		contents = fin.ReadAll()
		contents = Replace(contents, "@PERL@", "perl")
		fout.Write(contents)
		fin.Close()
		fout.Close()
		
	End If
	
	If f.FileExists("maint\extractstates") And f.FileExists("maint\extractstrings") Then
		
		Set WshShell = CreateObject("WScript.Shell")
		printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl maint\extractstates"
		WshShell.Run "perl maint\extractstates", 0, true

	Else

		If InStr(1, LCase(WScript.FullName), "cscript") > 0 Then
			printMsg "ERROR", "Missing files: maint\extractstates.in and maint\extractstrings.in"
		End If
 
	End If

End Function

If bForce Then
	GenerateStatesFiles()
End If

'
' Generate the c++ and fortran tests from their templates
'
Function GenerateTemplatedTests()

	set f = WScript.CreateObject("Scripting.FileSystemObject")
	If f.FileExists("test\mpi\maint\testmerge.in") Then

		set fin = f.OpenTextFile("test\mpi\maint\testmerge.in")
		printMsg "VERBOSE", "Creating test\mpi\maint\testmerge"
		set fout = f.CreateTextFile("test\mpi\maint\testmerge")
		contents = fin.ReadAll()
		contents = Replace(contents, "@PERL@", "perl")
		fout.Write(contents)
		fin.Close()
		fout.Close()
		Set WshShell = CreateObject("WScript.Shell")
		WshShell.CurrentDirectory = "test\mpi\cxx\io"
		printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl ..\..\maint\testmerge -defn=..\..\maint\common.defn ioharness.defn ioharness.tlt"
		WshShell.Run "perl ..\..\maint\testmerge -defn=..\..\maint\common.defn ioharness.defn ioharness.tlt", 0, true
		WshShell.CurrentDirectory = "..\..\f77\io"
		printMsg "VERBOSE", WshShell.CurrentDirectory & ">perl ..\..\maint\testmerge -defn=..\..\maint\common.defn ioharness.defn ioharness.tlt"
		WshShell.Run "perl ..\..\maint\testmerge -defn=..\..\maint\common.defn ioharness.defn ioharness.tlt", 0, true
		WshShell.CurrentDirectory = "..\..\..\.."

	Else

		printMsg "VERBOSE", "Missing file: test\mpi\maint\testmerge.in"

	End If

End Function

If bForce Then
	GenerateTemplatedTests()
End If

'
' Validate .in files
'


printMsg "STATUS", "Creating *conf.h header files for MPICH2..."
'
' Generate the conf.h files
'

Sub WriteHeader( fout, str )
	fout.WriteLine( "/* -*- Mode: C; c-basic-offset:4 ; -*- */" & vbNewLine & "/*" & vbNewLine & " *  (C) 2001 by Argonne National Laboratory." & vbNewLine & " *      See COPYRIGHT in top-level directory." & vbNewLine & " */" )
	fout.WriteLine("")
	fout.WriteLine("#ifndef " & UCase(str) & "CONF_H_INCLUDED")
	fout.WriteLine("#define " & UCase(str) & "CONF_H_INCLUDED")
	fout.WriteLine("")
	fout.WriteLine("/* " & str & "conf.h.  Generated automatically by winconfigure.  */")
	fout.WriteLine("")
End Sub

Sub WriteFooter( fout )
	fout.WriteLine("")
	fout.WriteLine("#endif")
End Sub


'
' mpichconf.h
'
printMsg "VERBOSE", "Creating src\include\win32\mpichconf.h"
Set fout = f.CreateTextFile("src\include\win32\mpichconf.h")
Call WriteHeader(fout, "mpich")
Call AddDefinitions(fout, "src\include\mpichconf.h.in", false)
fout.WriteLine("#define HAVE_PROCESS_H")
fout.WriteLine("#ifndef HAVE_WINDOWS_H")
fout.WriteLine("#define HAVE_WINDOWS_H")
fout.WriteLine("#endif")
fout.WriteLine("#ifndef HAVE_WINNT_H")
fout.WriteLine("#define HAVE_WINNT_H")
fout.WriteLine("#endif")
fout.WriteLine("#define HAVE_WINDOWS_SOCKET")
fout.WriteLine("#define HAVE_WINSOCK2_H")
fout.WriteLine("#define HAVE_INTSAFE_H")
fout.WriteLine("#define HAVE_WIN32_SLEEP")
fout.WriteLine("#define HAVE_NT_LOCKS")
fout.WriteLine("#define HAVE_MAPVIEWOFFILE")
fout.WriteLine("#define HAVE_CREATEFILEMAPPING")
fout.WriteLine("#define HAVE_INTERLOCKEDEXCHANGE")
fout.WriteLine("#define HAVE_BOOL")
fout.WriteLine("#define HAVE_CRTDBG_H")
fout.WriteLine("")
fout.WriteLine("#define snprintf _snprintf")
fout.WriteLine("#define inline __inline")
fout.WriteLine("")
fout.WriteLine("#define WITH_SOCK_TYPE SOCK_IOCP")
fout.WriteLine("")
fout.WriteLine("/* Define if building mpich in development mode */")
fout.WriteLine("#define MPICH_DEV_BUILD")
fout.WriteLine("#define MPICH_DBG_OUTPUT")
fout.WriteLine("")
fout.WriteLine("/*#define MPICH_MPI_FROM_PMPI*/")
fout.WriteLine("#define USE_PROCESS_LOCKS 1")
fout.WriteLine("#define USE_THREAD_PACKAGE")
fout.WriteLine("#define USE_WINTHREADS")
fout.WriteLine("#ifndef HAVE_INT64")
fout.WriteLine("#define HAVE_INT64 1")
fout.WriteLine("#define HAVE_PTRTOLONG")
fout.WriteLine("#define HAVE_PTRTOINT")
fout.WriteLine("#define HAVE_PTRTOAINT")
fout.WriteLine("#define HAVE_LONGTOPTR")
fout.WriteLine("#define HAVE_INTTOPTR")
fout.WriteLine("#define HAVE_AINTTOPTR")
fout.WriteLine("#endif")
fout.WriteLine("#ifndef HAVE_STRNICMP")
fout.WriteLine("	#define HAVE_STRNICMP")
fout.WriteLine("#endif")
fout.WriteLine("#ifndef _WIN32_WINNT")
fout.WriteLine("	#define _WIN32_WINNT 0x500")
fout.WriteLine("#endif")
fout.WriteLine("#define HAVE_SWITCHTOTHREAD	1")
fout.WriteLine("#define HAVE_GETLASTERROR 1")
fout.WriteLine("#define HAVE_FORMATMESSAGE 1")
fout.WriteLine("#define HAVE_SRAND 1")
fout.WriteLine("#define HAVE_QUERYPERFORMANCECOUNTER 1")
fout.WriteLine("#ifndef ENABLE_NO_MACRO_VARARG_NAME")
fout.WriteLine("	#define ENABLE_NO_MACRO_VARARG_NAME")
fout.WriteLine("#endif")
' Use Windows Intrinsics for atomics
fout.WriteLine("#define HAVE_NT_INTRINSICS")
' Use Windows SHM
fout.WriteLine("#define HAVE_NT_SHARED_MEM")
fout.WriteLine("#define USE_NT_SHM	1")
fout.WriteLine("#define USE_NT_SOCK 1")
' Disable warnings for unsecure versions, eg: snprintf instead of snprintf_s, of funcs
fout.WriteLine("#pragma warning( disable : 4996 )") 
' Define so that we can test whether the mpichconf.h file has been included 
fout.WriteLine(" /* Define so that we can test whether the mpichconf.h has been included */")
fout.WriteLine("#define HAVE_MPICHCONF 1")
If Not bRemoveFortran Then
	fout.WriteLine("/* Define to #define MPIR_F_TRUE/FALSE to F77_TRUE/FALSE_VALUE */")
	fout.WriteLine("#define F77_USE_BOOLEAN_LITERALS 1")
End If
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\mpichconf.h"
Set fout = f.CreateTextFile("src\include\win64\mpichconf.h")
Call WriteHeader(fout, "mpich")
Call AddDefinitions(fout, "src\include\mpichconf.h.in", true)
fout.WriteLine("#define HAVE_PROCESS_H")
fout.WriteLine("#ifndef HAVE_WINDOWS_H")
fout.WriteLine("#define HAVE_WINDOWS_H")
fout.WriteLine("#endif")
fout.WriteLine("#define HAVE_WINDOWS_SOCKET")
fout.WriteLine("#define HAVE_WINSOCK2_H")
fout.WriteLine("#define HAVE_INTSAFE_H")
fout.WriteLine("#define HAVE_WIN32_SLEEP")
fout.WriteLine("#define HAVE_NT_LOCKS")
fout.WriteLine("#define HAVE_MAPVIEWOFFILE")
fout.WriteLine("#define HAVE_CREATEFILEMAPPING")
fout.WriteLine("#define HAVE_INTERLOCKEDEXCHANGE")
fout.WriteLine("#define HAVE_BOOL")
fout.WriteLine("#define HAVE_CRTDBG_H")
fout.WriteLine("")
fout.WriteLine("#define snprintf _snprintf")
fout.WriteLine("#define inline __inline")
fout.WriteLine("")
fout.WriteLine("#define WITH_SOCK_TYPE SOCK_IOCP")
fout.WriteLine("")
fout.WriteLine("/* Define if building mpich in development mode */")
fout.WriteLine("#define MPICH_DEV_BUILD")
fout.WriteLine("#define MPICH_DBG_OUTPUT")
fout.WriteLine("")
fout.WriteLine("/*#define MPICH_MPI_FROM_PMPI*/")
fout.WriteLine("#define USE_PROCESS_LOCKS 1")
fout.WriteLine("#define USE_THREAD_PACKAGE")
fout.WriteLine("#define USE_WINTHREADS")
fout.WriteLine("#ifndef HAVE_INT64")
fout.WriteLine("#define HAVE_INT64 1")
fout.WriteLine("#define HAVE_PTRTOLONG")
fout.WriteLine("#define HAVE_PTRTOINT")
fout.WriteLine("#define HAVE_PTRTOAINT")
fout.WriteLine("#define HAVE_LONGTOPTR")
fout.WriteLine("#define HAVE_INTTOPTR")
fout.WriteLine("#define HAVE_AINTTOPTR")
fout.WriteLine("#endif")
fout.WriteLine("#ifndef HAVE_STRNICMP")
fout.WriteLine("	#define HAVE_STRNICMP")
fout.WriteLine("#endif")
fout.WriteLine("#ifndef _WIN32_WINNT")
fout.WriteLine("	#define _WIN32_WINNT 0x500")
fout.WriteLine("#endif")
fout.WriteLine("#define HAVE_SWITCHTOTHREAD	1")
fout.WriteLine("#define HAVE_GETLASTERROR 1")
fout.WriteLine("#define HAVE_FORMATMESSAGE 1")
fout.WriteLine("#define HAVE_SRAND 1")
fout.WriteLine("#define HAVE_QUERYPERFORMANCECOUNTER 1")
fout.WriteLine("#ifndef ENABLE_NO_MACRO_VARARG_NAME")
fout.WriteLine("	#define ENABLE_NO_MACRO_VARARG_NAME")
fout.WriteLine("#endif")
' Use Windows Intrinsics for atomics
fout.WriteLine("#define HAVE_NT_INTRINSICS")
' Use Windows SHM
fout.WriteLine("#define HAVE_NT_SHARED_MEM")
fout.WriteLine("#define USE_NT_SHM	1")
fout.WriteLine("#define USE_NT_SOCK 1")
' Disable warnings for unsecure versions, eg: snprintf instead of snprintf_s, of funcs
fout.WriteLine("#pragma warning( disable : 4996 )") 
' Define so that we can test whether the mpichconf.h file has been included 
fout.WriteLine(" /* Define so that we can test whether the mpichconf.h has been included */")
fout.WriteLine("#define HAVE_MPICHCONF 1")

If Not bRemoveFortran Then
	fout.WriteLine("/* Define to #define MPIR_F_TRUE/FALSE to F77_TRUE/FALSE_VALUE */")
	fout.WriteLine("#define F77_USE_BOOLEAN_LITERALS 1")
End If
Call WriteFooter(fout)
fout.Close()

'
' mpidi_ch3_conf.h
'
printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3_conf.h"
Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3_conf.h")
Call WriteHeader(fout, "mpidi_ch3_")
Call AddDefinitions(fout, "src\mpid\ch3\include\mpidi_ch3_conf.h.in", false)
fout.WriteLine("#define EWOULDBLOCK EAGAIN")
fout.WriteLine("#define HAVE_WINTHREADS")
fout.WriteLine("#define MPICH_CPU_TICK_TYPE USE_WIN_X86_CYCLE_ASM")
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3_conf.h"
Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3_conf.h")
Call WriteHeader(fout, "mpidi_ch3_")
Call AddDefinitions(fout, "src\mpid\ch3\include\mpidi_ch3_conf.h.in", true)
fout.WriteLine("#define EWOULDBLOCK EAGAIN")
fout.WriteLine("#define HAVE_WINTHREADS")
fout.WriteLine("#define MPICH_CPU_TICK_TYPE USE_WIN_X86_CYCLE_ASM")
Call WriteFooter(fout)
fout.Close()

'
' timerconf.h
'
printMsg "VERBOSE", "Creating src\include\win32\timerconf.h"
Set fout = f.CreateTextFile("src\include\win32\timerconf.h")
Call WriteHeader(fout, "timer")
Call AddDefinitions(fout, "src\mpi\timer\timerconf.h.in", false)
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\timerconf.h"
Set fout = f.CreateTextFile("src\include\win64\timerconf.h")
Call WriteHeader(fout, "timer")
Call AddDefinitions(fout, "src\mpi\timer\timerconf.h.in", true)
Call WriteFooter(fout)
fout.Close()

'
' mpid_locksconf.h
'
printMsg "VERBOSE", "Creating src\include\win32\mpid_locksconf.h"
Set fout = f.CreateTextFile("src\include\win32\mpid_locksconf.h")
Call WriteHeader(fout, "mpid_locks")
Call AddDefinitions(fout, "src\mpid\common\locks\mpid_locksconf.h.in", false)
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\mpid_locksconf.h"
Set fout = f.CreateTextFile("src\include\win64\mpid_locksconf.h")
Call WriteHeader(fout, "mpid_locks")
Call AddDefinitions(fout, "src\mpid\common\locks\mpid_locksconf.h.in", true)
Call WriteFooter(fout)
fout.Close()

'
' mpidu_sock_conf.h
'
printMsg "VERBOSE", "Creating src\include\win32\mpidu_sock_conf.h"
Set fout = f.CreateTextFile("src\include\win32\mpidu_sock_conf.h")
Call WriteHeader(fout, "mpidu_sock_")
Call AddDefinitions(fout, "src\mpid\common\sock\mpidu_sock_conf.h.in", false)
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\mpidu_sock_conf.h"
Set fout = f.CreateTextFile("src\include\win64\mpidu_sock_conf.h")
Call WriteHeader(fout, "mpidu_sock_")
Call AddDefinitions(fout, "src\mpid\common\sock\mpidu_sock_conf.h.in", true)
Call WriteFooter(fout)
fout.Close()

'
' ch3u_sock_conf.h
'
printMsg "VERBOSE", "Creating src\include\win32\ch3usockconf.h"
Set fout = f.CreateTextFile("src\include\win32\ch3usockconf.h")
Call WriteHeader(fout, "mpidi_ch3usock")
Call AddDefinitions(fout, "src\mpid\ch3\util\sock\ch3usockconf.h.in", false)
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\ch3usockconf.h"
Set fout = f.CreateTextFile("src\include\win64\ch3usockconf.h")
Call WriteHeader(fout, "mpidi_ch3usock")
Call AddDefinitions(fout, "src\mpid\ch3\util\sock\ch3usockconf.h.in", true)
Call WriteFooter(fout)
fout.Close()

'
' pmiconf.h
'
printMsg "VERBOSE", "Creating src\include\win32\pmiconf.h"
Set fout = f.CreateTextFile("src\include\win32\pmiconf.h")
Call WriteHeader(fout, "pmi")
Call AddDefinitions(fout, "src\pmi\smpd\pmiconf.h.in", false)
fout.WriteLine("#ifndef HAVE_WINDOWS_H")
fout.WriteLine("#define HAVE_WINDOWS_H")
fout.WriteLine("#endif")
Call WriteFooter(fout)
fout.Close()
printMsg "VERBOSE", "Creating src\include\win64\pmiconf.h"
Set fout = f.CreateTextFile("src\include\win64\pmiconf.h")
Call WriteHeader(fout, "pmi")
Call AddDefinitions(fout, "src\pmi\smpd\pmiconf.h.in", true)
fout.WriteLine("#ifndef HAVE_WINDOWS_H")
fout.WriteLine("#define HAVE_WINDOWS_H")
fout.WriteLine("#endif")
Call WriteFooter(fout)
fout.Close()

'
' mpiu_os_wrappers_conf.h
'
'If f.FileExists("src\util\wrappers\mpiu_os_wrappers_conf.h.in") Then
'	cEcho "Creating src\util\wrappers\mpiu_os_wrappers_conf.h"
'	Set fout = f.CreateTextFile("src\util\wrappers\mpiu_os_wrappers_conf.h")
'	Call WriteHeader(fout, "mpiu_os_wrappers")
'	Call AddDefinitions(fout, "src\util\wrappers\mpiu_os_wrappers_conf.h.in", false)
'	fout.WriteLine("#ifndef HAVE_WINDOWS_H")
'		fout.WriteLine("#define HAVE_WINDOWS_H")
'	fout.WriteLine("#endif")
'	fout.WriteLine("#define USE_NT_SHM	1")
'	fout.WriteLine("#define USE_NT_SOCK 1")
'	fout.WriteLine("#define HAVE_SWITCHTOTHREAD	1")
'	fout.WriteLine("#define HAVE_GETLASTERROR 1")
'	fout.WriteLine("#define HAVE_FORMATMESSAGE 1")
'	fout.WriteLine("#define HAVE_SRAND 1")
'	fout.WriteLine("#define HAVE_QUERYPERFORMANCECOUNTER 1")
'	fout.WriteLine("#define HAVE_DOUBLEUNDERSCOREINLINE 1")
'	fout.WriteLine("#ifndef __cplusplus")
'		fout.WriteLine("#define HAVE_NOINLINE 1")
'	fout.WriteLine("#endif")
'	Call WriteFooter(fout)
'	fout.Close()
'Else
'	cEcho "Skipping file: mpiu_os_wrappers_conf.h"
'End If

'
' mpidi_ch3i_rdma_conf.h
'
If f.FileExists("src\mpid\ch3\channels\rdma\include\mpidi_ch3i_rdma_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3i_rdma_conf.h"
	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_rdma_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_rdma_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\rdma\include\mpidi_ch3i_rdma_conf.h.in", false)
	fout.WriteLine("#define USE_BUSY_LOCKS")
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3i_rdma_conf.h"
	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_rdma_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_rdma_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\rdma\include\mpidi_ch3i_rdma_conf.h.in", true)
	fout.WriteLine("#define USE_BUSY_LOCKS")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpidi_ch3i_rdma_conf.h"
End If

'
' mpidi_ch3i_shm_conf.h
'
If f.FileExists("src\mpid\ch3\channels\shm\include\mpidi_ch3i_shm_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3i_shm_conf.h"
	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_shm_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_shm_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\shm\include\mpidi_ch3i_shm_conf.h.in", false)
	fout.WriteLine("#define USE_BUSY_LOCKS")
	fout.WriteLine("#define HAVE_SHARED_PROCESS_READ")
	fout.WriteLine("#define USE_RDMA_GET")
	fout.WriteLine("#define USE_SHM_RDMA_GET")
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3i_shm_conf.h"
	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_shm_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_shm_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\shm\include\mpidi_ch3i_shm_conf.h.in", true)
	fout.WriteLine("#define USE_BUSY_LOCKS")
	fout.WriteLine("#define HAVE_SHARED_PROCESS_READ")
	fout.WriteLine("#define USE_RDMA_GET")
	fout.WriteLine("#define USE_SHM_RDMA_GET")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpidi_ch3i_shm_conf.h"
End If

'
' mpidi_ch3i_sock_conf.h
'
If f.FileExists("src\mpid\ch3\channels\sock\include\mpidi_ch3i_sock_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3i_sock_conf.h"
	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_sock_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_sock_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\sock\include\mpidi_ch3i_sock_conf.h.in", false)
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3i_sock_conf.h"
	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_sock_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_sock_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\sock\include\mpidi_ch3i_sock_conf.h.in", true)
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpidi_ch3i_sock_conf.h"
End If

'
' mpidi_ch3i_ssm_conf.h
'
If f.FileExists("src\mpid\ch3\channels\ssm\include\mpidi_ch3i_ssm_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3i_ssm_conf.h"
	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_ssm_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_ssm_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\ssm\include\mpidi_ch3i_ssm_conf.h.in", false)
	fout.WriteLine("#define USE_PERSISTENT_SHARED_MEMORY")
	fout.WriteLine("#define HAVE_SHARED_PROCESS_READ")
	fout.WriteLine("#define USE_RDMA_GET")
	fout.WriteLine("#define USE_SHM_RDMA_GET")
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3i_ssm_conf.h"
	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_ssm_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_ssm_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\ssm\include\mpidi_ch3i_ssm_conf.h.in", true)
	fout.WriteLine("#define USE_PERSISTENT_SHARED_MEMORY")
	fout.WriteLine("#define HAVE_SHARED_PROCESS_READ")
	fout.WriteLine("#define USE_RDMA_GET")
	fout.WriteLine("#define USE_SHM_RDMA_GET")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpidi_ch3i_ssm_conf.h"
End If

'
' mpidi_ch3i_nemesis_conf.h
'
If f.FileExists("src\mpid\ch3\channels\nemesis\include\mpidi_ch3i_nemesis_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\mpid\ch3\channels\nemesis\include\mpidi_ch3i_nemesis_conf.h"
	Set fout = f.CreateTextFile("src\mpid\ch3\channels\nemesis\include\mpidi_ch3i_nemesis_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_nemesis_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\nemesis\include\mpidi_ch3i_nemesis_conf.h.in", false)
    ' Use Windows Intrinsics for atomics
	fout.WriteLine("#define HAVE_NT_INTRINSICS")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE","Skipping file: mpidi_ch3i_nemesis_conf.h"
End If
'
' mpidi_ch3i_essm_conf.h
'
'If f.FileExists("src\mpid\ch3\channels\essm\include\mpidi_ch3i_essm_conf.h.in") Then
'	cEcho "Creating src\include\win32\mpidi_ch3i_essm_conf.h"
'	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_essm_conf.h")
'	Call WriteHeader(fout, "mpidi_ch3i_essm_")
'	Call AddDefinitions(fout, "src\mpid\ch3\channels\essm\include\mpidi_ch3i_essm_conf.h.in", false)
'	Call WriteFooter(fout)
'	fout.Close()
'	cEcho "Creating src\include\win64\mpidi_ch3i_essm_conf.h"
'	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_essm_conf.h")
'	Call WriteHeader(fout, "mpidi_ch3i_essm_")
'	Call AddDefinitions(fout, "src\mpid\ch3\channels\essm\include\mpidi_ch3i_essm_conf.h.in", true)
'	Call WriteFooter(fout)
'	fout.Close()
'Else
'	cEcho "Skipping file: mpidi_ch3i_essm_conf.h"
'End If

'
' mpidi_ch3i_sshm_conf.h
'
If f.FileExists("src\mpid\ch3\channels\sshm\include\mpidi_ch3i_sshm_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3i_sshm_conf.h"
	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_sshm_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_sshm_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\sshm\include\mpidi_ch3i_sshm_conf.h.in", false)
	fout.WriteLine("#define HAVE_MASM_AND_X86")
	fout.WriteLine("#define USE_PERSISTENT_SHARED_MEMORY")
	fout.WriteLine("#define HAVE_SHARED_PROCESS_READ")
	fout.WriteLine("#define USE_RDMA_GET")
	fout.WriteLine("#define USE_SHM_RDMA_GET")
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3i_sshm_conf.h"
	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_sshm_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_sshm_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\sshm\include\mpidi_ch3i_sshm_conf.h.in", true)
	fout.WriteLine("#define HAVE_MASM_AND_X86")
	fout.WriteLine("#define USE_PERSISTENT_SHARED_MEMORY")
	fout.WriteLine("#define HAVE_SHARED_PROCESS_READ")
	fout.WriteLine("#define USE_RDMA_GET")
	fout.WriteLine("#define USE_SHM_RDMA_GET")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpidi_ch3i_sshm_conf.h"
End If

'
' mpidi_ch3i_ib_conf.h
'
If f.FileExists("src\mpid\ch3\channels\ib\include\mpidi_ch3i_ib_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\include\win32\mpidi_ch3i_ib_conf.h"
	Set fout = f.CreateTextFile("src\include\win32\mpidi_ch3i_ib_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_ib_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\ib\include\mpidi_ch3i_ib_conf.h.in", false)
	fout.WriteLine("#define MPID_IBU_TYPE_WINDOWS")
	fout.WriteLine("#define __WIN__")
	fout.WriteLine("#define __i386__")
	If bUsePinCache Then
		fout.WriteLine("/*#define USE_NO_PIN_CACHE*/")
	else
		fout.WriteLine("#define USE_NO_PIN_CACHE")
	End If
	fout.WriteLine("/*#define USE_RDMA_GET*/")
	fout.WriteLine("#define USE_RDMA_PUT")
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\include\win64\mpidi_ch3i_ib_conf.h"
	Set fout = f.CreateTextFile("src\include\win64\mpidi_ch3i_ib_conf.h")
	Call WriteHeader(fout, "mpidi_ch3i_ib_")
	Call AddDefinitions(fout, "src\mpid\ch3\channels\ib\include\mpidi_ch3i_ib_conf.h.in", true)
	fout.WriteLine("#define MPID_IBU_TYPE_WINDOWS")
	fout.WriteLine("#define __WIN__")
	If x64 then
		fout.WriteLine("#define __x86_64__")
	else
		fout.WriteLine("#define __ia64__")
	End If
	If bUsePinCache Then
		fout.WriteLine("/*#define USE_NO_PIN_CACHE*/")
	else
		fout.WriteLine("#define USE_NO_PIN_CACHE")
	End If
	fout.WriteLine("/*#define USE_RDMA_GET*/")
	fout.WriteLine("#define USE_RDMA_PUT")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpidi_ch3i_ib_conf.h"
End If

'
' Generate mpid_nem_net_module_defs.h
'
If f.FileExists("src\mpid\ch3\channels\nemesis\nemesis\include\mpid_nem_net_module_defs.h.in") Then
	printMsg "VERBOSE","Creating src\mpid\ch3\channels\nemesis\nemesis\include\mpid_nem_net_module_defs.h"
	set fout = f.CreateTextFile("src\mpid\ch3\channels\nemesis\nemesis\include\mpid_nem_net_module_defs.h")
	set fin  = f.OpenTextFile("src\mpid\ch3\channels\nemesis\nemesis\include\mpid_nem_net_module_defs.h.in")
	contents = fin.ReadAll()
	contents = ReplaceAts(contents, false, false)
	fout.Write(contents)
	fin.Close()
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpid_nem_net_module_defs.h"
End If

'
' Generate mpid_nem_net_array.c
'
If f.FileExists("src\mpid\ch3\channels\nemesis\nemesis\src\mpid_nem_net_array.c.in") Then
	printMsg "VERBOSE","Creating src\mpid\ch3\channels\nemesis\nemesis\src\mpid_nem_net_array.c"
	set fout = f.CreateTextFile("src\mpid\ch3\channels\nemesis\nemesis\src\mpid_nem_net_array.c")
	set fin  = f.OpenTextFile("src\mpid\ch3\channels\nemesis\nemesis\src\mpid_nem_net_array.c.in")
	contents = fin.ReadAll()
	contents = ReplaceAts(contents, false, false)
	fout.Write(contents)
	fin.Close()
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpid_nem_net_array.c"
End If

'
' mpiu_events_conf.h
'
'If f.FileExists("src\util\events\mpiu_events_conf.h.in") Then
'	cEcho "Creating src\include\win32\mpiu_events_conf.h"
'	Set fout = f.CreateTextFile("src\include\win32\mpiu_events_conf.h")
'	Call WriteHeader(fout, "mpiu_events_")
'	Call AddDefinitions(fout, "src\util\events\mpiu_events_conf.h.in", false)
'	fout.WriteLine("#ifndef USE_MPIU_EVENT_TYPE")
'	fout.WriteLine("#define USE_MPIU_EVENT_TYPE MPIU_EVENT_TYPE_WINDOWS")
'	fout.WriteLine("#endif")
'	Call WriteFooter(fout)
'	fout.Close()
'	cEcho "Creating src\include\win64\mpiu_events_conf.h"
'	Set fout = f.CreateTextFile("src\include\win64\mpiu_events_conf.h")
'	Call WriteHeader(fout, "mpiu_events_")
'	Call AddDefinitions(fout, "src\util\events\mpiu_events_conf.h.in", false)
'	fout.WriteLine("#ifndef USE_MPIU_EVENT_TYPE")
'	fout.WriteLine("#define USE_MPIU_EVENT_TYPE MPIU_EVENT_TYPE_WINDOWS")
'	fout.WriteLine("#endif")
'	Call WriteFooter(fout)
'	fout.Close()
'Else
'	Set fout = f.CreateTextFile("src\include\win32\mpiu_events_conf.h")
'	Call WriteHeader(fout, "mpiu_events_")
'	fout.WriteLine("#ifndef USE_MPIU_EVENT_TYPE")
'	fout.WriteLine("#define USE_MPIU_EVENT_TYPE MPIU_EVENT_TYPE_WINDOWS")
'	fout.WriteLine("#endif")
'	Call WriteFooter(fout)
'	fout.Close()
'	Set fout = f.CreateTextFile("src\include\win64\mpiu_events_conf.h")
'	Call WriteHeader(fout, "mpiu_events_")
'	fout.WriteLine("#ifndef USE_MPIU_EVENT_TYPE")
'	fout.WriteLine("#define USE_MPIU_EVENT_TYPE MPIU_EVENT_TYPE_WINDOWS")
'	fout.WriteLine("#endif")
'	Call WriteFooter(fout)
'	fout.Close()
'End If

'
' smpdconf.h
'
If f.FileExists("src\pm\smpd\smpdconf.h.in") Then
	printMsg "VERBOSE", "Creating src\pm\smpd\smpdconf.h"
	Set fout = f.CreateTextFile("src\pm\smpd\smpdconf.h")
        Call WriteHeader(fout, "smpd_")
	Call AddDefinitions(fout, "src\pm\smpd\smpdconf.h.in", false)
        fout.WriteLine("#ifndef HAVE_WINDOWS_H")
	fout.WriteLine("    #define HAVE_WINDOWS_H")
        fout.WriteLine("#endif")
'   Use human readable tokens in MPIU String funcs
'   - should be consistent with settings in mpichconf.h used in
'     compilation of string funcs, argstr.c
        fout.WriteLine("#ifndef USE_HUMAN_READABLE_TOKENS")
	fout.WriteLine("    #define USE_HUMAN_READABLE_TOKENS")
        fout.WriteLine("#endif")
	Call WriteFooter(fout)
	fout.Close()
Else
	cEcho "Skipping file: smpdconf.h"
End If

printMsg "STATUS", "Creating config.h header files for OpenPA..."
if not f.FolderExists("src\openpa\src\win32") then
        printMsg "VERBOSE", "Creating src\openpa\src\win32 directory"
	f.CreateFolder("src\openpa\src\win32")
end if
if not f.FolderExists("src\openpa\src\win64") then
        printMsg "VERBOSE", "Creating src\openpa\src\win64 directory"
	f.CreateFolder("src\openpa\src\win64")
end if

If f.FileExists("src\openpa\src\config.h.in") Then
	printMsg "VERBOSE", "Creating src\openpa\src\win32\opa_config.h"
	Set fout = f.CreateTextFile("src\openpa\src\win32\opa_config.h")
	Call WriteHeader(fout, "opa_config_")
	Call AddOPADefinitions(fout, "src\openpa\src\config.h.in", false)
	Call WriteFooter(fout)
	fout.Close()
	printMsg "VERBOSE", "Creating src\openpa\src\win64\opa_config.h"
	Set fout = f.CreateTextFile("src\openpa\src\win64\opa_config.h")
	Call WriteHeader(fout, "opa_config_")
	Call AddOPADefinitions(fout, "src\openpa\src\config.h.in", false)
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: src\openpa\src\config.h.in"
End If

printMsg "STATUS", "Creating *conf.h header files for MPE..."
If f.FolderExists("src\mpe2") Then

	'
	' mpe_logging_conf.h
	'
	If f.FileExists("src\mpe2\src\logging\mpe_logging_conf.h.in") Then
		printMsg "VERBOSE", "Creating src\include\win32\mpe_logging_conf.h"
		Set fout = f.CreateTextFile("src\include\win32\mpe_logging_conf.h")
		Call WriteHeader(fout, "mpe_logging_")
		Call AddDefinitions(fout, "src\mpe2\src\logging\mpe_logging_conf.h.in", false)
		fout.WriteLine("#define HAVE_IO_H 1")
		fout.WriteLine("#define HAVE_WINDOWS_H 1")
		fout.WriteLine("#define read _read")
		fout.WriteLine("#define write _write")
		fout.WriteLine("#define open _open")
		fout.WriteLine("#define close _close")
		fout.WriteLine("#define mktemp _mktemp")
		fout.WriteLine("#define lseek _lseek")
		fout.WriteLine("#define snprintf _snprintf")
		fout.WriteLine("#define OPEN( a , b , c ) _open( a , b | O_BINARY , c )")
		' Define *_FILENO -- defined in unistd.h in unix
		fout.WriteLine("#define STDOUT_FILENO (_fileno( stdout ))")
		fout.WriteLine("#define STDIN_FILENO (_fileno( stdin ))")
		fout.WriteLine("#define STDERR_FILENO (_fileno( stderr ))")
		Call WriteFooter(fout)
		fout.Close()
		printMsg "VERBOSE", "Creating src\include\win64\mpe_logging_conf.h"
		Set fout = f.CreateTextFile("src\include\win64\mpe_logging_conf.h")
		Call WriteHeader(fout, "mpe_logging_")
		Call AddDefinitions(fout, "src\mpe2\src\logging\mpe_logging_conf.h.in", true)
		fout.WriteLine("#define HAVE_IO_H 1")
		fout.WriteLine("#define HAVE_WINDOWS_H 1")
		fout.WriteLine("#define read _read")
		fout.WriteLine("#define write _write")
		fout.WriteLine("#define open _open")
		fout.WriteLine("#define close _close")
		fout.WriteLine("#define mktemp _mktemp")
		fout.WriteLine("#define lseek _lseek")
		fout.WriteLine("#define snprintf _snprintf")
		fout.WriteLine("#define OPEN( a , b , c ) _open( a , b | O_BINARY , c )")
		' Define *_FILENO -- defined in unistd.h in unix
		fout.WriteLine("#define STDOUT_FILENO (_fileno( stdout ))")
		fout.WriteLine("#define STDIN_FILENO (_fileno( stdin ))")
		fout.WriteLine("#define STDERR_FILENO (_fileno( stderr ))")
		Call WriteFooter(fout)
		fout.Close()
	Else
		printMsg "VERBOSE", "Skipping file: mpe_logging_conf.h"
	End If

	'/src/misc/mpe_misc_conf.h.in

	'
	' mpe_wrappers_conf.h
	'
	If f.FileExists("src\mpe2\src\wrappers\mpe_wrappers_conf.h.in") Then
		printMsg "VERBOSE", "Creating src\include\win32\mpe_wrappers_conf.h"
		Set fout = f.CreateTextFile("src\include\win32\mpe_wrappers_conf.h")
		Call WriteHeader(fout, "mpe_wrappers_")
		Call AddDefinitions(fout, "src\mpe2\src\wrappers\mpe_wrappers_conf.h.in", false)
		fout.WriteLine("#define HAVE_WINDOWS_H 1")
		Call WriteFooter(fout)
		fout.Close()
		printMsg "VERBOSE", "Creating src\include\win64\mpe_wrappers_conf.h"
		Set fout = f.CreateTextFile("src\include\win64\mpe_wrappers_conf.h")
		Call WriteHeader(fout, "mpe_wrappers_")
		Call AddDefinitions(fout, "src\mpe2\src\wrappers\mpe_wrappers_conf.h.in", true)
		fout.WriteLine("#define HAVE_WINDOWS_H 1")
		fout.WriteLine("#define HAVE___ARGV 1")
		Call WriteFooter(fout)
		fout.Close()
	Else
		printMsg "VERBOSE", "Skipping file: mpe_wrappers_conf.h"
	End If

	'/src/slog2sdk/trace_rlog/trace_impl.h.in
	'/src/slog2sdk/trace_sample/trace_impl.h.in

	'
	' mpe_conf.h
	'
	If f.FileExists("src\mpe2\mpe_conf.h.in") Then
		printMsg "VERBOSE", "Creating src\include\win32\mpe_conf.h"
		Set fout = f.CreateTextFile("src\include\win32\mpe_conf.h")
		Call WriteHeader(fout, "mpe_")
		Call AddDefinitions(fout, "src\mpe2\mpe_conf.h.in", false)
		fout.WriteLine("#define HAVE_IO_H 1")
		fout.WriteLine("#define HAVE_WINDOWS_H 1")
		fout.WriteLine("#define read _read")
		fout.WriteLine("#define write _write")
		fout.WriteLine("#define open _open")
		fout.WriteLine("#define close _close")
		fout.WriteLine("#define mktemp _mktemp")
		fout.WriteLine("#define lseek _lseek")
		fout.WriteLine("#define snprintf _snprintf")
		fout.WriteLine("#define OPEN( a , b , c ) _open( a , b | O_BINARY , c )")
		Call WriteFooter(fout)
		fout.Close()
		printMsg "VERBOSE", "Creating src\include\win64\mpe_conf.h"
		Set fout = f.CreateTextFile("src\include\win64\mpe_conf.h")
		Call WriteHeader(fout, "mpe_")
		Call AddDefinitions(fout, "src\mpe2\mpe_conf.h.in", true)
		fout.WriteLine("#define HAVE_IO_H 1")
		fout.WriteLine("#define HAVE_WINDOWS_H 1")
		fout.WriteLine("#define read _read")
		fout.WriteLine("#define write _write")
		fout.WriteLine("#define open _open")
		fout.WriteLine("#define close _close")
		fout.WriteLine("#define mktemp _mktemp")
		fout.WriteLine("#define lseek _lseek")
		fout.WriteLine("#define snprintf _snprintf")
		fout.WriteLine("#define OPEN( a , b , c ) _open( a , b | O_BINARY , c )")
		Call WriteFooter(fout)
		fout.Close()
	Else
		printMsg "VERBOSE", "Skipping file: mpe_conf.h"
	End If

End If

'
' mpe_callstack_conf.h
'
If f.FileExists("src\mpe2\src\callstack\mpe_callstack_conf.h.in") Then
	printMsg "VERBOSE", "Creating src\mpe2\src\callstack\mpe_callstack_conf.h"
	Set fout = f.CreateTextFile("src\mpe2\src\callstack\mpe_callstack_conf.h")
	Call WriteHeader(fout, "mpe_callstack_")
	Call AddDefinitions(fout, "src\mpe2\src\callstack\mpe_callstack_conf.h.in", false)
	fout.WriteLine("#define HAVE_WINDOWS_H 1")
	Call WriteFooter(fout)
	fout.Close()
Else
	printMsg "VERBOSE", "Skipping file: mpe_callstack_conf.h"
End If


Function ConfigureTestDir

	'
	' mpitestconf.h
	'
	If f.FileExists("test\mpi\include\mpitestconf.h.in") Then
		printMsg "VERBOSE", "Creating src\include\win32\mpitestconf.h"
		Set fout = f.CreateTextFile("src\include\win32\mpitestconf.h") ' Let's avoid adding a new include path to the test projects
		Call WriteHeader(fout, "mpitest")
		Call AddDefinitions(fout, "test\mpi\include\mpitestconf.h.in", false)
		fout.WriteLine("#ifndef HAVE_WINDOWS_H")
		fout.WriteLine("#define HAVE_WINDOWS_H")
		fout.WriteLine("#endif")
		Call WriteFooter(fout)
		fout.Close()
		printMsg "VERBOSE", "Creating src\include\win64\mpitestconf.h"
		Set fout = f.CreateTextFile("src\include\win64\mpitestconf.h") ' Let's avoid adding a new include path to the test projects
		Call WriteHeader(fout, "mpitest")
		Call AddDefinitions(fout, "test\mpi\include\mpitestconf.h.in", true)
		fout.WriteLine("#ifndef HAVE_WINDOWS_H")
		fout.WriteLine("#define HAVE_WINDOWS_H")
		fout.WriteLine("#endif")
		Call WriteFooter(fout)
		fout.Close()
	Else
		printMsg "VERBOSE", "Skipping file: mpitestconf.h"
	End If

	If Not bRemoveFortran Then
		'
		' attraints.h
		'
		If f.FileExists("test\mpi\f77\attr\attraints.h.in") Then
			'cEcho "Creating test\mpi\f77\attr\attraints.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\attr\attraints.h")
			printMsg "VERBOSE", "Creating src\include\win32\attraints.h"
			Set fout = f.CreateTextFile("src\include\win32\attraints.h")
			Set fin = f.OpenTextFile("test\mpi\f77\attr\attraints.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\attraints.h"
			Set fout = f.CreateTextFile("src\include\win64\attraints.h")
			Set fin = f.OpenTextFile("test\mpi\f77\attr\attraints.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: attraints.h"
		End If

		'
		' typeaints.h
		'
		If f.FileExists("test\mpi\f77\datatype\typeaints.h.in") Then
			'cEcho "Creating test\mpi\f77\datatype\typeaints.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\datatype\typeaints.h")
			printMsg "VERBOSE", "Creating src\include\win32\typeaints.h"
			Set fout = f.CreateTextFile("src\include\win32\typeaints.h")
			Set fin = f.OpenTextFile("test\mpi\f77\datatype\typeaints.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\typeaints.h"
			Set fout = f.CreateTextFile("src\include\win64\typeaints.h")
			Set fin = f.OpenTextFile("test\mpi\f77\datatype\typeaints.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: typeaints.h"
		End If

		'
		' ioaint.h
		'
		If f.FileExists("test\mpi\f77\io\ioaint.h.in") Then
			'cEcho "Creating test\mpi\f77\io\ioaint.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\io\ioaint.h")
			printMsg "VERBOSE", "Creating src\include\win32\ioaint.h"
			Set fout = f.CreateTextFile("src\include\win32\ioaint.h")
			Set fin = f.OpenTextFile("test\mpi\f77\io\ioaint.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\ioaint.h"
			Set fout = f.CreateTextFile("src\include\win64\ioaint.h")
			Set fin = f.OpenTextFile("test\mpi\f77\io\ioaint.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: ioaint.h"
		End If

		'
		' iooffset.h
		'
		If f.FileExists("test\mpi\f77\io\iooffset.h.in") Then
			'cEcho "Creating test\mpi\f77\io\iooffset.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\io\iooffset.h")
			printMsg "VERBOSE", "Creating src\include\win32\iooffset.h"
			Set fout = f.CreateTextFile("src\include\win32\iooffset.h")
			Set fin = f.OpenTextFile("test\mpi\f77\io\iooffset.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\iooffset.h"
			Set fout = f.CreateTextFile("src\include\win64\iooffset.h")
			Set fin = f.OpenTextFile("test\mpi\f77\io\iooffset.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: iooffset.h"
		End If

		'
		' iodisp.h
		'
		If f.FileExists("test\mpi\f77\io\iodisp.h.in") Then
			'cEcho "Creating test\mpi\f77\io\iodisp.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\io\iodisp.h")
			printMsg "VERBOSE", "Creating src\include\win32\iodisp.h"
			Set fout = f.CreateTextFile("src\include\win32\iodisp.h")
			Set fin = f.OpenTextFile("test\mpi\f77\io\iodisp.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\iodisp.h"
			Set fout = f.CreateTextFile("src\include\win64\iodisp.h")
			Set fin = f.OpenTextFile("test\mpi\f77\io\iodisp.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: iodisp.h"
		End If

		'
		' addsize.h
		'
		If f.FileExists("test\mpi\f77\rma\addsize.h.in") Then
			'cEcho "Creating test\mpi\f77\rma\addsize.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\rma\addsize.h")
			printMsg "VERBOSE", "Creating src\include\win32\addsize.h"
			Set fout = f.CreateTextFile("src\include\win32\addsize.h")
			Set fin = f.OpenTextFile("test\mpi\f77\rma\addsize.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\addsize.h"
			Set fout = f.CreateTextFile("src\include\win64\addsize.h")
			Set fin = f.OpenTextFile("test\mpi\f77\rma\addsize.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: addsize.h"
		End If

		'
		' type1aint.h
		'
		If f.FileExists("test\mpi\f77\spawn\type1aint.h.in") Then
			'cEcho "Creating test\mpi\f77\spawn\type1aint.h"
			'Set fout = f.CreateTextFile("test\mpi\f77\spawn\type1aint.h")
			printMsg "VERBOSE", "Creating src\include\win32\type1aint.h"
			Set fout = f.CreateTextFile("src\include\win32\type1aint.h")
			Set fin = f.OpenTextFile("test\mpi\f77\spawn\type1aint.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, false)
			fout.Write(contents)
			fin.Close()
			fout.Close()

			printMsg "VERBOSE", "Creating src\include\win64\type1aint.h"
			Set fout = f.CreateTextFile("src\include\win64\type1aint.h")
			Set fin = f.OpenTextFile("test\mpi\f77\spawn\type1aint.h.in")
			contents = fin.ReadAll()
			contents = ReplaceAts(contents, false, true)
			fout.Write(contents)
			fin.Close()
			fout.Close()
		Else
			printMsg "VERBOSE", "Skipping file: type1aint.h"
		End If

	End If

End Function

printMsg "STATUS", "Configuring MPICH2 test directory..."
ConfigureTestDir()

'
' fooconf.h
'
'Set fout = f.CreateTextFile("src\include\fooconf.h")
'Call WriteHeader(fout, "foo")
'Call AddDefinitions(fout, "src\include\fooconf.h.in", false)
'fout.WriteLine("foo specific stuff")
'Call WriteFooter(fout)
'fout.Close()

'
' Generate mpicc
'
Function GenerateMPICC()
	set f = WScript.CreateObject("Scripting.FileSystemObject")
	vbLessThan = "<"
	vbGreaterThan = ">"
	path_to_mpich = f.GetAbsolutePathName("winconfigure.wsf")
	path_to_mpich = Left(path_to_mpich, Len(path_to_mpich) - 16)
	If Not f.FolderExists("bin") Then
		f.CreateFolder("bin")
	End If
	printMsg "VERBOSE", "Creating bin\mpicc.wsf"
	Set fout = f.CreateTextFile("bin\mpicc.wsf")
	fout.WriteLine(vbLessThan & "package" & vbGreaterThan)
	fout.WriteLine(vbLessThan & "job id=""mpicc""" & vbGreaterThan)
	fout.WriteLine("    " & vbLessThan & "runtime" & vbGreaterThan)
	fout.WriteLine("        " & vbLessThan & "description" & vbGreaterThan & "This script compiles C console MPICH2 applications" & vbLessThan & "/description" & vbGreaterThan)
	fout.WriteLine("        " & vbLessThan & "unnamed")
	fout.WriteLine("            name = ""file""")
	fout.WriteLine("            helpstring = ""List the source files to compile""")
	fout.WriteLine("            many = ""true""")
	fout.WriteLine("            required = ""1""")
	fout.WriteLine("        /" & vbGreaterThan)
	fout.WriteLine("        " & vbLessThan & "named")
	fout.WriteLine("            name = ""out""")
	fout.WriteLine("            helpstring = ""Name of the output executable, default=myapp.exe""")
	fout.WriteLine("            type = ""string""")
	fout.WriteLine("            required = ""false""")
	fout.WriteLine("        /" & vbGreaterThan)
	fout.WriteLine("        " & vbLessThan & "example" & vbGreaterThan & "Example: mpicc main.c /out:foobar.exe" & vbLessThan & "/example" & vbGreaterThan)
	fout.WriteLine("    " & vbLessThan & "/runtime" & vbGreaterThan)
	fout.WriteLine(vbLessThan & "script language=""VBScript""" & vbGreaterThan)
	fout.WriteLine("")
	fout.WriteLine("' Set defaults")
	fout.WriteLine("outputExe = ""myapp.exe""")
	fout.WriteLine("")
	fout.WriteLine("If WScript.Arguments.Unnamed.Count = 0 Then")
	fout.WriteLine("    WScript.Arguments.ShowUsage")
	fout.WriteLine("    WScript.Quit")
	fout.WriteLine("End If")
	fout.WriteLine("")
	fout.WriteLine("Set f = WScript.CreateObject(""Scripting.FileSystemObject"")")
	fout.WriteLine("")
	fout.WriteLine("' Process named arguments")
	fout.WriteLine("If WScript.Arguments.Named.Exists(""out"") Then")
	fout.WriteLine("	outputExe = WScript.Arguments.Named.Item(""out"")")
	fout.WriteLine("End If")
	fout.WriteLine("")
	fout.WriteLine("' Create a new instance of Visual Studio .NET.")
	fout.WriteLine("Set DTE = WScript.CreateObject(""VisualStudio.DTE.7.1"")")
	fout.WriteLine("Set solution = DTE.Solution")
	if bVS2005 then
	    fout.WriteLine("solution.Open(""" & path_to_mpich & "examples\windows\skeleton\skeleton.vs05.sln"")")
	else
	    fout.WriteLine("solution.Open(""" & path_to_mpich & "examples\windows\skeleton\skeleton.sln"")")
	end if
	fout.WriteLine("Set project = solution.Projects.Item(1)")
	fout.WriteLine("")
	fout.WriteLine("' Add the C files to the project")
	fout.WriteLine("Set Cfiles = WScript.Arguments.Unnamed")
	fout.WriteLine("For arg = 0 To Cfiles.Count - 1")
	fout.WriteLine("	Cfile = Cfiles(arg)")
	fout.WriteLine("	Cfile = f.GetAbsolutePathName(Cfile)")
	fout.WriteLine("	project.ProjectItems.AddFromFile(Cfile)")
	fout.WriteLine("Next")
	fout.WriteLine("")
	fout.WriteLine("' Build the solution")
	fout.WriteLine("solution.SolutionBuild.Build()")
	fout.WriteLine("")
	fout.WriteLine("While solution.SolutionBuild.BuildState " & vbLessThan & vbGreaterThan & " 3")
	fout.WriteLine("	WScript.Sleep 1000")
	fout.WriteLine("Wend")
	fout.WriteLine("")
	fout.WriteLine("' Save the output on error")
	fout.WriteLine("If solution.SolutionBuild.LastBuildInfo " & vbLessThan & vbGreaterThan & " 0 Then")
	fout.WriteLine("	WScript.Echo ""Build failed""")
	fout.WriteLine("	Set shell = WScript.CreateObject(""WScript.shell"")")
	fout.WriteLine("	shell.run """ & path_to_mpich & "examples\windows\skeleton\Debug\BuildLog.htm""")
	fout.WriteLine("End If")
	fout.WriteLine("")
	fout.WriteLine("' Remove the C files from the project")
	fout.WriteLine("For i = 1 To project.ProjectItems.Count")
	fout.WriteLine("	If project.ProjectItems.Item(i).Name = ""Source Files"" Then")
	fout.WriteLine("		index = i")
	fout.WriteLine("	End If")
	fout.WriteLine("Next")
	fout.WriteLine("For arg = 0 To Cfiles.Count - 1")
	fout.WriteLine("	Cfile = Cfiles(arg)")
	fout.WriteLine("	Cfile = f.GetFileName(Cfile)")
	fout.WriteLine("	For i = project.ProjectItems.Item(index).ProjectItems.Count To 1 Step -1")
	fout.WriteLine("		If project.ProjectItems.Item(index).ProjectItems.Item(i).Name = Cfile Then")
	fout.WriteLine("			project.ProjectItems.Item(index).ProjectItems.Item(i).Remove()")
	fout.WriteLine("		End If")
	fout.WriteLine("	Next")
	fout.WriteLine("Next")
	fout.WriteLine("")
	fout.WriteLine("' Copy the executable")
	fout.WriteLine("If f.FileExists(""" & path_to_mpich & "examples\windows\skeleton\Debug\skeleton.exe"") Then")
	fout.WriteLine("	f.CopyFile """ & path_to_mpich & "examples\windows\skeleton\Debug\skeleton.exe"", outputExe, True")
	fout.WriteLine("End If")
	fout.WriteLine("")
	fout.WriteLine("' Clean up")
	fout.WriteLine("solution.SolutionBuild.Clean()")
	fout.WriteLine("")
	fout.WriteLine(vbLessThan & "/script" & vbGreaterThan)
	fout.WriteLine(vbLessThan & "/job" & vbGreaterThan)
	fout.WriteLine(vbLessThan & "/package" & vbGreaterThan)
	fout.Close()
End Function

GenerateMPICC()

Function MyTrim(str)
	str = Trim(str)
	while (Left(str, 1) = vbTab)
		str = Right(str, Len(str) - 1)
	wend
	while (Right(str, 1) = vbTab)
		str = Left(str, Len(str) - 1)
	wend
	MyTrim = str
End Function

' Use this function to exclude files that shouldn't be compiled
Function CompileFile(fname)
	CompileFile = true
	'fname = MyTrim(fname)
	If fname = "" Then
		CompileFile = false
	End If
	If fname = "$(mpi_sources)" Then
		CompileFile = false
	End If
	If fname = "${mpi_sources}" Then
		CompileFile = false
	End If
	If fname = "${socksources}" Then
		CompileFile = false
	End If
	If fname = "${ssmsources}" Then
		CompileFile = false
	End If
	If fname = "${shmsources}" Then
		CompileFile = false
	End If
	If fname = "${sshmsources}" Then
		CompileFile = false
	End If
	If fname = "timelimit.c" Then
		CompileFile = false
	End If
	If fname = "dbg_control.c" Then
		CompileFile = false
	End If
	If fname = "dbginit.c" Then
		CompileFile = false
	End If
	If fname = "groupdebug.c" Then
		CompileFile = false
	End If
	if Left(fname, 1) = "@" Then
		CompileFile = false
	End If
	If Right(fname, 2) = ".h" Then
		CompileFile = false
	End If
'	If fname = "register_datarepf.c" Then
'		CompileFile = false
'	End If
	If fname = "fileutil.c" Then
		CompileFile = false
	End If
End Function

Sub OutputLine(path, line)
	Dim do_output
	do_output = false
	If Left(line, 14) = "mpi_sources = " Then
		line = Right(line, Len(line) - 14)
		do_output = true
	End If
	If Left(line, 28) = "lib${MPILIBNAME}_a_SOURCES =" Then
		line = Right(line, Len(line) - 28)
		do_output = true
	End If
	If Left(line, 29) = "lib${MPIFLIBNAME}_a_SOURCES =" Then
		line = Right(line, Len(line) - 29)
		do_output = true
	End If
	If Left(line, 14) = "win_sources = " Then
		line = Right(line, Len(line) - 14)
		do_output = true
	End If
	If Left(line, 14) = "socksources = " Then
		line = Right(line, Len(line) - 14)
		do_output = true
	End If
	If Left(line, 13) = "ssmsources = " Then
		line = Right(line, Len(line) - 13)
		do_output = true
	End If
	If Left(line, 13) = "shmsources = " Then
		line = Right(line, Len(line) - 13)
		do_output = true
	End If
	If Left(line, 14) = "sshmsources = " Then
		line = Right(line, Len(line) - 14)
		do_output = true
	End If
	If do_output Then
		'WScript.Echo line
		line = Replace(line, "	", " ")
		fnames = Split(line)
		For Each fname in fnames
			fname = MyTrim(fname)
			If CompileFile(fname) Then
				If creating_rules Then
					' Make a rule for the entire directory
					files_found = true
					If Right(fname, 4) = ".cpp" Or Right(fname, 4) = ".cxx" Then
						cxx_files_found = true
					End If
					If Right(fname, 2) = ".f" Then
						fortran_files_found = true
					End If
					' Make rules for each individual file
					'mfile.WriteLine("$(" & outdir & ")\" & Left(fname, Len(fname) -1) & "obj: ..\" & path & "\" & fname)
					'mfile.WriteLine("	$(cc) $(cflags) /Fo""$(" & outdir & ")\\"" /Fd""$(" & outdir & ")\\"" ..\" & path & "\" & fname)
				Else
					'WScript.Echo path & "\" & fname
					' remove the file extension
					If Right(fname, 4) = ".cpp" Or Right(fname, 4) = ".cxx" Then
						fname = Left(fname, Len(fname) - 3)
					Else
						fname = Left(fname, Len(fname) - 1)
					End If
					mfile.Write(" \" & vbCrLF & "	$(" & outdir & ")\" & fname & "obj")
				End If
			End If
		Next
	End If
End Sub

' Returns true if name (folder/file name) is excluded from build
' eg: We don't want to compile sock/poll on windows
Function IsInBuildExclusionList(name)
    IsInBuildExclusionList = false
    If Right(name, 4) = "poll" Then
        IsInBuildExclusionList = true
    End If
End Function

Sub FindSimpleMakeFiles(folder, trimpath)
	For Each sub_folder in folder.SubFolders
                If Not IsInBuildExclusionList(sub_folder) Then
		    FindSimpleMakeFiles sub_folder, trimpath
                End If
	Next
	For Each file in folder.Files
		If file.Name = "Makefile.sm" Then
			Dim line, fullline
			Set fin = f.OpenTextFile(file.Path)
			'WScript.Echo file.ParentFolder
			fullline = ""
			files_found = false
			cxx_files_found = false
			fortran_files_found = false
			while not fin.AtEndOfStream
				line = MyTrim(fin.ReadLine)
				If Left(line, 1) <> "#" Then
					If Right(line, 1) = "\" Then
						If fullline = "" Then
							fullline = Left(line, len(line)-1)
						Else
							fullline = fullline & " " & Left(line, len(line)-1)
						End If
					Else
						If fullline = "" Then
							fullline = line
						Else
							fullline = fullline & " " & line
						End If
						'OutputLine file.ParentFolder, fullline
						OutputLine Right(file.ParentFolder, Len(file.ParentFolder) - trimpath), fullline
						fullline = ""
					End If
				End If
			wend
			fin.Close
			If creating_rules And files_found Then
				mfile.WriteLine("{..\" & Right(file.ParentFolder, Len(file.ParentFolder) - trimpath) & "}.c{$(" & outdir & ")}.obj:")
				mfile.Write("    $(cc) $(cflags) ")
				If extra_flags <> "" Then
					mfile.Write(extra_flags & " ")
				End If
				mfile.WriteLine("/Fo""$(" & outdir & ")\\"" /Fd""$(" & outdir & ")\\"" $**")
				mfile.WriteLine
				If cxx_files_found Then
					mfile.WriteLine("{..\" & Right(file.ParentFolder, Len(file.ParentFolder) - trimpath) & "}.cpp{$(" & outdir & ")}.obj:")
					mfile.WriteLine("    $(cc) $(" & cxxflags & ") /Fo""$(" & outdir & ")\\"" /Fd""$(" & outdir & ")\\"" $**")
					mfile.WriteLine
					mfile.WriteLine("{..\" & Right(file.ParentFolder, Len(file.ParentFolder) - trimpath) & "}.cxx{$(" & outdir & ")}.obj:")
					mfile.WriteLine("    $(cc) $(" & cxxflags & ") /Fo""$(" & outdir & ")\\"" /Fd""$(" & outdir & ")\\"" $**")
					mfile.WriteLine
				End If
				If fortran_files_found Then
					mfile.WriteLine("{..\" & Right(file.ParentFolder, Len(file.ParentFolder) - trimpath) & "}.f{$(" & outdir & ")}.obj:")
					'mfile.WriteLine("    $(fc) $(" & fort_prefix & "fortflags) /Fo""$(" & outdir & ")\\"" /Fd""$(" & outdir & ")\\"" $**")
					mfile.WriteLine("    $(fc) $(" & fort_prefix & "fortflags) /module:""$(" & outdir & ")\\"" /object:""$(" & outdir & ")\\"" $**")
					mfile.WriteLine
				End If
			End If
		End If
	Next
End Sub

Sub CreateRules(folder, trimpath)
	creating_rules = true
	FindSimpleMakeFiles folder, trimpath
End Sub

Sub CreateObjs(package, folder, trimpath, do_start, do_end)
	creating_rules = false
	If do_start Then
		mfile.Write(package & "_objs =")
	End If
	FindSimpleMakeFiles folder, trimpath
	If do_end Then
		mfile.WriteLine
		mfile.WriteLine
	End If
End Sub

Function GenBuild()
	If Not f.FolderExists("winbuild") Then
		f.CreateFolder("winbuild")
	End If
	Set bfile = f.CreateTextFile("winbuild\build.bat", true)
	bfile.WriteLine("REM   (C) 2001 by Argonne National Laboratory.")
	bfile.WriteLine("REM      See COPYRIGHT in top-level directory.")
	bfile.WriteLine
	bfile.WriteLine("IF ""%1"" == """" ( SET SILENT=/S ) ELSE ( SET SILENT= )")
	bfile.WriteLine("nmake %SILENT%")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=sock RLOG=1")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=mt")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=mt RLOG=1")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=ssm")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=ssm RLOG=1")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=shm")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=shm RLOG=1")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=nemesis")
	bfile.WriteLine("nmake %SILENT% /NOLOGO CHANNEL=nemesis RLOG=1")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=sshm")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=sshm RLOG=1")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=ib IB=IBAL IB_PATH=c:\ibal\src\base IB_PATH_LIB=c:\ibal\Install")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=ib IB=IBAL IB_PATH=c:\ibal\src\base IB_PATH_LIB=c:\ibal\Install RLOG=1")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=ib IB=VAPI")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=ib IB=VAPI RLOG=1")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=essm")
'	bfile.WriteLine("REM nmake %SILENT% /NOLOGO CHANNEL=essm RLOG=1")
	bfile.WriteLine("nmake %SILENT% /NOLOGO cxx")
	bfile.WriteLine("nmake %SILENT% /NOLOGO fort")
	bfile.WriteLine("nmake %SILENT% /NOLOGO mpi_mod")
	bfile.WriteLine("nmake %SILENT% /NOLOGO gfort")
	bfile.WriteLine("nmake %SILENT% /NOLOGO sfort")
	bfile.WriteLine("nmake %SILENT% /NOLOGO irlog2rlog")
	bfile.WriteLine("nmake %SILENT% /NOLOGO TraceInput")
	bfile.WriteLine("nmake %SILENT% /NOLOGO gcc_libs")
	bfile.Close()

	Set mfile = f.CreateTextFile("winbuild\makefile", true)
	mfile.WriteLine("#")
	mfile.WriteLine("#   (C) 2001 by Argonne National Laboratory.")
	mfile.WriteLine("#      See COPYRIGHT in top-level directory.")
	mfile.WriteLine("#")
	mfile.WriteLine
	mfile.WriteLine("!IF ( ""$(CPU)"" == ""i386"" ) || ( ""$(CPU)"" == ""I386"" ) || ( ""$(CPU)"" == ""X86"" ) || ( ""$(CPU)"" == """" ) || ( ""$(CPU)"" == ""ia32"" ) || ( ""$(CPU)"" == ""IA32"" )")
	mfile.WriteLine("CPU = x86")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ( ""$(CPU)"" == ""X64"" ) || ( ""$(CPU)"" == ""AMD64"" ) || ( ""$(CPU)"" == ""amd64"" )")
	mfile.WriteLine("CPU = x64")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ""$(CPU)"" == ""IA64""")
	mfile.WriteLine("CPU = ia64")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("!IF ""$(CPU)"" != ""x64""")
	mfile.WriteLine("!IF ""$(CPU)"" != ""ia64""")
	mfile.WriteLine("!ERROR  Must specify CPU environment variable ( CPU=i386,x86,ia32,x64,amd64,ia64 )")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(cc)"" == """"")
	mfile.WriteLine("cc     = cl")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ""$(link)"" == """"")
	mfile.WriteLine("link   = link")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ""$(implib)"" == """"")
	mfile.WriteLine("implib = lib")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ""$(fc)"" == """"")
	mfile.WriteLine("fc = ifort")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CPU)"" == ""x86""")
	mfile.WriteLine("common_cflags = $(common_cflags) -D_X86_=1 -DWIN32 -D_WIN32 -W3")
	mfile.WriteLine("!ELSEIF ""$(CPU)"" == ""x64""")
	'mfile.WriteLine("common_cflags = $(common_cflags) -D_AMD64_=1 -D__x86_64__ -DWIN64 -D_WIN64 -Wp64 -W4")
	mfile.WriteLine("common_cflags = $(common_cflags) -D_AMD64_=1 -DWIN64 -D_WIN64 -Wp64 -W4")
	mfile.WriteLine("!ELSEIF ""$(CPU)"" == ""ia64""")
	mfile.WriteLine("common_cflags = $(common_cflags) -D_IA64_=1 -DWIN64 -D_WIN64 -Wp64 -W4")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IFNDEF APPVER")
	mfile.WriteLine("APPVER = 5.0")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ""$(APPVER)"" == ""5.0""")
	mfile.WriteLine("NMAKE_WINVER = 0x0500")
	mfile.WriteLine("!ELSEIF ""$(APPVER)"" == ""5.01""")
	mfile.WriteLine("NMAKE_WINVER = 0x0501")
	mfile.WriteLine("!ELSEIF ""$(APPVER)"" == ""5.02""")
	mfile.WriteLine("NMAKE_WINVER = 0x0502")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("common_cflags = $(common_cflags) -Oi -DMPI_EXPORTS -D_WINNT -D_WIN32_WINNT=$(NMAKE_WINVER)")
	mfile.WriteLine
        mfile.WriteLine("# Set USE_MTDLL_RUNLIB env variable to 1 if you need to use")
        mfile.WriteLine("# Multithreaded dynamic link runtime library to build MPICH2")
        mfile.WriteLine("# Default is multithreaded static run lib")
	mfile.WriteLine("!IFDEF NODEBUG")
	mfile.WriteLine("!IFDEF USE_MTDLL_RUNLIB")
	mfile.WriteLine("common_cflags = $(common_cflags) -Ox -DNDEBUG -D_MT -D_DLL -MD")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("common_cflags = $(common_cflags) -Ox -DNDEBUG -D_MT -MT")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("!IFDEF USE_MTDLL_RUNLIB")
	mfile.WriteLine("common_cflags = $(common_cflags) -Zi -Od -DDEBUG -D_MT -D_DLL -MDd")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("common_cflags = $(common_cflags) -Zi -Od -DDEBUG -D_MT -MTd")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("lflags  = $(lflags) /OPT:REF /INCREMENTAL:NO /NOLOGO /MANIFEST")
	mfile.WriteLine("!IFDEF NODEBUG")
	mfile.WriteLine("lflags = $(lflags) /RELEASE")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("lflags = $(lflags) /DEBUG:full /DEBUGTYPE:cv")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("conlflags = $(lflags) -subsystem:console,$(APPVER)")
	mfile.WriteLine("dlllflags = $(lflags) -dll")
	mfile.WriteLine("liblflags =")
	' End of win32.mak replacement
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == """"")
	mfile.WriteLine("CHANNEL = sock")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IFDEF NODEBUG")
	mfile.WriteLine("D =")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("D = d")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IFDEF RLOG")
	mfile.WriteLine("P = p")
	mfile.WriteLine("common_cflags = $(common_cflags) /DHAVE_STRNICMP /DHAVE_TIMING=MPID_TIMING_KIND_LOG_DETAILED /DUSE_LOGGING=MPID_LOGGING_RLOG")
	mfile.WriteLine("rlog_libs = $(RLOG_OUTDIR)\rlog$(D).lib")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("P =")
	mfile.WriteLine("rlog_libs =")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("common_cflags = -c -nologo $(common_cflags) \")
	mfile.WriteLine(" /DHAVE_WINDOWS_H \")
	mfile.WriteLine(" /DUSE_WINCONF_H \")
	mfile.WriteLine(" /DMPIO_BUILD_PROFILING \")
	mfile.WriteLine(" /DROMIO_INSIDE_MPICH2")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(NO_FORTRAN)"" == """"")
	mfile.WriteLine("common_cflags = $(common_cflags) /DHAVE_FORTRAN_BINDING")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("common_cflags = $(common_cflags) \")
	mfile.WriteLine(" /I..\src\include \")
	mfile.WriteLine(" /I..\src\util\wrappers \")
	mfile.WriteLine(" /I..\src\openpa\src \")
	mfile.WriteLine(" /I..\src\mpid\ch3\include \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\$(CHANNEL)\include \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\$(CHANNEL)\src \")
	mfile.WriteLine(" /I..\src\mpid\common\sock \")
	mfile.WriteLine(" /I..\src\mpid\common\sock\iocp \")
	mfile.WriteLine(" /I..\src\mpid\ch3\util\sock \")
	mfile.WriteLine(" /I..\src\mpi\romio\mpi-io \")
	mfile.WriteLine(" /I..\src\mpi\romio\adio\include \")
	mfile.WriteLine(" /I..\src\mpid\common\datatype \")
	mfile.WriteLine(" /I..\src\mpid\common\locks \")
	mfile.WriteLine(" /I..\src\mpi\datatype \")
	mfile.WriteLine(" /I..\src\mpi\binding\f90 \")
	mfile.WriteLine(" /I..\src\pm\smpd \")
	mfile.WriteLine(" /I..\src\pm\smpd\sock\include \")
	mfile.WriteLine(" /I..\src\pm\smpd\sock\iocp\include \")
	mfile.WriteLine(" /I..\src\mpi\spawn \")
	mfile.WriteLine(" /I..\src\binding\f77")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CPU)"" == ""i386"" || ""$(CPU)"" == ""x86""")
	mfile.WriteLine("common_cflags = $(common_cflags) /I..\src\include\win32 /I..\src\binding\f90\win32 /I..\src\openpa\src\win32")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("common_cflags = $(common_cflags) /I..\src\include\win64 /I..\src\binding\f90\win64 /I..\src\openpa\src\win64")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("cxxflags = $(common_cflags)")
	mfile.WriteLine("cflags = $(cflags) $(common_cflags) /DMPICH_SKIP_MPICXX")
	mfile.WriteLine("fcflags = \")
	mfile.WriteLine(" /DUSE_FORT_CDECL \")
	mfile.WriteLine(" /DUSE_MSC_DLLSPEC \")
	mfile.WriteLine(" /DFORTRAN_EXPORTS \")
	mfile.WriteLine(" /UMPI_EXPORTS \")
	mfile.WriteLine(" /DF77_NAME_UPPER \")
	mfile.WriteLine(" /DHAVE_C_API")
	mfile.WriteLine("gfcflags = \")
	mfile.WriteLine(" /DUSE_FORT_CDECL \")
	mfile.WriteLine(" /DUSE_MSC_DLLSPEC \")
	mfile.WriteLine(" /DFORTRAN_EXPORTS \")
	mfile.WriteLine(" /UMPI_EXPORTS \")
	mfile.WriteLine(" /DFORTRANDOUBLEUNDERSCORE \")
	mfile.WriteLine(" /DF77_NAME_LOWER_2USCORE \")
	mfile.WriteLine(" /DHAVE_C_API")
	mfile.WriteLine("sfcflags = \")
	mfile.WriteLine(" /DUSE_FORT_STDCALL \")
	mfile.WriteLine(" /DUSE_MSC_DLLSPEC \")
	mfile.WriteLine(" /DFORTRAN_EXPORTS \")
	mfile.WriteLine(" /UMPI_EXPORTS \")
	mfile.WriteLine(" /DF77_NAME_UPPER \")
	mfile.WriteLine(" /DUSE_FORT_MIXED_STR_LEN \")
	mfile.WriteLine(" /DHAVE_C_API")
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("fcflags = $(fcflags) /DHAVE_AINT_LARGER_THAN_FINT")
	mfile.WriteLine("gfcflags = $(gfcflags) /DHAVE_AINT_LARGER_THAN_FINT")
	mfile.WriteLine("sfcflags = $(sfcflags) /DHAVE_AINT_LARGER_THAN_FINT")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("fortflags = /iface:cref /c /names:uppercase")
	mfile.WriteLine("gfortflags = /iface:cref /assume:underscore /c /names:lowercase")
	mfile.WriteLine("sfortflags = /iface:stdcall /c /names:uppercase")
	mfile.WriteLine("!IF ""$(CPU)"" == ""x86""")
        mfile.WriteLine("fortflags = $(fortflags) /I..\src\include\win32 ")
        mfile.WriteLine("!ELSE")
        mfile.WriteLine("fortflags = $(fortflags) /I..\src\include\win64 ")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("impl_cxxflags = $(cflags)")
	mfile.WriteLine("mpe_cflags = \")
	mfile.WriteLine(" /I ..\src\mpe2\include \")
	mfile.WriteLine(" /I ..\src\mpe2\src\logging\include \")
	mfile.WriteLine(" /I ..\src\mpe2\src\callstack \")
	mfile.WriteLine(" /I ..\src\mpe2\src\callstack\include")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""ib""")
	mfile.WriteLine("!IFNDEF IB")
	mfile.WriteLine("IB = IBAL")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IFNDEF IB_PATH")
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("IB_PATH = c:\mellanox64")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("IB_PATH = c:\mellanox")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!IF ""$(IB)"" == ""IBAL""")
	mfile.WriteLine("cflags = $(cflags) /DUSE_IB_$(IB) /I$(IB_PATH)\shared\include /I$(IB_PATH)\shared\include\iba /I$(IB_PATH)\winuser\include")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("cflags = $(cflags) /DUSE_IB_$(IB) /I$(IB_PATH)\include")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""mt""")
	mfile.WriteLine("cflags = $(cflags) \")
	mfile.WriteLine(" /DMPICH_MULTITHREADED \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\sock\include \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\sock\src")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""nemesis""")
	mfile.WriteLine("cflags = $(cflags) \")
	mfile.WriteLine(" /DMPICH_MULTITHREADED /D ENABLE_NO_MACRO_VARARG_NAME \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\nemesis\nemesis\include \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\nemesis\nemesis\utils\monitor \")
	mfile.WriteLine(" /I..\src\mpid\ch3\channels\nemesis\nemesis\netmod\wintcp")
	mfile.WriteLine("!ENDIF")
'	mfile.WriteLine
'	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""essm""")
'	mfile.WriteLine("cflags = $(cflags) /DMPICH_MULTITHREADED")
'	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("mpich2_libs = activeds.lib adsiid.lib netapi32.lib ntdsapi.lib secur32.lib mswsock.lib ws2_32.lib mpr.lib rpcrt4.lib crypt32.lib gdi32.lib kernel32.lib advapi32.lib")
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("common_libs = bufferoverflowU.lib")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""ib""")
	mfile.WriteLine("!IF ""$(IB)"" == ""IBAL""")
	mfile.WriteLine("!IF ""$(IB_PATH_LIB)"" == """"")
	mfile.WriteLine("mpich2_libs = $(mpich2_libs) ibal.lib complib.lib /LIBPATH:$(IB_PATH)\lib")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("mpich2_libs = $(mpich2_libs) ibal.lib complib.lib /LIBPATH:$(IB_PATH_LIB)\AMD64")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("mpich2_libs = $(mpich2_libs) ibal.lib complib.lib /LIBPATH:$(IB_PATH_LIB)\x86")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("!IF ""$(IB_PATH_LIB)"" == """"")
	mfile.WriteLine("mpich2_libs = $(mpich2_libs) vapi.lib vapi_common.lib /LIBPATH:$(IB_PATH)\lib\release")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("mpich2_libs = $(mpich2_libs) vapi.lib vapi_common.lib /LIBPATH:$(IB_PATH_LIB)")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(NODEBUG)"" == """"")
	mfile.WriteLine("CFG = Debug")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("CFG = Release")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""ib""")
	mfile.WriteLine("OUTDIR = $(CPU)\$(CFG)\$(CHANNEL)_$(IB)$(P)")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("OUTDIR = $(CPU)\$(CFG)\$(CHANNEL)$(P)")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("BIN_OUTDIR = $(CPU)\$(CFG)\bin")
	mfile.WriteLine("SOCK_OUTDIR = $(CPU)\$(CFG)\sock$(P)")
	mfile.WriteLine("MT_OUTDIR = $(CPU)\$(CFG)\mt$(P)")
	mfile.WriteLine("SSM_OUTDIR = $(CPU)\$(CFG)\ssm$(P)")
	mfile.WriteLine("SHM_OUTDIR = $(CPU)\$(CFG)\shm$(P)")
	mfile.WriteLine("NEMESIS_OUTDIR = $(CPU)\$(CFG)\nemesis$(P)")
'	mfile.WriteLine("SSHM_OUTDIR = $(CPU)\$(CFG)\sshm$(P)")
'	mfile.WriteLine("ESSM_OUTDIR = $(CPU)\$(CFG)\essm$(P)")
'	mfile.WriteLine("IB_OUTDIR = $(CPU)\$(CFG)\ib_$(IB)$(P)")
	mfile.WriteLine("FORT_OUTDIR = $(CPU)\$(CFG)\fortran")
	mfile.WriteLine("GFORT_OUTDIR = $(CPU)\$(CFG)\gfortran")
	mfile.WriteLine("SFORT_OUTDIR = $(CPU)\$(CFG)\sfortran")
	mfile.WriteLine("CXX_OUTDIR = $(CPU)\$(CFG)\cxx")
	mfile.WriteLine("MPI_OUTDIR = $(CPU)\$(CFG)\mpi")
	mfile.WriteLine("RLOG_OUTDIR = $(CPU)\$(CFG)\rlog")
	mfile.WriteLine("MPE_OUTDIR = $(CPU)\$(CFG)\mpe")
	mfile.WriteLine("FMPE_OUTDIR = $(CPU)\$(CFG)\fmpe")
	mfile.WriteLine("MPE_WRAP_OUTDIR = $(CPU)\$(CFG)\mpe_wrap")
	mfile.WriteLine("GCC_OUTDIR = $(CPU)\$(CFG)\gcc")
	mfile.WriteLine
	mfile.WriteLine("# The first rule gets built if nothing is specified on the nmake command line")
	mfile.WriteLine("all_redirect: all")
	mfile.WriteLine
	mfile.WriteLine("$(OUTDIR) :")
	mfile.WriteLine("    if not exist ""$(OUTDIR)\$(NULL)"" mkdir $(OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(BIN_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(BIN_OUTDIR)\$(NULL)"" mkdir $(BIN_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(FORT_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(FORT_OUTDIR)\$(NULL)"" mkdir $(FORT_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(GFORT_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(GFORT_OUTDIR)\$(NULL)"" mkdir $(GFORT_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(SFORT_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(SFORT_OUTDIR)\$(NULL)"" mkdir $(SFORT_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(CXX_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(CXX_OUTDIR)\$(NULL)"" mkdir $(CXX_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(MPI_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(MPI_OUTDIR)\$(NULL)"" mkdir $(MPI_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(RLOG_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(RLOG_OUTDIR)\$(NULL)"" mkdir $(RLOG_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(MPE_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(MPE_OUTDIR)\$(NULL)"" mkdir $(MPE_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(FMPE_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(FMPE_OUTDIR)\$(NULL)"" mkdir $(FMPE_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(MPE_WRAP_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(MPE_WRAP_OUTDIR)\$(NULL)"" mkdir $(MPE_WRAP_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("$(GCC_OUTDIR) :")
	mfile.WriteLine("	if not exist ""$(GCC_OUTDIR)\$(NULL)"" mkdir $(GCC_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("# clean destroys everything, even user generated files")
	mfile.WriteLine("CLEAN:")
	mfile.WriteLine("	if exist $(OUTDIR)\$(NULL) rd /s /q $(OUTDIR)")
	mfile.WriteLine("	if exist $(BIN_OUTDIR)\$(NULL) rd /s /q $(BIN_OUTDIR)")
	mfile.WriteLine("	if exist $(SOCK_OUTDIR)\$(NULL) rd /s /q $(SOCK_OUTDIR)")
	mfile.WriteLine("	if exist $(MT_OUTDIR)\$(NULL) rd /s /q $(MT_OUTDIR)")
	mfile.WriteLine("	if exist $(SSM_OUTDIR)\$(NULL) rd /s /q $(SSM_OUTDIR)")
	mfile.WriteLine("	if exist $(SHM_OUTDIR)\$(NULL) rd /s /q $(SHM_OUTDIR)")
	mfile.WriteLine("	if exist $(NEMESIS_OUTDIR)\$(NULL) rd /s /q $(NEMESIS_OUTDIR)")
'	mfile.WriteLine("	if exist $(SSHM_OUTDIR)\$(NULL) rd /s /q $(SSHM_OUTDIR)")
'	mfile.WriteLine("	if exist $(ESSM_OUTDIR)\$(NULL) rd /s /q $(ESSM_OUTDIR)")
'	mfile.WriteLine("	if exist $(IB_OUTDIR)IBAL\$(NULL) rd /s /q $(IB_OUTDIR)IBAL")
'	mfile.WriteLine("	if exist $(IB_OUTDIR)VAPI\$(NULL) rd /s /q $(IB_OUTDIR)VAPI")
	mfile.WriteLine("	if exist $(SOCK_OUTDIR)p\$(NULL) rd /s /q $(SOCK_OUTDIR)p")
	mfile.WriteLine("	if exist $(MT_OUTDIR)p\$(NULL) rd /s /q $(MT_OUTDIR)p")
	mfile.WriteLine("	if exist $(SSM_OUTDIR)p\$(NULL) rd /s /q $(SSM_OUTDIR)p")
	mfile.WriteLine("	if exist $(SHM_OUTDIR)p\$(NULL) rd /s /q $(SHM_OUTDIR)p")
	mfile.WriteLine("	if exist $(NEMESIS_OUTDIR)p\$(NULL) rd /s /q $(NEMESIS_OUTDIR)p")
'	mfile.WriteLine("	if exist $(SSHM_OUTDIR)p\$(NULL) rd /s /q $(SSHM_OUTDIR)p")
'	mfile.WriteLine("	if exist $(ESSM_OUTDIR)p\$(NULL) rd /s /q $(ESSM_OUTDIR)p")
'	mfile.WriteLine("	if exist $(IB_OUTDIR)IBALp\$(NULL) rd /s /q $(IB_OUTDIR)IBALp")
'	mfile.WriteLine("	if exist $(IB_OUTDIR)VAPIp\$(NULL) rd /s /q $(IB_OUTDIR)VAPIp")
	mfile.WriteLine("	if exist $(FORT_OUTDIR)\$(NULL) rd /s /q $(FORT_OUTDIR)")
	mfile.WriteLine("	if exist $(GFORT_OUTDIR)\$(NULL) rd /s /q $(GFORT_OUTDIR)")
	mfile.WriteLine("	if exist $(SFORT_OUTDIR)\$(NULL) rd /s /q $(SFORT_OUTDIR)")
	mfile.WriteLine("	if exist $(CXX_OUTDIR)\$(NULL) rd /s /q $(CXX_OUTDIR)")
	mfile.WriteLine("	if exist $(MPI_OUTDIR)\$(NULL) rd /s /q $(MPI_OUTDIR)")
	mfile.WriteLine("	if exist $(RLOG_OUTDIR)\$(NULL) rd /s /q $(RLOG_OUTDIR)")
	mfile.WriteLine("	if exist $(MPE_OUTDIR)\$(NULL) rd /s /q $(MPE_OUTDIR)")
	mfile.WriteLine("	if exist $(FMPE_OUTDIR)\$(NULL) rd /s /q $(FMPE_OUTDIR)")
	mfile.WriteLine("	if exist $(MPE_WRAP_OUTDIR)\$(NULL) rd /s /q $(MPE_WRAP_OUTDIR)")
	mfile.WriteLine("	if exist $(GCC_OUTDIR)\$(NULL) rd /s /q $(GCC_OUTDIR)")
	mfile.WriteLine

	trimlength = Len(f.GetFolder(".").Path) + 1

	mfile.WriteLine
	mfile.WriteLine("# MPICH2")
	mfile.WriteLine
	CreateRules f.GetFolder("src\mpi"), trimlength
	CreateRules f.GetFolder("src\binding\f90"), trimlength
	CreateRules f.GetFolder("src\mpid\common\datatype"), trimlength
	CreateRules f.GetFolder("src\util\mem"), trimlength
	CreateRules f.GetFolder("src\util\dbg"), trimlength
	CreateRules f.GetFolder("src\util\msgs"), trimlength
	CreateRules f.GetFolder("src\util\procmap"), trimlength
	CreateRules f.GetFolder("src\pmi\smpd"), trimlength
	CreateRules f.GetFolder("src\pm\smpd"), trimlength
	' Create a special rule for smpd_adreg.cpp since it must be compiled for UNICODE
	mfile.WriteLine("$(" & outdir & ")\smpd_adreg.obj: ..\src\pm\smpd\smpd_adreg.cpp")
	mfile.WriteLine("    $(cc) $(cflags) /DUNICODE /D_UNICODE /Fo""$(" & outdir & ")\\"" /Fd""$(" & outdir & ")\\"" ..\src\pm\smpd\smpd_adreg.cpp")
	mfile.WriteLine
	CreateRules f.GetFolder("src\nameserv\pmi"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\src"), trimlength
	CreateRules f.GetFolder("src\mpid\common\locks"), trimlength
	CreateRules f.GetFolder("src\mpid\common\sock\iocp"), trimlength
	CreateRules f.GetFolder("src\util\info"), trimlength
'	CreateRules f.GetFolder("src\util\timing"), trimlength
	CreateRules f.GetFolder("src\util\logging\common"), trimlength
	CreateRules f.GetFolder("src\util\param"), trimlength
        CreateRules f.GetFolder("src\util\thread"), trimlength
	' Insert rules for romio manually since romio is not build with Makefile.sm files
	mfile.WriteLine("{..\src\mpi\romio\adio\ad_ntfs}.c{$(OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpi\romio\adio\common}.c{$(OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpi\romio\mpi-io}.c{$(OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpi\romio\mpi-io\glue\mpich2}.c{$(OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpi\romio\mpi2-other\array}.c{$(OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("$(OUTDIR)\rlogtime.obj: ..\src\util\logging\rlog\rlogtime.c")
	mfile.WriteLine("	$(cc) $(cflags) /I..\src\util\logging\common /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\util\logging\rlog\rlogtime.c")
	mfile.WriteLine
	CreateObjs "mpich2", f.GetFolder("src\mpi"), trimlength, true, false
	CreateObjs "mpich2", f.GetFolder("src\mpid\common\datatype"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\mem"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\dbg"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\msgs"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\procmap"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\pmi\smpd"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\pm\smpd"), trimlength, false, false
	mfile.Write(" \" & vbCrLF & "	$(" & outdir & ")\smpd_adreg.obj")
	CreateObjs "mpich2", f.GetFolder("src\nameserv\pmi"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\mpid\ch3\src"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\mpid\common\locks"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\mpid\common\sock\iocp"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\info"), trimlength, false, false
'	CreateObjs "mpich2", f.GetFolder("src\util\timing"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\logging\common"), trimlength, false, false
	CreateObjs "mpich2", f.GetFolder("src\util\param"), trimlength, false, false
        CreateObjs "mpich2", f.GetFolder("src\util\thread"), trimlength, false, false
	mfile.WriteLine(" \" & vbCrLf & "	$(OUTDIR)\ad_ntfs.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_close.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_done.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_fcntl.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_flush.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_iread.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_iwrite.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_open.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_read.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_resize.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_wait.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_ntfs_write.obj \")
	mfile.WriteLine("	$(OUTDIR)\greq_fns.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_darray.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_subarray.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_aggregate.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_close.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_delete.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_end.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_fstype.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_get_sh_fp.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_hints.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_init.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_iopen.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_iread_fake.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_iwrite_fake.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_open.obj \")
	mfile.WriteLine("	$(OUTDIR)\system_hints.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_prealloc.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_features.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_opencoll.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_read_coll.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_read_str.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_read_str_naive.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_seek.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_set_sh_fp.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_set_view.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_write_coll.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_write_str.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_write_str_naive.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_io_coll.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_opencoll.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_coll_build_req_new.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_coll_exch_new.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_aggregate_new.obj \")
	mfile.WriteLine("	$(OUTDIR)\ad_features.obj \")
	mfile.WriteLine("	$(OUTDIR)\heap-sort.obj \")
'	mfile.WriteLine("	$(OUTDIR)\async_list.obj \")
	mfile.WriteLine("	$(OUTDIR)\byte_offset.obj \")
	mfile.WriteLine("	$(OUTDIR)\cb_config_list.obj \")
	mfile.WriteLine("	$(OUTDIR)\eof_offset.obj \")
	mfile.WriteLine("	$(OUTDIR)\error.obj \")
	mfile.WriteLine("	$(OUTDIR)\flatten.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_fp_posn.obj \")
	mfile.WriteLine("	$(OUTDIR)\iscontig.obj \")
	mfile.WriteLine("	$(OUTDIR)\lock.obj \")
	mfile.WriteLine("	$(OUTDIR)\malloc.obj \")
'	mfile.WriteLine("	$(OUTDIR)\req_malloc.obj \")
	mfile.WriteLine("	$(OUTDIR)\shfp_fname.obj \")
	mfile.WriteLine("	$(OUTDIR)\status_setb.obj \")
	mfile.WriteLine("	$(OUTDIR)\close.obj \")
	mfile.WriteLine("	$(OUTDIR)\delete.obj \")
	mfile.WriteLine("	$(OUTDIR)\mpir-mpioinit.obj \")
	mfile.WriteLine("	$(OUTDIR)\file_c2f.obj \")
	mfile.WriteLine("	$(OUTDIR)\file_f2c.obj \")
	mfile.WriteLine("	$(OUTDIR)\fsync.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_amode.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_atom.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_bytoff.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_extent.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_group.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_info.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_posn.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_posn_sh.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_size.obj \")
	mfile.WriteLine("	$(OUTDIR)\get_view.obj \")
	mfile.WriteLine("	$(OUTDIR)\mpio_err.obj \")
	mfile.WriteLine("	$(OUTDIR)\mpio_file.obj \")
	mfile.WriteLine("	$(OUTDIR)\ioreq_c2f.obj \")
	mfile.WriteLine("	$(OUTDIR)\ioreq_f2c.obj \")
	mfile.WriteLine("	$(OUTDIR)\iotest.obj \")
	mfile.WriteLine("	$(OUTDIR)\iowait.obj \")
	mfile.WriteLine("	$(OUTDIR)\iread.obj \")
	mfile.WriteLine("	$(OUTDIR)\iread_at.obj \")
	mfile.WriteLine("	$(OUTDIR)\iread_sh.obj \")
	mfile.WriteLine("	$(OUTDIR)\iwrite.obj \")
	mfile.WriteLine("	$(OUTDIR)\iwrite_at.obj \")
	mfile.WriteLine("	$(OUTDIR)\iwrite_sh.obj \")
	mfile.WriteLine("	$(OUTDIR)\mpich2_fileutil.obj \")
	mfile.WriteLine("	$(OUTDIR)\mpiu_greq.obj \")
	mfile.WriteLine("	$(OUTDIR)\open.obj \")
	mfile.WriteLine("	$(OUTDIR)\prealloc.obj \")
	mfile.WriteLine("	$(OUTDIR)\rd_atallb.obj \")
	mfile.WriteLine("	$(OUTDIR)\rd_atalle.obj \")
	mfile.WriteLine("	$(OUTDIR)\read.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_all.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_allb.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_alle.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_at.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_atall.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_ord.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_ordb.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_orde.obj \")
	mfile.WriteLine("	$(OUTDIR)\read_sh.obj \")
	mfile.WriteLine("	$(OUTDIR)\seek.obj \")
	mfile.WriteLine("	$(OUTDIR)\seek_sh.obj \")
	mfile.WriteLine("	$(OUTDIR)\set_atom.obj \")
	mfile.WriteLine("	$(OUTDIR)\set_info.obj \")
	mfile.WriteLine("	$(OUTDIR)\set_size.obj \")
	mfile.WriteLine("	$(OUTDIR)\set_view.obj \")
	mfile.WriteLine("	$(OUTDIR)\wr_atallb.obj \")
	mfile.WriteLine("	$(OUTDIR)\wr_atalle.obj \")
	mfile.WriteLine("	$(OUTDIR)\strfns.obj \")
	mfile.WriteLine("	$(OUTDIR)\write.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_all.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_allb.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_alle.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_at.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_atall.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_ord.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_ordb.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_orde.obj \")
	mfile.WriteLine("	$(OUTDIR)\write_sh.obj \")
	' Insert objs for f90 type create funcs manually because the src/binding/f90
        ' directory has both C & fortran interfaces
        mfile.WriteLine("   $(OUTDIR)\create_f90_util.obj \")
        mfile.WriteLine("   $(OUTDIR)\create_f90_int.obj \")
        mfile.WriteLine("   $(OUTDIR)\create_f90_real.obj \")
        mfile.WriteLine("   $(OUTDIR)\create_f90_complex.obj")
	mfile.WriteLine
	mfile.WriteLine("!IFDEF RLOG")
	mfile.WriteLine("mpich2_objs = $(mpich2_objs) $(OUTDIR)\rlogtime.obj")
	mfile.WriteLine("!ENDIF")

	mfile.WriteLine
	mfile.WriteLine("# ch3sock")
	mfile.WriteLine
	outdir = "SOCK_OUTDIR"
	CreateRules f.GetFolder("src\mpid\ch3\channels\sock"), trimlength
	'CreateRules f.GetFolder("src\mpid\common\sock\iocp"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\sock"), trimlength
	CreateObjs "ch3sock", f.GetFolder("src\mpid\ch3\channels\sock"), trimlength, true, false
	CreateObjs "ch3sock", f.GetFolder("src\mpid\ch3\util\sock"), trimlength, false, true
	'CreateObjs "ch3sock", f.GetFolder("src\mpid\common\sock\iocp"), trimlength, false, true

	mfile.WriteLine
	mfile.WriteLine("# ch3mt")
	mfile.WriteLine
	outdir = "MT_OUTDIR"
	CreateRules f.GetFolder("src\mpid\ch3\channels\sock"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\sock"), trimlength
	'CreateRules f.GetFolder("src\util\events"), trimlength
	CreateObjs "ch3mt", f.GetFolder("src\mpid\ch3\channels\sock"), trimlength, true, false
	CreateObjs "ch3mt", f.GetFolder("src\mpid\ch3\util\sock"), trimlength, false, true
	'CreateObjs "ch3mt", f.GetFolder("src\util\events"), trimlength, false, false

	mfile.WriteLine
	mfile.WriteLine("# ch3nemesis")
	mfile.WriteLine
	outdir = "NEMESIS_OUTDIR"
	CreateRules f.GetFolder("src\mpid\ch3\channels\nemesis\src"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\channels\nemesis\nemesis\src"), trimlength
'	CreateRules f.GetFolder("src\mpid\ch3\channels\nemesis\nemesis\utils"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\channels\nemesis\nemesis\netmod\wintcp"), trimlength
	CreateObjs "ch3nemesis", f.GetFolder("src\mpid\ch3\channels\nemesis\src"), trimlength, true, false
	CreateObjs "ch3nemesis", f.GetFolder("src\mpid\ch3\channels\nemesis\nemesis\src"), trimlength, false, false
'	CreateObjs "ch3nemesis", f.GetFolder("src\mpid\ch3\channels\nemesis\nemesis\utils"), trimlength, false, false
	CreateObjs "ch3nemesis", f.GetFolder("src\mpid\ch3\channels\nemesis\nemesis\netmod\wintcp"), trimlength, false, true

	mfile.WriteLine
	mfile.WriteLine("# ch3ssm")
	mfile.WriteLine
	outdir = "SSM_OUTDIR"
	CreateRules f.GetFolder("src\mpid\ch3\channels\ssm"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\sock"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\shm"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\shmproc"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\shmbase"), trimlength
	CreateObjs "ch3ssm", f.GetFolder("src\mpid\ch3\channels\ssm"), trimlength, true, false
	CreateObjs "ch3ssm", f.GetFolder("src\mpid\ch3\util\shm"), trimlength, false, false
	CreateObjs "ch3ssm", f.GetFolder("src\mpid\ch3\util\shmproc"), trimlength, false, false
	CreateObjs "ch3ssm", f.GetFolder("src\mpid\ch3\util\shmbase"), trimlength, false, false
	CreateObjs "ch3ssm", f.GetFolder("src\mpid\ch3\util\sock"), trimlength, false, true

	mfile.WriteLine
	mfile.WriteLine("# ch3shm")
	mfile.WriteLine
	outdir = "SHM_OUTDIR"
	CreateRules f.GetFolder("src\mpid\ch3\channels\shm"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\channels\shm\src"), trimlength
	CreateRules f.GetFolder("src\mpid\common\locks"), trimlength
	CreateRules f.GetFolder("src\mpid\ch3\util\shmbase"), trimlength
	CreateObjs "ch3shm", f.GetFolder("src\mpid\ch3\channels\shm"), trimlength, true, false
	CreateObjs "ch3shm", f.GetFolder("src\mpid\ch3\channels\shm\src"), trimlength, false, false
	CreateObjs "ch3shm", f.GetFolder("src\mpid\common\locks"), trimlength, false, false
	CreateObjs "ch3shm", f.GetFolder("src\mpid\ch3\util\shmbase"), trimlength, false, true

'	mfile.WriteLine
'	mfile.WriteLine("# ch3sshm")
'	mfile.WriteLine
'	outdir = "SSHM_OUTDIR"
'	CreateRules f.GetFolder("src\mpid\ch3\channels\sshm"), trimlength
'	CreateRules f.GetFolder("src\mpid\ch3\util\shm"), trimlength
'	CreateObjs "ch3sshm", f.GetFolder("src\mpid\ch3\channels\sshm"), trimlength, true, false
'	CreateObjs "ch3sshm", f.GetFolder("src\mpid\ch3\util\shm"), trimlength, false, true

'	mfile.WriteLine
'	mfile.WriteLine("# ch3essm")
'	mfile.WriteLine
'	outdir = "ESSM_OUTDIR"
'	CreateRules f.GetFolder("src\mpid\ch3\channels\essm"), trimlength
'	CreateRules f.GetFolder("src\util\events"), trimlength
'	mfile.WriteLine("{..\src\util\thread}.c{$(ESSM_OUTDIR)}.obj:")
'	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(ESSM_OUTDIR)\\"" /Fd""$(ESSM_OUTDIR)\\"" $**")
'	mfile.WriteLine
'	CreateObjs "ch3essm", f.GetFolder("src\mpid\ch3\channels\essm"), trimlength, true, false
'	CreateObjs "ch3essm", f.GetFolder("src\util\events"), trimlength, false, false
'	mfile.WriteLine(" \" & vbCrLf & "	$(ESSM_OUTDIR)\mpe_thread_win.obj")

'	mfile.WriteLine
'	mfile.WriteLine("# ch3ib")
'	mfile.WriteLine
'	outdir = "IB_OUTDIR"
'	CreateRules f.GetFolder("src\mpid\ch3\channels\ib"), trimlength
'	CreateObjs "ch3ib", f.GetFolder("src\mpid\ch3\channels\ib"), trimlength, true, true

	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""sock""")
	mfile.WriteLine
	mfile.WriteLine("ch3sock: $(SOCK_OUTDIR)\mpich2$(P)$(D).dll")
	mfile.WriteLine
	mfile.WriteLine("$(SOCK_OUTDIR)\mpich2$(P)$(D).dll: $(ch3sock_objs) $(mpich2_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(ch3sock_objs) $(mpich2_objs) $(mpich2_libs) $(rlog_libs) $(common_libs) -out:$(SOCK_OUTDIR)\mpich2$(P)$(D).dll /DEF:..\mpich2.def")
	mfile.WriteLine("	if exist $(SOCK_OUTDIR)\mpich2$(P)$(D).dll.manifest mt.exe -manifest $(SOCK_OUTDIR)\mpich2$(P)$(D).dll.manifest -outputresource:$(SOCK_OUTDIR)\mpich2$(P)$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("!ELSE")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""ssm""")
	mfile.WriteLine("channel_objs = $(ch3ssm_objs)")
	mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""shm""")
	mfile.WriteLine("channel_objs = $(ch3shm_objs)")
'	mfile.WriteLine("# !ELSEIF ""$(CHANNEL)"" == ""sshm""")
'	mfile.WriteLine("# channel_objs = $(ch3sshm_objs)")
'	mfile.WriteLine("# !ELSEIF ""$(CHANNEL)"" == ""essm""")
'	mfile.WriteLine("# channel_objs = $(ch3essm_objs)")
'	mfile.WriteLine("# !ELSEIF ""$(CHANNEL)"" == ""ib""")
'	mfile.WriteLine("# channel_objs = $(ch3ib_objs)")
	mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""mt""")
	mfile.WriteLine("channel_objs = $(ch3mt_objs)")
	mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""nemesis""")
	mfile.WriteLine("channel_objs = $(ch3nemesis_objs)")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("!ERROR Invalid channel selected - $(CHANNEL)")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine
	mfile.WriteLine("ch3$(CHANNEL): $(OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	mfile.WriteLine
	mfile.WriteLine("$(OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(channel_objs) $(mpich2_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(channel_objs) $(mpich2_objs) $(mpich2_libs) $(rlog_libs) $(common_libs) -out:$(OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll /DEF:..\mpich2.def")
	mfile.WriteLine("	if exist $(OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll.manifest mt.exe -manifest $(OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll.manifest -outputresource:$(OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("!ENDIF")

	'mfile.WriteLine
	'mfile.WriteLine("!IF ""$(CHANNEL)"" == ""sock""")
	'mfile.WriteLine("ch3sock: $(SOCK_OUTDIR)\mpich2$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(SOCK_OUTDIR)\mpich2$(P)$(D).dll: $(ch3sock_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3sock_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(SOCK_OUTDIR)\mpich2$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""ssm""")
	'mfile.WriteLine("ch3ssm: $(SSM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(SSM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(ch3ssm_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3ssm_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(SSM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""shm""")
	'mfile.WriteLine("ch3shm: $(SHM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(SHM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(ch3shm_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3shm_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(SHM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""sshm""")
	'mfile.WriteLine("ch3sshm: $(SSHM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(SSHM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(ch3sshm_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3sshm_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(SSHM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""essm""")
	'mfile.WriteLine("ch3essm: $(ESSM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(ESSM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(ch3essm_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3essm_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(ESSM_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""ib""")
	'mfile.WriteLine("ch3ib: $(IB_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(IB_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(ch3ib_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3ib_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(IB_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSEIF ""$(CHANNEL)"" == ""mt""")
	'mfile.WriteLine("ch3mt: $(MT_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("$(MT_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll: $(ch3mt_objs) $(mpich2_objs)")
	'mfile.WriteLine("	$(link) $(dlllflags) $(ch3mt_objs) $(mpich2_objs) $(rlog_libs) $(common_libs) -out:$(MT_OUTDIR)\mpich2$(CHANNEL)$(P)$(D).dll")
	'mfile.WriteLine
	'mfile.WriteLine("!ELSE")
	'mfile.WriteLine("!ERROR No channel selected")
	'mfile.WriteLine("!ENDIF")

	mfile.WriteLine
	mfile.WriteLine("# Fortran")
	mfile.WriteLine
	outdir = "FORT_OUTDIR"
	extra_flags = "$(fcflags)"
	fort_prefix = ""
	CreateRules f.GetFolder("src\binding\f77"), trimlength
	CreateRules f.GetFolder("src\binding\f90"), trimlength
	mfile.WriteLine
	CreateObjs "fort", f.GetFolder("src\binding\f77"), trimlength, true, false
	mfile.WriteLine(" \" & vbCrLf & "   $(FORT_OUTDIR)\typef90intf.obj \")
        mfile.WriteLine("   $(FORT_OUTDIR)\typef90realf.obj \")
        mfile.WriteLine("   $(FORT_OUTDIR)\typef90cmplxf.obj")
        mfile.WriteLine

	mfile.WriteLine("$(FORT_OUTDIR)\fmpich2$(D).dll: $(fort_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(fort_objs) $(MPI_OUTDIR)\mpi$(D).lib $(common_libs) /DEF:..\src\binding\f77\mpich2f.def -out:$(FORT_OUTDIR)\fmpich2$(D).dll")
	mfile.WriteLine("	if exist $(FORT_OUTDIR)\fmpich2$(D).dll.manifest mt.exe -manifest $(FORT_OUTDIR)\fmpich2$(D).dll.manifest -outputresource:$(FORT_OUTDIR)\fmpich2$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("fort: $(FORT_OUTDIR) $(FORT_OUTDIR)\fmpich2$(D).dll")
	mfile.WriteLine
        ' Adding rules for F90 mod files
        mfile.WriteLine("{..\src\binding\f90}.f90{$(FORT_OUTDIR)}.mod:")
	mfile.WriteLine("!IF ""$(CPU)"" == ""x86""")
        mfile.WriteLine("   copy /y ..\src\binding\f90\win32\mpi_sizeofs.f90 ..\src\binding\f90")
	mfile.WriteLine("!ELSE")
        mfile.WriteLine("   copy /y ..\src\binding\f90\win64\mpi_sizeofs.f90 ..\src\binding\f90")
	mfile.WriteLine("!ENDIF")
        mfile.WriteLine("   $(fc) $(fortflags) /module:""$(FORT_OUTDIR)\\"" /object:""$(FORT_OUTDIR)\\"" $**")
        mfile.WriteLine
        mfile.WriteLine("mpi_mod_objs = \")
        mfile.WriteLine("   $(FORT_OUTDIR)\mpi_constants.mod \")
        mfile.WriteLine("   $(FORT_OUTDIR)\mpi_base.mod \")
        mfile.WriteLine("   $(FORT_OUTDIR)\mpi_sizeofs.mod \")
        mfile.WriteLine("   $(FORT_OUTDIR)\mpi.mod ")
        mfile.WriteLine
        mfile.WriteLine("mpi_mod: $(FORT_OUTDIR) $(mpi_mod_objs)")
        mfile.WriteLine
	outdir = "GFORT_OUTDIR"
	extra_flags = "$(gfcflags)"
	fort_prefix = "g"
	CreateRules f.GetFolder("src\binding\f77"), trimlength
	CreateObjs "gfort", f.GetFolder("src\binding\f77"), trimlength, true, true
	mfile.WriteLine("$(GFORT_OUTDIR)\fmpich2g$(D).dll: $(gfort_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(gfort_objs) $(MPI_OUTDIR)\mpi$(D).lib $(common_libs) /DEF:..\src\binding\f77\mpich2fg.def -out:$(GFORT_OUTDIR)\fmpich2g$(D).dll")
	mfile.WriteLine("	if exist $(GFORT_OUTDIR)\fmpich2g$(D).dll.manifest mt.exe -manifest $(GFORT_OUTDIR)\fmpich2g$(D).dll.manifest -outputresource:$(GFORT_OUTDIR)\fmpich2g$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("gfort: $(GFORT_OUTDIR) $(GFORT_OUTDIR)\fmpich2g$(D).dll")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("# We don't build sfort for non-x86 platforms")
	mfile.WriteLine("sfort: $(SFORT_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("!ELSE")
	outdir = "SFORT_OUTDIR"
	extra_flags = "$(sfcflags)"
	fort_prefix = "s"
	CreateRules f.GetFolder("src\binding\f77"), trimlength
	CreateObjs "sfort", f.GetFolder("src\binding\f77"), trimlength, true, false
	' Add the extra character* versions of the MPI functions here
	mfile.WriteLine(" \" & vbCrLf & "	$(SFORT_OUTDIR)\accumulatefs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\allgatherfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\allgathervfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\allreducefs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\alltoallfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\alltoallvfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\alltoallwfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\bcastfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\bsendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\bsend_initfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\bufattachfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\bufdetachfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\exscanfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\gatherfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\gathervfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\getfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\ibsendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\irecvfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\irsendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\isendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\issendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\putfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\recvfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\recv_initfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\redscatfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\reducefs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\rsendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\rsend_initfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\scanfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\scatterfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\scattervfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\sendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\sendrecvfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\send_initfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\sndrcvrplfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\ssendfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\ssend_initfs.obj \")
	mfile.WriteLine("	$(SFORT_OUTDIR)\win_createfs.obj")
	mfile.WriteLine
	mfile.WriteLine("$(SFORT_OUTDIR)\fmpich2s$(D).dll: $(sfort_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(sfort_objs) $(MPI_OUTDIR)\mpi$(D).lib $(common_libs) /DEF:..\src\binding\f77\mpich2fs.def -out:$(SFORT_OUTDIR)\fmpich2s$(D).dll")
	mfile.WriteLine("	if exist $(SFORT_OUTDIR)\fmpich2s$(D).dll.manifest mt.exe -manifest $(SFORT_OUTDIR)\fmpich2s$(D).dll.manifest -outputresource:$(SFORT_OUTDIR)\fmpich2s$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("sfort: $(SFORT_OUTDIR) $(SFORT_OUTDIR)\fmpich2s$(D).dll")
	mfile.WriteLine
	mfile.WriteLine("!ENDIF")
	extra_flags = ""
	fort_prefix = ""

	mfile.WriteLine
	mfile.WriteLine("# MPI multi-channel wrapper")
	mfile.WriteLine
	outdir = "MPI_OUTDIR"
	CreateRules f.GetFolder("src\util\multichannel"), trimlength
	CreateObjs "mpi", f.GetFolder("src\util\multichannel"), trimlength, true, true
	mfile.WriteLine("$(MPI_OUTDIR)\mpich2mpi$(D).dll: $(mpi_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(mpi_objs) $(common_libs) /DEF:..\mpi.def -out:$(MPI_OUTDIR)\mpich2mpi$(D).dll /IMPLIB:$(MPI_OUTDIR)\mpi$(D).lib")
	mfile.WriteLine("	if exist $(MPI_OUTDIR)\mpich2mpi$(D).dll.manifest mt.exe -manifest $(MPI_OUTDIR)\mpich2mpi$(D).dll.manifest -outputresource:$(MPI_OUTDIR)\mpich2mpi$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("mpi: $(MPI_OUTDIR) $(MPI_OUTDIR)\mpich2mpi$(D).dll")

	mfile.WriteLine
	mfile.WriteLine("# C++")
	mfile.WriteLine
	outdir = "CXX_OUTDIR"
	cxxflags = "cxxflags"
	CreateRules f.GetFolder("src\binding\cxx"), trimlength
	CreateObjs "cxx", f.GetFolder("src\binding\cxx"), trimlength, true, true
	mfile.WriteLine("$(CXX_OUTDIR)\cxx$(D).lib: $(cxx_objs)")
	mfile.WriteLine("	$(implib) $(liblflags) $(cxx_objs) -out:$(CXX_OUTDIR)\cxx$(D).lib")
	mfile.WriteLine
	mfile.WriteLine("cxx: $(CXX_OUTDIR) $(CXX_OUTDIR)\cxx$(D).lib")

	mfile.WriteLine
	mfile.WriteLine("# MPE")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpe2\src\logging\src}.c{$(MPE_OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) $(mpe_cflags) /DMPE_EXPORTS /Fo""$(MPE_OUTDIR)\\"" /Fd""$(MPE_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpe2\src\callstack\src}.c{$(MPE_OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) $(mpe_cflags) /DMPE_EXPORTS /Fo""$(MPE_OUTDIR)\\"" /Fd""$(MPE_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("$(MPE_OUTDIR)\mpiu_thread.obj: ..\src\util\thread\mpiu_thread.c")
	mfile.WriteLine("    $(cc) $(cflags) $(mpe_cflags) /DMPE_EXPORTS /Fo""$(MPE_OUTDIR)\\"" /Fd""$(MPE_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("mpe_objs = \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_block.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_buffer.obj \")
	mfile.WriteLine("   $(MPE_OUTDIR)\clog_commset.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_merger.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_preamble.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_print.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_record.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_sync.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_timer.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_util.obj \")
	mfile.WriteLine("   $(MPE_OUTDIR)\clog_uuid.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_cache.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\clog_joiner.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\mpe_logf.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\mpiu_thread.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\fancyprint.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\iterator.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\mpe_log.obj")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpe2\src\logging\src}.c{$(FMPE_OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) $(mpe_cflags) /DMPE_EXPORTS /DF77_NAME_UPPER /Fo""$(FMPE_OUTDIR)\\"" /Fd""$(FMPE_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpe2\src\callstack\src}.c{$(MPE_OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) $(mpe_cflags) /DMPE_EXPORTS /Fo""$(MPE_OUTDIR)\\"" /Fd""$(MPE_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("$(FMPE_OUTDIR)\mpiu_thread.obj: ..\src\util\thread\mpiu_thread.c")
	mfile.WriteLine("    $(cc) $(cflags) $(mpe_cflags) /DMPE_EXPORTS /DF77_NAME_UPPER /Fo""$(FMPE_OUTDIR)\\"" /Fd""$(FMPE_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("fmpe_objs = \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_block.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_buffer.obj \")
	mfile.WriteLine("   $(FMPE_OUTDIR)\clog_commset.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_merger.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_preamble.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_print.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_record.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_sync.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_timer.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_util.obj \")
	mfile.WriteLine("   $(FMPE_OUTDIR)\clog_uuid.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_cache.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\clog_joiner.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\mpe_logf.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\mpiu_thread.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\fancyprint.obj \")
	mfile.WriteLine("	$(MPE_OUTDIR)\iterator.obj \")
	mfile.WriteLine("	$(FMPE_OUTDIR)\mpe_log.obj")
	mfile.WriteLine
	mfile.WriteLine("$(MPE_OUTDIR)\mpe$(D).dll: $(mpe_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(mpe_objs) $(MPI_OUTDIR)\mpi$(D).lib $(common_libs) /DEF:..\src\mpe2\mpe.def -out:$(MPE_OUTDIR)\mpe$(D).dll /IMPLIB:$(MPE_OUTDIR)\mpe$(D).lib")
	mfile.WriteLine("	if exist $(MPE_OUTDIR)\mpe$(D).dll.manifest mt.exe -manifest $(MPE_OUTDIR)\mpe$(D).dll.manifest -outputresource:$(MPE_OUTDIR)\mpe$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("$(FMPE_OUTDIR)\fmpe$(D).dll: $(fmpe_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(fmpe_objs) $(MPI_OUTDIR)\mpi$(D).lib $(common_libs) /DEF:..\src\mpe2\fmpe.def -out:$(FMPE_OUTDIR)\fmpe$(D).dll /IMPLIB:$(FMPE_OUTDIR)\fmpe$(D).lib")
	mfile.WriteLine("	if exist $(FMPE_OUTDIR)\fmpe$(D).dll.manifest mt.exe -manifest $(FMPE_OUTDIR)\fmpe$(D).dll.manifest -outputresource:$(FMPE_OUTDIR)\fmpe$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("mpe: $(MPE_OUTDIR) $(FMPE_OUTDIR) $(MPE_OUTDIR)\mpe$(D).dll $(FMPE_OUTDIR)\fmpe$(D).dll ")

	mfile.WriteLine
	mfile.WriteLine("# MPE wrapper")
	mfile.WriteLine
	mfile.WriteLine("{..\src\mpe2\src\wrappers\src}.c{$(MPE_WRAP_OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /DUSE_STDARG  /I..\src\mpe2\include /I..\src\mpe2\src\logging\include /I..\src\mpe2\src\wrappers\include /Fo""$(MPE_WRAP_OUTDIR)\\"" /Fd""$(MPE_WRAP_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("mpe_wrap_objs = \")
	mfile.WriteLine("	$(MPE_WRAP_OUTDIR)\log_mpi_util.obj \")
	mfile.WriteLine("	$(MPE_WRAP_OUTDIR)\log_mpi_core.obj")
	mfile.WriteLine
	mfile.WriteLine("$(MPE_WRAP_OUTDIR)\mpich2mpe$(D).dll: $(mpe_wrap_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(mpe_wrap_objs) $(MPI_OUTDIR)\mpi$(D).lib $(MPE_OUTDIR)\mpe$(D).lib $(common_libs) /DEF:..\src\mpe2\src\wrappers\mpewrap.def -out:$(MPE_WRAP_OUTDIR)\mpich2mpe$(D).dll /IMPLIB:$(MPE_WRAP_OUTDIR)\mpich2mpe$(D).lib")
	mfile.WriteLine("	if exist $(MPE_WRAP_OUTDIR)\mpich2mpe$(D).dll.manifest mt.exe -manifest $(MPE_WRAP_OUTDIR)\mpich2mpe$(D).dll.manifest -outputresource:$(MPE_WRAP_OUTDIR)\mpich2mpe$(D).dll;2")
	mfile.WriteLine
	mfile.WriteLine("mpe_wrap: $(MPE_WRAP_OUTDIR) $(MPE_WRAP_OUTDIR)\mpich2mpe$(D).dll")

	mfile.WriteLine
	mfile.WriteLine("# RLOG")
	mfile.WriteLine
	mfile.WriteLine("{..\src\util\logging\rlog}.c{$(RLOG_OUTDIR)}.obj:")
	mfile.WriteLine("    $(cc) $(cflags) /Fo""$(RLOG_OUTDIR)\\"" /Fd""$(RLOG_OUTDIR)\\"" $**")
	mfile.WriteLine
	mfile.WriteLine("rlog_objs = \")
	mfile.WriteLine("	$(RLOG_OUTDIR)\rlog.obj \")
	mfile.WriteLine("	$(RLOG_OUTDIR)\rlogutil.obj \")
	mfile.WriteLine("	$(RLOG_OUTDIR)\irlogutil.obj")
	mfile.WriteLine
	mfile.WriteLine("$(RLOG_OUTDIR)\rlog$(D).lib: $(rlog_objs)")
	mfile.WriteLine("	$(implib) $(liblflags) $(rlog_objs) -out:$(RLOG_OUTDIR)\rlog$(D).lib")
	mfile.WriteLine
	mfile.WriteLine("rlog: $(RLOG_OUTDIR) $(RLOG_OUTDIR)\rlog$(D).lib")
	mfile.WriteLine
	mfile.WriteLine("irlog_objs = \")
	mfile.WriteLine("	$(RLOG_OUTDIR)\irlog2rlog.obj")
	mfile.WriteLine
	mfile.WriteLine("$(RLOG_OUTDIR)\irlog2rlog.exe: $(irlog_objs) $(rlog_objs) $(mpich2_objs)")
	mfile.WriteLine("	$(link) $(conlflags) $(irlog_objs) $(rlog_objs) $(mpich2_objs) $(ch3sock_objs) $(common_libs) -out:""$(RLOG_OUTDIR)\irlog2rlog.exe"" $(mpich2_libs)")
	mfile.WriteLine("	if exist $(RLOG_OUTDIR)\irlog2rlog.exe.manifest mt.exe -manifest $(RLOG_OUTDIR)\irlog2rlog.exe.manifest -outputresource:$(RLOG_OUTDIR)\irlog2rlog.exe;1")
	mfile.WriteLine
	mfile.WriteLine("# create special rules for the TraceInput.dll source files since they need to include Java paths")
	mfile.WriteLine("$(RLOG_OUTDIR)\logformat_trace_InputLog.obj: ..\src\util\logging\rlog\logformat_trace_InputLog.c")
	mfile.WriteLine("    $(cc) $(cflags) /I..\src\mpe2\src\slog2sdk\src\logformat\trace -DHAVE_STRNICMP /I$(JAVA_HOME)\include /I$(JAVA_HOME)\include\win32 /Fo""$(RLOG_OUTDIR)\\"" /Fd""$(RLOG_OUTDIR)\\"" ..\src\util\logging\rlog\logformat_trace_InputLog.c")
	mfile.WriteLine
	mfile.WriteLine("$(RLOG_OUTDIR)\trace_input.obj: ..\src\util\logging\rlog\trace_input.c")
	mfile.WriteLine("    $(cc) $(cflags) /DHAVE_STRNICMP /I..\src\mpe2\src\slog2sdk\src\logformat\trace /I$(JAVA_HOME)\include /I$(JAVA_HOME)\include\win32 /Fo""$(RLOG_OUTDIR)\\"" /Fd""$(RLOG_OUTDIR)\\"" ..\src\util\logging\rlog\trace_input.c")
	mfile.WriteLine
	mfile.WriteLine("trace_input_objs = \")
	mfile.WriteLine("	$(RLOG_OUTDIR)\logformat_trace_InputLog.obj \")
	mfile.WriteLine("	$(RLOG_OUTDIR)\trace_input.obj")
	mfile.WriteLine
	mfile.WriteLine("$(RLOG_OUTDIR)\TraceInput.dll: $(trace_input_objs) $(rlog_objs) $(mpich2_objs)")
	mfile.WriteLine("	$(link) $(dlllflags) $(trace_input_objs) $(rlog_objs) $(mpich2_objs) $(ch3sock_objs) $(common_libs) -out:$(RLOG_OUTDIR)\TraceInput.dll /IMPLIB:$(RLOG_OUTDIR)\TraceInput.lib $(mpich2_libs)")
	mfile.WriteLine("	if exist $(RLOG_OUTDIR)\TraceInput.dll.manifest mt.exe -manifest $(RLOG_OUTDIR)\TraceInput.dll.manifest -outputresource:$(RLOG_OUTDIR)\TraceInput.dll;2")
	mfile.WriteLine
	mfile.WriteLine("TraceInput: $(RLOG_OUTDIR) $(RLOG_OUTDIR)\TraceInput.dll")
	mfile.WriteLine
	mfile.WriteLine("irlog2rlog: $(RLOG_OUTDIR) $(RLOG_OUTDIR)\irlog2rlog.exe")
	mfile.WriteLine

	mfile.WriteLine
	mfile.WriteLine("# mpiexec")
	mfile.WriteLine
	mfile.WriteLine("$(OUTDIR)\mpiexec.obj: ..\src\pm\smpd\mpiexec.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\mpiexec.c")
	mfile.WriteLine("$(OUTDIR)\mpiexec_rsh.obj: ..\src\pm\smpd\mpiexec_rsh.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\mpiexec_rsh.c")
	mfile.WriteLine("$(OUTDIR)\mp_parse_command_line.obj: ..\src\pm\smpd\mp_parse_command_line.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\mp_parse_command_line.c")
	mfile.WriteLine("$(OUTDIR)\mp_parse_oldconfig.obj: ..\src\pm\smpd\mp_parse_oldconfig.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\mp_parse_oldconfig.c")
	mfile.WriteLine
	mfile.WriteLine("mpiexec_objs = \")
	mfile.WriteLine("	$(OUTDIR)\mpiexec.obj \")
	mfile.WriteLine("	$(OUTDIR)\mpiexec_rsh.obj \")
	mfile.WriteLine("	$(OUTDIR)\mp_parse_command_line.obj \")
	mfile.WriteLine("	$(OUTDIR)\mp_parse_oldconfig.obj")
	mfile.WriteLine
	mfile.WriteLine("$(BIN_OUTDIR)\mpiexec.exe: $(mpiexec_objs) $(mpich2_objs)")
	mfile.WriteLine("	$(link) $(conlflags) $(mpiexec_objs) $(mpich2_objs) $(ch3sock_objs) $(common_libs) -out:$(BIN_OUTDIR)\mpiexec.exe $(mpich2_libs)")
	mfile.WriteLine("	if exist $(BIN_OUTDIR)\mpiexec.exe.manifest mt.exe -manifest $(BIN_OUTDIR)\mpiexec.exe.manifest -outputresource:$(BIN_OUTDIR)\mpiexec.exe;1")
	mfile.WriteLine
	mfile.WriteLine("mpiexec: $(BIN_OUTDIR) $(BIN_OUTDIR)\mpiexec.exe")

	mfile.WriteLine
	mfile.WriteLine("# smpd")
	mfile.WriteLine
	mfile.WriteLine("$(OUTDIR)\smpd.obj: ..\src\pm\smpd\smpd.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\smpd.c")
	mfile.WriteLine("$(OUTDIR)\smpd_cmd_args.obj: ..\src\pm\smpd\smpd_cmd_args.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\smpd_cmd_args.c")
	mfile.WriteLine("$(OUTDIR)\smpd_service.obj: ..\src\pm\smpd\smpd_service.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\smpd_service.c")
	mfile.WriteLine("$(OUTDIR)\smpd_watchprocs.obj: ..\src\pm\smpd\smpd_watchprocs.c")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(OUTDIR)\\"" /Fd""$(OUTDIR)\\"" ..\src\pm\smpd\smpd_watchprocs.c")
	mfile.WriteLine
	mfile.WriteLine("smpd_objs = \")
	mfile.WriteLine("	$(OUTDIR)\smpd.obj \")
	mfile.WriteLine("	$(OUTDIR)\smpd_cmd_args.obj \")
	mfile.WriteLine("	$(OUTDIR)\smpd_service.obj \")
	mfile.WriteLine("	$(OUTDIR)\smpd_watchprocs.obj")
	mfile.WriteLine
	mfile.WriteLine("$(BIN_OUTDIR)\smpd.exe: $(smpd_objs) $(mpich2_objs)")
	mfile.WriteLine("	$(link) $(conlflags) $(smpd_objs) $(mpich2_objs) $(ch3sock_objs) $(common_libs) -out:$(BIN_OUTDIR)\smpd.exe $(mpich2_libs)")
	mfile.WriteLine("	if exist $(BIN_OUTDIR)\smpd.exe.manifest mt.exe -manifest $(BIN_OUTDIR)\smpd.exe.manifest -outputresource:$(BIN_OUTDIR)\smpd.exe;1")
	mfile.WriteLine
	mfile.WriteLine("smpd: $(BIN_OUTDIR) $(BIN_OUTDIR)\smpd.exe")

	mfile.WriteLine
	mfile.WriteLine("# impgen")
	mfile.WriteLine
	mfile.WriteLine("$(GCC_OUTDIR)\gccimpgen.obj: ..\maint\gccimpgen.cpp")
	mfile.WriteLine("	$(cc) $(cflags) /Fo""$(GCC_OUTDIR)\\"" /Fd""$(GCC_OUTDIR)\\"" ..\maint\gccimpgen.cpp")
	mfile.WriteLine
	mfile.WriteLine("$(GCC_OUTDIR)\impgen.exe: $(GCC_OUTDIR)\gccimpgen.obj")
	mfile.WriteLine("	$(link) $(conlflags) $(GCC_OUTDIR)\gccimpgen.obj $(common_libs) -out:$(GCC_OUTDIR)\impgen.exe")
	mfile.WriteLine("	if exist $(GCC_OUTDIR)\impgen.exe.manifest mt.exe -manifest $(GCC_OUTDIR)\impgen.exe.manifest -outputresource:$(GCC_OUTDIR)\impgen.exe;1")
	mfile.WriteLine
	mfile.WriteLine("impgen: $(GCC_OUTDIR) $(GCC_OUTDIR)\impgen.exe")
	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CPU)"" != ""x86""")
	mfile.WriteLine("# Add 64bit gcc stuff here")
	mfile.WriteLine("gcc_libs: $(GCC_OUTDIR)")
	mfile.WriteLine
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("gcc_libs: impgen")
	mfile.WriteLine("	IF EXIST ""$(GCC_OUTDIR)\mpich2gcc$(D).def"" del $(GCC_OUTDIR)\mpich2gcc$(D).def")
	mfile.WriteLine("	$(GCC_OUTDIR)\impgen.exe $(SOCK_OUTDIR)\mpich2$(D).dll > $(GCC_OUTDIR)\mpich2gcc$(D).def")
	mfile.WriteLine("	dlltool --dllname mpich2$(D).dll --def $(GCC_OUTDIR)\mpich2gcc$(D).def --output-lib $(GCC_OUTDIR)\libmpich2$(D).a")
	mfile.WriteLine("	del $(GCC_OUTDIR)\mpich2gcc$(D).def")
	mfile.WriteLine("	IF EXIST ""$(GCC_OUTDIR)\mpich2mpi$(D).def"" del $(GCC_OUTDIR)\mpich2mpi$(D).def")
	mfile.WriteLine("	$(GCC_OUTDIR)\impgen.exe $(MPI_OUTDIR)\mpich2mpi$(D).dll > $(GCC_OUTDIR)\mpich2mpi$(D).def")
	mfile.WriteLine("	dlltool --dllname mpich2mpi$(D).dll --def $(GCC_OUTDIR)\mpich2mpi$(D).def --output-lib $(GCC_OUTDIR)\libmpi$(D).a")
	mfile.WriteLine("	del $(GCC_OUTDIR)\mpich2mpi$(D).def")
	mfile.WriteLine("	IF EXIST ""$(GCC_OUTDIR)\fmpich2gcc$(D).def"" del $(GCC_OUTDIR)\fmpich2gcc$(D).def")
	mfile.WriteLine("	$(GCC_OUTDIR)\impgen.exe $(GFORT_OUTDIR)\fmpich2g$(D).dll > $(GCC_OUTDIR)\fmpich2gcc$(D).def")
	mfile.WriteLine("	dlltool --dllname fmpich2g$(D).dll --def $(GCC_OUTDIR)\fmpich2gcc$(D).def --output-lib $(GCC_OUTDIR)\libfmpich2g$(D).a")
	mfile.WriteLine("	del $(GCC_OUTDIR)\fmpich2gcc$(D).def")
	mfile.WriteLine
	mfile.WriteLine("!ENDIF")

	mfile.WriteLine
	mfile.WriteLine("!IF ""$(CHANNEL)"" == ""sock""")
	mfile.WriteLine("!IFDEF RLOG")
	mfile.WriteLine("all: $(OUTDIR) rlog ch3$(CHANNEL)")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("all: $(OUTDIR) $(BIN_OUTDIR) ch3$(CHANNEL) smpd mpiexec mpi mpe mpe_wrap")
	mfile.WriteLine("!ENDIF")
	mfile.WriteLine("!ELSE")
	mfile.WriteLine("all: $(OUTDIR) ch3$(CHANNEL)")
	mfile.WriteLine("!ENDIF")

	mfile.Close()
End Function

printMsg "STATUS", "Creating makefile & build scripts for MPICH2..."
GenBuild()

Function ParseDirs(filename)
	Dim line, fullline
	'cEcho filename
	Set fin = f.OpenTextFile(filename)
	fullline = ""
	while not fin.AtEndOfStream
		line = MyTrim(fin.ReadLine)
		If Left(line, 1) <> "#" Then
			If Right(line, 1) = "\" Then
				If fullline = "" Then
					fullline = Left(line, len(line)-1)
				Else
					fullline = fullline & " " & Left(line, len(line)-1)
				End If
			Else
				If fullline = "" Then
					fullline = line
				Else
					fullline = fullline & " " & line
				End If
				'OutputLine Right(file.ParentFolder, Len(file.ParentFolder) - trimpath), fullline
				If Left(fullline, 10) = "SUBDIRS = " Then
					line = Right(fullline, Len(fullline) - 10)
					'cEcho line
					fin.Close
					ParseDirs = Split(line)
					Exit Function
				End If
				fullline = ""
			End If
		End If
	wend
	fin.Close
	ParseDirs = Array() ' return an empty array
End Function

Function ParseSrcFiles(filename)
	Dim line, fullline, src_line
	'cEcho filename
	Set fin = f.OpenTextFile(filename)
	fullline = ""
	src_line = ""
	while not fin.AtEndOfStream
		line = MyTrim(fin.ReadLine)
		If Left(line, 1) <> "#" Then
			If Right(line, 1) = "\" Then
				If fullline = "" Then
					fullline = Left(line, len(line)-1)
				Else
					fullline = fullline & " " & Left(line, len(line)-1)
				End If
			Else
				If fullline = "" Then
					fullline = line
				Else
					fullline = fullline & " " & line
				End If
				'OutputLine Right(file.ParentFolder, Len(file.ParentFolder) - trimpath), fullline
				If Left(fullline, 14) = "mpi_sources = " Then
					src_line = src_line & " " & Right(fullline, Len(fullline) - 14)
					'cEcho src_line
				End If
				If Left(fullline, 14) = "win_sources = " Then
					src_line = src_line & " " & Right(fullline, Len(fullline) - 14)
					'cEcho src_line
				End If
				If Left(fullline, 28) = "lib${MPILIBNAME}_a_SOURCES =" Then
					src_line = src_line & " " & Right(fullline, Len(fullline) - 28)
					'cEcho src_line
				End If
				fullline = ""
			End If
		End If
	wend
	fin.Close
	ParseSrcFiles = Split(src_line)
End Function

Function TraverseSubdir(byref dirname)
	TraverseSubdir = true
	If dirname = "." Then
		TraverseSubdir = false
	End If
	If dirname = "@device_name@" Then
		dirname = "ch3"
	ElseIf dirname = "@channel_name@" Then
		dirname = buildfiles_channel
	ElseIf dirname = "@pm_name@" Then
		dirname = "smpd"
	ElseIf dirname = "@pmi_name@" Then
		dirname = "smpd"
	Elseif Left(dirname, 1) = "@" Then
		TraverseSubdir = false
	End If
	If Left(dirname, 1) = "$" Then
		TraverseSubdir = false
	End If
	If dirname = "" Then
		TraverseSubdir = false
	End If
	If dirname = "binding" Then
		TraverseSubdir = false
	End If
End Function

Function GenBuildFiles(dirname)
	Dim dirs
	Dim dirs_fout, srcs_fout, mfile, first
	first = true
	dirs = ParseDirs(dirname & "\Makefile.sm")
	For Each subdir in dirs
		If TraverseSubdir(subdir) Then
			If remove_buildfiles Then
				If f.FileExists(dirname & "\DIRS") Then
					printMsg "VERBOSE", "del " & dirname & "\DIRS"
					f.DeleteFile(dirname & "\DIRS")
				End If
			Else
				If first Then
					Set dirs_fout = f.CreateTextFile(dirname & "\DIRS", true)
					dirs_fout.Write("DIRS = ")
					first = false
				End If
				dirs_fout.Write("\" & vbCrLf & " " & subdir)
			End If
			'cEcho "subdir: '" & dirname & "\" & subdir & "'"
			GenBuildFiles(dirname & "\" & subdir)
		End If
	Next
	If Not first Then
		dirs_fout.WriteLine
		dirs_fout.Close
		printMsg "VERBOSE", dirname & "\DIRS"
	End If
	If remove_buildfiles Then
		If f.FileExists(dirname & "\SOURCES") Then
			printMsg "VERBOSE", "del " & dirname & "\SOURCES"
			f.DeleteFile(dirname & "\SOURCES")
		End If
		If f.FileExists(dirname & "\makefile") Then
			printMsg "VERBOSE", "del " & dirname & "\makefile"
			f.DeleteFile(dirname & "\makefile")
		End If
	Else
		first = true
		For Each src_filename in ParseSrcFiles(dirname & "\Makefile.sm")
			If CompileFile(src_filename) Then
				'cEcho dirname & "\Makefile.sm" & ": " & src_filename
				If first Then
					Set srcs_fout = f.CreateTextFile(dirname & "\SOURCES")
					srcs_fout.Write("SOURCES = ")
					first = false
				End If
				srcs_fout.Write("\" & vbCrLf & " " & src_filename)
			End If
		Next
		If Not first Then
			srcs_fout.WriteLine
			srcs_fout.WriteLine
			Dim ex, dotdots, includes
			Set ex = New RegExp
			ex.Global = True
			ex.Pattern = "\w+\\"
			dotdots = ex.Replace(dirname & "\", "..\")
			srcs_fout.WriteLine("TARGETPATH=." & dotdots & "obj$(BUILD_ALT_DIR)")
			srcs_fout.WriteLine
			srcs_fout.WriteLine("TARGETTYPE=LIBRARY")'DYNLINK")
			srcs_fout.WriteLine
			srcs_fout.WriteLine("TARGETNAME=mpich2")
			srcs_fout.WriteLine
			srcs_fout.WriteLine("DLLDEF=" & dotdots & "mpich2.def")
			srcs_fout.WriteLine
			includes = dotdots & "src\include;" & _
				dotdots & "src\include\win32;" & _
				dotdots & "src\mpid\ch3\include;" & _
				dotdots & "src\mpid\ch3\channels\" & buildfiles_channel & "\include;" & _
				dotdots & "src\mpid\ch3\channels\" & buildfiles_channel & "\src;" & _
				dotdots & "src\mpid\common\sock;" & _
				dotdots & "src\mpid\common\sock\iocp;" & _
				dotdots & "src\mpi\romio\mpi-io;" & _
				dotdots & "src\mpi\romio\adio\include;" & _
				dotdots & "src\mpid\common\datatype;" & _
				dotdots & "src\mpid\common\locks;" & _
				dotdots & "src\mpi\datatype;" & _
				dotdots & "src\pm\smpd;" & _
				dotdots & "src\mpi\spawn;" & _
				dotdots & "src\binding\f77"
			srcs_fout.WriteLine("INCLUDES=$(INCLUDES);" & includes)
			srcs_fout.WriteLine
			srcs_fout.WriteLine("C_DEFINES=$(C_DEFINES) -DHAVE_WINDOWS_H -DUSE_WINCONF_H -DMPIO_BUILD_PROFILING -DROMIO_INSIDE_MPICH2 -DHAVE_FORTRAN_BINDING -DMPICH_SKIP_MPICXX")
			srcs_fout.WriteLine
			srcs_fout.WriteLine("MSC_WARNING_LEVEL= /W4")
			srcs_fout.WriteLine
			srcs_fout.Close
			printMsg "VERBOSE", dirname & "\SOURCES"
			Set mfile = f.CreateTextFile(dirname & "\makefile")
			mfile.WriteLine("#")
			mfile.WriteLine("# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source file to this component.")
			mfile.WriteLine("#")
			mfile.WriteLine
			mfile.WriteLine("!INCLUDE $(NTMAKEENV)\makefile.def")
			mfile.Close
			printMsg "VERBOSE", dirname & "\makefile"
		End If
	End If
End Function

' Only build these files if specified: "winconfigure --genbuildfiles"
'cEcho "Creating build tool files"
'GenBuildFiles(".")

Function ReplaceBetweenTags(str, tag1, find_str, tag2, replace_str)
	Dim index, left_str, right_str, start_index, end_index
	index = InStr(str, find_str)
	If index = 0 Then
		'MsgBox find_str & " not found in: " & str
		ReplaceBetweenTags = str
		Exit Function
	End If
	left_str = Left(str, index)
	right_str = Right(str, Len(str) - index)
	start_index = InStrRev(left_str, tag1)
	If start_index = 0 Then
		'MsgBox tag1 & " not found in: " & left_str
		ReplaceBetweenTags = str
		Exit Function
	End If
	end_index = InStr(right_str, tag2)
	If end_index = 0 Then
		'MsgBox tag2 & " not found in: " & right_str
		ReplaceBetweenTags = str
		Exit Function
	End If
	end_index = end_index + index
	ReplaceBetweenTags = Left(str, start_index-1) & replace_str & Right(str, Len(str) - end_index - Len(tag2) + 1)
End Function

If bRemoveFortran Then
	'Dim regEx, Match, Matches
	Set regEx = New RegExp
	regEx.IgnoreCase = False
	regEx.Global = True

	' mpich2.def
	'  remove:
	'	MPIPRIV
	'	MPIR_Keyval_set_fortran
	'	MPIR_Keyval_set_fortran90
	'	MPIR_Grequest_set_lang_f77
	Set fin = f.OpenTextFile("mpich2.def")
	contents = fin.ReadAll()
	fin.Close()
	regEx.Pattern = "(.*MPIPRIV.*)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPIR_Keyval_set_fortran)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPIR_Grequest_set_lang_f77)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPIR_F_MPI_BOTTOM)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPI_F_STATUS_IGNORE)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPI_F_STATUSES_IGNORE)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPI_F_ERRCODES_IGNORE)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*MPI_F_ARGVS_NULL)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*[P]?MPI_Status_c2f)"
	contents = regEx.Replace(contents, ";$1")
	regEx.Pattern = "(.*[P]?MPI_Status_f2c)"
	contents = regEx.Replace(contents, ";$1")
	'cEcho "Creating mpich2.def"
	gEcho "Creating mpich2.def"
	Set fout = f.CreateTextFile( "mpich2.def" )
	fout.Write(contents)
	fout.Close()

	' mpich2.sln
	'  remove:
	'	Project(..."mpich2f"...EndProject
	'   Project(..."mpich2ff"...EndProject
	'   fortDebug = fortDebug
	'   fortRelease = fortRelease
	'   gfortDebug = gfortDebug
	'   gfortRelease = gfortRelease
	'   sfortDebug = sfortDebug
	'   sfortRelease = sfortRelease
	'   *.fortDebug.*
	'   *.fortRelease.*
	'   *.gfortDebug.*
	'   *.gfortRelease.*
	'   *.sfortDebug.*
	'   *.sfortRelease.*
	'   *= fortDebug|Win32
	'   *= fortRelease|Win32
	'   *= gfortDebug|Win32
	'   *= gfortRelease|Win32
	'   *= sfortDebug|Win32
	'   *= sfortRelease|Win32
	if bVS2005 then
	    Set fin = f.OpenTextFile( "mpich2.vs05.sln" )
	else
	    Set fin = f.OpenTextFile( "mpich2.sln" )
	end if
	contents = fin.ReadAll()
	fin.Close()
	regEx.Pattern = "Project\(.*""mpich2ff?"".*\s*.*\s*.*\s*.*EndProject[\r\n]*"
	contents = regEx.Replace(contents, "")
	regEx.Pattern = ".*[gs]?fortDebug = [gs]?fortDebug.*[\r\n]*"
	contents = regEx.Replace(contents, "")
	regEx.Pattern = ".*[gs]?fortRelease = [gs]?fortRelease.*[\r\n]*"
	contents = regEx.Replace(contents, "")
	regEx.Pattern = ".*\.[gs]*fortDebug\..*[\r\n]*"
	contents = regEx.Replace(contents, "")
	regEx.Pattern = ".*\.[gs]*fortRelease\..*[\r\n]*"
	contents = regEx.Replace(contents, "")
	regEx.Pattern = ".*= [gs]?fortDebug\|Win32[\r\n]*"
	contents = regEx.Replace(contents, "")
	regEx.Pattern = ".*= [gs]?fortRelease\|Win32[\r\n]*"
	contents = regEx.Replace(contents, "")
	if bVS2005 then
		'cEcho "Creating mpich2.vs05.sln"
		gEcho "Creating mpich2.vs05.sln"
	    Set fout = f.CreateTextFile( "mpich2.vs05.sln" )
	else
		'cEcho "Creating mpich2.sln"
		gEcho "Creating mpich2.sln"
	    Set fout = f.CreateTextFile( "mpich2.sln" )
	end if
	fout.Write(contents)
	fout.Close()
	
	' mpich2.vcproj
	'  remove:
	'   ,HAVE_FORTRAN_BINDING
	'   mpich2ffd.lib
	'   mpich2ff.lib
	if bVS2005 then
	    Set fin = f.OpenTextFile( "mpich2.vs05.vcproj" )
	else
	    Set fin = f.OpenTextFile( "mpich2.vcproj" )
	end if
	contents = fin.ReadAll()
	fin.Close()
	contents = Replace(contents, ",HAVE_FORTRAN_BINDING", "")
	contents = Replace(contents, ";HAVE_FORTRAN_BINDING", "")
	contents = Replace(contents, "mpich2ffd.lib", "")
	contents = Replace(contents, "mpich2ff.lib", "")
	'regEx.Pattern = ".*<File.*\s*.*c2f\.c\s*.*</File>.*[\r\n]*"
	'contents = regEx.Replace(contents, "")
	'regEx.Pattern = ".*<File.*\s*.*f2c\.c\s*.*</File>.*[\r\n]*"
	'contents = regEx.Replace(contents, "")
	'regEx.Pattern = ".*<File.*\s*.*setbot\.c.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*</File>.*[\r\n]+"
	'contents = regEx.Replace(contents, "")
	contents = ReplaceBetweenTags(contents, "<File", "statusc2f.c", "</File>", "")
	contents = ReplaceBetweenTags(contents, "<File", "statusf2c.c", "</File>", "")
	contents = ReplaceBetweenTags(contents, "<File", "setbot.c", "</File>", "")
	if bVS2005 then
		'cEcho "Creating mpich2.vs05.vcproj"
		gEcho "Creating mpich2.vs05.vcproj"
	    Set fout = f.CreateTextFile( "mpich2.vs05.vcproj" )
	else
		'cEcho "Creating mpich2.vcproj"
		gEcho "Creating mpich2.vcproj"
	    Set fout = f.CreateTextFile( "mpich2.vcproj" )
	end if
	fout.Write(contents)
	fout.Close()

	' mpich2s.vcproj
	'  remove:
	'   lib\mpich2ffd.lib
	'   lib\mpich2ff.lib
	if bVS2005 then
	    Set fin = f.OpenTextFile( "mpich2s.vs05.vcproj" )
	else
	    Set fin = f.OpenTextFile( "mpich2s.vcproj" )
	end if
	contents = fin.ReadAll()
	fin.Close()
	contents = Replace(contents, ",HAVE_FORTRAN_BINDING", "")
	contents = Replace(contents, ";HAVE_FORTRAN_BINDING", "")
	contents = Replace(contents, "lib\mpich2ffd.lib", "")
	contents = Replace(contents, "lib\mpich2ff.lib", "")
	'regEx.Pattern = ".*<File.*\s*.*c2f\.c\s*.*</File>.*[\r\n]*"
	'contents = regEx.Replace(contents, "")
	'regEx.Pattern = ".*<File.*\s*.*f2c\.c\s*.*</File>.*[\r\n]*"
	'contents = regEx.Replace(contents, "")
	'regEx.Pattern = ".*<File.*\s*.*setbot\.c.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*</File>.*[\r\n]+"
	'contents = regEx.Replace(contents, "")
	contents = ReplaceBetweenTags(contents, "<File", "statusc2f.c", "</File>", "")
	contents = ReplaceBetweenTags(contents, "<File", "statusf2c.c", "</File>", "")
	contents = ReplaceBetweenTags(contents, "<File", "setbot.c", "</File>", "")
	if bVS2005 then
		'cEcho "Creating mpich2s.vs05.vcproj"
		gEcho "Creating mpich2s.vs05.vcproj"
	    Set fout = f.CreateTextFile( "mpich2s.vs05.vcproj" )
	else
		'cEcho "Creating mpich2s.vcproj"
		gEcho "Creating mpich2s.vcproj"
	    Set fout = f.CreateTextFile( "mpich2s.vcproj" )
	end if
	fout.Write(contents)
	fout.Close()

	' maint\mpich2i.vdproj
	'  remove:
	'   lots of stuff
End If

Sub UpdateSMPDVersion
        GetMPICH2Versions mpich2VerStr, mpich2ABIVerStr
	'WScript.Echo "Version = " & version_str
	printMsg "VERBOSE", "Creating src\pm\smpd\smpd_version.h: " & version_str
	Set fout = f.CreateTextFile("src\pm\smpd\smpd_version.h", true)
	fout.WriteLine("#define SMPD_VERSION """ & mpich2VerStr & """")
	fout.Close()
End Sub

Call UpdateSMPDVersion()

'
' Report any errors
'
If unhandled_definitions <> "" Then
	printMsg "ERROR", "Unhandled definitions" & vbNewLine & unhandled_definitions
	printMsg "ERROR", "ERROR: " & unhandled_definitions_count & " definitions not handled"
	printMsg "ERROR", "(" & unhandled_definitions_instances & " instances of unhandled definitions)"
End If
If unhandled_ats <> "" Then
	printMsg "ERROR", "Unhandled @foo@'s:" & vbNewLine & unhandled_ats
	printMsg "ERROR", "ERROR: " & unhandled_ats_count & " @foo@'s not handled"
	printMsg "ERROR", "(" & unhandled_ats_instances & " instances of unhandled @foo@'s)"
End If
printMsg "STATUS", "Configuring MPICH2 completed"
printMsgFlush

</script>
</job>
</package>