PROGRAM D9R8A
!DRIVER FOR ROUTINE MRQMIN
EXTERNAL FGAUSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PARAMETER(NPT=100,MA=6,SPREAD=0.001)
DIMENSION X(NPT),Y(NPT),SIG(NPT),A(MA),LISTA(MA),&
COVAR(MA,MA),ALPHA(MA,MA),GUES(MA)
DATA A/5.0,2.0,3.0,2.0,5.0,3.0/
DATA GUES/4.5,2.2,2.8,2.5,4.9,2.8/
IDUM=-911
!FIRST TRY A SUM OF TWO GAUSSIANS
DO I=1,100
X(I)=0.1*I
Y(I)=0.0
DO J=1,4,3
Y(I)=Y(I)+A(J)*EXP(-((X(I)-A(J+1))/A(J+2))**2)
END DO
Y(I)=Y(I)*(1.0+SPREAD*GASDEV(IDUM))
SIG(I)=SPREAD*Y(I)
END DO
MFIT=MA
DO I=1,MFIT
LISTA(I)=I
END DO
ALAMDA=-1
DO I=1,MA
A(I)=GUES(I)
END DO
CALL MRQMIN(X,Y,SIG,NPT,A,MA,LISTA,MFIT,COVAR,ALPHA,&
MA,CHISQ,FGAUSS,ALAMDA)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!报错actual argument must not be the name of procedure
K=1
ITST=0
DO
WRITE(*,'(/1X,A,I2,T18,A,F10.4,T43,A,E9.2)')&
'Iteration#',K,'Chi-squared:',CHISQ,'ALAMDA:',ALAMDA
WRITE(*,'(1X,T5,A,T13,A,T21,A,T29,A,T37,A,T45,A)')&
'A(I)','A(2)','A(3)','A(4)','A(5)','A(6)'
WRITE(*,'(1X,6F8.4)')(A(I),I=1,6)
K=K+1
OCHISQ=CHISQ
CALL MRQMIN(X,Y,SIG,NPT,A,MA,LISTA,MFIT,COVAR,ALPHA,&
MA,CHISQ,FGAUSS,ALAMDA)!!!!!!!!!!!!!!!
IF(CHISQ>OCHISQ)THEN
ITST=0
ELSE IF(ABS(OCHISQ-CHISQ)<0.1)THEN
ITST=ITST+1
END IF
IF(ITST>=2)EXIT
END DO
ALAMDA=0.0
CALL MRQMIN(X,Y,SIG,NPT,A,MA,LISTA,MFIT,COVAR,ALPHA,&
MA,CHISQ,FGAUSS,ALAMDA)
WRITE(*,*)'Uncertainties:'
WRITE(*,'(1X,6F8.4/)')(SQRT(COVAR(I,I)),I=1,6)
WRITE(*,'(1X,A)')'Expected results:'
WRITE(*,'(1X,F7.2,5F8.2)')5.0,2.0,3.0,2.0,5.0,3.0
END
734.05 KB, 下载次数: 19
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |