C+ C NAME: C write_val.f C PURPOSE: C write coeficients and errors into a data file C CATEGORY: C I/O C CALLING SEQUENCE: C call write_val(cfile,mfit,hvel,halphav,htheta,har,A,ER,MA,Ndat,inc,iVal,Chisqold,Chisq,anoise,sigv,alambdal) C C INPUTS: C Read_fft: C cfile character The output file name C mfit integer # of coefficients fit C hvel real Initial velocity C halphav real Initial alpha C htheta real Initial theta C har real Initial axial ratio C A real*8 The output coefficients C ER real*8 the output coefficient errors C MA integer the number of coeficients output C Ndat integer the number of frequency points C inc integer if inc = 1 the Marquardt system did not fully converge C iVal integer the number of the iteration C anoise real*8 the spectrum noise level C sigv real*8 the sigma value of the data C Chisqold real*8 the old chi**2 C Chisq real*8 the current chi**2 C alambdal real*8 the final lambda C C OUTPUTS: C A data file C C MODIFICATION HISTORY: C November-2013, Bernard Jackson (UCSD) C- subroutine write_val(cFile,mfit,hvel,halphav,htheta,har,A,ER,MA,Ndat,inc,iVal,Chisqold,Chisq,anoise,sigv,alamdal) implicit real*8(a-g,o-z) character cFile*44 ! The output file character cfileh*23 ! File header input character cdate*23 ! File date and time real*8 A (MA), ! The output coefficients & ER (MA,MA) ! The output coefficient errors C common elong,as,be, ! extra parameters used by make_model & zs,ze,xs,xe,ccc,PI,au,au2,anu,alamb,freq,twopi,qxf, & L1,L2,L3,L4,L5,L6,L7,L8,L9,A1,A2,A3,A4,A5,A6,A7,A8,A9, & z,z0,R,p,Vx,Xnorm,XMnorm,ahpow,aanoise, & er1,er2,er3,er4,er5,er6,er7,er8,er9,er10, & ijsing,iFs(500),iFt(500),iFd(500),aispecq(500),ispecq1,iq1(500),ispecq2,iq2(500) C C print *, ' ' cfileh(1:23) = cfile(19:41) write (*,'(3A)') 'inside write_val ',cFile,cfileh C call OSGetDateAndTime(cDate) open (iU, file=cFile,recl=120,access='sequential',form='formatted') C write(iU,'(4A)') ' Output ',cfileh,' created on ',cDate write(iU,'(A)') ' ' C write(iU,'(A,F10.4)') ' Initial Velocity =', hvel write(iU,'(A,F10.5)') ' Initial Alpha =', halphav write(iU,'(A,F10.6)') ' Initial Theta =', htheta write(iU,'(A,F10.5)') ' Initial Axial Ratio =', har C write(iU,'(A)') ' ' write(iU,'(A,F6.1)') ' Source elongation =', elong * 57.295779513d0 write(iU,'(A,I4)') ' # of Coefficients fit =', mfit write(iU,'(A)') ' ' C write(iU,'(A,F10.4,A,F10.4)') ' Velocity =', A(1)/1.0d3,' +-', sqrt(ER(1,1))/1.0d3 write(iU,'(A,F10.5,A,F10.5)') ' Alpha =', A(2),' +-', sqrt(ER(2,2)) write(iU,'(A,F10.6,A,F10.6)') ' Theta =', A(3)/4.84813681d-6,' +-', sqrt(ER(3,3))/4.84813681d-6 write(iU,'(A,F10.5,A,F10.5)') ' Axial Ratio =', A(4),' +-', sqrt(ER(4,4)) write(iU,'(A)') ' ' if(ijsing.eq.1) then write(iU,'(A,I3,A)') ' **** Singular Matrix at', ival,' iterations ****' inc = 1 end if if(inc.eq.1) write(iU,'(A,I3,A)') ' **** Analysis not fully converged at', ival,' iterations ****' if(inc.eq.0) write(iU,'(A,I3,A)') ' Analysis converged at', ival,' iterations.' write(iU,'(A,F13.3,A,F9.4)') ' Final value of Chi**2 =',Chisq,', % from last =',100.d0*(Chisqold-Chisq)/Chisq write(iU,'(A,F9.6,A,F9.6))') ' Normalized noise =',anoise,' sigma value =',sigv write(iU,'(A,E12.2)') ' The last Lambda is =', alamdal C iflag = 0 do i=1,Ndat if(iFd(i).ge.1) then write(iU,'(I8,A,F12.6)') iFd(i), ' errors in Fd at frequency', aispecq(i) iflag = iflag + iFd(i) end if if(iFs(i).ge.1) then write(iU,'(I8,A,F12.6)') iFs(i), ' errors in Fs at frequency', aispecq(i) iflag = iflag + iFs(i) end if if(iFt(i).ge.1) then write(iU,'(I8,A,F12.6)') iFt(i), ' errors in Ft at frequency', aispecq(i) iflag = iflag + iFt(i) end if if(iq1(i).ge.1) then write(iU,'(I8,A,F12.6)') iq1(i), ' errors in Qsimp1 at frequency', aispecq(i) iflag = iflag + iq1(i) end if if(iq2(i).ge.1) then write(iU,'(I8,A,F12.6)') iq2(i), ' errors in Qsimp1 at frequency', aispecq(i) iflag = iflag + iq2(i) end if end do if(iflag.lt.1) then write(iU,'(A)') ' No errors of any kind' else if(iflag.gt.1) write(iU,'(A,I8,A)') ' There were',iflag,' errors' if(iflag.eq.1) write(iU,'(A,I2,A)') ' There was',iflag,' error' end if C close(iU) C return end