module gvariables implicit none real(8),parameter::pi=3.14159265358979323846D0 real(8),parameter::g=9.80665D0 !Gravity acceleration integer,parameter::N=10 !Number of study cases for diameter of shaft character(len=256)::Title !Title (input data) real(8)::Hg ! Total head (input data) real(8)::Q0 ! Max.discharge (input data) real(8)::L ! Length of pressure tunnel (input data) real(8)::c ! Head loss coefficient (input data) real(8)::Cd ! Discharge coefficient of port (input data) real(8)::zm ! Max.water level (input data) real(8)::d0 ! Diameter of pressure tunnel (input data) real(8)::xc ! Chosen diameter of port real(8)::yc ! Chosen diameter of shaft real(8)::zc ! Max.water level of shaft with chosen diameter real(8)::R_DFC2 ! Min.diameter of shaft defined by dynamic stability real(8)::DF(1:N) ! Diameter of shaft (array for case study) real(8)::zmax(1:N) ! Max.water level (array for case study) real(4)::draw_xmin,draw_xmax,draw_dx real(4)::draw_ymin,draw_ymax,draw_dy end module gvariables program f90_surgeSCVF !********************************************* ! Stability and Max.Water level of surge tank !********************************************* use gvariables implicit none character(len=100)::fnameR !Input data file character(len=100)::fnameF_SC !Drawing (eps) file name for SC character(len=100)::fnameF_VF !drawing (eps) file name for VF call getarg(1,fnameR) call getarg(2,fnameF_SC) call getarg(3,fnameF_VF) open(11,file=fnameR,status='old') read(11,'(a)') Title read(11,'()') read(11,*) Hg,Q0,L,d0,c,Cd,zm,xc,yc close(11) call CAL_SC() call PLOT_SC(fnameF_SC) call CAL_VF() call PLOT_VF(fnameF_VF) write(6,*) 'End of calculation.' stop contains subroutine CAL_SC() integer::iflag real(8)::fwa,v0 real(8)::h0 ! Head loss of pressure tunnel before interception (h0=c*v0*v0) real(8)::k0 ! Resistance of port at interception real(8)::DFC1,DFC2,DFC3 ! Diameter of shaft (critical value) real(8)::Fsa ! Section area of shaft real(8)::Fpa ! Section area of port real(8)::d2,d2min,d2max,d2d ! Study range of diameter of port ! Stability condition fwa=0.25D0*pi*d0*d0 v0=Q0/fwa h0=c*v0*v0 Fsa=L*fwa/c/2.0D0/g/(Hg-zm) DFC2=sqrt(4.0D0*Fsa/pi) R_DFC2=DFC2 d2min=0.1D0 d2max=dble(int(DFC2+1.0)) d2d=0.1D0 open(12, file='temp_SC.csv', status='replace') write(12,'(a)') '#d2,k0-h0,DFC1,DFC2,DFC3' d2=d2min-d2d iflag=-1 do while(d2 D{/=10 1}", \' write(12,'(a)') '"temp_SC.csv" using 1:4 with lines linewidth 3 linetype 1 title "D{/=10 req} > D{/=10 2}", \' write(12,'(a)') '"temp_SC.csv" using 1:5 with lines linewidth 3 linetype 2 title "D{/=10 req} < D{/=10 3}", \' write(12,'(a)') '"-" with points pointsize 2 pointtype 7 title "Selected point"' write (dummy1,'(f8.3)') xc write (dummy2,'(f8.3)') yc linebuf=dummy1//','//dummy2 write(12,'(a)') trim(adjustl(linebuf)) write(12,'(a)') 'e' close(12) !************************** !Execute gnuplot !************************** call system('gnuplot "gpl_temp_SC.txt"') end subroutine PLOT_SC subroutine PLOT_VF(fnameF_VF) !****************************** !Make script file for gnuplot (VF) !****************************** character(len=100),intent(in)::fnameF_VF !drawing (eps) file name for VF character(len=1000)::linebuf character(len=100)::dummys character(len=50)::dummy1,dummy2,sloc real(4)::xx,yy integer::i,k open(12, file='gpl_temp_VF.txt', status='replace') write(12,'(a)') 'set terminal postscript eps enhanced font "Helvetica" 16' linebuf='set output "'//trim(adjustl(fnameF_VF))//'"' write(12,'(a)') trim(adjustl(linebuf)) write(12,'(a)') 'set datafile separator ","' write(12,'(a)') 'set size ratio 1.0' if(0