C......Program mvsh.for to plot magnetisation versus field. 
C......Experimental numbers are corrected for diamgnetism and 
C......converted to B.M. by dividing M(emuG per mole) by 5585
C......( = N.beta). Field is in Gauss. Theoretical values are 
C......for S = 5/2.
c...Data in file D. First line : sample wt.(mg), mol.wt, molar
c...diamagn. susceptibility(negative emu per mole), g-value, T
c...followed by field(H) and magnetisation(Msample) for each 
c...measurement.
c...Output file R contains data - can be input to plot programs
c...after editing.
c...Output file P contains data which can be input to PLOT.BAS
c...for screen plotting without editing.
c...............mvr/march '99.............  
      CHARACTER*40 TITLE
      OPEN(1,FILE='D')
      OPEN(2,FILE='R',STATUS='NEW')
      OPEN(3,FILE='P',STATUS='NEW')
      MOD=1
      READ(1,10)TITLE
      WRITE(2,10)TITLE
C sample wt.(mg), mol.wt., molar Chi-dia(-ve),G,T
      WRITE(2,50)
      READ(1,*)SW,WM,DC,G,T
   1  READ(1,*,END=2) IH,RMS
      IF(IH.EQ.0)THEN
      H=0.
      CHI=0.
      RM=0.
      GOTO 5
      ENDIF
      H=IH
      CHI = -DC + RMS*WM*1000./(H*SW)
      RM = CHI*H/5585.
   5  WRITE(2,40)H,RMS,CHI,RM
      WRITE(*,40)H,RMS,CHI,RM
      WRITE(3,30)H,RM,MOD
      GOTO 1
   2  WRITE(2,60)
      MOD=0
      H=0
      RM=0
      WRITE(2,20)H,RM
      WRITE(3,30)H,RM,MOD   
   3  H=H+100
      RM=RMAG(G,T,H)
      WRITE(2,20)H,RM
      WRITE(*,20)H,RM
      WRITE(3,30)H,RM,MOD
      IF(H.EQ.50000.)GOTO 4
      GOTO 3
   4  MOD=99
      WRITE(3,30)H,RM,MOD
      STOP
   10 FORMAT(A40)    
   20 FORMAT(3X,F8.1,1X,F12.6)
   30 FORMAT(3X,F8.1,1X,F12.6,I3)
   40 FORMAT(3X,F8.1,1X,F12.6,1X,F12.6,1X,F12.6)
   50 FORMAT(/3X,'FIELD/G',2X,'  M/emuG   ',2X,
     1' CHI/emuM-1', 3X,'    M/B.M.')
   60 FORMAT(/3X,'FIELD/G',2X,'Mcalc./B.M.')
      END
      FUNCTION RMAG(G,T,H)
      GBBYKT=G*6.7106E-5/T
      A=3.*GBBYKT*H
      B=0.5*GBBYKT*H
      COTHA=(1./TANH(A))
      COTHB=(1./TANH(B))
      RMAG=0.5*G*(6.*COTHA - COTHB)
      END    
      