#!/bin/csh set IO = `basename $0` # #------------------------------------------------------- Fortran Code --------- cat >! ${IO}.f << FINEF90 parameter (ndat=100) real y(ndat),x(ndat) character title*80 title='Producing scatter plots with "scatterplot" subroutine' do i=1,ndat ; y(i)=gauss(1.5,0.4) ; x(i)=gauss(0.5,0.2) ; enddo call mvsetflags('Palette di colori',7.0) call grapbound(0.1,0.9,0.3,0.7,-0.2,1.1,0.3,2.6,' ') call scatterplot2(x,y,ndat,'c7s1x-0.3') do i=1,ndat ; y(i)=gauss(1.5,0.4) ; x(i)=gauss(0.5,0.2) ; enddo call scatterplot2(x,y,ndat,'c6Sxa') c These rows are to produces the legend call pallocchetto(0.2,0.74,0.004,7) call mvsetflags('Colore Titoli',6.0) call complexchar(0.2,0.73,'x',0.006,0.0,0.0) call mvsetflags('Colore Titoli',1.0) call complexchar(0.24,0.74,'Data set 1',0.006,0.0,0.0) call complexchar(0.24,0.73,'Data set 2',0.006,0.0,0.0) call displayexample('$IO',title,' ') end subroutine grapbound(x1,x2,y1,y2,x3,x4,y3,y4,opt) implicit none real x1,x2,y1,y2,x3,x4,y3,y4 ; character opt*(*) call mvsetrflags(1,x1) ; call mvsetrflags(2,x2) call mvsetrflags(3,y1) ; call mvsetrflags(4,y2) call mvsetrflags(21,x3) ; call mvsetrflags(22,x4) call mvsetrflags(23,y3) ; call mvsetrflags(24,y4) return end subroutine scatterplot2(x,y,n,eopt) implicit none integer n,i,iopen,col,sim,lenstr,isave real x(n),y(n),rflg(4),minmax(4),xg,yg,xx,vecmin,vecmax,wk1(10),wk2(10), 2 xinc,yinc save minmax,rflg character eopt*(*),opt*132,ch*4,xflag*4,yflag*4 logical mkframe col=6 ; sim=1 ; opt=eopt ; mkframe=.true. ; xflag='I' ; yflag='I' if (n.gt.0) then wk1(1)=vecmin(x,n) ; wk1(2)=vecmax(x,n) wk1(3)=vecmin(y,n) ; wk1(4)=vecmax(y,n) else wk1(1)=0 ; wk1(2)=1 ; wk1(3)=0 ; wk1(4)=1 endif wk2(1:4)=0 do i=1,lenstr(opt) if (opt(i:i).eq.'a') then mkframe=.false. else if (opt(i:i).eq.'c') then call extractval(opt(i+1:),xx) col=nint(xx) else if (opt(i:i).eq.'M') then xflag='L' else if (opt(i:i).eq.'N') then yflag='L' else if (opt(i:i).eq.'s') then call extractval(opt(i+1:),xx) sim=nint(xx) else if (opt(i:i).eq.'S') then if (lenstr(opt).gt.i) then ch(1:1)=opt(i+1:i+1) opt(i+1:i+1)='1' sim=4 endif else if (opt(i:i).eq.'x') then call extractval(opt(i+1:),minmax(1)) ; wk2(1)=1 else if (opt(i:i).eq.'X') then call extractval(opt(i+1:),minmax(2)) ; wk2(2)=1 else if (opt(i:i).eq.'y') then call extractval(opt(i+1:),minmax(3)) ; wk2(3)=1 else if (opt(i:i).eq.'Y') then call extractval(opt(i+1:),minmax(4)) ; wk2(4)=1 else if ((ichar(opt(i:i)).ge.48.and.ichar(opt(i:i)).le.57).or. 2 ichar(opt(i:i)).eq.46.or. ichar(opt(i:i)).eq.45) then else write(6,'(/,10x,a)') 'Invalid option ('//opt(i:i)// 2 ') for subroutine scatterplot' write(6,'(12x,a,/)') 'Valid options are listed below:' write(6,'(9x,a)')'a To avoid the set of graphic limit' write(6,'(9x,a)')' Note: all the graphic options are '// 2 'ignored in this case' write(6,'(9x,a)')'c?? To set the color of scatterplot to ??' write(6,'(9x,a)')'M To set logarithmic scale on X axis' write(6,'(9x,a)')'N To set logarithmic scale on Y axis' write(6,'(9x,a)')'sX? To set the symbol type of scatterplot to ??' write(6,'(9x,a)')'S? To set the character scatterplot to ?' write(6,'(9x,a)')'x?? To set the minimum of X axis to ??' write(6,'(9x,a)')'X?? To set the maximum of X axis to ??' write(6,'(9x,a)')'y?? To set the minimum of Y axis to ??' write(6,'(9x,a)')'Y?? To set the maximum of Y axis to ??' call exit(1) endif enddo call checkifgksisopen call tmpset(0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0) do i=1,4 ; call mvgetrflags(i,rflg(i)) ; enddo if (mkframe) then do i=1,4 ; if (nint(wk2(i)).eq.0) minmax(i)=wk1(i) ; enddo call mveasyscale2(minmax,xinc,yinc) call mveasyscale(minmax(1),minmax(2),xinc) call mveasyscale(minmax(3),minmax(4),yinc) call tmpset(0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0) wk1(1)=rflg(1) ; wk1(2)=rflg(2) ; wk1(3)=rflg(2) ; wk1(4)=rflg(1) wk2(1)=rflg(3) ; wk2(2)=rflg(3) ; wk2(3)=rflg(4) ; wk2(4)=rflg(4) wk1(5)=wk1(1) ; wk2(5)=wk2(1) call contorno(wk1,wk2,5,0,1) call plotxaxis(minmax(1),minmax(2),xinc,rflg,minmax,xflag) call plotyaxis(minmax(3),minmax(4),yinc,rflg,minmax,yflag) do i=1,4 ; call mvsetrflags(20+i,minmax(i)) ; enddo else do i=1,4 ; call mvgetrflags(20+i,minmax(i)) ; enddo endif do i=1,n call graphiccoord(x(i),y(i),rflg,minmax,xg,yg) if (sim.eq.2) then call triangolino(xg,yg,0.007,col) else if (sim.eq.3) then call rettangolino(xg,yg,0.007,0.007,col) else if (sim.eq.4) then call mvgetiflags(12,isave) call mvsetflags('Colore Titoli',float(col)) call complexchar(xg,yg,ch(1:1),0.006,0.0,0.0) call mvsetflags('Colore Titoli',float(isave)) else call pallocchetto(xg,yg,0.004,col) endif enddo if (n.gt.0) call tmpreset return end subroutine mveasyscale2(minmax,xinc,yinc) implicit none ; real minmax(4),xinc,yinc,x(2),y(2) x(1:2)=minmax(1:2) ; y(1:2)=minmax(3:4) x(1)=5.0 ; x(2)=25.0 ;y(1)=5.0 ;y(2)=15.0 c call agstup(x,1,1,2,1,y,1,1,2,1) CALL AGSETI ('SET.',-1) call ezxy(x,y,2,' ') call aggetf('x/min.',xinc) ; print *,xinc return end subroutine mveasyscale(min,max,inc) implicit none ; real min,max,inc integer sign ; real dx dx=max-min if (dx.gt.1000.and.dx.lt.10000) then sign=1 ; if (min.lt.0) sign=-1 min=sign*(nint(abs(min)/100))*100 sign=1 ; if (max.lt.0) sign=-1 max=sign*(nint(abs(max)/100))*100 inc=100 if ((max-min)/inc.gt.20) inc=200 if ((max-min)/inc.gt.20) inc=400 else if (max-min.lt.1.001) then inc=0.1 ; min=floor(min*10)/10.0 ; max=floor(max*10)/10.0+inc else if (max-min.lt.2.001) then inc=0.2 ; min=floor(min*10)/10.0 ; max=floor(max*10)/10.0+inc else if (max-min.lt.5.001) then inc=0.5 ; min=floor(min*10)/10.0 ; max=floor(max*10)/10.0+inc else if (dx.gt.1.0.and.dx.lt.20.0) then inc=1 ; min=floor(min) ; max=floor(max) endif return end subroutine plotyaxis(min,max,inc,rflg,minmax,xflag) implicit none real min,max,inc,rflg(4),minmax(4) ; character xflag*(*) integer i ; real xg,y,xx(2),yy(2) ; character lab*32 xx(1)=rflg(1) ; xx(2)=xx(1)+0.007 y=min-inc ; if (xflag(1:1).eq.'L') y=min do i=1,100 y=y+inc ; if (y.gt.max) exit call graphiccoord(0.0,y,rflg,minmax,xg,yy(1)) ; yy(2)=yy(1) call contorno(xx,yy,2,0,1) if (xflag(1:1).eq.'I') then if (inc.lt.1) then write(lab,'(f4.1)') y else write(lab,'(i8)') nint(y) endif call nospace(lab) call complexchar(rflg(1)-0.015,yy,lab,9.0,0.,0.) else if (xflag(1:1).eq.'L') then write(lab,'(a,i3,a)') '10\S\',nint(y),'\N\' ; call nospace(lab) if (nint(y).eq.0) lab='1' call complexchar(rflg(1)-0.025,yy,lab,10.0,0.,0.) endif enddo return end subroutine plotxaxis(min,max,inc,rflg,minmax,xflag) implicit none real min,max,inc,rflg(4),minmax(4) ; character xflag*(*) integer i ; real xg,yg,x,xx(2),yy(2) ; character lab*32 yy(1)=rflg(3) ; yy(2)=yy(1)+0.007 x=min-inc do i=1,100 x=x+inc c if (x.gt.max) exit call graphiccoord(x,0.0,rflg,minmax,xx(1),yg) ; xx(2)=xx(1) if (xx(1).gt.rflg(2)+0.001) exit call contorno(xx,yy,2,0,1) if (xflag(1:1).eq.'I') then if (inc.lt.1) then write(lab,'(f4.1)') x else write(lab,'(i8)') nint(x) endif call nospace(lab) call complexchar(xx,rflg(3)-0.01,lab,9.0,0.,0.) else if (xflag(1:1).eq.'L') then write(lab,'(a,i3,a)') '10\S\',nint(x),'\N\' ; call nospace(lab) if (nint(x).eq.0) lab='1' call complexchar(xx,rflg(3)-0.01,lab,10.0,0.,0.) endif enddo return end FINEF90 set LOGF = "true" set LOGF = "false" goto chkplatf retchkplatf: if ( -f $IO.exe ) /bin/rm $IO.exe f90 $OPTION -o $IO.exe $IO.f $JETNET $MVLIB $NCARLIB $X11LIB >&! fortran.log if ( ! -x $IO.exe ) then echo " ${IO}: cannot find $IO.exe " echo " This is the log for compilation:" echo "******************************************************************" cat fortran.log echo "******************************************************************" goto CANCELLA else if ( $LOGF == "true" ) then cat fortran.log echo " Running $IO.exe" endif ./$IO.exe CANCELLA: if ( $LOGF == "true" ) echo " Removing all tmp files." foreach FILE ( $IO.exe gmeta core $IO.log fortran.log \ gifmerge.log ${IO}common.f CONDRV.SCR tbl.tmp ) if ( -f $FILE) /bin/rm $FILE end if ( $LOGF == "true" ) echo " Done." exit chkplatf: set CHKSEL = "${?IO}" if ( $CHKSEL == 0 ) set IO = `basename $0` set CHKSEL = "${?SELCOMP}" if ( $CHKSEL == 0 ) set SELCOMP = "nocomp" set X11LIB = " -lX11 -lm " if ( $SELCOMP == "nocomp" ) then else if ( $SELCOMP == "pgf90" ) then if ( ! -X ${SELCOMP} ) then echo " ${IO}: ${SELCOMP} non available on this system. Exiting..." exit endif alias f90 pgf90 ; set COMP = "pgf90" set OPTION = '-silent -Mextend -byteswapio' set IPLATF = 5 goto retchkplatf else if ( $SELCOMP == "ifort" ) then if ( ! -X ${SELCOMP} ) then echo " ${IO}: ${SELCOMP} non available on this system. Exiting..." exit endif alias f90 ifort ; set COMP = "ifort" set OPTION = '-O2 -extend-source -convert big_endian' set IPLATF = 5 goto retchkplatf else if ( $SELCOMP == "gfortran" ) then if ( ! -X ${SELCOMP} ) then echo " ${IO}: ${SELCOMP} non available on this system. Exiting..." exit endif alias f90 gfortran ; set COMP = "gfortran" set OPTION = '-ffixed-line-length-132 -fconvert=big-endian -w -Wno-tabs -O2' set IPLATF = 5 goto retchkplatf else echo " ${IO}: compiler ${SELCOMP} not available on this machine, exiting..." exit endif set COMP = "f90" if ( `uname -a | grep alpha | wc -l` > 0 ) then set OPTION = ' -convert big_endian -extend_source' set IPLATF = 1 else if ( `uname -a | grep SunOS | wc -l` > 0 ) then set OPTION = ' -silent -e' # -silent is unknown for f90 set OPTION = ' -e' set IPLATF = 2 else if ( `uname -a | grep IRIX64 | wc -l` > 0 ) then # set OPTION = ' -n32 -pfa -mpio -mp -Ofast ' set OPTION = ' -n32 -Ofast -extend_source' set IPLATF = 3 else if ( `uname -a | grep AIX | wc -l` > 0 ) then set OPTION = ' -q64 ' set AROPT = ' -X 64 ' set IPLATF = 4 echo " Preprocessing source files for IBM AIX Platform." ./ibmsources set FILES = `ls *.f` foreach FILE ( $FILES ) ./ibmsources.exe $FILE end /bin/rm ./ibmsources.exe alias f90 xlf set COMP = "xlf" else if ( `uname -a | grep Linux | wc -l` > 0 ) then if ( -X gfortran ) then alias f90 gfortran ; set COMP = "gfortran" set OPTION = \ ' -ffixed-line-length-132 -fconvert=big-endian -w -Wno-tabs -O2' # set NOLTIME = 'true' else if ( -X ifort ) then alias f90 ifort ; set COMP = "ifort" set OPTION = ' -O2 -extend-source -convert big_endian' else if ( -X pgf90 ) then alias f90 pgf90 ; set COMP = "pgf90" set OPTION = ' -silent -Mextend -byteswapio ' endif set IPLATF = 5 else echo " Unknown HW/SW Platform. Exiting ..." exit endif # Alla ricerca delle ncarlib set NCARLIB = ' ' foreach JDIR ( /usr/lib /usr/local/lib /usr/local/ncarg /usr/local/ncarg/lib \ $HOME/../verdecch/ncarg/lib/ $HOME/ncarg $HOME/ncarg/lib \ ./ncarg ./ncarg/lib ) if ( -f $JDIR/libncarg.a ) then set NCARLIB = " -L$JDIR -lncarg -lncarg_gks -lncarg_c " setenv NCARG_ROOT $JDIR endif end # Alla ricerca delle mvlib set MVLIB = " " if ( -f /usr/local/lib/libmv.a ) set MVLIB = " -L/usr/local/lib -lmvgraf -lncaruti -lmv" if ( -f ./libmv.a ) set MVLIB = " -L. -lmvgraf -lncaruti -lmv" if ( -f /usr/local/ncarg/lib/libmv.a ) set MVLIB = " -L/usr/local/ncarg/lib -lmvgraf -lncaruti -lmv" if ( -f $HOME/../verdecch//mvlib/lib/$IPLATF/libmv.a ) set MVLIB = " -L$HOME/../verdecch//mvlib/lib/$IPLATF/ -lmvgraf -lncaruti -lmv" if ( -f $HOME/mvlib/lib/$IPLATF/libmv.a ) set MVLIB = " -L$HOME/mvlib/lib/$IPLATF/ -lmvgraf -lncaruti -lmv" if ( -f ./libchym.a ) set MVLIB = " -L. -lchym " set JETNET = ' ' foreach JDIR ( $HOME/../verdecch/mvlib/lib/$IPLATF /usr/local/lib \ /usr/lib $HOME/mvlib/lib/$IPLATF ) if ( -f $JDIR/libjetnet20.a ) set JETNET = " -L$JDIR -ljetnet20" if ( -f $JDIR/jetnet20.a ) set JETNET = " $JDIR/jetnet20.a" end goto retchkplatf