c This is a subroutine that writes the data file that will be read by c our gnuplot program, gnutest, and then calls gnutest. c c modifications by jwb 5/25/2021 to generalize from L mode only to L/M c there are variables below which are specific to the L mode that have c been replaced by e.g. "64" is replaced by i64, which is 4*jne in the c general case, "47" has been replaced by i47, which is 3*jne+1 c SUBROUTINE writedat(JNE,IDEC,YB,icur) COMMON/ANSWER/ANS(150),CURRNT(512) COMMON/SIMCUR/BTOT(129,5,6,15) Real jdata(128,4,17),YB INTEGER*4 IDEC integer*2 JNE character*30 YS,IS character*96 comline Call System('rm data.txt') Open(27, FILE ='data.txt') c write(6,94) jne,jne,idec,yb 94 format("new writedata jne jne idec yb ",3i9,f7.1) c c sum up individual fits over fit components do 511 jcup = 1,4 DO 510 L=1,jne sum = 0. DO 520 N=1,15 sum=sum+BTOT(L,JCUP,1,N) 520 CONTINUE c this is the sum of all the fits jdata(L,jcup,2) = sum 510 CONTINUE 511 CONTINUE c 1254 continue do 576 i = 1,4 do 576 j=1,jne icount = j+jne*(i-1) c fill in the measured currents jdata(j,i,1)=currnt(icount) c allow for the fact that if icur = 0 there are no fit currents if(icur.eq.0) jdata(j,i,2)=0. do 579 n = 1,15 jdata(j,i,n+2)=btot(j,i,1,n) if(icur.eq.0) jdata(j,i,n+2)=0. 579 continue 576 continue c c output the data into data.txt for each channel do 1111 j = 1,jne xfit = j*1. write(27, 100) xfit,((jdata(j,m,n),m=1,4),n=1,17) 1111 continue 100 FORMAT(f7.1,' ',68F12.1) c c Here we take the inputted variables YB and IDEC and make them into c strings that we can pass into the command line and thus call the c graphing program correctly. c write(6,1932) 1932 format("writedat ") write(YS,*) YB write(IS,*) IDEC if(jne.eq.16) + comline = + 'gnuplot -e "t='//YS//' ; u='//IS//'" gnutest_L' if(jne.eq.128) + comline = + 'gnuplot -e "t='//YS//' ; u='//IS//'" gnutest_M' write(6,*) comline Call System(comline) return end