C  INPUT FILE FOR AT. WTS ETC. IS LOGICAL 1
      INTEGER ELEM(50),SYM(103)
      REAL AW(103),UMO(103),UCU(103),UCO(103)
      DIMENSION SUB(50),PROP(50),PCT(50)
      INTEGER BL/' '/
C THIS PROGRAM CALCULATES THE MOLECULAR WT.,PERCENT COMPOSITION AND THE
C  MASS ABSORPTION COEFFICIENTS FOR MO,CU AND CO X-RADIATIONS
C  FOR COMPOUNDS CONTAINING UP TO 16 DIFFERENT ELEMENTS
C TO USE ENTER THE FORMULA CARDS IN 16(A2,F3.0) FORMAT. FORMULA STARTS
C  IN COLUMN  ONE.  ONE SYMBOL ELEMENTS ARE PUNCHED BLANK
C  THE NUMBER PRESENT IS THEN ENTERED IN THE NEXT THREE SPACES
C  TO SIGNAL END OF DATA PUNCH A 999 IN COLUMNS 3,4 AND 5
C AFTER LAST FORMULA CARD
C FORMULA CARD FOR THE COMPOUND CU2C18H21O3 FOLLOWS (THE ORDER IS ARBITR
C***********************************************************************
C 018CU002H 021O 003
C***********************************************************************
C  ATOMIC WEIGHTS.
      DATA SYM
     1             /'H ','HE','LI','BE','B ','C ','N ','O ','F ','NE',
     1             'NA','MG','AL','SI','P ','S ','CL','AR','K ','CA',
     1             'SC','TI','V ','CR','MN','FE','CO','NI','CU','ZN',
     1             'GA','GE','AS','SE','BR','KR','RB','SR','Y ','ZR',
     1             'NB','MO','TC','RU','RH','PD','AG','CD','IN','SN',
     1             'SB','TE','I ','XE','CS','BA','LA','CE','PR','ND',
     1             'PM','SM','EU','GD','TB','DY','HO','ER','TM','YB',
     1             'LU','HF','TA','W ','RE','OS','IR','PT','AU','HG',
     1             'TL','PB','BI','PO','AT','RN','FR','RA','AC','TH',
     1             'PA','U ','NP','PU','AM','CM','BK','CF','ES','FM',
     1             'MD','NO','LW'/
      DATA AW
     1    /1.00797, 4.00260,  6.93900,  9.01220, 10.81100, 12.01110,
     1   14.00670, 15.99940, 18.99840, 20.18300, 22.98981, 24.31200,
     1   26.98151, 28.08600, 30.97380, 32.06400, 35.45300, 39.94800,
     1   39.10201, 40.08000, 44.95599, 47.89999, 50.94200, 51.99600,
     1   54.93800, 55.84700, 58.93300, 58.71001, 63.53999, 65.37000,
     1   69.72000, 72.59000, 74.92200, 78.96001, 79.90900, 83.80000,
     1   85.47000, 87.62000, 88.90500, 91.22000, 92.90601, 95.94000,
     1   99.00000,101.07001,102.90500,106.39999,107.87000,112.39999,
     1  114.82001,118.69000,121.75000,127.60001,126.90401,131.30000,
     1  132.90500,137.34000,138.91000,140.12000,140.90700,144.24001,
     1  147.00000,150.35001,151.96001,157.25000,158.92400,162.50000,
     1  164.92999,167.25999,168.93401,173.03999,174.97000,178.49001,
     1  180.94800,183.85001,186.20000,190.20000,192.20000,195.09000,
     1  196.96700,200.59000,204.37000,207.19000,208.98000,210.00000,
     1  210.00000,222.00000,223.00000,226.00000,227.00000,232.03799,
     1  231.00000,238.03999,237.00000,242.00000,243.00000,247.00000,
     1  247.00000,251.00000,254.00000,253.00000,256.00000,254.00000,
     1  257.00000/
      UMO(001)=000.380                                                      0219
      UMO(002)=000.207                                                      0220
      UMO(003)=000.217                                                      0221
      UMO(004)=000.298                                                      0222
      UMO(005)=000.392                                                      0223
      UMO(006)=000.625                                                      0224
      UMO(007)=000.916                                                      0225
      UMO(008)=001.310                                                      0226
      UMO(009)=001.800                                                      0227
      UMO(010)=002.470                                                      0228
      UMO(011)=003.210                                                      0229
      UMO(012)=004.110                                                      0230
      UMO(013)=005.160                                                      0231
      UMO(014)=006.440                                                      0232
      UMO(015)=007.890                                                      0233
      UMO(016)=009.550                                                      0234
      UMO(017)=011.400                                                      0235
      UMO(018)=013.500                                                      0236
      UMO(019)=015.800                                                      0237
      UMO(020)=018.300                                                      0238
      UMO(021)=021.100                                                      0239
      UMO(022)=024.200                                                      0240
      UMO(023)=027.500                                                      0241
      UMO(024)=031.100                                                      0242
      UMO(025)=034.700                                                      0243
      UMO(026)=038.500                                                      0244
      UMO(027)=042.500                                                      0245
      UMO(028)=046.600                                                      0246
      UMO(029)=050.900                                                      0247
      UMO(030)=055.400                                                      0248
      UMO(031)=060.100                                                      0249
      UMO(032)=064.800                                                      0250
      UMO(033)=069.700                                                      0251
      UMO(034)=074.700                                                      0252
      UMO(035)=079.800                                                      0253
      UMO(036)=084.900                                                      0254
      UMO(037)=090.000                                                      0255
      UMO(038)=095.000                                                      0256
      UMO(039)=100.000                                                      0257
      UMO(040)=015.900                                                      0258
      UMO(041)=017.100                                                      0259
      UMO(042)=018.400                                                      0260
      UMO(043)=019.700                                                      0261
      UMO(044)=021.100                                                      0262
      UMO(045)=022.600                                                      0263
      UMO(046)=024.100                                                      0264
      UMO(047)=025.800                                                      0265
      UMO(048)=027.500                                                      0266
      UMO(049)=029.300                                                      0267
      UMO(050)=031.100                                                      0268
      UMO(051)=033.100                                                      0269
      UMO(052)=035.000                                                      0270
      UMO(053)=037.100                                                      0271
      UMO(054)=039.200                                                      0272
      UMO(055)=041.300                                                      0273
      UMO(056)=043.500                                                      0274
      UMO(057)=045.800                                                      0275
      UMO(058)=048.200                                                      0276
      UMO(059)=050.700                                                      0277
      UMO(060)=053.200                                                      0278
      UMO(061)=055.900                                                      0279
      UMO(062)=058.600                                                      0280
      UMO(063)=061.500                                                      0281
      UMO(064)=064.400                                                      0282
      UMO(065)=067.500                                                      0283
      UMO(066)=070.600                                                      0284
      UMO(067)=073.900                                                      0285
      UMO(068)=077.300                                                      0286
      UMO(069)=080.800                                                      0287
      UMO(070)=084.500                                                      0288
      UMO(071)=088.200                                                      0289
      UMO(072)=091.700                                                      0290
      UMO(073)=095.400                                                      0291
      UMO(074)=099.100                                                      0292
      UMO(075)=103.000                                                      0293
      UMO(076)=106.000                                                      0294
      UMO(077)=110.000                                                      0295
      UMO(078)=113.000                                                      0296
      UMO(079)=115.000                                                      0297
      UMO(080)=117.000                                                      0298
      UMO(081)=119.000                                                      0299
      UMO(082)=120.000                                                      0300
      UMO(083)=120.000                                                      0301
      UCU(001)=000.435                                                      0303
      UCU(002)=000.383                                                      0304
      UCU(003)=000.716                                                      0305
      UCU(004)=001.500                                                      0306
      UCU(005)=002.390                                                      0307
      UCU(006)=004.600                                                      0308
      UCU(007)=007.520                                                      0309
      UCU(008)=011.500                                                      0310
      UCU(009)=016.400                                                      0311
      UCU(010)=022.900                                                      0312
      UCU(011)=030.100                                                      0313
      UCU(012)=038.600                                                      0314
      UCU(013)=048.600                                                      0315
      UCU(014)=060.600                                                      0316
      UCU(015)=074.100                                                      0317
      UCU(016)=089.100                                                      0318
      UCU(017)=106.000                                                      0319
      UCU(018)=123.000                                                      0320
      UCU(019)=143.000                                                      0321
      UCU(020)=162.000                                                      0322
      UCU(021)=184.000                                                      0323
      UCU(022)=208.000                                                      0324
      UCU(023)=233.000                                                      0325
      UCU(024)=260.000                                                      0326
      UCU(025)=285.000                                                      0327
      UCU(026)=308.000                                                      0328
      UCU(027)=313.000                                                      0329
      UCU(028)=045.700                                                      0330
      UCU(029)=052.900                                                      0331
      UCU(030)=060.300                                                      0332
      UCU(031)=067.900                                                      0333
      UCU(032)=075.600                                                      0334
      UCU(033)=083.400                                                      0335
      UCU(034)=091.400                                                      0336
      UCU(035)=099.600                                                      0337
      UCU(036)=108.000                                                      0338
      UCU(037)=117.000                                                      0339
      UCU(038)=125.000                                                      0340
      UCU(039)=134.000                                                      0341
      UCU(040)=143.000                                                      0342
      UCU(041)=153.000                                                      0343
      UCU(042)=162.000                                                      0344
      UCU(043)=172.000                                                      0345
      UCU(044)=183.000                                                      0346
      UCU(045)=194.000                                                      0347
      UCU(046)=206.000                                                      0348
      UCU(047)=218.000                                                      0349
      UCU(048)=231.000                                                      0350
      UCU(049)=243.000                                                      0351
      UCU(050)=256.000                                                      0352
      UCU(051)=270.000                                                      0353
      UCU(052)=282.000                                                      0354
      UCU(053)=294.000                                                      0355
      UCU(054)=306.000                                                      0356
      UCU(055)=318.000                                                      0357
      UCU(056)=330.000                                                      0358
      UCU(057)=341.000                                                      0359
      UCU(058)=352.000                                                      0360
      UCU(059)=363.000                                                      0361
      UCU(060)=374.000                                                      0362
      UCU(061)=386.000                                                      0363
      UCU(062)=397.000                                                      0364
      UCU(063)=425.000                                                      0365
      UCU(064)=439.000                                                      0366
      UCU(065)=273.000                                                      0367
      UCU(066)=286.000                                                      0368
      UCU(067)=128.000                                                      0369
      UCU(068)=134.000                                                      0370
      UCU(069)=140.000                                                      0371
      UCU(070)=146.000                                                      0372
      UCU(071)=153.000                                                      0373
      UCU(072)=159.000                                                      0374
      UCU(073)=166.000                                                      0375
      UCU(074)=172.000                                                      0376
      UCU(075)=179.000                                                      0377
      UCU(076)=186.000                                                      0378
      UCU(077)=193.000                                                      0379
      UCU(078)=200.000                                                      0380
      UCU(079)=208.000                                                      0381
      UCU(080)=216.000                                                      0382
      UCU(081)=224.000                                                      0383
      UCU(082)=232.000                                                      0384
      UCU(083)=240.000                                                      0385
      UCO(001)=000.464                                                      0387
      UCO(002)=000.491                                                      0388
      UCO(003)=001.030                                                      0389
      UCO(004)=002.250                                                      0390
      UCO(005)=003.630                                                      0391
      UCO(006)=007.070                                                      0392
      UCO(007)=011.600                                                      0393
      UCO(008)=017.800                                                      0394
      UCO(009)=025.400                                                      0395
      UCO(010)=035.400                                                      0396
      UCO(011)=046.500                                                      0397
      UCO(012)=059.500                                                      0398
      UCO(013)=074.800                                                      0399
      UCO(014)=093.300                                                      0400
      UCO(015)=114.000                                                      0401
      UCO(016)=136.000                                                      0402
      UCO(017)=161.000                                                      0403
      UCO(018)=187.000                                                      0404
      UCO(019)=215.000                                                      0405
      UCO(020)=243.000                                                      0406
      UCO(021)=273.000                                                      0407
      UCO(022)=308.000                                                      0408
      UCO(023)=343.000                                                      0409
      UCO(024)=381.000                                                      0410
      UCO(025)=414.000                                                      0411
      UCO(026)=052.800                                                      0412
      UCO(027)=061.100                                                      0413
      UCO(028)=070.500                                                      0414
      UCO(029)=081.600                                                      0415
      UCO(030)=093.000                                                      0416
      UCO(031)=105.000                                                      0417
      UCO(032)=116.000                                                      0418
      UCO(033)=128.000                                                      0419
      UCO(034)=140.000                                                      0420
      UCO(035)=152.000                                                      0421
      UCO(036)=165.000                                                      0422
      UCO(037)=177.000                                                      0423
      UCO(038)=190.000                                                      0424
      UCO(039)=203.000                                                      0425
      UCO(040)=216.000                                                      0426
      UCO(041)=230.000                                                      0427
      UCO(042)=243.000                                                      0428
      UCO(043)=257.000                                                      0429
      UCO(044)=272.000                                                      0430
      UCO(045)=288.000                                                      0431
      UCO(046)=304.000                                                      0432
      UCO(047)=321.000                                                      0433
      UCO(048)=338.000                                                      0434
      UCO(049)=356.000                                                      0435
      UCO(050)=373.000                                                      0436
      UCO(051)=391.000                                                      0437
      UCO(052)=407.000                                                      0438
      UCO(053)=422.000                                                      0439
      UCO(054)=436.000                                                      0440
      UCO(055)=450.000                                                      0441
      UCO(056)=463.000                                                      0442
      UCO(057)=475.000                                                      0443
      UCO(058)=486.000                                                      0444
      UCO(059)=497.000                                                      0445
      UCO(060)=543.000                                                      0446
      UCO(061)=327.000                                                      0447
      UCO(062)=344.000                                                      0448
      UCO(063)=156.000                                                      0449
      UCO(064)=165.000                                                      0450
      UCO(065)=173.000                                                      0451
      UCO(066)=182.000                                                      0452
      UCO(067)=191.000                                                      0453
      UCO(068)=199.000                                                      0454
      UCO(069)=208.000                                                      0455
      UCO(070)=217.000                                                      0456
      UCO(071)=226.000                                                      0457
      UCO(072)=235.000                                                      0458
      UCO(073)=244.000                                                      0459
      UCO(074)=253.000                                                      0460
      UCO(075)=262.000                                                      0461
      UCO(076)=272.000                                                      0462
      UCO(077)=282.000                                                      0463
      UCO(078)=291.000                                                      0464
      UCO(079)=302.000                                                      0465
      UCO(080)=312.000                                                      0466
      UCO(081)=323.000                                                      0467
      UCO(082)=334.000                                                      0468
      UCO(083)=346.000                                                      0469
      NEL = 50
      IN = 5
      IOUT = 6
      WRITE(IOUT,177)
  177 FORMAT(//' Program to calculate molecular weights and'/
     1' x-ray mass absorption coefficients'//
     2' *****PUSH CAPS LOCK DOWN****'//)
  182 FORMAT(//)
      WRITE(IOUT,180)
  180 FORMAT(' Type in formula as follows'/
     1' Atom symbol( left adjusted) followed by subscript',
     1 ' or percent'/
     2' in (A2,F6.3)   format  for example CA1.98CO3.10H2O is'/
     3' CA1.98'/' C 1.'/' O 13.'/' H 20.'//
     4' After last element hit return'/)
    1 WRITE(IOUT,183)
  183 FORMAT(' Are subscripts or percentages to be entered?',
     1' type S or P')
      READ(IN,184)IPER
  184 FORMAT(A1)
      WRITE(IOUT,181)
  181 FORMAT(/' Type in formula')
      FOOO= 0.0
      I = 0
      DO 444 J = 1,NEL
      I = I + 1
  442 READ(IN,140)ELEM(I),SUB(I)
      IF(ELEM(I).EQ.BL.AND.I.EQ.1)GO TO 9999
      IF(ELEM(I).EQ.BL)GO TO 445
      DO 443 K=1,103
      IF(ELEM(I).EQ.SYM(K))GO TO 444
  443 CONTINUE
      WRITE(IOUT,185)ELEM(I)
  185 FORMAT(1XA2,' is not a legal element try again')
      GO TO 442
  444 CONTINUE
  445 MAX = I - 1
      IF(IPER .EQ. 1HP) GO TO 905
C  THE FOLLOWING ROUTINE CALCULATES THE PROPORTION BY WEIGHT OF EACH
C  ELEMENT IN THE COMPOUND AND DETERMINES THE MOLECULAR WEIGHT OF THE
C  COMPOUND.
      SUM=0.0
      DO 315 J=1,MAX
      DO 320 K=1,103
      IF(ELEM(J)-SYM(K))320,15,320
  320 CONTINUE
      WRITE(IOUT,145)
      GO TO 1
   15 PROP(J)=SUB(J)*AW(K)
      SUM=SUM+PROP(J)
      AK=K
      FOOO=FOOO+AK*SUB(J)
  315 CONTINUE
C  THE FOLLOWING ROUTINE CALCULATES THE PERCENTAGE BY WEIGHT OF EACH
C  ELEMENT IN THE COMPOUND.
      DO 325 J=1,MAX
  325 PCT(J)=(PROP(J)/SUM)*100.
      WRITE(IOUT,150)SUM
      WRITE(IOUT,155)
      DO 330 J=1,MAX
      WRITE(IOUT,160)ELEM(J),SUB(J),PROP(J),PCT(J)
  330 CONTINUE
      GO TO 910
  905 SUM = 0.0
      DO 907 I=1,MAX
      PCT(I) = SUB(I)
      SUM = SUM + PCT(I)
  907 CONTINUE
      IF(SUM.GT.90.)GO TO 910
      MAX = MAX + 1
      ELEM(MAX) = 2HO 
      PCT(MAX) = 100. - SUM
      WRITE(IOUT,908)PCT(MAX)
  908 FORMAT(/' Percent oxygen = ',F7.3)
C THE FOLLOWING ROUTINE CALCULATES MASS ABSORPTION COEFFICIENTS
  910 FUMO=0.0
      FUCU=0.0
      FUCO=0.0
      DO911 J=1,MAX
      DO 912 K=1,83
      IF(ELEM(J)-SYM(K))912,913,912
  912 CONTINUE
      WRITE(IOUT,16)
      WRITE(IOUT,17)
      GO TO 1
  913 FUMO=FUMO+PCT(J)*UMO(K)/100.
      FUCU=FUCU+PCT(J)*UCU(K)/100.
  911 FUCO=FUCO+PCT(J)*UCO(K)/100.
      WRITE(IOUT,167)FUCU
      WRITE(IOUT,168)FUCO
      WRITE(IOUT,166)FUMO
      IF(IPER.EQ.S)WRITE(IOUT,169)FOOO
      WRITE(IOUT,182)
      GO TO 1
  140 FORMAT (A2,F6.3)
  145 FORMAT (/' Invalid element symbol in formula'/)
  150 FORMAT (//  ' Molecular weight of compound = ',F14.6)
  155 FORMAT(/   ' Element  Subscript  Wt. Proportion  Wt. Percent')
  160 FORMAT(/3X,A2,8XF3.0,2(2XG14.4))
   16 FORMAT(55H Get thee to the literature and find values of u/p for ,
     18Helements)
   17 FORMAT(47H Greater than Z=83 and add them to this program)
  166 FORMAT(/       47H Mass Absorption coefficient for Mo radiation =,
     1F10.4)
  167 FORMAT(   /    47H Mass Absorption coefficient for Cu radiation =,
     1F10.4)
  168 FORMAT(   /    47H Mass Absorption coefficient for Co radiation =,
     1F10.4)
  169 FORMAT(///' The number of electrons in the molecule (F000)='F10.4)
 9999 CALL EXIT
      END
