Hii,(adsbygoogle = window.adsbygoogle || []).push({});

Having trouble with some code I am writing, where a subroutine returns the same value regardless of different variable inputs.

.....

C Calculate Yth and Chi values. Compute sum of Chi-squared.

Subroutine Chisquared(CPREV,CHISQ)

Real TIME(17),COUNTS(17),ERROR(17),YTH(17),CHI(17)

Real A,B,LAMDA1,LAMDA2,CHISQ,CPREV

Common TIME,ERROR,COUNTS,YTH,A,B,LAMDA1,LAMDA2

CPREV=CHISQ

CPREV=0

Do K=1,17

YTH(K)=A*EXP(-LAMDA1*TIME(K))+B*EXP(-LAMDA2*TIME(K))

End Do

Do L=1,17

CHI(L)=(COUNTS(L)-YTH(L))/((ERROR(L)**2))

End Do

Do M=1,17

CPREV=CPREV+CHI(M)

End Do

Return

End

......

The user inputs A, B, LAMDA1 and LAMDA2 but it always returns the same value of CPREV.

Help please!!!

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Errors with fortran code, help!

**Physics Forums | Science Articles, Homework Help, Discussion**