SUBROUTINE CDWT ( * * inputs * : SCHEME, FVAR, SDVAR, NVAR, * * outputs * : WVAR, WEIGHT, STATUS) * * Module number: * * Module name: * * Keyphrase: * ---------- * Calculate the weights of ONE point from the specified scheme. * * Description: * ------------ * The weight is equal to SDVAR to SCHEME's power. e. g. if we use the inverse * of variance as weight, SCHEME =-2, and if equal weights, SCHEME = 0. * * Exceptions: if SCHEME = -1000 or less, it means the variable is free from * error and no weight is calculated for the corresponding variable, its * weight is set to be 10^30. * * After the weight of each variable is determined, the total weight is * calculated according to the following equation (see p. 134 of Statistical * Adjustment of Data by W. E. Deming): * * 1/WT = Fx^2 / Wx + Fy^2 / Wy + ... * * Where WT is the total weight, Fx is the partial derivative of the fitting * function relative to x, Fy is the partial derivative of the fitting function * relative to y, Wx is the weight in x, and Wy is the weight in y, etc. * * In this subroutine, Fx = FVAR(1), Fy = FVAR(2), Wx = WVAR(1), Wy = WVAR(2), * WT = WEIGHT, etc. * * FORTRAN name: CDWT.FOR * * Keywords of accessed files and tables: * -------------------------------------- * Name I/O Description / Comments * None * * Subroutines Called: * ------------------- * CDBS: * None * SDAS: * UMSPUT * Others: * None * * History: * -------- * Version Date Author Description * 1 02-16-87 J.-C. HSU design and coding *------------------------------------------------------------------------------- * *== input: * --data weighting scheme REAL SCHEME(1) * --partial derivatives of the fitting * --function relative to the variables DOUBLE PRECISION FVAR(1), * --standard deviations of the input data * --point : SDVAR(1) * --number of variables INTEGER NVAR * *== output: * --weights of each variable DOUBLE PRECISION WVAR(1), * --total weights : WEIGHT * --error status INTEGER STATUS * *== local: * --inverse of total weight DOUBLE PRECISION WINV * --loop index INTEGER I, * --error status : STATOK * --sum of scheme REAL SUM * --error message CHARACTER*130 CONTXT, MESS *=========================begin hsp.inc========================================= * --status return code INTEGER OK, ERRNUM(20) INTEGER DEST, PRIO DATA OK /0/ DATA ERRNUM /701, 702, 703, 704, 705, 706, 707, 708, 709, 710, : 711, 712, 713, 714, 715, 716, 717, 718, 719, 720/ * --message destination and priority DATA DEST, PRIO /1, 0/ *=========================end hsp.inc=========================================== *------------------------------------------------------------------------------ * * initialize * WINV = 0.D0 SUM = 0. * * check for the impossible case of all variables being free of errors * DO 10 I = 1, NVAR SUM = SUM + SCHEME(I) 10 CONTINUE * IF (SUM .LT. -1000. * FLOAT(NVAR) + 0.1) THEN STATUS = ERRNUM(1) CONTXT = 'impossible case: all variables are free from ' : // 'errors' GO TO 999 END IF * * process each variable * DO 20 I = 1, NVAR * * error free case * IF (SCHEME(I) .LT. -999.9) THEN WVAR(I) = 1.D30 * * other cases * * check SDVAR must be positive * ELSE IF (SDVAR(I) .LT. 1.E-30) THEN STATUS = ERRNUM(2) CONTXT = 'non-positive standard deviation(s)' GO TO 999 END IF * WVAR(I) = SDVAR(I) ** SCHEME(I) END IF * * total weight * WINV = FVAR(I) ** 2 / WVAR(I) + WINV 20 CONTINUE * WEIGHT = 1.D0 / WINV * STATUS = OK GO TO 1000 * * write error message * 999 MESS = 'CDWT: ' // CONTXT CALL UMSPUT (MESS, DEST, PRIO, STATOK) * 1000 RETURN END