#!/bin/csh set IO = `basename $0` # #------------------------------------------------------- Fortran Code --------- cat >! ${IO}.f << FINEF90 implicit none real d,a0,b0,xs,ys,alpha,beta,betas,cvdeg2rad,lplane real ay,by,x1,y1,x2,y2,a1,b1,a2,b2,cvrad2deg integer i ; character stitle*64 logical zoom ; data zoom /.false./ call mvsetflags('Palette di colori',7.0) call mvsetflags('Logo',2.0) d=700. ! Distanza sorgente alpha=60 ; alpha=cvdeg2rad(alpha) ! Angolo sorgente al centro xs=d*cos(alpha) ; ys=d*sin(alpha) ! Coordinate sorgente a0=0 ; b0=tan(alpha) ! Parametri linea centrale beta= 2 ; ! Angolo piano riflessione lplane=45.0 ! Larghezza del piano if (zoom) then call plottaframe(-20.0,20.0,-5.0,35.0) write(stitle,'(a,i2,a)')'Zoom view - Plane angle =',nint(beta),' deg' else call plottaframe(-100.0,650.0,-50.0,700.0) write(stitle,'(a,i2,a)') 'Plane angle=',nint(beta),' deg' endif beta=cvdeg2rad(beta) call gslwsc(2.0) call gsplci(6) call linea(0.0,0.0,xs,ys) call gsplci(7) do i=-45,45,10 call linearparam(float(i),0.0,xs,ys,a1,b1) x1=float(i) ; x2=xs ; call linea(x1,a1+b1*x1,x2,a1+b1*x2) enddo call linearparam( 5.0,0.0,xs,ys,a2,b2) call gsplci(9) ; call gslwsc(5.0) ay=0 ; by=tan(beta) x1=-lplane ; x2=lplane ; call linea(x1,ay+by*x1,x2,ay+by*x2) call displayexample('$IO','Bob Nerini Light path',stitle) call intersection(a2,b2,ay,by,x1,y1) call angleestimation(a2,b2,x1,betas) write(6,'(10x,a,f10.7)') ' True angle: ',cvrad2deg(beta) write(6,'(10x,a,f10.7)') 'Estimated angle: ',cvrad2deg(betas) end subroutine angleestimation(a,b,x,beta) implicit none real a,b,x,beta,y y=a+b*x beta=atan(y/x) return end subroutine intersection(a1,b1,a2,b2,x,y) implicit none real a1,b1,a2,b2,x,y x=-(a1-a2)/(b1-b2) y=a1+b1*x return end subroutine linearparam(x1,y1,x2,y2,a,b) implicit none real x1,y1,x2,y2,a,b b=(y1-y2)/(x1-x2) a=y1-b*x1 return end real function cvrad2deg(alpha) cvrad2deg=45.*alpha/atan(1.) return end real function cvdeg2rad(alpha) cvdeg2rad=4.*atan(1.)*alpha/180. 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