The program below takes the place of the data in the above example.
PROGRAM DSDQ
C Minuit test case. Fortran-callable.
C Fit randomly-generated leptonic K0 decays to the
C time distribution expected for interfering K1 and K2,
C with free parameters Re(X), Im(X), DeltaM, and GammaS.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
EXTERNAL FCNK0
CC OPEN (UNIT=6,FILE='DSDQ.OUT',STATUS='NEW',FORM='FORMATTED')
DIMENSION NPRM(5),VSTRT(5),STP(5),ARGLIS(10)
CHARACTER*10 PNAM(5)
DATA NPRM / 1 , 2 , 5 , 10 , 11 /
DATA PNAM /'Re(X)', 'Im(X)', 'Delta M','T Kshort','T Klong'/
DATA VSTRT/ 0. , 0. , .535 , .892 , 518.3 /
DATA STP / 0.1 , 0.1 , 0.1 , 0. , 0. /
C Initialize Minuit, define I/O unit numbers
CALL MNINIT(5,6,7)
C Define parameters, set initial values
ZERO = 0.
DO 11 I= 1, 5
CALL MNPARM(NPRM(I),PNAM(I),VSTRT(I),STP(I),ZERO,ZERO,IERFLG)
IF (IERFLG .NE. 0) THEN
WRITE (6,'(A,I)') ' UNABLE TO DEFINE PARAMETER NO.',I
STOP
ENDIF
11 CONTINUE
C
CALL MNSETI('Time Distribution of Leptonic K0 Decays')
C Request FCN to read in (or generate random) data (IFLAG=1)
ARGLIS(1) = 1.
CALL MNEXCM(FCNK0, 'CALL FCN', ARGLIS ,1,IERFLG)
C
ARGLIS(1) = 5.
CALL MNEXCM(FCNK0,'FIX', ARGLIS ,1,IERFLG)
ARGLIS(1) = 0.
CALL MNEXCM(FCNK0,'SET PRINT', ARGLIS ,1,IERFLG)
CALL MNEXCM(FCNK0,'MIGRAD', ARGLIS ,0,IERFLG)
CALL MNEXCM(FCNK0,'MINOS', ARGLIS ,0,IERFLG)
CALL PRTERR
ARGLIS(1) = 5.
CALL MNEXCM(FCNK0,'RELEASE', ARGLIS ,1,IERFLG)
CALL MNEXCM(FCNK0,'MIGRAD', ARGLIS ,0,IERFLG)
CALL MNEXCM(FCNK0,'MINOS', ARGLIS ,0,IERFLG)
ARGLIS(1) = 3.
CALL MNEXCM(FCNK0,'CALL FCN', ARGLIS , 1,IERFLG)
CALL PRTERR
CALL MNEXCM(FCNK0,'STOP ', 0,0,IERFLG)
STOP
END
SUBROUTINE PRTERR
C a little hand-made routine to print out parameter errors
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C find out how many variable parameters there are
CALL MNSTAT(FMIN,FEDM,ERRDEF,NPARI,NPARX,ISTAT)
C and their errors
DO 50 I= 1, NPARI
CALL MNERRS(-I,EPLUS,EMINUS,EPARAB,GLOBCC)
WRITE (6,45) I,EPLUS,EMINUS,EPARAB,GLOBCC
45 FORMAT (5X,I5,4F12.6)
50 CONTINUE
RETURN
END
The FCN is exactly the same in Fortran-callable mode as in data-driven mode.