Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
9
3.83M
C$Procedure TYEAR ( Seconds per tropical year ) DOUBLE PRECISION FUNCTION TYEAR () C$ Abstract C C Return the number of seconds in a tropical year. C C$ Disclaimer C C THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE C CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. C GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE C ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE C PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" C TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY C WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A C PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC C SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE C SOFTWARE AND RELATED MATERIALS, HOWEVER USED. C C IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA C BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT C LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, C INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, C REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE C REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. C C RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF C THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY C CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE C ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. C C$ Required_Reading C C None. C C$ Keywords C C CONSTANTS C C$ Declarations C C None. C C$ Brief_I/O C C VARIABLE I/O DESCRIPTION C -------- --- -------------------------------------------------- C TYEAR O The number of seconds/tropical year C C$ Detailed_Input C C None. C C$ Detailed_Output C C The function returns the number of seconds per tropical C year. This value is taken from the 1992 Explanatory Supplement C to the Astronomical Almanac. C C$ Parameters C C None. C C$ Particulars C C The tropical year is often used as a fundamental unit C of time when dealing with older ephemeris data. For this C reason its value in terms of ephemeris seconds is C recorded in this function. C C$ Examples C C Suppose you wish to compute the number of tropical centuries C that have elapsed since the ephemeris epoch B1950 (beginning C of the Besselian year 1950) at a particular ET epoch. The C following line of code will do the trick. C C C CENTRY = ( ET - UNITIM ( B1950(), 'JED', 'ET' ) ) C . / ( 100.0D0 * TYEAR() ) C C C$ Restrictions C C None. C C$ Exceptions C C Error free. C C$ Files C C None. C C$ Author_and_Institution C C W.L. Taber (JPL) C C$ Literature_References C C Explanatory Supplement to the Astronomical Almanac. C Page 80. University Science Books, 20 Edgehill Road, C Mill Valley, CA 94941 C C$ Version C C- SPICELIB Version 1.0.0, 13-JUL-1993 (WLT) C C-& C$ Index_Entries C C Number of seconds per tropical year C C-& TYEAR = 31556925.9747D0 RETURN END
SUBROUTINE MERGE (IRP,ICP,CORE) C C MERGE WILL PUT UP TO 4 MATRICES, IA11,IA21,IA12,IA22, TOGETHER C INTO NAMEA -- THIS ROUTINE IS THE INVERSE OF PARTN C C THE ARGUMENTS ARE EXACTLY THE SAME IN MEANING AND OPTION AS FOR C PARTITION C IMPLICIT INTEGER (A-Z) EXTERNAL RSHIFT,ANDF DIMENSION IRP(1),ICP(1),A11(4),B11(4), 1 CORE(1),BLOCK(40),NAME(2) COMMON /PARMEG/ NAMEA,NCOLA,NROWA,IFORMA,ITYPA,IA(2), 1 IA11(7,4),LCARE,RULE COMMON /SYSTEM/ SYSBUF,NOUT COMMON /TWO / TWO1(32) COMMON /ZBLPKX/ IC11(4),II DATA NAME / 4HMERG,4HE / C C CHECK FILES C LCORE = IABS(LCARE) K = NAMEA DO 15 I = 1,4 IF (K .EQ. 0) GO TO 15 DO 10 J = I,4 IF (IA11(1,J) .EQ. K) GO TO 440 10 CONTINUE 15 K = IA11(1,I) C C PICK UP PARAMETERS AND INITIALIZE C IREW = 0 IF (LCARE .LT. 0) IREW = 2 NCOLA1= NCOLA NCOLA = 0 IA(1) = 0 IA(2) = 0 ISTOR = 0 IOTP = ITYPA NMAT = 0 DO 30 I = 1,4 IF (IA11(1,I) .LE. 0) GO TO 30 CWKBD 2/94 SPR93025 IF (IA11(5,I) .NE. ITYPA) IOTP = 4 NMAT = NMAT + 1 DO 20 J = 2,5 IF (IA11(J,I) .EQ. 0) GO TO 460 20 CONTINUE 30 CONTINUE NTYPA = IOTP IF (NTYPA .EQ. 3) NTYPA = 2 IBUF = LCORE - SYSBUF + 1 IBUFCP = IBUF - NROWA IF (IBUFCP) 420,420,40 40 LCORE = IBUFCP - 1 CALL RULER (RULE,ICP,ZCPCT,OCPCT,CORE(IBUFCP),NROWA,CORE(IBUF),1) IF (IRP(1).EQ.ICP(1) .AND. IRP(1).NE.0) GO TO 60 IBUFRP = IBUFCP - (NCOLA1+31)/32 IF (IBUFRP) 420,420,50 50 CALL RULER (RULE,IRP,ZRPCT,ORPCT,CORE(IBUFRP),NCOLA1,CORE(IBUF),0) LCORE = IBUFRP - 1 GO TO 70 60 ISTOR = 1 C C OPEN INPUT FILES C 70 IF (LCORE-NMAT*SYSBUF .LT. 0) GO TO 420 DO 100 I = 1,4 IF (IA11(1,I)) 90,100,80 80 LCORE = LCORE - SYSBUF CALL OPEN (*90,IA11(1,I),CORE(LCORE+1),IREW) CALL SKPREC (IA11(1,I),1) GO TO 100 90 IA11(1,I) = 0 100 CONTINUE C C OPEN OUTPUT FILE C CALL GOPEN (NAMEA,CORE(IBUF),1) C C FIX POINTERS -- SORT ON ABS VALUE C K = IBUFCP - 1 L = IBUFCP DO 120 I = 1,NROWA K = K + 1 IF (CORE(K)) 110,120,120 110 CORE(L) = I L = L + 1 120 CONTINUE M = L - 1 K = IBUFCP DO 160 I = 1,NROWA 130 IF (CORE(K)-I) 150,160,140 140 CORE(L) = I L = L + 1 GO TO 160 150 IF (K .EQ. M) GO TO 140 K = K + 1 GO TO 130 160 CONTINUE C C LOOP ON COLUMNS OF OUTPUT C KM = 0 L2 = IBUFCP L3 = IBUFCP + ZCPCT DO 390 LOOP = 1,NCOLA1 CALL BLDPK (IOTP,ITYPA,NAMEA,0,0) IF (ISTOR .EQ. 1) GO TO 190 J = (LOOP-1)/32 + IBUFRP KM = KM + 1 IF (KM .GT. 32) KM = 1 ITEMP = ANDF(CORE(J),TWO1(KM)) IF (KM .EQ. 1) ITEMP = RSHIFT(ANDF(CORE(J),TWO1(KM)),1) IF (ITEMP .NE. 0) GO TO 180 C C IA11 AND IA21 BEING USED C 170 L1 = 0 IF (L2 .EQ. L3-1) GO TO 200 L2 = L2 + 1 GO TO 200 C C IA12 AND IA22 BEING USED C 180 L1 = 2 L3 = L3 + 1 GO TO 200 C C USE ROW STORE C 190 IF (CORE(L2) .EQ. LOOP) GO TO 170 IF (CORE(L3) .EQ. LOOP) GO TO 180 GO TO 460 C C BEGIN ON SUBMATRICES C 200 IO = 0 DO 220 J = 1,2 K = L1 + J IF (IA11(1,K)) 210,220,210 210 M = 20*J - 19 CALL INTPK (*220,IA11(1,K),BLOCK(M),IOTP,1) IO = IO + J 220 CONTINUE IF (IO) 230,380,230 C C PICK UP NON ZERO C 230 IEOL = 0 JEOL = 0 IPOS = 9999999 JPOS = 9999999 IAZ = 1 IBZ = 1 NAM1 = IA11(1,L1+1) NAM2 = IA11(1,L1+2) IF (IO-2) 240,280,240 240 IAZ = 0 250 IF (IEOL) 370,260,370 260 CALL INTPKI (A11(1),I,NAM1,BLOCK(1),IEOL) K = IBUFCP + I - 1 IPOS = CORE(K) IF (IO .EQ. 1) GO TO 310 IO = 1 280 IBZ = 0 290 IF (JEOL) 340,300,340 300 CALL INTPKI (B11(1),J,NAM2,BLOCK(21),JEOL) K = IBUFCP + ZCPCT + J - 1 JPOS = CORE(K) 310 IF (IPOS-JPOS) 350,320,320 C C PUT IN B11 C 320 DO 330 M = 1,NTYPA 330 IC11(M) = B11(M) II = JPOS CALL ZBLPKI GO TO 290 340 JPOS = 9999999 IBZ = 1 IF (IAZ+IBZ .EQ. 2) GO TO 380 350 DO 360 M = 1,NTYPA 360 IC11(M) = A11(M) II = IPOS CALL ZBLPKI GO TO 250 370 IAZ = 1 IPOS = 9999999 IF (IAZ+IBZ .NE. 2) GO TO 320 C C OUTPUT COLUMN C 380 CALL BLDPKN (NAMEA,0,NAMEA) C 390 CONTINUE C C DONE -- CLOSE OPEN MATRICES C DO 400 I = 1,4 IF (IA11(1,I) .GT. 0) CALL CLOSE (IA11(1,I),1) 400 CONTINUE CALL CLOSE (NAMEA,1) GO TO 500 C 420 MN = -8 GO TO 480 440 WRITE (NOUT,450) K 450 FORMAT ('0*** SYSTEM OR USER ERROR, DUPLICATE GINO FILES AS ', 1 'DETECTED BY MERGE ROUTINE - ',I5) NM = -37 GO TO 480 460 MN = -7 480 CALL MESAGE (MN,0,NAME) C 500 RETURN END
subroutine HPZFLC C C...fill HEPEVT from zebra banks C IMPLICIT NONE #include "stdhep/stdhep.inc" #include "stdhep/stdlun.inc" #include "stdhep/hepzbr.inc" integer I,J,K,LL,KK C...set everything to zero NEVHEP = 0 NHEP = 0 do 120 J=1,NMXHEP ISTHEP(J)=0 IDHEP(J)=0 do 100 K=1,2 JMOHEP(K,J)=0 100 JDAHEP(K,J)=0 do 105 K=1,5 105 PHEP(K,J)=0. do 110 K=1,4 110 VHEP(K,J)=0. 120 CONTINUE C...unpack and fill HEPEVT NEVHEP=IQ(LE1+1) NHEP=IQ(LE1+2) if(NHEP.GT.0)then do 200 I=1,NHEP LL=LQ(LE1-1) ISTHEP(I)=IQ(LL+I) LL=LQ(LE1-2) IDHEP(I)=IQ(LL+I) LL=LQ(LE1-3) JMOHEP(1,I)=IQ(LL+I) JMOHEP(2,I)=IQ(LL+NHEP+I) LL=LQ(LE1-4) JDAHEP(1,I)=IQ(LL+I) JDAHEP(2,I)=IQ(LL+NHEP+I) LL=LQ(LE1-5) do 170 K=1,5 KK=LL+NHEP*(K-1)+I 170 PHEP(K,I)=Q(KK) LL=LQ(LE1-6) do 180 K=1,4 KK=LL+NHEP*(K-1)+I 180 VHEP(K,I)=Q(KK) 200 CONTINUE endif return end
program bodedrv implicit double precision(a-h,o-z),integer(i-n) external xsin parameter (idimv=1) dimension a(idimv),b(idimv) a(1)=0.d0 b(1)=3.141592653589792d0 ivar=1 print*,ivar print*,a print*,b print* call bode(idimv,xsin,ivar,a,b,dinteg,iflag) print*,dinteg print*,iflag call simpson(idimv,xsin,ivar,a,b,dinteg,iflag) print*,dinteg print*,iflag call simps38(idimv,xsin,ivar,a,b,dinteg,iflag) print*,dinteg print*,iflag ! call b3(idimv,a,xsin) ! call xsin(idimv,a,fa) ! call bodestep(idimv,xsin,ivar,a,fa,b,fb,dstep,iflag) ! print*,a,fa ! print*,b,fb ! print*,dstep ! print*,iflag stop end subroutine xsin(idimv,x,dres) implicit double precision(a-h,o-z),integer(i-n) dimension x(idimv) dres=dsin(x(1)) return end subroutine b3(idimv,a,func) implicit double precision (a-h,o-z),integer(i-n) external func call func(idimv,a,dres) print*,'b3: dres=',dres return end
!----------------------- ! madgraph - a Feynman Diagram package by Tim Stelzer and Bill Long ! (c) 1993 ! ! Filename: drawfeyn.f !----------------------- !************************************************************************* ! This file contains routines for generating ps files for the Feynman ! diagrams. !************************************************************************* Subroutine PositionVerts(graphs,tops,igraph,next) !************************************************************************* ! For graph i determine an asthetic placement of the vertices and ! external lines. Basic idea is to minimize Sum(length^2) of all lines !************************************************************************* implicit none ! Constants include 'params.inc' ! Arguments integer graphs(0:maxgraphs,0:maxlines) integer tops(0:4,0:maxnodes,0:maxtops),next integer igraph ! Local Variables integer nverts,ntop integer i,iy,xoff,yoff,nden,j integer jline(-maxlines:maxlines,2) integer c(-maxlines:maxnodes,maxrows) integer lnum,ivert,nlines real xshift,yshift,x1,x2,y1,y2,ypos(maxlines) logical done real pverts(-maxlines:maxlines,2),goodverts(-maxlines:maxlines,2) integer perms(maxrows,maxcols),k(maxrows),count,iter real mysum,minsum integer rows,irow,icol,pgraph,npage,jdir integer n_incoming real xscale,yscale !Scaling factors for diagrams real m1,m3,xint,x3,x4,y3,y4 !used to see if lines cross real dx2, dy2, minlength !Used to avoid line getting too short logical crossed ! Global Variables character*(max_string) iwave(max_particles),owave(max_particles) integer iposx(3,max_particles) integer info_p(5,max_particles) character*(8) str(3,max_particles) common/to_external/iwave,owave,iposx,info_p,str integer iline(-maxlines:maxlines),idir(-maxlines:maxlines) integer this_coup(max_coup) ,goal_coup(max_coup) common/to_proc/iline,idir,this_coup,goal_coup character*60 proc integer iproc common/to_write/iproc,proc character*(4*max_particles) particle(4) integer charge_c(max_particles) integer iparticle(0:max_particles,0:4),inverse(max_particles) common/to_model/iparticle, particle, inverse, charge_c !----------- ! Begin Code !----------- minlength = 0. c c determine x and y scale for each diagram using historical c value that scale=0 when graphs_per_row = 3 and c rows_per_page=5 c xscale = scale*3.0/graphs_per_row yscale = scale*5.0/rows_per_page ! Initialize things do i=1,maxlines iline(-i) = graphs(igraph,i) enddo pgraph = mod(igraph-1,graphs_per_page)+1 if (pgraph .eq. 1) then npage = (igraph-1)/graphs_per_page + 1 c print*,'New page',npage xoff = graphs_per_row*15*xscale yoff = (rows_per_page*15)*yscale if (npage .gt. 1) write(4,'(a)') 'showpage' write(4,'(a,2I8)') '%%Page:',npage,npage write(4,'(a)') '%%PageBoundingBox:-20 -20 600 800' write(4,'(a)') '%%PageFonts: Helvetica' write(4,'(a)') '/Helvetica findfont 10 scalefont setfont' write(4,*) xoff/2+15,yoff+20,' moveto' write(4,'(a)') '(Diagrams by MadGraph) show' write(4,*) xoff/2+145,yoff+20,' moveto' write(4,'(a,a,a)') '(',proc(2:iproc), ') show' endif icol = mod(pgraph-1,graphs_per_row) irow = rows_per_page-int((pgraph-1)/graphs_per_row)-1 xoff = icol*15*xscale+100 yoff = irow*15*yscale+50 c c Incoming particles c n_incoming = 2 if (n_incoming .eq. 1) then pverts(-1,1) = 0 pverts(-1,2) = 10 else pverts(-1,1) = 0 pverts(-1,2) = 10 pverts(-2,1) = 0 pverts(-2,2) = 0 endif iy = 10 do i=3,next !Final leg positions ypos(i-2)=iy if (next .eq. 3) then ypos(1) = 5 else iy = iy - 10./(next-3) endif enddo ntop = graphs(igraph,0) nverts = tops(1,0,ntop) ! Determine which vertices are connected set up C(iline,ivert) do i=-maxlines,maxlines jline(i,1)=0 jline(i,2)=0 enddo do i=1,next jline(i,1) =-i jline(i,2) =-i enddo do ivert = 1,nverts nlines = tops(0,ivert,ntop) do i = 1,nlines lnum=tops(i,ivert,ntop) if (jline(lnum,1) .eq. 0) then jline(lnum,1) = i jline(lnum,2) = ivert elseif (jline(lnum,1) .lt. 0) then C(i,ivert) = jline(lnum,2) != -lnum jline(lnum,1) = ivert else C(i,ivert) = jline(lnum,2) C(jline(lnum,1),jline(lnum,2))= ivert jline(lnum,1) = ivert endif enddo enddo ! Loop over all configurations of final legs orders do i=1,next-2 k(i)=i enddo count=0 if (next .eq. 3) then rows=1 count=1 perms(1,1)=1 elseif (next .eq. 4) then rows = 2 call perm2(k,perms,rows,count) elseif (next .eq. 5) then rows = 3 call perm3(k,perms,rows,count) elseif (next .eq. 6) then rows = 4 call perm4(k,perms,rows,count) elseif (next .eq. 7) then rows = 5 call perm5(k,perms,rows,count) elseif (next .eq. 8) then rows = 6 call perm6(k,perms,rows,count) elseif (next .eq. 9) then rows = 7 call perm7(k,perms,rows,count) c elseif (next .eq. 10) then c rows = 8 c call perm8(k,perms,rows,count) else write(*,*) 'Warning from drawfeyn.f too many permutations.', & ' Graphs might not look very good.' endif minsum = -1 do iter=1,count do i=3,next !Final state particles if (next .le. 4) then pverts(-i,1)=10 elseif(next .eq. 5) then pverts(-i,1)=9 c elseif(next .eq. 6) then c pverts(-i,1)=8 c elseif(next .eq. 7) then c pverts(-i,1)=7 else pverts(-i,1)=8 endif pverts(-i,2)=ypos(perms(i-2,iter)) enddo ! Guess initial values for vertices, neg = external do ivert=1,nverts pverts(i,1)=0. pverts(i,2)=0. enddo do ivert=1,nverts xshift = 0 yshift = 0 nlines = tops(0,ivert,ntop) nden=0 do i=1,nlines if (c(i,ivert) .lt. 0) then !This is external xshift = xshift + pverts(c(i,ivert),1) yshift = yshift + pverts(c(i,ivert),2) nden=nden+1 endif enddo if (nden .gt. 0) then pverts(ivert,1)=xshift/nden pverts(ivert,2)=yshift/nden else pverts(ivert,1)=-1 pverts(ivert,2)=-1 !These are unassigned to start endif c write(*,*) ivert,pverts(ivert,1),pverts(ivert,2) enddo ! Now try to order done=.false. do while (.not. done) done=.true. do ivert=1,nverts xshift = 0 yshift = 0 nlines = tops(0,ivert,ntop) nden = 0 do i=1,nlines if (pverts(c(i,ivert),1) .ge. 0) then !This has been assigned nden = nden +1 xshift = xshift + pverts(c(i,ivert),1) yshift = yshift + pverts(c(i,ivert),2) c write(*,*) i, pverts(c(i,ivert),1) endif c write(*,*) 'shift ',ivert,xshift,yshift c $ ,pverts(c(i,ivert),1) enddo if (nden .gt. 0) then xshift=xshift/nden yshift=yshift/nden if (abs(pverts(ivert,1)-xshift) .gt. .1) done=.false. if (abs(pverts(ivert,2)-yshift) .gt. .1) done=.false. pverts(ivert,1)=xshift pverts(ivert,2)=yshift c write(*,*) 'opt ',ivert,pverts(ivert,1),pverts(ivert,2) else done=.false. endif enddo enddo c c Minimize total line length^2 c mysum = 0 do i=1,next dx2 = (pverts(jline(i,1),1)-pverts(jline(i,2),1))**2 dy2 = (pverts(jline(i,1),2)-pverts(jline(i,2),2))**2 mysum=mysum + dx2 + dy2 if (sqrt(dx2 + dy2) .lt. minlength) mysum = mysum+minlength**2 c if (sqrt(dx2 + dy2) .lt. minlength) mysum = mysum+9999 c mysum=mysum + enddo do i=1,nverts-1 dx2 = (pverts(jline(-i,1),1)-pverts(jline(-i,2),1))**2 dy2 = (pverts(jline(-i,1),2)-pverts(jline(-i,2),2))**2 mysum=mysum + dx2 + dy2 if (sqrt(dx2 + dy2) .lt. minlength) mysum = mysum+minlength**2 c if (sqrt(dx2 + dy2) .lt. minlength) mysum = mysum+9999 c mysum=mysum + c mysum=mysum + enddo c c Make sure final external lines don't cross line1=(x1,y1)->(x2,y2) c by finding intersection and seeing if its in region graphed c c i=3 i=1-nverts crossed=.false. do while (i .le. next .and. .not. crossed) j=i+1 if (j.eq. 0) j=1 do while (j .le. next .and. .not. crossed) c write(*,*) i,j x1 = pverts(jline(i,1),1) x2 = pverts(jline(i,2),1) y1 = pverts(jline(i,1),2) y2 = pverts(jline(i,2),2) x3 = pverts(jline(j,1),1) x4 = pverts(jline(j,2),1) y3 = pverts(jline(j,1),2) y4 = pverts(jline(j,2),2) c c See if the share a vertex. If so, don't worry about crossing c if ( ((x1.eq.x3).and.(y1.eq.y3)) .or. & ((x1.eq.x4).and.(y1.eq.y4)) .or. & ((x2.eq.x3).and.(y2.eq.y3)) .or. & ((x2.eq.x4).and.(y2.eq.y4)) ) then crossed=.false. else m1 = (y2-y1)/((x2-x1)+.00001) m3 = (y4-y3)/((x4-x3)+.00001) if (m1 .ne. m3) then xint = ((y1-y3)+(m3*x3-m1*x1))/(m3-m1) c write(*,'(a,4f8.0)') 'x1,y1,x2,y2 ',x1,y1,x2,y2 c write(*,'(a,4f8.0)') 'x3,y3,x4,y4 ',x3,y3,x4,y4 c write(*,'(a,4f8.0)') 'xint ',xint else xint = -9999 !Parallel lines, don't intersect endif if (xint .lt. max(x1,x2)+.1.and. xint.gt. min(x1,x2)-.1.and. & xint .lt. max(x3,x4)+.1.and. xint.gt. min(x3,x4)-.1)then crossed=.true. mysum = 2*mysum endif endif j=j+1 if (j.eq. 0) j=1 enddo i=i+1 if (i.eq. 0) i=1 enddo if (mysum .ge. 999999) then print*,'Warning mysum is large',mysum endif if (mysum .gt. 0 .or. minsum .eq. -1) then if (mysum .lt. minsum .or. minsum .lt. 0) then c write(*,*) 'Good',mysum minsum = mysum do i=-maxlines,maxlines goodverts(i,1) = pverts(i,1) goodverts(i,2) = pverts(i,2) enddo endif endif enddo !iteration c write(*,*) igraph,minsum c c Here it would be good to add special case for s-channel c processes. They look best if propagator is horizontal. c c write(*,*) 'Done' do i=-maxlines,maxlines pverts(i,1) = goodverts(i,1) pverts(i,2) = goodverts(i,2) enddo if (minsum .eq. 99999) then print*,'Warning graph not drawn',igraph return endif do i=3,next pverts(-i,1) = 10 enddo do i=1,next !Draw external lines x1 = xscale*pverts(jline(i,1),1)+xoff y1 = yscale*pverts(jline(i,1),2)+yoff x2 = xscale*pverts(jline(i,2),1)+xoff y2 = yscale*pverts(jline(i,2),2)+yoff c jdir=+1 c if (inverse(iline(i)) .lt. iline(i)) jdir=-1 jdir = inverse(iline(i)) - iline(i) c write(*,*) 'Line', i,jdir if (i .le. 2) jdir=-jdir if (i .le. 2) then call drawline(x2,y2,x1,y1,info_p(4,iline(i)),jdir, $ str(1,inverse(iline(i)))) else call drawline(x1,y1,x2,y2,info_p(4,iline(i)),jdir, $ str(1,iline(i))) endif enddo do i=1,nverts-1 x1 = xscale*pverts(jline(-i,1),1)+xoff y1 = yscale*pverts(jline(-i,1),2)+yoff x2 = xscale*pverts(jline(-i,2),1)+xoff y2 = yscale*pverts(jline(-i,2),2)+yoff c jdir=1 c if (inverse(iline(-i)) .lt. iline(-i)) jdir=-1 jdir = inverse(iline(-i)) - iline(-i) call drawline(x1,y1,x2,y2,info_p(4,graphs(igraph,i)),jdir, $ str(1,graphs(igraph,i))) enddo write(4,*) xoff+4*xscale,yoff-yscale,' moveto' write(4,'(a,i4,a)') '(graph ',igraph,') show' write(4,*) xoff-xscale,yoff+10*yscale,' moveto' write(4,*) '(1) show' write(4,*) xoff-xscale,yoff-2,' moveto' write(4,*) '(2) show' do i=3,next !Label final lines numbers write(4,*) xoff+10*xscale,yoff+yscale*pverts(-i,2),' moveto' write(4,'(a,i3,a)') '(',i,') show' enddo end Subroutine drawline(x1,y1,x2,y2,itype,jdir,name) !*************************************************************************** ! Routine to draw postscript for feynman diagram line ! from x1,y1 to x2,y2 with appropriate label !*************************************************************************** implicit none ! Arguments real x1,y1,x2,y2,dx,dy,d integer itype,jdir character*5 name ! Local Variables !----------- ! Begin Code !----------- d = sqrt((x1-x2)**2+(y1-y2)**2) if (d .gt. 0) then dx = (x1-x2)/d dy = (y1-y2)/d else write(*,*) 'Error zero line length ',name return endif if (dy .lt. 0) then dy=-dy dx=-dx endif if (itype .eq. 4) then write(4,*) x1,y1,x2,y2,' 0 Fgluon' elseif (itype .eq. 2) then if (jdir .gt. 0) then write(4,*) x1,y1,x2,y2,' Ffermion' elseif (jdir .lt. 0) then write(4,*) x2,y2,x1,y1,' Ffermion' else write(4,*) x1,y1,' moveto' write(4,*) x2,y2,' lineto' endif elseif(itype .eq. 3) then c c The top two should be fhiggsd, not fhiggs c if (jdir .gt. 0) then write(4,*) x1,y1,x2,y2,' Fhiggs' elseif (jdir .lt. 0) then write(4,*) x2,y2,x1,y1,' Fhiggs' else write(4,*) x1,y1,x2,y2,' Fhiggs' endif elseif (itype .eq. 1) then if (jdir .gt. 0) then write(4,*) x1,y1,x2,y2,' 0 Fphotond' elseif (jdir .lt. 0) then write(4,*) x2,y2,x1,y1,' 0 Fphotond' else write(4,*) x1,y1,x2,y2,' 0 Fphoton' endif c write(4,*) x1,y1,x2,y2,' 0 Fphotond' else write(*,*) 'Unknown Feynman line, using photon.',itype write(4,*) x1,y1,x2,y2,' 0 Fphoton' endif write(4,*) (x1+x2)/2.+5.*dy, (y1+y2)/2.-5.*dx-4., ' moveto' write(4,'(3a)') '(',name,') show' end
program TBEEP c to test spindrift beep etc integer if(2,10) c 2 call beep pause call BELL(3) !test new version pause print 1 1 format(' ifreq1,ifreq2 = ') read *,ifreq1,ifreq2 if(ifreq1.eq.0) STOP call tone(ifreq1,50) pause call tone2(ifreq1,ifreq2,50) pause n=1 if(1,n)=500 !=freq if(2,n)=8 !=duration n=n+1 if(1,n)=0 !=freq if(2,n)=3 !=duration n=n+1 if(1,n)=500 !=freq if(2,n)=8 !=duration n=n+1 if(1,n)=0 !=freq if(2,n)=3 !=duration n=n+1 if(1,n)=500 !=freq if(2,n)=8 !=duration n=n+1 if(1,n)=0 !=freq if(2,n)=3 !=duration n=n+1 if(1,n)=410 !=freq if(2,n)=50 !=duration c n=5 call TUNE(if,n) pause 4 print 3 3 format(' ifreq2 = ') read *,ifreq2 ifreq1=440 call tone2(ifreq1,ifreq2,50) goto 4 end
! *************** SUBROUTINE FOND ! *************** ! &(ZF ,X,Y,NPOIN,NFON,NBOR,KP1BOR,NPTFR) ! !*********************************************************************** ! BIEF V6P1 21/08/2010 !*********************************************************************** ! !brief INITIALISES THE BOTTOM ELEVATION. ! !history J-M HERVOUET (LNHE) !+ 20/03/08 !+ V5P9 !+ ! !history N.DURAND (HRW), S.E.BOURBAN (HRW) !+ 13/07/2010 !+ V6P0 !+ Translation of French comments within the FORTRAN sources into !+ English comments ! !history N.DURAND (HRW), S.E.BOURBAN (HRW) !+ 21/08/2010 !+ V6P0 !+ Creation of DOXYGEN tags for automated documentation and !+ cross-referencing of the FORTRAN sources ! !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !| KP1BOR |-->| GIVES THE NEXT BOUNDARY POINT IN A CONTOUR !| NBOR |-->| GLOBAL NUMBER OF BOUNDARY POINTS !| NFON |-->| LOGICAL UNIT OF FILE FOR BOTTOM BATHYMETRY !| NPOIN |-->| NUMBER OF POINTS !| NPTFR |-->| NUMBER OF BOUNDARY POINTS !| X |-->| ABSCISSAE OF POINTS IN THE MESH !| Y |-->| ORDINATES OF POINTS IN THE MESH !| ZF |-->| ELEVATION OF BOTTOM !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! USE BIEF, EX_FOND => FOND ! USE DECLARATIONS_SPECIAL IMPLICIT NONE ! !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! INTEGER, INTENT(IN) :: NFON,NPOIN,NPTFR DOUBLE PRECISION, INTENT(OUT) :: ZF(NPOIN) DOUBLE PRECISION, INTENT(IN) :: X(NPOIN),Y(NPOIN) INTEGER, INTENT(IN) :: NBOR(NPTFR),KP1BOR(NPTFR) ! !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! INTEGER NP,ERR ! DOUBLE PRECISION BID ! CHARACTER(LEN=1) C ! DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: XRELV,YRELV,COTE ! !----------------------------------------------------------------------- ! READS THE DIGITISED POINTS ! FROM LOGICAL UNIT NFON !----------------------------------------------------------------------- ! ! ASSESSES THE EXTENT OF DATA ! NP = 0 20 READ(NFON,120,END=24,ERR=124) C 120 FORMAT(A1) IF(C(1:1).NE.'C'.AND.C(1:1).NE.'B') THEN BACKSPACE ( UNIT = NFON ) NP = NP + 1 READ(NFON,*) BID,BID,BID ENDIF GO TO 20 124 CONTINUE IF(LNG.EQ.1) WRITE(LU,18) NP IF(LNG.EQ.2) WRITE(LU,19) NP 18 FORMAT(1X,'FOND (BIEF)' & ,/,1X,'ERREUR DANS LE FICHIER DES FONDS' & ,/,1X,'A LA LIGNE ',I7) 19 FORMAT(1X,'FOND (BIEF)' & ,/,1X,'ERROR IN THE BOTTOM FILE' & ,/,1X,'AT LINE ',I7) CALL PLANTE(1) STOP 24 CONTINUE ! ! DYNAMICALLY ALLOCATES THE ARRAYS ! ALLOCATE(XRELV(NP),STAT=ERR) ALLOCATE(YRELV(NP),STAT=ERR) ALLOCATE(COTE(NP) ,STAT=ERR) ! IF(ERR.NE.0) THEN IF(LNG.EQ.1) WRITE(LU,10) NP IF(LNG.EQ.2) WRITE(LU,11) NP 10 FORMAT(1X,'FOND (BIEF)' & ,/,1X,'ERREUR A L''ALLOCATION DE 3 TABLEAUX' & ,/,1X,'DE TAILLE ',I7) 11 FORMAT(1X,'FOND (BIEF)' & ,/,1X,'ERROR DURING ALLOCATION OF 3 ARRAYS' & ,/,1X,'OF SIZE ',I7) CALL PLANTE(1) STOP ENDIF ! ! READS THE DATA ! REWIND(NFON) NP = 0 23 READ(NFON,120,END=22,ERR=122) C IF(C(1:1).NE.'C'.AND.C(1:1).NE.'B') THEN BACKSPACE ( UNIT = NFON ) NP = NP + 1 READ(NFON,*) XRELV(NP) , YRELV(NP) , COTE(NP) ENDIF GO TO 23 ! 122 CONTINUE IF(LNG.EQ.1) WRITE(LU,12) NP IF(LNG.EQ.2) WRITE(LU,13) NP 12 FORMAT(1X,'FOND (BIEF)' & ,/,1X,'ERREUR DANS LE FICHIER DES FONDS' & ,/,1X,'A LA LIGNE ',I7) 13 FORMAT(1X,'FOND (BIEF)' & ,/,1X,'ERROR IN THE BOTTOM FILE' & ,/,1X,'AT LINE ',I7) CALL PLANTE(1) STOP ! 22 CONTINUE ! IF(LNG.EQ.1) WRITE(LU,112) NP IF(LNG.EQ.2) WRITE(LU,113) NP 112 FORMAT(1X,'FOND (BIEF) :' & ,/,1X,'NOMBRE DE POINTS DANS LE FICHIER DES FONDS : ',I7) 113 FORMAT(1X,'FOND (BIEF):' & ,/,1X,'NUMBER OF POINTS IN THE BOTTOM FILE: ',I7) ! !----------------------------------------------------------------------- ! THE BOTTOM ELEVATION IS COMPUTED BY INTERPOLATION ONTO THE ! DOMAIN INTERIOR POINTS !----------------------------------------------------------------------- ! CALL FASP(X,Y,ZF,NPOIN,XRELV,YRELV,COTE,NP,NBOR,KP1BOR,NPTFR,0.D0) ! !----------------------------------------------------------------------- ! DEALLOCATE(XRELV) DEALLOCATE(YRELV) DEALLOCATE(COTE) ! !----------------------------------------------------------------------- ! RETURN END
subroutine sub2() write(6, *) 'output from sub2.' return end
subroutine LOAD_HEADER( HEADER_TXT, N_TXT ) IMPLICIT NONE CHARACTER( 90 ) :: HEADER_TXT( 200 ) INTEGER :: N_TXT N_TXT = 21 HEADER_TXT( : ) = '' HEADER_TXT( 1:N_TXT ) = (/ & '#================================================================================#', & '#| |#', & '#| The Community Multiscale Air Quality (CMAQ) Model |#', & '#| Version 5.4 |#', & '#| |#', & '#| Built and Maintained by the |#', & '#| Office of Research and Development |#', & '#| United States Environmental Protection Agency |#', & '#| |#', & '#| https://www.epa.gov/cmaq |#', & '#| |#', & '#| Source Code: https://www.github.com/USEPA/cmaq/tree/master |#', & '#| Documentation: https://www.github.com/USEPA/cmaq/tree/master/DOCS |#', & '#| |#', & '#| The CMAQ Model is tested and released with cooperation from |#', & '#| the Community Modeling and Analysis System (CMAS) Center via |#', & '#| contract support. CMAS is managed by the Institute for the |#', & '#| Environment, University of North Carolina at Chapel Hill. |#', & '#| CMAS URL: (https://www.cmascenter.org) |#', & '#| |#', & '#================================================================================#' & /) end subroutine LOAD_HEADER
C C $Id: displa.f,v 1.6 2008-07-27 00:14:36 haley Exp $ C C Copyright (C) 2000 C University Corporation for Atmospheric Research C All Rights Reserved C C The use of this Software is governed by a License Agreement. C SUBROUTINE DISPLA (LFRA,LROW,LTYP) C C The subroutine DISPLA resets the parameters IFRA, IROW, and/or LLUX C and LLUY. C IF (LFRA.NE.0) CALL AGSETI ('FRAM.', MAX(1,MIN(3,LFRA))) C IF (LROW.NE.0) CALL AGSETI ('ROW .',LROW) C IF (LTYP.EQ.0) RETURN C ITYP=MAX(1,MIN(4,LTYP)) CALL AGSETI ('X/LOGA.', (1-ITYP)/2) CALL AGSETI ('Y/LOGA.',MOD(1-ITYP,2)) C RETURN C END
/* tdalgrset.f * MODULE Название Программного Модуля * DESCRIPTION Назначение программы, описание процедур и функций * RUN Способ вызова программы, описание параметров, примеры вызова * CALLER Список процедур, вызывающих этот файл * SCRIPT Список скриптов, вызывающих этот файл * INHERIT Список вызываемых процедур * MENU Перечень пунктов Меню Прагмы * BASES BANK COMM * AUTHOR 31/12/99 pragma * CHANGES 22/08/03 nataly изменен формат aaa.pri , pri.pri c "x(1)" - > "x(3)" 21/07/04 dpuchkov - изменил формат отображения для выплаты проц. 19/01/2011 evseev - изменил формат lgr.dueday с z9 на z99 */ def var v-comiss as char. form lgr.lgr label "Код " format "x(3)" lgr.des label "Описание группы" format "x(40)" lgr.gl label "Сч. Г/К" format "zzzzzz" help "Введите счет Главной книги; F2 - помощь" validate(can-find(gl where gl.gl = lgr.gl and gl.subled = "cif" and gl.level = 1), "Должен быть счет Г/К с подкнигой CIF 1-го уровня!") lgr.crc label "Вал" format "z9" validate(can-find(crc where crc.crc = lgr.crc and crc.sts <> 9) ,"Валюта с таким кодом не существует или закрыта!") help "Введите код валюты; F2 - помощь" lgr.autoext label "КНП" format "zzz" validate(can-find(codfr where codfr.codfr = 'spnpl' and codfr.code = string(lgr.autoext,'999')) and lgr.autoext <> 'msc' ,'Неверное значение кода назначения платежа') help "Введите КНП; F2 - помощь" lgr.tlev label "Тип кл" format "z" validate(lgr.tlev = '' or (can-find(codfr where codfr.codfr = 'lgrsts' and codfr.code = string(lgr.tlev)) and lgr.tlev <> 'msc') ,'Неверное значение кода типа клиентов') help "Введите код типа клиентов; F2 - помощь" lgr.feensf label "Схема" format "z" validate(can-find(codfr where codfr.codfr = 'dpschema' and codfr.code = string(lgr.feensf,'9')) and lgr.feensf <> 'msc', 'Неверное значение схемы начисления %%') help "Введите схему начисления %% по депозиту; F2 - помощь" v-comiss label "Ком" format "x(3)" help "1 - снимать комиссию за кросс-конвертацию, 0 - не снимать" validate (v-comiss = "0" or v-comiss = "1", "Неверное значение") with centered row 4 7 down overlay title " Определение групп счетов срочных депозитов " frame lgr. form lgr.prd label "Минимальный срок " format " z9" help "Мминимальный срок депозита в месяцах" validate(lgr.prd > 0, "Должен быть > 0 and <= 99") skip lgr.dueday label "Максимальный срок " format " z99" help "Максимальный срок депозита в месяцах; 0 - без ограничений" validate(lgr.prd >= 0, "Должен быть >= 0 and <= 99") skip lgr.tlimit[1] label "Минимальная сумма " format "zz,zzz,zzz.99" help "Минимальная сумма депозита; 0 - без ограничений" skip lgr.tlimit[2] label "Дополнительные взносы " format "zz,zzz,zzz.99" help "Минимальная сумма дополнительных взносов; 0 - не предусмотрены" skip lgr.tlimit[3] label "Макс. % изъятия " format "zz,zzz,zzz.99" help "Максимальный % по сумме изъятия; 0 - не предусмотрены" with side-label row 15 column 1 title " Cроки и суммы " frame lgr1. form lgr.pri label "Код таблицы % ставок " format "x(3)" validate(can-find(first pri where pri.pri begins "^" + lgr.pri and lgr.pri <> ' ') , "Таблица с таким кодом не существует!") help "Введите код таблицы % ставок; F2 - help" skip lgr.intcal label "Начисление " format " x(1)" help "Введите периодичность в месяцах, 0 - при открытии,D-ежедневно,N-не начислять" validate(lgr.intcal = "S" or lgr.intcal = "D" or lgr.intcal = "N" , "Должно быть S, D или N") skip lgr.intpay label "Выплата " format " x(1)" help "S-при открытии, M-ежемесячно,Q-ежеквартально,Y-ежегодно,F-по окончании" validate(lgr.intpay = "S" or lgr.intpay = "M" or lgr.intpay = "Q" or lgr.intpay = "Y" or lgr.intpay = "F" , "Должно быть S, M, Q, Y или F") skip lgr.type label "Капитализация " format " x(1)" help "M-ежемесячно,Q-ежеквартально,Y-ежегодно, N-не капитализировать" validate(lgr.type = "M" or lgr.type = "Q" or lgr.type = "Y" or lgr.type = "N" or lgr.type = "" , "Должно быть D, M, Q, Y или N") skip lgr.prefix label "Обновление таблицы % ставок " format " x(1)" help "M-ежемесячно,Q-ежеквартально,Y-ежегодно,N-не обновлять" validate(lgr.prefix = "M" or lgr.prefix = "Q" or lgr.prefix = "Y" or lgr.prefix = "N" or lgr.prefix = "" , "Должно быть M, Q, Y или N") with side-label overlay row 15 column 41 title " Проценты " frame lgr2.
! ************************* SUBROUTINE COEFRO_SISYPHE ! ************************* ! &(CF,H,KFROT,CHESTR,GRAV,NPOIN,HMIN,KARMAN) ! !*********************************************************************** ! SISYPHE V6P1 21/07/2011 !*********************************************************************** ! !brief COMPUTES THE QUADRATIC FRICTION COEFFICIENT CF. ! !history C. VILLARET (LNHE) !+ 01/10/2003 !+ V5P4 !+ ! !history N.DURAND (HRW), S.E.BOURBAN (HRW) !+ 13/07/2010 !+ V6P0 !+ Translation of French comments within the FORTRAN sources into !+ English comments ! !history N.DURAND (HRW), S.E.BOURBAN (HRW) !+ 21/08/2010 !+ V6P0 !+ Creation of DOXYGEN tags for automated documentation and !+ cross-referencing of the FORTRAN sources ! !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !| CF |<->| FRICTION COEFFICIENT !| CHESTR |-->| FRICTION COEFFICIENTS (BED) !| GRAV |-->| ACCELERATION OF GRAVITY !| HMIN |-->| MINIMUM VALUE OF WATER DEPTH !| HN |-->| WATER DEPTH !| KARMAN |-->| VON KARMAN CONSTANT !| KFROT |-->| FRICTION LAW (BED) !| NPOIN |-->| NUMBER OF POINTS !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! USE BIEF ! USE DECLARATIONS_SPECIAL IMPLICIT NONE ! !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! INTEGER, INTENT(IN):: NPOIN,KFROT DOUBLE PRECISION,INTENT(IN):: GRAV,KARMAN,HMIN ! TYPE(BIEF_OBJ), INTENT(INOUT) :: CF TYPE(BIEF_OBJ),INTENT(IN) :: CHESTR,H ! !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! INTEGER N DOUBLE PRECISION HC, AUX, TIERS,ZERO INTRINSIC MAX,LOG ! !----------------------------------------------------------------------- ! TIERS = 1.D0/3.D0 ZERO = 1.D-6 ! ! CONSTRUCTION OF THE FRICTION COEFFICIENT ! ! FRICTION LAWS: ! ! KFROT = 0 : FLAT BOTTOM (KS=3D50) ! KFROT = 1 : EQUILIBRIUM SAND RIPPLES (WAVES ONLY) KS=(MAX 3D50,ETA) ! KFROT = 2 : CHEZY ! KFROT = 3 : STRICKLER ! KFROT = 4 : MANNING ! KFROT = 5 : NIKURADSE ! DO N=1,NPOIN IF(CHESTR%R(N).LE.0.D0) THEN WRITE(LU,*) 'FROTTEMENT NON DEFINI DANS COEFRO AU POINT ',N CALL PLANTE(1) STOP ENDIF ENDDO ! ! *********************** IF(KFROT.EQ.5) THEN ! *********************** ! AUX=30.D0/EXP(1.D0) =11.036D0 DO N=1,NPOIN AUX = MAX(1.001D0,H%R(N)*11.036D0/CHESTR%R(N)) CF%R(N) = 2.D0 / (LOG( AUX)/KARMAN )**2 ENDDO ! *********************** ELSEIF(KFROT.EQ.2) THEN ! *********************** ! DO N=1,NPOIN CF%R(N) = 2.D0 * GRAV / CHESTR%R(N)**2 ENDDO ! ! *********************** ELSEIF(KFROT.EQ.3) THEN ! *********************** ! DO N=1,NPOIN HC = MAX(H%R(N),HMIN) CF%R(N) = 2.D0 * GRAV / CHESTR%R(N)**2 / HC**TIERS ENDDO ! ! *********************** ELSEIF(KFROT.EQ.4) THEN ! *********************** ! DO N=1,NPOIN HC = MAX(H%R(N),HMIN) CF%R(N) = 2.D0 * CHESTR%R(N)**2 * GRAV / HC**TIERS ENDDO ! ! **** ELSE ! **** ! IF(LNG.EQ.1) WRITE(LU,300) KFROT IF(LNG.EQ.2) WRITE(LU,301) KFROT 300 FORMAT(1X,'COEFRO : LOI DE FROTTEMENT INCONNUE :',1I6) 301 FORMAT(1X,'COEFRO: UNKNOWN LAW OF BOTTOM FRICTION: ',1I6) CALL PLANTE(1) STOP ! ! ***** ENDIF ! ***** ! !----------------------------------------------------------------------- ! RETURN END
! advance.f ! advance POM !______________________________________________________________________ ! subroutine advance !---------------------------------------------------------------------- ! Advances model a step !---------------------------------------------------------------------- ! called by: pom [pom.f] ! ! calls : check_nan [advance.f] ! check_nan_2d [advance.f] ! check_velocity [advance.f] ! ice_advance [seaice.f] ! lateral_viscosity [advance.f] ! mode_interaction [advance.f] ! mode_external [advance.f] ! mode_internal [advance.f] ! print_section [advance.f] ! store_mean [advance.f] ! store_surf_mean [advance.f] ! update_bc [advance.f] ! update_time [globals.f90] !______________________________________________________________________ ! use config , only: spinup, use_ice use model_run, only: iext, isplit & , update_time use seaice ! advance POM 1 step in time implicit none ! get time call update_time ! set time dependent boundary conditions if ( .not.spinup ) call update_bc ! set lateral viscosity call lateral_viscosity ! form vertical averages of 3-D fields for use in external (2-D) mode call mode_interaction ! external (2-D) mode calculation do iext = 1, isplit call mode_external call check_nan_2d !fhx:tide:debug ! if (use_ice) call ice_advance end do ! internal (3-D) mode calculation call mode_internal ! print section call print_section ! check nan call check_nan ! store mean 2010/4/26 call store_mean ! store SURF mean call store_surf_mean !fhx:20110131: ! write output ! call write_output( dtime ) ! write restart ! if(mod(iint,irestart).eq.0) call write_restart_pnetcdf ! check CFL condition call check_velocity end ! subroutine advance ! !______________________________________________________________________ ! subroutine get_time !---------------------------------------------------------------------- ! Returns the model time !---------------------------------------------------------------------- ! called by: [NO CALLS] !______________________________________________________________________ ! use model_run, only: dti, iint, ramp, time, time0 implicit none time=dti*float(iint)/86400.+time0 ramp=1. ! if(lramp) then ! ramp=time/period ! if(ramp.gt.1.e0) ramp=1.e0 ! else ! ramp=1.e0 ! endif end ! subroutine get_time ! !______________________________________________________________________ ! subroutine update_bc !---------------------------------------------------------------------- ! Sets time-dependent boundary conditions !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : step [air] ! step [bry] ! step [clim] ! step [seaice] !______________________________________________________________________ ! use air , only: air_step => step use bry , only: bry_step => step use clim , only: clm_step => step use seaice , only: ice_step => step use river , only: riv_step => step use model_run, only: dtime implicit none call clm_step( dtime ) call ice_step( dtime ) call air_step( dtime ) call bry_step( dtime ) call riv_step( dtime ) end ! subroutine update_bc ! !______________________________________________________________________ ! subroutine lateral_viscosity !---------------------------------------------------------------------- ! Sets the lateral viscosity !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : advct [solver.f] ! exchange3d_mpi [parallel_mpi.f] ! pgscheme [advance.f] !______________________________________________________________________ ! use config , only: aam_init, horcon, mode, n1d, npg use bry , only: aamfrz, USE_SPONGE use glob_domain, only: im, imm1, jm, jmm1, kbm1 use grid , only: dx, dy use glob_ocean , only: a, aam, aamfac, c, ee, u, v implicit none integer i,j,k ! if mode=2 then initial values of aam2d are used. If one wishes ! to use Smagorinsky lateral viscosity and diffusion for an ! external (2-D) mode calculation, then appropiate code can be ! adapted from that below and installed just before the end of the ! "if(mode.eq.2)" loop in subroutine advave ! calculate Smagorinsky lateral viscosity: ! ( hor visc = horcon*dx*dy*sqrt((du/dx)**2+(dv/dy)**2 ! +.5*(du/dy+dv/dx)**2) ) if ( mode /= 2 ) then call advct(a,c,ee) call pgscheme(npg) !lyo:scs1d: if ( n1d /= 0 ) then aam(:,:,:) = aam_init else do k=1,kbm1 do j=2,jmm1 do i=2,imm1 aam(i,j,k) = horcon*dx(i,j)*dy(i,j)*aamfac(i,j) !fhx:incmix $ *sqrt( ((u(i+1,j,k)-u(i,j,k))/dx(i,j))**2 $ +((v(i,j+1,k)-v(i,j,k))/dy(i,j))**2 $ +.5*( .25*(u(i,j+1,k)+u(i+1,j+1,k) $ -u(i,j-1,k)-u(i+1,j-1,k)) $ /dy(i,j) $ +.25*(v(i+1,j,k)+v(i+1,j+1,k) $ -v(i-1,j,k)-v(i-1,j+1,k)) $ /dx(i,j) )**2) if ( USE_SPONGE ) then aam(i,j,k) = aam(i,j,k)*(1.+aamfrz(i,j)) end if end do end do end do end if !lyo:scs1d: ! ! create sponge zones ! do k=1,kbm1 ! do j=2,jmm1 ! do i=2,imm1 ! aam(i,j,k)=aam(i,j,k)+1000*exp(-(j_global(j)-2)*1.5) ! $ +1000*exp((j_global(j)-jm_global+1)*1.5) ! end do ! end do ! end do call exchange3d_mpi(aam(:,:,1:kbm1),im,jm,kbm1) end if end ! subroutine lateral_viscosity ! !______________________________________________________________________ ! subroutine mode_interaction !---------------------------------------------------------------------- ! Forms vertical averages of 3-D fields for use in external (2-D) mode !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : advave [solver.f] !______________________________________________________________________ ! use config , only: mode use glob_domain, only: im, jm, kbm1 use grid , only: dz use glob_ocean use model_run , only: isp2i, ispi implicit none integer i,j,k if ( mode /= 2 ) then adx2d = 0. ady2d = 0. drx2d = 0. dry2d = 0. aam2d = 0. do k = 1, kbm1 adx2d = adx2d + advx(:,:,k)*dz(:,:,k) ady2d = ady2d + advy(:,:,k)*dz(:,:,k) drx2d = drx2d + drhox(:,:,k)*dz(:,:,k) dry2d = dry2d + drhoy(:,:,k)*dz(:,:,k) aam2d = aam2d + aam(:,:,k)*dz(:,:,k) end do call advave(tps) adx2d = adx2d - advua ady2d = ady2d - advva end if egf = el*ispi do j=1,jm do i=2,im utf(i,j)=ua(i,j)*(d(i,j)+d(i-1,j))*isp2i end do end do do j=2,jm do i=1,im vtf(i,j)=va(i,j)*(d(i,j)+d(i,j-1))*isp2i end do end do end ! subroutine mode_interaction ! !______________________________________________________________________ ! subroutine mode_external !---------------------------------------------------------------------- ! Calculates the external (2-D) mode !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : advave [solver.f] ! exchange2d_mpi [solver.f] ! bc_vel_ext [bry.f90] ! bc_zeta [bry.f90] !______________________________________________________________________ ! use module_time use air , only: e_atmos, vfluxf, wusurf, wvsurf use bry , only: apply_tide, bc_vel_ext, bc_zeta ! TODO: Move apply_tide to tide use config , only: alpha, cbcmax, cbcmin, ispadv, smoth & , use_tide, z0b use glob_const , only: grav, Kappa use glob_domain, only: im, imm1, jm, jmm1, kbm1 , my_task use grid , only: art, aru, arv, cor, dx, dy, fsm, h, zz use glob_ocean use tide , only: tide_ua, tide_va, tide_advance => step use model_run , only: dte, dte2, iext, isp2i, ispi, isplit,dtime & , iint,iext implicit none integer i,j do j=2,jm do i=2,im fluxua(i,j)=.25*( d(i,j)+ d(i-1,j)) $ *(dy(i,j)+dy(i-1,j))*ua(i,j) fluxva(i,j)=.25*( d(i,j)+ d(i,j-1)) $ *(dx(i,j)+dx(i,j-1))*va(i,j) end do end do ! NOTE addition of surface freshwater flux, w(i,j,1)=vflux, compared ! with pom98.f. See also modifications to subroutine vertvl do j=2,jmm1 do i=2,imm1 elf(i,j)=elb(i,j) $ +dte2*(-(fluxua(i+1,j)-fluxua(i,j) $ +fluxva(i,j+1)-fluxva(i,j))/art(i,j) $ -vfluxf(i,j)) end do end do call bc_zeta ! bcond(1) call exchange2d_mpi(elf,im,jm) if ( mod(iext,ispadv) == 0 ) call advave(tps) do j=2,jmm1 do i=2,im uaf(i,j) = adx2d(i,j) + advua(i,j) $ - aru(i,j)*.25_rk $ *( cor(i ,j)*d(i ,j)*(va(i ,j+1)+va(i ,j)) $ + cor(i-1,j)*d(i-1,j)*(va(i-1,j+1)+va(i-1,j)) ) $ + .25_rk*grav*(dy(i,j)+dy(i-1,j)) $ *(d (i,j)+d (i-1,j)) $ *( (1._rk - 2._rk*alpha)*(el (i,j)-el (i-1,j)) $ + alpha *(elb(i,j)-elb(i-1,j) $ +elf(i,j)-elf(i-1,j)) $ + (e_atmos(i,j)-e_atmos(i-1,j)) ) $ + drx2d(i,j) + aru(i,j)*(wusurf(i,j)-wubot(i,j)) end do end do do j=2,jmm1 do i=2,im uaf(i,j) = ( (h(i,j)+elb(i,j)+h(i-1,j)+elb(i-1,j)) $ * aru(i,j)*uab(i,j) $ - 4._rk*dte*uaf(i,j) ) $ /((h(i,j)+elf(i,j)+h(i-1,j)+elf(i-1,j)) $ *aru(i,j)) end do end do do j=2,jm do i=2,imm1 vaf(i,j) = ady2d(i,j) + advva(i,j) $ + arv(i,j)*.25_rk $ *( cor(i,j )*d(i,j )*(ua(i+1,j )+ua(i,j )) $ + cor(i,j-1)*d(i,j-1)*(ua(i+1,j-1)+ua(i,j-1)) ) $ + .25_rk*grav*(dx(i,j)+dx(i,j-1)) $ *(d (i,j)+d (i,j-1)) $ *( (1._rk - 2._rk*alpha)*(el (i,j)-el (i,j-1)) $ + alpha *(elb(i,j)-elb(i,j-1) $ +elf(i,j)-elf(i,j-1)) $ + (e_atmos(i,j)-e_atmos(i,j-1)) ) $ + dry2d(i,j) + arv(i,j)*(wvsurf(i,j)-wvbot(i,j)) end do end do do j=2,jm do i=2,imm1 vaf(i,j) = ( (h(i,j)+elb(i,j)+h(i,j-1)+elb(i,j-1)) $ * vab(i,j)*arv(i,j) $ - 4._rk*dte*vaf(i,j) ) $ /((h(i,j)+elf(i,j)+h(i,j-1)+elf(i,j-1)) $ *arv(i,j)) end do end do if ( use_tide ) call tide_advance( dtime ) ! update tide boundaries before applying boundary conditions call bc_vel_ext ! bcond(2) call exchange2d_mpi(uaf,im,jm) call exchange2d_mpi(vaf,im,jm) ! if ( use_tide ) then ! uaf = uaf - tide_ua ! vaf = vaf - tide_va ! call apply_tide(-1._rk) ! call tide_advance( dtime + int(iext*dte) ) ! call apply_tide(1._rk) ! uaf = uaf + tide_ua! - tide_ua_b ! vaf = vaf + tide_va! - tide_va_b ! end if if ( iext == (isplit-2) ) then etf = .25*smoth*elf elseif ( iext == (isplit-1) ) then etf = etf + .5*(1.-.5*smoth)*elf elseif ( iext == isplit ) then etf = ( etf + .5*elf )*fsm(:,:,1) end if ! apply filter to remove time split ua = ua + .5*smoth*( uab + uaf - 2.*ua ) va = va + .5*smoth*( vab + vaf - 2.*va ) el = el + .5*smoth*( elb + elf - 2.*el ) ! if (iint>2) then ! print *, iint,"=",my_task, ": UA : ", maxval(abs(va)) ! print *, iint,"=",my_task, ": UAB: ", maxval(abs(vab)) ! print *, iint,"=",my_task, ": UAF: ", maxval(abs(vaf)) ! call finalize_mpi ! stop ! end if elb = el el = elf d = h + el uab = ua ua = uaf vab = va va = vaf ! update bottom friction do j=1,jm do i=1,im cbc(i,j)=(Kappa/log((.1+(1.+zz(i,j,kbm1))*d(i,j))/z0b))**2 cbc(i,j)=max(cbcmin,cbc(i,j)) cbc(i,j)=min(cbcmax,cbc(i,j)) end do end do if ( iext /= isplit ) then egf = egf + el*ispi do j=1,jm do i=2,im utf(i,j)=utf(i,j)+ua(i,j)*(d(i,j)+d(i-1,j))*isp2i end do end do do j=2,jm do i=1,im vtf(i,j)=vtf(i,j)+va(i,j)*(d(i,j)+d(i,j-1))*isp2i end do end do end if end ! subroutine mode_external !______________________________________________________________________ ! subroutine mode_internal !---------------------------------------------------------------------- ! Calculates the internal (3-D) mode !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : advq [solver.f] ! advt1 [solver.f] ! advt2 [solver.f] ! advu [solver.f] ! advv [solver.f] ! bc_turb [bry.f90] ! bc_vel_int [bry.f90] ! bc_vel_vert [bry.f90] ! dens [solver.f] ! exchange3d_mpi [parallel_mpi.f] ! profq [solver.f] ! proft [solver.f] ! profu [solver.f] ! profv [solver.f] !______________________________________________________________________ ! use air , only: vfluxb, vfluxf, wssurf, wtsurf use bry , only: bc_ts, bc_turb, bc_vel_int, bc_vel_vert use clim , only: tclim, sclim, relax_to_clim use glob_const , only: rk, small use config , only: mode , nadv, nbcs, nbct, do_restart & , smoth, s_hi, s_lo, t_hi, t_lo use glob_domain use grid , only: dz, h ,fsm use glob_ocean use model_run implicit none integer i,j,k if ( mode /= 2 ) then if ( ( iint>2 .and. .not.do_restart ) & .or. do_restart ) then ! adjust u(z) and v(z) such that depth average of (u,v) = (ua,va) tps = 0. do k=1,kbm1 do j=1,jm do i=1,im tps(i,j)=tps(i,j)+u(i,j,k)*dz(i,j,k) end do end do end do do k=1,kbm1 do j=1,jm u(1,j,k) = .5*( u(1,j,k) - tps(1,j) ) & + ( utb(1,j) + utf(1,j) )/dt(1,j) do i=2,im u(i,j,k)=(u(i,j,k)-tps(i,j))+ $ (utb(i,j)+utf(i,j))/(dt(i,j)+dt(i-1,j)) end do end do end do do j=1,jm do i=1,im tps(i,j)=0. end do end do do k=1,kbm1 do j=1,jm do i=1,im tps(i,j)=tps(i,j)+v(i,j,k)*dz(i,j,k) end do end do end do do k=1,kbm1 do i=1,im v(i,1,k) = .5*( v(i,1,k) - tps(i,1) ) & + ( vtb(i,1) + vtf(i,1) )/dt(i,1) end do do j=2,jm do i=1,im v(i,j,k)=(v(i,j,k)-tps(i,j))+ $ (vtb(i,j)+vtf(i,j))/(dt(i,j)+dt(i,j-1)) end do end do end do !eda: do drifter assimilation !eda: this was the place where Lin et al. assimilate drifters !eda: /home/xil/OIpsLag/gomc27_test87d_hcast2me_pseudo1.f ! IF(MOD(IINT,16).EQ.0) THEN ! 16 = 3.*3600./dti, every 3 hours !-- IF(iint.eq.1 .or. MOD(IINT,16).EQ.0) THEN !-- IF(MOD(IINT,IASSIM).EQ.0) THEN ! call assimdrf_OIpsLag(time, itime1, mins, sec, ! 1 IM, JM, KB, u, v, Nx, Ny, beta, alon, alat, zz, D, ! 2 igs, ige, jgs, jge, ndrfmax, ! 3 ub, vb, dz, DrfDir) ! endif ! calculate w from u, v, dt (h+et), etf and etb call vertvl(a,c) call bc_vel_vert ! bcond(5) call exchange3d_mpi(w,im,jm,kb) ! set uf and vf to zero uf = 0. vf = 0. ! calculate q2f and q2lf using uf, vf, a and c as temporary variables call advq(q2b,q2,uf,a,c) call advq(q2lb,q2l,vf,a,c) call profq(a,c,tps,dtef) ! an attempt to prevent underflow (DEBUG) where(q2l.lt..5*small) q2l = .5*small where(q2lb.lt..5*small) q2lb = .5*small call bc_turb ! bcond(6) call exchange3d_mpi(uf(:,:,2:kbm1),im,jm,kbm2) call exchange3d_mpi(vf(:,:,2:kbm1),im,jm,kbm2) q2 = q2 + .5*smoth*( q2b -2.*q2 + uf ) q2l = q2l + .5*smoth*( q2lb -2.*q2l + vf ) q2b = q2 q2 = uf q2lb= q2l q2l = vf ! calculate tf and sf using uf, vf, a and c as temporary variables ! if( mode /= 4 .and. ( iint > 2 .or. do_restart ) ) then if( mode /= 4 ) then if ( nadv == 1 ) then call advt1(tb,t,tclim,uf,a,c,'T') call advt1(sb,s,sclim,vf,a,c,'S') elseif ( nadv == 2 ) then call advt2(tb,tclim,uf,a,c,'T') call advt2(sb,sclim,vf,a,c,'S') else error_status = 1 print *, '(/''Error: invalid value for nadv'')' end if call proft(uf,wtsurf,tsurf,nbct,tps) call proft(vf,wssurf,ssurf,nbcs,tps) if ( t_lo > -999. ) then where ( uf < t_lo ) uf = t_lo end if if ( t_hi < 999. ) then where ( uf > t_hi ) uf = t_hi end if if ( s_lo > -999. ) then where ( vf < s_lo ) vf = s_lo end if if ( s_hi < 999. ) then where ( vf > s_hi ) vf = s_hi end if call relax_to_clim( uf, vf ) call bc_ts ! bcond(4) call exchange3d_mpi(uf(:,:,1:kbm1),im,jm,kbm1) call exchange3d_mpi(vf(:,:,1:kbm1),im,jm,kbm1) t = t + .5*smoth*( tb + uf -2.*t ) s = s + .5*smoth*( sb + vf -2.*s ) tb = t t = uf sb = s s = vf call dens(s,t,rho) end if ! calculate uf and vf call advu call advv call profu call profv call bc_vel_int ! bcond(3) call exchange3d_mpi(uf(:,:,1:kbm1),im,jm,kbm1) call exchange3d_mpi(vf(:,:,1:kbm1),im,jm,kbm1) tps = 0. do k=1,kbm1 do j=1,jm do i=1,im tps(i,j)=tps(i,j) $ +(uf(i,j,k)+ub(i,j,k)-2.*u(i,j,k))*dz(i,j,k) end do end do end do do k=1,kbm1 do j=1,jm do i=1,im u(i,j,k)=u(i,j,k) $ +.5*smoth*(uf(i,j,k)+ub(i,j,k) $ -2.*u(i,j,k)-tps(i,j)) end do end do end do tps = 0. do k=1,kbm1 do j=1,jm do i=1,im tps(i,j)=tps(i,j) $ +(vf(i,j,k)+vb(i,j,k)-2.*v(i,j,k))*dz(i,j,k) end do end do end do do k=1,kbm1 do j=1,jm do i=1,im v(i,j,k)=v(i,j,k) $ +.5*smoth*(vf(i,j,k)+vb(i,j,k) $ -2.*v(i,j,k)-tps(i,j)) end do end do end do ub = u u = uf vb = v v = vf call geopotential_vertical_velocity end if end if egb = egf etb = et et = etf dt = h + et utb = utf vtb = vtf vfluxb = vfluxf end ! subroutine mode_internal ! !______________________________________________________________________ ! subroutine geopotential_vertical_velocity !---------------------------------------------------------------------- ! Calculates real (geopotential) vertical velocity as `wr` !---------------------------------------------------------------------- ! called by: mode_internal [advance.f] ! ! calls : exchange3d_mpi [parallel_mpi.f] !______________________________________________________________________ ! use glob_const , only: rk use glob_domain, only: im, imm1, jm, jmm1, kb, kbm1 & , n_east, n_north, n_south, n_west use grid , only: dx, dy, fsm, zz use glob_ocean , only: dt, et, etb, etf, tps, u, v, w, wr use model_run , only: dti2 implicit none integer i, j, k real(rk) dxr, dxl, dyt, dyb wr = 0. do k=1,kbm1 tps = zz(:,:,k)*dt + et do j=2,jmm1 do i=2,imm1 dxr = 2._rk/(dx(i+1,j)+dx(i ,j)) dxl = 2._rk/(dx(i ,j)+dx(i-1,j)) dyt = 2._rk/(dy(i,j+1)+dy(i,j )) dyb = 2._rk/(dy(i,j )+dy(i,j-1)) wr(i,j,k) = .5_rk*(w(i,j,k)+w(i,j,k+1)) $ + .5_rk* $ ( u(i+1,j,k)*(tps(i+1,j)-tps(i ,j))*dxr $ + u(i ,j,k)*(tps(i ,j)-tps(i-1,j))*dxl $ + v(i,j+1,k)*(tps(i,j+1)-tps(i,j ))*dyt $ + v(i,j ,k)*(tps(i,j )-tps(i,j-1))*dyb ) $ + (1._rk+zz(i,j,k))*(etf(i,j)-etb(i,j))/dti2 end do end do end do call exchange3d_mpi(wr(:,:,1:kbm1),im,jm,kbm1) do k=1,kb do i=1,im if(n_south.eq.-1) wr(i,1,k)=wr(i,2,k) if(n_north.eq.-1) wr(i,jm,k)=wr(i,jmm1,k) end do end do do k=1,kb do j=1,jm if(n_west.eq.-1) wr(1,j,k)=wr(2,j,k) if(n_east.eq.-1) wr(im,j,k)=wr(imm1,j,k) end do end do wr = fsm*wr end ! subroutine geopotential_vertical_velocity ! !______________________________________________________________________ ! subroutine print_section !---------------------------------------------------------------------- ! Prints output !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : bcast0i_mpi [parallel_mpi.f] ! finalize_mpi [parallel_mpi.f] ! sum0d_mpi [parallel_mpi.f] ! sum0i_mpi [parallel_mpi.f] !______________________________________________________________________ ! use config , only: sbias, tbias use glob_const , only: rk use glob_domain use grid , only: art, dz, fsm use glob_ocean , only: et, dt, sb, tb use glob_out , only: iprint use model_run implicit none real(rk), dimension(im,jm) :: d_vol real(rk) area_tot, vol_tot real(rk) elev_ave, temp_ave, salt_ave integer i,j,k if ( mod(iint,iprint) == 0 ) then ! print time if ( is_master ) print '(/ $ ''========================================================='' $ /''time ='',f9.4,'', iint ='',i8,'', iext ='',i8, $ '', iprint ='',i8)', time,iint,iext,iprint ! check for errors call sum0i_mpi(error_status,master_task) call bcast0i_mpi(error_status,master_task) if ( error_status /= 0 ) then if ( is_master ) print *, 'POM terminated with error' call finalize_mpi stop end if ! local averages vol_tot = 0. area_tot = 0. temp_ave = 0. salt_ave = 0. elev_ave = 0. do k=1,kbm1 d_vol = art*dt*dz(:,:,k)*fsm(:,:,k) vol_tot = vol_tot + sum(d_vol) temp_ave = temp_ave + sum(tb(:,:,k)*d_vol) salt_ave = salt_ave + sum(sb(:,:,k)*d_vol) end do area_tot = sum( art ) elev_ave = sum( et*art ) call sum0d_mpi( temp_ave, master_task ) call sum0d_mpi( salt_ave, master_task ) call sum0d_mpi( elev_ave, master_task ) call sum0d_mpi( vol_tot, master_task ) call sum0d_mpi( area_tot, master_task ) ! print averages if ( is_master ) then temp_ave = temp_ave / vol_tot salt_ave = salt_ave / vol_tot elev_ave = elev_ave / area_tot print '(a,e15.8,2(a,f11.8),a)' & , "mean ; et = ", elev_ave, " m, tb = " & , temp_ave + tbias, " deg, sb = " & , salt_ave + sbias, " psu" end if end if end ! subroutine print_section ! !______________________________________________________________________ ! subroutine check_velocity !---------------------------------------------------------------------- ! Checks if velocity condition is violated !---------------------------------------------------------------------- ! called by: advance [advance.f] !______________________________________________________________________ ! use config , only: vmaxl use glob_const , only: rk use glob_domain use model_run , only: iext, iint, time use glob_ocean , only: vaf use glob_out , only: iprint implicit none integer i,j,imax,jmax real(rk) vamax vamax = 0. do j=1,jm do i=1,im if ( abs(vaf(i,j)) /= vamax ) then vamax = abs(vaf(i,j)) imax = i jmax = j end if end do end do if ( vamax > vmaxl ) then if ( error_status == 0 ) print '(/ $ ''Error: velocity condition violated @ processor '',i3,/ $ ''time ='',f9.4, $ '', iint ='',i8,'', iext ='',i8,'', iprint ='',i8,/ $ ''vamax ='',e12.3,'' imax,jmax ='',2i5)' $ , my_task,time,iint,iext,iprint,vamax,imax,jmax error_status = 1 end if end ! subroutine check_velocity ! !______________________________________________________________________ ! subroutine store_mean !---------------------------------------------------------------------- ! Stores averages for further output (if enabled) !---------------------------------------------------------------------- ! called by: advance [advance.f] !______________________________________________________________________ ! use air , only: wssurf, wtsurf, wusurf, wvsurf, swrad use glob_domain, only: kb use glob_ocean , only: aam, cbc , elb , kh & , km , rho , s , t & , u , uab , v , vab & , w , wubot, wvbot use glob_out implicit none uab_mean = uab_mean + uab vab_mean = vab_mean + vab elb_mean = elb_mean + elb wusurf_mean = wusurf_mean + wusurf wvsurf_mean = wvsurf_mean + wvsurf wtsurf_mean = wtsurf_mean + wtsurf wssurf_mean = wssurf_mean + wssurf swrad_mean = swrad_mean + swrad u(:,:,kb) = wubot(:,:) !fhx:20110318:store wvbot v(:,:,kb) = wvbot(:,:) !fhx:20110318:store wvbot u_mean = u_mean + u v_mean = v_mean + v w_mean = w_mean + w t_mean = t_mean + t s_mean = s_mean + s rho_mean = rho_mean + rho kh_mean = kh_mean + kh aam(:,:,kb) = cbc(:,:) !lyo:20110315:botwavedrag:store cbc aam_mean = aam_mean + aam num = num + 1 end ! subroutine store_mean ! !______________________________________________________________________ ! subroutine store_surf_mean !---------------------------------------------------------------------- ! Stores averages for surface output !---------------------------------------------------------------------- ! called by: advance [advance.f] !______________________________________________________________________ ! use air , only: uwsrf, vwsrf use glob_ocean, only: elb, u, v use glob_out implicit none usrf_mean = usrf_mean + u(:,:,1) vsrf_mean = vsrf_mean + v(:,:,1) elsrf_mean = elsrf_mean + elb uwsrf_mean = uwsrf_mean + uwsrf vwsrf_mean = vwsrf_mean + vwsrf nums = nums + 1 end ! subroutine store_surf_mean ! !_______________________________________________________________________ ! subroutine write_output( d_in ) ! ! use module_time ! ! implicit none ! include 'pom.h' ! ! type(date), intent(in) :: d_in ! ! integer i,j,k ! real(kind=rk) u_tmp, v_tmp ! ! if(netcdf_file.ne.'nonetcdf' .and. mod(iint,iprint).eq.0) then ! ! ! uab_mean = uab_mean / real ( num ) ! vab_mean = vab_mean / real ( num ) ! elb_mean = elb_mean / real ( num ) ! wusurf_mean = wusurf_mean / real ( num ) ! wvsurf_mean = wvsurf_mean / real ( num ) ! wtsurf_mean = wtsurf_mean / real ( num ) ! wssurf_mean = wssurf_mean / real ( num ) ! u_mean = u_mean / real ( num ) ! v_mean = v_mean / real ( num ) ! w_mean = w_mean / real ( num ) ! t_mean = t_mean / real ( num ) ! s_mean = s_mean / real ( num ) ! rho_mean = rho_mean / real ( num ) ! kh_mean = kh_mean / real ( num ) ! km_mean = km_mean / real ( num ) ! ! ! !! if ( my_task == 41 ) !! $ print*, im/2,jm/2,rot(im/2,jm/2), !! $ uab_mean(im/2,jm/2),vab_mean(im/2,jm/2) !! do j = 1, jm !! do i = 1, im !! u_tmp = uab_mean(i,j) !! v_tmp = vab_mean(i,j) !! uab_mean(i,j) !! $ = u_tmp * cos( rot(i,j) * deg2rad ) !! $ - v_tmp * sin( rot(i,j) * deg2rad ) !! vab_mean(i,j) !! $ = u_tmp * sin( rot(i,j) * deg2rad ) !! $ + v_tmp * cos( rot(i,j) * deg2rad ) !! enddo !! enddo !! if ( my_task == 41 ) !! $ print*, im/2,jm/2, !! $ cos(rot(im/2,jm/2)*deg2rad), !! $ uab_mean(im/2,jm/2),vab_mean(im/2,jm/2) ! ! !! do j = 1, jm !! do i = 1, im !! u_tmp = wusurf_mean(i,j) !! v_tmp = wvsurf_mean(i,j) !! wusurf_mean(i,j) !! $ = u_tmp * cos( rot(i,j) * deg2rad ) !! $ - v_tmp * sin( rot(i,j) * deg2rad ) !! wvsurf_mean(i,j) !! $ = u_tmp * sin( rot(i,j) * deg2rad ) !! $ + v_tmp * cos( rot(i,j) * deg2rad ) !! enddo !! enddo !! do k=1,kbm1 !! do j = 1, jm !! do i = 1, im !! u_tmp = u_mean(i,j,k) !! v_tmp = v_mean(i,j,k) !! u_mean(i,j,k) !! $ = u_tmp * cos( rot(i,j) * deg2rad ) !! $ - v_tmp * sin( rot(i,j) * deg2rad ) !! v_mean(i,j,k) !! $ = u_tmp * sin( rot(i,j) * deg2rad ) !! $ + v_tmp * cos( rot(i,j) * deg2rad ) !! enddo !! enddo !! enddo ! ! ! write( filename, '("out/",2a,".nc")' ) ! $ trim( netcdf_file ), date2str( d_in ) ! ! call write_output_pnetcdf( filename ) ! ! uab_mean = 0.0 ! vab_mean = 0.0 ! elb_mean = 0.0 ! wusurf_mean = 0.0 ! wvsurf_mean = 0.0 ! wtsurf_mean = 0.0 ! wssurf_mean = 0.0 ! u_mean = 0.0 ! v_mean = 0.0 ! w_mean = 0.0 ! t_mean = 0.0 ! s_mean = 0.0 ! rho_mean = 0.0 ! kh_mean = 0.0 ! km_mean = 0.0 ! ! num = 0 ! ! endif ! ! return ! end ! !______________________________________________________________________ ! subroutine check_nan !---------------------------------------------------------------------- ! Checks if NaNs present !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : detect_nan [advance.f] !______________________________________________________________________ ! use glob_ocean, only: s, t, u, v implicit none call detect_nan( u, "u" ) call detect_nan( v, "v" ) call detect_nan( t, "t" ) call detect_nan( s, "s" ) end ! subroutine check_nan !______________________________________________________________________ ! subroutine detect_nan( var, varname ) !---------------------------------------------------------------------- ! Checks an array for NaNs !---------------------------------------------------------------------- ! called by: check_nan [advance.f] !______________________________________________________________________ ! use ieee_arithmetic, only: ieee_is_nan use glob_const , only: rk use glob_domain, only: i_global, im, j_global, jm, kb use grid , only: h implicit none real(rk) , intent(in) :: var(im,jm,kb) character(len=*), intent(in) :: varname integer i, j, k, num_nan num_nan = 0 do k=1,kb do j=1,jm do i=1,im if ( var(i,j,k) == var(i,j,k)+1 ) then print '(2a,3i4,2f12.4)' & , "detect nan : ",varname & , i_global(i), j_global(j), k & , var(i,j,k), h(i,j) if ( k == 1 ) num_nan = num_nan + 1 end if end do end do end do if ( num_nan /= 0 ) then print '(2a,2(a,i6))' & , " detect_nan : ", varname & , "j_global(1) = ", j_global(1) & , ", num_nan = ", num_nan ! call finalize_mpi stop end if end ! subroutine detect_nan ! !______________________________________________________________________ !fhx:tide:debug subroutine check_nan_2d !---------------------------------------------------------------------- ! Checks for NaNs present in 2D !---------------------------------------------------------------------- ! called by: advance [advance.f] ! ! calls : detect_nan_2d [advance.f] !______________________________________________________________________ ! use glob_ocean, only: elf, uaf, vaf implicit none call detect_nan_2d( uaf, "uaf" ) call detect_nan_2d( vaf, "vaf" ) call detect_nan_2d( elf, "elf" ) end ! subroutine check_nan_2d ! !______________________________________________________________________ !fhx:tide;debug subroutine detect_nan_2d( var, varname ) !---------------------------------------------------------------------- ! Checks a 2D array for NaNs !---------------------------------------------------------------------- ! called by: check_nan_2d [advance.f] !______________________________________________________________________ ! use air use glob_const , only: rk use glob_domain, only: i_global, im, j_global, jm use grid , only: fsm, h use model_run , only: time use glob_ocean implicit none integer i, j, num_nan real(kind=rk), intent(in) :: var(im,jm) character(len=*),intent(in) :: varname ! logical isnanf num_nan = 0 do j=1,jm do i=1,im if ( var(i,j) == var(i,j)+1 .or. var(i,j) /= var(i,j) ) then print '(2a,2i4,3f12.4)', $ "detect nan : ",varname, $ i_global(i),j_global(j), $ var(i,j),h(i,j),time num_nan = num_nan + 1 end if end do end do if ( num_nan /= 0 ) then print'(2a,2(a,i6))', $ " detect_nan : ", varname, $ "j_global(1) = ", j_global(1), $ ", num_nan = ", num_nan ! call finalize_mpi stop end if end ! subroutine detect_nan_2d ! !______________________________________________________________________ ! subroutine pgscheme(npg) !---------------------------------------------------------------------- ! Redirects to a proper PGF scheme !---------------------------------------------------------------------- ! called by: lateral_viscosity [advance.f] ! update_initial [initialize.f] ! ! calls : baropg [solver.f] ! baropg_lin [solver.f] ! baropg_mcc [solver.f] ! baropg_shch [solver.f] ! baropg_song_std [solver.f] !______________________________________________________________________ ! implicit none integer, intent(in) :: npg select case (npg) case (1) call baropg case (2) call baropg_mcc case (3) call baropg_lin case (4) call baropg_song_std case (5) call baropg_shch case default call baropg_mcc end select end ! subroutine pgscheme
C++*************************************************************** C spec_plot C Program to plot a 1-D spectrum. C C Input spectrum: image file C with flux in first line, wavelengths in second line C C Version of 17-12-98 C--************************************************************** PROGRAM SPEC_BACK CHARACTER IN_NAME*40,IN_COMMENTS*80 CHARACTER PLOTDEV*32 INTEGER*4 ISTAT,IMODE INTEGER*4 MADRID(1),PNTR_1,NX_1,NY_1 COMMON /VMR/MADRID CALL JLP_BEGIN 10 FORMAT(A) WRITE(6,22) 22 FORMAT(' Program plot_back JLP-Version of 17-12-98',/, 1 ' Input spectrum: image file flux in line #1, wavelength in line #2') C Inquires about the format of the files : CALL JLP_INQUIFMT WRITE(6,23) 23 FORMAT(' Graphic output device?') READ(5,10) PLOTDEV C************************************************************ C Loading input image file C************************************************************ WRITE(6,*) ' Input spectrum (image file) ?' READ(5,10) IN_NAME CALL JLP_VM_READIMAG(PNTR_1,NX_1,NY_1,IN_NAME,IN_COMMENTS) CALL PLT_SPECTRUM(MADRID(PNTR_1),NX_1,NY_1,PLOTDEV, 1 IN_NAME,IN_COMMENTS) CALL JLP_END STOP END C************************************************************************ C To plot a spectrum C INPUT: C IMAGE1(NX_1,NY_1) C PLOTDEV: name of plotting device C IN_NAME, IN_COMMENTS: name and comments of image to be written C on the caption of the plot (if hardcopy) C************************************************************************ SUBROUTINE PLT_SPECTRUM(IMAGE1,NX_1,NY_1,PLOTDEV, 1 IN_NAME,IN_COMMENTS) PARAMETER (IDIM=2000) REAL*4 IMAGE1(NX_1,*) REAL*4 X1(IDIM),Y1(IDIM) REAL*4 XOUT,YOUT INTEGER*4 NPTS,NOUT,FILE_OPENED CHARACTER ANS*1,PLOTDEV*32,LOGFILE*40,IN_NAME*40,IN_COMMENTS*80 CHARACTER CHAR1*30,CHAR2*30,TITLE*40,NCHAR*4 C Common block for cursor: COMMON /STR_OUTPUT/XOUT(200),YOUT(200),NOUT 10 FORMAT(A) C Flag set to one when logfile has been opened FILE_OPENED=0 C Transfer of the spectrum to X,Y array IF(NX_1.GT.IDIM)THEN WRITE(6,23) IDIM 23 FORMAT('PLT_SPECTRUM/Fatal error, maximum size set to ',I5) ISTAT=-1 ENDIF C Loading arrays for display: NPTS=NX_1 DO I=1,NPTS X1(I)=IMAGE1(I,2) Y1(I)=IMAGE1(I,1) ENDDO C Graphic output CHAR1='Wavelength' CHAR2='Flux' TITLE=IN_NAME NCHAR='L0' WRITE(6,28) 28 FORMAT(' Displaying the input spectrum') 62 CALL NEWPLOT(X1,Y1,NPTS,IDIM,1,CHAR1,CHAR2,TITLE, 1 NCHAR,PLOTDEV,IN_NAME,IN_COMMENTS) IF(NOUT.GT.0)THEN C Possibility of storing pixel values in a file: IF(FILE_OPENED.NE.1)THEN PRINT *,' Do you want to output the cursor values to a file? (Y)' READ(5,10) ANS IF(ANS.NE.'N'.AND.ANS.NE.'n') THEN FILE_OPENED=1 PRINT *,' Name of output file (if old file: appended)' READ(5,10) LOGFILE OPEN(2,FILE=LOGFILE,STATUS='UNKNOWN') ENDIF ENDIF C Output to logfile: IF(FILE_OPENED.EQ.1)THEN WRITE(2,35) XOUT(1),YOUT(1),IN_NAME 35 FORMAT(1PG11.4,1X,1PG11.4,1X,A) DO I=2,NOUT C WRITE(6,34) I,XOUT(I),YOUT(I) C34 FORMAT(' Point #',I5,' X =',G12.5,' Y=',G12.5) WRITE(2,36) XOUT(I),YOUT(I) 36 FORMAT(1PG11.4,1X,1PG11.4) END DO ENDIF ENDIF PRINT *,' Do you want to display the curve again? (Y)' READ(5,10) ANS IF(ANS.NE.'N'.AND.ANS.NE.'n')GOTO 62 C Close logfile: IF(FILE_OPENED.EQ.1) CLOSE(2) RETURN END
C C $Id: ngritd.f,v 1.4 2008-07-27 00:17:18 haley Exp $ C C Copyright (C) 2000 C University Corporation for Atmospheric Research C All Rights Reserved C C The use of this Software is governed by a License Agreement. C SUBROUTINE NGRITD (IAXS,ANGL,UCRD,VCRD,WCRD) C C Define a multiplicative constant to convert from degrees to radians. C DATA DTOR / .017453292519943 / C C This routine rotates the point with coordinates (UCRD,VCRD,WCRD) by C the angle ANGL about the axis specified by IAXS (1 for the U axis, C 2 for the V axis, 3 for the W axis). A right-handed coordinate C system is assumed. C SINA=SIN(DTOR*ANGL) COSA=COS(DTOR*ANGL) C UTMP=UCRD VTMP=VCRD WTMP=WCRD C IF (IAXS.EQ.1) THEN VCRD=VTMP*COSA-WTMP*SINA WCRD=WTMP*COSA+VTMP*SINA ELSE IF (IAXS.EQ.2) THEN UCRD=UTMP*COSA+WTMP*SINA WCRD=WTMP*COSA-UTMP*SINA ELSE UCRD=UTMP*COSA-VTMP*SINA VCRD=VTMP*COSA+UTMP*SINA END IF C RETURN C END
! *****************************COPYRIGHT******************************* ! (C) Crown copyright Met Office. All rights reserved. ! For further details please refer to the file COPYRIGHT.txt ! which you should have received as part of this distribution. ! *****************************COPYRIGHT******************************* ! !+ Subroutine to calculate the saturated mixing ratio for ice. ! ! Method: ! The standard Goff-Gratsch formula is implemented. ! !- --------------------------------------------------------------------- SUBROUTINE qsat_gg_ice(qs, t, p) ! ! ! ! Modules to set types of variables: USE realtype_rd ! ! IMPLICIT NONE ! ! ! Dummy arguments REAL (RealK), Intent(IN) :: & t ! Temperature & , p ! Pressure REAL (RealK), Intent(OUT) :: & qs ! Saturation mixing ratio ! ! Local variables. REAL (RealK) :: & x & , u1 & , u2 & , u3 ! Temporary variables & , ew ! Saturation vapour pressure of water vapour & , r ! Humidity mixing ratio ! ! ! x=2.7316e+02_RealK/t u1=-9.09718_RealK*(x-1.0_RealK) u2=-3.56654_RealK*log10(x) u3=8.76793_RealK*(1.0_RealK-1.0_RealK/x) ew=6.1071e+02_RealK*1.0e+01_RealK**(u1+u2+u3) r=6.2197e-01_RealK*ew/(p-ew) qs=r/(1.0_RealK+r) ! ! ! RETURN END
! *********************** SUBROUTINE POINT_STBTEL ! *********************** ! !*********************************************************************** ! PROGICIEL : STBTEL V5.2 09/08/89 J-C GALLAND (LNH) ! 19/02/93 J-M JANIN (LNH) ! 21/08/96 P CHAILLET (LHF) - FASTTABS ! 09/98 A. CABAL / SOGREAH ! ORIGINE : ULYSSE !*********************************************************************** ! ! FONCTION : CONSTRUCTION DES POINTEURS DES TABLEAUX A ET IA ! !----------------------------------------------------------------------- ! ARGUMENTS ! .________________.____.______________________________________________ ! | NOM |MODE| ROLE ! |________________|____|______________________________________________ ! | IDIMA | -->| DIMENSION DU TABLEAU A ! | IDIMIA | -->| DIMENSION DU TABLEAU IA ! | NBAT | -->| NOMBRE DE POINTS DE BATHY ! | NBFOND | -->| NOMBRE DE FICHIERS BATHY ! | MAILLE | -->| NOM DU MAILLEUR ! | | -->| POUR LA LECTURE DU FICHIER SIMAIL ! | arguments rajoutes pour l'option d'elimination des elements secs ! | ELISEC | -->| BOOLEAN INDIQUANT SI ELIMINATION DES POINTS SECS ! | | | EST DEMANDEE ! | fin arguments rajoutes pour l'option d'elimination des elements secs ! |________________|____|______________________________________________ ! | COMMON | | ! | K... |<-- | POINTEURS DU TABLEAU ENTIER ! | GEO: | | ! | MESH |--> | TYPE DE MAILLAGE ! | NDP |--> | NOMBRE DE NOEUDS PAR ELEMENTS ! | NPOIN |--> | NOMBRE TOTAL DE POINTS DU MAILLAGE ! | NELEM |--> | NOMBRE TOTAL D'ELEMENTS DU MAILLAGE ! | NPMAX |<-- | DIMENSION EFFECTIVE DES TABLEAUX X ET Y ! | | | (NPMAX = NPOIN + 0.1*NELEM) ! | NELMAX |<-- | DIMENSION EFFECTIVE DES TABLEAUX CONCERNANT ! | | | LES ELEMENTS (NELMAX = NELEM + 0.2*NELEM) ! |________________|____|______________________________________________ ! MODE : -->(DONNEE NON MODIFIEE), <--(RESULTAT), <-->(DONNEE MODIFIEE) !---------------------------------------------------------------------- ! APPELE PAR : HOMERE ! APPEL DE : - !*********************************************************************** ! USE DECLARATIONS_SPECIAL USE DECLARATIONS_STBTEL IMPLICIT NONE ! !======================================================================= ! POUR PREVOIR L'ELIMINATION DES TRIANGLES SURCONTRAINTS , LES VALEURS ! DE NPOIN ET NELEM2 SONT SURDIMENSIONNEES !======================================================================= ! NPMAX = NPOIN + INT(0.1*NELEM) NELMAX = NELEM + 2*INT(0.1*NELEM) IF(DIV4) NPMAX = NPMAX + 3*NELEM IF(DIV4) NELMAX = NELMAX + 3*NELEM ! RETURN END
PROGRAM FTEX06 C C Example of SURF1/SURF2. C C C Define the error file, the Fortran unit number, the workstation type, C and the workstation ID to be used in calls to GKS routines. C C PARAMETER (IERRF=6, LUNIT=2, IWTYPE=1, IWKID=1) ! NCGM C PARAMETER (IERRF=6, LUNIT=2, IWTYPE=8, IWKID=1) ! X Windows C PARAMETER (IERRF=6, LUNIT=2, IWTYPE=11, IWKID=1) ! PDF C PARAMETER (IERRF=6, LUNIT=2, IWTYPE=20, IWKID=1) ! PostScript C PARAMETER (IERRF=6, LUNIT=2, IWTYPE=1, IWKID=1) C PARAMETER (NXI=11,NYI=17,NXO=31,NYO=21,IDTEMP=2*NYI+NXI) C DIMENSION X(NXI),Y(NYI),Z(NXI,NYI) DIMENSION ZX1(NYI),ZXM(NYI),ZY1(NXI),ZYN(NXI) DIMENSION ZP(NXI,NYI,3),TEMP(IDTEMP) DIMENSION XO(NXO),YO(NYO),ZO(NXO,NYO) C C Declare a function ZF(U,V) that defines a surface. C ZF(U,V)=.5+.25*SIN(-7.*U)+.25*COS(5.*V) C C Define the surface to be drawn. C DO 104 I=1,NXI X(I) = REAL(I-1)/REAL(NXI-1) DO 103 J=1,NYI Y(J) = REAL(J-1)/REAL(NYI-1) Z(I,J)=ZF(X(I),Y(J)) 103 CONTINUE 104 CONTINUE C C Do SURF1 set up. C SIGMA = 1. ISF = 255 CALL SURF1(NXI,NYI,X,Y,Z,NXI,ZX1,ZXM,ZY1,ZYN, + ZXY11,ZXYM1,ZXY1N,ZXYMN,ISF,ZP,TEMP,SIGMA,IERR) IF (IERR .NE. 0) THEN PRINT *, 'Error return from SURF =',IERR STOP ENDIF C C Get interpolated points using SURF2. C TINCX = 1.0/(NXO-1) TINCY = 1.0/(NYO-1) DO 20 I=1,NXO XO(I) = (I-1)*TINCX DO 10 J=1,NYO YO(J) = (J-1)*TINCY ZO(I,J) = SURF2(XO(I),YO(J),NXI,NYI,X,Y,Z,NXI,ZP,SIGMA) 10 CONTINUE 20 CONTINUE C C Plot a surface. C CALL GOPKS (IERRF, ISZDM) CALL GOPWK (IWKID, LUNIT, IWTYPE) CALL GACWK (IWKID) CALL TDEZ2D(NXO, NYO, XO, YO, ZO, 3., 36., 67., -6) CALL FRAME() CALL GDAWK (IWKID) CALL GCLWK (IWKID) CALL GCLKS C STOP END
c subroutine read_x2c_pc_dip(icomp,g_pcdip) c implicit none c #include "mafdecls.fh" #include "global.fh" #include "tcgmsg.fh" #include "util.fh" #include "stdio.fh" #include "errquit.fh" #include "msgids.fh" #include "dra.fh" #include "inp.fh" #include "msgtypesf.h" c integer icomp integer g_pcdip c character*(nw_max_path_len) fn_pcdip character*3 ch_comp c logical dmat_from_file external dmat_from_file c integer inntsize,ok c c prepare file name call util_file_name('pcdip',.false.,.false.,fn_pcdip) if (icomp.eq.1) ch_comp='.1' if (icomp.eq.2) ch_comp='.2' if (icomp.eq.3) ch_comp='.3' fn_pcdip = fn_pcdip(1:inp_strlen(fn_pcdip))//ch_comp ! append component c c resolve path call util_file_name_resolve(fn_pcdip, .false.) c c read ga from file if (.not. dmat_from_file(g_pcdip,fn_pcdip)) & call errquit('read_x2c_pc_dip: dmat_from_file',0, & UNKNOWN_ERR) c c propagate status ok = 1 inntsize=MA_sizeof(MT_INT,1,MT_BYTE) call ga_brdcst(Msg_Vec_Stat+MSGINT, ok, inntsize, 0) ! Propagate status call ga_sync() c return end
!*********************************************************************** ! LICENSING ! Copyright (C) 2013 National Renewable Energy Laboratory (NREL) ! ! This is free software: you can redistribute it and/or modify it ! under the terms of the GNU General Public License as ! published by the Free Software Foundation, either version 3 of the ! License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty ! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. ! If not, see <http://www.gnu.org/licenses/>. ! !*********************************************************************** ! This code was created at NREL by Michael A. Sprague and Ignas ! Satkauskas and was meant for open-source distribution. ! ! Software was created under funding from a Shared Research Grant ! from the Center for Research and Education in Wind (CREW), during ! the period 01 October 2011 - 31 January 2013. ! ! http://crew.colorado.edu/ ! ! Questions? Please contact Michael Sprague: ! email: michael.a.sprague@nrel.gov ! !*********************************************************************** subroutine u3_solve(x,d,e,f,b,nx,ny) implicit double precision (a-h,o-z) C primary variables double precision x(nx*ny) !solution double precision d(nx*ny-1) !main diagonal, 0th double precision e(nx*ny-2) !super diagonal, 1st double precision f(nx*ny-nx-1) !ny-th diagonal double precision b(nx*ny) !RHS c open(unit=49,file='u3.dat',status='unknown') x(1)=0.d0 n = nx*ny-1 m = nx do i = 2,n+1 x(i) = b(i) enddo do i = n,m+1,-1 x(i+1) = x(i+1)/d(i) x(i) = x(i) - x(i+1)*e(i-1) x(i-m+1) = x(i-m+1) - x(i+1)*f(i-m) enddo do i = m,2,-1 x(i+1) = x(i+1)/d(i) x(i) = x(i) - x(i+1)*e(i-1) enddo i = 1 x(i+1) = x(i+1)/d(i) c do i = 1,n+1 c write(49,*) x(i) c enddo return end
SUBROUTINE F01ACZ(N,EPS,A,IA,B,IB,Z,L,IFAIL) C MARK 16 RELEASE. NAG COPYRIGHT 1993 C C This routine originally called F01ACF. C ACCINVERSE C THE UPPER TRIANGLE OF A POSITIVE DEFINITE SYMMETRIC MATRIX, C A, IS STORED IN THE UPPER TRIANGLE OF AN (N+1)*N ARRAY C A(I,J), I=1,N+1, J=1,N. X, THE INVERSE OF A, IS FORMED IN C THE REMAINDER OF THE ARRAY A(I,J) BY THE SUBROUTINE F01ADF C CHOLINVERSION 1. THE INVERSE IS IMPROVED BY CALCULATING X=X+Z C UNTIL THE CORRECTION, Z, IS SUCH THAT MAXIMUM ABS(Z(I,J)) IS C LESS THAN 2 EPS TIMES MAXIMUM ABS(X(I,J)), WHERE Z=XB AND C B=I-AX. B IS AN N*N ARRAY AND Z IS A 1*N ARRAY, X BEING C OVERWRITTEN A ROW AT A TIME. EXITS WITH IFAIL = 1 IF A IS C NOT POSITIVE DEFINITE AND WITH IFAIL = 2 IF THE MAXIMUM C CORRECTION AT ANY STAGE IS NOT LESS THAN HALF THAT AT THE C PREVIOUS STAGE. L IS THE NUMBER OF CORRECTIONS APPLIED. C ADDITIONAL PRECISION INNERPRODUCTS ARE ABSOLUTELY NECESSARY. C 1ST DECEMBER 1971 C C .. Parameters .. CHARACTER*6 SRNAME PARAMETER (SRNAME='F01ACZ') C .. Scalar Arguments .. DOUBLE PRECISION EPS INTEGER IA, IB, IFAIL, L, N C .. Array Arguments .. DOUBLE PRECISION A(IA,N), B(IB,N), Z(N) C .. Local Scalars .. DOUBLE PRECISION C, C1, C2, D, D1, D2, E, XMAX, ZMAX INTEGER I, IFAIL1, ISAVE, J, J1 C .. Local Arrays .. CHARACTER*1 P01REC(1) C .. External Functions .. INTEGER P01ABF EXTERNAL P01ABF C .. External Subroutines .. EXTERNAL F01ADF, X03AAF C .. Intrinsic Functions .. INTRINSIC ABS C .. Executable Statements .. ISAVE = IFAIL IFAIL1 = 0 E = 1.0D0 L = 0 IFAIL = 1 CALL F01ADF(N,A,IA,IFAIL) IF (IFAIL.EQ.0) GO TO 20 IFAIL = P01ABF(ISAVE,1,SRNAME,0,P01REC) RETURN 20 DO 100 I = 1, N DO 80 J = 1, N J1 = J + 1 C1 = 0.0D0 IF (J.LT.I) GO TO 40 IF (I.EQ.J) C1 = -1.0D0 CALL X03AAF(A(1,I),(N-I+1)*IA,A(J1,1) * ,N*IA-J1+1,I,1,IA,C1,0.0D0,D1,D2,.TRUE.,IFAIL1) IF (I.EQ.N) GO TO 60 C1 = D1 C2 = D2 CALL X03AAF(A(I,I+1),(N-I)*IA-I+1,A(J1,I+1),(N-I) * *IA-J1+1,J-I,IA,IA,C1,C2,D1,D2,.TRUE.,IFAIL1) IF (J1.GT.N) GO TO 60 C1 = D1 C2 = D2 CALL X03AAF(A(I,J1),(N-J)*IA-I+1,A(J1+1,J),(N-J+1) * *IA-J1,N-J,IA,1,C1,C2,D1,D2,.TRUE.,IFAIL1) GO TO 60 40 CALL X03AAF(A(1,I),(N-I+1)*IA,A(J1,1) * ,N*IA-J1+1,J,1,IA,C1,0.0D0,D1,D2,.TRUE.,IFAIL1) C1 = D1 C2 = D2 CALL X03AAF(A(J1,I),(N-I+1)*IA-J1+1,A(J1+1,J),(N-J+1) * *IA-J1,I-J1+1,1,1,C1,C2,D1,D2,.TRUE.,IFAIL1) IF (I.EQ.N) GO TO 60 C1 = D1 C2 = D2 CALL X03AAF(A(I,I+1),(N-I)*IA-I+1,A(I+2,J),(N-J+1) * *IA-I-1,N-I,IA,1,C1,C2,D1,D2,.TRUE.,IFAIL1) 60 B(I,J) = -D1 80 CONTINUE 100 CONTINUE XMAX = 0.0D0 ZMAX = 0.0D0 DO 180 I = 1, N DO 140 J = 1, I CALL X03AAF(A(I+1,1),N*IA-I,B(1,J),(N-J+1) * *IB,I,IA,1,0.0D0,0.0D0,D1,D2,.TRUE.,IFAIL1) IF (I.EQ.N) GO TO 120 C1 = D1 C2 = D2 CALL X03AAF(A(I+2,I),(N-I+1)*IA-I-1,B(I+1,J),(N-J+1) * *IB-I,N-I,1,1,C1,C2,D1,D2,.TRUE.,IFAIL1) 120 Z(J) = D1 140 CONTINUE DO 160 J = 1, I C = ABS(A(I+1,J)) D = ABS(Z(J)) IF (C.GT.XMAX) XMAX = C IF (D.GT.ZMAX) ZMAX = D A(I+1,J) = A(I+1,J) + Z(J) 160 CONTINUE 180 CONTINUE L = L + 1 D = ZMAX/XMAX IF (D.GT.E/2.0D0) GO TO 200 E = D IF (D.GT.2.0D0*EPS) GO TO 20 IFAIL = 0 RETURN 200 IFAIL = P01ABF(ISAVE,2,SRNAME,0,P01REC) RETURN END
c.. n-planet integrator, with restart capability c.. current configuration is for sun + nine planets program Integrator implicit real*8(a-h,o-z), integer*4(i-n) parameter (nb=10) parameter(n=6*nb,pi=3.14159265358979323846) dimension y(n),dydx(n),yscal(n) dimension abod(nb),ebody(nb),ri(nb),rOm(nb),fsini(nb) dimension period(nb),rnode(nb),anom(nb),Tperi(nb),rK(nb) common /path2/ rm(nb) external derivs c.. Set physical constants rmsun=1.98911e+33 rau=1.495978707e+13 G=6.672e-8 rmjup=1.8986e+30 year=365.25*24.*3600. c.. open the input file open(unit=1,file='input',status='old') c.. open the output files (one for each planet) c.. (only nb-1 files will be used) open(unit=11,file='planet.1',status='unknown') open(unit=12,file='planet.2',status='unknown') open(unit=13,file='planet.3',status='unknown') open(unit=14,file='planet.4',status='unknown') open(unit=15,file='planet.5',status='unknown') open(unit=16,file='planet.6',status='unknown') open(unit=17,file='planet.7',status='unknown') open(unit=18,file='planet.8',status='unknown') open(unit=19,file='planet.9',status='unknown') c.. read in start-up conditions from the input file c.. integration duration (years) read(1,*) x2 c.. printout interval read(1,*) nprint c.. mass of the central star read(1,*) rmstar rmstar=rmstar*rmsun rm(1)=rmstar c.. do we produce a surface of section? read(1,*) isection if(isection.eq.1) then open(unit=20,file='section.data',status='unknown') icross=0 ncross=0 end if read(1,*) iperiod c.. Periods or semi-major axes do i=2,nb if (iperiod.eq.0) then read(1,*) abod(i) abod(i)=abod(i)*rau else read(1,*) period(i) period(i)=period(i)*(24.*3600.) end if end do c.. Mean anomaly (0), T Peri (1), or mean longitude (2) read(1,*) imean if(imean.eq.0) then do i=2,nb read(1,*) anom(i) anom(i)=((anom(i))/360.)*2.*pi end do elseif(imean.eq.1) then c.. alternately read time of periastron passage do i=2,nb read(1,*) Tperi(i) Tperi(i)=Tperi(i)*(24.*3600.) end do elseif(imean.eq.2) then do i=2,nb read(1,*) anom(i) anom(i)=((anom(i))/360.)*2.*pi end do end if c.. current epoch: read(1,*) Epoch epochdays=epoch Epoch=Epoch*(24.*3600.) c.. eccentricities do i=2,nb read(1,*) ebody(i) end do c.. argument of perihelion do i=2,nb read(1,*) rOm(i) rOm(i)=((rOm(i))/360.)*2.*pi end do c.. adjust time of perihelion passage or mean longitude to mean anomaly if(imean.eq.1) then do i=2,nb anom(i)=((2.*pi)/period(i))*(epoch-Tperi(i)) end do end if if(imean.eq.2) then do i=2,nb anom(i)=anom(i)-rOm(i) end do end if c.. inclinations do i=2,nb read(1,*) ri(i) fsini(i)=sin(((90.-abs(ri(i)))/360.)*2.*pi) ri(i)=((ri(i))/360.)*2.*pi end do c.. nodes do i=2,nb read(1,*) rnode(i) rnode(i)=((rnode(i))/360.)*2.*pi end do c.. if ijov=1, then we are reading in masses directly read(1,*) ijov if(ijov.eq.1) then do i=2,nb read(1,*) rm(i) rm(i)=rm(i)*(1.0e+27) rmsum=0. do j=1,i rmsum=rmsum+rm(j) end do if(iperiod.eq.1) then abod(i)=period(i)*period(i)*G*(rmsum) abod(i)=abod(i)/(4.*pi*pi) abod(i)=abod(i)**0.33333333333 end if if(iperiod.eq.0) then period(i)=sqrt(abod(i)**3*4*pi*pi/(G*rmsum)) end if end do c.. if ijov=0, then we get the masses from radial velocity half-amplitudes elseif(ijov.eq.0) then rminterior=0. do j=2,nb read(1,*) rK(j) rK(j)=rK(j)*100. do i=1,100000000 rmp=(real(i)/10000.) rmp=rmp*rmjup abod(j)=period(j)*period(j)*G*(rmstar+rmp+rminterior) abod(j)=abod(j)/(4.*pi*pi) abod(j)=abod(j)**0.33333333333 q1=(1./rK(j))*(2.*pi*G/period(j))**0.333333333 q1=q1/sqrt(1-ebody(j)*ebody(j)) q1=(q1*rmp*fsini(j))/(rmstar+rmp+rminterior)**0.66666666 if(q1.gt.1.) then rm(j)=rmp goto 4104 end if end do 4104 continue rminterior=rminterior+rm(j) end do end if c.. code uses units G=1,m=1Msun,t=1yr,d=5.091369e+13cm rlu=(G*rmsun*(year**2))**0.333333333333 do i=2,nb abod(i)=abod(i)/rlu end do do i=1,nb rm(i)=rm(i)/rmsun end do do i=2,nb period(i)=period(i)/year end do c.. Timestep accuracy for Bulirsch-Stoer read(1,*) acc c.. timestep length for integrator (fraction of Period(2)) read(1,*) hfactor hstep=hfactor*period(2) c.. Jacobi (ijac=1) or astrometric (ijac=0) coordinates read(1,*) ijac c.. miscellaneous initializations c.. number of phase space dimensions nvar=n c.. starting time for the integration x=0. c.. number of integration steps completed iflag=0 c.. convert initial orbital elements to cartesian initial conditions c.. in star-centered frame: c.. options for astrocentric or jacobi coordinates: if(ijac.eq.0) then c.. use astrocentric y(1)=0.0 y(3)=0.0 y(5)=0.0 y(2)=0.0 y(4)=0.0 y(6)=0.0 do i=2,nb rmu=rm(1)+rm(i) q=abod(i)*(1.-ebody(i)) e=ebody(i) rinc=ri(i) p=rOm(i) rn=rnode(i) rl=anom(i) c.. this routine does the elements to cartesian conversion call mco_el2x (rmu,q,e,rinc,p,rn,rl,rx,ry,rz,ru,rv,rw) y(6*(i-1)+1)=rx y(6*(i-1)+3)=ry y(6*(i-1)+5)=rz y(6*(i-1)+2)=ru y(6*(i-1)+4)=rv y(6*(i-1)+6)=rw end do elseif (ijac.eq.1) then c.. use jacobi y(1)=0.0 y(3)=0.0 y(5)=0.0 y(2)=0.0 y(4)=0.0 y(6)=0.0 do i=2,nb xcom=0. ycom=0. zcom=0. vxcom=0. vycom=0. vzcom=0. do jdum=1,i-1 xcom=xcom+rm(jdum)*y(6*(jdum-1)+1) ycom=ycom+rm(jdum)*y(6*(jdum-1)+3) zcom=zcom+rm(jdum)*y(6*(jdum-1)+5) vxcom=vxcom+rm(jdum)*y(6*(jdum-1)+2) vycom=vycom+rm(jdum)*y(6*(jdum-1)+4) vzcom=vzcom+rm(jdum)*y(6*(jdum-1)+6) end do rmu=0.0 do jdum=1,i-1 rmu=rmu+rm(jdum) end do xcom=xcom/rmu ycom=ycom/rmu zcom=zcom/rmu vxcom=vxcom/rmu vycom=vycom/rmu vzcom=vzcom/rmu rmu=rmu+rm(i) q=abod(i)*(1.-ebody(i)) e=ebody(i) rinc=ri(i) p=rOm(i) rn=rnode(i) rl=anom(i) c.. this routine does the elements to cartesian conversion c.. (it is from the swift package via john chambers) call mco_el2x (rmu,q,e,rinc,p,rn,rl,rx,ry,rz,ru,rv,rw) y(6*(i-1)+1)=rx+xcom y(6*(i-1)+3)=ry+ycom y(6*(i-1)+5)=rz+zcom y(6*(i-1)+2)=ru+vxcom y(6*(i-1)+4)=rv+vycom y(6*(i-1)+6)=rw+vzcom end do end if c.. evaluate the orbital elements if(ijac.eq.0)then do i=2,nb v1=rm(1)+rm(i) v2=y(6*(i-1)+1)-y(1) v3=y(6*(i-1)+3)-y(3) v4=y(6*(i-1)+5)-y(5) v5=y(6*(i-1)+2)-y(2) v6=y(6*(i-1)+4)-y(4) v7=y(6*(i-1)+6)-y(6) call mco_x2el(v1,v2,v3,v4,v5,v6,v7,q,e,rinc,p,rn,rl) q=q/(1-e) write(*,*) 'Planet ',i,' starting Conditions:' write(*,*) 'a, e, i (dg), argper (dg), rn, m. anom. (dg)' rinc=(rinc/(2.*pi))*360. p= (p/(2.*pi))*360. rn=(rn/(2.*pi))*360. rl=(rl/(2.*pi))*360. write(*,*) (q*rlu)/rau,e,rinc,p,rn,rl end do elseif (ijac.eq.1) then do i=2,nb xcom=0. ycom=0. zcom=0. vxcom=0. vycom=0. vzcom=0. do jdum=1,i-1 xcom=xcom+rm(jdum)*y(6*(jdum-1)+1) ycom=ycom+rm(jdum)*y(6*(jdum-1)+3) zcom=zcom+rm(jdum)*y(6*(jdum-1)+5) vxcom=vxcom+rm(jdum)*y(6*(jdum-1)+2) vycom=vycom+rm(jdum)*y(6*(jdum-1)+4) vzcom=vzcom+rm(jdum)*y(6*(jdum-1)+6) end do rmu=0.0 do jdum=1,i-1 rmu=rmu+rm(jdum) end do xcom=xcom/rmu ycom=ycom/rmu zcom=zcom/rmu vxcom=vxcom/rmu vycom=vycom/rmu vzcom=vzcom/rmu rmu=rmu+rm(i) v1=rmu v2=y(6*(i-1)+1)-xcom v3=y(6*(i-1)+3)-ycom v4=y(6*(i-1)+5)-zcom v5=y(6*(i-1)+2)-vxcom v6=y(6*(i-1)+4)-vycom v7=y(6*(i-1)+6)-vzcom call mco_x2el(v1,v2,v3,v4,v5,v6,v7,q,e,rinc,p,rn,rl) q=q/(1-e) write(*,*) 'Planet ',i,' starting Conditions:' write(*,*) 'a, e, i (dg), argper (dg), rn, m. anom. (dg)' rinc=(rinc/(2.*pi))*360. p= (p/(2.*pi))*360. rn=(rn/(2.*pi))*360. rl=(rl/(2.*pi))*360. write(*,*) (q*rlu)/rau,e,rinc,p,rn,rl end do end if c.. Compute and subtract off center-of-mass velocity rmtot=0. vcx=0. vcy=0. vcz=0. do i=1,nb ib=(i-1)*6 rmtot=rmtot+rm(i) vcx=vcx+rm(i)*y(ib+2) vcy=vcy+rm(i)*y(ib+4) vcz=vcz+rm(i)*y(ib+6) end do vcx=vcx/rmtot vcy=vcy/rmtot vcz=vcz/rmtot do i=1,nb ib=(i-1)*6 y(ib+2)=y(ib+2)-vcx y(ib+4)=y(ib+4)-vcy y(ib+6)=y(ib+6)-vcz end do c.. Determine initial System Energy call EnergySum(y,Energy) Eorig=Energy c.. Initializations now finished. c.. Start the overall integration loop for the system 2105 continue iflag=iflag+1 htry=hstep c.. Use current timestep to take a Bulirsch-Stoer Integration Step call derivs(x,y,dydx) c.. refer accuracy to expected phase space values: do iscale=1,nvar yscal(iscale)=abs(y(iscale))+abs(htry*dydx(iscale))+1.e-30 end do call bsstep(y,dydx,nvar,x,htry,acc,yscal,hdid,hnext,derivs) c.. Probe the system at cadence nprint, c.. or alternatively, check for axis crossing if isection=1: if(mod(iflag,nprint).eq.0.or.isection.eq.1) then c.. Check conservation call EnergySum(y,Energy) Efrac=Energy/Eorig check=dabs(1.-Efrac) c.. evaluate orbital elements using john chamber's routine: if(mod(iflag,nprint).eq.0) then c.. print the time to the screen write(*,*) x if(ijac.eq.0)then do i=2,nb v1=rm(1)+rm(i) v2=y(6*(i-1)+1)-y(1) v3=y(6*(i-1)+3)-y(3) v4=y(6*(i-1)+5)-y(5) v5=y(6*(i-1)+2)-y(2) v6=y(6*(i-1)+4)-y(4) v7=y(6*(i-1)+6)-y(6) call mco_x2el(v1,v2,v3,v4,v5,v6,v7,q,e,rinc,p,rn,rl) q=q/(1-e) rinc=(rinc/(2.*pi))*360. p= (p/(2.*pi))*360. rn=(rn/(2.*pi))*360. rl=(rl/(2.*pi))*360. ifile=9+i c.. print elements to file write(ifile,2134) x,(q*rlu)/rau,e,rinc,p,rn,rl 2134 format(7e13.6) end do elseif (ijac.eq.1) then do i=2,nb xcom=0. ycom=0. zcom=0. vxcom=0. vycom=0. vzcom=0. do jdum=1,i-1 xcom=xcom+rm(jdum)*y(6*(jdum-1)+1) ycom=ycom+rm(jdum)*y(6*(jdum-1)+3) zcom=zcom+rm(jdum)*y(6*(jdum-1)+5) vxcom=vxcom+rm(jdum)*y(6*(jdum-1)+2) vycom=vycom+rm(jdum)*y(6*(jdum-1)+4) vzcom=vzcom+rm(jdum)*y(6*(jdum-1)+6) end do rmu=0.0 do jdum=1,i-1 rmu=rmu+rm(jdum) end do xcom=xcom/rmu ycom=ycom/rmu zcom=zcom/rmu vxcom=vxcom/rmu vycom=vycom/rmu vzcom=vzcom/rmu rmu=rmu+rm(i) v1=rmu v2=y(6*(i-1)+1)-xcom v3=y(6*(i-1)+3)-ycom v4=y(6*(i-1)+5)-zcom v5=y(6*(i-1)+2)-vxcom v6=y(6*(i-1)+4)-vycom v7=y(6*(i-1)+6)-vzcom call mco_x2el(v1,v2,v3,v4,v5,v6,v7,q,e,rinc,p,rn,rl) q=q/(1-e) rinc=(rinc/(2.*pi))*360. p= (p/(2.*pi))*360. rn=(rn/(2.*pi))*360. rl=(rl/(2.*pi))*360. ifile=i+9 c.. print elements to file write(ifile,2134) x,(q*rlu)/rau,e,rinc,p,rn,rl end do end if end if c.. check for periastron passage of second planet in order to construct surface of section c.. This block occurs if if(isection.eq.1) then if(rl.lt.0.5 .and. icross.eq.0) then icross=1 if((y(13).gt.0.).and.(y(15).gt.0.)) then phase3=atan(y(15)/y(13)) elseif((y(13).lt.0.).and.(y(15).gt.0.)) then phase3=atan(y(15)/y(13))+pi elseif((y(13).lt.0.).and.(y(15).lt.0.)) then phase3=atan(y(15)/y(13))+pi else phase3=atan(y(15)/y(13))+2*pi end if if((y(7).gt.0.).and.(y(9).gt.0.)) then phase2=atan(y(9)/y(7)) elseif((y(7).lt.0.).and.(y(9).gt.0.)) then phase2=atan(y(9)/y(7))+pi elseif((y(7).lt.0.).and.(y(9).lt.0.)) then phase2=atan(y(9)/y(7))+pi else phase2=atan(y(9)/y(7))+2*pi end if diff=phase3-phase2 ratio=q3/q2 if(diff.lt.0.) diff=diff+2.*pi ncross=ncross+1 if(mod(ncross,1).eq.0) then write(20,*) diff,ratio,x end if end if if(rl.gt.2. .and. icross.eq.1) then icross=0 end if end if c.. end surface of section calculation 2234 format(8e11.4) c.. check if physical time exceeded: if(x.gt.x2) then istop=2 goto 2106 end if end if c.. return to beginning of integration loop goto 2105 c.. we've finished up. Write the finish code to 'finish' 2106 continue open(unit=30,file='finish',status='unknown') write(30,*) istop close(30) c.. and we're done! end subroutine derivs(x,y,dydx) implicit real*8(a-h,o-z), integer*4(i-n) parameter (nb=10) common /path2/ rm(nb) parameter(n=6*nb) real*8 x,y(n),dydx(n) real*8 denom(nb,nb) do i=2,n,2 dydx(i-1)=y(i) end do do i=1,nb do j=1,nb denom(i,j)=1. end do end do do i=1,nb do j=i+1,nb if (i.ne.j) then jb=(j-1)*6 ib=(i-1)*6 ytx=y(jb+1)-y(ib+1) yty=y(jb+3)-y(ib+3) ytz=y(jb+5)-y(ib+5) denom(i,j)=ytx*ytx + yty*yty + ytz*ytz denom(i,j)=sqrt(denom(i,j))*denom(i,j) denom(j,i)=denom(i,j) end if end do end do do i=1,nb ib=(i-1)*6 do ic=1,3 dydx(ib+(2*ic))=0. do j=1,nb jb=(j-1)*6 if( i.ne.j) then dydx(ib+(2*ic))=dydx(ib+(2*ic)) - + rm(j)*(y(ib+2*ic-1)-y(jb+2*ic-1))/denom(i,j) end if end do end do end do return end c................................................................... subroutine EnergySum(y,energy) c................................................................... implicit real*8(a-h,o-z), integer*4(i-n) parameter (nb=10) common /path2/ rm(nb) real*8 y(6*nb) dimension denom(nb,nb) do i=1,nb do j=1,nb denom(i,j)=1.e+10 end do end do do i=1,nb ib=(i-1)*6 do j=1,nb jb=(j-1)*6 if (i.ne.j) then denom(i,j) = (y(jb+1)-y(ib+1))**2 + +(y(jb+3)-y(ib+3))**2 + +(y(jb+5)-y(ib+5))**2 denom(i,j)=sqrt(denom(i,j)) end if end do end do Energy=0. do i=1,nb ib=(i-1)*6 do j=1,nb if(i.ne.j) then Energy=Energy-0.5*rm(i)*rm(j)/denom(i,j) end if end do do ic=1,3 Energy=Energy+0.5*rm(i)*y(ib+2*ic)**2 end do end do return end c....................................................................... double precision FUNCTION RAN2(IDUM) c....................................................................... c.....random number generator (from numerical recipies) implicit real*8(a-h,o-z), integer*4(i-n) PARAMETER (M=714025,IA=1366,IC=150889,RM=1.4005112E-6) DIMENSION IR(97) DATA IFF /0/ save IF(IDUM.LT.0.OR.IFF.EQ.0)THEN IFF=1 IDUM=MOD(IC-IDUM,M) DO 11 J=1,97 IDUM=MOD(IA*IDUM+IC,M) IR(J)=IDUM 11 CONTINUE IDUM=MOD(IA*IDUM+IC,M) IY=IDUM ENDIF J=1+(97*IY)/M IF(J.GT.97.OR.J.LT.1)PAUSE IY=IR(J) RAN2=IY*RM IDUM=MOD(IA*IDUM+IC,M) IR(J)=IDUM RETURN end subroutine bsstep(y,dydx,nv,x,htry,eps,yscal,hdid,hnext,derivs) implicit real*8(a-h,o-z), integer*4(i-n) integer*4 nv,nmax,kmaxx,imax real*8 eps,hdid,hnext,htry,x,dydx(nv),y(nv),yscal(nv),safe1, + safe2,redmax,redmin,tiny,scalmx parameter (nmax=100,kmaxx=8,imax=kmaxx+1,safe1=0.25,safe2=0.7, + redmax=1.e-5,redmin=0.7,tiny=1.e-30,scalmx=0.1) integer*4 i,iq,k,kk,km,kmax,kopt,nseq(imax) real*8 eps1,epsold,errmax,fact,h,red,scale,work,wrkmin,xest, + xnew,a(imax),alf(kmaxx,kmaxx),err(kmaxx),yerr(nmax), + ysav(nmax),yseq(nmax) logical first,reduct external derivs data first/.true./,epsold/-1./ data nseq /2,4,6,8,10,12,14,16,18/ save a,alf,epsold, first,kmax,kopt,nseq,xnew if(eps.ne.epsold)then hnext=-1.e29 xnew=-1.e29 eps1=safe1*eps a(1)=nseq(1)+1 do k=1,kmaxx a(k+1)=a(k)+nseq(k+1) end do do iq=2,kmaxx do k=1,iq-1 alf(k,iq)=eps1**((a(k+1)-a(iq+1))/ + ((a(iq+1)-a(1)+1.)*(2*k+1))) end do end do epsold=eps do kopt=2,kmaxx-1 if(a(kopt+1).gt.a(kopt)*alf(kopt-1,kopt))goto 1 end do 1 kmax=kopt end if h=htry do i=1,nv ysav(i)=y(i) end do if(h.ne.hnext.or.x.ne.xnew) then first=.true. kopt=kmax end if reduct=.false. 2 do k=1,kmax xnew=x+h if(xnew.eq.x) pause 'step size underflow in bsstep' call mmid(ysav,dydx,nv,x,h,nseq(k),yseq,derivs) xest=(h/nseq(k))**2 call pzextr(k,xest,yseq,y,yerr,nv) if(k.ne.1) then errmax=TINY do i=1,nv errmax=max(errmax,abs(yerr(i)/yscal(i))) end do errmax=errmax/eps km=k-1 err(km)=(errmax/safe1)**(1./(2*km+1)) end if if(k.ne.1.and.(k.ge.kopt-1.or.first)) then if(errmax.lt.1.) goto 4 if(k.eq.kmax.or.k.eq.kopt+1) then red=safe2/err(km) goto 3 else if(k.eq.kopt) then if(alf(kopt-1,kopt).lt.err(km))then red=1./err(km) goto 3 end if else if(kopt.eq.kmax) then if(alf(km,kmax-1).lt.err(km))then red=alf(km,kmax-1)* + safe2/err(km) goto 3 endif else if(alf(km,kopt).lt.err(km))then red=alf(km,kopt-1)/err(km) goto 3 end if end if end do 3 red=min(red,redmin) red=max(red,redmax) h=h*red reduct=.true. goto 2 4 x=xnew hdid=h first=.false. wrkmin=1.e35 do kk=1,km fact=max(err(kk),scalmx) work=fact*a(kk+1) if(work.lt.wrkmin) then scale=fact wrkmin=work kopt=kk+1 end if end do hnext=h/scale if(kopt.ge.k.and.kopt.ne.kmax.and..not.reduct)then fact=max(scale/alf(kopt-1,kopt),scalmx) if(a(kopt+1)*fact.le.wrkmin)then hnext=h/fact kopt=kopt+1 endif end if return end subroutine pzextr(iest,xest,yest,yz,dy,nv) implicit real*8(a-h,o-z), integer*4(i-n) integer*4 iest,nv,imax,nmax real*8 xest,dy(nv),yest(nv),yz(nv) parameter (imax=13,nmax=100) integer*4 j,k1 real*8 delta,f1,f2,q,d(nmax),qcol(nmax,imax),x(imax) save qcol,x x(iest)=xest do j=1,nv dy(j)=yest(j) yz(j)=yest(j) end do if(iest.eq.1) then do j=1,nv qcol(j,1)=yest(j) end do else do j=1,nv d(j)=yest(j) end do do k1=1,iest-1 delta=1./(x(iest-k1)-xest) f1=xest*delta f2=x(iest-k1)*delta do j=1,nv q=qcol(j,k1) qcol(j,k1)=dy(j) delta=d(j)-q dy(j)=f1*delta d(j)=f2*delta yz(j)=yz(j)+dy(j) end do end do do j=1,nv qcol(j,iest)=dy(j) end do end if return end subroutine mmid(y,dydx,nvar,xs,htot,nstep,yout,derivs) integer*4 nstep,nvar,nmax real*8 htot,xs,dydx(nvar),y(nvar),yout(nvar) external derivs parameter (nmax=100) integer*4 i,n real*8 h,h2,swap,x,ym(nmax),yn(nmax) h=htot/nstep do i=1,nvar ym(i)=y(i) yn(i)=y(i)+h*dydx(i) end do x=xs+h call derivs(x,yn,yout) h2=2.*h do n=2,nstep do i=1,nvar swap=ym(i)+h2*yout(i) ym(i)=yn(i) yn(i)=swap end do x=x+h call derivs(x,yn,yout) end do do i=1,nvar yout(i)=0.5*(ym(i)+yn(i)+h*yout(i)) end do return end c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c MCO_X2EL.FOR (ErikSoft 6 May 2000) c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c Author: John E. Chambers c Calculates Keplerian orbital elements given relative coordinates and c velocities, and MU = G times the sum of the masses. c c The elements are: q = perihelion distance c e = eccentricity c i = inclination c p = longitude of perihelion (NOT argument of perihelion!!) c n = longitude of ascending node c l = mean anomaly (or mean longitude if e < 1.e-8) c c------------------------------------------------------------------------------ c subroutine mco_x2el (mu,x,y,z,u,v,w,q,e,i,p,n,l) c implicit none integer NMAX, CMAX, NMESS real*8 HUGE parameter (NMAX = 2000) parameter (CMAX = 50) parameter (NMESS = 200) parameter (HUGE = 9.9d29) c Constants: c c DR = conversion factor from degrees to radians c K2 = Gaussian gravitational constant squared c AU = astronomical unit in cm c MSUN = mass of the Sun in g c real*8 PI,TWOPI,PIBY2,DR,K2,AU,MSUN c parameter (PI = 3.141592653589793d0) parameter (TWOPI = PI * 2.d0) parameter (PIBY2 = PI * .5d0) parameter (DR = PI / 180.d0) parameter (K2 = 2.959122082855911d-4) parameter (AU = 1.4959787e13) parameter (MSUN = 1.9891e33) c c Input/Output real*8 mu,q,e,i,p,n,l,x,y,z,u,v,w c c Local real*8 hx,hy,hz,h2,h,v2,r,rv,s,true real*8 ci,to,temp,tmp2,bige,f,cf,ce c c------------------------------------------------------------------------------ c hx = y * w - z * v hy = z * u - x * w hz = x * v - y * u h2 = hx*hx + hy*hy + hz*hz v2 = u * u + v * v + w * w rv = x * u + y * v + z * w r = sqrt(x*x + y*y + z*z) h = sqrt(h2) s = h2 / mu c c Inclination and node ci = hz / h if (abs(ci).lt.1) then i = acos (ci) n = atan2 (hx,-hy) if (n.lt.0) n = n + TWOPI else if (ci.gt.0) i = 0.d0 if (ci.lt.0) i = PI n = 0.d0 end if c c Eccentricity and perihelion distance temp = 1.d0 + s*(v2/mu - 2.d0/r) if (temp.le.0) then e = 0.d0 else e = sqrt (temp) end if q = s / (1.d0 + e) c c True longitude if (hy.ne.0) then to = -hx/hy temp = (1.d0 - ci) * to tmp2 = to * to true = atan2((y*(1.d0+tmp2*ci)-x*temp),(x*(tmp2+ci)-y*temp)) else true = atan2(y * ci, x) end if if (ci.lt.0) true = true + PI c if (e.lt.1.d-8) then p = 0.d0 l = true else ce = (v2*r - mu) / (e*mu) c c Mean anomaly for ellipse if (e.lt.1) then if (abs(ce).gt.1) ce = sign(1.d0,ce) bige = acos(ce) if (rv.lt.0) bige = TWOPI - bige l = bige - e*sin(bige) else c c Mean anomaly for hyperbola if (ce.lt.1) ce = 1.d0 bige = log( ce + sqrt(ce*ce-1.d0) ) if (rv.lt.0) bige = TWOPI - bige l = e*sinh(bige) - bige end if c c Longitude of perihelion cf = (s - r) / (e*r) if (abs(cf).gt.1) cf = sign(1.d0,cf) f = acos(cf) if (rv.lt.0) f = TWOPI - f p = true - f p = mod (p + TWOPI + TWOPI, TWOPI) end if c if (l.lt.0) l = l + TWOPI if (l.gt.TWOPI) l = mod (l, TWOPI) c c------------------------------------------------------------------------------ c return end c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c MCO_KEP.FOR (ErikSoft 7 July 1999) c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c Author: John E. Chambers c c Solves Kepler's equation for eccentricities less than one. c Algorithm from A. Nijenhuis (1991) Cel. Mech. Dyn. Astron. 51, 319-330. c c e = eccentricity c l = mean anomaly (radians) c u = eccentric anomaly ( " ) c c------------------------------------------------------------------------------ c function mco_kep (e,oldl) implicit none c c Input/Outout real*8 oldl,e,mco_kep c c Local real*8 l,pi,twopi,piby2,u1,u2,ome,sign real*8 x,x2,sn,dsn,z1,z2,z3,f0,f1,f2,f3 real*8 p,q,p2,ss,cc logical flag,big,bigg c c------------------------------------------------------------------------------ c pi = 3.141592653589793d0 twopi = 2.d0 * pi piby2 = .5d0 * pi c c Reduce mean anomaly to lie in the range 0 < l < pi if (oldl.ge.0) then l = mod(oldl, twopi) else l = mod(oldl, twopi) + twopi end if sign = 1.d0 if (l.gt.pi) then l = twopi - l sign = -1.d0 end if c ome = 1.d0 - e c if (l.ge..45d0.or.e.lt..55d0) then c c Regions A,B or C in Nijenhuis c ----------------------------- c c Rough starting value for eccentric anomaly if (l.lt.ome) then u1 = ome else if (l.gt.(pi-1.d0-e)) then u1 = (l+e*pi)/(1.d0+e) else u1 = l + e end if end if c c Improved value using Halley's method flag = u1.gt.piby2 if (flag) then x = pi - u1 else x = u1 end if x2 = x*x sn = x*(1.d0 + x2*(-.16605 + x2*.00761) ) dsn = 1.d0 + x2*(-.49815 + x2*.03805) if (flag) dsn = -dsn f2 = e*sn f0 = u1 - f2 - l f1 = 1.d0 - e*dsn u2 = u1 - f0/(f1 - .5d0*f0*f2/f1) else c c Region D in Nijenhuis c --------------------- c c Rough starting value for eccentric anomaly z1 = 4.d0*e + .5d0 p = ome / z1 q = .5d0 * l / z1 p2 = p*p z2 = exp( log( dsqrt( p2*p + q*q ) + q )/1.5 ) u1 = 2.d0*q / ( z2 + p + p2/z2 ) c c Improved value using Newton's method z2 = u1*u1 z3 = z2*z2 u2 = u1 - .075d0*u1*z3 / (ome + z1*z2 + .375d0*z3) u2 = l + e*u2*( 3.d0 - 4.d0*u2*u2 ) end if c c Accurate value using 3rd-order version of Newton's method c N.B. Keep cos(u2) rather than sqrt( 1-sin^2(u2) ) to maintain accuracy! c c First get accurate values for u2 - sin(u2) and 1 - cos(u2) bigg = (u2.gt.piby2) if (bigg) then z3 = pi - u2 else z3 = u2 end if c big = (z3.gt.(.5d0*piby2)) if (big) then x = piby2 - z3 else x = z3 end if c x2 = x*x ss = 1.d0 cc = 1.d0 c ss = x*x2/6.*(1. - x2/20.*(1. - x2/42.*(1. - x2/72.*(1. - % x2/110.*(1. - x2/156.*(1. - x2/210.*(1. - x2/272.))))))) cc = x2/2.*(1. - x2/12.*(1. - x2/30.*(1. - x2/56.*(1. - % x2/ 90.*(1. - x2/132.*(1. - x2/182.*(1. - x2/240.*(1. - % x2/306.)))))))) c if (big) then z1 = cc + z3 - 1.d0 z2 = ss + z3 + 1.d0 - piby2 else z1 = ss z2 = cc end if c if (bigg) then z1 = 2.d0*u2 + z1 - pi z2 = 2.d0 - z2 end if c f0 = l - u2*ome - e*z1 f1 = ome + e*z2 f2 = .5d0*e*(u2-z1) f3 = e/6.d0*(1.d0-z2) z1 = f0/f1 z2 = f0/(f2*z1+f1) mco_kep = sign*( u2 + f0/((f3*z1+f2)*z2+f1) ) c c------------------------------------------------------------------------------ c return end c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c MCO_SINE.FOR (ErikSoft 17 April 1997) c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c Author: John E. Chambers c c Calculates sin and cos of an angle X (in radians). c c------------------------------------------------------------------------------ c subroutine mco_sine (x,sx,cx) c implicit none c c Input/Output real*8 x,sx,cx c c Local real*8 pi,twopi c c------------------------------------------------------------------------------ c pi = 3.141592653589793d0 twopi = 2.d0 * pi c if (x.gt.0) then x = mod(x,twopi) else x = mod(x,twopi) + twopi end if c cx = cos(x) c if (x.gt.pi) then sx = -sqrt(1.d0 - cx*cx) else sx = sqrt(1.d0 - cx*cx) end if c c------------------------------------------------------------------------------ c return end c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c MCO_SINH.FOR (ErikSoft 12 June 1998) c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c Calculates sinh and cosh of an angle X (in radians) c c------------------------------------------------------------------------------ c subroutine mco_sinh (x,sx,cx) c implicit none c c Input/Output real*8 x,sx,cx c c------------------------------------------------------------------------------ c sx = sinh(x) cx = sqrt (1.d0 + sx*sx) c c------------------------------------------------------------------------------ c return end *********************************************************************** c ORBEL_FGET.F *********************************************************************** * PURPOSE: Solves Kepler's eqn. for hyperbola using hybrid approach. * * Input: * e ==> eccentricity anomaly. (real scalar) * capn ==> hyperbola mean anomaly. (real scalar) * Returns: * orbel_fget ==> eccentric anomaly. (real scalar) * * ALGORITHM: Based on pp. 70-72 of Fitzpatrick's book "Principles of * Cel. Mech. ". Quartic convergence from Danby's book. * REMARKS: * AUTHOR: M. Duncan * DATE WRITTEN: May 11, 1992. * REVISIONS: 2/26/93 hfl *********************************************************************** real*8 function orbel_fget(e,capn) implicit NONE c... Version of Swift real*8 VER_NUM parameter(VER_NUM=2.0d0) c... Maximum array size integer NPLMAX, NTPMAX c parameter (NPLMAX = 21) ! max number of planets, including the Sun parameter (NPLMAX = 51) ! max number of planets, including the Sun parameter (NTPMAX = 1001) ! max number of test particles c... Size of the test particle integer status flag integer NSTATP ! Number of status parameters parameter (NSTATP = 3) integer NSTAT ! Number of status parameters parameter (NSTAT = NSTATP + NPLMAX - 1) ! include one for @ planet c... Size of the test particle integer status flag integer NSTATR parameter (NSTATR = NSTAT) ! io_init_tp assumes NSTAT==NSTATR c... convergence criteria for danby real*8 DANBYAC , DANBYB parameter (DANBYAC= 1.0d-14, DANBYB = 1.0d-13) c... loop limits in the Laguerre attempts integer NLAG1, NLAG2 parameter(NLAG1 = 50, NLAG2 = 400) c... A small number real*8 TINY PARAMETER(TINY=4.D-15) c... trig stuff real*8 PI,TWOPI,PIBY2,DEGRAD parameter (PI = 3.14159265358979D0) parameter (TWOPI = 2.0D0 * PI) parameter (PIBY2 = PI/2.0D0) parameter (DEGRAD = 180.0D0 / PI) c... Inputs Only: real*8 e,capn c... Internals: integer i,IMAX real*8 tmp,x,shx,chx real*8 esh,ech,f,fp,fpp,fppp,dx PARAMETER (IMAX = 10) c---- c... Executable code c Function to solve "Kepler's eqn" for F (here called c x) for given e and CAPN. c begin with a guess proposed by Danby if( capn .lt. 0.d0) then tmp = -2.d0*capn/e + 1.8d0 x = -log(tmp) else tmp = +2.d0*capn/e + 1.8d0 x = log( tmp) endif orbel_fget = x do i = 1,IMAX call orbel_schget(x,shx,chx) esh = e*shx ech = e*chx f = esh - x - capn c write(6,*) 'i,x,f : ',i,x,f fp = ech - 1.d0 fpp = esh fppp = ech dx = -f/fp dx = -f/(fp + dx*fpp/2.d0) dx = -f/(fp + dx*fpp/2.d0 + dx*dx*fppp/6.d0) orbel_fget = x + dx c If we have converged here there's no point in going on if(abs(dx) .le. TINY) RETURN x = orbel_fget enddo write(6,*) 'FGET : RETURNING WITHOUT COMPLETE CONVERGENCE' return end ! orbel_fget c------------------------------------------------------------------ *********************************************************************** c ORBEL_FLON.F *********************************************************************** * PURPOSE: Solves Kepler's eqn. for hyperbola using hybrid approach. * * Input: * e ==> eccentricity anomaly. (real scalar) * capn ==> hyperbola mean anomaly. (real scalar) * Returns: * orbel_flon ==> eccentric anomaly. (real scalar) * * ALGORITHM: Uses power series for N in terms of F and Newton,s method * REMARKS: ONLY GOOD FOR LOW VALUES OF N (N < 0.636*e -0.6) * AUTHOR: M. Duncan * DATE WRITTEN: May 26, 1992. * REVISIONS: *********************************************************************** real*8 function orbel_flon(e,capn) implicit NONE c... Version of Swift real*8 VER_NUM parameter(VER_NUM=2.0d0) c... Maximum array size integer NPLMAX, NTPMAX c parameter (NPLMAX = 21) ! max number of planets, including the Sun parameter (NPLMAX = 51) ! max number of planets, including the Sun parameter (NTPMAX = 1001) ! max number of test particles c... Size of the test particle integer status flag integer NSTATP ! Number of status parameters parameter (NSTATP = 3) integer NSTAT ! Number of status parameters parameter (NSTAT = NSTATP + NPLMAX - 1) ! include one for @ planet c... Size of the test particle integer status flag integer NSTATR parameter (NSTATR = NSTAT) ! io_init_tp assumes NSTAT==NSTATR c... convergence criteria for danby real*8 DANBYAC , DANBYB parameter (DANBYAC= 1.0d-14, DANBYB = 1.0d-13) c... loop limits in the Laguerre attempts integer NLAG1, NLAG2 parameter(NLAG1 = 50, NLAG2 = 400) c... A small number real*8 TINY PARAMETER(TINY=4.D-15) c... trig stuff real*8 PI,TWOPI,PIBY2,DEGRAD parameter (PI = 3.14159265358979D0) parameter (TWOPI = 2.0D0 * PI) parameter (PIBY2 = PI/2.0D0) parameter (DEGRAD = 180.0D0 / PI) c... Inputs Only: real*8 e,capn c... Internals: integer iflag,i,IMAX real*8 a,b,sq,biga,bigb real*8 x,x2 real*8 f,fp,dx real*8 diff real*8 a0,a1,a3,a5,a7,a9,a11 real*8 b1,b3,b5,b7,b9,b11 PARAMETER (IMAX = 10) PARAMETER (a11 = 156.d0,a9 = 17160.d0,a7 = 1235520.d0) PARAMETER (a5 = 51891840.d0,a3 = 1037836800.d0) PARAMETER (b11 = 11.d0*a11,b9 = 9.d0*a9,b7 = 7.d0*a7) PARAMETER (b5 = 5.d0*a5, b3 = 3.d0*a3) c---- c... Executable code c Function to solve "Kepler's eqn" for F (here called c x) for given e and CAPN. Only good for smallish CAPN iflag = 0 if( capn .lt. 0.d0) then iflag = 1 capn = -capn endif a1 = 6227020800.d0 * (1.d0 - 1.d0/e) a0 = -6227020800.d0*capn/e b1 = a1 c Set iflag nonzero if capn < 0., in which case solve for -capn c and change the sign of the final answer for F. c Begin with a reasonable guess based on solving the cubic for small F a = 6.d0*(e-1.d0)/e b = -6.d0*capn/e sq = sqrt(0.25*b*b +a*a*a/27.d0) biga = (-0.5*b + sq)**0.3333333333333333d0 bigb = -(+0.5*b + sq)**0.3333333333333333d0 x = biga + bigb c write(6,*) 'cubic = ',x**3 +a*x +b orbel_flon = x c If capn is tiny (or zero) no need to go further than cubic even for c e =1. if( capn .lt. TINY) go to 100 do i = 1,IMAX x2 = x*x f = a0 +x*(a1+x2*(a3+x2*(a5+x2*(a7+x2*(a9+x2*(a11+x2)))))) fp = b1 +x2*(b3+x2*(b5+x2*(b7+x2*(b9+x2*(b11 + 13.d0*x2))))) dx = -f/fp c write(6,*) 'i,dx,x,f : ' c write(6,432) i,dx,x,f 432 format(1x,i3,3(2x,1p1e22.15)) orbel_flon = x + dx c If we have converged here there's no point in going on if(abs(dx) .le. TINY) go to 100 x = orbel_flon enddo c Abnormal return here - we've gone thru the loop c IMAX times without convergence if(iflag .eq. 1) then orbel_flon = -orbel_flon capn = -capn endif write(6,*) 'FLON : RETURNING WITHOUT COMPLETE CONVERGENCE' diff = e*sinh(orbel_flon) - orbel_flon - capn write(6,*) 'N, F, ecc*sinh(F) - F - N : ' write(6,*) capn,orbel_flon,diff return c Normal return here, but check if capn was originally negative 100 if(iflag .eq. 1) then orbel_flon = -orbel_flon capn = -capn endif return end ! orbel_flon c------------------------------------------------------------------ *********************************************************************** c ORBEL_SCGET.F *********************************************************************** * PURPOSE: Given an angle, efficiently compute sin and cos. * * Input: * angle ==> angle in radians (real scalar) * * Output: * sx ==> sin(angle) (real scalar) * cx ==> cos(angle) (real scalar) * * ALGORITHM: Obvious from the code * REMARKS: The HP 700 series won't return correct answers for sin * and cos if the angle is bigger than 3e7. We first reduce it * to the range [0,2pi) and use the sqrt rather than cos (it's faster) * BE SURE THE ANGLE IS IN RADIANS - NOT DEGREES! * AUTHOR: M. Duncan. * DATE WRITTEN: May 6, 1992. * REVISIONS: *********************************************************************** subroutine orbel_scget(angle,sx,cx) implicit NONE c... Version of Swift real*8 VER_NUM parameter(VER_NUM=2.0d0) c... Maximum array size integer NPLMAX, NTPMAX c parameter (NPLMAX = 21) ! max number of planets, including the Sun parameter (NPLMAX = 51) ! max number of planets, including the Sun parameter (NTPMAX = 1001) ! max number of test particles c... Size of the test particle integer status flag integer NSTATP ! Number of status parameters parameter (NSTATP = 3) integer NSTAT ! Number of status parameters parameter (NSTAT = NSTATP + NPLMAX - 1) ! include one for @ planet c... Size of the test particle integer status flag integer NSTATR parameter (NSTATR = NSTAT) ! io_init_tp assumes NSTAT==NSTATR c... convergence criteria for danby real*8 DANBYAC , DANBYB parameter (DANBYAC= 1.0d-14, DANBYB = 1.0d-13) c... loop limits in the Laguerre attempts integer NLAG1, NLAG2 parameter(NLAG1 = 50, NLAG2 = 400) c... A small number real*8 TINY PARAMETER(TINY=4.D-15) c... trig stuff real*8 PI,TWOPI,PIBY2,DEGRAD parameter (PI = 3.14159265358979D0) parameter (TWOPI = 2.0D0 * PI) parameter (PIBY2 = PI/2.0D0) parameter (DEGRAD = 180.0D0 / PI) c... Inputs Only: real*8 angle c... Output: real*8 sx,cx c... Internals: integer nper real*8 x real*8 PI3BY2 parameter(PI3BY2 = 1.5d0*PI) c---- c... Executable code nper = angle/TWOPI x = angle - nper*TWOPI if(x.lt.0.d0) then x = x + TWOPI endif sx = sin(x) cx= sqrt(1.d0 - sx*sx) if( (x .gt. PIBY2) .and. (x .lt.PI3BY2)) then cx = -cx endif return end ! orbel_scget c------------------------------------------------------------------- *********************************************************************** c ORBEL_SCHGET.F *********************************************************************** * PURPOSE: Given an angle, efficiently compute sinh and cosh. * * Input: * angle ==> angle in radians (real scalar) * * Output: * shx ==> sinh(angle) (real scalar) * chx ==> cosh(angle) (real scalar) * * ALGORITHM: Obvious from the code * REMARKS: Based on the routine SCGET for sine's and cosine's. * We use the sqrt rather than cosh (it's faster) * BE SURE THE ANGLE IS IN RADIANS AND IT CAN'T BE LARGER THAN 300 * OR OVERFLOWS WILL OCCUR! * AUTHOR: M. Duncan. * DATE WRITTEN: May 6, 1992. * REVISIONS: *********************************************************************** subroutine orbel_schget(angle,shx,chx) implicit NONE c... Version of Swift real*8 VER_NUM parameter(VER_NUM=2.0d0) c... Maximum array size integer NPLMAX, NTPMAX c parameter (NPLMAX = 21) ! max number of planets, including the Sun parameter (NPLMAX = 51) ! max number of planets, including the Sun parameter (NTPMAX = 1001) ! max number of test particles c... Size of the test particle integer status flag integer NSTATP ! Number of status parameters parameter (NSTATP = 3) integer NSTAT ! Number of status parameters parameter (NSTAT = NSTATP + NPLMAX - 1) ! include one for @ planet c... Size of the test particle integer status flag integer NSTATR parameter (NSTATR = NSTAT) ! io_init_tp assumes NSTAT==NSTATR c... convergence criteria for danby real*8 DANBYAC , DANBYB parameter (DANBYAC= 1.0d-14, DANBYB = 1.0d-13) c... loop limits in the Laguerre attempts integer NLAG1, NLAG2 parameter(NLAG1 = 50, NLAG2 = 400) c... A small number real*8 TINY PARAMETER(TINY=4.D-15) c... trig stuff real*8 PI,TWOPI,PIBY2,DEGRAD parameter (PI = 3.14159265358979D0) parameter (TWOPI = 2.0D0 * PI) parameter (PIBY2 = PI/2.0D0) parameter (DEGRAD = 180.0D0 / PI) c... Inputs Only: real*8 angle c... Output: real*8 shx,chx c---- c... Executable code shx = sinh(angle) chx= sqrt(1.d0 + shx*shx) return end ! orbel_schget c--------------------------------------------------------------------- *********************************************************************** c ORBEL_ZGET.F *********************************************************************** * PURPOSE: Solves the equivalent of Kepler's eqn. for a parabola * given Q (Fitz. notation.) * * Input: * q ==> parabola mean anomaly. (real scalar) * Returns: * orbel_zget ==> eccentric anomaly. (real scalar) * * ALGORITHM: p. 70-72 of Fitzpatrick's book "Princ. of Cel. Mech." * REMARKS: For a parabola we can solve analytically. * AUTHOR: M. Duncan * DATE WRITTEN: May 11, 1992. * REVISIONS: May 27 - corrected it for negative Q and use power * series for small Q. *********************************************************************** real*8 function orbel_zget(q) implicit NONE c... Version of Swift real*8 VER_NUM parameter(VER_NUM=2.0d0) c... Maximum array size integer NPLMAX, NTPMAX c parameter (NPLMAX = 21) ! max number of planets, including the Sun parameter (NPLMAX = 51) ! max number of planets, including the Sun parameter (NTPMAX = 1001) ! max number of test particles c... Size of the test particle integer status flag integer NSTATP ! Number of status parameters parameter (NSTATP = 3) integer NSTAT ! Number of status parameters parameter (NSTAT = NSTATP + NPLMAX - 1) ! include one for @ planet c... Size of the test particle integer status flag integer NSTATR parameter (NSTATR = NSTAT) ! io_init_tp assumes NSTAT==NSTATR c... convergence criteria for danby real*8 DANBYAC , DANBYB parameter (DANBYAC= 1.0d-14, DANBYB = 1.0d-13) c... loop limits in the Laguerre attempts integer NLAG1, NLAG2 parameter(NLAG1 = 50, NLAG2 = 400) c... A small number real*8 TINY PARAMETER(TINY=4.D-15) c... trig stuff real*8 PI,TWOPI,PIBY2,DEGRAD parameter (PI = 3.14159265358979D0) parameter (TWOPI = 2.0D0 * PI) parameter (PIBY2 = PI/2.0D0) parameter (DEGRAD = 180.0D0 / PI) c... Inputs Only: real*8 q c... Internals: integer iflag real*8 x,tmp c---- c... Executable code iflag = 0 if(q.lt.0.d0) then iflag = 1 q = -q endif if (q.lt.1.d-3) then orbel_zget = q*(1.d0 - (q*q/3.d0)*(1.d0 -q*q)) else x = 0.5d0*(3.d0*q + sqrt(9.d0*(q**2) +4.d0)) tmp = x**(1.d0/3.d0) orbel_zget = tmp - 1.d0/tmp endif if(iflag .eq.1) then orbel_zget = -orbel_zget q = -q endif return end ! orbel_zget c---------------------------------------------------------------------- c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c MCO_EL2X.FOR (ErikSoft 7 July 1999) c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c c Author: John E. Chambers c c Calculates Cartesian coordinates and velocities given Keplerian orbital c elements (for elliptical, parabolic or hyperbolic orbits). c c Based on a routine from Levison and Duncan's SWIFT integrator. c c mu = grav const * (central + secondary mass) c q = perihelion distance c e = eccentricity c i = inclination ) c p = longitude of perihelion !!! ) in c n = longitude of ascending node ) radians c l = mean anomaly ) c c x,y,z = Cartesian positions ( units the same as a ) c u,v,w = " velocities ( units the same as sqrt(mu/a) ) c c------------------------------------------------------------------------------ c subroutine mco_el2x (mu,q,e,i,p,n,l,x,y,z,u,v,w) c implicit none integer NMAX, CMAX, NMESS real*8 HUGE parameter (NMAX = 2000) parameter (CMAX = 50) parameter (NMESS = 200) parameter (HUGE = 9.9d29) c Constants: c c DR = conversion factor from degrees to radians c K2 = Gaussian gravitational constant squared c AU = astronomical unit in cm c MSUN = mass of the Sun in g c real*8 PI,TWOPI,PIBY2,DR,K2,AU,MSUN c parameter (PI = 3.141592653589793d0) parameter (TWOPI = PI * 2.d0) parameter (PIBY2 = PI * .5d0) parameter (DR = PI / 180.d0) parameter (K2 = 2.959122082855911d-4) parameter (AU = 1.4959787e13) parameter (MSUN = 1.9891e33) c c Input/Output real*8 mu,q,e,i,p,n,l,x,y,z,u,v,w c c Local real*8 g,a,ci,si,cn,sn,cg,sg,ce,se,romes,temp real*8 z1,z2,z3,z4,d11,d12,d13,d21,d22,d23 real*8 mco_kep, orbel_fhybrid, orbel_zget c c------------------------------------------------------------------------------ c c Change from longitude of perihelion to argument of perihelion g = p - n c c Rotation factors call mco_sine (i,si,ci) call mco_sine (g,sg,cg) call mco_sine (n,sn,cn) z1 = cg * cn z2 = cg * sn z3 = sg * cn z4 = sg * sn d11 = z1 - z4*ci d12 = z2 + z3*ci d13 = sg * si d21 = -z3 - z2*ci d22 = -z4 + z1*ci d23 = cg * si c c Semi-major axis a = q / (1.d0 - e) c c Ellipse if (e.lt.1.d0) then romes = sqrt(1.d0 - e*e) temp = mco_kep (e,l) call mco_sine (temp,se,ce) z1 = a * (ce - e) z2 = a * romes * se temp = sqrt(mu/a) / (1.d0 - e*ce) z3 = -se * temp z4 = romes * ce * temp else c Parabola if (e.eq.1.d0) then ce = orbel_zget(l) z1 = q * (1.d0 - ce*ce) z2 = 2.d0 * q * ce z4 = sqrt(2.d0*mu/q) / (1.d0 + ce*ce) z3 = -ce * z4 else c Hyperbola romes = sqrt(e*e - 1.d0) temp = orbel_fhybrid(e,l) call mco_sinh (temp,se,ce) z1 = a * (ce - e) z2 = -a * romes * se temp = sqrt(mu/abs(a)) / (e*ce - 1.d0) z3 = -se * temp z4 = romes * ce * temp end if endif c x = d11*z1 + d21*z2 y = d12*z1 + d22*z2 z = d13*z1 + d23*z2 u = d11*z3 + d21*z4 v = d12*z3 + d22*z4 w = d13*z3 + d23*z4 c c------------------------------------------------------------------------------ c return end *********************************************************************** c ORBEL_FHYBRID.F *********************************************************************** * PURPOSE: Solves Kepler's eqn. for hyperbola using hybrid approach. * * Input: * e ==> eccentricity anomaly. (real scalar) * n ==> hyperbola mean anomaly. (real scalar) * Returns: * orbel_fhybrid ==> eccentric anomaly. (real scalar) * * ALGORITHM: For abs(N) < 0.636*ecc -0.6 , use FLON * For larger N, uses FGET * REMARKS: * AUTHOR: M. Duncan * DATE WRITTEN: May 26,1992. * REVISIONS: * REVISIONS: 2/26/93 hfl *********************************************************************** real*8 function orbel_fhybrid(e,n) implicit NONE c... Version of Swift real*8 VER_NUM parameter(VER_NUM=2.0d0) c... Maximum array size integer NPLMAX, NTPMAX c parameter (NPLMAX = 21) ! max number of planets, including the Sun parameter (NPLMAX = 51) ! max number of planets, including the Sun parameter (NTPMAX = 1001) ! max number of test particles c... Size of the test particle integer status flag integer NSTATP ! Number of status parameters parameter (NSTATP = 3) integer NSTAT ! Number of status parameters parameter (NSTAT = NSTATP + NPLMAX - 1) ! include one for @ planet c... Size of the test particle integer status flag integer NSTATR parameter (NSTATR = NSTAT) ! io_init_tp assumes NSTAT==NSTATR c... convergence criteria for danby real*8 DANBYAC , DANBYB parameter (DANBYAC= 1.0d-14, DANBYB = 1.0d-13) c... loop limits in the Laguerre attempts integer NLAG1, NLAG2 parameter(NLAG1 = 50, NLAG2 = 400) c... A small number real*8 TINY PARAMETER(TINY=4.D-15) c... trig stuff real*8 PI,TWOPI,PIBY2,DEGRAD parameter (PI = 3.14159265358979D0) parameter (TWOPI = 2.0D0 * PI) parameter (PIBY2 = PI/2.0D0) parameter (DEGRAD = 180.0D0 / PI) c... Inputs Only: real*8 e,n c... Internals: real*8 abn real*8 orbel_flon,orbel_fget c---- c... Executable code abn = n if(n.lt.0.d0) abn = -abn if(abn .lt. 0.636d0*e -0.6d0) then orbel_fhybrid = orbel_flon(e,n) else orbel_fhybrid = orbel_fget(e,n) endif return end ! orbel_fhybrid c-------------------------------------------------------------------
subroutine STDSPIN(IT,JSP) C...Get the J-spin of this particle C C IT = index to HEPEVT common block C For particle ID, +/- IJKLM C KQJ = M = 2*Jspin + 1 C JSP = Jspin C IMPLICIT NONE integer IT,KQ,KQA,KQJ real JSP #include "stdhep/stdhep.inc" KQ=IDHEP(IT) KQA=IABS(KQ) KQJ=MOD(KQA,10) JSP = (FLOAT(KQJ) - 1.)/2. return end
***************************************************************************** *** function dsIB3yieldone calculates the IB3 yield from one given *** annihilation channel, i.e. the *difference* to the corresponding qq *** yield when taking into account qqg final states. *** *** Currently included are: *** yieldk = 54 - antiproton yield above threshold emuthr *** 154 - differential antiproton yield at emuthr *** 52 - photon yield above threshold emuthr *** 152 - differential photon yield at emuthr *** *** The annihilation channels are: *** qch = 7 - u u-bar *** 8 - d d-bar *** 9 - c c-bar *** 10 - s s-bar *** 11 - t t-bar *** 12 - b b-bar *** *** See arXiv: 1510.02473 for more details on the scheme implemented here. *** *** the units are (annihilation into IBch)**-1 *** for the differential yields, the units are the same times gev**-1. *** *** istat will set upon return in case of errors *** bit decimal reason *** 0 1 dsIBf_intdxdy failed *** 1 2 dsIBf_intdy failed *** Author: torsten.bringmann@fys.uio.no *** Date: 2015-06-01 ***************************************************************************** real*8 function dsIB3yieldone(emuthr,qch,yieldk,istat) implicit none include 'dsmssm.h' c------------------------ variables ------------------------------------ real*8 emuthr,mDM,tmpresult, y integer qch,istat,yieldk, mix, pdg, yieldpdg, diff c------------------------ functions ------------------------------------ real*8 dsanyield_sim, dsIB3yieldtab, dsib3svqqgratio, dsib3svqqratio c----------------------------------------------------------------------- istat=-10 ! channel not implemented dsIB3yieldone=0d0 if (yieldk.ne.54.and.yieldk.ne.154.and.yieldk.ne.52.and.yieldk.ne.152) & return if (qch.lt.7.or.qch.gt.12) then write(*,*) 'ERROR in dsIB3yieldone: unknown channel IBch = ', qch istat=-20 return endif istat=0 tmpresult=0d0 mDM=mass(kn(1)) c...only if kinematically allowed go on to compute yields if (mdm.gt.mass(qch).and.emuthr.le.(0.9999*mdm*(1.-mass(qch)**2/mDM**2))) then call dsIB3yieldfit(qch,yieldk,mix,y) if (y.gt.1.5.or.y.lt.-0.5) then ! something went wrong, return zero return endif c... interpolate 3-body spectra between the two extreme cases tmpresult = y*dsIB3yieldtab(emuthr,mDM,qch,2-mix,yieldk) ! VIB-type spectrum if (y.lt.0.999) ! add heavy-squark-type spectrum & tmpresult= tmpresult+(1-y)*dsIB3yieldtab(emuthr,mDM,qch,4-mix,yieldk) tmpresult = tmpresult*dsib3svqqgratio(kn(1),qch) if (NLOoption.eq.'default') ! correct for the fact that the qq cross section ! already contains QCD corrections & tmpresult = tmpresult/dsib3svqqratio(2*mDM,kn(1),qch) c... add change in normalization of 2-body spectrum (if not already done in dssigmav0) if (NLOoption.ne.'default') then pdg = qch-7+2*mod(qch,2) diff = yieldk/100 if (mod(yieldk,100).eq.54) yieldpdg = -2212 ! pbar if (mod(yieldk,100).eq.52) yieldpdg = 22 ! gamma tmpresult = tmpresult + (dsib3svqqratio(2*mDM,kn(1),qch)-1.)* & dsanyield_sim(mDM,emuthr,pdg,0,yieldpdg,diff,istat) endif endif dsIB3yieldone=tmpresult return end
C=================================================================== #include "fintrf.h" C mxcreatecellmatrixf.f C C mxcreatecellmatrix takes the input arguments and places them in a C cell array. This cell array is returned back to MATLAB as the result. C C This is a MEX-file for MATLAB. C Copyright 1984-2018 The MathWorks, Inc. C All rights reserved. C C=================================================================== subroutine mexFunction(nlhs, plhs, nrhs, prhs) C Declarations implicit none mwPointer plhs(*), prhs(*) integer nlhs, nrhs mwPointer mxCreateCellMatrix, mxDuplicateArray mwPointer cell_array_ptr mwSize i, m, n mwPointer NULL C Check for proper number of input and output arguments if (nrhs .lt. 1) then call mexErrMsgIdAndTxt( 'MATLAB:mxcreatecellmatrixf:minrhs', + 'One input argument required.') end if if (nlhs .gt. 1) then call mexErrMsgIdAndTxt( 'MATLAB:mxcreatecellmatrixf:maxlhs', + 'Too many output arguments.') end if C Create a nrhs x 1 cell mxArray. m = nrhs n = 1 cell_array_ptr = mxCreateCellMatrix(m, n) C Fill cell matrix with input arguments do 10 i=1,m call mxSetCell(cell_array_ptr,i, + mxDuplicateArray(prhs(i))) 10 continue plhs(1) = cell_array_ptr return end
c $VERSION "08/16/95 @(#)cuintc.f 7.1" subroutine interc(ihr) c subroutine to calc precip or irrig intercepted by foliage c this intercepted rain may be much greater than that stored on c leaves at this point. after calling drip then pint(j) is that c stored on foliage parameter(mh=98) common/misc2/itot,itotp1,jtot,fr(10),ct(10),totlai,df,dt &,clai(20),distls(10,mh),jdead c distls(10,mh) in /misc2/ was added by Chen, 9/4/89. common/inter1/wtp(20),frwet(20),frwtmx,pint(20),pilast(20) 1,pint1(20),twater common/met1/temair(mh),vpair(mh),precip(mh),temsol(mh),watsol(mh) do100j=1,jtot jj=jtot+1-j if(precip(ihr).lt.0.001.and.pilast(jj).le.0.001)go to 175 frwet(jj)=frwtmx c pint1 is quantity of water in mm=kg/m2 intercepted on first c interaction of rain with a leaf. pint1(jj)=wtp(jj)*precip(ihr) pint(jj)=pint1(jj)+pilast(jj) sum3=sum3+pint(jj) go to 100 175 pint(jj)=0. pint1(jj)=0. frwet(jj)=0. 100 continue return end subroutine drips(ihr,lbredo,irrchk,tprecd) parameter(mh=98) dimension wtp0(20),irrchk(mh),tprecd(mh) common/leaf2/evap(10,20),gevap(10,20),heat(10,20),gheat(10,20) 1,alam ,tlfavg(20),tgheat(20),tgvap1(20),tgvap2(20) common/water1/iprecp,tprecp,pn(mh,50),wcond(50),wstor(50), & wpond(mh) common/misc2/itot,itotp1,jtot,fr(10),ct(10),totlai,df,dt &,clai(20),distls(10,mh),jdead c distls(10,mh) in /misc2/ was added by Chen, 9/4/89. common/inter2/evint(20),evimm(20),pintmx,frstem,drip(20),stem common/inter1/wtp(20),frwet(20),frwtmx,pint(20),pilast(20) 1,pint1(20),twater common/leaf1/delt(10,20),psilf,tran(10,20) common/met1/temair(mh),vpair(mh),precip(mh),temsol(mh),watsol(mh) c subroutine to calculate amount of intercepted precip that runs c down stem,drips and stays on leaves. c calc weighting factors for each layer for precip intercpt from zenith c and call it wtp0. only used for drip within canopy. cl=df do695j=2,jtot jj=jtot+2-j wtp0(jj)=exp(-.5*(cl-df))-exp(-.5*cl) cl=cl+df 695 continue sum=0. stem=0. lbredo=0 do800j=2,jtot jj=jtot+2-j evimm(jj)=evint(jj)*dt/(alam*4.18e3) if(abs(evimm(jj)-pint(jj)).lt.0.001)go to 540 if(evimm(jj)-pint(jj))600,500,500 500 continue frwet(jj)=pint(jj)*frwtmx/evimm(jj) drip(jj)=0. pint(jj)=0. lbredo=1 go to 800 540 drip(jj)=0. frwet(jj)=0. pint(jj)=0. go to 800 c 600 continue c mult pintmx times 2.*df because both sides of leaf are wetted. if(pint(jj)-evimm(jj)-pintmx*2.*df)520,650,650 520 drip(jj)=0. pint(jj)=pint(jj)-evimm(jj) if(pint(jj).lt.0.)pint(jj)=0. go to 800 c 650 continue drip(jj)=(1.-frstem)*(pint(jj)-evimm(jj)-pintmx*2.*df) stem=stem+frstem*(pint(jj)-evimm(jj)-pintmx*2.*df) pint(jj)=pintmx*2.*df jlay=jj-1 cl=df do690j2=1,jlay jjj=jlay+1-j2 if(jjj.gt.1)pint(jjj)=pint(jjj)+drip(jj)*wtp0(jtot+1-j2) if(jjj.eq.1)pint(1)=pint(1)+drip(jj)*(exp(-.5*(cl-df))) cl=cl+df 690 continue 800 continue c if irrchk(ihr)=2 then irrigation with drop tubes below the cpy if(irrchk(ihr).eq.2)goto700 c tprecp in kg m-2 s-1 = mm/s as b.c. for soil water infiltration tprecp=(pint(1)+stem)/dt goto710 c tprecd is same value as precip, but can't use precip because the c canopy gets wetted. see near beginning of daily loop in main prog 700 tprecp=tprecd(ihr)/dt 710 continue if(precip(ihr).lt.0.0)tprecp=-precip(ihr)/dt if(ihr.eq.16)then endif return end subroutine preang(ihr,drpang) c calculate incident angle of drops on canopy from wind speed and c droplet terminal velocity parameter(mh=98) common /wind1/fwind(20),wind(mh),sizelf,dmax,refhtw,z0,disp,am &,zcrit c drop size in mm drpdia=1. c term velocity m sec-1 empirical fit from smithsonian met tables c page 396 vterm=-0.334+(5.444+(-1.299+(0.168-0.00986*drpdia)*drpdia)*drpdia) &*drpdia drpang=atan(wind(ihr)/vterm) return end subroutine cpywt(anginc,weight) c subroutine to calculate weighting factor as fnc of depth in canopy c for precip c anginc is the angle from the vertical dimension weight(20) parameter(mh=98) common/misc2/itot,itotp1,jtot,fr(10),ct(10),totlai,df,dt &,clai(20),distls(10,mh),jdead c distls(10,mh) in /misc2/ was added by Chen, 9/4/89. cl=df sump=0. do695j=2,jtot jj=jtot+2-j weight(jj)=exp(-.5*(cl-df)/cos(anginc))-exp(-.5*cl/cos(anginc)) sump=sump+weight(jj) cl=cl+df 695 continue weight(1)=1.-sump return end
SUBROUTINE UFBEVN(LUNIT,USR,I1,I2,I3,IRET,STR) C$$$ SUBPROGRAM DOCUMENTATION BLOCK C C SUBPROGRAM: UFBEVN C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06 C C ABSTRACT: THIS SUBROUTINE READS SPECIFIED VALUES FROM THE CURRENT C BUFR DATA SUBSET WITHIN INTERNAL ARRAYS. THE DATA VALUES C CORRESPOND TO MNEMONICS WHICH ARE PART OF A MULTIPLE-REPLICATION C SEQUENCE WITHIN ANOTHER MULTIPLE-REPLICATION SEQUENCE. THE INNER C SEQUENCE IS USUALLY ASSOCIATED WITH DATA "LEVELS" AND THE OUTER C SEQUENCE WITH DATA "EVENTS". THE BUFR FILE IN LOGICAL UNIT LUNIT C MUST HAVE BEEN OPENED FOR INPUT VIA A PREVIOUS CALL TO BUFR ARCHIVE C LIBRARY SUBROUTINE OPENBF. IN ADDITION, THE DATA SUBSET MUST HAVE C SUBSEQUENTLY BEEN READ INTO THE INTERNAL BUFR ARCHIVE LIBRARY C ARRAYS VIA CALLS TO BUFR ARCHIVE LIBRARY SUBROUTINE READMG OR C READERME FOLLOWED BY A CALL TO BUFR ARCHIVE LIBRARY SUBROUTINE C READSB (OR VIA A SINGLE CALL TO BUFR ARCHIVE LIBRARY C SUBROUTINE READNS). OTHER THAN THE ADDITION OF A THIRD C DIMENSION AND THE READ ONLY RESTRICTION, THE CONTEXT AND USAGE OF C UFBEVN IS EXACTLY THE SAME AS FOR BUFR ARCHIVE LIBRARY SUBROUTINES C UFBINT, UFBREP AND UFBSEQ. THIS SUBROUTINE IS DESIGNED TO READ C EVENT INFORMATION FROM "PREPBUFR" TYPE BUFR FILES. PREPBUFR FILES C HAVE THE FOLLOWING BUFR TABLE EVENT STRUCTURE (NOTE SIXTEEN C CHARACTERS HAVE BEEN REMOVED FROM THE LAST COLUMN TO ALLOW THE C TABLE TO FIT IN THIS DOCBLOCK): C C | ADPUPA | HEADR {PLEVL} | C | HEADR | SID XOB YOB DHR ELV TYP T29 TSB ITP SQN | C | PLEVL | CAT <PINFO> <QINFO> <TINFO> <ZINFO> <WINFO> | C | PINFO | [PEVN] <PBACKG> <PPOSTP> | C | QINFO | [QEVN] TDO <QBACKG> <QPOSTP> | C | TINFO | [TEVN] TVO <TBACKG> <TPOSTP> | C | ZINFO | [ZEVN] <ZBACKG> <ZPOSTP> | C | WINFO | [WEVN] <WBACKG> <WPOSTP> | C | PEVN | POB PQM PPC PRC | C | QEVN | QOB QQM QPC QRC | C | TEVN | TOB TQM TPC TRC | C | ZEVN | ZOB ZQM ZPC ZRC | C | WEVN | UOB WQM WPC WRC VOB | C | PBACKG | POE PFC | C | QBACKG | QOE QFC | C | TBACKG | TOE TFC | C | ZBACKG | ZOE ZFC | C | WBACKG | WOE UFC VFC | C | PPOSTP | PAN | C | QPOSTP | QAN | C | TPOSTP | TAN | C | ZPOSTP | ZAN | C | WPOSTP | UAN VAN | C C NOTE THAT THE EIGHT-BIT DELAYED REPLIATION EVENT SEQUENCES "[xxxx]" C ARE NESTED INSIDE ONE-BIT DELAYED REPLICATED SEQUENCES "<yyyy>". C THE ANALOGOUS BUFR ARCHIVE LIBRARY SUBROUTINE UFBIN3 DOES NOT WORK C PROPERLY ON THIS TYPE OF EVENT STRUCTURE. IT WORKS ONLY ON THE C EVENT STRUCTURE FOUND IN "PREPFITS" TYPE BUFR FILES (SEE UFBIN3 FOR C MORE DETAILS). IN TURN, UFBEVN DOES NOT WORK PROPERLY ON THE EVENT C STRUCTURE FOUND IN PREPFITS FILES (ALWAYS USE UFBIN3 IN THIS CASE). C ONE OTHER DIFFERENCE BETWEEN UFBEVN AND UFBIN3 IS THAT UFBEVN C STORES THE MAXIMUM NUMBER OF EVENTS FOUND FOR ALL DATA VALUES C SPECIFIED AMONGST ALL LEVELS RETURNED INTERNALLY IN COMMON BLOCK C /UFBN3C/. UFBIN3 RETURNS THIS VALUE AS AN ADDITIONAL OUTPUT C ARGUMENT. C C PROGRAM HISTORY LOG: C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB C ROUTINE "BORT"; IMPROVED MACHINE C PORTABILITY C 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE C OPENED AT ONE TIME INCREASED FROM 10 TO 32 C (NECESSARY IN ORDER TO PROCESS MULTIPLE C BUFR FILES UNDER THE MPI) C 2003-11-04 J. WOOLLEN -- SAVES THE MAXIMUM NUMBER OF EVENTS FOUND C FOR ALL DATA VALUES SPECIFIED AMONGST ALL C LEVELS RETURNED AS VARIABLE MAXEVN IN NEW C COMMON BLOCK /UFBN3C/ C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE C INTERDEPENDENCIES C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES) C INCREASED FROM 15000 TO 16000 (WAS IN C VERIFICATION VERSION); ADDED CALL TO BORT C IF BUFR FILE IS OPEN FOR OUTPUT; UNIFIED/ C PORTABLE FOR WRF; ADDED DOCUMENTATION C (INCLUDING HISTORY); OUTPUTS MORE COMPLETE C DIAGNOSTIC INFO WHEN ROUTINE TERMINATES C ABNORMALLY OR UNUSUAL THINGS HAPPEN C DART $Id$ C C USAGE: CALL UFBEVN (LUNIT, USR, I1, I2, I3, IRET, STR) C INPUT ARGUMENT LIST: C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE C I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR OR THE C NUMBER OF BLANK-SEPARATED MNEMONICS IN STR (FORMER C MUST BE .GE. LATTER) C I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR C I3 - INTEGER: LENGTH OF THIRD DIMENSION OF USR (MAXIMUM C VALUE IS 255) C STR - CHARACTER*(*): STRING OF BLANK-SEPARATED TABLE B C MNEMONICS IN ONE-TO-ONE CORRESPONDENCE WITH FIRST C DIMENSION OF USR C - THERE ARE THREE "GENERIC" MNEMONICS NOT RELATED C TO TABLE B, THESE RETURN THE FOLLOWING C INFORMATION IN CORRESPONDING USR LOCATION: C 'NUL' WHICH ALWAYS RETURNS MISSING (10E10) C 'IREC' WHICH ALWAYS RETURNS THE CURRENT BUFR C MESSAGE (RECORD) NUMBER IN WHICH THIS C SUBSET RESIDES C 'ISUB' WHICH ALWAYS RETURNS THE CURRENT SUBSET C NUMBER OF THIS SUBSET WITHIN THE BUFR C MESSAGE (RECORD) NUMBER 'IREC' C C OUTPUT ARGUMENT LIST: C USR - REAL*8: (I1,I2,I3) STARTING ADDRESS OF DATA VALUES C READ FROM DATA SUBSET C IRET - INTEGER: NUMBER OF "LEVELS" OF DATA VALUES READ FROM C DATA SUBSET (MUST BE NO LARGER THAN I2) C C OUTPUT FILES: C UNIT 06 - STANDARD OUTPUT PRINT C C REMARKS: C APPLICATION PROGRAMS READING PREPFITS FILES SHOULD NOT CALL THIS C ROUTINE. C C THIS ROUTINE CALLS: BORT CONWIN GETWIN NVNWIN C NXTWIN STATUS STRING C THIS ROUTINE IS CALLED BY: None C Normally called only by application C programs. C C ATTRIBUTES: C LANGUAGE: FORTRAN 77 C MACHINE: PORTABLE TO ALL PLATFORMS C C$$$ INCLUDE 'bufrlib.prm' COMMON /MSGCWD/ NMSG(NFILES),NSUB(NFILES),MSUB(NFILES), . INODE(NFILES),IDATE(NFILES) COMMON /USRINT/ NVAL(NFILES),INV(MAXJL,NFILES),VAL(MAXJL,NFILES) COMMON /USRSTR/ NNOD,NCON,NODS(20),NODC(10),IVLS(10),KONS(10) COMMON /UFBN3C/ MAXEVN COMMON /QUIET / IPRT CHARACTER*(*) STR DIMENSION INVN(255) REAL*8 VAL,USR(I1,I2,I3),BMISS DATA BMISS /10E10/ C---------------------------------------------------------------------- C---------------------------------------------------------------------- MAXEVN = 0 IRET = 0 C CHECK THE FILE STATUS AND I-NODE C -------------------------------- CALL STATUS(LUNIT,LUN,IL,IM) IF(IL.EQ.0) GOTO 900 IF(IL.GT.0) GOTO 901 IF(IM.EQ.0) GOTO 902 IF(INODE(LUN).NE.INV(1,LUN)) GOTO 903 IF(I1.LE.0) THEN IF(IPRT.GE.0) THEN PRINT* PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT*,'BUFRLIB: UFBEVN - THIRD ARGUMENT (INPUT) IS .LE. 0', . ' - RETURN WITH SIXTH ARGUMENT (IRET) = 0' PRINT*,'STR = ',STR PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT* ENDIF GOTO 100 ELSEIF(I2.LE.0) THEN IF(IPRT.GE.0) THEN PRINT* PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT*,'BUFRLIB: UFBEVN - FOURTH ARGUMENT (INPUT) IS .LE. 0', . ' - RETURN WITH SIXTH ARGUMENT (IRET) = 0' PRINT*,'STR = ',STR PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT* ENDIF GOTO 100 ELSEIF(I3.LE.0) THEN IF(IPRT.GE.0) THEN PRINT* PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT*,'BUFRLIB: UFBEVN - FIFTH ARGUMENT (INPUT) IS .LE. 0', . ' - RETURN WITH SIXTH ARGUMENT (IRET) = 0' PRINT*,'STR = ',STR PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT* ENDIF GOTO 100 ENDIF C PARSE OR RECALL THE INPUT STRING C -------------------------------- CALL STRING(STR,LUN,I1,0) C INITIALIZE USR ARRAY C -------------------- DO K=1,I3 DO J=1,I2 DO I=1,I1 USR(I,J,K) = BMISS ENDDO ENDDO ENDDO C LOOP OVER COND WINDOWS C ---------------------- INC1 = 1 INC2 = 1 1 CALL CONWIN(LUN,INC1,INC2,I2) IF(NNOD.EQ.0) THEN IRET = I2 GOTO 100 ELSEIF(INC1.EQ.0) THEN GOTO 100 ELSE DO I=1,NNOD IF(NODS(I).GT.0) THEN INS2 = INC1 CALL GETWIN(NODS(I),LUN,INS1,INS2) IF(INS1.EQ.0) GOTO 100 GOTO 2 ENDIF ENDDO INS1 = INC1 INS2 = INC2 ENDIF C READ PUSH DOWN STACK DATA INTO 3D ARRAYS C ---------------------------------------- 2 IRET = IRET+1 IF(IRET.LE.I2) THEN DO I=1,NNOD IF(NODS(I).GT.0) THEN NNVN = NVNWIN(NODS(I),LUN,INS1,INS2,INVN,I3) MAXEVN = MAX(NNVN,MAXEVN) DO N=1,NNVN USR(I,IRET,N) = VAL(INVN(N),LUN) ENDDO ENDIF ENDDO ENDIF C DECIDE WHAT TO DO NEXT C ---------------------- CALL NXTWIN(LUN,INS1,INS2) IF(INS1.GT.0 .AND. INS1.LT.INC2) GOTO 2 IF(NCON.GT.0) GOTO 1 IF(IRET.EQ.0) THEN IF(IPRT.GE.1) THEN PRINT* PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT*,'BUFRLIB: UFBEVN - NO SPECIFIED VALUES READ IN - ', . 'RETURN WITH SIXTH ARGUMENT (IRET) = 0' PRINT*,'STR = ',STR PRINT*,'+++++++++++++++++++++++WARNING+++++++++++++++++++++++++' PRINT* ENDIF ENDIF C EXITS C ----- 100 RETURN 900 CALL BORT('BUFRLIB: UFBEVN - INPUT BUFR FILE IS CLOSED, IT MUST'// . ' BE OPEN FOR INPUT') 901 CALL BORT('BUFRLIB: UFBEVN - INPUT BUFR FILE IS OPEN FOR OUTPUT'// . ', IT MUST BE OPEN FOR INPUT') 902 CALL BORT('BUFRLIB: UFBEVN - A MESSAGE MUST BE OPEN IN INPUT '// . 'BUFR FILE, NONE ARE') 903 CALL BORT('BUFRLIB: UFBEVN - LOCATION OF INTERNAL TABLE FOR '// . 'INPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN '// . 'INTERNAL SUBSET ARRAY') END
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
9