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
LOCAL INCLUDE 'UVHIM.INC' REAL XSEQ, XDISK, XQUAL, XBAND, XFREQ, XFQID, XTIME(8), * XANT(50), XBASE(50), XUVRA(2), XSUBA, XBCHAN, XECHAN, XCHINC, * XBIF, XEIF, XDOCAL, XGUSE, XDOPOL, XPDVER, XBLVER, XFLAG, * XDOBND, XBPVER, XSMOTH(3), XOSEQ, XODISK, XIMSIZ(2), BPARM(10), * DOBLNK, BADD(10) HOLLERITH XNAME(3), XCLASS(2), XSOUR(4,30), XCALC, XSTOK, * XONAME(3), XOCLAS(2), MAPH(256) REAL DOMAIN(2,2), MAPR(256) INTEGER INDISK, CNO, NSUBA, NFRQ, CHINC, IMSIZE(2), CSIZE, * CTYPE, DISKO, CNOO, MAPHDR(256), SEQO, INSEQ, ATYPE(2), NOUT, * NIN, SCRTCH(256) LOGICAL HERMIT DOUBLE PRECISION MAPD(128) CHARACTER INNAME*12, INCLAS*6, OUNAME*12, OUCLAS*6 EQUIVALENCE (MAPHDR, MAPH, MAPR, MAPD) COMMON /UVHIMP/ XNAME, XCLASS, XSEQ, XDISK, XSOUR, XQUAL, XCALC, * XSTOK, XBAND, XFREQ, XFQID, XTIME, XANT, XBASE, XUVRA, XSUBA, * XBCHAN, XECHAN, XCHINC, XBIF, XEIF, XDOCAL, XGUSE, XDOPOL, * XPDVER, XBLVER, XFLAG, XDOBND, XBPVER, XSMOTH, XIMSIZ, XONAME, * XOCLAS, XOSEQ, XODISK, BPARM, DOBLNK, BADD COMMON /UVHIMI/ MAPHDR, SCRTCH, INDISK, CNO, NSUBA, NFRQ, CHINC, * IMSIZE, DOMAIN, CSIZE, CTYPE, DISKO, CNOO, INSEQ, SEQO, * ATYPE, NOUT, NIN, HERMIT COMMON /UVHIMC/ INNAME, INCLAS, OUNAME, OUCLAS LOCAL END PROGRAM UVHIM C----------------------------------------------------------------------- C! Makes image of 2-D histogram of a UV data set. C# Util UV Analysis C----------------------------------------------------------------------- C; Copyright (C) 2006, 2008-2010, 2012, 2015-2016, 2018 C; Associated Universities, Inc. Washington DC, USA. C; C; This program is free software; you can redistribute it and/or C; modify it under the terms of the GNU General Public License as C; published by the Free Software Foundation; either version 2 of C; the License, or (at your option) any later version. C; C; This program is distributed in the hope that it will be useful, C; but WITHOUT ANY WARRANTY; without even the implied warranty of C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the C; GNU General Public License for more details. C; C; You should have received a copy of the GNU General Public C; License along with this program; if not, write to the Free C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, C; MA 02139, USA. C; C; Correspondence concerning AIPS should be addressed as follows: C; Internet email: aipsmail@nrao.edu. C; Postal address: AIPS Project Office C; National Radio Astronomy Observatory C; 520 Edgemont Road C; Charlottesville, VA 22903-2475 USA C----------------------------------------------------------------------- C UVHIM makes an image of a 2-D histogram of a UV data set. C Adverbs: C INNAME(3) uv name (12 chars). C INCLASS(2) uv class ( 6 chars). C INSEQ uv sequence number. C INDISK uv disk. C STOKES Stokes parameter (I, Q, U, V, RR, LL, RL, LR). C BCHAN 1st Spectral channel number. C ECHAN last Spectral channel C BIF 1st IF band to use C EIF last Spectral channel C----------------------------------------------------------------------- INTEGER IERR, NWORDS LONGINT OFFSET, COFSET REAL HIMAG(2), HCONV(2) INCLUDE 'UVHIM.INC' INCLUDE 'INCS:DSEL.INC' INCLUDE 'INCS:DDCH.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DUVH.INC' C----------------------------------------------------------------------- C Initialize and open file. CALL UVHGIN (IERR) IF (IERR.NE.0) THEN MSGTXT = 'INITIALIZATION PROBLEM.' GO TO 990 END IF C make memory for image NWORDS = (IMSIZE(1) * IMSIZE(2) - 1) / 1024 + 1 CALL ZMEMRY ('GET ', TSKNAM, NWORDS, HIMAG, OFFSET, IERR) IF (IERR.NE.0) THEN MSGTXT = 'CANNOT MAKE MEMORY FOR IMAGE' GO TO 990 END IF NWORDS = CSIZE * CSIZE HCONV(1) = 1.0 COFSET = 0 IF (NWORDS.GT.1) THEN NWORDS = (NWORDS - 1) / 1024 + 1 CALL ZMEMRY ('GET ', TSKNAM, NWORDS, HCONV, COFSET, IERR) IF (IERR.NE.0) THEN MSGTXT = 'CANNOT MAKE MEMORY FOR CONVOLUTION FUNCTION' GO TO 990 END IF CALL BLDCNV (CSIZE, CTYPE, HCONV(1+COFSET)) END IF C Accumulate statistics from the C uv data. CALL BLDHGM (IMSIZE(1), IMSIZE(2), HIMAG(1+OFFSET), CSIZE, * HCONV(1+COFSET), IERR) IF (IERR.NE.0) THEN MSGTXT = 'PROBLEM PROCESSING THE UV DATA.' GO TO 990 END IF C write out image CALL WRIHGM (IMSIZE(1), IMSIZE(2), HIMAG(1+OFFSET), IERR) IF (IERR.NE.0) THEN MSGTXT = 'PROBLEM WRITING OUT THE IMAGE' GO TO 990 END IF GO TO 995 C 990 CALL MSGWRT (8) C 995 CALL DIE (IERR, SCRTCH) C 999 STOP END SUBROUTINE UVHGIN (IERR) C----------------------------------------------------------------------- C UVHGIN gets adverbs for UVHIM, opens the uv file, and determines C what is to be done. C Inputs: C IERR I Error code, 0 means success. C Output in Common: C ..... R(*) AIPS adverbs values. C NBINS I Number of histogram bins. C INDISK I uv input disk number. C CNO I uv catalog slot number. C BCHAN I Frequency channel. C----------------------------------------------------------------------- INTEGER IERR C CHARACTER PRGM*6, PTYPE*2, CBLANK*6 LOGICAL TABLE, EXIST, FITASC, MATCH INTEGER I, IRET, IROUND, IUSER, LUN, FQVER, NIF, JERR, UVLUN, * UVIND, NPARMS HOLLERITH CATH(256), CATUH(256) REAL CATR(256), CATUR(256) DOUBLE PRECISION CATD(128), CATUD(128) INCLUDE 'UVHIM.INC' INCLUDE 'INCS:DSEL.INC' INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DUVH.INC' INCLUDE 'INCS:DFIL.INC' EQUIVALENCE (CATBLK, CATH, CATR, CATD) EQUIVALENCE (CATUV, CATUH, CATUR, CATUD) DATA PRGM /'UVHIM '/ DATA CBLANK /' '/ C----------------------------------------------------------------------- C Initialize parameters. CALL ZDCHIN (.TRUE.) CALL VHDRIN CALL SELINI C Initialize /CFILES/ NSCR = 0 NCFILE = 0 C Get input parameters. NPARMS = 290 CALL GTPARM (PRGM, NPARMS, RQUICK, XNAME, SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1010) CALL MSGWRT (8) RQUICK = .TRUE. CALL RELPOP (IERR, SCRTCH, IRET) GO TO 999 END IF C Restart AIPS. IF (RQUICK) CALL RELPOP (IERR, SCRTCH, IRET) C Decode adverb values. C AIPS user number. IUSER = NLUSER DO 5 I = 1,10 IBAD(I) = IROUND(BADD(I)) 5 CONTINUE C Input uv name etc. CALL H2CHR (12, 1, XNAME, INNAME) CALL H2CHR (6, 1, XCLASS, INCLAS) INSEQ = IROUND (XSEQ) INDISK = IROUND (XDISK) CALL H2CHR (12, 1, XONAME, OUNAME) CALL H2CHR (6, 1, XOCLAS, OUCLAS) SEQO = IROUND (XOSEQ) DISKO = IROUND (XODISK) CALL H2CHR (4, 1, XSTOK, STOKES) CALL H2CHR (4, 1, XCALC, SELCOD) DO 10 I = 1,30 CALL H2CHR (16, 1, XSOUR(1,I), SOURCS(I)) 10 CONTINUE SELQUA = IROUND (XQUAL) DOCAL = XDOCAL.GT.0.0 DOWTCL = DOCAL .AND. (XDOCAL.LE.99.0) C Number of histogram bins. IMSIZE(1) = IROUND (XIMSIZ(1)) IMSIZE(2) = IROUND (XIMSIZ(2)) IF (IMSIZE(1).LE.64) IMSIZE(1) = 256 IF (IMSIZE(2).LE.64) IMSIZE(2) = 256 C Open the uv file and get its C catalog header. UVLUN = 45 PTYPE = 'UV' CALL MAPOPN ('READ', INDISK, INNAME, INCLAS, INSEQ, PTYPE, IUSER, * UVLUN, UVIND, CNO, CATBLK, SCRTCH, IERR) IF (IERR.NE.0) THEN MSGTXT = 'UVHGIN: ERROR OPENING UV FILE.' IERR = 1 GO TO 990 END IF CALL CHR2H (12, INNAME, 1, XNAME) CALL CHR2H (6, INCLAS, 1, XCLASS) XDISK = INDISK XSEQ = INSEQ NCFILE = NCFILE + 1 FVOL(NCFILE) = INDISK FCNO(NCFILE) = CNO FRW(NCFILE) = 0 CALL COPY (256, CATBLK, CATUV) C Get uv pointer information from C the catalog header. CALL UVPGET (IERR) IF (IERR.NE.0) THEN MSGTXT = 'UVHGIN: ERROR GETTING OFFSETS FROM UV FILE HEADER.' IERR = 1 GO TO 990 END IF C Info for UVGET: C Put selection criteria into C correct common. UNAME = INNAME UCLAS = INCLAS UDISK = INDISK USEQ = INSEQ C Set time range. CALL RCOPY (8, XTIME, TIMRNG) IF ((TIMRNG(1)+TIMRNG(2)+TIMRNG(3)+TIMRNG(4)) .EQ.0.0) * TIMRNG(1)=-1.0E6 IF ((TIMRNG(5)+TIMRNG(6)+TIMRNG(7)+TIMRNG(8)) .EQ.0.0) * TIMRNG(5)=1.0E6 TSTART = TIMRNG(1) + TIMRNG(2) / 24. + TIMRNG(3) / (24. * 60.) + * TIMRNG(4) / (24. * 60. * 60.) TEND = TIMRNG(5) + TIMRNG(6) / 24. + TIMRNG(7) / (24. * 60.) + * TIMRNG(8) / (24. * 60. * 60.) UVRNG(1) = XUVRA(1) UVRNG(2) = XUVRA(2) IF (TYPUVD.GT.0) CALL RFILL (2, 0.0, UVRNG) IF (UVRNG(2).LE.0.0) UVRNG(2) = 1.0E10 C Check spectral channel. BCHAN = 1 ECHAN = 1 IF (JLOCF.GE.0) THEN I = CATBLK(KINAX+JLOCF) IF (I.GT.1) THEN BCHAN = IROUND (XBCHAN) ECHAN = IROUND (XECHAN) IF (BCHAN.LE.0) BCHAN = 1 IF ((ECHAN.LT.BCHAN) .OR. (ECHAN.GT.I)) ECHAN = I IF (BCHAN.GT.I) THEN WRITE (MSGTXT,1020) BCHAN, I IERR = 1 GO TO 990 END IF END IF END IF CHINC = XCHINC CHINC = MAX (1, CHINC) IF (CHINC.GT.ECHAN-BCHAN+1) CHINC = 1 C Check IF band BIF = 1 EIF = 1 IF (JLOCIF.GT.1) THEN I = CATBLK(KINAX+JLOCIF) IF (I.GT.1) THEN BIF = IROUND (XBIF) EIF = IROUND (XEIF) IF (BIF.LE.0) BIF = 1 IF ((EIF.LT.BIF) .OR. (EIF.GT.I)) EIF = I IF (BIF.GT.I) THEN WRITE (MSGTXT,1025) BIF, I IERR = 1 GO TO 990 END IF END IF END IF XBCHAN = BCHAN XECHAN = ECHAN XCHINC = CHINC XBIF = BIF XEIF = EIF DOPOL = IROUND(XDOPOL) IF (XDOPOL.GT.0.0) DOPOL = MAX (1, DOPOL) PDVER = IROUND (XPDVER) DOAPPL = .FALSE. SUBARR = IROUND (XSUBA) IF (SUBARR.LT.0) SUBARR = 0 FGVER = IROUND (XFLAG) DOBAND = IROUND (XDOBND) BPVER = IROUND (XBPVER) C Freq id IF (XBAND.GT.0.0) SELBAN = XBAND IF (XFREQ.GT.0.0) SELFRQ = XFREQ FRQSEL = IROUND (XFQID) IF (FRQSEL.EQ.0) FRQSEL = -1 LUN = 28 C Allow multiple subarrays CALL FNDEXT ('AN', CATBLK, NSUBA) IF ((SUBARR.GT.0) .AND. (SUBARR.LE.NSUBA)) NSUBA = 1 NSUBA = MAX (1, NSUBA) C Allow multiple FQ ids NFRQ = 1 IF ((FRQSEL.LE.0) .AND. (SELBAN.LE.0.0) .AND. (SELFRQ.LE.0D0)) * THEN FRQSEL = 1 C Determine the number of FREQIDs. FQVER = 1 CALL ISTAB ('FQ', INDISK, CNO, FQVER, LUN, FQBUFF, TABLE, * EXIST, FITASC, IERR) IF (EXIST .AND. (IERR.EQ.0)) THEN CALL FQINI ('READ', FQBUFF, INDISK, CNO, FQVER, CATBLK, * LUN, IFQRNO, FQKOLS, FQNUMV, NIF, JERR) IF (JERR.NE.0) GO TO 999 NFRQ = FQBUFF(5) IF (NFRQ.GT.1) THEN WRITE (MSGTXT,1030) NFRQ CALL MSGWRT (3) END IF CALL TABIO ('CLOS', 0, IFQRNO, FQBUFF, FQBUFF, JERR) IF (JERR.NE.0) GO TO 999 END IF END IF C Find specified FQ id CALL FQMATC (INDISK, CNO, CATBLK, LUN, SELBAN, SELFRQ, * MATCH, FRQSEL, JERR) IF (.NOT.MATCH) THEN MSGTXT = 'NO MATCH TO SELBAND/SELFREQ ADVERBS - CHECK INPUTS' JERR = 1 GO TO 990 END IF IF (JERR.GT.0) GO TO 999 DOACOR = .FALSE. CALL RCOPY (3, XSMOTH, SMOOTH) CLVER = IROUND (XGUSE) CLUSE = IROUND (XGUSE) BLVER = IROUND (XBLVER) C histogram type ATYPE(1) = IROUND (BPARM(1)) ATYPE(2) = IROUND (BPARM(2)) IF ((ATYPE(1).LT.1) .OR. (ATYPE(1).GT.12) .OR. (ATYPE(2).LT.1) * .OR. (ATYPE(2).GT.12) .OR. (ATYPE(1).EQ.ATYPE(2))) THEN ATYPE(1) = 1 ATYPE(2) = 2 END IF C Hermitian?? IF (ATYPE(1).EQ.12) THEN HERMIT = ATYPE(2).EQ.9 ATYPE(1) = 10 ELSE IF (ATYPE(2).EQ.12) THEN HERMIT = ATYPE(1).EQ.9 ATYPE(2) = 10 END IF CSIZE = 100.0 * BPARM(8) + 0.5 CSIZE = (CSIZE/2) * 2 + 1 CTYPE = IROUND (BPARM(9)) IF (CSIZE.EQ.1) CTYPE = -1 C build image header CALL CATINI (CATBLK) CALL RCOPY (2, CATUH(KHOBJ), CATH(KHOBJ)) CALL RCOPY (2, CATUH(KHTEL), CATH(KHTEL)) CALL RCOPY (2, CATUH(KHINS), CATH(KHINS)) CALL RCOPY (2, CATUH(KHOBS), CATH(KHOBS)) CALL RCOPY (2, CATUH(KHDOB), CATH(KHDOB)) CATBLK(KIDIM) = 5 CATBLK(KINAX) = IMSIZE(1) CATBLK(KINAX+1) = IMSIZE(2) CATR(KREPO) = CATUR(KREPO) C Build new file cat name. CALL MAKOUT (INNAME, INCLAS, INSEQ, CBLANK, OUNAME, OUCLAS, SEQO) CALL CHR2H (12, OUNAME, KHIMNO, CATH(KHIMN)) CALL CHR2H (6, OUCLAS, KHIMCO, CATH(KHIMC)) CALL CHR2H (2, 'MA', KHPTYO, CATH(KHPTY)) CATBLK(KIIMS) = SEQO C Create new cataloged file. CALL MCREAT (DISKO, CNOO, SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1100) IERR GO TO 990 END IF SEQO = CATBLK(KIIMS) CALL COPY (256, CATBLK, MAPHDR) NCFILE = NCFILE + 1 FVOL(NCFILE) = DISKO FCNO(NCFILE) = CNOO FRW(NCFILE) = 2 C copy some (all) keywords CALL KEYPCP (INDISK, CNO, DISKO, CNOO, 0, ' ', IERR) GO TO 999 C 990 CALL MSGWRT (8) C 999 RETURN C----------------------------------------------------------------------- 1010 FORMAT ('UVHGIN: ERROR GETTING ADVERB VALUES.') 1020 FORMAT ('UVHGIN: FREQUENCY CHANNEL',I4,' EXCEEDS LIMIT',I4) 1025 FORMAT ('UVHGIN: IF BAND',I4,' EXCEEDS LIMIT',I4) 1030 FORMAT ('Plotting',I4,' frequency IDs.') 1100 FORMAT ('UVHGIN: MCREAT ERROR',I5) END SUBROUTINE BLDHGM (NX, NY, IMG, CS, CF, IERR) C----------------------------------------------------------------------- C BLDHGM does two passes through the uv data file. Firstly to get C the maxima and minima of the various parameters, and second to C construct the histogram image C Inputs: C NX I X pixels in image C NY I Y pixels in image C CS I size convolving function C CF R(CS,CS) convolving function C Outputs: C IMG R(NX,NY) histogram image C IERR I error code from UV disk IO mostly C----------------------------------------------------------------------- INTEGER NX, NY, CS, IERR REAL IMG(NX,NY), CF(CS,CS) C INCLUDE 'INCS:ZPBUFSZ.INC' LOGICAL DOTHIS, REQBAS INTEGER ADDRES, IBIN(2), IROUND, K, IIF, ICHAN, ISTK1, ISTK2, * ISTK, JSUB, IFRQ, ISUB, NIF, NXVER, NXLUN, NANT, IANT(50), * NBAS, IBAS(50), DESEL, I, J, IHERM, NHERM REAL AMPMAX, AMPSQ, ASQMAX, IM, R2D, RE, RSQ, TMAX, TMIN, U, * V, VAR, W, WGT, WGTMAX, UVMAX, RSQMAX, VIS(UVBFSS), RPARM(20), * CATUVR(256), RBIN(2) DOUBLE PRECISION FI, FZ, FRQMUL INCLUDE 'UVHIM.INC' INCLUDE 'INCS:DSEL.INC' DOUBLE PRECISION FOFF(MAXIF) REAL FINC(MAXIF) INTEGER ISBAND(MAXIF) CHARACTER BNDCOD(MAXIF)*8 INCLUDE 'INCS:DDCH.INC' INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DUVH.INC' EQUIVALENCE (CATUV, CATUVR) PARAMETER (R2D = 180.0/3.14159265358) C----------------------------------------------------------------------- NHERM = 1 IF (HERMIT) NHERM = 2 JSUB = SUBARR NXVER = 1 NXLUN = 90 C Initialize baseline selection. CALL SETANT (50, XANT, XBASE, NANT, NBAS, IANT, IBAS, DESEL) C init maxima RSQMAX = 0.0 TMIN = 1E30 TMAX = -1E30 ASQMAX = 0.0 WGTMAX = 0.0 ISTK1 = 1 ISTK2 = 0 C range set by user IF ((BPARM(3).GT.0.0) .AND. (BPARM(4).LT.BPARM(5)) .AND. * (BPARM(6).LT.BPARM(7))) THEN DOMAIN(1,1) = BPARM(4) DOMAIN(2,1) = BPARM(5) DOMAIN(1,2) = BPARM(6) DOMAIN(2,2) = BPARM(7) C range set by data ELSE MSGTXT = 'Begin determination of scaling' CALL MSGWRT (1) DO 70 IFRQ = 1,NFRQ IF (NFRQ.GT.1) FRQSEL = IFRQ CALL CHNDAT ('READ', NXBUFF, INDISK, CNO, NXVER, CATUV, * NXLUN, NIF, FOFF, ISBAND, FINC, BNDCOD, FRQSEL, IERR) IF (IERR.NE.0) THEN MSGTXT = 'PROBLEM FINDING FREQUENCIES' CALL MSGWRT (6) GO TO 70 END IF DO 60 ISUB = 1,NSUBA IF (JSUB.EQ.0) SUBARR = ISUB C Init vis file for read. CALL UVGET ('INIT', RPARM, VIS, IERR) C IF (IERR.EQ.-1) GO TO 50 IF (IERR.EQ.5) GO TO 50 IF (IERR.GT.0) GO TO 999 IF (ISTK2.LE.0) ISTK2 = CATBLK(KINAX+JLOCS) C Loop Read vis. record. 10 CALL UVGET ('READ', RPARM, VIS, IERR) IF (IERR.GT.0) THEN WRITE (MSGTXT,1010) IERR GO TO 990 C a data record ELSE IF (IERR.EQ.0) THEN C Do we need this baseline? IF (ILOCB.GE.0) THEN I = INT (RPARM(ILOCB+1)) / 256 J = MOD (INT (RPARM(ILOCB+1)), 256) ELSE I = RPARM(ILOCA1+1) + 0.1 J = RPARM(ILOCA2+1) + 0.1 END IF IF (.NOT.REQBAS (I, J, DESEL, IANT, NANT, IBAS, NBAS)) * GO TO 10 DOTHIS = .FALSE. DO 40 ICHAN = BCHAN,ECHAN,CHINC DO 30 IIF = BIF,EIF FZ = FOFF(IIF) / UVFREQ + 1.0D0 FI = FINC(IIF) / UVFREQ FRQMUL = 1.0D0 IF (TYPUVD.LE.0) FRQMUL = FZ + FI * * (ICHAN - 1 + BCHAN - CATUVR(KRCRP+KLOCFY)) FRQMUL = FRQMUL ** 2 DO 20 ISTK = ISTK1,ISTK2 ADDRES = 1 + (ICHAN-BCHAN) * INCF + * (IIF-BIF) * INCIF + (ISTK-ISTK1) * INCS WGT = VIS(ADDRES+2) C Get maxima and minima. IF (WGT.GT.0.0) THEN DOTHIS = .TRUE. RE = VIS(ADDRES) IM = VIS(ADDRES+1) AMPSQ = RE**2 + IM**2 ASQMAX = MAX (ASQMAX, AMPSQ) WGTMAX = MAX (WGTMAX, WGT) END IF 20 CONTINUE 30 CONTINUE 40 CONTINUE C Get maxima and minima. IF (DOTHIS) THEN RSQ = (RPARM(1+ILOCU)**2 + RPARM(1+ILOCV)**2) * * FRQMUL RSQMAX = MAX (RSQ, RSQMAX) TMIN = MIN (TMIN, RPARM(1+ILOCT)) TMAX = MAX (TMAX, RPARM(1+ILOCT)) END IF GO TO 10 END IF 50 CALL UVGET ('CLOS', RPARM, VIS, IERR) 60 CONTINUE 70 CONTINUE C AMPMAX = SQRT (ASQMAX) UVMAX = SQRT (RSQMAX) DO 75 I = 1,2 IF (ATYPE(I).LE.2) THEN DOMAIN(1,I) = -AMPMAX DOMAIN(2,I) = AMPMAX ELSE IF (ATYPE(I).EQ.3) THEN DOMAIN(1,I) = 0.0 DOMAIN(2,I) = AMPMAX ELSE IF (ATYPE(I).EQ.4) THEN DOMAIN(1,I) = -180.0 DOMAIN(2,I) = 180.0 ELSE IF (ATYPE(I).EQ.5) THEN DOMAIN(1,I) = 0.0 DOMAIN(2,I) = WGTMAX ELSE IF (ATYPE(I).EQ.6) THEN DOMAIN(1,I) = TMIN DOMAIN(2,I) = TMAX ELSE IF (ATYPE(I).EQ.7) THEN DOMAIN(1,I) = 0.0 DOMAIN(2,I) = UVMAX ELSE IF (ATYPE(I).EQ.8) THEN DOMAIN(1,I) = -180.0 DOMAIN(2,I) = 180.0 ELSE IF (ATYPE(I).GE.9) THEN DOMAIN(1,I) = -UVMAX DOMAIN(2,I) = UVMAX END IF IF (BPARM(3).GT.0.0) THEN IF (BPARM(2+2*I).LT.BPARM(3+2*I)) THEN DOMAIN(1,I) = BPARM(2+2*I) DOMAIN(2,I) = BPARM(3+2*I) ELSE IF (BPARM(2+2*I).GT.BPARM(3+2*I)) THEN DOMAIN(1,I) = MAX (BPARM(3+2*I), DOMAIN(1,I)) DOMAIN(2,I) = MIN (BPARM(2+2*I), DOMAIN(2,I)) END IF END IF 75 CONTINUE END IF C Second pass: Accumulate data C for the histograms. C Clear the histogram storage C array. MSGTXT = 'Begin binning of the data' CALL MSGWRT (1) I = NX * NY CALL RFILL (I, 0.0, IMG) NOUT = 0 NIN = 0 C over FQID DO 170 IFRQ = 1,NFRQ IF (NFRQ.GT.1) FRQSEL = IFRQ CALL CHNDAT ('READ', NXBUFF, INDISK, CNO, NXVER, CATUV, * NXLUN, NIF, FOFF, ISBAND, FINC, BNDCOD, FRQSEL, IERR) IF (IERR.NE.0) GO TO 170 DO 160 ISUB = 1,NSUBA IF (JSUB.EQ.0) SUBARR = ISUB C Init vis file for read. CALL UVGET ('INIT', RPARM, VIS, IERR) C IF (IERR.EQ.-1) GO TO 155 IF (IERR.EQ.5) GO TO 155 IF (IERR.GT.0) GO TO 999 IF (ISTK2.LE.0) ISTK2 = CATBLK(KINAX+JLOCS) C Loop Read vis. record. 110 CALL UVGET ('READ', RPARM, VIS, IERR) IF (IERR.GT.0) THEN WRITE (MSGTXT,1010) IERR, IFRQ, ISUB GO TO 990 C a data record ELSE IF (IERR.EQ.0) THEN C Do we need this baseline? IF (ILOCB.GE.0) THEN I = INT (RPARM(ILOCB+1)) / 256 J = MOD (INT (RPARM(ILOCB+1)), 256) ELSE I = RPARM(ILOCA1+1) + 0.1 J = RPARM(ILOCA2+1) + 0.1 END IF IF (.NOT.REQBAS (I, J, DESEL, IANT, NANT, IBAS, NBAS)) * GO TO 110 C Get visibilities out of uvbuff. DO 150 ICHAN = BCHAN,ECHAN,CHINC DO 140 IIF = BIF,EIF FZ = FOFF(IIF) / UVFREQ + 1.0D0 FI = FINC(IIF) / UVFREQ FRQMUL = 1.0D0 IF (TYPUVD.LE.0) FRQMUL = FZ + FI * * (ICHAN - 1 + BCHAN - CATUVR(KRCRP+KLOCFY)) C Get (u,v,w) out of uvbuff. U = RPARM(1+ILOCU) * FRQMUL V = RPARM(1+ILOCV) * FRQMUL W = RPARM(1+ILOCW) * FRQMUL DO 130 ISTK = ISTK1,ISTK2 ADDRES = 1 + (ICHAN-BCHAN) * INCF + * (IIF-BIF) * INCIF + (ISTK-ISTK1) * INCS RE = VIS(ADDRES) IM = VIS(ADDRES+1) WGT = VIS(ADDRES+2) IF (WGT.GT.0.0) THEN DO 125 IHERM = 1,NHERM DO 120 I = 1,2 VAR = 0.0 K = ATYPE(I) C Identify the variable. IF (K.EQ.9) THEN VAR = U ELSE IF (K.EQ.10) THEN VAR = V ELSE IF (K.EQ.11) THEN VAR = W ELSE IF (K.EQ.7) THEN VAR = SQRT (U*U + V*V) ELSE IF (K.EQ.8) THEN IF ((U.NE.0.0) .OR. (V.NE.0.0)) * VAR = ATAN2 (V, U) * R2D ELSE IF (K.EQ.6) THEN VAR = RPARM(1+ILOCT) ELSE IF (K.EQ.1) THEN VAR = RE ELSE IF (K.EQ.2) THEN VAR = IM ELSE IF (K.EQ.3) THEN VAR = SQRT (RE*RE + IM*IM) ELSE IF (K.EQ.4) THEN IF ((RE.NE.0.0) .OR. (IM.NE.0.0)) * VAR = ATAN2 (IM, RE) * R2D ELSE IF (K.EQ.5) THEN VAR = WGT END IF C Calculate the bin. RBIN(I) = (IMSIZE(I)-1.0) * * (VAR-DOMAIN(1,I)) / * (DOMAIN(2,I)-DOMAIN(1,I)) + 1.0 IBIN(I) = IROUND (RBIN(I)) 120 CONTINUE C Check for under- or overflow. IF ((IBIN(1).LT.1) .OR.(IBIN(2).LT.1) .OR. * (IBIN(1).GT.IMSIZE(1)) .OR. * (IBIN(2).GT.IMSIZE(2))) THEN NOUT = NOUT + 1 C grid the sample ELSE IF (CS.EQ.1) THEN NIN = NIN + 1 IMG(IBIN(1),IBIN(2)) = * IMG(IBIN(1),IBIN(2)) + 1 ELSE NIN = NIN + 1 CALL GRIDIT (NX, NY, IMG, CS, CF, RBIN, * IBIN) END IF U = -U V = -V 125 CONTINUE END IF 130 CONTINUE 140 CONTINUE 150 CONTINUE GO TO 110 END IF 155 CALL UVGET ('CLOS', RPARM, VIS, IERR) 160 CONTINUE 170 CONTINUE GO TO 999 C 990 CALL MSGWRT (8) C 999 RETURN C----------------------------------------------------------------------- 1010 FORMAT ('ERROR INITING FQ',I3,' SUBARRAY',I3) END SUBROUTINE BLDCNV (CS, CT, CF) C----------------------------------------------------------------------- C Build and normalizes the convolving function C Inputs: C CS I Size in pixels of convolving function C CT I Type of convolving function C Outputs: C CF R(CS,CS) Convolving function C----------------------------------------------------------------------- INTEGER CS, CT REAL CF(CS,CS) C INTEGER I, J, IC, IA, IB, I1, I2, J1, J2, II, JJ, IR REAL X, Y, R, SUP, YF, SCALE C----------------------------------------------------------------------- IC = (CS + 1) / 2 IF ((CT.LT.-4) .OR. (CT.GT.4) .OR. (CT.EQ.0)) CT = -1 C initial function computation SCALE = 1.0 / MAX (1.0, IC-1.0) SUP = (IC-1) * (IC-1) C rectangles : pill box IF (CT.EQ.-1) THEN I = CS * CS CALL RFILL (I, 1.0, CF) C linear ELSE IF (CT.EQ.-2) THEN DO 25 J = 1,CS Y = ABS (J-IC) YF = MAX (0.0, (1.0 - Y*SCALE)) DO 20 I = 1,CS X = ABS (I-IC) CF(I,J) = YF * MAX (0.0, (1.0 - X*SCALE)) 20 CONTINUE 25 CONTINUE C exponential ELSE IF (CT.EQ.-3) THEN DO 35 J = 1,CS Y = ABS (J-IC) * SCALE YF = EXP ( - 2.0 * Y) DO 30 I = 1,CS X = ABS (I-IC) * SCALE CF(I,J) = YF * EXP (-2.0 * X) 30 CONTINUE 35 CONTINUE C gaussian ELSE IF (CT.EQ.-4) THEN DO 45 J = 1,CS Y = ABS (J-IC) * SCALE YF = EXP ( - 4.0 * Y * Y) DO 40 I = 1,CS X = ABS (I-IC) * SCALE CF(I,J) = YF * EXP (-4.0 * X * X) 40 CONTINUE 45 CONTINUE C circular: pill box ELSE IF (CT.EQ.1) THEN DO 115 J = 1,CS Y = (J-IC)*(J-IC) DO 110 I = 1,CS X = I-IC R = X*X + Y IF (R.LE.SUP) THEN CF(I,J) = 1.0 ELSE CF(I,J) = 0.0 END IF 110 CONTINUE 115 CONTINUE C circular: linear ELSE IF (CT.EQ.2) THEN DO 125 J = 1,CS Y = (J-IC)*(J-IC) DO 120 I = 1,CS X = I-IC R = X*X + Y IF (R.LE.SUP) THEN R = SQRT (R) * SCALE CF(I,J) = MAX (0.0, (1.0 - R)) ELSE CF(I,J) = 0.0 END IF 120 CONTINUE 125 CONTINUE C circular: exponential ELSE IF (CT.EQ.3) THEN DO 135 J = 1,CS Y = (J-IC)*(J-IC) DO 130 I = 1,CS X = I-IC R = X*X + Y IF (R.LE.SUP) THEN R = SQRT (R) * SCALE CF(I,J) = 1.0 - EXP (-2.0 * R) ELSE CF(I,J) = 0.0 END IF 130 CONTINUE 135 CONTINUE C circular: gaussian ELSE IF (CT.EQ.4) THEN DO 145 J = 1,CS Y = (J-IC)*(J-IC) DO 140 I = 1,CS X = I-IC R = X*X + Y IF (R.LE.SUP) THEN R = R * SCALE * SCALE CF(I,J) = 1.0 - EXP (-4.0 * R) ELSE CF(I,J) = 0.0 END IF 140 CONTINUE 145 CONTINUE END IF C Now normalize so that each C convolution sums to 1.0 IA = IC - 25 IB = IC + 24 IR = (CS -1) / 100 + 1 DO 290 J = IA,IB J1 = J - 50 * IR IF (J1.LT.1) J1 = J1 + 50 IF (J1.LT.1) J1 = J1 + 50 IF (J1.LT.1) J1 = J1 + 50 IF (J1.LT.1) J1 = J1 + 50 J2 = J + 50 * IR IF (J2.GT.CS) J2 = J2 - 50 IF (J2.GT.CS) J2 = J2 - 50 IF (J2.GT.CS) J2 = J2 - 50 IF (J2.GT.CS) J2 = J2 - 50 DO 280 I = IA,IB I1 = I - 50 * IR IF (I1.LT.1) I1 = I1 + 50 IF (I1.LT.1) I1 = I1 + 50 IF (I1.LT.1) I1 = I1 + 50 IF (I1.LT.1) I1 = I1 + 50 I2 = I + 50 * IR IF (I2.GT.CS) I2 = I2 - 50 IF (I2.GT.CS) I2 = I2 - 50 IF (I2.GT.CS) I2 = I2 - 50 IF (I2.GT.CS) I2 = I2 - 50 SUP = 0.0 DO 220 JJ = J1,J2,50 DO 210 II = I1,I2,50 SUP = SUP + CF(II,JJ) 210 CONTINUE 220 CONTINUE IF (SUP.GT.0.0) THEN DO 240 JJ = J1,J2,50 DO 230 II = I1,I2,50 CF(II,JJ) = CF(II,JJ) / SUP 230 CONTINUE 240 CONTINUE END IF 280 CONTINUE 290 CONTINUE C 999 RETURN END SUBROUTINE GRIDIT (NX, NY, IMG, CS, CF, RBIN, IBIN) C----------------------------------------------------------------------- C grids a sample to the image C Inputs: C NX I X size of image C NY I Y size of image C CS I Size of convolving function C CF R(CS,CS) Convolving function C RBIN R(2) Bin location in image pixels C IBIN I(2) Integerized bin location C In/Out C IMG R(NX,NY) Image C----------------------------------------------------------------------- INTEGER NX, NY, CS, IBIN(2) REAL IMG(NX,NY), CF(CS,CS), RBIN(2) C INTEGER IC, ICX, ICY, IROUND, IR, I, I1, I2, J, J1, J2, II, JJ C----------------------------------------------------------------------- IC = (CS + 1) / 2 ICX = IROUND ((RBIN(1) - IBIN(1)) * 50.0) ICY = IROUND ((RBIN(2) - IBIN(2)) * 50.0) ICX = IC - ICX ICY = IC - ICY IR = (CS - 1) / 100 + 1 J1 = IBIN(2) - IR J2 = IBIN(2) + IR I1 = IBIN(1) - IR I2 = IBIN(1) + IR DO 50 J = J1,J2 JJ = ICY + (J-IBIN(2)) * 50 IF ((JJ.GE.1) .AND. (JJ.LE.CS)) THEN DO 40 I = I1,I2 II = ICX + (I-IBIN(1)) * 50 IF ((II.GE.1) .AND. (II.LE.CS)) * IMG(I,J) = IMG(I,J) + CF(II,JJ) 40 CONTINUE END IF 50 CONTINUE C 999 RETURN END SUBROUTINE WRIHGM (NX, NY, IMG, IERR) C----------------------------------------------------------------------- C WRIHGM completes the image header, writes the image data, does the C HI file C Inputs: C NX I X size of image C NY I Y size of image C IMG R(NX,NY) Image C Output: C IERR I Error code C CATBLK comes in pointing at UV data, MAPHDR at image header C----------------------------------------------------------------------- INTEGER NX, NY, IERR REAL IMG(NX,NY) C INCLUDE 'INCS:PMAD.INC' INCLUDE 'UVHIM.INC' INTEGER I, J, OLUN, OIND, OWIN(4), IBLKOF, NBY, OBIND, IH1LUN, * IH2LUN, I1, I2, NFILES CHARACTER TYPE(11)*8, UNITS(11)*11, MTYPE*2, HILINE*72 REAL CATR(256), BUFF(MABFSS), RMAX, RMIN, RSUM HOLLERITH CATH(256) DOUBLE PRECISION CATD(128) EQUIVALENCE (CATBLK, CATR, CATH, CATD) INCLUDE 'INCS:DSEL.INC' INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DUVH.INC' INCLUDE 'INCS:DDCH.INC' DATA TYPE /'VIS (RE)', 'VIS (IM)', 'VIS (AM)', 'VIS (PH)', * 'WEIGHT', 'TIME', 'BASELENG', 'BASEL PA', 'U', 'V', 'W'/ DATA UNITS /'Jy', 'Jy', 'Jy', 'Degrees', '1/(Jy**2)', 'Days', * 'Wavelengths', 'Degrees', 3*'Wavelengths'/ C----------------------------------------------------------------------- C work on header CALL CHR2H (8, 'COUNT ', 1, MAPH(KHBUN)) MAPD(KDORA) = CATD(KDORA) MAPD(KDODE) = CATD(KDODE) MAPD(KDRST) = CATD(KDRST) CALL CHR2H (8, TYPE(ATYPE(1)), 1, MAPH(KHCTP)) CALL CHR2H (8, TYPE(ATYPE(2)), 1, MAPH(KHCTP+2)) MAPD(KDCRV) = DOMAIN(1,1) MAPD(KDCRV+1) = DOMAIN(1,2) MAPR(KRCRP) = 1.0 MAPR(KRCRP+1) = 1.0 MAPR(KRCIC) = (DOMAIN(2,1)-DOMAIN(1,1)) / (IMSIZE(1)-1.0) MAPR(KRCIC+1) = (DOMAIN(2,2)-DOMAIN(1,2)) / (IMSIZE(2)-1.0) I = 1 IF (JLOCF.GE.0) THEN I = I + 1 MAPH(KHCTP+2*I) = CATH(KHCTP+2*JLOCF) MAPH(KHCTP+2*I+1) = CATH(KHCTP+2*JLOCF+1) MAPD(KDCRV+I) = CATD(KDCRV+JLOCF) + (1.-CATR(KRCRP+JLOCF)) * * CATR(KRCIC+JLOCF) MAPR(KRCIC+I) = CATR(KRCIC+JLOCF) MAPR(KRCRP+I) = 1.0 END IF IF (JLOCR.GE.0) THEN I = I + 1 MAPH(KHCTP+2*I) = CATH(KHCTP+2*JLOCR) MAPH(KHCTP+2*I+1) = CATH(KHCTP+2*JLOCR+1) MAPD(KDCRV+I) = CATD(KDCRV+JLOCR) MAPR(KRCIC+I) = CATR(KRCIC+JLOCR) MAPR(KRCRP+I) = 1.0 END IF IF (JLOCD.GE.0) THEN I = I + 1 MAPH(KHCTP+2*I) = CATH(KHCTP+2*JLOCD) MAPH(KHCTP+2*I+1) = CATH(KHCTP+2*JLOCD+1) MAPD(KDCRV+I) = CATD(KDCRV+JLOCD) MAPR(KRCIC+I) = CATR(KRCIC+JLOCD) MAPR(KRCRP+I) = 1.0 END IF MAPHDR(KIDIM) = I + 1 RMAX = -1.E10 RMIN = -RMAX RSUM = 0.0 DO 20 J = 1,NY DO 10 I = 1,NX IF ((DOBLNK.GT.0.0) .AND. (IMG(I,J).LE.0.0)) THEN IMG(I,J) = FBLANK ELSE RMAX = MAX (RMAX, IMG(I,J)) RMIN = MIN (RMIN, IMG(I,J)) RSUM = RSUM + IMG(I,J) END IF 10 CONTINUE 20 CONTINUE MAPR(KRDMX) = RMAX MAPR(KRDMN) = RMIN IF (DOBLNK.GT.0.0) MAPR(KRBLK) = FBLANK C force header update CALL CATIO ('UPDT', DISKO, CNOO, MAPHDR, 'REST', SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1000) IERR, 'CATIO UPDATE' CALL MSGWRT (7) END IF C open image output OLUN = 49 MTYPE = 'MA' CALL MAPOPN ('INIT', DISKO, OUNAME, OUCLAS, SEQO, MTYPE, NLUSER, * OLUN, OIND, CNOO, MAPHDR, SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1000) IERR, 'OPEN' GO TO 990 END IF OWIN(1) = 1 OWIN(2) = 1 OWIN(3) = NX OWIN(4) = NY IBLKOF = 1 NBY = 2 * MABFSS CALL MINIT ('WRIT', OLUN, OIND, NX, NY, OWIN, BUFF, NBY, IBLKOF, * IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1000) IERR, 'MINIT' GO TO 990 END IF DO 40 J = 1,NY CALL MDISK ('WRIT', OLUN, OIND, BUFF, OBIND, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1000) IERR, 'WRITE' GO TO 990 END IF CALL RCOPY (NX, IMG(1,J), BUFF(OBIND)) 40 CONTINUE CALL MDISK ('FINI', OLUN, OIND, BUFF, OBIND, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1000) IERR, 'FINISH' GO TO 990 END IF C Initialize HITAB NFILES = 3 CALL HIINIT (NFILES) C Create and copy history file. IH1LUN = 61 IH2LUN = 62 CALL HISCOP (IH1LUN, IH2LUN, INDISK, DISKO, CNO, CNOO, * MAPHDR, BUFF, SCRTCH, IERR) IF (IERR.GT.3) GO TO 300 IF (IERR.EQ.3) GO TO 200 C add UVHIM history CALL HENCO1 (TSKNAM, INNAME, INCLAS, INSEQ, INDISK, IH2LUN, * SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 CALL HENCOO (TSKNAM, OUNAME, OUCLAS, SEQO, DISKO, IH2LUN, * SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 C calibration adverbs C TIMERANG CALL HITIME (TSTART, TEND, IH2LUN, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 C Stokes' WRITE (HILINE,1100) TSKNAM, XSTOK CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 C IF range WRITE (HILINE,1110) TSKNAM, BIF, EIF CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 C Chan range WRITE (HILINE,1120) TSKNAM, BCHAN, ECHAN, CHINC CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 C Subarray IF (NSUBA.LE.1) THEN WRITE (HILINE,1130) TSKNAM, SUBARR ELSE WRITE (HILINE,1131) TSKNAM, NSUBA END IF CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 C Flagging IF (FGVER.GT.0) THEN WRITE (HILINE,1140) TSKNAM, FGVER CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C Spectral smoothing IF (SMOOTH(1).GT.0.5) THEN I1 = SMOOTH(1) + 0.5 I2 = SMOOTH(3) + 0.5 WRITE (HILINE,1150) TSKNAM, I1, SMOOTH(2), I2 CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C Calibration IF (DOCAL) THEN WRITE (HILINE,1160) TSKNAM, CLUSE CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C Polzn correction IF (DOPOL.GT.0) THEN WRITE (HILINE,1170) TSKNAM, DOPOL CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C BL table IF (XBLVER.GE.0.0) THEN WRITE (HILINE,1180) TSKNAM, BLVER CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C BP table IF (XDOBND.GT.0.0) THEN WRITE (HILINE,1190) TSKNAM, DOBAND CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 WRITE (HILINE,1200) TSKNAM, BPVER CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C Calibrate weights? IF (DOCAL) THEN IF (DOWTCL) THEN WRITE (HILINE,1210) TSKNAM ELSE WRITE (HILINE,1211) TSKNAM END IF CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 END IF C Add any other history WRITE (HILINE,1220) TSKNAM, 'X', TYPE(ATYPE(1)), UNITS(ATYPE(1)) CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 MSGTXT = HILINE(8:) CALL MSGWRT (2) WRITE (HILINE,1221) TSKNAM, 'X', DOMAIN(1,1), DOMAIN(2,1) CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 MSGTXT = HILINE(8:) CALL MSGWRT (2) WRITE (HILINE,1220) TSKNAM, 'Y', TYPE(ATYPE(2)), UNITS(ATYPE(2)) CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 MSGTXT = HILINE(8:) CALL MSGWRT (2) WRITE (HILINE,1221) TSKNAM, 'Y', DOMAIN(1,2), DOMAIN(2,2) CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 MSGTXT = HILINE(8:) CALL MSGWRT (2) WRITE (HILINE,1225) TSKNAM, NIN, RSUM CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 MSGTXT = HILINE(8:) CALL MSGWRT (2) IF (NOUT.GT.0) THEN WRITE (HILINE,1226) TSKNAM, NOUT CALL HIADD (IH2LUN, HILINE, SCRTCH, IERR) IF (IERR.NE.0) GO TO 200 MSGTXT = HILINE(8:) CALL MSGWRT (2) END IF C 200 CALL HICLOS (IH2LUN, .TRUE., SCRTCH, IERR) C close image 300 CALL MAPCLS ('INIT', DISKO, CNOO, OLUN, OIND, MAPHDR, .TRUE., * SCRTCH, IERR) GO TO 999 C 990 CALL MSGWRT (8) C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('WRIHGM: ERROR',I5,' DOING ',A) 1100 FORMAT (A6,'STOKES = ''',A4,''' / Stokes type') 1110 FORMAT (A6,'BIF =',I4,', EIF =',I4,'/ IF range') 1120 FORMAT (A6,'BCHAN=',I5,', ECHAN=',I5,', CHINC=',I3, * ' / Chan range') 1130 FORMAT (A6,'SUBARRAY =',I4) 1131 FORMAT (A6,'NSUBA =',I4,' / multiple subarrays included') 1140 FORMAT (A6,'/ Edited using FG table version',I3) 1150 FORMAT (A6,'SMOOTH = ',I1,',',F6.1,',',I4, * ' / Spectral smoothing parms') 1160 FORMAT (A6,'GAINUSE =',I3,' / CL table') 1170 FORMAT (A6,'DOPOL = ',I2,' / polarization correction made') 1180 FORMAT (A6,'BL table ',I3,' / applied to data') 1190 FORMAT (A6,'/ BP correction done, DOBAND = ',I2) 1200 FORMAT (A6,'/ BP correction used BP table ',I2) 1210 FORMAT (A6,'/ Weights calibrated') 1211 FORMAT (A6,'/ Weights not calibrated') 1220 FORMAT (A6,'/ ',A,'-axis type ',A,' units ',A) 1221 FORMAT (A6,'/ ',A,'-axis range',2(1PE13.5)) 1225 FORMAT (A6,'/ Pixels in image',I10,' pix sum',F13.2) 1226 FORMAT (A6,'/ Values outside image',I10) END
SUBROUTINE SCAN C C THIS IS THE MAIN DRIVER FOR THE OUTPUT SCAN MODULE - SCAN C C THIS SCAN MODULE CAN BE CALLED DIRECTLY FROM ALL RIGID FORMATS, OR C BY USER DMAP ALTER. THE CALLING INSTRUCTIONS ARE C C (THREE INPUT FILES IF CALLED BY RIGID FORMAT VIA SCAN INPUT CARDS) C (1) FORCE AND STRESS SCAN - C SCAN CASECC,OESI,OEFI/OESFI/*RF* $ (WHERE I=1, OR 2) C OR C SCAN CASECC,OESI,OEFI/OESFI/*OLI* $ FOR ON-LINE SCAN C C . IF INPUT FILES ARE OES1, OEF1, SORT1 TYPE DATA ARE SCANNED C . IF INPUT FILES ARE OES2, OEF2, SORT2 TYPE DATA ARE SCANNED C C (ONE INPUT FILE ONLY IF CALLED BY USER VIA DMAP ALTER) C (2) STRESS SCAN - C SCAN, ,OESI, /OESFI/C,N,ELEMENT/C,N,ICOMP/C,N,NTOP/C,N,AMAX/ C C,N,AMIN/C,N,IBEG/C,N,IEND/C,N,ICOMPX $ C OR (3) FORCE SCAN - C SCAN, ,,OEFI /OESFI/C,N,ELEMENT/C,N,ICOMP/C,N,NTOP/C,N,AMAX/ C C,N,AMIN/C,N,IBEG/C,N,IEND/C,N,ICOMPX $ C C . FOR SORT1 TYPE DATA, OESI AND OEFI ARE OES1 AND OEF1, AND C IBEG AND IEND ARE RANGE OF ELEMENT IDS TO BE SCANNED C . FOR SORT2 TYPE DATA, OESI AND OEFI ARE OES2 AND OEF2, AND C IBEG AND IEND ARE RANGE OF SUBCASE IDS TO BE SCANNED C . IF IBEG AND IEND ARE NOT GIVEN, ALL IDS IMPLY C C . OESB1, OESC1, OEFB1, AND OEFC1 CAN BE USED IN LIEU OF OES1 C AND OEF1. SIMILARLY, OESC2 AND OEFC2 FOR OES2 AND OEF2 C C INPUT FILES - CASECC, OES1, OEF1, (OR OES2, OEF2) C (OESB1, OESC1, OEFB1, OEFC1, OESB2, OEFB2 CAN BE C USED INSTEAD) C OUTPUT FILE - OESF1 (OR OESF2) C SCRATCH FILE - SCR1 C C THIS SCAN MODULE SHOULD BE FOLLOWED BY OFP TO PRINT SCAN RESULTS C OFP OESFI,,,,, //S,N,CARDNO $ C C PARAMETERS - C C ELEMENT - ELEMENT NAME IN BCD. E.G. BAR, CBAR, QUAD2, ETC. C ICOMP - THE OUTPUT FIELD NO. (BY COLUMN, 1 THRU 31) OF C OUTPUT LISTING. C ICOMPX - OUTPUT FIELD NO. CONTINUATION (FROM 32 THRU 62) C NTOP - TOP N VALUES TO BE OUTPUT. DEFAULT=20 C AMAX-AMIN - SCAN VALUES OUTSIDE THIS MAX-MIN RANGE, DEFAULT=0. C IBEG,IEND - SEE EXPLANATION ABOVE C C DEFINITION OF SOME LOCAL VARIABLES C C DEBUG - USED FOR LOCAL DEBUG C S OR F - STRESS OR FORCE SCAN FLAG C NSCAN - NO. OF SCAN INPUT CARDS IN CASECC C SUBC - CURRENT SUBCASE ID C NZ - TOP OF OPEN CORE, JUST BELOW GINO BUFFERS C LCORE - AVAILABLE CORE FOR STRSCN ROUTINE C IOPEN - INPUT FILE STATUS FLAG, .T. FOR OPEN, .F. NOT C JOPEN - OUTPUT FILE STATUS FLAG, .T. FOR OPEN, .F. NOT C KOPEN - SCR1 FILE STATUS FLAG, .T. FOR OPEN, .F. NOT C LOPEN - CASECC FILE STATUS FLAG, .T. FOR OPEN, .F. NOT C ISET - SCAN ONLY BY THE SPECIFIED SET OF ELEM. IDS C - ALL IS IMPLIED IF ISET IS NOT GIVEN C - USED ONLY IF SCAN IS CALLED FROM RIGID FORMAT C IDUPL,INC - SET UP COMPONENT FIELDS TO BE REPEATEDLY SCANNED C IDUPL TIMES, WITH FIELD INCREMENT BY INC (RF ONLY) C LBEG,LEND - A LIST OF TO-BE-SCANNED ELEMENT IDS, STORED IN C Z(LBEG) THRU Z(LEND). C - NO SUCH LIST EXISTS IF LBEG.GT.LEND OR LBEG=LEND=0 C IOPT - DATA SCAN BY AMAX AND AMIN IF IOPT=1, BY NTOP IF 2 C ISORT - SET TO 1 (BY STRSCN) IF DATA TYPE IS IN SORT1 C FORMAT, AND SET TO 2 IF SORT2 C C WRITTEN BY G.CHAN/SPERRY OCTOBER 1984 C C THIS ROUTINE OPENS AND CLOSES ALL INPUT AND OUTPUT FILES. C IT SETS UP THE SCANNING PARAMETERS AND CALL STRSCN TO SCAN THE C OUTPUT STRESS OR FORCE DATA C C THE SCAN INPUT CARDS OPERATE VERY SIMILARY TO THE ELEMENT STRESS C OR FORCE CARDS. THEY CAN BE PLACED ABOVE ALL SUBCASES, OR INSIDE C ANY SUBCASE LEVEL, OR BOTH C HOWEVER, UNLIKE THE STRESS OR FORCE CARDS, MULTI-SCAN CARDS ARE C ALLOWED, AND THEY DO NOT EXCLUDE ONE ANOTHER. C C MODIFIED IN 10/1989, TO ALLOW SETS TO BE DEFINED BEFORE OR AFTER C SCAN CARDS IN CASE CONTROL SECTION C (CURRENTLY, THIS MODIFICATION IS OK, BUT IFP1/IFP1H DO NOT ALLOW C SET TO BE DEFINED AFTER SCAN. IN FACT, IFP1 DOES NOT ALLOW SET TO C BE DEFINED AFTER ANY GUY WHO USES THE SET) C LOGICAL DEBUG, IOPEN, JOPEN, KOPEN, LOPEN CWKBI 1/4/94 SPR93010 & 93011 LOGICAL STRESS, FORCE, LAYERD CWKBI 1/4/94 SPR93010 & 93011 INTEGER QUAD4, TRIA3 CRLBR 12/29/93 SPR 93010 & 93011 C INTEGER CASECC, OESI, OEFI, OESFI, SCR1, INTEGER CASECC, OESI(2), OEFI(2), OESFI(2), SCR1, 1 OUFILE, FILE, SORF, Z(166), NAM(2), 2 E, EOR, SUBC, OSUBC, OEL CRLBNB 12/29/93 SPR 93010 & 93011 INTEGER JELT(2) CRLBNE 12/29/93 SPR 93010 & 93011 CHARACTER UFM*23, UWM*25, UIM*29, SFM*25, SWM*27 COMMON /XMSSG / UFM, UWM, UIM, SFM, SWM COMMON /BLANK / IELT(2), ICOMP, NTOP, AMAX, AMIN, 1 IBEG, IEND, ICOMPX COMMON /SYSTEM/ IBUF, NOUT, SKP(83), INTRA COMMON /NAMES / RD, RDREW, WRT, WRTREW, REW, 1 NOREW, EOFNRW COMMON /GPTA1 / NELEM, LAST, INCR, E(1) COMMON /XSCANX/ INFILE, OUFILE, LCORE, LBEG, LEND, 1 IOPEN, JOPEN, IEL, IOPT, ISET, 2 ISORT, ITRL3, SUBC, OSUBC, OEL, CWKBR 1/4/94 SPR93010 & 93011 3 DEBUG 3 DEBUG, LLOOP, QUAD4, TRIA3, STRESS, 4 FORCE, LAYERD COMMON /ZZZZZZ/ CORE(1) EQUIVALENCE (IMAX,AMAX), (IMIN,AMIN), 1 (IDUPL,IBEG), (INC,IEND), 2 (CORE(1),Z(1)) CRLBDB 12/29/93 SPR 93010 & 93011 C DATA CASECC, OESI, OEFI, OESFI, SCR1 / C 1 101, 102, 103, 201, 301 / CRLBDE 12/29/93 SPR 93010 & 93011 CRLBNB 12/29/93 SPR 93010 & 93011 DATA CASECC, OESI(1), OEFI(1), OESI(2), OEFI(2), 1 OESFI(1), OESFI(2), SCR1 / 2 101, 102, 103, 104, 105, 3 201, 202, 301 / CRLBNE 12/29/93 SPR 93010 & 93011 DATA NAM, LLC, EOR, IRF / 1 4HSCAN, 4H , 4HC , 1, 4HRF / DATA IOL1, IOL2 / 1 4HOL1 , 4HOL2 / C DEBUG = .FALSE. CWKBNB 1/4/94 SPR93011 & 93010 QUAD4 = 0 TRIA3 = 0 C C ALLOCATE OPEN CORE C CRLBNB 12/29/93 SPR 93010 & 93011 LLOOP = 1 JELT(1) = IELT(1) JELT(2) = IELT(2) 10 CONTINUE CRLBNB 12/29/93 SPR 93010 & 93011 NZ = KORSZ(Z) IBUF1 = NZ - IBUF + 1 IBUF2 = IBUF1 - IBUF IBUF3 = IBUF2 - IBUF NZ = IBUF3 - 1 LCORE = IBUF2 - 1 IOPEN =.FALSE. JOPEN =.FALSE. KOPEN =.FALSE. LOPEN =.FALSE. C C OPEN CASECC AND CHECK SCAN DATA C ISET = 0 IF (IELT(1) .NE. IRF) ISET = -2 IF (IELT(1).EQ.IOL1 .OR. IELT(1).EQ.IOL2) ISET = -3 IF (ISET .EQ. -2) GO TO 40 FILE = CASECC CALL OPEN (*310,CASECC,Z(IBUF1),RDREW) LOPEN = .TRUE. CALL FWDREC (*320,CASECC) IF (ISET .EQ. -3) GO TO 40 30 CALL READ (*80,*80,CASECC,Z(1),200,1,L) LENCC = Z(166) NSCAN = Z(LENCC-1) IF (NSCAN .EQ. 0) GO TO 30 C C CHECK THE PRESENCE OF STRESS AND/OR FORCE FILE. C QUIT IF BOTH ARE PURGED C 40 IOES = 1 IOEF = 1 CRLBDB 12/29/93 SPR 93010 & 93011 C Z( 1) = OESI C Z(11) = OEFI CRLBDE 12/29/93 SPR 93010 & 93011 CRLBNB 12/29/93 SPR 93010 & 93011 Z( 1) = OESI(LLOOP) Z(11) = OEFI(LLOOP) CRLBNE 12/29/93 SPR 93010 & 93011 CALL RDTRL (Z( 1)) CALL RDTRL (Z(11)) IF (Z( 1) .LT. 0) IOES = 0 IF (Z(11) .LT. 0) IOEF = 0 IF (IOES+IOEF.EQ.0 .AND. ISET.NE.-3) GO TO 300 C C OPEN OUTPUT FILE OESFI C CRLBDB 12/29/93 SPR 93010 & 93011 C FILE = OESFI C OUFILE = OESFI C CALL FNAME (OESFI,Z) C CALL OPEN (*310,OESFI,Z(IBUF2),WRTREW) C CALL WRITE (OESFI,Z,2,EOR) CRLBDE 12/29/93 SPR 93010 & 93011 CRLBNB 12/29/93 SPR 93010 & 93011 FILE = OESFI(LLOOP) OUFILE = OESFI(LLOOP) CALL FNAME (OUFILE,Z) CALL OPEN (*310,OUFILE,Z(IBUF2),WRTREW) CALL WRITE (OUFILE,Z,2,EOR) CRLBNE 12/29/93 SPR 93010 & 93011 JOPEN =.TRUE. ITRL3 = 0 LX =-1 IF (IELT(1) .EQ. IOL2) LX = -2 IF (ISET .EQ. -3) CALL ONLINS (*280,LX) IF (ISET .NE. -2) GO TO 90 C C SCAN CALLED BY USER VIA DMAP ALTER (ISET=-2) C ============================================ C LS = LCORE LBEG = 0 LEND = 0 C C CHECK USER DMAP ERROR, SET IOPT FLAG, AND INITIALIZE ISCAN ARRAY C FOR COMPONENT SPECIFIED. C IF (IOES+IOEF .GT. 1) GO TO 400 IF (AMIN .GT. AMAX) GO TO 410 IF (ICOMP .LE. 1) GO TO 420 IF ((AMAX.EQ.0. .AND. AMIN.EQ.0.) .AND. NTOP.EQ.0) GO TO 430 IF ((AMAX.NE.0. .OR. AMIN.NE.0.) .AND. NTOP.NE.0) GO TO 440 IF ((IBEG.EQ.0 .AND. IEND.NE.0) .OR. IBEG.GT.IEND .OR. 1 (IBEG.NE.0 .AND. IEND.EQ.0)) GO TO 460 IF ( IBEG.EQ.0 .AND. IEND.EQ.0 ) IBEG = -1 IOPT = 1 IF (NTOP .GT. 0) IOPT = 2 C C DETERMINE ELEMENT TYPE, DROP THE FIRST LETTER C IF NECESSARY C Z(1) = IRF Z(2) = IRF IF (KHRFN2(IELT(1),1,1) .NE. LLC) GO TO 50 Z(1) = KHRFN3(NAM(2),IELT(1),1,1) Z(1) = KHRFN1(Z(1),4,IELT(2),1 ) Z(2) = KHRFN3(NAM(2),IELT(2),1,1) 50 DO 60 I = 1,LAST,INCR IF (IELT(1).EQ.E(I) .AND. IELT(2).EQ.E(I+1)) GO TO 70 IF ( Z(1).EQ.E(I) .AND. Z(2).EQ.E(I+1)) GO TO 70 60 CONTINUE GO TO 450 70 IEL = E(I+2) C C SPECIAL HANDLING OF THE QUAD4 AND TRIA3 ELEMENT, STRESS ONLY C (THE 2ND, 3RD, 9TH, AND 13TH WORDS IN OES1/OES1L FILES ARE C NOT PRINTED. THE 9TH AND 13TH WORDS MAY BE BLANKS OR ASTERISKS) C IF ((IEL.NE.64 .AND. IEL.NE.83) .OR. IOES.EQ.0) GO TO 75 CWKBD 1/3/94 SPR93011 & 93011 ICOMP = ICOMP + 2 CWKBD 1/3/94 SPR93010 & 93011 IF (ICOMP .GT. 8) ICOMP = ICOMP + 1 C C OPEN INPUT FILE C CRLBDB 12/29/93 SPR 93010 & 93011 C75 INFILE = OESI C IF (IOES .EQ. 0) INFILE = OEFI CRLBDE 12/29/93 SPR 93010 & 93011 CRLBNB 12/29/93 SPR 93010 & 93011 75 INFILE = OESI(LLOOP) STRESS = .TRUE. FORCE = .FALSE. IF (IOES .NE. 0) GO TO 76 STRESS = .FALSE. FORCE = .TRUE. INFILE = OEFI(LLOOP) CRLBNE 12/29/93 SPR 93010 & 93011 76 FILE = INFILE CALL OPEN (*340,INFILE,Z(IBUF1),RDREW) IOPEN = .TRUE. C C ... NEXT I/O OPERATION ON INFILE WILL BE IN SUBROUTINE STRSCN C C ALL SET TO GO C J = 1 IF (IOES .EQ. 0) J = 2 CALL STRSCN (J) GO TO 280 C 80 CALL CLOSE (CASECC,REW) LOPEN = .FALSE. RETURN C C C SCAN IS CALLED BY RIGID FORMAT (ISET .GE. -1) C OR CALLED BY INTERACTIVE MODE (ISET .EQ. -3) C ============================================= C 90 LS = NZ C C OPEN SCR1 FILE, SEPERATE SCAN DATA FROM SET DATA IN CASECC, AND C SAVE THE COMPLETE SCAN DATA IN SCR1 FILE. C FILE = SCR1 CALL OPEN (*310,SCR1,Z(IBUF3),WRTREW) KOPEN =.TRUE. NSCAN = 0 NCASE = 0 NXX = NZ IF (INTRA .LE. 0) GO TO 95 NXX = 198 L = LX IF (LX .GT. 0) GO TO 110 95 FILE = CASECC CALL REWIND (CASECC) CALL FWDREC (*320,CASECC) C C READ CASECC AND PROCESS ALL SUBCASES C 100 CALL READ (*210,*110,CASECC,Z(1),NXX,1,L) IF (NXX .GE. 200) GO TO 380 110 NCASE = NCASE + 1 LENCC = Z(166) NSCAN = Z(LENCC-1) LSEM = Z(LENCC) SUBC = Z(1) C C PICK UP ALL THE SET ID'S AND THEIR LOCATIONS IN Z ARRAY, Z(L1) C THRU Z(LL). SORT, AND CHECK DUPLICATE C JMP = 0 II = LENCC + LSEM L1 = L + 1 LL = L 115 II = II + JMP IF (II .GE. L) GO TO 120 JMP = Z(II+2) + 2 IF (Z(II+1).GE.10000000 .AND. JMP.EQ.8) GO TO 115 Z(LL+1) = Z(II+1) Z(LL+2) = II LL = LL + 2 GO TO 115 120 LLL1 = LL - L1 + 1 LL2 = LLL1/2 IF (DEBUG) WRITE (NOUT,125) (Z(I),I=L1,LL) 125 FORMAT (' ...SET/@125',/,(10X,I8,' @',I6)) C JMP = 0 II = LENCC + LSEM KK = NZ IF (LL2 .LE. 1) GO TO 140 CALL SORT (0,0,2,1,Z(L1),LLL1) J = L1 + 2 DO 130 I = J,LL,2 IF (Z(I) .EQ. Z(I-2)) WRITE (NOUT,600) UWM,Z(I) 130 CONTINUE C C PROCESS THE SCAN CARDS C C PICK UP SCAN 8 WORD ARRAY, AND PICK UP SET DATA C WRITE TO SCR1 A RECORD (OF EACH SUBCASE) OF THE SCAN INPUT DATA C IN REVERSE ORDER (FIRST SCAN CARD LAST, AS SET UP BY CASECC) C 140 II = II + JMP IF (II .GE. L) GO TO 190 JMP = Z(II+2) + 2 IF (Z(II+1).LT.10000000 .OR. JMP.NE.8) GO TO 140 IE = 0 ISET= Z(II+4) IF (ISET .EQ. -1) GO TO 160 IF (LLL1 .LE. 0) GO TO 470 CALL BISLOC (*470,ISET,Z(L1),2,LL2,I) IB = Z(I+L1) + 2 IE = Z(IB) IF (DEBUG) WRITE (NOUT,145) ISET,I,IB,IE 145 FORMAT (' @145, SET',I8,' FOUND. I,IB,IE =',3I6) KK = KK - IE DO 150 I = 1,IE 150 Z(KK+I) = Z(IB+I) 160 KK = KK - 9 DO 170 I = 1,8 170 Z(KK+I) = Z(II+I) Z(KK+9) = 0 IDUPL = Z(KK+8) IF (IDUPL .EQ. 0) GO TO 180 CWKBD 1/3/94 SPR93010 & 93011 INC = IDUPL/100 CWKBD 1/3/94 SPR93010 & 93011 Z(KK+8) = MOD(IDUPL,100) CWKBNB 1/3/94 SPR93010 & 93011 INC = MOD ( IDUPL, 100 ) Z(KK+8) = IDUPL / 100 CWKBNE 1/3/94 SPR93010 & 93011 Z(KK+9) = INC 180 Z(KK+2) = Z(KK+2) + 1 + IE C C HERE AT THE TAIL END OF OPEN CORE, WE ACCUMULATE ANOTHER RECORD C OF A SCAN DATA SET C WORD 1, 10000000 FOR STRESS, OR 20000000 FOR FORCE C 2, NO. OF WORDS OF THIS DATA SET (SCAN + SET) C (FIRST 2 WORDS NOT INCLUDED) C 3, ELEMENT TYPE NUMERIC CODE C 4, SET-ID, OR -1 C 5, COMPONENT CODE, ICOMP C 6, NTOP, OR AMAX C 7, -1, OR AMIN C 8, COMPONENT - DUPLICATION, OR ZERO C 9, COMPONENT - INCREMENT, OR ZERO C 10-END, SET DATA C REPEAT FOR ANOTHER SCAN CARD C C C SPECIAL HANDLING OF THE QUAD4 AND TRIA3 ELEMENT, STRESS ONLY C (THE 2ND, 3RD, 9TH, AND 13TH WORDS IN OES1/OES1L FILES ARE C NOT PRINTED. THE 9TH AND 13TH WORDS MAY BE BLANKS OR ASTERISKS) CWKBI 12/93 SPR93010 & 93011 C ABOVE IS TRUE ONLY FOR LAMINATED QUAD4 AND TRIA3) C CWKBD 12/31/93 SPR93010 & 93011 C IF ((Z(KK+3).NE.64 .AND. Z(KK+3).NE.83) .OR. Z(KK+1).NE.10000000) IF ((Z(KK+3).NE.64 .AND. Z(KK+3).NE.83) .OR. Z(KK+8).EQ.0) 1 GO TO 140 CWKBDB 1/3/94 SPR93010 & 93011 C Z(KK+5) = Z(KK+5) + 2 C IF (Z(KK+5) .GT. 8) Z(KK+5) = Z(KK+5) + 1 C IF (Z(KK+9) .NE. 0) Z(KK+9) = Z(KK+9) + 2 CWKBDE 1/3/94 SPR93010 & 93011 GO TO 140 C C AT THE END OF EACH SUBCASE, WE COMPUTE THE TOTAL LENGTH OF THIS C SCAN DATA ARRAY, AND WRITE THE ARRAY OUT TO SCR1. ONE RECORD PER C SUBCASE C 190 KK = KK - 2 IF (KK .LT. LL) GO TO 610 IE = NZ - KK Z(KK+1) = SUBC Z(KK+2) = IE - 2 CALL WRITE (SCR1,Z(KK+1),IE,1) L = KK + 1 NN = 200 IF (DEBUG) WRITE (NOUT,200) NN,(Z(J),J=L,NZ) 200 FORMAT (/,11H SCAN/DEBUG,I3, (/2X,13I9)) IF (INTRA.LE.0 .OR. LX.LT.200) GO TO 100 C C THUS, END OF THE PREPARATION PHASE. CLOSE CASECC AND SCR1 C 210 CALL CLOSE (CASECC,REW) CALL CLOSE (SCR1 ,REW) KOPEN =.FALSE. LOPEN =.FALSE. C C NOW, SET UP 2 LOOPS FOR STRESS (10000000) AND FORCE (20000000) C OUTPUT SCAN C SORF = 30000000 220 SORF = SORF - 10000000 IF (DEBUG) WRITE (NOUT,225) SORF 225 FORMAT (///,18H PROCESSING SERIES,I15 /1X,8(4H====),/) IF (IOPEN) CALL CLOSE (INFILE,REW) IOPEN = .FALSE. IF (SORF.EQ.10000000 .AND. IOES.EQ.0) GO TO 220 IF (SORF.EQ.20000000 .AND. IOEF.EQ.0) GO TO 220 IF (SORF .LE. 0) GO TO 280 C C OPEN INPUT FILES C CRLBDB 12/29/93 SPR 93010 & 93011 C INFILE = OESI C IF (SORF .GE. 20000000) INFILE=OEFI CRLBDE 12/29/93 SPR 93010 & 93011 CRLBNB 12/29/93 SPR 93010 & 93011 INFILE = OESI(LLOOP) STRESS = .TRUE. FORCE = .FALSE. IF (SORF .LT. 20000000) GO TO 226 STRESS = .FALSE. FORCE = .TRUE. INFILE=OEFI(LLOOP) CRLBNE 12/29/93 SPR 93010 & 93011 226 FILE = INFILE CALL OPEN (*310,INFILE,Z(IBUF1),RDREW) IOPEN = .TRUE. C ... NEXT I/O OPERATION ON INFILE WILL BE IN SUBROUTINE STRSCN C C NOW, LOAD THE SCAN DATA PREVIOUSLY SAVED IN SCR1, TO THE TAIL END C OF THE OPEN CORE. C ONE OR MORE SCAN CARDS MAY BE PRESENT IN ONE SUBCASE C SET UP POINTERS IN FRONT OF THE SCAN DATA, SO THAT FIRST SCAN C INPUT CARD WILL BE PROCESS FIRST, SECOND CARD SECOND, ETC. C NOTE - USE SUBCASE 1 SCAN DATA IF OUTPUT IS SORT 2 TYPE C (IF SUBCASE 1 DOES NOT HAVE SCAN DATA, USE NEXT SUBCASE) C FILE = SCR1 IF (.NOT.KOPEN) CALL OPEN (*310,SCR1,Z(IBUF3),RDREW) IF ( KOPEN) CALL REWIND (SCR1) KOPEN =.TRUE. ISORT = 0 OSUBC = 0 OEL = 0 C DO 270 II = 1,NCASE IF (ISORT .EQ. 2) GO TO 220 CALL READ (*320,*330,SCR1,Z(1),2,0,L) J = Z(2) IF (J .EQ. 0) GO TO 260 SUBC = Z(1) LS = NZ - J CALL READ (*320,*330,SCR1,Z(LS+1),J,1,L) LE = LS I = LS 230 Z(LS) = I LS = LS - 1 I = I + Z(I+2) + 2 IF (I .LT. NZ) GO TO 230 LCORE = LS J = LS + 1 KK = 230 IF (DEBUG) WRITE (NOUT,200) KK,SUBC,(Z(I),I=J,NZ) C C NOW IS THE TIME TO SET THE SCAN PARAMETERS FOR EACH SCAN CARD C WITHIN A SUBCASE, AND CALL STRSCN TO SCAN THE OUTPUT DATA C I = LS 240 I = I + 1 IF (I .GT. LE) GO TO 270 IB = Z(I) IF (Z(IB+1) .NE. SORF) GO TO 240 JMP = Z(IB+2) IEL = Z(IB+3) C ONLY QUAD4 (=64) AND TRIA3 (=83) ARE VALID FOR LLOOP=2 IF ( LLOOP .EQ. 2 .AND. IEL .NE. 64 .AND. IEL .NE. 83 ) & GO TO 240 ISET = Z(IB+4) ICOMP = Z(IB+5) NTOP = Z(IB+6) IMAX = Z(IB+6) IMIN = Z(IB+7) IDUPL = Z(IB+8) INC = Z(IB+9) IOPT = 1 IF (IMIN .EQ. -1) IOPT = 2 IF (IOPT .NE. 2) NTOP = 0 LBEG = LCORE LEND = LCORE - 1 IF (ISET .EQ. -1) GO TO 250 LBEG = IB + 10 LEND = IB + JMP + 2 250 J = (IEL-1)*INCR IELT(1) = E(J+1) IELT(2) = E(J+2) IF (DEBUG) WRITE (NOUT,255) IELT,(Z(IB+J),J=3,9),IOPT,LBEG,LEND, 1 II,SUBC 255 FORMAT (/5X,16HDEBUG/SCAN255 - ,2A4,/5X,12I9) CALL STRSCN (SORF/10000000) IF (IOPT .LT. 0) GO TO 480 GO TO 240 260 CALL FWDREC (*320,SCR1) 270 CONTINUE C C GO BACK TO PROCESS NEXT INPUT FILE C GO TO 220 C C ALL SCAN DONE. WRITE OUTPUT FILE TRAILERS AND CLOSE ALL FILES C 280 IF (ITRL3 .LE. 0) GO TO 300 CRLBR 12/29/93 SPR 93010 & 93011 C Z(1) = OESFI Z(1) = OESFI(LLOOP) Z(2) = 1 Z(3) = ITRL3 DO 290 I = 4,7 290 Z(I) = 0 CALL WRTTRL (Z(1)) C 300 IF (IOPEN) CALL CLOSE (INFILE,REW) IF (JOPEN) CALL CLOSE (OUFILE,REW) IF (KOPEN) CALL CLOSE (SCR1 ,REW) IF (LOPEN) CALL CLOSE (CASECC,REW) CRLBNE 12/29/93 SPR 93010 & 93011 IF (LLOOP .EQ. 2) GO TO 305 LLOOP = 2 IELT(1) = JELT(1) IELT(2) = JELT(2) GO TO 10 305 CONTINUE IF ( QUAD4 .EQ. -1 ) WRITE ( NOUT, 605 ) 'QUAD4' IF ( TRIA3 .EQ. -1 ) WRITE ( NOUT, 605 ) 'TRIA3' 605 FORMAT(//' SCAN MODULE DID NOT FIND ELEMENT ',A5, & ' IN USER OUTPUT REQUESTS.',/ & ,' POSSIBLY WRONG COMPONENT SPECIFIED FOR LAYERED OR ' & ,'NON-LAYERED CASE',//) CRLBNE 12/29/93 SPR 93010 & 93011 RETURN C C FILE ERRORS C 310 J = -1 GO TO 350 320 J = -2 GO TO 350 330 J = -3 GO TO 350 340 CONTINUE GO TO 70 350 CALL MESAGE (J,FILE,NAM) 380 J = -8 GO TO 350 C C ERROR MESSAGES C 400 WRITE (NOUT,500) GO TO 490 410 WRITE (NOUT,510) GO TO 490 420 WRITE (NOUT,520) GO TO 490 430 WRITE (NOUT,530) GO TO 490 440 WRITE (NOUT,540) GO TO 490 450 WRITE (NOUT,550) IELT GO TO 490 460 WRITE (NOUT,560) SFM,IELT,IBEG,IEND GO TO 490 470 WRITE (NOUT,570) UWM,ISET GO TO 140 480 WRITE (NOUT,580) IOPT 490 WRITE (NOUT,590) SWM GO TO 280 C 500 FORMAT (//5X,48HONLY ONE INPUT FILE ALLOWED FROM SCAN DMAP ALTER) 510 FORMAT (//5X,21HAMAX-AMIN RANGE ERROR) 520 FORMAT (//5X,35HFIELD COMPONENT SPECIFICATION ERROR) 530 FORMAT (//5X,30HNO AMAX-AMIN OR NTOP SPECIFIED) 540 FORMAT (//5X,46HSPECIFY EITHER AMAX-AMIN OR NTOP, BUT NOT BOTH, 1 /5X,21H(NTOP=20 BY DEFAULT)) 550 FORMAT (//5X,22HELEMENT MIS-SPELLED - ,2A4) 560 FORMAT (A25,' - SCANNING ',2A4,' ELEMENT. IBEG-IEND OUT OF RANGE', 1 '. SCAN ABORTED') 570 FORMAT (A25,' FROM SCAN, SET',I9,' NOT FOUND') 580 FORMAT (//5X,44HUSER ERROR. ILLEGAL INPUT FILE SENT TO SCAN,I6) 590 FORMAT (A27,' FROM SCAN. CASE ABORTED ***') 600 FORMAT (A25,' FROM SCAN, DUPLICATE SET',I9) C 610 CALL MESAGE (8,0,NAM) RETURN END
C %W% %G% function get_value (ib, ia) integer ib, ia include 'tspinc/params.inc' include 'tspinc/wstequ.inc' include 'tspinc/room.inc' include 'tspinc/wfeq.inc' include 'tspinc/vfhistory.inc' include 'tspinc/filter.inc' if (ia .eq. 1) then volt = sqrt (eyr(ib) ** 2 + eyi(ib) ** 2) dv = amin1 (volt - rbuss(1,ib), 0.0) get_value = dv / rbuss(1,ib) else if (ia .eq. 2) then get_value = abs (frqbse + busfeq(ib)) else if (ia .eq. 3) then volt = sqrt (eyr(ib) ** 2 + eyi(ib) ** 2) get_value = volt else volt = sqrt (eyr(ib) ** 2 + eyi(ib) ** 2) dv = amax1 (volt - rbuss(1,ib), 0.0) get_value = dv / rbuss(1,ib) endif 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 divergence_rc(div, u, v, & u_bc_ew, v_bc_ns, & dpdx, dpdy, & dpdx_edge, dpdy_edge, & An, A_ew, A_ns, & div_rms, div_max, density, & dx, dy, dt, nx, ny) implicit double precision(a-h,o-z) double precision div(nx,ny), u(nx,ny), v(nx,ny) double precision u_bc_ew(ny,2) double precision v_bc_ns(nx,2) double precision An(nx,ny) ! A^n times ones double precision A_ew(nx-1, ny ) double precision A_ns(nx, ny-1) double precision dpdx(nx,ny), dpdy(nx,ny) double precision dpdx_edge(nx+1,ny), dpdy_edge(nx,ny+1) double precision u_ew(nx+1, ny) double precision v_ns(nx, ny+1) a = (dx*dy)/dt do j = 1, ny u_ew(1,j) = u_bc_ew(j,1) do i = 2, nx u_ew(i,j) = & 0.5*( & + u(i-1,j) & + dx*dy*dpdx(i-1,j) / (density * (a- 0.5d0*An(i-1,j) )) & + u(i,j) & + dx*dy*dpdx(i,j) / (density * (a- 0.5d0*An(i ,j) )) & ) & - dx*dy*dpdx_edge(i,j) * A_ew(i-1,j) / density enddo u_ew(nx+1,j) = u_bc_ew(j,2) enddo do i = 1, nx v_ns(i,1) = v_bc_ns(i,1) do j = 2, ny v_ns(i,j) = & 0.5*( & + v(i,j-1) & + dx*dy*dpdy(i,j-1) / (density * (a- 0.5d0*An(i,j-1) )) & + v(i,j) & + dx*dy*dpdy(i,j) / (density * (a- 0.5d0*An(i ,j) )) & ) & - dx*dy*dpdy_edge(i,j) * A_ns(i,j-1) / density enddo v_ns(i,ny+1) = v_bc_ns(i,2) enddo do j = 1, ny do i = 1, nx div(i,j) = dy*(u_ew(i,j) - u_ew(i+1,j)) & + dx*(v_ns(i,j) - v_ns(i,j+1)) enddo enddo div_max = 0.d0 div_rms = 0.d0 do j = 1, ny do i = 1, nx div(i,j) = abs(div(i,j)) if (div(i,j) .gt. div_max) div_max = div(i,j) div_rms = div_rms + div(i,j)**2 enddo enddo div_rms = sqrt(div_rms / float(nx*ny)) return end
SUBROUTINE GRDSET (FFTIM, SCRGRD, SCRWRK, BUFFER, IRET) C----------------------------------------------------------------------- C! Creates scratch files and sets up for GRDSUB C# UV Modeling C----------------------------------------------------------------------- C; Copyright (C) 1995, 1997, 2000, 2006, 2008-2009, 2012 C; Associated Universities, Inc. Washington DC, USA. C; C; This program is free software; you can redistribute it and/or C; modify it under the terms of the GNU General Public License as C; published by the Free Software Foundation; either version 2 of C; the License, or (at your option) any later version. C; C; This program is distributed in the hope that it will be useful, C; but WITHOUT ANY WARRANTY; without even the implied warranty of C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the C; GNU General Public License for more details. C; C; You should have received a copy of the GNU General Public C; License along with this program; if not, write to the Free C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, C; MA 02139, USA. C; C; Correspondence concerning AIPS should be addressed as follows: C; Internet email: aipsmail@nrao.edu. C; Postal address: AIPS Project Office C; National Radio Astronomy Observatory C; 520 Edgemont Road C; Charlottesville, VA 22903-2475 USA C----------------------------------------------------------------------- C GRDSET sets up for GRDSUB, mostly creates scratch files (type SC) C Also fills in LUNS array in /CFILES/ = 16,17,18,19,20 C Input: C FFTIM L Doing image or CC? C Output: C SCRGRD I /CFILES/ file number for grid file. C SCRWRK I /CFILES/ file number for work file C BUFFER I(512) Work buffer. C IRET I Return code, 0=>OK, otherwise failed. C----------------------------------------------------------------------- LOGICAL FFTIM INTEGER SCRGRD, SCRWRK, BUFFER(512), IRET C INTEGER NX, NY, NP(5), NCVSIZ, IFIELD, SIZE, SIZE2, MX, MY, * MXOFF, MYOFF, II INCLUDE 'INCS:PUVD.INC' INCLUDE 'INCS:DDCH.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DUVH.INC' INCLUDE 'INCS:DFIL.INC' INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DGDS.INC' C----------------------------------------------------------------------- C Setup. NCVSIZ = 10 C Find largest input file. NX = 1 NY = 1 DO 10 IFIELD = 1,MFIELD CALL CATIO ('READ', CCDISK(IFIELD), CCCNO(IFIELD), BUFFER, * 'REST', BUFFER(257), IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, IFIELD GO TO 990 END IF IF (FFTIM) THEN CALL IMGSIZ (BUFFER, BUFFER, MX, MY, MXOFF, MYOFF, IRET) ELSE MX = BUFFER(KINAX) MY = BUFFER(KINAX+1) END IF NX = MAX (NX, MX) NY = MAX (NY, MY) 10 CONTINUE CALL POWER2 (NX, II) IF (II.LT.NX) NX = 2 * II CALL POWER2 (NY, II) IF (II.LT.NY) NY = 2 * II C Grid. file. C Increase size if possible for C interpolation IF (NX.LE.8192) NX = 2 * NX IF (NY.LE.8192) NY = 2 * NY C try two estimates of size: NP(1) = 2 * NY + 2 * NCVSIZ NP(2) = NX / 2 + 1 + 2 * NCVSIZ CALL MAPSIZ (2, NP, SIZE2) C NP(1) = MIN (NX, NY) + 2 NP(2) = MAX (NX, NY) + 2 C Add extra rows for bandwidth C synthesis. NP(1) = NP(1) + 2 * NCVSIZ C Determine file size CALL MAPSIZ (2, NP, SIZE) SIZE = MAX (SIZE, SIZE2) C Make GRID (SCRGRD) file. CALL SCREAT (SIZE, BUFFER, IRET) SCRGRD = NSCR IF (IRET.NE.0) THEN IF (IRET.EQ.1) THEN MSGTXT = 'TOO LITTLE DISK SPACE FOR SCRATCH FILE' ELSE WRITE (MSGTXT,1011) IRET END IF GO TO 990 END IF C WORK file (SCRWRK) 40 CALL SCREAT (SIZE, BUFFER, IRET) SCRWRK = NSCR IF (IRET.NE.0) THEN IF (IRET.EQ.1) THEN MSGTXT = 'TOO LITTLE DISK SPACE FOR SCRATCH FILE' ELSE WRITE (MSGTXT,1011) IRET END IF GO TO 990 END IF C Fill LUNS array in /CFILES/ 50 LUNS(1) = 16 LUNS(2) = 17 LUNS(3) = 18 LUNS(4) = 19 LUNS(5) = 20 IRET = 0 GO TO 999 C Error. 990 CALL MSGWRT (8) C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('GRDSET: ERROR',I5,' READING CATBLK FIELD',I3) 1011 FORMAT ('GRDSET: ERROR',I5,' CREATING SCRATCH FILE') END
Subroutine Form_B_and_Tmatrices(R,T,nT,B,nB,nD,AJI,nQc,Iout) ! Inputs ! R = r-directional root domain value ! Nel = Element Number ! NelType = Element Type: ! 0 = Plane Stress ! 1 = Plane Strain ! 2 = Axi-symmtric (NOT DONE YET) ! nT = 6 (nDof) ! nB = 12 (nDof*2) ! nD = 6*nQc (nDof*nQc) = 6n ! ! Outputs ! T(nT,nD) = Dis & Primed Transformation Matrix ! at a point R ! B(nB,nD) = Dis & Primed Transformation Matrix ! at a point R ! Implicit Real(kind=8) (a-h,o-z) ! Real(kind=8) T ,B Dimension T(nT,nD),B(nB,nD) ! T(6,6n),B(12,6n) ! ! ndegR = Bezier degree in r-dir = 4 ! ndegS = Bezier degree in s-dir = 4 ! Real(kind=8) dum,xMult Real(kind=8) Br Dimension Br(nQc) Real(kind=8) H1D Dimension H1D(nQc) DATA zero/0.D0/,one/1.0D0/,two/2.0D0/,three/3.0D0/ ! --------------------------------------------- Check compatibility if (nB.NE.nT*2) Then stop 'nB.NE.nT*2 in Form__B_and_Tmatrices' endif !-------------------------------------------------- Displacement/Bernstein call Bernstein(Br,nQc,r,iOut) !-------------------------------------------------- Ist Derivative call Bernstein_IstDerivative(H1D,nQc,r,iOut) !-------------------------------------------------- T & B T = zero B = zero ! do 70 i = 1,nT ! For 3D Curve Beam with axial & shear strains k = (i-1)*nQc do 60 j = 1,nQc ! do 60 m = 1,nT T(i,j+k) = Br(j) !u,w,v,tt,tm,tb B(i,j+k) = Br(j) !u,w,v,tt,tm,tb B(nT+i,j+k) = H1D(j)*AJI !-primed 60 continue 70 continue ! iPrt = 0 if(iPrt == 1) Then write(Iout,1010) nT,nD,R, & (i,(T(i,j),j = 1,nD),i=1,nT) write(Iout,1020) nB,nD,R, & (i,(B(i,j),j = 1,nD),i=1,nB) endif return ! 1000 format(A,I5,A) 1010 format("T(",I2,",",I2,")"/ & "R = ",f20.16/(I5/,5(6(f10.7,1X)/))) 1020 format("B(",I2,",",I2,")"/ & "R = ",f20.16/(I5/,5(6(f10.7,1X)/))) end
c LGRFDC.FOR c This whole file makes up DC library for Lahey graphics LGRFDC.LIB c It has names for subroutines that do not clash with Hgraph c Colours: c 0=black; 1=dark blue; 2=green; 3=light blue; 4=red; 5=purple c 6=brown; 7=white; 8=pale white (grey); 9=dark blue -bright; 10=green -bright c 11=light blue -bright; 12=red -bright; 13=purple -bright; 14=yellow -bright c 15=white -bright c subroutine INITLGRF c Initialise common blocks for Lahey Graphics common/lscal/sx,sy,xoff,yoff !for Lahey graphics common/lgrf/xpos,ypos,ipen !ditto sx=1.0 sy=1.0 xoff=0. yoff=0. xpos=0. ypos=0. ipen=15 !bright white RETURN end subroutine SCALEL(xmin,xmax,ymin,ymax) common/lscal/sx,sy,xoff,yoff c Equivalent of SCALE for Lahey screen graphics. But app no separate x,y c scaling in Lahey, so calc factors sx,sy to use in calls below (or, quicker, c use them to scale data BEFORE it is displayed so scaling multiplication does c not need to be done at time display is drawn) ADC data must be converted c to REAL before display anyway. c This calculates scale factors such that the input xmin,... correspond c to the whole plottable area of the screen. To leave margins around the c graphics, simplest way is probably to call SCALEL with xmin,.. etc larger c than actually occurs in data so margin left in which nothing is plotted. c Nominal scale x=0.0-11.0, y=0.0-8.5 but to show on Dell 425 must use c range x=0.01-10.99, y=0.01-8.5. sx=(10.99-0.01)/(xmax-xmin) xoff=0.01-xmin*sx sy=(8.5-0.01)/(ymax-ymin) yoff=0.01-ymin*sy RETURN end subroutine MOVEL1(x,y) c Lahey graphics move (unscaled) call PLOTL(x,y,3) return end subroutine DRAWL1(x,y) c Lahey graphics draw (unscaled) call PLOTL(x,y,2) return end subroutine MOVEL(x,y) c Lahey graphics move (scaled) with real arg common/lscal/sx,sy,xoff,yoff x1=x*sx + xoff y1=y*sy + yoff call PLOTL(x1,y1,3) return end subroutine DRAWL(x,y) c Lahey graphics draw (scaled) with real arg common/lscal/sx,sy,xoff,yoff x1=x*sx + xoff y1=y*sy + yoff call PLOTL(x1,y1,2) return end subroutine DRAWLc(x,y,icol) common/lscal/sx,sy,xoff,yoff c Lahey graphics draw (scaled): version that calls PLOTL with ic=-icol, so c tests each pixel before drawing it, and does NOT alter any pixel unless it has c the colour specified by ICOL in the call. E.g. to draw a line that doesn't c cover any point that is already lit up call DRAWL2(x,y,0). And to delete c a line already drawn by this routine with colour=14 say, set ipen=0 c and call DRAWL2(x,y,14) so only yellow points are deleted x1=x*sx + xoff y1=y*sy + yoff call PLOTL(x1,y1,-icol) return end subroutine IMOVEL(ix,iy) c Lahey graphics move (scaled) with integer*2 arg integer*2 ix,iy common/lscal/sx,sy,xoff,yoff x=float(ix)*sx + xoff y=float(iy)*sy + yoff call PLOTL(x,y,3) return end subroutine IDRAWL(ix,iy) c Lahey graphics draw (scaled) with integer*2 arg integer*2 ix,iy common/lscal/sx,sy,xoff,yoff x=float(ix)*sx + xoff y=float(iy)*sy + yoff call PLOTL(x,y,2) return end subroutine PLOTL(x,y,ic) c Homemade routine to avoid use of call PLOT in Lahey graphics (which c clashes with Hgraph), by using SETPIX. Follows Lahey convention; ic=2 for c DRAW, ic=3 for MOVE. c Modified 01/02/91 06:05pm so that if called with IC=0 to -15 then tests each c pixel before drawing it, and does NOT alter any pixel unless it has c the colour specified by ICOL in the call. E.g. to draw a line that doesn't c cover any point that is already lit up call DRAWL2(x,y,0). And to delete c a line already drawn by this routine with colour=14 say, set ipen=0 c and call DRAWL2(x,y,14) so only yellow points are deleted c======needs fixing for lines that are not vertical or horizontal because c======pixels are in slightly different positions according to whether c======line drawn up or down eg fix so always drawn in same direction eg c=======always draw from lower left (even if this is x,y rather than xpos,ypos) c c Draws from last position to x,y, which then becomes the c current position, so need to keep xpos,ypos in common. Also this c routine has no way to know colour (icol in SETPIX presumably has c precedence over NEWPEN call, so keep ICOL in common too. c In X direction have 640/11=58.18181818 pixels/screen unit c i.e. 0.0171875 screen units/pixel c In Y direction have 480/8.5=56.470588235 pixels/s.u., ie 0.01770833 s.u./pixel c To light every pixel along a line need to move in steps not bigger than this. logical coltest common/lgrf/xpos,ypos,ipen !ditto c if(ic.eq.3) then xpos=x ypos=y RETURN endif c dx=0.0171875 dy=0.01770833 y0=y !define values so x,y,xpos,ypos not altered x0=x ypos0=ypos xpos0=xpos c coltest=.false. if(ic.le.0) then coltest=.true. icol=-ic endif c if(x.eq.xpos) then !vertical if(y.lt.ypos) dy=-dy y1=ypos n=ifixr(abs((y-ypos)/dy)) do 2 i=1,n if(coltest) then call GETPIX(xpos,y1,icol1) call RPIXEL(X,Y,COLOR) if(icol1.gt.15) icol1=0 !sometimes get crazy values!?? if(icol1.ne.icol) goto 21 endif call WPIXEL(X,Y,COLOR) -draw a pixel at coord. x,y in color call SETPIX(xpos,y1,ipen) 21 y1=y1+dy 2 continue ypos=y goto 9 endif if(y.eq.ypos) then !horizontal if(x.lt.xpos) dx=-dx x1=xpos n=ifixr(abs((x-xpos)/dx)) do 3 i=1,n if(coltest) then call GETPIX(x1,ypos,icol1) call RPIXEL(X,Y,COLOR) if(icol1.gt.15) icol1=0 !sometimes get crazy values!?? if(icol1.ne.icol) goto 31 endif call SETPIX(x1,ypos,ipen) call WPIXEL(X,Y,COLOR) -draw a pixel at coord. x,y in color 31 x1=x1+dx 3 continue xpos=x goto 9 endif c Should set dx to smaller value if line is near vertical c Draw line from xpos0,ypos0 to x0,y0 b=(y0-ypos0)/(x0-xpos0) x1=xpos0 y1=ypos0 if(abs(b).lt.1.) then !shallow so increment x n=ifixr(abs((x0-xpos0)/dx)) if(x0.lt.xpos0) dx=-dx !so x1 goes from xpos to x do 4 i=1,n if(coltest) then call GETPIX(x1,y1,icol1) call RPIXEL(X,Y,COLOR) if(icol1.gt.15) icol1=0 !sometimes get crazy values!?? if(icol1.ne.icol) goto 41 endif call SETPIX(x1,y1,ipen) call WPIXEL(X,Y,COLOR) -draw a pixel at coord. x,y in color 41 x1=x1+dx y1=ypos0+b*(x1-xpos0) 4 continue xpos=x !reset current pos ypos=y else !steep so increment y n=ifixr(abs((y0-ypos0)/dy)) if(y0.lt.ypos0) dy=-dy !so y1 goes from ypos to y do 5 i=1,n if(coltest) then call GETPIX(x1,y1,icol1) call RPIXEL(X,Y,COLOR) if(icol1.gt.15) icol1=0 !sometimes get crazy values!?? if(icol1.ne.icol) goto 51 endif call SETPIX(x1,y1,ipen) 51 y1=y1+dy x1=xpos0+(y1-ypos0)/b 5 continue xpos=x !reset current pos ypos=y endif c 9 if(coltest) then call GETPIX(xpos0,ypos0,icol1) call RPIXEL(X,Y,COLOR) if(icol1.gt.15) icol1=0 !sometimes get crazy values!?? if(icol1.ne.icol) RETURN endif call SETPIX(xpos,ypos,ipen) !last point call WPIXEL(X,Y,COLOR) -draw a pixel at coord. x,y in color RETURN end
C MODULE URVCMP C----------------------------------------------------------------------- C SUBROUTINE URVCMP (LPNTRO,IPNTRO,NPNTRO,LPNTRN,IPNTRN, * LDATAO,IDATAO,NDATAO,LDATAN,IDATAN, * ISTAT) C C ROUTINE TO COMPRESS PREPROCESSOR DATA BASE LESS THAN 24-HR TIME C INTERVAL DATA C CHARACTER*4 DTYPE CHARACTER*50 STRING C INTEGER*2 IPNTRO(LPNTRO),IPNTRN(LPNTRN) INTEGER*2 IDATAO(LDATAO),IDATAN(LDATAN) C INCLUDE 'uiox' INCLUDE 'udebug' INCLUDE 'ucommon/uordrx' INCLUDE 'pdbcommon/pdunts' INCLUDE 'pdbcommon/pdsifc' INCLUDE 'pdbcommon/pddtdr' INCLUDE 'pdbcommon/pdbdta' INCLUDE 'urcommon/urunts' INCLUDE 'urcommon/ursifc' INCLUDE 'urcommon/urpddt' C C ================================= RCS keyword statements ========== CHARACTER*68 RCSKW1,RCSKW2 DATA RCSKW1,RCSKW2 / ' .$Source: /fs/hseb/ob72/rfc/ofs/src/reorder/RCS/urvcmp.f,v $ . $', ' .$Id: urvcmp.f,v 1.2 2003/11/10 18:37:39 scv Exp $ . $' / C =================================================================== C C IF (IPDTR.GT.0) THEN WRITE (IOGDB,*) 'ENTER URVCMP' CALL SULINE (IOGDB,1) ENDIF C IF (IPDDB.GT.0) THEN WRITE (IOGDB,*) * ' LPNTRO=',LPNTRO, * ' LPNTRN=',LPNTRN, * ' LDATAO=',LDATAO, * ' LDATAN=',LDATAN, * ' ' CALL SULINE (IOGDB,1) ENDIF C ISTAT=0 C NDTYPE=0 MDTYPE=2 C C SET NUMBER OF INTEGER*2 WORDS PER RECORD LRCPD2=LRCPDD*2 C IF (IPDDB.GT.0) THEN WRITE (IOGDB,*) * ' LRCPD2=',LRCPD2, * ' MISSNG=',MISSNG, * ' IAMORD=',IAMORD, * ' ' CALL SULINE (IOGDB,1) ENDIF C IF (IAMORD.EQ.0.OR.IAMORD.EQ.1) THEN ELSE WRITE (LP,60) DTYPE CALL SUERRS (LP,2,-1) ISTAT=1 GO TO 50 ENDIF C NPNTRO=0 NDATAO=0 C 10 NDTYPE=NDTYPE+1 IF (NDTYPE.GT.MDTYPE) GO TO 50 C IF (NDTYPE.EQ.1) DTYPE='PPVR' IF (NDTYPE.EQ.2) DTYPE='TAVR' C WRITE (LP,70) DTYPE CALL SULINE (LP,2) C IF (IPDDB.GT.0) THEN WRITE (IOGDB,*) * ' NMDTYP=',NMDTYP, * ' IPTTYP=',IPTTYP, * ' ' CALL SULINE (IOGDB,1) ENDIF C C FIND DATA TYPE IN DIRECTORY IXTYPE=IPDCKD(DTYPE) IF (IXTYPE.EQ.0) THEN WRITE (LP,110) DTYPE CALL SUERRS (LP,2,-1) ISTAT=1 GO TO 40 ENDIF IXTM24=IPDCKD('TM24') IF (IXTM24.EQ.0) THEN WRITE (LP,110) 'TM24' CALL SUERRS (LP,2,-1) ISTAT=1 GO TO 40 ENDIF C IF (IPDDB.GT.0) THEN WRITE (IOGDB,*) * ' DTYPE=',DTYPE, * ' IXTYPE=',IXTYPE, * ' ' CALL SULINE (IOGDB,1) IF (IAMORD.EQ.0) THEN WRITE (IOGDB,*) * ' KPDSIF=',KPDSIF, * ' INFREC=',INFREC, * ' LSTSIF=',LSTSIF, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' IDDTDR(4,IXTYPE)=',IDDTDR(4,IXTYPE), * ' IDDTDR(5,IXTYPE)=',IDDTDR(5,IXTYPE), * ' IDDTDR(7,IXTYPE)=',IDDTDR(7,IXTYPE), * ' IDDTDR(14,IXTYPE)=',IDDTDR(14,IXTYPE), * ' IDDTDR(15,IXTYPE)=',IDDTDR(15,IXTYPE), * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' IDDTDR(17,IXTYPE)=',IDDTDR(17,IXTYPE), * ' IDDTDR(18,IXTYPE)=',IDDTDR(18,IXTYPE), * ' IDDTDR(19,IXTYPE)=',IDDTDR(19,IXTYPE), * ' IDDTDR(21,IXTYPE)*LRCPD2=',IDDTDR(21,IXTYPE)*LRCPD2, * ' ' CALL SULINE (IOGDB,1) ENDIF IF (IAMORD.EQ.1) THEN WRITE (IOGDB,*) * ' KURSIF=',KURSIF, * ' ISIFRC=',ISIFRC, * ' LTSIFR=',LTSIFR, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' JDDTDR(4,IXTYPE)=',JDDTDR(4,IXTYPE), * ' JDDTDR(5,IXTYPE)=',JDDTDR(5,IXTYPE), * ' JDDTDR(7,IXTYPE)=',JDDTDR(7,IXTYPE), * ' JDDTDR(14,IXTYPE)=',JDDTDR(14,IXTYPE), * ' JDDTDR(15,IXTYPE)=',JDDTDR(15,IXTYPE), * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' JDDTDR(17,IXTYPE)=',JDDTDR(17,IXTYPE), * ' JDDTDR(18,IXTYPE)=',JDDTDR(18,IXTYPE), * ' JDDTDR(19,IXTYPE)=',JDDTDR(19,IXTYPE), * ' JDDTDR(21,IXTYPE)*LRCPD2=',JDDTDR(21,IXTYPE)*LRCPD2, * ' ' ENDIF CALL SULINE (IOGDB,1) ENDIF C IUNITX=0 IUNITD=0 IRSIFC=0 LRSIFC=0 NPTR=0 NPTM24=0 NDAYS=0 IPTREC=0 IDTREC=0 NUMSTA=0 NPUSDO=0 NDUSDO=0 NDMAX=0 C IF (IAMORD.EQ.0) THEN IUNITX=KPDSIF IUNITD=KPDDDF(IDDTDR(4,IXTYPE)) IRSIFC=INFREC+1 LRSIFC=LSTSIF NPTR=IDDTDR(5,IXTYPE) NPTM24=IDDTDR(5,IXTM24) NDAYS=IDDTDR(7,IXTYPE) IPTREC=IDDTDR(14,IXTYPE) IDTREC=IDDTDR(15,IXTYPE) NUMSTA=IDDTDR(17,IXTYPE) NPUSDO=IDDTDR(18,IXTYPE) NDUSDO=IDDTDR(19,IXTYPE) NDMAX=IDDTDR(21,IXTYPE)*LRCPD2 ENDIF IF (IAMORD.EQ.1) THEN IUNITX=KURSIF IUNITD=KURDDF(JDDTDR(4,IXTYPE)) IRSIFC=ISIFRC+1 LRSIFC=LTSIFR NPTR=JDDTDR(5,IXTYPE) NPTM24=JDDTDR(5,IXTM24) NDAYS=JDDTDR(7,IXTYPE) IPTREC=JDDTDR(14,IXTYPE) IDTREC=JDDTDR(15,IXTYPE) NUMSTA=JDDTDR(17,IXTYPE) NPUSDO=JDDTDR(18,IXTYPE) NDUSDO=JDDTDR(19,IXTYPE) NDMAX=JDDTDR(21,IXTYPE)*LRCPD2 ENDIF C IF (NPUSDO.GT.NPNTRO) NPNTRO=NPUSDO IF (NDUSDO.GT.NDATAO) NDATAO=NDUSDO C IF (IPDDB.GT.0) THEN WRITE (IOGDB,*) * ' IUNITX=',IUNITX, * ' IUNITD=',IUNITD, * ' IRSIFC=',IRSIFC, * ' LRSIFC=',LRSIFC, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' NPTR=',NPTR, * ' NPTM24=',NPTM24, * ' NDAYS=',NDAYS, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' IPTREC=',IPTREC, * ' IDTREC=',IDTREC, * ' NUMSTA=',NUMSTA, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' NPUSDO=',NPUSDO, * ' NDUSDO=',NDUSDO, * ' NDMAX=',NDMAX, * ' ' CALL SULINE (IOGDB,1) ENDIF C C CHECK NUMBER OF STATIONS DEFINED IF (NUMSTA.EQ.0) THEN WRITE (LP,120) DTYPE CALL SULINE (LP,2) GO TO 40 ENDIF C C READ POINTER RECORDS IREC=IPTREC NREC=IUNRCD(NPUSDO,LRCPD2) CALL RVLRCD (IUNITD,IREC,NREC,IPNTRO,LRCPDD,IERR) IF (IERR.NE.0) THEN WRITE (LP,130) 'READING',IREC,IUNITD CALL SUERRS (LP,2,-1) ISTAT=1 GO TO 50 ENDIF C C DUMP POINTER RECORD IF (IPDDB.GT.0) THEN STRING='IPNTRO' CALL URVCM2 (STRING,IPNTRO,NPUSDO) ENDIF C C PROCESS EACH DAY NDUSDN=0 INEWDA=1 NRECPD=IUNRCD(NDMAX,LRCPD2) IRECDT=IDTREC DO 30 IDAYS=1,NDAYS C READ DATA RECORDS NREC=IUNRCD(NDUSDO,LRCPD2) IREC=IRECDT CALL RVLRCD (IUNITD,IREC,NREC,IDATAO,LRCPDD,IERR) IF (IERR.NE.0) THEN WRITE (LP,130) 'READING',IREC,IUNITD CALL SUERRS (LP,2,-1) ISTAT=1 GO TO 50 ENDIF C PRINT ARRAY IF (IPDDB.GT.0) THEN STRING='IDATAO' CALL URVCM2 (STRING,IDATAO,NDUSDO) ENDIF C COMPRESS DATA RECORDS IUPSIF=1 CALL URVCM3 (DTYPE,NPTR,NPTM24,LRCPD2,INEWDA, * IRSIFC,LRSIFC,IUNITX,IUPSIF, * LPNTRO,IPNTRO,NPUSDO,LPNTRN,IPNTRN, * LDATAO,IDATAO,NDUSDO,NDMAX,LDATAN,IDATAN,NDUSDN, * IERR) IF (IERR.NE.0) THEN IF (IPPDB.GT.0) THEN WRITE (IOGDB,*) * ' URVCM3 CALLED : ', * ' IERR=',IERR, * ' ' CALL SULINE (LP,1) ENDIF ISTAT=1 GO TO 40 ENDIF C CHECK IF NEW DAY IF (INEWDA.EQ.0) GO TO 20 IF (IPDDB.GT.0) THEN STRING='IPNTRN' CALL URVCM2 (STRING,IPNTRN,NPUSDO) ENDIF C WRITE POINTER ARRAY NPREC=IUNRCD(NPUSDO,LRCPD2) IREC=IPTREC CALL WVLRCD (IUNITD,IREC,NPREC,IPNTRN,LRCPDD,IERR) IF (IERR.NE.0) THEN WRITE (LP,130) 'WRITING',IREC,IUNITD CALL SUERRS (LP,2,-1) ISTAT=1 GO TO 50 ENDIF 20 IF (IPDDB.GT.0) THEN STRING='IDATAN' CALL URVCM2 (STRING,IDATAN,NDUSDN) ENDIF C WRITE DATA ARRAY NDREC=IUNRCD(NDUSDN,LRCPD2) IREC=IRECDT CALL WVLRCD (IUNITD,IREC,NDREC,IDATAN,LRCPDD,IERR) INEWDA=0 IRECDT=IRECDT+NRECPD 30 CONTINUE C C CHECK IF NUMBER OF DATA WORDS USED CHANGED NDUSDO=0 IF (IAMORD.EQ.0) NDUSDO=IDDTDR(19,IXTYPE) IF (IAMORD.EQ.1) NDUSDO=JDDTDR(19,IXTYPE) IF (NDUSDN.EQ.NDUSDO) THEN WRITE (LP,90) DTYPE,NDUSDO CALL SULINE (LP,2) GO TO 40 ELSE C UPDATE DIRECTORY FOR CHANGE IN NUMBER OF DATA VALUES WRITE (LP,100) DTYPE,NDUSDO,NDUSDN CALL SULINE (LP,2) IF (IAMORD.EQ.0) IDDTDR(19,IXTYPE)=NDUSDN IF (IAMORD.EQ.1) JDDTDR(19,IXTYPE)=NDUSDN GO TO 40 ENDIF C 40 GO TO 10 C 50 IF (IPDTR.GT.0) THEN WRITE (IOGDB,*) 'EXIT URVCMP' CALL SULINE (IOGDB,1) ENDIF C RETURN C C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C 60 FORMAT ('0*** ERROR - INVALID VALUE OF IAMORD : ',I3) 70 FORMAT ('0*** NOTE - BEGIN TO COMPRESS << ',A4, * ' DATA >> RECORDS.') 90 FORMAT ('0*** NOTE - DATA WORDS USED FOR TYPE ',A4, * ' (',I5,') DID NOT CHANGE.') 100 FORMAT ('0*** NOTE - DATA WORDS USED FOR TYPE ',A4, * ' WILL BE CHANGED FROM ',I5,' TO ',I5,'.') 110 FORMAT ('0*** ERROR - TYPE ',A4,' NOT FOUND IN THE ', * 'PREPROCESSOR DATA BASE DIRECTORY.') 120 FORMAT ('0*** NOTE - NO STATIONS WITH DATA TYPE ',A, * ' ARE DEFINED.') 130 FORMAT ('0*** ERROR - ',A,' RECORD ',I6,' FROM UNIT ',I2,'.') C END C C----------------------------------------------------------------------- C SUBROUTINE URVCM2 (STRING,ARRAY,LARRAY) C C ROUTINE TO PRINT I*2 ARRAY C CHARACTER*(*) STRING C INTEGER*2 ARRAY(LARRAY) C INCLUDE 'uiox' C C IF (LARRAY.EQ.0) GO TO 20 C WRITE (LP,30) STRING(1:LENSTR(STRING)) CALL SULINE (LP,2) C IPOS1=1 NPER=20 C 10 IPOS2=IPOS1+NPER-1 IF (IPOS2.GT.LARRAY) IPOS2=LARRAY C WRITE (LP,40) IPOS1,(ARRAY(I),I=IPOS1,IPOS2) CALL SULINE (LP,1) C IPOS1=IPOS1+NPER IF (IPOS1.GT.LARRAY) GO TO 20 GO TO 10 C 20 RETURN C C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C 30 FORMAT ('0',A,':') 40 FORMAT (' ',I5,': ',20(I5,1X)) C END C C----------------------------------------------------------------------- C SUBROUTINE URVCM3 (DTYPE,NPTR,NPTM24,LRCPD2,INEWDA, * IRSIFC,LRSIFC,IUNITX,IUPSIF, * LPNTRO,IPNTRO,NPUSDO,LPNTRN,IPNTRN, * LDATAO,IDATAO,NDUSDO,NDMAX,LDATAN,IDATAN,NDUSDN, * ISTAT) C C THIS ROUTINE COMPRESSES THE PREPROCESSOR DATA BASE DATA ARRAYS C CONTAINING VARIABLE TIME INTERVAL DATA FOR DAILY DATA TYPES. C C THE LAST POINTER POSITION FOR EACH STATION IS CHANGED IF C THE DATA ARE MOVED. POINTERS ARE NOT MOVED. C C ARGUMENT LIST: C C ARGUMENT I/O TYPE DIM DESCRIPTION C -------- ----- ----- ----- --------------------- C DTYPE I A4 1 DATA TYPE C NPTR I I*4 1 NUMBER OF POINTERS C NPTM24 I I*4 1 NUMBER OF POINTERS FOR DATA C TYPE TM24 C LRCPD2 I I*4 1 NUMBER OF I*2 WORDS IN RECORD C INEWDA I I*4 1 NEW DAY INDICATOR C 1=INITIAL DAY C 0=SUBSEQUENT DAY C IRSIFC I I*4 1 INITIAL SIF RECORD NUMBER C LRSIFC I I*4 1 LAST SIF RECORD NUMBER C IUNITX I I*4 1 INDEX UNIT NUMBER C IUPSIF I I*4 1 UPDATE INDICATOR C 1=ONLY UPDATE SIF IF C DATA POINTER CHANGES C -1=ALWAYS UPDATE SIF C LPNTRO I I*4 1 I*2 LENGTH OF IPNTRO C IPNTRO I I*2 LPNTR OLD POINTER ARRAY C NPUSDO I I*4 1 NUMBER OF POINTER WORDS USED C IN IPNTRO C LPNTRN I I*4 1 I*2 LENGTH OF IPNTRN C IPNTRN O I*2 LPNTR NEW POINTER ARRAY C LDATAO I I*4 1 I*2 LENGTH OF IDATAO C IDATAO I I*2 LDATA OLD DATA ARRAY C NDUSDO I I*4 1 NUMBER OF DATA WORDS USED C IN IDATAO C NDMAX I I*4 1 MAXIMUM NUMBER OF DATA WORDS C LDATAN I I*4 1 I*2 LENGTH OF IDATAN C IDATAN O I*2 LDATA NEW DATA ARRAY C NDUSDN O I*4 1 I*2 WORDS USED IN IDATAN C ISTAT O I*4 1 STATUS CODE C 0=NORMAL RETURN C 1=INVALID TYPE C 2=POINTER OR DATA C ARRAY TOO SMALL C 3=POINTER OR DATA C ARRAY EMPTY C 4=ALL STATIONS DELETED C 5=ERROR ACCESSING FILE C 6=NUMBER OF POINTERS IS ZERO C 7=NUMBER OF WORDS IN SIF IS C ZERO C C CHARACTER*(*) DTYPE CHARACTER*4 STYPE CHARACTER*8 STAID C INTEGER*2 IPNTRO(LPNTRO),IPNTRN(LPNTRN) INTEGER*2 IDATAO(LDATAO),IDATAN(LDATAN) INTEGER*2 I2VAL,ISIBUF(32) C INCLUDE 'uiox' INCLUDE 'udebug' INCLUDE 'pdbcommon/pdbdta' C EQUIVALENCE (ICVAR1,INOTE) C C IF (IPDTR.GT.0) THEN WRITE (IOGDB,*) 'ENTER URVCM3' CALL SULINE (IOGDB,1) ENDIF C IF (IPDDB.GT.0) THEN WRITE (IOGDB,*) * ' DTYPE=',DTYPE, * ' NPTR=',NPTR, * ' NPTM24=',NPTM24, * ' LRCPD2=',LRCPD2, * ' INEWDA=',INEWDA, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' IRSIFC=',IRSIFC, * ' LRSIFC=',LRSIFC, * ' IUNITX=',IUNITX, * ' IUPSIF=',IUPSIF, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' LPNTRO=',LPNTRO, * ' NPUSDO=',NPUSDO, * ' LPNTRN=',LPNTRN, * ' ' CALL SULINE (IOGDB,1) WRITE (IOGDB,*) * ' LDATAO=',LDATAO, * ' NDUSDO=',NDUSDO, * ' LDATAN=',LDATAN, * ' NDUSDN=',NDUSDN, * ' NDMAX=',NDMAX, * ' ' CALL SULINE (IOGDB,1) ENDIF C ISTAT=0 C INDERR=0 C IF (DTYPE.EQ.'PPVR'.OR.DTYPE.EQ.'TAVR') THEN ELSE WRITE (LP,160) DTYPE CALL SUERRS (LP,2,-1) ISTAT=1 INDERR=1 ENDIF IF (NPUSDO.GT.LPNTRO) THEN WRITE (LP,170) 'POINTERS',NPUSDO,LPNTRO CALL SUERRS (LP,2,-1) ISTAT=2 INDERR=1 ENDIF IF (NDUSDO.GT.LDATAO) THEN WRITE (LP,170) 'DATA',NDUSDO,LDATAO CALL SUERRS (LP,2,-1) ISTAT=2 INDERR=1 ENDIF IF (NPUSDO.EQ.0) THEN WRITE (LP,180) 'POINTER' CALL SUERRS (LP,2,-1) ISTAT=3 INDERR=1 ENDIF IF (NDUSDO.EQ.0) THEN WRITE (LP,180) 'DATA' CALL SUERRS (LP,2,-1) ISTAT=3 INDERR=1 ENDIF IF (NPTR.EQ.0) THEN WRITE (LP,190) 'POINTERS' CALL SUERRS (LP,2,-1) ISTAT=6 INDERR=1 ENDIF C IF (INDERR.GT.0) GO TO 150 C C CHECK IF FIRST DAY IF (INEWDA.EQ.1) THEN C CHANGE POINTER ARRAY IPOS=1 DO 30 IPUSD=1,NPUSDO IF (IPUSD.EQ.(IPUSD/NPTR)*NPTR) GO TO 20 10 IPNTRN(IPUSD)=IPNTRO(IPUSD) GO TO 30 20 IF (IPNTRO(IPUSD).EQ.0) GO TO 10 IPNTRN(IPUSD)=IPOS ITMINT=IPNTRO(IPUSD-1) IF (ITMINT.EQ.0) GO TO 30 NVAL=24/ITMINT IPOS=IPOS+NVAL 30 CONTINUE ENDIF C C COMPRESS DATA ARRAY NDUSDN=0 NUPSIF=0 NDELET=0 IPRBLN=0 DO 140 IPTR=NPTR,NPUSDO,NPTR NPOSN1=IPNTRN(IPTR) NPOSO1=IPNTRO(IPTR) IF (NPOSN1.EQ.0) GO TO 140 ITMINT=IPNTRO(IPTR-1) NVAL=24/ITMINT NPOSN2=NPOSN1+NVAL-1 IPNTR1=IPNTRO(IPTR-NPTR+1) IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' IPNTR1=',IPNTR1, * ' MISSNG=',MISSNG, * ' ' CALL SULINE (IOGDB,1) ENDIF C CHECK IF DELETED SLOT IF (IPNTR1.EQ.0) GO TO 60 C MOVE DATA DO 50 N=NPOSN1,NPOSN2 J=N-NPOSN1 IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' NPOSN1=',NPOSN1, * ' NPOSN2=',NPOSN2, * ' J=',J, * ' NDMAX=',NDMAX, * ' ' CALL SULINE (IOGDB,1) ENDIF IF (NPOSO1+J.GT.NDMAX) GO TO 40 IDATAN(N)=IDATAO(NPOSO1+J) GO TO 50 40 IDATAN(N)=MISSNG 50 CONTINUE 60 NDUSDN=NDUSDN+NVAL C CHECK IF NEW DAY IF (INEWDA.NE.1) GO TO 140 C CHECK IF DELETED SLOT IF (IPNTR1.EQ.0) THEN NDELET=NDELET+1 INOTE=0 IF (INOTE.EQ.1) THEN IF (IPRBLN.EQ.0) THEN WRITE (LP,*) CALL SULINE (LP,1) IPRBLN=1 ENDIF WRITE (LP,200) IPTR,DTYPE CALL SULINE (LP,1) ENDIF ENDIF C CHECK IF SIF TO ALWAYS BE UPDATED IF (IUPSIF.EQ.-1) GO TO 80 IF (NPOSO1.EQ.NPOSN1) GO TO 140 C CHECK IF DELETED SLOT IF (IPNTR1.EQ.0) THEN IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' IPNTR1=',IPNTR1, * ' NPOSN1=',NPOSN1, * ' NPOSN2=',NPOSN2, * ' ' CALL SULINE (IOGDB,1) ENDIF DO 70 N=NPOSN1,NPOSN2 IDATAN(N)=MISSNG 70 CONTINUE GO TO 140 ENDIF 80 JSIBUF=0 I2VAL=0 IF (DTYPE.EQ.'PPVR') THEN JSIBUF=7 I2VAL=IPNTR1 ENDIF IF (DTYPE.EQ.'TAVR') THEN JSIBUF=9 I2VAL=(IPNTR1/NPTM24)*2+1 ENDIF IREC=IRSIFC IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' IREC=',IREC, * ' JSIBUF=',JSIBUF, * ' I2VAL=',I2VAL, * ' ' CALL SULINE (IOGDB,1) ENDIF C READ SIF RECORD 90 CALL UREADT (IUNITX,IREC,ISIBUF,IERR) IF (IERR.NE.0) THEN WRITE (LP,270) 'READING',IREC,IUNITX CALL SUERRS (LP,2,-1) ISTAT=5 GO TO 150 ENDIF IF (ISIBUF(JSIBUF).NE.I2VAL) GO TO 100 C GET STATION IDENTIFIER STAID=' ' CALL SUBSTR (ISIBUF(2),1,LEN(STAID),STAID,-1) C CHECK IF DELETED IF (STAID.NE.'DELETED') GO TO 110 100 NWORDS=ISIBUF(1) IF (NWORDS.EQ.0) THEN WRITE (LP,210) 'WORDS IN',IUNITX,IREC CALL SUERRS (LP,2,-1) ISTAT=7 GO TO 150 ENDIF NREC=IUNRCD(NWORDS,LRCPD2) IF (NREC.EQ.0) THEN WRITE (LP,210) 'RECORDS FOR',IUNITX,IREC CALL SUERRS (LP,2,-1) ISTAT=7 GO TO 150 ENDIF IREC=IREC+NREC IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' NWORDS=',NWORDS, * ' NREC=',NREC, * ' IREC=',IREC, * ' LRSIFC=',LRSIFC, * ' ' CALL SULINE (IOGDB,1) ENDIF C CHECK IF PROCESSING LAST SIF RECORD IF (IREC.LE.LRSIFC) GO TO 90 C STATION NOT FOUND IPOS=IPTR-NPTR+1 WRITE (LP,220) DTYPE,IPOS CALL SUWRNS (LP,2,-1) GO TO 140 C UPDATE DATA ARRAY POSITION IN SIF 110 NTYPES=ISIBUF(10) JSIBUF=11 DO 120 ITYPES=1,NTYPES STYPE=' ' CALL SUBSTR (ISIBUF(JSIBUF),1,LEN(STYPE),STYPE,-1) IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' NTYPES=',NTYPES, * ' ITYPES=',ITYPES, * ' JSIBUF=',JSIBUF, * ' STYPE=',STYPE, * ' ITMINT=',ITMINT, * ' ' CALL SULINE (IOGDB,1) ENDIF IF (DTYPE.EQ.'PPVR'.AND. * (STYPE.EQ.'PP01'.AND.ITMINT.EQ.1.OR. * STYPE.EQ.'PP03'.AND.ITMINT.EQ.3.OR. * STYPE.EQ.'PP06'.AND.ITMINT.EQ.6)) GO TO 130 IF (DTYPE.EQ.'TAVR'.AND. * (STYPE.EQ.'TA01'.AND.ITMINT.EQ.1.OR. * STYPE.EQ.'TA03'.AND.ITMINT.EQ.3.OR. * STYPE.EQ.'TA06'.AND.ITMINT.EQ.6)) GO TO 130 JSIBUF=JSIBUF+3 120 CONTINUE C TYPE NOT FOUND IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' IPNTR1=',IPNTR1, * ' ' CALL SULINE (IOGDB,1) ENDIF WRITE (LP,230) STYPE,STAID CALL SUWRNS (LP,2,-1) GO TO 140 C UPDATE DATA ARRAY POSITION 130 ISIBUF(JSIBUF+2)=NPOSN1 C REWRITE SIF RECORD CALL UWRITT (IUNITX,IREC,ISIBUF,IERR) IF (IERR.NE.0) THEN ISTAT=5 WRITE (LP,270) 'WRITING',IREC,IUNITX CALL SUERRS (LP,2,-1) GO TO 150 ENDIF IF (IPDDB.GT.1) THEN WRITE (IOGDB,*) * ' DTYPE=',DTYPE, * ' STAID=',STAID, * ' NPOSN1=',NPOSN1, * ' IREC=',IREC, * ' ' CALL SULINE (IOGDB,1) ENDIF INOTE=0 IF (INOTE.EQ.1) THEN IF (IPRBLN.EQ.0) THEN WRITE (LP,*) CALL SULINE (LP,1) IPRBLN=1 ENDIF WRITE (LP,240) DTYPE,STAID,NPOSN1,IREC CALL SULINE (LP,1) ENDIF NUPSIF=NUPSIF+1 140 CONTINUE C IF (NDELET.GT.0) THEN WRITE (LP,250) NDELET,DTYPE CALL SULINE (LP,2) ENDIF C IF (NUPSIF.GT.0) THEN WRITE (LP,260) NUPSIF CALL SULINE (LP,2) ENDIF C IF (NDUSDN.GT.0) GO TO 150 C C NO STATIONS LEFT - ALL WERE DELETED ISTAT=4 WRITE (LP,280) CALL SULINE (LP,2) C 150 IF (IPDTR.GT.0) THEN WRITE (IOGDB,*) 'EXIT URVCM3' CALL SULINE (IOGDB,1) ENDIF C RETURN C C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C 160 FORMAT ('0*** ERROR - IN URVCM3 - ',A,' IS AN INVALID DATA TYPE.') 170 FORMAT ('0*** ERROR - IN URVCM3 - NUMBER OF ',A, * ' WORDS USED (',I5, * ') EXCEEDS MAXIMUM (',I5,').') 180 FORMAT ('0*** ERROR - IN URVCM3 - NUMBER OF ',A, * ' WORDS USED (',I5, * ') IS ZERO.') 190 FORMAT ('0*** ERROR - IN URVCM3 - NUMBER OF ',A, * ' IS ZERO.') 200 FORMAT (' *** NOTE - POSITION ',I6,' OF THE ',A4, * ' POINTER ARRAY IS MARKED DELETED.') 210 FORMAT ('0*** ERROR - IN URVCM3 - NUMBER OF ',A, * ' SIF RECORD AT RECORD ',I6,' OF UNIT ',I2, * 'IS ZERO.') 220 FORMAT ('0*** WARNING - IN URVCM3 - STATION IN ',A, * ' POINTER ARRAY POSITION ', * I6,' NOT FOUND IN THE SIF.') 230 FORMAT ('0*** WARNING - DATA TYPE ',A, * ' NOT FOUND IN THE SIF FOR STATION ',A,'.') 240 FORMAT (' *** NOTE - ',A4,' DATA ARRAY POSITION FOR STATION ',A, * ' SET TO ',I6,' IN SIF RECORD ',I6,'.') 250 FORMAT ('0*** NOTE - ',I4,' DELETED SLOTS FOUND IN ',A4, * ' POINTER ARRAY.') 260 FORMAT ('0*** NOTE - ',I4,' SIF RECORDS UPDATED TO ', * 'CHANGE DATA ARRAY POSITION.') 270 FORMAT ('0*** ERROR - ',A,' RECORD ',I6,' FROM UNIT ',I2,'.') 280 FORMAT ('0*** NOTE - ALL STATIONS IN SIF ARE DELETED.') C END
* ******************************************** * * * * * gen_PBE96_c_full_unrestricted * * * * * ******************************************** * * This function returns the PBE96 correlation * energy density, ce, and its derivatives with respect * to nup, ndn, |grad nup|, |grad ndn|, and |grad n|. * * Entry - dn1_in,dn2_in : spin densites nup and ndn * agr1_in,agr2_in,agr3_in: |grad nup|, |grad ndn|, and |grad n| * * Exit - ce : PBE96 correlation energy density * - fn1,fn2 : d(n*ce)/dnup, d(n*ce)/dndn * - fdn1,fdn2,fdn3: d(n*ce)/d|grad nup|, d(n*ce)/d|grad ndn| * d(n*ce)/d|grad n| subroutine gen_PBE96_c_full_unrestricted(dn1_in,dn2_in, > agr1_in,agr2_in,agr3_in, > ce,fn1,fn2,fdn1,fdn2,fdn3) implicit none * ***** input ***** real*8 dn1_in,dn2_in,agr1_in,agr2_in,agr3_in * ***** output ***** real*8 ce,fn1,fn2,fdn1,fdn2,fdn3 * **** Density cutoff parameter **** real*8 DNS_CUT,ETA,ETA2,alpha_zeta,alpha_zeta2 parameter (DNS_CUT = 1.0d-20) parameter (ETA=1.0d-20) parameter (ETA2=1.0d-14) parameter (alpha_zeta=(1.0d0-ETA2)) parameter (alpha_zeta2=(1.0d0-ETA2)) c ***** PBE96 GGA exchange constants ****** real*8 MU,KAPPA parameter (MU = 0.2195149727645171d0) parameter (KAPPA = 0.8040000000000000d0) c ****** PBE96 GGA correlation constants ****** real*8 GAMMA,BETA,BOG parameter (GAMMA = 0.031090690869655d0) parameter (BETA = 0.066724550603149d0) !parameter (BETA = 0.066725d0) parameter (BOG = BETA/GAMMA) c ****** Perdew-Wang92 LDA correlation coefficients ******* real*8 GAM,iGAM,FZZ,iFZZ parameter (GAM = 0.519842099789746329d0) parameter (iGAM = 1.0d0/GAM) parameter (FZZ = (8.0d0/(9.0d0*GAM)) ) parameter (iFZZ = 0.125d0*9.0d0*GAM) real*8 A_1,A1_1,B1_1,B2_1,B3_1,B4_1 parameter (A_1 = 0.0310907d0) !parameter (A_1 = 0.031091d0) parameter (A1_1 = 0.2137000d0) parameter (B1_1 = 7.5957000d0) parameter (B2_1 = 3.5876000d0) parameter (B3_1 = 1.6382000d0) parameter (B4_1 = 0.4929400d0) real*8 A_2,A1_2,B1_2,B2_2,B3_2,B4_2 parameter (A_2 = 0.01554535d0) !parameter (A_2 = 0.015545d0) parameter (A1_2 = 0.20548000d0) parameter (B1_2 = 14.11890000d0) parameter (B2_2 = 6.19770000d0) parameter (B3_2 = 3.36620000d0) parameter (B4_2 = 0.62517000d0) real*8 A_3,A1_3,B1_3,B2_3,B3_3,B4_3 parameter (A_3 = 0.0168869d0) !parameter (A_3 = 0.016887d0) parameter (A1_3 = 0.1112500d0) parameter (B1_3 = 10.3570000d0) parameter (B2_3 = 3.6231000d0) parameter (B3_3 = 0.8802600d0) parameter (B4_3 = 0.4967100d0) c **** other constants **** real*8 onethird,fourthird,fivethird,onesixthm real*8 twothird,sevensixthm real*8 onethirdm parameter (onethird=1.0d0/3.0d0) parameter (onethirdm=-1.0d0/3.0d0) parameter (twothird=2.0d0/3.0d0) parameter (fourthird=4.0d0/3.0d0) parameter (fivethird=5.0d0/3.0d0) parameter (onesixthm=-1.0d0/6.0d0) parameter (sevensixthm=-7.0d0/6.0d0) c **** local variables **** real*8 n,agr real*8 nup,agrup real*8 ndn,agrdn real*8 kf,ks,s,P0,n_onethird,pi,rs_scale real*8 rs ! Wigner radius real*8 rss ! rss = sqrt(rs) real*8 rs_n ! rs_n = n*drs/dn real*8 t,t2,t4,t6 real*8 t_nup ! t_nup = n*dt/dnup real*8 t_ndn ! t_ndn = n*dt/dndn real*8 t_agr ! t_agr = n*dt/dagr real*8 zet,twoksg real*8 zet_nup ! zet_nup = n*dzet/dnup real*8 zet_ndn ! zet_nup = n*dzet/dnup real*8 zetp_1_3,zetm_1_3 real*8 zetpm_1_3,zetmm_1_3 real*8 phi,phi3,phi4 real*8 phi_zet real*8 A,A2 real*8 A_phi,A_ec_lda real*8 Q0,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8 real*8 PON,FZ,z4 real*8 tau real*8 F real*8 Fs ! dF/ds real*8 Hpbe real*8 Hpbe_t ! dHpbe/dt real*8 Hpbe_phi ! dHpbe/dphi real*8 Hpbe_ec_lda ! dHpbe/d(ec_lda) real*8 Hpbe_nup,Hpbe_ndn ! n*dHpbe/dnup, n*dHpbe/dndn real*8 Ipbe real*8 Ipbe_t,Ipbe_A ! dIpbe/dt, dIpbe/dA real*8 exup,exdn,ex,ex_lda real*8 ecu,ecp,eca,ec,ec_lda real*8 ecu_rs,ecp_rs,eca_rs real*8 ec_lda_rs,ec_lda_zet ! d(ec_lda)/drs, d(ec_lda)/dzet real*8 ec_lda_nup,ec_lda_ndn ! n*d(ec_lda)/dnup, n*d(ec_lda)/dndn real*8 fnxup,fdnxup ! d(n*ex)/dnup, d(n*ex)/dndn real*8 fnxdn,fdnxdn ! d(n*ex)/d|grad nup|, d(n*ex)/d|grad ndn| real*8 fncup,fncdn ! d(n*ec)/dnup, d(n*ec)/dndn real*8 fdnx_const pi = 4.0d0*datan(1.0d0) rs_scale = (0.75d0/pi)**onethird fdnx_const = -3.0d0/(8.0d0*pi) ccc!$OMP DO nup = dn1_in+ETA agrup = agr1_in ndn = dn2_in+ETA agrdn = agr2_in c ******************************************************************* c ***** calculate polarized correlation energies and potentials ***** c ******************************************************************* n = nup + ndn agr = agr3_in zet = (nup-ndn)/n c if (zet.gt.0.0d0) zet = zet - ETA2 c if (zet.lt.0.0d0) zet = zet + ETA2 c if (dabs(dn_in(i,2)).gt.DNS_CUT) zet_nup = 2*ndn/n**2 c if (dabs(dn_in(i,1)).gt.DNS_CUT) zet_ndn = -2*nup/n**2 c if (dabs(dn_in(i,2)).gt.DNS_CUT) zet_nup = 2*ndn/n c zet_nup = 2*ndn/n c zet_ndn = -2*nup/n zet_nup = -(zet - 1.0d0) zet_ndn = -(zet + 1.0d0) zetpm_1_3 = (1.0d0+zet*alpha_zeta)**onethirdm zetmm_1_3 = (1.0d0-zet*alpha_zeta)**onethirdm zetp_1_3 = (1.0d0+zet*alpha_zeta)*zetpm_1_3**2 zetm_1_3 = (1.0d0-zet*alpha_zeta)*zetmm_1_3**2 phi = 0.5d0*( zetp_1_3**2 + zetm_1_3**2) phi_zet = alpha_zeta*( zetpm_1_3 - zetmm_1_3)/3.0d0 F =( (1.0d0+zet*alpha_zeta)*zetp_1_3 > + (1.0d0-zet*alpha_zeta)*zetm_1_3 > - 2.0d0)*iGAM FZ = (zetp_1_3 - zetm_1_3)*(alpha_zeta*fourthird*iGAM) * **** calculate Wigner radius **** rs = rs_scale/(n**onethird) rss = dsqrt(rs) * **** calculate n*drs/dn **** c rs_n = onethirdm*rs/n rs_n = onethirdm*rs c **** calculate t **** kf = (3.0d0*pi*pi*n)**onethird ks = dsqrt(4.0d0*kf/pi) twoksg = 2.0d0*ks*phi t = agr/(twoksg*n) * *** calculate n*dt/dnup, n*dt/dndn, n*dt/d|grad n| **** t_nup = sevensixthm*t - (phi_zet)*(zet_nup)*t/phi t_ndn = sevensixthm*t - (phi_zet)*(zet_ndn)*t/phi t_agr = 1.0d0/(twoksg) c ************************************************** c ***** compute LSDA correlation energy density **** c ************************************************** call LSDT(A_1,A1_1,B1_1,B2_1,B3_1,B4_1,rss,ecu,ecu_rs) call LSDT(A_2,A1_2,B1_2,B2_2,B3_2,B4_2,rss,ecp,ecp_rs) call LSDT(A_3,A1_3,B1_3,B2_3,B3_3,B4_3,rss,eca,eca_rs) z4 = zet**4 ec_lda = ecu*(1.0d0-F*z4) > + ecp*F*z4 > - eca*F*(1.0d0-z4)/FZZ ec_lda_rs = ecu_rs*(1.0d0-F*z4) > + ecp_rs*F*z4 > - eca_rs*F*(1.0d0-z4)/FZZ ec_lda_zet = (4.0d0*(zet**3)*F + FZ*z4)*(ecp-ecu+eca*iFZZ) > - FZ*eca*iFZZ c ******************************************** c **** calculate PBE96 correlation energy **** c ******************************************** phi3 = phi**3 phi4 = phi3*phi PON = -ec_lda/(phi3*GAMMA) tau = DEXP(PON) A = BOG/(tau-1.0d0+ETA) A2 = A*A t2 = t*t t4 = t2*t2 t6 = t4*t2 Q4 = 1.0d0 + A*t2 Q5 = 1.0d0 + 2.0d0*A*t2 Q6 = 2.0d0 + A*t2 Q7 = 1.0d0+A*t2+A2*t4 Q8 = Q7*Q7 Ipbe = 1.0d0 + BOG*t2*Q4/Q7 Hpbe = GAMMA*phi3*DLOG(Ipbe) Ipbe_t = BOG*(2.0d0*t)*Q5/Q8 Ipbe_A = -BOG*(A*t6) *Q6/Q8 A_ec_lda = tau/(BETA*phi3)*A2 A_phi = -3.0d0*ec_lda*tau/(BETA*phi4)*A2 Hpbe_ec_lda = (GAMMA*phi3/Ipbe)*Ipbe_A*A_ec_lda Hpbe_phi = 3.0d0*Hpbe/phi > + (GAMMA*phi3/Ipbe)*Ipbe_A*A_phi Hpbe_t = (GAMMA*phi3/Ipbe)*Ipbe_t ec_lda_nup = ec_lda_zet > - zet * ec_lda_zet > + rs_n * ec_lda_rs ec_lda_ndn = -ec_lda_zet > - zet * ec_lda_zet > + rs_n * ec_lda_rs Hpbe_nup = ec_lda_nup * Hpbe_ec_lda > + phi_zet*zet_nup * Hpbe_phi > + t_nup * Hpbe_t Hpbe_ndn = ec_lda_ndn * Hpbe_ec_lda > + phi_zet*zet_ndn * Hpbe_phi > + t_ndn * Hpbe_t ec = ec_lda + Hpbe fncup = ec + (ec_lda_nup + Hpbe_nup) fncdn = ec + (ec_lda_ndn + Hpbe_ndn) ce = ec fn1 = fncup fn2 = fncdn fdn1 = 0.0d0 fdn2 = 0.0d0 fdn3 = t_agr*Hpbe_t ccc!$OMP END DO return end * ************************************ * * * * * gen_PBE96_c_unrestricted * * * * * ************************************ * * This function returns the PBE96 correlation * energy density, ce, and its derivatives with respect * to n_sigma, |grad n_sigma|. * * Entry - dn_in : spin densites n_sigma * agr_in: |grad n_sigma| * * Exit - ce : PBE96 correlation energy density * - fn : d(n_sigma*ce)/dn_sigma, * - fdn: d(n_sigma*ce)/d|grad n_sigma| subroutine gen_PBE96_c_unrestricted(dn_in,agr_in, > ce,fn,fdn) implicit none * ***** input ***** real*8 dn_in,agr_in * ***** output ***** real*8 ce,fn,fdn * **** Density cutoff parameter **** real*8 DNS_CUT,ETA,ETA2,alpha_zeta,alpha_zeta2 parameter (DNS_CUT = 1.0d-20) parameter (ETA=1.0d-20) parameter (ETA2=1.0d-14) parameter (alpha_zeta=(1.0d0-ETA2)) parameter (alpha_zeta2=(1.0d0-ETA2)) c ***** PBE96 GGA exchange constants ****** real*8 MU,KAPPA parameter (MU = 0.2195149727645171d0) parameter (KAPPA = 0.8040000000000000d0) c ****** PBE96 GGA correlation constants ****** real*8 GAMMA,BETA,BOG parameter (GAMMA = 0.031090690869655d0) parameter (BETA = 0.066724550603149d0) !parameter (BETA = 0.066725d0) parameter (BOG = BETA/GAMMA) c ****** Perdew-Wang92 LDA correlation coefficients ******* real*8 GAM,iGAM,FZZ,iFZZ parameter (GAM = 0.519842099789746329d0) parameter (iGAM = 1.0d0/GAM) parameter (FZZ = (8.0d0/(9.0d0*GAM)) ) parameter (iFZZ = 0.125d0*9.0d0*GAM) real*8 A_1,A1_1,B1_1,B2_1,B3_1,B4_1 parameter (A_1 = 0.0310907d0) !parameter (A_1 = 0.031091d0) parameter (A1_1 = 0.2137000d0) parameter (B1_1 = 7.5957000d0) parameter (B2_1 = 3.5876000d0) parameter (B3_1 = 1.6382000d0) parameter (B4_1 = 0.4929400d0) real*8 A_2,A1_2,B1_2,B2_2,B3_2,B4_2 parameter (A_2 = 0.01554535d0) !parameter (A_2 = 0.015545d0) parameter (A1_2 = 0.20548000d0) parameter (B1_2 = 14.11890000d0) parameter (B2_2 = 6.19770000d0) parameter (B3_2 = 3.36620000d0) parameter (B4_2 = 0.62517000d0) real*8 A_3,A1_3,B1_3,B2_3,B3_3,B4_3 parameter (A_3 = 0.0168869d0) !parameter (A_3 = 0.016887d0) parameter (A1_3 = 0.1112500d0) parameter (B1_3 = 10.3570000d0) parameter (B2_3 = 3.6231000d0) parameter (B3_3 = 0.8802600d0) parameter (B4_3 = 0.4967100d0) c **** other constants **** real*8 onethird,fourthird,fivethird,onesixthm real*8 twothird,sevensixthm real*8 onethirdm parameter (onethird=1.0d0/3.0d0) parameter (onethirdm=-1.0d0/3.0d0) parameter (twothird=2.0d0/3.0d0) parameter (fourthird=4.0d0/3.0d0) parameter (fivethird=5.0d0/3.0d0) parameter (onesixthm=-1.0d0/6.0d0) parameter (sevensixthm=-7.0d0/6.0d0) c **** local variables **** real*8 n,agr real*8 nup,agrup real*8 kf,ks,s,P0,n_onethird,pi,rs_scale real*8 rs ! Wigner radius real*8 rss ! rss = sqrt(rs) real*8 rs_n ! rs_n = n*drs/dn real*8 t,t2,t4,t6 real*8 t_nup ! t_nup = n*dt/dnup real*8 t_agr ! t_agr = n*dt/dagr real*8 zet,twoksg real*8 zet_nup ! zet_nup = n*dzet/dnup real*8 zetp_1_3,zetm_1_3 real*8 zetpm_1_3,zetmm_1_3 real*8 phi,phi3,phi4 real*8 phi_zet real*8 A,A2 real*8 A_phi,A_ec_lda real*8 Q0,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8 real*8 PON,FZ,z4 real*8 tau real*8 F real*8 Fs ! dF/ds real*8 Hpbe real*8 Hpbe_t ! dHpbe/dt real*8 Hpbe_phi ! dHpbe/dphi real*8 Hpbe_ec_lda ! dHpbe/d(ec_lda) real*8 Hpbe_nup ! n*dHpbe/dnup, n*dHpbe/dndn real*8 Ipbe real*8 Ipbe_t,Ipbe_A ! dIpbe/dt, dIpbe/dA real*8 exup,exdn,ex,ex_lda real*8 ecu,ecp,eca,ec,ec_lda real*8 ecu_rs,ecp_rs,eca_rs real*8 ec_lda_rs,ec_lda_zet ! d(ec_lda)/drs, d(ec_lda)/dzet real*8 ec_lda_nup ! n*d(ec_lda)/dnup, n*d(ec_lda)/dndn real*8 fncup ! d(n*ec)/dnup, d(n*ec)/dndn real*8 fdnx_const pi = 4.0d0*datan(1.0d0) rs_scale = (0.75d0/pi)**onethird fdnx_const = -3.0d0/(8.0d0*pi) ccc!$OMP DO nup = dn_in+ETA c ******************************************************************* c ***** calculate polarized correlation energies and potentials ***** c ******************************************************************* n = nup agr = agr_in c zet = nup/n zet = 1.0d0 c if (zet.gt.0.0d0) zet = zet - ETA2 c if (zet.lt.0.0d0) zet = zet + ETA2 c if (dabs(dn_in(i,2)).gt.DNS_CUT) zet_nup = 2*ndn/n**2 c if (dabs(dn_in(i,1)).gt.DNS_CUT) zet_ndn = -2*nup/n**2 c if (dabs(dn_in(i,2)).gt.DNS_CUT) zet_nup = 2*ndn/n c zet_nup = 2*ndn/n c zet_ndn = -2*nup/n c zet_nup = -(zet - 1.0d0) zet_nup = 0.0d0 zetpm_1_3 = (1.0d0+zet*alpha_zeta)**onethirdm zetmm_1_3 = (1.0d0-zet*alpha_zeta)**onethirdm zetp_1_3 = (1.0d0+zet*alpha_zeta)*zetpm_1_3**2 zetm_1_3 = (1.0d0-zet*alpha_zeta)*zetmm_1_3**2 phi = 0.5d0*( zetp_1_3**2 + zetm_1_3**2) phi_zet = alpha_zeta*( zetpm_1_3 - zetmm_1_3)/3.0d0 F =( (1.0d0+zet*alpha_zeta)*zetp_1_3 > + (1.0d0-zet*alpha_zeta)*zetm_1_3 > - 2.0d0)*iGAM FZ = (zetp_1_3 - zetm_1_3)*(alpha_zeta*fourthird*iGAM) * **** calculate Wigner radius **** rs = rs_scale/(n**onethird) rss = dsqrt(rs) * **** calculate n*drs/dn **** c rs_n = onethirdm*rs/n rs_n = onethirdm*rs c **** calculate t **** kf = (3.0d0*pi*pi*n)**onethird ks = dsqrt(4.0d0*kf/pi) twoksg = 2.0d0*ks*phi t = agr/(twoksg*n) * *** calculate n*dt/dnup, n*dt/dndn, n*dt/d|grad n| **** t_nup = sevensixthm*t - (phi_zet)*(zet_nup)*t/phi t_agr = 1.0d0/(twoksg) c ************************************************** c ***** compute LSDA correlation energy density **** c ************************************************** call LSDT(A_1,A1_1,B1_1,B2_1,B3_1,B4_1,rss,ecu,ecu_rs) call LSDT(A_2,A1_2,B1_2,B2_2,B3_2,B4_2,rss,ecp,ecp_rs) call LSDT(A_3,A1_3,B1_3,B2_3,B3_3,B4_3,rss,eca,eca_rs) z4 = zet**4 ec_lda = ecu*(1.0d0-F*z4) > + ecp*F*z4 > - eca*F*(1.0d0-z4)/FZZ ec_lda_rs = ecu_rs*(1.0d0-F*z4) > + ecp_rs*F*z4 > - eca_rs*F*(1.0d0-z4)/FZZ ec_lda_zet = (4.0d0*(zet**3)*F + FZ*z4)*(ecp-ecu+eca*iFZZ) > - FZ*eca*iFZZ c ******************************************** c **** calculate PBE96 correlation energy **** c ******************************************** phi3 = phi**3 phi4 = phi3*phi PON = -ec_lda/(phi3*GAMMA) tau = DEXP(PON) A = BOG/(tau-1.0d0+ETA) A2 = A*A t2 = t*t t4 = t2*t2 t6 = t4*t2 Q4 = 1.0d0 + A*t2 Q5 = 1.0d0 + 2.0d0*A*t2 Q6 = 2.0d0 + A*t2 Q7 = 1.0d0+A*t2+A2*t4 Q8 = Q7*Q7 Ipbe = 1.0d0 + BOG*t2*Q4/Q7 Hpbe = GAMMA*phi3*DLOG(Ipbe) Ipbe_t = BOG*(2.0d0*t)*Q5/Q8 Ipbe_A = -BOG*(A*t6) *Q6/Q8 A_ec_lda = tau/(BETA*phi3)*A2 A_phi = -3.0d0*ec_lda*tau/(BETA*phi4)*A2 Hpbe_ec_lda = (GAMMA*phi3/Ipbe)*Ipbe_A*A_ec_lda Hpbe_phi = 3.0d0*Hpbe/phi > + (GAMMA*phi3/Ipbe)*Ipbe_A*A_phi Hpbe_t = (GAMMA*phi3/Ipbe)*Ipbe_t ec_lda_nup = ec_lda_zet > - zet * ec_lda_zet > + rs_n * ec_lda_rs Hpbe_nup = ec_lda_nup * Hpbe_ec_lda > + phi_zet*zet_nup * Hpbe_phi > + t_nup * Hpbe_t ec = ec_lda + Hpbe fncup = ec + (ec_lda_nup + Hpbe_nup) ce = ec fn = fncup fdn = t_agr*Hpbe_t CCC!$OMP END DO return end * ************************************ * * * * * gen_PBE96_c_restricted * * * * * ************************************ * * This routine calculates the PBE96 correlation * potential(cp) and energy density(ce). * * * Entry - rho_in: density (nup+ndn) * agr_in: |grad rho_in| * * Exit - ce : PBE96 correlation energy density * fn : d(n*ce)/dn * fdn: d(n*ce/d|grad n| * subroutine gen_PBE96_c_restricted(rho_in,agr_in, > ce,fn,fdn) implicit none * ****** input ****** real*8 rho_in,agr_in * ****** output ****** real*8 ce,fn,fdn * **** Density cutoff parameter **** real*8 DNS_CUT,ETA parameter (DNS_CUT = 1.0d-20) parameter (ETA = 1.0d-20) c ***** PBE96 GGA exchange constants ****** real*8 MU,KAPPA parameter (MU = 0.2195149727645171d0) parameter (KAPPA = 0.8040000000000000d0) c ****** PBE96 GGA correlation constants ****** real*8 GAMMA,BETA,BOG parameter (GAMMA = 0.031090690869655d0) parameter (BETA = 0.066724550603149d0) parameter (BOG = BETA/GAMMA) c ****** Perdew-Wang92 LDA correlation coefficients ******* real*8 A_1,A1_1,B1_1,B2_1,B3_1,B4_1 parameter (A_1 = 0.0310907d0) parameter (A1_1 = 0.2137000d0) parameter (B1_1 = 7.5957000d0) parameter (B2_1 = 3.5876000d0) parameter (B3_1 = 1.6382000d0) parameter (B4_1 = 0.4929400d0) real*8 A_2,A1_2,B1_2,B2_2,B3_2,B4_2 parameter (A_2 = 0.01554535d0) parameter (A1_2 = 0.20548000d0) parameter (B1_2 = 14.11890000d0) parameter (B2_2 = 6.19770000d0) parameter (B3_2 = 3.36620000d0) parameter (B4_2 = 0.62517000d0) real*8 A_3,A1_3,B1_3,B2_3,B3_3,B4_3 parameter (A_3 = 0.0168869d0) parameter (A1_3 = 0.1112500d0) parameter (B1_3 = 10.3570000d0) parameter (B2_3 = 3.6231000d0) parameter (B3_3 = 0.8802600d0) parameter (B4_3 = 0.4967100d0) c **** other constants **** real*8 onethird,fourthird,sevensixths parameter (onethird=1.0d0/3.0d0) parameter (fourthird=4.0d0/3.0d0) parameter (sevensixths=7.0d0/6.0d0) c **** local variables **** integer i real*8 n,agr real*8 kf,ks,s,P0,n_onethird,pi,rs_scale real*8 fdnx_const real*8 rs,rss,t,t2,t4,t6 real*8 Q0,Q1,Q2,Q3,Q4,Q5,Q8,Q9,B real*8 Ht real*8 B_ec,Hrs,H_B real*8 F,Fs real*8 ex_lda,ec_lda real*8 ec_lda_rs real*8 ex,ec,H real*8 fnx,fdnx,fnc,fdnc pi = 4.0d0*datan(1.0d0) rs_scale = (0.75d0/pi)**onethird fdnx_const = -3.0d0/(8.0d0*pi) ccc!$OMP DO n = rho_in+ETA agr = agr_in * ********************************************************************* c ***** calculate unpolarized correlation energies and potentials ***** * ********************************************************************* c **** calculate rs and t **** rs = rs_scale/(n**onethird) rss = dsqrt(rs) kf = (3.0d0*pi*pi*n)**onethird ks = dsqrt(4.0d0*kf/pi) t = agr/(2.0d0*ks*n) c **** unpolarized LDA correlation energy **** c **** ec_p = correlation energy **** c **** ec_p_rs = dec_p/drs **** c **** uc_p = dec_p/dn **** call LSDT(A_1,A1_1,B1_1,B2_1,B3_1,B4_1,rss,ec_lda,ec_lda_rs) c **** PBE96 correlation energy corrections **** t2 = t*t t4 = t2*t2 B = -ec_lda/GAMMA B = BOG/(exp(B)-1.0d0+ETA) Q4 = 1.0d0 + B*t2 Q5 = 1.0d0 + B*t2 + B*B*t4 H = GAMMA*dlog(1.0d0 + BOG*Q4*t2/Q5) c **** PBE96 correlation fdn and fdnc derivatives **** t6 = t4*t2 B_ec = (B/BETA)*(BOG+B) Q8 = Q5*Q5+BOG*Q4*Q5*t2 Q9 = 1.0d0+2*B*t2 H_B = -BETA*B*t6*(2.0d0+B*t2)/Q8 Hrs = H_B*B_ec*ec_lda_rs Ht = 2.0d0*BETA*Q9/Q8*t ec = ec_lda + H fnc = ec - (onethird*rs*ec_lda_rs) > - (onethird*rs*Hrs) > - (sevensixths*t*Ht) fdnc = 0.5d0* Ht/ks ce = ec fn = fnc fdn = fdnc c write(*,*) "pbe96:",i,ec,fnc,fdnc ccc!$OMP END DO return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
PROGRAM TSRFAC 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 C OPEN GKS, OPEN WORKSTATION OF TYPE 1, ACTIVATE WORKSTATION C CALL GOPKS (IERRF, ISZDM) CALL GOPWK (IWKID, LUNIT, IWTYPE) CALL GACWK (IWKID) C C INVOKE DEMO DRIVER C CALL SRFAC(IERR) C C DEACTIVATE AND CLOSE WORKSTATION, CLOSE GKS. C CALL GDAWK (IWKID) CALL GCLWK (IWKID) CALL GCLKS C STOP END C SUBROUTINE SRFAC (IERROR) C C PURPOSE To provide a simple demonstration of SRFACE. C C USAGE CALL SRFAC (IERROR) C C ARGUMENTS C C ON OUTPUT IERROR C An integer variable C = 0, if the test was successful, C = 1, the test was not successful. C C I/O If the test is successful, the message C C SRFACE TEST EXECUTED--SEE PLOT TO CERTIFY C C is printed on unit 6. In addition, 2 C frames are produced on the machine graphics C device. In order to determine if the test C was successful, it is necessary to examine C the plots. C C PRECISION Single C C LANGUAGE FORTRAN 77 C C REQUIRED ROUTINES SRFACE C C REQUIRED GKS LEVEL 0A C C ALGORITHM The function C C Z(X,Y) = .25*(X + Y + 1./((X-.1)**2+Y**2+.09) C -1./((X+.1)**2+Y**2+.09) C C for X = -1. to +1. in increments of .1, and C Y = -1.2 to +1.2 in increments of .1, C is computed. Then, entries EZSRFC and SURFACE C are called to generate surface plots of Z. C C HISTORY SURFACE was first written in April 1979 and C converted to FORTRAN 77 and GKS in March 1984. C C XX contains the X-direction coordinate values for Z(X,Y); YY contains C the Y-direction coordinate values for Z(X,Y); Z contains the function C values; S contains values for the line of sight for entry SRFACE; C WORK is a work array; ANGH contains the angle in degrees in the X-Y C plane to the line of sight; and ANGV contains the angle in degrees C from the X-Y plane to the line of sight. C REAL XX(21) ,YY(25) ,Z(21,25) ,S(6) , 1 WORK(1096) C DATA S(1), S(2), S(3), S(4), S(5), S(6)/ 1 -8.0, -6.0, 3.0, 0.0, 0.0, 0.0/ C DATA ANGH/45./, ANGV/15./ C C Specify coordinates for plot titles. The values CX and CY C define the center of the title string in a 0. to 1. range. C DATA CX/.5/, CY/.9/ C C Initialize the error parameter. C IERROR = 0 C C Fill the XX and YY coordinate arrays as well as the Z function array. C DO 20 I=1,21 X = .1*REAL(I-11) XX(I) = X DO 10 J=1,25 Y = .1*REAL(J-13) YY(J) = Y Z(I,J) = (X+Y+1./((X-.1)**2+Y**2+.09)- 1 1./((X+.1)**2+Y**2+.09))*.25 10 CONTINUE 20 CONTINUE C C Select the normalization transformation 0. C CALL GSELNT(0) C C C Frame 1 -- The EZSRFC entry. C C Add the plot title using GKS calls. C C Set the text alignment to center the string in horizontal and vertical C CALL GSTXAL(2,3) C C Set the character height. C CALL GSCHH(.016) C C Write the text. C CALL GTX(CX,CY,'DEMONSTRATION PLOT FOR EZSRFC ENTRY OF SRFACE') C CALL EZSRFC (Z,21,25,ANGH,ANGV,WORK) C C C Frame 2 -- The SRFACE entry. C C Add the plot title. C C Set the text alignment to center the string in horizontal and vertical C CALL GSTXAL(2,3) C C Set the character height. C CALL GSCHH(.016) C C Write the text. C CALL GTX(CX,CY,'DEMONSTRATION PLOT FOR SRFACE ENTRY OF SRFACE') C CALL SRFACE (XX,YY,Z,WORK,21,21,25,S,0.) C C This routine automatically generates frame advances. C WRITE (6,1001) C RETURN C 1001 FORMAT (' SRFACE TEST EXECUTED--SEE PLOT TO CERTIFY') C END
c Fortran Library for Skeleton 2-1/2D Electromagnetic Vector PIC Code c written by Viktor K. Decyk, UCLA c----------------------------------------------------------------------- subroutine DISTR2HT(part,vtx,vty,vtz,vdx,vdy,vdz,npx,npy,idimp,npe 1,nx,ny,ipbc) c for 2-1/2d code, this subroutine calculates initial particle c co-ordinates and velocities with uniform density and maxwellian c velocity with drift c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = velocity vx of particle n c part(n,4) = velocity vy of particle n c part(n,5) = velocity vz of particle n c vtx/vty/vtz = thermal velocity of electrons in x/y/z direction c vdx/vdy/vdz = drift velocity of beam electrons in x/y/z direction c npx/npy = initial number of particles distributed in x/y direction c idimp = size of phase space = 5 c npe = first dimension of particle array c nx/ny = system length in x/y direction c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) c ranorm = gaussian random number with zero mean and unit variance implicit none integer npx, npy, idimp, npe, nx, ny, ipbc real vtx, vty, vtz, vdx, vdy, vdz real part dimension part(npe,idimp) c local data integer j, k, k1, npxy real edgelx, edgely, at1, at2, at3, sum1, sum2, sum3 double precision dsum1, dsum2, dsum3 double precision ranorm npxy = npx*npy c set boundary values edgelx = 0.0 edgely = 0.0 at1 = real(nx)/real(npx) at2 = real(ny)/real(npy) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 at1 = real(nx-2)/real(npx) at2 = real(ny-2)/real(npy) else if (ipbc.eq.3) then edgelx = 1.0 at1 = real(nx-2)/real(npx) endif c uniform density profile do 20 k = 1, npy k1 = npx*(k - 1) at3 = edgely + at2*(real(k) - 0.5) do 10 j = 1, npx part(j+k1,1) = edgelx + at1*(real(j) - 0.5) part(j+k1,2) = at3 10 continue 20 continue c maxwellian velocity distribution do 30 j = 1, npxy part(j,3) = vtx*ranorm() part(j,4) = vty*ranorm() part(j,5) = vtz*ranorm() 30 continue c add correct drift dsum1 = 0.0d0 dsum2 = 0.0d0 dsum3 = 0.0d0 do 40 j = 1, npxy dsum1 = dsum1 + part(j,3) dsum2 = dsum2 + part(j,4) dsum3 = dsum3 + part(j,5) 40 continue sum1 = dsum1 sum2 = dsum2 sum3 = dsum3 at1 = 1./real(npxy) sum1 = at1*sum1 - vdx sum2 = at1*sum2 - vdy sum3 = at1*sum3 - vdz do 50 j = 1, npxy part(j,3) = part(j,3) - sum1 part(j,4) = part(j,4) - sum2 part(j,5) = part(j,5) - sum3 50 continue return end c----------------------------------------------------------------------- subroutine GBPUSH23LT(part,fxy,bxy,qbm,dt,dtc,ek,idimp,nop,npe,nx, 1ny,nxv,nyv,ipbc) c for 2-1/2d code, this subroutine updates particle co-ordinates and c velocities using leap-frog scheme in time and first-order linear c interpolation in space, with magnetic field. Using the Boris Mover. c scalar version using guard cells c 119 flops/particle, 1 divide, 29 loads, 5 stores c input: all, output: part, ek c velocity equations used are: c vx(t+dt/2) = rot(1)*(vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(2)*(vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(3)*(vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fx(x(t),y(t))*dt) c vy(t+dt/2) = rot(4)*(vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(5)*(vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(6)*(vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fy(x(t),y(t))*dt) c vz(t+dt/2) = rot(7)*(vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(8)*(vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(9)*(vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fz(x(t),y(t))*dt) c where q/m is charge/mass, and the rotation matrix is given by: c rot(1) = (1 - (om*dt/2)**2 + 2*(omx*dt/2)**2)/(1 + (om*dt/2)**2) c rot(2) = 2*(omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(3) = 2*(-omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(4) = 2*(-omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(5) = (1 - (om*dt/2)**2 + 2*(omy*dt/2)**2)/(1 + (om*dt/2)**2) c rot(6) = 2*(omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(7) = 2*(omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(8) = 2*(-omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(9) = (1 - (om*dt/2)**2 + 2*(omz*dt/2)**2)/(1 + (om*dt/2)**2) c and om**2 = omx**2 + omy**2 + omz**2 c the rotation matrix is determined by: c omx = (q/m)*bx(x(t),y(t)), omy = (q/m)*by(x(t),y(t)), and c omz = (q/m)*bz(x(t),y(t)). c position equations used are: c x(t+dt)=x(t) + vx(t+dt/2)*dt c y(t+dt)=y(t) + vy(t+dt/2)*dt c fx(x(t),y(t)), fy(x(t),y(t)), and fz(x(t),y(t)) c bx(x(t),y(t)), by(x(t),y(t)), and bz(x(t),y(t)) c are approximated by interpolation from the nearest grid points: c fx(x,y) = (1-dy)*((1-dx)*fx(n,m)+dx*fx(n+1,m)) + dy*((1-dx)*fx(n,m+1) c + dx*fx(n+1,m+1)) c where n,m = leftmost grid points and dx = x-n, dy = y-m c similarly for fy(x,y), fz(x,y), bx(x,y), by(x,y), bz(x,y) c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = velocity vx of particle n c part(n,4) = velocity vy of particle n c part(n,5) = velocity vz of particle n c fxy(1,j,k) = x component of force/charge at grid (j,k) c fxy(2,j,k) = y component of force/charge at grid (j,k) c fxy(3,j,k) = z component of force/charge at grid (j,k) c that is, convolution of electric field over particle shape c bxy(1,j,k) = x component of magnetic field at grid (j,k) c bxy(2,j,k) = y component of magnetic field at grid (j,k) c bxy(3,j,k) = z component of magnetic field at grid (j,k) c that is, the convolution of magnetic field over particle shape c qbm = particle charge/mass ratio c dt = time interval between successive calculations c dtc = time interval between successive co-ordinate calculations c kinetic energy/mass at time t is also calculated, using c ek = .5*sum((vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt)**2 + c (vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt)**2 + c (vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt)**2) c idimp = size of phase space = 5 c nop = number of particles c npe = first dimension of particle array c nx/ny = system length in x/y direction c nxv = second dimension of field arrays, must be >= nx+1 c nyv = third dimension of field arrays, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer idimp, nop, npe, nx, ny, nxv, nyv, ipbc real qbm, dt, dtc, ek real part, fxy, bxy dimension part(npe,idimp) dimension fxy(4,nxv*nyv), bxy(4,nxv*nyv) c local data integer j, nn, mm real qtmh, edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real dx, dy, dz, ox, oy, oz, acx, acy, acz, omxt, omyt, omzt, omt real anorm, rot1, rot2, rot3, rot4, rot5, rot6, rot7, rot8, rot9 real x, y, vx, vy, vz double precision sum1 qtmh = 0.5*qbm*dt sum1 = 0.0d0 c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif do 10 j = 1, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = x - real(nn) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = 1.0 - dxp amy = 1.0 - dyp c find electric field dx = amx*fxy(1,nn) dy = amx*fxy(2,nn) dz = amx*fxy(3,nn) dx = amy*(dxp*fxy(1,nn+1) + dx) dy = amy*(dxp*fxy(2,nn+1) + dy) dz = amy*(dxp*fxy(3,nn+1) + dz) acx = amx*fxy(1,nn+nxv) acy = amx*fxy(2,nn+nxv) acz = amx*fxy(3,nn+nxv) dx = dx + dyp*(dxp*fxy(1,nn+1+nxv) + acx) dy = dy + dyp*(dxp*fxy(2,nn+1+nxv) + acy) dz = dz + dyp*(dxp*fxy(3,nn+1+nxv) + acz) c find magnetic field ox = amx*bxy(1,nn) oy = amx*bxy(2,nn) oz = amx*bxy(3,nn) ox = amy*(dxp*bxy(1,nn+1) + ox) oy = amy*(dxp*bxy(2,nn+1) + oy) oz = amy*(dxp*bxy(3,nn+1) + oz) acx = amx*bxy(1,nn+nxv) acy = amx*bxy(2,nn+nxv) acz = amx*bxy(3,nn+nxv) ox = ox + dyp*(dxp*bxy(1,nn+1+nxv) + acx) oy = oy + dyp*(dxp*bxy(2,nn+1+nxv) + acy) oz = oz + dyp*(dxp*bxy(3,nn+1+nxv) + acz) c calculate half impulse dx = qtmh*dx dy = qtmh*dy dz = qtmh*dz c half acceleration acx = part(j,3) + dx acy = part(j,4) + dy acz = part(j,5) + dz c time-centered kinetic energy sum1 = sum1 + (acx*acx + acy*acy + acz*acz) c calculate cyclotron frequency omxt = qtmh*ox omyt = qtmh*oy omzt = qtmh*oz c calculate rotation matrix omt = omxt*omxt + omyt*omyt + omzt*omzt anorm = 2.0/(1.0 + omt) omt = 0.5*(1.0 - omt) rot4 = omxt*omyt rot7 = omxt*omzt rot8 = omyt*omzt rot1 = omt + omxt*omxt rot5 = omt + omyt*omyt rot9 = omt + omzt*omzt rot2 = omzt + rot4 rot4 = -omzt + rot4 rot3 = -omyt + rot7 rot7 = omyt + rot7 rot6 = omxt + rot8 rot8 = -omxt + rot8 c new velocity vx = (rot1*acx + rot2*acy + rot3*acz)*anorm + dx vy = (rot4*acx + rot5*acy + rot6*acz)*anorm + dy vz = (rot7*acx + rot8*acy + rot9*acz)*anorm + dz c new position dx = x + vx*dtc dy = y + vy*dtc c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x vx = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y vy = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x vx = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy c set new velocity part(j,3) = vx part(j,4) = vy part(j,5) = vz 10 continue c normalize kinetic energy ek = ek + 0.5*sum1 return end c----------------------------------------------------------------------- subroutine GRBPUSH23LT(part,fxy,bxy,qbm,dt,dtc,ci,ek,idimp,nop,npe 1,nx,ny,nxv,nyv,ipbc) c for 2-1/2d code, this subroutine updates particle co-ordinates and c velocities using leap-frog scheme in time and first-order linear c interpolation in space, for relativistic particles with magnetic field c Using the Boris Mover. c scalar version using guard cells c 131 flops/particle, 4 divides, 2 sqrts, 25 loads, 5 stores c input: all, output: part, ek c momentum equations used are: c px(t+dt/2) = rot(1)*(px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(2)*(py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(3)*(pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fx(x(t),y(t))*dt) c py(t+dt/2) = rot(4)*(px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(5)*(py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(6)*(pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fy(x(t),y(t))*dt) c pz(t+dt/2) = rot(7)*(px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(8)*(py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(9)*(pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fz(x(t),y(t))*dt) c where q/m is charge/mass, and the rotation matrix is given by: c rot(1) = (1 - (om*dt/2)**2 + 2*(omx*dt/2)**2)/(1 + (om*dt/2)**2) c rot(2) = 2*(omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(3) = 2*(-omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(4) = 2*(-omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(5) = (1 - (om*dt/2)**2 + 2*(omy*dt/2)**2)/(1 + (om*dt/2)**2) c rot(6) = 2*(omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(7) = 2*(omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(8) = 2*(-omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(9) = (1 - (om*dt/2)**2 + 2*(omz*dt/2)**2)/(1 + (om*dt/2)**2) c and om**2 = omx**2 + omy**2 + omz**2 c the rotation matrix is determined by: c omx = (q/m)*bx(x(t),y(t))*gami, omy = (q/m)*by(x(t),y(t))*gami, and c omz = (q/m)*bz(x(t),y(t))*gami, c where gami = 1./sqrt(1.+(px(t)*px(t)+py(t)*py(t)+pz(t)*pz(t))*ci*ci) c position equations used are: c x(t+dt) = x(t) + px(t+dt/2)*dtg c y(t+dt) = y(t) + py(t+dt/2)*dtg c where dtg = dtc/sqrt(1.+(px(t+dt/2)*px(t+dt/2)+py(t+dt/2)*py(t+dt/2)+ c pz(t+dt/2)*pz(t+dt/2))*ci*ci) c fx(x(t),y(t)), fy(x(t),y(t)), and fz(x(t),y(t)) c bx(x(t),y(t)), by(x(t),y(t)), and bz(x(t),y(t)) c are approximated by interpolation from the nearest grid points: c fx(x,y) = (1-dy)*((1-dx)*fx(n,m)+dx*fx(n+1,m)) + dy*((1-dx)*fx(n,m+1) c + dx*fx(n+1,m+1)) c where n,m = leftmost grid points and dx = x-n, dy = y-m c similarly for fy(x,y), fz(x,y), bx(x,y), by(x,y), bz(x,y) c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = momentum px of particle n c part(n,4) = momentum py of particle n c part(n,5) = momentum pz of particle n c fxy(1,j,k) = x component of force/charge at grid (j,k) c fxy(2,j,k) = y component of force/charge at grid (j,k) c fxy(3,j,k) = z component of force/charge at grid (j,k) c that is, convolution of electric field over particle shape c bxy(1,j,k) = x component of magnetic field at grid (j,k) c bxy(2,j,k) = y component of magnetic field at grid (j,k) c bxy(3,j,k) = z component of magnetic field at grid (j,k) c that is, the convolution of magnetic field over particle shape c qbm = particle charge/mass ratio c dt = time interval between successive calculations c dtc = time interval between successive co-ordinate calculations c ci = reciprocal of velocity of light c kinetic energy/mass at time t is also calculated, using c ek = gami*sum((px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt)**2 + c (py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt)**2 + c (pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt)**2)/(1. + gami) c idimp = size of phase space = 5 c nop = number of particles c npe = first dimension of particle array c nx/ny = system length in x/y direction c nxv = second dimension of field arrays, must be >= nx+1 c nyv = third dimension of field arrays, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer idimp, nop, npe, nx, ny, nxv, nyv, ipbc real qbm, dt, dtc, ci, ek real part, fxy, bxy dimension part(npe,idimp) dimension fxy(4,nxv*nyv), bxy(4,nxv*nyv) c local data integer j, nn, mm real qtmh, ci2, edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real dx, dy, dz, ox, oy, oz, acx, acy, acz, p2, gami, qtmg, dtg real omxt, omyt, omzt, omt, anorm real rot1, rot2, rot3, rot4, rot5, rot6, rot7, rot8, rot9 real x, y, vx, vy, vz double precision sum1 qtmh = 0.5*qbm*dt ci2 = ci*ci sum1 = 0.0d0 c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif do 10 j = 1, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = x - real(nn) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = 1.0 - dxp amy = 1.0 - dyp c find electric field dx = amx*fxy(1,nn) dy = amx*fxy(2,nn) dz = amx*fxy(3,nn) dx = amy*(dxp*fxy(1,nn+1) + dx) dy = amy*(dxp*fxy(2,nn+1) + dy) dz = amy*(dxp*fxy(3,nn+1) + dz) acx = amx*fxy(1,nn+nxv) acy = amx*fxy(2,nn+nxv) acz = amx*fxy(3,nn+nxv) dx = dx + dyp*(dxp*fxy(1,nn+1+nxv) + acx) dy = dy + dyp*(dxp*fxy(2,nn+1+nxv) + acy) dz = dz + dyp*(dxp*fxy(3,nn+1+nxv) + acz) c find magnetic field ox = amx*bxy(1,nn) oy = amx*bxy(2,nn) oz = amx*bxy(3,nn) ox = amy*(dxp*bxy(1,nn+1) + ox) oy = amy*(dxp*bxy(2,nn+1) + oy) oz = amy*(dxp*bxy(3,nn+1) + oz) acx = amx*bxy(1,nn+nxv) acy = amx*bxy(2,nn+nxv) acz = amx*bxy(3,nn+nxv) ox = ox + dyp*(dxp*bxy(1,nn+1+nxv) + acx) oy = oy + dyp*(dxp*bxy(2,nn+1+nxv) + acy) oz = oz + dyp*(dxp*bxy(3,nn+1+nxv) + acz) c calculate half impulse dx = qtmh*dx dy = qtmh*dy dz = qtmh*dz c half acceleration acx = part(j,3) + dx acy = part(j,4) + dy acz = part(j,5) + dz c find inverse gamma p2 = acx*acx + acy*acy + acz*acz gami = 1.0/sqrt(1.0 + p2*ci2) c renormalize magnetic field qtmg = qtmh*gami c time-centered kinetic energy sum1 = sum1 + gami*p2/(1.0 + gami) c calculate cyclotron frequency omxt = qtmg*ox omyt = qtmg*oy omzt = qtmg*oz c calculate rotation matrix omt = omxt*omxt + omyt*omyt + omzt*omzt anorm = 2.0/(1.0 + omt) omt = 0.5*(1.0 - omt) rot4 = omxt*omyt rot7 = omxt*omzt rot8 = omyt*omzt rot1 = omt + omxt*omxt rot5 = omt + omyt*omyt rot9 = omt + omzt*omzt rot2 = omzt + rot4 rot4 = -omzt + rot4 rot3 = -omyt + rot7 rot7 = omyt + rot7 rot6 = omxt + rot8 rot8 = -omxt + rot8 c new velocity vx = (rot1*acx + rot2*acy + rot3*acz)*anorm + dx vy = (rot4*acx + rot5*acy + rot6*acz)*anorm + dy vz = (rot7*acx + rot8*acy + rot9*acz)*anorm + dz c update inverse gamma p2 = vx*vx + vy*vy + vz*vz dtg = dtc/sqrt(1.0 + p2*ci2) c new position dx = x + vx*dtg dy = y + vy*dtg c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x vx = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y vy = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x vx = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy c set new momentum part(j,3) = vx part(j,4) = vy part(j,5) = vz 10 continue c normalize kinetic energy ek = ek + sum1 return end c----------------------------------------------------------------------- subroutine VGBPUSH23LT(part,fxy,bxy,qbm,dt,dtc,ek,idimp,nop,npe,nx 1,ny,nxv,nyv,ipbc) c for 2-1/2d code, this subroutine updates particle co-ordinates and c velocities using leap-frog scheme in time and first-order linear c interpolation in space, with magnetic field. Using the Boris Mover. c vectorizable version using guard cells c 119 flops/particle, 1 divide, 29 loads, 5 stores c input: all, output: part, ek c velocity equations used are: c vx(t+dt/2) = rot(1)*(vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(2)*(vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(3)*(vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fx(x(t),y(t))*dt) c vy(t+dt/2) = rot(4)*(vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(5)*(vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(6)*(vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fy(x(t),y(t))*dt) c vz(t+dt/2) = rot(7)*(vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(8)*(vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(9)*(vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fz(x(t),y(t))*dt) c where q/m is charge/mass, and the rotation matrix is given by: c rot(1) = (1 - (om*dt/2)**2 + 2*(omx*dt/2)**2)/(1 + (om*dt/2)**2) c rot(2) = 2*(omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(3) = 2*(-omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(4) = 2*(-omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(5) = (1 - (om*dt/2)**2 + 2*(omy*dt/2)**2)/(1 + (om*dt/2)**2) c rot(6) = 2*(omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(7) = 2*(omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(8) = 2*(-omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(9) = (1 - (om*dt/2)**2 + 2*(omz*dt/2)**2)/(1 + (om*dt/2)**2) c and om**2 = omx**2 + omy**2 + omz**2 c the rotation matrix is determined by: c omx = (q/m)*bx(x(t),y(t)), omy = (q/m)*by(x(t),y(t)), and c omz = (q/m)*bz(x(t),y(t)). c position equations used are: c x(t+dt)=x(t) + vx(t+dt/2)*dt c y(t+dt)=y(t) + vy(t+dt/2)*dt c fx(x(t),y(t)), fy(x(t),y(t)), and fz(x(t),y(t)) c bx(x(t),y(t)), by(x(t),y(t)), and bz(x(t),y(t)) c are approximated by interpolation from the nearest grid points: c fx(x,y) = (1-dy)*((1-dx)*fx(n,m)+dx*fx(n+1,m)) + dy*((1-dx)*fx(n,m+1) c + dx*fx(n+1,m+1)) c where n,m = leftmost grid points and dx = x-n, dy = y-m c similarly for fy(x,y), fz(x,y), bx(x,y), by(x,y), bz(x,y) c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = velocity vx of particle n c part(n,4) = velocity vy of particle n c part(n,5) = velocity vz of particle n c fxy(1,j,k) = x component of force/charge at grid (j,k) c fxy(2,j,k) = y component of force/charge at grid (j,k) c fxy(3,j,k) = z component of force/charge at grid (j,k) c that is, convolution of electric field over particle shape c bxy(1,j,k) = x component of magnetic field at grid (j,k) c bxy(2,j,k) = y component of magnetic field at grid (j,k) c bxy(3,j,k) = z component of magnetic field at grid (j,k) c that is, the convolution of magnetic field over particle shape c qbm = particle charge/mass ratio c dt = time interval between successive calculations c dtc = time interval between successive co-ordinate calculations c kinetic energy/mass at time t is also calculated, using c ek = .5*sum((vx(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt)**2 + c (vy(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt)**2 + c (vz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt)**2) c idimp = size of phase space = 5 c nop = number of particles c npe = first dimension of particle array c nx/ny = system length in x/y direction c nxv = second dimension of field arrays, must be >= nx+1 c nyv = third dimension of field arrays, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer idimp, nop, npe, nx, ny, nxv, nyv, ipbc real qbm, dt, dtc, ek real part, fxy, bxy dimension part(npe,idimp) dimension fxy(4,nxv*nyv), bxy(4,nxv*nyv) c local data integer npblk, lvect parameter(npblk=32,lvect=4) integer i, j, k, ipp, joff, nps, nn, mm real qtmh, edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real dx, dy, dz, ox, oy, oz, acx, acy, acz, omxt, omyt, omzt, omt real anorm, rot1, rot2, rot3, rot4, rot5, rot6, rot7, rot8, rot9 real x, y, vx, vy, vz c scratch arrays integer n real s1, s2, t dimension n(npblk), s1(npblk,lvect), s2(npblk,lvect), t(npblk,2) double precision sum1 qtmh = 0.5*qbm*dt sum1 = 0.0d0 c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif ipp = nop/npblk c outer loop over number of full blocks do 60 k = 1, ipp joff = npblk*(k - 1) c inner loop over particles in block do 10 j = 1, npblk c find interpolation weights x = part(j+joff,1) y = part(j+joff,2) nn = x mm = y dxp = x - real(nn) dyp = y - real(mm) n(j) = nn + nxv*mm amx = 1.0 - dxp amy = 1.0 - dyp s1(j,1) = amx*amy s1(j,2) = dxp*amy s1(j,3) = amx*dyp s1(j,4) = dxp*dyp t(j,1) = x t(j,2) = y 10 continue c find acceleration do 30 j = 1, npblk nn = n(j) mm = nn + nxv - 2 dx = 0.0 dy = 0.0 dz = 0.0 ox = 0.0 oy = 0.0 oz = 0.0 do 20 i = 1, lvect if (i.gt.2) nn = mm dx = dx + fxy(1,i+nn)*s1(j,i) dy = dy + fxy(2,i+nn)*s1(j,i) dz = dz + fxy(3,i+nn)*s1(j,i) ox = ox + bxy(1,i+nn)*s1(j,i) oy = oy + bxy(2,i+nn)*s1(j,i) oz = oz + bxy(3,i+nn)*s1(j,i) 20 continue s1(j,1) = dx s1(j,2) = dy s1(j,3) = dz s2(j,1) = ox s2(j,2) = oy s2(j,3) = oz 30 continue c new velocity do 40 j = 1, npblk x = t(j,1) y = t(j,2) c calculate half impulse dx = qtmh*s1(j,1) dy = qtmh*s1(j,2) dz = qtmh*s1(j,3) c half acceleration acx = part(j+joff,3) + dx acy = part(j+joff,4) + dy acz = part(j+joff,5) + dz c time-centered kinetic energy sum1 = sum1 + (acx*acx + acy*acy + acz*acz) c calculate cyclotron frequency omxt = qtmh*s2(j,1) omyt = qtmh*s2(j,2) omzt = qtmh*s2(j,3) c calculate rotation matrix omt = omxt*omxt + omyt*omyt + omzt*omzt anorm = 2.0/(1.0 + omt) omt = 0.5*(1.0 - omt) rot4 = omxt*omyt rot7 = omxt*omzt rot8 = omyt*omzt rot1 = omt + omxt*omxt rot5 = omt + omyt*omyt rot9 = omt + omzt*omzt rot2 = omzt + rot4 rot4 = -omzt + rot4 rot3 = -omyt + rot7 rot7 = omyt + rot7 rot6 = omxt + rot8 rot8 = -omxt + rot8 c new velocity vx = (rot1*acx + rot2*acy + rot3*acz)*anorm + dx vy = (rot4*acx + rot5*acy + rot6*acz)*anorm + dy vz = (rot7*acx + rot8*acy + rot9*acz)*anorm + dz c new position s1(j,1) = x + vx*dtc s1(j,2) = y + vy*dtc s2(j,1) = vx s2(j,2) = vy s2(j,3) = vz 40 continue ! check boundary conditions !dir$ novector do 50 j = 1, npblk dx = s1(j,1) dy = s1(j,2) vx = s2(j,1) vy = s2(j,2) vz = s2(j,3) c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = t(j,1) vx = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = t(j,2) vy = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = t(j,1) vx = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j+joff,1) = dx part(j+joff,2) = dy c set new velocity part(j+joff,3) = vx part(j+joff,4) = vy part(j+joff,5) = vz 50 continue 60 continue nps = npblk*ipp + 1 c loop over remaining particles do 70 j = nps, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = x - real(nn) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = 1.0 - dxp amy = 1.0 - dyp c find electric field dx = amx*fxy(1,nn) dy = amx*fxy(2,nn) dz = amx*fxy(3,nn) dx = amy*(dxp*fxy(1,nn+1) + dx) dy = amy*(dxp*fxy(2,nn+1) + dy) dz = amy*(dxp*fxy(3,nn+1) + dz) acx = amx*fxy(1,nn+nxv) acy = amx*fxy(2,nn+nxv) acz = amx*fxy(3,nn+nxv) dx = dx + dyp*(dxp*fxy(1,nn+1+nxv) + acx) dy = dy + dyp*(dxp*fxy(2,nn+1+nxv) + acy) dz = dz + dyp*(dxp*fxy(3,nn+1+nxv) + acz) c find magnetic field ox = amx*bxy(1,nn) oy = amx*bxy(2,nn) oz = amx*bxy(3,nn) ox = amy*(dxp*bxy(1,nn+1) + ox) oy = amy*(dxp*bxy(2,nn+1) + oy) oz = amy*(dxp*bxy(3,nn+1) + oz) acx = amx*bxy(1,nn+nxv) acy = amx*bxy(2,nn+nxv) acz = amx*bxy(3,nn+nxv) ox = ox + dyp*(dxp*bxy(1,nn+1+nxv) + acx) oy = oy + dyp*(dxp*bxy(2,nn+1+nxv) + acy) oz = oz + dyp*(dxp*bxy(3,nn+1+nxv) + acz) c calculate half impulse dx = qtmh*dx dy = qtmh*dy dz = qtmh*dz c half acceleration acx = part(j,3) + dx acy = part(j,4) + dy acz = part(j,5) + dz c time-centered kinetic energy sum1 = sum1 + (acx*acx + acy*acy + acz*acz) c calculate cyclotron frequency omxt = qtmh*ox omyt = qtmh*oy omzt = qtmh*oz c calculate rotation matrix omt = omxt*omxt + omyt*omyt + omzt*omzt anorm = 2.0/(1.0 + omt) omt = 0.5*(1.0 - omt) rot4 = omxt*omyt rot7 = omxt*omzt rot8 = omyt*omzt rot1 = omt + omxt*omxt rot5 = omt + omyt*omyt rot9 = omt + omzt*omzt rot2 = omzt + rot4 rot4 = -omzt + rot4 rot3 = -omyt + rot7 rot7 = omyt + rot7 rot6 = omxt + rot8 rot8 = -omxt + rot8 c new velocity vx = (rot1*acx + rot2*acy + rot3*acz)*anorm + dx vy = (rot4*acx + rot5*acy + rot6*acz)*anorm + dy vz = (rot7*acx + rot8*acy + rot9*acz)*anorm + dz c new position dx = x + vx*dtc dy = y + vy*dtc c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x vx = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y vy = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x vx = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy c set new velocity part(j,3) = vx part(j,4) = vy part(j,5) = vz 70 continue c normalize kinetic energy ek = ek + 0.5*sum1 return end c----------------------------------------------------------------------- subroutine VGRBPUSH23LT(part,fxy,bxy,qbm,dt,dtc,ci,ek,idimp,nop, 1npe,nx,ny,nxv,nyv,ipbc) c for 2-1/2d code, this subroutine updates particle co-ordinates and c velocities using leap-frog scheme in time and first-order linear c interpolation in space, for relativistic particles with magnetic field c Using the Boris Mover. c vectorizable version using guard cells c 131 flops/particle, 4 divides, 2 sqrts, 25 loads, 5 stores c input: all, output: part, ek c momentum equations used are: c px(t+dt/2) = rot(1)*(px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(2)*(py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(3)*(pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fx(x(t),y(t))*dt) c py(t+dt/2) = rot(4)*(px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(5)*(py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(6)*(pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fy(x(t),y(t))*dt) c pz(t+dt/2) = rot(7)*(px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt) + c rot(8)*(py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt) + c rot(9)*(pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt) + c .5*(q/m)*fz(x(t),y(t))*dt) c where q/m is charge/mass, and the rotation matrix is given by: c rot(1) = (1 - (om*dt/2)**2 + 2*(omx*dt/2)**2)/(1 + (om*dt/2)**2) c rot(2) = 2*(omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(3) = 2*(-omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(4) = 2*(-omz*dt/2 + (omx*dt/2)*(omy*dt/2))/(1 + (om*dt/2)**2) c rot(5) = (1 - (om*dt/2)**2 + 2*(omy*dt/2)**2)/(1 + (om*dt/2)**2) c rot(6) = 2*(omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(7) = 2*(omy*dt/2 + (omx*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(8) = 2*(-omx*dt/2 + (omy*dt/2)*(omz*dt/2))/(1 + (om*dt/2)**2) c rot(9) = (1 - (om*dt/2)**2 + 2*(omz*dt/2)**2)/(1 + (om*dt/2)**2) c and om**2 = omx**2 + omy**2 + omz**2 c the rotation matrix is determined by: c omx = (q/m)*bx(x(t),y(t))*gami, omy = (q/m)*by(x(t),y(t))*gami, and c omz = (q/m)*bz(x(t),y(t))*gami, c where gami = 1./sqrt(1.+(px(t)*px(t)+py(t)*py(t)+pz(t)*pz(t))*ci*ci) c position equations used are: c x(t+dt) = x(t) + px(t+dt/2)*dtg c y(t+dt) = y(t) + py(t+dt/2)*dtg c where dtg = dtc/sqrt(1.+(px(t+dt/2)*px(t+dt/2)+py(t+dt/2)*py(t+dt/2)+ c pz(t+dt/2)*pz(t+dt/2))*ci*ci) c fx(x(t),y(t)), fy(x(t),y(t)), and fz(x(t),y(t)) c bx(x(t),y(t)), by(x(t),y(t)), and bz(x(t),y(t)) c are approximated by interpolation from the nearest grid points: c fx(x,y) = (1-dy)*((1-dx)*fx(n,m)+dx*fx(n+1,m)) + dy*((1-dx)*fx(n,m+1) c + dx*fx(n+1,m+1)) c where n,m = leftmost grid points and dx = x-n, dy = y-m c similarly for fy(x,y), fz(x,y), bx(x,y), by(x,y), bz(x,y) c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = momentum px of particle n c part(n,4) = momentum py of particle n c part(n,5) = momentum pz of particle n c fxy(1,j,k) = x component of force/charge at grid (j,k) c fxy(2,j,k) = y component of force/charge at grid (j,k) c fxy(3,j,k) = z component of force/charge at grid (j,k) c that is, convolution of electric field over particle shape c bxy(1,j,k) = x component of magnetic field at grid (j,k) c bxy(2,j,k) = y component of magnetic field at grid (j,k) c bxy(3,j,k) = z component of magnetic field at grid (j,k) c that is, the convolution of magnetic field over particle shape c qbm = particle charge/mass ratio c dt = time interval between successive calculations c dtc = time interval between successive co-ordinate calculations c ci = reciprocal of velocity of light c kinetic energy/mass at time t is also calculated, using c ek = gami*sum((px(t-dt/2) + .5*(q/m)*fx(x(t),y(t))*dt)**2 + c (py(t-dt/2) + .5*(q/m)*fy(x(t),y(t))*dt)**2 + c (pz(t-dt/2) + .5*(q/m)*fz(x(t),y(t))*dt)**2)/(1. + gami) c idimp = size of phase space = 5 c nop = number of particles c npe = first dimension of particle array c nx/ny = system length in x/y direction c nxv = second dimension of field arrays, must be >= nx+1 c nyv = third dimension of field arrays, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer idimp, nop, npe, nx, ny, nxv, nyv, ipbc real qbm, dt, dtc, ci, ek real part, fxy, bxy dimension part(npe,idimp) dimension fxy(4,nxv*nyv), bxy(4,nxv*nyv) c local data integer npblk, lvect parameter(npblk=32,lvect=4) integer i, j, k, ipp, joff, nps, nn, mm real qtmh, ci2, edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real dx, dy, dz, ox, oy, oz, acx, acy, acz, p2, gami, qtmg, dtg real omxt, omyt, omzt, omt, anorm real rot1, rot2, rot3, rot4, rot5, rot6, rot7, rot8, rot9 real x, y, vx, vy, vz c scratch arrays integer n real s1, s2, t dimension n(npblk), s1(npblk,lvect), s2(npblk,lvect), t(npblk,2) double precision sum1 qtmh = 0.5*qbm*dt ci2 = ci*ci sum1 = 0.0d0 c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif ipp = nop/npblk c outer loop over number of full blocks do 60 k = 1, ipp joff = npblk*(k - 1) c inner loop over particles in block do 10 j = 1, npblk c find interpolation weights x = part(j+joff,1) y = part(j+joff,2) nn = x mm = y dxp = x - real(nn) dyp = y - real(mm) n(j) = nn + nxv*mm amx = 1.0 - dxp amy = 1.0 - dyp s1(j,1) = amx*amy s1(j,2) = dxp*amy s1(j,3) = amx*dyp s1(j,4) = dxp*dyp t(j,1) = x t(j,2) = y 10 continue c find acceleration do 30 j = 1, npblk nn = n(j) mm = nn + nxv - 2 dx = 0.0 dy = 0.0 dz = 0.0 ox = 0.0 oy = 0.0 oz = 0.0 do 20 i = 1, lvect if (i.gt.2) nn = mm dx = dx + fxy(1,i+nn)*s1(j,i) dy = dy + fxy(2,i+nn)*s1(j,i) dz = dz + fxy(3,i+nn)*s1(j,i) ox = ox + bxy(1,i+nn)*s1(j,i) oy = oy + bxy(2,i+nn)*s1(j,i) oz = oz + bxy(3,i+nn)*s1(j,i) 20 continue s1(j,1) = dx s1(j,2) = dy s1(j,3) = dz s2(j,1) = ox s2(j,2) = oy s2(j,3) = oz 30 continue c new momentum do 40 j = 1, npblk x = t(j,1) y = t(j,2) c calculate half impulse dx = qtmh*s1(j,1) dy = qtmh*s1(j,2) dz = qtmh*s1(j,3) c half acceleration acx = part(j+joff,3) + dx acy = part(j+joff,4) + dy acz = part(j+joff,5) + dz c find inverse gamma p2 = acx*acx + acy*acy + acz*acz gami = 1.0/sqrt(1.0 + p2*ci2) c renormalize magnetic field qtmg = qtmh*gami c time-centered kinetic energy sum1 = sum1 + gami*p2/(1.0 + gami) c calculate cyclotron frequency omxt = qtmg*s2(j,1) omyt = qtmg*s2(j,2) omzt = qtmg*s2(j,3) c calculate rotation matrix omt = omxt*omxt + omyt*omyt + omzt*omzt anorm = 2.0/(1.0 + omt) omt = 0.5*(1.0 - omt) rot4 = omxt*omyt rot7 = omxt*omzt rot8 = omyt*omzt rot1 = omt + omxt*omxt rot5 = omt + omyt*omyt rot9 = omt + omzt*omzt rot2 = omzt + rot4 rot4 = -omzt + rot4 rot3 = -omyt + rot7 rot7 = omyt + rot7 rot6 = omxt + rot8 rot8 = -omxt + rot8 c new velocity vx = (rot1*acx + rot2*acy + rot3*acz)*anorm + dx vy = (rot4*acx + rot5*acy + rot6*acz)*anorm + dy vz = (rot7*acx + rot8*acy + rot9*acz)*anorm + dz c update inverse gamma p2 = vx*vx + vy*vy + vz*vz dtg = dtc/sqrt(1.0 + p2*ci2) c new position s1(j,1) = x + vx*dtg s1(j,2) = y + vy*dtg s2(j,1) = vx s2(j,2) = vy s2(j,3) = vz 40 continue ! check boundary conditions !dir$ novector do 50 j = 1, npblk dx = s1(j,1) dy = s1(j,2) vx = s2(j,1) vy = s2(j,2) vz = s2(j,3) c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = t(j,1) vx = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = t(j,2) vy = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = t(j,1) vx = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j+joff,1) = dx part(j+joff,2) = dy c set new momentum part(j+joff,3) = vx part(j+joff,4) = vy part(j+joff,5) = vz 50 continue 60 continue nps = npblk*ipp + 1 c loop over remaining particles do 70 j = nps, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = x - real(nn) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = 1.0 - dxp amy = 1.0 - dyp c find electric field dx = amx*fxy(1,nn) dy = amx*fxy(2,nn) dz = amx*fxy(3,nn) dx = amy*(dxp*fxy(1,nn+1) + dx) dy = amy*(dxp*fxy(2,nn+1) + dy) dz = amy*(dxp*fxy(3,nn+1) + dz) acx = amx*fxy(1,nn+nxv) acy = amx*fxy(2,nn+nxv) acz = amx*fxy(3,nn+nxv) dx = dx + dyp*(dxp*fxy(1,nn+1+nxv) + acx) dy = dy + dyp*(dxp*fxy(2,nn+1+nxv) + acy) dz = dz + dyp*(dxp*fxy(3,nn+1+nxv) + acz) c find magnetic field ox = amx*bxy(1,nn) oy = amx*bxy(2,nn) oz = amx*bxy(3,nn) ox = amy*(dxp*bxy(1,nn+1) + ox) oy = amy*(dxp*bxy(2,nn+1) + oy) oz = amy*(dxp*bxy(3,nn+1) + oz) acx = amx*bxy(1,nn+nxv) acy = amx*bxy(2,nn+nxv) acz = amx*bxy(3,nn+nxv) ox = ox + dyp*(dxp*bxy(1,nn+1+nxv) + acx) oy = oy + dyp*(dxp*bxy(2,nn+1+nxv) + acy) oz = oz + dyp*(dxp*bxy(3,nn+1+nxv) + acz) c calculate half impulse dx = qtmh*dx dy = qtmh*dy dz = qtmh*dz c half acceleration acx = part(j,3) + dx acy = part(j,4) + dy acz = part(j,5) + dz c find inverse gamma p2 = acx*acx + acy*acy + acz*acz gami = 1.0/sqrt(1.0 + p2*ci2) c renormalize magnetic field qtmg = qtmh*gami c time-centered kinetic energy sum1 = sum1 + gami*p2/(1.0 + gami) c calculate cyclotron frequency omxt = qtmg*ox omyt = qtmg*oy omzt = qtmg*oz c calculate rotation matrix omt = omxt*omxt + omyt*omyt + omzt*omzt anorm = 2.0/(1.0 + omt) omt = 0.5*(1.0 - omt) rot4 = omxt*omyt rot7 = omxt*omzt rot8 = omyt*omzt rot1 = omt + omxt*omxt rot5 = omt + omyt*omyt rot9 = omt + omzt*omzt rot2 = omzt + rot4 rot4 = -omzt + rot4 rot3 = -omyt + rot7 rot7 = omyt + rot7 rot6 = omxt + rot8 rot8 = -omxt + rot8 c new velocity vx = (rot1*acx + rot2*acy + rot3*acz)*anorm + dx vy = (rot4*acx + rot5*acy + rot6*acz)*anorm + dy vz = (rot7*acx + rot8*acy + rot9*acz)*anorm + dz c update inverse gamma p2 = vx*vx + vy*vy + vz*vz dtg = dtc/sqrt(1.0 + p2*ci2) c new position dx = x + vx*dtg dy = y + vy*dtg c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = t(j,1) vx = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = t(j,2) vy = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = t(j,1) vx = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy c set new momentum part(j,3) = vx part(j,4) = vy part(j,5) = vz 70 continue c normalize kinetic energy ek = ek + sum1 return end c----------------------------------------------------------------------- subroutine GPOST2LT(part,q,qm,nop,npe,idimp,nxv,nyv) c for 2d code, this subroutine calculates particle charge density c using first-order linear interpolation, periodic boundaries c scalar version using guard cells c 17 flops/particle, 6 loads, 4 stores c input: all, output: q c charge density is approximated by values at the nearest grid points c q(n,m)=qm*(1.-dx)*(1.-dy) c q(n+1,m)=qm*dx*(1.-dy) c q(n,m+1)=qm*(1.-dx)*dy c q(n+1,m+1)=qm*dx*dy c where n,m = leftmost grid points and dx = x-n, dy = y-m c part(n,1) = position x of particle n c part(n,2) = position y of particle n c q(j,k) = charge density at grid point j,k c qm = charge on particle, in units of e c nop = number of particles c npe = first dimension of particle array c idimp = size of phase space = 4 c nxv = first dimension of charge array, must be >= nx+1 c nyv = second dimension of charge array, must be >= ny+1 implicit none integer nop, npe, idimp, nxv, nyv real qm real part, q dimension part(npe,idimp), q(nxv,nyv) c local data integer j, nn, mm real x, y, dxp, dyp, amx, amy do 10 j = 1, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) nn = nn + 1 mm = mm + 1 amx = qm - dxp amy = 1.0 - dyp c deposit charge x = q(nn,mm) + amx*amy y = q(nn+1,mm) + dxp*amy q(nn,mm) = x q(nn+1,mm) = y x = q(nn,mm+1) + amx*dyp y = q(nn+1,mm+1) + dxp*dyp q(nn,mm+1) = x q(nn+1,mm+1) = y 10 continue return end c----------------------------------------------------------------------- subroutine VGPOST2LT(part,q,qm,nop,npe,idimp,nxv,nyv) c for 2d code, this subroutine calculates particle charge density c using first-order linear interpolation, periodic boundaries c vectorizable version using guard cells c 17 flops/particle, 6 loads, 4 stores c input: all, output: q c charge density is approximated by values at the nearest grid points c q(n,m)=qm*(1.-dx)*(1.-dy) c q(n+1,m)=qm*dx*(1.-dy) c q(n,m+1)=qm*(1.-dx)*dy c q(n+1,m+1)=qm*dx*dy c where n,m = leftmost grid points and dx = x-n, dy = y-m c part(n,1) = position x of particle n c part(n,2) = position y of particle n c q(j,k) = charge density at grid point j,k c qm = charge on particle, in units of e c nop = number of particles c npe = first dimension of particle array c idimp = size of phase space = 4 c nxv = first dimension of charge array, must be >= nx+1 c nyv = second dimension of charge array, must be >= ny+1 implicit none integer nop, npe, idimp, nxv, nyv real qm real part, q dimension part(npe,idimp), q(nxv*nyv) c local data integer npblk, lvect parameter(npblk=32,lvect=4) integer i, j, k, ipp, joff, nps, nn, mm real x, y, dxp, dyp, amx, amy c scratch arrays integer n real s dimension n(npblk), s(npblk,lvect) ipp = nop/npblk c outer loop over number of full blocks do 40 k = 1, ipp joff = npblk*(k - 1) c inner loop over particles in block do 10 j = 1, npblk c find interpolation weights x = part(j+joff,1) y = part(j+joff,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) n(j) = nn + nxv*mm amx = qm - dxp amy = 1.0 - dyp s(j,1) = amx*amy s(j,2) = dxp*amy s(j,3) = amx*dyp s(j,4) = dxp*dyp 10 continue c deposit charge do 30 j = 1, npblk nn = n(j) mm = nn + nxv - 2 !dir$ ivdep do 20 i = 1, lvect if (i.gt.2) nn = mm q(i+nn) = q(i+nn) + s(j,i) 20 continue 30 continue 40 continue nps = npblk*ipp + 1 c loop over remaining particles do 50 j = nps, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = qm - dxp amy = 1.0 - dyp c deposit charge x = q(nn) + amx*amy y = q(nn+1) + dxp*amy q(nn) = x q(nn+1) = y x = q(nn+nxv) + amx*dyp y = q(nn+nxv+1) + dxp*dyp q(nn+nxv) = x q(nn+nxv+1) = y 50 continue return end c----------------------------------------------------------------------- subroutine GJPOST2LT(part,cu,qm,dt,nop,npe,idimp,nx,ny,nxv,nyv, 1ipbc) c for 2-1/2d code, this subroutine calculates particle current density c using first-order linear interpolation c in addition, particle positions are advanced a half time-step c scalar version using guard cells c 41 flops/particle, 17 loads, 14 stores c input: all, output: part, cu c current density is approximated by values at the nearest grid points c cu(i,n,m)=qci*(1.-dx)*(1.-dy) c cu(i,n+1,m)=qci*dx*(1.-dy) c cu(i,n,m+1)=qci*(1.-dx)*dy c cu(i,n+1,m+1)=qci*dx*dy c where n,m = leftmost grid points and dx = x-n, dy = y-m c and qci = qm*vi, where i = x,y,z c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = x velocity of particle n c part(n,4) = y velocity of particle n c part(n,5) = z velocity of particle n c cu(i,j,k) = ith component of current density at grid point j,k c qm = charge on particle, in units of e c dt = time interval between successive calculations c nop = number of particles c npe = first dimension of particle array c idimp = size of phase space = 5 c nx/ny = system length in x/y direction c nxv = second dimension of current array, must be >= nx+1 c nyv = third dimension of current array, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer nop, npe, idimp, nx, ny, nxv, nyv, ipbc real qm, dt real part, cu dimension part(npe,idimp), cu(4,nxv*nyv) c local data integer j, nn, mm real edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real x, y, dx, dy, vx, vy, vz c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif do 10 j = 1, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = qm - dxp amy = 1.0 - dyp c deposit current dx = amx*amy dy = dxp*amy vx = part(j,3) vy = part(j,4) vz = part(j,5) cu(1,nn) = cu(1,nn) + vx*dx cu(2,nn) = cu(2,nn) + vy*dx cu(3,nn) = cu(3,nn) + vz*dx dx = amx*dyp cu(1,nn+1) = cu(1,nn+1) + vx*dy cu(2,nn+1) = cu(2,nn+1) + vy*dy cu(3,nn+1) = cu(3,nn+1) + vz*dy dy = dxp*dyp cu(1,nn+nxv) = cu(1,nn+nxv) + vx*dx cu(2,nn+nxv) = cu(2,nn+nxv) + vy*dx cu(3,nn+nxv) = cu(3,nn+nxv) + vz*dx cu(1,nn+1+nxv) = cu(1,nn+1+nxv) + vx*dy cu(2,nn+1+nxv) = cu(2,nn+1+nxv) + vy*dy cu(3,nn+1+nxv) = cu(3,nn+1+nxv) + vz*dy c advance position half a time-step dx = x + vx*dt dy = y + vy*dt c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y part(j,4) = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy 10 continue return end c----------------------------------------------------------------------- subroutine GRJPOST2LT(part,cu,qm,dt,ci,nop,npe,idimp,nx,ny,nxv,nyv 1,ipbc) c for 2-1/2d code, this subroutine calculates particle current density c using first-order linear interpolation for relativistic particles c in addition, particle positions are advanced a half time-step c scalar version using guard cells c 47 flops/particle, 1 divide, 1 sqrt, 17 loads, 14 stores c input: all, output: part, cu c current density is approximated by values at the nearest grid points c cu(i,n,m)=qci*(1.-dx)*(1.-dy) c cu(i,n+1,m)=qci*dx*(1.-dy) c cu(i,n,m+1)=qci*(1.-dx)*dy c cu(i,n+1,m+1)=qci*dx*dy c where n,m = leftmost grid points and dx = x-n, dy = y-m c and qci = qm*pi*gami, where i = x,y,z c where gami = 1./sqrt(1.+sum(pi**2)*ci*ci) c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = x momentum of particle n c part(n,4) = y momentum of particle n c part(n,5) = z momentum of particle n c cu(i,j,k) = ith component of current density at grid point j,k c qm = charge on particle, in units of e c dt = time interval between successive calculations c ci = reciprocal of velocity of light c nop = number of particles c npe = first dimension of particle array c idimp = size of phase space = 5 c nx/ny = system length in x/y direction c nxv = second dimension of current array, must be >= nx+1 c nyv = third dimension of current array, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer nop, npe, idimp, nx, ny, nxv, nyv, ipbc real qm, dt, ci real part, cu dimension part(npe,idimp), cu(4,nxv*nyv) c local data integer j, nn, mm real ci2, edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real x, y, dx, dy, vx, vy, vz, ux, uy, uz, p2, gami ci2 = ci*ci c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif do 10 j = 1, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) c find inverse gamma ux = part(j,3) uy = part(j,4) uz = part(j,5) p2 = ux*ux + uy*uy + uz*uz gami = 1.0/sqrt(1.0 + p2*ci2) c calculate weights nn = nn + nxv*mm + 1 amx = qm - dxp amy = 1.0 - dyp c deposit current dx = amx*amy dy = dxp*amy vx = ux*gami vy = uy*gami vz = uz*gami cu(1,nn) = cu(1,nn) + vx*dx cu(2,nn) = cu(2,nn) + vy*dx cu(3,nn) = cu(3,nn) + vz*dx dx = amx*dyp cu(1,nn+1) = cu(1,nn+1) + vx*dy cu(2,nn+1) = cu(2,nn+1) + vy*dy cu(3,nn+1) = cu(3,nn+1) + vz*dy dy = dxp*dyp cu(1,nn+nxv) = cu(1,nn+nxv) + vx*dx cu(2,nn+nxv) = cu(2,nn+nxv) + vy*dx cu(3,nn+nxv) = cu(3,nn+nxv) + vz*dx cu(1,nn+1+nxv) = cu(1,nn+1+nxv) + vx*dy cu(2,nn+1+nxv) = cu(2,nn+1+nxv) + vy*dy cu(3,nn+1+nxv) = cu(3,nn+1+nxv) + vz*dy c advance position half a time-step dx = x + vx*dt dy = y + vy*dt c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -ux endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y part(j,4) = -uy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -ux endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy 10 continue return end c----------------------------------------------------------------------- subroutine VGJPOST2LT(part,cu,qm,dt,nop,npe,idimp,nx,ny,nxv,nyv, 1ipbc) c for 2-1/2d code, this subroutine calculates particle current density c using first-order linear interpolation c in addition, particle positions are advanced a half time-step c vectorizable version using guard cells c 41 flops/particle, 17 loads, 14 stores c input: all, output: part, cu c current density is approximated by values at the nearest grid points c cu(i,n,m)=qci*(1.-dx)*(1.-dy) c cu(i,n+1,m)=qci*dx*(1.-dy) c cu(i,n,m+1)=qci*(1.-dx)*dy c cu(i,n+1,m+1)=qci*dx*dy c where n,m = leftmost grid points and dx = x-n, dy = y-m c and qci = qm*vi, where i = x,y,z c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = x velocity of particle n c part(n,4) = y velocity of particle n c part(n,5) = z velocity of particle n c cu(i,j,k) = ith component of current density at grid point j,k c qm = charge on particle, in units of e c dt = time interval between successive calculations c nop = number of particles c npe = first dimension of particle array c idimp = size of phase space = 5 c nx/ny = system length in x/y direction c nxv = second dimension of current array, must be >= nx+1 c nyv = third dimension of current array, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer nop, npe, idimp, nx, ny, nxv, nyv, ipbc real qm, dt real part, cu dimension part(npe,idimp), cu(4,nxv*nyv) c local data integer npblk, lvect parameter(npblk=32,lvect=4) integer i, j, k, ipp, joff, nps, nn, mm real edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real x, y, dx, dy, vx, vy, vz c scratch arrays integer n real s1, s2, t dimension n(npblk), s1(npblk,lvect), s2(npblk,lvect), t(npblk,2) ipp = nop/npblk c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif c outer loop over number of full blocks do 50 k = 1, ipp joff = npblk*(k - 1) c inner loop over particles in block do 10 j = 1, npblk c find interpolation weights x = part(j+joff,1) y = part(j+joff,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) n(j) = nn + nxv*mm amx = qm - dxp amy = 1.0 - dyp s1(j,1) = amx*amy s1(j,2) = dxp*amy s1(j,3) = amx*dyp s1(j,4) = dxp*dyp t(j,1) = x t(j,2) = y s2(j,1) = part(j+joff,3) s2(j,2) = part(j+joff,4) s2(j,3) = part(j+joff,5) 10 continue c deposit current do 30 j = 1, npblk nn = n(j) mm = nn + nxv - 2 vx = s2(j,1) vy = s2(j,2) vz = s2(j,3) !dir$ ivdep do 20 i = 1, lvect if (i.gt.2) nn = mm cu(1,i+nn) = cu(1,i+nn) + vx*s1(j,i) cu(2,i+nn) = cu(2,i+nn) + vy*s1(j,i) cu(3,i+nn) = cu(3,i+nn) + vz*s1(j,i) 20 continue 30 continue c advance position half a time-step !dir$ novector do 40 j = 1, npblk x = t(j,1) y = t(j,2) vx = s2(j,1) vy = s2(j,2) dx = x + vx*dt dy = y + vy*dt c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j+joff,3) = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y part(j+joff,4) = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j+joff,3) = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j+joff,1) = dx part(j+joff,2) = dy 40 continue 50 continue nps = npblk*ipp + 1 c loop over remaining particles do 60 j = nps, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) nn = nn + nxv*mm + 1 amx = qm - dxp amy = 1.0 - dyp c deposit current dx = amx*amy dy = dxp*amy vx = part(j,3) vy = part(j,4) vz = part(j,5) cu(1,nn) = cu(1,nn) + vx*dx cu(2,nn) = cu(2,nn) + vy*dx cu(3,nn) = cu(3,nn) + vz*dx dx = amx*dyp cu(1,nn+1) = cu(1,nn+1) + vx*dy cu(2,nn+1) = cu(2,nn+1) + vy*dy cu(3,nn+1) = cu(3,nn+1) + vz*dy dy = dxp*dyp cu(1,nn+nxv) = cu(1,nn+nxv) + vx*dx cu(2,nn+nxv) = cu(2,nn+nxv) + vy*dx cu(3,nn+nxv) = cu(3,nn+nxv) + vz*dx cu(1,nn+1+nxv) = cu(1,nn+1+nxv) + vx*dy cu(2,nn+1+nxv) = cu(2,nn+1+nxv) + vy*dy cu(3,nn+1+nxv) = cu(3,nn+1+nxv) + vz*dy c advance position half a time-step dx = x + vx*dt dy = y + vy*dt c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -vx endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y part(j,4) = -vy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -vx endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy 60 continue return end c----------------------------------------------------------------------- subroutine VGRJPOST2LT(part,cu,qm,dt,ci,nop,npe,idimp,nx,ny,nxv, 1nyv,ipbc) c for 2-1/2d code, this subroutine calculates particle current density c using first-order linear interpolation for relativistic particles c in addition, particle positions are advanced a half time-step c vectorizable version using guard cells c 47 flops/particle, 1 divide, 1 sqrt, 17 loads, 14 stores c input: all, output: part, cu c current density is approximated by values at the nearest grid points c cu(i,n,m)=qci*(1.-dx)*(1.-dy) c cu(i,n+1,m)=qci*dx*(1.-dy) c cu(i,n,m+1)=qci*(1.-dx)*dy c cu(i,n+1,m+1)=qci*dx*dy c where n,m = leftmost grid points and dx = x-n, dy = y-m c and qci = qm*pi*gami, where i = x,y,z c where gami = 1./sqrt(1.+sum(pi**2)*ci*ci) c part(n,1) = position x of particle n c part(n,2) = position y of particle n c part(n,3) = x momentum of particle n c part(n,4) = y momentum of particle n c part(n,5) = z momentum of particle n c cu(i,j,k) = ith component of current density at grid point j,k c qm = charge on particle, in units of e c dt = time interval between successive calculations c ci = reciprocal of velocity of light c nop = number of particles c npe = first dimension of particle array c idimp = size of phase space = 5 c nx/ny = system length in x/y direction c nxv = second dimension of current array, must be >= nx+1 c nyv = third dimension of current array, must be >= ny+1 c ipbc = particle boundary condition = (0,1,2,3) = c (none,2d periodic,2d reflecting,mixed reflecting/periodic) implicit none integer nop, npe, idimp, nx, ny, nxv, nyv, ipbc real qm, dt, ci real part, cu dimension part(npe,idimp), cu(4,nxv*nyv) c local data integer npblk, lvect parameter(npblk=32,lvect=4) integer i, j, k, ipp, joff, nps, nn, mm real ci2, edgelx, edgely, edgerx, edgery, dxp, dyp, amx, amy real x, y, dx, dy, vx, vy, vz, ux, uy, uz, p2, gami c scratch arrays integer n real s1, s2, t dimension n(npblk), s1(npblk,lvect), s2(npblk,lvect), t(npblk,4) ci2 = ci*ci ipp = nop/npblk c set boundary values edgelx = 0.0 edgely = 0.0 edgerx = real(nx) edgery = real(ny) if (ipbc.eq.2) then edgelx = 1.0 edgely = 1.0 edgerx = real(nx-1) edgery = real(ny-1) else if (ipbc.eq.3) then edgelx = 1.0 edgerx = real(nx-1) endif c outer loop over number of full blocks do 50 k = 1, ipp joff = npblk*(k - 1) c inner loop over particles in block do 10 j = 1, npblk c find interpolation weights x = part(j+joff,1) y = part(j+joff,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) n(j) = nn + nxv*mm amx = qm - dxp amy = 1.0 - dyp s1(j,1) = amx*amy s1(j,2) = dxp*amy s1(j,3) = amx*dyp s1(j,4) = dxp*dyp t(j,1) = x t(j,2) = y c find inverse gamma ux = part(j+joff,3) uy = part(j+joff,4) uz = part(j+joff,5) p2 = ux*ux + uy*uy + uz*uz gami = 1.0/sqrt(1.0 + p2*ci2) s2(j,1) = ux*gami s2(j,2) = uy*gami s2(j,3) = uz*gami t(j,3) = ux t(j,4) = uy 10 continue c deposit current do 30 j = 1, npblk nn = n(j) mm = nn + nxv - 2 vx = s2(j,1) vy = s2(j,2) vz = s2(j,3) !dir$ ivdep do 20 i = 1, lvect if (i.gt.2) nn = mm cu(1,i+nn) = cu(1,i+nn) + vx*s1(j,i) cu(2,i+nn) = cu(2,i+nn) + vy*s1(j,i) cu(3,i+nn) = cu(3,i+nn) + vz*s1(j,i) 20 continue 30 continue c advance position half a time-step !dir$ novector do 40 j = 1, npblk x = t(j,1) y = t(j,2) vx = s2(j,1) vy = s2(j,2) ux = t(j,3) uy = t(j,4) dx = x + vx*dt dy = y + vy*dt c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j+joff,3) = -ux endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y part(j+joff,4) = -uy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j+joff,3) = -ux endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j+joff,1) = dx part(j+joff,2) = dy 40 continue 50 continue nps = npblk*ipp + 1 c loop over remaining particles do 60 j = nps, nop c find interpolation weights x = part(j,1) y = part(j,2) nn = x mm = y dxp = qm*(x - real(nn)) dyp = y - real(mm) c find inverse gamma ux = part(j,3) uy = part(j,4) uz = part(j,5) p2 = ux*ux + uy*uy + uz*uz gami = 1.0/sqrt(1.0 + p2*ci2) c calculate weights nn = nn + nxv*mm + 1 amx = qm - dxp amy = 1.0 - dyp c deposit current dx = amx*amy dy = dxp*amy vx = ux*gami vy = uy*gami vz = uz*gami cu(1,nn) = cu(1,nn) + vx*dx cu(2,nn) = cu(2,nn) + vy*dx cu(3,nn) = cu(3,nn) + vz*dx dx = amx*dyp cu(1,nn+1) = cu(1,nn+1) + vx*dy cu(2,nn+1) = cu(2,nn+1) + vy*dy cu(3,nn+1) = cu(3,nn+1) + vz*dy dy = dxp*dyp cu(1,nn+nxv) = cu(1,nn+nxv) + vx*dx cu(2,nn+nxv) = cu(2,nn+nxv) + vy*dx cu(3,nn+nxv) = cu(3,nn+nxv) + vz*dx cu(1,nn+1+nxv) = cu(1,nn+1+nxv) + vx*dy cu(2,nn+1+nxv) = cu(2,nn+1+nxv) + vy*dy cu(3,nn+1+nxv) = cu(3,nn+1+nxv) + vz*dy c advance position half a time-step dx = x + vx*dt dy = y + vy*dt c periodic boundary conditions if (ipbc.eq.1) then if (dx.lt.edgelx) dx = dx + edgerx if (dx.ge.edgerx) dx = dx - edgerx if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery c reflecting boundary conditions else if (ipbc.eq.2) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -ux endif if ((dy.lt.edgely).or.(dy.ge.edgery)) then dy = y part(j,4) = -uy endif c mixed reflecting/periodic boundary conditions else if (ipbc.eq.3) then if ((dx.lt.edgelx).or.(dx.ge.edgerx)) then dx = x part(j,3) = -ux endif if (dy.lt.edgely) dy = dy + edgery if (dy.ge.edgery) dy = dy - edgery endif c set new position part(j,1) = dx part(j,2) = dy 60 continue return end c----------------------------------------------------------------------- subroutine DSORTP2YLT(parta,partb,npic,idimp,nop,npe,ny1) c this subroutine sorts particles by y grid c linear interpolation c parta/partb = input/output particle arrays c parta(n,2) = position y of particle n c npic = address offset for reordering particles c idimp = size of phase space = 4 c nop = number of particles c npe = first dimension of particle array c ny1 = system length in y direction + 1 implicit none integer npic, idimp, nop, npe, ny1 real parta, partb dimension parta(npe,idimp), partb(npe,idimp), npic(ny1) c local data integer i, j, k, m, isum, ist, ip c clear counter array do 10 k = 1, ny1 npic(k) = 0 10 continue c find how many particles in each grid do 20 j = 1, nop m = parta(j,2) m = m + 1 npic(m) = npic(m) + 1 20 continue c find address offset isum = 0 do 30 k = 1, ny1 ist = npic(k) npic(k) = isum isum = isum + ist 30 continue c find addresses of particles at each grid and reorder particles do 50 j = 1, nop m = parta(j,2) m = m + 1 ip = npic(m) + 1 do 40 i = 1, idimp partb(ip,i) = parta(j,i) 40 continue npic(m) = ip 50 continue return end c----------------------------------------------------------------------- subroutine BGUARD2L(bxy,nx,ny,nxe,nye) c replicate extended periodic vector field bxy c linear interpolation c nx/ny = system length in x/y direction c nxe = first dimension of field arrays, must be >= nx+1 c nye = second dimension of field arrays, must be >= ny+1 implicit none real bxy integer nx, ny, nxe, nye dimension bxy(4,nxe,nye) c local data integer j, k c copy edges of extended field do 10 k = 1, ny bxy(1,nx+1,k) = bxy(1,1,k) bxy(2,nx+1,k) = bxy(2,1,k) bxy(3,nx+1,k) = bxy(3,1,k) 10 continue do 20 j = 1, nx bxy(1,j,ny+1) = bxy(1,j,1) bxy(2,j,ny+1) = bxy(2,j,1) bxy(3,j,ny+1) = bxy(3,j,1) 20 continue bxy(1,nx+1,ny+1) = bxy(1,1,1) bxy(2,nx+1,ny+1) = bxy(2,1,1) bxy(3,nx+1,ny+1) = bxy(3,1,1) return end c----------------------------------------------------------------------- subroutine ACGUARD2L(cu,nx,ny,nxe,nye) c accumulate extended periodic vector field cu c linear interpolation c nx/ny = system length in x/y direction c nxe = first dimension of field arrays, must be >= nx+1 c nye = second dimension of field arrays, must be >= ny+1 implicit none real cu integer nx, ny, nxe, nye dimension cu(4,nxe,nye) c local data integer i, j, k c accumulate edges of extended field do 20 k = 1, ny do 10 i = 1, 3 cu(i,1,k) = cu(i,1,k) + cu(i,nx+1,k) cu(i,nx+1,k) = 0.0 10 continue 20 continue do 40 j = 1, nx do 30 i = 1, 3 cu(i,j,1) = cu(i,j,1) + cu(i,j,ny+1) cu(i,j,ny+1) = 0.0 30 continue 40 continue do 50 i = 1, 3 cu(i,1,1) = cu(i,1,1) + cu(i,nx+1,ny+1) cu(i,nx+1,ny+1) = 0.0 50 continue return end c----------------------------------------------------------------------- subroutine AGUARD2L(q,nx,ny,nxe,nye) c accumulate extended periodic scalar field q c linear interpolation c nx/ny = system length in x/y direction c nxe = first dimension of field arrays, must be >= nx+1 c nye = second dimension of field arrays, must be >= ny+1 implicit none real q integer nx, ny, nxe, nye dimension q(nxe,nye) c local data integer j, k c accumulate edges of extended field do 10 k = 1, ny q(1,k) = q(1,k) + q(nx+1,k) q(nx+1,k) = 0.0 10 continue do 20 j = 1, nx q(j,1) = q(j,1) + q(j,ny+1) q(j,ny+1) = 0.0 20 continue q(1,1) = q(1,1) + q(nx+1,ny+1) q(nx+1,ny+1) = 0.0 return end c----------------------------------------------------------------------- subroutine VPOIS23(q,fxy,isign,ffc,ax,ay,affp,we,nx,ny,nxvh,nyv, 1nxhd,nyhd) c this subroutine solves 2-1/2d poisson's equation in fourier space for c force/charge (or convolution of electric field over particle shape) c with periodic boundary conditions. Zeros out z component. c for isign = 0, input: isign,ax,ay,affp,nx,ny,nxvh,nyhd, output: ffc c for isign /= 0, input: q,ffc,isign,nx,ny,nxvh,nyhd, output: fxy,we c approximate flop count is: 26*nxc*nyc + 12*(nxc + nyc) c where nxc = nx/2 - 1, nyc = ny/2 - 1 c equation used is: c fx(kx,ky) = -sqrt(-1)*kx*g(kx,ky)*s(kx,ky)*q(kx,ky), c fy(kx,ky) = -sqrt(-1)*ky*g(kx,ky)*s(kx,ky)*q(kx,ky), c fz(kx,ky) = zero, c where kx = 2pi*j/nx, ky = 2pi*k/ny, and j,k = fourier mode numbers, c g(kx,ky) = (affp/(kx**2+ky**2))*s(kx,ky), c s(kx,ky) = exp(-((kx*ax)**2+(ky*ay)**2)/2), except for c fx(kx=pi) = fy(kx=pi) = fx(ky=pi) = fy(ky=pi) = 0, and c fx(kx=0,ky=0) = fy(kx=0,ky=0) = 0. c q(j,k) = complex charge density for fourier mode (j-1,k-1) c fxy(1,j,k) = x component of complex force/charge, c fxy(2,j,k) = y component of complex force/charge, c fxy(3,j,k) = zero, c all for fourier mode (j-1,k-1) c if isign = 0, form factor array is prepared c if isign is not equal to 0, force/charge is calculated c aimag(ffc(j,k)) = finite-size particle shape factor s c for fourier mode (j-1,k-1) c real(ffc(j,k)) = potential green's function g c for fourier mode (j-1,k-1) c ax/ay = half-width of particle in x/y direction c affp = normalization constant = nx*ny/np, where np=number of particles c electric field energy is also calculated, using c we = nx*ny*sum((affp/(kx**2+ky**2))*|q(kx,ky)*s(kx,ky)|**2) c nx/ny = system length in x/y direction c nxvh = first dimension of field arrays, must be >= nxh c nyv = second dimension of field arrays, must be >= ny c nxhd = first dimension of form factor array, must be >= nxh c nyhd = second dimension of form factor array, must be >= nyh c vectorizable version implicit none integer isign, nx, ny, nxvh, nyv, nxhd, nyhd real ax, ay, affp, we complex q, fxy, ffc dimension q(nxvh,nyv), fxy(4,nxvh,nyv) dimension ffc(nxhd,nyhd) c local data integer nxh, nyh, ny2, j, k, k1 real dnx, dny, dkx, dky, at1, at2, at3, at4 complex zero, zt1, zt2 double precision wp nxh = nx/2 nyh = max(1,ny/2) ny2 = ny + 2 dnx = 6.28318530717959/real(nx) dny = 6.28318530717959/real(ny) zero = cmplx(0.0,0.0) if (isign.ne.0) go to 30 c prepare form factor array do 20 k = 1, nyh dky = dny*real(k - 1) at1 = dky*dky at2 = (dky*ay)**2 do 10 j = 1, nxh dkx = dnx*real(j - 1) at3 = dkx*dkx + at1 at4 = exp(-.5*((dkx*ax)**2 + at2)) if (at3.eq.0.0) then ffc(j,k) = cmplx(affp,1.0) else ffc(j,k) = cmplx(affp*at4/at3,at4) endif 10 continue 20 continue return c calculate force/charge and sum field energy 30 wp = 0.0d0 c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2 do 50 k = 2, nyh k1 = ny2 - k dky = dny*real(k - 1) !dir$ ivdep do 40 j = 2, nxh at1 = real(ffc(j,k))*aimag(ffc(j,k)) at2 = dnx*real(j - 1)*at1 at3 = dky*at1 zt1 = cmplx(aimag(q(j,k)),-real(q(j,k))) zt2 = cmplx(aimag(q(j,k1)),-real(q(j,k1))) fxy(1,j,k) = at2*zt1 fxy(2,j,k) = at3*zt1 fxy(3,j,k) = zero fxy(1,j,k1) = at2*zt2 fxy(2,j,k1) = -at3*zt2 fxy(3,j,k1) = zero at1 = at1*(q(j,k)*conjg(q(j,k)) + q(j,k1)*conjg(q(j,k1))) wp = wp + dble(at1) 40 continue 50 continue c mode numbers kx = 0, nx/2 cdir$ ivdep do 60 k = 2, nyh k1 = ny2 - k at1 = real(ffc(1,k))*aimag(ffc(1,k)) at3 = dny*real(k - 1)*at1 zt1 = cmplx(aimag(q(1,k)),-real(q(1,k))) fxy(1,1,k) = zero fxy(2,1,k) = at3*zt1 fxy(3,1,k) = zero fxy(1,1,k1) = zero fxy(2,1,k1) = zero fxy(3,1,k1) = zero at1 = at1*(q(1,k)*conjg(q(1,k))) wp = wp + dble(at1) 60 continue c mode numbers ky = 0, ny/2 k1 = nyh + 1 !dir$ ivdep do 70 j = 2, nxh at1 = real(ffc(j,1))*aimag(ffc(j,1)) at2 = dnx*real(j - 1)*at1 zt1 = cmplx(aimag(q(j,1)),-real(q(j,1))) fxy(1,j,1) = at2*zt1 fxy(2,j,1) = zero fxy(3,j,1) = zero fxy(1,j,k1) = zero fxy(2,j,k1) = zero fxy(3,j,k1) = zero at1 = at1*(q(j,1)*conjg(q(j,1))) wp = wp + dble(at1) 70 continue fxy(1,1,1) = zero fxy(2,1,1) = zero fxy(3,1,1) = zero fxy(1,1,k1) = zero fxy(2,1,k1) = zero fxy(3,1,k1) = zero we = real(nx*ny)*wp return end c----------------------------------------------------------------------- subroutine CUPERP2(cu,nx,ny,nxvh,nyv) c this subroutine calculates the transverse current in fourier space c input: all, output: cu c approximate flop count is: 36*nxc*nyc c and nxc*nyc divides c where nxc = nx/2 - 1, nyc = ny/2 - 1 c the transverse current is calculated using the equation: c cux(kx,ky) = cux(kx,ky)-kx*(kx*cux(kx,ky)+ky*cuy(kx,ky))/(kx*kx+ky*ky) c cuy(kx,ky) = cuy(kx,ky)-ky*(kx*cux(kx,ky)+ky*cuy(kx,ky))/(kx*kx+ky*ky) c where kx = 2pi*j/nx, ky = 2pi*k/ny, and j,k = fourier mode numbers, c except for cux(kx=pi) = cuy(kx=pi) = 0, cux(ky=pi) = cuy(ky=pi) = 0, c and cux(kx=0,ky=0) = cuy(kx=0,ky=0) = 0. c cu(i,j,k) = complex current density for fourier mode (j-1,k-1) c nx/ny = system length in x/y direction c nxvh = first dimension of current array, must be >= nxh c nyv = second dimension of current array, must be >= ny implicit none integer nx, ny, nxvh, nyv complex cu dimension cu(4,nxvh,nyv) c local data integer nxh, nyh, ny2, j, k, k1 real dnx, dny, dkx, dky, dky2, at1 complex zero, zt1 nxh = nx/2 nyh = max(1,ny/2) ny2 = ny + 2 dnx = 6.28318530717959/real(nx) dny = 6.28318530717959/real(ny) zero = cmplx(0.0,0.0) c calculate transverse part of current c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2 do 20 k = 2, nyh k1 = ny2 - k dky = dny*real(k - 1) dky2 = dky*dky !dir$ ivdep do 10 j = 2, nxh dkx = dnx*real(j - 1) at1 = 1./(dkx*dkx + dky2) zt1 = at1*(dkx*cu(1,j,k) + dky*cu(2,j,k)) cu(1,j,k) = cu(1,j,k) - dkx*zt1 cu(2,j,k) = cu(2,j,k) - dky*zt1 zt1 = at1*(dkx*cu(1,j,k1) - dky*cu(2,j,k1)) cu(1,j,k1) = cu(1,j,k1) - dkx*zt1 cu(2,j,k1) = cu(2,j,k1) + dky*zt1 10 continue 20 continue c mode numbers kx = 0, nx/2 cdir$ ivdep do 30 k = 2, nyh k1 = ny2 - k cu(2,1,k) = zero cu(1,1,k1) = zero cu(2,1,k1) = zero 30 continue c mode numbers ky = 0, ny/2 k1 = nyh + 1 do 40 j = 2, nxh cu(1,j,1) = zero cu(1,j,k1) = zero cu(2,j,k1) = zero 40 continue cu(1,1,1) = zero cu(2,1,1) = zero cu(1,1,k1) = zero cu(2,1,k1) = zero return end c----------------------------------------------------------------------- subroutine VIBPOIS23(cu,bxy,ffc,ci,wm,nx,ny,nxvh,nyv,nxhd,nyhd) c this subroutine solves 2-1/2d poisson's equation in fourier space for c magnetic field, with periodic boundary conditions. c input: cu,ffc,ci,nx,ny,nxv,nyhd, output: bxy,wm c approximate flop count is: 90*nxc*nyc + 40*(nxc + nyc) c where nxc = nx/2 - 1, nyc = ny/2 - 1 c the magnetic field is calculated using the equations: c bx(kx,ky) = ci*ci*sqrt(-1)*g(kx,ky)*ky*cuz(kx,ky), c by(kx,ky) = -ci*ci*sqrt(-1)*g(kx,ky)*kx*cuz(kx,ky), c bz(kx,ky) = ci*ci*sqrt(-1)*g(kx,ky)*(kx*cuy(kx,ky)-ky*cux(kx,ky)), c where kx = 2pi*j/nx, ky = 2pi*k/ny, and j,k = fourier mode numbers, c g(kx,ky) = (affp/(kx**2+ky**2))*s(kx,ky), c s(kx,ky) = exp(-((kx*ax)**2+(ky*ay)**2)/2), except for c bx(kx=pi) = by(kx=pi) = bz(kx=pi) = bx(ky=pi) = by(ky=pi) = bz(ky=pi) c = 0, and bx(kx=0,ky=0) = by(kx=0,ky=0) = bz(kx=0,ky=0) = 0. c cu(i,j,k) = complex current density for fourier mode (j-1,k-1) c bxy(i,j,k) = i component of complex magnetic field c all for fourier mode (j-1,k-1) c aimag(ffc(j,k)) = finite-size particle shape factor s c for fourier mode (j-1,k-1) c real(ffc(j,k)) = potential green's function g c for fourier mode (j-1,k-1) c ci = reciprocal of velocity of light c magnetic field energy is also calculated, using c wm = nx*ny*sum((affp/(kx**2+ky**2))*ci*ci* c |cu(kx,ky)*s(kx,ky)|**2), where c affp = normalization constant = nx*ny/np, where np=number of particles c this expression is valid only if the current is divergence-free c nx/ny = system length in x/y direction c nxvh = first dimension of field arrays, must be >= nxh c nyv = second dimension of field arrays, must be >= ny c nxhd = first dimension of form factor array, must be >= nxh c nyhd = second dimension of form factor array, must be >= nyh c vectorizable version implicit none integer nx, ny, nxvh, nyv, nxhd, nyhd real ci, wm complex cu, bxy, ffc dimension cu(4,nxvh,nyv), bxy(4,nxvh,nyv) dimension ffc(nxhd,nyhd) c local data integer nxh, nyh, ny2, j, k, k1 real dnx, dny, dky, ci2, at1, at2, at3 complex zero, zt1, zt2, zt3 double precision wp nxh = nx/2 nyh = max(1,ny/2) ny2 = ny + 2 dnx = 6.28318530717959/real(nx) dny = 6.28318530717959/real(ny) zero = cmplx(0.,0.) ci2 = ci*ci c calculate magnetic field and sum field energy wp = 0.0d0 c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2 do 20 k = 2, nyh k1 = ny2 - k dky = dny*real(k - 1) !dir$ ivdep do 10 j = 2, nxh at1 = ci2*real(ffc(j,k)) at2 = dnx*real(j - 1)*at1 at3 = dky*at1 at1 = at1*aimag(ffc(j,k)) zt1 = cmplx(-aimag(cu(3,j,k)),real(cu(3,j,k))) zt2 = cmplx(-aimag(cu(2,j,k)),real(cu(2,j,k))) zt3 = cmplx(-aimag(cu(1,j,k)),real(cu(1,j,k))) bxy(1,j,k) = at3*zt1 bxy(2,j,k) = -at2*zt1 bxy(3,j,k) = at2*zt2 - at3*zt3 zt1 = cmplx(-aimag(cu(3,j,k1)),real(cu(3,j,k1))) zt2 = cmplx(-aimag(cu(2,j,k1)),real(cu(2,j,k1))) zt3 = cmplx(-aimag(cu(1,j,k1)),real(cu(1,j,k1))) bxy(1,j,k1) = -at3*zt1 bxy(2,j,k1) = -at2*zt1 bxy(3,j,k1) = at2*zt2 + at3*zt3 at1 = at1*(cu(1,j,k)*conjg(cu(1,j,k)) + cu(2,j,k)*conjg(cu(2,j,k)) 1 + cu(3,j,k)*conjg(cu(3,j,k)) + cu(1,j,k1)*conjg(cu(1,j,k1)) 2 + cu(2,j,k1)*conjg(cu(2,j,k1)) + cu(3,j,k1)*conjg(cu(3,j,k1))) wp = wp + dble(at1) 10 continue 20 continue c mode numbers kx = 0, nx/2 cdir$ ivdep do 30 k = 2, nyh k1 = ny2 - k at1 = ci2*real(ffc(1,k)) at3 = dny*real(k - 1)*at1 at1 = at1*aimag(ffc(1,k)) zt1 = cmplx(-aimag(cu(3,1,k)),real(cu(3,1,k))) zt3 = cmplx(-aimag(cu(1,1,k)),real(cu(1,1,k))) bxy(1,1,k) = at3*zt1 bxy(2,1,k) = zero bxy(3,1,k) = -at3*zt3 bxy(1,1,k1) = zero bxy(2,1,k1) = zero bxy(3,1,k1) = zero at1 = at1*(cu(1,1,k)*conjg(cu(1,1,k)) + cu(2,1,k)*conjg(cu(2,1,k)) 1 + cu(3,1,k)*conjg(cu(3,1,k))) wp = wp + dble(at1) 30 continue c mode numbers ky = 0, ny/2 k1 = nyh + 1 !dir$ ivdep do 40 j = 2, nxh at1 = ci2*real(ffc(j,1)) at2 = dnx*real(j - 1)*at1 at1 = at1*aimag(ffc(j,1)) zt1 = cmplx(-aimag(cu(3,j,1)),real(cu(3,j,1))) zt2 = cmplx(-aimag(cu(2,j,1)),real(cu(2,j,1))) bxy(1,j,1) = zero bxy(2,j,1) = -at2*zt1 bxy(3,j,1) = at2*zt2 bxy(1,j,k1) = zero bxy(2,j,k1) = zero bxy(3,j,k1) = zero at1 = at1*(cu(1,j,1)*conjg(cu(1,j,1)) + cu(2,j,1)*conjg(cu(2,j,1)) 1 + cu(3,j,1)*conjg(cu(3,j,1))) wp = wp + dble(at1) 40 continue bxy(1,1,1) = zero bxy(2,1,1) = zero bxy(3,1,1) = zero bxy(1,1,k1) = zero bxy(2,1,k1) = zero bxy(3,1,k1) = zero wm = real(nx*ny)*wp return end c----------------------------------------------------------------------- subroutine VMAXWEL2(exy,bxy,cu,ffc,ci,dt,wf,wm,nx,ny,nxvh,nyv,nxhd 1,nyhd) c this subroutine solves 2-1/2d maxwell's equation in fourier space for c transverse electric and magnetic fields with periodic boundary c conditions. c input: all, output: wf, wm, exy, bxy c approximate flop count is: 286*nxc*nyc + 84*(nxc + nyc) c where nxc = nx/2 - 1, nyc = ny/2 - 1 c the magnetic field is first updated half a step using the equations: c bx(kx,ky) = bx(kx,ky) - .5*dt*sqrt(-1)*ky*ez(kx,ky) c by(kx,ky) = by(kx,ky) + .5*dt*sqrt(-1)*kx*ez(kx,ky) c bz(kx,ky) = bz(kx,ky) - .5*dt*sqrt(-1)*(kx*ey(kx,ky)-ky*ex(kx,ky)) c the electric field is then updated a whole step using the equations: c ex(kx,ky) = ex(kx,ky) + c2*dt*sqrt(-1)*ky*bz(kx,ky) c - affp*dt*cux(kx,ky)*s(kx,ky) c ey(kx,ky) = ey(kx,ky) - c2*dt*sqrt(-1)*kx*bz(kx,ky) c - affp*dt*cuy(kx,ky)*s(kx,ky) c ez(kx,ky) = ez(kx,ky) + c2*dt*sqrt(-1)*(kx*by(kx,ky)-ky*bx(kx,ky)) c - affp*dt*cuz(kx,ky)*s(kx,ky) c the magnetic field is finally updated the remaining half step with c the new electric field and the previous magnetic field equations. c where kx = 2pi*j/nx, ky = 2pi*k/ny, c2 = 1./(ci*ci) c and s(kx,ky) = exp(-((kx*ax)**2+(ky*ay)**2) c j,k = fourier mode numbers, except for c ex(kx=pi) = ey(kx=pi) = ez(kx=pi) = 0, c ex(ky=pi) = ey(ky=pi) = ex(ky=pi) = 0, c ex(kx=0,ky=0) = ey(kx=0,ky=0) = ez(kx=0,ky=0) = 0. c and similarly for bx, by, bz. c cu(i,j,k) = complex current density c exy(i,j,k) = complex transverse electric field c bxy(i,j,k) = complex magnetic field c for component i, all for fourier mode (j-1,k-1) c real(ffc(1,1)) = affp = normalization constant = nx*ny/np, c where np=number of particles c aimag(ffc(j,k)) = finite-size particle shape factor s, c s(kx,ky) = exp(-((kx*ax)**2+(ky*ay)**2)/2) c for fourier mode (j-1,k-1) c ci = reciprocal of velocity of light c dt = time interval between successive calculations c transverse electric field energy is also calculated, using c wf = nx*ny**sum((1/affp)*|exy(kx,ky)|**2) c magnetic field energy is also calculated, using c wm = nx*ny**sum((c2/affp)*|bxy(kx,ky)|**2) c nx/ny = system length in x/y direction c nxvh = first dimension of field arrays, must be >= nxh c nyv = second dimension of field arrays, must be >= ny c nxhd = first dimension of form factor array, must be >= nxh c nyhd = second dimension of form factor array, must be >= nyh c vectorizable version implicit none integer nx, ny, nxvh, nyv, nxhd, nyhd real ci, dt, wf, wm complex exy, bxy, cu, ffc dimension exy(4,nxvh,nyv), bxy(4,nxvh,nyv), cu(4,nxvh,nyv) dimension ffc(nxhd,nyhd) c local data integer nxh, nyh, ny2, j, k, k1 real dnx, dny, dth, c2, cdt, affp, anorm, dkx, dky, afdt, adt complex zero, zt1, zt2, zt3, zt4, zt5, zt6, zt7, zt8, zt9 real at1 double precision wp, ws if (ci.le.0.0) return nxh = nx/2 nyh = max(1,ny/2) ny2 = ny + 2 dnx = 6.28318530717959/real(nx) dny = 6.28318530717959/real(ny) dth = 0.5*dt c2 = 1.0/(ci*ci) cdt = c2*dt affp = real(ffc(1,1)) adt = affp*dt zero = cmplx(0.0,0.0) anorm = 1.0/affp c update electromagnetic field and sum field energies ws = 0.0d0 wp = 0.0d0 c calculate the electromagnetic fields c mode numbers 0 < kx < nx/2 and 0 < ky < ny/2 do 20 k = 2, nyh k1 = ny2 - k dky = dny*real(k - 1) !dir$ ivdep do 10 j = 2, nxh dkx = dnx*real(j - 1) afdt = adt*aimag(ffc(j,k)) c update magnetic field half time step, ky > 0 zt1 = cmplx(-aimag(exy(3,j,k)),real(exy(3,j,k))) zt2 = cmplx(-aimag(exy(2,j,k)),real(exy(2,j,k))) zt3 = cmplx(-aimag(exy(1,j,k)),real(exy(1,j,k))) zt4 = bxy(1,j,k) - dth*(dky*zt1) zt5 = bxy(2,j,k) + dth*(dkx*zt1) zt6 = bxy(3,j,k) - dth*(dkx*zt2 - dky*zt3) c update electric field whole time step zt1 = cmplx(-aimag(zt6),real(zt6)) zt2 = cmplx(-aimag(zt5),real(zt5)) zt3 = cmplx(-aimag(zt4),real(zt4)) zt7 = exy(1,j,k) + cdt*(dky*zt1) - afdt*cu(1,j,k) zt8 = exy(2,j,k) - cdt*(dkx*zt1) - afdt*cu(2,j,k) zt9 = exy(3,j,k) + cdt*(dkx*zt2 - dky*zt3) - afdt*cu(3,j,k) c update magnetic field half time step and store electric field zt1 = cmplx(-aimag(zt9),real(zt9)) zt2 = cmplx(-aimag(zt8),real(zt8)) zt3 = cmplx(-aimag(zt7),real(zt7)) exy(1,j,k) = zt7 exy(2,j,k) = zt8 exy(3,j,k) = zt9 at1 = anorm*(zt7*conjg(zt7) + zt8*conjg(zt8) + zt9*conjg(zt9)) ws = ws + dble(at1) zt4 = zt4 - dth*(dky*zt1) zt5 = zt5 + dth*(dkx*zt1) zt6 = zt6 - dth*(dkx*zt2 - dky*zt3) bxy(1,j,k) = zt4 bxy(2,j,k) = zt5 bxy(3,j,k) = zt6 at1 = anorm*(zt4*conjg(zt4) + zt5*conjg(zt5) + zt6*conjg(zt6)) wp = wp + dble(at1) c update magnetic field half time step, ky < 0 zt1 = cmplx(-aimag(exy(3,j,k1)),real(exy(3,j,k1))) zt2 = cmplx(-aimag(exy(2,j,k1)),real(exy(2,j,k1))) zt3 = cmplx(-aimag(exy(1,j,k1)),real(exy(1,j,k1))) zt4 = bxy(1,j,k1) + dth*(dky*zt1) zt5 = bxy(2,j,k1) + dth*(dkx*zt1) zt6 = bxy(3,j,k1) - dth*(dkx*zt2 + dky*zt3) c update electric field whole time step zt1 = cmplx(-aimag(zt6),real(zt6)) zt2 = cmplx(-aimag(zt5),real(zt5)) zt3 = cmplx(-aimag(zt4),real(zt4)) zt7 = exy(1,j,k1) - cdt*(dky*zt1) - afdt*cu(1,j,k1) zt8 = exy(2,j,k1) - cdt*(dkx*zt1) - afdt*cu(2,j,k1) zt9 = exy(3,j,k1) + cdt*(dkx*zt2 + dky*zt3) - afdt*cu(3,j,k1) c update magnetic field half time step and store electric field zt1 = cmplx(-aimag(zt9),real(zt9)) zt2 = cmplx(-aimag(zt8),real(zt8)) zt3 = cmplx(-aimag(zt7),real(zt7)) exy(1,j,k1) = zt7 exy(2,j,k1) = zt8 exy(3,j,k1) = zt9 at1 = anorm*(zt7*conjg(zt7) + zt8*conjg(zt8) + zt9*conjg(zt9)) ws = ws + dble(at1) zt4 = zt4 + dth*(dky*zt1) zt5 = zt5 + dth*(dkx*zt1) zt6 = zt6 - dth*(dkx*zt2 + dky*zt3) bxy(1,j,k1) = zt4 bxy(2,j,k1) = zt5 bxy(3,j,k1) = zt6 at1 = anorm*(zt4*conjg(zt4) + zt5*conjg(zt5) + zt6*conjg(zt6)) wp = wp + dble(at1) 10 continue 20 continue c mode numbers kx = 0, nx/2 cdir$ ivdep do 30 k = 2, nyh k1 = ny2 - k dky = dny*real(k - 1) afdt = adt*aimag(ffc(1,k)) c update magnetic field half time step zt1 = cmplx(-aimag(exy(3,1,k)),real(exy(3,1,k))) zt3 = cmplx(-aimag(exy(1,1,k)),real(exy(1,1,k))) zt4 = bxy(1,1,k) - dth*(dky*zt1) zt6 = bxy(3,1,k) + dth*(dky*zt3) c update electric field whole time step zt1 = cmplx(-aimag(zt6),real(zt6)) zt3 = cmplx(-aimag(zt4),real(zt4)) zt7 = exy(1,1,k) + cdt*(dky*zt1) - afdt*cu(1,1,k) zt9 = exy(3,1,k) - cdt*(dky*zt3) - afdt*cu(3,1,k) c update magnetic field half time step and store electric field zt1 = cmplx(-aimag(zt9),real(zt9)) zt3 = cmplx(-aimag(zt7),real(zt7)) exy(1,1,k) = zt7 exy(2,1,k) = zero exy(3,1,k) = zt9 at1 = anorm*(zt7*conjg(zt7) + zt9*conjg(zt9)) ws = ws + dble(at1) zt4 = zt4 - dth*(dky*zt1) zt6 = zt6 + dth*(dky*zt3) bxy(1,1,k) = zt4 bxy(2,1,k) = zero bxy(3,1,k) = zt6 at1 = anorm*(zt4*conjg(zt4) + zt6*conjg(zt6)) wp = wp + dble(at1) bxy(1,1,k1) = zero bxy(2,1,k1) = zero bxy(3,1,k1) = zero exy(1,1,k1) = zero exy(2,1,k1) = zero exy(3,1,k1) = zero 30 continue c mode numbers ky = 0, ny/2 k1 = nyh + 1 !dir$ ivdep do 40 j = 2, nxh dkx = dnx*real(j - 1) afdt = adt*aimag(ffc(j,1)) c update magnetic field half time step zt1 = cmplx(-aimag(exy(3,j,1)),real(exy(3,j,1))) zt2 = cmplx(-aimag(exy(2,j,1)),real(exy(2,j,1))) zt5 = bxy(2,j,1) + dth*(dkx*zt1) zt6 = bxy(3,j,1) - dth*(dkx*zt2) c update electric field whole time step zt1 = cmplx(-aimag(zt6),real(zt6)) zt2 = cmplx(-aimag(zt5),real(zt5)) zt8 = exy(2,j,1) - cdt*(dkx*zt1) - afdt*cu(2,j,1) zt9 = exy(3,j,1) + cdt*(dkx*zt2) - afdt*cu(3,j,1) c update magnetic field half time step and store electric field zt1 = cmplx(-aimag(zt9),real(zt9)) zt2 = cmplx(-aimag(zt8),real(zt8)) exy(1,j,1) = zero exy(2,j,1) = zt8 exy(3,j,1) = zt9 at1 = anorm*(zt8*conjg(zt8) + zt9*conjg(zt9)) ws = ws + dble(at1) zt5 = zt5 + dth*(dkx*zt1) zt6 = zt6 - dth*(dkx*zt2) bxy(1,j,1) = zero bxy(2,j,1) = zt5 bxy(3,j,1) = zt6 at1 = anorm*(zt5*conjg(zt5) + zt6*conjg(zt6)) wp = wp + dble(at1) bxy(1,j,k1) = zero bxy(2,j,k1) = zero bxy(3,j,k1) = zero exy(1,j,k1) = zero exy(2,j,k1) = zero exy(3,j,k1) = zero 40 continue bxy(1,1,1) = zero bxy(2,1,1) = zero bxy(3,1,1) = zero exy(1,1,1) = zero exy(2,1,1) = zero exy(3,1,1) = zero bxy(1,1,k1) = zero bxy(2,1,k1) = zero bxy(3,1,k1) = zero exy(1,1,k1) = zero exy(2,1,k1) = zero exy(3,1,k1) = zero wf = real(nx*ny)*ws wm = real(nx*ny)*c2*wp return end c----------------------------------------------------------------------- subroutine VEMFIELD2(fxy,exy,ffc,isign,nx,ny,nxvh,nyv,nxhd,nyhd) c this subroutine either adds complex vector fields if isign > 0 c or copies complex vector fields if isign < 0 c includes additional smoothing implicit none integer isign, nx, ny, nxvh, nyv, nxhd, nyhd complex fxy, exy, ffc dimension fxy(4,nxvh,nyv), exy(4,nxvh,nyv) dimension ffc(nxhd,nyhd) c local data integer j, k, nxh, nyh, ny2, k1 real at1 nxh = nx/2 nyh = max(1,ny/2) ny2 = ny + 2 c add the fields if (isign.gt.0) then do 20 k = 2, nyh k1 = ny2 - k !dir$ ivdep do 10 j = 1, nxh at1 = aimag(ffc(j,k)) fxy(1,j,k) = fxy(1,j,k) + exy(1,j,k)*at1 fxy(2,j,k) = fxy(2,j,k) + exy(2,j,k)*at1 fxy(3,j,k) = fxy(3,j,k) + exy(3,j,k)*at1 fxy(1,j,k1) = fxy(1,j,k1) + exy(1,j,k1)*at1 fxy(2,j,k1) = fxy(2,j,k1) + exy(2,j,k1)*at1 fxy(3,j,k1) = fxy(3,j,k1) + exy(3,j,k1)*at1 10 continue 20 continue k1 = nyh + 1 !dir$ ivdep do 30 j = 1, nxh at1 = aimag(ffc(j,1)) fxy(1,j,1) = fxy(1,j,1) + exy(1,j,1)*at1 fxy(2,j,1) = fxy(2,j,1) + exy(2,j,1)*at1 fxy(3,j,1) = fxy(3,j,1) + exy(3,j,1)*at1 fxy(1,j,k1) = fxy(1,j,k1) + exy(1,j,k1)*at1 fxy(2,j,k1) = fxy(2,j,k1) + exy(2,j,k1)*at1 fxy(3,j,k1) = fxy(3,j,k1) + exy(3,j,k1)*at1 30 continue c copy the fields else if (isign.lt.0) then do 50 k = 2, nyh k1 = ny2 - k !dir$ ivdep do 40 j = 1, nxh at1 = aimag(ffc(j,k)) fxy(1,j,k) = exy(1,j,k)*at1 fxy(2,j,k) = exy(2,j,k)*at1 fxy(3,j,k) = exy(3,j,k)*at1 fxy(1,j,k1) = exy(1,j,k1)*at1 fxy(2,j,k1) = exy(2,j,k1)*at1 fxy(3,j,k1) = exy(3,j,k1)*at1 40 continue 50 continue k1 = nyh + 1 !dir$ ivdep do 60 j = 1, nxh at1 = aimag(ffc(j,1)) fxy(1,j,1) = exy(1,j,1)*at1 fxy(2,j,1) = exy(2,j,1)*at1 fxy(3,j,1) = exy(3,j,1)*at1 fxy(1,j,k1) = exy(1,j,k1)*at1 fxy(2,j,k1) = exy(2,j,k1)*at1 fxy(3,j,k1) = exy(3,j,k1)*at1 60 continue endif return end c----------------------------------------------------------------------- subroutine WFFT2RINIT(mixup,sct,indx,indy,nxhyd,nxyhd) c this subroutine calculates tables needed by a two dimensional c real to complex fast fourier transform and its inverse. c input: indx, indy, nxhyd, nxyhd c output: mixup, sct c mixup = array of bit reversed addresses c sct = sine/cosine table c indx/indy = exponent which determines length in x/y direction, c where nx=2**indx, ny=2**indy c nxhyd = maximum of (nx/2,ny) c nxyhd = one half of maximum of (nx,ny) c written by viktor k. decyk, ucla implicit none integer indx, indy, nxhyd, nxyhd integer mixup complex sct dimension mixup(nxhyd), sct(nxyhd) c local data integer indx1, indx1y, nx, ny, nxy, nxhy, nxyh integer j, k, lb, ll, jb, it real dnxy, arg indx1 = indx - 1 indx1y = max0(indx1,indy) nx = 2**indx ny = 2**indy nxy = max0(nx,ny) nxhy = 2**indx1y c bit-reverse index table: mixup(j) = 1 + reversed bits of (j - 1) do 20 j = 1, nxhy lb = j - 1 ll = 0 do 10 k = 1, indx1y jb = lb/2 it = lb - 2*jb lb = jb ll = 2*ll + it 10 continue mixup(j) = ll + 1 20 continue c sine/cosine table for the angles 2*n*pi/nxy nxyh = nxy/2 dnxy = 6.28318530717959/real(nxy) do 30 j = 1, nxyh arg = dnxy*real(j - 1) sct(j) = cmplx(cos(arg),-sin(arg)) 30 continue return end c----------------------------------------------------------------------- subroutine WFFT2RVX(f,isign,mixup,sct,indx,indy,nxhd,nyd,nxhyd, 1nxyhd) c wrapper function for real to complex fft, with packed data implicit none complex f, sct integer mixup integer isign, indx, indy, nxhd, nyd, nxhyd, nxyhd dimension f(nxhd,nyd), mixup(nxhyd), sct(nxyhd) c local data integer nxh, ny, nxi, nyi data nxi, nyi /1,1/ c calculate range of indices nxh = 2**(indx - 1) ny = 2**indy c inverse fourier transform if (isign.lt.0) then c perform x fft call FFT2RVXX(f,isign,mixup,sct,indx,indy,nyi,ny,nxhd,nyd,nxhyd 1,nxyhd) c perform y fft call FFT2RXY(f,isign,mixup,sct,indx,indy,nxi,nxh,nxhd,nyd,nxhyd 1,nxyhd) c forward fourier transform else if (isign.gt.0) then c perform y fft call FFT2RXY(f,isign,mixup,sct,indx,indy,nxi,nxh,nxhd,nyd,nxhyd 1,nxyhd) c perform x fft call FFT2RVXX(f,isign,mixup,sct,indx,indy,nyi,ny,nxhd,nyd,nxhyd 1,nxyhd) endif return end c----------------------------------------------------------------------- subroutine WFFT2RV3(f,isign,mixup,sct,indx,indy,nxhd,nyd,nxhyd, 1nxyhd) c wrapper function for 3 2d real to complex ffts implicit none complex f, sct integer mixup integer isign, indx, indy, nxhd, nyd, nxhyd, nxyhd dimension f(4,nxhd,nyd), mixup(nxhyd), sct(nxyhd) c local data integer nxh, ny, nxi, nyi data nxi, nyi /1,1/ c calculate range of indices nxh = 2**(indx - 1) ny = 2**indy c inverse fourier transform if (isign.lt.0) then c perform x fft call FFT2RV3X(f,isign,mixup,sct,indx,indy,nyi,ny,nxhd,nyd,nxhyd 1,nxyhd) c perform y fft call FFT2RV3Y(f,isign,mixup,sct,indx,indy,nxi,nxh,nxhd,nyd, 1nxhyd,nxyhd) c forward fourier transform else if (isign.gt.0) then c perform y fft call FFT2RV3Y(f,isign,mixup,sct,indx,indy,nxi,nxh,nxhd,nyd, 1nxhyd,nxyhd) c perform x fft call FFT2RV3X(f,isign,mixup,sct,indx,indy,nyi,ny,nxhd,nyd,nxhyd 1,nxyhd) endif return end c----------------------------------------------------------------------- subroutine FFT2RVXX(f,isign,mixup,sct,indx,indy,nyi,nyp,nxhd,nyd, 1nxhyd,nxyhd) c this subroutine performs the x part of a two dimensional real to c complex fast fourier transform and its inverse, for a subset of y, c using complex arithmetic. c for isign = (-1,1), input: all, output: f c for isign = -1, approximate flop count: N*(5*log2(N) + 19/2) c for isign = 1, approximate flop count: N*(5*log2(N) + 15/2) c where N = (nx/2)*ny c indx/indy = exponent which determines length in x/y direction, c where nx=2**indx, ny=2**indy c if isign = -1, an inverse fourier transform is performed c f(n,m) = (1/nx*ny)*sum(f(j,k)* c exp(-sqrt(-1)*2pi*n*j/nx)*exp(-sqrt(-1)*2pi*m*k/ny)) c if isign = 1, a forward fourier transform is performed c f(j,k) = sum(f(n,m)*exp(sqrt(-1)*2pi*n*j/nx)*exp(sqrt(-1)*2pi*m*k/ny)) c mixup = array of bit reversed addresses c sct = sine/cosine table c nyi = initial y index used c nyp = number of y indices used c nxhd = first dimension of f >= nx/2 c nyd = second dimension of f >= ny c nxhyd = maximum of (nx/2,ny) c nxyhd = maximum of (nx,ny)/2 c fourier coefficients are stored as follows: c f(2*j-1,k),f(2*j,k) = real, imaginary part of mode j-1,k-1, where c 1 <= j <= nx/2 and 1 <= k <= ny, except for c f(1,k),f(2,k) = real, imaginary part of mode nx/2,k-1, where c ny/2+2 <= k <= ny, and c f(2,1) = real part of mode nx/2,0 and c f(2,ny/2+1) = real part of mode nx/2,ny/2 c written by viktor k. decyk, ucla implicit none integer isign, indx, indy, nyi, nyp, nxhd, nyd, nxhyd, nxyhd complex f, sct integer mixup dimension f(nxhd,nyd), mixup(nxhyd), sct(nxyhd) c local data integer indx1, indx1y, nx, nxh, nxhh, nxh2, ny, nxy, nxhy, nyt integer nrx, i, j, k, l, j1, k1, k2, ns, ns2, km, kmr real ani complex t1, t2, t3 if (isign.eq.0) return indx1 = indx - 1 indx1y = max0(indx1,indy) nx = 2**indx nxh = nx/2 nxhh = nx/4 nxh2 = nxh + 2 ny = 2**indy nxy = max0(nx,ny) nxhy = 2**indx1y nyt = nyi + nyp - 1 if (isign.gt.0) go to 100 c inverse fourier transform c bit-reverse array elements in x nrx = nxhy/nxh do 20 j = 1, nxh j1 = (mixup(j) - 1)/nrx + 1 if (j.ge.j1) go to 20 do 10 k = nyi, nyt t1 = f(j1,k) f(j1,k) = f(j,k) f(j,k) = t1 10 continue 20 continue c first transform in x nrx = nxy/nxh do 60 l = 1, indx1 ns = 2**(l - 1) ns2 = ns + ns km = nxhh/ns kmr = km*nrx do 50 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 40 i = nyi, nyt do 30 j = 1, ns t1 = sct(1+kmr*(j-1)) t2 = t1*f(j+k2,i) f(j+k2,i) = f(j+k1,i) - t2 f(j+k1,i) = f(j+k1,i) + t2 30 continue 40 continue 50 continue 60 continue c unscramble coefficients and normalize kmr = nxy/nx ani = 1.0/real(2*nx*ny) do 80 k = nyi, nyt do 70 j = 2, nxhh t3 = cmplx(aimag(sct(1+kmr*(j-1))),-real(sct(1+kmr*(j-1)))) t2 = conjg(f(nxh2-j,k)) t1 = f(j,k) + t2 t2 = (f(j,k) - t2)*t3 f(j,k) = ani*(t1 + t2) f(nxh2-j,k) = ani*conjg(t1 - t2) 70 continue 80 continue ani = 2.0*ani do 90 k = nyi, nyt f(nxhh+1,k) = ani*conjg(f(nxhh+1,k)) f(1,k) = ani*cmplx(real(f(1,k)) + aimag(f(1,k)), 1 real(f(1,k)) - aimag(f(1,k))) 90 continue return c forward fourier transform c scramble coefficients 100 kmr = nxy/nx do 120 k = nyi, nyt do 110 j = 2, nxhh t3 = cmplx(aimag(sct(1+kmr*(j-1))),real(sct(1+kmr*(j-1)))) t2 = conjg(f(nxh2-j,k)) t1 = f(j,k) + t2 t2 = (f(j,k) - t2)*t3 f(j,k) = t1 + t2 f(nxh2-j,k) = conjg(t1 - t2) 110 continue 120 continue do 130 k = nyi, nyt f(nxhh+1,k) = 2.0*conjg(f(nxhh+1,k)) f(1,k) = cmplx(real(f(1,k)) + aimag(f(1,k)), 1 real(f(1,k)) - aimag(f(1,k))) 130 continue c bit-reverse array elements in x nrx = nxhy/nxh do 150 j = 1, nxh j1 = (mixup(j) - 1)/nrx + 1 if (j.ge.j1) go to 150 do 140 k = nyi, nyt t1 = f(j1,k) f(j1,k) = f(j,k) f(j,k) = t1 140 continue 150 continue c then transform in x nrx = nxy/nxh do 190 l = 1, indx1 ns = 2**(l - 1) ns2 = ns + ns km = nxhh/ns kmr = km*nrx do 180 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 170 i = nyi, nyt do 160 j = 1, ns t1 = conjg(sct(1+kmr*(j-1))) t2 = t1*f(j+k2,i) f(j+k2,i) = f(j+k1,i) - t2 f(j+k1,i) = f(j+k1,i) + t2 160 continue 170 continue 180 continue 190 continue return end c----------------------------------------------------------------------- subroutine FFT2RXY(f,isign,mixup,sct,indx,indy,nxi,nxp,nxhd,nyd, 1nxhyd,nxyhd) c this subroutine performs the y part of a two dimensional real to c complex fast fourier transform and its inverse, for a subset of x, c using complex arithmetic c for isign = (-1,1), input: all, output: f c for isign = -1, approximate flop count: N*(5*log2(N) + 19/2) c for isign = 1, approximate flop count: N*(5*log2(N) + 15/2) c where N = (nx/2)*ny c indx/indy = exponent which determines length in x/y direction, c where nx=2**indx, ny=2**indy c if isign = -1, an inverse fourier transform is performed c f(n,m) = (1/nx*ny)*sum(f(j,k)* c exp(-sqrt(-1)*2pi*n*j/nx)*exp(-sqrt(-1)*2pi*m*k/ny)) c if isign = 1, a forward fourier transform is performed c f(j,k) = sum(f(n,m)*exp(sqrt(-1)*2pi*n*j/nx)*exp(sqrt(-1)*2pi*m*k/ny)) c mixup = array of bit reversed addresses c sct = sine/cosine table c nxi = initial x index used c nxp = number of x indices used c nxhd = first dimension of f >= nx/2 c nyd = second dimension of f >= ny c nxhyd = maximum of (nx/2,ny) c nxyhd = maximum of (nx,ny)/2 c fourier coefficients are stored as follows: c f(2*j-1,k),f(2*j,k) = real, imaginary part of mode j-1,k-1, where c 1 <= j <= nx/2 and 1 <= k <= ny, except for c f(1,k),f(2,k) = real, imaginary part of mode nx/2,k-1, where c ny/2+2 <= k <= ny, and c f(2,1) = real part of mode nx/2,0 and c f(2,ny/2+1) = real part of mode nx/2,ny/2 c written by viktor k. decyk, ucla implicit none integer isign, indx, indy, nxi, nxp, nxhd, nyd, nxhyd, nxyhd complex f, sct integer mixup dimension f(nxhd,nyd), mixup(nxhyd), sct(nxyhd) c local data integer indx1, indx1y, nx, ny, nyh, ny2, nxy, nxhy, nxt integer nry, i, j, k, l, j1, j2, k1, k2, ns, ns2, km, kmr complex t1, t2 if (isign.eq.0) return indx1 = indx - 1 indx1y = max0(indx1,indy) nx = 2**indx ny = 2**indy nyh = ny/2 ny2 = ny + 2 nxy = max0(nx,ny) nxhy = 2**indx1y nxt = nxi + nxp - 1 if (isign.gt.0) go to 80 c inverse fourier transform nry = nxhy/ny c bit-reverse array elements in y do 20 k = 1, ny k1 = (mixup(k) - 1)/nry + 1 if (k.ge.k1) go to 20 do 10 j = nxi, nxt t1 = f(j,k1) f(j,k1) = f(j,k) f(j,k) = t1 10 continue 20 continue c then transform in y nry = nxy/ny do 60 l = 1, indy ns = 2**(l - 1) ns2 = ns + ns km = nyh/ns kmr = km*nry do 50 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 40 j = 1, ns j1 = j + k1 j2 = j + k2 t1 = sct(1+kmr*(j-1)) do 30 i = nxi, nxt t2 = t1*f(i,j2) f(i,j2) = f(i,j1) - t2 f(i,j1) = f(i,j1) + t2 30 continue 40 continue 50 continue 60 continue c unscramble modes kx = 0, nx/2 do 70 k = 2, nyh if (nxi.eq.1) then t1 = f(1,ny2-k) f(1,ny2-k) = 0.5*cmplx(aimag(f(1,k) + t1),real(f(1,k) - t1)) f(1,k) = 0.5*cmplx(real(f(1,k) + t1),aimag(f(1,k) - t1)) endif 70 continue return c forward fourier transform c scramble modes kx = 0, nx/2 80 do 90 k = 2, nyh if (nxi.eq.1) then t1 = cmplx(aimag(f(1,ny2-k)),real(f(1,ny2-k))) f(1,ny2-k) = conjg(f(1,k) - t1) f(1,k) = f(1,k) + t1 endif 90 continue c bit-reverse array elements in y nry = nxhy/ny do 110 k = 1, ny k1 = (mixup(k) - 1)/nry + 1 if (k.ge.k1) go to 110 do 100 j = nxi, nxt t1 = f(j,k1) f(j,k1) = f(j,k) f(j,k) = t1 100 continue 110 continue c first transform in y nry = nxy/ny do 150 l = 1, indy ns = 2**(l - 1) ns2 = ns + ns km = nyh/ns kmr = km*nry do 140 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 130 j = 1, ns j1 = j + k1 j2 = j + k2 t1 = conjg(sct(1+kmr*(j-1))) do 120 i = nxi, nxt t2 = t1*f(i,j2) f(i,j2) = f(i,j1) - t2 f(i,j1) = f(i,j1) + t2 120 continue 130 continue 140 continue 150 continue return end c----------------------------------------------------------------------- subroutine FFT2RV3X(f,isign,mixup,sct,indx,indy,nyi,nyp,nxhd,nyd, 1nxhyd,nxyhd) c this subroutine performs the x part of 3 two dimensional real to c complex fast fourier transforms, and their inverses, for a subset of c y, using complex arithmetic c for isign = (-1,1), input: all, output: f c for isign = -1, approximate flop count: N*(5*log2(N) + 19/2) c for isign = 1, approximate flop count: N*(5*log2(N) + 15/2) c where N = (nx/2)*ny c indx/indy = exponent which determines length in x/y direction, c where nx=2**indx, ny=2**indy c if isign = -1, three inverse fourier transforms are performed c f(1:3,n,m) = (1/nx*ny)*sum(f(1:3,j,k)* c exp(-sqrt(-1)*2pi*n*j/nx)*exp(-sqrt(-1)*2pi*m*k/ny)) c if isign = 1, two forward fourier transforms are performed c f(1:3,j,k) = sum(f(1:3,n,m)*exp(sqrt(-1)*2pi*n*j/nx)* c exp(sqrt(-1)*2pi*m*k/ny)) c mixup = array of bit reversed addresses c sct = sine/cosine table c nyi = initial y index used c nyp = number of y indices used c nxhd = second dimension of f >= nx/2 c nyd = third dimension of f >= ny c nxhyd = maximum of (nx/2,ny) c nxyhd = maximum of (nx,ny)/2 c fourier coefficients are stored as follows: c f(1:3,j,k) = real, imaginary part of mode j-1,k-1, where c 1 <= j <= nx/2 and 1 <= k <= ny, except for c f(1:3,1,k) = real, imaginary part of mode nx/2,k-1, where c ny/2+2 <= k <= ny, and c imag(f(1:3,1,1)) = real part of mode nx/2,0 and c imag(f(1:3,1,ny/2+1) ) = real part of mode nx/2,ny/2 c written by viktor k. decyk, ucla implicit none integer isign, indx, indy, nyi, nyp, nxhd, nyd, nxhyd, nxyhd complex f, sct integer mixup dimension f(4,nxhd,nyd), mixup(nxhyd), sct(nxyhd) c local data integer indx1, indx1y, nx, nxh, nxhh, nxh2, ny, nxy, nxhy, nyt integer nrx, i, j, k, l, jj, j1, k1, k2, ns, ns2, km, kmr real at1, at2, ani complex t1, t2, t3, t4 if (isign.eq.0) return indx1 = indx - 1 indx1y = max0(indx1,indy) nx = 2**indx nxh = nx/2 nxhh = nx/4 nxh2 = nxh + 2 ny = 2**indy nxy = max0(nx,ny) nxhy = 2**indx1y nyt = nyi + nyp - 1 if (isign.gt.0) go to 140 c inverse fourier transform c swap complex components do 20 i = nyi, nyt do 10 j = 1, nxh at1 = aimag(f(3,j,i)) at2 = real(f(3,j,i)) f(3,j,i) = cmplx(real(f(2,j,i)),real(f(4,j,i))) f(2,j,i) = cmplx(aimag(f(1,j,i)),at1) f(1,j,i) = cmplx(real(f(1,j,i)),at2) 10 continue 20 continue c bit-reverse array elements in x nrx = nxhy/nxh do 40 j = 1, nxh j1 = (mixup(j) - 1)/nrx + 1 if (j.ge.j1) go to 40 do 30 k = nyi, nyt t1 = f(1,j1,k) t2 = f(2,j1,k) t3 = f(3,j1,k) f(1,j1,k) = f(1,j,k) f(2,j1,k) = f(2,j,k) f(3,j1,k) = f(3,j,k) f(1,j,k) = t1 f(2,j,k) = t2 f(3,j,k) = t3 30 continue 40 continue c first transform in x nrx = nxy/nxh do 80 l = 1, indx1 ns = 2**(l - 1) ns2 = ns + ns km = nxhh/ns kmr = km*nrx do 70 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 60 i = nyi, nyt do 50 j = 1, ns t1 = sct(1+kmr*(j-1)) t2 = t1*f(1,j+k2,i) t3 = t1*f(2,j+k2,i) t4 = t1*f(3,j+k2,i) f(1,j+k2,i) = f(1,j+k1,i) - t2 f(2,j+k2,i) = f(2,j+k1,i) - t3 f(3,j+k2,i) = f(3,j+k1,i) - t4 f(1,j+k1,i) = f(1,j+k1,i) + t2 f(2,j+k1,i) = f(2,j+k1,i) + t3 f(3,j+k1,i) = f(3,j+k1,i) + t4 50 continue 60 continue 70 continue 80 continue c unscramble coefficients and normalize kmr = nxy/nx ani = 1.0/real(2*nx*ny) do 110 k = nyi, nyt do 100 j = 2, nxhh t3 = cmplx(aimag(sct(1+kmr*(j-1))),-real(sct(1+kmr*(j-1)))) do 90 jj = 1, 3 t2 = conjg(f(jj,nxh2-j,k)) t1 = f(jj,j,k) + t2 t2 = (f(jj,j,k) - t2)*t3 f(jj,j,k) = ani*(t1 + t2) f(jj,nxh2-j,k) = ani*conjg(t1 - t2) 90 continue 100 continue 110 continue ani = 2.*ani do 130 k = nyi, nyt do 120 jj = 1, 3 f(jj,nxhh+1,k) = ani*conjg(f(jj,nxhh+1,k)) f(jj,1,k) = ani*cmplx(real(f(jj,1,k)) + aimag(f(jj,1,k)), 1 real(f(jj,1,k)) - aimag(f(jj,1,k))) 120 continue 130 continue return c forward fourier transform c scramble coefficients 140 kmr = nxy/nx do 170 k = nyi, nyt do 160 j = 2, nxhh t3 = cmplx(aimag(sct(1+kmr*(j-1))),real(sct(1+kmr*(j-1)))) do 150 jj = 1, 3 t2 = conjg(f(jj,nxh2-j,k)) t1 = f(jj,j,k) + t2 t2 = (f(jj,j,k) - t2)*t3 f(jj,j,k) = t1 + t2 f(jj,nxh2-j,k) = conjg(t1 - t2) 150 continue 160 continue 170 continue do 190 k = nyi, nyt do 180 jj = 1, 3 f(jj,nxhh+1,k) = 2.0*conjg(f(jj,nxhh+1,k)) f(jj,1,k) = cmplx(real(f(jj,1,k)) + aimag(f(jj,1,k)), 1 real(f(jj,1,k)) - aimag(f(jj,1,k))) 180 continue 190 continue c bit-reverse array elements in x nrx = nxhy/nxh do 210 j = 1, nxh j1 = (mixup(j) - 1)/nrx + 1 if (j.ge.j1) go to 210 do 200 k = nyi, nyt t1 = f(1,j1,k) t2 = f(2,j1,k) t3 = f(3,j1,k) f(1,j1,k) = f(1,j,k) f(2,j1,k) = f(2,j,k) f(3,j1,k) = f(3,j,k) f(1,j,k) = t1 f(2,j,k) = t2 f(3,j,k) = t3 200 continue 210 continue c then transform in x nrx = nxy/nxh do 250 l = 1, indx1 ns = 2**(l - 1) ns2 = ns + ns km = nxhh/ns kmr = km*nrx do 240 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 230 i = nyi, nyt do 220 j = 1, ns t1 = conjg(sct(1+kmr*(j-1))) t2 = t1*f(1,j+k2,i) t3 = t1*f(2,j+k2,i) t4 = t1*f(3,j+k2,i) f(1,j+k2,i) = f(1,j+k1,i) - t2 f(2,j+k2,i) = f(2,j+k1,i) - t3 f(3,j+k2,i) = f(3,j+k1,i) - t4 f(1,j+k1,i) = f(1,j+k1,i) + t2 f(2,j+k1,i) = f(2,j+k1,i) + t3 f(3,j+k1,i) = f(3,j+k1,i) + t4 220 continue 230 continue 240 continue 250 continue c swap complex components do 270 i = nyi, nyt do 260 j = 1, nxh f(4,j,i) = cmplx(aimag(f(3,j,i)),aimag(f(4,j,i))) at1 = real(f(3,j,i)) f(3,j,i) = cmplx(aimag(f(1,j,i)),aimag(f(2,j,i))) at2 = real(f(2,j,i)) f(2,j,i) = cmplx(at1,0.0) f(1,j,i) = cmplx(real(f(1,j,i)),at2) 260 continue 270 continue return end c----------------------------------------------------------------------- subroutine FFT2RV3Y(f,isign,mixup,sct,indx,indy,nxi,nxp,nxhd,nyd, 1nxhyd,nxyhd) c this subroutine performs the y part of 3 two dimensional real to c complex fast fourier transforms, and their inverses, for a subset of c x, using complex arithmetic c for isign = (-1,1), input: all, output: f c for isign = -1, approximate flop count: N*(5*log2(N) + 19/2) c for isign = 1, approximate flop count: N*(5*log2(N) + 15/2) c where N = (nx/2)*ny c indx/indy = exponent which determines length in x/y direction, c where nx=2**indx, ny=2**indy c if isign = -1, three inverse fourier transforms are performed c f(1:3,n,m) = (1/nx*ny)*sum(f(1:3,j,k)* c exp(-sqrt(-1)*2pi*n*j/nx)*exp(-sqrt(-1)*2pi*m*k/ny)) c if isign = 1, two forward fourier transforms are performed c f(1:3,j,k) = sum(f(1:3,n,m)*exp(sqrt(-1)*2pi*n*j/nx)* c exp(sqrt(-1)*2pi*m*k/ny)) c mixup = array of bit reversed addresses c sct = sine/cosine table c nxi = initial x index used c nxp = number of x indices used c nxhd = second dimension of f >= nx/2 c nyd = third dimension of f >= ny c nxhyd = maximum of (nx/2,ny) c nxyhd = maximum of (nx,ny)/2 c fourier coefficients are stored as follows: c f(1:3,j,k) = real, imaginary part of mode j-1,k-1, where c 1 <= j <= nx/2 and 1 <= k <= ny, except for c f(1:3,1,k) = real, imaginary part of mode nx/2,k-1, where c ny/2+2 <= k <= ny, and c imag(f(1:3,1,1)) = real part of mode nx/2,0 and c imag(f(1:3,1,ny/2+1) ) = real part of mode nx/2,ny/2 c written by viktor k. decyk, ucla implicit none integer isign, indx, indy, nxi, nxp, nxhd, nyd, nxhyd, nxyhd complex f, sct integer mixup dimension f(4,nxhd,nyd), mixup(nxhyd), sct(nxyhd) c local data integer indx1, indx1y, nx, ny, nyh, ny2, nxy, nxhy, nxt integer nry, i, j, k, l, jj, j1, j2, k1, k2, ns, ns2, km, kmr complex t1, t2, t3, t4 if (isign.eq.0) return indx1 = indx - 1 indx1y = max0(indx1,indy) nx = 2**indx ny = 2**indy nyh = ny/2 ny2 = ny + 2 nxy = max0(nx,ny) nxhy = 2**indx1y nxt = nxi + nxp - 1 if (isign.gt.0) go to 90 c inverse fourier transform nry = nxhy/ny c bit-reverse array elements in y do 20 k = 1, ny k1 = (mixup(k) - 1)/nry + 1 if (k.ge.k1) go to 20 do 10 j = nxi, nxt t1 = f(1,j,k1) t2 = f(2,j,k1) t3 = f(3,j,k1) f(1,j,k1) = f(1,j,k) f(2,j,k1) = f(2,j,k) f(3,j,k1) = f(3,j,k) f(1,j,k) = t1 f(2,j,k) = t2 f(3,j,k) = t3 10 continue 20 continue c then transform in y nry = nxy/ny do 60 l = 1, indy ns = 2**(l - 1) ns2 = ns + ns km = nyh/ns kmr = km*nry do 50 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 40 j = 1, ns j1 = j + k1 j2 = j + k2 t1 = sct(1+kmr*(j-1)) do 30 i = nxi, nxt t2 = t1*f(1,i,j2) t3 = t1*f(2,i,j2) t4 = t1*f(3,i,j2) f(1,i,j2) = f(1,i,j1) - t2 f(2,i,j2) = f(2,i,j1) - t3 f(3,i,j2) = f(3,i,j1) - t4 f(1,i,j1) = f(1,i,j1) + t2 f(2,i,j1) = f(2,i,j1) + t3 f(3,i,j1) = f(3,i,j1) + t4 30 continue 40 continue 50 continue 60 continue c unscramble modes kx = 0, nx/2 do 80 k = 2, nyh if (nxi.eq.1) then do 70 jj = 1, 3 t1 = f(jj,1,ny2-k) f(jj,1,ny2-k) = 0.5*cmplx(aimag(f(jj,1,k) + t1), 1 real(f(jj,1,k) - t1)) f(jj,1,k) = 0.5*cmplx(real(f(jj,1,k) + t1), 1 aimag(f(jj,1,k) - t1)) 70 continue endif 80 continue return c forward fourier transform c scramble modes kx = 0, nx/2 90 do 110 k = 2, nyh if (nxi.eq.1) then do 100 jj = 1, 3 t1 = cmplx(aimag(f(jj,1,ny2-k)),real(f(jj,1,ny2-k))) f(jj,1,ny2-k) = conjg(f(jj,1,k) - t1) f(jj,1,k) = f(jj,1,k) + t1 100 continue endif 110 continue c bit-reverse array elements in y nry = nxhy/ny do 130 k = 1, ny k1 = (mixup(k) - 1)/nry + 1 if (k.ge.k1) go to 130 do 120 j = nxi, nxt t1 = f(1,j,k1) t2 = f(2,j,k1) t3 = f(3,j,k1) f(1,j,k1) = f(1,j,k) f(2,j,k1) = f(2,j,k) f(3,j,k1) = f(3,j,k) f(1,j,k) = t1 f(2,j,k) = t2 f(3,j,k) = t3 120 continue 130 continue c first transform in y nry = nxy/ny do 170 l = 1, indy ns = 2**(l - 1) ns2 = ns + ns km = nyh/ns kmr = km*nry do 160 k = 1, km k1 = ns2*(k - 1) k2 = k1 + ns do 150 j = 1, ns j1 = j + k1 j2 = j + k2 t1 = conjg(sct(1+kmr*(j-1))) do 140 i = nxi, nxt t2 = t1*f(1,i,j2) t3 = t1*f(2,i,j2) t4 = t1*f(3,i,j2) f(1,i,j2) = f(1,i,j1) - t2 f(2,i,j2) = f(2,i,j1) - t3 f(3,i,j2) = f(3,i,j1) - t4 f(1,i,j1) = f(1,i,j1) + t2 f(2,i,j1) = f(2,i,j1) + t3 f(3,i,j1) = f(3,i,j1) + t4 140 continue 150 continue 160 continue 170 continue return end c----------------------------------------------------------------------- function ranorm() c this program calculates a random number y from a gaussian distribution c with zero mean and unit variance, according to the method of c mueller and box: c y(k) = (-2*ln(x(k)))**1/2*sin(2*pi*x(k+1)) c y(k+1) = (-2*ln(x(k)))**1/2*cos(2*pi*x(k+1)), c where x is a random number uniformly distributed on (0,1). c written for the ibm by viktor k. decyk, ucla implicit none integer iflg,isc,i1,r1,r2,r4,r5 double precision ranorm,h1l,h1u,h2l,r0,r3,asc,bsc,temp save iflg,r1,r2,r4,r5,h1l,h1u,h2l,r0 data r1,r2,r4,r5 /885098780,1824280461,1396483093,55318673/ data h1l,h1u,h2l /65531.0d0,32767.0d0,65525.0d0/ data iflg,r0 /0,0.0d0/ if (iflg.eq.0) go to 10 ranorm = r0 r0 = 0.0d0 iflg = 0 return 10 isc = 65536 asc = dble(isc) bsc = asc*asc i1 = r1 - (r1/isc)*isc r3 = h1l*dble(r1) + asc*h1u*dble(i1) i1 = r3/bsc r3 = r3 - dble(i1)*bsc bsc = 0.5d0*bsc i1 = r2/isc isc = r2 - i1*isc r0 = h1l*dble(r2) + asc*h1u*dble(isc) asc = 1.0d0/bsc isc = r0*asc r2 = r0 - dble(isc)*bsc r3 = r3 + (dble(isc) + 2.0d0*h1u*dble(i1)) isc = r3*asc r1 = r3 - dble(isc)*bsc temp = dsqrt(-2.0d0*dlog((dble(r1) + dble(r2)*asc)*asc)) isc = 65536 asc = dble(isc) bsc = asc*asc i1 = r4 - (r4/isc)*isc r3 = h2l*dble(r4) + asc*h1u*dble(i1) i1 = r3/bsc r3 = r3 - dble(i1)*bsc bsc = 0.5d0*bsc i1 = r5/isc isc = r5 - i1*isc r0 = h2l*dble(r5) + asc*h1u*dble(isc) asc = 1.0d0/bsc isc = r0*asc r5 = r0 - dble(isc)*bsc r3 = r3 + (dble(isc) + 2.0d0*h1u*dble(i1)) isc = r3*asc r4 = r3 - dble(isc)*bsc r0 = 6.28318530717959d0*((dble(r4) + dble(r5)*asc)*asc) ranorm = temp*dsin(r0) r0 = temp*dcos(r0) iflg = 1 return end c----------------------------------------------------------------------- function randum() c this is a version of the random number generator dprandom due to c c. bingham and the yale computer center, producing numbers c in the interval (0,1). written for the sun by viktor k. decyk, ucla implicit none integer isc,i1,r1,r2 double precision randum,h1l,h1u,r0,r3,asc,bsc save r1,r2,h1l,h1u data r1,r2 /1271199957,1013501921/ data h1l,h1u /65533.0d0,32767.0d0/ isc = 65536 asc = dble(isc) bsc = asc*asc i1 = r1 - (r1/isc)*isc r3 = h1l*dble(r1) + asc*h1u*dble(i1) i1 = r3/bsc r3 = r3 - dble(i1)*bsc bsc = 0.5d0*bsc i1 = r2/isc isc = r2 - i1*isc r0 = h1l*dble(r2) + asc*h1u*dble(isc) asc = 1.0d0/bsc isc = r0*asc r2 = r0 - dble(isc)*bsc r3 = r3 + (dble(isc) + 2.0d0*h1u*dble(i1)) isc = r3*asc r1 = r3 - dble(isc)*bsc randum = (dble(r1) + dble(r2)*asc)*asc return end
SUBROUTINE MRGINV C$$$ SUBPROGRAM DOCUMENTATION BLOCK C C SUBPROGRAM: MRGINV C PRGMMR: WOOLLEN ORG: NP20 DATE: 1996-10-09 C C ABSTRACT: THIS SUBROUTINE PRINTS A SUMMARY OF MERGE ACTIVITY. C C PROGRAM HISTORY LOG: C 1996-10-09 J. WOOLLEN -- ORIGINAL AUTHOR (ENTRY POINT IN INVMRG) C 2002-05-14 J. WOOLLEN -- CHANGED FROM AN ENTRY POINT TO INCREASE C PORTABILITY TO OTHER PLATFORMS C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE C INTERDEPENDENCIES C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED C DOCUMENTATION (INCLUDING HISTORY) C DART $Id$ C C USAGE: CALL MRGINV C C OUTPUT FILES: C UNIT 06 - STANDARD OUTPUT PRINT C C REMARKS: C THIS ROUTINE CALLS: None 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$$$ COMMON /MRGCOM/ NRPL,NMRG,NAMB,NTOT COMMON /QUIET / IPRT C----------------------------------------------------------------------- C----------------------------------------------------------------------- IF(IPRT.GE.0) THEN PRINT*,'+++++++++++++++++++++++BUFRLIB+++++++++++++++++++++++++' PRINT*,'-------------------------------------------------------' PRINT*,'INVENTORY FROM MERGE PROCESS IN BUFRLIB ROUTINE INVMRG ' PRINT*,'-------------------------------------------------------' PRINT*,'NUMBER OF DRB EXPANSIONS = ',NRPL PRINT*,'NUMBER OF MERGES = ',NMRG PRINT*,'NUMBER THAT ARE AMBIGUOUS = ',NAMB PRINT*,'-------------------------------------------------------' PRINT*,'TOTAL NUMBER OF VISITS = ',NTOT PRINT*,'-------------------------------------------------------' PRINT*,'+++++++++++++++++++++++BUFRLIB+++++++++++++++++++++++++' ENDIF RETURN END
PROGRAM LDGPS C----------------------------------------------------------------------- C! Loads GPS delay data from a text file C# Task Calibration VLA C----------------------------------------------------------------------- C; Copyright (C) 1996-1999, 2009 C; Associated Universities, Inc. Washington DC, USA. C; C; This program is free software; you can redistribute it and/or C; modify it under the terms of the GNU General Public License as C; published by the Free Software Foundation; either version 2 of C; the License, or (at your option) any later version. C; C; This program is distributed in the hope that it will be useful, C; but WITHOUT ANY WARRANTY; without even the implied warranty of C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the C; GNU General Public License for more details. C; C; You should have received a copy of the GNU General Public C; License along with this program; if not, write to the Free C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, C; MA 02139, USA. C; C; Correspondence concerning AIPS should be addressed as follows: C; Internet email: aipsmail@nrao.edu. C; Postal address: AIPS Project Office C; National Radio Astronomy Observatory C; 520 Edgemont Road C; Charlottesville, VA 22903-2475 USA C----------------------------------------------------------------------- C LDGPS reads GPS delay data from a CONAN-ASCII file, corrects it C for receiver and satellite time offsets and writes it to a GP C table for use by calibration programs. C----------------------------------------------------------------------- C C Local variables C INPUTS INPUTS object for access to adverbs C UVFILE UVDATA object for access to uv file C GPSTAB TABLE object for access to GP table C INFILE name of input file C DIEBUF scratch space for DIE subroutine C IRET status indicator C CHARACTER INPUTS*13 PARAMETER (INPUTS = 'Inputs object') CHARACTER UVFILE*14 PARAMETER (UVFILE = 'UV data object') CHARACTER GPSTAB*15 PARAMETER (GPSTAB = 'GP table object') CHARACTER INFILE*48 INTEGER DIEBUF(256), IRET C INCLUDE 'INCS:DDCH.INC' INCLUDE 'INCS:DFIL.INC' INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DMSG.INC' C----------------------------------------------------------------------- C C Read input adverbs C CALL SETUP (INPUTS, UVFILE, GPSTAB, INFILE, IRET) IF (IRET .NE. 0) GO TO 990 C C Read the data from the text file. C CALL RDFILE (INFILE, GPSTAB, UVFILE, IRET) IF (IRET .NE. 0) GO TO 990 C C Update the history file C CALL LGPHIS (INPUTS, GPSTAB, UVFILE, IRET) IF (IRET .NE. 0) GO TO 990 C 990 CALL DIE (IRET, DIEBUF) END SUBROUTINE SETUP (INPUTS, UVFILE, GPSTAB, INFILE, IRET) C----------------------------------------------------------------------- C Read the input adverbs. C C Inputs: C INPUTS C*(*) INPUTS object used to access adverbs C UVFILE C*(*) UVDATA object used to access uv data file C GPSTAB C*(*) TABLE object used to access GP table C C Outputs: C INFILE C*(*) Name of input ffile C IRET I Status code: C 0: input adverbs read C anything else: an error was detected C C Preconditions: C INPUTS is not blank C UVFILE is not blank C GPSTAB is not blank C C Postconditions C if IRET is 0 then: C INPUTS is initialized C UVFILE is initialized and corresponds to the INNAME, INCLASS, C INSEQ and INDISK adverbs C UVFILE is closed C GPSTAB is initialized and corresponds to UVFILE and the C OUTVERS adverb C GPSTAB is closed C INFILE has the value of the INFILE adverb C----------------------------------------------------------------------- CHARACTER INPUTS*(*), UVFILE*(*), GPSTAB*(*), INFILE*(*) INTEGER IRET C C Local variables C C PRGN Task name C NPARM Number of input adverbs C AVNAME Adverb names C AVTYPE Adverb types C AVDIM Adverb dimensions C OUTVER Value of OUTVERS keyword C TYPE AIPS object attribute type code C DIM AIPS object attribute dimensions C NKEYS Number of adverbs to copy to UVFILE C INKEY Adverbs to copy to UVFILE C OUTKEY UVFILE attributes to receive adverb values C CHARACTER PRGN*6 PARAMETER (PRGN = 'LDGPS ') INTEGER NPARM PARAMETER (NPARM = 6) CHARACTER AVNAME(NPARM)*8 INTEGER AVTYPE(NPARM), AVDIM(2, NPARM) INTEGER NKEYS PARAMETER (NKEYS = 4) CHARACTER INKEY(NKEYS)*8, OUTKEY(NKEYS)*16 INTEGER OUTVER, TYPE, DIM(3) CHARACTER CDUMMY INTEGER NDUMMY C INCLUDE 'INCS:PAOOF.INC' INCLUDE 'INCS:DMSG.INC' C DATA AVNAME / 'INNAME ', 'INCLASS ', 'INSEQ ', 'INDISK ', * 'INFILE ', 'OUTVERS ' / DATA AVTYPE / OOACAR, OOACAR, OOAINT, OOAINT, OOACAR, OOAINT / DATA AVDIM / 12,1, 6,1, 1,1, 1,1, 48,1, 1,1 / C DATA INKEY / 'INNAME ', 'INCLASS ', 'INSEQ ', 'INDISK ' / DATA OUTKEY / 'FILE_NAME.NAME ', 'FILE_NAME.CLASS ', * 'FILE_NAME.IMSEQ ', 'FILE_NAME.DISK ' / C----------------------------------------------------------------------- CALL AV2INP (PRGN, NPARM, AVNAME, AVTYPE, AVDIM, INPUTS, IRET) IF (IRET .NE. 0) GO TO 999 C C Initialize the UVDATA object: C CALL OUVCRE (UVFILE, IRET) IF (IRET .NE. 0) GO TO 999 CALL IN2OBJ (INPUTS, NKEYS, INKEY, OUTKEY, UVFILE, IRET) IF (IRET .NE. 0) GO TO 999 C C Initialize GPSTAB: C CALL INGET (INPUTS, 'OUTVERS', TYPE, DIM, OUTVER, CDUMMY, IRET) IF (IRET .NE. 0) GO TO 999 CALL UV2TAB (UVFILE, GPSTAB, 'GP', OUTVER, IRET) IF (IRET .NE. 0) GO TO 999 C C Read input file name and check for null string: C CALL INGET (INPUTS, 'INFILE', TYPE, DIM, NDUMMY, INFILE, IRET) IF (IRET .NE. 0) GO TO 999 IF (INFILE .EQ. ' ') THEN MSGTXT = 'YOU MUST SPECIFY AN INPUT FILE (INFILE)' CALL MSGWRT (9) IRET = 1 GO TO 999 END IF C 999 RETURN END SUBROUTINE LGPHIS (INPUTS, GPSTAB, UVFILE, IRET) C----------------------------------------------------------------------- C Update the history file for UVFILE. C C Inputs: C INPUTS C*(*) INPUTS object for access to adverbs C GPSTAB C*(*) TABLE object for access to GP table C UVFILE C*(*) UVDATA object for access to UV file C C Outputs: C IRET I Error code (0 => no error) C----------------------------------------------------------------------- CHARACTER INPUTS*(*), GPSTAB*(*), UVFILE*(*) INTEGER IRET C C Local variables: C C VERS Table version number C TYPE Attribute type code C DIM Attribute dimensions C MSG History file message buffer C NUMADV Number of adverbs (parameter) C AVNAME Adverb names C INTEGER VERS, TYPE, DIM(3), NUMADV PARAMETER (NUMADV = 6) CHARACTER MSG*72, AVNAME(NUMADV)*8, CDUMMY C INCLUDE 'INCS:PAOOF.INC' C DATA AVNAME / 'INNAME ', 'INCLASS ', 'INSEQ ', 'INDISK ', * 'INFILE ', 'OUTVERS ' / C----------------------------------------------------------------------- C C Open and close the uv file to establish the mapping between the C UVDATA object and the disk file C CALL OUVOPN (UVFILE, 'READ', IRET) IF (IRET .NE. 0) GO TO 999 CALL OUVCLO (UVFILE, IRET) IF (IRET .NE. 0) GO TO 999 C CALL OHTIME (UVFILE, IRET) IF (IRET .NE. 0) GO TO 999 CALL OHLIST (INPUTS, AVNAME, NUMADV, UVFILE, IRET) IF (IRET .NE. 0) GO TO 999 C C Write a comment giving the actual output table version number C if the default version was used C CALL INGET (INPUTS, 'OUTVERS', TYPE, DIM, VERS, CDUMMY, IRET) IF (IRET .NE. 0) GO TO 999 IF (VERS .LE. 0) THEN CALL TABGET (GPSTAB, 'VER', TYPE, DIM, VERS, CDUMMY, IRET) IF (IRET .NE. 0) GO TO 999 WRITE (MSG, 1000) VERS CALL OHWRIT (MSG, UVFILE, IRET) IF (IRET .NE. 0) GO TO 999 END IF C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('/ Wrote GP table version ', I4) END SUBROUTINE RDFILE (INFILE, GPSTAB, UVFILE, IRET) C----------------------------------------------------------------------- C Read GPS data from INFILE and write it to GPSTAB. C C Inputs: C INFILE C*(*) Name of input file C GPSTAB C*(*) Name of TABLE object used to access the GP C table C UVFILE C*(*) Name of UVDATA object used to access the C parent data file of the GP table C C Output: C IRET I Status code C 0: data written to table successfully C anything else: an error was detected C C Preconditions: C INFILE is not blank C GPSTAB is not blank C UVFILE is not blank C GPSTAB is not the same as UVFILE C The UVDATA object with name UVFILE is initialized C The TABLE object with name GPSTAB is initialized and closed. C C Postconditions: C IRET = 0 implies that C Data in INFILE has been written to the table object with C name GPSTAB C The table object with name GPSTAB is closed. C----------------------------------------------------------------------- CHARACTER INFILE*(*), GPSTAB*(*), UVFILE*(*) INTEGER IRET C C Local variables: C C TXTLUN LUN for text file C TXTIND FTAB index for text file C C TXTEOF Has the end of the text file been reached? C C MAXPRN Maximum satellite PRN C SATOFF Satellite offsets in TECU indexed by PRN C OFFINI Have satellite offsets been initialized? C C IRET2 Temporary status code C INTEGER TXTLUN, TXTIND PARAMETER (TXTLUN = 10) C LOGICAL TXTEOF C INTEGER MAXPRN PARAMETER (MAXPRN = 32) REAL SATOFF(MAXPRN) LOGICAL OFFINI C INTEGER IRET2 C INCLUDE 'INCS:DMSG.INC' C DATA SATOFF / MAXPRN * 0.0 / C----------------------------------------------------------------------- CALL ZTXOPN ('READ', TXTLUN, TXTIND, INFILE, .FALSE., IRET) IF (IRET .EQ. 0) THEN TXTEOF = .FALSE. OFFINI = .FALSE. C C Loop invariant 1: OFFINI implies that a satellite bias record C occurred in the set of records already C processed C Loop invariant 2: OFFINI implies that SATOFF contains the C biases from the last satellite bias record C before the current point in the input text C file C Loop invariant 3: All data occurring in records before the C current point in the input text file have C been transferred to GPSTAB C Bound: The number of after the current point in the file C 10 IF ((IRET .EQ. 0) .AND. (.NOT. TXTEOF)) THEN CALL PRRECD (TXTLUN, TXTIND, GPSTAB, UVFILE, SATOFF, * OFFINI, TXTEOF, IRET) GO TO 10 END IF CALL ZTXCLS (TXTLUN, TXTIND, IRET2) IF (IRET2 .NE. 0) THEN MSGTXT = 'FAILED TO CLOSE ' // INFILE CALL MSGWRT (8) IRET = 1 END IF ELSE MSGTXT = 'FAILED TO OPEN ' // INFILE CALL MSGWRT (8) IRET = 1 END IF END SUBROUTINE PRRECD (TXTLUN, TXTIND, GPSTAB, UVFILE, SATOFF, OFFINI, * TXTEOF, IRET) C----------------------------------------------------------------------- C Process the next record from the text file open for reading on C TXTLUN with FTAB index TXTIND. C C Inputs: C TXTLUN I LUN of text file C TXTIND I FTAB index of text file C GPSTAB C*(*) Name of TABLE object used to access GP table C UVFILE C*(*) Name of UVDATA object used to access data file C C Input/ouput: C SATOFF R(*) List of satellite biases in TEC units indexed C by PRN C OFFINI L Has SATOFF been initialized? C C Output: C TXTEOF L Has the text file been exhausted? C IRET I Status code: C 0 - record processed or no records left C 1 - syntax error in input file C 2 - receiver changed in input file C 3 - data encountered without satellite biases C 4 - error reading input file C 5 - error writing table C C Preconditions: C TXTLUN and TXTIND refer to an open text file C GPSTAB is not blank and refers to a TABLE object C UVFILE is not blank and refers to a UVDATA object C The UVDATA object with name UVFILE encapsulates the parent data C file of the table encapsulated by GPSTAB. C The TABLE object with name GPSTAB is closed. C C Postconditions: C If there were no records left to read in the input file then C IRET = 0 and TXTEOF is true C If the next record was a satellite offset record then IRET = 0 C implies that SATOFF has been updated and OFFINI is true C If the next record was a data header than IRET = 0 implies that C the data following the header have been transferred to GPSTAB C GPSTAB is closed. C----------------------------------------------------------------------- INTEGER TXTLUN, TXTIND CHARACTER GPSTAB*(*), UVFILE*(*) REAL SATOFF(*) LOGICAL OFFINI, TXTEOF INTEGER IRET C C Local variables: C C MAXPRN Maximum GPS PRN C C NUMVAL Maximum number of values that can be returned by KEYIN C KEYS Keyword list for KEYIN C VALUES Numeric values from KEYIN C VALCHR Character values from KEYIN C NPARM Number of KEYIN parameters C ENDMRK End-of-record marker for KEYIN C INTEGER MAXPRN PARAMETER (MAXPRN = 32) C INTEGER NUMVAL PARAMETER (NUMVAL = 9 + MAXPRN - 1) CHARACTER KEYS(NUMVAL)*8 DOUBLE PRECISION VALUES(NUMVAL) CHARACTER VALCHR(NUMVAL)*8 INTEGER NPARM CHARACTER ENDMRK*8 PARAMETER (ENDMRK = '/ ') C INCLUDE 'INCS:DMSG.INC' C DATA KEYS / 'GPS ', 'GPSDATA ', 'TECU ', 'NANOSEC ', * 'RECEIVER', 'X ', 'Y ', 'Z ', * MAXPRN * 'BIAS ' / C----------------------------------------------------------------------- C C Initialize VALUES to a non-zero value since KEYIN will set the C entries for keywords that it finds that do not have explicit C values to zero: C CALL DFILL (NUMVAL, -9999.9D0, VALUES) C C Set receiver name to blank so we can tell if has been set by C KEYIN: C VALCHR(5) = ' ' C NPARM = NUMVAL CALL KEYIN (KEYS, VALUES, VALCHR, NPARM, ENDMRK, 0, TXTLUN, * TXTIND, IRET) IF (IRET .EQ. 0) THEN IF ((VALUES(1) .NE. -9999.9D0) * .AND. (VALUES(2) .EQ. -9999.9D0)) THEN C C The record was a satellite bias record so extract the C biases: C CALL PRBIAS (VALUES, SATOFF, OFFINI, IRET) C C If IRET is non-zero then it already has the correct C value. C ELSE IF ((VALUES(1) .EQ. -9999.9D0) * .AND. (VALUES(2) .NE. -9999.9D0)) THEN C C The record was a data header so process the data block that C follows it: C IF (OFFINI) THEN CALL PRDATA (TXTLUN, TXTIND, VALUES, VALCHR, GPSTAB, * UVFILE, SATOFF, IRET) C C Error codes 0, 4, and 5 are returned unchanged. C IF ((IRET .EQ. 1) .OR. (IRET .EQ. 2)) THEN IRET = 1 ELSE IF (IRET .EQ. 3) THEN IRET = 2 END IF ELSE MSGTXT = 'DATA MUST BE PRECEDED BY A SATELLITE BIAS ' * // 'RECORD' CALL MSGWRT (8) IRET = 3 END IF ELSE IF ((VALUES(1) .EQ. -9999.9D0) * .AND. (VALUES(2) .EQ. -9999.9D0)) THEN MSGTXT = 'INVALID RECORD FOUND: NEITHER GPS NOR GPSDATA' CALL MSGWRT (8) IRET = 1 ELSE MSGTXT = 'INVALID RECORD FOUND: BOTH GPS AND GPSDATA' CALL MSGWRT (8) IRET = 1 END IF ELSE IF (IRET .EQ. 1) THEN C C Reached the end of the text file. Note this and clear status: C TXTEOF = .TRUE. IRET = 0 ELSE WRITE (MSGTXT, 9000) IRET CALL MSGWRT (8) IRET = 4 END IF C----------------------------------------------------------------------- 9000 FORMAT ('ERROR ', I6, ' READING INPUT FILE') END SUBROUTINE PRBIAS (VALUES, SATOFF, OFFINI, IRET) C----------------------------------------------------------------------- C Process a satellite bias record. C C Input: C VALUES D(*) Values from KEYIN C C Output: C SATOFF R(*) Satellite biases in TEC units, indexed by PRN C OFFINI L Has SATOFF been initialized? C IRET I Status code: C 0 - biases updated C 1 - invalid record C C Preconditions: C VALUES has been set by KEYIN from a satellite bias record C C Postconditions: C IRET = 0 implies that OFFINI is true and SATOFF has been updated C----------------------------------------------------------------------- DOUBLE PRECISION VALUES(*) REAL SATOFF(*) LOGICAL OFFINI INTEGER IRET C C Local variables C C SCALE Nanoseconds of delay between L1 and L2 for 1 TECU C FACTOR Factor to scale values to TECU C C MAXPRN Maximum satellite PRN C BIAS Index of first bias in VALUES C TECU Index of TECU in VALUES C NANOS Index of NANOSEC in VALUES C SET Have any bias values been set? C I Loop counter C REAL SCALE PARAMETER (SCALE = 2.854) REAL FACTOR C INTEGER MAXPRN, BIAS, TECU, NANOS PARAMETER (MAXPRN = 32) PARAMETER (BIAS = 9) PARAMETER (TECU = 3) PARAMETER (NANOS = 4) LOGICAL SET INTEGER I C INCLUDE 'INCS:DMSG.INC' C----------------------------------------------------------------------- SET = .TRUE. C C Loop invariant: SET is equivalent to VALUES(BIAS + j) not being C equal to -9999.9D0 (the marker for missing values) C for all j, 0 <= j < I C DO 10 I = 0, MAXPRN - 1 IF (VALUES(BIAS + I) .EQ. -9999.9D0) THEN SET = .FALSE. END IF 10 CONTINUE C C SET implies that there is a new set of biases. C IF (SET) THEN C C Find the units: C IF ((VALUES(TECU) .EQ. -9999.9D0) * .OR. (VALUES(NANOS) .EQ. -9999.9D0)) THEN IF (VALUES(TECU) .EQ. -9999.9D0) THEN FACTOR = SCALE ELSE FACTOR = 1.0 END IF C C Copy the bias values to SATOFF: C DO 20 I = 0, MAXPRN - 1 SATOFF(I + 1) = FACTOR * VALUES(BIAS + I) 20 CONTINUE OFFINI = .TRUE. ELSE MSGTXT = 'INVALID BIAS RECORD FOUND: AMBIGUOUS UNITS' CALL MSGWRT (8) IRET = 1 END IF ELSE MSGTXT = 'INVALID BIAS RECORD FOUND: SOME BIASES MISSING' CALL MSGWRT (8) IRET = 1 END IF C END SUBROUTINE PRDATA (TXTLUN, TXTIND, VALUES, VALCHR, GPSTAB, UVFILE, * SATOFF, IRET) C----------------------------------------------------------------------- C Process a data block. C C Inputs: C TXTLUN I LUN of text file C TXTIND I FTAB index of text file C VALUES D(*) Values array from KEYIN C VALCHR C(*)*8 Character value array from KEYIN C GPSTAB C*(*) Name of TABLE object used to access GP table C UVFILE C*(*) Name of UVDATA object used to access parent C file of GPSTAB C SATOFF R(*) Satellite biases in TEC units, indexed by PRN C C Output: C IRET I Status code: C 0 - data transferred to table C 1 - data incomplete C 2 - data block too large C 3 - receiver changed C 4 - error reading text file C 5 - error writing table C C Preconditions: C TXTLUN and TXTIND refer to an open text file positioned after C a data header record C VALUES has been set by KEYIN from the data header record C immediately preceding the current position of the text file C GPSTAB is not blank and refers to a TABLE object C GPSTAB is closed C UVFILE is not blank and refers to a UVDATA object associated C with the parent file of GPSDATA C C Postconditions: C IRET = 0 implies that the data following the header has been C transferred to GPSTAB and the text file is positioned at C the next record C GPSTAB is closed C----------------------------------------------------------------------- INTEGER TXTLUN, TXTIND DOUBLE PRECISION VALUES(*) CHARACTER VALCHR(*)*8, GPSTAB*(*), UVFILE*(*) REAL SATOFF(*) INTEGER IRET C C Local variables: C C IRCVR Index of receiver name in VALCHR C IX Index of X coordinate in VALUES C IY Index of Y coordinate in VALUES C IZ Index of Z coordinate in VALUES C IBIAS Index of bias in VALUES C INANOS Index of NANOSEC keyword in VALUES C ITECU Index of TECU keyword in VALUES C C SCALE Nanoseconds of delay between L1 and L2 for 1 TECU C FACTOR Factor to scale values to TECU C C BIAS Receiver bias in TEC units C C LAT Receiver latitude in degrees C LON Receiver longitude in degrees C HT Receiver height in metres C R Distance of antenna from coordinate origin C RE Mean radius of the Earth in metres C C TRCVR Receiver name in table C TLON Receiver longitude in table in degrees C TLAT Reciever latitude in table in degrees C THT Receiver height in table C GPROW New row to read or write in table C C MAXENT Maximum number of entries in data block C ENTRY Entries in data block C NVAL Number of values in data block C ENDMRK End marker for data block C KEYS Dummy keyword list C C POSERR Maximum error in latitude or longitude in degrees C HTERR Maximum error in height in metres C C IRET2 Temporary return status C INTEGER IRCVR, IX, IY, IZ, IBIAS, INANOS, ITECU PARAMETER (IRCVR = 5) PARAMETER (IX = 6) PARAMETER (IY = 7) PARAMETER (IZ = 8) PARAMETER (IBIAS = 9) PARAMETER (INANOS = 4) PARAMETER (ITECU = 3) C REAL SCALE PARAMETER (SCALE = 2.854) REAL FACTOR C REAL BIAS C DOUBLE PRECISION LAT, LON, HT, R, RE PARAMETER (RE = 6371000.0) C CHARACTER TRCVR*8 REAL TLAT, TLON, THT INTEGER GPROW C INTEGER MAXENT PARAMETER (MAXENT = 36000) DOUBLE PRECISION ENTRY(8 * MAXENT) INTEGER NVAL CHARACTER ENDMRK*8, KEYS(1)*8 PARAMETER (ENDMRK = '/ ') C REAL POSERR, HTERR C Allowable position change is 5 C seconds in lat or long PARAMETER (POSERR = 5.0 / 3600.0) C Allowable height change is 10 C metres PARAMETER (HTERR = 10.0) C INTEGER IRET2 C INCLUDE 'INCS:PSTD.INC' INCLUDE 'INCS:DMSG.INC' C----------------------------------------------------------------------- C C Process data block only if all required values are present in the C header: C IF ((VALCHR(IRCVR) .NE. ' ') * .AND. (VALUES(IX) .NE. -9999.9D0) * .AND. (VALUES(IY) .NE. -9999.9D0) * .AND. (VALUES(IZ) .NE. -9999.9D0) * .AND. (VALUES(IBIAS) .NE. -9999.9D0) * .AND. ((VALUES(INANOS) .EQ. -9999.9D0) * .OR. (VALUES(ITECU) .EQ. -9999.9D0))) THEN C C Find bias units: C IF (VALUES(ITECU) .EQ. -9999.9D0) THEN FACTOR = SCALE ELSE FACTOR = 1.0 END IF C BIAS = FACTOR * VALUES(IBIAS) C C Convert geocentric coordinates to latitude, longitude, and C height (it should be enough to assume a spherical Earth): C R = SQRT (VALUES(IX) ** 2 + VALUES(IY) ** 2 + VALUES(IZ) ** 2) HT = R - RE LAT = RAD2DG * ASIN (VALUES(IZ) / R) IF (VALUES(IX) .NE. 0.0D0) THEN LON = RAD2DG * ATAN2 (VALUES(IY), VALUES(IX)) ELSE IF (VALUES(IY) .GT. 0.0D0) THEN LON = +90.0D0 ELSE LON = -90.0D0 END IF C C Copy receiver information so that the values returned by OGPINI C can be compared with those read from the file: C TRCVR = VALCHR(IRCVR) TLAT = LAT TLON = LON THT = HT C CALL OGPINI (GPSTAB, 'WRIT', GPROW, TRCVR, TLON, TLAT, THT, * IRET) IF (IRET .EQ. 0) THEN IF ((TRCVR .EQ. VALCHR(IRCVR)) * .AND. (ABS (TLON - LON) .LE. POSERR) * .AND. (ABS (TLAT - LAT) .LE. POSERR) * .AND. (ABS (THT - HT) .LE. HTERR)) THEN C C Reciever has not changed so read the data: C NVAL = 8 * MAXENT CALL KEYIN (KEYS, ENTRY, VALCHR, NVAL, ENDMRK, 3, TXTLUN, * TXTIND, IRET) IF (IRET .EQ. 0) THEN IF ((NVAL .LE. 8 * MAXENT) * .AND. (MOD (NVAL, 8) .EQ. 0)) THEN CALL CPYDAT (ENTRY, NVAL / 8, BIAS, SATOFF, * UVFILE, GPSTAB, GPROW, IRET) IF (IRET .NE. 0) THEN MSGTXT = 'FAILED TO UPDATE OUTPUT TABLE' CALL MSGWRT (8) IRET = 5 END IF ELSE IF (NVAL .GT. 8 * MAXENT) THEN WRITE (MSGTXT, 9000) MAXENT CALL MSGWRT (8) IRET = 2 ELSE MSGTXT = 'DATA BLOCK CONTAINS AN INCOMPLETE ENTRY' CALL MSGWRT (8) IRET = 1 END IF ELSE IF (IRET .EQ. 1) THEN MSGTXT = 'DATA BLOCK MISSING AT END OF FILE' CALL MSGWRT (8) IRET = 1 ELSE WRITE (MSGTXT, 9001) IRET CALL MSGWRT (8) IRET = 4 END IF ELSE MSGTXT = 'CAN NOT HANDLE MORE THAN ONE RECEIVER' CALL MSGWRT (8) WRITE (MSGTXT, 9002) 'RECEIVER WAS', TRCVR, TLAT, TLON, * THT CALL MSGWRT (8) WRITE (MSGTXT, 9002) 'RECEIVER NOW', VALCHR(IRCVR), LAT, * LON, HT CALL MSGWRT (8) IRET = 3 END IF CALL TABCLO (GPSTAB, IRET2) IF (IRET2 .NE. 0) THEN MSGTXT = 'FAILED TO CLOSE OUTPUT TABLE' CALL MSGWRT (8) IRET = 5 END IF ELSE MSGTXT = 'FAILED TO OPEN OUTPUT TABLE FOR WRITING' CALL MSGWRT (8) IRET = 5 END IF ELSE IF (VALCHR(IRCVR) .EQ. ' ') THEN MSGTXT = 'INVALID DATA HEADER: RECEIVER NAME MISSING' CALL MSGWRT (8) IRET = 1 ELSE IF (VALUES(IX) .EQ. -9999.9D0) THEN MSGTXT = 'INVALID DATA HEADER: X COORDINATE MISSING' CALL MSGWRT (8) IRET = 1 ELSE IF (VALUES(IY) .EQ. -9999.9D0) THEN MSGTXT = 'INVALID DATA HEADER: Y COORDINATE MISSING' CALL MSGWRT (8) IRET = 1 ELSE IF (VALUES(IZ) .EQ. -9999.9D0) THEN MSGTXT = 'INVALID DATA HEADER: Z COORDINATE MISSING' CALL MSGWRT (8) IRET = 1 ELSE IF (VALUES(IBIAS) .EQ. -9999.9D0) THEN MSGTXT = 'INVALID DATA HEADER: RECEIVER BIAS MISSING' CALL MSGWRT (8) IRET = 1 ELSE MSGTXT = 'INVALID DATA HEADER: AMBIGUOUS BIAS UNITS' CALL MSGWRT (8) IRET = 1 END IF C----------------------------------------------------------------------- 9000 FORMAT ('DATA BLOCK TOO LONG: LIMIT ', I7, ' ENTRIES') 9001 FORMAT ('ERROR ', I3, ' READING FROM TEXT FILE') 9002 FORMAT (A12, ': ', A8, ' LT = ', F7.2, ' LN = ', F7.2, ' HT = ', * F7.1) END SUBROUTINE CPYDAT (VALUES, NENTRY, BIAS, SATOFF, UVFILE, GPSTAB, * GPROW, IRET) C----------------------------------------------------------------------- C Translate data entries in VALUES and add them to GPSTAB starting at C row GPROW. C C Inputs: C VALUES D(8, *) Data entries -- first index is C 1 year number C 2 day of year C 3 time of observation (UTC hour) C 4 satellite PRN C 5 satellite azimuth in degrees C 6 satellite elevation in degrees C 7 TEC from phase difference in TEC units C 8 TEC from delay difference in TEC units C NENTRY I Number of data entries C BIAS R Receiver bias in TEC units C SATOFF R(*) List of satellite offsets in TEC units indexed C by PRN C UVFILE C*(*) Name of UVDATA object used to access data file C GPSTAB C*(*) Name of TABLE object used to access output C table C C Input/Output: C GPROW I Next row to write in table C C Output: C IRET I Status code: C 0 - data written to table C 1 - error writing to table C 2 - other error C C Preconditions: C UVFILE is not blank and is the name of a UVDATA object C GPSTAB is not blank and is the name of a TABLE object C GPSTAB is open for writing C GPSTAB is attached to UVFILE C GPROW > 0 C NENTRY >= 0 C VALUES has been populated from a GPS data block by KEYIN C C Postconditions: C The data have been written to GPSTAB C----------------------------------------------------------------------- DOUBLE PRECISION VALUES(8, *) INTEGER NENTRY REAL BIAS, SATOFF(*) CHARACTER UVFILE*(*), GPSTAB*(*) INTEGER GPROW, ITEMP, IRET C C Local variables: C C RTIME Julian date of file reference time C ETIME Julian date of measurement C C ANTAB TABLE object used to access AN table C ANVER Antenna table version C ANROW Next antenna table row to read (ignored) C ARRAYC Coordinates of array centre (ignored) C GSTIA0 GST at 00:00:00 IAT on reference date (ignored) C DEGPDY Rotational rate of the Earth (ignored) C SAFREQ Subarray frequency offset (ignored) C OBSDAT Observing date C POLRXY Coordinates of North pole (ignored) C UT1UTC UT1 - UTC (ignored) C DATUTC Data time - UTC in seconds C TIMSYS Time system (ignored) C ANAME Array name (ignored) C NUMORB Number of orbital parameters (ignored) C NOPCAL Number of polarization parameters (ignored) C ANFQID Frequency ID (ignored) C C ENTRY Number of entries processed so far C IT Broken down time (year, month, day, hour, min, sec) C PRN Current PRN C C HRSPDY Number of UTC hours in a day C SECPDY Number of UTC seconds in a day C DOUBLE PRECISION RTIME, ETIME C CHARACTER ANTAB*15 PARAMETER (ANTAB = 'AN table object') INTEGER ANVER, ANROW DOUBLE PRECISION ARRAYC(3), GSTIA0, DEGPDY, SAFREQ CHARACTER OBSDAT*8 REAL POLRXY(2), UT1UTC, DATUTC CHARACTER TIMSYS*8, ANAME*8 INTEGER NUMORB, NOPCAL, ANFQID C INTEGER ENTRY, IT(6), PRN C REAL HRSPDY, SECPDY PARAMETER (HRSPDY = 24.0) PARAMETER (SECPDY = HRSPDY * 60.0 * 60.0) C INCLUDE 'INCS:DMSG.INC' C----------------------------------------------------------------------- C C Extract reference time from antenna table 1 C ANVER = 1 CALL UV2TAB (UVFILE, ANTAB, 'AN', ANVER, IRET) IF (IRET .EQ. 0) THEN CALL OANINI (ANTAB, 'READ', ANROW, ARRAYC, GSTIA0, DEGPDY, * SAFREQ, OBSDAT, POLRXY, UT1UTC, DATUTC, TIMSYS, ANAME, * NUMORB, NOPCAL, ITEMP, ANFQID, IRET) IF (IRET .EQ. 0) THEN CALL TABCLO (ANTAB, IRET) IF (IRET .EQ. 0) THEN CALL TABDES (ANTAB, IRET) IF (IRET .EQ. 0) THEN CALL JULDAY (OBSDAT, RTIME) C C Shift to UTC: C RTIME = RTIME - DATUTC / SECPDY ENTRY = 0 C C Transfer entries to output table: C C Loop invariant: IRET == 0 implies that the first ENTRY C entries in values have been copied to C GPSTAB C Bound: NENTRY - ENTRY C 10 IF ((IRET .EQ. 0) .AND. (ENTRY .NE. NENTRY)) THEN ENTRY = ENTRY + 1 C C Convert time to Julian date to find offset from C reference time: C CALL FILL (6, 0, IT) IT(1) = NINT (VALUES(1, ENTRY)) IT(2) = 1 CALL DAT2JD (IT, ETIME) ETIME = ETIME + VALUES(2, ENTRY) * + VALUES(3, ENTRY) / HRSPDY C PRN = NINT (VALUES(4, ENTRY)) CALL OTABGP (GPSTAB, 'WRIT', GPROW, ETIME - RTIME, * PRN, * REAL (VALUES(5, ENTRY)), * REAL (VALUES(6, ENTRY)), * 1.0E16 * REAL (VALUES(8, ENTRY) * - (BIAS + SATOFF(PRN))), * 1.0E16 * REAL (VALUES(7, ENTRY)) * - (BIAS + SATOFF(PRN)), IRET) IF (IRET .NE. 0) THEN WRITE (MSGTXT, 9010) IRET CALL MSGWRT (8) IRET = 1 END IF GO TO 10 END IF ELSE MSGTXT = 'FAILED TO RECYCLE TEMPORARY TABLE OBJECT' CALL MSGWRT (8) IRET = 2 END IF ELSE MSGTXT = 'FAILED TO CLOSE ANTENNA TABLE' CALL MSGWRT (8) IRET = 2 END IF ELSE MSGTXT = 'FAILED TO READ REFERENCE DATE FROM AN TABLE 1' CALL MSGWRT (8) IRET = 2 END IF ELSE MSGTXT = 'FAILED TO CREATE TEMPORARY TABLE OBJECT' CALL MSGWRT (8) IRET = 2 END IF C----------------------------------------------------------------------- 9010 FORMAT ('ERROR ', I3, ' WRITING OUPUT TABLE') END
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 CSA2LXS (NI,XI,UI,WTS,KNOTS,SSMTH,NDERIV,NO,XO,YO,UO, + NWRK,WORK,IER) C DIMENSION XI(2,NI),UI(NI),WTS(*),KNOTS(2),XO(NO),YO(NO), + UO(NO),WORK(NWRK),NDERIV(2) DIMENSION XMN(2),XMX(2),XV(2) C C Check on the number of knots. C NTOT = KNOTS(1)*KNOTS(2) C DO 20 I=1,2 IF (KNOTS(I) .LT. 4) THEN CALL CFAERR (202,' CSA2LXS - must have at least four knots in +every coordinate direction',70) IER = 202 RETURN ENDIF 20 CONTINUE C C Check on the size of the workspace. C IF (NWRK .LT. NTOT*(NTOT+3)) THEN CALL CFAERR (203,' CSA2LXS - workspace too small',30) IER = 203 RETURN ENDIF C C Calculate the min and max for the knots as the minimum value of C the input data and output data and the maximum of the input and C output data. C DO 30 J=1,2 XMN(J) = XI(J,1) XMX(J) = XI(J,1) DO 10 I=2,NI XMN(J) = MIN(XMN(J),XI(J,I)) XMX(J) = MAX(XMX(J),XI(J,I)) 10 CONTINUE 30 CONTINUE C DO 35 I=1,NO XMN(1) = MIN(XMN(1),XO(I)) XMX(1) = MAX(XMX(1),XO(I)) XMN(2) = MIN(XMN(2),YO(I)) XMX(2) = MAX(XMX(2),YO(I)) 35 CONTINUE C C Find the coefficients. C CALL SPLCW(2,XI,2,UI,WTS,NI,XMN,XMX,KNOTS,SSMTH,WORK,NTOT, + WORK(NTOT+1),NWRK-NTOT,IERR) IF (IERR .NE. 0) RETURN C C Calculate the approximated values (coefficients are stored at C the beginnig of WORK). C DO 60 I=1,NO XV(1) = XO(I) XV(2) = YO(I) UO(I) = SPLDE(2,XV,NDERIV,WORK,XMN,XMX,KNOTS,IER) IF (IERR .NE. 0) RETURN 60 CONTINUE C RETURN END
SUBROUTINE DO_COMMAND(X,Y,HEIGHT,ANGLE,COMM,LENT,IDCNT,IUCNT & ,JUSTIFY,PLEN,COSX,SINX,CLASSES,FONT,LENFONT & ,HITMAX,*) C modified by J.Chuma 20Mar97 for g77 C CHARACTER COMM*(*), COMM2*255, COMM1*1, CTRL*2,FONT*60,FONT2*14 & ,GETLAB*2, CHARL*2, HEXCODE*2 INTEGER*4 NHATCH(2) integer*2 CLASSES(0:127) LOGICAL FIRST, JUSTIFY, DEFAULTS BYTE ACHARI C COMMON /PLOT_LEVEL/ ILEV C LOGICAL ASIS, ASIS_OLD COMMON /MODE/ ASIS C INTEGER*4 COLOURS(0:11,0:20) COMMON /GPLOT_COLOURS/ COLOURS, ICOL COMMON /PLOT_COLOURS/ ICOLR1, ICOLR2 C LOGICAL BOLD COMMON /GPLOT_BOLDING/ BOLD C LOGICAL ITALICS COMMON /GPLOT_PSALPH/ ITALICS, ANGL, ANGL_OLD C COMMON /PLOT_OUTPUT_UNIT/ IOUTS COMMON /PSYM_HATCHING/ NHATCH COMMON /GPLOT_CONTROLS/ CTRL COMMON /GPLOT_TEXT/ DEFAULTS COMMON /PLOTMONITOR/ IMONITOR, IOUTM COMMON /PLOTMONITOR2/ IMONITOR2, IOUTM2 C Modified by J.L.Chuma, 08-Apr-1997 to elimate SIND, COSD for g77 REAL*4 DTOR /0.017453292519943/ C DATA DH / 0.6 / DATA FIRST / .TRUE. / DATA LTRS_OLD / -32768 / LENFONT = ABS(LENFONT) YLWIND = GETNAM('YLWIND') YUWIND = GETNAM('YUWIND') XLWIND = GETNAM('XLWIND') XUWIND = GETNAM('XUWIND') I1 = 1 2 IND = INDEX(COMM(I1:LENT),',') IF( IND .GT. 0 )THEN LEN = IND - 1 ELSE LEN = LENT - I1 + 1 END IF I2 = I1 + LEN - 1 C C First check to see if the command is a special name C CALL UPRCASE(COMM(I1:I2),COMM2(1:LEN)) COMM1 = COMM2(1:1) CALL NAME_IN_HEXCODE(COMM(I1:I2),HEXCODE,FONT2,LF) IF(HEXCODE .NE. ' ')THEN ASIS_OLD = ASIS IF( FONT2(1:LF) .NE. FONT(1:LENFONT) ) & CALL PFONT(FONT2(1:LF),0) ASIS = .TRUE. CALL GLINE_SUB(HEXCODE,2,JUSTIFY,PLEN,X,Y,HEIGHT,ANGLE) ASIS = ASIS_OLD IF( FONT2(1:LF) .NE. FONT(1:LENFONT) ) & CALL PFONT(FONT(1:LENFONT),0) GO TO 10 END IF IF( INDEX(COMM2(1:LEN),'DEF') .EQ. 1 )THEN DEFAULTS = .TRUE. ELSE IF( INDEX(COMM2(1:LEN),'NOD') .EQ. 1 )THEN DEFAULTS = .FALSE. ELSE IF( COMM1 .EQ. 'X' )THEN C C Hexadecimal input flag C ASIS = .NOT. ASIS ELSE IF( (COMM1 .EQ. 'I') .OR. (COMM2(1:LEN) .EQ. 'EM') )THEN C C Italics flag C IF( ITALICS )THEN ITALICS = .FALSE. ANGL = ANGL_OLD ELSE ITALICS = .TRUE. ANGL = 20.0 END IF CALL PSALPH('ANGL',ANGL,IDUMMY,*30) ELSE IF(COMM1 .EQ. 'F')THEN C C Set the font C FONT(1:LEN-1) = COMM2(2:LEN) LENFONT = LEN - 1 CALL PFONT(FONT(1:LENFONT),0) CALL PSALPH('ANGL',ANGL,IDUMMY,*30) ELSE IF(COMM1 .EQ. 'H')THEN C C Set the height C IF( COMM2(LEN:LEN) .EQ. '%' )THEN #ifdef g77 CALL CHREAL(COMM2(2:LEN-1),LEN-2,XHEIGHT,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN-1)),LEN-2,XHEIGHT,1,*20) #endif HEIGHT = XHEIGHT * (YUWIND - YLWIND) / 100. ELSE #ifdef g77 CALL CHREAL(COMM2(2:LEN),LEN-1,XHEIGHT,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN)),LEN-1,XHEIGHT,1,*20) #endif HEIGHT = XHEIGHT END IF IF( HEIGHT .GT. HITMAX )HITMAX = HEIGHT ELSE IF(COMM1 .EQ. 'B')THEN C C Bolding flag C IF( JUSTIFY )GO TO 10 IF(LEN .LT. 2)THEN BOLD = .FALSE. NHATCH(1) = 0 NHATCH(2) = 0 ELSE BOLD = .TRUE. INDX = INDEX(COMM2(2:LEN),':') IF(INDX .GT. 0)THEN LENB = INDX #ifdef g77 CALL CHREAL(COMM2(INDX+2:LEN),LEN-INDX-1,XBOLD,1,*20) #else CALL CHREAL(%REF(COMM2(INDX+2:LEN)),LEN-INDX-1,XBOLD,1,*20) #endif NHATCH(2) = IFIX(XBOLD) ELSE NHATCH(2) = 0 LENB = LEN END IF #ifdef g77 CALL CHREAL(COMM2(2:LENB),LENB-1,XBOLD,1,*20) #else CALL CHREAL(%REF(COMM2(2:LENB)),LENB-1,XBOLD,1,*20) #endif NHATCH(1) = IFIX(XBOLD) END IF ELSE IF(COMM1 .EQ. 'Z')THEN C C Include a horizontal space C IF( COMM2(LEN:LEN) .EQ. '%' )THEN #ifdef g77 CALL CHREAL(COMM2(2:LEN-1),LEN-2,HORIZ_SPACE,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN-1)),LEN-2,HORIZ_SPACE,1,*20) #endif HORIZ_SPACE = HORIZ_SPACE * (XUWIND - XLWIND) / 100. ELSE #ifdef g77 CALL CHREAL(COMM2(2:LEN),LEN-1,HORIZ_SPACE,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN)),LEN-1,HORIZ_SPACE,1,*20) #endif END IF X = X + COSX*HORIZ_SPACE Y = Y + SINX*HORIZ_SPACE IF( JUSTIFY )PLEN = PLEN + HORIZ_SPACE ELSE IF(COMM1 .EQ. 'V')THEN C C Include a vertical space C IF( COMM2(LEN:LEN) .EQ. '%' )THEN #ifdef g77 CALL CHREAL(COMM2(2:LEN-1),LEN-2,VERT_SPACE,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN-1)),LEN-2,VERT_SPACE,1,*20) #endif VERT_SPACE = VERT_SPACE * (YUWIND - YLWIND) / 100. ELSE #ifdef g77 CALL CHREAL(COMM2(2:LEN),LEN-1,VERT_SPACE,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN)),LEN-1,VERT_SPACE,1,*20) #endif END IF X = X - SINX*VERT_SPACE Y = Y + COSX*VERT_SPACE ELSE IF( (COMM1 .EQ. 'U') .OR. (COMM1 .EQ. '^') )THEN C C Super-script flag C IF(IDCNT .GT. 0)THEN IDCNT = IDCNT - 1 X = X - SINX*HEIGHT Y = Y + COSX*HEIGHT HEIGHT = HEIGHT / DH ELSE IUCNT = IUCNT + 1 HEIGHT = HEIGHT * DH X = X - SINX*HEIGHT Y = Y + COSX*HEIGHT END IF ELSE IF( (COMM1 .EQ. 'D') .OR. (COMM1 .EQ. '_') )THEN C C Sub-script flag C IF(IUCNT .GT. 0)THEN IUCNT = IUCNT - 1 Y = Y - COSX*HEIGHT X = X + SINX*HEIGHT HEIGHT = HEIGHT / DH ELSE IDCNT = IDCNT + 1 HEIGHT = HEIGHT * DH Y = Y - COSX*HEIGHT X = X + SINX*HEIGHT END IF CC ELSE IF(COMM1 .EQ. 'Q')THEN C C Set the control characters C CC CLASSES(ICHAR(CTRL(1:1))) = 3 CC CLASSES(ICHAR(CTRL(2:2))) = 3 CC IF(LEN .EQ. 2)THEN CC CTRL = COMM(I1+1:I1+1)//COMM(I1+1:I1+1) CC ELSE IF(LEN .EQ. 3)THEN CC CTRL = COMM(I1+1:I1+2) CC ELSE CC GO TO 40 CC END IF CC CLASSES(ICHAR(CTRL(1:1))) = 1 CC CLASSES(ICHAR(CTRL(2:2))) = 2 ELSE IF(COMM1 .EQ. 'C')THEN C C Set the terminal colour and the pen number C IF( JUSTIFY .OR. ( ILEV .EQ. 1) )GO TO 10 #ifdef g77 CALL CHREAL(COMM2(2:LEN),LEN-1,XCOLOR,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN)),LEN-1,XCOLOR,1,*20) #endif ICOL = MAX(0,MIN(11,IFIX(XCOLOR))) CALL PLOT_COLOR(COLOURS(ICOL,IMONITOR),COLOURS(ICOL,IMONITOR2)) ELSE IF(COMM1 .EQ. 'M')THEN C C Insert a plotting symbol Marker into the text string C CHARSZ = GETNAM('CHARSZ') PLEN = PLEN + CHARSZ IF( .NOT.JUSTIFY )THEN CHARA = GETNAM('CHARA') #ifdef g77 CALL CHREAL(COMM2(2:LEN),LEN-1,XMARKER,1,*20) #else CALL CHREAL(%REF(COMM2(2:LEN)),LEN-1,XMARKER,1,*20) #endif IMARKER = IFIX(XMARKER) IF( IMARKER .EQ. 0 )THEN CHARL = GETLAB('CHAR') IMARKER = ICHAR(CHARL(1:1)) END IF IF( (IMARKER .LT. 32) .AND. (IMARKER .GT. 0) )THEN COSANG = COS(CHARA*DTOR) SINANG = SIN(CHARA*DTOR) NFILL = IFIX(500*CHARSZ/ABS(YUWIND-YLWIND))+1 NFILL = MAX(10,NFILL) XP = X + COSX*0.5*CHARSZ YP = Y + (1.+SINX)*0.5*CHARSZ CALL GPLOT_SYMBOL(XP,YP,CHARSZ,COSANG,SINANG,NFILL,IMARKER) ELSE IF( (IMARKER .GT. 32) .AND. (IMARKER .LT. 97) )THEN ACHARI = IMARKER CALL SYMBOL(X,Y,CHARSZ,ACHARI,CHARA,1) END IF END IF X = X + COSX*CHARSZ Y = Y + SINX*CHARSZ ELSE IF(COMM1 .EQ. '?')THEN IF( JUSTIFY )GO TO 10 CALL TRANSPARENT_MODE(0) WRITE(IOUTS,*)'B bolding C colour' WRITE(IOUTS,*)'_ sub-script ^ super-script' WRITE(IOUTS,*)'H height EM italics' WRITE(IOUTS,*)'F font M plotting symbol marker' WRITE(IOUTS,*)'Z horizontal space V vertical space' WRITE(IOUTS,*)'X hexadecimal input' WRITE(IOUTS,*)' ' WRITE(IOUTS,*)'DEF reset the defaults' WRITE(IOUTS,*)'NODEF do not reset the defaults' ELSE GO TO 40 END IF 10 IF( IND .GT. 0 )THEN I1 = I1 + IND GO TO 2 END IF RETURN 20 CALL TRANSPARENT_MODE(0) WRITE(IOUTS,21)CTRL(1:1),COMM(I1:I2),CTRL(2:2) 21 FORMAT(' *** ERROR converting ',3A,' to real number(s) ***') RETURN1 30 CALL TRANSPARENT_MODE(0) WRITE(IOUTS,31)CTRL(1:1),COMM(I1:I2),CTRL(2:2) 31 FORMAT(' *** ERROR in calling PSALPH with ',3A,' ***') RETURN1 40 CALL TRANSPARENT_MODE(0) WRITE(IOUTS,41)CTRL(1:1),COMM(I1:I2),CTRL(2:2) 41 FORMAT(' *** ERROR: Incorrect text-format command ',3A,' ***') RETURN1 END
c$Id:$ subroutine therm1d(d,ul,xl,ix,s,p,ndf,ndm,nst,isw) c * * F E A P * * A Finite Element Analysis Program c.... Copyright (c) 1984-2014: Regents of the University of California c All rights reserved c-----[--.----+----.----+----.-----------------------------------------] c Modification log Date (dd/mm/year) c Original version 01/11/2006 c 1. Correct lumped s(j1,j1) (was i1) for isw=5 15/08/2007 c 2. Revise quadrature sets for d(5) 27/03/2009 c 3. Save xref in 'elcoor.h' 26/07/2009 c 4. Correct format 2003 29/03/2011 c-----[--.----+----.----+----.-----------------------------------------] c One dimensional (plane/axisymmetric) Linear Thermal Element c-----[--.----+----.----+----.-----------------------------------------] c This is a one dimensional element which can analyze plane c or axisymmetric geometries. Set control parameters as c follows: c ndm - set to 1 (x or r-coord) c ndf - set > or = 1 (nodal temperature) c nel - set > or = 2 c o-----------o ----> x or r c 1 2 c Node numbering c-----[--.----+----.----+----.-----------------------------------------] implicit none include 'bdata.h' include 'cdata.h' include 'eldata.h' include 'elplot.h' include 'eltran.h' include 'fdata.h' include 'iofile.h' include 'mdata.h' include 'part0.h' include 'pmod2d.h' include 'rdata.h' include 'strnum.h' include 'comblk.h' integer ndf,ndm,nst,isw, i,j, i1,j1, l,lint, tdof, ix(*) real*8 xx, xsj, a1,a3,a4,shj,tdot,cfac,lfac, hh,tinf real*8 d(*),ul(ndf,nen,*),xl(ndm,*),s(nst,*),p(*) real*8 temp,gradt,flux,dd,shp(2,4),sg(2,5) save c Set mass factors if(d(7).ge.0.0d0 .or. d(183).ne.0.0d0) then cfac = d(7) lfac = 1.d0 - cfac else cfac = 0.0d0 lfac = 0.0d0 endif c Input material properties if(isw.eq.1) then if(ior.lt.0) write(*,2000) write(iow,2000) call inmate(d,tdof,0,6) c Delete unused parameters do i = 2,ndf ix(i) = 0 end do ! i c Set to preclude sloping boundary transformations ea(1,-iel) = 0 ea(2,-iel) = 0 c Set plot sequence pstyp = 1 istv = max(istv,15) c Check of mesh if desired (chec) elseif(isw.eq.2) then if(nel.eq.3 .or. nel.eq.6 .or. nel.eq.7) then call cktris(ix,xl,shp,ndm) else call ckisop(ix,xl,shp,ndm) endif c Compute conductivity (stiffness) matrix elseif(isw.eq.3 .or. isw.eq.6) then lint = min(5,nint(d(5))) if(lint.eq.0) then lint = nel endif if(nint(d(182)).gt.0) then call int1dn(lint,sg) else call int1d (lint,sg) endif c Get global dof for thermal variable tdof = max(1,nint(d(19))) hh = d(127) tinf = d(128) do l = 1,lint call shp1d(sg(1,l),xl,shp,ndm,nel,xsj) xsj = xsj*sg(2,l)*d(14) c Compute flux call thfx1d(d,xl,ul,xx,shp, temp,gradt,flux,dd,ndm,ndf,nel) c Save data for tplot j = 4*(l-1) tt(j+1) = flux tt(j+3) = gradt c Compute thermal rate tdot = 0.0d0 do j = 1,nel tdot = tdot + shp(2,j)*ul(1,j,4) end do ! j if(stype.eq.3) then xsj = xsj*xx endif j1 = 1 do j = 1,nel a1 = dd*shp(1,j)*xsj a3 = d(4)*d(64)*shp(2,j)*xsj a4 = d(127)*shp(2,j)*xsj c Compute residual p(j1) = p(j1) - a1*gradt & - a3*(cfac*tdot + lfac*ul(1,j,4)) & - a4*(temp - d(128)) & + d(66)*shp(2,j)*xsj*dm c Compute tangent a1 = a1*ctan(1) if(shflg) then a3 = a3*ctan(3) elseif(ndfo(tdof).gt.0) then a3 = a3*ctan(2) else a3 = 0.0d0 endif a4 = a4*ctan(1) + a3*cfac c Lumped rate terms s(j1,j1) = s(j1,j1) + a3*lfac c Consistent rate and conductivity terms i1 = 1 do i = 1,nel s(i1,j1) = s(i1,j1) + a1*shp(1,i) + a4*shp(2,i) i1 = i1 + ndf end do ! i j1 = j1 + ndf end do ! j end do ! l c Output heat flux elseif(isw.eq.4) then lint = min(5,nint(d(5))) if(lint.eq.0) then lint = nel endif if(nint(d(182)).gt.0) then call int1dn(lint,sg) else call int1d (lint,sg) endif do l=1,lint call shp1d(sg(1,l),xl,shp,ndm,nel,xsj) c Compute flux and gradients call thfx1d(d,xl,ul, xx,shp,temp,gradt,flux,dd, ndm,ndf,nel) a4 = -d(127)*(temp - d(128)) mct = mct - 1 if(mct.le.0) then write(iow,2002) o,head if(d(127).gt.0.0d0) then write(iow,2004) endif if(ior.lt.0 .and. pfr) then write(*,2002) o,head if(d(127).gt.0.0d0) then write(*,2004) endif endif mct = 50 endif write(iow,2003) n,ma,xx,flux,gradt if(d(127).gt.0.0d0) then write(iow,2005) a4 endif if(ior.lt.0 .and. pfr) then write(*,2003) n,ma,xx,flux,gradt if(d(127).gt.0.0d0) then write(*,2005) a4 endif endif end do ! l c Compute heat capacity (mass) matrix elseif(isw.eq.5) then lint = min(5,nint(d(5))) if(lint.eq.0) then lint = nel endif if(nint(d(182)).gt.0) then call int1dn(lint,sg) else call int1d (lint,sg) endif do l=1,lint call shp1d(sg(1,l),xl,shp,ndm,nel,xsj) xsj = xsj*sg(2,l)*d(14) if(stype.eq.3) then xx = 0.0d0 do i = 1,nel xx = xx + shp(2,i)*xl(1,i) end do ! i xsj = xsj*xx endif j1 = 1 do j = 1,nel shj = d(4)*d(64)*shp(2,j)*xsj c Lumped capacity (lmas) p(j1) = p(j1) + shj i1 = 1 c Consistent (interpolated ) capacity (mass) s(j1,j1) = s(j1,j1) + shj*lfac do i = 1,nel s(i1,j1) = s(i1,j1) + shj*shp(2,i)*cfac i1 = i1 + ndf end do ! i j1 = j1 + ndf end do ! j end do ! l c Compute surface flux loading (not implemented) c elseif(isw.eq.7) then c Compute nodal heat flux for output/plots elseif(isw.eq.8) then call thcn1d(d,xl,ul,shp,p,s,p(nen+1),ndf,ndm,nel) c Compute error data for heat flux elseif(isw.eq.11) then call ther1d(d,xl,ul,shp,s,ndf,ndm,nel,nen) c External node check elseif(isw.eq.26) then endif c Formats 2000 format(5x,'F o u r i e r H e a t C o n d u c t i o n') 2002 format(a1,20a4//5x,'Element Flux'//' Elmt Mat 1-Coord 2-Coord' & ,' 1-Flux 2-Flux 1-Grad 2-Grad') 2003 format(i8,i4,1p,4e12.3) 2004 format(28x,' Surf. Conv.') 2005 format(28x,1p,1e12.3) end subroutine thcn1d(d,xl,ul,shp,dt,st,ser,ndf,ndm,nel) implicit none include 'iodata.h' include 'cdata.h' include 'prstrs.h' include 'strnum.h' integer ndf,ndm,nel, j,l,lint real*8 xx,xsj,xg,d(*), sg(2,3) real*8 dt(*),st(nen,*),ser(*),xl(ndm,*),shp(2,*) real*8 temp,gradt,flux,dd,ul(ndf,*) save c Lumped projection routine lint = min(5,nint(d(5))) if(lint.eq.0) then lint = nel endif if(nint(d(182)).gt.0) then call int1dn(lint,sg) else call int1d (lint,sg) endif do l=1,lint call shp1d(sg(1,l),xl,shp,ndm,nel,xsj) xsj = xsj*sg(2,l)*d(14) call thfx1d(d,xl,ul, xx,shp,temp,gradt,flux,dd, ndm,ndf,nel) temp = -d(127)*(temp - d(128)) c Compute lumped projection and assemble stress integrals do j = 1,nel xg = xsj*shp(2,j) dt(j) = dt(j) + xg st(j,13) = st(j,13) + flux*xg st(j,15) = st(j,15) + temp*xg ser(j) = ser(j) + erav*xg end do ! j end do ! l iste = 15 end subroutine thfx1d(d,xl,ul, xx,shp, temp,gradt,flux,dd, & ndm,ndf,nel) c Compute thermal gradient and flux implicit none include 'elcoor.h' integer ndm,ndf,nel, i real*8 d(*),xl(ndm,*),ul(ndf,*), shp(2,*) real*8 xx, temp,gradt,flux,dd save temp = 0.0d0 gradt = 0.0d0 xx = 0.0d0 do i = 1,nel gradt = gradt + shp(1,i)*ul(1,i) temp = temp + shp(2,i)*ul(1,i) xx = xx + shp(2,i)*xl(1,i) end do ! i c Compute thermal flux dd = d(61) flux = -dd*gradt c Save coordinates xref(1) = xx do i = 2,3 xref(i) = 0.0d0 end do ! i end subroutine ther1d(d,xl,ul,shp,st,ndf,ndm,nel,nen) implicit none include 'adapt1.h' include 'adapt2.h' include 'errind.h' integer ndf,ndm,nel,nen, i,ii real*8 g,xx,xsj,detd, st(nen,*),xl(ndm,*),shp(2,*) real*8 d(*),gradt,flux,dd, temp,gradp,fluxp,sg real*8 ul(ndf,*),ss(3) save data ss/-1.d0, 1.d0, 0.d0/ c Simple routine vfem = 0.d0 vproj = 0.d0 verror = 0.d0 vener = 0.d0 venere = 0.d0 heta = 0.0d0 g = 1.d0/sqrt(3.0d0) do ii = 1,2 sg = ss(ii)*g call shp1d(sg,xl,shp,ndm,nel,xsj) call thfx1d(d,xl,ul, xx,shp,temp,gradt,flux,dd, ndm,ndf,nel) fluxp = 0.0d0 do i = 1,nel fluxp = fluxp + shp(2,i)*st(i,7) end do ! i c Compute integral of stress squares for error indicator use detd = 1.d0/dd gradp = -detd*fluxp heta = heta + xsj vfem = vfem + flux*flux*xsj vproj = vproj + fluxp*fluxp*xsj verror = verror + ((fluxp-flux)**2)*xsj vener = vener + flux*gradt*xsj venere = venere + (fluxp-flux)*(gradp-gradt)*xsj end do ! ii arsq = arsq + heta efem = efem + vfem eproj = eproj + vproj eerror= eerror+ verror eener = eener + vener eenere= eenere+ venere areai = heta c Check for triangle heta = d(50)*sqrt(heta) end
C$PROG LABLV C C ************************************************************ C BY WT MILNER AT HHIRF - LAST MODIFIED 08/24/92 C ************************************************************ C FUNCTION LABLV(LABEL) C INTEGER*4 LABEL,LABL(2) C C ************************************************************ C RETURNS THE VALUE ASSOCIATED WITH ASCII LABEL CONTAINED IN C "LABEL" (!!!! CHECK DIMENSION REQUIREMENTS !!!!) C ************************************************************ C LABL(1)=LABEL LABL(2)='20202020'X C CALL LABLMAN('GET ',LABL,IV,IERR) C LABLV=IV RETURN END
program lat222 C Copyright, Bernd Berg, Nov 8 2000. C Bookkeeping for a hypercubic 2x2x2 lattice (lat3d.par and lat3d.dat). include '../../ForLib/implicit.sta' parameter(iuo=6) include 'lat3d.par' include '../../ForLib/lat.com' include 'lat222.dat' dimension ix(nd) C write(iuo,*) " is ix(1) (2) (3)", & " ipf(is,1) (,2) (,3) ipb(is,1) (,2) (,3)" call lat_init(ns,nd,ipf,ipb,nla,ix,nlink) ! lattice do is=1,ns call ixcor(ix,nla,is,nd) write(iuo,'(1I4,3X,3I4,7X,3I5,7X,3I5)') & is,ix,(ipf(id,is),id=1,nd),(ipb(id,is),id=1,nd) end do C stop end include '../../ForLib/ipointer.f' include '../../ForLib/isfun.f' include '../../ForLib/ixcor.f' include '../../ForLib/lat_init.f' include '../../ForLib/nsfun.f'
C MEMBER SARP51 C-------------------------------------------------------------------- C C@PROCESS LVL(77) C SUBROUTINE TSID51(TSID,DTYPE,IDT,TSOK) C C--------------------------------------------------------------------- C ARGS: C TSID - 8 CHARACTER ID OF TIME SERIES C DTYPE - DATATYPE OF TIME-SERIES C IDT - TIME INTERVAL OF TIME SERIES C TSOK - LOGICAL VARIABLE INDICATING THAT INFO HAS BEEN READ IN OK. C--------------------------------------------------------------------- C C KUANG HSU - HRL - OCTOBER 1994 C---------------------------------------------------------------- INCLUDE 'common/fld51' C DIMENSION TSID(2) LOGICAL TSOK C C ================================= RCS keyword statements ========== CHARACTER*68 RCSKW1,RCSKW2 DATA RCSKW1,RCSKW2 / ' .$Source: /fs/hseb/ob72/rfc/ofs/src/fcinit_ssarresv/RCS/tsid51.f,v $ . $', ' .$Id: tsid51.f,v 1.1 1996/03/21 14:41:30 page Exp $ . $' / C =================================================================== C C TSOK = .FALSE. C C ALWAYS LOOK FOR NEXT FIELD ON LINE AND NOTHING MORE C NUMFLD = -2 CALL UFLD51(NUMFLD,IERF) IF (IERF.GT.0) GO TO 9000 C C FIRST FIELD IS TS ID C NUMWD = (LEN-1)/4 + 1 IF (NUMWD.LE.2) GO TO 220 C CALL STER51(20,1) GO TO 9999 C 220 CONTINUE DO 225 I=1,2 TSID(I) = CHAR(I) 225 CONTINUE C C NEXT FIELD IS DATATYPE C NUMFLD = -2 CALL UFLD51(NUMFLD,IERF) IF (IERF.GT.0) GO TO 9000 C NUMWD = (LEN-1)/4 + 1 IF (NUMWD.EQ.1) GO TO 230 C CALL STER51(20,1) GO TO 9999 C 230 CONTINUE DTYPE = CHAR(1) C C NEXT FIELD IS TIME INTERVAL. MUST BE POSITIVE INTEGER. C NUMFLD = -2 CALL UFLD51(NUMFLD,IERF) IF (IERF.GT.0) GO TO 9000 C IF (ITYPE.EQ.0) GO TO 240 C CALL STER51(5,1) GO TO 9999 C 240 CONTINUE IF (INTEGR .GT. 0) GO TO 250 C CALL STER51(61,1) GO TO 9999 C C EVERYTHING OK IF WE REACH HERE C 250 CONTINUE IDT = INTEGR TSOK = .TRUE. GO TO 9999 C 9000 CONTINUE IF (IERF.EQ.1) CALL STER51(19,1) IF (IERF.EQ.2) CALL STER51(20,1) IF (IERF.EQ.3) CALL STER51(21,1) IF (IERF.EQ.4) CALL STER51(1,1) C 9999 CONTINUE RETURN END
C %W% %G% C**************************************************************** C C File: ld_geld.f C C Purpose: Routine to load GE load data from raw data file C c Return code: n = 0 : Success c n = 1 " Error c C Author: Walt Powell Date: 21 May 1996 C Called by: load_ge.f C C**************************************************************** integer function ld_geld (xbuf, file, options, error) integer file, error, options(*) character *(*) xbuf include 'ipfinc/parametr.inc' include 'ipfinc/prt.inc' include 'ipfinc/pti_data.inc' include 'ipfinc/blank.inc' include 'ipfinc/alt_case.inc' include 'ipfinc/alpha.inc' include 'ipfinc/bus.inc' include 'ipfinc/cbus.inc' character word(60)*10, busname*8, ld_id*1, ld_type*2, & ld_own*3, getid*1 integer fnd_ptin, find_bus, ftn_atoi, status, ptr, add_cbs, & read_ge_file ld_geld = 0 error = 0 last = lastch0 (xbuf) do while (xbuf(last:last) .eq. '/') status = read_ge_file (file, xbuf(last:)) if (status .eq. 0) go to 340 last = lastch0 (xbuf) enddo call uscan (xbuf(1:last), word, nwrd, '~', ' ') npti1 = ftn_atoi(word(1)) status = ftn_atoi(word(7)) npti2 = ftn_atoi(word(8)) if (npti1 .eq. 0) then if (ichar (xbuf(1:1)) .ge. ichar ('a') .and. & ichar (xbuf(1:1)) .le. ichar ('z')) ld_geld = 1 else if (status .eq. 0) then else num1 = fnd_ptin (npti1) if (num1 .le. 0) then write (errbuf(1), 10000) 10000 format (' Load record is not preceded with a Bus record in raw & data file.') errbuf(2)= ' (' // xbuf(1:60) // ')' call prterx ('W',2) error = 1 go to 900 endif busname = pti_name(num1) basekv = pti_base(num1) nb = find_bus (busname, basekv) if (nb .lt. 0) then write (errbuf(1), 10010) busname, basekv 10010 format (' Bus (', a8, f7.1, ') in Load record is not in system &.') call prterx ('W', 1) error = 1 go to 900 endif ld_id = getid (word(4)) ld_own = word(20) ix = 1 do while (ix .lt. 4) if (ix .eq. 1) then pload = ftn_atof (word(8)) qload = ftn_atof (word(9)) ld_type = '*P' if (index ('123456789', word(4)(2:2)) .ne. 0) then ld_type = word(4)(2:2) endif if (pload .eq. 0.0 .and. qload .eq. 0.0) ix = 2 endif if (ix .eq. 2) then pload = ftn_atof (word(10)) qload = ftn_atof (word(11)) ld_type = '*I' if (pload .eq. 0.0 .and. qload .eq. 0.0) ix = 3 endif if (ix .eq. 3) then pload = ftn_atof (word(12)) qload = ftn_atof (word(13)) ld_type = '*Z' if (pload .eq. 0.0 .and. qload .eq. 0.0) ix = 4 endif if (ix .lt. 4) then ptr = add_cbs (nb, ld_id, ld_own, ld_type) if (ptr .eq. 0) go to 900 if (ix .le. 2) then bctbl(2,ptr) = bctbl(2,ptr) + pload bctbl(3,ptr) = bctbl(3,ptr) + qload else bctbl(4,ptr) = bctbl(4,ptr) + pload bctbl(5,ptr) = bctbl(5,ptr) + qload endif ix = ix + 1 endif enddo endif go to 900 340 write (errbuf(1), 10090) 10090 format (' Premature E-O-F encountered processing Load data') errbuf(2)= ' (' // xbuf(1:60) // ')' call prterx ('W', 2) ld_geld = 1 900 continue return end
SUBROUTINE D02(VPREE,VDE) C==================================================================== C pg 206 C==================================================================== C TO FORM MATRIX D (2 DIMENSIONAL ELASTICITY) C INPUT C VPREE ELEMENT PROPERTIES C VPREE(1) YOUNG'S MODULUS C VPREE(2) POISSON'S COEFFICIENT C VPREE(3) .EQ.0 PLANE STRESSES C .EQ.1 PLANE STRAINS C OUTPUT C VDE MATRIX D (FULL) C==================================================================== IMPLICIT REAL*8(A-H,O-Z) DIMENSION VPREE(*),VDE(9) DATA ZERO/0.D0/,UN/1.D0/,DEUX/2.D0/ E=VPREE(1) X=VPREE(2) A=VPREE(3) C1=E*(UN-A*X)/((UN+X)*(UN-X-A*X)) C2=C1*X/(UN-A*X) C3=E/(DEUX*(UN+X)) VDE(1)=C1 VDE(2)=C2 VDE(3)=ZERO VDE(4)=C2 VDE(5)=C1 VDE(6)=ZERO VDE(7)=ZERO VDE(8)=ZERO VDE(9)=C3 RETURN END
! $Id: cppcheck.F 697 2011-04-11 12:35:17Z gcambon $ ! !====================================================================== ! ROMS_AGRIF is a branch of ROMS developped at IRD and INRIA, in France ! The two other branches from UCLA (Shchepetkin et al) ! and Rutgers University (Arango et al) are under MIT/X style license. ! ROMS_AGRIF specific routines (nesting) are under CeCILL-C license. ! ! ROMS_AGRIF website : http://roms.mpl.ird.fr !====================================================================== ! program cppcheck ! ! PURPOSE: Scan all existing CPP-switches in file "cppdefs.h" and ! automatomatically generate file check_switches1.F which contains ! subroutine check_switches1. When later this file is compiled and ! executed a part of SCRUM/ROMS model, it creates log of activated ! CPP-switches. ! ! Algorithm: this program reads line-by-line file "cppdefs.h" and ! creates catalog of CPP-switches found there. It does not matter, ! whether switches are in defined or undefined status, either way ! they are put into catalog. For the purpose of this algorithm ! CPP-switch (CPP-macro name) is a word which follows a command ! (reserved word) of C-preprocessor, such as "ifdef", "define" etc. ! Conversely, a word which follows another word which is not a ! CPP-command is not considered as a CPP-macro name. ! ! For the purpopse of preceeding paragraph "word" means a consecutive ! string of nonblank and nonspecial characters (i.e. letters, digits ! and ! underscore '_'). ! ! The algorithm works as follows: !---- --------- ----- -- -------- ! 0. reset catalog: arrays of names of CPP-switches and their sizes; ! 1. read line from the file; ignore all lines which do not have #; ! 2. find non-trivial length of that line; ! 3. set all symbols within C-style comments to blank (' '); ! 4. set all special characters to blank; ! 5. identify words within the modified line; ! 6. identify words which are CPP commands and CPP-macro names. ! 7. for each CPP-macro name encountered in (6) check whether it ! already listed in the catalog, and if not, place it there. ! 8. Once catalog is complete, generate code for checkdefs. ! ! Created by Alexander Shchepetkin <alex@atmos.ucla.edu> on May 2000. ! implicit none integer input,iout, maxstring, lstring parameter (input=11, iout=12, maxstring=80) character*80 string integer nwords , nswitches,nexample & , max_switches parameter (nwords=16 , max_switches=1024) integer istart(nwords), is , size(max_switches) & , iend(nwords), ie,ln , line(max_switches) logical macro(nwords) , example character*32 switch(max_switches) integer count, iocheck, i,k,n logical end_of_file, comment, word, command, new write(*,'(/1x,A,1x,A/)') 'This is CPPCHECK: Creating', & 'new version of check_switches1.F.' example=.true. nexample=0 ! nswitches=0 ! Initialize catalog. do i=1,max_switches ! reset/blank out arrays size(i)=0 ! of sizes and names. switch(i)=' ' enddo !!! 12345678901234567890123456789012 ! open(input,file='cppdefs.h',status='old',form='formatted') open(input,file='mergcpp.txt',status='old',form='formatted') count=0 ! <-- reset counter of lines within the file. end_of_file=.false. ! 1 count=count+1 ! Read line from input file. do i=1,maxstring ! Ignore all lines, which do string(i:i)=' ' ! not start with #. enddo ! read(input,'(A)',iostat=iocheck,end=2) string if (string(1:1).ne.'#') goto 1 ! goto 3 ! Find length of the string, 2 end_of_file=.true. ! which is equal to position ! of the most right nonblank 3 lstring=maxstring+1 ! character. 4 lstring=lstring-1 ! if ((string(lstring:lstring).eq.' ').AND.(lstring.GT.1)) goto 4 ! ! Suppress C-style comments and special characters. ! n=0 ! <-- reset counter of comments within the string. comment=.false. i=1 5 i=i+1 if (.not.comment .and. string(i:i+1).eq.'/*') then comment=.true. n=n+1 istart(n)=i elseif (comment .and. string(i:i+1).eq.'*/') then comment=.false. iend(n)=i+1 endif if (i+1.lt.lstring) goto 5 ! if (comment) then ! If string ends as an open lstring=istart(n)-1 ! comment, restrict lstring n=n-1 ! and disregard all symbols endif ! one right right from it. do k=1,n ! do i=istart(k),iend(k) ! string(i:i)=' ' ! blank out C-style comments enddo ! enddo ! Suppress special characters do i=1,lstring c* if (string(i:i).eq.'(' .or. string(i:i).eq.')' .or. c* & string(i:i).eq.'&' .or. string(i:i).eq.'|' .or. c* & string(i:i).eq.'!' .or. ichar(string(i:i)).eq.9) c* & string(i:i)=' ' ! Character 9 is TaB symbol. k=ichar(string(i:i)) if (k.lt.48 .or. (k.gt.57 .and. k.lt.65) .or. (k.gt.90 & .and. k.lt.95) .or. k.eq.96 .or. k.gt.122) string(i:i)=' ' enddo ! ! Identify words within the string, find starting and ending ! characters of each word. Since all special characters have ! been removed, at this point word is a sequence of non-blank ! characters. ! n=0 ! <-- reset counter of words within the string. word=.false. i=1 6 i=i+1 if (string(i:i).ne.' ' .and. .not.word) then word=.true. n=n+1 istart(n)=i elseif (string(i:i).eq.' ' .and. word) then word=.false. iend(n)=i-1 endif if (i.lt.lstring) goto 6 if (word) iend(n)=i c** write(*,'(/,I4,I4,/)') count, n ! Print out words. c** do k=1,n c** write(*,'(10x,80A1)') (string(i:i), i=istart(k),iend(k)) c** enddo ! ! Identify CPP-commands (i.e. command=.false. ! reserved words) and CPP- do k=1,n ! macro names among the words macro(k)=.false. ! of the line. Cancel example is=istart(k) ! switch when encounter first ie=iend(k) ! conditional CPP-command. ln=ie-is+1 ! if (ln.eq.6 .and. string(is:ie).eq.'define') then command=.true. elseif (ln.eq.5 .and. string(is:ie).eq.'undef') then command=.true. elseif (ln.eq.2 .and. string(is:ie).eq.'if') then command=.true. example=.false. elseif (ln.eq.5 .and. string(is:ie).eq.'ifdef') then command=.true. example=.false. elseif (ln.eq.7 .and. string(is:ie).eq.'defined') then command=.true. example=.false. elseif (ln.eq.4 .and. string(is:ie).eq.'elif') then command=.true. example=.false. elseif (ln.eq.4 .and. string(is:ie).eq.'else') then elseif (ln.eq.5 .and. string(is:ie).eq.'endif') then elseif (ln.eq.7 .and. string(is:ie).eq.'include') then elseif (command) then command=.false. macro(k)=.true. c** elseif (string(istart(1):iend(1)) .ne. 'include') then c** write (*,'(6x,A,1x,A,1x,I4,A1/8x,A)') 'CPPCHECK ERROR:', c** & 'Unknown CPP-command on line', count, ':', string(is:ie) endif enddo c** write(*,'(/,I4,I4,/)') count, n ! Print out CPP-macro names. c** do k=1,n c** if (macro(k)) then c** write(*,'(10x,80A1)') (string(i:i),i=istart(k),iend(k)) c** endif c** enddo ! do k=1,n ! Scan catalog of previously if (macro(k)) then ! discovered switches to find is=istart(k) ! match with CPP-macro names ie=iend(k) ! found in the present line. ln=ie-is+1 ! If no match is found, add new=.true. ! the new switch to the do i=1,nswitches ! catalog. if (ln.eq.size(i)) then ! if (string(is:ie).eq.switch(i)(1:ln)) new=.false. endif enddo if (new) then nswitches=nswitches+1 size(nswitches)=ln switch(nswitches)(1:ln)=string(is:ie) line(nswitches)=count if (example) nexample=nexample+1 endif ! endif ! CPP-switches found prior enddo ! to the first conditional if (.not.end_of_file) goto 1 ! CPP-command correspond to close(unit=input) ! predefined examples. c** write(*,'(/,I4,/)') nswitches ! Print out catalog. c** do i=1,nswitches c** ln=size(i) c** write(*,'(10x,I4,I4,2x,A)') line(i), ln, switch(i)(1:ln) c** enddo ! ! Generate CPP-checking subroutine. ! open (unit=iout,file='check_switches1.F',form='formatted') write(iout,'(A/)') '#include "cppdefs.h"' write(iout,'(/6x,A/)') 'subroutine check_switches1 (ierr)' write(iout,'(4(A,1x,A/),A,14x,A/A,1x,A,3x,A/A,14x,A/A,22x,A)') & '!!!!!! WARNING: THIS IS A MACHINE GENERATED', & 'CODE, DO NOT EDIT! !!!!!!', & '!!!!!! This file needs to be updated only if', & 'new CPP-switches !!!!!!', & '!!!!!! were introduced into "cppdefs.h".', & ' NO ACTION IS NEEDED !!!!!!', & '!!!!!! if changes in "cppdefs.h" are limited', & 'to activation or !!!!!!', & '!!!!!! deactivation of previously known switches.','!!!!!!', & '!!!!!! To refresh this file compile and execute', & '"cppcheck.F"', '!!!!!!', & '!!!!!! as an independent program, or use commands','!!!!!!', & '!!!!!! "make checkdefs" or "make depend".', '!!!!!!' write(iout,'(A,20x,I3,1x,A/A,23x,I3,1x,A)') & '!!!!!! Number of Configuration Choices:',nexample, '!!!!!!', & '!!!!!! Total number of CPP-switches:', nswitches, '!!!!!!' write(iout,'(2(/6x,A), 5(/A) /6x,A /5x,A1,6x,A, 5(/6x,A))') & 'implicit none', 'integer ierr, is,ie, iexample', & '#include "param.h"', '#include "strings.h"', & '#ifdef MPI', '# include "scalars.h"', '#endif', & 'MPI_master_only write(stdout,''(/1x,A/)'')', '&', & '''Activated C-preprocessing Options:''', & 'do is=1,max_opt_size', ' Coptions(is:is)='' ''', 'enddo', & 'iexample=0', 'is=1' do i=1,nswitches ln=size(i) write(iout,'(A,1x,A)') '#ifdef', switch(i)(1:ln) if (i.le.nexample) write(iout,'(6x,A)') 'iexample=iexample+1' write(iout,'(6x,A,1x,A1,A,A1)') & 'MPI_master_only write(stdout,''(10x,A)'')', & '''', switch(i)(1:ln), '''' write(iout,'(6x,A7,I2/6x,A/6x,A,A,A1/6x,A/6x,A/A)') & 'ie=is +', ln-1, 'if (ie.ge.max_opt_size) goto 99', & 'Coptions(is:ie)=''', switch(i)(1:ln), '''', & 'Coptions(ie+1:ie+1)='' ''', 'is=ie+2', '#endif' enddo write(iout,'(6x,A/6x,A/8x,A/5x,A1,1x,A/8x,A/6x,A)') & 'MPI_master_only write(stdout,''(/)'')', & 'if (iexample.eq.0) then', & 'MPI_master_only write(stdout,''(1x,A)'')', '&', & '''ERROR in "cppdefs.h": no configuration is specified.''', & 'ierr=ierr+1', 'elseif (iexample.gt.1) then' write(iout,'(8x,A/5x,A1,1x,A/8x,A/6x,A/6x,A)') & 'MPI_master_only write(stdout,''(1x,A)'')', '&', & '''ERROR: more than one configuration in "cppdefs.h".''', & 'ierr=ierr+1', 'endif', 'return' write(iout,'(2x,A/5x,A1,2x,A,1x,A/5x,A1,2x,A,1x,A)') & '99 MPI_master_only write(stdout,''(/1x,A,A/14x,A)'')', & '&', '''CHECKDEFS -- ERROR: Unsufficient size of string', & 'Coptions'',', '&', '''in file "strings.h".'',', & '''Increase the size it and recompile.''' write(iout,'(6x,A,2(/6x,A))') 'ierr=ierr+1', 'return', 'end' close(unit=iout) stop end
C$Procedure SUFFIX (Suffix a character string) SUBROUTINE SUFFIX ( SUFF, SPACES, STRING ) C$ Abstract C C Add a suffix to a character string. 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 ASSIGNMENT, CHARACTER, STRING C C$ Declarations CHARACTER*(*) SUFF INTEGER SPACES CHARACTER*(*) STRING C$ Brief_I/O C C VARIABLE I/O DESCRIPTION C -------- --- -------------------------------------------------- C SUFF I Suffix. C SPACES I Number of spaces separating prefix and suffix. C STRING I/O Prefix on input, string on output. C C$ Detailed_Input C C SUFF is the suffix to be added to the string. C Leading blanks are significant. (A blank C suffix is interpreted as a null suffix.) C C SPACES is the number of spaces (blanks) in the output C string separating the last non-blank character C of the prefix from the first (blank or non-blank) C character of the suffix. Typically, this will be C zero or one. If not positive, SPACES defaults to C zero. C C STRING on input is the prefix to which the suffix is C to be added. Leading blanks are significant. C Trailing blanks are ignored. C C$ Detailed_Output C C STRING on output is the suffixed string. If STRING C is not large enough to contain the output string, C the output string is truncated on the right. C C STRING may NOT overwrite SUFF. C C$ Parameters C C None. C C$ Particulars C C The suffix is added to the right of the last non-blank character C of the prefix. (Any necessary truncation is done automatically.) C C$ Examples C C The following examples illustrate the use of SUFFIX. C C SUFF STRING (input) SPACES STRING (output) C ---------- -------------- ------ --------------- C 'abc ' 'def ' 0 'defabc ' C 'abc ' 'def ' 1 'def abc' C 'abc ' ' def ' 0 ' defabc' C 'abc ' ' def ' 1 ' def ab' C ' abc ' 'def ' 0 'def abc' C ' abc ' 'def ' 1 'def ab' C ' abc ' ' def ' -1 ' def ab' C ' ' 'def ' 0 'def ' C ' ' 'def ' 1 'def ' C ' abc ' ' ' 0 ' abc ' C ' abc ' ' ' 1 ' abc ' C C$ Restrictions C C SUFF and STRING must be distinct. 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 I.M. Underwood (JPL) C C$ Literature_References C C None. C C$ Version C C- SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) C C Comment section for permuted index source lines was added C following the header. C C- SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU) C C-& C$ Index_Entries C C suffix a character_string C C-& C C SPICELIB functions C INTEGER LASTNB C C Local variables C INTEGER L INTEGER SLEN INTEGER END C C SLEN is the allocated length of the string. L is the location of C the last non-blank character of the prefix. C SLEN = LEN ( STRING ) L = LASTNB ( STRING ) C C Put the suffix at the end of the string. The spaces will fill C themselves in. C END = L + MAX ( SPACES, 0 ) IF ( END .LT. SLEN ) THEN STRING(END+1: ) = SUFF END IF RETURN END
SUBROUTINE SMCCCD ( DTEMP, ZIL, ILIM, ZOL ) DOUBLE COMPLEX DTEMP( ILIM ), ZIL( ILIM ), ZOL DO 10 I = 1, ILIM DTEMP( I ) = DTEMP( I ) + ZIL( I ) * ZOL 10 CONTINUE RETURN END
10 <--SHAPES 10 <--LINES id1 2 <--TYPE 333 <--LEFT 66 <--TOP 70 <--WIDTH 30 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- START id2 91 <--TYPE 268 <--LEFT 113 <--TOP 220 <--WIDTH 40 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- INPUT N sayısısını giriniz N id3 92 <--TYPE 323 <--LEFT 205 <--TOP 112 <--WIDTH 50 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- IF_LESS N 1 id4 3 <--TYPE 578 <--LEFT 227 <--TOP 10 <--WIDTH 10 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- INTERSECTION id5 3 <--TYPE 578 <--LEFT 127 <--TOP 10 <--WIDTH 10 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- INTERSECTION id6 0 <--TYPE 331 <--LEFT 297 <--TOP 92 <--WIDTH 30 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- ADD N 1 M id7 0 <--TYPE 330 <--LEFT 357 <--TOP 92 <--WIDTH 30 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- MULTIPLY N M K id8 0 <--TYPE 311 <--LEFT 434 <--TOP 132 <--WIDTH 30 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- DIVIDE K 2 Toplam id9 91 <--TYPE 300 <--LEFT 516 <--TOP 156 <--WIDTH 40 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- OUTPUT Toplam: Toplam id10 2 <--TYPE 344 <--LEFT 599 <--TOP 70 <--WIDTH 30 <--HEIGHT 16777215 <--BACKCOLOR 0 <--BORDERCOLOR 0 <--BORDERCOLOR -reserved 1- -reserved 2- STOP ---- LINES ---- from,to ---- id1,id2 reserved 1 id2,id3 reserved 1 id3,id4 reserved 1 EVET id4,id5 reserved 1 id5,id2 reserved 1 id3,id6 reserved 1 HAYIR id6,id7 reserved 1 id7,id8 reserved 1 id8,id9 reserved 1 id9,id10 reserved 1
C %W% %G% subroutine savfil c c CREATES A NEW SAVED DATA FILE (FOR015) FROM DATA ENTERED c ON THE INPUT FILE (FOR005). CALLED BY SDATA. c include 'tspinc/params.inc' include 'tspinc/blkcom1.inc' include 'tspinc/prt.inc' include 'tspinc/reread.inc' include 'tspinc/cntrl2.inc' include 'tspinc/in1n.inc' include 'tspinc/in1c.inc' include 'tspinc/lnet.inc' include 'tspinc/param.inc' include 'tspinc/contrl.inc' include 'tspinc/comn34.inc' include 'tspinc/pointr.inc' include 'tspinc/titles.inc' character*10 machin(8,100),lsrcp(8,100), & lrelay(8,100),lrrod(8,100), & lrepdt(8,100), & lshed(8,100),dccard(8,150) character*8 plotd logical debug !dem data plotd /'VER01'/ c c Begin Begin Begin Begin Begin Begin call mpost('SAVFIL') debug = .true. !dem blnk10 = ' ' if (debug) !dem & call dbgeko ('SAVFIL - at start - fetching file 1 rec nums') !dem call whrec1 ('MAC', ilo, ihi, isz) !dem if (debug) !dem & call dbgwri (' for gens, count rec # = ',ihi) !dem read (l1,rec=ihi) mac !dem c read (l1,rec=101) MAC call whrec1 ('LDA', ilo, ihi, isz) !dem if (debug) !dem & call dbgwri (' for area load rep, count rec # = ',ihi) !dem read (l1,rec=ihi) ldar !dem c read (l1,rec=139) LDAR call whrec1 ('LDZ', ilo, ihi, isz) !dem if (debug) !dem & call dbgwri (' for zone load rep, count rec # = ',ihi) !dem read (l1,rec=ihi) ldz !dem c read (l1,rec=141) LDZ call whrec1 ('LDB', ilo, ihi, isz) !dem if (debug) !dem & call dbgwri (' for bus load rep, count rec # = ',ihi) !dem read (l1,rec=ihi) lrep !dem c read (l1,rec=145) LREP call whrec1 ('LSH', ilo, ihi, isz) !dem if (debug) !dem & call dbgwri (' for load shedding, count rec # = ',ihi) !dem read (l1,rec=ihi) ls !dem c read (l1,rec=170) LS call whrec1 ('RG ', ilo, ihi, isz) !dem read (l1,rec=ihi) lsc !dem c read (l1,rec=177) LSC call whrec1 ('RD ', ilo, ihi, isz) !dem read (l1,rec=ihi) lrd !dem c read (l1,rec=180) LRD call whrec1 ('RR ', ilo, ihi, isz) !dem read (l1,rec=ihi) lrr !dem c read (l1,rec=184) LRR call whrec1 ('DC ', ilo, ihi, isz) !dem read (l1,rec=ihi) jdctot,jdc !dem c read (l1,rec=187) JDCTOT,JDC call opents(4) c ! Write header write (l15) swdata,savout,swdate,swdate c ! Write number of base kV's write (l15) ibxyz,(basekv(i),i=1,ibxyz) c ! Write LOCAL RELAY header and number of records write (l15) relay,blnk10,datx,lrd if (lrd .gt. 0) then call whrec1 ('RD ', ilo, ihi, isz) !dem c MSLRD=181 mslrd = ihi + 1 !dem if (debug) !dem & call dbgwri (' for local relays, data rec # = ',mslrd) !dem numrec = lrd do while (numrec .gt. 0) num = min (100, numrec) read (l1,rec=mslrd) ((lrelay(i,j),i=1,8),j=1,num) write (l15) ((lrelay(i,j),i=1,8),j=1,num) mslrd = mslrd + 1 numrec = numrec - num enddo endif c ! Write REMOTE RELAY header and number of records write (l15) remote,relay,datx,lrr if (lrr .gt. 0) then call whrec1 ('RR ', ilo, ihi, isz) !dem mslrr = ihi + 1 !dem c MSLRR=185 if (debug) !dem & call dbgwri (' for remote relays, data rec # = ',mslrr) !dem read (l1,rec=mslrr) lrrod write (l15) ((lrrod(i,j),i=1,8),j=1,lrr) endif c ! Write SERIES CAPACITOR header and number of records write (l15) series,capac,datx,lsc if (lsc .gt. 0) then call whrec1 ('RG ', ilo, ihi, isz) !dem mslsc = ihi + 1 !dem c MSLSC=178 if (debug) !dem & call dbgwri (' for series cap relays, data rec # = ',mslsc) !dem read (l1,rec=mslsc) lsrcp write (l15) ((lsrcp(i,j),i=1,8),j=1,lsc) endif c ! Write LOAD REPRESENTATION BY AREA header and number of records write (l15) load,repr,datx,ldar if (ldar .gt. 0) then call whrec1 ('LDA', ilo, ihi, isz) !dem mslrep = ihi + 1 !dem c MSLREP=140 if (debug) !dem & call dbgwri (' for area load rep, data rec # = ',mslrep) !dem read (l1,rec=mslrep) (( lrepdt(i,j),i=1,8),j=1,ldar) write (l15) ((lrepdt(i,j),i=1,8),j=1,ldar) endif c ! Write LOAD REPRESENTATION BY ZONE header and number of records write (l15) load,repr,datx,ldz if (ldz .gt. 0) then call whrec1 ('LDZ', ilo, ihi, isz) !dem mslrep = ihi + 1 !dem c MSLREP=142 if (debug) !dem & call dbgwri (' for zone load rep, data rec # = ',mslrep) !dem numrec = ldz do while (numrec .gt. 0) num = min (100, numrec) read (l1,rec=mslrep) ((lrepdt(i,j),i=1,8),j=1,num) write (l15) ((lrepdt(i,j),i=1,8),j=1,num) mslrep = mslrep + 1 numrec = numrec - num enddo endif c ! Write LOAD REPRESENTATION BY BUS header and number of records write (l15) load,repr,datx,lrep if (lrep .gt. 0) then call whrec1 ('LDB', ilo, ihi, isz) !dem mslrep = ihi + 1 !dem c MSLREP=146 if (debug) !dem & call dbgwri (' for bus load rep, data rec # = ',mslrep) !dem numrec = lrep do while (numrec .gt. 0) num = min (100, numrec) read (l1,rec=mslrep) ((lrepdt(i,j),i=1,8),j=1,num) write (l15) ((lrepdt(i,j),i=1,8),j=1,num) mslrep = mslrep + 1 numrec = numrec - num enddo endif c ! Write LOAD SHEDDING header and number of records write (l15) load,shed,datx,ls if (ls .gt. 0) then call whrec1 ('LSH', ilo, ihi, isz) !dem msls = ihi + 1 !dem c MSLS=171 if (debug) !dem & call dbgwri (' for load shedding, data rec # = ',msls) !dem numrec = ls do while (numrec .gt. 0) num = min (100, numrec) read (l1,rec=msls) ((lshed(i,j),i=1,8),j=1,num) write (l15) ((lshed(i,j),i=1,8),j=1,num) msls = msls + 1 numrec = numrec - num enddo endif c ! Write LOAD NETTING header and number of records write (l15) load,net,datx,ln,ibxyz if (ln .gt. 0) then call whrec1 ('LN ', ilo, ihi, isz) !dem msln = ihi + 1 !dem c MSLN=168 if (debug) !dem & call dbgwri (' for load netting, data rec # = ',msln) !dem write (l15) (lnetc(i),i=1,ln),(lnetn(i),i=1,ln), & (basekv(ii),ii=1,ibxyz) 1060 write (l15) machn,blnk10,datx,mac endif c ! Write MACHINE (PLANT DATA) header and number of records if (mac .gt. 0) then call whrec1 ('MAC', ilo, ihi, isz) !dem msmac = ihi + 1 !dem c MSMAC=102 if (debug) !dem & call dbgwri (' for machines, data rec # = ',msmac) !dem numrec = mac do while (numrec .gt. 0) num = min (100, numrec) read (l1,rec=msmac) ((machin(i,j),i=1,8),j=1,num) write (l15) ((machin(i,j),i=1,8),j=1,num) msmac = msmac + 1 numrec = numrec - num enddo endif c ! Write DIRECT CURRENT header and number of records write (l15) direct,currnt,datx,jdc if (jdc .gt. 0) then call whrec1 ('DC ', ilo, ihi, isz) !dem msjdc = ihi + 1 !dem c MSJDC=188 if (debug) !dem & call dbgwri (' for dc convertors, data rec # = ',msjdc) !dem read (l1,rec=msjdc) (( dccard(i,j),i=1,8),j=1,jdc) write (l15) ((dccard(i,j),i=1,8),j=1,jdc) endif write (l15) swdata,xend,blnk10,blnk10 call closts (l15,0) return end
* Copyright (c) Colorado School of Mines, 2010. * All rights reserved. c................................................................... subroutine plasol(n,xr,xs,zs,c,v,x,noconv) c........................................................................... c Plasol finds the coordinates of the ray in the stratified c medium. it follows the procedure outlined in appendix a of c John Fawcett's thesis ( 3D Ray Tracing and Ray inversion c in Layered Media, Caltech, 1983). c........................................................................... integer n real xr, xs, zs, c(0:n+1), : v(n+1), x(0:n+1) logical noconv c........................................................................... cc Local variables c A() ratio of layer velocity to velocity in layer one c AMIN largest value of sin(takeoff angle) - one over c maximum value of A. c CLOSE a measure of how close ray is to receiver c DELTAX change in sin(takeoff angle)- see reference above c DFDX derivative of x distance travelled c DIST distance between source and end of ray c FX function that calculates the distance travelled (DIST) c by the ray c IBIS counts number of bisections c I loop variable c K loop variable c INEWT counts number of newton iterations c IBIS counts number of bisections c INTVAL number of intervals to divide range of values c of sine of takeoff angle c MAXBIS maximum allowed number of bisections c MAXNP1 maximum value of N plus one c MAXNWT maximum allowed number of newton iterations c NP1 N plus one c OFFSET distance (positive) between source and receiver c SIGN + or - one, depending on receiver location c THICK() thickness of layers c VCLOSE if the ray is this close to the receiver then c we've found the solution. c VMAX maximum layer velocity c X1,X2 values of sin(takeoff angle) used in bisection c XNEW next value to use in bisection or newton iteration c........................................................................... integer maxnp1 parameter( maxnp1 = 51) real a(maxnp1), thick(maxnp1) real fx real amin, close, deltax, : dfdx, dist, offset, sign, : vclose, vmax, : x1, x2, xnew parameter ( close = 10., : vclose = 1. ) integer i, inewt, intval, maxbis, : maxnwt, ibis, np1, k parameter ( maxbis = 100, : maxnwt = 100, : intval = 10 ) c noconv = .false. np1 = n + 1 c initialize the iteration counters ibis = 0 inewt = 0 c c The depths of the interfaces at the x coordinate of the source c are supplied by the main program. C(1) is the shallowest, etc. c Calculate the layer thicknesses from depths. c thick(1) = c(1) do 30 i = 2, n thick(i) = c(i) - c(i-1) 30 continue c Bottom of last layer set at depth of source. thick(np1) = zs - c(n) c If receiver is above source then all x coordinates are equal. if(xr.eq.xs) then do 40 i = 0, np1 x(i) = xr 40 continue return end if c c Setting alpha (in Fawcett's thesis). c a(1) = 1. do 50 i = 2, np1 a(i) = v(i) / v(1) 50 continue c Find the maximum velocity. vmax = v(1) do 60 i = 2, np1 if(vmax.lt.v(i)) then vmax = v(i) end if 60 continue c c Setting minimum of 1 / alpha c amin = v(1) / vmax offset = abs( xs - xr ) c Divide up the interval. deltax = amin / intval c Find part of interval on which solution lies. x2 = deltax dist = fx(x2,a,thick,np1) i = 2 80 if(dist.lt.offset.and.i.lt.intval) then x2 = x2 + deltax dist = fx(x2,a,thick,np1) i = i + 1 go to 80 end if if(dist.lt.offset) then c X lies inside last interval. x2 = .9999 * amin dist = fx(x2,a,thick,np1) if(dist.lt.offset) then c ray is too close to grazing noconv = .true. return end if end if x1 = ( i - 2 ) * deltax c c Use bisection to get close. c if(abs(dist-offset).lt.close) then c ?????? else xnew = ( x2 + x1 ) / 2. dist = fx(xnew,a,thick,np1) 100 if(abs(dist-offset).lt.close) then else ibis = ibis + 1 if(ibis.gt.maxbis) then noconv = .true. return end if if((dist-offset).lt.0.) then x1 = xnew else x2 = xnew end if xnew = ( x2 + x1 ) / 2. dist = fx(xnew,a,thick,np1) go to 100 end if end if c c Use newton's method to get very close. c 140 if(abs(dist-offset).le.vclose) then c ??????? else inewt = inewt + 1 if(inewt.gt.maxnwt) then noconv = .true. return end if dfdx = 0.0 do 150 k = 1, np1 dfdx = dfdx+thick(k)*a(k)/(1-(a(k)*xnew)**2)**1.5 150 continue xnew = xnew - ( dist - offset ) / dfdx c do 160 k = 1, np1 if(abs(a(k)*xnew).ge.1.0) then c Newton's method can be unpredictable. c If the above product is greater than 1., we c get into trouble with square roots below. noconv = .true. return end if 160 continue dist = fx(xnew,a,thick,np1) go to 140 end if c if((xs-xr).lt.0.) then sign = - 1.0 else sign = 1.0 end if c x(1) = xr + sign * thick(1) * a(1) * xnew / : sqrt( 1. - ( a(1) * xnew )**2 ) do 200 i = 2, n x(i) = x(i-1) + sign * thick(i) * a(i) * xnew / : sqrt( 1. - ( a(i) * xnew )**2 ) 200 continue x(np1) = xs x(0) = xr return end
! @@name: nowait.1f ! @@type: F-fixed ! @@compilable: yes ! @@linkable: no ! @@expect: success SUBROUTINE NOWAIT_EXAMPLE(N, M, A, B, Y, Z) INTEGER N, M REAL A(*), B(*), Y(*), Z(*) INTEGER I !$OMP PARALLEL !$OMP DO DO I=2,N B(I) = (A(I) + A(I-1)) / 2.0 ENDDO !$OMP END DO NOWAIT !$OMP DO DO I=1,M Y(I) = SQRT(Z(I)) ENDDO !$OMP END DO NOWAIT !$OMP END PARALLEL END SUBROUTINE NOWAIT_EXAMPLE
subroutine crs_proc( i, de, d_crs ) implicit none integer i real*8 de, d_crs write (6,1) write (6,*) 'CRS_PROC: You must use your own routine crs_proc!' write (6,1) stop 1 format(80('*')) end
C MEMBER SU1626 C (from old member FCSU1626) C SUBROUTINE SU1626(WORK,IUSEW,LEFTW,IERR) C C--------------------------------------------------------------------- C SUBROUTINE TO GET PARAMETERS, TIME-SERIES, AND CARRYOVER VALUES C FOR SCHEME/UTILITY #16 - RAINFALL/EVAPORATION ON SURFACE UTILITY C--------------------------------------------------------------------- C ARGS: C WORK - ARRAY TO HOLD INFORMATION C IUSEW - NUMBER OF WORDS ALREADY USED IN WORK ARRAY C LEFTW - NUMBER OF WORDS LEFT IN WORK ARRAY C------------------------------------------------------------------- C JTOSTROWSKI - HRL - MARCH 1983 C---------------------------------------------------------------- C THE FOLLOWING CHANGE MADE ON 10/17/90 C INCLUDE 'common/comn26' C C END OF CHANGE OF 10/17/90 C INCLUDE 'common/err26' C C INCLUDE 'common/fld26' C C INCLUDE 'common/read26' C C INCLUDE 'common/suid26' C C INCLUDE 'common/suin26' C C INCLUDE 'common/suky26' C C INCLUDE 'common/warn26' C C DIMENSION ENDSU(3),TNAME(3),ISU(3) DIMENSION WORK(1) C LOGICAL ENDFND,NEEDEP C C ================================= RCS keyword statements ========== CHARACTER*68 RCSKW1,RCSKW2 DATA RCSKW1,RCSKW2 / ' .$Source: /fs/hseb/ob72/rfc/ofs/src/fcinit_res/RCS/su1626.f,v $ . $', ' .$Id: su1626.f,v 1.1 1995/09/17 18:53:03 dws Exp $ . $' / C =================================================================== C C C DATA ENDSU/4HENDR,4HAIN ,4H / C C INITIALIZE NO. OF WORDS FOR HOLDING PARMS, TIME-SERIES, AND CARRYOVER C FOR THIS SCHEME/UTILITY. C NPARXX = 0 NTSXX = 0 C C WILL ALWAYS BE AT LEAST TW0 TS ID'S TO BE SCANNED FOR THIS S/U. C NTSPXX = 2 C NCOXX = 0 C THE FOLLOWING CHANGE MADE ON 10/17/90 C NEEDEP = .FALSE. NEEDEP = .TRUE. C END OF CHANGE OF 10/17/90 C USEDUP = .FALSE. ENDFND = .FALSE. NPACK = 3 C DO 3 I = 1,3 ISU(I) = 0 3 CONTINUE C C C-------------------------------------------------------------------- C NOW PROCESS INPUT UP TO 'ENDRAIN ',LOOKING FOR, IN ORDER, KEYWORDS C FOR PARMS, TIME-SERIES, AND CARRYOVER. C IERR = 0 C C SU FOUND , LOOKING FOR ENDSU C LPOS = LSPEC + NCARD + 1 LASTCD = NSPEC -2 IBLOCK = 1 C 5 IF (NCARD .LT. LASTCD) GO TO 6 CALL STRN26(59,1,ENDSU,3) IERR = 1 GO TO 9 6 NUMFLD = 0 CALL UFLD26(NUMFLD,IERF) IF(IERF .GT. 0 ) GO TO 9000 ISAME = IUSAME(CHAR,ENDSU,2) IF(ISAME .EQ. 1) GO TO 9 C C INSTEAD OF ENDSU, WE FIND OTHER SU W/O (). C IF (LLPAR .GT. 0 .AND. LRPAR .GT. 0) GO TO 7 NUMWD = (LEN -1)/4 + 1 IDEST = IKEY26(CHAR,NUMWD,SUID,LSUID,NSUID,NDSUID) IF (IDEST .EQ. 0) GO TO 5 CALL STRN26(59,1,ENDSU,3) IERR = 99 GO TO 9 C C INSTEAD OF ENDSU, WE FIND OTHER SU WITH (). C 7 CALL IDWP26(TNAME,NPACK,JNAME,INTVAL,IERID) IF (JNAME .EQ. 0) GO TO 5 CALL STRN26(59,1,ENDSU,3) IERR = 99 C 9 LENDSU = NCARD C C ENDSU CARD OR OTHER SU FOUND AT LENDSU, C ALSO ERR RECOVERY IF THERE'S NO ENDSU FOUND. C C NOW WE'RE LOOKING FOR PARMS, TIME-SERIES AND CARRYOVER. C IBLOCK = 2 CALL POSN26(MUNI26,LPOS) NCARD = LPOS - LSPEC -1 C 10 CONTINUE NUMFLD = 0 CALL UFLD26(NUMFLD,IERF) IF(IERF .GT. 0) GO TO 9000 NUMWD = (LEN -1)/4 + 1 IDEST = IKEY26(CHAR,NUMWD,SUKYWD,LSUKEY,NSUKEY,NDSUKY) IF(IDEST .GT. 0) GO TO 50 IF (NCARD .GE. LENDSU) GO TO 900 C C BAD BLOCK STRUCTURE, DESIRED BLOCK WILL BE DETERMINED SOON. C CALL STER26(82,1) GO TO 10 C C NOW SEND TO CONTROL TO LOCATION TO PROCESS PROPER KEYWORD C 50 CONTINUE IF (IDEST .LT. 7) GO TO 60 C C BAD BLOCK STRUCTURE FOR PM,TS OR CO. C IDST = (IDEST-7)/2 ISUKY = 2 * IDST + 1 CALL STRN26(94,1,SUKYWD(1,ISUKY),3) GO TO 10 60 GO TO (100,100,200,200,300,300) , IDEST C-------------------------------------------------------------------- C PARMS EXPECTED, IF NOT FOUND, INDICATE NO EVAP TO BE USED (WILL BE C CHANGED IF AN EVAP TIME-SERIES IS FOUND), AND C SET THE ITERATION TOLERANCE (10% (0.10)). C IF FOUND, GO GET PARM NEEDED FOR OPERATION. C 100 CONTINUE ISU(1) = ISU(1) + 1 IF (ISU(1).GT.1) CALL STER26(39,1) C C PARMS SHOULD COME BEFORE TIME-SERIES IN THIS SU IF PARMS IS NEEDED. C IF (ISU(2).GT.0) CALL STRN26(103,1,SUKYWD(1,3),LSUKEY(3)) C PMLOC = IUSEW + 1.01 CALL RFIL26(WORK,LOCPXX,PMLOC) C CALL PM1626(WORK,IUSEW,LEFTW,NPARXX,NEEDEP,LOCWHC, . LENDSU,JDEST,IERPM) C C WE'RE AT LENDSU WHEN IERPM IS 99 C IF (IERPM.EQ.99) GO TO 900 C IF (IERPM.NE.89) GO TO 10 C C BAD BLOCK STRUCTURE OF PM WHEN IERPM IS 89 WHERE TS OR CO FOUND. C IDEST = JDEST GO TO 50 C C----------------------------------------------------------------------- C TIME-SERIES INFORMATION EXPECTED NEXT. IF NOT FOUND, SIGNAL ERROR. C IF FOUND, CALL ROUTINE TO INPUT ALL REQUIRED AND OPTIONAL TIME-SERIES C 200 CONTINUE ISU(2) = ISU(2) + 1 IF (ISU(2).GT.1) CALL STER26(39,1) C IF (ISU(1).GT.0) GO TO 250 C C FILL 'WHICH' AND 'TOL' IN WORK ARRAY IF PARMS NOT ENTERED. C PMLOC = IUSEW + 1.01 CALL RFIL26(WORK,LOCPXX,PMLOC) CALL FLWK26(WORK,IUSEW,LEFTW,-1.01,501) LOCWHC = IUSEW C THE FOLLOWING CHANGE MADE ON 10/17/90 NEDIST=24/MINODT EDIST=1./NEDIST DO 210 I=1,NEDIST 210 CALL FLWK26(WORK,IUSEW,LEFTW,EDIST,501) C END OF CHANGE OF 10/17/90 CALL FLWK26(WORK,IUSEW,LEFTW,0.10,501) NEEDEP = .TRUE. C THE FOLLOWING CHANGE MADE ON 10/17/90 C NPARXX = 2 NPARXX = 2+NEDIST C END OF CHANGE OF 10/17/90 C 250 CONTINUE TSLOC = IUSEW + 1.01 CALL RFIL26(WORK,LOCTXX,TSLOC) C CALL TS1626(WORK,IUSEW,LEFTW,NTSXX,NEEDEP,LOCWHC,IFND2, . LENDSU,JDEST,IERTS) C IF (IFND2.GT.0) NTSPXX = NTSPXX + 1 C C WE'RE AT LENDSU WHEN IERTS IS 99 C IF (IERTS.EQ.99) GO TO 900 C IF (IERTS.NE.89) GO TO 10 C C BAD BLOCK STRUCTURE OF TS WHEN IERTS IS 89 WHERE PM OR CO FOUND. C IDEST = JDEST GO TO 50 C C------------------------------------------------------------------ C NO CARRYOVER NEEDED. IF FOUND,SIGNAL ERROR. C 300 CONTINUE C CALL STER26(56,1) GO TO 10 C C--------------------------------------------------------------- C SUMMARY C 900 CONTINUE IF (ISU(2).EQ.0) CALL STER26(36,1) C GO TO 9999 C C--------------------------------------------------------------------- C ERROR IN UFLD26 C 9000 CONTINUE IF (IERF.EQ.1) CALL STER26(19,1) IF (IERF.EQ.2) CALL STER26(20,1) IF (IERF.EQ.3) CALL STER26(21,1) IF (IERF.EQ.4) CALL STER26( 1,1) C IF (NCARD.GE.LASTCD) GO TO 9100 IF (IBLOCK.EQ.1) GO TO 5 IF (IBLOCK.EQ.2) GO TO 10 C 9100 USEDUP = .TRUE. C 9999 CONTINUE RETURN END
SUBROUTINE FCLOSE(I,NNB) * * * Force & first derivative from close bodies. * ------------------------------------------- * INCLUDE 'common6.h' REAL*8 A(9) * * * Initialize F & FDOT for body #I. DO 10 K = 1,3 F(K,I) = 0.0D0 FDOT(K,I) = 0.0D0 10 CONTINUE * * Obtain F & FDOT due to NNB members of JLIST. DO 50 L = 1,NNB J = JLIST(L) IF (J.EQ.I) GO TO 50 * RIJ2 = 0.0D0 RIJDOT = 0.0D0 DO 20 K = 1,3 A(K) = X(K,J) - X(K,I) A(K+3) = XDOT(K,J) - XDOT(K,I) RIJ2 = RIJ2 + A(K)**2 RIJDOT = RIJDOT + A(K)*A(K+3) 20 CONTINUE A(8) = BODY(J)/(RIJ2*SQRT(RIJ2)) A(9) = 3.0*RIJDOT/RIJ2 * * Set approximate F & FDOT to be used by body #I in FPOLY2. DO 30 K = 1,3 F(K,I) = F(K,I) + A(K)*A(8) FDOT(K,I) = FDOT(K,I) + (A(K+3) - A(K)*A(9))*A(8) 30 CONTINUE 50 CONTINUE * * Initialize time of last force (prevents prediction in FPOLY2). T0(I) = TIME * RETURN * END
SUBROUTINE G13DBV(A,IA,B,IB,N) C MARK 11 RELEASE. NAG COPYRIGHT 1983. C MARK 11.5(F77) REVISED. (SEPT 1985.) C C COPIES UPPER TRIANGLE OF TOP LEFT (N,N) SQUARE C OF MATRIX A INTO FULL SYMMETRIC FORM IN TOP LEFT C (N,N) SQUARE IN MATRIX B. A AND B MAY BE C IDENTICAL C C .. Scalar Arguments .. INTEGER IA, IB, N C .. Array Arguments .. DOUBLE PRECISION A(IA,N), B(IB,N) C .. Local Scalars .. INTEGER I, J C .. Executable Statements .. DO 40 I = 1, N DO 20 J = I, N B(J,I) = A(I,J) B(I,J) = A(I,J) 20 CONTINUE 40 CONTINUE CONTINUE RETURN END
PROGRAM CCPRC 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) PARAMETER (LRWK=3500,LIWK=4000,LMAP=75000) PARAMETER (M=50,N=50) REAL X(M),Y(N),Z(M,N), RWRK(LRWK) INTEGER IWRK(LIWK), MAP(LMAP) EXTERNAL CPDRPL CALL GETDAT (X, Y, Z, M, N, RWRK, IWRK, LRWK, LIWK) C C Open GKS C CALL GOPKS (IERRF, ISZDM) CALL GOPWK (IWKID, LUNIT, IWTYPE) CALL GACWK (IWKID) C C Initialize Areas C CALL ARINAM(MAP,LMAP) C C Choose which labelling scheme will be used. C CALL CPSETI('LLP - LINE LABEL POSITIONING FLAG',2) CALL CPSETR('RC1 - REGULAR SCHEME CONSTANT 1',.1) C C Initialize Conpack C CALL CPRECT(Z, M, M, N, RWRK, LRWK, IWRK, LIWK) C C Force Conpack to chose contour levels C CALL CPPKCL(Z, RWRK, IWRK) C C Modify Conpack chosen parameters C CALL CPGETI('NCL - NUMBER OF CONTOUR LEVELS',NCONS) DO 12, I=1,NCONS CALL CPSETI('PAI - PARAMETER ARRAY INDEX',I) C C Force every line to be labeled. C CALL CPSETI('CLU - CONTOUR LEVEL USE FLAG',3) 12 CONTINUE C C Draw Perimeter C CALL CPBACK(Z, RWRK, IWRK) C C Add contours and labels to area map C CALL CPCLAM(Z, RWRK, IWRK, MAP) CALL CPLBAM(Z, RWRK, IWRK, MAP) C C Draw Contours C CALL CPCLDM(Z, RWRK, IWRK, MAP, CPDRPL) CALL CPLBDR(Z,RWRK,IWRK) C C Close frame and close GKS C CALL FRAME CALL GDAWK (IWKID) CALL GCLWK (IWKID) CALL GCLKS WRITE (6,*) 'AREA MAP SIZE =',MAP(1) - MAP(6) + MAP(5) STOP END SUBROUTINE GETDAT (X,Y,Z,M,N,RWRK,IWRK,LRWK,LIWK) PARAMETER (NRAN=30) REAL XRAN(NRAN), YRAN(NRAN), ZRAN(NRAN) REAL X(M), Y(N), Z(M,N), RWRK(LRWK) REAL XDELTA(50) INTEGER IWRK(LIWK) DATA XRAN /12., 60., 14., 33., 8., 12., 43., 57., 22., 15., + 19., 12., 64., 19., 15., 55., 31., 32., 33., 29., + 18., 1., 18., 42., 56., 9., 6., 12., 44., 19./ DATA YRAN / 1., 2., 3., 53., 7., 11., 13., 17., 19., 49., + 1., 31., 37., 5., 7., 47., 61., 17., 5., 23., + 29., 3., 5., 41., 43., 9., 13., 59., 1., 67./ DATA ZRAN /1.0, 1.5, 1.7, 1.4, 1.9, 1.0, 1.5, 1.2, 1.8, 1.4, + 1.8, 1.7, 1.9, 1.5, 1.2, 1.1, 1.3, 1.7, 1.2, 1.6, + 1.9, 1.0, 1.6, 1.3, 1.4, 1.8, 1.7, 1.5, 1.1, 1.0/ DATA XDELTA/.00,.02,.04,.06,.08,.10,.12,.14,.16,.18,.20, + .22,.24,.26,.28,.30,.32,.34,.36,.38,.40,.42, + .44,.46,.48,.50,.52,.54,.56,.58,.60,.62,.64, + .66,.68,.70,.72,.74,.76,.78,.80,.82,.84,.86, + .88,.90,.92,.94,.96,.98/ C C Set the min and max data values. C XMIN = 0.0 XMAX = 65.0 YMIN = 0.0 YMAX = 68.0 C C Choose the X and Y coordinates for interpolation points on the C regular grid. C DO 101 I=1,M X(I)=XMIN + (XMAX - XMIN)*XDELTA(I) 101 CONTINUE C DO 102 I=1,N Y(I)=YMIN + (YMAX - YMIN)*XDELTA(I) 102 CONTINUE C C Interpolate data onto a regular grid C CALL IDSFFT (1,NRAN,XRAN,YRAN,ZRAN,M,N,M,X,Y,Z,IWRK,RWRK) RETURN END
Subroutine CPF(X,Y,WR,WI) C------------------------------------------------- C "CPF": Complex Probability Function C ......................................................... C . Subroutine to Compute the Complex . C . Probability Function W(z=X+iY) . C . W(z)=exp(-z**2)*Erfc(-i*z) with Y>=0 . C . Which Appears when Convoluting a Complex . C . Lorentzian Profile by a Gaussian Shape . C ................................................. C C WR : Real Part of W(z) C WI : Imaginary Part of W(z) C C This Routine was Taken from the Paper by J. Humlicek, which C is Available in Page 309 of Volume 21 of the 1979 Issue of C the Journal of Quantitative Spectroscopy and Radiative Transfer C Please Refer to this Paper for More Information C C Accessed Files: None C -------------- C C Called Routines: None C --------------- C C Called By: 'CompAbs' (COMPute ABSorpton) C --------- C C Double Precision Version C C------------------------------------------------- C Implicit None Integer I double complex zm1,zm2,zterm,zsum,zone,zi Double Precision X,Y,WR,WI Double Precision T,U,S,Y1,Y2,Y3,R,R2,D,D1,D2,D3,D4 Double Precision TT(15),pipwoeronehalf C Dimension T(6),U(6),S(6) Data T/.314240376d0,.947788391d0,1.59768264d0,2.27950708d0 , ,3.02063703d0,3.8897249d0/ Data U/1.01172805d0,-.75197147d0,1.2557727d-2,1.00220082d-2 , ,-2.42068135d-4,5.00848061d-7/ Data S/1.393237d0,.231152406d0,-.155351466d0,6.21836624d-3 , ,9.19082986d-5,-6.27525958d-7/ Data zone,zi/(1.d0,0.D0),(0.d0,1.D0)/ data tt/0.5d0,1.5d0,2.5d0,3.5d0,4.5d0,5.5d0,6.5d0,7.5d0,8.5d0, , 9.5d0,10.5d0,11.5d0,12.5d0,13.5d0,14.5d0/ data pipwoeronehalf/0.564189583547756d0/ C new Region 3 if(dsqrt(x*x+y*Y).gt.8.D0)then zm1=zone/dcmplx(x,y) zm2=zm1*zm1 zsum=zone zterm=zone do i=1,15 zterm=zterm*zm2*tt(i) zsum=zsum+zterm end do zsum=zsum*zi*zm1*pipwoeronehalf wr=dreal(zsum) wi=dimag(zsum) return end if C WR=0.d0 WI=0.d0 Y1=Y+1.5d0 Y2=Y1*Y1 If( (Y.GT.0.85d0) .OR. (DABS(X).LT.(18.1d0*Y+1.65d0)) )GoTo 2 C C Region 2 C If( DABS(X).LT.12.d0 )WR=DEXP(-X*X) Y3=Y+3.d0 Do 1 I=1,6 R=X-T(I) R2=R*R D=1.d0/(R2+Y2) D1=Y1*D D2=R*D WR=WR+Y*(U(I)*(R*D2-1.5d0*D1)+S(I)*Y3*D2)/(R2+2.25d0) R=X+T(I) R2=R*R D=1.d0/(R2+Y2) D3=Y1*D D4=R*D WR=WR+Y*(U(I)*(R*D4-1.5d0*D3)-S(I)*Y3*D4)/(R2+2.25d0) WI=WI+U(I)*(D2+D4)+S(I)*(D1-D3) 1 Continue Return C C Region 1 C 2 Continue Do 3 I=1,6 R=X-T(I) D=1.d0/(R*R+Y2) D1=Y1*D D2=R*D R=X+T(I) D=1.d0/(R*R+Y2) D3=Y1*D D4=R*D WR=WR+U(I)*(D1+D3)-S(I)*(D2-D4) WI=WI+U(I)*(D2+D4)+S(I)*(D1-D3) 3 Continue Return End
#include "cppdefs.h" MODULE esmf_roms_mod #if defined MODEL_COUPLING && defined ESMF_LIB ! !svn $Id: esmf_roms.F 889 2018-02-10 03:32:52Z arango $ !======================================================================= ! Copyright (c) 2002-2018 The ROMS/TOMS Group ! ! Licensed under a MIT/X style license Hernan G. Arango ! ! See License_ROMS.txt Ufuk Utku Turuncoglu ! !======================================================================= ! ! ! This module sets ROMS as the ocean gridded component using generic ! ! ESMF/NUOPC layer: ! ! ! ! ROMS_SetServices Sets ROMS component shared-object entry ! ! points using NUPOC generic methods for ! ! "initialize", "run", and "finalize". ! ! ! ! ROMS_SetInitializeP1 ROMS component phase 1 initialization: ! ! sets import and export fields long and ! ! short names into its respective state. ! ! ! ! ROMS_SetInitializeP2 ROMS component phase 2 initialization: ! ! Initializes component (ROMS_initialize), ! ! sets component grid (ROMS_SetGridArrays), ! ! and adds fields into import and export ! ! into respective states. ! ! ! ! ROMS_DataInit Exports ROMS component fields during ! ! initialization or restart. ! ! ! ! ROMS_SetClock Sets ROMS component date calendar, start ! ! and stop times, and coupling interval. ! ! ! ! ROMS_CheckImport Checks if ROMS component import field is ! ! at the correct time. ! ! ! ! ROMS_SetGridArrays Sets ROMS component staggered, horizontal ! ! grid arrays, grid area, and land/sea mask ! ! if any. ! ! ! ! ROMS_SetStates Adds ROMS component export and import ! ! fields into its respective state. ! ! ! ! ROMS_ModelAdvance Advances ROMS component for a coupling ! ! interval. It calls import and export ! ! routines. ! ! ! ! ROMS_SetFinalize Finalizes ROMS component execution. ! ! ! ! ROMS_GetGridNumber Gets ROMS nested grid number from ! ! component name label. ! ! ! ! ROMS_import Imports fields into ROMS. The fields are ! ! loaded into the snapshot storage arrays ! ! to allow time interpolation elsewhere. ! ! ! ! ROMS_export Exports ROMS fields to other gridded ! ! components. ! ! ! ! ESMF: Earth System Modeling Framework (Version 7 or higher) ! ! https://www.earthsystemcog.org/projects/esmf ! ! ! ! NUOPC: National Unified Operational Prediction Capability ! ! https://www.earthsystemcog.org/projects/nuopc ! ! ! ! ROMS: Regional Ocean Modeling System ! ! https://www.myroms.org ! ! ! !======================================================================= ! ! ! WARNING: Th ROMS NUOPC cap file will be released in the future. We ! are completely rewriting the coupling interface using the ! ESMF library with the NUOCP layer. ! #endif END MODULE esmf_roms_mod
LOCAL INCLUDE 'MODSP.INC' C Local include for MODSP INCLUDE 'INCS:PMAD.INC' INTEGER MAXGAU PARAMETER (MAXGAU = 9999) C HOLLERITH XNAME1(3), XCLAS1(2), XNAME2(3), XCLAS2(2), XNAMOU(3), * XINLST(12) REAL XSEQ1, XDISK1, XSEQ2, XDISK2, XSEQO, XDISKO, BLC(7), * TRC(7), FLUX, FACTOR, COORD(6), XIMSIZ(2), CELLS(2), APARM(10) REAL BUFF(MABFSL), FLUXR(MAXGAU), FLUXL(MAXGAU), * FPOS(2,MAXGAU), FWID(3,MAXGAU), CHLINE(3,MAXGAU), * WLINE(3,MAXGAU) INTEGER SEQI(2), SEQO(2), DISKI(2), DISKO(2), NPOL, NEWCNO(2), * OLDCNO(2), JBUFSZ, CATOLD(256,2), CATNEW(256,2), NGAUSS, * SCRTCH(256), ICODES(MAXGAU) CHARACTER NAMEI(2)*12, CLASI(2)*6, NAMOUT*12, CLASO(2)*6, * INLIST*48 LOGICAL DONEW, IVIN COMMON /INPARM/ XNAME1, XCLAS1, XSEQ1, XDISK1, XNAME2, XCLAS2, * XSEQ2, XDISK2, XNAMOU, XSEQO, XDISKO, BLC, TRC, FLUX, FACTOR, * XINLST, COORD, XIMSIZ, CELLS, APARM COMMON /CHRCOM/ NAMEI, CLASI, NAMOUT, CLASO, INLIST COMMON /PARMS/ CATOLD, CATNEW, SEQI, SEQO, DISKI, DISKO, NPOL, * NEWCNO, OLDCNO, JBUFSZ, DONEW, NGAUSS, IVIN COMMON /BUFRS/ FLUXR, FLUXL, FPOS, FWID, CHLINE, WLINE, ICODES, * BUFF, SCRTCH INCLUDE 'INCS:DCAT.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DDCH.INC' INCLUDE 'INCS:DHDR.INC' C End MODSP LOCAL END PROGRAM MODSP C----------------------------------------------------------------------- C! Adds a model to a pair of new or old I/V or RR/LL image cubes C# Map Modeling C----------------------------------------------------------------------- C; Copyright (C) 2014-2015 C; Associated Universities, Inc. Washington DC, USA. C; C; This program is free software; you can redistribute it and/or C; modify it under the terms of the GNU General Public License as C; published by the Free Software Foundation; either version 2 of C; the License, or (at your option) any later version. C; C; This program is distributed in the hope that it will be useful, C; but WITHOUT ANY WARRANTY; without even the implied warranty of C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the C; GNU General Public License for more details. C; C; You should have received a copy of the GNU General Public C; License along with this program; if not, write to the Free C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, C; MA 02139, USA. C; C; Correspondence concerning AIPS should be addressed as follows: C; Internet email: aipsmail@nrao.edu. C; Postal address: AIPS Project Office C; National Radio Astronomy Observatory C; 520 Edgemont Road C; Charlottesville, VA 22903-2475 USA C----------------------------------------------------------------------- C MODSP is an AIPS task to modify an image by a model - specifically C a spectral model with Zeeman options C Inputs: C AIPS adverb Prg. name. Description. C INNAME NAMEI Name of Q input image. C INCLASS CLASI Class of Q input image. C INSEQ SEQI Seq. of Q input image. C INDISK DISKI Disk number of Q input image. C IN2NAME NAMEI Name of U input image. C IN2CLASS CLASI Class of U input image. C IN2SEQ SEQI Seq. of U input image. C IN2DISK DISKI Disk number of U input image. C OUTNAME NAMOUT Name of the output image C Default output is input image. C OUTCLASS CLASO Class of the output image. C Default is input class. C OUTSEQ SEQO Seq. number of output image. C OUTDISK DISKO Disk number of the output image. C BLC(7) BLC Bottom left corner of subimage C of input image. C TRC(7) TRC Top right corner of subimage. C FLUX FLUX Noise level in Jy/Pix. C FACTOR FACTOR Multiplying factor for previous C data. C----------------------------------------------------------------------- CHARACTER PRGM*6 INTEGER IRET, NX, NY, NEED LONGINT PIMAGE REAL IMAGE(2) INCLUDE 'MODSP.INC' INCLUDE 'INCS:DFIL.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DDCH.INC' INCLUDE 'INCS:DHDR.INC' DATA PRGM /'MODSP '/ C----------------------------------------------------------------------- C Get inputs, create output file CALL MODSPI (PRGM, IRET) IF (IRET.NE.0) GO TO 990 C get memory for 2 planes NX = CATBLK(KINAX) NY = CATBLK(KINAX+1) NEED = (NX * NY - 1) / 1024 + 2 NEED = 2 * NEED CALL ZMEMRY ('GET ', TSKNAM, NEED, IMAGE, PIMAGE, IRET) IF (IRET.NE.0) THEN MSGTXT = 'FAILED TO GET NEEDED DYNAMIC MEMORY' CALL MSGWRT (8) GO TO 990 END IF C Apply model to image CALL MODSPD (NX, NY, IMAGE(1+PIMAGE), IRET) C Add history IF (IRET.EQ.0) CALL MODSPH C Close down files, etc. 990 CALL DIE (IRET, SCRTCH) C 999 STOP END SUBROUTINE MODSPI (PRGN, IRET) C----------------------------------------------------------------------- C MODSPI gets input parameters for MODSP and creates an output file. C Inputs: C PRGN C*6 Program name C Output: C IRET I Error code: 0 => ok C 4 => user routine detected error. C 5 => catalog troubles C 8 => can't start C Commons: /INPARM/ all input adverbs in order given by INPUTS C file C /MAPHDR/ output file catalog header C----------------------------------------------------------------------- CHARACTER PRGN*6 INTEGER IRET C CHARACTER STAT*4, MTYPE*2 INTEGER IERR, NPARM, IROUND, I, IST REAL STV(2) INCLUDE 'MODSP.INC' INCLUDE 'INCS:DFIL.INC' C----------------------------------------------------------------------- C Init for AIPS, disks, ... CALL ZDCHIN (.TRUE.) CALL VHDRIN JBUFSZ = 2 * MABFSL IRET = 0 C Initialize /CFILES/ NSCR = 0 NCFILE = 0 C Get input parameters. NPARM = 67 CALL GTPARM (PRGN, NPARM, RQUICK, XNAME1, SCRTCH, IERR) IF (IERR.NE.0) THEN RQUICK = .TRUE. IRET = 8 IF (IERR.EQ.1) GO TO 999 WRITE (MSGTXT,1000) IERR CALL MSGWRT (8) END IF C Restart AIPS IF (RQUICK) CALL RELPOP (IRET, SCRTCH, IERR) IF (IRET.NE.0) GO TO 999 IRET = 5 NPOL = 1 C Crunch input parameters. SEQI(1) = IROUND (XSEQ1) SEQI(2) = IROUND (XSEQ2) SEQO(1) = IROUND (XSEQO) SEQO(2) = IROUND (XSEQO) DISKI(1) = IROUND (XDISK1) DISKI(2) = IROUND (XDISK1) DISKO(1) = IROUND (XDISKO) DISKO(2) = IROUND (XDISKO) C Convert characters CALL H2CHR (12, 1, XNAME1, NAMEI(1)) CALL H2CHR (6, 1, XCLAS1, CLASI(1)) CALL H2CHR (12, 1, XNAME2, NAMEI(2)) CALL H2CHR (6, 1, XCLAS2, CLASI(2)) CALL H2CHR (12, 1, XNAMOU, NAMOUT) CLASO(1) = 'IMODEL' CLASO(2) = 'VMODEL' CALL H2CHR (48, 1, XINLST, INLIST) IF (INLIST.EQ.' ') THEN MSGTXT = 'AN INLIST MUST BE SPECIFIED' GO TO 990 END IF C get components, err msg if error CALL READIT (IERR) IF (IERR.NE.0) GO TO 990 WRITE (MSGTXT,1005) NGAUSS CALL MSGWRT (3) IF (NGAUSS.LE.0) THEN IRET = 10 GO TO 999 END IF DONEW = (NAMEI(1).EQ.' ') .OR. (NAMEI(2).EQ.' ') C Get CATBLK from old file. MTYPE = 'MA' IF (.NOT.DONEW) THEN DO 20 I = 1,2 OLDCNO(I) = 1 CALL CATDIR ('SRCH', DISKI(I), OLDCNO(I), NAMEI(I), * CLASI(I), SEQI(I), MTYPE, NLUSER, STAT, SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1010) IERR, NAMEI(I), CLASI(I), SEQI(I), * DISKI(I), NLUSER GO TO 990 END IF C Read CATBLK and mark 'READ'. CALL CATIO ('READ', DISKI(I), OLDCNO(I), CATOLD(1,I), * 'READ', SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1020) IERR, I GO TO 990 END IF NCFILE = NCFILE + 1 FVOL(NCFILE) = DISKI(I) FCNO(NCFILE) = OLDCNO(I) FRW(NCFILE) = 0 C check Stokes CALL COPY (256, CATOLD(1,I), CATBLK) CALL AXEFND (8, 'STOKES ', CATBLK(KIDIM), CATH(KHCTP), IST, * IERR) IF (IERR.EQ.0) THEN IF (CATBLK(KINAX+IST).NE.1) IERR = 10 STV(I) = CATD(KDCRV+IST) + (1.0-CATR(KRCRP+IST)) * * CATR(KRCIC+IST) END IF IF (IERR.NE.0) THEN MSGTXT = 'THERE MUST BE A 1-PIXEL STOKES AXIS' GO TO 990 END IF 20 CONTINUE IF ((STV(1).EQ.1.0) .AND. (STV(2).EQ.4.0)) THEN IVIN = .TRUE. ELSE IF ((STV(1).EQ.-11.0) .AND. (STV(2).EQ.-2.0)) THEN IVIN = .FALSE. ELSE MSGTXT = 'STOKES PAIRS MUST BE EITHER I/V OR RR/LL' GO TO 990 END IF C Make a new header ELSE IVIN = .FALSE. CALL RFILL (7, 0.0, BLC) CALL RFILL (7, 0.0, TRC) CALL NEWHDR END IF C Set defaults on BLC,TRC CALL WINDOW (CATOLD(KIDIM,1), CATOLD(KINAX,1), BLC, TRC, IERR) IF (IERR.NE.0) GO TO 999 C create outputs DO 40 I = 1,2 C Copy old CATBLK to new. CALL COPY (256, CATOLD(1,I), CATBLK) C Put new values in CATBLK. CALL MAKOUT (NAMEI(I), CLASI(I), SEQI(I), ' ', NAMOUT, * CLASO(I), SEQO(I)) CALL CHR2H (12, NAMOUT, KHIMNO, CATH(KHIMN)) CALL CHR2H (6, CLASO(I), KHIMCO, CATH(KHIMC)) CATBLK(KIIMS) = SEQO(I) C Get user modification to CATBLK IF (.NOT.DONEW) CALL IMMHED C Create output file. NEWCNO(I) = 1 IRET = 4 CALL MCREAT (DISKO(I), NEWCNO(I), SCRTCH, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1030) IERR, I GO TO 990 END IF NCFILE = NCFILE + 1 FVOL(NCFILE) = DISKO(I) FCNO(NCFILE) = NEWCNO(I) FRW(NCFILE) = 2 SEQO(I) = CATBLK(KIIMS) C set Stokes value CALL AXEFND (8, 'STOKES ', CATBLK(KIDIM), CATH(KHCTP), IST, * IERR) CATBLK(KDCRV+IST) = 1.0D0 + 3.0D0 * (I-1) CATR(KRCIC+IST) = 1.0 CATR(KRCRP+IST) = 1.0 C keywords copied mostly IF (.NOT.DONEW) CALL KEYPCP (DISKI(I), OLDCNO(I), DISKO(I), * NEWCNO(I), 0, ' ', IERR) CALL COPY (256, CATBLK, CATNEW(1,I)) 40 CONTINUE C init random number generator IF (FLUX.GT.0.0) CALL RANDIN (I) IRET = 0 GO TO 999 C Error 990 CALL MSGWRT (8) C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('MODSPI: ERROR',I3,' OBTAINING INPUT PARAMETERS') 1005 FORMAT ('Will use',I5,' model components') 1010 FORMAT ('ERROR',I3,' FINDING ',A12,'.',A6,'.',I3,' DISK=', * I3,' USID=',I5) 1020 FORMAT ('ERROR',I3,' COPYING CATBLK IMAGE',I2) 1030 FORMAT ('MODSPI: ERROR',I3,' CREATING OUTPUT FILE',I2) END SUBROUTINE NEWHDR C----------------------------------------------------------------------- C NEWHDR makes up image headers from scratch C----------------------------------------------------------------------- C INTEGER DATE(3), I CHARACTER STRNG*8 INCLUDE 'MODSP.INC' C----------------------------------------------------------------------- C blank slate CALL CATINI (CATBLK) CALL CHR2H (8, 'IVmodsp', 1, CATH(KHOBJ)) CALL CHR2H (8, 'JY/BEAM ', 1, CATH(KHBUN)) CALL ZDATE (DATE) WRITE (STRNG,1000) DATE CALL CHR2H (8, STRNG, 1, CATH(KHDMP)) CALL CHR2H (8, STRNG, 1, CATH(KHDOB)) CATR(KREPO) = 2000.0 CALL CHR2H (2, 'MA', KHPTYO, CATH(KHPTY)) CATBLK(KIDIM) = 4 C RA I = XIMSIZ(1) + 0.5 IF (I.LE.0) I = 512 CATBLK(KINAX) = I CATD(KDCRV) = (COORD(1)*15.D0 + COORD(2)/4.D0 + COORD(3)/240.D0) CATR(KRCRP) = (I + 1) / 2 IF (CELLS(1).EQ.0.0) CELLS(1) = 1. CATR(KRCIC) = -ABS(CELLS(1)) / 3600.0 CALL CHR2H (8, 'RA---SIN', 1, CATH(KHCTP)) C DEC I = XIMSIZ(2) + 0.5 IF (I.LE.0) I = 512 CATBLK(KINAX+1) = I CATD(KDCRV+1) = (COORD(4) + COORD(5)/60.D0 + COORD(6)/3600.D0) CATR(KRCRP+1) = (I + 2) / 2 IF (CELLS(1).EQ.0.0) CELLS(1) = 1. CATR(KRCIC+1) = ABS(CELLS(1)) / 3600.0 CALL CHR2H (8, 'DEC--SIN', 1, CATH(KHCTP+2)) C FREQ I = APARM(3) + 0.5 IF (I.LE.0) I = 512 CATBLK(KINAX+2) = I CATD(KDCRV+2) = APARM(1) * 1.D9 CATR(KRCRP+2) = 1.0 IF (APARM(2).EQ.0.0) APARM(2) = 0.001 CATR(KRCIC+2) = APARM(2) * 1.E9 CALL CHR2H (8, 'FREQ ', 1, CATH(KHCTP+4)) C STOKES CATBLK(KINAX+3) = 1 CATD(KDCRV+3) = 1.0D0 CATR(KRCRP+3) = 1.0 CATR(KRCIC+3) = 1.0 CALL CHR2H (8, 'STOKES ', 1, CATH(KHCTP+6)) C clean beam fake CATR(KRBMJ) = 3.0 * ABS (CATR(KRCIC)) CATR(KRBMN) = 3.0 * ABS (CATR(KRCIC)) C to output CALL COPY (256, CATBLK, CATOLD(1,1)) CATD(KDCRV+3) = 4.0D0 CALL COPY (256, CATBLK, CATOLD(1,2)) C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT (I4,2I2.2) END SUBROUTINE IMMHED C----------------------------------------------------------------------- C Adjust the output header for blc, trc C----------------------------------------------------------------------- C CHARACTER FCHARS(3)*4, CHTMP*4 INTEGER LIMIT, I, INDEX INCLUDE 'MODSP.INC' DATA FCHARS /'FREQ','VELO','FELO'/ C----------------------------------------------------------------------- C Set axes in output CATBLK. LIMIT = CATBLK(KIDIM) C Copy/update axis values DO 80 I = 1,LIMIT CATBLK(KINAX+I-1) = TRC(I) - BLC(I) + 1.01 CATR(KRCRP+I-1) = CATR(KRCRP+I-1) - BLC(I) + 1.0 IF (CATBLK(KIALT).NE.0) THEN INDEX = KHCTP + (I-1) * 2 CALL H2CHR (4, 1, CATH(INDEX), CHTMP) IF ((CHTMP.EQ.FCHARS(1)) .OR. (CHTMP.EQ.FCHARS(2)) .OR. * (CHTMP.EQ.FCHARS(3))) CATR(KRARP) = CATR(KRARP) - * BLC(I) + 1.0 END IF 80 CONTINUE C 999 RETURN END SUBROUTINE READIT (IRET) C----------------------------------------------------------------------- C Prepares list of components for adverbs or text file C Output C IRET I Error code C rest in Common C----------------------------------------------------------------------- INTEGER IRET C INCLUDE 'MODSP.INC' INTEGER TLUN, TIND, LUNTMP, LLIM, LP, I, JTRIM, J REAL BMAJ, BMIN, BPA, XINC CHARACTER LINE*132 DOUBLE PRECISION X C----------------------------------------------------------------------- C width defaults XINC = ABS (CATR(KRCIC)) BMAJ = 0.0 IF (XINC.GT.0.0) THEN BMAJ = CATR(KRBMJ) / XINC BMIN = CATR(KRBMN) / XINC BPA = CATR(KRBPA) END IF IF ((BMAJ.LE.0.0) .OR. (BMIN.LE.0.0)) THEN BMAJ = 3.0 BMIN = 3.0 BPA = 0.0 END IF C read text file TLUN = LUNTMP (2) C open the text file CALL ZTXOPN ('READ', TLUN, TIND, INLIST, .FALSE., IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'OPEN TEXT FILE' GO TO 999 END IF NGAUSS = 0 100 CALL ZTXIO ('READ', TLUN, TIND, LINE, IRET) IF ((IRET.EQ.0) .AND. (NGAUSS.LT.MAXGAU)) THEN LLIM = JTRIM (LINE) C blanks, comments IF (LLIM.LE.0) GO TO 100 IF (LINE(1:1).EQ.'#') GO TO 100 C parse C R flux LP = 1 CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN GO TO 100 ELSE NGAUSS = NGAUSS + 1 FLUXR(NGAUSS) = X END IF C L flux CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE FLUXL(NGAUSS) = X END IF C position CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE FPOS(1,NGAUSS) = X END IF CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE FPOS(2,NGAUSS) = X END IF C width CALL RFILL (3, 0.0, FWID(1,NGAUSS)) DO 110 J = 1,3 CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE FWID(J,NGAUSS) = X END IF 110 CONTINUE C model type ICODES(NGAUSS) = 0 IF (LP.LE.LLIM) THEN CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE ICODES(NGAUSS) = X + 0.01 END IF END IF IF ((ICODES(NGAUSS).LT.1) .OR. (ICODES(NGAUSS).GT.6)) * ICODES(NGAUSS) = 2 C line center CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE CHLINE(1,NGAUSS) = X CHLINE(2,NGAUSS) = 0.0 CHLINE(3,NGAUSS) = 0.0 END IF C line width CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN NGAUSS = NGAUSS - 1 GO TO 100 ELSE WLINE(1,NGAUSS) = MAX (0.5D0, X) WLINE(2,NGAUSS) = 0.0 WLINE(3,NGAUSS) = 0.0 END IF C derivatives DO 120 J = 1,4 CALL GETNUM (LINE, LLIM, LP, X) IF (X.EQ.DBLANK) THEN GO TO 100 ELSE IF (J.LE.2) THEN CHLINE(J+1,NGAUSS) = X ELSE WLINE(J-1,NGAUSS) = X END IF 120 CONTINUE GO TO 100 C real error ELSE IF ((IRET.GT.0) .AND. (IRET.NE.2)) THEN WRITE (MSGTXT,1000) IRET, 'READING TEXT FILE' GO TO 999 C EOF ELSE CALL ZTXCLS (TLUN, TIND, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'CLOSING TEXT FILE' GO TO 999 END IF END IF C check defaults DO 130 I = 1,NGAUSS IF ((FWID(1,I).LE.0.0) .OR. (FWID(2,I).LE.0.0)) THEN FWID(1,I) = BMAJ FWID(2,I) = BMIN FWID(3,I) = BPA END IF 130 CONTINUE C MSGWRT left to caller 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('READIT ERROR',I4,' ON ',A) END SUBROUTINE MODSPD (NX, NY, IMAGE, IRET) C----------------------------------------------------------------------- C MODSPD read in the input images one plane at a time, adds the model C appropriate to that plane, and then writes out the plane C Input: C NX I Number X pixels C NY I Nu,ber Y pixels C Output: C IMAGE R(*) Adequate memory for 2 planes C IRET I Return code, 0 => OK, otherwise abort. C----------------------------------------------------------------------- INTEGER NX, NY, IRET REAL IMAGE(NX,NY,2) C CHARACTER IFILE*48 INTEGER IROUND, LUNI(2), LUNO(2), NYI, NXI, WINI(4), NXO, NYO, * WINO(4), BOI, BOO, LIM2, LIM3, LIM4, LIM5, LIM6, LIM7, I3, I4, * I5, I6, I7, IPOS(7), CORN(7), BOTEMP, LIMO, IBIND, OBIND, * INDI(2), INDO(2), LIM1, FRAX, J, IX, IY REAL OUTMAX(2), OUTMIN(2) LOGICAL T, F, BLNKD(2) INCLUDE 'MODSP.INC' INCLUDE 'INCS:DFIL.INC' INCLUDE 'INCS:PSTD.INC' DATA LUNI, LUNO /16,17, 18,19/ DATA T, F /.TRUE.,.FALSE./ C----------------------------------------------------------------------- C loop over polarization CALL COPY (256, CATNEW(1,1), CATBLK) CALL AXEFND (4, 'FREQ', CATBLK(KIDIM), CATH(KHCTP), FRAX, IRET) IF (IRET.NE.0) THEN MSGTXT = 'CANNOT FIND FREQ AXIS' GO TO 990 END IF C Open and init for read IF (.NOT.DONEW) THEN DO 10 J = 1,2 CALL ZPHFIL ('MA', DISKI(J), OLDCNO(J), 1, IFILE, IRET) CALL ZOPEN (LUNI(J), INDI(J), DISKI(J), IFILE, T, F, T, * IRET) IF (IRET.GT.0) THEN WRITE (MSGTXT,1000) IRET, 'OPEN INPUT', J GO TO 990 END IF 10 CONTINUE END IF DO 15 J = 1,2 CALL ZPHFIL ('MA', DISKO(J), NEWCNO(J), 1, IFILE, IRET) CALL ZOPEN (LUNO(J), INDO(J), DISKO(J), IFILE, T, T, T, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'OPEN OUPUT', J GO TO 990 END IF 15 CONTINUE C Setup for I/O J = 1 NXI = CATOLD(KINAX,J) NYI = CATOLD(KINAX+1,J) NXO = CATBLK(KINAX) NYO = CATBLK(KINAX+1) WINI(1) = IROUND (BLC(1)) WINI(2) = IROUND (BLC(2)) WINI(3) = IROUND (TRC(1)) WINI(4) = IROUND (TRC(2)) WINO(1) = 1 WINO(2) = 1 WINO(3) = NXO WINO(4) = NYO OUTMAX(1) = -1.0E30 OUTMIN(1) = 1.0E30 OUTMAX(2) = -1.0E30 OUTMIN(2) = 1.0E30 BLNKD(1) = F BLNKD(2) = F C Setup for looping LIM1 = TRC(1) - BLC(1) + 1.01 LIM2 = TRC(2) - BLC(2) + 1.01 LIM3 = TRC(3) - BLC(3) + 1.01 LIM4 = TRC(4) - BLC(4) + 1.01 LIM5 = TRC(5) - BLC(5) + 1.01 LIM6 = TRC(6) - BLC(6) + 1.01 LIM7 = TRC(7) - BLC(7) + 1.01 CORN(7) = 1 LIMO = CATBLK(KINAX) - 1 C Loop IPOS(1) = WINI(1) DO 90 I7 = 1,LIM7 IPOS(7) = BLC(7) + I7 - 0.9 CORN(7) = I7 DO 85 I6 = 1,LIM6 IPOS(6) = BLC(6) + I6 - 0.9 CORN(6) = I6 DO 80 I5 = 1,LIM5 IPOS(5) = BLC(5) + I5 - 0.9 CORN(5) = I5 DO 75 I4 = 1,LIM4 IPOS(4) = BLC(4) + I4 - 0.9 CORN(4) = I4 DO 70 I3 = 1,LIM3 IPOS(3) = BLC(3) + I3 - 0.9 CORN(3) = I3 C Init. files, first input. IF (DONEW) THEN IY = 2 * NX * NY CALL RFILL (IY, 0.0, IMAGE) ELSE DO 25 J = 1,2 CALL COMOFF (CATOLD(KIDIM,J), * CATOLD(KINAX,J), IPOS(3), BOTEMP,IRET) BOI = BOTEMP + 1 CALL MINIT ('READ', LUNI(J), INDI(J), NXI, * NYI, WINI, BUFF, JBUFSZ, BOI, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'INIT INPUT', J GO TO 990 END IF DO 20 IY = 1,LIM2 IPOS(2) = BLC(2) + IY - 0.99 C Read. CALL MDISK ('READ', LUNI(J), INDI(J), * BUFF, IBIND, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'READ INPUT', * J GO TO 990 END IF CALL RCOPY (NXO, BUFF(IBIND), * IMAGE(1,IY,J)) 20 CONTINUE 25 CONTINUE END IF CALL THEMOD (I3, NX, NY, IMAGE) DO 50 J = 1,2 DO 35 IY = 1,NYO DO 30 IX = 1,NXO IF (IMAGE(IX,IY,J).EQ.FBLANK) THEN BLNKD(J) = .TRUE. ELSE OUTMAX(J) = MAX (OUTMAX(J), * IMAGE(IX,IY,J)) OUTMIN(J) = MIN (OUTMIN(J), * IMAGE(IX,IY,J)) END IF 30 CONTINUE 35 CONTINUE C Init output file. CALL COMOFF (CATBLK(KIDIM), CATBLK(KINAX), * CORN(3), BOTEMP, IRET) BOO = BOTEMP + 1 CALL MINIT ('WRIT', LUNO(J), INDO(J), NXO, NYO, * WINO, BUFF, JBUFSZ, BOO, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'INIT OUTPUT', J GO TO 990 END IF DO 40 IY = 1,LIM2 IPOS(2) = BLC(2) + IY - 0.99 C Write. CALL MDISK ('WRIT', LUNO(J), INDO(J), BUFF, * OBIND, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'WRITE OUTPUT', * J GO TO 990 END IF CALL RCOPY (NX, IMAGE(1,IY,J), BUFF(OBIND)) 40 CONTINUE C Flush buffer. CALL MDISK ('FINI', LUNO(J), INDO(J), BUFF, * OBIND, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'FINISH OUTPUT', J GO TO 990 END IF 50 CONTINUE 70 CONTINUE 75 CONTINUE 80 CONTINUE 85 CONTINUE 90 CONTINUE C Mark blanking in CATBLK. DO 100 J = 1,2 CALL COPY (256, CATNEW(1,J), CATBLK) CATR(KRBLK) = 0.0 IF (BLNKD(J)) CATR(KRBLK) = FBLANK CATR(KRDMX) = OUTMAX(J) CATR(KRDMN) = OUTMIN(J) CALL COPY (256, CATBLK, CATNEW(1,J)) CALL CATIO ('UPDT', DISKO(J), NEWCNO(J), CATBLK, 'REST', * SCRTCH, IRET) IF (IRET.NE.0) THEN WRITE (MSGTXT,1000) IRET, 'UPDATING HEADER OF', J GO TO 990 END IF C Close images IF (.NOT.DONEW) CALL ZCLOSE (LUNI(J), INDI(J), IRET) CALL ZCLOSE (LUNO(J), INDO(J), IRET) 100 CONTINUE IRET = 0 GO TO 999 C Error 990 CALL MSGWRT (8) C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('MODSPD: ERROR',I3,' ON ',A,' FILE',I2) END SUBROUTINE THEMOD (J, NX, NY, IMAGE) C----------------------------------------------------------------------- C Apply model to one plane of the image C Inputs: C J I spectral channel C NX I Number X pixels C NY I Number Y pixels C In/out C IMAGE R(NX,*) image C----------------------------------------------------------------------- INTEGER J, NX, NY REAL IMAGE(NX,NY,2) C INCLUDE 'MODSP.INC' REAL XX, YY, CPHI(MAXGAU), SPHI(MAXGAU), R, ANOISE, MV, RSUM, * LSUM, RVAL, LVAL, ALPHA, WID, RCH, DX, DY INTEGER IX, IY, II, JJ, K, ISET, IXBLC, IYBLC, I INCLUDE 'INCS:DHDR.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:PSTD.INC' SAVE ISET, IYBLC, IXBLC, CPHI, SPHI DATA ISET /0/ C----------------------------------------------------------------------- C Initialize constants ALPHA = 4.0 * LOG (2.0) IF (ISET.EQ.0) THEN ISET = 1 DO 10 I = 1,NGAUSS CPHI(I) = COS (FWID(3,I) * DG2RAD) SPHI(I) = SIN (FWID(3,I) * DG2RAD) 10 CONTINUE C Convert x-window to integers IXBLC = BLC(1) + 0.01 IYBLC = BLC(2) + 0.01 END IF C Loop over image and apply model C Point DO 130 IY = 1,NY JJ = IY + IYBLC - 1 DO 120 IX = 1,NX II = IX + IXBLC - 1 C input value scaled IF (IVIN) THEN RSUM = (IMAGE(IY,IX,1) + IMAGE(IY,IX,2)) / 2.0 LSUM = (IMAGE(IY,IX,1) - IMAGE(IY,IX,2)) / 2.0 ELSE RSUM = IMAGE(IY,IX,1) LSUM = IMAGE(IY,IX,2) END IF RSUM = RSUM * FACTOR LSUM = LSUM * FACTOR C add model DO 110 K = 1,NGAUSS DX = II - FPOS(1,K) DY = JJ - FPOS(2,K) RCH = CHLINE(1,K) + DX*CHLINE(2,K) + DY*CHLINE(3,K) WID = WLINE(1,K) + DX*WLINE(2,K) + DY*WLINE(3,K) WID = MAX (0.5, ABS(WID)) RVAL = FLUXR(K) * EXP (-ALPHA * (((J-RCH) / WID)**2)) LVAL = FLUXL(K) * EXP (-ALPHA * (((J-RCH) / WID)**2)) IF ((ABS(LVAL).GT.1.E-9) .OR. (ABS(RVAL).GT.1.E-9)) THEN C point IF (ICODES(K).EQ.1) THEN R = (II-FPOS(1,K))**2 + (JJ-FPOS(2,K))**2 IF (R.LE.0.25) THEN RSUM = RSUM + RVAL LSUM = LSUM + LVAL END IF C Gaussian ELSE IF (ICODES(K).EQ.2) THEN CALL RADPOS (II, JJ, FPOS(1,K), FWID(1,K), CPHI(K), * SPHI(K), XX, YY, R) IF (R.LT.2.0) THEN MV = EXP (-2.772588722 * R * R) RSUM = RSUM + RVAL * MV LSUM = LSUM + LVAL * MV END IF C disk ELSE IF (ICODES(K).EQ.3) THEN CALL RADPOS (II, JJ, FPOS(1,K), FWID(1,K), CPHI(K), * SPHI(K), XX, YY, R) IF (R.LE.0.5) THEN RSUM = RSUM + RVAL LSUM = LSUM + LVAL END IF C rectangle ELSE IF (ICODES(K).EQ.4) THEN CALL RADPOS (II, JJ, FPOS(1,K), FWID(1,K), CPHI(K), * SPHI(K), XX, YY, R) IF ((ABS(XX).LE.0.5) .AND. (ABS(YY).LE.0.5)) THEN RSUM = RSUM + RVAL LSUM = LSUM + LVAL END IF C Sphere ELSE IF (ICODES(K).EQ.5) THEN CALL RADPOS (II, JJ, FPOS(1,K), FWID(1,K), CPHI(K), * SPHI(K), XX, YY, R) IF (R.LT.0.5) THEN MV = SQRT (1.0 - 4.0 * R * R) RSUM = RSUM + RVAL * MV LSUM = LSUM + LVAL * MV END IF ELSE IF (ICODES(K).EQ.6) THEN CALL RADPOS (II, JJ, FPOS(1,K), FWID(1,K), CPHI(K), * SPHI(K), XX, YY, R) IF (R.LT.8.0) THEN MV = EXP (-1.386294361 * R) RSUM = RSUM + RVAL * MV LSUM = LSUM + LVAL * MV END IF END IF END IF 110 CONTINUE C Add random noise? IF (FLUX.GT.0.0) THEN CALL NOISE (ANOISE) RSUM = RSUM + ANOISE * FLUX CALL NOISE (ANOISE) LSUM = LSUM + ANOISE * FLUX END IF C convert to I/V IMAGE(IX,IY,1) = (RSUM + LSUM) / 2.0 IMAGE(IX,IY,2) = (RSUM - LSUM) / 2.0 120 CONTINUE 130 CONTINUE C 999 RETURN END SUBROUTINE RADPOS (I, J, FP, FW, CPHI, SPHI, XX, YY, R) C----------------------------------------------------------------------- C Work out distance of current pixel from model center and normalize C by the FWHM and correct for p.a. of model C Inputs: C I I X pixel C J I Y pixel C FP R(2) Component X,Y center pixels C FW R(3) Component Bmaj, Bmin, Bpa (pixels, pixel, deg) C CPHI R Cos (Bpa) C SPHI R Sin (Bpa) C Outputs: C XX R Normalized X position C YY R Normalized Y position C R R Normalized radius of current pixel from model C center C Disks and rectangles extend only to R=0.5 or XX,YY=0.5 C----------------------------------------------------------------------- INTEGER I, J REAL FP(2), FW(3), CPHI, SPHI, XX, YY, R C REAL X, Y C----------------------------------------------------------------------- X = I - FP(1) Y = J - FP(2) XX = (Y * CPHI - X * SPHI) / FW(1) YY = (X * CPHI + Y * SPHI) / FW(2) R = SQRT (XX**2 + YY**2) C RETURN END SUBROUTINE NOISE (A) C----------------------------------------------------------------------- C NOISE generates a random number approximately distributed in a C Gaussian manner about zero. It does it by summing a uniformly- C distributed random number 12 times. C Output: C A R The current sample from the gaussian distribution C----------------------------------------------------------------------- REAL A, B INTEGER J C----------------------------------------------------------------------- A = -6.0 DO 10 J = 1,12 CALL RANDUM (B) A = A + B 10 CONTINUE C 999 RETURN END SUBROUTINE MODSPH C----------------------------------------------------------------------- C MODSPH copies and updates history file. C----------------------------------------------------------------------- CHARACTER ATIME*8, ADATE*12, HILINE*72, NOTTYP*2, CODES(6)*4 INTEGER LUN1, LUN2, IERR, I, NCOMP, J, TIME(3), DATE(3) INCLUDE 'MODSP.INC' INCLUDE 'INCS:DMSG.INC' INCLUDE 'INCS:DFIL.INC' DATA LUN1, LUN2 /27,28/ DATA NOTTYP /'CC'/ DATA CODES /'POIN','GAUS','DISK','RECT','SPHE','EXPD'/ C----------------------------------------------------------------------- C Write History. CALL HIINIT (3) DO 100 J = 1,2 CALL COPY (256, CATNEW(1,J), CATBLK) C Copy/open history file. IF (.NOT.DONEW) THEN CALL HISCOP (LUN1, LUN2, DISKI(J), DISKO(J), OLDCNO(J), * NEWCNO(J), CATBLK, SCRTCH, BUFF, IERR) IF (IERR.GT.2) THEN WRITE (MSGTXT,1000) IERR, 'COPYING HI FILE', J CALL MSGWRT (6) GO TO 20 END IF C New history IF (J.EQ.1) THEN CALL HENCO1 (TSKNAM, NAMEI(J), CLASI(J), SEQI(J), * DISKI(J), LUN2, BUFF, IERR) ELSE IF (J.EQ.2) THEN CALL HENCO2 (TSKNAM, NAMEI(J), CLASI(J), SEQI(J), * DISKI(J), LUN2, BUFF, IERR) END IF IF (IERR.NE.0) GO TO 20 C BLC WRITE (HILINE,2000) TSKNAM, BLC CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C TRC WRITE (HILINE,2001) TSKNAM, TRC CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C need new HI file ELSE C Create/open hist. file. CALL HICREA (LUN2, DISKO(J), NEWCNO(J), CATBLK, BUFF, IERR) IF (IERR.NE.0) THEN WRITE (MSGTXT,1000) IERR, 'CREATING HI FILE', J CALL MSGWRT (6) GO TO 20 END IF C Get current date/time. CALL ZDATE (DATE) CALL ZTIME (TIME) CALL TIMDAT (TIME, DATE, ATIME, ADATE) C Write first record. WRITE (HILINE,1010) TSKNAM, NLUSER, ADATE, ATIME CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 END IF C outname CALL HENCOO (TSKNAM, NAMOUT, CLASO(J), SEQO(J), DISKO(J), LUN2, * BUFF, IERR) IF (IERR.NE.0) GO TO 20 C Components NCOMP = NGAUSS NCOMP = MAX (1, MIN (9, NCOMP)) IF (NGAUSS.GT.NCOMP) THEN MSGTXT = 'ONLY FIRST 9 LISTED IN HI' IF (J.EQ.1) CALL MSGWRT (2) END IF WRITE (HILINE,2003) TSKNAM, NGAUSS CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 DO 10 I = 1,NCOMP C FLUXR WRITE (HILINE,2004) TSKNAM, 'R', I, FLUXR(I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 WRITE (HILINE,2004) TSKNAM, 'L', I, FLUXL(I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C FPOS WRITE (HILINE,2005) TSKNAM, I, FPOS(1,I), FPOS(2,I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C BMAJ IF (ICODES(I).NE.1) THEN WRITE (HILINE,2006) TSKNAM, I, FWID(1,I), FWID(2,I), * FWID(3,I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 END IF C OPCODE WRITE (HILINE,2007) TSKNAM, I, CODES(ICODES(I)) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C CHLINE, WLINE WRITE (HILINE,2008) TSKNAM, I, CHLINE(1,I), WLINE(1,I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C shifts IF ((CHLINE(2,I).NE.0.0) .OR. (CHLINE(3,I).NE.0.0)) THEN WRITE (HILINE,2010) TSKNAM, I, CHLINE(2,I), CHLINE(3,I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 END IF IF ((WLINE(2,I).NE.0.0) .OR. (WLINE(3,I).NE.0.0)) THEN WRITE (HILINE,2011) TSKNAM, I, WLINE(2,I), WLINE(3,I) CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 END IF 10 CONTINUE C FLUX WRITE (HILINE,2020) TSKNAM, FLUX CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 C FACTOR IF (.NOT.DONEW) THEN WRITE (HILINE,2021) TSKNAM, FACTOR CALL HIADD (LUN2, HILINE, BUFF, IERR) IF (IERR.NE.0) GO TO 20 END IF C Close HI file 20 CALL HICLOS (LUN2, .TRUE., BUFF, IERR) C Copy tables IF (.NOT.DONEW) THEN CALL ALLTAB (1, NOTTYP, LUN1, LUN2, DISKI(J), DISKO(J), * OLDCNO(J), NEWCNO(J), CATBLK, BUFF, SCRTCH, IERR) IF (IERR.GT.2) THEN MSGTXT = 'ERROR COPYING TABLE FILES' CALL MSGWRT (6) END IF END IF C Update CATBLK. CALL CATIO ('UPDT', DISKO(J), NEWCNO(J), CATBLK, 'REST', * BUFF, IERR) 100 CONTINUE C 999 RETURN C----------------------------------------------------------------------- 1000 FORMAT ('MODSPH: ERROR',I3,' ON ',A,' FILE',I2) 1010 FORMAT (A6,'/ Image created by user',I5,' at ',A12,2X,A8) 2000 FORMAT (A6,'BLC =',7F6.0) 2001 FORMAT (A6,'TRC =',7F6.0) 2003 FORMAT (A6,'NGAUSS=',I6,' total number components') 2004 FORMAT (A6,'FLUX',A,'(',I4,') =',1PE12.4,12X,'/ JY/BEAM') 2005 FORMAT (A6,'FPOS(',I4,') =',F8.2,',',F8.2,7X,'/ pixels') 2006 FORMAT (A6,'FWIDTH(',I4,') =',F7.3,',',F7.3,',',F6.1, * ' / Maj pix, Min pix, PA deg') 2007 FORMAT (A6,'OPCODE(',I4,') = ''',A4,'''',12X,'/ component type') 2008 FORMAT (A6,'LINE(',I4,') =',F8.2,',',F8.2,7X,'/ channels', * ' center, FWHM') 2010 FORMAT (A6,'DL(',I4,')/Dx,y =',F7.3,',',F7.3,5X,'/ channels/pix', * ' center shift') 2011 FORMAT (A6,'DW(',I4,')/Dx,y =',F7.3,',',F7.3,5X,'/ channels/pix', * ' width shift') 2020 FORMAT (A6,'FLUX = ',1PE12.4,5X,'/ noise added') 2021 FORMAT (A6,'FACTOR = ',1PE12.4,5X,'/ Applied to input data') END
real*8 function dssenu_ctabget(wh,st,mx) *********************************************************************** *** Interpolates in capture rate tables and returns the capture *** rate (apart from the cross section) *** Input: wh ('su' or 'ea' for sun or earth) *** st, spin-type (1:spin-independent, 2:spin-dependent) *** mx WIMP mass in GeV *** Hidden input: velocity distribution model as given in *** veldf (for the Sun) and veldfearth (for the Earth) *** and possible escape velocity corrections (Jupiter effects) *** Author: Joakim Edsjo *** Date: 2003-11-27 *********************************************************************** implicit none include 'dssecap.h' include 'dshmcom.h' include 'dssecom.h' integer i,st,mxi,index character*2 wh character*200 file character*10 vec real*8 mx,mxpl,tmp logical newfile c...Determine which table is needed based on veldf or veldfearth c...Generate a file name call dsdatafile(file,'ctab-') write(vec,'(F10.2)') veout if (wh.eq.'su'.or.wh.eq.'SU') then if (veldf.eq.'num'.or.veldf.eq.'numc') then call dscharadd(file,'su-num-'//vec//'-'//haloid//'.dat') else call dscharadd(file,'su-'//vec//'-'//veldf//'.dat') endif else call dscharadd(file,'ea-'//veldfearth//'.dat') endif newfile=.true. if (wh.eq.'su'.or.wh.eq.'SU') then do i=1,nsuloaded if (file.eq.filesu(i)) then index=i newfile=.false. goto 10 endif enddo nsuloaded=nsuloaded+1 ! one more file loaded if (nsuloaded.gt.ntsu) then write(*,*) & 'DS WARNING in dssenu_ctabget: Too many files loaded' write(*,*) 'DarkSUSY will still work, but your performance ', & 'will not be optimal.' write(*,*) 'Increase ntsu in dssecap.h to fix this problem.' nsuloaded=ntsu endif index=nsuloaded filesu(index)=file else do i=1,nealoaded if (file.eq.fileea(i)) then index=i newfile=.false. goto 10 endif enddo nealoaded=nealoaded+1 ! one more file loaded if (nealoaded.gt.ntea) then write(*,*) 'WARNING in dssenu_ctabget: Too many files loaded' write(*,*) 'DarkSUSY will still work, but you performance ', & 'will not be optimal.' write(*,*) 'Increase ntea in dssecap.h to fix this problem.' nealoaded=ntea endif index=nealoaded fileea(index)=file endif 10 continue c...if newfile=.false., we have already loaded this file with index index c...if new=.true., we need to reload the file c...Load tables if needed if (newfile) then call dssenu_ctabread(wh,index,file) endif c...Find entry if (mx.lt.1.0d0.or.mx.ge.1.0d5) then write(*,*) 'WARNING from dssenu_ctabget: ', & 'WIMP mass outside allowed range: ',mx dssenu_ctabget=0.0d0 endif tmp=log10(mx)*dble(nc)/5.0d0 mxi=int(tmp) mxpl=tmp-mxi if (wh.eq.'su'.or.wh.eq.'SU') then if (st.eq.1) then ! spin-independent c dssenu_ctabget=(1.0d0-mxpl)*ctabsusi(mxi,index) c & +mxpl*ctabsusi(mxi+1,index) dssenu_ctabget=exp((1.0d0-mxpl)*log(ctabsusi(mxi,index)) & +mxpl*log(ctabsusi(mxi+1,index))) else ! spin-dependent c dssenu_ctabget=(1.0d0-mxpl)*ctabsusd(mxi,index) c & +mxpl*ctabsusd(mxi+1,index) dssenu_ctabget=exp((1.0d0-mxpl)*log(ctabsusd(mxi,index)) & +mxpl*log(ctabsusd(mxi+1,index))) endif else if (st.eq.1) then ! spin-independent c dssenu_ctabget=(1.0d0-mxpl)*ctabea(mxi,index) c & +mxpl*ctabea(mxi+1,index) dssenu_ctabget=exp((1.0d0-mxpl)*log(ctabea(mxi,index)) & +mxpl*log(ctabea(mxi+1,index))) else ! spin-dependent dssenu_ctabget=0.0d0 endif endif return end
C This program calculates the time evolution of the membrane potential C at a node of Ranvier with left-shifted NaV currents. C shft = the left shift of the affected channels in mV C LS = the fraction of affected channels at a node program singlenodeHH implicit none C Initializes variables integer imax,zi real*8 dt,tmax,V,t,RTF,m,h,n real*8 mLS,hLS,dVdt,Ii real*8 Ki,Nai,Ko,Nao real*8 INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,ILS real*8 LS,shft common/imax/imax common/I/INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,ILS,Ii common/RTF/RTF common/LS/LS common/shft/shft common/dt/dt C Initializes the output files open(20,file='node1.dat') open(21,file='node2.dat') open(22,file='node3.dat') open(23,file='node4.dat') open(24,file='node5.dat') open(25,file='node6.dat') open(26,file='node7.dat') open(27,file='node8.dat') open(28,file='node9.dat') write(20,*) 't',' V',' It' write(21,*) 'm',' h',' n' write(22,*) ' mLS',' hLS' write(23,*) 'INat',' INal',' IKl' write(24,*) 'Ikn',' dVdt' write(25,*) ' Ileak',' Inapump',' Ikpump' write(26,*) 'Nai',' Ki' write(27,*) 'Nao',' Ko' write(28,*) 'Ena',' Ek' C the do loop (using 4 as its end marker) is controled by the dummy-variable zi. C it determines the phases of the simulation. C phase 1 (zi = 1) is usually an equilibration phase C imax = number of steps between output to file C tmax = maximal time value for a phase (ms) C Ii = injected current C LS = relative amount of left-shifted channels C shft = left-shift of channels (in mV) do 4 zi=1,3 if (zi.eq.1) then imax=1000 tmax=200.0d0 Ii=0.0d0 LS=0.00d0 shft=0.0d0 call init(t,m,h,n,mLS,hLS,V,Nao,Nai,Ko,Ki) elseif (zi.eq.2) then imax=1000 tmax=400.0d0 Ii=-12.0d0 else imax=1000 tmax=900.0d0 Ii=0.0d0 endif C this while loop controls the progress of the simulation, C time evolves as long as time is smaller than the set value of tmax dowhile (t.lt.tmax) C propagate fait avancer de imax pas de longueur dt (variable?) C the propagate subroutine calculates the time evolution of NaV channel C parameters (m, h as well as mLS and hLS for shifted channels), n for C K channels, Nai and Ki (interior concentration), Nao and Ko (exterior concentration), C time t and membrane potential V. C the propagate subroutine advances for a number of imax steps. call propagate(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko,t) C the update subroutine recalculates the values of currents with C changed values of parameters. C update is called here simply to output correct current values. call update(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko) C Output to files. write(20,*) t,V,INat+Inal+Ikl+Ikn+Ikp * +Inapmp+Ii+Ileak+ILS write(21,*) m,h,n write(22,*) mLS,hLS write(23,*) ILS+Inat,Inal,Ikl write(24,*) Ikn,dVdt(INat+Inal+Ikl+ * Ikn+Ikp+Inapmp+Ii+Ileak+ILS) write(25,*) Ileak,Inapmp,Ikp write(26,*) Nai,Ki write(27,*) Nao,Ko write(28,*) RTF*dlog(Nao/Nai),RTF*dlog(Ko/Ki) enddo 4 continue stop end C The propagate subroutine uses an RK4 scheme. The update subroutine C is called each step to use correct values for currents. subroutine propagate(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko,t) implicit none integer i,imax,count real*8 m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko,t real*8 mk1,mk2,mk3,mk4,hk1,hk2,hk3,hk4 real*8 mLSk1,mLSk2,mLSk3,mLSk4,hLSk1,hLSk2,hLSk3,hLSk4 real*8 nk1,nk2,nk3,nk4,vk1,vk2,vk3,vk4 real*8 naik1,naik2,naik3,naik4,naok1,naok2,naok3,naok4 real*8 kik1,kik2,kik3,kik4,kok1,kok2,kok3,kok4 real*8 dmdt,dhdt,dndt,dCdt,dVdt real*8 Inat,Inal,Ikl,Ikn,Ikp,Inapmp,Ii,Ileak,Ils real*8 shft,dt,voli,volo,test1,test2,test3 common/imax/imax common/vol/volo common/volume/voli common/shft/shft common/dt/dt common/I/INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,Ils,Ii count=0 do 1 i=1,imax 2 continue mk1=dt*dmdt(m,V) hk1=dt*dhdt(h,V) mLSk1=dt*dmdt(mLS,V+shft) hLSk1=dt*dhdt(hLS,V+shft) nk1=dt*dndt(n,V) call update(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko) Vk1=dt*dVdt(INat+Inal+Ikl+Ikn+Ikp+Inapmp+Ii+Ileak+ILS) naik1=dt*dCdt(Inat+Inal+Inapmp+ILS) kik1=dt*dCdt(Ikl+Ikn+Ikp) Naok1=-1.0d0*naik1*voli/volo kok1=-1.0d0*kik1*voli/volo mk2=dt*dmdt(m+0.5d0*mk1,V+0.5d0*Vk1) hk2=dt*dhdt(h+0.5d0*hk1,V+0.5d0*Vk1) mLSk2=dt*dmdt(mLS+0.5d0*mLSk1,V+0.5d0*Vk1+shft) hLSk2=dt*dhdt(hLS+0.5d0*hLSk1,V+0.5d0*Vk1+shft) nk2=dt*dndt(n+0.5d0*nk1,V+0.5d0*Vk1) call update(m+0.5d0*mk1,h+0.5d0*hk1,mLS+0.5d0*mLSk1, * hLS+0.5d0*hLSk1,n+0.5d0*nk1,V+0.5d0*Vk1, *Nai+0.5d0*Naik1,Nao+0.5d0*Naok1,Ki+0.5d0*Kik1,Ko+0.5d0*kok1) Vk2=dt*dVdt(INat+Inal+Ikl+Ikn+Ikp+Inapmp+Ii+Ileak+ILS) naik2=dt*dCdt(Inat+Inal+Inapmp+ILS) kik2=dt*dCdt(Ikl+Ikn+Ikp) Naok2=-1.0d0*naik2*voli/volo kok2=-1.0d0*kik2*voli/volo mk3=dt*dmdt(m+0.5d0*mk2,V+0.5d0*Vk2) hk3=dt*dhdt(h+0.5d0*hk2,V+0.5d0*Vk2) mLSk3=dt*dmdt(mLS+0.5d0*mLSk2,V+0.5d0*Vk2+shft) hLSk3=dt*dhdt(hLS+0.5d0*hLSk2,V+0.5d0*Vk2+shft) nk3=dt*dndt(n+0.5d0*nk2,V+0.5d0*Vk2) call update(m+0.5d0*mk2,h+0.5d0*hk2,mLS+0.5d0*mLSk2, * hLS+0.5d0*hLSk2,n+0.5d0*nk2,V+0.5d0*Vk2, *nai+0.5d0*naik2,nao+0.5d0*naok2,Ki+0.5d0*kik2,Ko+0.5d0*kok2) Vk3=dt*dVdt(INat+Inal+Ikl+Ikn+Ikp+Inapmp+Ii+Ileak+ILS) naik3=dt*dCdt(Inat+Inal+Inapmp+ILS) kik3=dt*dCdt(Ikl+Ikn+Ikp) Naok3=-1.0d0*naik3*voli/volo kok3=-1.0d0*kik3*voli/volo mk4=dt*dmdt(m+mk3,V+Vk3) hk4=dt*dhdt(h+hk3,V+Vk3) mLSk4=dt*dmdt(mLS+mLSk3,V+Vk3+shft) hLSk4=dt*dhdt(hLS+hLSk3,V+Vk3+shft) nk4=dt*dndt(n+nk3,V+Vk3) call update(m+mk3,h+hk3,mLS+mLSk3,hLS+hLSk3,n+nk3, *V+dt*Vk3,nai+naik3,nao+naok3,Ki+kik3,Ko+kok3) Vk4=dt*dVdt(INat+Inal+Ikl+Ikn+Ikp+Inapmp+Ii * +Ileak+ILS) naik4=dt*dCdt(Inat+Inal+Inapmp+ILS) kik4=dt*dCdt(Ikl+Ikn+Ikp) Naok4=-1.0d0*naik4*voli/volo kok4=-1.0d0*kik4*voli/volo C this section ensures a rapid simulation by allowing the timestep C to vary is values are changing rapidly or slowly. test1=dabs((mk1+2.0d0*mk2+2.0d0*mk3+mk4)/6.0d0/m) test2=dabs((Vk1+2.0d0*Vk2+2.0d0*Vk3+Vk4)/6.0d0/V) test3=dabs(((mLSk1+2.0d0*mLSk2+2.0d0*mLSk3+mLSk4)/6.0d0))/mLS if (((test1.ge.1.0d-3).or. *(test2.ge.1.0d-3).or.(test3.ge.1.0d-3)).and.(dt.ge.1.0d-4)) then if (count.ge.2) goto 3 dt=dt/10.0d0 count=count+1 goto 2 elseif ((test1.le.1.0d-5).and.(test2.le.1.0d-5).and. * (test3.le.1.0d-5).and.(dt.lt.1.0d-2)) then if (count.ge.2) goto 3 dt=dt*10.0d0 count=count+1 goto 2 endif 3 continue count=0 C The values of the parameters are calculated with the correct RK4 weight. m=m+(mk1+2.0d0*mk2+2.0d0*mk3+mk4)/6.0d0 h=h+(hk1+2.0d0*hk2+2.0d0*hk3+hk4)/6.0d0 mLS=mLS+(mLSk1+2.0d0*mLSk2+2.0d0*mLSk3+mLSk4)/6.0d0 hLS=hLS+(hLSk1+2.0d0*hLSk2+2.0d0*hLSk3+hLSk4)/6.0d0 n=n+(nk1+2.0d0*nk2+2.0d0*nk3+nk4)/6.0d0 V=V+(Vk1+2.0d0*Vk2+2.0d0*Vk3+Vk4)/6.0d0 Nai=Nai+(naik1+2.0d0*naik2+2.0d0*naik3+naik4)/6.0d0 Ki=Ki+(Kik1+2.0d0*Kik2+2.0d0*Kik3+Kik4)/6.0d0 Nao=Nao+(naok1+2.0d0*naok2+2.0d0*naok3+naok4)/6.0d0 Ko=Ko+(Kok1+2.0d0*Kok2+2.0d0*Kok3+Kok4)/6.0d0 t=t+dt 1 continue return end C The update subroutine calculates the values for the currents (which are common variables) C given a set of parameters. subroutine update(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko) implicit none real*8 m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko real*8 INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,Ii,ILS real*8 gna,gnal,gkl,gkn,Imaxp real*8 Apump,gleak,LS,Ek,Ena,RTF,Eleak common/up1/gna,gnal,gkl,gkn,Imaxp,gleak common/I/INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,ILS,Ii common/RTF/RTF common/LS/LS common/Eleak/Eleak Ena=RTF*dlog(Nao/Nai) INat=(1.0d0-LS)*gna*m**3*h*(V-Ena) ILS=LS*gna*mLS**3*hLS*(V-Ena) Inal=gnal*(V-Ena) Ek=RTF*dlog(Ko/Ki) Ikl=gkl*(V-Ek) Ikn=gkn*n**4*(V-Ek) Ileak=gleak*(V-Eleak) Apump=Imaxp*(1.0d0+3.5d0/Ko)**(-2)*(1.0d0+10.0d0/Nai)**(-3) Ikp=-2.0d0*Apump Inapmp=3.0d0*Apump return end C this function calculates the rate of change of membrane potential. function dVdt(Itot) implicit none real*8 Itot,C,dVdt common/Cap/C dVdt=-1.0d0*Itot/C return end C this function calculates the rate of change of one species of ion. function dCdt(Itot) implicit none real*8 dCdt,Itot,F,voli,surf common/F/F common/volume/voli common/surf/surf dCdt=-1.0d-6*Itot*surf/F/voli return end C rate of change for the n variable. function dndt(n,V) implicit none real*8 dndt,n,V,alpha,beta alpha=0.01d0*(V+55.0d0)/(1.0d0-dexp(-1.0d0*(V+55.0d0)/10.0d0)) beta=0.1250d0*dexp(-1.0d0*(V+65.0d0)/80.0d0) dndt=alpha*(1.0d0-n)-beta*n return end C rate of change of the m variable. function dmdt(m,V) implicit none real*8 dmdt,m,V,alpha,beta alpha=0.1d0*(V+40.0d0)/(1.0d0-dexp(-1.0d0*(V+40.0d0)/10.0d0)) beta=4.0d0*dexp(-1.0d0*(V+65.0d0)/18.0d0) dmdt=alpha*(1.0d0-m)-beta*m return end C rate of change of the h variable. function dhdt(h,V) implicit none real*8 dhdt,h,V,alpha,beta alpha=0.07d0*dexp(-1.0d0*(V+65.0d0)/20.0d0) beta=1.0d0/(1.0d0+dexp(-1.0d0*(V+35.0d0)/10.0d0)) dhdt=alpha*(1.0d0-h)-beta*h return end C this subroutine simply sets ths initial values of most parameters. subroutine init(t,m,h,n,mLS,hLS,V,Nao,Nai,Ko,Ki) implicit none real*8 t,m,h,n,mLS,hLS,V,Nao,Nai,Ko,Ki real*8 gna,gkn,Imaxp,gnal,gkl,gleak,voli,volo,C,F real*8 Temp,dt,RTF,Eleak,surf,R real*8 INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,ILS,Ii common/cap/C common/F/F common/RTF/RTF common/dt/dt common/vol/volo common/volume/voli common/up1/gna,gnal,gkl,gkn,Imaxp,gleak common/Eleak/Eleak common/surf/surf common/I/INat,Inal,Ikl,Ikn,Ikp,Inapmp,Ileak,ILS,Ii F=96485.3399d0 R=8.314472d0 Temp=293.150d0 RTF=R*temp/F*1000.0d0 gna=120.0d0 gkn=36.0d0 C gleak=0.25d0 gleak=0.50d0 Eleak=-59.9d0 C=1.0d0 gkl=0.1d0 Imaxp=1.0d0 gnal=1.0d0 C Volume in m3 C surface in cm2 C voli=1.0d100 voli=3.0d-15 C volo=1.0d100 volo=voli C volo=0.15*1.0d-15 C volo=0.150d0*voli surf=6.0d-8 Ko=6.0d0 Nao=154.0d0 Ki=150.0d0 Nai=20.0d0 dt=1.0d-3 t=0.0d0 m=0.095d0 h=0.414d0 n=0.398d0 V=-59.9d0 mls=m hls=h write(*,*) m,h,m**3*h write(*,*) 'mLS=',mls,', hls=',hls,' mls**3hls=',mls**3*hls call update(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko) gnal=(-3.0d0/2.0d0*(Ikl+Ikn)-(Inat+ILS))/Inal call update(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko) Imaxp=-1.0d0*(Inat+Inal+ILS)/Inapmp call update(m,h,mLS,hLS,n,V,Nai,Nao,Ki,Ko) write(*,*) 'Inattotal: ',Inat+Inal+ILS,'=',Inat,'+',Inal,'+',ILS write(*,*) 'Iktot: ',Ikl+Ikn,'=',Ikl,'+',Ikn write(*,*) 'Ina/Iktot: ',(Inat+Inal+ILS)/(Ikl+Ikn) write(*,*) 'A= ', (-3.0d0/2.0d0*(Ikl+Ikn)-(Inat+ILS))/Inal write(*,*) 'Inapump: ',Inapmp,' Ikp: ',Ikp write(*,*) 'Inapmp/Ikp: ',Inapmp/Ikp write(*,*) '-Inat/Inp: ', -1.0d0*(Inat+Inal+ILS)/Inapmp write(*,*) 'Ileak= ',Ileak,' Itotal=',INat+Inal+Ikl+ * Ikn+Ikp+Inapmp+Ii+ILS write(*,*) 'Ek= ',RTF*dlog(Ko/Ki), * ' Ena= ',RTF*dlog(Nao/Nai) write(*,*) 'gnal:',gnal,' Imaxp:',Imaxp C pause return end
C C $Id: plchmq.f,v 1.15 2008-07-27 00:17:20 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 PLCHMQ (XPOS,YPOS,CHRS,SIZE,ANGD,CNTR) C C This is the medium-quality character-drawing routine. C C C D E C L A R A T I O N S C C CHARACTER*(*) CHRS C C The COMMON block PCPFLQ contains internal parameters that affect the C behavior of routines besides PLCHHQ. C COMMON /PCPFLQ/ IMAP,OORV,RHTW SAVE /PCPFLQ/ C C Define an array in which to declare the 94 legal characters. C CHARACTER*1 LCHR(94) C C Define arrays in which to declare the pointers into the digitization C arrays and the digitizations themselves. C DIMENSION INDX(94),KXCO(857),KYCO(857) C C Three internal variables are subject to change and need to be saved C from each call to the next. C SAVE INIT,LCHR,INDX C C The following DATA statements associate each character with an index C in the digitization arrays. For example, the digitization for the C character A starts at KXCO(328) and KYCO(328), while that for a B C starts at KXCO(336) and KYCO(336). C DATA (LCHR(I),I= 1, 94) / O '!','"','#','$','%','&','''','(',')','*', 1 '+',',','-','.','/','0','1','2','3','4', 2 '5','6','7','8','9',':',';','<','=','>', 3 '?','@','A','B','C','D','E','F','G','H', 4 'I','J','K','L','M','N','O','P','Q','R', 5 'S','T','U','V','W','X','Y','Z','[','\\', 6 ']','^','_','`','a','b','c','d','e','f', 7 'g','h','i','j','k','l','m','n','o','p', 8 'q','r','s','t','u','v','w','x','y','z', 9 '{','|','}','~' / C DATA (INDX(I),I= 1, 94) / O 1, 11, 23, 35, 51, 74, 87, 93,100,107, 1 116,122,129,132,139,142,155,159,168,183, 2 193,203,215,219,238,250,264,278,282,288, 3 292,308,328,336,350,359,367,377,386,399, 4 408,417,423,432,436,442,447,457,465,478, 5 489,502,508,515,519,525,531,538,543,548, 6 551,556,560,563,566,581,593,602,614,625, 7 634,649,658,669,683,692,697,712,721,731, 8 743,755,763,776,785,794,798,804,810,816, 9 821,833,839,851 / C C The following DATA statements define the character digitizations. C Each character is digitized in a box which is basically 60 units C wide by 70 units tall. The width includes 20 units of white space C along the right edge of the character. A few characters dip below C the bottom of the box. Vertical spacing is intended to be 120 units. C If KXCO(I) = 77, KYCO(I) is a flag: KYCO(I) = 0 means that the next C delared move is pen-up (all others are pen-down), and KYCO(I)=77 C signals the end of the digitization for a given character. C C Note: KYCO(151) changed from 0 to 77 to remove slash from zero. DJK C (3/11/88). C DATA (KXCO(I),I= 1,100) / O 21, 21, 77, 19, 19, 24, 24, 19, 24, 77, 1 9, 9, 77, 9, 9, 77, 31, 31, 77, 31, 2 31, 77, 14, 9, 77, 26, 31, 77, 40, 5, 3 77, 0, 35, 77, 19, 19, 77, 0, 9, 28, 4 38, 38, 28, 9, 0, 0, 9, 28, 38, 77, 5 12, 5, 0, 0, 5, 12, 16, 16, 12, 77, 6 40, 0, 77, 24, 24, 28, 35, 40, 40, 35, 7 28, 24, 77, 40, 5, 5, 9, 16, 21, 21, 8 0, 0, 7, 24, 40, 77, 19, 16, 19, 21, 9 19, 77, 24, 19, 16, 16, 19, 24, 77, 16/ DATA (KYCO(I),I= 1,100) / O 70, 21, 0, 3, -3, -3, 3, 3, -3, 77, 1 70, 60, 0, 60, 70, 0, 70, 60, 0, 60, 2 70, 77, 65, 26, 0, 26, 65, 0, 54, 54, 3 0, 36, 36, 77, 70, 0, 0, 16, 5, 5, 4 13, 26, 36, 36, 44, 54, 65, 65, 54, 77, 5 70, 70, 65, 57, 52, 52, 57, 65, 70, 0, 6 70, 0, 0, 13, 5, 0, 0, 5, 13, 18, 7 18, 13, 77, 0, 52, 62, 70, 70, 62, 54, 8 23, 10, 0, 0, 23, 77, 70, 60, 60, 70, 9 70, 77, 70, 60, 47, 23, 10, 0, 77, 70/ DATA (KXCO(I),I=101,200) / O 21, 24, 24, 21, 16, 77, 0, 38, 77, 19, 1 19, 77, 0, 38, 77, 19, 19, 77, 0, 38, 2 77, 16, 19, 19, 16, 16, 19, 77, 0, 38, 3 77, 19, 19, 24, 24, 19, 24, 77, 0, 40, 4 77, 12, 0, 0, 12, 28, 40, 40, 28, 12, 5 77, 40, 0, 77, 5, 21, 21, 77, 0, 9, 6 31, 40, 40, 0, 0, 40, 77, 0, 12, 28, 7 40, 40, 28, 19, 77, 28, 40, 40, 28, 12, 8 0, 77, 31, 31, 26, 0, 0, 31, 77, 31, 9 40, 77, 2, 28, 40, 40, 28, 12, 0, 0/ DATA (KYCO(I),I=101,200) / O 60, 47, 23, 10, 0, 77, 54, 16, 0, 62, 1 8, 0, 16, 54, 77, 52, 10, 0, 31, 31, 2 77,-10, -5, 3, 3, 0, 0, 77, 31, 31, 3 77, 3, -3, -3, 3, 3, -3, 77, 0, 70, 4 77, 70, 54, 16, 0, 0, 16, 54, 70, 70, 5 77, 70, 0, 77, 54, 70, 0, 77, 60, 70, 6 70, 60, 39, 10, 0, 0, 77, 60, 70, 70, 7 60, 47, 36, 36, 0, 36, 26, 10, 0, 0, 8 13, 77, 0, 70, 70, 23, 18, 18, 0, 18, 9 18, 77, 0, 0, 13, 31, 44, 44, 34, 70/ DATA (KXCO(I),I=201,300) / O 40, 77, 0, 12, 28, 40, 40, 28, 12, 0, 1 0, 2, 21, 77, 0, 40, 12, 77, 9, 0, 2 0, 9, 0, 0, 9, 31, 40, 40, 31, 9, 3 77, 31, 40, 40, 31, 9, 77, 21, 38, 40, 4 40, 28, 12, 0, 0, 12, 28, 40, 77, 19, 5 24, 24, 19, 19, 24, 77, 19, 19, 24, 24, 6 19, 24, 77, 19, 24, 24, 19, 19, 24, 77, 7 19, 21, 21, 19, 19, 21, 77, 33, 2, 33, 8 77, 38, 2, 77, 2, 38, 77, 2, 33, 2, 9 77, 5, 5, 12, 24, 33, 33, 16, 16, 77/ DATA (KYCO(I),I=201,300) / O 70, 77, 29, 41, 41, 29, 13, 0, 0, 13, 1 29, 49, 70, 77, 70, 70, 0, 77, 70, 60, 2 47, 36, 26, 10, 0, 0, 10, 26, 36, 36, 3 0, 36, 47, 60, 70, 70, 77, 0, 21, 41, 4 57, 70, 70, 57, 41, 29, 29, 41, 77, 31, 5 31, 26, 26, 31, 26, 0, 16, 10, 10, 16, 6 16, 10, 77, 31, 31, 26, 26, 31, 26, 0, 7 3, 8, 16, 16, 13, 13, 77, 52, 31, 10, 8 77, 41, 41, 0, 21, 21, 77, 52, 31, 10, 9 77, 54, 62, 70, 67, 60, 47, 29, 18, 0/ DATA (KXCO(I),I=301,400) / O 16, 16, 21, 21, 16, 21, 77, 31, 9, 0, 1 0, 9, 31, 40, 40, 35, 31, 28, 28, 24, 2 16, 12, 12, 16, 24, 28, 77, 0, 14, 24, 3 38, 77, 5, 33, 77, 0, 31, 40, 40, 31, 4 0, 77, 31, 40, 40, 31, 0, 0, 77, 40, 5 28, 12, 0, 0, 12, 28, 40, 77, 0, 28, 6 40, 40, 28, 0, 0, 77, 0, 0, 40, 77, 7 0, 26, 77, 0, 40, 77, 0, 0, 77, 0, 8 26, 77, 0, 40, 77, 24, 40, 40, 77, 40, 9 28, 12, 0, 0, 12, 28, 40, 77, 0, 0/ DATA (KYCO(I),I=301,400) / O 3, -3, -3, 3, 3, -3, 77, 10, 10, 21, 1 49, 60, 60, 49, 29, 23, 23, 29, 39, 47, 2 47, 39, 29, 23, 23, 29, 77, 0, 70, 70, 3 0, 0, 26, 26, 77, 70, 70, 60, 47, 36, 4 36, 0, 36, 26, 10, 0, 0, 70, 77, 13, 5 0, 0, 13, 57, 70, 70, 57, 77, 70, 70, 6 57, 13, 0, 0, 70, 77, 70, 0, 0, 0, 7 36, 36, 0, 70, 70, 77, 70, 0, 0, 36, 8 36, 0, 70, 70, 77, 26, 26, 0, 0, 13, 9 0, 0, 13, 57, 70, 70, 57, 77, 70, 0/ DATA (KXCO(I),I=401,500) / O 77, 0, 40, 77, 40, 40, 77, 7, 31, 77, 1 19, 19, 77, 9, 31, 77, 0, 12, 26, 38, 2 38, 77, 0, 0, 77, 40, 12, 77, 0, 40, 3 77, 0, 0, 40, 77, 0, 0, 19, 38, 38, 4 77, 0, 0, 40, 40, 77, 0, 12, 28, 40, 5 40, 28, 12, 0, 0, 77, 0, 0, 31, 40, 6 40, 31, 0, 77, 0, 0, 12, 28, 40, 40, 7 28, 12, 0, 77, 16, 40, 77, 0, 0, 31, 8 40, 40, 31, 0, 77, 31, 40, 77, 0, 9, 9 31, 40, 40, 31, 9, 0, 0, 9, 31, 40/ DATA (KYCO(I),I=401,500) / O 0, 34, 34, 0, 0, 70, 77, 70, 70, 0, 1 70, 0, 0, 0, 0, 77, 13, 0, 0, 13, 2 70, 77, 70, 0, 0, 0, 39, 0, 26, 70, 3 77, 70, 0, 0, 77, 0, 70, 34, 70, 0, 4 77, 0, 70, 0, 70, 77, 57, 70, 70, 57, 5 13, 0, 0, 13, 57, 77, 0, 70, 70, 60, 6 41, 31, 31, 77, 57, 13, 0, 0, 13, 57, 7 70, 70, 57, 0, 41,-10, 77, 0, 70, 70, 8 60, 44, 36, 36, 0, 36, 0, 77, 10, 0, 9 0, 10, 23, 34, 36, 47, 60, 70, 70, 60/ DATA (KXCO(I),I=501,600) / O 77, 21, 21, 77, 0, 42, 77, 0, 0, 12, 1 28, 40, 40, 77, 0, 19, 38, 77, 0, 9, 2 21, 33, 42, 77, 0, 40, 77, 0, 40, 77, 3 0, 19, 19, 77, 19, 38, 77, 0, 40, 0, 4 40, 77, 26, 14, 14, 26, 77, 0, 40, 77, 5 12, 24, 24, 12, 77, 7, 19, 31, 77, -2, 6 42, 77, 16, 21, 77, 9, 24, 31, 31, 21, 7 9, 0, 0, 7, 24, 31, 77, 31, 40, 77, 8 0, 0, 77, 0, 9, 26, 35, 35, 26, 9, 9 0, 77, 33, 26, 9, 0, 0, 9, 26, 33/ DATA (KYCO(I),I=501,600) / O 77, 0, 70, 0, 70, 70, 77, 70, 13, 0, 1 0, 13, 70, 77, 70, 0, 70, 77, 70, 0, 2 34, 0, 70, 77, 70, 0, 0, 0, 70, 77, 3 70, 39, 0, 0, 39, 70, 77, 70, 70, 0, 4 0, 77, 75, 75, -3, -3, 77, 70, 0, 77, 5 75, 75, -3, -3, 77, 62, 70, 62, 77,-13, 6 -13, 77, 70, 54, 77, 49, 49, 39, 10, 0, 7 0, 10, 21, 31, 31, 26, 0, 10, 0, 77, 8 70, 0, 0, 10, 0, 0, 10, 29, 39, 39, 9 29, 77, 34, 39, 39, 29, 10, 0, 0, 5/ DATA (KXCO(I),I=601,700) / O 77, 35, 26, 9, 0, 0, 9, 26, 35, 77, 1 35, 35, 77, 0, 35, 35, 26, 9, 0, 0, 2 9, 26, 35, 77, 5, 31, 77, 14, 14, 21, 3 31, 35, 77, 0, 9, 26, 35, 35, 77, 35, 4 26, 9, 0, 0, 9, 26, 35, 77, 0, 0, 5 77, 0, 9, 26, 35, 35, 77, 16, 16, 21, 6 21, 16, 21, 77, 16, 19, 19, 77, 16, 16, 7 21, 21, 16, 21, 77, 16, 19, 19, 14, 7, 8 2, 77, 0, 0, 77, 0, 28, 77, 9, 35, 9 77, 14, 19, 19, 24, 77, 0, 0, 77, 19/ DATA (KYCO(I),I=601,700) / O 77, 29, 39, 39, 29, 10, 0, 0, 10, 0, 1 0, 70, 77, 21, 21, 29, 39, 39, 29, 10, 2 0, 0, 8, 77, 41, 41, 0, 0, 57, 65, 3 65, 60, 77,-13,-21,-21,-10, 39, 0, 29, 4 39, 39, 29, 10, 0, 0, 10, 77, 70, 0, 5 0, 29, 39, 39, 29, 0, 77, 54, 49, 49, 6 54, 54, 49, 0, 34, 34, 0, 77, 54, 49, 7 49, 54, 54, 49, 0, 34, 34,-16,-21,-21, 8 -16, 77, 70, 0, 0, 31, 47, 0, 36, 0, 9 77, 70, 65, 5, 0, 77, 39, 0, 0, 0/ DATA (KXCO(I),I=701,800) / O 19, 77, 0, 7, 14, 19, 24, 31, 38, 38, 1 77, 0, 0, 77, 0, 9, 26, 35, 35, 77, 2 0, 0, 9, 26, 35, 35, 26, 9, 0, 77, 3 0, 0, 77, 0, 9, 26, 35, 35, 26, 9, 4 0, 77, 35, 35, 77, 35, 26, 9, 0, 0, 5 9, 26, 35, 77, 0, 0, 77, 0, 9, 26, 6 35, 77, 0, 9, 26, 35, 35, 26, 9, 0, 7 0, 9, 26, 33, 77, 7, 31, 77, 33, 28, 8 21, 16, 16, 77, 0, 0, 9, 26, 35, 77, 9 35, 35, 77, 2, 19, 35, 77, 0, 9, 19/ DATA (KYCO(I),I=701,800) / O 31, 0, 31, 39, 39, 31, 39, 39, 31, 0, 1 77, 39, 0, 0, 29, 39, 39, 29, 0, 77, 2 29, 10, 0, 0, 10, 29, 39, 39, 29, 77, 3 39,-21, 0, 29, 39, 39, 29, 10, 0, 0, 4 10, 77, 39,-21, 0, 10, 0, 0, 10, 29, 5 39, 39, 29, 77, 39, 0, 0, 29, 39, 39, 6 31, 77, 5, 0, 0, 5, 16, 21, 21, 26, 7 34, 39, 39, 34, 77, 39, 39, 0, 5, 0, 8 0, 5, 65, 77, 39, 10, 0, 0, 10, 0, 9 0, 39, 77, 39, 0, 39, 77, 39, 0, 34/ DATA (KXCO(I),I=801,857) / O 28, 38, 77, 2, 35, 77, 2, 35, 77, 0, 1 19, 77, 9, 38, 77, 2, 35, 2, 35, 77, 2 26, 21, 16, 16, 14, 9, 14, 16, 16, 21, 3 26, 77, 19, 19, 77, 19, 19, 77, 14, 19, 4 24, 24, 26, 31, 26, 24, 24, 19, 14, 77, 5 0, 7, 14, 26, 33, 40, 77 / DATA (KYCO(I),I=801,857) / O 0, 39, 77, 39, 0, 0, 0, 39, 77, 39, 1 0, 0,-21, 39, 77, 39, 39, 0, 0, 77, 2 75, 75, 67, 44, 39, 36, 34, 29, 3, -3, 3 -3, 77, 70, 44, 0, 26, 0, 77, 75, 75, 4 67, 44, 39, 36, 34, 29, 3, -3, -3, 77, 5 29, 36, 36, 23, 23, 31, 77 / C C INIT is 0 if this is the first call to PLCHMQ, 1 otherwise. C DATA INIT / 0 / C C NLCH is the length of LCHR and INDX. C DATA NLCH / 94 / C C WIDE and HIGH are the digitized width and height of the characters; C WIDE includes white space on the right edge, the width of which is C WHTE. C DATA WIDE,HIGH,WHTE / 60.,70.,20. / C C C I N I T I A L I Z A T I O N C C C Do a call forcing a BLOCKDATA to be loaded from a binary library. C CALL PCBLDA C C Check for an uncleared prior error. C IF (ICFELL('PLCHMQ - UNCLEARED PRIOR ERROR',1).NE.0) RETURN C C On the first call to PLCHMQ, sort LCHR, maintaining its relationship C with INDX. (For example, after sorting, if LCHR(I)='B', INDX(I)=336.) C The sorting makes it possible to locate characters quickly. C IF (INIT.EQ.0) THEN INIT=1 CALL PCSORT (LCHR,INDX,NLCH) END IF C C Find the length of the string and, if it's zero, quit. C NCHR=LEN(CHRS) IF (NCHR.LE.0) RETURN C C Get the fractional coordinates of the reference point. C IF (IMAP.LE.0) THEN XFRA=CUFX(XPOS) IF (ICFELL('PLCHMQ',2).NE.0) RETURN YFRA=CUFY(YPOS) IF (ICFELL('PLCHMQ',3).NE.0) RETURN ELSE XFRA=XPOS YFRA=YPOS END IF C C Determine the resolution of the plotter, as declared by default or C by the user. C CALL GETUSV ('XF',IRSX) IF (ICFELL('PLCHMQ',4).NE.0) RETURN RSLN=2.**IRSX-1. C C Determine a multiplier for the digitized size which will make the C characters have the size requested by the user. First, compute the C same multiplier we would use for PLCHHQ (except for the adjustment C factor SIZA) ... C IF (IMAP.LE.0) THEN IF (SIZE.LE.0.) THEN SIZM=ABS(SIZE)/1023. ELSE IF (SIZE.LT.1.) THEN SIZM=SIZE/16. ELSE SIZM=(SIZE/RSLN)/16. END IF ELSE SIZM=SIZE/16. END IF C C ... and then adjust for the fact that the digitization is different. C SIZM=16.*SIZM/WIDE C C Compute the orientation angle, in radians, and the magnitudes of the C X and Y components of a vector at that angle with magnitude SIZM. C ANGR=.017453292519943*ANGD C XCOV=SIZM*COS(ANGR) YCOV=SIZM*SIN(ANGR) C C Compute a multiplier for the digitized y coordinates that will make C the height come out right. C YMLT=ABS(RHTW)/1.75 C C Find the fractional coordinates for the beginning of the string. We C must take into account the fact that each character is digitized with C (0,0) at the lower left-hand corner of the character. We must also C take into account the user's centering option. C XLLC=XFRA+.5*HIGH*YMLT*YCOV + -.5*(CNTR+1.)*(REAL(NCHR)*WIDE-WHTE)*XCOV YLLC=YFRA-.5*HIGH*YMLT*XCOV + -.5*(CNTR+1.)*(REAL(NCHR)*WIDE-WHTE)*YCOV C C C C H A R A C T E R L O O P C C C Loop through all the characters in the input string. C DO 107 ICHR=1,NCHR C C If the character is not a blank, get a pointer to the beginning of C its digitization. C IPNT=0 IF (CHRS(ICHR:ICHR).NE.' ') + CALL PCGPTR (CHRS(ICHR:ICHR),LCHR,INDX,NLCH,IPNT) C C Once we've got a valid pointer, stroke out the character it points to. C The pen starts out "up". If mapping is turned on and an out-of-range C value is defined, initialize a visibility flag and X and Y coordinates C of a "new" point. C IF (IPNT.GT.0) THEN C IPNT=IPNT-1 IPEN=0 C IF (IMAP.GT.0.AND.OORV.NE.0.) THEN IVSN=0 XNEW=0. YNEW=0. END IF C C Advance to the next digitization pair. C 101 IPNT=IPNT+1 C C Check for an X/Y coordinate pair (as opposed to an op code). C IF (KXCO(IPNT).NE.77) THEN C C Process an X/Y coordinate pair. See if mapping is off or on. C IF (IMAP.LE.0) THEN C C Mapping is turned off; just compute the appropriate fractional C coordinates and use the SPPS routine PLOTIF. C CALL PLOTIF (XLLC+REAL(KXCO(IPNT))*XCOV- + YMLT*REAL(KYCO(IPNT))*YCOV, + YLLC+REAL(KXCO(IPNT))*YCOV+ + YMLT*REAL(KYCO(IPNT))*XCOV,IPEN) IF (ICFELL('PLCHMQ',5).NE.0) RETURN C ELSE C C Mapping is turned on. If the pen is up, just move to the current C point. If the pen is down and the current point is too far from the C last one, arrange to generate some points in between. C IF (IPEN.EQ.0) THEN XTMB=0. YTMB=0. NINT=1 ELSE XTMB=REAL(KXCO(IPNT-1)) YTMB=REAL(KYCO(IPNT-1)) NINT=MAX(1,ABS(KXCO(IPNT)-KXCO(IPNT-1))/7, + ABS(KYCO(IPNT)-KYCO(IPNT-1))/7) END IF C XTME=REAL(KXCO(IPNT)) YTME=REAL(KYCO(IPNT)) C C Begin interpolation loop. C DO 106 IINT=1,NINT C C Interpolate to get an X/Y position. C P=REAL(NINT-IINT)/REAL(NINT) C XTMI=P*XTMB+(1.-P)*XTME YTMI=P*YTMB+(1.-P)*YTME C C Check whether an out-of-range value is defined or not. C IF (OORV.EQ.0.) THEN C C No out-of-range value is defined; do the mapping, transform to the C fractional system, and use PLOTIF. C CALL PCMPXY (IMAP,XLLC+XTMI*XCOV-YMLT*YTMI*YCOV, + YLLC+XTMI*YCOV+YMLT*YTMI*XCOV, + XTMP,YTMP) IF (ICFELL('PLCHMQ',6).NE.0) RETURN XPEN=CUFX(XTMP) IF (ICFELL('PLCHMQ',7).NE.0) RETURN YPEN=CUFY(YTMP) IF (ICFELL('PLCHMQ',8).NE.0) RETURN CALL PLOTIF (XPEN,YPEN,IPEN) IF (ICFELL('PLCHMQ',9).NE.0) RETURN C ELSE C C An out-of-range value is defined; we have to cope with the fact that C some points may disappear under the given mapping. C C The new point becomes the old point. C IVSO=IVSN XOLD=XNEW YOLD=YNEW C C Compute the coordinates and the visibility flag for the new point. C XNEW=XLLC+XTMI*XCOV-YMLT*YTMI*YCOV YNEW=YLLC+XTMI*YCOV+YMLT*YTMI*XCOV C CALL PCMPXY (IMAP,XNEW,YNEW,XTMP,YTMP) IF (ICFELL('PLCHMQ',10).NE.0) RETURN C IF (XTMP.EQ.OORV) THEN IVSN=0 ELSE IVSN=1 END IF C C Process the various combinations of old-point/new-point visibility. C IF (IVSO.EQ.0.AND.IVSN.NE.0) THEN C C The old point was invisible and the new one is visible. If the line C segment between them is supposed to be drawn, use a binary-halving C process to find a point at the edge of the visible area and start C drawing there. In any case, leave the pen down at the position of C the new point. C IF (IPEN.NE.0) THEN XINV=XOLD YINV=YOLD XVIS=XNEW YVIS=YNEW DO 102 IHLF=1,64 XHLF=.5*(XINV+XVIS) YHLF=.5*(YINV+YVIS) CALL PCMPXY (IMAP,XHLF,YHLF,XTMP,YTMP) IF (ICFELL('PLCHMQ',11).NE.0) RETURN IF (XTMP.EQ.OORV) THEN IF (XHLF.EQ.XINV.AND.YHLF.EQ.YINV) GO TO 103 XINV=XHLF YINV=YHLF ELSE IF (XHLF.EQ.XVIS.AND.YHLF.EQ.YVIS) GO TO 103 XVIS=XHLF YVIS=YHLF END IF 102 CONTINUE 103 CALL PCMPXY (IMAP,XVIS,YVIS,XTMP,YTMP) IF (ICFELL('PLCHMQ',12).NE.0) RETURN XPEN=CUFX(XTMP) IF (ICFELL('PLCHMQ',13).NE.0) RETURN YPEN=CUFY(YTMP) IF (ICFELL('PLCHMQ',14).NE.0) RETURN CALL PLOTIF (XPEN,YPEN,0) END IF C CALL PCMPXY (IMAP,XNEW,YNEW,XTMP,YTMP) IF (ICFELL('PLCHMQ',15).NE.0) RETURN XPEN=CUFX(XTMP) IF (ICFELL('PLCHMQ',16).NE.0) RETURN YPEN=CUFY(YTMP) IF (ICFELL('PLCHMQ',17).NE.0) RETURN CALL PLOTIF (XPEN,YPEN,IPEN) IF (ICFELL('PLCHMQ',18).NE.0) RETURN C C Check for the next combination. C ELSE IF (IVSO.NE.0.AND.IVSN.EQ.0) THEN C C The old point was visible and the new one is not. If the line segment C between them is supposed to be drawn, use a binary-halving process to C find out where the line segment disappears and extend it to there. C IF (IPEN.NE.0) THEN XVIS=XOLD YVIS=YOLD XINV=XNEW YINV=YNEW DO 104 IHLF=1,64 XHLF=.5*(XINV+XVIS) YHLF=.5*(YINV+YVIS) CALL PCMPXY (IMAP,XHLF,YHLF,XTMP,YTMP) IF (ICFELL('PLCHMQ',19).NE.0) RETURN IF (XTMP.EQ.OORV) THEN IF (XHLF.EQ.XINV.AND.YHLF.EQ.YINV) GO TO 105 XINV=XHLF YINV=YHLF ELSE IF (XHLF.EQ.XVIS.AND.YHLF.EQ.YVIS) GO TO 105 XVIS=XHLF YVIS=YHLF END IF 104 CONTINUE 105 CALL PCMPXY (IMAP,XVIS,YVIS,XTMP,YTMP) IF (ICFELL('PLCHMQ',20).NE.0) RETURN XPEN=CUFX(XTMP) IF (ICFELL('PLCHMQ',21).NE.0) RETURN YPEN=CUFY(YTMP) IF (ICFELL('PLCHMQ',22).NE.0) RETURN CALL PLOTIF (XPEN,YPEN,1) IF (ICFELL('PLCHMQ',23).NE.0) RETURN END IF C C Check for the next combination. C ELSE IF (IVSO.NE.0.AND.IVSN.NE.0) THEN C C The old and new points are both visible. An easy case. C CALL PCMPXY (IMAP,XNEW,YNEW,XTMP,YTMP) IF (ICFELL('PLCHMQ',24).NE.0) RETURN XPEN=CUFX(XTMP) IF (ICFELL('PLCHMQ',25).NE.0) RETURN YPEN=CUFY(YTMP) IF (ICFELL('PLCHMQ',26).NE.0) RETURN CALL PLOTIF (XPEN,YPEN,IPEN) IF (ICFELL('PLCHMQ',27).NE.0) RETURN C C End of checks for different combinations. C END IF C C End of check for out-of-range value defined. C END IF C C End of interpolation loop. C 106 CONTINUE C C End of processing of X/Y coordinate pair. C END IF C C The pen goes down for the next point. C IPEN=1 C C Go back for the next digitization pair. C GO TO 101 C ELSE C C Process an "op-code", which may either force the pen up or stop us. C IF (KYCO(IPNT).NE.77) THEN IPEN=0 GO TO 101 END IF C END IF C END IF C C Move to the lower left-hand corner of the next character. C XLLC=XLLC+60.*XCOV YLLC=YLLC+60.*YCOV C 107 CONTINUE C C Flush the buffer in PLOTIF. C CALL PLOTIF (0.,0.,2) IF (ICFELL('PLCHMQ',28).NE.0) RETURN C C Done. C RETURN C END
! ***************** SUBROUTINE EXTMSK ! ***************** ! &(MASKBR,MASK,NETAGE,NELEB) ! !*********************************************************************** ! TELEMAC3D V7P0 21/08/2010 !*********************************************************************** ! !brief EXTRUDES THE 2D MASK ON THE VERTICAL FOR LATERAL !+ BOUNDARIES. ! !history J.M. HERVOUET (LNH) !+ 23/12/2003 !+ V5P5 !+ ! !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 ! !history J-M HERVOUET (EDF LAB, LNHE) !+ 19/03/2014 !+ V7P0 !+ Boundary segments have now their own numbering, independent of !+ boundary points numbering. ! !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !| MASK |-->| 2D MASK !| MASKBR |<->| 3D MASK ON LATERAL BOUNDARIES !| NELEB |-->| NUMBER OF BOUNDARY ELEMENTS !| NETAGE |-->| NUMBER OF PLANES - 1 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! USE BIEF ! USE DECLARATIONS_SPECIAL IMPLICIT NONE ! !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! INTEGER, INTENT(IN) :: NETAGE,NELEB DOUBLE PRECISION, INTENT(IN) :: MASK(*) TYPE(BIEF_OBJ), INTENT(INOUT) :: MASKBR ! !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! INTEGER IETAGE,IELEB ! !======================================================================= ! !======================================================================= ! IF(MASKBR%ELM.EQ.70) THEN ! ! QUADRILATERAL ON THE LATERAL BOUNDARIES ! DO IELEB = 1,NELEB DO IETAGE = 1,NETAGE MASKBR%R((IETAGE-1)*NELEB+IELEB)=MASK(IELEB) ENDDO ENDDO ! ELSEIF(MASKBR%ELM.EQ.60) THEN ! ! TRIANGLES ON THE LATERAL BOUNDARIES ! DO IELEB = 1,NELEB DO IETAGE = 1,NETAGE MASKBR%R((IETAGE-1)*2*NELEB+IELEB )=MASK(IELEB) MASKBR%R((IETAGE-1)*2*NELEB+IELEB+NELEB)=MASK(IELEB) ENDDO ENDDO ! ELSE ! WRITE(LU,*) 'UNKNOWN ELEMENT FOR MASKBR IN EXTMSK' CALL PLANTE(1) STOP ! ENDIF ! !----------------------------------------------------------------------- ! RETURN END
SUBROUTINE AXLINE( XS0, YS0, SLEN, THETAS, XMIN, XMAX, & NLINC, NSINC, TICL, TICS, TICANG, ITYPTC, TICLAB, TICANL, & ANGLAB, SIZLAB, NPOS, NDEC, IPOW, ITYPLB, MAX_NLABCH, AXMOD, & XOFF, LEADZERO, GRID, XTICARR, YTICARR, NUMTIC, MAXTIC, NXYS, & XVMIN, XVMAX, XLAXIS, XUAXIS, XS1, YS1 ) C C AXLINE: Plots a general linear axis with equally spaced tic marks. C The axis both starts and ends with a large tic mark, i.e. C it is subdivided into a whole number of equally spaced C large tic marks which are in turn subdivided into a whole C number of small tic marks. C C Written by Arthur Haynes, TRIUMF U.B.C., April 22, 1981 C C Input Parameters: XS0,YS0,SLEN,THETAS,XMIN,XMAX (R*4); C NLINC,NSINC (I*4); TICL,TICS,TICANG (R*4); C ITYPTC (I*4); TICLAB,TICANL,ANGLAB,SIZLAB (R*4); C NPOS,NDEC,IPOW,ITYPLB (I*4) C C Output Parameters: IPOW (If ITYPLB < 0) (I*4) C C Parameter definitions: C C XS0 : screen x-coordinate of the start of the axis C C YS0 : screen y-coordinate of the start of the axis C C SLEN : length of axis in screen units C C THETAS: angle of the axis in degrees relative to the horizontal C C XMIN : label value "X" which corresponds to the origin C of the axis, i.e. minimum "X" value of the axis C C XMAX : label value "X" which corresponds to the end of C the axis, i.e. maximum "X" value of the axis C C NLINC : number of large increments into which the axis is C to be subdivided. The number of large tic marks C plotted on the axis which delineate the large C increments will be exactly NLINC+1 C C NSINC : number of small increments into which each of the C large increments will be subdivided. The number C of small tic marks plotted between each large C increment will be exactly NSINC-1 C C TICL : length of the large tic marks which are used to C indicate the large increments C C TICS : length of the small tic marks which are used to C indicate the small increments C C TICANG: angle of the tic marks w.r.t. the axis direction C C ITYPTC: tells "AXCURV" what type of tic mark to plot C If ITYPTC = 1 then the tic marks are plotted only C on one side of the axis, i.e. that side given by "TICANG" C If ITYPTC = 2 then the tic marks are plotted symmetrically C on both sides of the axis as straight line segments C crossing the axis at an angle of "TICANG" degrees C C TICLAB: length of the virtual pointer (tic mark), which points to C the location where the axis label will be centered on its C perimeter at the large tic mark locations C C TICANL: angle of the virtual pointer (tic mark), which C points to the location where the axis label C will be centered on its perimeter at the large C tic mark locations. This angle is in degrees C relative to the axis direction C C Note: The virtual pointers are vectors whose C starting points are on the axis at the C large tic mark locations and end points C determine the positions of the axis labels C C ANGLAB: angle of the axis labels in degrees, w.r.t. the "horizontal" C screen direction if |ITYPLB| = 1, or w.r.t. the axis C direction if |ITYPLB| = 2 C C SIZLAB: height of the axis label values. If SIZLAB <= 0, C then no axis labels will be plotted C C NPOS : width in characters of the axis label format C Maximum value of "NPOS" is 20. If "NPOS" <= 0 C then no axis labels will be plotted C C NDEC : number of decimal places in the axis label format C If "NDEC" < 0 then the decimal point is suppressed C C IPOW : If "X" is an axis label value at a large tic mark C location then the label plotted will have value C "C" with format F(NPOS.NDEC) where "X" = "C" * 10**IPOW C If "ITYPLB" => 0 then "IPOW" will be accepted as C input to the subroutine C If "ITYPLB" < 0 then "IPOW" will be returned as C output from the subroutine so that the label C values "C" which are plotted will have maximum C significance in the format field F(NPOS.NDEC) C C ITYPLB: Denotes the type of label. See ANGLAB and IPOW C REAL*4 XTICARR(1), YTICARR(1), GRID INTEGER*4 NUMTIC BYTE LABEL(20) ! modified by J.Chuma, 20Mar97 for g77 INTEGER*4 NHATCH(2) COMMON /PSYM_HATCHING/ NHATCH INTEGER*4 NUMBOLD COMMON /BOLD_AXIS_NUMBERS/ NUMBOLD C Modified by J.L.Chuma, 08-Apr-1997 to elimate SIND, COSD for g77 REAL*4 DTOR /0.017453292519943/ CCC NHATCH(1) = NUMBOLD NHATCH(2) = 0 MAX_NLABCH = 0 IGRID = IFIX(GRID) C Initialize constants needed throughout the subroutine and C check the input parameters COSTH = COS(THETAS*DTOR) SINTH = SIN(THETAS*DTOR) IF( ABS(COSTH) .LE. 1.E-7 )COSTH=0.0 IF( ABS(SINTH) .LE. 1.E-7 )SINTH=0.0 COSTIC = COS(TICANG*DTOR) SINTIC = SIN(TICANG*DTOR) ANGLB = ANGLAB IF( IABS(ITYPLB) .NE. 2 )ANGLB=ANGLAB-THETAS NLINC2 = MAX(NLINC,1) NSINC2 = MAX(NSINC,1) NPOS2 = MAX(MIN0(NPOS,20),0) C If "SIZLAB" <= 0 then no labels are to be plotted. IF( SIZLAB .LE. 0 )NPOS2=0 IF( ITYPLB .LT. 0 )IPOW=0 C TICSP: is the spacing in "S" between the small tic marks of the axis TICSP = SLEN/NLINC2/NSINC2 XINC = (XVMAX-XVMIN)/NLINC2/NSINC2 IF( NPOS2 .NE. 0 )THEN IF( ITYPLB .LT. 0 )THEN C NPOS2 > 0 and ITYPLB < 0 : labels are to be plotted and C "IPOW" will be returned as output from the subroutine. CALL REALCH(XVMIN,-1,IPOW1,NPOS2,NDEC,LABEL) CALL REALCH(XVMAX,-1,IPOW2,NPOS2,NDEC,LABEL) IPOW = MAX0(IPOW1,IPOW2) END IF C Initialize some more constants to be used by the subroutine. C See "Parameter Definitions". C (XTICL,YTICL) are the coordinates of the end of the C virtual pointer (tic mark) which points to the location C where the axis label will be centered on its perimeter COSLAB = COS(ANGLB*DTOR) SINLAB = SIN(ANGLB*DTOR) XTICL = COS(TICANL*DTOR)*TICLAB YTICL = SIN(TICANL*DTOR)*TICLAB C Set "YLIM" for the call to "LABXY" which determines the label C position relative to the axis at each long tic mark. The label is C not allowed to cross the line "Y = YLIM", where "YLIM" is set to be C the maximum perpendicular distance of the long and short tic marks C from the axis on the labelled side of the axis IF( ITYPTC .NE. 2 )THEN C ITYPTC = 1 : Tic marks are plotted on one side of the axis IF( YTICL .LE. 0. )YLIM=AMIN1(SINTIC*TICL,SINTIC*TICS,0.) IF( YTICL .GT. 0. )YLIM=AMAX1(SINTIC*TICL,SINTIC*TICS,0.) ELSE C ITYPTC = 2 : Tic marks are plotted on both sides of the axis YLIM=SIGN(1.,YTICL)*AMAX1(ABS(SINTIC*TICL),ABS(SINTIC*TICS)) IF(YTICL.EQ.0.)YLIM=0. END IF END IF NTICS = NLINC2*NSINC2+1 NUMTIC = 0 LTIC = 0 XFN = XS0+COSTH*(XUAXIS-XLAXIS) YFN = YS0+SINTH*(XUAXIS-XLAXIS) CALL PLOT_R(XS0,YS0,3) CALL PLOT_R(XFN,YFN,2) EPS = (XMAX+XMIN)*0.0005 XS0 = XS0 - XS1*COSTH YS0 = YS0 - YS1*SINTH DO 100 I = 1, NTICS XDUM = XVMIN + (I-1)*XINC IF( I .EQ. NTICS )XDUM = XVMAX IF( (XDUM .LT. MIN(XMIN,XMAX)) .OR. & (XDUM .GT. MAX(XMIN,XMAX)) )GO TO 100 STIC = (I-1)*TICSP XS = XS0+COSTH*STIC YS = YS0+SINTH*STIC C Determine whether the tic length "TICLEN" is long (TICL) or short (TICS) MODINC = MOD(I-1,NSINC2) IF( MODINC .EQ. 0 )THEN LTIC = LTIC + 1 TICLEN = TICL IF( (IGRID .NE. 0) .AND. (NUMTIC .LT. MAXTIC) )THEN IF( (IGRID .LT. 0) .OR. & ((LTIC+1)/IGRID*IGRID-(LTIC+1) .EQ. 0) )THEN XTICARR(NUMTIC+1) = XS YTICARR(NUMTIC+1) = YS NUMTIC = NUMTIC + 1 END IF END IF ELSE TICLEN = TICS IF( (IGRID .LT. 0) .AND. (NUMTIC .LT. MAXTIC) )THEN XTICARR(NUMTIC+1) = XS YTICARR(NUMTIC+1) = YS NUMTIC = NUMTIC + 1 END IF END IF C (XT,YT) are the unrotated coordinates of the end of the C tic mark relative to the location "STIC" XT=COSTIC*TICLEN YT=SINTIC*TICLEN C (XTS,YTS) are rotated screen coordinates of end of the tic mark XTS=XS+COSTH*XT-SINTH*YT YTS=YS+SINTH*XT+COSTH*YT C Plot the tic mark by moving the pen from the tic mark location C (XS,YS) to the end of the tic mark (XTS,YTS) with the pen down IF( ITYPTC .EQ. 2 )THEN C ITYPTC = 2 : Plot the tic mark symmetrically on both sides of the C axis as a straight line segment crossing the axis at C an angle of "TICANG" degrees XTSN=XS-COSTH*XT+SINTH*YT YTSN=YS-SINTH*XT-COSTH*YT CALL PLOT_R(XTS,YTS,3) CALL PLOT_R(XTSN,YTSN,2) ELSE CALL PLOT_R(XS,YS,3) CALL PLOT_R(XTS,YTS,2) END IF C Check to see if a label is to be plotted IF( (MODINC .NE. 0) .OR. (NPOS2 .EQ. 0) )GO TO 100 IF( (NXYS.LT.0) .AND. ((I.EQ.1) .OR. (I.EQ.NTICS)) )GO TO 100 C MODINC = 0 and NPOS2 > 0. Therefore an x-label is to be plotted C Store the characters for the real label in "LABEL" C NLABCH: is the number of non-blank characters in "LABEL" XDUM2 = XDUM IF( AXMOD .LT. 0. )THEN XDUM2 = MOD(XDUM2,ABS(AXMOD)) ELSE IF( AXMOD .GT. 0. )THEN XDUM2 = MOD(XDUM2,AXMOD) IF( XDUM2 .LT. 0. )XDUM2 = XDUM2 + AXMOD END IF XDUM2 = XDUM2 + XOFF CALL REALCH(XDUM2,1,IPOW,NPOS2,NDEC,LABEL) IFIND = 1 DO WHILE ( CHAR(LABEL(IFIND)) .EQ. ' ' ) IF( IFIND .EQ. NPOS2 )GO TO 100 IFIND = IFIND+1 END DO NLABCH = NPOS2 - IFIND + 1 MAX_NLABCH = MAX(MAX_NLABCH,NLABCH) C Left-justify the "NLABCH" characters of "LABEL" C FLENG : is the length in screen units of the label, as C plotted by "PSYM" DO IJK = 1, NLABCH LABEL(IJK) = LABEL(IFIND+IJK-1) END DO IF( LEADZERO .GT. 0 )THEN IF( CHAR(LABEL(1)) .EQ. '.' )THEN DO IJK = MIN(20,NLABCH), 1, -1 LABEL(IJK+1) = LABEL(IJK) END DO LABEL(1) = ICHAR('0') NLABCH = NLABCH + 1 MAX_NLABCH = MAX(MAX_NLABCH,NLABCH) END IF END IF IF( CHAR(LABEL(1)) .EQ. '-' )THEN IF( CHAR(LABEL(2)) .EQ. '.' )THEN DO IJK = MIN(19,NLABCH), 2, -1 LABEL(IJK+1) = LABEL(IJK) END DO LABEL(2) = ICHAR('0') NLABCH = NLABCH + 1 MAX_NLABCH = MAX(MAX_NLABCH,NLABCH) END IF END IF FLENG = PSMLEN(LABEL,NLABCH,SIZLAB) C Determine the lower left hand corner: (XLAB,YLAB) at which the label C is to be plotted, relative to the axis direction, and the location C "STIC" of the large tic mark on the axis CALL LABXY(XTICL,YTICL,ANGLB,COSLAB,SINLAB,SIZLAB, & FLENG,YLIM,XLAB,YLAB) C (XLS,YLS) are the rotated screen coordinates at which the label is C to be plotted by "PSYM" XLS=XS+COSTH*XLAB-SINTH*YLAB YLS=YS+SINTH*XLAB+COSTH*YLAB IF(XLS.EQ.-0.)XLS=0. IF(YLS.EQ.-0.)YLS=0. C Plot the label at angle relative to the horizontal of ANGLE degrees ANGLE=ANGLB+THETAS CALL PSYMBOLD(XLS,YLS,SIZLAB,LABEL,ANGLE,NLABCH) C Move with the pen up to the beginning of the tic mark 100 CONTINUE NHATCH(1) = 0 NHATCH(2) = 0 RETURN END
SUBROUTINE ALSASK (ALIST, KEYWRD, TYPE, DIM, IERR) C----------------------------------------------------------------------- C! Inquire about an entry in an Associative list (ALIST) C# Utility C----------------------------------------------------------------------- C; Copyright (C) 1995 C; Associated Universities, Inc. Washington DC, USA. C; C; This program is free software; you can redistribute it and/or C; modify it under the terms of the GNU General Public License as C; published by the Free Software Foundation; either version 2 of C; the License, or (at your option) any later version. C; C; This program is distributed in the hope that it will be useful, C; but WITHOUT ANY WARRANTY; without even the implied warranty of C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the C; GNU General Public License for more details. C; C; You should have received a copy of the GNU General Public C; License along with this program; if not, write to the Free C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, C; MA 02139, USA. C; C; Correspondence concerning AIPS should be addressed as follows: C; Internet email: aipsmail@nrao.edu. C; Postal address: AIPS Project Office C; National Radio Astronomy Observatory C; 520 Edgemont Road C; Charlottesville, VA 22903-2475 USA C----------------------------------------------------------------------- C----------------------------------------------------------------------- C Public C Inquire about an entry in an Associative list (ALIST) C See ALSINI for details of the package. C Note the AIPS datatypes are defined as parameters in the INCLUDE C 'INCS:PAOOF.INC': OOADP = double precision, OOARE = real, C OOACAR = character, OOAINT = integer, and OOALOG = logical. C Inputs: C ALIST I(*) ALIST array C KEYWRD C*16 Keyword C Outputs: C TYPE I data type: 1=D, 2=R, 3=C, 4=I, 5=L C DIM I(*) Dimensionality of value, an axis dimension of zero C means that that dimension and higher are undefined. C IERR I Error code, 0=OK. 1=> didn't find. C----------------------------------------------------------------------- INTEGER ALIST(*), TYPE, DIM(*), IERR CHARACTER KEYWRD*(*) C INTEGER KEYPNT, NDIM, DATOFF CHARACTER ALNAME*32 INCLUDE 'INCS:PALIST.INC' C----------------------------------------------------------------------- IERR = 0 NDIM = ALIST(ALSNDM) DATOFF = ALIST(ALSDAT) C Validity test IF (ALIST(ALSCHK).NE.ALSCVL) THEN MSGTXT = 'ALSASK: DAMAGED OR UNINITIALIZED ALIST' IERR = 6 GO TO 990 END IF C See if keyword is in the list CALL ALSKEY (ALIST, KEYWRD, KEYPNT, IERR) IF (IERR.NE.0) THEN C Didn't find IERR = 1 GO TO 999 END IF C Type TYPE = ALIST(KEYPNT+ALSTYP) C Dimensions CALL COPY (NDIM, ALIST(KEYPNT+ALSDIM), DIM) GO TO 999 C Error 990 CALL MSGWRT (6) MSGTXT = 'KEYWORD =' // KEYWRD CALL MSGWRT (6) CALL H2CHR (32, 1, ALIST(ALSNAM), ALNAME) MSGTXT = 'PROBLEM WITH ALIST: ' // ALNAME CALL MSGWRT (6) C 999 RETURN END
PROGRAM LABQPT IMPLICIT NONE C ******************************************************************** C * * C * This software is an unpublished work containing confidential and * C * proprietary information of Birkbeck College. Use, disclosure, * C * reproduction and transfer of this work without the express * C * written consent of Birkbeck College are prohibited. This notice * C * must be attached to all copies or extracts of the software. * C * * C * (c) 1993, 1996 Oliver Smart & Birkbeck College, * C * * C ******************************************************************** C C Modification history: C C Date Author Modification C 12/93 O.S. Smart Original public release in HOLE suite beta1.0 C 28/02/97 O.S.S. Release HOLE2 beta001 C 11/97 O.S.S. vt control codes C C C This program allows the user to produce a QUANTA binary 3D plot file C containing labels for selected atoms read from a pdb format co-ordinate file. C use freda to decode some replies INCLUDE 'FREDAINC' C screen, keyboard INTEGER NIN PARAMETER( NIN = 5) INTEGER NOUT PARAMETER( NOUT= 6) C input/output file stream INTEGER SIN, SOUT C dummy filename CHARACTER*200 FDUM C working integer INTEGER IDUM C abort indicator LOGICAL LABORT C s/r tsatr which reads pdb file needs bonding and vdw radius arrays C (though they are not used here) C maximum no of entries in lists INTEGER MAXLST PARAMETER( MAXLST = 1) C bond radius list INTEGER BNDNO CHARACTER*4 BNDBRK(MAXLST) DOUBLE PRECISION BNDR(MAXLST) C vdW radius list INTEGER VDWNO CHARACTER*4 VDWBRK(MAXLST) CHARACTER*3 VDWRES(MAXLST) DOUBLE PRECISION VDWR(MAXLST) C arrays to store atoms C maximum no. of atoms INTEGER ATMAX PARAMETER( ATMAX = 10000) C number of atoms read in from each file: INTEGER ATNO C atom names found in Brookhaven file: CHARACTER*4 ATBRK(ATMAX) C residue name in brook CHARACTER*3 ATRES(ATMAX) C integer residue no. INTEGER ATRNO(ATMAX) C chain identifier in brookhaven pdb file CHARACTER*1 ATCHN(ATMAX) C co-ordinates DOUBLE PRECISION ATXYZ( 3, ATMAX) C vdw and bond radii of each atoms DOUBLE PRECISION ATVDW(ATMAX), ATBND(ATMAX) C error indicator LOGICAL LERR C test name to find atom, test residue number C (which becomes atom's list numb) and test chain id CHARACTER*4 BRK INTEGER IAT CHARACTER*1 TCH C logical function which finds list number for a particular atom LOGICAL SSAFN2 C character to be output CHARACTER*80 LAB C number of characters in label to be output C the position controling integer INTEGER LABEND, POSINT C real number for writing REAL RVEC4(4) C (added 11/97 for call to tsatr - not neeeded here) C introduce a string which will list residues to be ignored on read CHARACTER*80 IGNRES C need to record on the initial read of the pdb file the C original atom numbers of the each atom from the pdb file C - as we ignore some residues in the read. C oatno(0) is the total number of original atoms in the pdb file C oatno(1) is the original atom number of the stored atom#1 etc. INTEGER OATNO(0:ATMAX) C end of decs *********** C ignore residue string IGNRES = '........................................'// & '........................................' C turn on VT codes with bold after prompt- CALL VTCON( .TRUE.) WRITE( NOUT, '(A)') &' This program allows the user to produce a QUANTA', &' binary 3D plot file containing labels for selected atoms', &' read from a pdb format co-ordinate file.', &' Copyright 1993,1997 by Oliver Smart and Birkbeck College', &' Copyright 2004 by Oliver Smart ', &' Program modification number 2.2 001' C write link time of program to screen CALL VERTIM( NOUT) WRITE( NOUT, '(A)') &' ', &' Program qplot includes an extension to the standard qpt format.', &' You can specify an integer to indicate where each string ', &' should be placed on the page in a qplot output file', &' 1 indicates below to the left', &' 2 ............... centred etc.', &' key to remember 789', &' 456 (like a numeric keypad)', &' 123', &' ' C find last .pdb file in the current directory CALL LASTF( FDUM, '.pdb') IF (FDUM(1:4).EQ.'none') FDUM = 'input' C get input filename LABORT = .TRUE. C (input stream, output, oldfile?, file_stream, file_type, name, C allow abort?, default extension) CALL INTERF( NIN, NOUT, .TRUE., SIN, & 'input pdb co-ordinate', FDUM, LABORT, '.pdb') IF (LABORT) GOTO 55555 C get output filename LABORT = .TRUE. C default filename should be same as pdb filename with _label on the end C assume that pdb file will be identified with one of .pdb, .brk or .atm IDUM = MAX( INDEX(FDUM,'.pdb'), & INDEX(FDUM,'.brk'), INDEX(FDUM,'.atm')) IF (IDUM.NE.0) FDUM = FDUM(1:IDUM-1)//'_label' CALL INTERF( NIN, NOUT, .FALSE., SOUT, & 'output binary quanta plot file', FDUM, LABORT, '.qpt') IF (LABORT) GOTO 55555 C Use s/r tsatr to read in pdb file, C As in porgram HOLE - originally written for program TooShort. C The two logicals set false mean that bond and vdw radii are C not set up for each atom - as they are not needed here. CALL TSATR( SIN, NOUT, LERR, .FALSE., .FALSE., .FALSE., & ATMAX, ATNO, ATBRK, ATRES, ATCHN, ATRNO, ATXYZ, ATVDW, ATBND, & MAXLST, BNDNO, BNDBRK, BNDR, VDWNO, VDWBRK, VDWRES, VDWR, & IGNRES, OATNO) IF (LERR) GOTO 55555 WRITE( NOUT, '(/A,I5,A)') &' Have read', ATNO, ' atoms from the pdb file' C start loop where we ask for an atom to be labelled 10 CONTINUE WRITE( NOUT, '(/20(A:/))' ) &' Which atom do you want to be labelled?', &' Specify atom name, resno (eg. CA 1) or', &' atom name, resno, chain id. (eg. CG2 23 D).', &' (If no chain id. is specified then no any chain id will'// & ' do for a match).', &' Numerical chain id''s should be preceeded by a / eg. /2' CALL PROMPT( NOUT, & 'Which atoms <no more labels>: ') READ( NIN, '(A)', ERR= 55555, END= 55555) COL CALL VTCLEAR( NOUT) IF (INDEX(COL,' ').EQ.1) GOTO 55555 C used freda to decode col CALL FREDA(1,80,FL,6) C info returned C kl must be at least one kn at least one C fl(1,1 to 4): brookhaven atom name C fn(1) : residue no C and optionally C fl(1,1) chain id C clear col COL = ' ' IF ((KL.LT.1) .OR. (KN.LT.1)) THEN WRITE( NOUT, *) &'Must specify at least one name & one number!'//CHAR(7) GOTO 10 ELSE C assume two names + 1 no. BRK = FL(1,1)//FL(1,2)//FL(1,3)//FL(1,4) IAT = FN(1) TCH = '?' ENDIF C chain id specified? IF (KL.GE.2) THEN TCH = FL(2,1) C if a backslash specified take 2nd character IF (TCH.EQ.'/') TCH = FL(2,2) ENDIF C to find list number for atom use routine grabbed from series_stat C ssafn2( C4, I, C1, *) will find out whether atom C name C4 resno I chain C1 exists: C if it does i will be returned as list no. C if not ssafn2 will be returned .false. IF (.NOT.SSAFN2( BRK, IAT, TCH, & ATMAX, ATNO, ATBRK, ATRNO, ATCHN) )THEN WRITE(NOUT, '( A,I5, A/ A)' ) &' Cannot find atom: '//BRK//' residue no:', IAT, &' chain: '//TCH, &' Please try again!'//CHAR(7) GOTO 10 ENDIF C user wants to label atom iat C What label? C make up default WRITE( LAB, '(A,I5)') ATBRK(IAT), ATRNO(IAT) C eliminate all double spaces do until all gone 15 CONTINUE C find last non-blank character in default label CALL CHREND( LAB, LABEND) C first (if any double space IDUM = INDEX(LAB(1:LABEND),' ') IF (IDUM.GT.0) THEN LAB(IDUM:LABEND) = LAB(IDUM+1:LABEND+1) GOTO 15 ENDIF C label stripped of all double spaces C make up prompt COL = & 'What label do you to place at atom''s position? <'// & LAB(1:LABEND)//'>:' CALL PROMPT( NOUT, COL) READ( NIN, '(A)', END= 55555, ERR= 55555) COL CALL VTCLEAR( NOUT) C wants default? IF (COL(1:5).NE.' ') THEN LAB = COL C has specified label in col - find last non-blank character CALL CHREND( LAB, LABEND) C if the last character in label is a '/' then make a space IF (LAB(LABEND:LABEND).EQ.'/') LAB(LABEND:LABEND) = ' ' ENDIF C ask for positioning integer CALL PROMPT( NOUT, & 'What position # do you want for label <6>:') POSINT = 6 READ( NIN, '(A)', END= 55555, ERR= 55555) COL CALL VTCLEAR( NOUT) CALL FREDA(1,80,FL,6) IF (KN.GE.1) POSINT = FN(1) C make sure that it is within limits IF (POSINT.GT.9) POSINT = 9 IF (POSINT.LT.1) POSINT = 1 C finally write the record IF (LABEND.EQ.0) THEN WRITE( NOUT, '(A)') &' ERROR'//CHAR(7)//' cannot plot zero length string!!!' ELSE C move to atom RVEC4(1) = 2. RVEC4(2) = ATXYZ(1,IAT) RVEC4(3) = ATXYZ(2,IAT) RVEC4(4) = ATXYZ(3,IAT) WRITE( SOUT) RVEC4 C character record - indicate by 5.0 number of character C the last record is positioning integer RVEC4(1) = 5. RVEC4(2) = LABEND RVEC4(3) = 0. RVEC4(4) = POSINT WRITE( SOUT) RVEC4 C write the bloody thing WRITE( SOUT) LAB(1:LABEND) ENDIF C got back up and do next label GOTO 10 55555 CONTINUE WRITE( NOUT,*) STOP 'FORTRAN STOP - labqpt normal completion.' END
C MODULE PUOPT2 C SUBROUTINE PUOPT2 (P,MP,C,MC,T,MT,TS,MTS,NUMOP,IERR) C....................................... C THIS ROUTINE CALLS THE PUNCH CARD ROUTINES FOR C OPERATIONS 20 THRU 40. C....................................... C ROUTINE WRITTEN BY... C ERIC ANDERSON - HRL APRIL 1981 C....................................... DIMENSION P(MP),C(MC),TS(MTS) C INTEGER T(MT) C C COMMON BLOCKS COMMON/FDBUG/IODBUG,ITRACE,IDBALL,NDEBUG,IDEBUG(20) COMMON/FCOPPT/LOCT,LPM,LCO C C ================================= RCS keyword statements ========== CHARACTER*68 RCSKW1,RCSKW2 DATA RCSKW1,RCSKW2 / ' .$Source: /fs/hseb/ob72/rfc/ofs/src/fcinit_setup/RCS/puopt2.f,v $ . $', ' .$Id: puopt2.f,v 1.4 1998/07/02 19:34:52 page Exp $ . $' / C =================================================================== C C....................................... C TRACE LEVEL=1 C IF(ITRACE.GE.1)WRITE(IODBUG,900) 900 FORMAT(1H0,17H** PUOPT2 ENTERED) C....................................... C CHECK THAT A CALL TO THE OPERATION IS INCLUDED. C IF((NUMOP.LT.20).OR.(NUMOP.GT.40)) GO TO 190 C....................................... C GO TO THE SECTION FOR THE CURRENT OPERATION. C NUM=NUMOP-19 GO TO (200,201,202,203,204,205,206,207,190,209, 1 210,211,212,213,214,215,216,217,218,219,220),NUM C....................................... C CHANGE TIME INTERVAL OPERATION. C 200 CALL PUC20(P(LPM),C(LCO)) GO TO 99 C....................................... C DWOPER OPERATION C 201 LPMM1=LPM-1 LKD=P(LPMM1+53) + LPMM1 LKU=P(LPMM1+54) + LPMM1 LNB=P(LPMM1+56) + LPMM1 LNCM=P(LPMM1+74) + LPMM1 LNCSSS=P(LPMM1+75) + LPMM1 LNCSS1=P(LPMM1+57) + LPMM1 LNJUN=P(LPMM1+58) + LPMM1 LNNYQ=P(LPMM1+59) + LPMM1 LNQL=P(LPMM1+60) + LPMM1 LNRCM1=P(LPMM1+61) + LPMM1 LNRT1=P(LPMM1+62) + LPMM1 LNT=P(LPMM1+76) + LPMM1 LNWJ=P(LPMM1+64) + LPMM1 LNUMLA=P(LPMM1+63) + LPMM1 LNWJX=P(LPMM1+77) + LPMM1 LLAD=P(LPMM1+73) + LPMM1 LLQ=P(LPMM1+93) + LPMM1 LNSTR=P(LPMM1+104) + LPMM1 LNST=P(LPMM1+107) + LPMM1 LNDIV=P(LPMM1+109) + LPMM1 LLDIV=P(LPMM1+110) + LPMM1 LKTYPE=P(LPMM1+108) + LPMM1 LIWTI=P(LPMM1+125) + LCO-1 LNQSL=P(LPMM1+143) + LPMM1 CALL PUC21(P(LPM),C(LCO),P(LKD),P(LKU),P(LNB),P(LNCM), 1 P(LNCSSS),P(LNCSS1),P(LNJUN),P(LNNYQ),P(LNQL),P(LNRCM1), 2 P(LNRT1),P(LNT),P(LNWJ),P(LNUMLA),P(LNWJX),P(LLAD), 3 P(LLQ),P(LNSTR),P(LNST),P(LNDIV),P(LLDIV),P(LKTYPE),C(LIWTI), 4 P(LNQSL)) GO TO 99 C....................................... C HFS OPERATION. C 202 CALL PUC22(P(LPM),C(LCO)) GO TO 99 C....................................... C STAGE-DISCHARGE CONVERSION. C 203 CALL PUC23(P(LPM),C(LCO)) GO TO 99 C....................................... C API-CONT OPERATION C 204 CALL PUC24(P(LPM),C(LCO)) GO TO 99 C....................................... C PLOT-TUL OPERATION C 205 CALL PUC25(P(LPM)) GO TO 99 C....................................... C SINGLE RESERVOIR SIMULATION OPERATION. C 206 CALL PUC26(P(LPM),MC,LCO,C(LCO)) GO TO 99 C....................................... C FORT WORTH TABULAR DISPLAY C 207 CALL PUC27(P(LPM)) GO TO 99 C....................................... C KANSAS CITY API OPERATION C 209 CALL PUC29(P(LPM),C(LCO)) GO TO 99 C....................................... C MERGE TIME SERIES OPERATION C 210 CALL PUC30(P(LPM)) GO TO 99 C....................................... C HYDRO-43 SNOW MODEL C 211 CALL PUC31(P(LPM),C(LCO)) GO TO 99 C....................................... C FLASH FLOOD GUIDANCE OPERATION C 212 CALL PUC32(P(LPM)) GO TO 99 C....................................... C CINCINNATI API OPERATION C 213 CALL PUC33(P(LPM),C(LCO)) GO TO 99 C....................................... C SALT LAKE CITY API OPERATION C 214 CALL PUC34(P(LPM),C(LCO)) GO TO 99 C....................................... C HARRISBURG RFC API OPERATION C 215 CALL PUC35(P(LPM),C(LCO)) GO TO 99 C....................................... C XINANJIANG MODEL C 216 CALL PUC36(P(LPM),C(LCO)) GO TO 99 C....................................... C MINNEAPOLIS RUNOFF TABULATION C 217 CALL PUC37(P(LPM)) GO TO 99 C....................................... C BASEFLOW OPERATION C 218 CALL PUC38(P(LPM),C(LCO)) GO TO 99 C....................................... C TABLE LOOKUP -- FT. WORTH C 219 CALL PUC39(P(LPM)) GO TO 99 C....................................... C WATER BALANCE OPERATION C 220 CALL PUC40(P(LPM)) GO TO 99 C...................................... C OPERATION NOT INCLUDED. C 190 IERR=1 99 CONTINUE RETURN END
SUBROUTINE GETBAS IMPLICIT REAL*8 (A-H,O-Z) DIMENSION I30(200),LICT(400) COMMON/COM101/NATOM,N3N COMMON/COM104/NT,NCASE,ISPOT(150) COMMON/COM105/IOFF(256),IPRNT COMMON/COM106/PTR(3,3,48) COMMON/COM107/ICT(150,48) C 1 FORMAT(/,2X,' ICT MATRIX, ISYM = ',I5/) 2 FORMAT(2X,10I5) 3 FORMAT(/,2X,' PTR MATRIX, ISYM = ',I5/) C IOFF(1)=0 DO 101 I=1,255 101 IOFF(I+1)=IOFF(I)+I C C GET CONSTANTS FROM TAPE30 ITAP30=30 CALL RFILE(ITAP30) CALL SREW(ITAP30) CALL WREADW(ITAP30,I30,200,101,JUNK) C MPOINT = I30(2) MCONST = I30(3) NATOM = I30(19) NT = I30(29) N3N=NATOM*3 NATRI=IOFF(N3N+1) C C READ POINTERS FROM TAPE30 IPOS=101+MCONST CALL WREADW(ITAP30,I30,MPOINT,IPOS,JUNK) C C READ SYMMETRY INFORMATION CALL WREADW(ITAP30,LICT,NATOM*NT,I30(2),JUNK) CALL WREADW(ITAP30,PTR,3*3*NT*2,I30(31),JUNK) C DO 103 I=1,NT II=(I-1)*NATOM DO 102 IATOM=1,NATOM II=II+1 ICT(IATOM,I)=LICT(II) 102 CONTINUE 103 CONTINUE C DO 104 ISYM=1,NT WRITE(6,1) ISYM WRITE(6,2) (ICT(I,ISYM),I=1,NATOM) WRITE(6,3) ISYM CALL MATOUT(PTR(1,1,ISYM),3,3,3,3,6) 104 CONTINUE C CALL RCLOSE(ITAP30,3) RETURN END
!------------------------------------------------------------------------! ! The Community Multiscale Air Quality (CMAQ) system software is in ! ! continuous development by various groups and is based on information ! ! from these groups: Federal Government employees, contractors working ! ! within a United States Government contract, and non-Federal sources ! ! including research institutions. These groups give the Government ! ! permission to use, prepare derivative works of, and distribute copies ! ! of their work in the CMAQ system to the public and to permit others ! ! to do so. The United States Environmental Protection Agency ! ! therefore grants similar permission to use the CMAQ system software, ! ! but users are requested to provide copies of derivative works or ! ! products designed to operate in the CMAQ system to the United States ! ! Government without restrictions as to use by others. Software ! ! that is used with the CMAQ system but distributed under the GNU ! ! General Public License or the GNU Lesser General Public License is ! ! subject to their copyright restrictions. ! !------------------------------------------------------------------------! C::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SUBROUTINE HCDIFF3D ( JDATE, JTIME, K11BAR, K22BAR, DT ) C----------------------------------------------------------------------- C Function: C Computes the contravariant diffusivities in x1 or x2 directions C using a constant physical horizontal diffusivity. C Preconditions: C This routine can only be used for conformal map coordinates C in the horizontal. C Dates and times should be represented YYYYDDD:HHMMSS. C Subroutines and functions called: C INTERP3, M3EXIT, DEFORM C Revision history: C October 17, 1995 by M. Talat Odman and Clint L. Ingram at NCSC: C created for SAQM-type coordinates C 5 Nov 97 Jeff targetted C Sep. 1998 David Wong C -- parallelize the code C -- use GLOBAL_MAX to compute the global max C 1/19/99 David Wong C -- add a loop_index call C -- change loop index ending point to avoid accessing invalid region. C (reason to do this is to prevent using boundary data from PINTERP, C which sets pseudo-boundary data to 0) C Jul. 8 1999 David Wong C -- replace GLOBAL_MAX with GLOBAL_RMAX for naming consistency C C 10/10/2000 Daewon Byun C -- generalized 3d horizontal diffusivity C 23 Dec 00 J.Young: GLOBAL_RMAX -> Dave Wong's f90 stenex GLOBAL_MAX C PE_COMM3 -> Dave Wong's f90 stenex COMM C 6 Aug 01 J.Young: Use HGRD_DEFN; replace INTERP3 with INTERPX; C allocatable arrays C 31 Jan 05 J.Young: dyn alloc - establish both horizontal & vertical C domain specifications in one module C 16 Feb 11 S. Roselle: replaced I/O-API include files w/UTILIO_DEFN C 03 Aug 11 David Wong: moved DT calculation outside the loop for efficency C purposes C 01 Feb 19 David Wong: Implemented centralized I/O approach, removed all MY_N C clauses C----------------------------------------------------------------------- USE GRID_CONF ! horizontal & vertical domain specifications USE UTILIO_DEFN USE CENTRALIZED_IO_MODULE #ifdef parallel USE SE_MODULES ! stenex (using SE_GLOBAL_MAX_MODULE, SE_COMM_MODULE, ! SE_UTIL_MODULE) #else USE NOOP_MODULES ! stenex (using NOOP_GLOBAL_MAX_MODULE, NOOP_COMM_MODULE, ! NOOP_UTIL_MODULE) #endif IMPLICIT NONE C Includes: INCLUDE SUBST_CONST ! constants INCLUDE SUBST_FILES_ID ! file name parameters INCLUDE SUBST_PE_COMM ! PE communication displacement and direction C Arguments: INTEGER, INTENT( IN ) :: JDATE ! current model date, coded YYYYDDD INTEGER, INTENT( IN ) :: JTIME ! current model time, coded HHMMSS ! Contravariant diffusivity ! REAL K11BAR3D( NCOLS+1,NROWS+1,NLAYS ) ! x1-flux points ! REAL K22BAR3D( NCOLS+1,NROWS+1,NLAYS ) ! x2-flux points REAL, INTENT( OUT ) :: K11BAR( :,:,: ) ! x1-flux points REAL, INTENT( OUT ) :: K22BAR( :,:,: ) ! x2-flux points REAL, INTENT( OUT ) :: DT ! diffusivity time step C Parameters: C Horizontal eddy diffusivity (m^2/s) ! REAL, PARAMETER :: KH = 3.3E+04 ! From Brost et al., J.Geophys.Res., 1988 ! REAL, PARAMETER :: KH = 50.0 ! For 12 km SARMAP simulation as per SAQM REAL, PARAMETER :: KH = 2000.0 ! For 4 km SARMAP simulation as per SAQM REAL, PARAMETER :: KHMIN = 200.0 ! For min KH assigned for deformation REAL, PARAMETER :: DXB = 4000.0 REAL, PARAMETER :: ALP = 0.28 C "Courant" factor = 99%(1/sqrt(2)) ! REAL, PARAMETER :: CFC = 0.700 REAL, PARAMETER :: CFC = 0.300 C local variables: CHARACTER( 16 ) :: PNAME = 'HCDIFF3D' CHARACTER( 96 ) :: XMSG = ' ' LOGICAL, SAVE :: FIRSTIME = .TRUE. INTEGER, SAVE :: MLAYS REAL, SAVE :: DX1, DX2 ! CX x1- and x2-cell widths REAL, SAVE :: KHA ! resolution-adjusted base diffusivity REAL, SAVE :: ACOEF ! ALP**2 * DX1 * DX2 REAL KHD ! Deformation induced KH REAL DEFORM3D( NCOLS+1,NROWS+1,NLAYS ) ! wind deformation REAL EDDYH3D ( NCOLS+1,NROWS+1,NLAYS ) ! Contra. diffusivity REAL EFFKB ! Effective Kbar ! REAL EKHMAX ! max Contra. diffusivity (diagnos) ! REAL MS2MAX ! max squared map scale factor (diagnos) INTEGER ALLOCSTAT INTEGER COL, ROW, LVL ! column,row,level indices INTEGER MY_TEMP INTEGER, SAVE :: STARTROW, ENDROW INTEGER, SAVE :: STARTCOL, ENDCOL INTERFACE SUBROUTINE DEFORM( JDATE, JTIME, DEFORM3D ) INTEGER, INTENT( IN ) :: JDATE, JTIME REAL, INTENT( OUT ) :: DEFORM3D( :,:,: ) END SUBROUTINE DEFORM END INTERFACE C----------------------------------------------------------------------- IF ( FIRSTIME ) THEN FIRSTIME = .FALSE. MLAYS = SIZE ( K11BAR,3 ) CALL SUBST_LOOP_INDEX ( 'R', 1, NROWS, 1, MY_TEMP, STARTROW, ENDROW ) CALL SUBST_LOOP_INDEX ( 'C', 1, NCOLS, 1, MY_TEMP, STARTCOL, ENDCOL ) IF ( GDTYP_GD .EQ. LATGRD3 ) THEN DX1 = DG2M * XCELL_GD ! in m. DX2 = DG2M * YCELL_GD & * COS( PI180*( YORIG_GD + YCELL_GD * FLOAT( GL_NROWS/2 ))) ! in m. ELSE DX1 = XCELL_GD ! in m. DX2 = YCELL_GD ! in m. END IF C Get map scale factor KHA = ( DXB * DXB ) / ( DX1 * DX2 ) * KH ACOEF = ALP * ALP * ( DX1 * DX2 ) END IF ! if firstime C get wind deformation CALL DEFORM ( JDATE, JTIME, DEFORM3D ) EDDYH3D = 0.0 DO LVL = 1, MLAYS ! EKHMAX = 0.0 DO ROW = STARTROW, ENDROW ! DO ROW = 1, NROWS+1 DO COL = STARTCOL, ENDCOL ! DO COL = 1, NCOLS+1 ! EDDYH3D( COL,ROW,LVL ) = MSFD2( COL,ROW ) * ! & ( ACOEF * KHA * DEFORM3D( COL,ROW,LVL ) ! & / ( KHA + ACOEF * DEFORM3D( COL,ROW,LVL ) ) ! & + KHMIN ) ! Daewon prefers the following KHD = MAX( KHMIN, ACOEF * DEFORM3D( COL,ROW,LVL ) ) EDDYH3D( COL,ROW,LVL ) = MSFD2( COL,ROW ) & * KHA * KHD / ( KHA + KHD ) ! EKHMAX = MAX( EKHMAX, EDDYH3D( COL,ROW,LVL ) ) END DO END DO END DO CALL SUBST_COMM ( EDDYH3D, DSPL_N1_E1_S0_W0, DRCN_N_E ) C Obtain flux average values of contravariant diffusivities EFFKB = 0.0 DO LVL = 1, MLAYS DO ROW = 1, NROWS + 1 DO COL = 1, NCOLS + 1 K11BAR( COL,ROW,LVL ) = 0.0 K22BAR( COL,ROW,LVL ) = 0.0 END DO END DO END DO 1003 FORMAT( / '@2@Layer', 5X, 'Time Step', 9X, 'EffKB' ) DO LVL = 1, MLAYS DO ROW = 1, NROWS DO COL = STARTCOL, ENDCOL K11BAR( COL,ROW,LVL ) = 0.5 * ( EDDYH3D( COL,ROW+1,LVL ) & + EDDYH3D( COL,ROW,LVL ) ) END DO END DO DO COL = STARTCOL, ENDCOL K11BAR( COL,NROWS+1,LVL ) = 0.0 END DO DO ROW = STARTROW, ENDROW DO COL = 1, NCOLS K22BAR( COL,ROW,LVL ) = 0.5 * ( EDDYH3D( COL,ROW,LVL ) & + EDDYH3D( COL+1,ROW,LVL ) ) END DO END DO DO ROW = STARTROW, ENDROW K22BAR( NCOLS+1,ROW,LVL ) = 0.0 END DO DO ROW = 1, NROWS DO COL = 1, NCOLS EFFKB = MAX ( EFFKB, & K11BAR( COL,ROW,LVL ), & K22BAR( COL,ROW,LVL ) ) END DO END DO ! DT = CFC * DX1 * DX2 / SUBST_GLOBAL_MAX ( EFFKB ) 1005 FORMAT( '@2@ ', I3, 1X, F18.7, 1X, F12.7 ) END DO ! for LVL DT = CFC * DX1 * DX2 / SUBST_GLOBAL_MAX ( EFFKB ) RETURN END
SUBROUTINE STRIR1 C C C***** C THIS ROUTINE IS PHASE I OF STRESS DATA RECOVERY FOR THE TRIANGULAR C CROSS SECTION RING C***** C C C ECPT FOR THE TRIANGULAR RING C C C TYPE C ECPT( 1) ELEMENT IDENTIFICATION I C ECPT( 2) SCALAR INDEX NO. FOR GRID POINT A I C ECPT( 3) SCALAR INDEX NO. FOR GRID POINT B I C ECPT( 4) SCALAR INDEX NO. FOR GRID POINT C I C ECPT( 5) MATERIAL ORIENTATION ANGLE(DEGREES) R C ECPT( 6) MATERIAL IDENTIFICATION I C ECPT( 7) COOR. SYS. ID. FOR GRID POINT A I C ECPT( 8) X-COOR. OF GRID POINT A (IN BASIC COOR.) R C ECPT( 9) Y-COOR. OF GRID POINT A (IN BASIC COOR.) R C ECPT(10) Z-COOR. OF GRID POINT A (IN BASIC COOR.) R C ECPT(11) COOR. SYS. ID. FOR GRID POINT B I C ECPT(12) X-COOR. OF GRID POINT B (IN BASIC COOR.) R C ECPT(13) Y-COOR. OF GRID POINT B (IN BASIC COOR.) R C ECPT(14) Z-COOR. OF GRID POINT B (IN BASIC COOR.) R C ECPT(15) COOR. SYS. ID. FOR GRID POINT C I C ECPT(16) X-COOR. OF GRID POINT C (IN BASIC COOR.) R C ECPT(17) Y-COOR. OF GRID POINT C (IN BASIC COOR.) R C ECPT(18) Z-COOR. OF GRID POINT C (IN BASIC COOR.) R C ECPT(19) EL. TEMPERATURE FOR MATERIAL PROPERTIES R C C DIMENSION IECPT(19) DIMENSION R(3), Z(3), ICS(3) DIMENSION SP(18), TEO(16), DELINT(8) C COMMON /CONDAS/ CONSTS(5) COMMON /SDR2X5/ 1 ECPT(19) 2, DUM5(81) 3, IDEL, IGP(3), TZ 4, SEL(36), TS(4), AK(81) COMMON /MATIN/ 1 MATIDC ,MATFLG 2, ELTEMP ,STRESS 3, SINTH ,COSTH COMMON /MATOUT/ 1 E(3) ,ANU(3) 2, RHO ,G(3) 3, ALF(3) ,TZERO COMMON /SDR2X6/ 1 D(81) , GAMBQ(36), EE(16), GAMQS(54) 3, DZERO(24), GAMBL(81), ALFB(4) C EQUIVALENCE ( CONSTS(2) , TWOPI ) EQUIVALENCE ( CONSTS(4) , DEGRA ) EQUIVALENCE (IECPT(1) , ECPT(1)) EQUIVALENCE (R(1),R1), (R(2),R2), (R(3),R3) 1, (Z(1),Z1), (Z(2),Z2), (Z(3),Z3) EQUIVALENCE (GAMBL( 1), SP(1)) EQUIVALENCE (GAMBL( 1), TEO(1)) EQUIVALENCE (GAMBL(17), DELINT(1)) C C ---------------------------------------------------------------------- C C STORE ECPT PARAMETERS IN LOCAL VARIABLES C IDEL = IECPT(1) IGP(1)= IECPT(2) IGP(2)= IECPT(3) IGP(3)= IECPT(4) MATID = IECPT(6) ICS(1)= IECPT(7) ICS(2)= IECPT(11) ICS(3)= IECPT(15) R(1) = ECPT(8) D(1) = ECPT(9) Z(1) = ECPT(10) R(2) = ECPT(12) D(2) = ECPT(13) Z(2) = ECPT(14) R(3) = ECPT(16) D(3) = ECPT(17) Z(3) = ECPT(18) TEMPE = ECPT(19) DGAMA = ECPT(5) C C C TEST THE VALIDITY OF THE GRID POINT COORDINATES C DO 200 I = 1,3 IF (R(I) .LT. 0.0E0) CALL MESAGE (-30, 37, IDEL) IF (D(I) .NE. 0.0E0) CALL MESAGE (-30, 37, IDEL) 200 CONTINUE C C C COMPUTE THE ELEMENT COORDINATES C ZMIN = AMIN1(Z1, Z2, Z3) Z1 = Z1 - ZMIN Z2 = Z2 - ZMIN Z3 = Z3 - ZMIN C C C C FORM THE TRANSFORMATION MATRIX (6X6) FROM FIELD COORDINATES TO GRID C POINT DEGREES OF FREEDOM C DO 300 I = 1,36 GAMBQ(I) = 0.0E0 300 CONTINUE GAMBQ( 1) = 1.0E0 GAMBQ( 2) = R1 GAMBQ( 3) = Z1 GAMBQ(10) = 1.0E0 GAMBQ(11) = R1 GAMBQ(12) = Z1 GAMBQ(13) = 1.0E0 GAMBQ(14) = R2 GAMBQ(15) = Z2 GAMBQ(22) = 1.0E0 GAMBQ(23) = R2 GAMBQ(24) = Z2 GAMBQ(25) = 1.0E0 GAMBQ(26) = R3 GAMBQ(27) = Z3 GAMBQ(34) = 1.0E0 GAMBQ(35) = R3 GAMBQ(36) = Z3 C C C NO NEED TO COMPUTR DETERMINANT SINCE IT IS NOT USED SUBSEQUENTLY. ISING = -1 CALL INVERS (6, GAMBQ(1),6 , D(10), 0, D(11) , ISING , SP) C IF (ISING .EQ. 2) CALL MESAGE(-30,26,IDEL) C C C C CALCULATE THE INTEGRAL VALUES IN ARRAY DELINT WHERE THE ORDER IS C INDICATED BY THE FOLLOWING TABLE C C DELINT( 1) - (-1,0) C DELINT( 2) - (-1,1) C DELINT( 3) - (-1,2) C DELINT( 4) - ( 0,0) C DELINT( 5) - ( 0,1) C DELINT( 6) - ( 1,0) C DELINT( 7) - ( 0,2) C DELINT( 8) - ( 1,2) C C C TEST FOR RELATIVE SMALL AREA OF INTEGRATION C AND IF AREA IS SMALL THEN APPROXIMATE INTEGRALS C DR = AMAX1 ( ABS(R1-R2) , ABS(R2-R3) , ABS(R3-R1) ) RH = AMIN1 ( R1 , R2 , R3 ) / 10.0E0 DZ = AMAX1 ( ABS(Z1-Z2) , ABS(Z2-Z3) , ABS(Z3-Z1) ) ZH = AMIN1 ( Z1 , Z2 , Z3 ) / 10.0E0 RA = (R1 + R2 + R3) / 3.0E0 ZA = (Z1 + Z2 + Z3) / 3.0E0 AREA =(R1*(Z2-Z3) + R2*(Z3-Z1) + R3*(Z1-Z2)) / 2.0E0 KODE = 0 IF ( ABS( (R2-R1)/R2 ) .LT. 1.0E-5) KODE = 1 IF ( DR .LE. RH .OR. DZ .LE. ZH ) KODE = -1 C C 310 CONTINUE I1 = 0 DO 400 I = 1,3 IP = I - 2 DO 350 J = 1,3 IQ = J - 1 IF (IP.EQ.1 .AND. IQ.EQ.1) GO TO 350 I1 = I1 + 1 IF (KODE) 320,330,340 320 DELINT(I1) =((RA) ** IP)*((ZA) ** IQ) * AREA GO TO 350 330 DELINT(I1) = AI (1,3,1,2,1,3,IP,IQ,R,Z) 1 + AI (3,2,1,2,3,2,IP,IQ,R,Z) GO TO 350 340 CONTINUE DELINT(I1) = AI (1,3,3,2,1,3,IP,IQ,R,Z) 350 CONTINUE 400 CONTINUE D(1) = DELINT(6) DELINT(6) = DELINT(7) DELINT(7) = D(1) C C C TEST FOR EXCESSIVE ROUND-OFF ERROR IN INTEGRAL CALCULATIONS C AND IF IT EXIST APPROXIMATE INTEGRALS C IF (KODE .LT. 0) GO TO 500 DO 450 I = 1,8 IF (DELINT(I) .LT. 0.0E0) GO TO 475 450 CONTINUE IF (DELINT(8) .LE. DELINT(7)) GO TO 475 IF (DELINT(3) .GE. DELINT(8)) GO TO 475 IF (DELINT(3) .GT. DELINT(7)) GO TO 475 GO TO 500 475 CONTINUE KODE = -1 GO TO 310 500 CONTINUE C C C C LOCATE THE MATERIAL PROPERTIES IN THE MAT1 OR MAT3 TABLE C MATIDC = MATID MATFLG = 7 ELTEMP = TEMPE CALL MAT (IDEL) C C C SET MATERIAL PROPERTIES IN LOCAL VARIABLES C ER = E(1) ET = E(2) EZ = E(3) VRT = ANU(1) VTZ = ANU(2) VZR = ANU(3) GRZ = G(3) TZ = TZERO VTR = VRT * ET / ER VZT = VTZ * EZ / ET VRZ = VZR * ER / EZ DEL = 1.0E0 - VRT*VTR - VTZ*VZT - VZR*VRZ - VRT*VTZ*VZR 1 - VRZ*VTR*VZT C C C GENERATE ELASTIC CONSTANTS MATRIX (4X4) C EE(1) = ER * (1.0E0 - VTZ*VZT) / DEL EE(2) = ER * (VTR + VZR*VTZ) / DEL EE(3) = ER * (VZR + VTR*VZT) / DEL EE(4) = 0.0E0 EE(5) = EE(2) EE(6) = ET * (1.0E0 - VRZ*VZR) / DEL EE(7) = ET * (VZT + VRT*VZR) / DEL EE(8) = 0.0E0 EE(9) = EE(3) EE(10)= EE(7) EE(11)= EZ * (1.0E0 - VRT*VTR) / DEL EE(12)= 0.0E0 EE(13)= 0.0E0 EE(14)= 0.0E0 EE(15)= 0.0E0 EE(16)= GRZ C C C FORM TRANSFORMATION MATRIX (4X4) FROM MATERIAL AXIS TO ELEMENT C GEOMETRIC AXIS C DGAMR = DGAMA * DEGRA COSG = COS(DGAMR) SING = SIN(DGAMR) TEO( 1) = COSG ** 2 TEO( 2) = 0.0E0 TEO( 3) = SING ** 2 TEO( 4) = SING * COSG TEO( 5) = 0.0E0 TEO( 6) = 1.0E0 TEO( 7) = 0.0E0 TEO( 8) = 0.0E0 TEO( 9) = TEO(3) TEO(10) = 0.0E0 TEO(11) = TEO(1) TEO(12) = -TEO(4) TEO(13) = -2.0E0 * TEO(4) TEO(14) = 0.0E0 TEO(15) = -TEO(13) TEO(16) = TEO(1) - TEO(3) C C C TRANSFORM THE ELASTIC CONSTANTS MATRIX FROM MATERIAL C TO ELEMENT GEOMETRIC AXIS C CALL GMMATS (TEO , 4, 4, 1, EE , 4, 4, 0, D ) CALL GMMATS (D , 4, 4, 0, TEO, 4, 4, 0, EE) C C C C FORM THE ELEMENT STIFFNESS MATRIX IN FIELD COORDINATES C AK( 1) = EE(6) * DELINT(1) AK( 2) = (EE(2) + EE(6)) * DELINT(4) AK( 3) = EE(6) * DELINT(2) + EE(8) * DELINT(4) AK( 4) = 0.0E0 AK( 5) = EE(8) * DELINT(4) AK( 6) = EE(7) * DELINT(4) AK( 7) = AK(2) AK( 8) = (EE(1) + 2.0E0*EE(2) + EE(6)) * DELINT(6) AK( 9) = (EE(2) + EE(6)) * DELINT(5) + (EE(4) + EE(8)) *DELINT(6) AK(10) = 0.0E0 AK(11) = (EE(4) + EE(8)) * DELINT(6) AK(12) = (EE(3) + EE(7)) * DELINT(6) AK(13) = AK(3) AK(14) = AK(9) AK(15) = EE(6) * DELINT(3) + 2.0E0*EE(8) * DELINT(5) 1 + EE(16) * DELINT(6) AK(16) = 0.0E0 AK(17) = EE(8) * DELINT(5) + EE(16) * DELINT(6) AK(18) = EE(7) * DELINT(5) + EE(12) * DELINT(6) AK(19) = 0.0E0 AK(20) = 0.0E0 AK(21) = 0.0E0 AK(22) = 0.0E0 AK(23) = 0.0E0 AK(24) = 0.0E0 AK(25) = AK(5) AK(26) = AK(11) AK(27) = AK(17) AK(28) = 0.0E0 AK(29) = EE(16) * DELINT(6) AK(30) = EE(12) * DELINT(6) AK(31) = AK(6) AK(32) = AK(12) AK(33) = AK(18) AK(34) = 0.0E0 AK(35) = AK(30) AK(36) = EE(11) * DELINT(6) C DO 600 I = 1,36 AK(I) = TWOPI * AK(I) 600 CONTINUE C C TRANSFORM THE ELEMENT STIFFNESS MATRIX FROM FIELD COORDINATES C TO GRID POINT DEGREES OF FREEDOM C CALL GMMATS (GAMBQ , 6, 6, 1, AK , 6, 6, 0, D ) CALL GMMATS (D , 6, 6, 0, GAMBQ , 6, 6, 0, AK) C C C C GENERATE THE TRANSFORMATION MATRIX FROM TWO TO THREE DEGREES OF C FREEDOM PER POINT C DO 700 I = 1,54 GAMQS( I) = 0.0E0 700 CONTINUE GAMQS( 1) = 1.0E0 GAMQS(12) = 1.0E0 GAMQS(22) = 1.0E0 GAMQS(33) = 1.0E0 GAMQS(43) = 1.0E0 GAMQS(54) = 1.0E0 C C C TRANSFORM THE STIFFNESS MATRIX FROM TWO TO THREE DEGREES OF C FREEDOM PER POINT C CALL GMMATS (GAMQS(1) , 6, 9, 1, AK(1) , 6, 6, 0, D(1) ) CALL GMMATS (D(1) , 9, 6, 0, GAMQS(1) , 6, 9, 0, AK(1) ) C C C LOCATE THE TRANSFORMATION MATRICES FOR THE THREE GRID POINTS C DO 750 I = 1,81 GAMBL(I) = 0.0E0 750 CONTINUE DO 800 I = 1,3 CALL TRANSS (ICS(I) , D(1)) K = 30* (I-1) + 1 DO 800 J = 1,3 KK = K + 9 * (J-1) JJ = 3 * (J-1) + 1 GAMBL(KK ) = D(JJ ) GAMBL(KK+1) = D(JJ+1) GAMBL(KK+2) = D(JJ+2) 800 CONTINUE C C C TRANSFORM THE STIFFNESS MATRIX FROM BASIC TO LOCAL COORDINATES C CALL GMMATS (GAMBL(1) , 9, 9, 1, AK(1) , 9, 9, 0, D(1) ) CALL GMMATS (D(1) , 9, 9, 0, GAMBL(1) , 9, 9, 0, AK(1) ) C C C FORM THE D SUB 0 MATRIX C DO 850 I = 1,24 DZERO(I) = 0.0E0 850 CONTINUE DZERO( 2) = 1.0E0 DZERO( 7) = 1.0E0 / RA DZERO( 8) = 1.0E0 DZERO( 9) = ZA / RA DZERO(18) = 1.0E0 DZERO(21) = 1.0E0 DZERO(23) = 1.0E0 C C C COMPUTE THE STRESS MATRIX IN FIELD COORDINATES C CALL GMMATS (EE(1) , 4, 4, 0, DZERO(1) , 4, 6, 0, D(1) ) C C C TRANSFORM THE STRESS MATRIX TO GRID POINT DEGREES OF FREEDOM C CALL GMMATS (D(1) , 4, 6, 0, GAMBQ(1) , 6, 6, 0, SEL(1) ) C C C TRANSFORM THE STRESS MATRIX FROM TWO TO THREE DEGREES OF FREEDOM C PER POINT C CALL GMMATS (SEL(1) , 4, 6, 0, GAMQS(1) , 6, 9, 0, D(1) ) C C C TRANSFORM THE STRESS MATRIX FROM BASIC TO LOCAL COORDINATES C CALL GMMATS (D(1) , 4, 9, 0, GAMBL(1) , 9, 9, 0, SEL(1) ) C C C COMPUTE THE THERMAL STRAIN VECTOR C DO 900 I = 1,3 ALFB(I) = ALF(I) 900 CONTINUE ALFB(4) = 0.0E0 C C C COMPUTE THE THERMAL STRESS VECTOR C CALL GMMATS (EE(1) , 4, 4, 0, ALFB(1) , 4, 1, 0, TS(1) ) C C RETURN END
REAL FUNCTION PSLAMCH10( ICTXT, CMACH ) * include "mpif.h" * -- ScaLAPACK auxiliary routine (version 1.0) -- * University of Tennessee, Knoxville, Oak Ridge National Laboratory, * and University of California, Berkeley. * February 28, 1995 * * .. Scalar Arguments .. CHARACTER CMACH INTEGER ICTXT * .. * * Purpose * ======= * * PSLAMCH determines single precision machine parameters. * * Arguments * ========= * * ICTXT (global input) INTEGER * The BLACS context handle in which the computation takes * place. * * CMACH (global input) CHARACTER*1 * Specifies the value to be returned by PSLAMCH: * = 'E' or 'e', PSLAMCH := eps * = 'S' or 's , PSLAMCH := sfmin * = 'B' or 'b', PSLAMCH := base * = 'P' or 'p', PSLAMCH := eps*base * = 'N' or 'n', PSLAMCH := t * = 'R' or 'r', PSLAMCH := rnd * = 'M' or 'm', PSLAMCH := emin * = 'U' or 'u', PSLAMCH := rmin * = 'L' or 'l', PSLAMCH := emax * = 'O' or 'o', PSLAMCH := rmax * * where * * eps = relative machine precision * sfmin = safe minimum, such that 1/sfmin does not overflow * base = base of the machine * prec = eps*base * t = number of (base) digits in the mantissa * rnd = 1.0 when rounding occurs in addition, 0.0 otherwise * emin = minimum exponent before (gradual) underflow * rmin = underflow threshold - base**(emin-1) * emax = largest exponent before overflow * rmax = overflow threshold - (base**emax)*(1-eps) * * ===================================================================== * * .. Local Scalars .. INTEGER IDUMM REAL TEMP, TEMP1, buf2(1) * .. * .. External Subroutines .. * EXTERNAL SGAMN2D, SGAMX2D * .. * .. External Functions .. LOGICAL LSAME REAL SLAMCH EXTERNAL LSAME, SLAMCH * .. * .. Executable Statements .. * TEMP1 = SLAMCH( CMACH ) * IF( LSAME( CMACH, 'E' ).OR.LSAME( CMACH, 'S' ).OR. $ LSAME( CMACH, 'M' ).OR.LSAME( CMACH, 'U' ) ) THEN CALL MPI_ALLREDUCE( [TEMP1], buf2, 1, MPI_REAL, $ MPI_MAX, ICTXT, IDUMM ) TEMP = buf2(1) * CALL SGAMX2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM, * $ IDUMM, 1, -1, IDUMM ) ELSE IF( LSAME( CMACH, 'L' ).OR.LSAME( CMACH, 'O' ) ) THEN CALL MPI_ALLREDUCE( [TEMP1], buf2, 1, MPI_REAL, $ MPI_MIN, ICTXT, IDUMM ) TEMP = buf2(1) * CALL SGAMN2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM, * $ IDUMM, 1, -1, IDUMM ) ELSE TEMP = TEMP1 END IF * PSLAMCH10 = TEMP * * End of PSLAMCH10 * END
SUBROUTINE OFPPUN (IBUF,BUF,NWDS,IOPT,IDD,PNCHED) C C MAIN OFP PUNCH ROUTINE FOR PUNCHING OF DATA LINES ONLY C C $MIXED_FORMATS C LOGICAL TEMPER,PNCHED INTEGER IBUF(NWDS),VECTOR,ID(50),OF(56) REAL BUF(NWDS),RID(50) COMMON /SYSTEM/ SYSBUF,L,DUM53(53),ITHERM,DUM34(34),LPCH COMMON /OUTPUT/ HD(96) C COMMON /ZZOFPX/ L1,L2,L3,L4,L5,ID(50) COMMON /ZZZZZZ/ CORE(1) COMMON /BLANK / ICARD COMMON /OFPCOM/ TEMPER, M COMMON /GPTA1 / NELM,LAST,INCR,IE(25,1) EQUIVALENCE (RID(1),ID(1),OF(6)), (L1,OF(1),CORE(1)), 1 (L2,OF(2)), (L3,OF(3)), (L4,OF(4)), (L5,OF(5)) DATA VECTOR, IDTEMP / 1, 0 / C C IF (.NOT. PNCHED) GO TO 700 20 IF (NWDS .LT. 0) GO TO 1710 C C FIRST CARD OUT C ICARD = ICARD + 1 IF (IOPT .EQ. VECTOR) GO TO 200 C C GENERAL 1-ST CARD (FIRST WORD OF BUF ASSUMED INTEGER) C N = MIN0(4,NWDS) IF (IDD) 30,90,40 30 IF (IDD .EQ. -1) GO TO 90 40 GO TO (50,60,70,80), N 50 WRITE (LPCH,440,ERR=180) BUF(1),ICARD GO TO 180 60 WRITE (LPCH,450,ERR=180) BUF(1),BUF(2),ICARD GO TO 180 70 WRITE (LPCH,460,ERR=180) BUF(1),BUF(2),BUF(3),ICARD GO TO 180 80 WRITE (LPCH,470,ERR=180) BUF(1),BUF(2),BUF(3),BUF(4),ICARD GO TO 180 90 GO TO (100,110,120,130), N 100 WRITE (LPCH,400) IBUF(1),ICARD GO TO 180 110 WRITE (LPCH,410,ERR=180) IBUF(1),BUF(2),ICARD GO TO 180 120 WRITE (LPCH,420,ERR=180) IBUF(1),BUF(2),BUF(3),ICARD GO TO 180 C C CHECK FOR THERMAL FORCES FOR ISOPARAMETRICS C 130 IF (ITHERM.EQ.0 .OR. M.NE.4) GO TO 150 IF (ID(3).LT.65 .OR. ID(3).GT.67) GO TO 150 WRITE (LPCH,140) IBUF(1),BUF(2),IBUF(3),BUF(4),ICARD 140 FORMAT (I10,8X,A4,14X,I10,8X,1P,E18.6,I8) GO TO 180 C C CHECK FOR INTEGER IN SECOND ARGUMENT ALSO. C 150 IF (M .EQ. 19) GO TO 170 IF (NUMTYP(BUF(2)) .LE. 1) GO TO 160 WRITE (LPCH,430,ERR=180) IBUF(1),BUF(2),BUF(3),BUF(4),ICARD GO TO 180 160 WRITE (LPCH,500,ERR=180) IBUF(1),IBUF(2),BUF(3),BUF(4),ICARD GO TO 180 170 WRITE (LPCH,510) IBUF(1),IBUF(2),BUF(3),BUF(4),ICARD GO TO 180 180 NWORD = 4 GO TO 230 C C VECTOR 1-ST CARD (FIRST WORD INTEGER, SECOND WORD BCD) C 200 IF (TEMPER) GO TO 280 IF (IDD.NE.0 .AND. IDD.NE.-1) GO TO 210 WRITE (LPCH,520,ERR=220) IBUF(1),BUF(2),BUF(3),BUF(4),BUF(5),ICARD GO TO 220 210 WRITE (LPCH,530,ERR=220) BUF(1),BUF(2),BUF(3),BUF(4),BUF(5),ICARD 220 NWORD = 5 C C CONTINUATION CARDS IF ANY. C 230 IF (NWORD .GE. NWDS) GO TO 1710 ICARD = ICARD + 1 NWORD = NWORD + 3 IF (NWORD .LE. NWDS) GO TO 250 NWORD = NWORD - 1 IF (NWORD .EQ. NWDS) GO TO 240 NWORD = NWORD - 1 C C 1 WORD OUT C WRITE (LPCH,610,ERR=1710) BUF(NWORD),ICARD GO TO 1710 C C 2 WORDS OUT C 240 WRITE (LPCH,600,ERR=1710) BUF(NWORD-1),BUF(NWORD),ICARD GO TO 1710 C C 3 WORDS OUT C 250 IF (IBUF(NWORD-1) .EQ. VECTOR) GO TO 260 IF (IBUF(NWORD ) .EQ. VECTOR) GO TO 270 WRITE (LPCH,590,ERR=230) BUF(NWORD-2),BUF(NWORD-1),BUF(NWORD), 1 ICARD GO TO 230 260 WRITE (LPCH,620) BUF(NWORD-2),BUF(NWORD),ICARD GO TO 230 270 WRITE (LPCH,600) BUF(NWORD-2),BUF(NWORD-1),ICARD GO TO 230 C C SPECIAL PUNCH ONLY WHEN TEMPER FLAG IS ON IN A -HEAT- FORMULATION. C 280 IC1 = IBUF(1) IF (IDD.EQ.0 .OR. IDD.EQ.-1) GO TO 290 IDTEMP = IDTEMP + 1 IC1 = IDD 290 CONTINUE WRITE (LPCH,300) IDTEMP,IC1,BUF(3),ICARD 300 FORMAT (8HTEMP* ,I16,I16,1P,E16.6,16X,I8) GO TO 1710 C 400 FORMAT (I10,62X,I8) 410 FORMAT (I10,8X,1P,E18.6,36X,I8) 420 FORMAT (I10,8X,2(1P,E18.6),18X,I8) 430 FORMAT (I10,8X,3(1P,E18.6),I8) 440 FORMAT (1P,E18.6,54X,I8) 450 FORMAT (2(1P,E18.6),36X,I8) 460 FORMAT (3(1P,E18.6),18X,I8) 470 FORMAT (4(1P,E18.6),I8) 500 FORMAT (I10,8X,I10,8X,2(1P,E18.6),I8) 510 FORMAT (I10,8X,I10,8X,2A4,28X,I8) 520 FORMAT (I10,7X,A1,3(1P,E18.6),I8) 530 FORMAT (1P,E16.6,1X,A1,3(1P,E18.6),I8) 590 FORMAT (6H-CONT-,12X,3(1P,E18.6),I8) 600 FORMAT (6H-CONT-,12X,2(1P,E18.6),18X,I8) 610 FORMAT (6H-CONT-,12X,1P,E18.6,36X,I8) 620 FORMAT (6H-CONT-,12X,1P,E18.6,18X,1P,E18.6,I8) C C C PUNCH HEADING CARDS C C C TITLE,SUBTITLE,AND LABEL C 700 DO 740 I = 1,3 ICARD = ICARD + 1 GO TO (710,720,730), I 710 WRITE (LPCH,750) (HD(J),J= 1,15),ICARD GO TO 740 720 WRITE (LPCH,760) (HD(J),J=33,47),ICARD GO TO 740 730 WRITE (LPCH,770) (HD(J),J=65,79),ICARD 740 CONTINUE C 750 FORMAT (10H$TITLE =,15A4,2X,I8) 760 FORMAT (10H$SUBTITLE=,15A4,2X,I8) 770 FORMAT (10H$LABEL =,15A4,2X,I8) C KTYPE = ID(2)/1000 M = ID(2) - (KTYPE)*1000 IF (M.LT.1 .OR. M.GT.19) GO TO 1200 ICARD = ICARD + 1 GO TO (780,790,800 ,810,900,1170,910,1170,1170,920, 1 930,940,1170,950,960,970 ,980,990 ,1000), M 780 WRITE (LPCH,1010) ICARD GO TO 1200 790 WRITE (LPCH,1020) ICARD GO TO 1200 800 WRITE (LPCH,1030) ICARD GO TO 1200 810 WRITE (LPCH,1040) ICARD GO TO 1200 C C PUNCH ELEMENT STRESS OR GRID POINT STRESS HEADING LINE C 900 IF (L2 .NE. 378) WRITE(LPCH,1050) ICARD IF (L2 .EQ. 378) WRITE(LPCH,1060) ICARD GO TO 1200 910 WRITE (LPCH,1070) ICARD GO TO 1200 920 WRITE (LPCH,1080) ICARD GO TO 1200 930 WRITE (LPCH,1090) ICARD GO TO 1200 940 WRITE (LPCH,1100) ICARD GO TO 1200 950 WRITE (LPCH,1110) ICARD GO TO 1200 960 WRITE (LPCH,1120) ICARD GO TO 1200 970 WRITE (LPCH,1130) ICARD GO TO 1200 980 WRITE (LPCH,1140) ICARD GO TO 1200 990 WRITE (LPCH,1150) ICARD GO TO 1200 1000 WRITE (LPCH,1160) ICARD GO TO 1200 C 1010 FORMAT (14H$DISPLACEMENTS,58X,I8) 1020 FORMAT (7H$OLOADS,65X,I8) 1030 FORMAT (5H$SPCF,67X,I8) 1040 FORMAT (15H$ELEMENT FORCES,57X,I8) 1050 FORMAT (17H$ELEMENT STRESSES,55X,I8) 1060 FORMAT (24H$STRESSES AT GRID POINTS,48X,I8) 1070 FORMAT (12H$EIGENVECTOR,60X,I8) 1080 FORMAT (9H$VELOCITY,63X,I8) 1090 FORMAT (13H$ACCELERATION,59X,I8) 1100 FORMAT (18H$NON-LINEAR-FORCES,54X,I8) 1110 FORMAT (27H$EIGENVECTOR (SOLUTION SET),45X,I8) 1120 FORMAT (29H$DISPLACEMENTS (SOLUTION SET),43X,I8) 1130 FORMAT (24H$VELOCITY (SOLUTION SET),48X,I8) 1140 FORMAT (28H$ACCELERATION (SOLUTION SET),43X,I8) 1150 FORMAT (23HELEMENT STRAIN ENERGIES ,49X,I8) 1160 FORMAT (24HGRID POINT FORCE BALANCE ,48X,I8) 1170 ICARD = ICARD - 1 C C REAL, REAL/IMAGINARY, MAGNITUDE/PHASE C 1200 ICARD = ICARD + 1 IF (KTYPE.LT.1 .OR. KTYPE.EQ.2) GO TO 1210 IF (ID(9).EQ. 3) GO TO 1230 GO TO 1220 1210 WRITE (LPCH,1240) ICARD GO TO 1300 1220 WRITE (LPCH,1250) ICARD GO TO 1300 C 1230 WRITE (LPCH,1260) ICARD 1240 FORMAT (12H$REAL OUTPUT,60X,I8) 1250 FORMAT (22H$REAL-IMAGINARY OUTPUT, 50X,I8) 1260 FORMAT (23H$MAGNITUDE-PHASE OUTPUT,49X,I8) C C SUBCASE NUMBER FOR SORT1 OUTPUT, OR C SUBCASE NUMBER FOR SORT2, FREQUENCY AND TRANSIENT RESPONSE ONLY C 1300 IF (KTYPE .LE. 1) GO TO 1310 IAPP = ID(1)/10 IF (IAPP.NE.5 .AND. IAPP.NE.6) GO TO 1400 1310 ICARD = ICARD + 1 WRITE (LPCH,1320) ID(4),ICARD 1320 FORMAT (13H$SUBCASE ID =,I12,47X,I8) C C IF ELEMENT STRESS OR FORCE PUNCH ELEMENT TYPE NUMBER C 1400 IF (M.NE.4 .AND. M.NE.5) GO TO 1500 ICARD = ICARD + 1 ID3 = ID(3) IF (L2 .NE. 378) WRITE (LPCH,1410) ID3,IE(1,ID3),IE(2,ID3),ICARD IF (L2 .EQ. 378) WRITE (LPCH,1420) ICARD 1410 FORMAT (15H$ELEMENT TYPE =,I12,3X,1H(,2A4,1H),32X,I8) 1420 FORMAT (38H$PUNCHED IN MATERIAL COORDINATE SYSTEM,34X,I8) C C PUNCH EIGENVALUE, FREQUENCY, POINT OR ELEMENT ID, OR TIME C 1500 IAPP = ID(1)/10 IF (IAPP.LT.1 .OR. IAPP.GT.10) GO TO 1700 GO TO (1590,1510,1590,1590,1550,1570,1590,1510,1510,1590), IAPP C C PUNCH EIGENVALUE C 1510 ICARD = ICARD + 1 IF (KTYPE .EQ. 1) GO TO 1530 WRITE (LPCH,1520,ERR=1700) RID(6),ID(5),ICARD 1520 FORMAT (13H$EIGENVALUE =,E15.7,2X,6HMODE =,I6,30X,I8) GO TO 1700 1530 WRITE (LPCH,1540,ERR=1700) RID(6),RID(7),ID(5),ICARD 1540 FORMAT (15H$EIGENVALUE = (,E15.7,1H,,E15.7,8H) MODE =,I6,12X,I8) GO TO 1700 C C FREQUENCY OR TIME, POINT OR ELEMENT ID C 1550 IF (KTYPE .GT. 1) GO TO 1590 ICARD = ICARD + 1 WRITE (LPCH,1560,ERR=1700) RID(5),ICARD 1560 FORMAT (12H$FREQUENCY =,E16.7,44X,I8) GO TO 1700 1570 IF (KTYPE .GT. 1) GO TO 1590 ICARD = ICARD + 1 WRITE (LPCH,1580,ERR=1700) RID(5),ICARD 1580 FORMAT (7H$TIME =,E16.7,49X,I8) GO TO 1700 1590 IF (KTYPE .LE. 1) GO TO 1700 ICARD = ICARD + 1 IF (M.EQ.4 .OR. M.EQ.5) GO TO 1610 WRITE (LPCH,1600) ID(5),ICARD 1600 FORMAT (11H$POINT ID =,I12,49X,I8) GO TO 1700 1610 WRITE (LPCH,1620) ID(5),ICARD 1620 FORMAT (13H$ELEMENT ID =,I10,49X,I8) C C CARD HEADING COMPLETE C 1700 PNCHED = .TRUE. IF (.NOT.TEMPER) GO TO 20 IDTEMP = IDTEMP + 1 IF (IDD .GT. 0) IDTEMP = 0 GO TO 20 C 1710 RETURN END
program TTBXD implicit none ! Couples source term of Ahn 1998 model to multi-region analysis with longitudinal dispersion ! Alex Salazar ! University of California Berkeley ! Department of Nuclear Engineering ! Nuclear Waste Management Laboratory ! ! Based on earlier code developed for bateman equations (Nov 22, 2016) !VERSION HISTORY !0.0 !******************************VARIABLES******************************** integer :: i,j,k,l,q,idx !loop iteration !INTEGERS FOR DECAY CHAIN integer ne !number of elements integer nc !number of decay chains integer mxi !maximum number of isotopes-per-element integer mxd !maximum number of decay chains detected integer mxp !maximum number of isotopes in DC detected !TIME double precision :: t1,t2 !time start/end double precision, allocatable :: bins(:) !time bins integer nbins !number of time bins !DECAY CHAINS character(len=2) els character(len=2),allocatable::ele(:) !element names integer,allocatable::nie(:) !number of isotopes per element character(len=2),allocatable::pos(:,:) !raw position indicator integer,allocatable::dind(:,:) !decay chain indicator integer,allocatable::pind(:,:) !position indicator character(len=2),allocatable::eld(:,:) !element names in decay chain character(len=7),allocatable::isd(:,:) !isotope descriptor ZZ-AAAM integer,allocatable::n(:) !number of isotopes in the decay chain character(len=4),allocatable::AAA(:,:) !mass numbers double precision,allocatable::mi(:,:) !initial masses double precision,allocatable::t(:,:) !half-lives double precision,allocatable::lambda(:,:) !decay constants !TRANSPORT PARAMETERS double precision,allocatable::sol(:) !solubilities double precision,allocatable::kdb(:) !buffer Kd double precision,allocatable::kdr(:) !rock kd double precision,allocatable::deb(:) !effective diffusion in buffer double precision,allocatable::dfw(:) !diffusion in free water !FILE I/O character(len=134) :: line !line of text from input file integer :: lstr,lend !for string component extraction character(len=30) :: date !date of calculation !BATEMAN EQUATIONS double precision :: F1 !function double precision,allocatable::results(:,:,:) !calculated masses !*****************************PARAMETERS******************************** !CONSTANTS double precision, parameter :: pi=3.14159265358979324 !SPECIAL CHARACTERS character(len=1), parameter :: tab=char(9) !tab character(len=1), parameter :: rt=char(13) !carriage return character(len=1), parameter :: nl=char(10) !new line !READING integer, parameter :: lskip=4 !number of lines to skip up to element data in input !FILES integer, parameter :: input=1 !INPUT FILE integer, parameter :: output=2 !OUTPUTFILE !*****************************INITIALIZE******************************** !********************************MAIN*********************************** !Read input file open(input,action="read",file="input.txt") open(output,status="replace",action="write",file="output.txt") call ctime(time8(),date) write(output,1)nl,trim(date) 1 format('Results for Decay Chain',A,'Date: ',A) read(input,'(es10.3)',ADVANCE="YES")t1 read(input,'(es10.3)',ADVANCE="YES")t2 read(input,'(I5.1)',ADVANCE="YES")nbins read(input,'(I2.1)',ADVANCE="YES")ne write(output,2)tab,ne 2 format('Number of elements:',A1,I2.1) allocate(ele(ne)) !elements allocate(nie(ne)) !number of isotopes per element allocate(sol(ne)) !solubilities allocate(kdb(ne)) !buffer Kd allocate(kdr(ne)) !rock kd allocate(deb(ne)) !effective diffusion in buffer allocate(dfw(ne)) !diffusion in free water allocate(pos(ne,30)) !position inidicators (buffered) pos="00" !Read the element lines do i=1,ne read(input,'(A134)',ADVANCE='YES')line read(line(1:2),'(A2)')ele(i) read(line(59:60),'(I2)')nie(i) lstr=62 lend=63 do j=1,nie(i),1 read(line(lstr:lend),'(A2)')pos(i,j) lstr=lstr+3 lend=lend+3 end do end do mxi=maxval(nie) !maximum number of isotopes-per-element considered allocate(dind(ne,mxi)) allocate(pind(ne,mxi)) close(input) !Collect elemental transport parameters open(input,action="read",file="input.txt") !skip lines to element data do i=1,4 read(input,*) end do do i=1,ne read(input,3)sol(i),kdb(i),kdr(i),deb(i),dfw(i) 3 format(3X,es10.3,1X,es10.3,1X,es10.3,1X,es10.3,1X,es10.3) end do !For each element, find the decay chain position indicators mxd=0 mxp=0 do i=1,ne do j=1,nie(i) read(pos(i,j)(1:1),'(I1)')dind(i,j) read(pos(i,j)(2:2),'(I1)')pind(i,j) !Guess the apprarent number of decay chains involved and their sizes if(dind(i,j).gt.mxd)then mxd=dind(i,j)!apparent number of decay chains end if if(pind(i,j).gt.mxp)then mxp=pind(i,j)!apparent maximum number of decay chain members end if end do end do !Read the decay chains, check for errors in specs read(input,'(I2.1)',ADVANCE="YES")nc if(nc.ne.mxd)then print*,'Error in decay chain number specifications!' goto 99999 end if allocate(n(nc)) !decay chain array allocate(AAA(nc,mxp)) !isotope mass number array allocate(mi(nc,mxp)) !initial mass array allocate(t(nc,mxp)) !half-lives array allocate(lambda(nc,mxp))!decay constant array !zero-padding AAA="0000" mi=0 t=0 lambda=0 write(output,5)tab,nc 5 format('Number of decay chains:',A1,I2.1) do i=1,nc !loop for every decay chain read(input,'(I2.1)',ADVANCE="YES")n(i) do j=1,n(i) !grab isotope data in the chain !MASS NUMBER, t(1/2), Initial Amount read(input,'(A4,2(2X,1es10.3))',ADVANCE="YES")AAA(i,j), & t(i,j),mi(i,j) end do end do if(sum(nie).ne.sum(n))then print*,'Error: An isotope was not specified!' goto 99999 end if write(output,8)nl,nl 8 format(A1,'*****************************ELEMENTS****************** &************',A1, &'El Cs Kdb Kdr Deb Dfw') do i=1,ne write(output,9)ele(i),sol(i),kdb(i),kdr(i),deb(i),dfw(i) 9 format(A2,5(1X,es10.3)) end do write(output,10)nl 10 format(A1,'******************************CHAINS******************* &************') allocate(eld(nc,mxp)) !helps in specifying decay chain elements allocate(isd(nc,mxp)) !isotope identifier do i=1,ne !number of elements do j=1,nie(i) !maximum number of isotopes-per-element eld(dind(i,j),pind(i,j))=ele(i) end do end do do i=1,nc do j=1,n(i) isd(i,j)=trim(eld(i,j))//'-'//trim(AAA(i,j)) if(j.lt.n(i))then write(output,16,ADVANCE="NO")isd(i,j) 16 format(A7,'--->') else write(output,16,ADVANCE="YES")isd(i,j) end if end do end do write(output,20)nl 20 format(A1,'****************************HALF-LIVES***************** &************') do i=1,nc do j=1,n(i) if(j.lt.n(i))then write(output,26,ADVANCE="NO")t(i,j) 26 format(es11.3) else write(output,26,ADVANCE="YES")t(i,j) end if !create decay constant from half life lambda(i,j)=log(2.0d0)/t(i,j) end do end do write(output,27)nl 27 format(A1,'*************************DECAY CONSTANTS*************** &************') do i=1,nc do j=1,n(i) if(j.lt.n(i))then write(output,28,ADVANCE="NO")lambda(i,j) 28 format(es11.3) else write(output,26,ADVANCE="YES")lambda(i,j) end if end do end do write(output,30)nl 30 format(A1,'************************INITIAL INVENTORY************** &************') do i=1,nc do j=1,n(i) if(j.lt.n(i))then write(output,36,ADVANCE="NO")mi(i,j) 36 format(es11.3) else write(output,36,ADVANCE="YES")mi(i,j) end if end do end do write(output,40)nl 40 format(A1,'**************************IN-SITU DECAY**************** &************') allocate(bins(nbins)) call logbinner(t1,t2,nbins,bins) allocate(results(nc,mxp,nbins)) do i=1,nc write(output,50)i write(*,50)i 50 format('Decay Chain #',I2,A1) write(output,52,ADVANCE="NO")'Time ',tab do j=1,n(i) if(j.lt.n(i))then write(output,52,ADVANCE="NO")isd(i,j),tab write(*,52,ADVANCE="NO")isd(i,j),tab 52 format(A7,A1) else write(output,52,ADVANCE="YES")isd(i,j) write(*,52,ADVANCE="YES")isd(i,j) end if end do do j=1,nbins write(output,60,ADVANCE="NO")bins(j),tab 60 format(es10.3,A1) do k=1,n(i) results(i,j,k)=F1(i,k,bins(j),lambda,mi,nc,n(i)) if(k.lt.n(i))then write(output,60,ADVANCE="NO")results(i,j,k),tab else write(output,60,ADVANCE="YES")results(i,j,k),tab end if end do end do write(output,*) end do 99999 continue END PROGRAM !*****************************SUBROUTINES******************************* !-----Create intervals on the log10-scale SUBROUTINE LOGBINNER(t1,t2,nbins,bins) IMPLICIT NONE double precision, intent(in) :: t1 double precision, intent(in) :: t2 integer, intent(in) :: nbins double precision, intent(inout):: bins(nbins) integer :: i double precision:: int1 double precision:: dist dist=abs(log10(t2)-log10(t1)) int1=t1 !initiate left interval, helps avoid double counting do i=1,nbins,1 bins(i)=int1 int1=10**(log10(t1)+((dist/(nbins-1))*(i))) end do END SUBROUTINE !******************************FUNCTIONS******************************** !-----BATEMAN EQUATIONS FUNCTION F1(idx,k,t,lambda,mi,nc,n) implicit none !idx shall be decay chain index !k shall be position index within decay chain integer :: j,k,l,q,idx,ldummy double precision,intent(in) :: t double precision :: sum1,sum2,res1,res2,ml,p1,p2,F1 integer,intent(in) :: nc integer,intent(in) :: n double precision,dimension(nc,n),intent(in) :: lambda double precision,dimension(nc,n),intent(in) :: mi if(k.gt.1)then !FIRST SUMMATION sum1=0.0d+0 do l=1,k-1 !FIRST PRODUCT OPERATOR p1=1.0d+0 do j=l,k-1 p1=lambda(idx,j)*p1 end do !SECOND SUMMATION sum2=0.0d+0 do j=l,k !DENOMINATOR, SECOND PRODUCT OPERATOR p2=1.0d+0 do q=l,k if(q.ne.j)then p2=(lambda(idx,q)-lambda(idx,j))*p2 ! else ! cycle end if end do !NUMERATOR res2= exp(-1*lambda(idx,j)*t)*(1.0/p2) sum2=sum2+res2 end do res1=mi(idx,l)*p1*sum2 sum1=sum1+res1 end do else sum1=0.0d+0 end if F1=(mi(idx,k)*exp(-1*lambda(idx,k)*t))+sum1 END FUNCTION
subroutine disp_ono(yplot) use size_mod implicit none integer nmax, npoints, nline, i, nsum, n, kmax, kn, jmid integer pgopen, pgbeg, ier, nlevmax, iflag, numb integer nxmx, nymx, nnodex, nnodey, j, jplot parameter (nxmx = nmodesmax) parameter (nymx = mmodesmax) parameter (nmax = nmodesmax) parameter (nlevmax = 101) real xgrid(nmax), ygrid(nmax), f(nmax), dx, xmin, xmax, capf(nmax) real capr(nmax), ff(101), rhoplasm, dy, yplot, ybottom, yprime complex xkperp2_slow(nxmx, nymx), xkperp2_fast(nxmx, nymx) complex xkperp_slow(nxmx, nymx), xkperp_fast(nxmx, nymx) complex P(nxmx, nymx) real xkprl(nxmx, nymx) complex xkperp2_slow_plot(nxmx), xkperp2_fast_plot(nxmx) complex xkperp_slow_plot(nxmx), xkperp_fast_plot(nxmx) real rho(nxmx, nymx) real f3(nmax) real y(nmax), k, capk, c, xdeg, yh, L, kr, nr real factrl, xn, an, diff1, diff2 real ans_simpson, ans_trapezoidal, ans_analytic, ymax, ymin real dummy, time, t1, t2, second1, pi, x, a, e, dydx, sum character*32 title character*32 titlx character*32 tityl character*32 tityr character*32 titx character*32 tity character*32 titz integer nblack, nred, nyellow, ngreen, nblue, ncyan, nmagenta, . nwhite, norange common/boundcom/rhoplasm open(unit=130, file='Ono_disp', status='unknown', . form='formatted') nwhite = 0 nblack = 1 nred = 2 ngreen = 3 nblue = 4 ncyan = 5 nmagenta = 6 nyellow = 7 norange = 8 numb = 100 pi = 3.14159 e = 2.71828 a = 3.0 k = .0015 capk = 6000. f3 = 0. read(130, 309) nnodex, nnodey, jmid read(130, 310) rhoplasm read(130, 310) (capr(i), i = 1, nnodex) read(130, 310) (y(j), j = 1, nnodey) read(130, 310) ((xkperp2_slow(i, j), i = 1, nnodex), . j = 1, nnodey) read(130, 310) ((xkperp2_fast(i, j), i = 1, nnodex), . j = 1, nnodey) read(130, 310) ((rho(i, j), i = 1, nnodex), j = 1, nnodey) read(130, 310) ((xkprl(i,j), i = 1, nnodex), j = 1, nnodey) read(130, 310) ((P(i, j), i = 1, nnodex), j = 1, nnodey) xgrid = capr ygrid = y npoints = nnodex xmin = xgrid(1) xmax = xgrid(nnodex) jplot = jmid dy = y(2) - y(1) ybottom = y(1) c yplot = 0.05 yprime = yplot - ybottom jplot = yprime / dy + 1 write(6, *) "jplot = ", jplot write(6, *) "yplot = ", yplot ! ------------------------------- ! Open the pgplot graphics device ! ------------------------------- IER = PGBEG(0, 'disper.ps/vcps', 1, 1) IF (IER.NE.1) STOP call PGSCH (1.5) ! ------------------------------------------- ! Plot contours of k**2 - slow root ! ------------------------------------------- titx = 'R (m)' tity = 'Z (m)' title = 'Re(k**2) - slow root' call ezconc(capr, y, real(xkperp2_slow), ff, nnodex, nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) title = 'k_parallel' call ezconc(capr, y, xkprl, ff, nnodex, nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) title = 'Re(P)' call ezconc(capr, y, real(P), ff, nnodex, nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) title = 'Im(P)' call ezconc(capr, y, aimag(P), ff, nnodex, nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) title = 'Im(k**2) - slow root' call ezconc(capr, y, aimag(xkperp2_slow), ff, nnodex, nnodey,numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) ! ------------------------ ! Plot cut in y at yplot ! ------------------------ do i = 1, nnodex xkperp2_slow_plot(i) = xkperp2_slow(i, jplot) xkperp2_fast_plot(i) = xkperp2_fast(i, jplot) end do xkperp_slow_plot = csqrt(xkperp2_slow_plot) xkperp_fast_plot = csqrt(xkperp2_fast_plot) titlx = 'R (m)' tityl = 'kperp2 (m-2)' tityr = ' ' title = 'fast and slow roots' call ezplot2_s(title, titlx, tityl, tityr, xgrid, . real(xkperp2_slow_plot), real(xkperp2_fast_plot), f3, . npoints, nmax, ymax, ymin, xmin, xmax) tityl = 'kperp (m-1)' call ezplot2_b(title, titlx, tityl, tityr, xgrid, . real(xkperp_slow_plot), real(xkperp_fast_plot), f3, . npoints, nmax, ymax, ymin, xmin, xmax) c title = 'slow root' c call ezplot1_s(title, titlx, tityl, tityr, xgrid, c . real(xkperp2_slow_plot), f3, c . npoints, nmax, ymax, ymin, xmin, xmax, nred) tityl = 'kperp2 (m-2)' title = 'fast root' call ezplot1_s(title, titlx, tityl, tityr, xgrid, . real(xkperp2_fast_plot), f3, . npoints, nmax, ymax, ymin, xmin, xmax, nblue) ! ------------------------------------------- ! Plot contours of k**2 - fast root ! ------------------------------------------- title = 'Re(k**2) - fast root' call ezconc(capr, y, real(xkperp2_fast), ff, nnodex, nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) title = 'Im(k**2) - fast root' call ezconc(capr, y, aimag(xkperp2_fast), ff, nnodex, nnodey,numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) xkperp_slow = csqrt(xkperp2_slow) xkperp_fast = csqrt(xkperp2_fast) do i = 1, nnodex xkperp_slow_plot(i) = xkperp_slow(i, jplot) xkperp_fast_plot(i) = xkperp_fast(i, jplot) end do ! ------------------------------------------------- ! write the function xkperp_fast_plot(i) to screen ! ------------------------------------------------- do i = 1, npoints write(6, '(i10, 1p5e15.5)') i, xgrid(i), xkperp_fast_plot(i) end do title = 'Re(k) - fast and slow roots' titlx = 'R (m)' tityl = 'Re(k) (m-1)' tityr = ' ' call ezplot2_sym(title, titlx, tityl, tityr, xgrid, . real(xkperp_slow_plot), real(xkperp_fast_plot), f3, . npoints, nmax, 0.0, 0.0, xmin, xmax) title = 'Re(k) - fast and slow (blowup)' titlx = 'R (m)' tityl = 'Re(k) (m-1)' tityr = ' ' call ezplot2_sym(title, titlx, tityl, tityr, xgrid, . real(xkperp_slow_plot), real(xkperp_fast_plot), f3, . npoints, nmax, 2000., -2000., xmin, xmax) title = 'Re(k) - slow root' call ezconc(capr, y, real(xkperp_slow), ff, nnodex, nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity, iflag) if (iflag .eq. 0) call boundary(capr, y, rho, ff, nnodex, . nnodey, numb, . nxmx, nymx, nlevmax, title, titx, tity) ! ------------------------- ! Close the graphics device ! ------------------------- call pgclos close (130) 310 format(1p6e12.4) 3310 format(1p6e18.10) 8310 format(1p6e14.6) 309 format(10i10) return end ! !******************************************************************************* ! subroutine ezplot1_s(title, titx, titll, titlr, x1, y1, y3, . nr, nrmax, . ymax, ymin, xmin, xmax, ncolor) implicit none real xzmax,xzmin,xnmin,xnmax,rhomin,rhomax real x1(nrmax), y1(nrmax), y3(nrmax) real y1max,y2max,y3max,y1min,y2min,y3min real ymin, ymax, xmin, xmax character*32 title character*32 titx character*32 titll character*32 titlr integer nr, nrmax integer nplot1,ncollab, ncolion,ncolbox, ncyan, ncolelec, . ncolln2, ncollin, ncolbrd integer nblack, nred, nyellow, ngreen, naqua, npink, nwheat, . ngrey, nbrown, nblue, nblueviolet, ncyan1, ncolor integer nturquoise, nmagenta, nsalmon, nwhite, norange, ncolln3 nwhite = 0 nblack = 1 nred = 2 ngreen = 3 nblue = 4 ncyan = 5 nmagenta = 6 nyellow = 7 norange = 8 ncolln3 = ngreen call a1mnmx(y1, nrmax, nr, y1min, y1max) if(y1max .eq. 0.0 .and. y1min .eq. 0.0)return ymax = y1max ymin = y1min rhomax = xmax rhomin = xmin ! Advance plotter to a new page, define coordinate range of graph and draw axes CALL PGPAGE CALL PGSVP (0.15,0.85,0.15,0.85) CALL PGSWIN (rhomin, rhomax, ymin, ymax) CALL PGBOX ('BCNST', 0.0, 0, 'BCNST', 0.0, 0) CALL PGSCI(nblack) ! Label the axes (note use of \u and \d for raising exponent). call pglab(titx, titll, title) ! Plot the line graph. CALL PGSCI(ncolor) call pgline(nr, x1, y1) 300 format (1p9e11.3) CALL PGSCI(nblack) call pgline(nr, x1, y3) return end ! !******************************************************************** ! subroutine ezplot2_s(title, titlb, titll, titlr, x1, y1, y2, y3, . nr, nrmax, ymax, ymin, xmin, xmax) implicit none real xzmax,xzmin,xnmin,xnmax,rhomin,rhomax real x1(nrmax),y1(nrmax), y2(nrmax), y3(nrmax) real y1max,y2max,y3max,y1min,y2min,y3min real ymin,ymax, xmin, xmax character*32 title character*32 titll character*32 titlr character*32 titlb integer nr, nrmax, n integer nplot1,ncollab, ncolion,ncolbox, ncyan, ncolelec, . ncolln2, ncollin, ncolbrd integer nblack,nred,nyellow, ngreen,naqua,npink, nwheat, . ngrey,nbrown,nblue,nblueviolet,ncyan1 integer nturquoise,nmagenta,nsalmon,nwhite,ncolln3, norange nwhite = 0 nblack = 1 nred = 2 ngreen = 3 nblue = 4 ncyan = 5 nmagenta = 6 nyellow = 7 norange = 8 call a1mnmx(y1, nrmax, nr, y1min, y1max) if(y1max .eq. 0.0 .and. y1min .eq. 0.0)return ymax = y1max ymin = y1min rhomax = xmax rhomin = xmin CALL PGPAGE CALL PGSVP (0.15,0.85,0.15,0.85) CALL PGSWIN (rhomin, rhomax, ymin, ymax) CALL PGBOX ('BCNST', 0.0, 0, 'BCNST', 0.0, 0) CALL PGSCI(nblack) ! Label the axes (note use of \u and \d for raising exponent). call pglab(titlb, titll, title) CALL PGSCI(nred) call pgline(nr, x1, y1) CALL PGSCI(nblue) call pgline(nr, x1, y2) CALL PGSCI(nblack) call pgline(nr, x1, y3) 300 format (1p9e11.3) return end ! !******************************************************************** ! subroutine ezplot2_b(title, titlb, titll, titlr, x1, y1, y2, y3, . nr, nrmax, ymax, ymin, xmin, xmax) implicit none real xzmax,xzmin,xnmin,xnmax,rhomin,rhomax real x1(nrmax),y1(nrmax), y2(nrmax), y3(nrmax) real y1max,y2max,y3max,y1min,y2min,y3min real ymin,ymax, xmin, xmax character*32 title character*32 titll character*32 titlr character*32 titlb integer nr, nrmax, n integer nplot1,ncollab, ncolion,ncolbox, ncyan, ncolelec, . ncolln2, ncollin, ncolbrd integer nblack,nred,nyellow, ngreen,naqua,npink, nwheat, . ngrey,nbrown,nblue,nblueviolet,ncyan1 integer nturquoise,nmagenta,nsalmon,nwhite,ncolln3, norange nwhite = 0 nblack = 1 nred = 2 ngreen = 3 nblue = 4 ncyan = 5 nmagenta = 6 nyellow = 7 norange = 8 call a1mnmx(y2, nrmax, nr, y2min, y2max) if(y1max .eq. 0.0 .and. y1min .eq. 0.0)return ymax = y2max * 2.0 ymin = y2min rhomax = xmax rhomin = xmin CALL PGPAGE CALL PGSVP (0.15,0.85,0.15,0.85) CALL PGSWIN (rhomin, rhomax, ymin, ymax) CALL PGBOX ('BCNST', 0.0, 0, 'BCNST', 0.0, 0) CALL PGSCI(nblack) ! Label the axes (note use of \u and \d for raising exponent). call pglab(titlb, titll, title) CALL PGSCI(nred) call pgline(nr, x1, y1) CALL PGSCI(nblue) call pgline(nr, x1, y2) CALL PGSCI(nblack) call pgline(nr, x1, y3) 300 format (1p9e11.3) return end ! !***************************************************************** ! subroutine ezplot2_sym(title, titlb, titll, titlr, x1, y1, y2, y3, . nr, nrmax, ymax_giv, ymin_giv, xmin, xmax) implicit none real xzmax,xzmin,xnmin,xnmax,rhomin,rhomax real x1(nrmax),y1(nrmax), y2(nrmax), y3(nrmax) real y1max,y2max,y3max,y1min,y2min,y3min real ymin,ymax, xmin, xmax, ymax_giv, ymin_giv character*32 title character*32 titll character*32 titlr character*32 titlb integer nr, nrmax, n integer nplot1,ncollab, ncolion,ncolbox, ncyan, ncolelec, . ncolln2, ncollin, ncolbrd integer nblack,nred,nyellow, ngreen,naqua,npink, nwheat, . ngrey,nbrown,nblue,nblueviolet,ncyan1 integer nturquoise,nmagenta,nsalmon,nwhite,ncolln3, norange nwhite = 0 nblack = 1 nred = 2 ngreen = 3 nblue = 4 ncyan = 5 nmagenta = 6 nyellow = 7 norange = 8 call a1mnmx(y1, nrmax, nr, y1min, y1max) ! write(6, 300) y2min, y2max if(y1max .eq. 0.0 .and. y1min .eq. 0.0)return ymax = y1max * 1.1 ymin = y1min if(ymax_giv .ne. 0.0)ymax = ymax_giv ymin = -ymax rhomax = xmax rhomin = xmin CALL PGPAGE CALL PGSVP (0.15,0.85,0.15,0.85) CALL PGSWIN (rhomin, rhomax, ymin, ymax) CALL PGBOX ('BCNST', 0.0, 0, 'BCNST', 0.0, 0) CALL PGSCI(nblack) ! Label the axes (note use of \u and \d for raising exponent). call pglab(titlb, titll, title) CALL PGSCI(nred) call pgline(nr, x1, y1) call pgline(nr, x1, -y1) CALL PGSCI(nblue) call pgline(nr, x1, y2) call pgline(nr, x1, -y2) CALL PGSCI(nblack) call pgline(nr, x1, y3) 300 format (1p9e11.3) return end ! !******************************************************************** !
SUBROUTINE ABMAT(ALPA,BETA,ALP,BET,LORD) IMPLICIT REAL*8 (A-H,O-Z) DIMENSION ALPA(NBATRI),BETA(NBATRI) DIMENSION ALP(NBATRI),BET(NBATRI),LORD(NBASIS) CHARACTER*8 SCFTYP,CITYP,DERTYP COMMON/BASIS/NBASIS,NTRI,NST,NSYM,NBFAO,NBFSO,NBATRI COMMON/COUPL/ALPC(15),BETC(15),ALPT(15),BETT(15) COMMON/FUNCS/NTYPES,NATOMS,N3N COMMON/GRSCF/FOCC(10),NSORB(10) COMMON/SIGNS/IOFF(256),IPRNT COMMON/TYPES/SCFTYP,CITYP,DERTYP DATA A00,QURT,HALF,ONE / 0.0D+00 , 0.25D+00 , 0.5D+00 , 1.0D+00 / 1 FORMAT(//,2X,' ALPA MATRIX'/) 2 FORMAT(//,2X,' BETA MATRIX'/) 3 FORMAT(//,2X,' ALP MATRIX'/) 4 FORMAT(//,2X,' BET MATRIX'/) C C IF CI THEN CHANGE BETA COUPLINGS BY ALPHA-BETA IF(CITYP.EQ.'CI ') THEN DO 10 I=1,15 BETC(I)=ALPC(I)-BETC(I) 10 CONTINUE ENDIF C C SET UP ALPHA AND BETA MATRICES CALL ZERO(ALPA,NTRI) CALL ZERO(BETA,NTRI) CALL ZERO(ALP,NTRI) CALL ZERO(BET,NTRI) C NSTRI=0 NENDI=0 DO 105 ITYP=1,NTYPES MM=NSORB(ITYP) IF(MM.EQ.0) GO TO 105 FI=FOCC(ITYP) NSTRI=NENDI+1 NENDI=NSTRI+MM-1 NSTRJ=0 NENDJ=0 DO 104 JTYP=1,ITYP NN=NSORB(JTYP) IF(NN.EQ.0) GO TO 104 FJ=FOCC(JTYP) NSTRJ=NENDJ+1 NENDJ=NSTRJ+NN-1 DO 102 I=NSTRI,NENDI DO 102 J=NSTRJ,NENDJ IJ=IOFF(MAX0(I,J))+MIN0(I,J) IIJJ=IOFF(MAX0(ITYP,JTYP))+MIN0(ITYP,JTYP) ALPA(IJ)=(ONE-ALPC(IIJJ))*FI*FJ*HALF BETA(IJ)=-(ONE-BETC(IIJJ))*FI*FJ*QURT 102 CONTINUE 104 CONTINUE 105 CONTINUE C CTPH NOW ROTATE ALPA AND BETA TO SCF ORDERING C CALL MREAD(LORD,4) DO 110 I=1,NBASIS M=LORD(I) DO 109 J=1,I N=LORD(J) IJ=IOFF(I)+J MN=IOFF(MAX(M,N))+MIN(M,N) ALP(MN)=ALPA(IJ) BET(MN)=BETA(IJ) 109 CONTINUE 110 CONTINUE C CALL MWRIT(ALP,40) CALL MWRIT(BET,41) IF(IPRNT.LE.2) GO TO 205 WRITE(6,1) CALL PRINT(ALPA,NTRI,NBASIS,6) WRITE(6,2) CALL PRINT(BETA,NTRI,NBASIS,6) WRITE(6,3) CALL PRINT(ALP,NTRI,NBASIS,6) WRITE(6,4) CALL PRINT(BET,NTRI,NBASIS,6) C 205 RETURN END
C ////////////////////////////////////////////////////////////// C BEND (OPT2) (NUMB) SUBROUTINE HIJS2(NAD,K1,K2,K3,XA,H11,H21,H31,H22,H32,H33) IMPLICIT REAL*8 (A-H,O-Z) DIMENSION XA(NAD,3),V1(3),V2(3),V3(3),E21(3),E23(3) DIMENSION H11(3,3),H21(3,3),H31(3,3),H22(3,3),H32(3,3),H33(3,3) DIMENSION H11A(3,3),H33A(3,3) PARAMETER(ONE=1.0D0) CALL VECT2(NAD,K1,K2,K3,V1,V2,V3,XA,PHI) CALL VECT1(NAD,K1,K2,E21,XA,T21) CALL VECT1(NAD,K3,K2,E23,XA,T23) CALL HIJS1(NAD,K1,K2,XA,H11A) CALL HIJS1(NAD,K3,K2,XA,H33A) SPHI=DSIN(PHI) CTPHI=DCOS(PHI)/SPHI W1=CTPHI W2=ONE/T21 W3=W1*W2 W4=ONE/T23 W5=W1*W4 DO 5 J=1,3 DO 5 I=J,3 H11(I,J)=H11A(I,J)*W3-V1(I)*V1(J)*W1 $ -(E21(I)*V1(J)+V1(I)*E21(J))*W2 H33(I,J)=H33A(I,J)*W5-V3(I)*V3(J)*W1 $ -(E23(I)*V3(J)+V3(I)*E23(J))*W4 5 CONTINUE DO 10 J=1,2 DO 10 I=J+1,3 H11(J,I)=H11(I,J) 10 H33(J,I)=H33(I,J) W3=ONE/(T21*SPHI) DO 15 J=1,3 W4=W2*E21(J)+W1*V1(J) DO 15 I=1,3 H31(I,J)=-H33A(I,J)*W3-V3(I)*W4 H21(I,J)=-(H11(I,J)+H31(I,J)) H32(I,J)=-(H31(I,J)+H33(I,J)) 15 CONTINUE DO 20 J=1,3 DO 20 I=1,3 H22(I,J)=-(H21(J,I)+H32(I,J)) 20 CONTINUE RETURN END
SUBROUTINE iau_ATICQN ( RI, DI, ASTROM, N, B, RC, DC ) *+ * - - - - - - - - - - - * i a u _ A T I C Q N * - - - - - - - - - - - * * Quick CIRS to ICRS astrometric place transformation, given the * star-independent astrometry parameters plus a list of light- * deflecting bodies. * * Use of this routine is appropriate when efficiency is important and * where many star positions are all to be transformed for one date. * The star-independent astrometry parameters can be obtained by * calling one of the routines iau_APCI[13], iau_APCG[13], iau_APCO[13] * or iau_APCS[13]. * * If the only light-deflecting body to be taken into account is the * Sun, the iau_ATICQ routine can be used instead. * * This routine is part of the International Astronomical Union's * SOFA (Standards of Fundamental Astronomy) software collection. * * Status: support routine. * * Given: * RI,DI d CIRS RA,Dec (radians) * ASTROM d(30) star-independent astrometry parameters: * (1) PM time interval (SSB, Julian years) * (2-4) SSB to observer (vector, au) * (5-7) Sun to observer (unit vector) * (8) distance from Sun to observer (au) * (9-11) v: barycentric observer velocity (vector, c) * (12) sqrt(1-|v|^2): reciprocal of Lorenz factor * (13-21) bias-precession-nutation matrix * (22) longitude + s' (radians) * (23) polar motion xp wrt local meridian (radians) * (24) polar motion yp wrt local meridian (radians) * (25) sine of geodetic latitude * (26) cosine of geodetic latitude * (27) magnitude of diurnal aberration vector * (28) "local" Earth rotation angle (radians) * (29) refraction constant A (radians) * (30) refraction constant B (radians) * N i number of bodies (Note 3) * B d(8,N) data for each of the NB bodies (Notes 3,4): * (1,I) mass of the body (solar masses, Note 5) * (2,I) deflection limiter (Note 6) * (3-5,I) barycentric position of the body (au) * (6-8,I) barycentric velocity of the body (au/day) * * Returned: * RC,DC d ICRS astrometric RA,Dec (radians) * * Notes: * * 1) Iterative techniques are used for the aberration and light * deflection corrections so that the routines iau_ATICQN and * iau_ATCIQN are accurate inverses; even at the edge of the Sun's * disk the discrepancy is only about 1 nanoarcsecond. * * 2) If the only light-deflecting body to be taken into account is the * Sun, the iau_ATICQ routine can be used instead. * * 3) The array B contains N entries, one for each body to be * considered. If N = 0, no gravitational light deflection will be * applied, not even for the Sun. * * 4) The array B should include an entry for the Sun as well as for any * planet or other body to be taken into account. The entries should * be in the order in which the light passes the body. * * 5) In the entry in the B array for body I, the mass parameter B(1,I) * can, as required, be adjusted in order to allow for such effects * as quadrupole field. * * 6) The deflection limiter parameter B(2,I) is phi^2/2, where phi is * the angular separation (in radians) between star and body at which * limiting is applied. As phi shrinks below the chosen threshold, * the deflection is artificially reduced, reaching zero for phi = 0. * Example values suitable for a terrestrial observer, together with * masses, are as follows: * * body I B(1,I) B(2,I) * * Sun 1D0 6D-6 * Jupiter 0.00095435D0 3D-9 * Saturn 0.00028574D0 3D-10 * * 7) For efficiency, validation of the contents of the B array is * omitted. The supplied masses must be greater than zero, the * position and velocity vectors must be right, and the deflection * limiter greater than zero. * * Called: * iau_S2C spherical coordinates to unit vector * iau_TRXP product of transpose of r-matrix and p-vector * iau_ZP zero p-vector * iau_AB stellar aberration * iau_LDN light deflection by n bodies * iau_C2S p-vector to spherical * iau_ANP normalize angle into range +/- pi * * This revision: 2013 September 30 * * SOFA release 2020-07-21 * * Copyright (C) 2020 IAU SOFA Board. See notes at end. * *----------------------------------------------------------------------- IMPLICIT NONE DOUBLE PRECISION RI, DI, ASTROM(30) INTEGER N DOUBLE PRECISION B(8,N), RC, DC INTEGER J, I DOUBLE PRECISION PI(3), PPR(3), PNAT(3), PCO(3), W, D(3), : BEFORE(3), R2, R, AFTER(3) DOUBLE PRECISION iau_ANP * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CIRS RA,Dec to Cartesian. CALL iau_S2C ( RI, DI, PI ) * Bias-precession-nutation, giving GCRS proper direction. CALL iau_TRXP ( ASTROM(13), PI, PPR ) * Aberration, giving GCRS natural direction. CALL iau_ZP ( D ) DO 50 J=1,2 R2 = 0D0 DO 10 I=1,3 W = PPR(I) - D(I) BEFORE(I) = W R2 = R2 + W*W 10 CONTINUE R = SQRT ( R2 ) DO 20 I=1,3 BEFORE(I) = BEFORE(I) / R 20 CONTINUE CALL iau_AB ( BEFORE, ASTROM(9), ASTROM(8), ASTROM(12), AFTER ) R2 = 0D0 DO 30 I=1,3 D(I) = AFTER(I) - BEFORE(I) W = PPR(I) - D(I) PNAT(I) = W R2 = R2 + W*W 30 CONTINUE R = SQRT ( R2 ) DO 40 I=1,3 PNAT(I) = PNAT(I) / R 40 CONTINUE 50 CONTINUE * Light deflection, giving BCRS coordinate direction. CALL iau_ZP ( D ) DO 100 J=1,5 R2 = 0D0 DO 60 I=1,3 W = PNAT(I) - D(I) BEFORE(I) = W R2 = R2 + W*W 60 CONTINUE R = SQRT ( R2 ) DO 70 I=1,3 BEFORE(I) = BEFORE(I) / R 70 CONTINUE CALL iau_LDN ( N, B, ASTROM(2), BEFORE, AFTER ) R2 = 0D0 DO 80 I=1,3 D(I) = AFTER(I) - BEFORE(I) W = PNAT(I) - D(I) PCO(I) = W R2 = R2 + W*W 80 CONTINUE R = SQRT ( R2 ) DO 90 I=1,3 PCO(I) = PCO(I) / R 90 CONTINUE 100 CONTINUE * ICRS astrometric RA,Dec. CALL iau_C2S ( PCO, W, DC ) RC = iau_ANP ( W ) * Finished. *+---------------------------------------------------------------------- * * Copyright (C) 2020 * Standards Of Fundamental Astronomy Board * of the International Astronomical Union. * * ===================== * SOFA Software License * ===================== * * NOTICE TO USER: * * BY USING THIS SOFTWARE YOU ACCEPT THE FOLLOWING SIX TERMS AND * CONDITIONS WHICH APPLY TO ITS USE. * * 1. The Software is owned by the IAU SOFA Board ("SOFA"). * * 2. Permission is granted to anyone to use the SOFA software for any * purpose, including commercial applications, free of charge and * without payment of royalties, subject to the conditions and * restrictions listed below. * * 3. You (the user) may copy and distribute SOFA source code to others, * and use and adapt its code and algorithms in your own software, * on a world-wide, royalty-free basis. That portion of your * distribution that does not consist of intact and unchanged copies * of SOFA source code files is a "derived work" that must comply * with the following requirements: * * a) Your work shall be marked or carry a statement that it * (i) uses routines and computations derived by you from * software provided by SOFA under license to you; and * (ii) does not itself constitute software provided by and/or * endorsed by SOFA. * * b) The source code of your derived work must contain descriptions * of how the derived work is based upon, contains and/or differs * from the original SOFA software. * * c) The names of all routines in your derived work shall not * include the prefix "iau" or "sofa" or trivial modifications * thereof such as changes of case. * * d) The origin of the SOFA components of your derived work must * not be misrepresented; you must not claim that you wrote the * original software, nor file a patent application for SOFA * software or algorithms embedded in the SOFA software. * * e) These requirements must be reproduced intact in any source * distribution and shall apply to anyone to whom you have * granted a further right to modify the source code of your * derived work. * * Note that, as originally distributed, the SOFA software is * intended to be a definitive implementation of the IAU standards, * and consequently third-party modifications are discouraged. All * variations, no matter how minor, must be explicitly marked as * such, as explained above. * * 4. You shall not cause the SOFA software to be brought into * disrepute, either by misuse, or use for inappropriate tasks, or * by inappropriate modification. * * 5. The SOFA software is provided "as is" and SOFA makes no warranty * as to its use or performance. SOFA does not and cannot warrant * the performance or results which the user may obtain by using the * SOFA software. SOFA makes no warranties, express or implied, as * to non-infringement of third party rights, merchantability, or * fitness for any particular purpose. In no event will SOFA be * liable to the user for any consequential, incidental, or special * damages, including any lost profits or lost savings, even if a * SOFA representative has been advised of such damages, or for any * claim by any third party. * * 6. The provision of any version of the SOFA software under the terms * and conditions specified herein does not imply that future * versions will also be made available under the same terms and * conditions. * * In any published work or commercial product which uses the SOFA * software directly, acknowledgement (see www.iausofa.org) is * appreciated. * * Correspondence concerning SOFA software should be addressed as * follows: * * By email: sofa@ukho.gov.uk * By post: IAU SOFA Center * HM Nautical Almanac Office * UK Hydrographic Office * Admiralty Way, Taunton * Somerset, TA1 2DN * United Kingdom * *----------------------------------------------------------------------- END
C $Header: /u/gcmpack/MITgcm_contrib/llc_hires/llc_4320/code-async/asyncio_register_field_code.F,v 1.1 2013/09/20 12:38:03 dimitri Exp $ C Register a field code with the ASYNCIO layer SUBROUTINE ASYNCIO_REGISTER_FIELD_CODE ( fCode ) IMPLICIT NONE CHARACTER*(*) fCode RETURN END
SUBROUTINE CREATE_COUNTER_LIST( string, array, nmax, status ) * * This software was developed by the Thermal Modeling and Analysis * Project(TMAP) of the National Oceanographic and Atmospheric * Administration's (NOAA) Pacific Marine Environmental Lab(PMEL), * hereafter referred to as NOAA/PMEL/TMAP. * * Access and use of this software shall impose the following * obligations and understandings on the user. The user is granted the * right, without any fee or cost, to use, copy, modify, alter, enhance * and distribute this software, and any derivative works thereof, and * its supporting documentation for any purpose whatsoever, provided * that this entire notice appears in all copies of the software, * derivative works and supporting documentation. Further, the user * agrees to credit NOAA/PMEL/TMAP in any publications that result from * the use of this software or in any product that includes this * software. The names TMAP, NOAA and/or PMEL, however, may not be used * in any advertising or publicity to endorse or promote any products * or commercial entity unless specific written permission is obtained * from NOAA/PMEL/TMAP. The user also understands that NOAA/PMEL/TMAP * is not obligated to provide the user with any support, consulting, * training or assistance of any kind with regard to the use, operation * and performance of this software nor to provide the user with any * updates, revisions, new versions or "bug fixes". * * THIS SOFTWARE IS PROVIDED BY NOAA/PMEL/TMAP "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL NOAA/PMEL/TMAP BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE. * * return a list of values for a counter (REPEAT/RANGE=string ) where ! string is the string, e.g. 10:1000:100 * ACM * As in counter_var_context, without error checking since it has * already been done in that routine. * V554: *acm* 1/4 IMPLICIT NONE * calling argument declarations INTEGER nmax, status REAL array(nmax) CHARACTER*(*) string * internal variable declarations: INTEGER TM_LENSTR, ATOM_POS, slen, . colon_pos, colon2_pos, lo_start, lo_end, hi_start, . hi_end, dum, xlo, xhi, n LOGICAL colon, colon2, fmat, use_subscripts REAL*8 ss_answer include 'ferret.parm' include 'errmsg.parm' * set the limits slen = TM_LENSTR(string) * ... ":" lo_start = 1 colon = .FALSE. colon_pos = ATOM_POS( string, ':' ) lo_end = colon_pos - 1 * ... second ":" colon2 = .FALSE. colon2_pos = ATOM_POS(string( colon_pos+1:slen ), ':' ) colon2 = colon2_pos .NE. atom_not_found IF ( colon2 ) THEN colon2_pos = colon2_pos + colon_pos hi_end = colon2_pos - 1 ELSE hi_end = slen ENDIF hi_start = colon_pos + 1 * Call translate_limit to check syntax and set ss limits use_subscripts = .TRUE. dum = 1 CALL TRANSLATE_LIMIT . ( string(lo_start:lo_end), x_dim, . use_subscripts, . ss_answer, fmat, dum, status ) xlo = INT(ss_answer) CALL TRANSLATE_LIMIT . ( string(hi_start:hi_end), x_dim, . use_subscripts, . ss_answer, fmat, dum, status ) xhi = INT(ss_answer) DO 100 n = xlo, xhi array(n) = n 100 CONTINUE * success 1000 status = ferr_ok RETURN END
INTEGER A$BUF(200) INTEGER ARG(128) INTEGER I,OWNER(3),CODE,MAXLE0,LEVEL,ENTRY(32) INTEGER FOLLOW,GETARG,TSCAN$ INTEGER USAGE(45) INTEGER AAAAA0 INTEGER AAAAB0 INTEGER PARSCL INTEGER AAAAC0(8) INTEGER AAAAD0(20) INTEGER AAAAE0(19) INTEGER AAAAF0 INTEGER AAAAG0 INTEGER AAAAH0(25) DATA USAGE/213,243,225,231,229,186,160,227,232,239,247,238,160,219 *,173,243,160,219,188,236,229,246,229,236,243,190,221,221,160,188,2 *39,247,238,229,242,190,160,251,188,228,233,242,190,253,0/ DATA AAAAC0/173,243,160,188,239,233,190,0/ DATA AAAAD0/239,247,238,229,242,160,238,225,237,229,160,244,239,23 *9,160,236,239,238,231,0/ DATA AAAAE0/170,243,186,160,226,225,228,160,240,225,244,232,238,22 *5,237,229,170,238,0/ DATA AAAAH0/170,243,186,160,227,225,238,167,244,160,227,232,225,23 *8,231,229,160,239,247,238,229,242,170,238,0/ IF((PARSCL(AAAAC0,A$BUF).NE.-3))GOTO 10002 CALL ERROR(USAGE) 10002 IF((A$BUF(243-225+1).EQ.2))GOTO 10003 A$BUF(243-225+27)=31 10003 MAXLE0=A$BUF(243-225+27)+1 IF((GETARG(1,ARG,128).NE.-1))GOTO 10004 CALL ERROR(USAGE) 10004 CALL MAPSTR(ARG,2) DO 10005 I=1,3 OWNER(I)=' ' 10005 CONTINUE 10006 I=1 CALL CTOP(ARG,I,OWNER,3) IF((ARG(I).EQ.0))GOTO 10007 CALL ERROR(AAAAD0) 10007 I=2 GOTO 10010 10008 I=I+(1) 10010 IF((GETARG(I,ARG,128).EQ.-1))GOTO 10009 IF((FOLLOW(ARG,0).EQ.-3))GOTO 10011 IF((A$BUF(243-225+1).EQ.0))GOTO 10012 AAAAA0=1 GOTO 10000 10013 GOTO 10014 10012 AAAAB0=1 GOTO 10001 10015 CONTINUE 10014 CALL AT$HOM(CODE) GOTO 10016 10011 CALL PRINT(-15,AAAAE0,ARG) 10016 GOTO 10008 10009 IF((I.NE.2))GOTO 10017 IF((A$BUF(243-225+1).EQ.0))GOTO 10018 AAAAA0=2 GOTO 10000 10019 GOTO 10020 10018 AAAAB0=2 GOTO 10001 10021 CONTINUE 10020 CONTINUE 10017 GOTO 10022 10000 LEVEL=0 10023 AAAAF0=TSCAN$(ARG,ENTRY,LEVEL,MAXLE0,8) GOTO 10024 10025 GOTO 10026 10027 AAAAB0=3 GOTO 10001 10028 GOTO 10029 10024 AAAAG0=AAAAF0+2 GOTO(10025,10027),AAAAG0 10029 CONTINUE GOTO 10023 10026 GOTO 10030 10022 GOTO 10031 10001 CALL SPAS$$(OWNER,0,CODE) IF((CODE.EQ.0))GOTO 10032 CALL PRINT(-15,AAAAH0,ARG) 10032 GOTO 10033 10031 CALL SWT 10030 GOTO(10013,10019),AAAAA0 GOTO 10030 10033 GOTO(10015,10021,10028),AAAAB0 GOTO 10033 END C ---- Long Name Map ---- C dosubtree dosub0 C maxlevels maxle0 C docurrentdir docur0
module DiffEq implicit none integer :: nsize,msize integer,private :: i,j,k type state ! state of ode real :: t real, dimension(:), allocatable :: x real, dimension(:,:), allocatable :: y integer :: step endtype state integer, parameter :: order = 2 ! Order of ODE in deriv() - input parameter real, dimension(:), allocatable :: y0 REAL, PARAMETER :: Pi = 3.1415927 contains ! Subroutine CRANK_NICHOLSON_2D_INIT is the initialization routine for the ! Crank-Nicholson solver for the 2D diffusion equation. It creates the A matrix ! and performs a cholesky decomposition for use in the solve routine. ! ! ** Input parameters ** ! x : input x vector (evenly spaced) ! y : input y vector (evenly spaced) ! bigI : input mesh I value ! bigJ : input mesh J value ! dt : timestep ! D : diffusion coefficient ! fg1,fg2,fg3,fg4 : dirichlet boundary conditions ! f3a,f3b : advection boundary functions ! A : out matrix 'U' cholesky decomposed matrix of LHS (n+1 timestep) SUBROUTINE CRANK_NICHOLSON_2D_INIT(x,y,bigI,bigJ,dt,D,fg1,fg2,fg3,fg4,A) use LinAl IMPLICIT NONE integer :: i,j,k,m,n,bigI,bigJ,INFO real :: dy,dx,dxf,dyf,dt,D real, dimension(0:bigI+1) :: x real, dimension(0:bigJ+1) :: y real, dimension(1:bigI*bigJ, 1:bigI*bigJ) :: A real, dimension(bigI*bigJ,1) :: B real, dimension(0:bigI+1,0:bigJ+1,0:2) :: u real, dimension(bigI*bigJ) :: w character (len=100) :: filename = 'hw6debugA.dat' ! Output data filename character (len=100) :: filename2 = 'hw6debugB.dat' ! Output data filename real :: fg1,fg2,fg3,fg4 external fg1,fg2,fg3,fg4 A = 0.0 B = 0.0 ! Calculate dy, dx (assume x and y vectors are evenly spaced) dy = y(1) - y(0) dx = x(1) - x(0) dyf = 1. / (dy ** 2) dxf = 1. / (dx ** 2) ! Create A and RHS vector B do j=1,bigJ do i=1,bigI ! calculate n index k = i + (j-1) * bigI A(k,k) = 1.0 + dt * D * (dxf + dyf) !-2.0 * (dxf + dyf) ! B(n,1) = fsolve(x(i),y(j)) ! Check for indexing to boundary conditions if (i .lt. bigI) then A(k,k+1) = -dxf * dt * D / 2.0 else ! B(n,1) = B(n,1) - dxf * fg4(y(j)) endif if (i .gt. 1) then A(k,k-1) = -dxf * dt * D / 2.0 else ! B(n,1) = B(n,1) - dxf * fg3(y(j)) endif if (j .lt. bigJ) then A(k,k+bigI) = -dyf * dt * D / 2.0 else ! B(n,1) = B(n,1) - dyf * fg2(x(i)) endif if (j .gt. 1) then A(k,k-bigI) = -dyf * dt * D / 2.0 else ! B(n,1) = B(n,1) - dyf * fg1(x(i)) endif enddo enddo ! For Debug: Output matrix A and B !call writematrix(A,filename) !call writematrix(B,filename2) ! Solve Ax = B (cholesky) !A = -A ! Call LAPACK routine to solve cholesky decomposition call SPOTRF( 'U', size(a,1), A, size(a,1), INFO ) if (INFO .ne. 0) write(*,*) 'ERROR CALCULATING CHOLESKY DECOMPOSITION.... FAILED',INFO ! w = B(:,1) !w = -B(:,1) END SUBROUTINE CRANK_NICHOLSON_2D_INIT ! Subroutine CRANK_NICHOLSON_2D_SOLVER is a Crank-Nicholson solver for the 2D diffusion equation ! ! ** Input parameters ** ! x : input x vector (evenly spaced) ! y : input y vector (evenly spaced) ! bigI : input mesh I value ! bigJ : input mesh J value ! dt : timestep ! D : diffusion coefficient ! fg1,fg2,fg3,fg4 : dirichlet boundary conditions ! f3a,f3b : advection boundary functions ! A : 'U' cholesky decomposed matrix of LHS (n+1 timestep) ! u : output solution mesh matrix SUBROUTINE CRANK_NICHOLSON_2D_SOLVER(x,y,bigI,bigJ,dt,D,fg1,fg2,fg3,fg4,A,u) use LinAl IMPLICIT NONE integer :: i,j,k,m,n,bigI,bigJ,INFO real :: dy,dx,dxf,dyf,dt,D real, dimension(0:bigI+1) :: x real, dimension(0:bigJ+1) :: y real, dimension(1:bigI*bigJ, 1:bigI*bigJ) :: A real, dimension(bigI*bigJ,1) :: R ! B real, dimension(0:bigI+1,0:bigJ+1,0:2) :: u real, dimension(bigI*bigJ) :: w character (len=100) :: filename = 'hw6debugA.dat' ! Output data filename character (len=100) :: filename2 = 'hw6debugB.dat' ! Output data filename real :: fg1,fg2,fg3,fg4 external fg1,fg2,fg3,fg4 R = 0.0 ! Calculate dy, dx (assume x and y vectors are evenly spaced) dy = y(1) - y(0) dx = x(1) - x(0) dyf = 1. / (dy ** 2) dxf = 1. / (dx ** 2) do i=1,bigI do j=1,bigJ k = i + (j-1) * bigI R(k,1) = u(i,j,0) * (1 - (dt * D * (dxf + dyf))) ! u(i,j,0) - u(i,j,0) * dt * D * (dxf + dyf) ! Check for indexing to boundary conditions if (i .eq. bigI) then ! i=bigI R(k,1) = R(k,1) + dt * D * dxf * fg4(y(j)) else ! i < bigI R(k,1) = R(k,1) + dt * D * dxf / 2.0 * u(i+1,j,0) endif if (i .eq. 1) then ! i=1 R(k,1) = R(k,1) + dt * D * dxf * fg3(y(j)) else ! i > 1 R(k,1) = R(k,1) + dt * D * dxf / 2.0 * u(i-1,j,0) endif if (j .eq. bigJ) then ! j=bigJ R(k,1) = R(k,1) + dt * D * dyf * fg2(x(i)) else ! j < bigJ R(k,1) = R(k,1) + dt * D * dyf / 2.0 * u(i,j+1,0) endif if (j .eq. 1) then ! j=1 R(k,1) = R(k,1) + dt * D * dyf * fg1(x(i)) else ! j > 1 R(k,1) = R(k,1) + dt * D * dyf / 2.0 * u(i,j-1,0) endif enddo enddo !w = R(:,1) ! Call LAPACK routine to solve backsubstitution call SPOTRS( 'U', size(a,1), 1, A, size(a,1), R(:,1), size(a,1), INFO ) if (INFO .ne. 0) write(*,*) 'ERROR CALCULATING SOLUTION FROM CHOLESKY DECOMPOSITION.... FAILED' ! For debug - write matrix w (solution to Ax=B) !call writevector(w,filename2) !call writevector(R(:,1),filename2) ! Recreate u from w do i=1,bigI do j=1,bigJ n = i + (j-1)*bigI u(i,j,0) = R(n,1) !w(n) enddo enddo do i=0,bigI+1 ! u(i,0) = fg1(x(i)) ! u(i,bigJ+1) = fg2(x(i)) enddo do j=0,bigJ+1 ! u(0,j) = fg3(y(j)) ! u(bigI+1,j) = fg4(y(j)) enddo END SUBROUTINE CRANK_NICHOLSON_2D_SOLVER ! Subroutine CN_FTCS_FULL_SOLVER is a Crank-Nicolson - FTCS solver for the advection-diffusion equation ! ! ** Input parameters ** ! x : input x vector (evenly spaced) ! y : input y vector (evenly spaced) ! bigI : input mesh I value ! bigJ : input mesh J value ! dt : timestep ! D : diffusion coefficient ! fg1,fg2,fg3,fg4 : dirichlet boundary conditions ! f3a,f3b : advection boundary functions ! A : 'U' cholesky decomposed matrix of LHS (n+1 timestep) ! u : output solution mesh matrix SUBROUTINE CN_FTCS_FULL_SOLVER(x,y,bigI,bigJ,dt,D,fg1,fg2,fg3,fg4,f3a,f3b,A,u) use LinAl IMPLICIT NONE integer :: i,j,k,m,n,bigI,bigJ,INFO real :: dy,dx,dxf,dyf,dt,D!,C real, dimension(0:bigI+1) :: x real, dimension(0:bigJ+1) :: y real, dimension(1:bigI*bigJ, 1:bigI*bigJ) :: A real, dimension(bigI*bigJ,1) :: R ! B real, dimension(0:bigI+1,0:bigJ+1,0:2) :: u real, dimension(bigI*bigJ) :: w character (len=100) :: filename = 'hw6debugA.dat' ! Output data filename character (len=100) :: filename2 = 'hw6debugB.dat' ! Output data filename real :: fg1,fg2,fg3,fg4,f3a,f3b external fg1,fg2,fg3,fg4,f3a,f3b R = 0.0 ! Calculate dy, dx (assume x and y vectors are evenly spaced) dy = y(1) - y(0) dx = x(1) - x(0) dyf = 1. / (dy ** 2) dxf = 1. / (dx ** 2) do i=1,bigI do j=1,bigJ k = i + (j-1) * bigI ! C = f3a(x(i),y(j)) + f3b(x(i),y(j)) ! write(*,*) 'C=',C R(k,1) = u(i,j,0) - u(i,j,0) * dt * D * (dxf + dyf) ! CN Contribution ! R(k,1) = R(k,1) + u(i,j,0) * ( 1.0 - 2 * dt * (-C) * (dxf + dyf) ) ! FTCS contribution ! Check for indexing to boundary conditions if (i .eq. bigI) then ! i=bigI R(k,1) = R(k,1) + dt * D * dxf * fg4(y(j)) ! CN Contribution R(k,1) = R(k,1) - dt * f3a(x(i),y(j)) * dxf * fg4(y(j)) ! FTCS Contribution else ! i < bigI R(k,1) = R(k,1) + dt * D * dxf / 2.0 * u(i+1,j,0) ! CN Contribution R(k,1) = R(k,1) - dt * f3a(x(i),y(j)) * dxf / 2.0 * u(i+1,j,0) ! FTCS contribution endif if (i .eq. 1) then ! i=1 R(k,1) = R(k,1) + dt * D * dxf * fg3(y(j)) ! CN Contribution R(k,1) = R(k,1) + dt * f3a(x(i),y(j)) * dxf * fg3(y(j)) ! FTCS Contribution else ! i > 1 R(k,1) = R(k,1) + dt * D * dxf / 2.0 * u(i-1,j,0) ! CN Contribution R(k,1) = R(k,1) + dt * f3a(x(i),y(j)) * dxf / 2.0 * u(i-1,j,0) ! FTCS contribution endif if (j .eq. bigJ) then ! j=bigJ R(k,1) = R(k,1) + dt * D * dyf * fg2(x(i)) ! CN Contribution R(k,1) = R(k,1) - dt * f3b(x(i),y(j)) * dyf * fg2(x(i)) ! FTCS Contribution else ! j < bigJ R(k,1) = R(k,1) + dt * D * dyf / 2.0 * u(i,j+1,0) ! CN Contribution R(k,1) = R(k,1) - dt * f3b(x(i),y(j)) * dyf / 2.0 * u(i,j+1,0) ! FTCS Contribution endif if (j .eq. 1) then ! j=1 R(k,1) = R(k,1) + dt * D * dyf * fg1(x(i)) ! CN Contribution R(k,1) = R(k,1) + dt * f3b(x(i),y(j)) * dyf * fg1(x(i)) ! FTCS Contribution else ! j > 1 R(k,1) = R(k,1) + dt * D * dyf / 2.0 * u(i,j-1,0) ! CN Contribution R(k,1) = R(k,1) + dt * f3b(x(i),y(j)) * dyf / 2.0 * u(i,j-1,0) ! FTCS Contribution endif enddo enddo !w = R(:,1) ! Call LAPACK routine to solve backsubstitution call SPOTRS( 'U', size(a,1), 1, A, size(a,1), R(:,1), size(a,1), INFO ) if (INFO .ne. 0) write(*,*) 'ERROR CALCULATING SOLUTION FROM CHOLESKY DECOMPOSITION.... FAILED' ! For debug - write matrix w (solution to Ax=B) !call writevector(w,filename2) !call writevector(R(:,1),filename2) ! Recreate u from w do i=1,bigI do j=1,bigJ n = i + (j-1)*bigI u(i,j,0) = R(n,1) !w(n) enddo enddo do i=0,bigI+1 ! u(i,0) = fg1(x(i)) ! u(i,bigJ+1) = fg2(x(i)) enddo do j=0,bigJ+1 ! u(0,j) = fg3(y(j)) ! u(bigI+1,j) = fg4(y(j)) enddo END SUBROUTINE CN_FTCS_FULL_SOLVER ! Subroutine FTCS_2D_SOLVER is a FTCS solver for the 2D diffusion equation ! ! ** Input parameters ** ! x : input x vector (evenly spaced) ! y : input y vector (evenly spaced) ! bigI : input mesh I value ! bigJ : input mesh J value ! dt : timestep ! D : diffusion coefficient ! fg1,fg2,fg3,fg4 : dirichlet boundary conditions ! u : output solution mesh matrix SUBROUTINE FTCS_2D_SOLVER(x,y,bigI,bigJ,dt,D,fg1,fg2,fg3,fg4,u) use LinAl IMPLICIT NONE integer :: i,j,k,m,n,bigI,bigJ,INFO real :: dy,dx,dxf,dyf,dt,D real, dimension(0:bigI+1) :: x real, dimension(0:bigJ+1) :: y real, dimension(1:bigI*bigJ, 1:bigI*bigJ) :: A real, dimension(bigI*bigJ,1) :: R ! B real, dimension(0:bigI+1,0:bigJ+1,0:2) :: u real, dimension(bigI*bigJ) :: w character (len=100) :: filename = 'hw6debugA.dat' ! Output data filename character (len=100) :: filename2 = 'hw6debugB.dat' ! Output data filename real :: fg1,fg2,fg3,fg4,fsolve external fg1,fg2,fg3,fg4,fsolve ! Calculate dy, dx (assume x and y vectors are evenly spaced) dy = y(1) - y(0) dx = x(1) - x(0) dyf = 1. / (dy ** 2) dxf = 1. / (dx ** 2) do i=1,bigI do j=1,bigJ k = i + (j-1) * bigI u(i,j,1) = u(i,j,0) * ( 1.0 - 2 * dt * D * (dxf + dyf) ) ! Check for indexing to boundary conditions if (i .lt. bigI) then if (i .gt. 1) then !u(i,j,1) = u(i,j,1) + dt * D * dxf * u(i+1,j,0) !u(i,j,1) = u(i,j,1) + dt * D * dxf * u(i-1,j,0) u(i,j,1) = u(i,j,1) + dt * D * dxf * u(i+1,j,0) u(i,j,1) = u(i,j,1) + dt * D * dxf * u(i-1,j,0) else ! if i=1 u(i,j,1) = u(i,j,1) + dt * D * dxf * fg3(y(j)) + dt * D * dxf * u(i+1,j,0) !u(i,j,1) = u(i,j,1) + dt * D * dxf * 1.0 + dt * D * dxf * u(i+1,j,0) endif else ! if i=bigI u(i,j,1) = u(i,j,1) + dt * D * dxf * fg4(y(j)) + dt * D * dxf * u(i-1,j,0) endif if (j .lt. bigJ) then if (j .gt. 1) then u(i,j,1) = u(i,j,1) + dt * D * dyf * u(i,j-1,0) u(i,j,1) = u(i,j,1) + dt * D * dyf * u(i,j+1,0) else ! if j=1 u(i,j,1) = u(i,j,1) + dt * D * dyf * fg1(x(i)) + dt * D * dyf * u(i,j+1,0) endif else ! if j=bigJ u(i,j,1) = u(i,j,1) + dt * D * dyf * fg2(x(i)) + dt * D * dyf * u(i,j-1,0) endif ! Check for indexing to boundary conditions if (i .eq. bigI) then ! u(i,j,1) = u(i,j,1) + dt * D * dxf * fg4(y(j)) !R(k,1) = R(k,1) + dt * D * dxf * fg4(y(j)) else endif if (i .eq. 1) then ! u(i,j,1) = u(i,j,1) + dt * D * dxf * fg3(y(j)) ! R(k,1) = R(k,1) + dt * D * dxf * fg3(y(j)) else endif if (j .eq. bigJ) then ! u(i,j,1) = u(i,j,1) + dt * D * dyf * fg2(x(i)) !R(k,1) = R(k,1) + dt * D * dyf * fg2(x(i)) else endif if (j .eq. 1) then ! u(i,j,1) = u(i,j,1) + dt * D * dyf * fg1(x(i)) !R(k,1) = R(k,1) + dt * D * dyf * fg1(x(i)) else endif enddo enddo u(:,:,0) = u(:,:,1) u(:,:,1) = 0.0 ! Recreate u from w do i=1,bigI do j=1,bigJ ! n = i + (j-1)*bigI ! u(i,j,0) = w(n) !R(n,1) !w(n) enddo enddo do i=0,bigI+1 u(i,0,0) = fg1(x(i)) u(i,bigJ+1,0) = fg2(x(i)) enddo do j=0,bigJ+1 u(0,j,0) = fg3(y(j)) u(bigI+1,j,0) = fg4(y(j)) enddo END SUBROUTINE FTCS_2D_SOLVER SUBROUTINE FTCS_1D_SOLVER(x,y,bigI,bigJ,dt,D,fg1,fg2,fg3,fg4,u) use LinAl IMPLICIT NONE integer :: i,j,k,m,n,bigI,bigJ,INFO real :: dy,dx,dxf,dyf,dt,D real, dimension(0:bigI+1) :: x real, dimension(0:bigJ+1) :: y real, dimension(1:bigI*bigJ, 1:bigI*bigJ) :: A real, dimension(bigI*bigJ,1) :: R ! B real, dimension(0:bigI+1,0:bigJ+1,0:2) :: u real, dimension(bigI*bigJ) :: w character (len=100) :: filename = 'hw6debugA.dat' ! Output data filename character (len=100) :: filename2 = 'hw6debugB.dat' ! Output data filename real :: fg1,fg2,fg3,fg4,fsolve external fg1,fg2,fg3,fg4,fsolve ! Calculate dy, dx (assume x and y vectors are evenly spaced) dy = y(1) - y(0) dx = x(1) - x(0) dyf = 0.0 ! 1. / (dy ** 2) dxf = 1. / (dx ** 2) do i=1,bigI do j=0,0!bigJ k = i + (j-1) * bigI u(i,j,1) = u(i,j,0) * ( 1.0 - 2 * dt * D * (dxf + dyf) ) ! Check for indexing to boundary conditions if (i .lt. bigI) then if (i .gt. 1) then ! u(i,inew) = r*u(i-1,iold) + diag*u(i,iold) + r*u(i+1,iold) u(i,j,1) = u(i,j,1) + dt * D * dxf * u(i+1,j,0) u(i,j,1) = u(i,j,1) + dt * D * dxf * u(i-1,j,0) else ! if i=1 ! u(i,j,1) = u(i,j,1) + dt * D * dxf * fg3(y(j)) u(i,j,1) = u(i,j,1) + dt * D * dxf * 1.0 + dt * D * dxf * u(i+1,j,0) ! + (1.0-2.0*dt*D*dxf*u(i,j,0)) ! fg3(y(j)) ! u(1,inew) = r*ua + diag*u(1,iold) + r*u(2,iold) endif else ! if i=bigI ! u(i,j,1) = u(i,j,1) + dt * D * dxf * fg4(y(j)) u(i,j,1) = u(i,j,1) + dt * D * dxf * 0.0 + dt * D * dxf * u(i-1,j,0) ! + (1.0-2.0*dt*D*dxf*u(i,j,0)) ! fg4(y(j)) ! u(nmesh,inew) = r*u(nmesh-1,iold) + diag*u(nmesh,iold) + r*ub endif if (j .lt. bigJ) then if (j .gt. 1) then ! u(i,j,1) = u(i,j,1) + dt * D * dyf * u(i,j-1,0) ! u(i,j,1) = u(i,j,1) + dt * D * dyf * u(i,j+1,0) else ! if j=1 ! u(i,j,1) = u(i,j,1) + dt * D * dyf * fg1(x(i)) endif else ! if j=bigJ ! u(i,j,1) = u(i,j,1) + dt * D * dyf * fg2(x(i)) endif ! Check for indexing to boundary conditions if (i .eq. bigI) then ! u(i,j,1) = u(i,j,1) + dt * D * dxf * fg4(y(j)) !R(k,1) = R(k,1) + dt * D * dxf * fg4(y(j)) else endif if (i .eq. 1) then ! u(i,j,1) = u(i,j,1) + dt * D * dxf * fg3(y(j)) ! R(k,1) = R(k,1) + dt * D * dxf * fg3(y(j)) else endif if (j .eq. bigJ) then ! u(i,j,1) = u(i,j,1) + dt * D * dyf * fg2(x(i)) !R(k,1) = R(k,1) + dt * D * dyf * fg2(x(i)) else endif if (j .eq. 1) then ! u(i,j,1) = u(i,j,1) + dt * D * dyf * fg1(x(i)) !R(k,1) = R(k,1) + dt * D * dyf * fg1(x(i)) else endif enddo enddo u(:,:,0) = u(:,:,1) u(:,:,1) = 0.0 ! Recreate u from w do i=1,bigI do j=1,bigJ ! n = i + (j-1)*bigI ! u(i,j,0) = w(n) !R(n,1) !w(n) enddo enddo do i=0,bigI+1 ! u(i,0,0) = fg1(x(i)) ! u(i,bigJ+1,0) = fg2(x(i)) enddo do j=0,bigJ+1 ! u(0,j,0) = fg3(y(j)) ! u(bigI+1,j,0) = fg4(y(j)) enddo END SUBROUTINE FTCS_1D_SOLVER ! Final project : Question 3 initial condition ! function u0 function f3(x,y) implicit none real :: f3,x,y f3 = y end function f3 ! Final project : Question 2 initial condition ! function u0 function f2(x,y) implicit none real :: f2,x,y f2 = y + sin(3 * PI * x) * sin(2 * PI * y) end function f2 ! function f function f1(x,y) implicit none real :: f1,x,y f1 = exp(-(x-0.5)**2/0.01) * exp(-(y-0.5)**2/0.01)!0 ! sin(PI * x) * sin(PI * y) end function f1 ! Final project : Question 3 ! function a function fa(x,y) implicit none real :: fa,x,y fa = PI * sin(2 * PI * x) * cos(PI * y) end function fa ! Final project : Question 3 ! function b function fb(x,y) implicit none real :: fb,x,y fb = -2 * PI * cos(2 * PI * x) * sin(PI * y) end function fb ! boundary function g1 (bottom) ! u(x,0) function g1(x) implicit none real :: g1,x g1 = 0 end function g1 ! boundary function g2 (top) ! u(x,1) function g2(x) implicit none real :: g2,x g2 = 1 !sin(PI * x) end function g2 ! boundary function g3 (left) ! u(0,y) function g3(x) implicit none real :: g3,x g3 = x end function g3 ! boundary function g4 (right) ! u(1,y) function g4(x) implicit none real :: g4,x g4 = x end function g4 subroutine printresult(x,y,u,time,nfile) implicit none ! This routine prints out the solution at a particular timestep. real, dimension(0:,0:) :: u real, dimension(:) :: x,y ! real, dimension(0:nmesh+1) :: utheor real :: time!,bmt,mpi integer :: nmesh,nfile,i,m integer, parameter :: mmax = 500 ! real, parameter :: pi = dacos(-1.d0) character hundred,ten,unit hundred = char(nfile/100+48) ten=char(mod(nfile,100)/10+48) unit=char(mod(nfile,10) + 48) open(10,file='u.'//hundred//ten//unit,status='unknown') open(13,file='time.'//hundred//ten//unit,status='unknown') ! This calculates the theoretical solution for the ! initial step function problem with specific values ! For ua = 1, ub = 0, xa = 0 and xb = 1. ! do i=0,nmesh+1 ! utheor(i) = 1.d0 - x(i) ! enddo ! do m=1,mmax ! mpi = dble(m)*pi ! bmt = (-2.d0/mpi) * dcos(mpi/2.d0) * dexp(-mpi**2*kappa*time) ! do i=0,nmesh+1 ! utheor(i) = utheor(i) + bmt*dsin(mpi*x(i)) ! enddo ! enddo ! Writes out the solution and the theoretical solution. ! do i=0,nmesh+1 ! write(10,*) x(i),u(i),utheor(i) ! enddo do i=1,size(x)-1 do j=1,size(y)-1 ! 2D - Splot write(10,*) x(i),y(j),u(i,j) ! 1D - plot !write(10,*) x(i),u(i,0) enddo write(10,*) '' enddo write(13,*) time close(10) close(13) end subroutine printresult ! Poisson solver using dirichlet conditions ! Input parameters ! x : input x vector (evenly spaced) ! y : input y vector (evenly spaced) ! bigI : input I value ! bigJ : input J value ! f : function to solve ! g1,g2,g3,g4 : boundary functions ! u : output solution mesh matrix ! SUBROUTINE POISSON_SOLVE_DIRICHLET(x,y,bigI,bigJ,fsolve,fg1,fg2,fg3,fg4,u) use LinAl IMPLICIT NONE integer :: i,j,k,m,n,bigI,bigJ,INFO real :: dy,dx,dxf,dyf real, dimension(0:bigI+1) :: x real, dimension(0:bigJ+1) :: y real, dimension(1:bigI*bigJ, 1:bigI*bigJ) :: A real, dimension(bigI*bigJ,1) :: B real, dimension(0:bigI+1,0:bigJ+1) :: u real, dimension(bigI*bigJ) :: w character (len=100) :: filename = 'hw6debugA.dat' ! Output data filename character (len=100) :: filename2 = 'hw6debugB.dat' ! Output data filename real :: fg1,fg2,fg3,fg4,fsolve external fg1,fg2,fg3,fg4,fsolve A = 0 B = 0 ! Calculate dy, dx (assume x and y vectors are evenly spaced) dy = y(1) - y(0) dx = x(1) - x(0) dyf = 1. / (dy ** 2) dxf = 1. / (dx ** 2) ! Create A and RHS vector B do j=1,bigJ do i=1,bigI ! calculate n index n = i + (j-1) * bigI A(n,n) = -2.0 * (dxf + dyf) B(n,1) = fsolve(x(i),y(j)) ! Check for indexing to boundary conditions if (i .lt. bigI) then A(n,n+1) = dxf else B(n,1) = B(n,1) - dxf * fg4(y(j)) endif if (i .gt. 1) then A(n,n-1) = dxf else B(n,1) = B(n,1) - dxf * fg3(y(j)) endif if (j .lt. bigJ) then A(n,n+bigI) = dyf else B(n,1) = B(n,1) - dyf * fg2(x(i)) endif if (j .gt. 1) then A(n,n-bigI) = dyf else B(n,1) = B(n,1) - dyf * fg1(x(i)) endif ! endif enddo enddo ! For Debug: Output matrix A and B !call writematrix(A,filename) !call writematrix(B,filename2) ! Solve Ax = B (cholesky) A = -A ! Call LAPACK routine to solve cholesky decomposition call SPOTRF( 'U', size(a,1), A, size(a,1), INFO ) if (INFO .ne. 0) write(*,*) 'ERROR CALCULATING CHOLESKY DECOMPOSITION.... FAILED',INFO w = -B(:,1) !3. Solve RT y = AT b (forward solve), and Solve Rx = y (backward solve) . ! Call LAPACK routine to solve backsubstitution call SPOTRS( 'U', size(a,1), 1, A, size(a,1), w, size(a,1), INFO ) if (INFO .ne. 0) write(*,*) 'ERROR CALCULATING SOLUTION FROM CHOLESKY DECOMPOSITION.... FAILED' ! For debug - write matrix w (solution to Ax=B) !call writevector(w,filename2) ! Recreate u from w do i=1,bigI do j=1,bigJ n = i + (j-1)*bigI u(i,j) = w(n) enddo enddo do i=0,bigI+1 u(i,0) = fg1(x(i)) u(i,bigJ+1) = fg2(x(i)) enddo do j=0,bigJ+1 u(0,j) = fg3(y(j)) u(bigI+1,j) = fg4(y(j)) enddo END SUBROUTINE POISSON_SOLVE_DIRICHLET ! Write .dat file for gnuplot splot SUBROUTINE WriteSPlotDat(x,y,a,filename) IMPLICIT NONE INTEGER :: n,i,j CHARACTER(LEN=*) :: filename real, dimension(:) :: x,y real, dimension(:,:) :: a n=18 open(n,file=filename) do i=1,size(x) do j=1,size(y) write(n,*) x(i),y(j),a(i,j) enddo enddo write(*,*) 'Printing output splot data points to: ',filename close(n) END SUBROUTINE WriteSPlotDat ! deriv is a function deriv(t,y,dy) that takes t and y as inputs and returns dy ! y and dy are arrays of size (n) where n is the order of the ODE (SET ABOVE AS A PARAMETER) subroutine deriv(t,y,dy) implicit none integer :: n real :: t!,y real, dimension(:) :: y real, dimension(:), allocatable :: dy n = size(y) ! if (allocated(dy)) then ! deallocate(dy) ! endif allocate(dy(n)) ! f'' = -f' -f, with initial conditions f(0) = 2, f'(0) = 1. Test different timesteps. ! solve ordinary differential equation y''(t)=-y'(t)-y(t), y(0)=2, y'(0)=1 ! eigenvalue {{1,0},{-1,-1}} ! lambda1 = -1, lambda2 = 1 v1 = (0,1) v2 = (-2,1) ! y1 = f, y2 = f', y1' = y2 , y2' = -y2 - y1 dy(1) = y(2) dy(2) = -y(2) - y(1) end subroutine deriv ! Set initial conditions for above function SUBROUTINE initialconditions() ! Initial Condition for function allocate(y0(order)) y0(1) = 2. y0(2) = 1. END SUBROUTINE initialconditions ! Create a driver program that integrates the ODE above using one method, and then the other. The program must take in as ! arguments the initial time, the initial value of f, the final time, and the timestep. The user must know how to modify ! the routine that calculates G(f,t). ! Input parameters ! deriv : derivative function ! orderf : order of derivative function ! t0 : initial time ! tf : final time ! dt : timestep ! filename : output data filename for coordinates ! algorithm : implementation step routine, either 'EulerModified' or 'EulerExplicit' ! SUBROUTINE ODEDRIVER(derivf,t0,tf,dt,filename,algorithm) IMPLICIT NONE integer :: i,j,k,m,n real :: t0,dt,tf external derivf type(state) :: curstate character (len=*) :: filename,algorithm write(*,*) 'Input Values :: timestep: ',dt,'Initial Time: ',t0,'Final Time: ',tf if (algorithm .eq. 'EulerExplicit') then write(*,*) 'Using Eulers Explicit Algorithm' else if (algorithm .eq. 'EulerModified') then write(*,*) 'Using Eulers Modified Algorithm' else if (algorithm .eq. 'AdamsBashforth2') then write(*,*) 'Using Adams-Bashforth 2nd order Algorithm' else write(*,*) 'Invalid Input Algorithm' endif ! Initial Condition for function call initialconditions() ! calculate number of timesteps n = tf / dt + 2 ! Initializations allocate(curstate%y(order,n)) do i=1,n curstate%y(i,1) = y0(i) enddo curstate%t = t0 curstate%step = 1 allocate(curstate%x(n)) curstate%x(1) = t0 do while (curstate%t .lt. tf) if (algorithm .eq. 'EulerExplicit') then call EULEREXPLICIT(curstate,dt,derivf) else if ((algorithm .eq. 'EulerModified') .or. ((algorithm .eq. 'AdamsBashforth2') .and. (curstate%step .lt. 3))) then call EULERMODIFIED(curstate,dt,derivf) else if (algorithm .eq. 'AdamsBashforth2') then call ADAMSBASHFORTH(curstate,dt,derivf,2) endif enddo ! Print output coordinates to file open(12,file=filename) do i=1,size(curstate%x) write(12,*) curstate%x(i),curstate%y(:,i) enddo write(*,*) 'Printing output fit coordinates to: ',filename close(12) deallocate(curstate%y) deallocate(curstate%x) deallocate(y0) END SUBROUTINE ODEDRIVER ! Adams-Bashforth 2nd order scheme. ! the scheme must be able to deal with any number of coupled ODEs. ! As in the previous homework: create a timestepper routine, and a driver routine. Make sure the timestepper routine ! takes in as argument the RHS function/routine that returns the derivatives. Bonus point for elegant use of derived data types. SUBROUTINE ADAMSBASHFORTH(curstate,dt,derivf,aorder) IMPLICIT NONE INTEGER :: i,j,k,m,nsize,msize,prevstep,aorder real :: f0,t0,t,dt,tf,y0, deriv,x real, dimension(:), allocatable :: dy,fn1,fn2 type(state) :: curstate interface subroutine derivf(t,y,dy) integer :: n real :: t real, dimension(:) :: y real, dimension(:), allocatable :: dy end subroutine derivf end interface prevstep = curstate%step curstate%step = curstate%step + 1 curstate%t = curstate%t + dt ! Calculate f_n-1 call derivf(curstate%x(prevstep),curstate%y(:,prevstep),fn1) ! Calculate f_n-2 call derivf(curstate%x(prevstep-1),curstate%y(:,prevstep-1),fn2) ! Calculate y(n) if (aorder .eq. 2) then curstate%y(:,curstate%step) = curstate%y(:,prevstep) + 0.5 * dt * (3.0 * fn1 - fn2) endif curstate%x(curstate%step) = curstate%t END SUBROUTINE ADAMSBASHFORTH ! Create a routine that advances the solution to an ODE of the kind df/dt = G(f,t) for one timestep using Euler's modified ! midpoint method. The input and outputs to the routine must be a derived data type that contains (1) the time and (2) ! the value of the function f at that time. The name of the function that contains G(f,t) must be passed as an argument ! to the routine. SUBROUTINE EULERMODIFIED(curstate,dt,derivf) IMPLICIT NONE INTEGER :: i,j,k,m,nsize,msize,prevstep real :: f0,t0,t,dt,tf,y0, deriv,x!,k1,k2 real, dimension(:), allocatable :: dy,k1,k2 type(state) :: curstate interface subroutine derivf(t,y,dy) integer :: n real :: t real, dimension(:) :: y real, dimension(:), allocatable :: dy end subroutine derivf end interface prevstep = curstate%step curstate%step = curstate%step + 1 curstate%t = curstate%t + dt allocate(k1(order)) allocate(k2(order)) nsize = size(curstate%y,1) call derivf(curstate%x(prevstep),curstate%y(:,prevstep),dy) k1 = dt * dy deallocate(dy) call derivf(curstate%x(curstate%step),curstate%y(:,prevstep)+k1,dy) k2 = dt * dy deallocate(dy) curstate%y(:,curstate%step) = curstate%y(:,prevstep) + 0.5 * k1 + 0.5 * k2 curstate%x(curstate%step) = curstate%t END SUBROUTINE EULERMODIFIED ! Create a routine that advances the solution to an ODE of the kind df/dt = G(f,t) for one timestep using Euler's method. ! The input and outputs to the routine must be a derived data type that contains (1) the time and (2) the value of the ! function f at that time. The name of the function that contains G(f,t) must be passed as an argument to the routine. ! ! Approximates y(t) in y'(t) = f(y, t) with y(a) = y0 and t = t0..tf and step size dt. SUBROUTINE EULEREXPLICIT(curstate,dt,derivf) IMPLICIT NONE INTEGER :: i,j,k,n,m,nsize,msize,prevstep real :: f0,t0,t,dt,tf,y0,x real, dimension(:), allocatable :: dy type(state) :: curstate interface subroutine derivf(t,y,dy) integer :: n real :: t real, dimension(:) :: y real, dimension(:), allocatable :: dy end subroutine derivf end interface prevstep = curstate%step curstate%step = curstate%step + 1 curstate%t = curstate%t + dt nsize = size(curstate%y,1) call derivf(curstate%x(prevstep),curstate%y(:,prevstep),dy) do i=1,nsize curstate%y(i,curstate%step) = curstate%y(i,prevstep) + dt * dy(i) curstate%x(curstate%step) = curstate%t enddo END SUBROUTINE EULEREXPLICIT end module DiffEq
program pdb_amber2nwchem implicit none #include "pre_common.fh" character(len=1024) :: inputfile character(len=1024) :: outputfile character(len=100) :: line character(len=12) :: l1 ! characters 1-12 character(len=6) :: catm(3,1) ! characters 13-16 character(len=1) :: l2 ! characters 17 character(len=5) :: cseq(2,1) ! characters 18-20 character(len=100) :: l3 ! characters 21-72 integer, external :: inp_strlen logical, external :: pre_namiup integer :: lfninp integer :: lfnout integer :: iline integer :: lseq(6,1) integer :: latm(5,1) logical :: ll ffield = "amber" call pdb_readcommandlinearguments(inputfile,outputfile,ffield) lfninp = 5 lfnout = 6 lseq = 1 latm = 1 if (inputfile.ne."-") then close(lfninp) open(unit=lfninp,file=inputfile,err=100,form="formatted", + status="old") endif 100 continue if (outputfile.ne."-") then close(lfnout) open(unit=lfnout,file=outputfile,err=200,form="formatted") endif 200 continue iline = 0 line = "" do while (line(1:3).ne."END") catm = " " cseq = " " iline = iline + 1 read(lfninp,'(a)')line select case (line(1:4)) case ("ATOM ", "HETA") read(line,1002,end=300,err=300)l1,catm(1,1)(1:4),l2, + cseq(1,1)(1:3),l3 ll = pre_namiup(0,lseq,cseq,1,1,latm,catm,1,1) call namseq(catm,cseq) write(lfnout,1002)l1,catm(2,1)(1:4),l2,cseq(2,1)(1:3), + l3(1:inp_strlen(l3)) case default write(lfnout,'(a)')line(1:inp_strlen(line)) end select enddo 300 continue close(lfninp) close(lfnout) 1002 format(a12,a4,a1,a3,a) end ! !----------------------------------------------------------------------- ! subroutine namseq(catm,cseq) implicit none character(len=6), intent(inout) :: catm(3,1) character(len=5), intent(inout) :: cseq(2,1) ! cseq(2,1)(1:3) = cseq(1,1)(1:3) if (cseq(2,1)(1:3).eq."WAT") then cseq(2,1)(1:3) = "HOH" if (catm(2,1)(1:4).eq." H1 ") then catm(2,1)(1:4) = "2H " endif if (catm(2,1)(1:4).eq." H2 ") then catm(2,1)(1:4) = "3H " endif if (catm(2,1)(1:4).eq." H3 ") then catm(2,1)(1:4) = "2H " endif endif if (cseq(2,1)(1:3).eq."Cl-") then cseq(2,1)(1:3) = " Cl" if (catm(2,1)(1:4).eq."Cl- ") then catm(2,1)(1:4) = "Cl " endif endif if (cseq(2,1)(1:3).eq."Na+") then cseq(2,1)(1:3) = " Na" if (catm(2,1)(1:4).eq."Na+ ") then catm(2,1)(1:4) = "Na " endif endif if (cseq(2,1)(1:3).eq." K+") then cseq(2,1)(1:3) = " K " if (catm(2,1)(1:4).eq." K+ ") then catm(2,1)(1:4) = " K " endif endif return end
parameter(nmax=1000000) real w(nmax),xf(nmax),sn(nmax),sb(nmax),sr(nmax) real*8 dra(nmax),ddec(nmax),drad,dx1,dx2 integer iok(nmax),iok2(nmax) parameter(radtodeg=57.29578) rad=5.5 rad=2.0 wc=2.5 open(unit=1,file='d4',status='old') n=0 do i=1,nmax read(1,*,end=666) dx1,dx2,x3,x4 n=n+1 dra(n)=dx1 ddec(n)=dx2 sb(n)=x3 sr(n)=x4 sn(n)=x3+x4 iok(n)=1 iok2(n)=1 enddo 666 continue close(1) cosd=cos(sngl(ddec(1))/radtodeg) do i=1,n-1 if(iok(i).eq.1) then imax=i snmax=sn(i) do j=i+1,n drad=dble(cosd)*(dra(i)-dra(j))**2+(ddec(i)-ddec(j))**2 drad=3600.d0*dsqrt(drad) radc=sngl(drad) if(radc.lt.rad) then print *,i,j,radc,sn(i),sn(j) iok(j)=0 iok2(j)=0 iok2(i)=0 if(sn(j).ge.snmax) then imax=j snmax=sn(j) iok(i)=0 endif c print *,i,j,sn(i),sn(j),imax,iok(i) endif enddo iok2(imax)=1 endif enddo iwrite=0 do i=1,n if(iok2(i).eq.1) iwrite=1 enddo if(iwrite.eq.0) goto 888 open(unit=11,file='radec.out',status='unknown') do i=1,n if(iok2(i).eq.1) then write(11,1011) dra(i),ddec(i),sb(i),sr(i) endif enddo close(11) 888 continue 1011 format(2(1x,f11.7),2(1x,f14.2)) end
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C FFTPACK 5.0 C Copyright (C) 1995-2004, Scientific Computing Division, C University Corporation for Atmospheric Research C Licensed under the GNU General Public License (GPL) C C Authors: Paul N. Swarztrauber and Richard A. Valent C C $Id: msntf1.f,v 1.2 2006-11-21 01:10:18 haley Exp $ C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC SUBROUTINE DMSNTF1(LOT,JUMP,N,INC,X,WSAVE,DSUM,XH,WORK,IER) DOUBLE PRECISION WORK DOUBLE PRECISION SSQRT3 DOUBLE PRECISION XHOLD DOUBLE PRECISION T1 DOUBLE PRECISION T2 DOUBLE PRECISION SFNP1 DOUBLE PRECISION X(INC,*),WSAVE(*),XH(LOT,*) C*PT*WARNING* Already double-precision DOUBLE PRECISION DSUM(*) IER = 0 LJ = (LOT-1)*JUMP + 1 IF (N-2) 101,102,103 102 SSQRT3 = 1.D0/SQRT(3.D0) DO 112 M = 1,LJ,JUMP XHOLD = SSQRT3* (X(M,1)+X(M,2)) X(M,2) = SSQRT3* (X(M,1)-X(M,2)) X(M,1) = XHOLD 112 CONTINUE 101 GO TO 200 103 NP1 = N + 1 NS2 = N/2 DO 104 K = 1,NS2 KC = NP1 - K M1 = 0 DO 114 M = 1,LJ,JUMP M1 = M1 + 1 T1 = X(M,K) - X(M,KC) T2 = WSAVE(K)* (X(M,K)+X(M,KC)) XH(M1,K+1) = T1 + T2 XH(M1,KC+1) = T2 - T1 114 CONTINUE 104 CONTINUE MODN = MOD(N,2) IF (MODN.EQ.0) GO TO 124 M1 = 0 DO 123 M = 1,LJ,JUMP M1 = M1 + 1 XH(M1,NS2+2) = 4.D0*X(M,NS2+1) 123 CONTINUE 124 DO 127 M = 1,LOT XH(M,1) = 0.D0 127 CONTINUE LNXH = LOT - 1 + LOT* (NP1-1) + 1 LNSV = NP1 + INT(LOG(DBLE(NP1))) + 4 LNWK = LOT*NP1 C CALL DRFFTMF(LOT,1,NP1,LOT,XH,LNXH,WSAVE(NS2+1),LNSV,WORK,LNWK, + IER1) IF (IER1.NE.0) THEN IER = 20 CALL DXERFFT('MSNTF1',-5) GO TO 200 END IF C IF (MOD(NP1,2).NE.0) GO TO 30 DO 20 M = 1,LOT XH(M,NP1) = XH(M,NP1) + XH(M,NP1) 20 CONTINUE 30 SFNP1 = 1.D0/DBLE(NP1) M1 = 0 DO 125 M = 1,LJ,JUMP M1 = M1 + 1 X(M,1) = .5D0*XH(M1,1) DSUM(M1) = X(M,1) 125 CONTINUE DO 105 I = 3,N,2 M1 = 0 DO 115 M = 1,LJ,JUMP M1 = M1 + 1 X(M,I-1) = .5D0*XH(M1,I) DSUM(M1) = DSUM(M1) + .5D0*XH(M1,I-1) X(M,I) = DSUM(M1) 115 CONTINUE 105 CONTINUE IF (MODN.NE.0) GO TO 200 M1 = 0 DO 116 M = 1,LJ,JUMP M1 = M1 + 1 X(M,N) = .5D0*XH(M1,N+1) 116 CONTINUE 200 CONTINUE RETURN END
SUBROUTINE ALG06(R1,R2,X1,X2,H,S,VM,TB1,TB2,W,XK,SCLFAC,SPEED,SPD 1FAC,G,EJ,HMIN,NSTRMS,PI) C DIMENSION R1(1),R2(1),X1(1),X2(1),H(1),S(1),VM(1),TB1(1),TB2(1),W( 11) DIMENSION R(150),W2D(150),W3D(150),XX1(150),XX2(150),XX3(150),XX5( 19,9),B(150) C EQUIVALENCE (XX2(1),XX5(1,1)) C NTUB=NSTRMS-1 DO 50 J=1,NSTRMS Q1=H(J)-VM(J)**2*(1.0+(TB2(J)+R2(J)*SPEED*SPDFAC*PI/(SCLFAC*30.0*V 1M(J)))**2)/(2.0*G*EJ) IF(Q1.LT.HMIN)Q1=HMIN XX1(J)=ALG4(Q1,S(J)) 50 XX2(J)=ALG5(Q1,S(J)) CALL ALG01(R2,XX1,NSTRMS,R2,Q1,XX3,NSTRMS,0,1) DO 60 J=1,NSTRMS 60 XX1(J)=XX3(J)*G/XX2(J) Q1=(R2(NSTRMS)-R2(1))/149.0 R(1)=R2(1) DO 70 J=2,150 70 R(J)=R(J-1)+Q1 CALL ALG01(R2,XX1,NSTRMS,R,XX2,Q1,150,0,0) DO 80 J=1,NSTRMS 80 XX3(J)=((R2(J)-R1(J))**2+(X2(J)-X1(J))**2)*(1.0+((TB1(J)+TB2(J))*0 1.5)**2) CALL ALG01(R2,XX3,NSTRMS,R,XX1,Q1,150,0,0) DO 90 J=1,NSTRMS 90 W2D(J)=VM(J)**2*(1.0+TB2(J)**2) CALL ALG01(R2,W2D,NSTRMS,R,XX3,Q1,150,0,0) CALL ALG01(R2,W ,NSTRMS,R,W2D,Q1,150,0,0) NKEEP=NSTRMS NSTRMS=150 NTUB=149 Q2=(SPEED*SPDFAC*PI/(30.0*SCLFAC))**2 DO 100 J=1,NSTRMS 100 W3D(J)=0.0 B(1)=(R(2)-R(1))/2.0 B(NSTRMS)=(R(NSTRMS)-R(NTUB))/2.0 DO 110 J=2,NTUB 110 B(J)=(R(J+1)-R(J-1))/2.0 DO 270 J=1,NSTRMS DR=XK*XX1(J)/XX3(J)*(Q2*R(J)-XX2(J)) IF(DR)130,120,200 120 W3D(J)=W3D(J)+W2D(J) GO TO 270 130 IF(J.EQ.1)GO TO 120 IF(R(J)+DR.LE.R(1))GO TO 180 DO 140 JJ=2,J JJJ=J-JJ+1 IF(R(J)+DR.GE.R(JJJ))GO TO 150 140 CONTINUE 150 JJJ=JJJ+1 Q1=W2D(J)*B(J)/(B(J)-DR) DO 170 JJ=JJJ,J 170 W3D(JJ)=W3D(JJ)+Q1 GO TO 270 180 A=B(J)*W2D(J)/(R(NSTRMS)-R(1)) IF(J.NE.NSTRMS)A=B(J)*W2D(J)/((R(J+1)+R(J))*0.5-R(1)) DO 190 JJ=1,J 190 W3D(JJ)=W3D(JJ)+A GO TO 270 200 IF(J.EQ.NSTRMS)GO TO 120 IF(R(J)+DR.GE.R(NSTRMS))GO TO 250 DO 210 JJ=J,NSTRMS IF(R(J)+DR.LT.R(JJ))GO TO 220 210 CONTINUE 220 JJ=JJ-1 Q1=W2D(J)*B(J)/(B(J)+DR) DO 240 JJJ=J,JJ 240 W3D(JJJ)=W3D(JJJ)+Q1 GO TO 270 250 A=B(J)*W2D(J)/(R(NSTRMS)-R(1)) IF(J.NE.1)A=B(J)*W2D(J)/(R(NSTRMS)-(R(J)+R(J-1))*0.5) DO 260 JJ=J,NSTRMS 260 W3D(JJ)=W3D(JJ)+A 270 CONTINUE NSTRMS=NKEEP XX1(1)=0.0 DO 280 LL=1,150 280 XX1(1)=XX1(1)+W3D(LL) DO 290 L=2,9 XX1(L)=0.0 DO 290 LL=1,150 290 XX1(L)=XX1(L)+R(LL)**(L-1)*W3D(LL) DO 330 L=1,9 DO 320 J=L,9 IF(J.EQ.1)GO TO 310 XX5(L,J)=0.0 DO 300 LL=1,150 300 XX5(L,J)=XX5(L,J)+R(LL)**(L+J-2) GO TO 320 310 XX5(1,1)=150 320 XX5(J,L)=XX5(L,J) 330 CONTINUE CALL ALG30(XX5,XX1) DO 340 J=1,NSTRMS 340 W(J)=(((((((XX1(9)*R2(J)+XX1(8))*R2(J)+XX1(7))*R2(J)+XX1(6))*R2(J) 1+XX1(5))*R2(J)+XX1(4))*R2(J)+XX1(3))*R2(J)+XX1(2))*R2(J)+XX1(1) RETURN END
c ===================================================================== c pgm: mrrcv (rdx,mpo,po) c c in: rdx .... array of 8-character identifiers c out: mpo .... maximum words in array po c in: po .... rainfall-runoff curve parameters c ===================================================================== c subroutine mrrcv (rdx,mpo,po) c c....................................................................... c c define parameters for rainfall-runoff curves c c....................................................................... c Initially written by c Tim Sweeney, HRL - March 1992 c....................................................................... c character cresp,resp,tent character*2 bname character*4 ddesc(5),bbid(2),desc(5) character*4 dtype,rdx(2,1) character*4 accmode character*8 ffgid c include 'ffg_inc/iuws' include 'ffg_inc/gdebug' c dimension ldur(5),rr(40) dimension po(*) C C ================================= RCS keyword statements ========== CHARACTER*68 RCSKW1,RCSKW2 DATA RCSKW1,RCSKW2 / ' .$Source: /fs/hseb/ob72/rfc/ffg/src/ffguid_init/RCS/mrrcv.f,v $ . $', ' .$Id: mrrcv.f,v 1.6 2004/09/13 14:23:54 scv Exp $ . $' / C =================================================================== C data ddesc/'ente','r de','scri','ptio','n '/ data ldur/1,3,6,12,24/ data bname/ ' ' / c c call prbug ('mrrcv',1,1,ibug) c npo = 57 c c maximum number of ffg rainfall-runoff files for a c new index file (times 2), if needed mxdx = 4000 c c get index file for ffg rainfall-runoff files dtype = 'ffg' call getidx (dtype,idxdv,mxdx,po,mr,rdx,istat) if (istat.ne.0) then write (iutw,10) dtype(1:lenstr(dtype)) if (iupr.ne.iutw) write (iupr,10) dtype(1:lenstr(dtype)) 10 format (' ERROR: cannot open file type ',a,'.') go to 330 endif ifirst = -1 c 20 write (iutw,30) 30 format (29x,'Rainfall Runoff Curves' /) c c display ffg area ids call dispid (resp,ifirst,mr,rdx) if (resp.eq.' ') then go to 320 else if (resp.eq.'A'.or.resp.eq.'a') then write (iutw,40) 40 format (' Add at number: ',$) read (iutr,50,err=20) num 50 format (i4) i = mr + 1 if (num.lt.0.or.num.gt.i) go to 20 else if (resp.eq.'C'.or.resp.eq.'c') then num = 0 go to 60 else go to 230 endif c 60 call typent (tent) jfun = 0 if (tent.eq.'f') go to 190 if (tent.eq.'m') go to 320 c c editor write (iutw,80) 80 format (' Enter FFG identifier: ',$) read (iutr,'(a)') ffgid c c read the file kod = 2 call rppfil (ffgid,dtype,kod,ipdv,mpo,po,npo,istat) if (istat.eq.0) then rewind (ipdv) call umemov (po(4),desc,5) call umemov (po(9),bbid,2) ndur = po(13) + 0.01 do 100 i=1,40 rr(i) = po(i+17) 100 continue else if (istat.eq.1) then c create new file - set default values istat = 0 do 110 i=1,5 desc(i) = ddesc(i) 110 continue kdur = 0 do 120 i=1,40 rr(i) = -99.0 120 continue else go to 20 endif c 130 write (iutw,140) desc,ndur 140 format (5x,'1 - Description: ',5a4 / + 5x,'2 - Duration flag: ',i2 ) call umemov (ffgid,bbid,2) ndur = kdur + 3 do 150 i=1,ndur itmx = i + 2 k = (i-1)*8 write (iutw,160) itmx,ldur(i),(rr(k+l),l=1,8) 150 continue 160 format (5x,i1,' - ',i2,'-hour rainfall-runoff curve:' / + 12x,4(2x,2f6.2)) write (iutw,170) 170 format (' Select: ',$) c read (iutr,180) it 180 format (i4) isl = 2 nperg = 2 if (it.eq.1) then call edvca (isl,iutw,5,desc) else if (it.eq.2) then call edvi (isl,iutw,ndur) else if (it.gt.2.and.it.le.itmx) then locrr = (it-3)*8 + 1 call edvrag (isl,iutr,iutw,rr(locrr),8,nperg,npr) else jfun = 1 go to 210 endif go to 130 c c ascii file input for add and change 190 write (iutw,200) 200 format (' ERROR: ASCII file input not found for rainfall ', + 'runoff curves.') go to 20 c fill po array 210 rvers = 1.0 po(1) = rvers call umemov (ffgid,po(2),2) call umemov (desc,po(4),5) call umemov (bbid,po(9),2) po(13) = kdur + 0.01 do 220 i=1,40 po(i+17) = rr(i) 220 continue c c write to file call wppfil (ipdv,npo,po,istat) call pstcod (istat,ffgid,dtype,ipdv) call upclos (ipdv,bname,ic) c c add identifier ffgid to index for ffg files call addidx (num,ffgid,rdx,mxdx,mr,istat) c if (jfun.eq.0) then if (num.gt.0) num = num + 1 go to 190 endif go to 20 c c delete 230 if (resp.ne.'D'.and.resp.ne.'d') go to 300 write (iutw,240) 240 format (' Delete rainfall runoff number: ',$) read (iutr,250) num 250 format (i4) if (num.lt.1.or.num.gt.mr) go to 20 write (iutw,260) 260 format (' Identifier: ',$) read (iutr,'(a)') ffgid write (iutw,280) 280 format (' Are you sure (y or n): ',$) read (iutr,290) cresp 290 format (a1) if (cresp.eq.'Y'.or.cresp.eq.'y') then c delete r-r curve call umemov (rdx(1,num),ffgid,2) accmode = 'rw' kod = 0 call fixopn (ffgid,dtype,bname,accmode,kod,ipdv,istat) close (ipdv,status='delete',iostat=iostat,err=292) write (iutw,291) ffgid(1:lenstr(ffgid)) 291 format (' NOTE: rainfall-runoff curve deleted for ', + 'identifier ',a,'.') c compress index file call subidx (num,mxdx,mr,rdx) go to 20 292 write (iutw,293) ffgid(1:lenstr(ffgid)),iostat 293 format (' ERROR: rainfall-runoff curve not deleted for ', + 'identifier ',a,'. iostat=',i2) go to 20 endif c c list rainfall runoff curves 300 if (resp.ne.'L'.and.resp.ne.'l') go to 20 write (iutw,310) 310 format (' Refer to NWSRFS to list rainfall runoff curves.' / + ' Enter <return> to continue.') read (iutr,290) cresp go to 20 c c store index array for rainfall runoff curves 320 call stridx (idxdv,mxdx,po,mr,rdx,dtype) c 330 return c end
Subroutine Get_SupportedDOFs(Sx,mSup,mQc1,mQc2,jCont,iOut) Implicit Real(kind=8) (a-h,o-z) !========================================================================================== include 'Drill.h' include 'Examples.h' include 'SizeVar.h' !========================================================================================== integer Sx Dimension Sx(mSup) !-------------------------------------------- for Check with Quintic SELECT CASE (nEx) CASE (1) ! PALAZOTTO:c0=0: Ex_1 call Get_SupportedDOFs_Pal(Sx,mSup,mQc1,mQc2,jCont,iOut) CASE (2) if(bDrill) then ! PALAZOTTO:c0=0.01: Ex_2 call Get_SupportedDOFs_Pal_D(Sx,mSup,mQc1,mQc2,jCont,iOut) else call Get_SupportedDOFs_Pal(Sx,mSup,mQc1,mQc2,jCont,iOut) endif CASE (3) ! 2D Str. Cantilever-TipMom:Ex_3 call Get_SupportedDOFs_Str(Sx,mSup,mQc1,mQc2,jCont,iOut) CASE (4) ! 3D Curved Cantilev.LINMOD:Ex_4 ! call Get_SupportedDOFs_LIN(Sx,mSup,nQc,jCont,iOut) CASE (5) ! 3D Curved Cantilev. Bathe:Ex_5 ! call Get_SupportedDOFs_Bat(Sx,mSup,nQc,jCont,iOut) CASE (6) ! 2D STr.Cantilev. ARGYRIS :Ex_6 ! call Get_SupportedDOFs_Bat(Sx,mSup,nQc,jCont,iOut) CASE (7:9) ! FALL THRO' other: Ex_7 return CASE (10) ! Hemisphere w/ hole Ex_10 if(nElem == 1) then call & Get_SupportedDOFs_Hem(Sx,mSup,mQc1,mQc2,jCont,iOut) elseif(nElem == 4) then call & Get_SupportedDOFs_Hem_4(Sx,mSup,mQc1,mQc2,jCont,iOut) endif CASE (11) ! Scodelis Low Ex_11 call Get_SupportedDOFs_Sco(Sx,mSup,mQc1,mQc2,jCont,iOut) CASE (12) ! 2D Str. Cantil-Tip Twist:Ex_12 if(bDrill) then call Get_SupportedDOFs_Str_TT_D & (Sx,mSup,mQc1,mQc2,jCont,iOut) else call Get_SupportedDOFs_Str_TT & (Sx,mSup,mQc1,mQc2,jCont,iOut) endif CASE DEFAULT return END SELECT ! ======================================================= return end
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11! subroutine extract_substr( String, mxCount,count,substr) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11! ! Purpose: to extract substring indicated "" ! Input: STRING a string ! Ouput: COUNT the number of substring found in the string ! SUBSTR the substring founded ! ! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! implicit none integer::i, index1, count, mxCount character *(*)::String character *(*)::substr dimension substr(mxCount) integer::curchar count=0 index1=0 i = 1 substr = "" do while(.true.) if( iachar(String(i:i)) .eq. curchar .and. index1.gt.0 ) then count = count + 1 substr(count)=string(index1:i-1) index1 = 0 else if(String(i:i) .eq. '"' .or. String(i:i).eq."'" )then index1 = i+1 curchar = iachar(String(i:i)) end if end if i=i+1 if(i .gt. len_trim(string) .or. count .ge. mxCount) then exit end if enddo return end subroutine extract_substr !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11! subroutine extract_subsymb(String, symb) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11! ! Purpose: to extract header symble of a string ! Input: STRING a string ! ! example: String = He3, output Symb = He ! ! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! implicit none integer i, j, n, flag character *(*)::String, Symb Symb = "" n = len(symb) flag = 0 j = 0 do i = 1, len_trim(String) !--- skip the space if(flag .le. 0) then if(String(I:I) .eq. ' ') cycle flag = 1 end if if((iachar(String(i:i)) .ge. iachar('A') .and. c iachar(String(i:i)) .le. iachar('Z')) .or. c (iachar(String(i:i)) .ge. iachar('a') .and. c iachar(String(i:i)) .le. iachar('z')) )then j = j + 1 Symb(j:j) = String(i:i) if(j .ge. n) exit cycle end if exit end do end subroutine extract_subsymb !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine extract_subnum(String, Sbn) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Purpose: to extract sub-string which is numberical characters ! Input: STRING a string ! ! example: String = He3, output Sbn = 3 ! ! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! implicit none integer i, j, n character *(*)::String, Sbn Sbn = "" n = len(Sbn) j = 0 do i = 1, len_trim(String) if( (iachar(String(i:i)).ge.iachar('0')) .and. c (iachar(String(i:i)).le.iachar('9')) ) then j = j + 1 Sbn(j:j) = String(i:i) if(j.ge.n) exit cycle end if if(j. gt. 0) then exit end if end do end subroutine extract_subnum
c-------------------------------------------------------------------------------------------------c program project_euler_108 c-------------------------------------------------------------------------------------------------c c c c In the following equation x, y, and n are positive integers. c c 1 1 1 c c - + - = - c c x y n c c c c For n = 4 there are exactly three distinct solutions: c c x=5, y=20 c c x=6, y=12 c c x=8, y=8 c c c c What is the least value of n for which the number of distinct solutions exceeds one-thousand? c c c c NOTE: This problem is an easier version of problem 110; it is strongly advised that you solve c c this one first. c c c c-------------------------------------------------------------------------------------------------c implicit none include 'euler.inc' c parameter used in this program only integer*8 n, nsq, x, y, num_solutions logical done c initialize some parameters done = .false. n = 1 do while(.not. done) num_solutions = 0 nsq = n**2 do x1=1,int(dsqrt(dble(nsq))) if (((nsq/x1)*x1).eq.nsq) then num_solutions = num_solutions + 1 c solution 1 x = n+x1 y = n+nsq/x1 c write(*,*) 'x=',x,' y=',y c solutions are positive integers so this isn't valid C c solution 2 C x = n-x1 C y = n-nsq/x1 C if ((x.ne.0).and.(y.ne.0)) then C num_solutions = num_solutions + 1 C write(*,*) 'x=',x,' y=',y C endif endif enddo if (num_solutions.gt.1000) then done = .true. write(*,*) 'Found it at n=',n endif write(*,*) n,num_solutions c read(*,*) n=n+1 enddo end
!Single Line Comment program commentyourcode Print *, "You should comment your code." end program commentyourcode
SUBROUTINE ZCLWAV(GRAT,ORDER,CARPOS,CAP,COEF,SAMPLE, $ DELTAS,NS,WAVE,ISTAT) * * Module number: * * Module name: ZCLWAV * * Keyphrase: * ---------- * Compute HRS wavelength array * Description: * ------------ * This routine computes the wavelengths by solving the * dispersion relation for wavelength using Newtons iterative * method. * * The dispersion relation is: * * s = a0 + a1*m*w + a2*m*m*w*w + a3*m + a4*w + * a5*m*m*w + a6*m*w*w + a7*m*m*m*w*w*w * * where: * m - spectral order * w - wavelength * a0,a1,... - dispersion coefficients * s - sample position computed by SAMPLE+(i-1)*DELTAS * where i is the data point number. * * FORTRAN name: zclwav.for * * Keywords of accessed files and tables: * -------------------------------------- * None * * Subroutines Called: * ------------------- * SDAS: * ZMSPUT * * History: * -------- * Version Date Author Description * 1 May 89 D. Lindler Designed and coded * 1.1 May 91 S. Hulbert Added cubic dispersion term * Change starting wavelength guess * Modify calling sequence to include * carpos * 1.2 Sep 91 S. Hulbert Bug fix for problem calculating "d" * 1.2.1 Feb 92 S. Hulbert Bug Fix--change datatype of "d" to * double precision * 1.3 Apr 94 J. Eisenhamer Removed hardwired constants related * wavelength guessing. *------------------------------------------------------------------------------- * * INPUTS: * * grat - grating mode * order - spectral order * coef - dispersion coefficients (8 of them, real*8) * sample - starting sample position * deltas - delta sample position * ns - number of data points * * OUTPUTS: * wave - wavelength vector (real*8) * istat - error status * *----------------------------------------------------------------------------- CHARACTER*5 GRAT INTEGER ORDER,CARPOS,NS,ISTAT DOUBLE PRECISION COEF(8),WAVE(1),CAP(2) REAL SAMPLE,DELTAS C C ZMSPUT DESTINATIONS -- CB, DAO, 4-SEP-87 C INTEGER STDOUT PARAMETER (STDOUT = 1) INTEGER STDERR PARAMETER (STDERR = 2) C C LOCAL VARIABLES C DOUBLE PRECISION S,W,DSDW,W2,MAXERR,SCOMP,A,B,C,D CHARACTER*80 CONTXT INTEGER M2,NITER,I,ITER C DATA NITER/20/ C --->maximum allowed number of iterations DATA MAXERR/0.001D0/ C --->maximum allowed error in sample units C C----------------------------------------------------------------------------- C C Check for valid spectral order C IF (((GRAT .EQ. 'ECH-A') .AND. ((ORDER .LT. 32) .OR. $ (ORDER .GT. 52))).OR. $ ((GRAT .EQ. 'ECH-B') .AND. ((ORDER .LT. 17) .OR. $ (ORDER .GT. 34))))THEN CONTXT='Invalid order number computed' GO TO 999 ENDIF C C Initialize starting guess C W = CAP(1)/ORDER*SIN((CAP(2)-CARPOS)/10430.378D0) C C convert disp. coef. to coefficients of w only C M2=ORDER*ORDER A = COEF(1) + COEF(4)*ORDER B = COEF(2)*ORDER + COEF(5) + COEF(6)*M2 C = COEF(3)*M2 + COEF(7)*ORDER D = COEF(8)*M2*ORDER C C Loop on data points C DO 1000 I=1,NS S=SAMPLE+(I-1)*DELTAS C C LOOP ON ITERATIONS C DO 100 ITER=1,NITER W2=W*W SCOMP = A + B*W + C*W2 + D*W2*W DSDW = B + 2.0*C*W + 3.0*D*W2 IF(DABS(DSDW).LT.1.0E-30) GO TO 120 W = W + (S-SCOMP)/DSDW IF(DABS(SCOMP-S).LT.MAXERR) GO TO 200 100 CONTINUE C C If we made it here, we did not converge C 120 CONTXT='Convergence Failure in the wavelength '// * 'computation' GO TO 999 C C converged. C 200 WAVE(I) = W 1000 CONTINUE ISTAT=0 GO TO 2000 C C error section C 999 DO 1500 I=1,NS WAVE(I)=0.0 1500 CONTINUE CALL ZMSPUT(CONTXT,STDOUT+STDERR,0,ISTAT) ISTAT=1 2000 RETURN END
double precision function Helm(x,d,idos) include 'P1' include 'dos.inc' include 'const.inc' integer idos,jlo,kl,klo,ku,mint double precision x,d,c2,c4,dx,dy,fein,sfac,u,v,xl,xu,y,yl,yu C Empirical low-T behavior of Sin double precision, parameter :: asin=23.594, bsin=6.1 C non-Empirical high-T behavior of F of Sin C parameter comes from difference between theta(0) and theta_i for the C sin dispersion relation (see notes) 8/30/01 double precision, parameter :: csin=0.188256 C Einstein + Taylor Series in d*x limit of the width of the Optic Continuum double precision, parameter :: dmin = 0.4 if (x .eq. 0.) then Helm = 0. return end if if (idos .eq. 5) then Helm = log(x) - 1./3. return end if mint = 4 sfac = (2./pirad)**3 if (idos .ne. 4) then call bserch(xa,na,x,jlo) klo = min(max(jlo-(mint-1)/2,1),na+1-mint) end if if (idos .eq. 1) go to 10 if (idos .eq. 2) go to 20 if (idos .eq. 3) go to 30 if (idos .eq. 4) go to 40 10 continue ! Debye call neville(xa(klo),deb3(klo),mint,x,y,dy) Helm = y + log(1. - exp(-x)) if (x .gt. xamax) Helm = -(pirad*pirad*pirad*pirad/15.)/(x*x*x) if (x .lt. xamin) Helm = log(x) - 4./3. & + 1.0 - (1.0 - deb2(imin))/xamin*x return 20 continue ! Einstein Helm = log(1. - exp(-x)) if (x .gt. xamax) Helm = - exp(-x) return 30 continue ! Sin call neville(xa(klo),sin3(klo),mint,x,y,dy) Helm = y + log(1. - exp(-x)) if (x .gt. xamax) Helm = -(pirad*pirad*pirad*pirad/15.)/(x*x*x)*sfac & - asin*x**(1. - bsin) if (x .lt. xamin) Helm = log(x) - 4./3. & + 1.0 - (1.0 - sin2(imin))/xamin*x & + csin return 40 continue ! Optic Continuum if (d .le. dmin) then dx = x*d/2. u = exp(-x) v = u/(1. - u) fein = log(1. - u) c2 = -2.*v - 2.*v*v c4 = -2.*v - 14.*v*v - 24.*v*v*v - 12.*v*v*v*v Helm = fein + c2*dx*dx/(2.*6.) + c4*dx*dx*dx*dx/(2.*120.) return end if xu = x*(1. + d/2.) xl = x*(1. - d/2.) call bserch(xa,na,xu,jlo) ku = min(max(jlo-(mint-1)/2,1),na+1-mint) call bserch(xa,na,xl,jlo) kl = min(max(jlo-(mint-1)/2,1),na+1-mint) call neville(xa(ku),opt3(ku),mint,xu,yu,dy) call neville(xa(kl),opt3(kl),mint,xl,yl,dy) if (xu .ne. 0.) yu = yu + log(1. - exp(-xu)) if (xl .ne. 0.) yl = yl + log(1. - exp(-xl)) if (xu .lt. xamin) yu = log(1. - exp(-xu)) & - (1.0 - (1.0 - opt2(imin))/xamin*xu) if (xl .lt. xamin) yl = log(1. - exp(-xl)) & - (1.0 - (1.0 - opt2(imin))/xamin*xl) if (xu .gt. xamax) yu = -(pirad*pirad/6.)/(xu) if (xl .gt. xamax) yl = -(pirad*pirad/6.)/(xl) if (xl .eq. 0.) yl = 0. if (xu .eq. 0.) yu = 0. Helm = (xu*yu - xl*yl)/(xu - xl) c print*, xu,yu,xl,yl return end
c This is the problem definition for the Two layer Burgers' equation: c PDE: u_t = eps*u_xx - u*u_x, with initial and boundary conditions c defined from the exact solution, defined as follows: c Let a1 = (-x + 0.5d0 - 4.95d0 * t) * 0.5d-1 / eps, c a2 = (-x + 0.5d0 - 0.75d0 * t) * 0.25d0 / eps, c a3 = (-x + 0.375d0) * 0.5 / eps, c expa1 = 0.d0, expa2 = 0.d0, expa3 = 0.d0, temp = max(a1, a2, a3). c if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) c if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) c if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) c Then c u = (0.1d0*expa1+0.5d0*expa2+expa3) / (expa1+expa2+expa3) c c This code uses loops to produce multiple independent copies of c the problem in order to artificially increase the computation c required, when npde > 1. c----------------------------------------------------------------------- subroutine f(t, x, u, ux, uxx, fval, npde) c----------------------------------------------------------------------- c purpose: c this subroutine defines the right hand side vector of the c npde dimensional parabolic partial differential equation c ut = f(t, x, u, ux, uxx). c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision x c the current spatial coordinate. c double precision u(npde) c u(1:npde) is the approximation of the c solution at the point (t,x). c double precision ux(npde) c ux(1:npde) is the approximation of the c spatial derivative of the solution at c the point (t,x). c double precision uxx(npde) c uxx(1:npde) is the approximation of the c second spatial derivative of the c solution at the point (t,x). c c output: double precision fval(npde) c fval(1:npde) is the right hand side c vector f(t, x, u, ux, uxx) of the pde. c----------------------------------------------------------------------- double precision eps common /burger/ eps c----------------------------------------------------------------------- c loop indices: integer i c----------------------------------------------------------------------- c c assign fval(1:npde) according to the right hand side of the pde c in terms of u(1:npde), ux(1:npde), uxx(1:npde). c do i = 1, npde fval(i) = eps*uxx(i) - u(i)*ux(i) end do c return end c----------------------------------------------------------------------- subroutine derivf(t, x, u, ux, uxx, dfdu, dfdux, dfduxx, npde) c----------------------------------------------------------------------- c purpose: c this subroutine is used to define the information about the c pde required to form the analytic jacobian matrix for the dae c or ode system. assuming the pde is of the form c ut = f(t, x, u, ux, uxx) c this routine returns the jacobians d(f)/d(u), d(f)/d(ux), and c d(f)/d(uxx). c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision x c the current spatial coordinate. c double precision u(npde) c u(1:npde) is the approximation of the c solution at the point (t,x). c double precision ux(npde) c ux(1:npde) is the approximation of the c spatial derivative of the solution at c the point (t,x). c double precision uxx(npde) c uxx(1:npde) is the approximation of the c second spatial derivative of the c solution at the point (t,x). c c output: double precision dfdu(npde,npde) c dfdu(i,j) is the partial derivative c of the i-th component of the vector f c with respect to the j-th component c of the unknown function u. c double precision dfdux(npde,npde) c dfdux(i,j) is the partial derivative c of the i-th component of the vector f c with respect to the j-th component c of the spatial derivative of the c unknown function u. c double precision dfduxx(npde,npde) c dfduxx(i,j) is the partial derivative c of the i-th component of the vector f c with respect to the j-th component c of the second spatial derivative of the c unknown function u. double precision eps common /burger/ eps c----------------------------------------------------------------------- c loop indices: integer i, j c----------------------------------------------------------------------- c c assign dfdu(1:npde,1:npde), dfdux(1:npde,1:npde), and c dfduxx(1:npde,1:npde) according to the right hand side of the pde c in terms of u(1:npde), ux(1:npde), uxx(1:npde). c do i = 1, npde do j = 1, npde dfdu(i,j) = 0.d0 dfdux(i,j) = 0.d0 dfduxx(i,j) = 0.d0 end do dfdu(i,i) = -ux(i) dfdux(i,i) = -u(i) dfduxx(i,i) = eps end do c return end c----------------------------------------------------------------------- subroutine bndxa(t, u, ux, bval, npde) c----------------------------------------------------------------------- c purpose: c the subroutine is used to define the boundary conditions at the c left spatial end point x = xa. c b(t, u, ux) = 0 c c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision u(npde) c u(1:npde) is the approximation of the c solution at the point (t,xa). c double precision ux(npde) c ux(1:npde) is the approximation of the c spatial derivative of the solution at c the point (t,xa). c c output: double precision bval(npde) c bval(1:npde) is the boundary contidition c at the left boundary point. c----------------------------------------------------------------------- double precision eps common /burger/ eps c----------------------------------------------------------------------- c c local variables double precision a1, a2, a3 double precision expa1, expa2, expa3 double precision temp c----------------------------------------------------------------------- c loop indices: integer i c----------------------------------------------------------------------- c a1 = (0.5d0 - 4.95d0 * t) * 0.5d-1 / eps a2 = (0.5d0 - 0.75d0 * t) * 0.25d0 / eps a3 = 0.1875d0 / eps expa1 = 0.d0 expa2 = 0.d0 expa3 = 0.d0 temp = max(a1, a2, a3) if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) do i = 1, npde bval(i) = u(i) - (0.1d0*expa1+0.5d0*expa2+expa3) & / (expa1+expa2+expa3) end do c return end c----------------------------------------------------------------------- subroutine bndxb(t, u, ux, bval, npde) c----------------------------------------------------------------------- c purpose: c the subroutine is used to define the boundary conditions at the c right spatial end point x = xb. c b(t, u, ux) = 0 c c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision u(npde) c u(1:npde) is the approximation of the c solution at the point (t,xb). c double precision ux(npde) c ux(1:npde) is the approximation of the c spatial derivative of the solution at c the point (t,xb). c c output: double precision bval(npde) c bval(1:npde) is the boundary contidition c at the right boundary point. c----------------------------------------------------------------------- double precision eps common /burger/ eps c----------------------------------------------------------------------- c c local variables double precision a1, a2, a3 double precision expa1, expa2, expa3 double precision temp c----------------------------------------------------------------------- c loop indices: integer i c----------------------------------------------------------------------- a1 = (-0.5d0 - 4.95d0 * t) * 0.5d-1 / eps a2 = (-0.5d0 - 0.75d0 * t) * 0.25d0 / eps a3 = - 0.3125d0 / eps expa1 = 0.d0 expa2 = 0.d0 expa3 = 0.d0 temp = max(a1, a2, a3) if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) do i = 1, npde bval(i) = u(i) - (0.1d0*expa1+0.5d0*expa2+expa3) & / (expa1+expa2+expa3) end do c return end c----------------------------------------------------------------------- subroutine difbxa(t, u, ux, dbdu, dbdux, dbdt, npde) c----------------------------------------------------------------------- c purpose: c the subroutine is used to define the differentiated boundary c conditions at the left spatial end point x = xa. for the c boundary condition equation c b(t, u, ux) = 0 c the partial derivatives db/du, db/dux, and db/dt are supplied c by this routine. c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision u(npde) c u(1:npde) is the approximation of the c solution at the point (t,x). c double precision ux(npde) c ux(1:npde) is the approximation of the c spatial derivative of the solution at c the point (t,x). c c output: double precision dbdu(npde,npde) c dbdu(i,j) is the partial derivative c of the i-th component of the vector b c with respect to the j-th component c of the unknown function u. c double precision dbdux(npde,npde) c dbdux(i,j) is the partial derivative c of the i-th component of the vector b c with respect to the j-th component c of the spatial derivative of the c unknown function u. c double precision dbdt(npde) c dbdt(i) is the partial derivative c of the i-th component of the vector b c with respect to time t. c c common variables: double precision eps common /burger/ eps c c local variables double precision a1, a2, a3 double precision expa1, expa2, expa3 double precision temp c----------------------------------------------------------------------- c loop indices: integer i, j c----------------------------------------------------------------------- c----------------------------------------------------------------------- a1 = (0.5d0 - 4.95d0 * t) * 0.5d-1 / eps a2 = (0.5d0 - 0.75d0 * t) * 0.25d0 / eps a3 = 0.1875d0 / eps expa1 = 0.d0 expa2 = 0.d0 expa3 = 0.d0 temp = max(a1, a2, a3) if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) c c assign dbdu(1:npde,1:npde), dbdu(1:npde,1:npde), and dbdt(1:npde) c according to the right boundary condition equation in terms of c u(1:npde), ux(1:npde), uxx(1:npde). c do i = 1, npde do j = 1, npde dbdu(i,j) = 0.0d0 dbdux(i,j) = 0.0d0 end do dbdu(i,i) = 1.0d0 dbdt(i) = -(0.24d-1*expa1*expa2 + 0.22275d0*expa1*expa3 & + 0.9375d-1*expa2*expa3) & /eps/(expa1+expa2+expa3)**2 end do c return end c----------------------------------------------------------------------- subroutine difbxb(t, u, ux, dbdu, dbdux, dbdt, npde) c----------------------------------------------------------------------- c purpose: c the subroutine is used to define the differentiated boundary c conditions at the right spatial end point 1 = xb. for the c boundary condition equation c b(t, u, ux) = 0 c the partial derivatives db/du, db/dux, and db/dt are supplied c by this routine. c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision u(npde) c u(1:npde) is the approximation of the c solution at the point (t,x). c double precision ux(npde) c ux(1:npde) is the approximation of the c spatial derivative of the solution at c the point (t,x). c c output: double precision dbdu(npde,npde) c dbdu(i,j) is the partial derivative c of the i-th component of the vector b c with respect to the j-th component c of the unknown function u. c double precision dbdux(npde,npde) c dbdux(i,j) is the partial derivative c of the i-th component of the vector b c with respect to the j-th component c of the spatial derivative of the c unknown function u. c double precision dbdt(npde) c dbdt(i) is the partial derivative c of the i-th component of the vector b c with respect to time t. c c common variables: double precision eps common /burger/ eps c c local variables double precision a1, a2, a3 double precision expa1, expa2, expa3 double precision temp c----------------------------------------------------------------------- c loop indices: integer i, j c----------------------------------------------------------------------- a1 = (-0.5d0 - 4.95d0 * t) * 0.5d-1 / eps a2 = (-0.5d0 - 0.75d0 * t) * 0.25d0 / eps a3 = - 0.3125d0 / eps expa1 = 0.d0 expa2 = 0.d0 expa3 = 0.d0 temp = max(a1, a2, a3) if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) c c assign dbdu(1:npde,1:npde), dbdu(1:npde,1:npde), and dbdt(1:npde) c according to the right boundary condition equation in terms of c u(1:npde), ux(1:npde), uxx(1:npde). c do i = 1, npde do j = 1, npde dbdu(i,j) = 0.0d0 dbdux(i,j) = 0.0d0 end do dbdu(i,i) = 1.0d0 dbdt(i) = -(0.24d-1*expa1*expa2 + 0.22275d0*expa1*expa3 * +0.9375d-1*expa2*expa3) * /eps/(expa1+expa2+expa3)**2 end do c return end c----------------------------------------------------------------------- subroutine uinit(x, u, npde) c----------------------------------------------------------------------- c purpose: c this subroutine is used to return the npde-vector of initial c conditions of the unknown function at the initial time t = t0 c at the spatial coordinate x. c----------------------------------------------------------------------- c subroutine parameters: c input: double precision x c the spatial coordinate. c integer npde c the number of pdes in the system. c c output: double precision u(npde) c u(1:npde) is vector of initial values of c the unknown function at t = t0 and the c given value of x. c----------------------------------------------------------------------- double precision eps common /burger/ eps c----------------------------------------------------------------------- c c local variables double precision a1, a2, a3 double precision expa1, expa2, expa3 double precision temp c----------------------------------------------------------------------- c loop indices: integer i c----------------------------------------------------------------------- c c assign u(1:npde) the initial values of u(t0,x). c c----------------------------------------------------------------------- a1 = (-x + 0.5d0) * 0.5d-1 / eps a2 = (-x + 0.5d0) * 0.25d0 / eps a3 = (-x + 0.375d0) * 0.5 / eps expa1 = 0.d0 expa2 = 0.d0 expa3 = 0.d0 temp = max(a1, a2, a3) if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) do i = 1, npde u(i) = (0.1d0*expa1+0.5d0*expa2+expa3) / (expa1+expa2+expa3) end do c return end c----------------------------------------------------------------------- subroutine truu(t, x, u, npde) c----------------------------------------------------------------------- c purpose: c this function provides the exact solution of the pde. c----------------------------------------------------------------------- c subroutine parameters: c input: integer npde c the number of pdes in the system. c double precision t c the current time coordinate. c double precision x c the current spatial coordinate. c c output: double precision u(npde) c u(1:npde) is the exact solution at the c point (t,x). c----------------------------------------------------------------------- double precision eps common /burger/ eps c----------------------------------------------------------------------- c c local variables double precision a1, a2, a3 double precision expa1, expa2, expa3 double precision temp c----------------------------------------------------------------------- c loop indices: integer i c----------------------------------------------------------------------- a1 = (-x + 0.5d0 - 4.95d0 * t) * 0.5d-1 / eps a2 = (-x + 0.5d0 - 0.75d0 * t) * 0.25d0 / eps a3 = (-x + 0.375d0) * 0.5 / eps expa1 = 0.d0 expa2 = 0.d0 expa3 = 0.d0 temp = max(a1, a2, a3) if ((a1-temp) .ge. -35.d0) expa1 = exp(a1-temp) if ((a2-temp) .ge. -35.d0) expa2 = exp(a2-temp) if ((a3-temp) .ge. -35.d0) expa3 = exp(a3-temp) do i = 1, npde u(i) = (0.1d0*expa1+0.5d0*expa2+expa3) / (expa1+expa2+expa3) end do c return end c----------------------------------------------------------------------- subroutine header(nout) c----------------------------------------------------------------------- c purpose: c this subroutine writes a header describing the npde dimensional c parabolic partial differential equation c ut = f(t, x, u, ux, uxx). c----------------------------------------------------------------------- c subroutine parameters: c input: integer nout c nout is the output unit number. c----------------------------------------------------------------------- c constants: double precision t0 parameter (t0 = 0.0d0) c double precision xa parameter (xa = 0.0d0) c double precision xb parameter (xb = 1.0d0) c----------------------------------------------------------------------- c write(nout,95) 'burgers'' equation:' write(nout,95) 'pde:' write(nout,95) ' u_t = eps * u_xx - u * u_x , ' write(nout,95) 'domain:' write(nout,96) ' t0 =', t0, ' < t,' write(nout,96) ' xa =', xa, ' <= x <= xb =', xb, ',' c return 95 format(a) 96 format(a,e13.5,a,e13.5,a,e13.5,a,e13.5,a) end
program epcsolver implicit none c * EPCSOLVER solves for SNe parameters [p1] and [p2] assuming that they c * depend on the [epc] coefficient c * { epc = p1 - p2 }. c * c * Benjamin Sadler, Florida State University 01/05/12 c * modified 051712: using [utail] (u)-band tail offset in variance calculation include 'epcs.h' character*3 pcsource character*6 name1(msne) character*13 name0(malpha) character*23 filename character*10 echar integer alpha,i,i1,i2,j,nsne,one real a(malpha,msne),c(msne,msne),d(msne,malpha),ecof(malpha), & oner,para(msne),v(msne,msne),w(msne),w1(msne,msne),zerr integer bin(60),ibin,k,nrec(malpha) real binwid,chi2_1(malpha),chi2_1t,chi2_2(malpha),chi2_2t,m1, & mepc(nstep),re(mrec),rm(mrec),rt(mrec),t1,tepc(nstep) real max12,min12 real utail(malpha),utailp(msne),secof,sutail integer nrec1(malpha) one = 1 oner = 1.0 zerr = 0.0 echar = "epcsolverx" c * import SNe names, [epc] coefficients, [utail] values * alpha = 0 open(unit=1,file='svd_u.fit') do i = 1, malpha read(1,100,end=5) name0(i),ecof(i),secof,utail(i),sutail alpha = alpha + 1 end do 5 continue close(1) c 100 format(4X,A13,29X,F6.3,4X,F6.3,11X,F6.3,4X,F5.3) c 100 format(4X,A13,29X,F8.3,11X,F8.3) 100 format(1X,A13,3X,F9.3,1X,F9.3,3X,F9.3,1X,F9.3) c * determine SNe names * nsne = (1 + int(sqrt(1.+8.*float(alpha))))/2 name1(1) = name0(1)(1:6) do i = 1, nsne-1 name1(i+1) = name0(i)(8:13) end do c * solve overdetermined system * a = 0.0 do i = 1, alpha do j = 1, nsne if(name0(i)(1:6).eq.name1(j)) i1 = j if(name0(i)(8:13).eq.name1(j)) i2 = j end do a(i,i1) = 1.0 a(i,i2) = -1.0 end do call svdcmp(a,alpha,nsne,malpha,msne,w,v) w1 = 0.0 do i = 1, nsne if(w(i).gt.(0.001)) then w1(i,i) = 1.0/w(i) else w1(i,i) = 0.0 end if end do call dgemm('n','n',nsne,nsne,nsne,oner,v,msne,w1,msne,zerr,c,msne) call dgemm('n','t',nsne,alpha,nsne,oner,c,msne,a,malpha,zerr,d, & msne) call dgemm('n','n',nsne,one,alpha,oner,d,msne,ecof,malpha,zerr, & para,msne) call dgemm('n','n',nsne,one,alpha,oner,d,msne,utail,malpha,zerr, & utailp,msne) c * output solution * open(unit=1,file='epc.par') do i = 1, nsne write(1,*) name1(i),para(i),utailp(i) end do close(1) c * save scaled {epc.dat} signals * open(unit=1,file='SDAT/mtl.x.gold') do i = 1, nstep read(1,*) tepc(i),mepc(i) end do close(1) do i = 1, alpha filename = scalsigpath // name0(i) // ".scal" open(unit=1,file=filename) do j = 1, nstep write(1,*) tepc(j),mepc(j)*ecof(i)+utail(i) end do close(1) end do c * load residuals and calculate X**2 variance * open(unit=1,file='pcsource.dat') read(1,*) pcsource close(1) chi2_1 = 0.0 chi2_2 = 0.0 chi2_1t = 0.0 chi2_2t = 0.0 nrec = 0 nrec1 = 0 do i = 1, alpha if(pcsource.eq."PCr") filename = "RSDL/" // name0(i) // ".rsdl" if(pcsource.eq."PCd") filename = "DIFL/" // name0(i) // ".difl" open(unit=1,file=filename) do j = 1, mrec read(1,*,end=10) rt(j),rm(j),re(j) nrec(i) = nrec(i) + 1 end do 10 continue close(1) do j = 1, nrec(i) if(rt(j).gt.(-4.09).and.rt(j).lt.(50.0)) then nrec1(i) = nrec1(i) + 1 chi2_1(i) = chi2_1(i) + ((rm(j)-utail(i))/re(j))**2 do k = 1, nstep if(tepc(k).gt.rt(j)) go to 15 end do 15 continue t1 = rt(j) call parrot(tepc,mepc,k,nstep,nstep,t1,m1,one,echar) chi2_2(i) = chi2_2(i) + ((rm(j)-m1*ecof(i)-utail(i))/re(j))**2 c write(*,*) name0(i),rm(j),m1*ecof(i) end if end do if(nrec1(i).eq.0) then write(*,*) "diff ",name0(i)," has no points!" pause end if chi2_1t = chi2_1t + chi2_1(i)/float(nrec1(i)) chi2_2t = chi2_2t + chi2_2(i)/float(nrec1(i)) end do write(*,'(A28,F7.2)') "Pre-EPC Residual Variance: ",chi2_1t write(*,'(A28,F9.2)') "Post-EPC Residual Variance: ",chi2_2t open(unit=1,file='epcvar.dat') do i = 1, alpha write(1,*) name0(i),chi2_1(i)/(float(nrec1(i))-1), & chi2_2(i)/float(nrec1(i)-1) end do close(1) c * calculate [ecof] histogram * min12 = 1000.0 max12 = -1000.0 do i = 1, alpha if(ecof(i).gt.max12) max12 = ecof(i) if(ecof(i).lt.min12) min12 = ecof(i) end do binwid = (max12-min12)/60.0 bin = 0 do i = 1, alpha ibin = int((ecof(i)-min12)/binwid) + 1 bin(ibin) = bin(ibin) + 1 end do open(unit=1,file='ecof.hist') do i = 1, 60 write(1,*) (min12-binwid/2.0)+float(i)*binwid,float(bin(i)) end do close(1) c * exit * end
c main code a=5 print *, 'a = ',a call nnsteps(a) print *, 'a = ',a stop end
program playf implicit logical (a-z) c Program to implement the classic "Playfair" cipher. c The key, which is to be read into the square sequentially c into each row from left to right, contains 26 letters. c Throughout the cipher, all occurrences of J are changed c to I. c c Plaintext on standard input; c Ciphertext on standard output. c Keyphrase prompted for on the console. c c Written by Mark Riordan 24 October 1987 integer alfsiz,gdchsz,linsiz,outsiz parameter(alfsiz=26,gdchsz=52,linsiz=80,outsiz=60) integer boxsiz,modp1 parameter(boxsiz=25) character alf*(alfsiz) character keyphr*80,cipalf*(alfsiz) character*60 infl,outfl character*1 outc(outsiz) character boxstr*(boxsiz),boxary(5,5) equivalence(boxstr,boxary) character*1 ch,newch,pch1,pch2,doubch,cch1,cch2 integer r1,r2,c1,c2 integer newr1,newr2,newc1,newc2 integer iadd,j,iout,jbox,i logical qeof,double,doit,encip c Query the user for key, encipher vs. decipher, and c input/output files. cc open(10,file='CON',status='UNKNOWN') write(*,9000) 9000 format(' Input the keyphrase:') read(*,8000) keyphr 8000 format(a) 80 continue write(*,9020) 9020 format(' Encipher (E) or Decipher (D) ?') read(*,8000) ch write(*,9030) 9030 format(' Input file (blank==terminal)?') read(*,8000) infl if(infl .eq. ' ') infl = 'con' write(*,9040) 9040 format(' Output file (blank==terminal)?') read(*,8000) outfl if(outfl .eq. ' ') outfl = 'con' open(1,file=infl,status='UNKNOWN') open(2,file=outfl,status='UNKNOWN') if(ch.eq.'e' .or. ch.eq.'E') then iadd = 1 encip = .true. else if(ch.eq.'d' .or. ch.eq.'D') then iadd = -1 encip = .false. else go to 80 endif c Make the cipher alphabet from the key phrase, and read it c into the box. Eliminate the character "J". call mksmpl(keyphr,cipalf) jbox = 0 do 120 j = 1, alfsiz if(cipalf(j:j) .ne. 'J') then jbox = jbox + 1 boxstr(jbox:jbox) = cipalf(j:j) endif 120 continue write(*,9080) ((boxary(i,j),i=1,5),j=1,5) 9080 format(' box = ',5a1,4(/7x,5a1)) qeof = .false. double = .false. doit = .true. iout = 0 c Do this loop once for each pair of plaintext letters. 200 continue c If we were processing a doubled letter last time, then c now return the second of these doubled letters as the c first input character of the current pair. if(double) then pch1 = doubch double = .false. else call getch(pch1,qeof) endif c If we reached a end of file on the first character, c then we have to decide whether we have any characters left c to process at all. We do have one only if the last pair was c was a double letter, in which case the second letter this c time is a Q. if(qeof) then if(double) then pch2 = 'Q' else doit = .false. endif else c Normal situation--no EOF, so get next character as second c plaintext character. c If EOF, set second plaintext to Q. c If first==second, then set second plaintext to Q, but c save the second letter for next time around. call getch(pch2,qeof) if(qeof) then pch2 = 'Q' else if(pch1 .eq. pch2) then doubch = pch2 pch2 = 'Q' double = .true. endif endif c We now have pch1==first plaintext character and c pch2==second plaintext character. Go ahead and do c the enciphering unless there was no input (doit==.false.) if(doit) then c Find the row and column of each of the two plaintext letters. c1 = mod(index(boxstr,pch1)-1,5)+1 r1 = ((index(boxstr,pch1)-1)/5)+1 c2 = mod(index(boxstr,pch2)-1,5)+1 r2 = ((index(boxstr,pch2)-1)/5)+1 c Now decide which of the three classic Playfair situations holds: c 1. Different row and column. c 2. Same row, different column. c 3. Same column, different row. cch1 = boxary(c2,r1) cch2 = boxary(c1,r2) if(r1 .eq. r2) then newc1 = modp1(c1+iadd,5) cch1 = boxary(newc1,r1) newc2 = modp1(c2+iadd,5) cch2 = boxary(newc2,r2) else if(c1 .eq. c2) then newr1 = modp1(r1+iadd,5) cch1 = boxary(c1,newr1) newr2 = modp1(r2+iadd,5) cch2 = boxary(c2,newr2) endif c Ciphertext letters in cch1 and cch2. Pack them into c the line "outc" and write the line if we fill it. outc(iout+1) = cch1 outc(iout+2) = cch2 iout = iout + 2 if(iout .ge. outsiz) then if(encip) then write(2,9200) (outc(j),j=1,iout) 9200 format(12(1x,5a1)) else write(2,9210) (outc(j),j=1,iout) 9210 format(1x,60a1) endif iout = 0 endif cc write(*,*) pch1,pch2,' yields ',cch1,cch2, cc + '; r1,c1,r2,c2=',r1,c1,r2,c2 endif c Loop until end-of-file. if(.not. qeof) go to 200 c Flush the output line "outc" if there's anything in it. if(iout .gt. 0) then if(encip) then write(2,9200) (outc(j),j=1,iout) else write(2,9210) (outc(j),j=1,iout) endif iout = 0 endif end subroutine getch(ch,qeof) c Return one character from the standard input. character ch*1 logical qeof integer gdchsz parameter(gdchsz=52) integer linsiz parameter (linsiz=80) logical qdig integer wchdig,idgch character gdinch*(gdchsz) character gdtrn*(gdchsz) character line*(linsiz),tch*1 character nums*10 character*6 alfdig(10) data gdinch/ + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'/ data gdtrn/ + 'ABCDEFGHIIKLMNOPQRSTUVWXYZABCDEFGHIIKLMNOPQRSTUVWXYZ'/ data nums/'0123456789'/ data alfdig/'ZERO','ONE','TWO','THREE','FOUR','FIVE','SIX', + 'SEVEN','EIGHT','NINE'/ data iptr/999/ 100 continue c If we are processing a previously-entered digit, return c the next letter of the spelled-out word version of the digit. c But if this character is a blank, we're at the end of the c word, so signal the end of this digit and go on to processing c the next character of input. if(qdig) then idgch = idgch + 1 ch = alfdig(wchdig)(idgch:idgch) if(ch .eq. ' ') then qdig = .false. else go to 999 endif endif c Get the next character in the line. iptr = iptr + 1 if(iptr .gt. linsiz) then read(1,8000,end=666) line 8000 format(a) iptr = 1 endif tch = line(iptr:iptr) c Check to make sure it's a legal input character. If so, c translate it and return it. idx = index(gdinch,tch) if(idx .ne. 0) then ch = gdtrn(idx:idx) else c Not an alphabetic character. Is it a digit? c If so, set up flags and then return the first letter of c the spelled-out version of the digit. wchdig = index(nums,tch) if(wchdig .ne. 0) then qdig = .true. idgch = 1 ch = alfdig(wchdig)(idgch:idgch) else go to 100 endif endif go to 999 666 continue qeof = .true. 999 continue cc write(*,*) 'getch returns ',ch,' qeof=',qeof return end subroutine mksmpl(line,outalf) c MKSMKY -- Make a simple-style (substitution) cipher alphabet. c c entry line is an input keyphrase c c exit outalf is the output key--the 26 letters c of the alphabet in the order prescribed c by the key. c This is simply the input keyphrase, with c duplicates removed, followed by the rest c of the alphabet. character line*(*),outalf*(*) integer alfsiz,gdchsz,linsiz parameter(alfsiz=26,gdchsz=52,linsiz=80) character gdinch*(gdchsz) character ch*1,newch*1 character gdtrn*(gdchsz),alf*(alfsiz) gdinch = 'abcdefghijklmnopqrstuvwxyz'// + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' gdtrn = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'// + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' alf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' jin = 0 jout = 0 c Go through this loop once for each input character. 100 continue jin = jin + 1 ch = line(jin:jin) jidx = index(gdinch,ch) c This key character is legal. Check to see if it is already c in the output key being generated. if(jidx .gt. 0) then newch = gdtrn(jidx:jidx) if(index(outalf,newch).eq.0) then jout = jout + 1 outalf(jout:jout) = newch endif endif if(jin .lt. linsiz) go to 100 c The input key phrase, minus duplicate characters, has been c copied to outalf. Now copy the rest of the alphabet. do 200 jch = 1, alfsiz ch = alf(jch:jch) if(index(outalf,ch) .eq. 0) then jout = jout + 1 outalf(jout:jout) = ch endif 200 continue end integer function modp1(num,modx) implicit logical(a-z) c MODP1 -- Compute "num" modulus "modx", except return c the result in the range 1:modx, rather than 0:(modx-1). c Also, negative results are adjusted to be in this range. integer num,modx integer ires ires = num - (num/modx)*modx 100 continue if(ires .le. 0) then ires = ires + modx go to 100 endif modp1 = ires end end