{"size":2135,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":" LOGICAL FUNCTION DSLECT( ZR, ZI )\n*\n* -- LAPACK test routine (version 3.1) --\n* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..\n* November 2006\n*\n* .. Scalar Arguments ..\n DOUBLE PRECISION ZI, ZR\n* ..\n*\n* Purpose\n* =======\n*\n* DSLECT returns .TRUE. if the eigenvalue ZR+sqrt(-1)*ZI is to be\n* selected, and otherwise it returns .FALSE.\n* It is used by DCHK41 to test if DGEES succesfully sorts eigenvalues,\n* and by DCHK43 to test if DGEESX succesfully sorts eigenvalues.\n*\n* The common block \/SSLCT\/ controls how eigenvalues are selected.\n* If SELOPT = 0, then DSLECT return .TRUE. when ZR is less than zero,\n* and .FALSE. otherwise.\n* If SELOPT is at least 1, DSLECT returns SELVAL(SELOPT) and adds 1\n* to SELOPT, cycling back to 1 at SELMAX.\n*\n* Arguments\n* =========\n*\n* ZR (input) DOUBLE PRECISION\n* The real part of a complex eigenvalue ZR + i*ZI.\n*\n* ZI (input) DOUBLE PRECISION\n* The imaginary part of a complex eigenvalue ZR + i*ZI.\n*\n* =====================================================================\n*\n* .. Arrays in Common ..\n LOGICAL SELVAL( 20 )\n DOUBLE PRECISION SELWI( 20 ), SELWR( 20 )\n* ..\n* .. Scalars in Common ..\n INTEGER SELDIM, SELOPT\n* ..\n* .. Common blocks ..\n COMMON \/ SSLCT \/ SELOPT, SELDIM, SELVAL, SELWR, SELWI\n* ..\n* .. Local Scalars ..\n INTEGER I\n DOUBLE PRECISION RMIN, X\n* ..\n* .. Parameters ..\n DOUBLE PRECISION ZERO\n PARAMETER ( ZERO = 0.0D0 )\n* ..\n* .. External Functions ..\n DOUBLE PRECISION DLAPY2\n EXTERNAL DLAPY2\n* ..\n* .. Executable Statements ..\n*\n IF( SELOPT.EQ.0 ) THEN\n DSLECT = ( ZR.LT.ZERO )\n ELSE\n RMIN = ZERO\n DO 10 I = 1, SELDIM\n X = DLAPY2( ZR-SELWR( I ), ZI-SELWI( I ) )\n IF( X.LE.RMIN ) THEN\n RMIN = X\n DSLECT = SELVAL( I )\n END IF\n 10 CONTINUE\n END IF\n RETURN\n*\n* End of DSLECT\n*\n END\n","avg_line_length":27.7272727273,"max_line_length":72,"alphanum_fraction":0.5236533958} {"size":2725,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"program matrix_reduce\nuse, intrinsic :: iso_fortran_env, only : output_unit, error_unit, &\n dp => REAL64\nuse :: mpi\nimplicit none\ninteger, parameter :: root = 0\ninteger :: rank, size, istat, ierr\ninteger :: nr_rows, nr_cols, nr_iters, iter, i, j\ncharacter(len=15) :: argv\nreal(kind=dp), allocatable, dimension(:, :) :: matrix, total_matrix\nreal(kind=dp) :: r, total\n\ncall MPI_Init(ierr)\ncall MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)\ncall MPI_Comm_size(MPI_COMM_WORLD, size, ierr)\n\n! get command line arguments, and broadcast them to all\nif (rank == root) then\n nr_rows = 5\n if (command_argument_count() >= 1) then\n call get_command_argument(1, argv)\n read (argv, '(I10)') nr_rows\n end if\n if (command_argument_count() >= 2) then\n call get_command_argument(2, argv)\n read (argv, '(I10)') nr_cols\n else\n nr_cols = nr_rows\n end if\n if (command_argument_count() >= 3) then\n call get_command_argument(3, argv)\n read (argv, '(I10)') nr_iters\n else\n nr_iters = 1\n end if\n write (unit=output_unit, fmt='(3(A, I10, \/))') &\n 'nr. rows: ', nr_rows, &\n 'nr. columns: ', nr_cols, &\n 'nr. iterations: ', nr_iters\nend if\ncall MPI_Bcast(nr_rows, 1, MPI_INTEGER, root, MPI_COMM_WORLD, ierr)\ncall MPI_Bcast(nr_cols, 1, MPI_INTEGER, root, MPI_COMM_WORLD, ierr)\ncall MPI_Bcast(nr_iters, 1, MPI_INTEGER, root, MPI_COMM_WORLD, ierr)\n\n! allocate matrix for each process\nallocate(matrix(nr_rows, nr_cols), stat=istat)\nif (istat \/= 0) then\n write (unit=error_unit, fmt='(A)'), 'can not allocate matrix'\n call MPI_Abort(MPI_COMM_WORLD, 1, ierr)\nend if\n\n! allocate and initialize matrix for the root process\nif (rank == root) then\n allocate(total_matrix(nr_rows, nr_cols), stat=istat)\n if (istat \/= 0) then\n write (unit=error_unit, fmt='(A)'), 'can not allocate total_matrix'\n call MPI_Abort(MPI_COMM_WORLD, 1, ierr)\n end if\nend if\n\ndo iter = 1, nr_iters\n call random_number(r)\n do j = 1, nr_cols\n do i = 1, nr_rows\n matrix(i, j) = 2*r + i + rank*(j - 1) + rank*size\n end do\n end do\n\n call MPI_Reduce(matrix, total_matrix, &\n nr_rows*nr_cols, MPI_DOUBLE_PRECISION, &\n MPI_SUM, root, MPI_COMM_WORLD, ierr)\n if (rank == root) then\n total = sum(total_matrix)\n write(unit=output_unit, fmt='(A, I5, F8.1)') &\n 'iteration', iter, total\n end if\nend do\n\nif (rank == root .and. nr_rows < 20 .and. nr_cols < 20) then\n do i = 1, nr_rows\n write (unit=output_unit, fmt='(*(F8.1))') total_matrix(i, :)\n end do\nend if\n\ncall MPI_Finalize(ierr)\n\nend program matrix_reduce\n","avg_line_length":30.9659090909,"max_line_length":75,"alphanum_fraction":0.6304587156} {"size":5556,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"C Copyright (c) 2007-2017 National Technology & Engineering Solutions of\nC Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with\nC NTESS, the U.S. Government retains certain rights in this software.\nC\nC Redistribution and use in source and binary forms, with or without\nC modification, are permitted provided that the following conditions are\nC met:\nC\nC * Redistributions of source code must retain the above copyright\nC notice, this list of conditions and the following disclaimer.\nC\nC * Redistributions in binary form must reproduce the above\nC copyright notice, this list of conditions and the following\nC disclaimer in the documentation and\/or other materials provided\nC with the distribution.\nC\nC * Neither the name of NTESS nor the names of its\nC contributors may be used to endorse or promote products derived\nC from this software without specific prior written permission.\nC\nC THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\nC \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nC LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nC A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nC OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nC SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nC LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nC DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nC THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\nC (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nC OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\nC\n\nC=======================================================================\n SUBROUTINE RWSTEP (NTXT, NDB, istep, idelb,\n & NVARGL, NVARNP, NUMNP, NVAREL, NELBLK, NUMELB,\n & ISEVOK, TIME, VAR, *)\nC=======================================================================\n\nC --*** RDSTEP *** (TXTEXO) Read database variables for one time step\nC -- Written by Amy Gilkey - revised 03\/02\/88\nC --\nC --RDSTEP reads the database history, global, nodal, and element variables\nC --for one time step.\nC --\nC --Parameters:\nC -- NTXT - IN - the text file\nC -- NVARGL - IN - the number of global variables\nC -- NVARNP - IN - the number of nodal variables\nC -- NUMNP - IN - the number of nodes\nC -- NVAREL - IN - the number of element variables\nC -- NELBLK - IN - the number of element blocks\nC -- NUMELB - IN - the number of elements per block\nC -- ISEVOK - IN - the element block variable truth table;\nC -- variable i of block j exists iff ISEVOK(j,i)\nC -- TIME - OUT - the time step time\nC -- VAR - OUT - the global variables for the time step\nC -- * - return statement if error encountered, including end-of-file;\nC -- message is printed\nC --\nC --Database must be positioned in front of time step upon entry;\nC --upon exit positioned after time step.\n\n INTEGER NUMELB(*)\n integer idelb(*)\n LOGICAL ISEVOK(NVAREL, *)\n REAL VAR(*)\n\n CHARACTER*32 STRA\n\nC --Read step time\n\n READ (NTXT, *, END=180, ERR=130)\n READ (NTXT, *, END=180, ERR=130) TIME\n call exptim(ndb, istep, time, ierr)\n\nC --Read global variables\n\n IF (NVARGL .GT. 0) THEN\n READ (NTXT, *, END=150, ERR=150)\n READ (NTXT, *, END=150, ERR=150) (VAR(I), I=1,NVARGL)\n call expgv(ndb, istep, nvargl, var, ierr)\n END IF\n\nC --Read nodal variables\n\n IF (NVARNP .GT. 0) THEN\n READ (NTXT, *, END=160, ERR=160)\n DO 100 INP = 1, NUMNP\n READ (NTXT, *, END=160, ERR=160)\n & (VAR(inp+(i-1)*numnp), I=1,NVARNP)\n 100 CONTINUE\n\n ioff = 1\n do 105 i=1, nvarnp\n call expnv(ndb, istep, i, numnp, var(ioff), ierr)\n ioff = ioff + numnp\n 105 continue\n END IF\n\nC --Read element variables\nC ... Values for all element variables are stored in text file\nC Read an element block at a time and then write that element block\n IF (NVAREL .GT. 0) THEN\nC ... Skip comment line\n READ (NTXT, *, END=170, ERR=170)\n DO 120 IELB = 1, NELBLK\nC ... Skip comment line\n READ (NTXT, *, END=170, ERR=170)\n READ (NTXT, *, END=170, ERR=170)\n DO 110 N = 1, NUMELB(IELB)\n READ (NTXT, *, END=170, ERR=170)\n & (VAR(N+(I-1)*numelb(ielb)), I=1,NVAREL)\n 110 CONTINUE\nC ... Write this blocks variables\n ioff = 1\n do 115 i=1, nvarel\n if (isevok(i,ielb)) then\n call expev(ndb, istep, i, idelb(ielb), numelb(ielb),\n & var(ioff), ierr)\n end if\n ioff = ioff + numelb(ielb)\n 115 continue\n 120 CONTINUE\n END IF\n\n RETURN\n\n 130 CONTINUE\n CALL PRTERR ('FATAL', 'Reading TIME STEP TIME')\n GOTO 180\n 150 CONTINUE\n CALL PRTERR ('FATAL', 'Reading GLOBAL VARIABLES')\n GOTO 180\n 160 CONTINUE\n CALL INTSTR (1, 0, INP, STRA, LSTRA)\n CALL PRTERR ('FATAL',\n & 'Reading NODAL VARIABLES for node ' \/\/ STRA(:LSTRA))\n GOTO 180\n 170 CONTINUE\n CALL INTSTR (1, 0, N, STRA, LSTRA)\n CALL PRTERR ('FATAL',\n & 'Reading ELEMENT VARIABLES for element ' \/\/ STRA(:LSTRA))\n GOTO 180\n 180 CONTINUE\n RETURN 1\n END\n","avg_line_length":37.5405405405,"max_line_length":77,"alphanum_fraction":0.6085313175} {"size":4618,"ext":"f","lang":"FORTRAN","max_stars_count":1.0,"content":"*\n* -------------------------------------------------------------\n* N O N R E L A T 3 1 \n* -------------------------------------------------------------\n* *\n* THIS PACKAGE DETERMINES THE VALUES OF MATRIX ELEMENTS *\n* OF TWO PARTICLE OPERATOR IN CASE : N'1 = N1 - 1 *\n* N'2 = N2 + 1 *\n* *\n* Written by G. Gaigalas, * \n* Vanderbilt University, Nashville February 1994 * \n*\n SUBROUTINE NONRELAT31(IA,IB,IIA,IIB,IIC,IID,IIRE)\n IMPLICIT DOUBLEPRECISION (A-H,O-Z)\n LOGICAL RECOUPLS0,CALCULATION\n COMMON\/CONSTS\/ZERO,TENTH,HALF,ONE,TWO,THREE,FOUR,SEVEN,ELEVEN,EPS\n COMMON\/MEDEFN\/IHSH,NJ(16),LJ(16),NOSH1(16),NOSH2(16),J1QN1(31,3),\n : J1QN2(31,3),IJFUL(16)\n COMMON\/DIAGNL\/IDIAG,JA,JB\n COMMON \/OPERAT\/ ICOLOM,ISOTOP,IORBORB\n COMMON\/TRK\/BD1(3),BD2(3),BK1(3),BK2(3),\n *ID1(7),ID2(7),IK1(7),IK2(7)\n IF(IHSH.LE.1)RETURN\n IF(IA.EQ.IB)RETURN\n IF(IA.LT.IB) THEN\n IAA=IA\n IBB=IB\n ELSE\n IAA=IB\n IBB=IA\n ENDIF\n IF(.NOT.RECOUPLS0(1,IAA,IBB,IBB,IBB,0))RETURN\n IF(.NOT.RECOUPLS0(2,IAA,IBB,IBB,IBB,1))RETURN\n IF(.NOT.RECOUPLS0(3,IAA,IBB,IBB,IBB,1))RETURN\n CALL RECOUPLS2(3,IAA,IBB,1,0,IAT,REC)\n IF(IAT.EQ.0)RETURN\n LIA2=LJ(IA)*2\n LIB2=LJ(IB)*2\n CALL RECOUPLS2(2,IAA,IBB,LIB2,0,IAT,REC)\n IF(IAT.EQ.0)RETURN\n CALL RECOUPLS2(3,IAA,IBB,1,1,IAT,RECS)\n CALL RECOUPLS2(2,IAA,IBB,LIB2,1,IAT,RECL)\n QM1=HALF\n QM2=-HALF\n A1=ZERO\n A2=ZERO\n LA=IJFUL(IAA)\n LB=IJFUL(IBB)\n CALL HIBFF(IA,IB,IA,IA,2)\n IF(LJ(IA).EQ.LJ(IB)) THEN\n CALL A1A2LS(IK1,IK2,BK1,BK2,ID1,ID2,BD1,BD2,QM2,QM1,WW)\n IF(DABS(WW).GT.EPS) THEN\n B=WW*RECL*RECS*HALF*DSQRT(DBLE(4*LJ(IA)+2))\n NN=0\n IB1=IBB-1\n DO 15 II=IAA,IB1\n NN=NOSH1(II)+NN\n 15 CONTINUE\n IF((NN\/2)*2.EQ.NN)B=-B\n IF(DABS(B).GT.EPS) CALL SAVENON(4,B,0,0,LA,0,LB,JA,JB,0)\n ENDIF\n ENDIF\n IF(IIRE.EQ.0)RETURN\nC\nC CASES 2111 + + - - TRANSFORM TO 1112 + - - +\nC 1211 1112 \nC\n LA=IJFUL(IIA)\n LB=IJFUL(IIB)\n LC=IJFUL(IIC)\n LD=IJFUL(IID)\n IP2=ITREXG(LJ(IA),LJ(IA),LJ(IA),LJ(IB),IKK)+1\n IF(IKK.LE.0)RETURN\n IG2=IP2+IKK-1\n DO 2 I2=IP2,IG2\n KL=I2-1\n\tIF(CALCULATION(KL)) THEN\n IF((ICOLOM+ISOTOP).EQ.1) \n : CALL COULOMBLS(LJ(IB),LJ(IA),LJ(IA),LJ(IA),KL,A1)\n IF(IORBORB.EQ.1) \n : CALL ORBITORBIT(LJ(IB),LJ(IA),LJ(IA),LJ(IA),KL+1,A2)\n IF((DABS(A1)+DABS(A2)).GT.EPS) THEN\n AB=ZERO\n DO 3 I3=IP2,IG2\n L12=I3-1\n IF(IXJTIK(LIB2,LIA2,KL*2,LIA2,LIA2,L12*2).NE.0) THEN\n\t AC=ZERO\n DO 4 I13=1,2\n JS12=I13-1\n IFAZ=L12+JS12\n IF((IFAZ\/2)*2.EQ.IFAZ) THEN\n CALL A1AW2LS(IK2,IK1,BK2,BK1,ID2,ID1,BD2,\n * BD1,L12,JS12,QM1,QM1,QM2,QM2,AD)\n AD=AD*DSQRT(DBLE(2*JS12+1))\n\t\t AC=AC+AD\n ENDIF\n 4 CONTINUE\n CALL SIXJ(LIB2,LIA2,KL*2,LIA2,LIA2,L12*2,0,SI)\n AA=AC*SI*DSQRT(DBLE(2*L12+1))\n IFAZ=KL+L12\n IF((IFAZ\/2)*2.NE.IFAZ)AA=-AA\n AB=AB+AA\n\t ENDIF\n 3 CONTINUE\n AB=-AB*RECL*RECS\n IF(DABS(AB).GT.EPS) THEN\n\t NN=0\n\t IB1=IBB-1\n DO 5 II=IAA,IB1\n\t NN=NOSH1(II)+NN\n 5 CONTINUE\n\t IF((NN\/2)*2.EQ.NN)AB=-AB\n\t ABB=AB\n IF((ICOLOM+ISOTOP).EQ.1) THEN\n IF(DABS(A1).GT.EPS) THEN\n AB=A1*AB\n CALL SAVENON(3,AB,KL,LA,LB,LC,LD,JA,JB,0)\n\t ENDIF\n\t ENDIF\nC Orbit 2111\n IF(IORBORB.EQ.1) THEN\n IF(DABS(A2).GT.EPS) THEN\n\t KLL=KL-1\n ABB=A2*ABB*HALF\/DSQRT(DBLE(2*KL+1))\n CALL SAVENON(9,ABB,KLL,LA,LB,LC,LD,JA,JB,0)\n CALL SAVENON(9,ABB,KLL,LB,LA,LD,LC,JA,JB,0)\nC WRITE(79,656) ABB,KLL,LJ(IA),LJ(IB),JA,JB\n 656 FORMAT(1X,'1221 O-O','AA=',F17.7,'K=',I3,'LA=',2I3,'JA=',I4,\n :'JB=',I4)\n END IF\n END IF\n\t ENDIF\n\t ENDIF\n\tENDIF\n 2 CONTINUE\n RETURN\n END\n","avg_line_length":33.4637681159,"max_line_length":71,"alphanum_fraction":0.4523603291} {"size":36687,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!\n! HOANG Danh Tai - Asia Pacific Center for Theoretical Physics, \n! Hogil Kim Memorial Building #501 POSTECH,\n! San 31, Hyoja-dong, Namgum, Pohang, Gyeongbuk 790-784, Korea.\n! Personal site: http:\/\/hoangdanhtai.com\n!-----------------------------------------------------------------------------------------!\n!!! Estimate parameter Jaa, Jab, Jbb from data\n!!! 16.6: Bo sung T, de chon gia tri E be nhat\n!!!! 17.6: Check xem neu dung ic la nearest neighbor thi co dung khong???\n!!!! 30.07: Sua lai doc experiment data tu thu muc\n!!! 06.08.2013: Xac dinh so neighbor bang mat, bo sung i0\n!!! 09.08.2013: Xac dinh nearest neighbor bang PP sap xep khoang cach tu be den lon\n!!! 25.08.2013: Su dung ic de so sanh la random \n!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! \n PROGRAM main_bio\n IMPLICIT NONE\n\n CHARACTER (LEN=3) :: SAt\n CHARACTER (LEN=150):: name_data,CONFIG_INI,FIND_NN\n CHARACTER (LEN=50) :: name\n CHARACTER (LEN=15) :: tmp\n CHARACTER (256) :: Ligne23,Ligne24\n REAL (KIND=8),PARAMETER :: nul=0.\n\n INTEGER (KIND=8):: i,j,n_cell,n_max,i_n,ic,S,i_Jbb,n_Jbb,i_Jab,n_Jab,number,i0,i0_n,k,i_n2\n INTEGER (KIND=8):: i_delN,i_loop,i_loop1,i_loop2,n_equi1,n_equi2,n_average,i_times,n_times\n INTEGER (KIND=8):: nn_total,nn_max,na,nb,n_T,i_T,ia,ib,n_min,nn_min,tmp2\n \n REAL (KIND=8):: r02,r2,n_cell_p,delT,T,Tmin,Tmax,rdn_config,r02max\n \n REAL (KIND=8):: energy,E1_old,E2_old,E1_new,E2_new,Naa,Nbb,Nab,H1a,H1b,H2a,H2b\n REAL (KIND=8):: Jaa,Jbb,Jab,del_Jbb,Jbbmax,Jbbmin,del_Jab,Jabmax,Jabmin\n REAL (KIND=8):: Sa_mtp,Sb_mtp,rdn_ic,rdn_mtp,Naa_av,Nbb_av,Nab_av\n REAL (KIND=8):: E_av,Nabc_total,delNabc,Naa0,Nbb0,Nab0,Nabc0_total\n REAL (KIND=8):: pi,alpha,alpha0,OA2,OB2,AB2,tmp1 \n\n INTEGER (KIND=8),DIMENSION(:),ALLOCATABLE :: nn,spin1,spin2,nn1\n INTEGER (KIND=8),DIMENSION(:,:),ALLOCATABLE :: name_in,a\n REAL (KIND=8),DIMENSION(:),ALLOCATABLE :: Sa,Sb,x,y,z,Sa0,Sb0\n REAL (KIND=8),DIMENSION(:,:),ALLOCATABLE :: delNabc_tab,r \n!!!=======================================================================================\n!!!=======================================================================================\n CALL system('rm -r config_ini_3D')\n CALL system('mkdir config_ini_3D')\n CALL system('rm -r config_3D')\n CALL system('mkdir config_3D')\n CALL system('rm *.dat*')\n \n CALL ini_rdm_number()\n CALL read_input_parameter()\n CALL open_data()\n \n ALLOCATE(x(n_cell),y(n_cell),z(n_cell))\n ALLOCATE(Sa(n_cell),Sb(n_cell))\n ALLOCATE(nn(n_cell))\n ALLOCATE(nn1(0:n_cell))\n ALLOCATE(delNabc_tab(n_Jbb,n_Jab))\n ALLOCATE(spin1(n_cell),spin2(n_cell))\n\n ALLOCATE(r(n_cell,0:n_cell))\n ALLOCATE(a(n_cell,0:n_cell))\n ALLOCATE(Sa0(n_cell),Sb0(n_cell))\n\n CALL read_data()\n \n IF (n_T==1) THEN\n delT=0.\n ELSE\n delT=(Tmax-Tmin)\/real(n_T-1)\n END IF\n\n IF (n_Jbb==1) THEN\n del_Jbb=0.\n ELSE\n del_Jbb=(Jbbmax-Jbbmin)\/real(n_Jbb-1)\n END IF\n \n IF (n_Jab==1) THEN\n del_Jab=0.\n ELSE\n del_Jab=(Jabmax-Jabmin)\/real(n_Jab-1)\n END IF\n\n n_cell_p=real(n_cell)+1.\n\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! ====== MAIN PROGRAM === MAIN PROGRAM === MAIN PROGRAM === MAIN PROGRAM ======\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n \n CALL write_config_ini_3D()\n CALL number_neighbor_ini()\n CALL nearest_neighbor()\n CALL number_interaction_ini()\n \n!!!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n!!! Doi voi i-consider (i0)\n IF (FIND_NN=='YES') THEN\n CALL neighbor_i0()\n WRITE(*,*)'Finish find NN of i0'\n END IF\n\n!!!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n OPEN(unit=21,file='average_thermal.dat')\n OPEN(unit=22,file='del_Nabc2_min.dat')\n OPEN(unit=23,file='energy.dat')\n OPEN(unit=24,file='E_times.dat') \n \n i_delN=0\n\n DO i_T=1,n_T\n WRITE(*,*)'i_T = ', i_T \n T=Tmin+delT*real(i_T-1)\n\n DO i_Jbb=1,n_Jbb\n WRITE(*,*)'i_Jbb=',i_Jbb\n Jbb=Jbbmin+del_Jbb*real(i_Jbb-1)\n \n DO i_Jab=1,n_Jab\n\n i_delN=i_delN+1\n !WRITE(*,*)'i_delN=',i_delN\n Jab=Jabmin+del_Jab*real(i_Jab-1)\n\n CALL load_config_ini()\n \n CALL average_thermal()\n \n !CALL value_thermal()\n \n !WRITE(*,*)'Naa=',Naa,'Nbb=',Nbb,'Nab=',Nab\n \n !CALL write_config_3D()\n\n delNabc_tab(i_Jbb,i_Jab)=delNabc\n\n END DO\n END DO\n END DO\n \n WRITE(22,'(2I5,5X,F16.3)')MINLOC(delNabc_tab),MINVAL(delNabc_tab)\n \n WRITE(*,*)Jbb,MINLOC(delNabc_tab),MINVAL(delNabc_tab)\n\n CLOSE(21)\n CLOSE(22)\n CLOSE(23)\n \n CONTAINS\n\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! Number nearest neighbor from experimental data\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n SUBROUTINE number_neighbor_ini()\n IMPLICIT NONE\n \n OPEN(unit=15,file='nn_i_cell.dat') \n \n !!!--------------------------------------------------------------\n !!! \n nn_total=0 ; nn(:)=0\n \n DO i=1,n_cell\n DO j=1,n_cell\n \n r2=(x(i)-x(j))**2.+(y(i)-y(j))**2.+(z(i)-z(j))**2.\n \n IF ((0.10) THEN\n \n !ic=0 \n !DO WHILE (int(Sa(ic)+Sb(ic))==0) \n !CALL random_number(rdn_ic)\n !j_ic=int(rdn_ic*real(nn(i)+1))\n !ic=name_in(i,j_ic)\n !END DO\n \n CALL value_H1()\n \n E1_old=-Sa(i)*(Jaa*H1a+Jab*H1b)-Sb(i)*(Jab*H1a+Jbb*H1b) \n\n!!======================================================================================== \n IF (int(Sa(i))\/=int(Sa(ic))) THEN \n\n CALL value_H2()\n E2_old=-Sa(ic)*(Jaa*H2a+Jab*H2b)-Sb(ic)*(Jab*H2a+Jbb*H2b)\n\n Sa_mtp=Sa(i) ; Sb_mtp=Sb(i)\n Sa(i)=Sa(ic) ; Sb(i)=Sb(ic)\n Sa(ic)=Sa_mtp ; Sb(ic)=Sb_mtp\n\n CALL value_H1()\n CALL value_H2() \n E1_new=-Sa(i)*(Jaa*H1a+Jab*H1b)-Sb(i)*(Jab*H1a+Jbb*H1b) \n E2_new=-Sa(ic)*(Jaa*H2a+Jab*H2b)-Sb(ic)*(Jab*H2a+Jbb*H2b)\n\n CALL random_number(rdn_mtp)\n\n IF (exp((E1_old+E2_old-E1_new-E2_new)\/T) > rdn_mtp) THEN\n E1_old=E1_new\n\n ELSE \n Sa(ic)=Sa(i) ; Sb(ic)=Sb(i)\n Sa(i)=Sa_mtp ; Sb(i)=Sb_mtp\n\n END IF\n\n END IF \n!!======================================================================================== \n !END IF\n \n END DO \n \n END SUBROUTINE equi_lattice \n\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! SUBROUTINE value_thermal()\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n SUBROUTINE value_thermal()\n IMPLICIT NONE\n \n energy=0. ; E1_old=0. ; E2_old=0. ; E1_new=0. ; E2_new=0.\n Naa=0. ; Nbb=0. ; Nab=0.\n\n DO i=1,n_cell\n \n !!! su dung ic bat ky\n ic=0 \n !DO WHILE (int(Sa(ic)+Sb(ic))==0)\n DO WHILE ((int(Sa(ic)+Sb(ic))==0).or.(int(Sa(ic))==int(Sa(i)))) \n\n CALL random_number(rdn_ic)\n ic=int(rdn_ic*n_cell_p)\n \n END DO\n !!!-----------------\n \n !IF (nn(i)>0) THEN\n \n !!! Su dung ic la neighbor cua i:\n !ic=0 \n !DO WHILE (int(Sa(ic)+Sb(ic))==0)\n \n !CALL random_number(rdn_ic)\n !j_ic=int(rdn_ic*real(nn(i)+1)) \n !ic=name_in(i,j_ic)\n\n !END DO \n\n\n !WRITE(*,*)'HAHHAHHHAHHH j_ic=',j_ic\n CALL value_H1()\n \n E1_old=-Sa(i)*(Jaa*H1a+Jab*H1b)-Sb(i)*(Jab*H1a+Jbb*H1b) \n\n!!======================================================================================== \n IF (int(Sa(i))\/=int(Sa(ic))) THEN \n\n CALL value_H2()\n E2_old=-Sa(ic)*(Jaa*H2a+Jab*H2b)-Sb(ic)*(Jab*H2a+Jbb*H2b)\n\n Sa_mtp=Sa(i) ; Sb_mtp=Sb(i)\n Sa(i)=Sa(ic) ; Sb(i)=Sb(ic)\n Sa(ic)=Sa_mtp ; Sb(ic)=Sb_mtp\n\n CALL value_H1()\n CALL value_H2() \n E1_new=-Sa(i)*(Jaa*H1a+Jab*H1b)-Sb(i)*(Jab*H1a+Jbb*H1b) \n E2_new=-Sa(ic)*(Jaa*H2a+Jab*H2b)-Sb(ic)*(Jab*H2a+Jbb*H2b)\n\n CALL random_number(rdn_mtp)\n\n IF (exp((E1_old+E2_old-E1_new-E2_new)\/T) > rdn_mtp) THEN\n E1_old=E1_new\n\n ELSE \n Sa(ic)=Sa(i) ; Sb(ic)=Sb(i)\n Sa(i)=Sa_mtp ; Sb(i)=Sb_mtp\n\n END IF\n\n END IF\n!!======================================================================================== \n \n energy=energy+E1_old\n\n !END IF\n \n END DO\n\n !!! Tinh Naa, Nbb, Nab : -----------------------------------\n DO i=1,n_cell\n CALL value_H1()\n Naa=Naa+Sa(i)*H1a ; Nbb=Nbb+Sb(i)*H1b ; Nab=Nab+Sa(i)*H1b+Sb(i)*H1a\n !!!-----------------------------------------------------\n END DO \n\n energy=energy\/2.\/n_cell\n\n Naa=Naa\/2. ; Nbb=Nbb\/2. ; Nab=Nab\/2.\n \n END SUBROUTINE value_thermal\n\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! SUBROUTINE average_thermal()\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n SUBROUTINE average_thermal()\n IMPLICIT NONE\n\n E_av=0.; Naa_av=0.; Nbb_av=0. ; Nab_av=0.\n\n DO i_times=1,n_times\n\n DO i_loop1=1,n_equi2\n CALL equi_lattice()\n END DO\n \n DO i_loop2=1,n_average\n CALL value_thermal() \n \n E_av=E_av+energy\n Naa_av=Naa_av+Naa ; Nbb_av=Nbb_av+Nbb ; Nab_av=Nab_av+Nab\n \n END DO\n\n WRITE(Ligne24,*) i_times,E_av\/real(i_times*n_average)\n WRITE(24,'(a)') trim(Ligne24)\n \n END DO\n\n E_av=E_av\/real(n_times*n_average)\n \n Naa_av=Naa_av\/real(n_times*n_average)\n Nbb_av=Nbb_av\/real(n_times*n_average)\n Nab_av=Nab_av\/real(n_times*n_average) \n \n Nabc_total=(Naa_av+Nbb_av+Nab_av)\n \n delNabc=(Naa0-Naa_av)**2.+(Nbb0-Nbb_av)**2.+(Nab0-Nab_av)**2.\n \n !WRITE(*,*)'Naa-av=',Naa_av,Nbb_av,Nab_av,Nabc_total\n \n WRITE(21,'(I3,2X,F8.4,2X,F8.4,2X,F8.4,2X,4F12.4,1X,F16.3)') &\n i_delN,Jaa,Jbb,Jab,Naa_av,Nbb_av,Nab_av,Nabc_total,delNabc\n \n WRITE(Ligne23,*) T,E_av\n WRITE(23,'(a)') trim(Ligne23)\n \n END SUBROUTINE average_thermal\n\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! SUBROUTINE init_rdm_number()\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n SUBROUTINE ini_rdm_number()\n IMPLICIT NONE\n\n INTEGER (KIND=8),DIMENSION(8) :: time\n INTEGER (KIND=8),DIMENSION(50) :: seed\n\n CALL DATE_AND_TIME(values=time) ! Get the current time\n seed(1) = time(4)*(360000*time(5) + 6000*time(6) + 100*time(7) + time(8))\n CALL RANDOM_SEED(PUT=seed)\n\n END SUBROUTINE ini_rdm_number \n \n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! OPEN the parameter from file \"parameter.in\"\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n SUBROUTINE read_input_parameter()\n IMPLICIT NONE\n CHARACTER (LEN=150) :: tamp\n OPEN(11,file='1parameter.in')\n \n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n READ(11, '(A30,(A10))') tamp, CONFIG_INI\n READ(11, '(A30,(A10))') tamp, FIND_NN\n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n READ(11, '(A30,(A10))') tamp, name_data\n READ(11, '(A30,(F12.6))') tamp, r02\n READ(11, '(A30,(F12.6))') tamp, r02max\n READ(11, '(A30,(I5))') tamp, i0\n READ(11, '(A30,(F12.6))') tamp, alpha0\n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n READ(11, '(A30,(F12.6))') tamp, Jaa\n READ(11, '(A50)') tamp\n READ(11, '(A30,(F12.6))') tamp, Jbbmin\n READ(11, '(A30,(F12.6))') tamp, Jbbmax\n READ(11, '(A30,(I5))') tamp, n_Jbb\n READ(11, '(A50)') tamp\n READ(11, '(A30,(F12.6))') tamp, Jabmin\n READ(11, '(A30,(F12.6))') tamp, Jabmax\n READ(11, '(A30,(I5))') tamp, n_Jab\n READ(11, '(A50)') tamp\n READ(11, '(A30,(F12.6))') tamp, Tmin\n READ(11, '(A30,(F12.6))') tamp, Tmax\n READ(11, '(A30,(I5))') tamp, n_T\n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n READ(11, '(A30,(I12))') tamp,n_equi1\n READ(11, '(A30,(I12))') tamp,n_equi2\n READ(11, '(A30,(I12))') tamp,n_average\n READ(11, '(A30,(I12))') tamp,n_times\n READ(11, '(A50)') tamp\n READ(11, '(A50)') tamp\n\n CLOSE(11) \n\n END SUBROUTINE read_input_parameter\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!!! Change config as random from data\n!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n SUBROUTINE load_config_ini()\n IMPLICIT NONE\n\n !!!==========================================================\n!!! Hinh dang ban dau nhu data goc\n IF (CONFIG_INI=='YES') THEN\n\n Sa(:)=0. ; Sb(:)=0.\n \n DO i=1,n_cell\n Sa(i)=Sa0(i)\n Sb(i)=Sb0(i)\n END DO\n\n END IF\n \n!!!========================================================== \n!!! Hinh dang ban dau bat ky\n IF (CONFIG_INI=='NO') THEN\n\n Sa(:)=0. ; Sb(:)=0.\n ia=0 ; ib=0\n \n DO WHILE (ia \\brief \\b CUNBDB5\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download CUNBDB5 + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE CUNBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,\n* LDQ2, WORK, LWORK, INFO )\n*\n* .. Scalar Arguments ..\n* INTEGER INCX1, INCX2, INFO, LDQ1, LDQ2, LWORK, M1, M2,\n* $ N\n* ..\n* .. Array Arguments ..\n* COMPLEX Q1(LDQ1,*), Q2(LDQ2,*), WORK(*), X1(*), X2(*)\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*>\\verbatim\n*>\n*> CUNBDB5 orthogonalizes the column vector\n*> X = [ X1 ]\n*> [ X2 ]\n*> with respect to the columns of\n*> Q = [ Q1 ] .\n*> [ Q2 ]\n*> The columns of Q must be orthonormal.\n*>\n*> If the projection is zero according to Kahan's \"twice is enough\"\n*> criterion, then some other vector from the orthogonal complement\n*> is returned. This vector is chosen in an arbitrary but deterministic\n*> way.\n*>\n*>\\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] M1\n*> \\verbatim\n*> M1 is INTEGER\n*> The dimension of X1 and the number of rows in Q1. 0 <= M1.\n*> \\endverbatim\n*>\n*> \\param[in] M2\n*> \\verbatim\n*> M2 is INTEGER\n*> The dimension of X2 and the number of rows in Q2. 0 <= M2.\n*> \\endverbatim\n*>\n*> \\param[in] N\n*> \\verbatim\n*> N is INTEGER\n*> The number of columns in Q1 and Q2. 0 <= N.\n*> \\endverbatim\n*>\n*> \\param[in,out] X1\n*> \\verbatim\n*> X1 is COMPLEX array, dimension (M1)\n*> On entry, the top part of the vector to be orthogonalized.\n*> On exit, the top part of the projected vector.\n*> \\endverbatim\n*>\n*> \\param[in] INCX1\n*> \\verbatim\n*> INCX1 is INTEGER\n*> Increment for entries of X1.\n*> \\endverbatim\n*>\n*> \\param[in,out] X2\n*> \\verbatim\n*> X2 is COMPLEX array, dimension (M2)\n*> On entry, the bottom part of the vector to be\n*> orthogonalized. On exit, the bottom part of the projected\n*> vector.\n*> \\endverbatim\n*>\n*> \\param[in] INCX2\n*> \\verbatim\n*> INCX2 is INTEGER\n*> Increment for entries of X2.\n*> \\endverbatim\n*>\n*> \\param[in] Q1\n*> \\verbatim\n*> Q1 is COMPLEX array, dimension (LDQ1, N)\n*> The top part of the orthonormal basis matrix.\n*> \\endverbatim\n*>\n*> \\param[in] LDQ1\n*> \\verbatim\n*> LDQ1 is INTEGER\n*> The leading dimension of Q1. LDQ1 >= M1.\n*> \\endverbatim\n*>\n*> \\param[in] Q2\n*> \\verbatim\n*> Q2 is COMPLEX array, dimension (LDQ2, N)\n*> The bottom part of the orthonormal basis matrix.\n*> \\endverbatim\n*>\n*> \\param[in] LDQ2\n*> \\verbatim\n*> LDQ2 is INTEGER\n*> The leading dimension of Q2. LDQ2 >= M2.\n*> \\endverbatim\n*>\n*> \\param[out] WORK\n*> \\verbatim\n*> WORK is COMPLEX array, dimension (LWORK)\n*> \\endverbatim\n*>\n*> \\param[in] LWORK\n*> \\verbatim\n*> LWORK is INTEGER\n*> The dimension of the array WORK. LWORK >= N.\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit.\n*> < 0: if INFO = -i, the i-th argument had an illegal value.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\ingroup complexOTHERcomputational\n*\n* =====================================================================\n SUBROUTINE CUNBDB5( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,\n $ LDQ2, WORK, LWORK, INFO )\n*\n* -- LAPACK computational routine --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n*\n* .. Scalar Arguments ..\n INTEGER INCX1, INCX2, INFO, LDQ1, LDQ2, LWORK, M1, M2,\n $ N\n* ..\n* .. Array Arguments ..\n COMPLEX Q1(LDQ1,*), Q2(LDQ2,*), WORK(*), X1(*), X2(*)\n* ..\n*\n* =====================================================================\n*\n* .. Parameters ..\n COMPLEX ONE, ZERO\n PARAMETER ( ONE = (1.0E0,0.0E0), ZERO = (0.0E0,0.0E0) )\n* ..\n* .. Local Scalars ..\n INTEGER CHILDINFO, I, J\n* ..\n* .. External Subroutines ..\n EXTERNAL CUNBDB6, XERBLA\n* ..\n* .. External Functions ..\n REAL SCNRM2\n EXTERNAL SCNRM2\n* ..\n* .. Intrinsic Function ..\n INTRINSIC MAX\n* ..\n* .. Executable Statements ..\n*\n* Test input arguments\n*\n INFO = 0\n IF( M1 .LT. 0 ) THEN\n INFO = -1\n ELSE IF( M2 .LT. 0 ) THEN\n INFO = -2\n ELSE IF( N .LT. 0 ) THEN\n INFO = -3\n ELSE IF( INCX1 .LT. 1 ) THEN\n INFO = -5\n ELSE IF( INCX2 .LT. 1 ) THEN\n INFO = -7\n ELSE IF( LDQ1 .LT. MAX( 1, M1 ) ) THEN\n INFO = -9\n ELSE IF( LDQ2 .LT. MAX( 1, M2 ) ) THEN\n INFO = -11\n ELSE IF( LWORK .LT. N ) THEN\n INFO = -13\n END IF\n*\n IF( INFO .NE. 0 ) THEN\n CALL XERBLA( 'CUNBDB5', -INFO )\n RETURN\n END IF\n*\n* Project X onto the orthogonal complement of Q\n*\n CALL CUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2, LDQ2,\n $ WORK, LWORK, CHILDINFO )\n*\n* If the projection is nonzero, then return\n*\n IF( SCNRM2(M1,X1,INCX1) .NE. ZERO\n $ .OR. SCNRM2(M2,X2,INCX2) .NE. ZERO ) THEN\n RETURN\n END IF\n*\n* Project each standard basis vector e_1,...,e_M1 in turn, stopping\n* when a nonzero projection is found\n*\n DO I = 1, M1\n DO J = 1, M1\n X1(J) = ZERO\n END DO\n X1(I) = ONE\n DO J = 1, M2\n X2(J) = ZERO\n END DO\n CALL CUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,\n $ LDQ2, WORK, LWORK, CHILDINFO )\n IF( SCNRM2(M1,X1,INCX1) .NE. ZERO\n $ .OR. SCNRM2(M2,X2,INCX2) .NE. ZERO ) THEN\n RETURN\n END IF\n END DO\n*\n* Project each standard basis vector e_(M1+1),...,e_(M1+M2) in turn,\n* stopping when a nonzero projection is found\n*\n DO I = 1, M2\n DO J = 1, M1\n X1(J) = ZERO\n END DO\n DO J = 1, M2\n X2(J) = ZERO\n END DO\n X2(I) = ONE\n CALL CUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,\n $ LDQ2, WORK, LWORK, CHILDINFO )\n IF( SCNRM2(M1,X1,INCX1) .NE. ZERO\n $ .OR. SCNRM2(M2,X2,INCX2) .NE. ZERO ) THEN\n RETURN\n END IF\n END DO\n*\n RETURN\n*\n* End of CUNBDB5\n*\n END\n\n","avg_line_length":26.6691176471,"max_line_length":112,"alphanum_fraction":0.5114419631} {"size":6232,"ext":"f","lang":"FORTRAN","max_stars_count":998.0,"content":"*> \\brief \\b DGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download DGETC2 + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE DGETC2( N, A, LDA, IPIV, JPIV, INFO )\n*\n* .. Scalar Arguments ..\n* INTEGER INFO, LDA, N\n* ..\n* .. Array Arguments ..\n* INTEGER IPIV( * ), JPIV( * )\n* DOUBLE PRECISION A( LDA, * )\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> DGETC2 computes an LU factorization with complete pivoting of the\n*> n-by-n matrix A. The factorization has the form A = P * L * U * Q,\n*> where P and Q are permutation matrices, L is lower triangular with\n*> unit diagonal elements and U is upper triangular.\n*>\n*> This is the Level 2 BLAS algorithm.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] N\n*> \\verbatim\n*> N is INTEGER\n*> The order of the matrix A. N >= 0.\n*> \\endverbatim\n*>\n*> \\param[in,out] A\n*> \\verbatim\n*> A is DOUBLE PRECISION array, dimension (LDA, N)\n*> On entry, the n-by-n matrix A to be factored.\n*> On exit, the factors L and U from the factorization\n*> A = P*L*U*Q; the unit diagonal elements of L are not stored.\n*> If U(k, k) appears to be less than SMIN, U(k, k) is given the\n*> value of SMIN, i.e., giving a nonsingular perturbed system.\n*> \\endverbatim\n*>\n*> \\param[in] LDA\n*> \\verbatim\n*> LDA is INTEGER\n*> The leading dimension of the array A. LDA >= max(1,N).\n*> \\endverbatim\n*>\n*> \\param[out] IPIV\n*> \\verbatim\n*> IPIV is INTEGER array, dimension(N).\n*> The pivot indices; for 1 <= i <= N, row i of the\n*> matrix has been interchanged with row IPIV(i).\n*> \\endverbatim\n*>\n*> \\param[out] JPIV\n*> \\verbatim\n*> JPIV is INTEGER array, dimension(N).\n*> The pivot indices; for 1 <= j <= N, column j of the\n*> matrix has been interchanged with column JPIV(j).\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit\n*> > 0: if INFO = k, U(k, k) is likely to produce overflow if\n*> we try to solve for x in Ax = b. So U is perturbed to\n*> avoid the overflow.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\ingroup doubleGEauxiliary\n*\n*> \\par Contributors:\n* ==================\n*>\n*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,\n*> Umea University, S-901 87 Umea, Sweden.\n*\n* =====================================================================\n SUBROUTINE DGETC2( N, A, LDA, IPIV, JPIV, INFO )\n*\n* -- LAPACK auxiliary routine --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n*\n* .. Scalar Arguments ..\n INTEGER INFO, LDA, N\n* ..\n* .. Array Arguments ..\n INTEGER IPIV( * ), JPIV( * )\n DOUBLE PRECISION A( LDA, * )\n* ..\n*\n* =====================================================================\n*\n* .. Parameters ..\n DOUBLE PRECISION ZERO, ONE\n PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )\n* ..\n* .. Local Scalars ..\n INTEGER I, IP, IPV, J, JP, JPV\n DOUBLE PRECISION BIGNUM, EPS, SMIN, SMLNUM, XMAX\n* ..\n* .. External Subroutines ..\n EXTERNAL DGER, DSWAP, DLABAD\n* ..\n* .. External Functions ..\n DOUBLE PRECISION DLAMCH\n EXTERNAL DLAMCH\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC ABS, MAX\n* ..\n* .. Executable Statements ..\n*\n INFO = 0\n*\n* Quick return if possible\n*\n IF( N.EQ.0 )\n $ RETURN\n*\n* Set constants to control overflow\n*\n EPS = DLAMCH( 'P' )\n SMLNUM = DLAMCH( 'S' ) \/ EPS\n BIGNUM = ONE \/ SMLNUM\n CALL DLABAD( SMLNUM, BIGNUM )\n*\n* Handle the case N=1 by itself\n*\n IF( N.EQ.1 ) THEN\n IPIV( 1 ) = 1\n JPIV( 1 ) = 1\n IF( ABS( A( 1, 1 ) ).LT.SMLNUM ) THEN\n INFO = 1\n A( 1, 1 ) = SMLNUM\n END IF\n RETURN\n END IF\n*\n* Factorize A using complete pivoting.\n* Set pivots less than SMIN to SMIN.\n*\n DO 40 I = 1, N - 1\n*\n* Find max element in matrix A\n*\n XMAX = ZERO\n DO 20 IP = I, N\n DO 10 JP = I, N\n IF( ABS( A( IP, JP ) ).GE.XMAX ) THEN\n XMAX = ABS( A( IP, JP ) )\n IPV = IP\n JPV = JP\n END IF\n 10 CONTINUE\n 20 CONTINUE\n IF( I.EQ.1 )\n $ SMIN = MAX( EPS*XMAX, SMLNUM )\n*\n* Swap rows\n*\n IF( IPV.NE.I )\n $ CALL DSWAP( N, A( IPV, 1 ), LDA, A( I, 1 ), LDA )\n IPIV( I ) = IPV\n*\n* Swap columns\n*\n IF( JPV.NE.I )\n $ CALL DSWAP( N, A( 1, JPV ), 1, A( 1, I ), 1 )\n JPIV( I ) = JPV\n*\n* Check for singularity\n*\n IF( ABS( A( I, I ) ).LT.SMIN ) THEN\n INFO = I\n A( I, I ) = SMIN\n END IF\n DO 30 J = I + 1, N\n A( J, I ) = A( J, I ) \/ A( I, I )\n 30 CONTINUE\n CALL DGER( N-I, N-I, -ONE, A( I+1, I ), 1, A( I, I+1 ), LDA,\n $ A( I+1, I+1 ), LDA )\n 40 CONTINUE\n*\n IF( ABS( A( N, N ) ).LT.SMIN ) THEN\n INFO = N\n A( N, N ) = SMIN\n END IF\n*\n* Set last pivots to N\n*\n IPIV( N ) = N\n JPIV( N ) = N\n*\n RETURN\n*\n* End of DGETC2\n*\n END\n","avg_line_length":26.8620689655,"max_line_length":111,"alphanum_fraction":0.5019255456} {"size":8555,"ext":"f","lang":"FORTRAN","max_stars_count":31.0,"content":" SUBROUTINE CTBT05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,\n $ LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS )\n*\n* -- LAPACK test routine (version 3.1) --\n* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..\n* November 2006\n*\n* .. Scalar Arguments ..\n CHARACTER DIAG, TRANS, UPLO\n INTEGER KD, LDAB, LDB, LDX, LDXACT, N, NRHS\n* ..\n* .. Array Arguments ..\n REAL BERR( * ), FERR( * ), RESLTS( * )\n COMPLEX AB( LDAB, * ), B( LDB, * ), X( LDX, * ),\n $ XACT( LDXACT, * )\n* ..\n*\n* Purpose\n* =======\n*\n* CTBT05 tests the error bounds from iterative refinement for the\n* computed solution to a system of equations A*X = B, where A is a\n* triangular band matrix.\n*\n* RESLTS(1) = test of the error bound\n* = norm(X - XACT) \/ ( norm(X) * FERR )\n*\n* A large value is returned if this ratio is not less than one.\n*\n* RESLTS(2) = residual from the iterative refinement routine\n* = the maximum of BERR \/ ( NZ*EPS + (*) ), where\n* (*) = NZ*UNFL \/ (min_i (abs(A)*abs(X) +abs(b))_i )\n* and NZ = max. number of nonzeros in any row of A, plus 1\n*\n* Arguments\n* =========\n*\n* UPLO (input) CHARACTER*1\n* Specifies whether the matrix A is upper or lower triangular.\n* = 'U': Upper triangular\n* = 'L': Lower triangular\n*\n* TRANS (input) CHARACTER*1\n* Specifies the form of the system of equations.\n* = 'N': A * X = B (No transpose)\n* = 'T': A'* X = B (Transpose)\n* = 'C': A'* X = B (Conjugate transpose = Transpose)\n*\n* DIAG (input) CHARACTER*1\n* Specifies whether or not the matrix A is unit triangular.\n* = 'N': Non-unit triangular\n* = 'U': Unit triangular\n*\n* N (input) INTEGER\n* The number of rows of the matrices X, B, and XACT, and the\n* order of the matrix A. N >= 0.\n*\n* KD (input) INTEGER\n* The number of super-diagonals of the matrix A if UPLO = 'U',\n* or the number of sub-diagonals if UPLO = 'L'. KD >= 0.\n*\n* NRHS (input) INTEGER\n* The number of columns of the matrices X, B, and XACT.\n* NRHS >= 0.\n*\n* AB (input) COMPLEX array, dimension (LDAB,N)\n* The upper or lower triangular band matrix A, stored in the\n* first kd+1 rows of the array. The j-th column of A is stored\n* in the j-th column of the array AB as follows:\n* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;\n* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).\n* If DIAG = 'U', the diagonal elements of A are not referenced\n* and are assumed to be 1.\n*\n* LDAB (input) INTEGER\n* The leading dimension of the array AB. LDAB >= KD+1.\n*\n* B (input) COMPLEX array, dimension (LDB,NRHS)\n* The right hand side vectors for the system of linear\n* equations.\n*\n* LDB (input) INTEGER\n* The leading dimension of the array B. LDB >= max(1,N).\n*\n* X (input) COMPLEX array, dimension (LDX,NRHS)\n* The computed solution vectors. Each vector is stored as a\n* column of the matrix X.\n*\n* LDX (input) INTEGER\n* The leading dimension of the array X. LDX >= max(1,N).\n*\n* XACT (input) COMPLEX array, dimension (LDX,NRHS)\n* The exact solution vectors. Each vector is stored as a\n* column of the matrix XACT.\n*\n* LDXACT (input) INTEGER\n* The leading dimension of the array XACT. LDXACT >= max(1,N).\n*\n* FERR (input) REAL array, dimension (NRHS)\n* The estimated forward error bounds for each solution vector\n* X. If XTRUE is the true solution, FERR bounds the magnitude\n* of the largest entry in (X - XTRUE) divided by the magnitude\n* of the largest entry in X.\n*\n* BERR (input) REAL array, dimension (NRHS)\n* The componentwise relative backward error of each solution\n* vector (i.e., the smallest relative change in any entry of A\n* or B that makes X an exact solution).\n*\n* RESLTS (output) REAL array, dimension (2)\n* The maximum over the NRHS solution vectors of the ratios:\n* RESLTS(1) = norm(X - XACT) \/ ( norm(X) * FERR )\n* RESLTS(2) = BERR \/ ( NZ*EPS + (*) )\n*\n* =====================================================================\n*\n* .. Parameters ..\n REAL ZERO, ONE\n PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )\n* ..\n* .. Local Scalars ..\n LOGICAL NOTRAN, UNIT, UPPER\n INTEGER I, IFU, IMAX, J, K, NZ\n REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM\n COMPLEX ZDUM\n* ..\n* .. External Functions ..\n LOGICAL LSAME\n INTEGER ICAMAX\n REAL SLAMCH\n EXTERNAL LSAME, ICAMAX, SLAMCH\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC ABS, AIMAG, MAX, MIN, REAL\n* ..\n* .. Statement Functions ..\n REAL CABS1\n* ..\n* .. Statement Function definitions ..\n CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )\n* ..\n* .. Executable Statements ..\n*\n* Quick exit if N = 0 or NRHS = 0.\n*\n IF( N.LE.0 .OR. NRHS.LE.0 ) THEN\n RESLTS( 1 ) = ZERO\n RESLTS( 2 ) = ZERO\n RETURN\n END IF\n*\n EPS = SLAMCH( 'Epsilon' )\n UNFL = SLAMCH( 'Safe minimum' )\n OVFL = ONE \/ UNFL\n UPPER = LSAME( UPLO, 'U' )\n NOTRAN = LSAME( TRANS, 'N' )\n UNIT = LSAME( DIAG, 'U' )\n NZ = MIN( KD, N-1 ) + 1\n*\n* Test 1: Compute the maximum of\n* norm(X - XACT) \/ ( norm(X) * FERR )\n* over all the vectors X and XACT using the infinity-norm.\n*\n ERRBND = ZERO\n DO 30 J = 1, NRHS\n IMAX = ICAMAX( N, X( 1, J ), 1 )\n XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )\n DIFF = ZERO\n DO 10 I = 1, N\n DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )\n 10 CONTINUE\n*\n IF( XNORM.GT.ONE ) THEN\n GO TO 20\n ELSE IF( DIFF.LE.OVFL*XNORM ) THEN\n GO TO 20\n ELSE\n ERRBND = ONE \/ EPS\n GO TO 30\n END IF\n*\n 20 CONTINUE\n IF( DIFF \/ XNORM.LE.FERR( J ) ) THEN\n ERRBND = MAX( ERRBND, ( DIFF \/ XNORM ) \/ FERR( J ) )\n ELSE\n ERRBND = ONE \/ EPS\n END IF\n 30 CONTINUE\n RESLTS( 1 ) = ERRBND\n*\n* Test 2: Compute the maximum of BERR \/ ( NZ*EPS + (*) ), where\n* (*) = NZ*UNFL \/ (min_i (abs(A)*abs(X) +abs(b))_i )\n*\n IFU = 0\n IF( UNIT )\n $ IFU = 1\n DO 90 K = 1, NRHS\n DO 80 I = 1, N\n TMP = CABS1( B( I, K ) )\n IF( UPPER ) THEN\n IF( .NOT.NOTRAN ) THEN\n DO 40 J = MAX( I-KD, 1 ), I - IFU\n TMP = TMP + CABS1( AB( KD+1-I+J, I ) )*\n $ CABS1( X( J, K ) )\n 40 CONTINUE\n IF( UNIT )\n $ TMP = TMP + CABS1( X( I, K ) )\n ELSE\n IF( UNIT )\n $ TMP = TMP + CABS1( X( I, K ) )\n DO 50 J = I + IFU, MIN( I+KD, N )\n TMP = TMP + CABS1( AB( KD+1+I-J, J ) )*\n $ CABS1( X( J, K ) )\n 50 CONTINUE\n END IF\n ELSE\n IF( NOTRAN ) THEN\n DO 60 J = MAX( I-KD, 1 ), I - IFU\n TMP = TMP + CABS1( AB( 1+I-J, J ) )*\n $ CABS1( X( J, K ) )\n 60 CONTINUE\n IF( UNIT )\n $ TMP = TMP + CABS1( X( I, K ) )\n ELSE\n IF( UNIT )\n $ TMP = TMP + CABS1( X( I, K ) )\n DO 70 J = I + IFU, MIN( I+KD, N )\n TMP = TMP + CABS1( AB( 1+J-I, I ) )*\n $ CABS1( X( J, K ) )\n 70 CONTINUE\n END IF\n END IF\n IF( I.EQ.1 ) THEN\n AXBI = TMP\n ELSE\n AXBI = MIN( AXBI, TMP )\n END IF\n 80 CONTINUE\n TMP = BERR( K ) \/ ( NZ*EPS+NZ*UNFL \/ MAX( AXBI, NZ*UNFL ) )\n IF( K.EQ.1 ) THEN\n RESLTS( 2 ) = TMP\n ELSE\n RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )\n END IF\n 90 CONTINUE\n*\n RETURN\n*\n* End of CTBT05\n*\n END\n","avg_line_length":33.9484126984,"max_line_length":72,"alphanum_fraction":0.4693161894} {"size":1926,"ext":"f90","lang":"FORTRAN","max_stars_count":28.0,"content":" Program zpotrs_example\n\n! ZPOTRS Example Program Text\n\n! Copyright (c) 2018, Numerical Algorithms Group (NAG Ltd.)\n! For licence see\n! https:\/\/github.com\/numericalalgorithmsgroup\/LAPACK_Examples\/blob\/master\/LICENCE.md\n\n! .. Use Statements ..\n Use lapack_example_aux, Only: nagf_file_print_matrix_complex_gen_comp\n Use lapack_interfaces, Only: zpotrf, zpotrs\n Use lapack_precision, Only: dp\n! .. Implicit None Statement ..\n Implicit None\n! .. Parameters ..\n Integer, Parameter :: nin = 5, nout = 6\n! .. Local Scalars ..\n Integer :: i, ifail, info, lda, ldb, n, nrhs\n Character (1) :: uplo\n! .. Local Arrays ..\n Complex (Kind=dp), Allocatable :: a(:, :), b(:, :)\n Character (1) :: clabs(1), rlabs(1)\n! .. Executable Statements ..\n Write (nout, *) 'ZPOTRS Example Program Results'\n! Skip heading in data file\n Read (nin, *)\n Read (nin, *) n, nrhs\n lda = n\n ldb = n\n Allocate (a(lda,n), b(ldb,nrhs))\n\n! Read A and B from data file\n\n Read (nin, *) uplo\n If (uplo=='U') Then\n Read (nin, *)(a(i,i:n), i=1, n)\n Else If (uplo=='L') Then\n Read (nin, *)(a(i,1:i), i=1, n)\n End If\n Read (nin, *)(b(i,1:nrhs), i=1, n)\n\n! Factorize A\n Call zpotrf(uplo, n, a, lda, info)\n\n Write (nout, *)\n Flush (nout)\n If (info==0) Then\n\n! Compute solution\n Call zpotrs(uplo, n, nrhs, a, lda, b, ldb, info)\n\n! Print solution\n\n! ifail: behaviour on error exit\n! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft\n ifail = 0\n Call nagf_file_print_matrix_complex_gen_comp('General', ' ', n, nrhs, &\n b, ldb, 'Bracketed', 'F7.4', 'Solution(s)', 'Integer', rlabs, &\n 'Integer', clabs, 80, 0, ifail)\n\n Else\n Write (nout, *) 'A is not positive definite'\n End If\n\n End Program\n","avg_line_length":29.1818181818,"max_line_length":90,"alphanum_fraction":0.559709242} {"size":1515,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"\n\nThe Department of Nutrition offers undergraduate Nutrition Major majors focusing on nutrition: Clinical Nutrition and Nutritional Science.\nIt is home to the http:\/\/ggnb.ucdavis.edu Graduate Group in Nutritional Biology, an interdepartmental graduate program that offers both graduate students masters and PhD degrees. The largest nutrition class in the country (Nutrition 10) is through the department.\n\nThe Department of Nutrition is internationally recognized for its contributions to the study of human nutrition. It is most notably a leader in the areas of developmental and child nutrition, international nutrition, control of food intake, and the influence of nutrition on the progression of chronic diseases. There are a large number of distinguished professors\n\n Some Faculty \n Judith S. Stern\n Liz Applegate\n http:\/\/en.wikipedia.org\/wiki\/MRC_Greenwood MRC Greenwood\n\nIf you are interested in participating in a research study (often you are compen$ated....), please go to their http:\/\/nutrition.ucdavis.edu\/clinical\/index.cfm website.\n\nRelated\/Affiliated Centers and Programs\n Western Human Nutrition Research Center\n http:\/\/picn.ucdavis.edu Program in International & Community Nutrition (PICN)\n http:\/\/ffhi.ucdavis.edu Foods for Health Institute\n http:\/\/efnep.ucdavis.edu Expanded Food and Nutrition Education Program (EFNEP)\n http:\/\/ajcn.org American Journal of Clinical Nutrition\n http:\/\/lactation.ucdavis.edu Human Lactation Center and the http:\/\/jhl.sagepub.com Journal of Human Lactation\n","avg_line_length":68.8636363636,"max_line_length":364,"alphanum_fraction":0.8092409241} {"size":5592,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":"!##############################################################################\n!# ****************************************************************************\n!# ccinitparamtriang <\/name>\n!# ****************************************************************************\n!#\n!# \n!# This module contains basic initialisation routines for CC2D:\n!# Initialisation of the parametrisation and the triangulations on all levels.\n!#\n!# 1.) cc_initParamTriang\n!# -> Read parametrisation, read triangulation, refine the mesh\n!#\n!# 2.) cc_doneParamTriang\n!# -> Remove the meshes of all levels from the heap\n!#\n!# <\/purpose>\n!##############################################################################\n\nmodule ccinitparamtriang\n\n use fsystem\n use storage\n use linearsolver\n use boundary\n use bilinearformevaluation\n use linearformevaluation\n use cubature\n use matrixfilters\n use vectorfilters\n use bcassembly\n use triangulation\n use spatialdiscretisation\n use coarsegridcorrection\n use spdiscprojection\n use nonlinearsolver\n use paramlist\n use statistics\n \n use collection\n use convection\n \n use ccbasic\n \n implicit none\n \ncontains\n\n ! ***************************************************************************\n\n!\n\n subroutine cc_initParamTriang (rproblem)\n \n!\n ! This routine initialises the parametrisation and triangulation of the\n ! domain. The corresponding .prm\/.tri files are read from disc and\n ! the triangulation is refined as described by the NLMIN\/NLMAX parameters\n ! from the INI\/DAT files.\n!<\/description>\n\n!\n ! A problem structure saving problem-dependent information.\n type(t_problem), intent(INOUT) :: rproblem\n!<\/inputoutput>\n\n!<\/subroutine>\n\n ! local variables\n integer :: i,ilvmin,ilvmax\n \n ! Variable for a filename:\n character(LEN=SYS_STRLEN) :: sString\n character(LEN=SYS_STRLEN) :: sPRMFile, sTRIFile\n type(t_timer) :: rtimer\n\n call stat_clearTimer(rtimer)\n call stat_startTimer(rtimer)\n\n ! Get min\/max level from the parameter file.\n !\n ! ilvmin receives the minimal level where to discretise for supporting\n ! the solution process.\n ! ilvmax receives the level where we want to solve.\n \n call parlst_getvalue_int (rproblem%rparamList,'CC-DISCRETISATION',&\n 'NLMIN',ilvmin,2)\n call parlst_getvalue_int (rproblem%rparamList,'CC-DISCRETISATION',&\n 'NLMAX',ilvmax,4)\n \n ! Get the .prm and the .tri file from the parameter list.\n ! note that parlst_getvalue_string returns us exactly what stands\n ! in the parameter file, so we have to apply READ to get rid of\n ! probable ''!\n call parlst_getvalue_string (rproblem%rparamList,'PARAMTRIANG',&\n 'sParametrisation',sString)\n read (sString,*) sPRMFile\n \n call parlst_getvalue_string (rproblem%rparamList,'PARAMTRIANG',&\n 'sMesh',sString)\n read (sString,*) sTRIFile\n \n ! Read in the parametrisation of the boundary and save it to rboundary.\n call boundary_read_prm(rproblem%rboundary, sPrmFile)\n \n ! Now read in the basic triangulation.\n call tria_readTriFile2D (rproblem%RlevelInfo(rproblem%NLMIN)%rtriangulation, &\n sTRIFile, rproblem%rboundary)\n\n ! Refine the mesh up to the minimum level\n call tria_quickRefine2LevelOrdering(rproblem%NLMIN-1,&\n rproblem%RlevelInfo(rproblem%NLMIN)%rtriangulation,rproblem%rboundary)\n\n ! Create information about adjacencies and everything one needs from\n ! a triangulation. Afterwards, we have the coarse mesh.\n call tria_initStandardMeshFromRaw (&\n rproblem%RlevelInfo(rproblem%NLMIN)%rtriangulation,rproblem%rboundary)\n \n ! Now, refine to level up to nlmax.\n do i=rproblem%NLMIN+1,rproblem%NLMAX\n call tria_refine2LevelOrdering (rproblem%RlevelInfo(i-1)%rtriangulation,&\n rproblem%RlevelInfo(i)%rtriangulation, rproblem%rboundary)\n call tria_initStandardMeshFromRaw (rproblem%RlevelInfo(i)%rtriangulation,&\n rproblem%rboundary)\n end do\n \n ! Compress the level hierarchy.\n ! Share the vertex coordinates of all levels, so the coarse grid coordinates\n ! are 'contained' in the fine grid coordinates. The effect is:\n ! 1.) Save some memory\n ! 2.) Every change in the fine grid coordinates also affects the coarse\n ! grid coordinates and vice versa.\n do i=rproblem%NLMAX-1,rproblem%NLMIN,-1\n call tria_compress2LevelOrdHierarchy (rproblem%RlevelInfo(i+1)%rtriangulation,&\n rproblem%RlevelInfo(i)%rtriangulation)\n end do\n \n ! Gather statistics\n call stat_stopTimer(rtimer)\n rproblem%rstatistics%dtimeGridGeneration = &\n rproblem%rstatistics%dtimeGridGeneration + rtimer%delapsedReal\n\n end subroutine\n\n ! ***************************************************************************\n\n!\n\n subroutine cc_doneParamTriang (rproblem)\n \n!\n ! Releases the triangulation and parametrisation from the heap.\n!<\/description>\n\n!\n ! A problem structure saving problem-dependent information.\n type(t_problem), intent(INOUT), target :: rproblem\n!<\/inputoutput>\n\n!<\/subroutine>\n\n ! local variables\n integer :: i\n\n ! Release the triangulation on all levels\n do i=rproblem%NLMAX,rproblem%NLMIN,-1\n call tria_done (rproblem%RlevelInfo(i)%rtriangulation)\n end do\n \n ! Finally release the domain.\n call boundary_release (rproblem%rboundary)\n \n end subroutine\n\nend module\n","avg_line_length":31.9542857143,"max_line_length":85,"alphanum_fraction":0.6462804006} {"size":1900,"ext":"f90","lang":"FORTRAN","max_stars_count":13.0,"content":"subroutine volume_jacobian_wrap(u, v, w, tu, tv, tw, ku, kv, kw, nctlu, nctlv, nctlw, &\n nu, nv, nw, vals, row_ptr, col_ind)\n use precision\n implicit none\n\n ! Input\n integer , intent(in) :: ku, kv, kw, nctlu, nctlv, nctlw, nu, nv, nw\n real(kind=realType), intent(in) :: u(nw, nv, nu), v(nw, nv, nu), w(nw, nv, nu)\n real(kind=realType), intent(in) :: tu(nctlu+ku), tv(nctlv+kv), tw(nctlw+kw)\n\n ! Output\n real(kind=realType), intent(out) :: vals(nu*nv*nw*ku*kv*kw)\n integer , intent(out) :: col_ind(nu*nv*nw*ku*kv*kw), row_ptr(nu*nv*nw+1)\n\n ! Working\n real(kind=realType) :: basisu(ku), basisv(kv), basisw(kw)\n integer :: i, j, k, ii, jj, kk, counter, c1, c2\n integer :: ileftu, ileftv, ileftw\n\n counter = 1\n do i=1, nu\n do j = 1, nv\n do k=1, nw\n ! U \n call findSpan(u(k, j, i), ku, tu, nctlu, ileftu)\n call basis(tu, nctlu, ku, u(k, j, i), ileftu, basisu)\n\n ! V\n call findSpan(v(k, j, i), kv, tv, nctlv, ileftv)\n call basis(tv, nctlv, kv, v(k, j, i), ileftv, basisv)\n\n ! W\n call findSpan(w(k, j, i), kw, tw, nctlw, ileftw)\n call basis(tw, nctlw, kw, w(k, j, i), ileftw, basisw)\n\n row_ptr( (i-1)*nv*nw + (j-1)*nw + k ) = counter-1\n do ii=1, ku\n c1 = (ileftu-ku+ii-1)*Nctlv*Nctlw\n do jj = 1, kv\n c2 = (ileftv-kv+jj-1)*Nctlw\n do kk=1, kw\n col_ind(counter) = c1 + c2 + (ileftw-kw+kk-1)\n vals(counter) = basisu(ii)*basisv(jj)*basisw(kk)\n counter = counter + 1\n end do\n end do\n end do\n end do\n end do\n end do\n row_ptr(nu*nv*nw+1) = counter-1\n\nend subroutine volume_jacobian_wrap\n","avg_line_length":35.1851851852,"max_line_length":89,"alphanum_fraction":0.4852631579} {"size":28808,"ext":"f","lang":"FORTRAN","max_stars_count":2.0,"content":" SUBROUTINE SLARRE( RANGE, N, VL, VU, IL, IU, D, E, E2,\n $ RTOL1, RTOL2, SPLTOL, NSPLIT, ISPLIT, M,\n $ W, WERR, WGAP, IBLOCK, INDEXW, GERS, PIVMIN,\n $ WORK, IWORK, INFO )\n IMPLICIT NONE\n*\n* -- LAPACK auxiliary routine (version 3.2) --\n* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..\n* November 2006\n*\n* .. Scalar Arguments ..\n CHARACTER RANGE\n INTEGER IL, INFO, IU, M, N, NSPLIT\n REAL PIVMIN, RTOL1, RTOL2, SPLTOL, VL, VU\n* ..\n* .. Array Arguments ..\n INTEGER IBLOCK( * ), ISPLIT( * ), IWORK( * ),\n $ INDEXW( * )\n REAL D( * ), E( * ), E2( * ), GERS( * ),\n $ W( * ),WERR( * ), WGAP( * ), WORK( * )\n* ..\n*\n* Purpose\n* =======\n*\n* To find the desired eigenvalues of a given real symmetric\n* tridiagonal matrix T, SLARRE sets any \"small\" off-diagonal\n* elements to zero, and for each unreduced block T_i, it finds\n* (a) a suitable shift at one end of the block's spectrum,\n* (b) the base representation, T_i - sigma_i I = L_i D_i L_i^T, and\n* (c) eigenvalues of each L_i D_i L_i^T.\n* The representations and eigenvalues found are then used by\n* SSTEMR to compute the eigenvectors of T.\n* The accuracy varies depending on whether bisection is used to\n* find a few eigenvalues or the dqds algorithm (subroutine SLASQ2) to\n* conpute all and then discard any unwanted one.\n* As an added benefit, SLARRE also outputs the n\n* Gerschgorin intervals for the matrices L_i D_i L_i^T.\n*\n* Arguments\n* =========\n*\n* RANGE (input) CHARACTER\n* = 'A': (\"All\") all eigenvalues will be found.\n* = 'V': (\"Value\") all eigenvalues in the half-open interval\n* (VL, VU] will be found.\n* = 'I': (\"Index\") the IL-th through IU-th eigenvalues (of the\n* entire matrix) will be found.\n*\n* N (input) INTEGER\n* The order of the matrix. N > 0.\n*\n* VL (input\/output) REAL \n* VU (input\/output) REAL \n* If RANGE='V', the lower and upper bounds for the eigenvalues.\n* Eigenvalues less than or equal to VL, or greater than VU,\n* will not be returned. VL < VU.\n* If RANGE='I' or ='A', SLARRE computes bounds on the desired\n* part of the spectrum.\n*\n* IL (input) INTEGER\n* IU (input) INTEGER\n* If RANGE='I', the indices (in ascending order) of the\n* smallest and largest eigenvalues to be returned.\n* 1 <= IL <= IU <= N.\n*\n* D (input\/output) REAL array, dimension (N)\n* On entry, the N diagonal elements of the tridiagonal\n* matrix T.\n* On exit, the N diagonal elements of the diagonal\n* matrices D_i.\n*\n* E (input\/output) REAL array, dimension (N)\n* On entry, the first (N-1) entries contain the subdiagonal\n* elements of the tridiagonal matrix T; E(N) need not be set.\n* On exit, E contains the subdiagonal elements of the unit\n* bidiagonal matrices L_i. The entries E( ISPLIT( I ) ),\n* 1 <= I <= NSPLIT, contain the base points sigma_i on output.\n*\n* E2 (input\/output) REAL array, dimension (N)\n* On entry, the first (N-1) entries contain the SQUARES of the\n* subdiagonal elements of the tridiagonal matrix T;\n* E2(N) need not be set.\n* On exit, the entries E2( ISPLIT( I ) ),\n* 1 <= I <= NSPLIT, have been set to zero\n*\n* RTOL1 (input) REAL \n* RTOL2 (input) REAL \n* Parameters for bisection.\n* An interval [LEFT,RIGHT] has converged if\n* RIGHT-LEFT.LT.MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) )\n*\n* SPLTOL (input) REAL \n* The threshold for splitting.\n*\n* NSPLIT (output) INTEGER\n* The number of blocks T splits into. 1 <= NSPLIT <= N.\n*\n* ISPLIT (output) INTEGER array, dimension (N)\n* The splitting points, at which T breaks up into blocks.\n* The first block consists of rows\/columns 1 to ISPLIT(1),\n* the second of rows\/columns ISPLIT(1)+1 through ISPLIT(2),\n* etc., and the NSPLIT-th consists of rows\/columns\n* ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N.\n*\n* M (output) INTEGER\n* The total number of eigenvalues (of all L_i D_i L_i^T)\n* found.\n*\n* W (output) REAL array, dimension (N)\n* The first M elements contain the eigenvalues. The\n* eigenvalues of each of the blocks, L_i D_i L_i^T, are\n* sorted in ascending order ( SLARRE may use the\n* remaining N-M elements as workspace).\n*\n* WERR (output) REAL array, dimension (N)\n* The error bound on the corresponding eigenvalue in W.\n*\n* WGAP (output) REAL array, dimension (N)\n* The separation from the right neighbor eigenvalue in W.\n* The gap is only with respect to the eigenvalues of the same block\n* as each block has its own representation tree.\n* Exception: at the right end of a block we store the left gap\n*\n* IBLOCK (output) INTEGER array, dimension (N)\n* The indices of the blocks (submatrices) associated with the\n* corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue\n* W(i) belongs to the first block from the top, =2 if W(i)\n* belongs to the second block, etc.\n*\n* INDEXW (output) INTEGER array, dimension (N)\n* The indices of the eigenvalues within each block (submatrix);\n* for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the\n* i-th eigenvalue W(i) is the 10-th eigenvalue in block 2\n*\n* GERS (output) REAL array, dimension (2*N)\n* The N Gerschgorin intervals (the i-th Gerschgorin interval\n* is (GERS(2*i-1), GERS(2*i)).\n*\n* PIVMIN (output) DOUBLE PRECISION\n* The minimum pivot in the Sturm sequence for T.\n*\n* WORK (workspace) REAL array, dimension (6*N)\n* Workspace.\n*\n* IWORK (workspace) INTEGER array, dimension (5*N)\n* Workspace.\n*\n* INFO (output) INTEGER\n* = 0: successful exit\n* > 0: A problem occured in SLARRE.\n* < 0: One of the called subroutines signaled an internal problem.\n* Needs inspection of the corresponding parameter IINFO\n* for further information.\n*\n* =-1: Problem in SLARRD.\n* = 2: No base representation could be found in MAXTRY iterations.\n* Increasing MAXTRY and recompilation might be a remedy.\n* =-3: Problem in SLARRB when computing the refined root\n* representation for SLASQ2.\n* =-4: Problem in SLARRB when preforming bisection on the\n* desired part of the spectrum.\n* =-5: Problem in SLASQ2.\n* =-6: Problem in SLASQ2.\n*\n* Further Details\n* The base representations are required to suffer very little\n* element growth and consequently define all their eigenvalues to\n* high relative accuracy.\n* ===============\n*\n* Based on contributions by\n* Beresford Parlett, University of California, Berkeley, USA\n* Jim Demmel, University of California, Berkeley, USA\n* Inderjit Dhillon, University of Texas, Austin, USA\n* Osni Marques, LBNL\/NERSC, USA\n* Christof Voemel, University of California, Berkeley, USA\n*\n* =====================================================================\n*\n* .. Parameters ..\n REAL FAC, FOUR, FOURTH, FUDGE, HALF, HNDRD,\n $ MAXGROWTH, ONE, PERT, TWO, ZERO\n PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0,\n $ TWO = 2.0E0, FOUR=4.0E0,\n $ HNDRD = 100.0E0,\n $ PERT = 4.0E0,\n $ HALF = ONE\/TWO, FOURTH = ONE\/FOUR, FAC= HALF,\n $ MAXGROWTH = 64.0E0, FUDGE = 2.0E0 )\n INTEGER MAXTRY, ALLRNG, INDRNG, VALRNG\n PARAMETER ( MAXTRY = 6, ALLRNG = 1, INDRNG = 2,\n $ VALRNG = 3 )\n* ..\n* .. Local Scalars ..\n LOGICAL FORCEB, NOREP, USEDQD\n INTEGER CNT, CNT1, CNT2, I, IBEGIN, IDUM, IEND, IINFO,\n $ IN, INDL, INDU, IRANGE, J, JBLK, MB, MM,\n $ WBEGIN, WEND\n REAL AVGAP, BSRTOL, CLWDTH, DMAX, DPIVOT, EABS,\n $ EMAX, EOLD, EPS, GL, GU, ISLEFT, ISRGHT, RTL,\n $ RTOL, S1, S2, SAFMIN, SGNDEF, SIGMA, SPDIAM,\n $ TAU, TMP, TMP1\n\n\n* ..\n* .. Local Arrays ..\n INTEGER ISEED( 4 )\n* ..\n* .. External Functions ..\n LOGICAL LSAME\n REAL SLAMCH\n EXTERNAL SLAMCH, LSAME\n\n* ..\n* .. External Subroutines ..\n EXTERNAL SCOPY, SLARNV, SLARRA, SLARRB, SLARRC, SLARRD,\n $ SLASQ2\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC ABS, MAX, MIN\n\n* ..\n* .. Executable Statements ..\n*\n\n INFO = 0\n\n*\n* Decode RANGE\n*\n IF( LSAME( RANGE, 'A' ) ) THEN\n IRANGE = ALLRNG\n ELSE IF( LSAME( RANGE, 'V' ) ) THEN\n IRANGE = VALRNG\n ELSE IF( LSAME( RANGE, 'I' ) ) THEN\n IRANGE = INDRNG\n END IF\n\n M = 0\n\n* Get machine constants\n SAFMIN = SLAMCH( 'S' )\n EPS = SLAMCH( 'P' )\n\n* Set parameters\n RTL = HNDRD*EPS\n* If one were ever to ask for less initial precision in BSRTOL,\n* one should keep in mind that for the subset case, the extremal\n* eigenvalues must be at least as accurate as the current setting\n* (eigenvalues in the middle need not as much accuracy)\n BSRTOL = SQRT(EPS)*(0.5E-3)\n\n* Treat case of 1x1 matrix for quick return\n IF( N.EQ.1 ) THEN\n IF( (IRANGE.EQ.ALLRNG).OR.\n $ ((IRANGE.EQ.VALRNG).AND.(D(1).GT.VL).AND.(D(1).LE.VU)).OR.\n $ ((IRANGE.EQ.INDRNG).AND.(IL.EQ.1).AND.(IU.EQ.1)) ) THEN\n M = 1\n W(1) = D(1)\n* The computation error of the eigenvalue is zero\n WERR(1) = ZERO\n WGAP(1) = ZERO\n IBLOCK( 1 ) = 1\n INDEXW( 1 ) = 1\n GERS(1) = D( 1 )\n GERS(2) = D( 1 )\n ENDIF\n* store the shift for the initial RRR, which is zero in this case\n E(1) = ZERO\n RETURN\n END IF\n\n* General case: tridiagonal matrix of order > 1\n*\n* Init WERR, WGAP. Compute Gerschgorin intervals and spectral diameter.\n* Compute maximum off-diagonal entry and pivmin.\n GL = D(1)\n GU = D(1)\n EOLD = ZERO\n EMAX = ZERO\n E(N) = ZERO\n DO 5 I = 1,N\n WERR(I) = ZERO\n WGAP(I) = ZERO\n EABS = ABS( E(I) )\n IF( EABS .GE. EMAX ) THEN\n EMAX = EABS\n END IF\n TMP1 = EABS + EOLD\n GERS( 2*I-1) = D(I) - TMP1\n GL = MIN( GL, GERS( 2*I - 1))\n GERS( 2*I ) = D(I) + TMP1\n GU = MAX( GU, GERS(2*I) )\n EOLD = EABS\n 5 CONTINUE\n* The minimum pivot allowed in the Sturm sequence for T\n PIVMIN = SAFMIN * MAX( ONE, EMAX**2 )\n* Compute spectral diameter. The Gerschgorin bounds give an\n* estimate that is wrong by at most a factor of SQRT(2)\n SPDIAM = GU - GL\n\n* Compute splitting points\n CALL SLARRA( N, D, E, E2, SPLTOL, SPDIAM,\n $ NSPLIT, ISPLIT, IINFO )\n\n* Can force use of bisection instead of faster DQDS.\n* Option left in the code for future multisection work.\n FORCEB = .FALSE.\n\n* Initialize USEDQD, DQDS should be used for ALLRNG unless someone\n* explicitly wants bisection.\n USEDQD = (( IRANGE.EQ.ALLRNG ) .AND. (.NOT.FORCEB))\n\n IF( (IRANGE.EQ.ALLRNG) .AND. (.NOT. FORCEB) ) THEN\n* Set interval [VL,VU] that contains all eigenvalues\n VL = GL\n VU = GU\n ELSE\n* We call SLARRD to find crude approximations to the eigenvalues\n* in the desired range. In case IRANGE = INDRNG, we also obtain the\n* interval (VL,VU] that contains all the wanted eigenvalues.\n* An interval [LEFT,RIGHT] has converged if\n* RIGHT-LEFT.LT.RTOL*MAX(ABS(LEFT),ABS(RIGHT))\n* SLARRD needs a WORK of size 4*N, IWORK of size 3*N\n CALL SLARRD( RANGE, 'B', N, VL, VU, IL, IU, GERS,\n $ BSRTOL, D, E, E2, PIVMIN, NSPLIT, ISPLIT,\n $ MM, W, WERR, VL, VU, IBLOCK, INDEXW,\n $ WORK, IWORK, IINFO )\n IF( IINFO.NE.0 ) THEN\n INFO = -1\n RETURN\n ENDIF\n* Make sure that the entries M+1 to N in W, WERR, IBLOCK, INDEXW are 0\n DO 14 I = MM+1,N\n W( I ) = ZERO\n WERR( I ) = ZERO\n IBLOCK( I ) = 0\n INDEXW( I ) = 0\n 14 CONTINUE\n END IF\n\n\n***\n* Loop over unreduced blocks\n IBEGIN = 1\n WBEGIN = 1\n DO 170 JBLK = 1, NSPLIT\n IEND = ISPLIT( JBLK )\n IN = IEND - IBEGIN + 1\n\n* 1 X 1 block\n IF( IN.EQ.1 ) THEN\n IF( (IRANGE.EQ.ALLRNG).OR.( (IRANGE.EQ.VALRNG).AND.\n $ ( D( IBEGIN ).GT.VL ).AND.( D( IBEGIN ).LE.VU ) )\n $ .OR. ( (IRANGE.EQ.INDRNG).AND.(IBLOCK(WBEGIN).EQ.JBLK))\n $ ) THEN\n M = M + 1\n W( M ) = D( IBEGIN )\n WERR(M) = ZERO\n* The gap for a single block doesn't matter for the later\n* algorithm and is assigned an arbitrary large value\n WGAP(M) = ZERO\n IBLOCK( M ) = JBLK\n INDEXW( M ) = 1\n WBEGIN = WBEGIN + 1\n ENDIF\n* E( IEND ) holds the shift for the initial RRR\n E( IEND ) = ZERO\n IBEGIN = IEND + 1\n GO TO 170\n END IF\n*\n* Blocks of size larger than 1x1\n*\n* E( IEND ) will hold the shift for the initial RRR, for now set it =0\n E( IEND ) = ZERO\n*\n* Find local outer bounds GL,GU for the block\n GL = D(IBEGIN)\n GU = D(IBEGIN)\n DO 15 I = IBEGIN , IEND\n GL = MIN( GERS( 2*I-1 ), GL )\n GU = MAX( GERS( 2*I ), GU )\n 15 CONTINUE\n SPDIAM = GU - GL\n\n IF(.NOT. ((IRANGE.EQ.ALLRNG).AND.(.NOT.FORCEB)) ) THEN\n* Count the number of eigenvalues in the current block.\n MB = 0\n DO 20 I = WBEGIN,MM\n IF( IBLOCK(I).EQ.JBLK ) THEN\n MB = MB+1\n ELSE\n GOTO 21\n ENDIF\n 20 CONTINUE\n 21 CONTINUE\n\n IF( MB.EQ.0) THEN\n* No eigenvalue in the current block lies in the desired range\n* E( IEND ) holds the shift for the initial RRR\n E( IEND ) = ZERO\n IBEGIN = IEND + 1\n GO TO 170\n ELSE\n\n* Decide whether dqds or bisection is more efficient\n USEDQD = ( (MB .GT. FAC*IN) .AND. (.NOT.FORCEB) )\n WEND = WBEGIN + MB - 1\n* Calculate gaps for the current block\n* In later stages, when representations for individual\n* eigenvalues are different, we use SIGMA = E( IEND ).\n SIGMA = ZERO\n DO 30 I = WBEGIN, WEND - 1\n WGAP( I ) = MAX( ZERO,\n $ W(I+1)-WERR(I+1) - (W(I)+WERR(I)) )\n 30 CONTINUE\n WGAP( WEND ) = MAX( ZERO,\n $ VU - SIGMA - (W( WEND )+WERR( WEND )))\n* Find local index of the first and last desired evalue.\n INDL = INDEXW(WBEGIN)\n INDU = INDEXW( WEND )\n ENDIF\n ENDIF\n IF(( (IRANGE.EQ.ALLRNG) .AND. (.NOT. FORCEB) ).OR.USEDQD) THEN\n* Case of DQDS\n* Find approximations to the extremal eigenvalues of the block\n CALL SLARRK( IN, 1, GL, GU, D(IBEGIN),\n $ E2(IBEGIN), PIVMIN, RTL, TMP, TMP1, IINFO )\n IF( IINFO.NE.0 ) THEN\n INFO = -1\n RETURN\n ENDIF\n ISLEFT = MAX(GL, TMP - TMP1\n $ - HNDRD * EPS* ABS(TMP - TMP1))\n\n CALL SLARRK( IN, IN, GL, GU, D(IBEGIN),\n $ E2(IBEGIN), PIVMIN, RTL, TMP, TMP1, IINFO )\n IF( IINFO.NE.0 ) THEN\n INFO = -1\n RETURN\n ENDIF\n ISRGHT = MIN(GU, TMP + TMP1\n $ + HNDRD * EPS * ABS(TMP + TMP1))\n* Improve the estimate of the spectral diameter\n SPDIAM = ISRGHT - ISLEFT\n ELSE\n* Case of bisection\n* Find approximations to the wanted extremal eigenvalues\n ISLEFT = MAX(GL, W(WBEGIN) - WERR(WBEGIN)\n $ - HNDRD * EPS*ABS(W(WBEGIN)- WERR(WBEGIN) ))\n ISRGHT = MIN(GU,W(WEND) + WERR(WEND)\n $ + HNDRD * EPS * ABS(W(WEND)+ WERR(WEND)))\n ENDIF\n\n\n* Decide whether the base representation for the current block\n* L_JBLK D_JBLK L_JBLK^T = T_JBLK - sigma_JBLK I\n* should be on the left or the right end of the current block.\n* The strategy is to shift to the end which is \"more populated\"\n* Furthermore, decide whether to use DQDS for the computation of\n* the eigenvalue approximations at the end of SLARRE or bisection.\n* dqds is chosen if all eigenvalues are desired or the number of\n* eigenvalues to be computed is large compared to the blocksize.\n IF( ( IRANGE.EQ.ALLRNG ) .AND. (.NOT.FORCEB) ) THEN\n* If all the eigenvalues have to be computed, we use dqd\n USEDQD = .TRUE.\n* INDL is the local index of the first eigenvalue to compute\n INDL = 1\n INDU = IN\n* MB = number of eigenvalues to compute\n MB = IN\n WEND = WBEGIN + MB - 1\n* Define 1\/4 and 3\/4 points of the spectrum\n S1 = ISLEFT + FOURTH * SPDIAM\n S2 = ISRGHT - FOURTH * SPDIAM\n ELSE\n* SLARRD has computed IBLOCK and INDEXW for each eigenvalue\n* approximation.\n* choose sigma\n IF( USEDQD ) THEN\n S1 = ISLEFT + FOURTH * SPDIAM\n S2 = ISRGHT - FOURTH * SPDIAM\n ELSE\n TMP = MIN(ISRGHT,VU) - MAX(ISLEFT,VL)\n S1 = MAX(ISLEFT,VL) + FOURTH * TMP\n S2 = MIN(ISRGHT,VU) - FOURTH * TMP\n ENDIF\n ENDIF\n\n* Compute the negcount at the 1\/4 and 3\/4 points\n IF(MB.GT.1) THEN\n CALL SLARRC( 'T', IN, S1, S2, D(IBEGIN),\n $ E(IBEGIN), PIVMIN, CNT, CNT1, CNT2, IINFO)\n ENDIF\n\n IF(MB.EQ.1) THEN\n SIGMA = GL\n SGNDEF = ONE\n ELSEIF( CNT1 - INDL .GE. INDU - CNT2 ) THEN\n IF( ( IRANGE.EQ.ALLRNG ) .AND. (.NOT.FORCEB) ) THEN\n SIGMA = MAX(ISLEFT,GL)\n ELSEIF( USEDQD ) THEN\n* use Gerschgorin bound as shift to get pos def matrix\n* for dqds\n SIGMA = ISLEFT\n ELSE\n* use approximation of the first desired eigenvalue of the\n* block as shift\n SIGMA = MAX(ISLEFT,VL)\n ENDIF\n SGNDEF = ONE\n ELSE\n IF( ( IRANGE.EQ.ALLRNG ) .AND. (.NOT.FORCEB) ) THEN\n SIGMA = MIN(ISRGHT,GU)\n ELSEIF( USEDQD ) THEN\n* use Gerschgorin bound as shift to get neg def matrix\n* for dqds\n SIGMA = ISRGHT\n ELSE\n* use approximation of the first desired eigenvalue of the\n* block as shift\n SIGMA = MIN(ISRGHT,VU)\n ENDIF\n SGNDEF = -ONE\n ENDIF\n\n\n* An initial SIGMA has been chosen that will be used for computing\n* T - SIGMA I = L D L^T\n* Define the increment TAU of the shift in case the initial shift\n* needs to be refined to obtain a factorization with not too much\n* element growth.\n IF( USEDQD ) THEN\n* The initial SIGMA was to the outer end of the spectrum\n* the matrix is definite and we need not retreat.\n TAU = SPDIAM*EPS*N + TWO*PIVMIN\n ELSE\n IF(MB.GT.1) THEN\n CLWDTH = W(WEND) + WERR(WEND) - W(WBEGIN) - WERR(WBEGIN)\n AVGAP = ABS(CLWDTH \/ REAL(WEND-WBEGIN))\n IF( SGNDEF.EQ.ONE ) THEN\n TAU = HALF*MAX(WGAP(WBEGIN),AVGAP)\n TAU = MAX(TAU,WERR(WBEGIN))\n ELSE\n TAU = HALF*MAX(WGAP(WEND-1),AVGAP)\n TAU = MAX(TAU,WERR(WEND))\n ENDIF\n ELSE\n TAU = WERR(WBEGIN)\n ENDIF\n ENDIF\n*\n DO 80 IDUM = 1, MAXTRY\n* Compute L D L^T factorization of tridiagonal matrix T - sigma I.\n* Store D in WORK(1:IN), L in WORK(IN+1:2*IN), and reciprocals of\n* pivots in WORK(2*IN+1:3*IN)\n DPIVOT = D( IBEGIN ) - SIGMA\n WORK( 1 ) = DPIVOT\n DMAX = ABS( WORK(1) )\n J = IBEGIN\n DO 70 I = 1, IN - 1\n WORK( 2*IN+I ) = ONE \/ WORK( I )\n TMP = E( J )*WORK( 2*IN+I )\n WORK( IN+I ) = TMP\n DPIVOT = ( D( J+1 )-SIGMA ) - TMP*E( J )\n WORK( I+1 ) = DPIVOT\n DMAX = MAX( DMAX, ABS(DPIVOT) )\n J = J + 1\n 70 CONTINUE\n* check for element growth\n IF( DMAX .GT. MAXGROWTH*SPDIAM ) THEN\n NOREP = .TRUE.\n ELSE\n NOREP = .FALSE.\n ENDIF\n IF( USEDQD .AND. .NOT.NOREP ) THEN\n* Ensure the definiteness of the representation\n* All entries of D (of L D L^T) must have the same sign\n DO 71 I = 1, IN\n TMP = SGNDEF*WORK( I )\n IF( TMP.LT.ZERO ) NOREP = .TRUE.\n 71 CONTINUE\n ENDIF\n IF(NOREP) THEN\n* Note that in the case of IRANGE=ALLRNG, we use the Gerschgorin\n* shift which makes the matrix definite. So we should end up\n* here really only in the case of IRANGE = VALRNG or INDRNG.\n IF( IDUM.EQ.MAXTRY-1 ) THEN\n IF( SGNDEF.EQ.ONE ) THEN\n* The fudged Gerschgorin shift should succeed\n SIGMA =\n $ GL - FUDGE*SPDIAM*EPS*N - FUDGE*TWO*PIVMIN\n ELSE\n SIGMA =\n $ GU + FUDGE*SPDIAM*EPS*N + FUDGE*TWO*PIVMIN\n END IF\n ELSE\n SIGMA = SIGMA - SGNDEF * TAU\n TAU = TWO * TAU\n END IF\n ELSE\n* an initial RRR is found\n GO TO 83\n END IF\n 80 CONTINUE\n* if the program reaches this point, no base representation could be\n* found in MAXTRY iterations.\n INFO = 2\n RETURN\n\n 83 CONTINUE\n* At this point, we have found an initial base representation\n* T - SIGMA I = L D L^T with not too much element growth.\n* Store the shift.\n E( IEND ) = SIGMA\n* Store D and L.\n CALL SCOPY( IN, WORK, 1, D( IBEGIN ), 1 )\n CALL SCOPY( IN-1, WORK( IN+1 ), 1, E( IBEGIN ), 1 )\n\n\n IF(MB.GT.1 ) THEN\n*\n* Perturb each entry of the base representation by a small\n* (but random) relative amount to overcome difficulties with\n* glued matrices.\n*\n DO 122 I = 1, 4\n ISEED( I ) = 1\n 122 CONTINUE\n\n CALL SLARNV(2, ISEED, 2*IN-1, WORK(1))\n DO 125 I = 1,IN-1\n D(IBEGIN+I-1) = D(IBEGIN+I-1)*(ONE+EPS*PERT*WORK(I))\n E(IBEGIN+I-1) = E(IBEGIN+I-1)*(ONE+EPS*PERT*WORK(IN+I))\n 125 CONTINUE\n D(IEND) = D(IEND)*(ONE+EPS*FOUR*WORK(IN))\n*\n ENDIF\n*\n* Don't update the Gerschgorin intervals because keeping track\n* of the updates would be too much work in SLARRV.\n* We update W instead and use it to locate the proper Gerschgorin\n* intervals.\n\n* Compute the required eigenvalues of L D L' by bisection or dqds\n IF ( .NOT.USEDQD ) THEN\n* If SLARRD has been used, shift the eigenvalue approximations\n* according to their representation. This is necessary for\n* a uniform SLARRV since dqds computes eigenvalues of the\n* shifted representation. In SLARRV, W will always hold the\n* UNshifted eigenvalue approximation.\n DO 134 J=WBEGIN,WEND\n W(J) = W(J) - SIGMA\n WERR(J) = WERR(J) + ABS(W(J)) * EPS\n 134 CONTINUE\n* call SLARRB to reduce eigenvalue error of the approximations\n* from SLARRD\n DO 135 I = IBEGIN, IEND-1\n WORK( I ) = D( I ) * E( I )**2\n 135 CONTINUE\n* use bisection to find EV from INDL to INDU\n CALL SLARRB(IN, D(IBEGIN), WORK(IBEGIN),\n $ INDL, INDU, RTOL1, RTOL2, INDL-1,\n $ W(WBEGIN), WGAP(WBEGIN), WERR(WBEGIN),\n $ WORK( 2*N+1 ), IWORK, PIVMIN, SPDIAM,\n $ IN, IINFO )\n IF( IINFO .NE. 0 ) THEN\n INFO = -4\n RETURN\n END IF\n* SLARRB computes all gaps correctly except for the last one\n* Record distance to VU\/GU\n WGAP( WEND ) = MAX( ZERO,\n $ ( VU-SIGMA ) - ( W( WEND ) + WERR( WEND ) ) )\n DO 138 I = INDL, INDU\n M = M + 1\n IBLOCK(M) = JBLK\n INDEXW(M) = I\n 138 CONTINUE\n ELSE\n* Call dqds to get all eigs (and then possibly delete unwanted\n* eigenvalues).\n* Note that dqds finds the eigenvalues of the L D L^T representation\n* of T to high relative accuracy. High relative accuracy\n* might be lost when the shift of the RRR is subtracted to obtain\n* the eigenvalues of T. However, T is not guaranteed to define its\n* eigenvalues to high relative accuracy anyway.\n* Set RTOL to the order of the tolerance used in SLASQ2\n* This is an ESTIMATED error, the worst case bound is 4*N*EPS\n* which is usually too large and requires unnecessary work to be\n* done by bisection when computing the eigenvectors\n RTOL = LOG(REAL(IN)) * FOUR * EPS\n J = IBEGIN\n DO 140 I = 1, IN - 1\n WORK( 2*I-1 ) = ABS( D( J ) )\n WORK( 2*I ) = E( J )*E( J )*WORK( 2*I-1 )\n J = J + 1\n 140 CONTINUE\n WORK( 2*IN-1 ) = ABS( D( IEND ) )\n WORK( 2*IN ) = ZERO\n CALL SLASQ2( IN, WORK, IINFO )\n IF( IINFO .NE. 0 ) THEN\n* If IINFO = -5 then an index is part of a tight cluster\n* and should be changed. The index is in IWORK(1) and the\n* gap is in WORK(N+1)\n INFO = -5\n RETURN\n ELSE\n* Test that all eigenvalues are positive as expected\n DO 149 I = 1, IN\n IF( WORK( I ).LT.ZERO ) THEN\n INFO = -6\n RETURN\n ENDIF\n 149 CONTINUE\n END IF\n IF( SGNDEF.GT.ZERO ) THEN\n DO 150 I = INDL, INDU\n M = M + 1\n W( M ) = WORK( IN-I+1 )\n IBLOCK( M ) = JBLK\n INDEXW( M ) = I\n 150 CONTINUE\n ELSE\n DO 160 I = INDL, INDU\n M = M + 1\n W( M ) = -WORK( I )\n IBLOCK( M ) = JBLK\n INDEXW( M ) = I\n 160 CONTINUE\n END IF\n\n DO 165 I = M - MB + 1, M\n* the value of RTOL below should be the tolerance in SLASQ2\n WERR( I ) = RTOL * ABS( W(I) )\n 165 CONTINUE\n DO 166 I = M - MB + 1, M - 1\n* compute the right gap between the intervals\n WGAP( I ) = MAX( ZERO,\n $ W(I+1)-WERR(I+1) - (W(I)+WERR(I)) )\n 166 CONTINUE\n WGAP( M ) = MAX( ZERO,\n $ ( VU-SIGMA ) - ( W( M ) + WERR( M ) ) )\n END IF\n* proceed with next block\n IBEGIN = IEND + 1\n WBEGIN = WEND + 1\n 170 CONTINUE\n*\n\n RETURN\n*\n* end of SLARRE\n*\n END\n","avg_line_length":38.0554821664,"max_line_length":78,"alphanum_fraction":0.5064565399} {"size":8136,"ext":"f","lang":"FORTRAN","max_stars_count":9.0,"content":" DOUBLE PRECISION FUNCTION DINTSM (SXMIN)\nc Copyright (c) 1996 California Institute of Technology, Pasadena, CA.\nc ALL RIGHTS RESERVED.\nc Based on Government Sponsored Research NAS7-03001.\nC>> 1996-03-31 DINTSM Krogh Removed unused variable in common.\nc>> 1995-11-20 DINTSM Krogh Converted from SFTRAN to Fortran 77.\nc>> 1994-10-19 DINTSM Krogh Changes to use M77CON\nc>> 1994-07-07 DINTSM Snyder set up for CHGTYP.\nc>> 1994-07-05 DINTSM Snyder Corrected calculation\nC>> 1993-05-18 DINTSM Krogh -- Changed \"END\" to \"END PROGRAM\"\nC>> 1987-11-19 DINTSM Snyder Initial code.\nC\nc--D replaces \"?\": ?intc, ?intec, ?intnc, ?INTSM\nc\nC CALCULATE THE MINIMUM STEPSIZE TO USE IF ALOCAL WERE SET EQUAL TO\nC SXMIN.\nC\nC WRITE X = TA + (T-TA)**2\/TB. IF WE LET X2 - X1 BE THE SMALLEST\nC ALLOWED STEP AT X1, SAY SMIN, THEN\nC TB*(X2-X1) = TB*SMIN = (T2-TA)**2 - (T1-TA)**2, OR\nC TB*SMIN = (T2-T1)*(T2-T1+2*(T1-TA)). SOLVING FOR T2-T1 PROVIDES\nC THE EXPRESSIONS IN THE CODE BELOW. THE ANALYSIS PROCEEDS\nC SIMILARLY WHEN X = TA + (T-TA)**4\/TB**3.\nC\n DOUBLE PRECISION SXMIN\nC\nC ***** LOCAL VARIABLES ************************************\nC\nC SG IS A TEMPORARY VARIABLE\n DOUBLE PRECISION SG\nC SMIN IS THE VALUE THAT WILL BE RETURNED AS THE MINIMUM STEPSIZE.\n DOUBLE PRECISION SMIN\nC SOLVE IS AN ARITHMETIC STATEMENT FUNCTION DEFINED BELOW.\n DOUBLE PRECISION SOLVE\nC SQRTTB IS SQRT(ABS(TB))\n DOUBLE PRECISION SQRTTB\nC SX IS A LOCAL COPY OF SXMIN.\n DOUBLE PRECISION SX\nC TDECR IS AN ARITHMETIC STATEMENT FUNCTION DEFINED BELOW.\n DOUBLE PRECISION TDECR\nC\nC ***** COMMON VARIABLES ***********************************\nC\nC COMMON \/DINTNC\/ CONTAINS VARIABLES NOT SEPARATELY SAVED FOR\nC EACH DIMENSION OF A MULTIPLE QUADRATURE. COMMON \/DINTC\/\nC CONTAINS VARIABLES THAT MUST BE SAVED FOR EACH DIMENSION OF THE\nC QUADRATURE. THE VARIABLES IN EACH COMMON BLOCK ARE STORED IN THE\nC ORDER - ALWAYS DOUBLE, DOUBLE IF DOUBLE PRECISION PROGRAM, DOUBLE\nC IF DOUBLE PRECISION PROGRAM AND EXPONENT RANGE OF DOUBLE AND\nC SINGLE VERY DIFFERENT, SINGLE, INTEGER, LOGICAL. A PAD OF LOGICAL\nC VARIABLES IS INCLUDED AT THE END OF \/DINTC\/. THE DIMENSION OF\nC THE PAD MAY NEED TO BE VARIED SO THAT NO VARIABLES BEYOND THE END\nC OF THE COMMON BLOCK ARE ALTERED.\nC\nC DECLARATIONS OF COMMON \/DINTNC\/ VARIABLES.\nC\n DOUBLE PRECISION AINIT, BINIT, FNCVAL, S, TP\n DOUBLE PRECISION FER, FER1, RELOBT, TPS, XJ, XJP\n INTEGER FEA, FEA1, INC, INC2, IPRINT,\n 1 ISTOP(2,2),JPRINT, KDIM, KK, KMAXF, NDIM,\n 2 NFINDX, NFMAX, NFMAXM, RELTOL, REVERM, REVERS,\n 3 WHEREM\n LOGICAL NEEDH\nC\nC DECLARATIONS OF COMMON \/DINTC\/ VARIABLES.\nC\nc--D Next line special: S => D, X => Q, D => D, P => D\n DOUBLE PRECISION ACUM, PACUM, RESULT(2)\nC 139 $.TYPE.$ VARIABLES\n DOUBLE PRECISION\n 1 AACUM, ABSCIS, DELMIN, DELTA, DIFF, DISCX(2),\n 2 END(2), ERRINA, ERRINB, FAT(2), FSAVE,\n 3 FUNCT(24), F1, F2, LOCAL(4), PAACUM, PF1,\n 4 PF2, PHISUM, PHTSUM, PX, SPACE(6),\n 5 STEP(2), START(2), SUM, T, TA, TASAVE,\n 6 TB, TEND, WORRY(2), X, X1,\n 7 X2, XT(17), FT(17), PHI(34)\nc Note XT, FT, and PHI above are last, because they must be in adjacent\nc locations in DINTC.\nC 30 $DSTYP$ VARIABLES\n DOUBLE PRECISION\n 1 ABSDIF, COUNT, EDUE2A, EDUE2B, EP, EPNOIZ,\n 2 EPS, EPSMAX, EPSMIN, EPSO, EPSR, EPSS,\n 3 ERR, ERRAT(2), ERRC, ERRF, ERRI, ERRT(2),\n 4 ESOLD, EXTRA, PEPSMN, RE, RELEPS, REP,\n 5 REPROD, RNDC, TLEN, XJUMP\nC 29 INTEGER VARIABLES\n INTEGER DISCF, DISCHK, ENDPTS, I, INEW,\n 1 IOLD, IP, IXKDIM, J, J1, J1OLD,\n 2 J2, J2OLD, K, KAIMT, KMAX, KMIN,\n 3 L, LENDT, NFEVAL, NFJUMP, NSUB, NSUBSV,\n 4 NXKDIM, PART, SEARCH, TALOC, WHERE, WHERE2\nC 11 TO 18 LOGICALS (7 ARE PADDING).\n LOGICAL DID1, FAIL, FATS(2), FSAVED, HAVDIF,\n 1 IEND, INIT, ROUNDF, XCDOBT(2), PAD(7)\nC\nC THE COMMON BLOCKS.\nC\n COMMON \/DINTNC\/\nc 1 2 3 4 5 6 7 8\n W AINIT, BINIT, FNCVAL, S, TP, FER, FER1, RELOBT,\nc 9 10 11 12 13 1 2 3\n X TPS, XJ, XJP, FEA, FEA1, KDIM, INC, INC2,\nc 4 (2,2) 8 9 10 11 12 13 14\n Y ISTOP, JPRINT, IPRINT, KK, KMAXF, NDIM, NFINDX, NFMAX,\nc 15 16 17 18 19 20\n Z NFMAXM, RELTOL, REVERM, REVERS, WHEREM, NEEDH\n COMMON \/DINTC\/\n 1 ACUM, PACUM, RESULT\n COMMON \/DINTC\/\nc 1 2 (4) 6 7 8 9 10 11 (2)\n 1 AACUM, LOCAL, ABSCIS, TA, DELTA, DELMIN, DIFF, DISCX,\nc 13 (2) 15 16 17 (2) 19 20 (24) 44\n 2 END, ERRINA, ERRINB, FAT, FSAVE, FUNCT, F2,\nc 45 46 47 48 49 50 51 (6)\n 3 PAACUM, PF1, PF2, PHISUM, PHTSUM, PX, SPACE,\nc 57 (2) 59 (2) 61 62 63 64 65\n 4 STEP, START, SUM, T, TASAVE, TB, TEND,\nc 66 (2) 68 69 70 71 72\n 5 WORRY, X1, X2, X, F1, COUNT,\nc 73 (17) 90 (17) 107 (34)\n 6 XT, FT, PHI\n COMMON \/DINTC\/\nc 141 142 143 144 145 146\n 1 ABSDIF, EDUE2A, EDUE2B, EP, EPNOIZ, EPSMAX,\nc 147 148 149 150 (2) 152 153\n 2 EPSO, EPSR, EPSS, ERRAT, ERRC, ERRF,\nc 154 (2) 156 157 158 159 160\n 3 ERRT, ESOLD, EXTRA, PEPSMN, RELEPS, REP,\nc 161 162 163\n 4 RNDC, TLEN, XJUMP,\nc 164 165 166 167 168 169\n 5 ERRI, ERR, EPSMIN, EPS, RE, REPROD\n COMMON \/DINTC\/\nc 170 171 172\n 1 DISCF, DISCHK, ENDPTS, INEW, IOLD, IP, IXKDIM,\n 2 J, J1, J1OLD, J2, J2OLD, KMAX, KMIN,\n 3 L, LENDT, NFJUMP, NSUBSV, NXKDIM, TALOC, WHERE2,\nc 1 2 3 4 5 6 7 8\n 4 I, K, KAIMT, NSUB, PART, SEARCH, WHERE, NFEVAL\n COMMON \/DINTC\/\n 1 DID1, FAIL, FATS, FSAVED, HAVDIF, IEND, INIT, ROUNDF,\n 2 XCDOBT, PAD\n SAVE \/DINTNC\/, \/DINTC\/\nC\nC THE VARIABLES HERE DEFINE THE MACHINE ENVIRONMENT. ALL ARE SET\nC IN DINTOP. THE MEANING ATTACHED TO THESE VARIABLES CAN BE\nC FOUND BY LOOKING AT THE DEFINITIONS IN DINTOP.\n DOUBLE PRECISION\n 1 EMEPS, EEPSM8, EDELM2, EDELM3, ESQEPS, ERSQEP, ERSQE6, EMINF,\n 2 ESMALL, ENZER, EDELM1, ENINF\n COMMON \/DINTEC\/\n 1 EMEPS, EEPSM8, EDELM2, EDELM3, ESQEPS, ERSQEP, ERSQE6, EMINF,\n 2 ESMALL, ENZER, EDELM1, ENINF\n SAVE \/DINTEC\/\nC\nC ***** STATEMENT FUNCTIONS ********************************\nC\nC SOLVE PROVIDES THE SOLUTION OF A QUADRATIC EQUATION.\n SOLVE(SX,SG)=SQRTTB*SX\/(SG*SQRTTB+SQRT(ABS(TB)*SG*SG+SX))\nC TDECR IS USED TO TRANSFORM AN ABSCISSA FROM THE CURRENT COORDINATE\nC SYSTEM TO ONE IN WHICH NSUB IS DECREMENTED BY A FACTOR OF 2.\nC TDECR(SX)=TA+(SX-TA)*((SX-TA)\/TB)\n TDECR(SX)=TA*(1.0+TA\/TB)+SX*((SX-TA)\/TB-TA\/TB)\nC\nC ***** EXECUTABLE STATEMENTS ******************************\nC\n SX=SXMIN\n IF (NSUB .EQ. 0) THEN\n SG = SX\n ELSE\n SG = TDECR(SX)\n IF (NSUB .NE. 2) SG = TDECR(SG)\n END IF\n SMIN=EDELM3*MAX(EDELM1,ABS(SG))\n IF (NSUB .NE. 0) THEN\n SQRTTB=SQRT(ABS(TB))\n SG = ABS((SX-TA)\/TB)\n SMIN=SOLVE(SMIN,SG)\n IF (NSUB .NE. 2) SMIN=SOLVE(SMIN,SG*SG)\n END IF\n DINTSM=SMIN\n RETURN\n END\n","avg_line_length":43.9783783784,"max_line_length":72,"alphanum_fraction":0.5342920354} {"size":26703,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"!\n! CalculiX - A 3-dimensional finite element program\n! Copyright (C) 1998-2021 Guido Dhondt\n!\n! This program is free software; you can redistribute it and\/or\n! modify it under the terms of the GNU General Public License as\n! published by the Free Software Foundation(version 2);\n! \n!\n! This program is distributed in the hope that it will be useful,\n! but WITHOUT ANY WARRANTY; without even the implied warranty of \n! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n! GNU General Public License for more details.\n!\n! You should have received a copy of the GNU General Public License\n! along with this program; if not, write to the Free Software\n! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n!\n subroutine gencontelem_n2f(tieset,ntie,itietri,ne,ipkon,kon,\n & lakon,cg,straight,ifree,\n & koncont,co,vold,xo,yo,zo,x,y,z,nx,ny,nz,ielmat,\n & elcon,istep,iinc,iit,ncmat_,ntmat_,\n & nmethod,mi,imastop,nslavnode,islavnode,islavsurf,\n & itiefac,areaslav,iponoels,inoels,springarea,set,nset,istartset,\n & iendset,ialset,tietol,reltime,filab,nasym,xnoels,icutb,ne0,\n & jobnamef,mortar,auw,jqw,iroww,nzsw,imastnode,nmastnode)\n!\n! generate contact elements for the slave contact nodes\n!\n implicit none\n!\n character*8 lakon(*)\n character*33 cfile\n character*81 tieset(3,*),slavset,set(*),noset,setname\n character*87 filab(*)\n character*132 jobnamef(*)\n!\n integer ntie,ifree,nasym,icutb,ne0,mortar,jqw(*),iroww(*),\n & itietri(2,ntie),ipkon(*),kon(*),koncont(4,*),ne,node,\n & neigh(1),iflag,kneigh,i,j,k,l,isol,iset,idummy,\n & itri,ll,kflag,n,nx(*),ny(*),istep,iinc,mi(*),nzsw,\n & nz(*),nstart,ielmat(mi(3),*),imat,ifaceq(8,6),ifacet(6,4),\n & ifacew1(4,5),ifacew2(8,5),nelem,jface,indexe,iit,\n & nface,nope,nodef(9),ncmat_,ntmat_,index1,indexel,\n & nmethod,iteller,ifaces,jfaces,irelslavface,number(4),lenset,\n & imastop(3,*), itriangle(100),ntriangle,ntriangle_,itriold,\n & itrinew,id,nslavnode(*),islavnode(*),islavsurf(2,*),\n & itiefac(2,*),iponoels(*),inoels(2,*),konl(26),nelems,m,\n & mint2d,nopes,ipos,nset,istartset(*),iendset(*),m1,m2,\n & ialset(*),length,iorder(4),imastnode(*),nmastnode(*),\n & jbasis,kbasis\n!\n real*8 cg(3,*),straight(16,*),co(3,*),vold(0:mi(2),*),p(3),\n & dist,xo(*),yo(*),zo(*),x(*),y(*),z(*),c0coef,auw(*),\n & beta,c0,elcon(0:ncmat_,ntmat_,*),weight,t1(3),t2(3),dt1,\n & areaslav(*),springarea(2,*),xl2(3,9),area,xi,et,shp2(7,9),\n & xs2(3,2),xsj2(3),adjust,tietol(3,*),reltime,xns(3,3),\n & clear,ratio(9),pl(3,9),\n & pproj(3),al(3),xn(3),xm(3),dm,xnoels(*)\n!\n! nodes per face for hex elements\n!\n data ifaceq \/4,3,2,1,11,10,9,12,\n & 5,6,7,8,13,14,15,16,\n & 1,2,6,5,9,18,13,17,\n & 2,3,7,6,10,19,14,18,\n & 3,4,8,7,11,20,15,19,\n & 4,1,5,8,12,17,16,20\/\n!\n! nodes per face for tet elements\n!\n data ifacet \/1,3,2,7,6,5,\n & 1,2,4,5,9,8,\n & 2,3,4,6,10,9,\n & 1,4,3,8,10,7\/\n!\n! nodes per face for linear wedge elements\n!\n data ifacew1 \/1,3,2,0,\n & 4,5,6,0,\n & 1,2,5,4,\n & 2,3,6,5,\n & 3,1,4,6\/\n!\n! nodes per face for quadratic wedge elements\n!\n data ifacew2 \/1,3,2,9,8,7,0,0,\n & 4,5,6,10,11,12,0,0,\n & 1,2,5,4,7,14,10,13,\n & 2,3,6,5,8,15,11,14,\n & 3,1,4,6,9,13,12,15\/\n!\n! flag for shape functions\n!\n data iflag \/2\/\n data indexel \/0\/\n!\n save indexel\n!\n include \"gauss.f\"\n!\n! opening a file to store the contact spring elements\n! \n if(filab(1)(3:3).eq.'C') then\n iteller=iteller+1\n!\n do i=1,132\n if(jobnamef(1)(i:i).eq.' ') exit\n enddo\n i=i-1\n cfile=jobnamef(1)(1:i)\/\/'.cel'\n open(27,file=cfile,status='unknown',position='append')\n!\n setname(1:15)='contactelements'\n lenset=15\n number(1)=istep\n number(2)=iinc\n number(3)=icutb+1\n number(4)=iit\n if(number(4).le.0) number(4)=1\n do i=1,4\n setname(lenset+1:lenset+1)='_'\n if(i.eq.1) then\n setname(lenset+2:lenset+3)='st'\n elseif(i.eq.2) then\n setname(lenset+2:lenset+3)='in'\n elseif(i.eq.3) then\n setname(lenset+2:lenset+3)='at'\n else\n setname(lenset+2:lenset+3)='it'\n endif\n if(number(i).lt.10) then\n write(setname(lenset+4:lenset+4),'(i1)') number(i)\n lenset=lenset+4\n elseif(number(i).lt.100) then\n write(setname(lenset+4:lenset+5),'(i2)') number(i)\n lenset=lenset+5\n elseif(number(i).lt.1000) then\n write(setname(lenset+4:lenset+6),'(i3)') number(i)\n lenset=lenset+6\n else\n write(*,*) '*ERROR in gencontelem_f2f: no more than 1000'\n write(*,*) ' steps\/increments\/cutbacks\/iterations'\n write(*,*) ' allowed (for output in '\n write(*,*) ' contactelements.inp)'\n stop\n endif\n enddo\n endif\n!\n! massless contact: initialization of nzsw\n!\n if(mortar.eq.-1) nzsw=0\n!\n do i=1,ntie\n if(tieset(1,i)(81:81).ne.'C') cycle\n kneigh=1\n slavset=tieset(2,i)\n imat=int(tietol(2,i))\n c0coef=elcon(4,1,imat)\n!\n! check whether an adjust node set has been defined\n! only checked at the start of the first step\n!\nc if((istep.eq.1).and.(iinc.eq.1).and.(iit.le.0)) then\n if((istep.eq.1).and.(iit.lt.0)) then\n iset=0\n if(tieset(1,i)(1:1).ne.' ') then\n noset(1:80)=tieset(1,i)(1:80)\n noset(81:81)=' '\n ipos=index(noset,' ')\n noset(ipos:ipos)='N'\nc do iset=1,nset\nc if(set(iset).eq.noset) exit\nc enddo\n call cident81(set,noset,nset,id)\n iset=nset+1\n if(id.gt.0) then\n if(noset.eq.set(id)) then\n iset=id\n endif\n endif\n kflag=1\n call isortii(ialset(istartset(iset)),idummy,\n & iendset(iset)-istartset(iset)+1,kflag)\n endif\n endif\n! \n! determine the area of the slave surfaces\n! \n do l = itiefac(1,i), itiefac(2,i)\n ifaces = islavsurf(1,l)\n nelems = int(ifaces\/10)\n jfaces = ifaces - nelems*10\n! \n! Decide on the max integration points number, just consider 2D situation \n! \n if(lakon(nelems)(4:5).eq.'8R') then\n mint2d=1\n nopes=4\n nope=8\n elseif(lakon(nelems)(4:4).eq.'8') then\n mint2d=4\n nopes=4\n nope=8\n elseif(lakon(nelems)(4:6).eq.'20R') then\n mint2d=4\n nopes=8\n nope=20\n elseif(lakon(nelems)(4:5).eq.'20') then\n mint2d=9\n nopes=8\n nope=20\n elseif(lakon(nelems)(4:5).eq.'10') then\n mint2d=3\n nopes=6\n nope=10\n elseif(lakon(nelems)(4:4).eq.'4') then\n mint2d=1\n nopes=3\n nope=4\n! \n! treatment of wedge faces\n! \n elseif(lakon(nelems)(4:4).eq.'6') then\n mint2d=1\n nope=6\n if(jfaces.le.2) then\n nopes=3\n else\n nopes=4\n endif\n elseif(lakon(nelems)(4:5).eq.'15') then\n nope=15\n if(jfaces.le.2) then\n mint2d=3\n nopes=6\n else\n mint2d=4\n nopes=8\n endif\n endif\n! \n! actual position of the nodes belonging to the\n! slave surface\n! \n do j=1,nope\n konl(j)=kon(ipkon(nelems)+j)\n enddo\n! \n if((nope.eq.20).or.(nope.eq.8)) then\n do m=1,nopes\n do j=1,3\n xl2(j,m)=co(j,konl(ifaceq(m,jfaces)))+\n & vold(j,konl(ifaceq(m,jfaces)))\n enddo\n enddo\n elseif((nope.eq.10).or.(nope.eq.4)) then\n do m=1,nopes\n do j=1,3\n xl2(j,m)=co(j,konl(ifacet(m,jfaces)))+\n & vold(j,konl(ifacet(m,jfaces)))\n enddo\n enddo\n elseif(nope.eq.15) then\n do m=1,nopes\n do j=1,3\n xl2(j,m)=co(j,konl(ifacew2(m,jfaces)))+\n & vold(j,konl(ifacew2(m,jfaces)))\n enddo\n enddo\n else\n do m=1,nopes\n do j=1,3\n xl2(j,m)=co(j,konl(ifacew1(m,jfaces)))+\n & vold(j,konl(ifacew1(m,jfaces)))\n enddo\n enddo\n endif\n! \n! calculating the area of the slave face\n!\n area=0.d0\n do m=1,mint2d\n if((lakon(nelems)(4:5).eq.'8R').or.\n & ((lakon(nelems)(4:4).eq.'6').and.(nopes.eq.4))) then\n xi=gauss2d1(1,m)\n et=gauss2d1(2,m)\n weight=weight2d1(m)\n elseif((lakon(nelems)(4:4).eq.'8').or.\n & (lakon(nelems)(4:6).eq.'20R').or.\n & ((lakon(nelems)(4:5).eq.'15').and.\n & (nopes.eq.8))) then\n xi=gauss2d2(1,m)\n et=gauss2d2(2,m)\n weight=weight2d2(m)\n elseif(lakon(nelems)(4:4).eq.'2') then\n xi=gauss2d3(1,m)\n et=gauss2d3(2,m)\n weight=weight2d3(m)\n elseif((lakon(nelems)(4:5).eq.'10').or.\n & ((lakon(nelems)(4:5).eq.'15').and.\n & (nopes.eq.6))) then\n xi=gauss2d5(1,m)\n et=gauss2d5(2,m)\n weight=weight2d5(m)\n elseif((lakon(nelems)(4:4).eq.'4').or.\n & ((lakon(nelems)(4:4).eq.'6').and.\n & (nopes.eq.3))) then\n xi=gauss2d4(1,m)\n et=gauss2d4(2,m)\n weight=weight2d4(m)\n endif\n! \nc if(nopes.eq.9) then\nc call shape9q(xi,et,xl2,xsj2,xs2,shp2,iflag)\n if(nopes.eq.8) then\n call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag)\n elseif(nopes.eq.4) then\n call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag)\n elseif(nopes.eq.6) then\n call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag)\nc elseif(nopes.eq.7) then\nc call shape7tri(xi,et,xl2,xsj2,xs2,shp2,iflag)\n else\n call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag)\n endif\n area=area+weight*dsqrt(xsj2(1)**2+xsj2(2)**2+\n & xsj2(3)**2)\n enddo\n areaslav(l)=area\n enddo\n!\n! search a master face for each slave node and generate a contact\n! spring element if successful\n! \n nstart=itietri(1,i)-1\n n=itietri(2,i)-nstart\n if(n.lt.kneigh) kneigh=n\n do j=1,n\n xo(j)=cg(1,nstart+j)\n x(j)=xo(j)\n nx(j)=j\n yo(j)=cg(2,nstart+j)\n y(j)=yo(j)\n ny(j)=j\n zo(j)=cg(3,nstart+j)\n z(j)=zo(j)\n nz(j)=j\n enddo\n kflag=2\n call dsort(x,nx,n,kflag)\n call dsort(y,ny,n,kflag)\n call dsort(z,nz,n,kflag)\n!\n do j=nslavnode(i)+1,nslavnode(i+1)\n if(iit.le.0) springarea(2,j)=0.d0\n node=islavnode(j)\n!\n! calculating the area corresponding to the\n! slave node; is made up of the area\n! of the neighboring slave faces\n!\n area=0.d0\n index1=iponoels(node)\n do\n if(index1.eq.0) exit\n irelslavface=inoels(1,index1)\n if((itiefac(1,i).le.irelslavface).and.\n & (irelslavface.le.itiefac(2,i))) then\n area=area+areaslav(irelslavface)*\n & xnoels(index1)\n endif\n index1=inoels(2,index1)\n enddo\n! \n do k=1,3\n p(k)=co(k,node)+vold(k,node)\n enddo\n! \n! determining the kneigh neighboring master contact\n! triangle centers of gravity\n! \n call near3d(xo,yo,zo,x,y,z,nx,ny,nz,p(1),p(2),p(3),\n & n,neigh,kneigh)\n! \n isol=0\n! \n itriold=0\n itri=neigh(1)+itietri(1,i)-1\n ntriangle=0\n ntriangle_=100\n! \n loop1: do\n do l=1,3\n ll=4*l-3\n dist=straight(ll,itri)*p(1)+\n & straight(ll+1,itri)*p(2)+\n & straight(ll+2,itri)*p(3)+\n & straight(ll+3,itri)\n! \n! 1.d-6 was increased to 1.d-3 on 19\/04\/2012\n! this is important for 2d-calculations or\n! calculations for which structures fit exactly\n! at their boundaries\n! \n if(dist.gt.1.d-3*dsqrt(area)) then\n itrinew=imastop(l,itri)\n if(itrinew.eq.0) then\nc write(*,*) '**border reached'\n exit loop1\n elseif((itrinew.lt.itietri(1,i)).or.\n & (itrinew.gt.itietri(2,i))) then\nc write(*,*) '**border reached'\n exit loop1\n elseif(itrinew.eq.itriold) then\nc write(*,*) '**solution in between triangles'\n isol=itri\n exit loop1\n else\n call nident(itriangle,itrinew,ntriangle,id)\n if(id.gt.0) then\n if(itriangle(id).eq.itrinew) then\nc write(*,*) '**circular path;no solution'\n exit loop1\n endif\n endif\n ntriangle=ntriangle+1\n if(ntriangle.gt.ntriangle_) then\nc write(*,*) '**too many iterations'\n exit loop1\n endif\n do k=ntriangle,id+2,-1\n itriangle(k)=itriangle(k-1)\n enddo\n itriangle(id+1)=itrinew\n itriold=itri\n itri=itrinew\n cycle loop1\n endif\n elseif(l.eq.3) then\nc write(*,*) '**regular solution'\n isol=itri\n exit loop1\n endif\n enddo\n enddo loop1\n! \n! check whether distance is larger than c0:\n! no element is generated\n! \n if(isol.ne.0) then\n!\n! determining the clearance\n!\n! identifying the element face to which the\n! triangle belongs\n!\n nelem=int(koncont(4,itri)\/10.d0)\n jface=koncont(4,itri)-10*nelem\n!\n indexe=ipkon(nelem)\n if(lakon(nelem)(4:5).eq.'20') then\n nopes=8\n nface=6\n elseif(lakon(nelem)(4:4).eq.'8') then\n nopes=4\n nface=6\n elseif(lakon(nelem)(4:5).eq.'10') then\n nopes=6\n nface=4\n elseif(lakon(nelem)(4:4).eq.'4') then\n nopes=3\n nface=4\n elseif(lakon(nelem)(4:5).eq.'15') then\n if(jface.le.2) then\n nopes=6\n else\n nopes=8\n endif\n nface=5\n nope=15\n elseif(lakon(nelem)(4:4).eq.'6') then\n if(jface.le.2) then\n nopes=3\n else\n nopes=4\n endif\n nface=5\n nope=6\n else\n cycle\n endif\n!\n! determining the nodes of the face\n!\n if(nface.eq.4) then\n do k=1,nopes\n nodef(k)=kon(indexe+ifacet(k,jface))\n enddo\n elseif(nface.eq.5) then\n if(nope.eq.6) then\n do k=1,nopes\n nodef(k)=kon(indexe+ifacew1(k,jface))\n enddo\n elseif(nope.eq.15) then\n do k=1,nopes\n nodef(k)=kon(indexe+ifacew2(k,jface))\n enddo\n endif\n elseif(nface.eq.6) then\n do k=1,nopes\n nodef(k)=kon(indexe+ifaceq(k,jface))\n enddo\n endif\n!\n! orthogonal projection on the element face\n!\n do k=1,nopes\n do l=1,3\n pl(l,k)=co(l,nodef(k))+vold(l,nodef(k))\n enddo\n enddo\n do l=1,3\n pproj(l)=p(l)\n enddo\n!\n call attach_2d(pl,pproj,nopes,ratio,dist,xi,et)\n!\n do l=1,3\n al(l)=p(l)-pproj(l)\n enddo\n!\n! determining the jacobian vector on the surface \n!\n if(nopes.eq.8) then\n call shape8q(xi,et,pl,xm,xs2,shp2,iflag)\n elseif(nopes.eq.4) then\n call shape4q(xi,et,pl,xm,xs2,shp2,iflag)\n elseif(nopes.eq.6) then\n call shape6tri(xi,et,pl,xm,xs2,shp2,iflag)\n else\n call shape3tri(xi,et,pl,xm,xs2,shp2,iflag)\n endif\n!\n! normal on the surface\n!\n dm=dsqrt(xm(1)*xm(1)+xm(2)*xm(2)+xm(3)*xm(3))\n do l=1,3\n xn(l)=xm(l)\/dm\n enddo\n!\n! massless contact: filling matrix Wb\n!\n if(mortar.eq.-1) then\n!\n! determining a local system (cf. springforc_n2f.f)\n!\n if(1.d0 - dabs(xn(1)).lt.1.5231d-6) then \n! \n! calculating the local directions on master surface\n!\n t1(1)=-xn(3)*xn(1)\n t1(2)=-xn(3)*xn(2)\n t1(3)=1.d0-xn(3)*xn(3)\n else\n t1(1)=1.d0-xn(1)*xn(1)\n t1(2)=-xn(1)*xn(2)\n t1(3)=-xn(1)*xn(3)\n endif\n dt1=dsqrt(t1(1)*t1(1)+t1(2)*t1(2)+t1(3)*t1(3))\n do m1=1,3\n t1(m1)=t1(m1)\/dt1\n enddo\n t2(1)=xn(2)*t1(3)-xn(3)*t1(2)\n t2(2)=xn(3)*t1(1)-xn(1)*t1(3)\n t2(3)=xn(1)*t1(2)-xn(2)*t1(1) \n!\n! storing in a matrix xns=[xn t1 t2]\n!\n do m1=1,3\n xns(m1,1)=xn(m1)\n xns(m1,2)=t1(m1)\n xns(m1,3)=t2(m1)\n enddo\n!\n! sorting the nodes of the master face in\n! ascending order\n!\n length=nmastnode(i+1)-nmastnode(i)\n do k=1,nopes\n iorder(k)=k\n enddo\n kflag=2\n call isortii(nodef,iorder,nopes,kflag)\n!\n jbasis=3*(j-1)\n do m2=1,3\n jqw(jbasis+m2)=nzsw+1\n do m1=1,3\n nzsw=nzsw+1\n auw(nzsw)=xns(m1,m2)\n iroww(nzsw)=jbasis+m1\n enddo\n!\n do k=1,nopes\n call nident(imastnode(nmastnode(i)+1),\n & nodef(k),length,id)\n kbasis=3*(nslavnode(ntie+1)+nmastnode(i)+id-1)\n do m1=1,3\n nzsw=nzsw+1\n auw(nzsw)=-ratio(iorder(k))*xns(m1,m2)\n iroww(nzsw)=kbasis+m1\n enddo\n enddo\n! \n enddo\n cycle\n endif\n!\n! distance from surface along normal (= clearance)\n!\n clear=al(1)*xn(1)+al(2)*xn(2)+al(3)*xn(3)\n if((istep.eq.1).and.(iit.lt.0.d0)) then\n if(clear.lt.0.d0) then\n springarea(2,j)=clear\n endif\n endif\n if(nmethod.eq.1) then\n clear=clear-springarea(2,j)*(1.d0-reltime)\n endif\n! \n! check for an adjust parameter (only at the start\n! of the first step)\n! \n if((istep.eq.1).and.(iit.lt.0)) then\n if(iset.ne.0) then\n! \n! check whether node belongs to the adjust node\n! set\n! \n call nident(ialset(istartset(iset)),node,\n & iendset(iset)-istartset(iset)+1,id)\n if(id.gt.0) then\n if(ialset(istartset(iset)+id-1).eq.node) then\n do k=1,3\n co(k,node)=co(k,node)-\n & clear*straight(12+k,itri)\n enddo\n clear=0.d0\n endif\n endif\n elseif(dabs(tietol(1,i)).ge.2.d0) then\n! \n! adjust parameter\n! \n adjust=dabs(tietol(1,i))-2.d0\n if(clear.le.adjust) then\n do k=1,3\n co(k,node)=co(k,node)-\n & clear*straight(12+k,itri)\n enddo\n clear=0.d0\n endif\n endif\n endif\n! \n if(int(elcon(3,1,imat)).eq.1) then\n!\n! exponential overclosure\n!\n beta=elcon(1,1,imat)\n c0=dlog(100.d0)\/beta\n else\n!\n! linear or tabular overclosure\n!\n if(dabs(area).gt.0.d0) then\n c0=c0coef*dsqrt(area)\n else\n c0=1.d-10\n endif\n endif\n if(clear.gt.c0) then\n isol=0\n!\n endif\n endif\n! \n if(isol.ne.0) then\n! \n! plane spring\n! \n ne=ne+1\n ipkon(ne)=ifree\n lakon(ne)='ESPRNGC '\n ielmat(1,ne)=imat\n!\n! nasym indicates whether at least one contact\n! spring elements exhibits friction in the present\n! step. If so, nasym=1, else nasym=0; nasym=1\n! triggers the asymmetric equation solver\n!\n if(ncmat_.ge.7) then\n if(elcon(6,1,imat).gt.0) then\n nasym=1\n endif\n endif\n if(ncmat_.ge.8) then\n if(elcon(8,1,imat).gt.0) then\n nasym=1\n endif\n endif\n!\nc nelem=int(koncont(4,itri)\/10.d0)\nc jface=koncont(4,itri)-10*nelem\n!\n! storing the area corresponding to the slave node\n! and the clearance if penetration takes place,\n! i.e. clear <0 at the start of the first step\n! \n springarea(1,j)=area\nc if((istep.eq.1).and.(iit.lt.0.d0)) then\nc if(clear.lt.0.d0) then\nc springarea(2,j)=clear\nc else\nc springarea(2,j)=0.d0\nc endif\nc endif\n!\n do k=1,nopes\n kon(ifree+k)=nodef(k)\n enddo\n ifree=ifree+nopes+1\n kon(ifree)=node\n ifree=ifree+1\n kon(ifree)=j\n!\n write(lakon(ne)(8:8),'(i1)') nopes\n!\n indexel=indexel+1\n!\n if((nopes.eq.3).or.(nopes.eq.6)) then\n if(filab(1)(3:3).eq.'C') then\n write(27,100) setname(1:lenset)\n 100 format('*ELEMENT,TYPE=C3D4,ELSET=',A)\n write(27,*) ne0+indexel,',',nodef(1),',',\n & nodef(2),',',nodef(3),',',node\n endif\n else\n if(filab(1)(3:3).eq.'C') then\n write(27,101) setname(1:lenset)\n 101 format('*ELEMENT,TYPE=C3D6,ELSET=',A)\n write(27,*) ne0+indexel,',',nodef(2),',',node,\n & ',',\n & nodef(3),',',nodef(1),',',node,',',nodef(4)\n endif\n endif\n endif\n! \n enddo\n enddo\n!\n! closing the file containing the contact elements\n! \n if(filab(1)(3:3).eq.'C') then\n close(27)\n endif\n!\n! complete the definition of jqw for massless contact\n! \n if(mortar.eq.-1) then\n jqw(3*nslavnode(ntie+1)+1)=nzsw+1\n endif\n! \n return\n end\n","avg_line_length":34.322622108,"max_line_length":78,"alphanum_fraction":0.4141107741} {"size":813,"ext":"f90","lang":"FORTRAN","max_stars_count":61.0,"content":"! RUN: %S\/test_modfile.sh %s %t %flang_fc1\n! REQUIRES: shell\n! Test 7.6 enum values\n\nmodule m1\n integer, parameter :: x(1) = [4]\n enum, bind(C)\n enumerator :: red, green\n enumerator blue\n enumerator yellow\n enumerator :: purple = 2\n enumerator :: brown\n end enum\n\n enum, bind(C)\n enumerator :: oak, beech = -rank(x)*x(1), pine, poplar = brown\n end enum\n\nend\n\n!Expect: m1.mod\n!module m1\n!integer(4),parameter::x(1_8:1_8)=[INTEGER(4)::4_4]\n!integer(4),parameter::red=0_4\n!integer(4),parameter::green=1_4\n!integer(4),parameter::blue=2_4\n!integer(4),parameter::yellow=3_4\n!integer(4),parameter::purple=2_4\n!integer(4),parameter::brown=3_4\n!integer(4),parameter::oak=0_4\n!integer(4),parameter::beech=-4_4\n!intrinsic::rank\n!integer(4),parameter::pine=-3_4\n!integer(4),parameter::poplar=3_4\n!end\n\n","avg_line_length":21.972972973,"max_line_length":66,"alphanum_fraction":0.6851168512} {"size":1376,"ext":"for","lang":"FORTRAN","max_stars_count":null,"content":" SUBROUTINE mppi(n)\r\n INTEGER n,IAOFF,NMAX\r\n PARAMETER (IAOFF=48,NMAX=8192)\r\nCU USES mpinit,mp2dfr,mpadd,mpinv,mplsh,mpmov,mpmul,mpsdv,mpsqrt\r\n INTEGER ir,j,m\r\n CHARACTER*1 x(NMAX),y(NMAX),sx(NMAX),sxi(NMAX),t(NMAX),s(3*NMAX),\r\n *pi(NMAX)\r\n call mpinit\r\n t(1)=char(2)\r\n do 11 j=2,n\r\n t(j)=char(0)\r\n11 continue\r\n call mpsqrt(x,x,t,n,n)\r\n call mpadd(pi,t,x,n)\r\n call mplsh(pi,n)\r\n call mpsqrt(sx,sxi,x,n,n)\r\n call mpmov(y,sx,n)\r\n1 continue\r\n call mpadd(x,sx,sxi,n)\r\n call mpsdv(x,x(2),n,2,ir)\r\n call mpsqrt(sx,sxi,x,n,n)\r\n call mpmul(t,y,sx,n,n)\r\n call mpadd(t(2),t(2),sxi,n)\r\n x(1)=char(ichar(x(1))+1)\r\n y(1)=char(ichar(y(1))+1)\r\n call mpinv(s,y,n,n)\r\n call mpmul(y,t(3),s,n,n)\r\n call mplsh(y,n)\r\n call mpmul(t,x,s,n,n)\r\n continue\r\n m=mod(255+ichar(t(2)),256)\r\n do 12 j=3,n\r\n if(ichar(t(j)).ne.m)goto 2\r\n12 continue\r\n if (abs(ichar(t(n+1))-m).gt.1)goto 2\r\n write (*,*) 'pi='\r\n s(1)=char(ichar(pi(1))+IAOFF)\r\n s(2)='.'\r\n call mp2dfr(pi(2),s(3),n-1,m)\r\n write (*,'(1x,64a1)') (s(j),j=1,m+1)\r\n return\r\n2 continue\r\n call mpmul(s,pi,t(2),n,n)\r\n call mpmov(pi,s(2),n)\r\n goto 1\r\n END\r\n","avg_line_length":29.2765957447,"max_line_length":72,"alphanum_fraction":0.4745639535} {"size":5703,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":" ! UNION 2.1 Supernovae Ia dataset\n !\n ! This module uses the SCP (Supernova Cosmology Project) Union 2\n ! compilation. Please cite\n ! \"Suzuki et al. (SCP) 2011, arXiv:1105.3470 (2011 ApJ Dec 20 issue)\".\n ! and the references of other compiled supernovae data are in there.\n !\n ! Originally by A Slosar, heavily based on the original code by A Lewis, S Bridle\n ! and D Rapetti E-mail: Anze Slosar (anze@berkeley.edu) for questions\n ! about the code and David Rubin (rubind@berkeley.edu) for questions\n ! regarding the dataset itself. Updated by Nao Suzuki (nsuzuki@lbl.gov)\n !\n ! Marginalizes anayltically over H_0 with flat prior. (equivalent to\n ! marginalizing over M, absolute magnitude; see appendix F of cosmomc\n ! paper). Resultant log likelihood has arbitary origin and is\n ! numerically equal to -chi^2\/2 value at the best-fit value.\n !\n ! Update Note :\n !\n ! Union1 (Kowalski et al 2008) : 307 SNe with SALT1 fit (Guy et al 2005)\n ! Union2 (Amanullah et al 2010) : 557 SNe with SALT2 fit (Guy et al 2007)\n ! Union2.1 (Suzuki et al 2011) : 580 SNe with SALT2 fit (Guy et al 2007)\n !\n ! The following parameters are used to calculate distance moduli\n ! (see Suzuki et al. 2011 for complete description)\n !\n ! alpha 0.121851859725 ! Stretch Correction Factor\n ! beta 2.46569277393 ! Color Correction Factor\n ! delta -0.0363405630486\n ! M(h=0.7, statistical only) -19.3182761161 ! Absolute B Magnitue of SNIa\n ! M(h=0.7, with systematics) -19.3081547178 ! Absolute B Magnitue of SNIa\n !\n ! Tips for running cosmomc with SCP UNION2.1 data\n !\n ! 1) Place the following 3 data files in your cosmomc data dir (DataDir)\n ! a) sn_z_mu_dmu_plow_union2.1.txt : SN data\n ! SN name, z, distance moduli mu, mu error, host mass weight probability\n ! b) sn_covmat_sys_union2.1.txt : Covariance Matrix with systematic error\n ! c) sn_covmat_nosys_union2.1.txt : Covariance Matrix without systematic error\n !\n ! 2) Make sure DataDir is set in your settings.f90\n ! character(LEN=1024) :: DataDir='yourdirpathto\/cosmomc\/data\/'\n ! The default is 'data\/' and if it works for you, just leave it as it is\n !\n ! 3) Pick SN data 'with' or 'without' systematic error\n ! (default is 'with' systematic error)\n ! Modify the folowing SN_syscovamat=.True. or .False.\n !\n ! 4) To make UNION2 as your default,\n ! either rename supernovae_union2.1.f90 as supernovae.f90 and recompile it\n ! or change targets in your Makefile from supernova to supernovae_union2.1\n !\n ! Note: In your default params.ini, there is a line for 'SN_filename', but this\n ! union2 module does not use it. You can leave it as it is, and cosmomc\n ! runs without any error but that information is not used.\n ! To avoid confusion, you may want to comment it out.\n !\n ! Update Note by Nao Suzuki (LBNL)\n\n module Union2\n use CosmologyTypes\n use MatrixUtils\n use likelihood\n use CosmoTheory\n use Calculator_Cosmology\n use Likelihood_Cosmology\n implicit none\n private\n\n integer, parameter :: SN_num = 580\n\n type, extends(TCosmoCalcLikelihood) :: Union2Likelihood\n double precision :: SN_z(SN_num), SN_moduli(SN_num), SN_modulierr(SN_num), SN_plow(SN_num)\n double precision :: SN_Ninv(SN_num,SN_Num)\n contains\n procedure :: logLikeTheory => SN_LnLike\n end type Union2Likelihood\n\n public Union2Likelihood,Union2Likelihood_Add\n contains\n\n subroutine Union2Likelihood_Add(LikeList, Ini)\n class(TLikelihoodList) :: LikeList\n class(TSettingIni) :: ini\n Type(Union2Likelihood), pointer :: this\n character (LEN=20):: name\n integer i\n ! The following line selects which error estimate to use\n ! default .True. = with systematic errors\n logical :: Union_syscovmat = .False. !! Use covariance matrix with or without systematics\n Type(TTextFile) :: F\n\n if (.not. Ini%Read_Logical('use_Union',.false.)) return\n\n allocate(this)\n this%LikelihoodType = 'SN'\n this%name='Union2.1'\n this%needs_background_functions = .true.\n call LikeList%Add(this)\n\n Union_syscovmat = Ini%read_Logical('Union_syscovmat',Union_syscovmat)\n\n if (Feedback > 0) write (*,*) 'Reading: supernovae data'\n call F%Open(trim(DataDir)\/\/'sn_z_mu_dmu_plow_union2.1.txt')\n do i=1, sn_num\n read(F%unit, *) name, this%SN_z(i),this%SN_moduli(i), &\n this%SN_modulierr(i),this%SN_plow(i)\n ! read(unit, *) name, SN_z(i),SN_moduli(i)\n end do\n call F%Close()\n\n if (Union_syscovmat) then\n call F%Open(trim(DataDir)\/\/'sn_wmat_sys_union2.1.txt')\n else\n call F%Open(trim(DataDir)\/\/'sn_wmat_nosys_union2.1.txt')\n end if\n\n do i=1, sn_num\n read (F%unit,*) this%sn_ninv (i,1:sn_num)\n end do\n\n call F%Close()\n\n end subroutine Union2Likelihood_Add\n\n function SN_LnLike(this, CMB)\n !Assume this is called just after CAMB with the correct model use camb\n Class(CMBParams) CMB\n Class(Union2Likelihood) :: this\n real(mcp) SN_LnLike\n integer i\n double precision z\n real(mcp) diffs(SN_num), chisq\n\n !! This is actually seems to be faster without OMP\n\n do i=1, SN_num\n z= this%SN_z(i)\n diffs(i) = 5*log10((1+z)**2*this%Calculator%AngularDiameterDistance(z))+25 -this%sn_moduli(i)\n end do\n\n chisq = dot_product(diffs,matmul(this%sn_ninv,diffs))\n\n !! H0 normalisation alla Bridle and co.\n\n if (Feedback > 1) write (*,*) 'SN chisq: ', chisq\n\n SN_LnLike = chisq\/2\n\n\n end function SN_LnLike\n\n\n end module Union2\n","avg_line_length":36.7935483871,"max_line_length":101,"alphanum_fraction":0.6699982465} {"size":58445,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":"!> This module uses full-field binary wind files to determine the wind inflow.\n!! This module assumes that the origin, (0,0,0), is located at the tower centerline at ground level,\n!! and that all units are specified in the metric system (using meters and seconds).\n!! Data is shifted by half the grid width to account for turbine yaw (so that data in the X\n!! direction actually starts at -1*p%FFYHWid meters).\nMODULE IfW_FFWind_Base\n!!\n!! Created 25-Sep-2009 by B. Jonkman, National Renewable Energy Laboratory\n!! using subroutines and modules from AeroDyn v12.58\n!!\n!!----------------------------------------------------------------------------------------------------\n!! Feb 2013 v2.00.00 A. Platt\n!! -- updated to the new framework\n!! -- Modified to use NWTC_Library v. 2.0\n!! -- Note: Jacobians are not included in this version.\n!!\n!**********************************************************************************************************************************\n! LICENSING\n! Copyright (C) 2015-2016 National Renewable Energy Laboratory\n!\n! This file is part of InflowWind.\n!\n! Licensed under the Apache License, Version 2.0 (the \"License\");\n! you may not use this file except in compliance with the License.\n! You may obtain a copy of the License at\n!\n! http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n!\n! Unless required by applicable law or agreed to in writing, software\n! distributed under the License is distributed on an \"AS IS\" BASIS,\n! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n! See the License for the specific language governing permissions and\n! limitations under the License.\n!\n!**********************************************************************************************************************************\n\n USE NWTC_Library\n USE IfW_FFWind_Base_Types\n\n IMPLICIT NONE\n\n \n INTEGER(IntKi), PARAMETER :: WindProfileType_None = -1 !< don't add wind profile; already included in input \n INTEGER(IntKi), PARAMETER :: WindProfileType_Constant = 0 !< constant wind\n INTEGER(IntKi), PARAMETER :: WindProfileType_Log = 1 !< logarithmic\n INTEGER(IntKi), PARAMETER :: WindProfileType_PL = 2 !< power law\n\n INTEGER(IntKi), PARAMETER :: ScaleMethod_None = 0 !< no scaling\n INTEGER(IntKi), PARAMETER :: ScaleMethod_Direct = 1 !< direct scaling factors\n INTEGER(IntKi), PARAMETER :: ScaleMethod_StdDev = 2 !< requested standard deviation\n \n\nCONTAINS\n!====================================================================================================\n\n!====================================================================================================\n!> This routine acts as a wrapper for the GetWindSpeed routine. It steps through the array of input\n!! positions and calls the GetWindSpeed routine to calculate the velocities at each point.\nSUBROUTINE IfW_FFWind_CalcOutput(Time, PositionXYZ, p, Velocity, DiskVel, ErrStat, ErrMsg)\n\n IMPLICIT NONE\n\n\n ! Passed Variables\n REAL(DbKi), INTENT(IN ) :: Time !< time from the start of the simulation\n REAL(ReKi), INTENT(IN ) :: PositionXYZ(:,:) !< Array of XYZ coordinates, 3xN\n TYPE(IfW_FFWind_ParameterType), INTENT(IN ) :: p !< Parameters\n REAL(ReKi), INTENT(INOUT) :: Velocity(:,:) !< Velocity output at Time (Set to INOUT so that array does not get deallocated)\n REAL(ReKi), INTENT( OUT) :: DiskVel(3) !< HACK for AD14: disk velocity output at Time\n\n ! Error handling\n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< error status\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< The error message\n\n ! local variables\n INTEGER(IntKi) :: NumPoints ! Number of points specified by the PositionXYZ array\n\n ! local counters\n INTEGER(IntKi) :: PointNum ! a loop counter for the current point\n\n ! temporary variables\n INTEGER(IntKi) :: TmpErrStat ! temporary error status\n CHARACTER(ErrMsgLen) :: TmpErrMsg ! temporary error message\n CHARACTER(*), PARAMETER :: RoutineName = 'IfW_FFWind_CalcOutput'\n\n\n !-------------------------------------------------------------------------------------------------\n ! Check that the module has been initialized.\n !-------------------------------------------------------------------------------------------------\n\n ErrStat = ErrID_None\n ErrMsg = ''\n\n !-------------------------------------------------------------------------------------------------\n ! Initialize some things\n !-------------------------------------------------------------------------------------------------\n\n\n ! The array is transposed so that the number of points is the second index, x\/y\/z is the first.\n ! This is just in case we only have a single point, the SIZE command returns the correct number of points.\n NumPoints = SIZE(PositionXYZ,2)\n\n\n ! Step through all the positions and get the velocities\n !$OMP PARALLEL default(shared) if(PointNum>1000)\n !$OMP do private(PointNum, TmpErrStat, TmpErrMsg ) schedule(runtime)\n DO PointNum = 1, NumPoints\n\n ! Calculate the velocity for the position\n Velocity(:,PointNum) = FFWind_Interp(Time,PositionXYZ(:,PointNum),p,TmpErrStat,TmpErrMsg)\n\n ! Error handling\n IF (TmpErrStat \/= ErrID_None) THEN ! adding this so we don't have to convert numbers to strings every time\n !$OMP CRITICAL ! Needed to avoid data race on ErrStat and ErrMsg\n ErrStat = ErrID_None\n ErrMsg = \"\"\n CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName\/\/\" [position=(\"\/\/ &\n TRIM(Num2LStr(PositionXYZ(1,PointNum)))\/\/\", \"\/\/ &\n TRIM(Num2LStr(PositionXYZ(2,PointNum)))\/\/\", \"\/\/ &\n TRIM(Num2LStr(PositionXYZ(3,PointNum)))\/\/\") in wind-file coordinates]\" )\n !$OMP END CRITICAL\n END IF\n\n ENDDO\n !$OMP END DO \n !$OMP END PARALLEL\n IF (ErrStat >= AbortErrLev) RETURN ! Return cannot be in parallel loop\n\n IF (p%AddMeanAfterInterp) THEN\n DO PointNum = 1, NumPoints\n Velocity(1,PointNum) = Velocity(1,PointNum) + CalculateMeanVelocity(p,PositionXYZ(3,PointNum))\n ENDDO\n END IF\n\n\n !REMOVE THIS for AeroDyn 15\n ! Return the average disk velocity values needed by AeroDyn 14. This is the WindInf_ADhack_diskVel routine.\n DiskVel(1) = p%MeanFFWS\n DiskVel(2:3) = 0.0_ReKi\n\n\n RETURN\n\nEND SUBROUTINE IfW_FFWind_CalcOutput\n!+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n!> This function is used to interpolate into the full-field wind array or tower array if it has\n!! been defined and is necessary for the given inputs. It receives X, Y, Z and\n!! TIME from the calling routine. It then computes a time shift due to a nonzero X based upon\n!! the average windspeed. The modified time is used to decide which pair of time slices to interpolate\n!! within and between. After finding the two time slices, it decides which four grid points bound the\n!! (Y,Z) pair. It does a bilinear interpolation for each time slice. Linear interpolation is then used\n!! to interpolate between time slices. This routine assumes that X is downwind, Y is to the left when\n!! looking downwind and Z is up. It also assumes that no extrapolation will be needed.\n!!\n!! If tower points are used, it assumes the velocity at the ground is 0. It interpolates between\n!! heights and between time slices, but ignores the Y input.\n!!\n!! 11\/07\/1994 - Created by M. Buhl from the original TURBINT.\n!! 09\/25\/1997 - Modified by M. Buhl to use f90 constructs and new variable names. Renamed to FF_Interp.\n!! 09\/23\/2009 - Modified by B. Jonkman to use arguments instead of modules to determine time and position.\n!! Height is now relative to the ground\n!! 16-Apr-2013 - A. Platt, NREL. Converted to modular framework. Modified for NWTC_Library 2.0\nFUNCTION FFWind_Interp(Time, Position, p, ErrStat, ErrMsg)\n\n IMPLICIT NONE\n\n CHARACTER(*), PARAMETER :: RoutineName=\"FFWind_Interp\"\n\n REAL(DbKi), INTENT(IN ) :: Time !< time (s)\n REAL(ReKi), INTENT(IN ) :: Position(3) !< takes the place of XGrnd, YGrnd, ZGrnd\n TYPE(IfW_FFWind_ParameterType), INTENT(IN ) :: p !< Parameters\n REAL(ReKi) :: FFWind_Interp(3) !< The U, V, W velocities\n\n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< error status\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< error message \n\n ! Local Variables:\n\n REAL(ReKi) :: TimeShifted\n REAL(ReKi),PARAMETER :: Tol = 1.0E-3 ! a tolerance for determining if two reals are the same (for extrapolation)\n REAL(ReKi) :: T\n REAL(ReKi) :: TGRID\n REAL(ReKi) :: Y\n REAL(ReKi) :: YGRID\n REAL(ReKi) :: Z\n REAL(ReKi) :: ZGRID\n REAL(ReKi) :: N(8) ! array for holding scaling factors for the interpolation algorithm\n REAL(ReKi) :: u(8) ! array for holding the corner values for the interpolation algorithm across a cubic volume\n REAL(ReKi) :: M(4) ! array for holding scaling factors for the interpolation algorithm\n REAL(ReKi) :: v(4) ! array for holding the corner values for the interpolation algorithm across an area\n\n INTEGER(IntKi) :: IDIM\n INTEGER(IntKi) :: ITHI\n INTEGER(IntKi) :: ITLO\n INTEGER(IntKi) :: IYHI\n INTEGER(IntKi) :: IYLO\n INTEGER(IntKi) :: IZHI\n INTEGER(IntKi) :: IZLO\n\n LOGICAL :: OnGrid\n\n !-------------------------------------------------------------------------------------------------\n ! Initialize variables\n !-------------------------------------------------------------------------------------------------\n\n FFWind_Interp(:) = 0.0_ReKi ! the output velocities (in case p%NFFComp \/= 3)\n\n ErrStat = ErrID_None\n ErrMsg = \"\"\n \n \n !-------------------------------------------------------------------------------------------------\n ! By definition, wind below the ground is always zero (no turbulence, either). \n !-------------------------------------------------------------------------------------------------\n IF ( Position(3) <= 0.0_ReKi ) THEN\n FFWind_Interp = 0.0_ReKi\n RETURN\n END IF\n \n\n !-------------------------------------------------------------------------------------------------\n ! Find the bounding time slices.\n !-------------------------------------------------------------------------------------------------\n\n ! Perform the time shift. At time=0, a point half the grid width downstream (p%FFYHWid) will index into the zero time slice.\n ! If we did not do this, any point downstream of the tower at the beginning of the run would index outside of the array.\n ! This all assumes the grid width is at least as large as the rotor. If it isn't, then the interpolation will not work.\n\n\n TimeShifted = TIME + ( p%InitXPosition - Position(1) )*p%InvMFFWS ! in distance, X: InputInfo%Position(1) - p%InitXPosition - TIME*p%MeanFFWS\n\n\n IF ( p%Periodic ) THEN ! translate TimeShifted to ( 0 <= TimeShifted < p%TotalTime )\n\n TimeShifted = MODULO( TimeShifted, p%TotalTime )\n ! If TimeShifted is a very small negative number, modulo returns the incorrect value due to internal rounding errors.\n ! See bug report #471\n IF (TimeShifted == p%TotalTime) TimeShifted = 0.0_ReKi\n\n TGRID = TimeShifted*p%FFRate\n ITLO = INT( TGRID ) ! convert REAL to INTEGER (add 1 later because our grids start at 1, not 0)\n T = 2.0_ReKi * ( TGRID - REAL(ITLO, ReKi) ) - 1.0_ReKi ! a value between -1 and 1 that indicates a relative position between ITLO and ITHI\n\n ITLO = ITLO + 1\n IF ( ITLO == p%NFFSteps ) THEN\n ITHI = 1\n ELSE\n IF (ITLO > p%NFFSteps) ITLO = 1\n ITHI = ITLO + 1\n ENDIF\n\n\n ELSE\n\n TGRID = TimeShifted*p%FFRate\n ITLO = INT( TGRID ) ! convert REAL to INTEGER (add 1 later because our grids start at 1, not 0)\n T = 2.0_ReKi * ( TGRID - REAL(ITLO, ReKi) ) - 1.0_ReKi ! a value between -1 and 1 that indicates a relative position between ITLO and ITHI\n\n ITLO = ITLO + 1 ! add one since our grids start at 1, not 0\n ITHI = ITLO + 1\n\n IF ( ITLO >= p%NFFSteps .OR. ITLO < 1 ) THEN\n IF ( ITLO == p%NFFSteps ) THEN\n ITHI = ITLO\n IF ( T <= TOL ) THEN ! we're on the last point\n T = -1.0_ReKi\n ELSE ! We'll extrapolate one dt past the last value in the file\n ITLO = ITHI - 1\n ENDIF\n ELSE\n ErrMsg = ' Error: FF wind array was exhausted at '\/\/TRIM( Num2LStr( REAL( TIME, ReKi ) ) )\/\/ &\n ' seconds (trying to access data at '\/\/TRIM( Num2LStr( REAL( TimeShifted, ReKi ) ) )\/\/' seconds).'\n ErrStat = ErrID_Fatal\n RETURN\n ENDIF\n ENDIF\n\n ENDIF\n\n\n !-------------------------------------------------------------------------------------------------\n ! Find the bounding rows for the Z position. [The lower-left corner is (1,1) when looking upwind.]\n !-------------------------------------------------------------------------------------------------\n\n ZGRID = ( Position(3) - p%GridBase )*p%InvFFZD\n\n IF (ZGRID > -1*TOL) THEN\n OnGrid = .TRUE.\n\n ! Index for start and end slices\n IZLO = INT( ZGRID ) + 1 ! convert REAL to INTEGER, then add one since our grids start at 1, not 0\n IZHI = IZLO + 1\n\n ! Set Z as a value between -1 and 1 for the relative location between IZLO and IZHI.\n ! Subtract 1_IntKi from Z since the indices are starting at 1, not 0\n Z = 2.0_ReKi * (ZGRID - REAL(IZLO - 1_IntKi, ReKi)) - 1.0_ReKi\n\n IF ( IZLO < 1 ) THEN\n IF ( IZLO == 0 .AND. Z >= 1.0-TOL ) THEN\n Z = -1.0_ReKi\n IZLO = 1\n ELSE\n ErrMsg = ' FF wind array boundaries violated. Grid too small in Z direction (Z='\/\/&\n TRIM(Num2LStr(Position(3)))\/\/' m is below the grid).'\n ErrStat = ErrID_Fatal\n RETURN\n ENDIF\n ELSEIF ( IZLO >= p%NZGrids ) THEN\n IF ( IZLO == p%NZGrids .AND. Z <= TOL ) THEN\n Z = -1.0_ReKi\n IZHI = IZLO ! We're right on the last point, which is still okay\n ELSE\n ErrMsg = ' FF wind array boundaries violated. Grid too small in Z direction (Z='\/\/&\n TRIM(Num2LStr(Position(3)))\/\/' m is above the grid).'\n ErrStat = ErrID_Fatal\n RETURN\n ENDIF\n ENDIF\n\n ELSE\n\n OnGrid = .FALSE. ! this is on the tower\n \n IF (p%InterpTower) then\n \n ! get Z between ground and bottom of grid\n ZGRID = Position(3)\/p%GridBase\n Z = 2.0_ReKi * ZGRID - 1.0_ReKi\n IZHI = 1\n IZLO = 0\n \n IF ( ZGRID < 0.0_ReKi ) THEN\n ErrMsg = ' FF wind array boundaries violated. Grid too small in Z direction '\/\/ &\n '(height (Z='\/\/TRIM(Num2LStr(Position(3)))\/\/' m) is below the ground).'\n ErrStat = ErrID_Fatal\n RETURN\n ENDIF \n \n ELSE\n \n IF ( p%NTGrids < 1) THEN\n ErrMsg = ' FF wind array boundaries violated. Grid too small in Z direction '\/\/ &\n '(height (Z='\/\/TRIM(Num2LStr(Position(3)))\/\/' m) is below the grid and no tower points are defined).'\n ErrStat = ErrID_Fatal\n RETURN\n ENDIF\n\n IZLO = INT( -1.0*ZGRID ) + 1 ! convert REAL to INTEGER, then add one since our grids start at 1, not 0\n\n\n IF ( IZLO >= p%NTGrids ) THEN !our dz is the difference between the bottom tower point and the ground\n IZLO = p%NTGrids\n\n ! Check that this isn't zero. Value between -1 and 1 corresponding to the relative position.\n Z = 1.0_ReKi - 2.0_ReKi * (Position(3) \/ (p%GridBase - REAL(IZLO - 1_IntKi, ReKi)\/p%InvFFZD))\n\n ELSE\n\n ! Set Z as a value between -1 and 1 for the relative location between IZLO and IZHI. Used in the interpolation.\n Z = 2.0_ReKi * (ABS(ZGRID) - REAL(IZLO - 1_IntKi, ReKi)) - 1.0_ReKi\n\n ENDIF\n IZHI = IZLO + 1\n\n ENDIF\n\n END IF\n\n IF ( OnGrid ) THEN ! The tower points don't use this\n\n CALL GetInterpValues(); if (ErrStat\/=ErrID_None) return\n \n !-------------------------------------------------------------------------------------------------\n ! Interpolate on the grid\n !-------------------------------------------------------------------------------------------------\n\n DO IDIM=1,p%NFFComp ! all the components\n\n u(1) = p%FFData( IZHI, IYLO, IDIM, ITLO )\n u(2) = p%FFData( IZHI, IYHI, IDIM, ITLO )\n u(3) = p%FFData( IZLO, IYHI, IDIM, ITLO )\n u(4) = p%FFData( IZLO, IYLO, IDIM, ITLO )\n u(5) = p%FFData( IZHI, IYLO, IDIM, ITHI )\n u(6) = p%FFData( IZHI, IYHI, IDIM, ITHI )\n u(7) = p%FFData( IZLO, IYHI, IDIM, ITHI )\n u(8) = p%FFData( IZLO, IYLO, IDIM, ITHI )\n \n FFWind_Interp(IDIM) = SUM ( N * u ) \n\n END DO !IDIM\n\n ELSE\n\n IF (p%InterpTower) THEN\n \n CALL GetInterpValues(); if (ErrStat >= AbortErrLev) return\n \n !-------------------------------------------------------------------------------------------------\n ! Interpolate on the bottom of the grid to the ground\n !-------------------------------------------------------------------------------------------------\n\n DO IDIM=1,p%NFFComp ! all the components\n\n u(1) = p%FFData( IZHI, IYLO, IDIM, ITLO )\n u(2) = p%FFData( IZHI, IYHI, IDIM, ITLO )\n u(3) = 0.0_ReKi !p%FFData( IZLO, IYHI, IDIM, ITLO )\n u(4) = 0.0_ReKi !p%FFData( IZLO, IYLO, IDIM, ITLO )\n u(5) = p%FFData( IZHI, IYLO, IDIM, ITHI )\n u(6) = p%FFData( IZHI, IYHI, IDIM, ITHI )\n u(7) = 0.0_ReKi !p%FFData( IZLO, IYHI, IDIM, ITHI )\n u(8) = 0.0_ReKi !p%FFData( IZLO, IYLO, IDIM, ITHI )\n \n FFWind_Interp(IDIM) = SUM ( N * u ) \n\n END DO !IDIM \n \n ELSE\n \n !-------------------------------------------------------------------------------------------------\n ! Interpolate on the tower array\n !-------------------------------------------------------------------------------------------------\n ! Setup the scaling factors. Set the unused portion of the array to zero\n M(1) = ( 1.0_ReKi + Z )*( 1.0_ReKi - T )\n M(2) = ( 1.0_ReKi + Z )*( 1.0_ReKi + T )\n M(3) = ( 1.0_ReKi - Z )*( 1.0_ReKi - T )\n M(4) = ( 1.0_ReKi - Z )*( 1.0_ReKi + T )\n M = M \/ 4.0_ReKi ! normalize\n\n\n DO IDIM=1,p%NFFComp ! all the components\n\n !----------------------------------------------------------------------------------------------\n ! Interpolate between the two times using an area interpolation.\n !----------------------------------------------------------------------------------------------\n\n IF (IZHI > p%NTGrids) THEN\n v(1) = 0.0_ReKi ! on the ground\n v(2) = 0.0_ReKi ! on the ground\n ELSE\n v(1) = p%FFTower( IDIM, IZHI, ITLO )\n v(2) = p%FFTower( IDIM, IZHI, ITHI )\n END IF\n \n v(3) = p%FFTower( IDIM, IZLO, ITLO )\n v(4) = p%FFTower( IDIM, IZLO, ITHI )\n \n FFWind_Interp(IDIM) = SUM ( M * v ) \n\n\n END DO !IDIM\n \n END IF ! Interpolate below the grid\n \n ENDIF ! OnGrid\n RETURN\n\nCONTAINS \n SUBROUTINE GetInterpValues()\n \n !-------------------------------------------------------------------------------------------------\n ! Find the bounding columns for the Y position. [The lower-left corner is (1,1) when looking upwind.]\n !-------------------------------------------------------------------------------------------------\n\n YGRID = ( Position(2) + p%FFYHWid )*p%InvFFYD ! really, it's (Position(2) - -1.0*p%FFYHWid)\n\n IYLO = INT( YGRID ) + 1 ! convert REAL to INTEGER, then add one since our grids start at 1, not 0\n IYHI = IYLO + 1\n\n ! Set Y as a value between -1 and 1 for the relative location between IYLO and IYHI. Used in the interpolation.\n ! Subtract 1_IntKi from IYLO since grids start at index 1, not 0\n Y = 2.0_ReKi * (YGRID - REAL(IYLO - 1_IntKi, ReKi)) - 1.0_ReKi\n\n IF ( IYLO >= p%NYGrids .OR. IYLO < 1 ) THEN\n IF ( IYLO == 0 .AND. Y >= 1.0-TOL ) THEN\n Y = -1.0_ReKi\n IYLO = 1\n ELSE IF ( IYLO == p%NYGrids .AND. Y <= TOL ) THEN\n Y = -1.0_ReKi\n IYHI = IYLO ! We're right on the last point, which is still okay\n ELSE\n ErrMsg = ' FF wind array boundaries violated: Grid too small in Y direction. Y='\/\/ &\n TRIM(Num2LStr(Position(2)))\/\/'; Y boundaries = ['\/\/TRIM(Num2LStr(-1.0*p%FFYHWid))\/\/ &\n ', '\/\/TRIM(Num2LStr(p%FFYHWid))\/\/']'\n ErrStat = ErrID_Fatal ! we don't return anything\n RETURN\n ENDIF\n ENDIF\n \n !-------------------------------------------------------------------------------------------------\n ! Get normalization values for 3d-linear interpolation on the grid\n !-------------------------------------------------------------------------------------------------\n \n!New Algorithm here\n N(1) = ( 1.0_ReKi + Z )*( 1.0_ReKi - Y )*( 1.0_ReKi - T )\n N(2) = ( 1.0_ReKi + Z )*( 1.0_ReKi + Y )*( 1.0_ReKi - T )\n N(3) = ( 1.0_ReKi - Z )*( 1.0_ReKi + Y )*( 1.0_ReKi - T )\n N(4) = ( 1.0_ReKi - Z )*( 1.0_ReKi - Y )*( 1.0_ReKi - T )\n N(5) = ( 1.0_ReKi + Z )*( 1.0_ReKi - Y )*( 1.0_ReKi + T )\n N(6) = ( 1.0_ReKi + Z )*( 1.0_ReKi + Y )*( 1.0_ReKi + T )\n N(7) = ( 1.0_ReKi - Z )*( 1.0_ReKi + Y )*( 1.0_ReKi + T )\n N(8) = ( 1.0_ReKi - Z )*( 1.0_ReKi - Y )*( 1.0_ReKi + T )\n N = N \/ REAL( SIZE(N), ReKi ) ! normalize\n \n END SUBROUTINE GetInterpValues\nEND FUNCTION FFWind_Interp\n!====================================================================================================\n!> This routine is used read scale the full-field turbulence data stored in HAWC format.\nSUBROUTINE ScaleTurbulence(InitInp, FFData, ScaleFactors, ErrStat, ErrMsg)\n\n ! Passed Variables\n TYPE(IfW_FFWind_InitInputType), INTENT(IN ) :: InitInp !< Initialization input data passed to the module\n REAL(SiKi), INTENT(INOUT) :: FFData(:,:,:,:) !< full-field wind inflow data\n REAL(ReKi), INTENT( OUT) :: ScaleFactors(3) !< scaling factors that were used \n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< determines if an error has been encountered\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< Message about errors\n \n ! Local Variables:\n ! note that the variables used to compute statistics use double precision:\n REAL(DbKi) :: v(3) ! instanteanous wind speed at target position \n REAL(DbKi) :: vMean(3) ! average wind speeds over time at target position\n REAL(DbKi) :: vSum(3) ! sum over time of wind speeds at target position\n REAL(DbKi) :: vSum2(3) ! sum of wind speeds squared\n REAL(ReKi) :: ActualSigma(3) ! computed standard deviation\n \n INTEGER :: ic ! Loop counter for wind component\n INTEGER :: ix ! Loop counter for x or t\n INTEGER :: iy ! Loop counter for y\n INTEGER :: iz ! Loop counter for z\n\n INTEGER :: nc ! number of FF wind components\n INTEGER :: nx ! size of x (or t) dimension of turbulence box\n INTEGER :: ny ! size of y dimension of turbulence box\n INTEGER :: nz ! size of z dimension of turbulence box\n \n CHARACTER(*), PARAMETER :: RoutineName = 'ScaleTurbulence'\n\n \n \n ErrStat = ErrID_None\n ErrMsg = \"\"\n \n nz = size(FFData,1)\n ny = size(FFData,2)\n nc = size(FFData,3)\n nx = size(FFData,4)\n \n if ( InitInp%ScaleMethod == ScaleMethod_None ) then\n \n ! don't scale FFWind: \n ScaleFactors = 1.0_ReKi \n \n else ! ScaleMethod_Direct or ScaleMethod_StdDev\n \n !..............................\n ! determine the scaling factors:\n !..............................\n \n if ( InitInp%ScaleMethod == ScaleMethod_Direct ) then\n ! Use the scaling factors specified in the input file:\n ScaleFactors = InitInp%sf\n \n else !if ( InitInp%ScaleMethod == ScaleMethod_StdDev ) then\n ! compute the scale factor to get requested sigma:\n \n ! find the center point of the grid (if we don't have an odd number of grid points, we'll pick the point closest to the center)\n iz = (nz + 1) \/ 2 ! integer division\n iy = (ny + 1) \/ 2 ! integer division\n \n ! compute the actual sigma at the point specified by (iy,iz). (This sigma should be close to 1.)\n v = 0.0_ReKi\n vSum = 0.0_ReKi\n vSum2 = 0.0_ReKi\n DO ix=1,nx \n v(1:nc) = FFData(iz,iy,:,ix)\n \n vSum = vSum + v\n vSum2 = vSum2 + v**2\n ENDDO ! IX\n \n vMean = vSum\/nx \n ActualSigma = SQRT( ABS( (vSum2\/nx) - vMean**2 ) )\n \n ! check that the ActualSigma isn't 0\n !InitOut%sf = InitInp%SigmaF \/ ActualSigma ! factor = Target \/ actual \n do ic=1,nc\n if ( EqualRealNos( ActualSigma(ic), 0.0_ReKi ) ) then\n ScaleFactors(ic) = 0.0_ReKi\n if ( .not. EqualRealNos( InitInp%SigmaF(ic), 0.0_ReKi ) ) then\n call SetErrStat( ErrID_Fatal,\"Computed standard deviation is zero; cannot scale to achieve target non-zero standard deviation.\", ErrStat, ErrMsg, RoutineName ) \n end if \n else\n ScaleFactors(ic) = InitInp%SigmaF(ic) \/ ActualSigma(ic)\n end if \n end do\n\n end if\n \n !..............................\n ! scale the data using our scaling factors:\n !..............................\n \n do ix=1,nx \n do ic = 1,nc\n FFData( :, :, ic, ix ) = ScaleFactors(ic) * FFData( :, :, ic, ix ) \n end do !IC \n end do \n \n end if\n \nEND SUBROUTINE ScaleTurbulence \n!====================================================================================================\n!> This routine is used to add a mean wind profile to the HAWC format turbulence data.\nSUBROUTINE AddMeanVelocity(InitInp, GridBase, dz, FFData)\n\n ! Passed Variables\n TYPE(IfW_FFWind_InitInputType), INTENT(IN ) :: InitInp !< Initialization input data passed to the module\n REAL(ReKi), INTENT(IN ) :: GridBase !< height of the lowest point on the grid\n REAL(ReKi), INTENT(IN ) :: dz !< distance between two zertically consectutive grid points\n REAL(SiKi), INTENT(INOUT) :: FFData(:,:,:,:) !< FF wind-inflow data\n \n ! Local Variables:\n REAL(ReKi) :: Z ! height\n REAL(ReKi) :: U ! mean wind speed\n INTEGER(IntKi) :: iz ! loop counter\n INTEGER(IntKi) :: nz ! number of points in the z direction\n \n \n nz = size(FFData,1)\n \n DO iz = 1,nz\n\n Z = GridBase + ( iz - 1 )*dz\n if (Z <= 0.0_ReKi) cycle\n \n SELECT CASE ( InitInp%WindProfileType )\n\n CASE ( WindProfileType_PL )\n \n U = InitInp%URef*( Z \/ InitInp%RefHt )**InitInp%PLExp ! [IEC 61400-1 6.3.1.2 (10)]\n\n CASE ( WindProfileType_Log )\n\n IF ( .not. EqualRealNos( InitInp%RefHt, InitInp%Z0 ) .and. Z > 0.0_ReKi ) THEN\n U = InitInp%URef*( LOG( Z \/ InitInp%Z0 ) )\/( LOG( InitInp%RefHt \/ InitInp%Z0 ) )\n ELSE\n U = 0.0_ReKi\n ENDIF\n\n CASE ( WindProfileType_Constant )\n \n U = InitInp%URef\n \n CASE DEFAULT ! WindProfileType_None\n \n U = 0.0_ReKi\n\n END SELECT\n\n FFData( iz, :, 1, : ) = FFData( iz, :, 1, : ) + U\n\n END DO ! iz\n \n \nEND SUBROUTINE AddMeanVelocity\n!====================================================================================================\nFUNCTION CalculateMeanVelocity(p,z) RESULT(u)\n\n TYPE(IfW_FFWind_ParameterType), INTENT(IN ) :: p !< Parameters\n REAL(ReKi) , INTENT(IN ) :: Z ! height\n REAL(ReKi) :: u ! mean wind speed at height z\n\n SELECT CASE ( p%WindProfileType )\n\n CASE ( WindProfileType_PL )\n \n U = p%MeanFFWS*( Z \/ p%RefHt )**p%PLExp ! [IEC 61400-1 6.3.1.2 (10)]\n\n CASE ( WindProfileType_Log )\n\n IF ( .not. EqualRealNos( p%RefHt, p%Z0 ) .and. Z > 0.0_ReKi ) THEN\n U = p%MeanFFWS*( LOG( Z \/ p%Z0 ) )\/( LOG( p%RefHt \/ p%Z0 ) )\n ELSE\n U = 0.0_ReKi\n ENDIF\n\n CASE ( WindProfileType_Constant )\n \n U = p%MeanFFWS\n \n CASE DEFAULT\n \n U = 0.0_ReKi\n\n END SELECT\n \nEND FUNCTION CalculateMeanVelocity\n!====================================================================================================\n!> This routine is used to add a subtract the mean wind speed from turbulence data (so that the added mean can be added later).\n!! Note that this does NOT scale using the length of the wind simulation, so there may be differences with the HAWC implementation.\nSUBROUTINE SubtractMeanVelocity(FFData)\n\n ! Passed Variables\n REAL(SiKi), INTENT(INOUT) :: FFData(:,:,:,:) !< FF wind-inflow data\n \n ! Local Variables:\n REAL(ReKi) :: MeanVal ! computed mean wind speed\n INTEGER(IntKi) :: ic ! loop counter\n INTEGER(IntKi) :: iy ! loop counter\n INTEGER(IntKi) :: iz ! loop counter\n INTEGER(IntKi) :: nt ! number of points in the x (time) direction\n \n \n nt = size(FFData,4)\n \n DO ic = 1,1 !size(FFData,3)\n DO iy = 1,size(FFData,2)\n DO iz = 1,size(FFData,1)\n meanVal = sum(FFData(iz,iy,ic,:)) \/ nt\n\n FFData( iz,iy,ic,: ) = FFData( iz,iy,ic,: ) - meanVal\n END DO ! iz\n END DO ! iy\n END DO ! ic\n \n \nEND SUBROUTINE SubtractMeanVelocity\n!====================================================================================================\n!> This routine is used to make sure the initInp data is valid.\nSUBROUTINE FFWind_ValidateInput(InitInp, nffc, ErrStat, ErrMsg)\n\n ! Passed Variables\n TYPE(IfW_FFWind_InitInputType), INTENT(IN ) :: InitInp !< Initialization input data passed to the module\n INTEGER(IntKi), INTENT(IN ) :: nffc !< number of full-field wind components (normally 3)\n\n ! Error Handling\n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< determines if an error has been encountered\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< Message about errors\n character(*), parameter :: RoutineName = 'FFWind_ValidateInput'\n \n integer(intki) :: ic ! loop counter\n \n ErrStat = ErrID_None\n ErrMsg = \"\"\n \n IF ( InitInp%RefHt < 0.0_ReKi .or. EqualRealNos( InitInp%RefHt, 0.0_ReKi ) ) call SetErrStat( ErrID_Fatal, 'The grid reference height must be larger than 0.', ErrStat, ErrMsg, RoutineName )\n\n if ( InitInp%ScaleMethod == ScaleMethod_Direct) then\n do ic=1,nffc\n if ( InitInp%sf(ic) < 0.0_ReKi ) CALL SetErrStat( ErrID_Fatal, 'Turbulence scaling factors must not be negative.', ErrStat, ErrMsg, RoutineName ) \n end do\n elseif ( InitInp%ScaleMethod == ScaleMethod_StdDev ) then\n do ic=1,nffc\n if ( InitInp%sigmaf(ic) < 0.0_ReKi ) CALL SetErrStat( ErrID_Fatal, 'Turbulence standard deviations must not be negative.', ErrStat, ErrMsg, RoutineName ) \n end do\n#ifdef UNUSED_INPUTFILE_LINES \n if ( InitInp%TStart < 0.0_ReKi ) CALL SetErrStat( ErrID_Fatal, 'TStart for turbulence standard deviation calculations must not be negative.', ErrStat, ErrMsg, RoutineName ) \n if ( InitInp%TEnd <= InitInp%TStart ) CALL SetErrStat( ErrID_Fatal, 'TEnd for turbulence standard deviation calculations must be after TStart.', ErrStat, ErrMsg, RoutineName ) \n#endif \n elseif ( InitInp%ScaleMethod \/= ScaleMethod_None ) then\n CALL SetErrStat( ErrID_Fatal, 'Turbulence scaling method must be 0 (none), 1 (direct scaling factors), or 2 (target standard deviation).', ErrStat, ErrMsg, RoutineName ) \n end if\n\n \n if (InitInp%WindProfileType == WindProfileType_Log) then\n if ( InitInp%z0 < 0.0_ReKi .or. EqualRealNos( InitInp%z0, 0.0_ReKi ) ) &\n call SetErrStat( ErrID_Fatal, 'The surface roughness length, Z0, must be greater than zero', ErrStat, ErrMsg, RoutineName )\n elseif ( InitInp%WindProfileType < WindProfileType_None .or. InitInp%WindProfileType > WindProfileType_PL) then \n call SetErrStat( ErrID_Fatal, 'The WindProfile type must be 0 (constant), 1 (logarithmic) or 2 (power law).', ErrStat, ErrMsg, RoutineName )\n end if\n\n IF ( InitInp%URef < 0.0_ReKi ) call SetErrStat( ErrID_Fatal, 'The reference wind speed must not be negative.', ErrStat, ErrMsg, RoutineName )\n \n \nEND SUBROUTINE FFWind_ValidateInput\n!====================================================================================================\nSUBROUTINE ConvertFFWind_to_HAWC2(FileRootName, p, ErrStat, ErrMsg)\n CHARACTER(*), INTENT(IN ) :: FileRootName !< RootName for output files\n TYPE(IfW_FFWind_ParameterType), INTENT(IN ) :: p !< Parameters\n\n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat \/= ErrID_None\n\n\n ! Local variables\n REAL(SiKi) :: delta(3)\n\n delta(1) = p%MeanFFWS * p%FFDTime\n delta(2) = 1.0_SiKi \/ p%InvFFYD\n delta(3) = 1.0_SiKi \/ p%InvFFZD\n \n CALL WrBinHAWC(FileRootName, p%FFData(:,:,:,1:p%NFFSteps), delta, ErrStat, ErrMsg)\n\n IF (.NOT. p%Periodic) THEN\n call SetErrStat( ErrID_Severe, 'File converted to HAWC format is not periodic. Jumps may occur in resulting simulation.', &\n ErrStat, ErrMsg, 'ConvertFFWind_to_HAWC2')\n END IF\n\nEND SUBROUTINE ConvertFFWind_to_HAWC2\n!====================================================================================================\nSUBROUTINE ConvertFFWind_to_Bladed(FileRootName, p, ErrStat, ErrMsg)\n CHARACTER(*), INTENT(IN ) :: FileRootName !< RootName for output files\n TYPE(IfW_FFWind_ParameterType), INTENT(IN ) :: p !< Parameters\n\n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat \/= ErrID_None\n\n\n ! Local variables\n REAL(SiKi) :: delta(3)\n\n delta(1) = p%MeanFFWS * p%FFDTime\n delta(2) = 1.0_SiKi \/ p%InvFFYD\n delta(3) = 1.0_SiKi \/ p%InvFFZD\n \n CALL WrBinBladed(FileRootName, p%FFData(:,:,:,1:p%NFFSteps), delta, p%MeanFFWS, p%RefHt, p%GridBase, p%Periodic, p%AddMeanAfterInterp, ErrStat, ErrMsg)\n\nEND SUBROUTINE ConvertFFWind_to_Bladed\n!==================================================================================================================================\n SUBROUTINE WrBinHAWC(FileRootName, FFWind, delta, ErrStat, ErrMsg)\n CHARACTER(*), INTENT(IN) :: FileRootName !< Name of the file to write the output in\n REAL(SiKi), INTENT(IN) :: FFWind(:,:,:,:) !< 4D wind speeds: index 1=z (height), 2=y (lateral), 3=dimension(u,v,w), 4=time or x\n REAL(SiKi), INTENT(IN) :: delta(3) !< array containing dx, dy, dz in meters\n INTEGER(IntKi), INTENT(OUT):: ErrStat !< Indicates whether an error occurred (see NWTC_Library)\n CHARACTER(*), INTENT(OUT):: ErrMsg !< Error message associated with the ErrStat\n \n ! local variables\n CHARACTER(*), PARAMETER :: Comp(3) = (\/'u','v','w'\/)\n INTEGER(IntKi), PARAMETER :: AryDim(3) = (\/4, 2, 1\/) ! x,y,z dimensions of FFWind array\n INTEGER(IntKi) :: nc\n INTEGER(IntKi) :: IC, IX, IY, IZ\n INTEGER(IntKi) :: UnWind\n !REAL(SiKi) :: MeanVal(size(FFWind,1),size(FFWind,2))\n REAL(SiKi) :: MeanVal(size(FFWind,1))\n\n INTEGER(IntKi) :: ErrStat2\n CHARACTER(ErrMsgLen) :: ErrMsg2\n CHARACTER(*), PARAMETER :: RoutineName = 'WrBinHAWC'\n CHARACTER(1024) :: RootWithoutPathName\n \n ErrStat = ErrID_None\n ErrMsg = \"\"\n \n CALL GetNewUnit( UnWind, ErrStat2, ErrMsg2 )\n CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) \n IF (ErrStat >= AbortErrLev) RETURN\n \n nc = size(FFWind,3) ! check that nc == 3 ????\n \n ! need to remove time-average value from DIM=1\n MeanVal = 0.0_SiKi\n DO IX = 1,size(FFWind,4)\n MeanVal = MeanVal + FFWind(:,1,1,ix)\n END DO\n MeanVal = MeanVal \/ size(FFWind,4)\n\n\n ! write the summary file\n CALL OpenFOutFile ( UnWind, trim(FileRootName)\/\/'-HAWC.sum', ErrStat2, ErrMsg2 )\n CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)\n IF (ErrStat >= AbortErrLev) RETURN\n\n WRITE( UnWind, '(A)' ) '; Wind file converted to HAWC format on '\/\/CurDate()\/\/' at '\/\/CurTime()\n \n WRITE( UnWind, '()' ) \n DO IZ = size(FFWind,AryDim(3)),1,-1\n WRITE( UnWind, '(A,I3,A,F15.5)' ) '; mean removed at z(', iz, ') = ', MeanVal(iz)\n END DO\n \n WRITE( UnWind, '(A)' ) 'turb_format 1 ;'\n! WRITE( UnWind, '(A)' ) 'center_pos0 0.0 0.0 '\/\/trim(num2lstr( ';'\n \n WRITE( UnWind, '()' )\n WRITE( UnWind, '(A)' ) 'begin mann;'\n \n ic = INDEX( FileRootName, '\\', BACK=.TRUE. )\n ic = MAX( ic, INDEX( FileRootName, '\/', BACK=.TRUE. ) )\n RootWithoutPathName = FileRootName((ic+1):)\n\n\n DO IC = 1,nc\n WRITE( UnWind, '(2x,A, T30, A, \" ;\")' ) 'filename_'\/\/Comp(IC), trim(RootWithoutPathName)\/\/'-HAWC-'\/\/Comp(IC)\/\/'.bin' \n END DO\n DO IC = 1,nc\n WRITE( UnWind, '(2x,A, T30, I8, 1x, F15.5, \" ;\")' ) 'box_dim_'\/\/Comp(IC), size( FFWind, AryDim(ic) ), delta(ic)\n END DO\n WRITE( UnWind, '(2x,A)' ) 'dont_scale 1; converter did not rescale turbulence to unit standard deviation'\n WRITE( UnWind, '(A)' ) 'end mann;'\n CLOSE ( UnWind )\n \n \n ! write the binary files for each component\n \n DO IC = 1,nc\n\n CALL OpenBOutFile ( UnWind, trim(FileRootName)\/\/'-HAWC-'\/\/Comp(ic)\/\/'.bin', ErrStat2, ErrMsg2 )\n CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) \n IF (ErrStat >= AbortErrLev) RETURN\n\n DO IX = 1,size(FFWind,AryDim(1))\n DO IY = size(FFWind,AryDim(2)),1,-1\n WRITE( UnWind, IOSTAT=ErrStat2 ) FFWind(:,iy,ic,ix) - MeanVal(:) ! note that FFWind is SiKi (4-byte reals, not default kinds)\n END DO\n END DO\n\n CLOSE ( UnWind )\n\n MeanVal = 0.0_SiKi\n\n END DO\n\n END SUBROUTINE WrBinHAWC\n!==================================================================================================================================\n SUBROUTINE WrBinBladed(FileRootName, FFWind, delta, MeanFFWS, HubHt, GridBase, Periodic, AddMeanAfterInterp, ErrStat, ErrMsg)\n CHARACTER(*), INTENT(IN) :: FileRootName !< Name of the file to write the output in\n REAL(SiKi), INTENT(IN) :: FFWind(:,:,:,:) !< 4D wind speeds: index 1=z (height), 2=y (lateral), 3=dimension(u,v,w), 4=time or x\n REAL(SiKi), INTENT(IN) :: delta(3) !< array containing dx, dy, dz in meters\n REAL(ReKi), INTENT(IN) :: MeanFFWS !< advection speed (mean wind speed at hub)\n REAL(ReKi), INTENT(IN) :: HubHt !< hub height\n REAL(ReKi), INTENT(IN) :: GridBase !< height of lowest grid point\n LOGICAL, INTENT(IN) :: Periodic !< whether this wind file is periodic\n LOGICAL, INTENT(IN) :: AddMeanAfterInterp !< whether this wind file contains a mean longditudinal wind speed\n INTEGER(IntKi), INTENT(OUT):: ErrStat !< Indicates whether an error occurred (see NWTC_Library)\n CHARACTER(*), INTENT(OUT):: ErrMsg !< Error message associated with the ErrStat\n \n ! local variables\n INTEGER(IntKi), PARAMETER :: AryDim(3) = (\/4, 2, 1\/) ! x,y,z dimensions of FFWind array\n INTEGER(IntKi) :: ic, it, iy, iz\n INTEGER(IntKi) :: UnWind\n REAL(SiKi) :: MeanVal(size(FFWind,1),size(FFWind,2))\n REAL(SiKi) :: SigmaGrid( size(FFWind,1),size(FFWind,2))\n REAL(SiKi) :: TI(3) !< array containing turbulence intensity (for scaling factors)\n REAL(SiKi) :: Sigma(3) !< array containing standard deviations (for scaling factors)\n REAL(SiKi) :: Scl(3) !< array containing scaling factors\n REAL(SiKi) :: Off(3) !< array containing offsets\n REAL(SiKi) :: Tmp \n REAL(ReKi) :: MeanFFWS_nonZero !< advection speed (mean wind speed at hub)\n \n\n INTEGER(IntKi) :: ErrStat2\n CHARACTER(ErrMsgLen) :: ErrMsg2\n CHARACTER(*), PARAMETER :: RoutineName = 'WrBinBladed'\n \n REAL(SiKi), PARAMETER :: Tolerance = 0.0001 ! The largest difference between two numbers that are assumed to be equal\n\n \n ErrStat = ErrID_None\n ErrMsg = \"\"\n \n !-----------------------------------------------------\n ! Calculate the stats\n !-----------------------------------------------------\n \n do ic=3,1,-1\n \n ! mean values:\n MeanVal = 0.0_SiKi\n DO it = 1,size(FFWind,AryDim(1))\n MeanVal = MeanVal + FFWind(:,:,ic,it)\n END DO\n MeanVal = MeanVal \/ real( size(FFWind,AryDim(1)), SiKi)\n \n ! standard deviations (with 1\/N scaling factor):\n SigmaGrid = 0.0_SiKi\n DO it = 1,size(FFWind,4)\n SigmaGrid = SigmaGrid + FFWind(:,:,ic,it)**2\n END DO\n SigmaGrid = SigmaGrid \/ size(FFWind,AryDim(1))\n SigmaGrid = SQRT( MAX( SigmaGrid - MeanVal**2, 0.0_SiKi ) )\n \n ! now get the average standard deviation for each component:\n Sigma(ic) = sum(SigmaGrid)\/size(SigmaGrid) ! get the average sigma over the grid\n Sigma(ic) = MAX(100.0_SiKi*Tolerance, Sigma(ic)) ! make sure this scaling isn't too small\n\n end do\n\n ! We need to take into account the shear across the grid in the sigma calculations for scaling the data, \n ! and ensure that 32.767*sigma_u >= |V-UHub| so that we don't get values out of the range of our scaling values\n ! in this BLADED-style binary output. Tmp is |V-UHub|\n Tmp = MAX( ABS(MAXVAL(FFWind(:,:,1,:))-MeanFFWS), ABS(MINVAL(FFWind(:,:,1,:))-MeanFFWS) ) !Get the range of wind speed values for scaling in BLADED-format .wnd files\n Sigma(1) = MAX(Sigma(1),0.05_SiKi*Tmp)\n do ic=2,3\n Sigma(ic) = MAX( Sigma(ic), 0.05_SiKi*ABS(MAXVAL(FFWind(:,:,ic,:))), 0.05_SiKi*ABS(MINVAL(FFWind(:,:,ic,:))) ) ! put the abs() after the maxval() and minval() to avoid stack-overflow issues with large wind files \n end do\n \n ! Put normalizing factors into the summary file. The user can use them to\n ! tell a simulation program how to rescale the data.\n\n if ( abs(MeanFFWS) < 0.1_ReKi ) then\n MeanFFWS_nonZero = sign( 0.1, MeanFFWS )\n else\n MeanFFWS_nonZero = MeanFFWS\n end if\n \n TI = Sigma \/ MeanFFWS_nonZero\n\n !-----------------------------------------------------\n ! The summary file\n !----------------------------------------------------- \n CALL GetNewUnit( UnWind, ErrStat2, ErrMsg2 )\n CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) \n IF (ErrStat >= AbortErrLev) RETURN\n\n CALL OpenFOutFile ( UnWind, trim(FileRootName)\/\/'-Bladed.sum', ErrStat2, ErrMsg2 )\n CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)\n IF (ErrStat >= AbortErrLev) RETURN\n \n !The string \"TurbSim\" needs to be in the 2nd line of the summary file if AeroDyn will read this.\n WRITE( UnWind,\"( \/ 'TurbSim - This summary file was generated by ', A, ' on ' , A , ' at ' , A , '.' \/ )\") \"NWTC_Library\", CurDate(), CurTime()\n WRITE( UnWind, '(\/)' )\n WRITE( UnWind, '(\/)' )\n WRITE( UnWind, '( L10, 2X, \"Clockwise rotation when looking downwind?\")' ) .FALSE. \n WRITE( UnWind, '( F10.3, 2X, \"Hub height [m]\")' ) HubHt\n WRITE( UnWind, '( F10.3, 2X, \"Grid height [m]\")' ) delta(3)*(size(FFWind,AryDim(3)) - 1)\n WRITE( UnWind, '( F10.3, 2X, \"Grid width [m]\")' ) delta(2)*(size(FFWind,AryDim(2)) - 1)\n WRITE( UnWind, '(\/\"BLADED-style binary scaling parameters:\"\/)' )\n WRITE( UnWind, '( 2X, \"UBar = \", F9.4, \" m\/s\")' ) MeanFFWS_nonZero\n WRITE( UnWind, '( 2X, \"TI(u) = \", F9.4, \" %\")' ) 100.0*TI(1)\n WRITE( UnWind, '( 2X, \"TI(v) = \", F9.4, \" %\")' ) 100.0*TI(2)\n WRITE( UnWind, '( 2X, \"TI(w) = \", F9.4, \" %\")' ) 100.0*TI(3)\n WRITE( UnWind, '(\/)' )\n WRITE( UnWind, '( 2X, \"Height offset = \", F9.4, \" m\" )' ) HubHt - 0.5*delta(3)*(size(FFWind,AryDim(3)) - 1) - GridBase ! This will be zero for square grids\n ! ZGOffset = ( HubHt - delta(3)*(size(FFWind,1) - 1) \/ 2.0 - Zbottom )\n WRITE( UnWind, '( 2X, \"Grid Base = \", F9.4, \" m\" )' ) GridBase\n if (Periodic) then\n WRITE (UnWind,'()' )\n WRITE (UnWind,'( A)' ) 'Creating a PERIODIC output file.'\n end if\n WRITE (UnWind,'( A)' ) 'Creating a BLADED LEFT-HAND RULE output file.'\n\n\n CLOSE (UnWind)\n \n !-----------------------------------------------------\n ! The BINARY file\n !-----------------------------------------------------\n CALL OpenBOutFile ( UnWind, TRIM(FileRootName)\/\/'-Bladed.wnd', ErrStat, ErrMsg )\n CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)\n IF (ErrStat >= AbortErrLev) RETURN\n \n WRITE (UnWind) INT( -99 , B2Ki ) ! -99 = New Bladed format\n WRITE (UnWind) INT( 4 , B2Ki ) ! 4 = improved von karman (not used, but needed for next 7 inputs)\n WRITE (UnWind) INT( size(FFWind,3) , B4Ki ) ! size(FFWind,3) = 3 = number of wind components \n WRITE (UnWind) REAL( 45.0_SiKi , SiKi ) ! Latitude (degrees) (informational, not used in FAST)\n WRITE (UnWind) REAL( 0.03_SiKi , SiKi ) ! Roughness length (m) (informational, not used in FAST)\n WRITE (UnWind) REAL( HubHt , SiKi ) ! Reference Height (m) (informational, not used in FAST)\n WRITE (UnWind) REAL( 100.0*TI(1) , SiKi ) ! Longitudinal turbulence intensity (%)\n WRITE (UnWind) REAL( 100.0*TI(2) , SiKi ) ! Lateral turbulence intensity (%)\n WRITE (UnWind) REAL( 100.0*TI(3) , SiKi ) ! Vertical turbulence intensity (%)\n\n WRITE (UnWind) REAL( delta(3) , SiKi ) ! grid spacing in vertical direction, in m\n WRITE (UnWind) REAL( delta(2) , SiKi ) ! grid spacing in lateral direction, in m\n WRITE (UnWind) REAL( delta(1) , SiKi ) ! grid spacing in longitudinal direciton, in m\n WRITE (UnWind) INT( size(FFWind,AryDim(1))\/2 , B4Ki ) ! half the number of points in alongwind direction\n WRITE (UnWind) REAL( MeanFFWS_nonZero , SiKi ) ! the mean wind speed in m\/s\n WRITE (UnWind) REAL( 0 , SiKi ) ! the vertical length scale of the longitudinal component in m\n WRITE (UnWind) REAL( 0 , SiKi ) ! the lateral length scale of the longitudinal component in m\n WRITE (UnWind) REAL( 0 , SiKi ) ! the longitudinal length scale of the longitudinal component in m \n WRITE (UnWind) INT( 0 , B4Ki ) ! an unused integer\n WRITE (UnWind) INT( 0 , B4Ki ) ! the random number seed\n WRITE (UnWind) INT( size(FFWind,AryDim(3)) , B4Ki ) ! the number of grid points vertically\n WRITE (UnWind) INT( size(FFWind,AryDim(2)) , B4Ki ) ! the number of grid points laterally\n WRITE (UnWind) INT( 0 , B4Ki ) ! the vertical length scale of the lateral component, not used\n WRITE (UnWind) INT( 0 , B4Ki ) ! the lateral length scale of the lateral component, not used\n WRITE (UnWind) INT( 0 , B4Ki ) ! the longitudinal length scale of the lateral component, not used\n WRITE (UnWind) INT( 0 , B4Ki ) ! the vertical length scale of the vertical component, not used\n WRITE (UnWind) INT( 0 , B4Ki ) ! the lateral length scale of the vertical component, not used\n WRITE (UnWind) INT( 0 , B4Ki ) ! the longitudinal length scale of the vertical component, not used\n \n ! Scaling value to convert wind speeds to 16-bit integers\n do ic = 1,3\n if (.not. EqualRealNos( Sigma(ic), 0.0_SiKi ) ) then\n Scl(ic) = 1000.0\/( Sigma(ic) )\n else\n Scl(ic) = 1.0_SiKi\n end if\n end do\n Scl(2) = -Scl(2) ! Bladed convention is positive V is pointed along negative Y (IEC turbine coordinate)\n \n ! Offset value to convert wind speeds to 16-bit integers\n IF (AddMeanAfterInterp) THEN ! Note that this will not take into account any shear!!!\n Off(1) = 0.0\n ELSE\n Off(1) = MeanFFWS * Scl(1)\n END IF\n Off(2) = 0.0\n Off(3) = 0.0\n \n DO it=1,size(FFWind,AryDim(1))\n DO iz=1,size(FFWind,AryDim(3)) ! 1=bottom of grid\n DO iy=1,size(FFWind,AryDim(2)) ! 1=left of grid, i.e. y(1) = -GridWidth\/2\n\n ! Scale velocity for 16-bit integers:\n WRITE ( UnWind ) NINT( FFWind(iz,iy,:,it) * Scl - Off , B2Ki ) ! scale to int16 \n\n ENDDO !IY\n ENDDO !IZ\n ENDDO !IT\n \n CLOSE( UnWind )\n \n \n END SUBROUTINE WrBinBladed\n!====================================================================================================\nSUBROUTINE ConvertFFWind_toVTK(FileRootName, p, ErrStat, ErrMsg)\n CHARACTER(*), INTENT(IN ) :: FileRootName !< RootName for output files\n TYPE(IfW_FFWind_ParameterType), INTENT(IN ) :: p !< Parameters\n\n INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation\n CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat \/= ErrID_None\n\n\n ! Local variables\n CHARACTER(1024) :: RootPathName\n CHARACTER(1024) :: FileName\n INTEGER :: UnWind\n INTEGER :: i\n INTEGER :: iy\n INTEGER :: iz\n\n INTEGER(IntKi) :: ErrStat2\n CHARACTER(ErrMsgLen) :: ErrMsg2\n CHARACTER(*), PARAMETER :: RoutineName = 'ConvertFFWind_toVTK'\n\n \n CALL GetPath ( FileRootName, RootPathName )\n CALL GetNewUnit( UnWind, ErrStat, ErrMsg )\n\n do i = 1,p%NFFSteps\n\n ! Create the output vtk file with naming \/vtk\/DisYZ.t.vtk\n \n RootPathName = trim(RootPathName)\/\/PathSep\/\/\"vtk\"\n call MkDir( trim(RootPathName) ) ! make this directory if it doesn't already exist\n \n !FileName = trim(RootPathName)\/\/PathSep\/\/\"vtk\"\/\/PathSep\/\/\"DisYZ.t\"\/\/trim(num2lstr(i))\/\/\".vtp\"\n FileName = trim(RootPathName)\/\/PathSep\/\/\"DisYZ.t\"\/\/trim(num2lstr(i))\/\/\".vtp\"\n \n ! see WrVTK_SP_header\n CALL OpenFOutFile ( UnWind, TRIM(FileName), ErrStat2, ErrMsg2 )\n call SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)\n if (ErrStat >= AbortErrLev) return\n \n WRITE(UnWind,'(A)') '# vtk DataFile Version 3.0'\n WRITE(UnWind,'(A)') \"InflowWind YZ Slice at T= \"\/\/trim(num2lstr((i-1)*p%FFDTime))\/\/\" s\"\n WRITE(UnWind,'(A)') 'ASCII'\n WRITE(UnWind,'(A)') 'DATASET STRUCTURED_POINTS'\n \n ! Note: gridVals must be stored such that the left-most dimension is X and the right-most dimension is Z\n ! see WrVTK_SP_vectors3D()\n WRITE(UnWind,'(A,3(i5,1X))') 'DIMENSIONS ', 1, p%NYGrids, p%NZGrids\n WRITE(UnWind,'(A,3(f10.2,1X))') 'ORIGIN ' , p%InitXPosition, -p%FFYHWid, p%GridBase\n WRITE(UnWind,'(A,3(f10.2,1X))') 'SPACING ' , 0.0_ReKi, 1.0_SiKi \/ p%InvFFYD, 1.0_SiKi \/ p%InvFFZD\n WRITE(UnWind,'(A,i5)') 'POINT_DATA ', p%NYGrids*p%NZGrids\n WRITE(UnWind,'(A)') 'VECTORS DisYZ float'\n \n DO iz=1,p%NZGrids\n DO iy=1,p%NYGrids\n WRITE(UnWind,'(3(f10.2,1X))') p%FFData(iz,iy,:,i)\n END DO\n END DO\n\n CLOSE(UnWind)\n\n end do\n \n \nEND SUBROUTINE ConvertFFWind_toVTK\n\n \n!====================================================================================================\n\nEND MODULE IfW_FFWind_Base\n","avg_line_length":49.8252344416,"max_line_length":220,"alphanum_fraction":0.4907690992} {"size":2716,"ext":"f90","lang":"FORTRAN","max_stars_count":3.0,"content":"module Structural3DApplicationM\n use UtilitiesM\n use DebuggerM\n\n use SourceM\n use NodeM\n \n use StructuralElementM\n use PressureM\n use StructuralMaterialM\n use StructuralModelM\n\n implicit none\n\n private\n public :: Structural3DApplicationDT, structural3DApplication\n\n type :: Structural3DApplicationDT\n type(NodeDT) , dimension(:), allocatable :: node\n type(StructuralElementDT) , dimension(:), allocatable :: element\n type(PressureDT) , dimension(:), allocatable :: pressure\n type(SourceDT) , dimension(:), allocatable :: source\n type(StructuralMaterialDT), dimension(:), allocatable :: material\n type(StructuralModelDT) :: model\n contains\n procedure, public :: init\n end type Structural3DApplicationDT\n\n interface structural3DApplication\n procedure :: constructor\n end interface structural3DApplication\n\ncontains\n\n type(Structural3DApplicationDT) function &\n constructor(nNode, nElement, nPressure, nSource, nMaterial, nGauss, nnz)\n implicit none\n integer(ikind), intent(in) :: nNode\n integer(ikind), intent(in) :: nElement\n integer(ikind), intent(in) :: nPressure\n integer(ikind), intent(in) :: nSource\n integer(ikind), intent(in) :: nMaterial\n integer(ikind), intent(in) :: nGauss\n integer(ikind), intent(in) :: nnz\n call constructor%init(nNode, nElement, nPressure, nSource, nMaterial, nGauss, nnz)\n end function constructor\n\n subroutine init(this, nNode, nElement, nPressure, nSource, nMaterial, nGauss, nnz)\n implicit none\n class(Structural3DApplicationDT), intent(inout) :: this\n integer(ikind) , intent(in) :: nNode\n integer(ikind) , intent(in) :: nElement\n integer(ikind) , intent(in) :: nPressure\n integer(ikind) , intent(in) :: nSource\n integer(ikind) , intent(in) :: nMaterial\n integer(ikind) , intent(in) :: nGauss\n integer(ikind) , intent(in) :: nnz\n allocate(this%node(nNode))\n allocate(this%element(nElement))\n allocate(this%pressure(nPressure))\n allocate(this%source(nSource))\n allocate(this%material(nMaterial))\n call initGeometries(nGauss)\n this%model = structuralModel( &\n nDof = 3*nNode &\n , nnz = nnz &\n , id = 1 &\n , nNode = nNode &\n , nElement = nElement &\n , nCondition = nPressure )\n end subroutine init\n\nend module Structural3DApplicationM\n","avg_line_length":36.7027027027,"max_line_length":86,"alphanum_fraction":0.5997790869} {"size":15507,"ext":"f","lang":"FORTRAN","max_stars_count":157.0,"content":"*> \\brief \\b CLAHEF_AA\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download CLAHEF_AA + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE CLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV,\n* H, LDH, WORK, INFO )\n*\n* .. Scalar Arguments ..\n* CHARACTER UPLO\n* INTEGER J1, M, NB, LDA, LDH, INFO\n* ..\n* .. Array Arguments ..\n* INTEGER IPIV( * )\n* COMPLEX A( LDA, * ), H( LDH, * ), WORK( * )\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> CLAHEF_AA factorizes a panel of a complex hermitian matrix A using\n*> the Aasen's algorithm. The panel consists of a set of NB rows of A\n*> when UPLO is U, or a set of NB columns when UPLO is L.\n*>\n*> In order to factorize the panel, the Aasen's algorithm requires the\n*> last row, or column, of the previous panel. The first row, or column,\n*> of A is set to be the first row, or column, of an identity matrix,\n*> which is used to factorize the first panel.\n*>\n*> The resulting J-th row of U, or J-th column of L, is stored in the\n*> (J-1)-th row, or column, of A (without the unit diagonals), while\n*> the diagonal and subdiagonal of A are overwritten by those of T.\n*>\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] UPLO\n*> \\verbatim\n*> UPLO is CHARACTER*1\n*> = 'U': Upper triangle of A is stored;\n*> = 'L': Lower triangle of A is stored.\n*> \\endverbatim\n*>\n*> \\param[in] J1\n*> \\verbatim\n*> J1 is INTEGER\n*> The location of the first row, or column, of the panel\n*> within the submatrix of A, passed to this routine, e.g.,\n*> when called by CHETRF_AA, for the first panel, J1 is 1,\n*> while for the remaining panels, J1 is 2.\n*> \\endverbatim\n*>\n*> \\param[in] M\n*> \\verbatim\n*> M is INTEGER\n*> The dimension of the submatrix. M >= 0.\n*> \\endverbatim\n*>\n*> \\param[in] NB\n*> \\verbatim\n*> NB is INTEGER\n*> The dimension of the panel to be facotorized.\n*> \\endverbatim\n*>\n*> \\param[in,out] A\n*> \\verbatim\n*> A is COMPLEX array, dimension (LDA,M) for\n*> the first panel, while dimension (LDA,M+1) for the\n*> remaining panels.\n*>\n*> On entry, A contains the last row, or column, of\n*> the previous panel, and the trailing submatrix of A\n*> to be factorized, except for the first panel, only\n*> the panel is passed.\n*>\n*> On exit, the leading panel is factorized.\n*> \\endverbatim\n*>\n*> \\param[in] LDA\n*> \\verbatim\n*> LDA is INTEGER\n*> The leading dimension of the array A. LDA >= max(1,N).\n*> \\endverbatim\n*>\n*> \\param[out] IPIV\n*> \\verbatim\n*> IPIV is INTEGER array, dimension (N)\n*> Details of the row and column interchanges,\n*> the row and column k were interchanged with the row and\n*> column IPIV(k).\n*> \\endverbatim\n*>\n*> \\param[in,out] H\n*> \\verbatim\n*> H is COMPLEX workspace, dimension (LDH,NB).\n*>\n*> \\endverbatim\n*>\n*> \\param[in] LDH\n*> \\verbatim\n*> LDH is INTEGER\n*> The leading dimension of the workspace H. LDH >= max(1,M).\n*> \\endverbatim\n*>\n*> \\param[out] WORK\n*> \\verbatim\n*> WORK is COMPLEX workspace, dimension (M).\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit\n*> < 0: if INFO = -i, the i-th argument had an illegal value\n*> > 0: if INFO = i, D(i,i) is exactly zero. The factorization\n*> has been completed, but the block diagonal matrix D is\n*> exactly singular, and division by zero will occur if it\n*> is used to solve a system of equations.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\date December 2016\n*\n*> \\ingroup complexSYcomputational\n*\n* =====================================================================\n SUBROUTINE CLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV,\n $ H, LDH, WORK, INFO )\n*\n* -- LAPACK computational routine (version 3.7.0) --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* December 2016\n*\n IMPLICIT NONE\n*\n* .. Scalar Arguments ..\n CHARACTER UPLO\n INTEGER M, NB, J1, LDA, LDH, INFO\n* ..\n* .. Array Arguments ..\n INTEGER IPIV( * )\n COMPLEX A( LDA, * ), H( LDH, * ), WORK( * )\n* ..\n*\n* =====================================================================\n* .. Parameters ..\n COMPLEX ZERO, ONE\n PARAMETER ( ZERO = (0.0E+0, 0.0E+0), ONE = (1.0E+0, 0.0E+0) )\n*\n* .. Local Scalars ..\n INTEGER J, K, K1, I1, I2\n COMPLEX PIV, ALPHA\n* ..\n* .. External Functions ..\n LOGICAL LSAME\n INTEGER ICAMAX, ILAENV\n EXTERNAL LSAME, ILAENV, ICAMAX\n* ..\n* .. External Subroutines ..\n EXTERNAL XERBLA\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC REAL, CONJG, MAX\n* ..\n* .. Executable Statements ..\n*\n INFO = 0\n J = 1\n*\n* K1 is the first column of the panel to be factorized\n* i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks\n*\n K1 = (2-J1)+1\n*\n IF( LSAME( UPLO, 'U' ) ) THEN\n*\n* .....................................................\n* Factorize A as U**T*D*U using the upper triangle of A\n* .....................................................\n*\n 10 CONTINUE\n IF ( J.GT.MIN(M, NB) )\n $ GO TO 20\n*\n* K is the column to be factorized\n* when being called from CHETRF_AA,\n* > for the first block column, J1 is 1, hence J1+J-1 is J,\n* > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,\n*\n K = J1+J-1\n*\n* H(J:N, J) := A(J, J:N) - H(J:N, 1:(J-1)) * L(J1:(J-1), J),\n* where H(J:N, J) has been initialized to be A(J, J:N)\n*\n IF( K.GT.2 ) THEN\n*\n* K is the column to be factorized\n* > for the first block column, K is J, skipping the first two\n* columns\n* > for the rest of the columns, K is J+1, skipping only the\n* first column\n*\n CALL CLACGV( J-K1, A( 1, J ), 1 )\n CALL CGEMV( 'No transpose', M-J+1, J-K1,\n $ -ONE, H( J, K1 ), LDH,\n $ A( 1, J ), 1,\n $ ONE, H( J, J ), 1 )\n CALL CLACGV( J-K1, A( 1, J ), 1 )\n END IF\n*\n* Copy H(i:n, i) into WORK\n*\n CALL CCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )\n*\n IF( J.GT.K1 ) THEN\n*\n* Compute WORK := WORK - L(J-1, J:N) * T(J-1,J),\n* where A(J-1, J) stores T(J-1, J) and A(J-2, J:N) stores U(J-1, J:N)\n*\n ALPHA = -CONJG( A( K-1, J ) )\n CALL CAXPY( M-J+1, ALPHA, A( K-2, J ), LDA, WORK( 1 ), 1 )\n END IF\n*\n* Set A(J, J) = T(J, J)\n*\n A( K, J ) = REAL( WORK( 1 ) )\n*\n IF( J.LT.M ) THEN\n*\n* Compute WORK(2:N) = T(J, J) L(J, (J+1):N)\n* where A(J, J) stores T(J, J) and A(J-1, (J+1):N) stores U(J, (J+1):N)\n*\n IF( K.GT.1 ) THEN\n ALPHA = -A( K, J )\n CALL CAXPY( M-J, ALPHA, A( K-1, J+1 ), LDA,\n $ WORK( 2 ), 1 )\n ENDIF\n*\n* Find max(|WORK(2:n)|)\n*\n I2 = ICAMAX( M-J, WORK( 2 ), 1 ) + 1\n PIV = WORK( I2 )\n*\n* Apply hermitian pivot\n*\n IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN\n*\n* Swap WORK(I1) and WORK(I2)\n*\n I1 = 2\n WORK( I2 ) = WORK( I1 )\n WORK( I1 ) = PIV\n*\n* Swap A(I1, I1+1:N) with A(I1+1:N, I2)\n*\n I1 = I1+J-1\n I2 = I2+J-1\n CALL CSWAP( I2-I1-1, A( J1+I1-1, I1+1 ), LDA,\n $ A( J1+I1, I2 ), 1 )\n CALL CLACGV( I2-I1, A( J1+I1-1, I1+1 ), LDA )\n CALL CLACGV( I2-I1-1, A( J1+I1, I2 ), 1 )\n*\n* Swap A(I1, I2+1:N) with A(I2, I2+1:N)\n*\n CALL CSWAP( M-I2, A( J1+I1-1, I2+1 ), LDA,\n $ A( J1+I2-1, I2+1 ), LDA )\n*\n* Swap A(I1, I1) with A(I2,I2)\n*\n PIV = A( I1+J1-1, I1 )\n A( J1+I1-1, I1 ) = A( J1+I2-1, I2 )\n A( J1+I2-1, I2 ) = PIV\n*\n* Swap H(I1, 1:J1) with H(I2, 1:J1)\n*\n CALL CSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )\n IPIV( I1 ) = I2\n*\n IF( I1.GT.(K1-1) ) THEN\n*\n* Swap L(1:I1-1, I1) with L(1:I1-1, I2),\n* skipping the first column\n*\n CALL CSWAP( I1-K1+1, A( 1, I1 ), 1,\n $ A( 1, I2 ), 1 )\n END IF\n ELSE\n IPIV( J+1 ) = J+1\n ENDIF\n*\n* Set A(J, J+1) = T(J, J+1)\n*\n A( K, J+1 ) = WORK( 2 )\n IF( (A( K, J ).EQ.ZERO ) .AND.\n $ ( (J.EQ.M) .OR. (A( K, J+1 ).EQ.ZERO))) THEN\n IF(INFO .EQ. 0) THEN\n INFO = J\n END IF\n END IF\n*\n IF( J.LT.NB ) THEN\n*\n* Copy A(J+1:N, J+1) into H(J:N, J),\n*\n CALL CCOPY( M-J, A( K+1, J+1 ), LDA,\n $ H( J+1, J+1 ), 1 )\n END IF\n*\n* Compute L(J+2, J+1) = WORK( 3:N ) \/ T(J, J+1),\n* where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)\n*\n IF( A( K, J+1 ).NE.ZERO ) THEN\n ALPHA = ONE \/ A( K, J+1 )\n CALL CCOPY( M-J-1, WORK( 3 ), 1, A( K, J+2 ), LDA )\n CALL CSCAL( M-J-1, ALPHA, A( K, J+2 ), LDA )\n ELSE\n CALL CLASET( 'Full', 1, M-J-1, ZERO, ZERO,\n $ A( K, J+2 ), LDA)\n END IF\n ELSE\n IF( (A( K, J ).EQ.ZERO) .AND. (INFO.EQ.0) ) THEN\n INFO = J\n END IF\n END IF\n J = J + 1\n GO TO 10\n 20 CONTINUE\n*\n ELSE\n*\n* .....................................................\n* Factorize A as L*D*L**T using the lower triangle of A\n* .....................................................\n*\n 30 CONTINUE\n IF( J.GT.MIN( M, NB ) )\n $ GO TO 40\n*\n* K is the column to be factorized\n* when being called from CHETRF_AA,\n* > for the first block column, J1 is 1, hence J1+J-1 is J,\n* > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,\n*\n K = J1+J-1\n*\n* H(J:N, J) := A(J:N, J) - H(J:N, 1:(J-1)) * L(J, J1:(J-1))^T,\n* where H(J:N, J) has been initialized to be A(J:N, J)\n*\n IF( K.GT.2 ) THEN\n*\n* K is the column to be factorized\n* > for the first block column, K is J, skipping the first two\n* columns\n* > for the rest of the columns, K is J+1, skipping only the\n* first column\n*\n CALL CLACGV( J-K1, A( J, 1 ), LDA )\n CALL CGEMV( 'No transpose', M-J+1, J-K1,\n $ -ONE, H( J, K1 ), LDH,\n $ A( J, 1 ), LDA,\n $ ONE, H( J, J ), 1 )\n CALL CLACGV( J-K1, A( J, 1 ), LDA )\n END IF\n*\n* Copy H(J:N, J) into WORK\n*\n CALL CCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )\n*\n IF( J.GT.K1 ) THEN\n*\n* Compute WORK := WORK - L(J:N, J-1) * T(J-1,J),\n* where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1)\n*\n ALPHA = -CONJG( A( J, K-1 ) )\n CALL CAXPY( M-J+1, ALPHA, A( J, K-2 ), 1, WORK( 1 ), 1 )\n END IF\n*\n* Set A(J, J) = T(J, J)\n*\n A( J, K ) = REAL( WORK( 1 ) )\n*\n IF( J.LT.M ) THEN\n*\n* Compute WORK(2:N) = T(J, J) L((J+1):N, J)\n* where A(J, J) = T(J, J) and A((J+1):N, J-1) = L((J+1):N, J)\n*\n IF( K.GT.1 ) THEN\n ALPHA = -A( J, K )\n CALL CAXPY( M-J, ALPHA, A( J+1, K-1 ), 1,\n $ WORK( 2 ), 1 )\n ENDIF\n*\n* Find max(|WORK(2:n)|)\n*\n I2 = ICAMAX( M-J, WORK( 2 ), 1 ) + 1\n PIV = WORK( I2 )\n*\n* Apply hermitian pivot\n*\n IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN\n*\n* Swap WORK(I1) and WORK(I2)\n*\n I1 = 2\n WORK( I2 ) = WORK( I1 )\n WORK( I1 ) = PIV\n*\n* Swap A(I1+1:N, I1) with A(I2, I1+1:N)\n*\n I1 = I1+J-1\n I2 = I2+J-1\n CALL CSWAP( I2-I1-1, A( I1+1, J1+I1-1 ), 1,\n $ A( I2, J1+I1 ), LDA )\n CALL CLACGV( I2-I1, A( I1+1, J1+I1-1 ), 1 )\n CALL CLACGV( I2-I1-1, A( I2, J1+I1 ), LDA )\n*\n* Swap A(I2+1:N, I1) with A(I2+1:N, I2)\n*\n CALL CSWAP( M-I2, A( I2+1, J1+I1-1 ), 1,\n $ A( I2+1, J1+I2-1 ), 1 )\n*\n* Swap A(I1, I1) with A(I2, I2)\n*\n PIV = A( I1, J1+I1-1 )\n A( I1, J1+I1-1 ) = A( I2, J1+I2-1 )\n A( I2, J1+I2-1 ) = PIV\n*\n* Swap H(I1, I1:J1) with H(I2, I2:J1)\n*\n CALL CSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )\n IPIV( I1 ) = I2\n*\n IF( I1.GT.(K1-1) ) THEN\n*\n* Swap L(1:I1-1, I1) with L(1:I1-1, I2),\n* skipping the first column\n*\n CALL CSWAP( I1-K1+1, A( I1, 1 ), LDA,\n $ A( I2, 1 ), LDA )\n END IF\n ELSE\n IPIV( J+1 ) = J+1\n ENDIF\n*\n* Set A(J+1, J) = T(J+1, J)\n*\n A( J+1, K ) = WORK( 2 )\n IF( (A( J, K ).EQ.ZERO) .AND.\n $ ( (J.EQ.M) .OR. (A( J+1, K ).EQ.ZERO)) ) THEN\n IF (INFO .EQ. 0)\n $ INFO = J\n END IF\n*\n IF( J.LT.NB ) THEN\n*\n* Copy A(J+1:N, J+1) into H(J+1:N, J),\n*\n CALL CCOPY( M-J, A( J+1, K+1 ), 1,\n $ H( J+1, J+1 ), 1 )\n END IF\n*\n* Compute L(J+2, J+1) = WORK( 3:N ) \/ T(J, J+1),\n* where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)\n*\n IF( A( J+1, K ).NE.ZERO ) THEN\n ALPHA = ONE \/ A( J+1, K )\n CALL CCOPY( M-J-1, WORK( 3 ), 1, A( J+2, K ), 1 )\n CALL CSCAL( M-J-1, ALPHA, A( J+2, K ), 1 )\n ELSE\n CALL CLASET( 'Full', M-J-1, 1, ZERO, ZERO,\n $ A( J+2, K ), LDA )\n END IF\n ELSE\n IF( (A( J, K ).EQ.ZERO) .AND. (J.EQ.M)\n $ .AND. (INFO.EQ.0) ) INFO = J\n END IF\n J = J + 1\n GO TO 30\n 40 CONTINUE\n END IF\n RETURN\n*\n* End of CLAHEF_AA\n*\n END\n","avg_line_length":30.1692607004,"max_line_length":114,"alphanum_fraction":0.4299348681} {"size":250,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"program ringrav\nuse para\nimplicit none\n!r1=92000.d0\n!r2=117580.d0\n!r1=r1\/r_saturn\n!r2=r2\/r_saturn\n!dim=4.d0\n!r1=0.5d0\n!r2=1.5d0\n\ncall readriv\nprint*, \"\u5185\u5f84=\",r1,\"\u5916\u5f84=\",r2\nprint*,\"1\u5355\u4f4d\u957f\u5ea6(\u571f\u661f\u534a\u5f84)=60268Km\"\nprint*,\"\u683c\u7f51\u8fb9\u957f=\",dim\n\ncall grid \n\nend program ringrav\n\n","avg_line_length":11.9047619048,"max_line_length":28,"alphanum_fraction":0.704} {"size":12285,"ext":"f90","lang":"FORTRAN","max_stars_count":2.0,"content":"\n! ###############################################################\n! # #\n! # VLIDORT_2p8p2 #\n! # #\n! # Vectorized LInearized Discrete Ordinate Radiative Transfer #\n! # - -- - - - - #\n! # #\n! ###############################################################\n\n! ###############################################################\n! # #\n! # Author : Robert. J. D. Spurr #\n! # #\n! # Address : RT Solutions, Inc. #\n! # 9 Channing Street #\n! # Cambridge, MA 02138, USA #\n! # #\n! # Tel: (617) 492 1183 #\n! # Email : rtsolutions@verizon.net #\n! # #\n! # FIRST-ORDER SCALAR\/VECTOR MODEL #\n! # (EXACT SINGLE-SCATTERING and DIRECT-THERMAL) #\n! # #\n! # This Version : FO_1p5 (Version 1.5.2) #\n! # Release Date : 15 April 2020 #\n! # #\n! # Previous FO CODE Versions under Standard GPL 3.0: #\n! # ------------------------------------------------- #\n! # #\n! # Version 1.1, 13 February 2012, First Code #\n! # Version 1.2, 01 June 2012, Modularization #\n! # Version 1.3a, 29 October 2012, Obsgeom Multi-geom. #\n! # Version 1.3b, 24 January 2013, BRDF\/SL Supplements #\n! # Version 1.4, 31 July 2013, Lattice Multi-geom. #\n! # Version 1.5, 7 July 2016. Use Fmatrix\/Phasfunc #\n! # Version 1.5, 22 August 2016. Partial-layer output. #\n! # Version 1.5, 30 April 2017. Shakedown completed #\n! # #\n! # FO Version 1.5 coincides (V)LIDORT Version (2.8)3.8 #\n! # FO Version 1.5.1 coincides (V)LIDORT Version (2.8.1)3.8.1 #\n! # #\n! # This Version #\n! # ------------ #\n! # #\n! # FO_1.5.2, released April 15 2020. #\n! # ==> Geometry (FO), separated from RT Calculations #\n! # ==> Use of phase functions only in FO code #\n! # ==> Use I\/O Geometry type structures directly #\n! # ==> Optional for the Doublet Geometry #\n! # #\n! # FO Version 1.5.2 coincides (V)LIDORT Version (2.8.2)3.8.2 #\n! # #\n! ###############################################################\n\n! ##################################################################\n! # #\n! # This is Version 1.5.2 of the FO_1p5 software library. This #\n! # library comes with the Standard GNU General Public License, #\n! # Version 3.0, 29 June 2007. Please read this license carefully. #\n! # #\n! # FO CODE Copyright (c) 2010-2020. #\n! # Robert Spurr, RT Solutions Inc. #\n! # 9 Channing Street, Cambridge, MA 02138, USA. #\n! # #\n! # This file is part of FO_1p5 Version 1.5.2. #\n! # #\n! # FO_1p5 is free software: you can redistribute it #\n! # and\/or modify it under the terms of the GNU GPL (Standard) #\n! # General Public License) as published by the Free Software #\n! # Foundation, either version 3.0 of this License, or any #\n! # later version. #\n! # #\n! # FO_1p5 is distributed in the hope that it will be #\n! # useful, but WITHOUT ANY WARRANTY; without even the implied #\n! # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR #\n! # PURPOSE. See the GNU Standard General Public License (GPL) #\n! # for more details. #\n! # #\n! # You should have received a copy of the GNU Standard General #\n! # Public License (GPL) Version 3.0, along with FO_1p5_ #\n! # Version 1.5.2. If not, see . #\n! # #\n! ##################################################################\n\n! ###############################################################\n! # #\n! # Subroutines in this Module #\n! # #\n! # FO_get_planckfunction #\n! # #\n! ###############################################################\n\n module FO_getPlanck_m\n\n PRIVATE\n PUBLIC :: FO_get_planckfunction\n\n contains\n\n subroutine FO_get_planckfunction &\n ( WNUMLO, WNUMHI, TEMPERATURE, & ! Inputs\n BBFUNC, SMALLV, FAIL, MESSAGE ) ! Outputs\n\n implicit none\n\n! Input arguments\n! ---------------\n\n! WNUMLO, WNUMHI are the wavenumber integration limits\n! TEMPERATURE is self-evident, must be in units K\n\n DOUBLE PRECISION, intent(in) :: WNUMLO, WNUMHI\n DOUBLE PRECISION, intent(in) :: TEMPERATURE\n\n! output arguments\n! ----------------\n\n! BBFUNC is the Planck function\n! SMALLV is a debug diagnostic\n\n DOUBLE PRECISION, intent(out) :: BBFUNC\n INTEGER, intent(out) :: SMALLV\n\n! Exception handling\n\n LOGICAL, intent(out) :: FAIL\n CHARACTER*(*), intent(out) :: MESSAGE\n\n! Local variables\n! ---------------\n\n! Local parameters for:\n! (1) General use\n DOUBLE PRECISION, parameter :: &\n C2 = 1.438786d0, & !Planck function constant #2\n SIGMA = 5.67032d-8, & !Stefan-Boltzmann constant\n SIGDPI = 1.80491891383d-8, & !SIGMA\/Pi\n POWER4 = 4.0d0, &\n CONC = 1.5398973382d-01 !15.0d0\/(Pi**POWER4)\n! (2) Method discrimination\n DOUBLE PRECISION, parameter :: &\n EPSIL = 1.0d-8, &\n VMAX = 32.0d0\n! (2a) Method #1: Simpson's rule\n integer, parameter :: &\n NSIMPSON = 25\n DOUBLE PRECISION, parameter :: &\n CRITERION = 1.0d-10\n! (2b) Method #2: Polynomial series\n DOUBLE PRECISION, parameter :: &\n A1 = 3.33333333333d-01, & ! 1.0\/3.0\n A2 = -1.25d-01, & ! -1.0\/8.0\n A3 = 1.66666666667d-02, & ! 1.0\/60.0\n A4 = -1.98412698413d-04, & ! -1.0\/5040.0\n A5 = 3.67430922986d-06, & ! 1.0\/272160.0\n A6 = -7.51563251563d-08 ! -1.0\/13305600.0\n! (2c) Method #3: Exponential series\n DOUBLE PRECISION, parameter :: &\n VCUT = 1.5d0\n DOUBLE PRECISION, parameter, dimension(7) :: &\n VCP = (\/ 10.25d0, 5.7d0, 3.9d0, 2.9d0, &\n 2.3d0, 1.9d0, 0.0d0 \/)\n\n! Other variables\n\n INTEGER :: N, K, M, MMAX, I\n\n DOUBLE PRECISION :: XLOW, XHIG, XX, X(2), XCUBE, EXPX, OEXPXM1\n DOUBLE PRECISION :: RANGE, XSTEP, XSTEP3, FACTOR, GAMMA\n DOUBLE PRECISION :: PLANCK_LOW, PLANCK_HIG, PLANCK, SCALING\n DOUBLE PRECISION :: VAL, VAL0, OLDVAL, T\n\n DOUBLE PRECISION :: EX, F, MV, M4, PL, XSQ\n DOUBLE PRECISION :: PLANCK_EXP(2)\n DOUBLE PRECISION :: PLANCK_POL(2)\n\n! Initialize output\n\n FAIL = .false.\n MESSAGE = ' '\n SMALLV = 0\n BBFUNC = 0.0d0\n\n! Check input\n\n T = TEMPERATURE\n IF( T.LT.0.0 .OR. WNUMHI.LE.WNUMLO .OR. WNUMLO.LT.0. ) THEN\n FAIL = .true.\n MESSAGE = 'Bad input--temperature or wavenums. wrong'\n RETURN\n END IF\n\n! Limits in x-space\n\n GAMMA = C2 \/ T\n X(1) = GAMMA * WNUMLO\n X(2) = GAMMA * WNUMHI\n\n! Scaling constants\n\n SCALING = SIGDPI * T ** POWER4\n\n! Wavenumbers are very close. Get integral\n! by iterating Simpson rule to convergence.\n\n IF ( X(1).GT.EPSIL .AND. X(2).LT.VMAX .AND. &\n ( WNUMHI - WNUMLO ) \/ WNUMHI .LT. 1.D-2 ) THEN\n!write(*,*) 'doing simpson'\n SMALLV = 3\n\n! interval\n\n XLOW = X(1)\n XHIG = X(2)\n RANGE = XHIG - XLOW\n\n! Two end values\n\n EXPX = DEXP ( XLOW )\n OEXPXM1 = 1.0d0 \/ ( EXPX - 1.0d0 )\n XCUBE = XLOW * XLOW * XLOW\n PLANCK_LOW = XCUBE * OEXPXM1\n\n EXPX = DEXP ( XHIG )\n OEXPXM1 = 1.0d0 \/ ( EXPX - 1.0d0 )\n XCUBE = XHIG * XHIG * XHIG\n PLANCK_HIG = XCUBE * OEXPXM1\n\n! Integral starting points\n\n VAL0 = PLANCK_LOW + PLANCK_HIG\n\n! First guess\n\n OLDVAL = VAL0 * 0.5d0 * RANGE\n\n! Simpson's Rule up to 10 steps\n\n DO N = 1, NSIMPSON\n\n! Interval\n\n XSTEP = 0.5d0 * RANGE \/ DBLE(N)\n XSTEP3 = XSTEP \/ 3.0d0\n\n! Integral\n\n VAL = VAL0\n DO K = 1, 2*N - 1\n XX = X(1) + DBLE(K) * XSTEP\n FACTOR = DBLE(2*(1+MOD(K,2)))\n EXPX = DEXP ( XX )\n OEXPXM1 = 1.0d0 \/ ( EXPX - 1.0d0 )\n XCUBE = XX * XX * XX\n PLANCK = XCUBE * OEXPXM1\n VAL = VAL + FACTOR * PLANCK\n ENDDO\n VAL = VAL * XSTEP3\n\n! Examine convergence\n\n IF (DABS((VAL-OLDVAL)\/VAL).LE.CRITERION) GOTO 30\n OLDVAL = VAL\n\n! End integration loop\n\n ENDDO\n\n! No convergence, error message and return\n\n MESSAGE = 'Simpson rule didnt converge'\n FAIL = .true.\n RETURN\n\n! Continuation point\n\n 30 CONTINUE\n\n! Set the final answer\n\n BBFUNC = SCALING * VAL * CONC\n\n RETURN\n\n! Finish\n\n ENDIF\n\n! Regular cases\n\n SMALLV = 0\n\n! Loop over two values\n\n DO I = 1, 2\n\n! Power series\n\n IF( X( I ).LT.VCUT ) THEN\n!write(*,*) 'doing polynomial'\n SMALLV = SMALLV + 1\n XX = X(I)\n XSQ = XX * XX\n PLANCK_POL(I) = CONC * XSQ * XX*( A1 + &\n XX*( A2 + XX*( A3 + XSQ*( A4 + XSQ*( A5 + XSQ*A6 ) ) ) ) )\n ELSE\n\n! Use exponential series\n!write(*,*) 'doing exponential'\n! .......Find the upper limit of the series\n\n MMAX = 0\n 40 CONTINUE\n MMAX = MMAX + 1\n IF( X(I) .LT. VCP( MMAX ) ) GO TO 40\n\n! .......Exponential series integration\n\n EX = DEXP( - X(I) )\n F = 1.0d0\n PL = 0.0d0\n DO M = 1, MMAX\n MV = M*X(I)\n F = EX * F\n M4 = DBLE(M) ** (-POWER4)\n PL = PL + F*(6.0d0+MV*(6.0d0+MV*(3.0d0+MV)))*M4\n ENDDO\n PLANCK_EXP(I) = PL * CONC\n ENDIF\n ENDDO\n\n! ** Handle ill-conditioning\n! SMALLV = 0 ---> ** WNUMLO and WNUMHI both small\n! SMALLV = 1 ---> ** WNUMLO small, WNUMHI large\n! SMALLV = 2 ---> ** WNUMLO and WNUMHI both large\n\n IF( SMALLV.EQ.2 ) THEN\n VAL = PLANCK_POL(2) - PLANCK_POL(1)\n ELSE IF( SMALLV.EQ.1 ) THEN\n VAL = 1.0d0 - PLANCK_POL (1) - PLANCK_EXP(2)\n ELSE\n VAL = PLANCK_EXP(1) - PLANCK_EXP(2)\n END IF\n\n! Set the final answer\n\n BBFUNC = SCALING * VAL\n\n! Finish\n\n RETURN\n END SUBROUTINE FO_get_planckfunction\n\n! End module\n\nend module FO_getPlanck_m\n\n","avg_line_length":34.2200557103,"max_line_length":69,"alphanum_fraction":0.4105820106} {"size":1357,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"\n!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n SUBROUTINE mexFunction( nlhs, plhs, nrhs, prhs )\n!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n! Matlab Gateway for the Derivative Function Fun\n!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n USE cbmz_sorgam_Model\n\n INTEGER nlhs, nrhs\n INTEGER plhs(*), prhs(*)\n INTEGER mxGetPr, mxCreateFull, mxGetM, mxgetN\n INTEGER VPtr, FPtr, RPtr, VdotPtr\n REAL(kind=dp) V(66), F(2), RCT(142)\n REAL(kind=dp) Vdot(66)\n\n! Check for the right number of input arguments\n IF ( nrhs .ne. 3 ) THEN\n CALL mexErrMsgTxt('Fun requires 3 input vectors: &\n &V(66), F(2), RCT(142)')\n END IF \n! Check for the right number of output arguments\n IF ( nlhs .ne. 1 ) THEN\n CALL mexErrMsgTxt('Fun requires 1 output vector: &\n &Vdot(66)')\n END IF \n\n plhs(1) = mxCreateDoubleMatrix(66,1,0)\n\n VPtr = mxGetPr(prhs(1))\n CALL mxCopyPtrToReal8(VPtr,V,66)\n \n FPtr = mxGetPr(prhs(2))\n CALL mxCopyPtrToReal8(FPtr,F,2)\n \n RPtr = mxGetPr(prhs(3))\n CALL mxCopyPtrToReal8(RPtr,RCT,142)\n\n VdotPtr = mxGetPr(plhs(1))\n\n CALL Fun( V, F, RCT, Vdot )\n\n CALL mxCopyReal8ToPtr(Vdot, VdotPtr, 66)\n\n END SUBROUTINE mexFunction\n","avg_line_length":29.5,"max_line_length":75,"alphanum_fraction":0.5084745763} {"size":380,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"\nThe UC Davis Religious Studies department offers both major and minor programs specializing in world and local religions. They even have a website that tells you more!\n\nThe department office is located on the 6th floor of Sproul Hall and is headed by Naomi Janowitz. Popular professors within the department have included Naomi Janowitz, Whalen Lai, and formerly, Lincoln Hurst.\n","avg_line_length":76.0,"max_line_length":209,"alphanum_fraction":0.8184210526} {"size":2947,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":"!***********************************************************************\n!\n SUBROUTINE GETOLDWT(NDEF, NCMIN, WT)\n!\n! Interactively determines the weights for EOL calculation.\n! It's modified to always ask the question for the weight\n!\n! Call(s) to: [LIB92]: GETYN.\n!\n! Written by Xinghong He Last revision: 19 Mar 1999\n!\n!***********************************************************************\n!...Translated by Pacific-Sierra Research 77to90 4.3E 14:04:58 1\/ 3\/07\n!...Modified by Charlotte Froese Fischer\n! Gediminas Gaigalas 10\/05\/17\n!-----------------------------------------------\n! M o d u l e s\n!-----------------------------------------------\n USE vast_kind_param, ONLY: DOUBLE\n USE iounit_C\n IMPLICIT NONE\n!-----------------------------------------------\n! D u m m y A r g u m e n t s\n!-----------------------------------------------\n INTEGER :: NDEF\n INTEGER , INTENT(IN) :: NCMIN\n REAL(DOUBLE) :: WT(NCMIN)\n!-----------------------------------------------\n! L o c a l V a r i a b l e s\n!-----------------------------------------------\n INTEGER :: I, N159\n REAL(DOUBLE) :: SUMWGT\n!-----------------------------------------------\n\n! Standard weights: ncmin=1, OL calculation\n\n IF (NCMIN == 1) THEN\n WT(1) = -1.D0\n RETURN\n ENDIF\n\n! Select a method to assign level weights for ncmin > 1 case\n\n WRITE (ISTDE, *) 'level weights (1 equal; 5 standard; 9 user)'\n\n ! Let user try 10 times to get the correct input. 10 is BIG\n ! enough since the idea here is to allow user mistakes and\n ! at the same time to avoid an infinity loop.\n\n DO I = 1, 10\n READ (ISTDI, *) N159\n IF (N159==1 .OR. N159==5 .OR. N159==9) EXIT\n WRITE (ISTDE, *) 'Input not correct, do it again. tried=', I\n END DO\n\n IF (NDEF.EQ.0) THEN\n WRITE(734,*) n159,'! level weights'\n END IF\n\n IF (I > 10) ERROR STOP\n\n!------------------------------------------------------------------\n\n SELECT CASE (N159) ! Equal weight\n CASE (1)\n WT = -2.D0\n CASE (5) ! Standard weight\n WT = -1.D0\n CASE (9) ! User-input weight\n\n 123 CONTINUE\n WRITE (ISTDE, *) 'Enter the (relative) weights of the', NCMIN, &\n ' levels :'\n READ (ISTDI, *) (WT(I),I=1,NCMIN)\n\n SUMWGT = 0.D0\n DO I = 1, NCMIN\n IF (WT(I) <= 0.D0) THEN\n WRITE (ISTDE, *) 'Weights must exceed 0;'\n GO TO 123\n ELSE\n SUMWGT = SUMWGT + WT(I)\n ENDIF\n END DO\n SUMWGT = 1.D0\/SUMWGT\n WT = SUMWGT*WT\n\n CASE DEFAULT\n WRITE (ISTDE, *) 'Impossible ! Because it was guarded'\n ERROR STOP\n END SELECT\n\n RETURN\n END SUBROUTINE GETOLDWT\n","avg_line_length":31.0210526316,"max_line_length":74,"alphanum_fraction":0.4214455378} {"size":1724,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"!! --------------------------------------------------------------------------\n!!\n!! FyMcPack Example\n!!\n!! Example : testDict\n!!\n!! Initiaize dictionary with input file and get variables\n!!\n!! Authors\n!! YoungMyung Choi, Ecole Centrale de Nantes\n!!\n!! --------------------------------------------------------------------------\n Program main\n\n use mfpGlobal\n use mfpGeneral\n\n Implicit None\n type(typDictionaryPtr) :: dictPtr, subDict\n character(len=CHAR_LEN) :: fileDir\n character(len=CHAR_LEN) :: fileName\n character(len=CHAR_LEN) :: fileExt\n\n real(rp) :: realval\n real(rp), allocatable :: realArr(:)\n\n !!... Set Dictionary File Path\n fileDir = \"..\/\"\n fileName = \"testDict\"\n fileExt = \"\"\n\n !!... Intialize Dictionary\n Call dictPtr%initialize(fileDir, fileName, fileExt)\n\n !!... Show Dictionary Contents\n Call dictPtr%print()\n\n !!... Get Variables\n !!\n !! Be careful. Fortran does not recognize output type.\n !! It could be dangerous.\n !!\n write(*,*) \"varR : \", dictPtr%getReal(\"varR\")\n\n realArr = dictPtr%getRealArray(\"arrR\")\n\n write(*,*) \"realArray : \",realArr\n\n subDict = dictPtr%subDict(\"dict1\")\n\n Call subDict%print()\n\n Call checkSubDict(subDict%subDict(\"dict3\"))\n\n End Program\n\n Subroutine checkSubDict(dict)\n use mfpGlobal\n use mfpGeneral\n Implicit None\n type(typDictionaryPtr) :: dict\n character(len=CHAR_LEN) :: fruit\n\n fruit = dict%getChar(\"fruit\")\n write(*,*) \"fruit = \", fruit\n\n End Subroutine\n","avg_line_length":25.3529411765,"max_line_length":77,"alphanum_fraction":0.5040603248} {"size":34,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"#redirect Davis Healthcare Center\n","avg_line_length":17.0,"max_line_length":33,"alphanum_fraction":0.8529411765} {"size":104399,"ext":"f","lang":"FORTRAN","max_stars_count":13.0,"content":"*> \\brief \\b SBLAT3\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n* Definition:\n* ===========\n*\n* PROGRAM SBLAT3\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> Test program for the REAL Level 3 Blas.\n*>\n*> The program must be driven by a short data file. The first 14 records\n*> of the file are read using list-directed input, the last 6 records\n*> are read using the format ( A6, L2 ). An annotated example of a data\n*> file can be obtained by deleting the first 3 characters from the\n*> following 20 lines:\n*> 'sblat3.out' NAME OF SUMMARY OUTPUT FILE\n*> 6 UNIT NUMBER OF SUMMARY FILE\n*> 'SBLAT3.SNAP' NAME OF SNAPSHOT OUTPUT FILE\n*> -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0)\n*> F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD.\n*> F LOGICAL FLAG, T TO STOP ON FAILURES.\n*> T LOGICAL FLAG, T TO TEST ERROR EXITS.\n*> 16.0 THRESHOLD VALUE OF TEST RATIO\n*> 6 NUMBER OF VALUES OF N\n*> 0 1 2 3 5 9 VALUES OF N\n*> 3 NUMBER OF VALUES OF ALPHA\n*> 0.0 1.0 0.7 VALUES OF ALPHA\n*> 3 NUMBER OF VALUES OF BETA\n*> 0.0 1.0 1.3 VALUES OF BETA\n*> SGEMM T PUT F FOR NO TEST. SAME COLUMNS.\n*> SSYMM T PUT F FOR NO TEST. SAME COLUMNS.\n*> STRMM T PUT F FOR NO TEST. SAME COLUMNS.\n*> STRSM T PUT F FOR NO TEST. SAME COLUMNS.\n*> SSYRK T PUT F FOR NO TEST. SAME COLUMNS.\n*> SSYR2K T PUT F FOR NO TEST. SAME COLUMNS.\n*>\n*> Further Details\n*> ===============\n*>\n*> See:\n*>\n*> Dongarra J. J., Du Croz J. J., Duff I. S. and Hammarling S.\n*> A Set of Level 3 Basic Linear Algebra Subprograms.\n*>\n*> Technical Memorandum No.88 (Revision 1), Mathematics and\n*> Computer Science Division, Argonne National Laboratory, 9700\n*> South Cass Avenue, Argonne, Illinois 60439, US.\n*>\n*> -- Written on 8-February-1989.\n*> Jack Dongarra, Argonne National Laboratory.\n*> Iain Duff, AERE Harwell.\n*> Jeremy Du Croz, Numerical Algorithms Group Ltd.\n*> Sven Hammarling, Numerical Algorithms Group Ltd.\n*>\n*> 10-9-00: Change STATUS='NEW' to 'UNKNOWN' so that the testers\n*> can be run multiple times without deleting generated\n*> output files (susan)\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\date April 2012\n*\n*> \\ingroup single_blas_testing\n*\n* =====================================================================\n PROGRAM SBLAT3\n use M_blas, only : set_xerbla\n*\n* -- Reference BLAS test routine (version 3.7.0) --\n* -- Reference BLAS is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* April 2012\n*\n* =====================================================================\n*\n* .. Parameters ..\n INTEGER NIN\n PARAMETER ( NIN = 5 )\n INTEGER NSUBS\n PARAMETER ( NSUBS = 6 )\n REAL ZERO, ONE\n PARAMETER ( ZERO = 0.0, ONE = 1.0 )\n INTEGER NMAX\n PARAMETER ( NMAX = 65 )\n INTEGER NIDMAX, NALMAX, NBEMAX\n PARAMETER ( NIDMAX = 9, NALMAX = 7, NBEMAX = 7 )\n* .. Local Scalars ..\n REAL EPS, ERR, THRESH\n INTEGER I, ISNUM, J, N, NALF, NBET, NIDIM, NOUT, NTRA\n LOGICAL FATAL, LTESTT, REWI, SAME, SFATAL, TRACE,\n $ TSTERR\n CHARACTER*1 TRANSA, TRANSB\n CHARACTER*6 SNAMET\n CHARACTER*32 SNAPS, SUMMRY\n* .. Local Arrays ..\n REAL AA( NMAX*NMAX ), AB( NMAX, 2*NMAX ),\n $ ALF( NALMAX ), AS( NMAX*NMAX ),\n $ BB( NMAX*NMAX ), BET( NBEMAX ),\n $ BS( NMAX*NMAX ), C( NMAX, NMAX ),\n $ CC( NMAX*NMAX ), CS( NMAX*NMAX ), CT( NMAX ),\n $ G( NMAX ), W( 2*NMAX )\n INTEGER JDIM( NIDMAX )\n LOGICAL LTEST( NSUBS )\n CHARACTER*6 SNAMES( NSUBS )\n* .. External Functions ..\n REAL SDIFF\n LOGICAL LSE\n EXTERNAL SDIFF, LSE\n* .. External Subroutines ..\n EXTERNAL SCHK1, SCHK2, SCHK3, SCHK4, SCHK5, SCHKE, SMMCH\n* .. Intrinsic Functions ..\n INTRINSIC MAX, MIN\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n CHARACTER*6 SRNAMT\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n COMMON \/SRNAMC\/SRNAMT\n* .. Data statements ..\n DATA SNAMES\/'SGEMM ', 'SSYMM ', 'STRMM ', 'STRSM ',\n $ 'SSYRK ', 'SSYR2K'\/\n* .. Executable Statements ..\n call set_xerbla(test_xerbla)\n open(unit=nin,file='test\/sblat3.in')\n*\n* Read name and unit number for summary output file and open file.\n*\n READ( NIN, FMT = * )SUMMRY\n READ( NIN, FMT = * )NOUT\n if(summry.ne.' ') OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )\n NOUTC = NOUT\n*\n* Read name and unit number for snapshot output file and open file.\n*\n READ( NIN, FMT = * )SNAPS\n READ( NIN, FMT = * )NTRA\n TRACE = NTRA.GE.0\n IF( TRACE )THEN\n OPEN( NTRA, FILE = SNAPS )\n END IF\n* Read the flag that directs rewinding of the snapshot file.\n READ( NIN, FMT = * )REWI\n REWI = REWI.AND.TRACE\n* Read the flag that directs stopping on any failure.\n READ( NIN, FMT = * )SFATAL\n* Read the flag that indicates whether error exits are to be tested.\n READ( NIN, FMT = * )TSTERR\n* Read the threshold value of the test ratio\n READ( NIN, FMT = * )THRESH\n*\n* Read and check the parameter values for the tests.\n*\n* Values of N\n READ( NIN, FMT = * )NIDIM\n IF( NIDIM.LT.1.OR.NIDIM.GT.NIDMAX )THEN\n WRITE( NOUT, FMT = 9997 )'N', NIDMAX\n GO TO 220\n END IF\n READ( NIN, FMT = * )( JDIM( I ), I = 1, NIDIM )\n DO 10 I = 1, NIDIM\n IF( JDIM( I ).LT.0.OR.JDIM( I ).GT.NMAX )THEN\n WRITE( NOUT, FMT = 9996 )NMAX\n GO TO 220\n END IF\n 10 CONTINUE\n* Values of ALPHA\n READ( NIN, FMT = * )NALF\n IF( NALF.LT.1.OR.NALF.GT.NALMAX )THEN\n WRITE( NOUT, FMT = 9997 )'ALPHA', NALMAX\n GO TO 220\n END IF\n READ( NIN, FMT = * )( ALF( I ), I = 1, NALF )\n* Values of BETA\n READ( NIN, FMT = * )NBET\n IF( NBET.LT.1.OR.NBET.GT.NBEMAX )THEN\n WRITE( NOUT, FMT = 9997 )'BETA', NBEMAX\n GO TO 220\n END IF\n READ( NIN, FMT = * )( BET( I ), I = 1, NBET )\n*\n* Report values of parameters.\n*\n WRITE( NOUT, FMT = 9995 )\n WRITE( NOUT, FMT = 9994 )( JDIM( I ), I = 1, NIDIM )\n WRITE( NOUT, FMT = 9993 )( ALF( I ), I = 1, NALF )\n WRITE( NOUT, FMT = 9992 )( BET( I ), I = 1, NBET )\n IF( .NOT.TSTERR )THEN\n WRITE( NOUT, FMT = * )\n WRITE( NOUT, FMT = 9984 )\n END IF\n WRITE( NOUT, FMT = * )\n WRITE( NOUT, FMT = 9999 )THRESH\n WRITE( NOUT, FMT = * )\n*\n* Read names of subroutines and flags which indicate\n* whether they are to be tested.\n*\n DO 20 I = 1, NSUBS\n LTEST( I ) = .FALSE.\n 20 CONTINUE\n 30 READ( NIN, FMT = 9988, END = 60 )SNAMET, LTESTT\n DO 40 I = 1, NSUBS\n IF( SNAMET.EQ.SNAMES( I ) )\n $ GO TO 50\n 40 CONTINUE\n WRITE( NOUT, FMT = 9990 )SNAMET\n STOP\n 50 LTEST( I ) = LTESTT\n GO TO 30\n*\n 60 CONTINUE\n CLOSE ( NIN )\n*\n* Compute EPS (the machine precision).\n*\n EPS = EPSILON(ZERO)\n WRITE( NOUT, FMT = 9998 )EPS\n*\n* Check the reliability of SMMCH using exact data.\n*\n N = MIN( 32, NMAX )\n DO 100 J = 1, N\n DO 90 I = 1, N\n AB( I, J ) = MAX( I - J + 1, 0 )\n 90 CONTINUE\n AB( J, NMAX + 1 ) = J\n AB( 1, NMAX + J ) = J\n C( J, 1 ) = ZERO\n 100 CONTINUE\n DO 110 J = 1, N\n CC( J ) = J*( ( J + 1 )*J )\/2 - ( ( J + 1 )*J*( J - 1 ) )\/3\n 110 CONTINUE\n* CC holds the exact result. On exit from SMMCH CT holds\n* the result computed by SMMCH.\n TRANSA = 'N'\n TRANSB = 'N'\n CALL SMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,\n $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC,\n $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. )\n SAME = LSE( CC, CT, N )\n IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN\n WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR\n STOP\n END IF\n TRANSB = 'T'\n CALL SMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,\n $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC,\n $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. )\n SAME = LSE( CC, CT, N )\n IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN\n WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR\n STOP\n END IF\n DO 120 J = 1, N\n AB( J, NMAX + 1 ) = N - J + 1\n AB( 1, NMAX + J ) = N - J + 1\n 120 CONTINUE\n DO 130 J = 1, N\n CC( N - J + 1 ) = J*( ( J + 1 )*J )\/2 -\n $ ( ( J + 1 )*J*( J - 1 ) )\/3\n 130 CONTINUE\n TRANSA = 'T'\n TRANSB = 'N'\n CALL SMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,\n $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC,\n $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. )\n SAME = LSE( CC, CT, N )\n IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN\n WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR\n STOP\n END IF\n TRANSB = 'T'\n CALL SMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX,\n $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC,\n $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. )\n SAME = LSE( CC, CT, N )\n IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN\n WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR\n STOP\n END IF\n*\n* Test each subroutine in turn.\n*\n DO 200 ISNUM = 1, NSUBS\n WRITE( NOUT, FMT = * )\n IF( .NOT.LTEST( ISNUM ) )THEN\n* Subprogram is not to be tested.\n WRITE( NOUT, FMT = 9987 )SNAMES( ISNUM )\n ELSE\n SRNAMT = SNAMES( ISNUM )\n* Test error exits.\n IF( TSTERR )THEN\n CALL SCHKE( ISNUM, SNAMES( ISNUM ), NOUT )\n WRITE( NOUT, FMT = * )\n END IF\n* Test computations.\n INFOT = 0\n OK = .TRUE.\n FATAL = .FALSE.\n GO TO ( 140, 150, 160, 160, 170, 180 )ISNUM\n* Test SGEMM, 01.\n 140 CALL SCHK1( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE,\n $ REWI, FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET,\n $ NMAX, AB, AA, AS, AB( 1, NMAX + 1 ), BB, BS, C,\n $ CC, CS, CT, G )\n GO TO 190\n* Test SSYMM, 02.\n 150 CALL SCHK2( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE,\n $ REWI, FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET,\n $ NMAX, AB, AA, AS, AB( 1, NMAX + 1 ), BB, BS, C,\n $ CC, CS, CT, G )\n GO TO 190\n* Test STRMM, 03, STRSM, 04.\n 160 CALL SCHK3( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE,\n $ REWI, FATAL, NIDIM, JDIM, NALF, ALF, NMAX, AB,\n $ AA, AS, AB( 1, NMAX + 1 ), BB, BS, CT, G, C )\n GO TO 190\n* Test SSYRK, 05.\n 170 CALL SCHK4( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE,\n $ REWI, FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET,\n $ NMAX, AB, AA, AS, AB( 1, NMAX + 1 ), BB, BS, C,\n $ CC, CS, CT, G )\n GO TO 190\n* Test SSYR2K, 06.\n 180 CALL SCHK5( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE,\n $ REWI, FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET,\n $ NMAX, AB, AA, AS, BB, BS, C, CC, CS, CT, G, W )\n GO TO 190\n*\n 190 IF( FATAL.AND.SFATAL )\n $ GO TO 210\n END IF\n 200 CONTINUE\n WRITE( NOUT, FMT = 9986 )\n GO TO 230\n*\n 210 CONTINUE\n WRITE( NOUT, FMT = 9985 )\n GO TO 230\n*\n 220 CONTINUE\n WRITE( NOUT, FMT = 9991 )\n*\n 230 CONTINUE\n IF( TRACE )\n $ CLOSE ( NTRA )\n CLOSE ( NOUT )\n STOP\n*\n 9999 FORMAT( ' ROUTINES PASS COMPUTATIONAL TESTS IF TEST RATIO IS LES',\n $ 'S THAN', F8.2 )\n 9998 FORMAT( ' RELATIVE MACHINE PRECISION IS TAKEN TO BE', 1P, E9.1 )\n 9997 FORMAT( ' NUMBER OF VALUES OF ', A, ' IS LESS THAN 1 OR GREATER ',\n $ 'THAN ', I2 )\n 9996 FORMAT( ' VALUE OF N IS LESS THAN 0 OR GREATER THAN ', I2 )\n 9995 FORMAT( ' TESTS OF THE REAL LEVEL 3 BLAS', \/\/' THE F',\n $ 'OLLOWING PARAMETER VALUES WILL BE USED:' )\n 9994 FORMAT( ' FOR N ', 9I6 )\n 9993 FORMAT( ' FOR ALPHA ', 7F6.1 )\n 9992 FORMAT( ' FOR BETA ', 7F6.1 )\n 9991 FORMAT( ' AMEND DATA FILE OR INCREASE ARRAY SIZES IN PROGRAM',\n $ \/' ******* TESTS ABANDONED *******' )\n 9990 FORMAT( ' SUBPROGRAM NAME ', A6, ' NOT RECOGNIZED', \/' ******* T',\n $ 'ESTS ABANDONED *******' )\n 9989 FORMAT( ' ERROR IN SMMCH - IN-LINE DOT PRODUCTS ARE BEING EVALU',\n $ 'ATED WRONGLY.', \/' SMMCH WAS CALLED WITH TRANSA = ', A1,\n $ ' AND TRANSB = ', A1, \/' AND RETURNED SAME = ', L1, ' AND ',\n $ 'ERR = ', F12.3, '.', \/' THIS MAY BE DUE TO FAULTS IN THE ',\n $ 'ARITHMETIC OR THE COMPILER.', \/' ******* TESTS ABANDONED ',\n $ '*******' )\n 9988 FORMAT( A6, L2 )\n 9987 FORMAT( 1X, A6, ' WAS NOT TESTED' )\n 9986 FORMAT( \/' END OF TESTS' )\n 9985 FORMAT( \/' ******* FATAL ERROR - TESTS ABANDONED *******' )\n 9984 FORMAT( ' ERROR-EXITS WILL NOT BE TESTED' )\n*\n* End of SBLAT3.\n*\n contains\n SUBROUTINE test_XERBLA( SRNAME, INFO )\n*\n* This is a special version of XERBLA to be used only as part of\n* the test program for testing error exits from the Level 3 BLAS\n* routines.\n*\n* XERBLA is an error handler for the Level 3 BLAS routines.\n*\n* It is called by the Level 3 BLAS routines if an input parameter is\n* invalid.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Scalar Arguments ..\n INTEGER,intent(in) :: INFO\n CHARACTER(len=*),intent(in) :: SRNAME\n* .. Scalars in Common ..\n INTEGER INFOT, NOUT\n LOGICAL LERR, OK\n CHARACTER*6 SRNAMT\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUT, OK, LERR\n COMMON \/SRNAMC\/SRNAMT\n* .. Executable Statements ..\n LERR = .TRUE.\n IF( INFO.NE.INFOT )THEN\n IF( INFOT.NE.0 )THEN\n WRITE( NOUT, FMT = 9999 )INFO, INFOT\n ELSE\n WRITE( NOUT, FMT = 9997 )INFO\n END IF\n OK = .FALSE.\n END IF\n IF( SRNAME.NE.SRNAMT )THEN\n WRITE( NOUT, FMT = 9998 )SRNAME, SRNAMT\n OK = .FALSE.\n END IF\n RETURN\n*\n 9999 FORMAT( ' ******* XERBLA WAS CALLED WITH INFO = ', I6, ' INSTEAD',\n $ ' OF ', I2, ' *******' )\n 9998 FORMAT( ' ******* XERBLA WAS CALLED WITH SRNAME = ', A6, ' INSTE',\n $ 'AD OF ', A6, ' *******' )\n 9997 FORMAT( ' ******* XERBLA WAS CALLED WITH INFO = ', I6,\n $ ' *******' )\n*\n* End of XERBLA\n*\n END SUBROUTINE test_XERBLA\n\n END PROGRAM SBLAT3\n SUBROUTINE SCHK1( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI,\n $ FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET, NMAX,\n $ A, AA, AS, B, BB, BS, C, CC, CS, CT, G )\n*\n* Tests SGEMM.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO\n PARAMETER ( ZERO = 0.0 )\n* .. Scalar Arguments ..\n REAL EPS, THRESH\n INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA\n LOGICAL FATAL, REWI, TRACE\n CHARACTER*6 SNAME\n* .. Array Arguments ..\n REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ),\n $ AS( NMAX*NMAX ), B( NMAX, NMAX ),\n $ BB( NMAX*NMAX ), BET( NBET ), BS( NMAX*NMAX ),\n $ C( NMAX, NMAX ), CC( NMAX*NMAX ),\n $ CS( NMAX*NMAX ), CT( NMAX ), G( NMAX )\n INTEGER JDIM( NIDIM )\n* .. Local Scalars ..\n REAL ALPHA, ALS, BETA, BLS, ERR, ERRMAX\n INTEGER I, IA, IB, ICA, ICB, IK, IM, IN, K, KS, LAA,\n $ LBB, LCC, LDA, LDAS, LDB, LDBS, LDC, LDCS, M,\n $ MA, MB, MS, N, NA, NARGS, NB, NC, NS\n LOGICAL NILL, RESET, SAME, TRANA, TRANB\n CHARACTER*1 TRANAS, TRANBS, TRANSA, TRANSB\n CHARACTER*3 ICH\n* .. Local Arrays ..\n LOGICAL ISAME( 13 )\n* .. External Functions ..\n LOGICAL LSE, LSERES\n EXTERNAL LSE, LSERES\n* .. External Subroutines ..\n EXTERNAL SGEMM, SMAKE, SMMCH\n* .. Intrinsic Functions ..\n INTRINSIC MAX\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n* .. Data statements ..\n DATA ICH\/'NTC'\/\n* .. Executable Statements ..\n*\n NARGS = 13\n NC = 0\n RESET = .TRUE.\n ERRMAX = ZERO\n*\n DO 110 IM = 1, NIDIM\n M = JDIM( IM )\n*\n DO 100 IN = 1, NIDIM\n N = JDIM( IN )\n* Set LDC to 1 more than minimum value if room.\n LDC = M\n IF( LDC.LT.NMAX )\n $ LDC = LDC + 1\n* Skip tests if not enough room.\n IF( LDC.GT.NMAX )\n $ GO TO 100\n LCC = LDC*N\n NILL = N.LE.0.OR.M.LE.0\n*\n DO 90 IK = 1, NIDIM\n K = JDIM( IK )\n*\n DO 80 ICA = 1, 3\n TRANSA = ICH( ICA: ICA )\n TRANA = TRANSA.EQ.'T'.OR.TRANSA.EQ.'C'\n*\n IF( TRANA )THEN\n MA = K\n NA = M\n ELSE\n MA = M\n NA = K\n END IF\n* Set LDA to 1 more than minimum value if room.\n LDA = MA\n IF( LDA.LT.NMAX )\n $ LDA = LDA + 1\n* Skip tests if not enough room.\n IF( LDA.GT.NMAX )\n $ GO TO 80\n LAA = LDA*NA\n*\n* Generate the matrix A.\n*\n CALL SMAKE( 'GE', ' ', ' ', MA, NA, A, NMAX, AA, LDA,\n $ RESET, ZERO )\n*\n DO 70 ICB = 1, 3\n TRANSB = ICH( ICB: ICB )\n TRANB = TRANSB.EQ.'T'.OR.TRANSB.EQ.'C'\n*\n IF( TRANB )THEN\n MB = N\n NB = K\n ELSE\n MB = K\n NB = N\n END IF\n* Set LDB to 1 more than minimum value if room.\n LDB = MB\n IF( LDB.LT.NMAX )\n $ LDB = LDB + 1\n* Skip tests if not enough room.\n IF( LDB.GT.NMAX )\n $ GO TO 70\n LBB = LDB*NB\n*\n* Generate the matrix B.\n*\n CALL SMAKE( 'GE', ' ', ' ', MB, NB, B, NMAX, BB,\n $ LDB, RESET, ZERO )\n*\n DO 60 IA = 1, NALF\n ALPHA = ALF( IA )\n*\n DO 50 IB = 1, NBET\n BETA = BET( IB )\n*\n* Generate the matrix C.\n*\n CALL SMAKE( 'GE', ' ', ' ', M, N, C, NMAX,\n $ CC, LDC, RESET, ZERO )\n*\n NC = NC + 1\n*\n* Save every datum before calling the\n* subroutine.\n*\n TRANAS = TRANSA\n TRANBS = TRANSB\n MS = M\n NS = N\n KS = K\n ALS = ALPHA\n DO 10 I = 1, LAA\n AS( I ) = AA( I )\n 10 CONTINUE\n LDAS = LDA\n DO 20 I = 1, LBB\n BS( I ) = BB( I )\n 20 CONTINUE\n LDBS = LDB\n BLS = BETA\n DO 30 I = 1, LCC\n CS( I ) = CC( I )\n 30 CONTINUE\n LDCS = LDC\n*\n* Call the subroutine.\n*\n IF( TRACE )\n $ WRITE( NTRA, FMT = 9995 )NC, SNAME,\n $ TRANSA, TRANSB, M, N, K, ALPHA, LDA, LDB,\n $ BETA, LDC\n IF( REWI )\n $ REWIND NTRA\n CALL SGEMM( TRANSA, TRANSB, M, N, K, ALPHA,\n $ AA, LDA, BB, LDB, BETA, CC, LDC )\n*\n* Check if error-exit was taken incorrectly.\n*\n IF( .NOT.OK )THEN\n WRITE( NOUT, FMT = 9994 )\n FATAL = .TRUE.\n GO TO 120\n END IF\n*\n* See what data changed inside subroutines.\n*\n ISAME( 1 ) = TRANSA.EQ.TRANAS\n ISAME( 2 ) = TRANSB.EQ.TRANBS\n ISAME( 3 ) = MS.EQ.M\n ISAME( 4 ) = NS.EQ.N\n ISAME( 5 ) = KS.EQ.K\n ISAME( 6 ) = ALS.EQ.ALPHA\n ISAME( 7 ) = LSE( AS, AA, LAA )\n ISAME( 8 ) = LDAS.EQ.LDA\n ISAME( 9 ) = LSE( BS, BB, LBB )\n ISAME( 10 ) = LDBS.EQ.LDB\n ISAME( 11 ) = BLS.EQ.BETA\n IF( NILL )THEN\n ISAME( 12 ) = LSE( CS, CC, LCC )\n ELSE\n ISAME( 12 ) = LSERES( 'GE', ' ', M, N, CS,\n $ CC, LDC )\n END IF\n ISAME( 13 ) = LDCS.EQ.LDC\n*\n* If data was incorrectly changed, report\n* and return.\n*\n SAME = .TRUE.\n DO 40 I = 1, NARGS\n SAME = SAME.AND.ISAME( I )\n IF( .NOT.ISAME( I ) )\n $ WRITE( NOUT, FMT = 9998 )I\n 40 CONTINUE\n IF( .NOT.SAME )THEN\n FATAL = .TRUE.\n GO TO 120\n END IF\n*\n IF( .NOT.NILL )THEN\n*\n* Check the result.\n*\n CALL SMMCH( TRANSA, TRANSB, M, N, K,\n $ ALPHA, A, NMAX, B, NMAX, BETA,\n $ C, NMAX, CT, G, CC, LDC, EPS,\n $ ERR, FATAL, NOUT, .TRUE. )\n ERRMAX = MAX( ERRMAX, ERR )\n* If got really bad answer, report and\n* return.\n IF( FATAL )\n $ GO TO 120\n END IF\n*\n 50 CONTINUE\n*\n 60 CONTINUE\n*\n 70 CONTINUE\n*\n 80 CONTINUE\n*\n 90 CONTINUE\n*\n 100 CONTINUE\n*\n 110 CONTINUE\n*\n* Report result.\n*\n IF( ERRMAX.LT.THRESH )THEN\n WRITE( NOUT, FMT = 9999 )SNAME, NC\n ELSE\n WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX\n END IF\n GO TO 130\n*\n 120 CONTINUE\n WRITE( NOUT, FMT = 9996 )SNAME\n WRITE( NOUT, FMT = 9995 )NC, SNAME, TRANSA, TRANSB, M, N, K,\n $ ALPHA, LDA, LDB, BETA, LDC\n*\n 130 CONTINUE\n RETURN\n*\n 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL',\n $ 'S)' )\n 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH',\n $ 'ANGED INCORRECTLY *******' )\n 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C',\n $ 'ALLS)', \/' ******* BUT WITH MAXIMUM TEST RATIO', F8.2,\n $ ' - SUSPECT *******' )\n 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' )\n 9995 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',''', A1, ''',',\n $ 3( I3, ',' ), F4.1, ', A,', I3, ', B,', I3, ',', F4.1, ', ',\n $ 'C,', I3, ').' )\n 9994 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *',\n $ '******' )\n*\n* End of SCHK1.\n*\n END\n SUBROUTINE SCHK2( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI,\n $ FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET, NMAX,\n $ A, AA, AS, B, BB, BS, C, CC, CS, CT, G )\n*\n* Tests SSYMM.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO\n PARAMETER ( ZERO = 0.0 )\n* .. Scalar Arguments ..\n REAL EPS, THRESH\n INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA\n LOGICAL FATAL, REWI, TRACE\n CHARACTER*6 SNAME\n* .. Array Arguments ..\n REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ),\n $ AS( NMAX*NMAX ), B( NMAX, NMAX ),\n $ BB( NMAX*NMAX ), BET( NBET ), BS( NMAX*NMAX ),\n $ C( NMAX, NMAX ), CC( NMAX*NMAX ),\n $ CS( NMAX*NMAX ), CT( NMAX ), G( NMAX )\n INTEGER JDIM( NIDIM )\n* .. Local Scalars ..\n REAL ALPHA, ALS, BETA, BLS, ERR, ERRMAX\n INTEGER I, IA, IB, ICS, ICU, IM, IN, LAA, LBB, LCC,\n $ LDA, LDAS, LDB, LDBS, LDC, LDCS, M, MS, N, NA,\n $ NARGS, NC, NS\n LOGICAL LEFT, NILL, RESET, SAME\n CHARACTER*1 SIDE, SIDES, UPLO, UPLOS\n CHARACTER*2 ICHS, ICHU\n* .. Local Arrays ..\n LOGICAL ISAME( 13 )\n* .. External Functions ..\n LOGICAL LSE, LSERES\n EXTERNAL LSE, LSERES\n* .. External Subroutines ..\n EXTERNAL SMAKE, SMMCH, SSYMM\n* .. Intrinsic Functions ..\n INTRINSIC MAX\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n* .. Data statements ..\n DATA ICHS\/'LR'\/, ICHU\/'UL'\/\n* .. Executable Statements ..\n*\n NARGS = 12\n NC = 0\n RESET = .TRUE.\n ERRMAX = ZERO\n*\n DO 100 IM = 1, NIDIM\n M = JDIM( IM )\n*\n DO 90 IN = 1, NIDIM\n N = JDIM( IN )\n* Set LDC to 1 more than minimum value if room.\n LDC = M\n IF( LDC.LT.NMAX )\n $ LDC = LDC + 1\n* Skip tests if not enough room.\n IF( LDC.GT.NMAX )\n $ GO TO 90\n LCC = LDC*N\n NILL = N.LE.0.OR.M.LE.0\n*\n* Set LDB to 1 more than minimum value if room.\n LDB = M\n IF( LDB.LT.NMAX )\n $ LDB = LDB + 1\n* Skip tests if not enough room.\n IF( LDB.GT.NMAX )\n $ GO TO 90\n LBB = LDB*N\n*\n* Generate the matrix B.\n*\n CALL SMAKE( 'GE', ' ', ' ', M, N, B, NMAX, BB, LDB, RESET,\n $ ZERO )\n*\n DO 80 ICS = 1, 2\n SIDE = ICHS( ICS: ICS )\n LEFT = SIDE.EQ.'L'\n*\n IF( LEFT )THEN\n NA = M\n ELSE\n NA = N\n END IF\n* Set LDA to 1 more than minimum value if room.\n LDA = NA\n IF( LDA.LT.NMAX )\n $ LDA = LDA + 1\n* Skip tests if not enough room.\n IF( LDA.GT.NMAX )\n $ GO TO 80\n LAA = LDA*NA\n*\n DO 70 ICU = 1, 2\n UPLO = ICHU( ICU: ICU )\n*\n* Generate the symmetric matrix A.\n*\n CALL SMAKE( 'SY', UPLO, ' ', NA, NA, A, NMAX, AA, LDA,\n $ RESET, ZERO )\n*\n DO 60 IA = 1, NALF\n ALPHA = ALF( IA )\n*\n DO 50 IB = 1, NBET\n BETA = BET( IB )\n*\n* Generate the matrix C.\n*\n CALL SMAKE( 'GE', ' ', ' ', M, N, C, NMAX, CC,\n $ LDC, RESET, ZERO )\n*\n NC = NC + 1\n*\n* Save every datum before calling the\n* subroutine.\n*\n SIDES = SIDE\n UPLOS = UPLO\n MS = M\n NS = N\n ALS = ALPHA\n DO 10 I = 1, LAA\n AS( I ) = AA( I )\n 10 CONTINUE\n LDAS = LDA\n DO 20 I = 1, LBB\n BS( I ) = BB( I )\n 20 CONTINUE\n LDBS = LDB\n BLS = BETA\n DO 30 I = 1, LCC\n CS( I ) = CC( I )\n 30 CONTINUE\n LDCS = LDC\n*\n* Call the subroutine.\n*\n IF( TRACE )\n $ WRITE( NTRA, FMT = 9995 )NC, SNAME, SIDE,\n $ UPLO, M, N, ALPHA, LDA, LDB, BETA, LDC\n IF( REWI )\n $ REWIND NTRA\n CALL SSYMM( SIDE, UPLO, M, N, ALPHA, AA, LDA,\n $ BB, LDB, BETA, CC, LDC )\n*\n* Check if error-exit was taken incorrectly.\n*\n IF( .NOT.OK )THEN\n WRITE( NOUT, FMT = 9994 )\n FATAL = .TRUE.\n GO TO 110\n END IF\n*\n* See what data changed inside subroutines.\n*\n ISAME( 1 ) = SIDES.EQ.SIDE\n ISAME( 2 ) = UPLOS.EQ.UPLO\n ISAME( 3 ) = MS.EQ.M\n ISAME( 4 ) = NS.EQ.N\n ISAME( 5 ) = ALS.EQ.ALPHA\n ISAME( 6 ) = LSE( AS, AA, LAA )\n ISAME( 7 ) = LDAS.EQ.LDA\n ISAME( 8 ) = LSE( BS, BB, LBB )\n ISAME( 9 ) = LDBS.EQ.LDB\n ISAME( 10 ) = BLS.EQ.BETA\n IF( NILL )THEN\n ISAME( 11 ) = LSE( CS, CC, LCC )\n ELSE\n ISAME( 11 ) = LSERES( 'GE', ' ', M, N, CS,\n $ CC, LDC )\n END IF\n ISAME( 12 ) = LDCS.EQ.LDC\n*\n* If data was incorrectly changed, report and\n* return.\n*\n SAME = .TRUE.\n DO 40 I = 1, NARGS\n SAME = SAME.AND.ISAME( I )\n IF( .NOT.ISAME( I ) )\n $ WRITE( NOUT, FMT = 9998 )I\n 40 CONTINUE\n IF( .NOT.SAME )THEN\n FATAL = .TRUE.\n GO TO 110\n END IF\n*\n IF( .NOT.NILL )THEN\n*\n* Check the result.\n*\n IF( LEFT )THEN\n CALL SMMCH( 'N', 'N', M, N, M, ALPHA, A,\n $ NMAX, B, NMAX, BETA, C, NMAX,\n $ CT, G, CC, LDC, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n ELSE\n CALL SMMCH( 'N', 'N', M, N, N, ALPHA, B,\n $ NMAX, A, NMAX, BETA, C, NMAX,\n $ CT, G, CC, LDC, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n END IF\n ERRMAX = MAX( ERRMAX, ERR )\n* If got really bad answer, report and\n* return.\n IF( FATAL )\n $ GO TO 110\n END IF\n*\n 50 CONTINUE\n*\n 60 CONTINUE\n*\n 70 CONTINUE\n*\n 80 CONTINUE\n*\n 90 CONTINUE\n*\n 100 CONTINUE\n*\n* Report result.\n*\n IF( ERRMAX.LT.THRESH )THEN\n WRITE( NOUT, FMT = 9999 )SNAME, NC\n ELSE\n WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX\n END IF\n GO TO 120\n*\n 110 CONTINUE\n WRITE( NOUT, FMT = 9996 )SNAME\n WRITE( NOUT, FMT = 9995 )NC, SNAME, SIDE, UPLO, M, N, ALPHA, LDA,\n $ LDB, BETA, LDC\n*\n 120 CONTINUE\n RETURN\n*\n 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL',\n $ 'S)' )\n 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH',\n $ 'ANGED INCORRECTLY *******' )\n 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C',\n $ 'ALLS)', \/' ******* BUT WITH MAXIMUM TEST RATIO', F8.2,\n $ ' - SUSPECT *******' )\n 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' )\n 9995 FORMAT( 1X, I6, ': ', A6, '(', 2( '''', A1, ''',' ), 2( I3, ',' ),\n $ F4.1, ', A,', I3, ', B,', I3, ',', F4.1, ', C,', I3, ') ',\n $ ' .' )\n 9994 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *',\n $ '******' )\n*\n* End of SCHK2.\n*\n END\n SUBROUTINE SCHK3( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI,\n $ FATAL, NIDIM, JDIM, NALF, ALF, NMAX, A, AA, AS,\n $ B, BB, BS, CT, G, C )\n*\n* Tests STRMM and STRSM.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO, ONE\n PARAMETER ( ZERO = 0.0, ONE = 1.0 )\n* .. Scalar Arguments ..\n REAL EPS, THRESH\n INTEGER NALF, NIDIM, NMAX, NOUT, NTRA\n LOGICAL FATAL, REWI, TRACE\n CHARACTER*6 SNAME\n* .. Array Arguments ..\n REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ),\n $ AS( NMAX*NMAX ), B( NMAX, NMAX ),\n $ BB( NMAX*NMAX ), BS( NMAX*NMAX ),\n $ C( NMAX, NMAX ), CT( NMAX ), G( NMAX )\n INTEGER JDIM( NIDIM )\n* .. Local Scalars ..\n REAL ALPHA, ALS, ERR, ERRMAX\n INTEGER I, IA, ICD, ICS, ICT, ICU, IM, IN, J, LAA, LBB,\n $ LDA, LDAS, LDB, LDBS, M, MS, N, NA, NARGS, NC,\n $ NS\n LOGICAL LEFT, NILL, RESET, SAME\n CHARACTER*1 DIAG, DIAGS, SIDE, SIDES, TRANAS, TRANSA, UPLO,\n $ UPLOS\n CHARACTER*2 ICHD, ICHS, ICHU\n CHARACTER*3 ICHT\n* .. Local Arrays ..\n LOGICAL ISAME( 13 )\n* .. External Functions ..\n LOGICAL LSE, LSERES\n EXTERNAL LSE, LSERES\n* .. External Subroutines ..\n EXTERNAL SMAKE, SMMCH, STRMM, STRSM\n* .. Intrinsic Functions ..\n INTRINSIC MAX\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n* .. Data statements ..\n DATA ICHU\/'UL'\/, ICHT\/'NTC'\/, ICHD\/'UN'\/, ICHS\/'LR'\/\n* .. Executable Statements ..\n*\n NARGS = 11\n NC = 0\n RESET = .TRUE.\n ERRMAX = ZERO\n* Set up zero matrix for SMMCH.\n DO 20 J = 1, NMAX\n DO 10 I = 1, NMAX\n C( I, J ) = ZERO\n 10 CONTINUE\n 20 CONTINUE\n*\n DO 140 IM = 1, NIDIM\n M = JDIM( IM )\n*\n DO 130 IN = 1, NIDIM\n N = JDIM( IN )\n* Set LDB to 1 more than minimum value if room.\n LDB = M\n IF( LDB.LT.NMAX )\n $ LDB = LDB + 1\n* Skip tests if not enough room.\n IF( LDB.GT.NMAX )\n $ GO TO 130\n LBB = LDB*N\n NILL = M.LE.0.OR.N.LE.0\n*\n DO 120 ICS = 1, 2\n SIDE = ICHS( ICS: ICS )\n LEFT = SIDE.EQ.'L'\n IF( LEFT )THEN\n NA = M\n ELSE\n NA = N\n END IF\n* Set LDA to 1 more than minimum value if room.\n LDA = NA\n IF( LDA.LT.NMAX )\n $ LDA = LDA + 1\n* Skip tests if not enough room.\n IF( LDA.GT.NMAX )\n $ GO TO 130\n LAA = LDA*NA\n*\n DO 110 ICU = 1, 2\n UPLO = ICHU( ICU: ICU )\n*\n DO 100 ICT = 1, 3\n TRANSA = ICHT( ICT: ICT )\n*\n DO 90 ICD = 1, 2\n DIAG = ICHD( ICD: ICD )\n*\n DO 80 IA = 1, NALF\n ALPHA = ALF( IA )\n*\n* Generate the matrix A.\n*\n CALL SMAKE( 'TR', UPLO, DIAG, NA, NA, A,\n $ NMAX, AA, LDA, RESET, ZERO )\n*\n* Generate the matrix B.\n*\n CALL SMAKE( 'GE', ' ', ' ', M, N, B, NMAX,\n $ BB, LDB, RESET, ZERO )\n*\n NC = NC + 1\n*\n* Save every datum before calling the\n* subroutine.\n*\n SIDES = SIDE\n UPLOS = UPLO\n TRANAS = TRANSA\n DIAGS = DIAG\n MS = M\n NS = N\n ALS = ALPHA\n DO 30 I = 1, LAA\n AS( I ) = AA( I )\n 30 CONTINUE\n LDAS = LDA\n DO 40 I = 1, LBB\n BS( I ) = BB( I )\n 40 CONTINUE\n LDBS = LDB\n*\n* Call the subroutine.\n*\n IF( SNAME( 4: 5 ).EQ.'MM' )THEN\n IF( TRACE )\n $ WRITE( NTRA, FMT = 9995 )NC, SNAME,\n $ SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA,\n $ LDA, LDB\n IF( REWI )\n $ REWIND NTRA\n CALL STRMM( SIDE, UPLO, TRANSA, DIAG, M,\n $ N, ALPHA, AA, LDA, BB, LDB )\n ELSE IF( SNAME( 4: 5 ).EQ.'SM' )THEN\n IF( TRACE )\n $ WRITE( NTRA, FMT = 9995 )NC, SNAME,\n $ SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA,\n $ LDA, LDB\n IF( REWI )\n $ REWIND NTRA\n CALL STRSM( SIDE, UPLO, TRANSA, DIAG, M,\n $ N, ALPHA, AA, LDA, BB, LDB )\n END IF\n*\n* Check if error-exit was taken incorrectly.\n*\n IF( .NOT.OK )THEN\n WRITE( NOUT, FMT = 9994 )\n FATAL = .TRUE.\n GO TO 150\n END IF\n*\n* See what data changed inside subroutines.\n*\n ISAME( 1 ) = SIDES.EQ.SIDE\n ISAME( 2 ) = UPLOS.EQ.UPLO\n ISAME( 3 ) = TRANAS.EQ.TRANSA\n ISAME( 4 ) = DIAGS.EQ.DIAG\n ISAME( 5 ) = MS.EQ.M\n ISAME( 6 ) = NS.EQ.N\n ISAME( 7 ) = ALS.EQ.ALPHA\n ISAME( 8 ) = LSE( AS, AA, LAA )\n ISAME( 9 ) = LDAS.EQ.LDA\n IF( NILL )THEN\n ISAME( 10 ) = LSE( BS, BB, LBB )\n ELSE\n ISAME( 10 ) = LSERES( 'GE', ' ', M, N, BS,\n $ BB, LDB )\n END IF\n ISAME( 11 ) = LDBS.EQ.LDB\n*\n* If data was incorrectly changed, report and\n* return.\n*\n SAME = .TRUE.\n DO 50 I = 1, NARGS\n SAME = SAME.AND.ISAME( I )\n IF( .NOT.ISAME( I ) )\n $ WRITE( NOUT, FMT = 9998 )I\n 50 CONTINUE\n IF( .NOT.SAME )THEN\n FATAL = .TRUE.\n GO TO 150\n END IF\n*\n IF( .NOT.NILL )THEN\n IF( SNAME( 4: 5 ).EQ.'MM' )THEN\n*\n* Check the result.\n*\n IF( LEFT )THEN\n CALL SMMCH( TRANSA, 'N', M, N, M,\n $ ALPHA, A, NMAX, B, NMAX,\n $ ZERO, C, NMAX, CT, G,\n $ BB, LDB, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n ELSE\n CALL SMMCH( 'N', TRANSA, M, N, N,\n $ ALPHA, B, NMAX, A, NMAX,\n $ ZERO, C, NMAX, CT, G,\n $ BB, LDB, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n END IF\n ELSE IF( SNAME( 4: 5 ).EQ.'SM' )THEN\n*\n* Compute approximation to original\n* matrix.\n*\n DO 70 J = 1, N\n DO 60 I = 1, M\n C( I, J ) = BB( I + ( J - 1 )*\n $ LDB )\n BB( I + ( J - 1 )*LDB ) = ALPHA*\n $ B( I, J )\n 60 CONTINUE\n 70 CONTINUE\n*\n IF( LEFT )THEN\n CALL SMMCH( TRANSA, 'N', M, N, M,\n $ ONE, A, NMAX, C, NMAX,\n $ ZERO, B, NMAX, CT, G,\n $ BB, LDB, EPS, ERR,\n $ FATAL, NOUT, .FALSE. )\n ELSE\n CALL SMMCH( 'N', TRANSA, M, N, N,\n $ ONE, C, NMAX, A, NMAX,\n $ ZERO, B, NMAX, CT, G,\n $ BB, LDB, EPS, ERR,\n $ FATAL, NOUT, .FALSE. )\n END IF\n END IF\n ERRMAX = MAX( ERRMAX, ERR )\n* If got really bad answer, report and\n* return.\n IF( FATAL )\n $ GO TO 150\n END IF\n*\n 80 CONTINUE\n*\n 90 CONTINUE\n*\n 100 CONTINUE\n*\n 110 CONTINUE\n*\n 120 CONTINUE\n*\n 130 CONTINUE\n*\n 140 CONTINUE\n*\n* Report result.\n*\n IF( ERRMAX.LT.THRESH )THEN\n WRITE( NOUT, FMT = 9999 )SNAME, NC\n ELSE\n WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX\n END IF\n GO TO 160\n*\n 150 CONTINUE\n WRITE( NOUT, FMT = 9996 )SNAME\n WRITE( NOUT, FMT = 9995 )NC, SNAME, SIDE, UPLO, TRANSA, DIAG, M,\n $ N, ALPHA, LDA, LDB\n*\n 160 CONTINUE\n RETURN\n*\n 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL',\n $ 'S)' )\n 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH',\n $ 'ANGED INCORRECTLY *******' )\n 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C',\n $ 'ALLS)', \/' ******* BUT WITH MAXIMUM TEST RATIO', F8.2,\n $ ' - SUSPECT *******' )\n 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' )\n 9995 FORMAT( 1X, I6, ': ', A6, '(', 4( '''', A1, ''',' ), 2( I3, ',' ),\n $ F4.1, ', A,', I3, ', B,', I3, ') .' )\n 9994 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *',\n $ '******' )\n*\n* End of SCHK3.\n*\n END\n SUBROUTINE SCHK4( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI,\n $ FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET, NMAX,\n $ A, AA, AS, B, BB, BS, C, CC, CS, CT, G )\n*\n* Tests SSYRK.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO\n PARAMETER ( ZERO = 0.0 )\n* .. Scalar Arguments ..\n REAL EPS, THRESH\n INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA\n LOGICAL FATAL, REWI, TRACE\n CHARACTER*6 SNAME\n* .. Array Arguments ..\n REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ),\n $ AS( NMAX*NMAX ), B( NMAX, NMAX ),\n $ BB( NMAX*NMAX ), BET( NBET ), BS( NMAX*NMAX ),\n $ C( NMAX, NMAX ), CC( NMAX*NMAX ),\n $ CS( NMAX*NMAX ), CT( NMAX ), G( NMAX )\n INTEGER JDIM( NIDIM )\n* .. Local Scalars ..\n REAL ALPHA, ALS, BETA, BETS, ERR, ERRMAX\n INTEGER I, IA, IB, ICT, ICU, IK, IN, J, JC, JJ, K, KS,\n $ LAA, LCC, LDA, LDAS, LDC, LDCS, LJ, MA, N, NA,\n $ NARGS, NC, NS\n LOGICAL NILL, RESET, SAME, TRAN, UPPER\n CHARACTER*1 TRANS, TRANSS, UPLO, UPLOS\n CHARACTER*2 ICHU\n CHARACTER*3 ICHT\n* .. Local Arrays ..\n LOGICAL ISAME( 13 )\n* .. External Functions ..\n LOGICAL LSE, LSERES\n EXTERNAL LSE, LSERES\n* .. External Subroutines ..\n EXTERNAL SMAKE, SMMCH, SSYRK\n* .. Intrinsic Functions ..\n INTRINSIC MAX\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n* .. Data statements ..\n DATA ICHT\/'NTC'\/, ICHU\/'UL'\/\n* .. Executable Statements ..\n*\n NARGS = 10\n NC = 0\n RESET = .TRUE.\n ERRMAX = ZERO\n*\n DO 100 IN = 1, NIDIM\n N = JDIM( IN )\n* Set LDC to 1 more than minimum value if room.\n LDC = N\n IF( LDC.LT.NMAX )\n $ LDC = LDC + 1\n* Skip tests if not enough room.\n IF( LDC.GT.NMAX )\n $ GO TO 100\n LCC = LDC*N\n NILL = N.LE.0\n*\n DO 90 IK = 1, NIDIM\n K = JDIM( IK )\n*\n DO 80 ICT = 1, 3\n TRANS = ICHT( ICT: ICT )\n TRAN = TRANS.EQ.'T'.OR.TRANS.EQ.'C'\n IF( TRAN )THEN\n MA = K\n NA = N\n ELSE\n MA = N\n NA = K\n END IF\n* Set LDA to 1 more than minimum value if room.\n LDA = MA\n IF( LDA.LT.NMAX )\n $ LDA = LDA + 1\n* Skip tests if not enough room.\n IF( LDA.GT.NMAX )\n $ GO TO 80\n LAA = LDA*NA\n*\n* Generate the matrix A.\n*\n CALL SMAKE( 'GE', ' ', ' ', MA, NA, A, NMAX, AA, LDA,\n $ RESET, ZERO )\n*\n DO 70 ICU = 1, 2\n UPLO = ICHU( ICU: ICU )\n UPPER = UPLO.EQ.'U'\n*\n DO 60 IA = 1, NALF\n ALPHA = ALF( IA )\n*\n DO 50 IB = 1, NBET\n BETA = BET( IB )\n*\n* Generate the matrix C.\n*\n CALL SMAKE( 'SY', UPLO, ' ', N, N, C, NMAX, CC,\n $ LDC, RESET, ZERO )\n*\n NC = NC + 1\n*\n* Save every datum before calling the subroutine.\n*\n UPLOS = UPLO\n TRANSS = TRANS\n NS = N\n KS = K\n ALS = ALPHA\n DO 10 I = 1, LAA\n AS( I ) = AA( I )\n 10 CONTINUE\n LDAS = LDA\n BETS = BETA\n DO 20 I = 1, LCC\n CS( I ) = CC( I )\n 20 CONTINUE\n LDCS = LDC\n*\n* Call the subroutine.\n*\n IF( TRACE )\n $ WRITE( NTRA, FMT = 9994 )NC, SNAME, UPLO,\n $ TRANS, N, K, ALPHA, LDA, BETA, LDC\n IF( REWI )\n $ REWIND NTRA\n CALL SSYRK( UPLO, TRANS, N, K, ALPHA, AA, LDA,\n $ BETA, CC, LDC )\n*\n* Check if error-exit was taken incorrectly.\n*\n IF( .NOT.OK )THEN\n WRITE( NOUT, FMT = 9993 )\n FATAL = .TRUE.\n GO TO 120\n END IF\n*\n* See what data changed inside subroutines.\n*\n ISAME( 1 ) = UPLOS.EQ.UPLO\n ISAME( 2 ) = TRANSS.EQ.TRANS\n ISAME( 3 ) = NS.EQ.N\n ISAME( 4 ) = KS.EQ.K\n ISAME( 5 ) = ALS.EQ.ALPHA\n ISAME( 6 ) = LSE( AS, AA, LAA )\n ISAME( 7 ) = LDAS.EQ.LDA\n ISAME( 8 ) = BETS.EQ.BETA\n IF( NILL )THEN\n ISAME( 9 ) = LSE( CS, CC, LCC )\n ELSE\n ISAME( 9 ) = LSERES( 'SY', UPLO, N, N, CS,\n $ CC, LDC )\n END IF\n ISAME( 10 ) = LDCS.EQ.LDC\n*\n* If data was incorrectly changed, report and\n* return.\n*\n SAME = .TRUE.\n DO 30 I = 1, NARGS\n SAME = SAME.AND.ISAME( I )\n IF( .NOT.ISAME( I ) )\n $ WRITE( NOUT, FMT = 9998 )I\n 30 CONTINUE\n IF( .NOT.SAME )THEN\n FATAL = .TRUE.\n GO TO 120\n END IF\n*\n IF( .NOT.NILL )THEN\n*\n* Check the result column by column.\n*\n JC = 1\n DO 40 J = 1, N\n IF( UPPER )THEN\n JJ = 1\n LJ = J\n ELSE\n JJ = J\n LJ = N - J + 1\n END IF\n IF( TRAN )THEN\n CALL SMMCH( 'T', 'N', LJ, 1, K, ALPHA,\n $ A( 1, JJ ), NMAX,\n $ A( 1, J ), NMAX, BETA,\n $ C( JJ, J ), NMAX, CT, G,\n $ CC( JC ), LDC, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n ELSE\n CALL SMMCH( 'N', 'T', LJ, 1, K, ALPHA,\n $ A( JJ, 1 ), NMAX,\n $ A( J, 1 ), NMAX, BETA,\n $ C( JJ, J ), NMAX, CT, G,\n $ CC( JC ), LDC, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n END IF\n IF( UPPER )THEN\n JC = JC + LDC\n ELSE\n JC = JC + LDC + 1\n END IF\n ERRMAX = MAX( ERRMAX, ERR )\n* If got really bad answer, report and\n* return.\n IF( FATAL )\n $ GO TO 110\n 40 CONTINUE\n END IF\n*\n 50 CONTINUE\n*\n 60 CONTINUE\n*\n 70 CONTINUE\n*\n 80 CONTINUE\n*\n 90 CONTINUE\n*\n 100 CONTINUE\n*\n* Report result.\n*\n IF( ERRMAX.LT.THRESH )THEN\n WRITE( NOUT, FMT = 9999 )SNAME, NC\n ELSE\n WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX\n END IF\n GO TO 130\n*\n 110 CONTINUE\n IF( N.GT.1 )\n $ WRITE( NOUT, FMT = 9995 )J\n*\n 120 CONTINUE\n WRITE( NOUT, FMT = 9996 )SNAME\n WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, TRANS, N, K, ALPHA,\n $ LDA, BETA, LDC\n*\n 130 CONTINUE\n RETURN\n*\n 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL',\n $ 'S)' )\n 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH',\n $ 'ANGED INCORRECTLY *******' )\n 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C',\n $ 'ALLS)', \/' ******* BUT WITH MAXIMUM TEST RATIO', F8.2,\n $ ' - SUSPECT *******' )\n 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' )\n 9995 FORMAT( ' THESE ARE THE RESULTS FOR COLUMN ', I3 )\n 9994 FORMAT( 1X, I6, ': ', A6, '(', 2( '''', A1, ''',' ), 2( I3, ',' ),\n $ F4.1, ', A,', I3, ',', F4.1, ', C,', I3, ') .' )\n 9993 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *',\n $ '******' )\n*\n* End of SCHK4.\n*\n END\n SUBROUTINE SCHK5( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI,\n $ FATAL, NIDIM, JDIM, NALF, ALF, NBET, BET, NMAX,\n $ AB, AA, AS, BB, BS, C, CC, CS, CT, G, W )\n*\n* Tests SSYR2K.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO\n PARAMETER ( ZERO = 0.0 )\n* .. Scalar Arguments ..\n REAL EPS, THRESH\n INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA\n LOGICAL FATAL, REWI, TRACE\n CHARACTER*6 SNAME\n* .. Array Arguments ..\n REAL AA( NMAX*NMAX ), AB( 2*NMAX*NMAX ),\n $ ALF( NALF ), AS( NMAX*NMAX ), BB( NMAX*NMAX ),\n $ BET( NBET ), BS( NMAX*NMAX ), C( NMAX, NMAX ),\n $ CC( NMAX*NMAX ), CS( NMAX*NMAX ), CT( NMAX ),\n $ G( NMAX ), W( 2*NMAX )\n INTEGER JDIM( NIDIM )\n* .. Local Scalars ..\n REAL ALPHA, ALS, BETA, BETS, ERR, ERRMAX\n INTEGER I, IA, IB, ICT, ICU, IK, IN, J, JC, JJ, JJAB,\n $ K, KS, LAA, LBB, LCC, LDA, LDAS, LDB, LDBS,\n $ LDC, LDCS, LJ, MA, N, NA, NARGS, NC, NS\n LOGICAL NILL, RESET, SAME, TRAN, UPPER\n CHARACTER*1 TRANS, TRANSS, UPLO, UPLOS\n CHARACTER*2 ICHU\n CHARACTER*3 ICHT\n* .. Local Arrays ..\n LOGICAL ISAME( 13 )\n* .. External Functions ..\n LOGICAL LSE, LSERES\n EXTERNAL LSE, LSERES\n* .. External Subroutines ..\n EXTERNAL SMAKE, SMMCH, SSYR2K\n* .. Intrinsic Functions ..\n INTRINSIC MAX\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n* .. Data statements ..\n DATA ICHT\/'NTC'\/, ICHU\/'UL'\/\n* .. Executable Statements ..\n*\n NARGS = 12\n NC = 0\n RESET = .TRUE.\n ERRMAX = ZERO\n*\n DO 130 IN = 1, NIDIM\n N = JDIM( IN )\n* Set LDC to 1 more than minimum value if room.\n LDC = N\n IF( LDC.LT.NMAX )\n $ LDC = LDC + 1\n* Skip tests if not enough room.\n IF( LDC.GT.NMAX )\n $ GO TO 130\n LCC = LDC*N\n NILL = N.LE.0\n*\n DO 120 IK = 1, NIDIM\n K = JDIM( IK )\n*\n DO 110 ICT = 1, 3\n TRANS = ICHT( ICT: ICT )\n TRAN = TRANS.EQ.'T'.OR.TRANS.EQ.'C'\n IF( TRAN )THEN\n MA = K\n NA = N\n ELSE\n MA = N\n NA = K\n END IF\n* Set LDA to 1 more than minimum value if room.\n LDA = MA\n IF( LDA.LT.NMAX )\n $ LDA = LDA + 1\n* Skip tests if not enough room.\n IF( LDA.GT.NMAX )\n $ GO TO 110\n LAA = LDA*NA\n*\n* Generate the matrix A.\n*\n IF( TRAN )THEN\n CALL SMAKE( 'GE', ' ', ' ', MA, NA, AB, 2*NMAX, AA,\n $ LDA, RESET, ZERO )\n ELSE\n CALL SMAKE( 'GE', ' ', ' ', MA, NA, AB, NMAX, AA, LDA,\n $ RESET, ZERO )\n END IF\n*\n* Generate the matrix B.\n*\n LDB = LDA\n LBB = LAA\n IF( TRAN )THEN\n CALL SMAKE( 'GE', ' ', ' ', MA, NA, AB( K + 1 ),\n $ 2*NMAX, BB, LDB, RESET, ZERO )\n ELSE\n CALL SMAKE( 'GE', ' ', ' ', MA, NA, AB( K*NMAX + 1 ),\n $ NMAX, BB, LDB, RESET, ZERO )\n END IF\n*\n DO 100 ICU = 1, 2\n UPLO = ICHU( ICU: ICU )\n UPPER = UPLO.EQ.'U'\n*\n DO 90 IA = 1, NALF\n ALPHA = ALF( IA )\n*\n DO 80 IB = 1, NBET\n BETA = BET( IB )\n*\n* Generate the matrix C.\n*\n CALL SMAKE( 'SY', UPLO, ' ', N, N, C, NMAX, CC,\n $ LDC, RESET, ZERO )\n*\n NC = NC + 1\n*\n* Save every datum before calling the subroutine.\n*\n UPLOS = UPLO\n TRANSS = TRANS\n NS = N\n KS = K\n ALS = ALPHA\n DO 10 I = 1, LAA\n AS( I ) = AA( I )\n 10 CONTINUE\n LDAS = LDA\n DO 20 I = 1, LBB\n BS( I ) = BB( I )\n 20 CONTINUE\n LDBS = LDB\n BETS = BETA\n DO 30 I = 1, LCC\n CS( I ) = CC( I )\n 30 CONTINUE\n LDCS = LDC\n*\n* Call the subroutine.\n*\n IF( TRACE )\n $ WRITE( NTRA, FMT = 9994 )NC, SNAME, UPLO,\n $ TRANS, N, K, ALPHA, LDA, LDB, BETA, LDC\n IF( REWI )\n $ REWIND NTRA\n CALL SSYR2K( UPLO, TRANS, N, K, ALPHA, AA, LDA,\n $ BB, LDB, BETA, CC, LDC )\n*\n* Check if error-exit was taken incorrectly.\n*\n IF( .NOT.OK )THEN\n WRITE( NOUT, FMT = 9993 )\n FATAL = .TRUE.\n GO TO 150\n END IF\n*\n* See what data changed inside subroutines.\n*\n ISAME( 1 ) = UPLOS.EQ.UPLO\n ISAME( 2 ) = TRANSS.EQ.TRANS\n ISAME( 3 ) = NS.EQ.N\n ISAME( 4 ) = KS.EQ.K\n ISAME( 5 ) = ALS.EQ.ALPHA\n ISAME( 6 ) = LSE( AS, AA, LAA )\n ISAME( 7 ) = LDAS.EQ.LDA\n ISAME( 8 ) = LSE( BS, BB, LBB )\n ISAME( 9 ) = LDBS.EQ.LDB\n ISAME( 10 ) = BETS.EQ.BETA\n IF( NILL )THEN\n ISAME( 11 ) = LSE( CS, CC, LCC )\n ELSE\n ISAME( 11 ) = LSERES( 'SY', UPLO, N, N, CS,\n $ CC, LDC )\n END IF\n ISAME( 12 ) = LDCS.EQ.LDC\n*\n* If data was incorrectly changed, report and\n* return.\n*\n SAME = .TRUE.\n DO 40 I = 1, NARGS\n SAME = SAME.AND.ISAME( I )\n IF( .NOT.ISAME( I ) )\n $ WRITE( NOUT, FMT = 9998 )I\n 40 CONTINUE\n IF( .NOT.SAME )THEN\n FATAL = .TRUE.\n GO TO 150\n END IF\n*\n IF( .NOT.NILL )THEN\n*\n* Check the result column by column.\n*\n JJAB = 1\n JC = 1\n DO 70 J = 1, N\n IF( UPPER )THEN\n JJ = 1\n LJ = J\n ELSE\n JJ = J\n LJ = N - J + 1\n END IF\n IF( TRAN )THEN\n DO 50 I = 1, K\n W( I ) = AB( ( J - 1 )*2*NMAX + K +\n $ I )\n W( K + I ) = AB( ( J - 1 )*2*NMAX +\n $ I )\n 50 CONTINUE\n CALL SMMCH( 'T', 'N', LJ, 1, 2*K,\n $ ALPHA, AB( JJAB ), 2*NMAX,\n $ W, 2*NMAX, BETA,\n $ C( JJ, J ), NMAX, CT, G,\n $ CC( JC ), LDC, EPS, ERR,\n $ FATAL, NOUT, .TRUE. )\n ELSE\n DO 60 I = 1, K\n W( I ) = AB( ( K + I - 1 )*NMAX +\n $ J )\n W( K + I ) = AB( ( I - 1 )*NMAX +\n $ J )\n 60 CONTINUE\n CALL SMMCH( 'N', 'N', LJ, 1, 2*K,\n $ ALPHA, AB( JJ ), NMAX, W,\n $ 2*NMAX, BETA, C( JJ, J ),\n $ NMAX, CT, G, CC( JC ), LDC,\n $ EPS, ERR, FATAL, NOUT,\n $ .TRUE. )\n END IF\n IF( UPPER )THEN\n JC = JC + LDC\n ELSE\n JC = JC + LDC + 1\n IF( TRAN )\n $ JJAB = JJAB + 2*NMAX\n END IF\n ERRMAX = MAX( ERRMAX, ERR )\n* If got really bad answer, report and\n* return.\n IF( FATAL )\n $ GO TO 140\n 70 CONTINUE\n END IF\n*\n 80 CONTINUE\n*\n 90 CONTINUE\n*\n 100 CONTINUE\n*\n 110 CONTINUE\n*\n 120 CONTINUE\n*\n 130 CONTINUE\n*\n* Report result.\n*\n IF( ERRMAX.LT.THRESH )THEN\n WRITE( NOUT, FMT = 9999 )SNAME, NC\n ELSE\n WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX\n END IF\n GO TO 160\n*\n 140 CONTINUE\n IF( N.GT.1 )\n $ WRITE( NOUT, FMT = 9995 )J\n*\n 150 CONTINUE\n WRITE( NOUT, FMT = 9996 )SNAME\n WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, TRANS, N, K, ALPHA,\n $ LDA, LDB, BETA, LDC\n*\n 160 CONTINUE\n RETURN\n*\n 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL',\n $ 'S)' )\n 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH',\n $ 'ANGED INCORRECTLY *******' )\n 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C',\n $ 'ALLS)', \/' ******* BUT WITH MAXIMUM TEST RATIO', F8.2,\n $ ' - SUSPECT *******' )\n 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' )\n 9995 FORMAT( ' THESE ARE THE RESULTS FOR COLUMN ', I3 )\n 9994 FORMAT( 1X, I6, ': ', A6, '(', 2( '''', A1, ''',' ), 2( I3, ',' ),\n $ F4.1, ', A,', I3, ', B,', I3, ',', F4.1, ', C,', I3, ') ',\n $ ' .' )\n 9993 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *',\n $ '******' )\n*\n* End of SCHK5.\n*\n END\n SUBROUTINE SCHKE( ISNUM, SRNAMT, NOUT )\n*\n* Tests the error exits from the Level 3 Blas.\n* Requires a special version of the error-handling routine XERBLA.\n* A, B and C should not need to be defined.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* 3-19-92: Initialize ALPHA and BETA (eca)\n* 3-19-92: Fix argument 12 in calls to SSYMM with INFOT = 9 (eca)\n*\n* .. Scalar Arguments ..\n INTEGER ISNUM, NOUT\n CHARACTER*6 SRNAMT\n* .. Scalars in Common ..\n INTEGER INFOT, NOUTC\n LOGICAL LERR, OK\n* .. Parameters ..\n REAL ONE, TWO\n PARAMETER ( ONE = 1.0E0, TWO = 2.0E0 )\n* .. Local Scalars ..\n REAL ALPHA, BETA\n* .. Local Arrays ..\n REAL A( 2, 1 ), B( 2, 1 ), C( 2, 1 )\n* .. External Subroutines ..\n EXTERNAL CHKXER, SGEMM, SSYMM, SSYR2K, SSYRK, STRMM,\n $ STRSM\n* .. Common blocks ..\n COMMON \/INFOC\/INFOT, NOUTC, OK, LERR\n* .. Executable Statements ..\n* OK is set to .FALSE. by the special version of XERBLA or by CHKXER\n* if anything is wrong.\n OK = .TRUE.\n* LERR is set to .TRUE. by the special version of XERBLA each time\n* it is called, and is then tested and re-set by CHKXER.\n LERR = .FALSE.\n*\n* Initialize ALPHA and BETA.\n*\n ALPHA = ONE\n BETA = TWO\n*\n GO TO ( 10, 20, 30, 40, 50, 60 )ISNUM\n 10 INFOT = 1\n CALL SGEMM( '\/', 'N', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 1\n CALL SGEMM( '\/', 'T', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL SGEMM( 'N', '\/', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL SGEMM( 'T', '\/', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SGEMM( 'N', 'N', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SGEMM( 'N', 'T', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SGEMM( 'T', 'N', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SGEMM( 'T', 'T', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SGEMM( 'N', 'N', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SGEMM( 'N', 'T', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SGEMM( 'T', 'N', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SGEMM( 'T', 'T', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL SGEMM( 'N', 'N', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL SGEMM( 'N', 'T', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL SGEMM( 'T', 'N', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL SGEMM( 'T', 'T', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 8\n CALL SGEMM( 'N', 'N', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 8\n CALL SGEMM( 'N', 'T', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 8\n CALL SGEMM( 'T', 'N', 0, 0, 2, ALPHA, A, 1, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 8\n CALL SGEMM( 'T', 'T', 0, 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SGEMM( 'N', 'N', 0, 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SGEMM( 'T', 'N', 0, 0, 2, ALPHA, A, 2, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SGEMM( 'N', 'T', 0, 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SGEMM( 'T', 'T', 0, 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 13\n CALL SGEMM( 'N', 'N', 2, 0, 0, ALPHA, A, 2, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 13\n CALL SGEMM( 'N', 'T', 2, 0, 0, ALPHA, A, 2, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 13\n CALL SGEMM( 'T', 'N', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 13\n CALL SGEMM( 'T', 'T', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n GO TO 70\n 20 INFOT = 1\n CALL SSYMM( '\/', 'U', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL SSYMM( 'L', '\/', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYMM( 'L', 'U', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYMM( 'R', 'U', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYMM( 'L', 'L', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYMM( 'R', 'L', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYMM( 'L', 'U', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYMM( 'R', 'U', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYMM( 'L', 'L', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYMM( 'R', 'L', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYMM( 'L', 'U', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYMM( 'R', 'U', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYMM( 'L', 'L', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYMM( 'R', 'L', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYMM( 'L', 'U', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYMM( 'R', 'U', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYMM( 'L', 'L', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYMM( 'R', 'L', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYMM( 'L', 'U', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYMM( 'R', 'U', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYMM( 'L', 'L', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYMM( 'R', 'L', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n GO TO 70\n 30 INFOT = 1\n CALL STRMM( '\/', 'U', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL STRMM( 'L', '\/', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL STRMM( 'L', 'U', '\/', 'N', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL STRMM( 'L', 'U', 'N', '\/', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'L', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'L', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'R', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'R', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'L', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'L', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'R', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRMM( 'R', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'L', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'L', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'R', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'R', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'L', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'L', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'R', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRMM( 'R', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'R', 'U', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'R', 'U', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'R', 'L', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRMM( 'R', 'L', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'R', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'R', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'R', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRMM( 'R', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n GO TO 70\n 40 INFOT = 1\n CALL STRSM( '\/', 'U', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL STRSM( 'L', '\/', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL STRSM( 'L', 'U', '\/', 'N', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL STRSM( 'L', 'U', 'N', '\/', 0, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'L', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'L', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'R', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'R', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'L', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'L', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'R', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 5\n CALL STRSM( 'R', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'L', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'L', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'R', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'R', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'L', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'L', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'R', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 6\n CALL STRSM( 'R', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'R', 'U', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'R', 'U', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'R', 'L', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL STRSM( 'R', 'L', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'R', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'R', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'R', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 11\n CALL STRSM( 'R', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n GO TO 70\n 50 INFOT = 1\n CALL SSYRK( '\/', 'N', 0, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL SSYRK( 'U', '\/', 0, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYRK( 'U', 'N', -1, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYRK( 'U', 'T', -1, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYRK( 'L', 'N', -1, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYRK( 'L', 'T', -1, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYRK( 'U', 'N', 0, -1, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYRK( 'U', 'T', 0, -1, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYRK( 'L', 'N', 0, -1, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYRK( 'L', 'T', 0, -1, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYRK( 'U', 'N', 2, 0, ALPHA, A, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYRK( 'U', 'T', 0, 2, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYRK( 'L', 'N', 2, 0, ALPHA, A, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYRK( 'L', 'T', 0, 2, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SSYRK( 'U', 'N', 2, 0, ALPHA, A, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SSYRK( 'U', 'T', 2, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SSYRK( 'L', 'N', 2, 0, ALPHA, A, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 10\n CALL SSYRK( 'L', 'T', 2, 0, ALPHA, A, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n GO TO 70\n 60 INFOT = 1\n CALL SSYR2K( '\/', 'N', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 2\n CALL SSYR2K( 'U', '\/', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYR2K( 'U', 'N', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYR2K( 'U', 'T', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYR2K( 'L', 'N', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 3\n CALL SSYR2K( 'L', 'T', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYR2K( 'U', 'N', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYR2K( 'U', 'T', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYR2K( 'L', 'N', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 4\n CALL SSYR2K( 'L', 'T', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYR2K( 'U', 'N', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYR2K( 'U', 'T', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYR2K( 'L', 'N', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 7\n CALL SSYR2K( 'L', 'T', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYR2K( 'U', 'N', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYR2K( 'U', 'T', 0, 2, ALPHA, A, 2, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYR2K( 'L', 'N', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 2 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 9\n CALL SSYR2K( 'L', 'T', 0, 2, ALPHA, A, 2, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYR2K( 'U', 'N', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYR2K( 'U', 'T', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYR2K( 'L', 'N', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n INFOT = 12\n CALL SSYR2K( 'L', 'T', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 )\n CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n*\n 70 IF( OK )THEN\n WRITE( NOUT, FMT = 9999 )SRNAMT\n ELSE\n WRITE( NOUT, FMT = 9998 )SRNAMT\n END IF\n RETURN\n*\n 9999 FORMAT( ' ', A6, ' PASSED THE TESTS OF ERROR-EXITS' )\n 9998 FORMAT( ' ******* ', A6, ' FAILED THE TESTS OF ERROR-EXITS *****',\n $ '**' )\n*\n* End of SCHKE.\n*\n END\n SUBROUTINE SMAKE( TYPE, UPLO, DIAG, M, N, A, NMAX, AA, LDA, RESET,\n $ TRANSL )\n*\n* Generates values for an M by N matrix A.\n* Stores the values in the array AA in the data structure required\n* by the routine, with unwanted elements set to rogue value.\n*\n* TYPE is 'GE', 'SY' or 'TR'.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO, ONE\n PARAMETER ( ZERO = 0.0, ONE = 1.0 )\n REAL ROGUE\n PARAMETER ( ROGUE = -1.0E10 )\n* .. Scalar Arguments ..\n REAL TRANSL\n INTEGER LDA, M, N, NMAX\n LOGICAL RESET\n CHARACTER*1 DIAG, UPLO\n CHARACTER*2 TYPE\n* .. Array Arguments ..\n REAL A( NMAX, * ), AA( * )\n* .. Local Scalars ..\n INTEGER I, IBEG, IEND, J\n LOGICAL GEN, LOWER, SYM, TRI, UNIT, UPPER\n* .. External Functions ..\n REAL SBEG\n EXTERNAL SBEG\n* .. Executable Statements ..\n GEN = TYPE.EQ.'GE'\n SYM = TYPE.EQ.'SY'\n TRI = TYPE.EQ.'TR'\n UPPER = ( SYM.OR.TRI ).AND.UPLO.EQ.'U'\n LOWER = ( SYM.OR.TRI ).AND.UPLO.EQ.'L'\n UNIT = TRI.AND.DIAG.EQ.'U'\n*\n* Generate data in array A.\n*\n DO 20 J = 1, N\n DO 10 I = 1, M\n IF( GEN.OR.( UPPER.AND.I.LE.J ).OR.( LOWER.AND.I.GE.J ) )\n $ THEN\n A( I, J ) = SBEG( RESET ) + TRANSL\n IF( I.NE.J )THEN\n* Set some elements to zero\n IF( N.GT.3.AND.J.EQ.N\/2 )\n $ A( I, J ) = ZERO\n IF( SYM )THEN\n A( J, I ) = A( I, J )\n ELSE IF( TRI )THEN\n A( J, I ) = ZERO\n END IF\n END IF\n END IF\n 10 CONTINUE\n IF( TRI )\n $ A( J, J ) = A( J, J ) + ONE\n IF( UNIT )\n $ A( J, J ) = ONE\n 20 CONTINUE\n*\n* Store elements in array AS in data structure required by routine.\n*\n IF( TYPE.EQ.'GE' )THEN\n DO 50 J = 1, N\n DO 30 I = 1, M\n AA( I + ( J - 1 )*LDA ) = A( I, J )\n 30 CONTINUE\n DO 40 I = M + 1, LDA\n AA( I + ( J - 1 )*LDA ) = ROGUE\n 40 CONTINUE\n 50 CONTINUE\n ELSE IF( TYPE.EQ.'SY'.OR.TYPE.EQ.'TR' )THEN\n DO 90 J = 1, N\n IF( UPPER )THEN\n IBEG = 1\n IF( UNIT )THEN\n IEND = J - 1\n ELSE\n IEND = J\n END IF\n ELSE\n IF( UNIT )THEN\n IBEG = J + 1\n ELSE\n IBEG = J\n END IF\n IEND = N\n END IF\n DO 60 I = 1, IBEG - 1\n AA( I + ( J - 1 )*LDA ) = ROGUE\n 60 CONTINUE\n DO 70 I = IBEG, IEND\n AA( I + ( J - 1 )*LDA ) = A( I, J )\n 70 CONTINUE\n DO 80 I = IEND + 1, LDA\n AA( I + ( J - 1 )*LDA ) = ROGUE\n 80 CONTINUE\n 90 CONTINUE\n END IF\n RETURN\n*\n* End of SMAKE.\n*\n END\n SUBROUTINE SMMCH( TRANSA, TRANSB, M, N, KK, ALPHA, A, LDA, B, LDB,\n $ BETA, C, LDC, CT, G, CC, LDCC, EPS, ERR, FATAL,\n $ NOUT, MV )\n*\n* Checks the results of the computational tests.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Parameters ..\n REAL ZERO, ONE\n PARAMETER ( ZERO = 0.0, ONE = 1.0 )\n* .. Scalar Arguments ..\n REAL ALPHA, BETA, EPS, ERR\n INTEGER KK, LDA, LDB, LDC, LDCC, M, N, NOUT\n LOGICAL FATAL, MV\n CHARACTER*1 TRANSA, TRANSB\n* .. Array Arguments ..\n REAL A( LDA, * ), B( LDB, * ), C( LDC, * ),\n $ CC( LDCC, * ), CT( * ), G( * )\n* .. Local Scalars ..\n REAL ERRI\n INTEGER I, J, K\n LOGICAL TRANA, TRANB\n* .. Intrinsic Functions ..\n INTRINSIC ABS, MAX, SQRT\n* .. Executable Statements ..\n TRANA = TRANSA.EQ.'T'.OR.TRANSA.EQ.'C'\n TRANB = TRANSB.EQ.'T'.OR.TRANSB.EQ.'C'\n*\n* Compute expected result, one column at a time, in CT using data\n* in A, B and C.\n* Compute gauges in G.\n*\n DO 120 J = 1, N\n*\n DO 10 I = 1, M\n CT( I ) = ZERO\n G( I ) = ZERO\n 10 CONTINUE\n IF( .NOT.TRANA.AND..NOT.TRANB )THEN\n DO 30 K = 1, KK\n DO 20 I = 1, M\n CT( I ) = CT( I ) + A( I, K )*B( K, J )\n G( I ) = G( I ) + ABS( A( I, K ) )*ABS( B( K, J ) )\n 20 CONTINUE\n 30 CONTINUE\n ELSE IF( TRANA.AND..NOT.TRANB )THEN\n DO 50 K = 1, KK\n DO 40 I = 1, M\n CT( I ) = CT( I ) + A( K, I )*B( K, J )\n G( I ) = G( I ) + ABS( A( K, I ) )*ABS( B( K, J ) )\n 40 CONTINUE\n 50 CONTINUE\n ELSE IF( .NOT.TRANA.AND.TRANB )THEN\n DO 70 K = 1, KK\n DO 60 I = 1, M\n CT( I ) = CT( I ) + A( I, K )*B( J, K )\n G( I ) = G( I ) + ABS( A( I, K ) )*ABS( B( J, K ) )\n 60 CONTINUE\n 70 CONTINUE\n ELSE IF( TRANA.AND.TRANB )THEN\n DO 90 K = 1, KK\n DO 80 I = 1, M\n CT( I ) = CT( I ) + A( K, I )*B( J, K )\n G( I ) = G( I ) + ABS( A( K, I ) )*ABS( B( J, K ) )\n 80 CONTINUE\n 90 CONTINUE\n END IF\n DO 100 I = 1, M\n CT( I ) = ALPHA*CT( I ) + BETA*C( I, J )\n G( I ) = ABS( ALPHA )*G( I ) + ABS( BETA )*ABS( C( I, J ) )\n 100 CONTINUE\n*\n* Compute the error ratio for this result.\n*\n ERR = ZERO\n DO 110 I = 1, M\n ERRI = ABS( CT( I ) - CC( I, J ) )\/EPS\n IF( G( I ).NE.ZERO )\n $ ERRI = ERRI\/G( I )\n ERR = MAX( ERR, ERRI )\n IF( ERR*SQRT( EPS ).GE.ONE )\n $ GO TO 130\n 110 CONTINUE\n*\n 120 CONTINUE\n*\n* If the loop completes, all results are at least half accurate.\n GO TO 150\n*\n* Report fatal error.\n*\n 130 FATAL = .TRUE.\n WRITE( NOUT, FMT = 9999 )\n DO 140 I = 1, M\n IF( MV )THEN\n WRITE( NOUT, FMT = 9998 )I, CT( I ), CC( I, J )\n ELSE\n WRITE( NOUT, FMT = 9998 )I, CC( I, J ), CT( I )\n END IF\n 140 CONTINUE\n IF( N.GT.1 )\n $ WRITE( NOUT, FMT = 9997 )J\n*\n 150 CONTINUE\n RETURN\n*\n 9999 FORMAT( ' ******* FATAL ERROR - COMPUTED RESULT IS LESS THAN HAL',\n $ 'F ACCURATE *******', \/' EXPECTED RESULT COMPU',\n $ 'TED RESULT' )\n 9998 FORMAT( 1X, I7, 2G18.6 )\n 9997 FORMAT( ' THESE ARE THE RESULTS FOR COLUMN ', I3 )\n*\n* End of SMMCH.\n*\n END\n LOGICAL FUNCTION LSE( RI, RJ, LR )\n*\n* Tests if two arrays are identical.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Scalar Arguments ..\n INTEGER LR\n* .. Array Arguments ..\n REAL RI( * ), RJ( * )\n* .. Local Scalars ..\n INTEGER I\n* .. Executable Statements ..\n DO 10 I = 1, LR\n IF( RI( I ).NE.RJ( I ) )\n $ GO TO 20\n 10 CONTINUE\n LSE = .TRUE.\n GO TO 30\n 20 CONTINUE\n LSE = .FALSE.\n 30 RETURN\n*\n* End of LSE.\n*\n END\n LOGICAL FUNCTION LSERES( TYPE, UPLO, M, N, AA, AS, LDA )\n*\n* Tests if selected elements in two arrays are equal.\n*\n* TYPE is 'GE' or 'SY'.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Scalar Arguments ..\n INTEGER LDA, M, N\n CHARACTER*1 UPLO\n CHARACTER*2 TYPE\n* .. Array Arguments ..\n REAL AA( LDA, * ), AS( LDA, * )\n* .. Local Scalars ..\n INTEGER I, IBEG, IEND, J\n LOGICAL UPPER\n* .. Executable Statements ..\n UPPER = UPLO.EQ.'U'\n IF( TYPE.EQ.'GE' )THEN\n DO 20 J = 1, N\n DO 10 I = M + 1, LDA\n IF( AA( I, J ).NE.AS( I, J ) )\n $ GO TO 70\n 10 CONTINUE\n 20 CONTINUE\n ELSE IF( TYPE.EQ.'SY' )THEN\n DO 50 J = 1, N\n IF( UPPER )THEN\n IBEG = 1\n IEND = J\n ELSE\n IBEG = J\n IEND = N\n END IF\n DO 30 I = 1, IBEG - 1\n IF( AA( I, J ).NE.AS( I, J ) )\n $ GO TO 70\n 30 CONTINUE\n DO 40 I = IEND + 1, LDA\n IF( AA( I, J ).NE.AS( I, J ) )\n $ GO TO 70\n 40 CONTINUE\n 50 CONTINUE\n END IF\n*\n LSERES = .TRUE.\n GO TO 80\n 70 CONTINUE\n LSERES = .FALSE.\n 80 RETURN\n*\n* End of LSERES.\n*\n END\n REAL FUNCTION SBEG( RESET )\n*\n* Generates random numbers uniformly distributed between -0.5 and 0.5.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Scalar Arguments ..\n LOGICAL RESET\n* .. Local Scalars ..\n INTEGER I, IC, MI\n* .. Save statement ..\n SAVE I, IC, MI\n* .. Executable Statements ..\n IF( RESET )THEN\n* Initialize local variables.\n MI = 891\n I = 7\n IC = 0\n RESET = .FALSE.\n END IF\n*\n* The sequence of values of I is bounded between 1 and 999.\n* If initial I = 1,2,3,6,7 or 9, the period will be 50.\n* If initial I = 4 or 8, the period will be 25.\n* If initial I = 5, the period will be 10.\n* IC is used to break up the period by skipping 1 value of I in 6.\n*\n IC = IC + 1\n 10 I = I*MI\n I = I - 1000*( I\/1000 )\n IF( IC.GE.5 )THEN\n IC = 0\n GO TO 10\n END IF\n SBEG = ( I - 500 )\/1001.0\n RETURN\n*\n* End of SBEG.\n*\n END\n REAL FUNCTION SDIFF( X, Y )\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Scalar Arguments ..\n REAL X, Y\n* .. Executable Statements ..\n SDIFF = X - Y\n RETURN\n*\n* End of SDIFF.\n*\n END\n SUBROUTINE CHKXER( SRNAMT, INFOT, NOUT, LERR, OK )\n*\n* Tests whether XERBLA has detected an error when it should.\n*\n* Auxiliary routine for test program for Level 3 Blas.\n*\n* -- Written on 8-February-1989.\n* Jack Dongarra, Argonne National Laboratory.\n* Iain Duff, AERE Harwell.\n* Jeremy Du Croz, Numerical Algorithms Group Ltd.\n* Sven Hammarling, Numerical Algorithms Group Ltd.\n*\n* .. Scalar Arguments ..\n INTEGER INFOT, NOUT\n LOGICAL LERR, OK\n CHARACTER*6 SRNAMT\n* .. Executable Statements ..\n IF( .NOT.LERR )THEN\n WRITE( NOUT, FMT = 9999 )INFOT, SRNAMT\n OK = .FALSE.\n END IF\n LERR = .FALSE.\n RETURN\n*\n 9999 FORMAT( ' ***** ILLEGAL VALUE OF PARAMETER NUMBER ', I2, ' NOT D',\n $ 'ETECTED BY ', A6, ' *****' )\n*\n* End of CHKXER.\n*\n END\n","avg_line_length":36.2748436414,"max_line_length":80,"alphanum_fraction":0.4113066217} {"size":38179,"ext":"f90","lang":"FORTRAN","max_stars_count":5.0,"content":"module rnglib\n\n! Library implementing a random number generator (RNG) with splitting facilities,\n! allowing multiple independent streams to be computed by L'Ecuyer and Cote. \n\n! See\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n! \n! FORTRAN90 code by John Burkardt (see individual subroutines for details)\n!\n! Shaped into a module for FERRE by Carlos Allende Prieto\n! November 2017\n\nimplicit none\n\npublic\n\ncontains\n\n\nsubroutine advance_state ( k )\n\n!*****************************************************************************80\n!\n!! ADVANCE_STATE advances the state of the current generator.\n!\n! Discussion:\n!\n! This procedure advances the state of the current generator by 2^K \n! values and resets the initial seed to that value.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) K, indicates that the generator is to be \n! advanced by 2^K values.\n! 0 <= K.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: a1 = 40014\n integer ( kind = 4 ), parameter :: a2 = 40692\n integer ( kind = 4 ) b1\n integer ( kind = 4 ) b2\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n! integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n! logical initialized_get\n integer ( kind = 4 ) k\n integer ( kind = 4 ), parameter :: m1 = 2147483563\n integer ( kind = 4 ), parameter :: m2 = 2147483399\n! integer ( kind = 4 ) multmod\n\n if ( k < 0 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'ADVANCE_STATE - Fatal error!'\n write ( *, '(a)' ) ' Input exponent K is out of bounds.'\n stop 1\n end if\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'ADVANCE_STATE - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Get the current generator index.\n!\n g = cgn_get ( )\n\n b1 = a1\n b2 = a2\n\n do i = 1, k\n b1 = multmod ( b1, b1, m1 )\n b2 = multmod ( b2, b2, m2 )\n end do\n\n call cg_get ( g, cg1, cg2 )\n cg1 = multmod ( b1, cg1, m1 )\n cg2 = multmod ( b2, cg2, m2 )\n call cg_set ( g, cg1, cg2 )\n\n return\nend subroutine advance_state\n\nfunction antithetic_get ( )\n\n!*****************************************************************************80\n!\n!! ANTITHETIC_GET queries the antithetic value for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 31 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Output, logical ANTITHETIC_GET, is TRUE if generator G is antithetic.\n!\n implicit none\n\n logical antithetic_get\n integer ( kind = 4 ) i\n logical value\n\n i = -1\n call antithetic_memory ( i, value )\n\n antithetic_get = value\n\n return\nend function antithetic_get\n\nsubroutine antithetic_memory ( i, value )\n\n!*****************************************************************************80\n!\n!! ANTITHETIC_MEMORY stores the antithetic value for all generators.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 31 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) I, the desired action.\n! -1, get a value.\n! 0, initialize all values.\n! 1, set a value.\n!\n! Input\/output, logical VALUE. For I = -1, VALUE is an output\n! quantity, for I = +1, an input quantity.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: g_max = 32\n\n logical a_save(g_max)\n! integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n logical value\n\n save a_save\n\n data a_save \/ 32 * .false. \/\n\n if ( i < 0 ) then\n g = cgn_get ( )\n value = a_save(g)\n else if ( i == 0 ) then\n a_save(1:g_max) = .false.\n else if ( 0 < i ) then\n g = cgn_get ( )\n a_save(g) = value\n end if\n\n return\nend subroutine antithetic_memory\n\n\nsubroutine antithetic_set ( value )\n\n!*****************************************************************************80\n!\n!! ANTITHETIC_SET sets the antithetic value for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 31 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, logical VALUE, is TRUE if generator G is to be antithetic.\n!\n implicit none\n\n integer ( kind = 4 ) i\n logical value\n\n i = +1\n call antithetic_memory ( i, value )\n\n return\nend subroutine antithetic_set \n\n\nsubroutine cg_get ( g, cg1, cg2 )\n\n!*****************************************************************************80\n!\n!! CG_GET queries the CG values for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n! Output, integer ( kind = 4 ) CG1, CG2, the CG values for generator G.\n!\n implicit none\n\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n\n i = -1\n call cg_memory ( i, g, cg1, cg2 )\n\n return\nend subroutine cg_get \n\n\nsubroutine cg_memory ( i, g, cg1, cg2 )\n\n!*****************************************************************************80\n!\n!! CG_MEMORY stores the CG values for all generators.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) I, the desired action.\n! -1, get a value.\n! 0, initialize all values.\n! 1, set a value.\n!\n! Input, integer ( kind = 4 ) G, for I = -1 or +1, the index of \n! the generator, with 1 <= G <= 32.\n!\n! Input\/output, integer ( kind = 4 ) CG1, CG2. For I = -1, \n! these are output, for I = +1, these are input, for I = 0,\n! these arguments are ignored. When used, the arguments are\n! old or new values of the CG parameter for generator G.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: g_max = 32\n\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg1_save(g_max)\n integer ( kind = 4 ) cg2\n integer ( kind = 4 ) cg2_save(g_max)\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n\n save cg1_save\n save cg2_save\n\n data cg1_save \/ 32 * 0 \/\n data cg2_save \/ 32 * 0 \/\n\n if ( g < 1 .or. g_max < g ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'CG_MEMORY - Fatal error!'\n write ( *, '(a)' ) ' Input generator index G is out of bounds.'\n stop 1\n end if\n\n if ( i < 0 ) then\n cg1 = cg1_save(g)\n cg2 = cg2_save(g)\n else if ( i == 0 ) then\n cg1_save(1:g_max) = 0\n cg2_save(1:g_max) = 0\n else if ( 0 < i ) then\n cg1_save(g) = cg1\n cg2_save(g) = cg2\n end if\n\n return\nend subroutine cg_memory\n\n\nsubroutine cg_set ( g, cg1, cg2 )\n\n!*****************************************************************************80\n!\n!! CG_SET sets the CG values for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n! Input, integer ( kind = 4 ) CG1, CG2, the CG values for generator G.\n!\n implicit none\n\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n\n i = +1\n call cg_memory ( i, g, cg1, cg2 )\n\n return\nend subroutine cg_set \n\n\nfunction cgn_get ( )\n\n!*****************************************************************************80\n!\n!! CGN_GET gets the current generator index.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Output, integer ( kind = 4 ) CGN_GET, the current generator index.\n! 1 <= CGN_GET <= 32.\n!\n implicit none\n\n integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n\n i = -1\n call cgn_memory ( i, g )\n\n cgn_get = g\n\n return\nend function cgn_get\n\n\nsubroutine cgn_memory ( i, g )\n\n!*****************************************************************************80\n!\n!! CGN_MEMORY stores the current generator index.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) I, the desired action.\n! -1, get the value.\n! 0, initialize the value.\n! 1, set the value.\n!\n! Input\/output, integer ( kind = 4 ) G. For I = -1 or 0,\n! this is output, for I = +1, this is input.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: g_max = 32\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) g_save\n integer ( kind = 4 ) i\n\n save g_save\n\n data g_save \/ 1 \/\n\n if ( i < 0 ) then\n\n g = g_save\n\n else if ( i == 0 ) then\n\n g_save = 1\n g = g_save\n\n else if ( 0 < i ) then\n\n if ( g < 1 .or. g_max < g ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'CGN_MEMORY - Fatal error!'\n write ( *, '(a)' ) ' Generator index G is out of bounds.'\n stop 1\n end if\n\n g_save = g\n\n end if\n\n return\nend subroutine cgn_memory\n\n\nsubroutine cgn_set ( g )\n\n!*****************************************************************************80\n!\n!! CGN_SET sets the current generator index.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n implicit none\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n\n i = +1\n call cgn_memory ( i, g )\n\n return\nend subroutine cgn_set\n\n\nsubroutine get_state ( cg1, cg2 )\n\n!*****************************************************************************80\n!\n!! GET_STATE returns the state of the current generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Output, integer ( kind = 4 ) CG1, CG2, the CG values for the\n! current generator.\n!\n implicit none\n\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n! integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n! logical initialized_get\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'GET_STATE - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Get the current generator index.\n!\n g = cgn_get ( )\n!\n! Retrieve the seed values for this generator.\n!\n call cg_get ( g, cg1, cg2 )\n\n return\nend subroutine get_state\n\n\nfunction i4_uni ( )\n\n!*****************************************************************************80\n!\n!! I4_UNI generates a random positive integer.\n!\n! Discussion:\n!\n! This procedure returns a random integer following a uniform distribution \n! over (1, 2147483562) using the current generator.\n!\n! The original name of this function was \"random()\", but this conflicts\n! with a standard library function name in C.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 05 August 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Output, integer ( kind = 4 ) I4_UNI, the random integer.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: a1 = 40014\n integer ( kind = 4 ), parameter :: a2 = 40692\n! logical antithetic_get\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n! integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i4_uni\n! logical initialized_get\n integer ( kind = 4 ) k\n integer ( kind = 4 ), parameter :: m1 = 2147483563\n integer ( kind = 4 ), parameter :: m2 = 2147483399\n logical value\n integer ( kind = 4 ) z\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'I4_UNI - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Get the current generator index.\n!\n g = cgn_get ( )\n!\n! Retrieve the seeds for the current generator.\n!\n call cg_get ( g, cg1, cg2 )\n!\n! Update the seeds.\n!\n k = cg1 \/ 53668\n cg1 = a1 * ( cg1 - k * 53668 ) - k * 12211\n\n if ( cg1 < 0 ) then\n cg1 = cg1 + m1\n end if\n\n k = cg2 \/ 52774\n cg2 = a2 * ( cg2 - k * 52774 ) - k * 3791\n\n if ( cg2 < 0 ) then\n cg2 = cg2 + m2\n end if\n!\n! Store the updated seeds.\n!\n call cg_set ( g, cg1, cg2 )\n!\n! Construct the random integer from the seeds.\n!\n z = cg1 - cg2\n\n if ( z < 1 ) then\n z = z + m1 - 1\n end if\n!\n! If the generator is in antithetic mode, we must reflect the value.\n!\n value = antithetic_get ( )\n\n if ( value ) then\n z = m1 - z\n end if\n\n i4_uni = z\n\n return\nend function i4_uni\n\n\n\nsubroutine ig_get ( g, ig1, ig2 )\n\n!*****************************************************************************80\n!\n!! IG_GET queries the IG values for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n! Output, integer ( kind = 4 ) IG1, IG2, the IG values for generator G.\n!\n implicit none\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n integer ( kind = 4 ) ig1\n integer ( kind = 4 ) ig2\n\n i = -1\n call ig_memory ( i, g, ig1, ig2 )\n\n return\nend subroutine ig_get\n\n\nsubroutine ig_memory ( i, g, ig1, ig2 )\n\n!*****************************************************************************80\n!\n!! IG_MEMORY stores the IG values for all generators.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) I, the desired action.\n! -1, get a value.\n! 0, initialize all values.\n! 1, set a value.\n!\n! Input, integer ( kind = 4 ) G, for I = -1 or +1, the index of \n! the generator, with 1 <= G <= 32.\n!\n! Input\/output, integer ( kind = 4 ) IG1, IG2. For I = -1, \n! these are output, for I = +1, these are input, for I = 0,\n! these arguments are ignored. When used, the arguments are\n! old or new values of the IG parameter for generator G.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: g_max = 32\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n integer ( kind = 4 ) ig1\n integer ( kind = 4 ) ig1_save(g_max)\n integer ( kind = 4 ) ig2\n integer ( kind = 4 ) ig2_save(g_max)\n\n save ig1_save\n save ig2_save\n\n data ig1_save \/ 32 * 0 \/\n data ig2_save \/ 32 * 0 \/\n\n if ( g < 1 .or. g_max < g ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'IG_MEMORY - Fatal error!'\n write ( *, '(a)' ) ' Input generator index G is out of bounds.'\n stop 1\n end if\n\n if ( i < 0 ) then\n ig1 = ig1_save(g)\n ig2 = ig2_save(g)\n else if ( i == 0 ) then\n ig1_save(1:g_max) = 0\n ig2_save(1:g_max) = 0\n else if ( 0 < i ) then\n ig1_save(g) = ig1\n ig2_save(g) = ig2\n end if\n\n return\nend subroutine ig_memory\n\n\nsubroutine ig_set ( g, ig1, ig2 )\n\n!*****************************************************************************80\n!\n!! IG_SET sets the IG values for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n! Input, integer ( kind = 4 ) IG1, IG2, the IG values for generator G.\n!\n implicit none\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n integer ( kind = 4 ) ig1\n integer ( kind = 4 ) ig2\n\n i = +1\n call ig_memory ( i, g, ig1, ig2 )\n\n return\nend subroutine ig_set\n\n\nsubroutine init_generator ( t )\n\n!*****************************************************************************80\n!\n!! INIT_GENERATOR sets the current generator to initial, last or new seed.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 31 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) T, the seed type:\n! 0, use the seed chosen at initialization time.\n! 1, use the last seed.\n! 2, use a new seed set 2^30 values away.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: a1_w = 1033780774\n integer ( kind = 4 ), parameter :: a2_w = 1494757890\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n! integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n integer ( kind = 4 ) ig1\n integer ( kind = 4 ) ig2\n! logical initialized_get\n integer ( kind = 4 ) lg1\n integer ( kind = 4 ) lg2\n integer ( kind = 4 ), parameter :: m1 = 2147483563\n integer ( kind = 4 ), parameter :: m2 = 2147483399\n! integer ( kind = 4 ) multmod\n integer ( kind = 4 ) t\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'INIT_GENERATOR - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Get the current generator index.\n!\n g = cgn_get ( )\n!\n! 0: restore the initial seed.\n!\n if ( t == 0 ) then\n\n call ig_get ( g, ig1, ig2 )\n lg1 = ig1\n lg2 = ig2\n call lg_set ( g, lg1, lg2 )\n!\n! 1: restore the last seed.\n!\n else if ( t == 1 ) then\n\n call lg_get ( g, lg1, lg2 )\n!\n! 2: advance to a new seed.\n!\n else if ( t == 2 ) then\n\n call lg_get ( g, lg1, lg2 )\n lg1 = multmod ( a1_w, lg1, m1 )\n lg2 = multmod ( a2_w, lg2, m2 )\n call lg_set ( g, lg1, lg2 )\n\n else\n\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'INIT_GENERATOR - Fatal error!'\n write ( *, '(a)' ) ' Input parameter T out of bounds.'\n stop 1\n\n end if\n!\n! Store the new seed.\n!\n cg1 = lg1\n cg2 = lg2\n call cg_set ( g, cg1, cg2 )\n\n return\nend subroutine init_generator\n\n\nsubroutine initialize ( )\n\n!*****************************************************************************80\n!\n!! INITIALIZE initializes the random number generator library.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 30 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! None\n!\n implicit none\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ), parameter :: g_max = 32\n integer ( kind = 4 ) ig1\n integer ( kind = 4 ) ig2\n logical value\n!\n! Remember that we have called INITIALIZE().\n!\n call initialized_set ( )\n!\n! Initialize all generators to have FALSE antithetic value.\n!\n value = .false.\n do g = 1, g_max\n call cgn_set ( g )\n call antithetic_set ( value )\n end do\n!\n! Set the initial seeds.\n!\n ig1 = 1234567890\n ig2 = 123456789\n call set_initial_seed ( ig1, ig2 )\n!\n! Initialize the current generator index to the first one.\n!\n g = 1\n call cgn_set ( g )\n\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'INITIALIZE - Note:'\n write ( *, '(a)' ) ' The RNGLIB package has been initialized.'\n\n return\nend subroutine initialize\n\n\nfunction initialized_get ( )\n\n!*****************************************************************************80\n!\n!! INITIALIZED_GET queries the INITIALIZED value.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 28 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Output, logical INITIALIZED_GET, is TRUE if the package has \n! been initialized.\n!\n implicit none\n\n integer ( kind = 4 ) i\n logical initialized\n logical initialized_get\n\n i = -1\n call initialized_memory ( i, initialized )\n\n initialized_get = initialized\n\n return\nend function initialized_get\n\n\nsubroutine initialized_memory ( i, initialized )\n\n!*****************************************************************************80\n!\n!! INITIALIZED_MEMORY stores the INITIALIZED value for the package.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 28 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) I, the desired action.\n! -1, get the value.\n! 0, initialize the value.\n! 1, set the value.\n!\n! Input\/output, logical INITIALIZED. For I = -1, \n! this is output, for I = +1, this is input, for I = 0,\n! this argument is ignored. \n!\n implicit none\n\n integer ( kind = 4 ) i\n logical initialized\n logical initialized_save\n\n save initialized_save\n\n data initialized_save \/ .false. \/\n\n if ( i < 0 ) then\n initialized = initialized_save\n else if ( i == 0 ) then\n initialized_save = .false.\n else if ( 0 < i ) then\n initialized_save = initialized\n end if\n\n return\nend subroutine initialized_memory\n\n\nsubroutine initialized_set ( )\n\n!*****************************************************************************80\n!\n!! INITIALIZED_SET sets the INITIALIZED value true.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 28 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! None\n!\n implicit none\n\n integer ( kind = 4 ) i\n logical initialized\n\n i = +1\n initialized = .true.\n call initialized_memory ( i, initialized )\n\n return\nend subroutine initialized_set\n\n\nsubroutine lg_get ( g, lg1, lg2 )\n\n!*****************************************************************************80\n!\n!! LG_GET queries the LG values for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n! Output, integer ( kind = 4 ) LG1, LG2, the LG values for generator G.\n!\n implicit none\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n integer ( kind = 4 ) lg1\n integer ( kind = 4 ) lg2\n\n i = -1\n call lg_memory ( i, g, lg1, lg2 )\n\n return\nend subroutine lg_get \n\n\nsubroutine lg_memory ( i, g, lg1, lg2 )\n\n!*****************************************************************************80\n!\n!! LG_MEMORY stores the LG values for all generators.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) I, the desired action.\n! -1, get a value.\n! 0, initialize all values.\n! 1, set a value.\n!\n! Input, integer ( kind = 4 ) G, for I = -1 or +1, the index of \n! the generator, with 1 <= G <= 32.\n!\n! Input\/output, integer ( kind = 4 ) LG1, LG2. For I = -1, \n! these are output, for I = +1, these are input, for I = 0,\n! these arguments are ignored. When used, the arguments are\n! old or new values of the LG parameter for generator G.\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: g_max = 32\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n integer ( kind = 4 ) lg1\n integer ( kind = 4 ) lg1_save(g_max)\n integer ( kind = 4 ) lg2\n integer ( kind = 4 ) lg2_save(g_max)\n\n save lg1_save\n save lg2_save\n\n data lg1_save \/ 32 * 0 \/\n data lg2_save \/ 32 * 0 \/\n\n if ( g < 1 .or. g_max < g ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'LG_MEMORY - Fatal error!'\n write ( *, '(a)' ) ' Input generator index G is out of bounds.'\n stop 1\n end if\n\n if ( i < 0 ) then\n lg1 = lg1_save(g)\n lg2 = lg2_save(g)\n else if ( i == 0 ) then\n lg1_save(1:g_max) = 0\n lg2_save(1:g_max) = 0\n else if ( 0 < i ) then\n lg1_save(g) = lg1\n lg2_save(g) = lg2\n end if\n\n return\nend subroutine lg_memory\n\n\nsubroutine lg_set ( g, lg1, lg2 )\n\n!*****************************************************************************80\n!\n!! LG_SET sets the LG values for a given generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) G, the index of the generator.\n! 1 <= G <= 32.\n!\n! Input, integer ( kind = 4 ) LG1, LG2, the LG values for generator G.\n!\n implicit none\n\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n integer ( kind = 4 ) lg1\n integer ( kind = 4 ) lg2\n\n i = +1\n call lg_memory ( i, g, lg1, lg2 )\n\n return\nend subroutine lg_set\n\n\nfunction multmod ( a, s, m )\n\n!*****************************************************************************80\n!\n!! MULTMOD carries out modular multiplication.\n!\n! Discussion:\n!\n! This procedure returns \n!\n! ( A * S ) mod M\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 26 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) A, S, M, the arguments.\n!\n! Output, integer ( kind = 4 ) MULTMOD, the value of the product of A and S, \n! modulo M.\n!\n implicit none\n\n integer ( kind = 4 ) a\n integer ( kind = 4 ) a0\n integer ( kind = 4 ) a1\n integer ( kind = 4 ), parameter :: h = 32768\n integer ( kind = 4 ) k\n integer ( kind = 4 ) m\n integer ( kind = 4 ) multmod\n integer ( kind = 4 ) p\n integer ( kind = 4 ) q\n integer ( kind = 4 ) qh\n integer ( kind = 4 ) rh\n integer ( kind = 4 ) s\n\n if ( a <= 0 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'MULTMOD - Fatal error!'\n write ( *, '(a)' ) ' A <= 0.'\n stop 1\n end if\n\n if ( m <= a ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'MULTMOD - Fatal error!'\n write ( *, '(a)' ) ' M <= A.'\n stop 1\n end if\n\n if ( s <= 0 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'MULTMOD - Fatal error!'\n write ( *, '(a)' ) ' S <= 0.'\n stop 1\n end if\n\n if ( m <= s ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'MULTMOD - Fatal error!'\n write ( *, '(a)' ) ' M <= S.'\n stop 1\n end if\n\n if ( a < h ) then\n\n a0 = a\n p = 0\n\n else\n\n a1 = a \/ h\n a0 = a - h * a1\n qh = m \/ h\n rh = m - h * qh\n\n if ( h <= a1 ) then\n \n a1 = a1 - h\n k = s \/ qh\n p = h * ( s - k * qh ) - k * rh\n\n do while ( p < 0 )\n p = p + m\n end do\n\n else\n\n p = 0\n\n end if\n\n if ( a1 \/= 0 ) then\n\n q = m \/ a1\n k = s \/ q\n p = p - k * ( m - a1 * q )\n\n if ( 0 < p ) then\n p = p - m\n end if\n\n p = p + a1 * ( s - k * q )\n\n do while ( p < 0 )\n p = p + m\n end do\n\n end if\n\n k = p \/ qh\n p = h * ( p - k * qh ) - k * rh\n\n do while ( p < 0 )\n p = p + m\n end do\n\n end if\n\n if ( a0 \/= 0 ) then\n\n q = m \/ a0\n k = s \/ q\n p = p - k * ( m - a0 * q )\n\n if ( 0 < p ) then\n p = p - m\n end if\n\n p = p + a0 * ( s - k * q )\n\n do while ( p < 0 )\n p = p + m\n end do\n\n end if\n\n multmod = p\n\n return\nend function multmod\n\n\nfunction r4_uni_01 ( )\n\n!*****************************************************************************80\n!\n!! R4_UNI_01 returns a uniform random real number in [0,1].\n!\n! Discussion:\n!\n! This procedure returns a random floating point number from a uniform \n! distribution over (0,1), not including the endpoint values, using the\n! current random number generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 05 August 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Output, real ( kind = 4 ) R4_UNI_01, a uniform random value in [0,1].\n!\n implicit none\n\n integer ( kind = 4 ) i\n! integer ( kind = 4 ) i4_uni\n! logical initialized_get\n real ( kind = 4 ) r4_uni_01\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'R4_UNI_01 - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Get a random positive integer.\n!\n i = i4_uni ( )\n!\n! Scale it to a random real in [0,1].\n!\n r4_uni_01 = real ( i, kind = 4 ) * 4.656613057E-10\n\n return\nend function r4_uni_01\n\n\nfunction r8_uni_01 ( )\n\n!*****************************************************************************80\n!\n!! R8_UNI_01 returns a uniform random double precision number in [0,1].\n!\n! Discussion:\n!\n! This procedure returns a random floating point number from a uniform \n! distribution over (0,1), not including the endpoint values, using the\n! current random number generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 05 August 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Output, real ( kind = 8 ) R8_UNI_01, a uniform random value in [0,1].\n!\n implicit none\n\n integer ( kind = 4 ) i\n! integer ( kind = 4 ) i4_uni\n! logical initialized_get\n real ( kind = 8 ) r8_uni_01\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'R8_UNI_01 - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Get a random positive integer.\n!\n i = i4_uni ( )\n!\n! Scale it to a random real in [0,1].\n!\n r8_uni_01 = real ( i, kind = 8 ) * 4.656613057D-10\n\n return\nend function r8_uni_01 \n\n\nsubroutine set_initial_seed ( ig1, ig2 )\n\n!*****************************************************************************80\n!\n!! SET_INITIAL_SEED resets the initial seed and state for all generators.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 28 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) IG1, IG2, the initial seed values \n! for the first generator.\n! 1 <= IG1 < 2147483563\n! 1 <= IG2 < 2147483399\n!\n implicit none\n\n integer ( kind = 4 ), parameter :: a1_vw = 2082007225\n integer ( kind = 4 ), parameter :: a2_vw = 784306273\n integer ( kind = 4 ) g\n integer ( kind = 4 ), parameter :: g_max = 32\n integer ( kind = 4 ) i\n integer ( kind = 4 ) ig1\n integer ( kind = 4 ) ig2\n! logical initialized_get\n integer ( kind = 4 ), parameter :: m1 = 2147483563\n integer ( kind = 4 ), parameter :: m2 = 2147483399\n! integer ( kind = 4 ) multmod\n integer ( kind = 4 ) t\n\n if ( ig1 < 1 .or. m1 <= ig1 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'SET_INITIAL_SEED - Fatal error!'\n write ( *, '(a)' ) ' Input parameter IG1 out of bounds.'\n stop 1\n end if\n\n if ( ig2 < 1 .or. m2 <= ig2 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'SET_INITIAL_SEED - Fatal error!'\n write ( *, '(a)' ) ' Input parameter IG2 out of bounds.'\n stop 1\n end if\n!\n! Because INITIALIZE calls SET_INITIAL_SEED, it's not easy to correct\n! the error that arises if SET_INITIAL_SEED is called before INITIALIZE.\n! So don't bother trying.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'SET_INITIAL_SEED - Fatal error!'\n write ( *, '(a)' ) ' The RNGLIB package has not been initialized.'\n stop 1\n end if\n!\n! Set the initial seed, then initialize the first generator.\n!\n g = 1\n call cgn_set ( g )\n\n call ig_set ( g, ig1, ig2 )\n\n t = 0\n call init_generator ( t )\n!\n! Now do similar operations for the other generators.\n!\n do g = 2, g_max\n\n call cgn_set ( g )\n ig1 = multmod ( a1_vw, ig1, m1 )\n ig2 = multmod ( a2_vw, ig2, m2 )\n call ig_set ( g, ig1, ig2 )\n call init_generator ( t )\n\n end do\n!\n! Now choose the first generator.\n!\n g = 1\n call cgn_set ( g )\n\n return\nend subroutine set_initial_seed\n\nsubroutine set_seed ( cg1, cg2 )\n\n!*****************************************************************************80\n!\n!! SET_SEED resets the initial seed and state of the current generator.\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 31 March 2013\n!\n! Author:\n!\n! Original Pascal version by Pierre L'Ecuyer, Serge Cote.\n! FORTRAN90 version by John Burkardt.\n!\n! Reference:\n!\n! Pierre LEcuyer, Serge Cote,\n! Implementing a Random Number Package with Splitting Facilities,\n! ACM Transactions on Mathematical Software,\n! Volume 17, Number 1, March 1991, pages 98-111.\n!\n! Parameters:\n!\n! Input, integer ( kind = 4 ) CG1, CG2, the CG values for generator G.\n! 1 <= CG1 < 2147483563\n! 1 <= CG2 < 2147483399\n!\n implicit none\n\n integer ( kind = 4 ) cg1\n integer ( kind = 4 ) cg2\n! integer ( kind = 4 ) cgn_get\n integer ( kind = 4 ) g\n integer ( kind = 4 ) i\n! logical initialized_get\n integer ( kind = 4 ), parameter :: m1 = 2147483563\n integer ( kind = 4 ), parameter :: m2 = 2147483399\n integer ( kind = 4 ) t\n\n if ( cg1 < 1 .or. m1 <= cg1 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'SET_SEED - Fatal error!'\n write ( *, '(a)' ) ' Input parameter CG1 out of bounds.'\n stop 1\n end if\n\n if ( cg2 < 1 .or. m2 <= cg2 ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'SET_SEED - Fatal error!'\n write ( *, '(a)' ) ' Input parameter CG2 out of bounds.'\n stop 1\n end if\n!\n! Check whether the package must be initialized.\n!\n if ( .not. initialized_get ( ) ) then\n write ( *, '(a)' ) ' '\n write ( *, '(a)' ) 'SET_SEED - Note:'\n write ( *, '(a)' ) ' Initializing RNGLIB package.'\n call initialize ( )\n end if\n!\n! Retrieve the current generator index.\n!\n g = cgn_get ( )\n!\n! Set the seeds.\n!\n call cg_set ( g, cg1, cg2 )\n!\n! Initialize the generator.\n!\n t = 0\n call init_generator ( t )\n\n return\nend subroutine set_seed\n\n\nsubroutine timestamp ( )\n\n!*****************************************************************************80\n!\n!! TIMESTAMP prints the current YMDHMS date as a time stamp.\n!\n! Example:\n!\n! 31 May 2001 9:45:54.872 AM\n!\n! Licensing:\n!\n! This code is distributed under the GNU LGPL license.\n!\n! Modified:\n!\n! 18 May 2013\n!\n! Author:\n!\n! John Burkardt\n!\n! Parameters:\n!\n! None\n!\n implicit none\n\n character ( len = 8 ) ampm\n integer ( kind = 4 ) d\n integer ( kind = 4 ) h\n integer ( kind = 4 ) m\n integer ( kind = 4 ) mm\n character ( len = 9 ), parameter, dimension(12) :: month = (\/ &\n 'January ', 'February ', 'March ', 'April ', &\n 'May ', 'June ', 'July ', 'August ', &\n 'September', 'October ', 'November ', 'December ' \/)\n integer ( kind = 4 ) n\n integer ( kind = 4 ) s\n integer ( kind = 4 ) values(8)\n integer ( kind = 4 ) y\n\n call date_and_time ( values = values )\n\n y = values(1)\n m = values(2)\n d = values(3)\n h = values(5)\n n = values(6)\n s = values(7)\n mm = values(8)\n\n if ( h < 12 ) then\n ampm = 'AM'\n else if ( h == 12 ) then\n if ( n == 0 .and. s == 0 ) then\n ampm = 'Noon'\n else\n ampm = 'PM'\n end if\n else\n h = h - 12\n if ( h < 12 ) then\n ampm = 'PM'\n else if ( h == 12 ) then\n if ( n == 0 .and. s == 0 ) then\n ampm = 'Midnight'\n else\n ampm = 'AM'\n end if\n end if\n end if\n\n write ( *, '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) &\n d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm )\n\n return\nend subroutine timestamp\n\nend module rnglib\n\n","avg_line_length":20.5153143471,"max_line_length":81,"alphanum_fraction":0.5637916132} {"size":32762,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":"! fsqlite.f90 --\r\n! Module for interacting with SQLite3\r\n!\r\n! Arjen Markus\r\n!\r\n! General information:\r\n! This module and the associated C code is\r\n! inspired by work by Al Danial (http:\/\/danial.org).\r\n! The purpose is to provide a high-level means\r\n! for Fortran programmers to use the SQLite\r\n! library by Richard Hipp (http:\/\/www.sqlite.org)\r\n!\r\n! Detailed documentation can be found in\r\n! the file fsqlite.html.\r\n!\r\n! TODO:\r\n! - Arbitrary length character strings in set_column\r\n! and get_column\r\n! - Think about finalize and reset: error code?\r\n! - Support BLOBs\r\n! - Support DATE\r\n! - Support NULL\r\n! - More elegant selection of functions of columns\r\n!\r\n! Implementation notes:\r\n! The handles to the database or prepared statements\r\n! are stored in an array of two integers to take\r\n! care of 64-bits platforms.\r\n! With the appropriate compilation options (if needed)\r\n! the code should be thread-safe, as no data are shared.\r\n!\r\n! $Id$\r\n!\r\nmodule sqlite_types\r\n\r\n integer, parameter :: dp = kind(1.0d00)\r\n\r\n integer, parameter :: SQLITE_INT = 1\r\n integer, parameter :: SQLITE_REAL = 2\r\n integer, parameter :: SQLITE_DOUBLE = 3\r\n integer, parameter :: SQLITE_CHAR = 4\r\n\r\n integer, parameter :: SQLITE_OK = 0\r\n integer, parameter :: SQLITE_ERROR = 1\r\n integer, parameter :: SQLITE_MISUSE = 21\r\n integer, parameter :: SQLITE_ROW = 100\r\n integer, parameter :: SQLITE_DONE = 101\r\n\r\n\r\n type SQLITE_STATEMENT\r\n integer, dimension(2) :: stmt_handle\r\n end type SQLITE_STATEMENT\r\n\r\n type SQLITE_DATABASE\r\n integer, dimension(2) :: db_handle\r\n integer :: error\r\n character(len=80) :: errmsg\r\n end type SQLITE_DATABASE\r\n\r\n type SQLITE_COLUMN\r\n character(len=40) :: name = ' '\r\n character(len=40) :: type = ' '\r\n character(len=40) :: function = ' '\r\n integer :: type_set\r\n integer :: int_value\r\n real(kind=dp) :: double_value\r\n character(len=80) :: char_value\r\n end type SQLITE_COLUMN\r\nend module sqlite_types\r\n\r\nmodule sqlite\r\n use sqlite_types\r\n\r\n implicit none\r\n\r\n private :: stringtof\r\n private :: stringtoc\r\n private :: typename\r\n private :: column_func\r\n\r\n !\r\n ! Convenient interfaces\r\n !\r\n interface sqlite3_set_column\r\n module procedure sqlite3_set_column_int\r\n module procedure sqlite3_set_column_real\r\n module procedure sqlite3_set_column_double\r\n module procedure sqlite3_set_column_char\r\n end interface\r\n interface sqlite3_get_column\r\n module procedure sqlite3_get_column_int\r\n module procedure sqlite3_get_column_real\r\n module procedure sqlite3_get_column_double\r\n module procedure sqlite3_get_column_char\r\n end interface\r\n\r\ncontains\r\n\r\n\r\n! typename --\r\n! Construct the type and attributes of a column\r\n! in a new table\r\n! Arguments:\r\n! column Column information\r\n! primary Name of the primary key\r\n!\r\ncharacter(len=40) function typename( column, primary )\r\n type(SQLITE_COLUMN), intent(in) :: column\r\n character(len=*), intent(in) :: primary\r\n\r\n if ( column%name .ne. primary ) then\r\n typename = column%type\r\n else\r\n !write( typename, '(2a)' ) trim(column%type), ' primary key'\r\n typename = trim(column%type) \/\/ ' primary key'\r\n endif\r\n\r\nend function typename\r\n\r\n\r\n! column_func --\r\n! Construct the name and function of a column\r\n! in a new table\r\n! Arguments:\r\n! column Column information\r\n!\r\ncharacter(len=80) function column_func( column )\r\n type(SQLITE_COLUMN), intent(in) :: column\r\n\r\n if ( column%function .ne. ' ' ) then\r\n column_func = trim(column%function) \/\/ '(' \/\/ trim(column%name) \/\/ ')'\r\n else\r\n column_func = column%name\r\n endif\r\n\r\nend function column_func\r\n\r\n\r\n! stringtof --\r\n! Convert a C string to Fortran\r\n! Arguments:\r\n! string String to be converted\r\n!\r\nsubroutine stringtof( string )\r\n character(len=*) :: string\r\n\r\n integer :: last\r\n last = index( string, char(0) )\r\n if ( last .gt. 0 ) then\r\n string(last:) = ' '\r\n endif\r\n\r\nend subroutine stringtof\r\n\r\n\r\n! stringtoc --\r\n! Convert a Fortran string to C\r\n! Arguments:\r\n! string String to be converted\r\n! Note:\r\n! It is assumed that the last character\r\n! is a space. As this is a private\r\n! routine, this should have been taken\r\n! care of in the caller.\r\n!\r\nsubroutine stringtoc( string )\r\n character(len=*) :: string\r\n\r\n integer :: last\r\n\r\n last = 1 + len_trim(string)\r\n string(last:last) = char(0)\r\n\r\nend subroutine stringtoc\r\n\r\n\r\n! sqlite3_column_props --\r\n! Convenience routine to set the properties of a column\r\n! Arguments:\r\n! column Column structure\r\n! name Name of the column\r\n! type Type of the column\r\n! length Length if a string\r\n! Side effects:\r\n! Fields in column filled\r\n!\r\nsubroutine sqlite3_column_props( column, name, type, length )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n character(len=*), intent(in) :: name\r\n integer, intent(in) :: type\r\n integer, intent(in), optional :: length\r\n\r\n integer :: length_\r\n character(len=40) :: type_expr\r\n\r\n length_ = 20\r\n if ( present(length) ) then\r\n length_ = length\r\n endif\r\n\r\n column%name = name\r\n column%type_set = type\r\n\r\n select case ( type )\r\n case (SQLITE_INT)\r\n column%type = 'INT'\r\n case (SQLITE_REAL)\r\n column%type = 'FLOAT'\r\n case (SQLITE_DOUBLE)\r\n column%type = 'DOUBLE'\r\n case (SQLITE_CHAR)\r\n write( column%type, '(a,i0,a)' ) 'CHAR(', length_, ')'\r\n case default\r\n column%type = 'UNKNOWN!'\r\n end select\r\n\r\nend subroutine sqlite3_column_props\r\n\r\n\r\n! sqlite3_column_query --\r\n! Convenience routine to query a column or a function of that column\r\n! Arguments:\r\n! column Column structure\r\n! name Name of the column\r\n! type Type of the column\r\n! length Length if a string (optional)\r\n! function Name of the function to apply (if any)\r\n! Side effects:\r\n! Fields in column filled\r\n!\r\nsubroutine sqlite3_column_query( column, name, type, length, function )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n character(len=*), intent(in) :: name\r\n integer, intent(in) :: type\r\n integer, intent(in), optional :: length\r\n character(len=*), intent(in), optional :: function\r\n\r\n column%function = ' '\r\n if ( present(function) ) then\r\n column%function = function\r\n endif\r\n if ( present(length) ) then\r\n call sqlite3_column_props( column, name, type, length )\r\n else\r\n call sqlite3_column_props( column, name, type )\r\n endif\r\n\r\nend subroutine sqlite3_column_query\r\n\r\n\r\n! sqlite3_set_column_int --\r\n! sqlite3_set_column_real --\r\n! sqlite3_set_column_double --\r\n! sqlite3_set_column_char --\r\n! Convenience routines to set the value of a column\r\n! Arguments:\r\n! column Column structure\r\n! value The value to be set\r\n! Side effects:\r\n! Appropriate value field in column set\r\n!\r\nsubroutine sqlite3_set_column_int( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n integer, intent(in) :: value\r\n\r\n column%int_value = value\r\n column%type_set = SQLITE_INT\r\nend subroutine sqlite3_set_column_int\r\n\r\nsubroutine sqlite3_set_column_real( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n real, intent(in) :: value\r\n\r\n column%double_value = value\r\n column%type_set = SQLITE_DOUBLE\r\nend subroutine sqlite3_set_column_real\r\n\r\nsubroutine sqlite3_set_column_double( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n real(kind=dp), intent(in) :: value\r\n\r\n column%double_value = value\r\n column%type_set = SQLITE_DOUBLE\r\nend subroutine sqlite3_set_column_double\r\n\r\nsubroutine sqlite3_set_column_char( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n character(len=*), intent(in) :: value\r\n\r\n column%char_value = value\r\n column%type_set = SQLITE_CHAR\r\nend subroutine sqlite3_set_column_char\r\n\r\n\r\n! sqlite3_get_column_int --\r\n! sqlite3_get_column_real --\r\n! sqlite3_get_column_double --\r\n! sqlite3_get_column_char --\r\n! Convenience routines to get the value of a column\r\n! Arguments:\r\n! column Column structure\r\n! value Value on return\r\n! Side effects:\r\n! Value argument will be set\r\n! Note:\r\n! No attempt is made to convert the value\r\n! to the requested value. You will have to\r\n! check this yourself\r\n!\r\nsubroutine sqlite3_get_column_int( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n integer, intent(out) :: value\r\n\r\n value = column%int_value\r\nend subroutine sqlite3_get_column_int\r\n\r\nsubroutine sqlite3_get_column_real( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n real, intent(out) :: value\r\n\r\n value = column%double_value\r\nend subroutine sqlite3_get_column_real\r\n\r\nsubroutine sqlite3_get_column_double( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n real(kind=dp), intent(out) :: value\r\n\r\n value = column%double_value\r\nend subroutine sqlite3_get_column_double\r\n\r\nsubroutine sqlite3_get_column_char( column, value )\r\n type(SQLITE_COLUMN), intent(inout) :: column\r\n character(len=*), intent(out) :: value\r\n\r\n value = column%char_value\r\nend subroutine sqlite3_get_column_char\r\n\r\n\r\n! sqlite3_error --\r\n! Return the last error code\r\n! Arguments:\r\n! db Structure for the database\r\n! Returns:\r\n! Last SQLite error code for this database\r\n!\r\nlogical function sqlite3_error( db )\r\n type(SQLITE_DATABASE) :: db\r\n\r\n sqlite3_error = db%error .ne. 0\r\nend function sqlite3_error\r\n\r\n\r\n! sqlite3_errmsg --\r\n! Return the last error message\r\n! Arguments:\r\n! db Structure for the database\r\n! Returns:\r\n! Last SQLite error message for this database\r\n!\r\ncharacter(len=80) function sqlite3_errmsg( db )\r\n type(SQLITE_DATABASE) :: db\r\n\r\n sqlite3_errmsg = db%errmsg\r\nend function sqlite3_errmsg\r\n\r\n\r\n! sqlite3_open --\r\n! Open a database file\r\n! Arguments:\r\n! fname Name of the file\r\n! db Structure for the database\r\n! Side effects:\r\n! The database file is opened and can be\r\n! used via the db argument\r\n!\r\nsubroutine sqlite3_open( fname, db )\r\n character(len=*) :: fname\r\n type(SQLITE_DATABASE) :: db\r\n\r\n character(len=len(fname)+1) :: fnamec\r\n\r\n interface\r\n integer function sqlite3_open_c( fnamec, handle, len_fnamec ) bind(C, name = 'sqlite3_open_c' )\r\n character(len=1), dimension(*) :: fnamec\r\n integer, dimension(*) :: handle\r\n integer, value :: len_fnamec\r\n end function sqlite3_open_c\r\n end interface\r\n\r\n db%db_handle = 0\r\n db%error = 0\r\n db%errmsg = ' '\r\n\r\n fnamec = fname\r\n call stringtoc( fnamec )\r\n\r\n db%error = sqlite3_open_c( fnamec, db%db_handle, len(fnamec) )\r\nend subroutine sqlite3_open\r\n\r\n\r\n! sqlite3_close --\r\n! Close a database file\r\n! Arguments:\r\n! db Structure for the database\r\n! Side effects:\r\n! The database file is closed and can no\r\n! longer be accessed\r\n!\r\nsubroutine sqlite3_close( db )\r\n type(SQLITE_DATABASE) :: db\r\n\r\n interface\r\n integer function sqlite3_close_c( handle ) bind(C, name = 'sqlite3_close_c')\r\n integer, dimension(*) :: handle\r\n end function sqlite3_close_c\r\n end interface\r\n\r\n db%error = sqlite3_close_c( db%db_handle )\r\n db%db_handle = 0\r\n\r\nend subroutine sqlite3_close\r\n\r\n\r\n! sqlite3_do --\r\n! Run a single SQL command\r\n! Arguments:\r\n! db Structure for the database\r\n! command Complete SQL command\r\n! Side effects:\r\n! Whatever effects the command has. Note\r\n! that no output is reported back to the\r\n! caller (except for error codes and\r\n! messages if any)\r\n! longer be accessed\r\n!\r\nsubroutine sqlite3_do( db, command )\r\n type(SQLITE_DATABASE) :: db\r\n character(len=*) :: command\r\n\r\n interface\r\n integer function sqlite3_do_c( handle, command, errmsg, len_command, len_errmsg ) bind(C, name = 'sqlite3_do_c')\r\n integer, dimension(*) :: handle\r\n character(len=1), dimension(*) :: command\r\n character(len=1), dimension(*) :: errmsg\r\n integer, value :: len_command\r\n integer, value :: len_errmsg\r\n end function sqlite3_do_c\r\n end interface\r\n\r\n character(len=len(command)+1) :: commandc\r\n integer :: k\r\n\r\n commandc = command\r\n call stringtoc( commandc )\r\n\r\n db%errmsg = ' '\r\n db%error = sqlite3_do_c( db%db_handle, commandc, db%errmsg, len(commandc), len(db%errmsg) )\r\n\r\nend subroutine sqlite3_do\r\n\r\n\r\n! sqlite3_begin --\r\n! Start a transaction on the given database\r\n! Arguments:\r\n! db Structure for the database\r\n! Note:\r\n! Should be accompanied by a call to either\r\n! sqlite3_commit or sqlite3_rollback\r\n!\r\nsubroutine sqlite3_begin( db )\r\n type(SQLITE_DATABASE) :: db\r\n\r\n call sqlite3_do( db, \"BEGIN TRANSACTION\" )\r\n\r\nend subroutine sqlite3_begin\r\n\r\n\r\n! sqlite3_commit --\r\n! Commits a transaction on the given database\r\n! Arguments:\r\n! db Structure for the database\r\n! Note:\r\n! Accompanies sqlite3_begin\r\n!\r\nsubroutine sqlite3_commit( db )\r\n type(SQLITE_DATABASE) :: db\r\n\r\n call sqlite3_do( db, \"COMMIT TRANSACTION\" )\r\n\r\nend subroutine sqlite3_commit\r\n\r\n\r\n! sqlite3_rollback --\r\n! Rolls back any changes to the database since the last commit\r\n! Arguments:\r\n! db Structure for the database\r\n! Note:\r\n! Accompanies sqlite3_begin\r\n!\r\nsubroutine sqlite3_rollback( db )\r\n type(SQLITE_DATABASE) :: db\r\n\r\n call sqlite3_do( db, \"ROLLBACK\" )\r\n\r\nend subroutine sqlite3_rollback\r\n\r\n\r\n! sqlite3_delete_table --\r\n! Delete a table\r\n! Arguments:\r\n! db Structure for the database\r\n! tablename Name of the table to be deleted\r\n! Note:\r\n! The table can not be recovered, unless this\r\n! is part of a transaction\r\n!\r\nsubroutine sqlite3_delete_table( db, tablename )\r\n type(SQLITE_DATABASE) :: db\r\n character(len=*) :: tablename\r\n\r\n character(len=20+len(tablename)) :: command\r\n\r\n write( command, \"(2A)\" ) \"DELETE TABLE \", tablename\r\n call sqlite3_do( db, command )\r\n\r\nend subroutine sqlite3_delete_table\r\n\r\n\r\n! sqlite3_create_table --\r\n! Create a new table\r\n! Arguments:\r\n! db Structure for the database\r\n! tablename Name of the table\r\n! columns Properties of the columns\r\n! primary Name of the primary key (if any)\r\n! Side effects:\r\n! The new table is created\r\n!\r\nsubroutine sqlite3_create_table( db, tablename, columns, primary )\r\n type(SQLITE_DATABASE) :: db\r\n character(len=*) :: tablename\r\n type(SQLITE_COLUMN), dimension(:) :: columns\r\n character(len=*), optional :: primary\r\n\r\n character(len=20+80*size(columns)) :: command\r\n character(len=40) :: primary_\r\n character(len=40) :: format\r\n integer :: i\r\n integer :: ncols\r\n\r\n primary_ = ' '\r\n if ( present(primary) ) then\r\n primary_ = primary\r\n endif\r\n\r\n ncols = size(columns)\r\n write( format, '(a,i0,a)' ) '(', 4 + 4 * ncols, 'a)'\r\n write( command, format ) 'create table ', tablename, ' (', &\r\n ( trim(columns(i)%name), ' ', trim(typename(columns(i), primary_)), ', ', &\r\n i = 1,ncols-1 ), &\r\n trim(columns(ncols)%name), ' ', trim(typename(columns(ncols),primary_)), ')'\r\n\r\n call sqlite3_do( db, command )\r\nend subroutine sqlite3_create_table\r\n\r\n\r\n! sqlite3_prepare_select --\r\n! Prepare a selection of data from the database\r\n! Arguments:\r\n! db Structure for the database\r\n! tablename Name of the table\r\n! columns Columns to be returned\r\n! stmt Prepared statement (returned)\r\n! extra_clause Extra clause for SELECT statement (appended)\r\n! Side effects:\r\n! A new selection is prepared\r\n!\r\nsubroutine sqlite3_prepare_select( db, tablename, columns, stmt, extra_clause )\r\n type(SQLITE_DATABASE) :: db\r\n character(len=*) :: tablename\r\n type(SQLITE_COLUMN), dimension(:), pointer :: columns ! On return: actual columns!\r\n character(len=*), optional :: extra_clause\r\n type(SQLITE_STATEMENT), intent(out) :: stmt\r\n\r\n character(len=20+80*size(columns)) :: command\r\n character(len=40) :: format\r\n integer :: nocols\r\n integer :: i\r\n\r\n !\r\n ! Prepare the select statement for this table\r\n !\r\n ! TODO: expand the syntax!!\r\n !\r\n nocols = size(columns)\r\n write( format, '(a,i0,a)' ) '(', 4 + 2 * nocols, 'a)'\r\n write( command, format ) 'select ', &\r\n (trim(column_func(columns(i))), ',', i = 1,nocols-1), &\r\n trim(column_func(columns(nocols))), &\r\n ' from ', trim(tablename)\r\n\r\n !\r\n ! Hm, appending a string of arbitrary length is tricky ...\r\n !\r\n if ( present(extra_clause) ) then\r\n command = trim(command) \/\/ ' ' \/\/ extra_clause\r\n endif\r\n\r\n call stringtoc( command )\r\n call sqlite3_prepare( db, command, stmt, columns )\r\n\r\nend subroutine sqlite3_prepare_select\r\n\r\n! sqlite3_insert --\r\n! Insert a row into the given table\r\n! Arguments:\r\n! db Structure for the database\r\n! tablename Name of the table\r\n! columns Columns whose value is to be inserted\r\n! Side effects:\r\n! A new row is written to the database\r\n!\r\nsubroutine sqlite3_insert( db, tablename, columns )\r\n type(SQLITE_DATABASE) :: db\r\n character(len=*) :: tablename\r\n type(SQLITE_COLUMN), dimension(:), target :: columns\r\n character(len=20+80*size(columns)) :: command\r\n character(len=40) :: format\r\n\r\n type(SQLITE_COLUMN), dimension(:), pointer :: prepared_columns\r\n type(SQLITE_STATEMENT) :: stmt\r\n integer :: i\r\n integer :: rc\r\n\r\n interface\r\n subroutine sqlite3_errmsg_c( handle, errmsg, len_errmsg ) bind(C, name = 'sqlite3_errmsg_c')\r\n integer, dimension(*) :: handle\r\n character(len=1), dimension(*) :: errmsg\r\n integer, value :: len_errmsg\r\n end subroutine sqlite3_errmsg_c\r\n end interface\r\n\r\n interface\r\n integer function sqlite3_bind_int_c( handle, colidx, value ) bind(C, name = 'sqlite3_bind_int_c')\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n integer :: value\r\n end function sqlite3_bind_int_c\r\n end interface\r\n\r\n interface\r\n integer function sqlite3_bind_double_c( handle, colidx, value ) bind(C, name = 'sqlite3_bind_double_c')\r\n use sqlite_types\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n real(kind=dp) :: value\r\n end function sqlite3_bind_double_c\r\n end interface\r\n\r\n interface\r\n integer function sqlite3_bind_text_c( handle, colidx, value, len_value ) bind(C, name = 'sqlite3_bind_text_c')\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n character(len=1), dimension(*) :: value\r\n integer, value :: len_value\r\n end function sqlite3_bind_text_c\r\n end interface\r\n\r\n !\r\n ! Prepare the insert statement for this table\r\n !\r\n write( format, '(a,i0,a)' ) '(', 4 + 2 * size(columns), 'a)'\r\n write( command, format ) 'insert into ', trim(tablename), ' values(', &\r\n ('?,', i = 1,size(columns)-1), '?)'\r\n\r\n call stringtoc( command )\r\n prepared_columns => columns\r\n call sqlite3_prepare( db, command, stmt, prepared_columns )\r\n\r\n !\r\n ! Bind the values\r\n !\r\n do i = 1,size(columns)\r\n select case (columns(i)%type_set)\r\n case (SQLITE_INT)\r\n rc = sqlite3_bind_int_c( stmt%stmt_handle, i, columns(i)%int_value )\r\n case (SQLITE_DOUBLE)\r\n rc = sqlite3_bind_double_c( stmt%stmt_handle, i, columns(i)%double_value )\r\n case (SQLITE_CHAR)\r\n rc = sqlite3_bind_text_c( stmt%stmt_handle, i, trim(columns(i)%char_value), len_trim(columns(i)%char_value) )\r\n end select\r\n if ( rc .ne. 0 ) then\r\n db%error = rc\r\n call sqlite3_errmsg_c( db%db_handle, db%errmsg, len(db%errmsg) )\r\n call stringtof( db%errmsg )\r\n endif\r\n enddo\r\n\r\n !\r\n ! Actually perform the insert command\r\n !\r\n call sqlite3_step( stmt, rc )\r\n call sqlite3_finalize( stmt )\r\n\r\nend subroutine sqlite3_insert\r\n\r\n\r\n! sqlite3_next_row --\r\n! Gets the next row of data from a selection\r\n! Arguments:\r\n! stmt Prepared statement\r\n! columns Columns to be returned\r\n! finished Indicates there are no more data\r\n!\r\nsubroutine sqlite3_next_row( stmt, columns, finished )\r\n type(SQLITE_STATEMENT) :: stmt\r\n type(SQLITE_COLUMN), dimension(:) :: columns\r\n logical :: finished\r\n\r\n interface\r\n integer function sqlite3_column_int_c( handle, colidx, value ) bind(C, name = 'sqlite3_column_int_c')\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n integer :: value\r\n end function sqlite3_column_int_c\r\n end interface\r\n\r\n interface\r\n integer function sqlite3_column_double_c( handle, colidx, value ) bind(C, name = 'sqlite3_column_double_c')\r\n use sqlite_types\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n real(kind=dp) :: value\r\n end function sqlite3_column_double_c\r\n end interface\r\n\r\n interface\r\n integer function sqlite3_column_text_c( handle, colidx, value, len_value ) bind(C, name = 'sqlite3_column_text_c')\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n character(len=1), dimension(*) :: value\r\n integer, value :: len_value\r\n end function sqlite3_column_text_c\r\n end interface\r\n\r\n integer :: rc\r\n integer :: i\r\n\r\n call sqlite3_step( stmt, rc )\r\n\r\n if ( rc .eq. SQLITE_ROW ) then\r\n finished = .false.\r\n\r\n !\r\n ! Get the values\r\n !\r\n ! TODO: check validity of \"type_set\"\r\n !\r\n do i = 1,size(columns)\r\n select case (columns(i)%type_set)\r\n case (SQLITE_INT)\r\n rc = sqlite3_column_int_c( stmt%stmt_handle, i-1, columns(i)%int_value )\r\n case (SQLITE_REAL,SQLITE_DOUBLE)\r\n rc = sqlite3_column_double_c( stmt%stmt_handle, i-1, columns(i)%double_value )\r\n case (SQLITE_CHAR)\r\n rc = sqlite3_column_text_c( stmt%stmt_handle, i-1, columns(i)%char_value, len(columns(i)%char_value) )\r\n call stringtof( columns(i)%char_value )\r\n end select\r\n ! if ( rc .ne. 0 ) then\r\n ! db%error = rc\r\n ! call sqlite3_errmsg_c( db%db_handle, db%errmsg )\r\n ! call stringtof( db%errmsg )\r\n ! endif\r\n enddo\r\n else\r\n finished = .true.\r\n endif\r\n\r\nend subroutine sqlite3_next_row\r\n\r\n\r\n! sqlite3_query_table --\r\n! Retrieve the column names and types from a table\r\n! Arguments:\r\n! db Structure for the database\r\n! tablename Name of the table\r\n! columns Columns (allocated array)\r\n! Side effects:\r\n! The columns array is allocated and filled\r\n! Note:\r\n! On entry the columns argument must not be\r\n! associated. On exit, it will point to a\r\n! freshly allocated array of column names\/types\r\n!\r\nsubroutine sqlite3_query_table( db, tablename, columns )\r\n type(SQLITE_DATABASE) :: db\r\n character(len=*) :: tablename\r\n type(SQLITE_COLUMN), dimension(:), pointer :: columns ! On return: actual columns!\r\n\r\n type(SQLITE_STATEMENT) :: stmt\r\n character(len=20+len(tablename)) :: command\r\n\r\n write( command, '(2a)' ) 'select * from ',tablename\r\n\r\n !\r\n ! Note, we must free the columns, but we can not be sure\r\n ! they are no longer used. So simply disassociate.\r\n if ( associated(columns) ) then\r\n nullify( columns )\r\n endif\r\n call sqlite3_prepare( db, command, stmt, columns )\r\n call sqlite3_finalize( stmt )\r\n\r\nend subroutine sqlite3_query_table\r\n\r\n\r\n! sqlite3_finalize --\r\n! Finalize the prepared SQL statement\r\n! Arguments:\r\n! stmt Handle to the prepared statement\r\n!\r\nsubroutine sqlite3_finalize( stmt )\r\n type(SQLITE_STATEMENT) :: stmt\r\n\r\n interface\r\n subroutine sqlite3_finalize_c( stmt ) bind(C, name = 'sqlite3_finalize_c')\r\n integer, dimension(*) :: stmt\r\n end subroutine sqlite3_finalize_c\r\n end interface\r\n\r\n call sqlite3_finalize_c( stmt%stmt_handle )\r\n\r\nend subroutine sqlite3_finalize\r\n\r\n\r\n! sqlite3_reset --\r\n! Reset the prepared SQL statement so that it can\r\n! be used again\r\n! Arguments:\r\n! stmt Handle to the prepared statement\r\n!\r\nsubroutine sqlite3_reset( stmt )\r\n type(SQLITE_STATEMENT) :: stmt\r\n\r\n interface\r\n subroutine sqlite3_reset_c( stmt ) bind(C, name = 'sqlite3_reset_c')\r\n integer, dimension(*) :: stmt\r\n end subroutine sqlite3_reset_c\r\n end interface\r\n\r\n call sqlite3_reset_c( stmt%stmt_handle )\r\n\r\nend subroutine sqlite3_reset\r\n\r\n\r\n! sqlite3_step --\r\n! Run the prepared SQL statement\r\n! Arguments:\r\n! stmt Handle to the prepared statement\r\n! completion Return code, indicating if the command is complete or\r\n! not (SQLITE_DONE, SQLITE_MISUSE or SQLITE_ERROR)\r\n!\r\nsubroutine sqlite3_step( stmt, completion )\r\n type(SQLITE_STATEMENT) :: stmt\r\n integer, intent(out) :: completion\r\n\r\n interface\r\n subroutine sqlite3_step_c( stmt, completion ) bind(C, name = 'sqlite3_step_c')\r\n integer, dimension(*) :: stmt\r\n integer :: completion\r\n end subroutine sqlite3_step_c\r\n end interface\r\n\r\n call sqlite3_step_c( stmt%stmt_handle, completion )\r\n\r\nend subroutine sqlite3_step\r\n\r\n\r\n! sqlite3_prepare --\r\n! Prepare the SQL statement for actual use\r\n! Arguments:\r\n! stmt Handle to the prepared statement\r\n!\r\nsubroutine sqlite3_prepare( db, command, stmt, columns )\r\n type(SQLITE_DATABASE), intent(inout) :: db\r\n character(len=*), intent(in) :: command\r\n type(SQLITE_STATEMENT), intent(out) :: stmt\r\n type(SQLITE_COLUMN), dimension(:), pointer :: columns ! On return: actual columns!\r\n\r\n interface\r\n subroutine sqlite3_errmsg_c( handle, errmsg, len_errmsg ) bind(C, name = 'sqlite3_errmsg_c')\r\n integer, dimension(*) :: handle\r\n character(len=1), dimension(*) :: errmsg\r\n integer, value :: len_errmsg\r\n end subroutine sqlite3_errmsg_c\r\n end interface\r\n\r\n interface\r\n integer function sqlite3_prepare_c( db, command, stmt, len_command ) bind(C, name = 'sqlite3_prepare_c')\r\n integer, dimension(*) :: db\r\n character(len=1), dimension(*) :: command\r\n integer, dimension(*) :: stmt\r\n integer, value :: len_command\r\n end function sqlite3_prepare_c\r\n end interface\r\n\r\n interface\r\n subroutine sqlite3_column_count_c( handle, count ) bind(C, name = 'sqlite3_column_count_c')\r\n integer, dimension(*) :: handle\r\n integer :: count\r\n end subroutine sqlite3_column_count_c\r\n end interface\r\n\r\n interface\r\n subroutine sqlite3_column_name_type_c( handle, colidx, name, type, &\r\n len_name, len_type ) bind(C, name = 'sqlite3_column_name_type_c')\r\n integer, dimension(*) :: handle\r\n integer :: colidx\r\n character(len=1), dimension(*) :: name\r\n character(len=1), dimension(*) :: type\r\n integer, value :: len_name\r\n integer, value :: len_type\r\n end subroutine sqlite3_column_name_type_c\r\n end interface\r\n\r\n integer :: count\r\n integer :: i\r\n character(len=len(command)+1) :: commandc\r\n\r\n commandc = command\r\n call stringtoc( commandc )\r\n db%error = sqlite3_prepare_c( db%db_handle, commandc, stmt%stmt_handle, len(commandc) )\r\n\r\n if ( db%error .eq. 0 ) then\r\n if ( associated(columns) ) return ! Assumption: they are already known\r\n\r\n call sqlite3_column_count_c( stmt%stmt_handle, count )\r\n\r\n allocate( columns(1:count) )\r\n\r\n do i = 1,count\r\n call sqlite3_column_name_type_c( stmt%stmt_handle, i-1, &\r\n columns(i)%name, columns(i)%type, len(columns(i)%name), len(columns(i)%type) )\r\n call stringtof( columns(i)%name )\r\n call stringtof( columns(i)%type )\r\n\r\n select case (columns(i)%type(1:4) )\r\n case( 'INT ', 'INTE' )\r\n columns(i)%type_set = SQLITE_INT\r\n case( 'FLOA', 'DOUB' )\r\n columns(i)%type_set = SQLITE_DOUBLE\r\n case( 'CHAR', 'VARC' )\r\n columns(i)%type_set = SQLITE_CHAR\r\n end select\r\n\r\n enddo\r\n else\r\n call sqlite3_errmsg_c( db%db_handle, db%errmsg, len(db%errmsg) )\r\n endif\r\n\r\nend subroutine sqlite3_prepare\r\n\r\n\r\n! sqlite3_get_table --\r\n! Call sqlite3_exec() and return the result in an\r\n! array of strings\r\n! Arguments:\r\n! db Handle to the database\r\n! command SQL comman to be executed\r\n! result Two-dimensional array of strings (pointer)\r\n! errmsg Error message (if any)\r\n! Note:\r\n! The result array is _nullified_ first, then allocated\r\n! to hold the resulting table (within the limits of the\r\n! character strings). It is up to the user to deallocate\r\n! this array when done.\r\n! Further note:\r\n! Because we have to split the process into two parts,\r\n! to allocate an array that is large enough to hold all\r\n! strings, use is made of a static variable. As a consequence\r\n! this routine is _not_ thread-safe.\r\n!\r\nsubroutine sqlite3_get_table( db, command, result, errmsg )\r\n type(SQLITE_DATABASE), intent(inout) :: db\r\n character(len=*), intent(in) :: command\r\n character(len=*), pointer, dimension(:,:) :: result\r\n character(len=*), intent(out) :: errmsg\r\n\r\n character(len=len(command)+1) :: commandc\r\n integer :: ncol\r\n integer :: nrow\r\n\r\n interface\r\n integer function sqlite3_get_table_1_c( handle, commandc, ncol, &\r\n nrow, errmsg, len_commandc, len_errmsg ) bind(C, name = 'sqlite3_get_table_1_c')\r\n integer, dimension(*) :: handle\r\n character(len=1), dimension(*) :: commandc\r\n integer :: ncol\r\n integer :: nrow\r\n character(len=1), dimension(*) :: errmsg\r\n integer, value :: len_commandc\r\n integer, value :: len_errmsg\r\n end function sqlite3_get_table_1_c\r\n end interface\r\n\r\n interface\r\n subroutine sqlite3_get_table_2_c( ncol, nrow, result, len_result ) bind(C, name = 'sqlite3_get_table_2_c' )\r\n integer :: ncol\r\n integer :: nrow\r\n character(len=1),dimension(*) :: result\r\n integer, value :: len_result\r\n end subroutine sqlite3_get_table_2_c\r\n end interface\r\n\r\n\r\n commandc = command\r\n call stringtoc( commandc )\r\n\r\n db%error = sqlite3_get_table_1_c( db%db_handle, commandc, ncol, nrow, db%errmsg, &\r\n len(commandc), len(db%errmsg) )\r\n\r\n nullify( result )\r\n if ( db%error == 0 ) then\r\n allocate( result(ncol,nrow+1) )\r\n call sqlite3_get_table_2_c( ncol, nrow, result, len(result) )\r\n endif\r\n\r\n errmsg = db%errmsg\r\n\r\nend subroutine sqlite3_get_table\r\n\r\nend module\r\n","avg_line_length":31.715392062,"max_line_length":121,"alphanum_fraction":0.6024662719} {"size":1783,"ext":"f","lang":"FORTRAN","max_stars_count":11.0,"content":" subroutine pmbdrw(datas,iobs,nobs,ndata,title,case,lfno)\nc----- Draw accumulated data of PMEAS. ------- \n implicit real*8 (a-h,o-z)\n parameter (item=20,itemn=item\/2)\n character*(*) title,case\nc character line*131,lepton(2)*4,autofg*8,name*8\n dimension iobs(nobs+1),datas(itemn,2,nobs,ndata)\nc data lepton\/'(e+)','(e-)'\/\nc\nc..... plot min and max of emiy\/emix .... \n write(lfno,*)'NEWFRAME;SET FONT DUPLEX;SET TITLE SIZE -3'\n write(lfno,*)'SET WINDOW X 3.3 12.1 Y 2.5 8.35'\n write(lfno,*)'TITLE 8.5 9.1 CENTER '' '''\n write(lfno,*)'MORE ''',title(1:min(59,lene(title))),''''\n write(lfno,*)'CASE '' ',case(1:min(59,lene(case))) ,''''\n write(lfno,*)'SET TITLE SIZE -2.6'\n write(lfno,*)'TITLE BOTTOM ''NUMBER OF STEP'''\n write(lfno,*)'CASE '' LLLLL LL LLL'''\n write(lfno,*)'TITLE LEFT ''E0Y1\/E0X1'' SIZE -3'\n write(lfno,*)'CASE ''GXLX GXLX'''\n write(lfno,*)'SET SYMBOL ''. '' SIZE 0.02'\n call tdinit(lfno,'PLOT;JOIN 1','10 ')\n ymax=abs(datas(10,1,1,1))\n ymin=ymax\n do 8 i=1,ndata\n y=abs(datas(10,1,1,i))\n if(y.lt.ymin) ymin=y\n ymax=max(y,datas(10,2,1,i),ymax)\n 8 continue\n write(lfno,'(a,i4,a,1p,2g13.5)')'SET LIMIT X 0 ',ndata,' Y ',\n $ 1.05*ymin-0.05*ymax,1.05*ymax-0.05*ymin\n yp=abs(datas(10,1,1,1))\n do 10 i=1,ndata\n y=datas(10,1,1,i)\n if(y.lt.0d0) then \n yp=abs(y)\n endif\n call tdput(dble(i),yp)\n 10 continue\n call tdterm\n yp=datas(10,2,1,1)\n call tdinit(lfno,'PLOT;JOIN 1','.2 .04 ')\n do 12 i=1,ndata\n y=datas(10,2,1,i)\n if(y.ne.0d0) yp=y\n call tdput(dble(i),yp)\n 12 continue\n call tdterm\n return\n end\n","avg_line_length":34.9607843137,"max_line_length":67,"alphanum_fraction":0.537296691} {"size":977,"ext":"f90","lang":"FORTRAN","max_stars_count":115.0,"content":"program message_size\nuse, intrinsic :: iso_fortran_env, only : i4 => INT32, dp => REAL64\nuse :: mpi\nimplicit none\ninteger, parameter :: send_buff_size = 5\ninteger, parameter :: recv_buff_size = 5\ninteger(kind=i4), dimension(send_buff_size) :: send_buff\nreal(kind=dp), dimension(recv_buff_size) :: recv_buff\ninteger :: ierr, rank, size, i\ninteger, parameter :: tag = 17\n\ncall MPI_Init(ierr)\ncall MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)\ncall MPI_Comm_size(MPI_COMM_WORLD, size, ierr)\nif (rank == 0) then\n do i = 1, send_buff_size\n send_buff(i) = i\n end do\n call MPI_Ssend(send_buff, send_buff_size, MPI_INTEGER, 1, tag, &\n MPI_COMM_WORLD, ierr)\nelse if (rank == 1) then\n call MPI_Recv(recv_buff, recv_buff_size, MPI_DOUBLE_PRECISION, 0, tag, &\n MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr)\n do i = 1, recv_buff_size\n print '(E25.15)', recv_buff(i)\n end do\nend if\n\ncall MPI_Finalize(ierr)\n\nend program message_size\n","avg_line_length":30.53125,"max_line_length":76,"alphanum_fraction":0.6960081883} {"size":15548,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":"subroutine gmres(x,d,dold,w,bg,dg,hg,ien,fext,id,&\n ne_local,ien_local,node_local,nn_local,&\n global_com,nn_global_com,local_com,nn_local_com,send_address,ad_length,&\n fden,fvis,I_fluid,rngface)\n use fluid_variables, only: nsd,nn,ne,nen,ndf,inner,outer,neface\n use solid_variables, only: nn_solid\n use mpi_variables\n use pml_variables\n implicit none\n include 'mpif.h'\n\treal* 8 x(nsd,nn)\n integer id(ndf,nn)\n\treal* 8 d(ndf,nn), dold(ndf,nn),hg(ne),fext(ndf,nn)\n integer ien(nen,ne)\n\treal* 8 bg(ndf*(nn+nn_PML)), dg(ndf*(nn+nn_PML)), w(ndf*(nn+nn_PML))\n\treal* 8 Hm(inner+1,inner) !Henssenberg matrix\n!=========================================================\n! reduce dimension to save memory\n\treal* 8 Vm(ndf*(nn_local+nn_PML_local), inner+1) ! Krylov space matrix\n! real* 8 Vm(ndf*nn, inner+1) ! Krylov space matrix\n!=========================================================\n integer i,j,iouter,icount,INFO\n\treal* 8 e1(inner+1)\n\treal* 8 x0(ndf*(nn+nn_PML))\n\treal* 8 beta(inner+1)\n\treal* 8 eps\n\treal* 8 r0(ndf*(nn+nn_PML))\n\treal* 8 rnorm, rnorm0, err\n real* 8 dv(ndf*(nn+nn_PML))\n\treal* 8 Vy(ndf*(nn+nn_PML))\n real* 8 vloc(ndf,nn+nn_PML), avloc(ndf*(nn+nn_PML))\n!==============================\n! reduce dimension save memory\n\treal* 8 temp\n!==============================\n character(1) TRAN\n\treal* 8 workls(2*inner)\n\treal* 8 av_tmp(ndf,nn+nn_PML)\n integer rngface(neface,ne)\n!---------------------------------------\n real(8) fden(nn)\n real(8) fvis(nn)\n real(8) I_fluid(nn)\n!============================\n! MPI varibalbes\n integer ne_local ! # of element on each processor\n integer ien_local(ne_local) ! subregion-->wholeregion element index\n integer ie_local ! loop parameter\n integer node_local(nn_local)\n integer nn_local\n integer jcount\n integer kcount\n integer node\n integer nn_global_com\n integer global_com(nn_global_com) ! global node index for communication\n integer nn_local_com\n integer local_com(nn_local_com) ! local index in the communication region on each processor\n integer ad_length\n integer send_address(ad_length,2)\n integer flag\n real(8) dg_sent(ndf*(nn+nn_PML))\n real(8) space1(inner)\n real(8) space2(inner)\n integer time_arrary_0(8)\n integer time_arrary_1(8)\n real(8) start_time\n real(8) end_time\n real(8) linerr\n!---------------------------------------------\n eps = 1.0e-6\n linerr = 1.0e-6\n e1(:) = 0.0\n e1(1) = 1.0\n x0(:) = 0.0\n iouter = 1\n r0(:) = bg(:)\n TRAN = 'N'\n av_tmp(:,:) = 0\n avloc(:) = 0\n!\tw(:) = 1\n call getnormpml_pa(r0,ndf,nn,node_local,nn_local,rnorm0)\n rnorm = sqrt(rnorm0)\n\n!!!!!!!!!!!!!!!start outer loop!!!!!!!!!\ndo 111, while((iouter .le. outer) .and. (rnorm .ge. linerr))\n\n!==============================\n Vm(:,:) = 0.0d0\n! Already is a local variable defined on each proc\n!===============================\n do icount = 1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n Vm((icount-1)*ndf+jcount,1) = r0((node-1)*ndf+jcount)\/rnorm\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n Vm((nn_local+seqcPMLlocal(icount)-1)*ndf+jcount,1) = r0((nn+seqcPML(node)-1)*ndf+jcount)\/rnorm\n enddo\n endif\n enddo ! get V1\n\n beta(:) = rnorm*e1(:) ! get beta*e1\n Hm(:,:) = 0.0\n!!!!!!!!!!!!!!!!start inner loop!!!!!!!!!!!!!\n do j=1,inner\n do icount=1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n dv((node-1)*ndf+jcount) = eps\/w((node-1)*ndf+jcount)*Vm((icount-1)*ndf+jcount,j)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n dv((nn+seqcPML(node)-1)*ndf+jcount) = eps*Vm((nn_local+seqcPMLlocal(icount)-1)*ndf+jcount,j) &\n \/w((nn+seqcPML(node)-1)*ndf+jcount)\n enddo\n endif\n enddo!!!!!!!!!!calcule eps*inv(P)*V1\n!===============================================\n!\t\tvloc(:,:) = 0.0d0\n! Clear the matrix locally to avoid too many loops \n do icount=1,nn_local\n node=node_local(icount)\n vloc(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n vloc(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n! clear all the processor internal nodes\n do icount=1,nn_local_com\n node=global_com(local_com(icount))\n vloc(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n vloc(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n! clear the processor boundary nodes\n!===============================================\n call equalpml_pa(dv,vloc,ndf,nn,node_local,nn_local)\n!============================\n do icount=1,nn_local\n node=node_local(icount)\n vloc(1:ndf,node)=vloc(1:ndf,node)+d(1:ndf,node)\n if (seqcPML(node) > 0) then\n vloc(1:ndf,nn+seqcPML(node))=vloc(1:ndf,nn+seqcPML(node))+qv(1:ndf,node)\n endif\n enddo\n! Let vloc=vloc+d first then communicate, and then it should same # of loop (avoiding loop at the whole domain)\n!=============================\n call communicate_respml_ad_sub(vloc,ndf,nn,send_address,ad_length)\n!----------------------------------------------------------------------------------------------\n!vloc(:,:)=vloc(:,:)+d(:,:)\n!----------------------------------------------------------------------------------------------\n! Clear matrix local first interal then boundary processor nodes\n do icount=1,nn_local\n node=node_local(icount)\n av_tmp(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n av_tmp(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n do icount=1,nn_local_com\n node=global_com(local_com(icount))\n av_tmp(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n av_tmp(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n!\t\tav_tmp(:,:) = 0.0d0\n!======================================\n!!!!!! av_tmp is a temporary residual\n call blockgmresnew(x,vloc,dold,av_tmp,hg,ien,fext,ne_local,ien_local,node_local,nn_local,&\n fden,fvis,I_fluid,rngface)\n call communicate_respml_ad_sub(av_tmp,ndf,nn,send_address,ad_length)\n!===================\n! avloc(:)=0.0d0\n!==================\n call equalpml_pa(av_tmp,avloc,ndf,nn,node_local,nn_local)\n do icount=1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n avloc(kcount) = (-avloc(kcount)+bg(kcount))\/eps ! get Av,bg=-r(u)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n avloc(kcount) = (-avloc(kcount)+bg(kcount))\/eps ! get Av,bg=-r(u)\n enddo\n endif\n enddo\n call setidpml_pa(avloc,ndf,nn,nn_PML,id,node_local,nn_local)\n space1(:)=0.0d0\n space2(:)=0.0d0\n end_time=mpi_wtime()\n do i=1,j\n do icount=1,nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n space1(i)=space1(i)+avloc(kcount)*Vm((icount-1)*ndf+jcount,i)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n space1(i)=space1(i)+avloc(kcount)*Vm((nn_local+seqcPMLlocal(icount)-1)*ndf+jcount,i)\n enddo\n endif\n enddo\n! Do the vector product of v_i * v_i set it to be h_i,j\n enddo ! construct AVj and hi,j\n call mpi_barrier(mpi_comm_world,ierror)\n call mpi_allreduce(space1(1),space2(1),j,mpi_double_precision,mpi_sum,mpi_comm_world,ierror)\n end_time=mpi_wtime()-end_time\n Hm(1:j,j)=space2(1:j)\n do icount = 1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(icount-1)*ndf+jcount\n do i=1,j\n Vm(kcount,j+1) = Vm(kcount,j+1)-Hm(i,j)*Vm(kcount,i)\n enddo\n Vm(kcount,j+1)=Vm(kcount,j+1)+avloc((node-1)*ndf+jcount)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn_local+seqcPMLlocal(icount)-1)*ndf+jcount\n do i=1,j\n Vm(kcount,j+1) = Vm(kcount,j+1)-Hm(i,j)*Vm(kcount,i)\n enddo\n Vm(kcount,j+1)=Vm(kcount,j+1)+avloc((nn+seqcPML(node)-1)*ndf+jcount)\n enddo\n endif\n enddo ! construct v(j+1)\n temp=0.0d0\n do icount = 1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(icount-1)*ndf+jcount\n temp=temp+Vm(kcount,j+1)*Vm(kcount,j+1)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn_local+seqcPMLlocal(icount)-1)*ndf+jcount\n temp=temp+Vm(kcount,j+1)*Vm(kcount,j+1)\n enddo\n endif\n enddo\n call mpi_barrier(mpi_comm_world,ierror)\n call mpi_allreduce(temp,rnorm0,1,mpi_double_precision,mpi_sum,mpi_comm_world,ierror)\n\n Hm(j+1,j) = sqrt(rnorm0)\n do icount = 1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(icount-1)*ndf+jcount\n Vm(kcount,j+1)=Vm(kcount,j+1)\/Hm(j+1,j)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn_local+seqcPMLlocal(icount)-1)*ndf+jcount\n Vm(kcount,j+1)=Vm(kcount,j+1)\/Hm(j+1,j)\n enddo\n endif\n enddo\n enddo ! end inner loop\n!====================================================================================\t\t\n! Use lapack to solve the LS problem\n!\tcall DGELS(TRAN,inner+1,inner,1,Hm,inner+1,beta,inner+1,workls,2*inner,INFO)\n!===================================================================================\n! Use Givens rotation to solve the LS problem\n call mpi_barrier(mpi_comm_world,ierror)\n call givens(Hm,inner,beta)\n!!!!!!!!!!!!beta(1:inner) is ym, the solution!!!!!!!!!!!!!!!!!!!!!!!!!\n Vy(:) = 0\n do icount=1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n do i=1,inner\n Vy(kcount)=Vy(kcount)+Vm((icount-1)*ndf+jcount,i)*beta(i)\n enddo\n x0(kcount)=x0(kcount)+Vy(kcount)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n do i=1,inner\n Vy(kcount)=Vy(kcount)+Vm((nn_local+seqcPMLlocal(icount)-1)*ndf+jcount,i)*beta(i)\n enddo\n x0(kcount)=x0(kcount)+Vy(kcount)\n enddo\n endif\n enddo ! calculate Xm\n do icount = 1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n dv(kcount) = eps\/w(kcount)*x0(kcount)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n dv(kcount) = eps\/w(kcount)*x0(kcount)\n enddo\n endif\n enddo\n!============================\n! Clear matirx locally \n do icount=1,nn_local\n node=node_local(icount)\n vloc(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n vloc(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n! clear all the processor internal nodes\n do icount=1,nn_local_com\n node=global_com(local_com(icount))\n vloc(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n vloc(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n! clear the processor boundary nodes\n!\tvloc(:,:) = 0\n!==============================\n call equalpml_pa(dv,vloc,ndf,nn,node_local,nn_local)\n do icount=1,nn_local\n node=node_local(icount)\n vloc(1:ndf,node)=vloc(1:ndf,node)+d(1:ndf,node)\n if (seqcPML(node) > 0) then\n vloc(1:ndf,nn+seqcPML(node))=vloc(1:ndf,nn+seqcPML(node))+qv(1:ndf,node)\n endif\n enddo\n call communicate_respml_ad_sub(vloc,ndf,nn,send_address,ad_length)\n!==============================\n!\tvloc(:,:) = vloc(:,:)+d(:,:)\n!===============================\n! Clear matrix local first interal then boundary processor nodes\n do icount=1,nn_local\n node=node_local(icount)\n av_tmp(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n av_tmp(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n do icount=1,nn_local_com\n node=global_com(local_com(icount))\n av_tmp(1:ndf,node)=0.0d0\n if (seqcPML(node) > 0) then\n av_tmp(1:ndf,nn+seqcPML(node))=0.0d0\n endif\n enddo\n!\tav_tmp(:,:) = 0.0d0\n!================================\n call blockgmresnew(x,vloc,dold,av_tmp,hg,ien,fext,ne_local,ien_local,node_local,nn_local,&\n fden,fvis,I_fluid,rngface)\n call communicate_respml_ad_sub(av_tmp,ndf,nn,send_address,ad_length)\n!==================\n!avloc(:)=0.0d0\n!==================\n call equalpml_pa(av_tmp,avloc,ndf,nn,node_local,nn_local)\n call setidpml_pa(avloc,ndf,nn,nn_PML,id,node_local,nn_local)\n do icount=1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n avloc(kcount) = (-avloc(kcount)+bg(kcount))\/eps\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n avloc(kcount) = (-avloc(kcount)+bg(kcount))\/eps\n enddo\n endif\n enddo\n!!!!!!!!!!calculate AXm\n do icount=1,nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n r0(kcount) = bg(kcount)-avloc(kcount)\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n r0(kcount) = bg(kcount)-avloc(kcount)\n enddo\n endif\n enddo !update r0=f-AX0\n\n call getnormpml_pa(r0,ndf,nn,node_local,nn_local,rnorm0)\n err = sqrt(rnorm0)\n rnorm = sqrt(rnorm0)\n iouter = iouter + 1 \n if (myid == 0) write(*,*) '||r0||=||f-AX0||=',err\n\n111 continue ! end outer loop\n\n dg_sent(1:ndf*(nn+nn_PML))=0.0d0\n do icount=1, nn_local\n node=node_local(icount)\n do jcount=1,ndf\n kcount=(node-1)*ndf+jcount\n dg_sent(kcount) = 1\/w(kcount)*x0(kcount) ! unscaled x0\n enddo\n if (seqcPML(node) > 0) then\n do jcount=1,ndf\n kcount=(nn+seqcPML(node)-1)*ndf+jcount\n dg_sent(kcount) = 1\/w(kcount)*x0(kcount) ! unscaled x0\n enddo\n endif\n enddo\n dg(1:ndf*(nn+nn_PML))=0.0d0\n call mpi_barrier(mpi_comm_world,ierror)\n call mpi_allreduce(dg_sent(1),dg(1),ndf*(nn+nn_PML),mpi_double_precision,mpi_sum,mpi_comm_world,ierror)\n!\tcall mpi_bcast(dg(1),ndf*nn,mpi_double_precision,0,mpi_comm_world,ierror)\n call mpi_barrier(mpi_comm_world,ierror)\n\nreturn\nend subroutine gmres","avg_line_length":36.8436018957,"max_line_length":114,"alphanum_fraction":0.5228325187} {"size":3139,"ext":"f","lang":"FORTRAN","max_stars_count":8.0,"content":" subroutine dgesl(a,lda,n,ipvt,b,job)\n integer lda,n,ipvt(*),job\n double precision a(lda,*),b(*)\nc\nc dgesl solves the double precision system\nc a * x = b or trans(a) * x = b\nc using the factors computed by dgeco or dgefa.\nc\nc on entry\nc\nc a double precision(lda, n)\nc the output from dgeco or dgefa.\nc\nc lda integer\nc the leading dimension of the array a .\nc\nc n integer\nc the order of the matrix a .\nc\nc ipvt integer(n)\nc the pivot vector from dgeco or dgefa.\nc\nc b double precision(n)\nc the right hand side vector.\nc\nc job integer\nc = 0 to solve a*x = b ,\nc = nonzero to solve trans(a)*x = b where\nc trans(a) is the transpose.\nc\nc on return\nc\nc b the solution vector x .\nc\nc error condition\nc\nc a division by zero will occur if the input factor contains a\nc zero on the diagonal. technically this indicates singularity\nc but it is often caused by improper arguments or improper\nc setting of lda . it will not occur if the subroutines are\nc called correctly and if dgeco has set rcond .gt. 0.0\nc or dgefa has set info .eq. 0 .\nc\nc to compute inverse(a) * c where c is a matrix\nc with p columns\nc call dgeco(a,lda,n,ipvt,rcond,z)\nc if (rcond is too small) go to ...\nc do 10 j = 1, p\nc call dgesl(a,lda,n,ipvt,c(1,j),0)\nc 10 continue\nc\nc linpack. this version dated 08\/14\/78 .\nc cleve moler, university of new mexico, argonne national lab.\nc\nc subroutines and functions\nc\nc blas daxpy,ddot\nc\nc internal variables\nc\n double precision ddot,t\n integer k,kb,l,nm1\nc\n nm1 = n - 1\n if (job .ne. 0) go to 50\nc\nc job = 0 , solve a * x = b\nc first solve l*y = b\nc\n if (nm1 .lt. 1) go to 30\n do 20 k = 1, nm1\n l = ipvt(k)\n t = b(l)\n if (l .eq. k) go to 10\n b(l) = b(k)\n b(k) = t\n 10 continue\n call daxpy(n-k,t,a(k+1,k),1,b(k+1),1)\n 20 continue\n 30 continue\nc\nc now solve u*x = y\nc\n do 40 kb = 1, n\n k = n + 1 - kb\n b(k) = b(k)\/a(k,k)\n t = -b(k)\n call daxpy(k-1,t,a(1,k),1,b(1),1)\n 40 continue\n go to 100\n 50 continue\nc\nc job = nonzero, solve trans(a) * x = b\nc first solve trans(u)*y = b\nc\n do 60 k = 1, n\n t = ddot(k-1,a(1,k),1,b(1),1)\n b(k) = (b(k) - t)\/a(k,k)\n 60 continue\nc\nc now solve trans(l)*x = y\nc\n if (nm1 .lt. 1) go to 90\n do 80 kb = 1, nm1\n k = n - kb\n b(k) = b(k) + ddot(n-k,a(k+1,k),1,b(k+1),1)\n l = ipvt(k)\n if (l .eq. k) go to 70\n t = b(l)\n b(l) = b(k)\n b(k) = t\n 70 continue\n 80 continue\n 90 continue\n 100 continue\n return\n end\n","avg_line_length":26.6016949153,"max_line_length":70,"alphanum_fraction":0.4864606563} {"size":3266,"ext":"f90","lang":"FORTRAN","max_stars_count":1.0,"content":"subroutine do_burn() bind(C)\n\n use network\n use eos_type_module, only : eos_t, eos_input_rt\n use eos_module\n use burner_module\n use actual_burner_module\n use actual_rhs_module, only: actual_rhs_init\n use meth_params_module\n use reactions_module, only: ca_react_state\n use extern_probin_module, only: ncell, dt, dens_min, dens_max, temp_min, temp_max\n\n use amrex_fort_module, only : rt => amrex_real\n implicit none\n\n integer, parameter :: nv = 7 + nspec\n\n real(rt) , parameter :: time = 0.0e0_rt\n\n integer :: lo(3), hi(3), w(3)\n\n real(rt) :: dlogrho, dlogT\n\n real(rt) , allocatable :: state(:,:,:,:), reactions(:,:,:,:)\n integer, allocatable :: mask(:,:,:)\n real(rt), allocatable :: weights(:,:,:)\n\n integer :: i, j, k\n\n type (eos_t) :: eos_state\n\n real(rt) :: start, finish\n\n character (len=32) :: probin_file\n integer :: probin_pass(32)\n integer :: n\n\n probin_file = \"probin\"\n do n = 1, len(trim(probin_file))\n probin_pass(n) = ichar(probin_file(n:n))\n enddo\n\n call runtime_init(probin_pass(1:len(trim(probin_file))), len(trim(probin_file)))\n call ca_set_castro_method_params()\n\n call network_init()\n call actual_rhs_init()\n call burner_init()\n call eos_init()\n\n ! Normally the state indices get loaded in through the main C++ interface,\n ! so we have to hack around that by explicitly setting them here.\n\n NVAR = nv\n URHO = 1\n UTEMP = 2\n UEINT = 3\n UEDEN = 4\n UMX = 5\n UMY = 6\n UMZ = 7\n UFS = 8\n UFX = -1\n\n !$acc update device(URHO, UTEMP, UEINT, UEDEN, UMX, UMY, UMZ, UFS, UFX)\n\n lo = [0, 0, 0]\n hi = [ncell, ncell, ncell]\n w = hi - lo + 1\n\n allocate(state(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3),NVAR))\n allocate(reactions(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3),nspec+2))\n allocate(mask(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3)))\n allocate(weights(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3)))\n\n dlogrho = (log10(dens_max) - log10(dens_min)) \/ w(1)\n dlogT = (log10(temp_max) - log10(temp_min)) \/ w(2)\n\n do k = lo(3), hi(3)\n do j = lo(2), hi(2)\n do i = lo(1), hi(1)\n\n state(i,j,k,:) = ZERO\n\n eos_state % rho = 10.0e0_rt**(log10(dens_min) + dble(i)*dlogrho)\n eos_state % T = 10.0e0_rt**(log10(temp_min) + dble(j)*dlogT )\n eos_state % xn = 1.e-12_rt\n eos_state % xn(1 + INT( (dble(k) \/ w(3)) * nspec)) = ONE - (nspec - 1) * 1.e-12_rt\n\n call eos(eos_input_rt, eos_state)\n\n state(i,j,k,URHO) = eos_state % rho\n state(i,j,k,UTEMP) = eos_state % T\n state(i,j,k,UFS:UFS+nspec-1) = eos_state % rho * eos_state % xn\n state(i,j,k,UEINT) = eos_state % rho * eos_state % e\n state(i,j,k,UEDEN) = eos_state % rho * eos_state % e\n state(i,j,k,UMX:UMZ) = ZERO\n\n mask(i,j,k) = 1\n weights(i,j,k) = 0.0\n\n enddo\n enddo\n enddo\n\n call cpu_time(start)\n\n call ca_react_state(lo, hi, state, lo, hi, reactions, lo, hi, &\n weights, lo, hi, &\n mask, lo, hi, time, dt, 0)\n\n call cpu_time(finish)\n\n print *, 'done!'\n print *, 'execution time = ', finish - start\n print *, 'sum of reactions energy = ', sum(reactions(:,:,:,nspec+1))\n\nend subroutine do_burn\n","avg_line_length":27.4453781513,"max_line_length":94,"alphanum_fraction":0.581139008} {"size":2099,"ext":"for","lang":"FORTRAN","max_stars_count":5.0,"content":" SUBROUTINE DECODE_CONTROL_DATA\n & (input_string,cntrl_string,data_string)\n\nc***********************************************************************\nc subroutine decode_control_data\nc***********************************************************************\n\nc Program Source: Naval Ocean Systems Center - Code 542\n\nc Date:\nc 05 Apr 1990\n\nc Function:\nc Returns a control string and its associated data string.\n\nc Parameters passed:\nc input_string [s] input string: CONTROL DATA\n\nc Parameters returned:\nc cntrl_string [s] output string: CONTROL\nc data_string [s] output string: DATA\n\nc Common blocks referenced:\n\nc Functions and subroutines referenced:\nc len\n\nc References:\n\nc Change History:\n\nc*******************!***************************************************\n\n character input_string*(*),cntrl_string*(*),data_string*(*)\n\n\nc Find the length of the input string\n jl=LEN(input_string)\n do while (input_string(jl:jl) .eq. ' ')\n jl=jl-1\n end do\n\nc Find the end of the control string by starting at the beginning\nc of the string and looking for the first blank character\n jf=1\n do while (input_string(jf:jf) .ne. ' ')\n if (jf .eq. jl) then ! there is only the control string\n cntrl_string=input_string\n nn=LEN(data_string)\n do while (nn .gt. 0)\n data_string(nn:nn)=' '\n nn=nn-1\n end do\n RETURN\n end if\n jf=jf+1\n end do\n cntrl_string=input_string(1:jf)\n\nc Now, find the beginning of the data by looking for the first non-\nc blank location\n do while (input_string(jf:jf) .eq. ' ')\n if (jf .eq. jl) then ! there is no data\n nn=LEN(data_string)\n do while (nn .gt. 0)\n data_string(nn:nn)=' '\n nn=nn-1\n end do\n RETURN\n end if\n jf=jf+1\n end do\n data_string=input_string(jf:jl)\n\n RETURN\n END ! DECODE_CONTROL_DATA\n","avg_line_length":27.2597402597,"max_line_length":72,"alphanum_fraction":0.5221534064} {"size":13168,"ext":"f","lang":"FORTRAN","max_stars_count":13.0,"content":" PROGRAM PRUNOFF\n USE MOD_ZA ! HYCOM array I\/O interface\n IMPLICIT NONE\nC\n INTEGER MXRIV\n PARAMETER (MXRIV=9000)\nC\nC PRECIP ARRAY.\nC\n INTEGER, ALLOCATABLE :: MSK(:,:),ISEA(:,:),JSEA(:,:)\n REAL*4, ALLOCATABLE :: DXDY(:,:)\n REAL*4, ALLOCATABLE :: ROI(:,:),PCM(:,:),DEPTH(:,:)\nC\n CHARACTER PREAMBL(5)*79,CLINE*240\nC\n LOGICAL IGNORE\n INTEGER NSMOOTH,MAXDIST\n NAMELIST\/RUNOFF\/ NSMOOTH,MAXDIST,\n & IGNORE\nC\nC**********\nC*\nC 1) GENERATE A MONTHLY PRECIPITATION BOGAS FIELD\nC PARAMETERIZING RUNOFF INFLOW.\nC\nC 3) NAMELIST INPUT:\nC\nC \/RUNOFF\/\nC NSMOOTH - NUMBER OF SMOOTHING PASSES.\nC MAXDIST - MAXIMUM NUMBER OF GRID POINTS TO MOVE RUNOFF\nC IGNORE - IGNORE \"BAD\" RUNOFF LOCATIONS (DEFAULT .FALSE.)\nC\nC 4) INPUT:\nC ON UNIT 5: NAMELIST \/RTITLE\/, \/RUNOFF\/\nC ON UNIT 11: HYCOM UNMASKED RUNOFF FILE (.[ab])\nC ON UNIT 51: HYCOM BATHYMETRY FILE (.[ab])\nC OUTPUT:\nC ON UNIT 14: HYCOM RUNOFF PRECIP. FILE (.[ab])\nC*\nC**********\nC\n LOGICAL LARCTIC,LPERIOD,LFATAL\n INTEGER I,II,IJD,IJDMAX,IOS,J,JJ,K,MONTH\n REAL*4 X,Y,HMINA,HMINB,HMAXA,HMAXB,XMIN,XMAX\nC\nC ARRAYS.\nC\n CALL XCSPMD\n ALLOCATE( MSK(IDM,JDM) )\n ALLOCATE( ISEA(IDM,JDM) )\n ALLOCATE( JSEA(IDM,JDM) )\n ALLOCATE( DXDY(IDM,JDM) )\n ALLOCATE( ROI(IDM,JDM) )\n ALLOCATE( PCM(IDM,JDM) )\n ALLOCATE( DEPTH(IDM,JDM) )\nC\nC NAMELIST INPUT.\nC\n CALL ZHOPEN(6, 'FORMATTED', 'UNKNOWN', 0)\nC\n IGNORE = .FALSE.\n NSMOOTH = 0\n MAXDIST = 0\n WRITE(6,*) 'READING \/RUNOFF\/'\n CALL ZHFLSH(6)\n READ( 5,RUNOFF)\n WRITE(6,RUNOFF)\n WRITE(6,*)\n CALL ZHFLSH(6)\nC\nC GRID INPUT.\nC\n CALL ZAIOST\nC\n CALL ZHOPNC(21, 'regional.grid.b', 'FORMATTED', 'OLD', 0)\n CALL ZAIOPF('regional.grid.a', 'OLD', 21)\nC\n READ(21,*) ! skip idm\n READ(21,*) ! skip jdm\n READ(21,*) ! skip mapflg\nC\n READ(21,*) ! skip plon\n CALL ZAIOSK(21)\n READ(21,*) ! skip plat\n CALL ZAIOSK(21)\n READ(21,*) ! skip qlon\n CALL ZAIOSK(21)\n READ(21,*) ! skip qlat\n CALL ZAIOSK(21)\n READ(21,*) ! skip ulon\n CALL ZAIOSK(21)\n READ(21,*) ! skip ulat\n CALL ZAIOSK(21)\n READ(21,*) ! skip vlon\n CALL ZAIOSK(21)\n READ(21,*) ! skip vlat\n CALL ZAIOSK(21)\n READ(21,*) ! skip pang\n CALL ZAIOSK(21)\n READ(21,'(A)') CLINE\n I = INDEX(CLINE,'=')\n READ (CLINE(I+1:),*) HMINB,HMAXB\n CALL ZAIORD(PCM, MSK,.FALSE., HMINA,HMAXA, 21)\n IF (ABS(HMINA-HMINB).GT.ABS(HMINB)*1.E-4 .OR.\n & ABS(HMAXA-HMAXB).GT.ABS(HMAXB)*1.E-4 ) THEN\n WRITE(6,'(\/ a \/ a,1p3e14.6 \/ a,1p3e14.6 \/)')\n & 'error - .a and .b grid files not consistent (pscx):',\n & '.a,.b min = ',HMINA,HMINB,HMINA-HMINB,\n & '.a,.b max = ',HMAXA,HMAXB,HMAXA-HMAXB\n CALL ZHFLSH(6)\n STOP\n ENDIF\nC\n READ(21,'(A)') CLINE\n I = INDEX(CLINE,'=')\n READ (CLINE(I+1:),*) HMINB,HMAXB\n CALL ZAIORD(DXDY, MSK,.FALSE., HMINA,HMAXA, 21)\n IF (ABS(HMINA-HMINB).GT.ABS(HMINB)*1.E-4 .OR.\n & ABS(HMAXA-HMAXB).GT.ABS(HMAXB)*1.E-4 ) THEN\n WRITE(6,'(\/ a \/ a,1p3e14.6 \/ a,1p3e14.6 \/)')\n & 'error - .a and .b grid files not consistent (pscy):',\n & '.a,.b min = ',HMINA,HMINB,HMINA-HMINB,\n & '.a,.b max = ',HMAXA,HMAXB,HMAXA-HMAXB\n CALL ZHFLSH(6)\n STOP\n ENDIF\n DXDY(:,:) = PCM(:,:)*DXDY(:,:) !dx*dy\nC\n CLOSE(UNIT=21)\n CALL ZAIOCL(21)\nC\nC TOPOGRAPHY INPUT.\nC\n CALL ZHOPEN(51, 'FORMATTED', 'OLD', 0)\n READ (51,'(A79)') PREAMBL\n READ (51,'(A)') CLINE\n CLOSE(UNIT=51)\n WRITE(6,'(\/(1X,A79))') PREAMBL,CLINE\nC\n I = INDEX(CLINE,'=')\n READ (CLINE(I+1:),*) HMINB,HMAXB\nC\n CALL ZAIOPN('OLD', 51)\n CALL ZAIORD(DEPTH,MSK,.FALSE., HMINA,HMAXA, 51)\n CALL ZAIOCL(51)\nC\n IF (ABS(HMINA-HMINB).GT.ABS(HMINB)*1.E-4 .OR.\n & ABS(HMAXA-HMAXB).GT.ABS(HMAXB)*1.E-4 ) THEN\n WRITE(6,'(\/ a \/ a,1p3e14.6 \/ a,1p3e14.6 \/)')\n & 'error - .a and .b topography files not consistent:',\n & '.a,.b min = ',HMINA,HMINB,HMINA-HMINB,\n & '.a,.b max = ',HMAXA,HMAXB,HMAXA-HMAXB\n CALL ZHFLSH(6)\n STOP\n ENDIF\nC\nC INITIALIZE LAND\/SEA MASK AND LOCATION OF NEAREST COASTLINE.\nC\n DO J= 1,JDM\n DO I= 1,IDM\n IF (DEPTH(I,J).GT. 0.0 .AND.\n & DEPTH(I,J).LE.HMAXA ) THEN\n MSK(I,J) = 1\n ELSE\n MSK(I,J) = 0\n ENDIF\n ISEA(I,J) = 0\n JSEA(I,J) = 0\n ENDDO\n ENDDO\nC\nC CHECK FOR AN ARCTIC BIPOLAR PATCH\nC\n LARCTIC = MAXVAL(MSK(:,JDM)).EQ.1 !open top boundary\n LPERIOD = MAXVAL(MSK(IDM,:)).EQ.1 !open right boundary\nC\n WRITE(6,*)\n WRITE(6,*) 'LPERIOD = ',LPERIOD\n WRITE(6,*) 'LARCTIC = ',LARCTIC\n WRITE(6,*)\n CALL ZHFLSH(6)\nC\nC INITIALIZE OUTPUT.\nC\n CALL ZAIOPN('OLD', 11)\n CALL ZAIOPN('NEW', 14)\nC\n CALL ZHOPEN(11, 'FORMATTED', 'OLD', 0)\n CALL ZHOPEN(14, 'FORMATTED', 'NEW', 0)\nC\n READ( 11,'(A79)') PREAMBL\n WRITE(PREAMBL(5),'(I4,A)') NSMOOTH,' smoothing passes.'\n WRITE(14,4101) PREAMBL\n WRITE(6,*)\n WRITE(6, 4101) PREAMBL\n WRITE(6,*)\n CALL ZHFLSH(6)\nC\nC LOOP THROUGH ALL MONTHS.\nC\n IJDMAX = 0\n DO MONTH= 1,HUGE(MONTH)\n READ( 11, '(A)',IOSTAT=IOS) CLINE\n IF (IOS.NE.0) THEN\n EXIT\n ENDIF\n CALL ZAIORD(ROI,MSK,.FALSE., XMIN,XMAX, 11)\nC\n DO J= 1,JDM\n DO I= 1,IDM\n PCM(I,J) = 0.0\n ENDDO\n ENDDO\nC\n LFATAL = .FALSE.\n DO J= 1,JDM\n DO I= 1,IDM\n IF (ROI(I,J).EQ.0.0) THEN\n CYCLE !nothing to do\n ENDIF\n IF (MSK(I,J).NE.1) THEN\n IF (ISEA(I,J).EQ.0) THEN\nC\nC FIND A CLOSE SEA POINT, IF THERE IS ONE.\nC\n IJD = MAXDIST**2 + 1\n DO K= 1,MAXDIST\n IF (IJD.LT.K**2) THEN\n EXIT\n ENDIF !early exit\n DO II= MAX(I-K,1),MIN(I+K,IDM)\n JJ=MAX(J-K,1)\n IF (MSK(II,JJ).EQ.1) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n JJ=MIN(J+K,JDM)\n IF (MSK(II,JJ).EQ.1) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n ENDDO !ii\n DO JJ= MAX(J-K+1,1),MIN(J+K-1,JDM)\n II=MAX(I-K,1)\n IF (MSK(II,JJ).EQ.1) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n II=MIN(I+K,IDM)\n IF (MSK(II,JJ).EQ.1) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n ENDDO !jj\n ENDDO !k\n ENDIF !ISEA==0\n IF (ISEA(I,J).NE.0) THEN\n II = ISEA(I,J)\n JJ = JSEA(I,J)\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n IF (IJD.GT.IJDMAX) THEN\n IJDMAX = IJD\n WRITE(6,'(a,2i6,f12.2)')\n & 'I,J,DIST =',I,J,SQRT(REAL(IJD))\n ENDIF\n PCM(II,JJ) = PCM(II,JJ) + ROI(I,J)*DXDY(I,J)\n ROI(I, J ) = 0.0\n ELSE\n WRITE(6,*) \"can't move land point\",i,j,\" to the coast\"\n LFATAL = .TRUE.\n II = ISEA(I,J)\n JJ = JSEA(I,J)\n ENDIF !ISEA\/=0\n ELSE !MSK(I,J).EQ.1\n IF (MINVAL(MSK(MAX(I-1,1):MIN(I+1,IDM),\n & MAX(J-1,1):MIN(J+1,JDM) )).NE.0) THEN\n IF (ISEA(I,J).EQ.0) THEN\nC\nC FIND A SEA POINT CLOSER TO LAND, IF THERE IS ONE.\nC\n IJD = MAXDIST**2 + 1\n DO K= 1,MAXDIST\n IF (IJD.LT.K**2) THEN\n EXIT\n ENDIF !early exit\n DO II= MAX(I-K,1),MIN(I+K,IDM)\n JJ=MAX(J-K,1)\n IF (MSK(II,JJ).EQ.1 .AND.\n & MINVAL(MSK(MAX(II-1,1):MIN(II+1,IDM),\n & MAX(JJ-1,1):MIN(JJ+1,JDM) ))\n & .EQ.0) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n JJ=MIN(J+K,JDM)\n IF (MSK(II,JJ).EQ.1 .AND.\n & MINVAL(MSK(MAX(II-1,1):MIN(II+1,IDM),\n & MAX(JJ-1,1):MIN(JJ+1,JDM) ))\n & .EQ.0) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n ENDDO !ii\n DO JJ= MAX(J-K+1,1),MIN(J+K-1,JDM)\n II=MAX(I-K,1)\n IF (MSK(II,JJ).EQ.1 .AND.\n & MINVAL(MSK(MAX(II-1,1):MIN(II+1,IDM),\n & MAX(JJ-1,1):MIN(JJ+1,JDM) ))\n & .EQ.0) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n II=MIN(I+K,IDM)\n IF (MSK(II,JJ).EQ.1 .AND.\n & MINVAL(MSK(MAX(II-1,1):MIN(II+1,IDM),\n & MAX(JJ-1,1):MIN(JJ+1,JDM) ))\n & .EQ.0) THEN\n IF ((I-II)**2+(J-JJ)**2.LT.IJD) THEN\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n ISEA(I,J) = II\n JSEA(I,J) = JJ\n ENDIF\n ENDIF\n ENDDO !jj\n ENDDO !k\n ENDIF !isea==0\n IF (ISEA(I,J).EQ.0) THEN !no better sea point\n ISEA(I,J) = I\n JSEA(I,J) = J\n ENDIF !isea==0\n ELSE !sea next to land\n ISEA(I,J) = I\n JSEA(I,J) = J\n ENDIF !sea away from land:else\n II = ISEA(I,J)\n JJ = JSEA(I,J)\n IJD = (I-II)**2+(J-JJ)**2 !distance squared to I,J\n IF (IJD.GT.IJDMAX) THEN\n IJDMAX = IJD\n WRITE(6,'(a,2i6,f12.2)')\n & 'I,J,DIST =',I,J,SQRT(REAL(IJD))\n ENDIF\n PCM(II,JJ) = PCM(II,JJ) + ROI(I,J)*DXDY(I,J)\n ROI(I, J ) = 0.0\n ENDIF !msk.ne.1:else\n ENDDO !j\n ENDDO !i\nC\n IF (LFATAL .AND. .NOT.IGNORE) THEN\n WRITE(6,*) \n CALL ZHFLSH(6)\n STOP\n ENDIF\nC\nC SMOOTH POINT SOURCES OVER NEARBY OCEAN.\nC\n CALL SMOOTH1(PCM,MSK,IDM,JDM, 1,NSMOOTH,\n & LPERIOD,LARCTIC,.FALSE.)\n DO J= 1,JDM\n DO I= 1,IDM\n PCM(I,J) = PCM(I,J)\/DXDY(I,J)\n ENDDO\n ENDDO\nC\nC WRITE OUT HYCOM PRECIP.\nC\n CALL ZAIOWR(PCM,MSK,.FALSE., XMIN,XMAX, 14, .FALSE.)\n I = INDEX(CLINE,'=') + 4\n WRITE(14,'(A,1P2E16.7)') CLINE(1:I),XMIN,XMAX\n WRITE( 6,'(A,1P2E16.7)') CLINE(1:I),XMIN,XMAX\n CALL ZHFLSH(6)\n ENDDO !months\nC\n CALL ZAIOCL(14)\n CLOSE( UNIT=14)\n STOP\nC\n 4101 FORMAT(A79)\nC END OF PROGRAM PRUNOFF.\n END\n","avg_line_length":32.7562189055,"max_line_length":79,"alphanum_fraction":0.409781288} {"size":5056,"ext":"f90","lang":"FORTRAN","max_stars_count":15.0,"content":"! Copyright 2012-2018, University of Strathclyde\n! Authors: Lawrence T. Campbell\n! License: BSD-3-Clause\n\n!> @author\n!> Lawrence Campbell, Cynthia Nam\n!> University of Strathclyde, \n!> Glasgow, UK\n!> @brief\n!> Module to calculate the error function\n\nMODULE error_fn\n\nUSE typesAndConstants\nUSE nrutil\n\nIMPLICIT NONE\nCONTAINS\n\n!********************************************************\n!*+*Return the error function*+*!\n\nFUNCTION erf(x)\n\n IMPLICIT NONE\n\n REAL(KIND=WP),INTENT(IN) :: x\n REAL(KIND=WP) :: erf\n\n erf=gammp(0.5_WP,x**2)\n\n IF (x<0.0) erf=-erf\n\nEND FUNCTION erf\n!********************************************************\n!*+*Return the complementary error function*+*!\n\nFUNCTION erfc(x)\n\n IMPLICIT NONE\n\n REAL(KIND=WP),INTENT(IN) :: x\n REAL(KIND=WP)\t\t :: erfc\n\n erfc=merge(1.0_WP+gammp(0.5_WP,x**2),gammq(0.5_WP,x**2),x<0.0)\n\nEND FUNCTION erfc\n!********************************************************\n\nFUNCTION erfi(Y)\t\t\t\n!-----------------------\n! Inverse error function\n!-----------------------\n REAL(KIND=WP),INTENT(IN) :: Y\n REAL(KIND=WP)\t\t :: erfi\n \n!---\n! constants and parameters\n!---\n INTEGER(KIND=IP) :: maxit, iter\n REAL(KIND=WP) :: eps\n REAL(KIND=WP) :: const\n REAL(KIND=WP) :: Y0, Y1, DY0, DY1\n REAL(KIND=WP) :: Derfi\n\n maxit = 20_IP\n eps = 0.0000001_WP\n const = sqrt(pi)\/2.0_WP \n\n!---\n! very small value\n!---\n\n If(abs(Y).LE.eps) then\n erfi = Const*Y\n iter = 1_IP\n Return\n End If\n\n!---\n! Newton iterations\n!---\n\n If(abs(Y).LT.1.0_WP) then\n\n erfi = const*abs(Y)\n Y0 = ERF(0.9_WP*ERFI)\n Derfi = 0.1_WP*erfi\n\n Do iter=1,maxit\n Y1 = 1.0_WP - erfc(erfi)\n DY1 = abs(Y) - Y1\n If (abs(DY1).LT.eps) Go to 99\n DY0 = Y1 - Y0\n Derfi = Derfi*DY1\/DY0\n Y0 = Y1\n erfi = erfi + Derfi\n If(abs(Derfi\/erfi).LT.eps) Go to 99\n End Do\n\n End If\n\n!-----------\n! unfeasible\n!-----------\n\n Iter = 0_IP ! Did not converge\n erfi = 0.0_WP\n\n Return\n\n 99 Continue\n\n If(Y.LT.0.0_WP) erfi = -erfi\n\n!-----\n! Done\n!-----\n Return\nEnd Function erfi\n!********************************************************\n\nFUNCTION gammp(a,x)\n\n IMPLICIT NONE\n\n REAL(KIND=WP),INTENT(IN)\t\t\t:: a,x\n REAL(KIND=WP)\t\t\t\t\t:: gammp\n\n CALL assert(x>=0.0, a>0.0,'gammp args')\n\n IF (x=0.0, a>0.0,'gammq args')\n\n IF (x ITMAX) CALL nrerror('A too large,ITMAX too small in GSER')\n\n IF (present(GLN)) THEN\n\n GLN=gammln(A)\n gser_s=SUMM*EXP(-X+A*LOG(X)-GLN)\n ELSE\n gser_s=SUMM*EXP(-X+A*LOG(X)-gammln(A))\n ENDIF\n\nEND FUNCTION gser_s\n!********************************************************\n\nFUNCTION gcf(a,x,gln)\n\n REAL(KIND=WP),INTENT(IN)\t\t\t:: a,x\n REAL(KIND=WP),OPTIONAL,INTENT(OUT)\t\t:: gln\n REAL(KIND=WP)\t\t\t\t\t:: gcf,EPS,FPMIN\n REAL(KIND=WP)\t\t\t\t\t:: an,b,c,d,del,h\n INTEGER(KIND=IP)\t\t\t\t:: ITMAX,i\n\n ITMAX=100_IP\n EPS=epsilon(x)\n FPMIN=tiny(x)\/EPS\n\n IF (x==0.0_WP) THEN\n gcf=1.0_WP\n RETURN\n ENDIF\n\n b=x+1.0_WP-a\n c=1.0_WP\/FPMIN\n d=1.0_WP\/b\n h=d\n\n DO i=1,ITMAX\n an=-i*(i-a)\n b=b+2.0_WP\n d=an*d+b\n IF (ABS(d) ITMAX) CALL nrerror ('a too large, ITMAX too small in gcf')\n IF (present(gln)) THEN\n gln=gammln(a)\n gcf=EXP(-x+a*log(x)-gln)*h\n ELSE\n gcf=EXP(-x+a*log(x)-gammln(a))*h\n ENDIF\n \nEND FUNCTION gcf\n!********************************************************\n\nFUNCTION gammln(xx)\n\n USE paratype\n\n IMPLICIT NONE\n\n REAL(KIND=WP),INTENT(IN) :: xx\n REAL(KIND=WP) :: gammln,tmp,ser,x,y,stp\n REAL(KIND=WP),DIMENSION(6) :: coef\n \n INTEGER(KIND=IP) :: i\n\n stp=2.5066282746310005_WP\n coef=(\/76.18009172947146_WP,-86.50532032941677_WP,24.01409824083091_WP, &\n -1.231739572450155_WP,0.1208650973866179E-2_WP,-0.5395239384953E-5_WP \/)\n\n IF (xx==0) RETURN\n\n CALL assert(xx > 0.0,'gammln_s arg')\n\n x=xx\n tmp=x+5.5_WP\n tmp=(x+0.5_WP)*log(tmp)-tmp\n ser=1.000000000190015_WP\n y=x\n DO i=1,size(coef)\n y=y+1.0_WP\n ser=ser+coef(i)\/y\n ENDDO\n gammln=tmp+log(stp*ser\/x)\n\nEND FUNCTION gammln\n\nEND MODULE error_fn\n","avg_line_length":18.0571428571,"max_line_length":79,"alphanum_fraction":0.5338212025} {"size":878,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"! RUN: %S\/test_errors.sh %s %t %flang_fc1\n! C1003 - can't parenthesize function call returning procedure pointer\nmodule m1\n type :: dt\n procedure(frpp), pointer, nopass :: pp\n end type dt\n contains\n subroutine boring\n end subroutine boring\n function frpp\n procedure(boring), pointer :: frpp\n frpp => boring\n end function frpp\n subroutine tests\n procedure(boring), pointer :: mypp\n type(dt) :: dtinst\n mypp => boring ! legal\n mypp => (boring) ! legal, not a function reference\n !ERROR: A function reference that returns a procedure pointer may not be parenthesized\n mypp => (frpp()) ! C1003\n mypp => frpp() ! legal, not parenthesized\n dtinst%pp => frpp\n mypp => dtinst%pp() ! legal\n !ERROR: A function reference that returns a procedure pointer may not be parenthesized\n mypp => (dtinst%pp())\n end subroutine tests\nend module m1\n","avg_line_length":31.3571428571,"max_line_length":90,"alphanum_fraction":0.6867881549} {"size":1107,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"!==============================================================================!\n subroutine Comm_Mod_Global_Sum_Real(phi) \n!------------------------------------------------------------------------------!\n! Estimates global sum over all processors. !\n!------------------------------------------------------------------------------!\n implicit none\n!---------------------------------[Arguments]----------------------------------!\n real :: phi\n!-----------------------------------[Locals]-----------------------------------!\n real :: phi_new\n integer :: error\n!==============================================================================!\n\n call Mpi_Allreduce(phi, & ! send buffer\n phi_new, & ! recv buffer \n 1, & ! length \n MPI_DOUBLE_PRECISION, & ! datatype \n MPI_SUM, & ! operation \n MPI_COMM_WORLD, & \n error) \n\n phi = phi_new\n\n end subroutine\n","avg_line_length":44.28,"max_line_length":80,"alphanum_fraction":0.2429990967} {"size":12758,"ext":"f90","lang":"FORTRAN","max_stars_count":36.0,"content":"module sst_roe_operator\n use mod_kinds, only: rk,ik\n use mod_constants, only: ZERO,ONE,TWO,THREE,HALF\n use type_operator, only: operator_t\n use type_properties, only: properties_t\n use type_chidg_worker, only: chidg_worker_t\n use DNAD_D\n use ieee_arithmetic, only: ieee_is_nan\n implicit none\n\n\n \n !> Implementation of Roe's approximate Riemann solver.\n !!\n !! The formulation used here is from the reference:\n !! J. Blazek,\"Computational Fluid Dynamics: Principles and Applications\"\n !!\n !! @author Nathan A. Wukie\n !! @date 1\/28\/2016\n !!\n !------------------------------------------------------------------------------\n type, extends(operator_t), public :: sst_roe_operator_t\n\n contains\n\n procedure :: init\n procedure :: compute\n\n end type sst_roe_operator_t\n !*******************************************************************************\n\n\n\n\n\n\n\n\n\n\ncontains\n\n\n !>\n !!\n !! @author Nathan A. Wukie (AFRL)\n !! @date 8\/29\/2016\n !!\n !--------------------------------------------------------------------------------\n subroutine init(self)\n class(sst_roe_operator_t), intent(inout) :: self\n\n ! Set operator name\n call self%set_name(\"SST Roe Flux\")\n\n ! Set operator type\n call self%set_operator_type(\"Boundary Advective Flux\")\n\n ! Set operator equations\n call self%add_primary_field(\"Density\" )\n call self%add_primary_field(\"Momentum-1\")\n call self%add_primary_field(\"Momentum-2\")\n call self%add_primary_field(\"Momentum-3\")\n call self%add_primary_field(\"Energy\" )\n call self%add_primary_field(\"Density * k\" )\n call self%add_primary_field(\"Density * Omega\" )\n\n end subroutine init\n !********************************************************************************\n\n\n\n\n !> Compute Roe approximate Riemann upwind flux\n !! \n !! @author Nathan A. Wukie\n !! @date 1\/28\/2016\n !!\n !!---------------------------------------------------------------------------\n subroutine compute(self,worker,prop)\n class(sst_roe_operator_t), intent(inout) :: self\n type(chidg_worker_t), intent(inout) :: worker\n class(properties_t), intent(inout) :: prop\n\n\n ! Storage at quadrature nodes\n type(AD_D), allocatable, dimension(:) :: &\n density_m, density_p, &\n mom1_m, mom1_p, &\n mom2_m, mom2_p, &\n mom3_m, mom3_p, &\n energy_m, energy_p, &\n enthalpy_m, enthalpy_p, &\n k_m, k_p, &\n invdensity_m, invdensity_p, &\n p_m, p_p, &\n un_m, un_p, &\n rtil, util, vtil, wtil, vmagtil, Htil, ctil, qtil2, &\n C1, C2_a, C2_b, C3, &\n u_m, v_m, w_m, &\n u_p, v_p, w_p, &\n vmag_p, vmag_m, &\n delr, delp, delvmag, delu, delv, delw, &\n lamda1, lamda2, lamda3, &\n sqrt_rhom, sqrt_rhop, sqrt_rhom_plus_rhop, ctil2, upwind, ktil, cturb, cturb2, &\n norm_1, norm_2, norm_3, &\n unorm_1, unorm_2, unorm_3, &\n unorm_1_ale, unorm_2_ale, unorm_3_ale, &\n r, grid_vel_n\n\n real(rk), allocatable, dimension(:) :: ale_area_ratio\n real(rk), allocatable, dimension(:,:) :: grid_vel\n real(rk) :: eps\n\n\n grid_vel = worker%get_grid_velocity_face('face interior')\n ale_area_ratio = worker%get_area_ratio()\n\n\n !\n ! Interpolate solution to quadrature nodes\n !\n density_m = worker%get_field('Density' , 'value', 'face interior')\n density_p = worker%get_field('Density' , 'value', 'face exterior')\n\n mom1_m = worker%get_field('Momentum-1', 'value', 'face interior')\n mom1_p = worker%get_field('Momentum-1', 'value', 'face exterior')\n\n mom2_m = worker%get_field('Momentum-2', 'value', 'face interior')\n mom2_p = worker%get_field('Momentum-2', 'value', 'face exterior')\n\n mom3_m = worker%get_field('Momentum-3', 'value', 'face interior')\n mom3_p = worker%get_field('Momentum-3', 'value', 'face exterior')\n\n energy_m = worker%get_field('Energy' , 'value', 'face interior')\n energy_p = worker%get_field('Energy' , 'value', 'face exterior')\n\n\n\n k_m = worker%get_field('k' , 'value', 'face interior')\n k_p = worker%get_field('k' , 'value', 'face exterior')\n\n !\n ! Account for cylindrical. Get tangential momentum from angular momentum.\n !\n if (worker%coordinate_system() == 'Cylindrical') then\n r = worker%coordinate('1','face interior') \n mom2_m = mom2_m \/ r\n mom2_p = mom2_p \/ r\n end if\n\n\n\n norm_1 = worker%normal(1)\n norm_2 = worker%normal(2)\n norm_3 = worker%normal(3)\n\n unorm_1 = worker%unit_normal(1)\n unorm_2 = worker%unit_normal(2)\n unorm_3 = worker%unit_normal(3)\n\n !\n ! Account for cylindrical. Get tangential momentum from angular momentum.\n !\n if (worker%coordinate_system() == 'Cylindrical') then\n r = worker%coordinate('1','face interior') \n mom2_m = mom2_m \/ r\n mom2_p = mom2_p \/ r\n end if\n\n\n\n norm_1 = worker%normal(1)\n norm_2 = worker%normal(2)\n norm_3 = worker%normal(3)\n\n unorm_1 = worker%unit_normal(1)\n unorm_2 = worker%unit_normal(2)\n unorm_3 = worker%unit_normal(3)\n\n !\n ! Account for cylindrical. Get tangential momentum from angular momentum.\n !\n if (worker%coordinate_system() == 'Cylindrical') then\n r = worker%coordinate('1','face interior') \n mom2_m = mom2_m \/ r\n mom2_p = mom2_p \/ r\n end if\n\n\n\n norm_1 = worker%normal(1)\n norm_2 = worker%normal(2)\n norm_3 = worker%normal(3)\n\n unorm_1 = worker%unit_normal(1)\n unorm_2 = worker%unit_normal(2)\n unorm_3 = worker%unit_normal(3)\n\n unorm_1_ale = worker%unit_normal_ale(1)\n unorm_2_ale = worker%unit_normal_ale(2)\n unorm_3_ale = worker%unit_normal_ale(3)\n\n\n\n\n !\n ! Compute pressure and gamma\n !\n p_m = worker%get_field('Pressure', 'value', 'face interior')\n p_p = worker%get_field('Pressure', 'value', 'face exterior')\n\n invdensity_m = ONE\/density_m\n invdensity_p = ONE\/density_p\n\n !\n ! Compute enthalpy\n !\n enthalpy_m = (energy_m + p_m)*invdensity_m\n enthalpy_p = (energy_p + p_p)*invdensity_p\n\n\n !\n ! Compute velocity components\n !\n u_m = mom1_m*invdensity_m \n v_m = mom2_m*invdensity_m \n w_m = mom3_m*invdensity_m \n vmag_m = u_m*unorm_1_ale + v_m*unorm_2_ale + w_m*unorm_3_ale\n\n u_p = mom1_p*invdensity_p \n v_p = mom2_p*invdensity_p \n w_p = mom3_p*invdensity_p \n vmag_p = u_p*unorm_1_ale + v_p*unorm_2_ale + w_p*unorm_3_ale\n\n\n !\n ! Compute Roe-averaged variables\n !\n sqrt_rhom = sqrt(density_m)\n sqrt_rhop = sqrt(density_p)\n sqrt_rhom_plus_rhop = sqrt_rhom + sqrt_rhop\n rtil = sqrt(density_p * density_m) ! Roe-averaged density\n util = (sqrt_rhom*u_m + sqrt_rhop*u_p ) \/ (sqrt_rhom_plus_rhop) ! Roe-averaged u-velocity\n vtil = (sqrt_rhom*v_m + sqrt_rhop*v_p ) \/ (sqrt_rhom_plus_rhop) ! Roe-averaged v-velocity\n wtil = (sqrt_rhom*w_m + sqrt_rhop*w_p ) \/ (sqrt_rhom_plus_rhop) ! Roe-averaged w-velocity\n Htil = (sqrt_rhom*enthalpy_m + sqrt_rhop*enthalpy_p) \/ (sqrt_rhom_plus_rhop) ! Roe-averaged Enthalpy\n\n vmagtil = util*unorm_1_ale + vtil*unorm_2_ale + wtil*unorm_3_ale ! Magnitude of Roe-averaged velocity in the face normal direction\n qtil2 = util**TWO + vtil**TWO + wtil**TWO\n\n\n !& HARDCODED GAMMA\n ctil = sqrt((1.4_rk - ONE)*(Htil - HALF*qtil2)) ! Roe-averaged speed of sound\n ctil2 = ctil**TWO\n\n ! Compute Roe-averaged k\n ktil = (sqrt_rhom*k_m + sqrt_rhop*k_p) \/ (sqrt_rhom_plus_rhop)\n\n ! Compute turbulent speed of sound\n cturb2 = ctil2 + (TWO\/THREE)*1.4_rk*ktil\n ctil = sqrt(cturb2)\n ctil2 = cturb2\n\n\n !\n ! Compute jump terms\n !\n delr = (density_m - density_p)\n delu = (u_m - u_p)\n delv = (v_m - v_p)\n delw = (w_m - w_p)\n delvmag = (vmag_m - vmag_p)\n delp = (p_m - p_p)\n\n\n !\n ! Limit wave speeds for entropy fix\n !\n !lamda1 = abs(vmagtil - ctil) + sqrt(grid_vel(:,1)**TWO+grid_vel(:,2)**TWO+grid_vel(:,3)**TWO)\n !lamda2 = abs(vmagtil) + sqrt(grid_vel(:,1)**TWO+grid_vel(:,2)**TWO+grid_vel(:,3)**TWO)\n !lamda3 = abs(vmagtil + ctil) + sqrt(grid_vel(:,1)**TWO+grid_vel(:,2)**TWO+grid_vel(:,3)**TWO)\n\n grid_vel_n = grid_vel(:,1)*unorm_1_ale + grid_vel(:,2)*unorm_2_ale + grid_vel(:,3)*unorm_3_ale\n lamda1 = abs(vmagtil + grid_vel_n - ctil)\n lamda2 = abs(vmagtil + grid_vel_n)\n lamda3 = abs(vmagtil + grid_vel_n + ctil)\n\n eps = 0.01_rk\n where ( (-eps*ctil < lamda1) .and. (lamda1 < eps*ctil) )\n lamda1 = HALF*(eps*ctil + lamda1*lamda1\/(eps*ctil))\n else where\n lamda1 = sqrt(lamda1*lamda1)\n end where\n\n where ( (-eps*ctil < lamda2) .and. (lamda2 < eps*ctil) )\n lamda2 = HALF*(eps*ctil + lamda2*lamda2\/(eps*ctil))\n else where\n lamda2 = sqrt(lamda2*lamda2)\n end where\n\n where ( (-eps*ctil < lamda3) .and. (lamda3 < eps*ctil) )\n lamda3 = HALF*(eps*ctil + lamda3*lamda3\/(eps*ctil))\n else where\n lamda3 = sqrt(lamda3*lamda3)\n end where\n\n\n\n\n\n C1 = abs(lamda1)*( delp - rtil*ctil*delvmag)\/(TWO*(ctil2))\n C2_a = abs(lamda2)*(delr - delp\/(ctil2))\n C2_b = abs(lamda2)*rtil\n C3 = abs(lamda3)*( delp + rtil*ctil*delvmag)\/(TWO*(ctil2))\n\n\n\n !================================\n ! Mass flux\n !================================\n upwind = HALF*(C1 + C2_a + C3)\n\n call worker%integrate_boundary_upwind('Density',upwind)\n\n\n !================================\n ! Momentum-1 flux\n !================================\n upwind = HALF*(C1*(util - ctil*unorm_1_ale) + C2_a*util + C2_b*(delu - delvmag*unorm_1_ale) + C3*(util + ctil*unorm_1_ale))\n\n call worker%integrate_boundary_upwind('Momentum-1',upwind)\n\n\n !================================\n ! Momentum-2 flux\n !================================\n upwind = HALF*(C1*(vtil - ctil*unorm_2_ale) + C2_a*vtil + C2_b*(delv - delvmag*unorm_2_ale) + C3*(vtil + ctil*unorm_2_ale))\n\n ! Convert to tangential to angular momentum flux\n if (worker%coordinate_system() == 'Cylindrical') then\n upwind = upwind * r\n end if\n\n call worker%integrate_boundary_upwind('Momentum-2',upwind)\n\n !================================\n ! Momentum-3 flux\n !================================\n upwind = HALF*(C1*(wtil - ctil*unorm_3_ale) + C2_a*wtil + C2_b*(delw - delvmag*unorm_3_ale) + C3*(wtil + ctil*unorm_3_ale))\n\n call worker%integrate_boundary_upwind('Momentum-3',upwind)\n\n !================================\n ! Energy flux\n !================================\n upwind = HALF*(C1*(Htil - ctil*vmagtil) + C2_a*(qtil2\/TWO) + C2_b*(util*delu + vtil*delv + wtil*delw - vmagtil*delvmag) + C3*(Htil + ctil*vmagtil))\n\n call worker%integrate_boundary_upwind('Energy',upwind)\n\n\n end subroutine compute\n !**********************************************************************************************\n\n\n\n\n\n\n\n\n\n\n\n\n\nend module sst_roe_operator\n","avg_line_length":33.7513227513,"max_line_length":161,"alphanum_fraction":0.499608089} {"size":3699,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"!\n! CalculiX - A 3-dimensional finite element program\n! Copyright (C) 1998-2021 Guido Dhondt\n!\n! This program is free software; you can redistribute it and\/or\n! modify it under the terms of the GNU General Public License as\n! published by the Free Software Foundation(version 2);\n! \n!\n! This program is distributed in the hope that it will be useful,\n! but WITHOUT ANY WARRANTY; without even the implied warranty of \n! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n! GNU General Public License for more details.\n!\n! You should have received a copy of the GNU General Public License\n! along with this program; if not, write to the Free Software\n! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n!\n subroutine extrapolate_d_v_simplec(ielfa,xrlfa,adv,advfa,\n & hfa,icyclic,c,ifatie,vel,nef,volume,\n & auv,ipnei,nfacea,nfaceb,ncfd)\n!\n! inter\/extrapolation of volume\/adv at the center of the elements\n! to the center of the faces\n!\n! inter\/extrapolation of v* at the center of the elements \n! to the center of the faces; \n!\n implicit none\n!\n integer ielfa(4,*),iel1,iel2,iel3,i,j,icyclic,ifatie(*),\n & nef,ipnei(*),indexf,nfacea,nfaceb,ncfd\n!\n real*8 xrlfa(3,*),xl1,xl2,advfa(*),adv(*),vel(nef,0:7),hfa(3,*),\n & c(3,3),volume(*),auv(*),a1,a2,a3\n!\n!\n! \n do i=nfacea,nfaceb\n iel1=ielfa(1,i)\n xl1=xrlfa(1,i)\n iel2=ielfa(2,i)\n if(iel2.gt.0) then\n!\n! internal face\n!\n xl2=xrlfa(2,i)\n!\n a1=adv(iel1)\n do indexf=ipnei(iel1)+1,ipnei(iel1+1)\n a1=a1+auv(indexf)\n enddo\n!\n a2=adv(iel2)\n do indexf=ipnei(iel2)+1,ipnei(iel2+1)\n a2=a2+auv(indexf)\n enddo\n!\n advfa(i)=xl1*volume(iel1)\/a1\n & +xl2*volume(iel2)\/a2\n!\n if((icyclic.eq.0).or.(ifatie(i).eq.0)) then\n do j=1,ncfd\n hfa(j,i)=(xl1*vel(iel1,j)\n & +xl2*vel(iel2,j))\n enddo\n elseif(ifatie(i).gt.0) then\n do j=1,ncfd\n hfa(j,i)=(xl1*vel(iel1,j)\n & +xl2*(c(j,1)*vel(iel2,1)+\n & c(j,2)*vel(iel2,2)+\n & c(j,3)*vel(iel2,3)))\n enddo\n else\n do j=1,ncfd\n hfa(j,i)=(xl1*vel(iel1,j)\n & +xl2*(c(1,j)*vel(iel2,1)+\n & c(2,j)*vel(iel2,2)+\n & c(3,j)*vel(iel2,3)))\n enddo\n endif\n elseif(ielfa(3,i).ne.0) then\n!\n! external face; linear extrapolation\n!\n a1=adv(iel1)\n do indexf=ipnei(iel1)+1,ipnei(iel1+1)\n a1=a1+auv(indexf)\n enddo\n!\n iel3=abs(ielfa(3,i))\n a3=adv(iel3)\n do indexf=ipnei(iel3)+1,ipnei(iel3+1)\n a3=a3+auv(indexf)\n enddo\n!\n advfa(i)=xl1*volume(iel1)\/a1\n & +xrlfa(3,i)*volume(iel3)\/a3\n!\n do j=1,ncfd\n hfa(j,i)=(xl1*vel(iel1,j)+xrlfa(3,i)*vel(iel3,j))\n enddo\n else\n!\n! external face: constant extrapolation (only one adjacent\n! element layer)\n!\n a1=adv(iel1)\n do indexf=ipnei(iel1)+1,ipnei(iel1+1)\n a1=a1+auv(indexf)\n enddo\n!\n advfa(i)=volume(iel1)\/a1\n!\n do j=1,ncfd\n hfa(j,i)=vel(iel1,j)\n enddo\n endif\n enddo\n! \n return\n end\n","avg_line_length":30.0731707317,"max_line_length":71,"alphanum_fraction":0.4936469316} {"size":33511,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"!\n! Copyright 2019-2020 SALMON developers\n!\n! Licensed under the Apache License, Version 2.0 (the \"License\");\n! you may not use this file except in compliance with the License.\n! You may obtain a copy of the License at\n!\n! http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n!\n! Unless required by applicable law or agreed to in writing, software\n! distributed under the License is distributed on an \"AS IS\" BASIS,\n! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n! See the License for the specific language governing permissions and\n! limitations under the License.\n!\n\n#include \"config.h\"\n\nmodule initialization_sub\n implicit none\n integer,parameter,private :: Nd=4\n\ncontains\n\n!===================================================================================================================================\n\nsubroutine init_dft(comm,info,lg,mg,system,stencil,fg,poisson,srg,srg_scalar,ofile)\n use structures\n use salmon_global, only: iperiodic,layout_multipole, &\n nproc_k,nproc_ob,nproc_rgrid\n use sendrecv_grid\n use init_communicator\n use init_poisson_sub\n use checkpoint_restart_sub, only: init_dir_out_restart\n use sym_rho_sub, only: init_sym_rho\n implicit none\n integer ,intent(in) :: comm\n type(s_parallel_info) :: info\n type(s_rgrid) :: lg,mg\n type(s_dft_system) :: system\n type(s_stencil) :: stencil\n type(s_reciprocal_grid) :: fg\n type(s_poisson) :: poisson\n type(s_sendrecv_grid) :: srg,srg_scalar\n type(s_ofile) :: ofile\n !\n integer,dimension(2,3) :: neig\n\n! electron system\n call init_dft_system(lg,system,stencil)\n\n! process distribution\n info%npk = nproc_k\n info%nporbital = nproc_ob\n info%nprgrid = nproc_rgrid\n call init_process_distribution(system,comm,info)\n call init_communicator_dft(comm,info)\n\n! parallelization\n call check_ffte_condition(info,lg)\n call init_grid_parallel(info,lg,mg) ! lg --> mg\n call init_parallel_dft(system,info)\n call create_sendrecv_neig(neig, info) ! neighboring node array\n ! sendrecv_grid object for wavefunction updates\n call init_sendrecv_grid(srg, mg, info%numo*info%numk*system%nspin, info%icomm_rko, neig)\n ! sendrecv_grid object for scalar field updates\n call init_sendrecv_grid(srg_scalar, mg, 1, info%icomm_rko, neig)\n\n! symmetry\n\n call init_sym_rho( lg%num, mg%is, mg%ie, info%icomm_r )\n\n! for Poisson equation\n\n poisson%iterVh = 0 ! Iteration counter\n select case(iperiodic)\n case(0)\n if(layout_multipole==2.or.layout_multipole==3) call make_corr_pole(lg,mg,system,poisson)\n case(3)\n call init_reciprocal_grid(lg,mg,fg,system,info,poisson)\n end select\n call set_ig_bound(lg,mg,poisson)\n\n! output files\n\n call init_dir_out_restart(ofile)\n\nend subroutine init_dft\n\n!===================================================================================================================================\n\nsubroutine init_dft_system(lg,system,stencil)\n use structures\n use lattice\n use salmon_global, only: al_vec1,al_vec2,al_vec3,al,spin,natom,nelem,nstate,iperiodic,num_kgrid,num_rgrid,dl, &\n & nproc_rgrid,Rion,Rion_red,nelec,calc_mode,temperature,projection_option,nelec_spin, &\n & iflag_atom_coor,ntype_atom_coor_reduced,epdir_re1,quiet\n use sym_sub, only: init_sym_sub\n use communication, only: comm_is_root\n use parallelization, only: nproc_id_global\n use occupation_so, only: SPIN_ORBIT_ON, init_occupation_so\n implicit none\n type(s_rgrid) :: lg\n type(s_dft_system) :: system\n type(s_stencil) :: stencil\n !\n integer :: ii,jj\n real(8) :: rsize(3),hgs(3),cnmat(0:12,12),bnmat(4,4)\n\n if(al_vec1(2)==0d0 .and. al_vec1(3)==0d0 .and. al_vec2(1)==0d0 .and. &\n al_vec2(3)==0d0 .and. al_vec3(1)==0d0 .and. al_vec3(2)==0d0) then\n stencil%if_orthogonal = .true.\n if(al(1)*al(2)*al(3)==0d0) then\n if(num_rgrid(1)*num_rgrid(2)*num_rgrid(3)==0 .or. dl(1)*dl(2)*dl(3)==0d0) then\n stop \"error: invalid cell\"\n end if\n al = dl * dble(num_rgrid)\n end if\n system%primitive_a = 0d0\n system%primitive_a(1,1) = al(1)\n system%primitive_a(2,2) = al(2)\n system%primitive_a(3,3) = al(3)\n rsize = al\n else\n stencil%if_orthogonal = .false.\n system%primitive_a(1:3,1) = al_vec1\n system%primitive_a(1:3,2) = al_vec2\n system%primitive_a(1:3,3) = al_vec3\n rsize(1) = sqrt(sum(al_vec1**2))\n rsize(2) = sqrt(sum(al_vec2**2))\n rsize(3) = sqrt(sum(al_vec3**2))\n end if\n\n if(sum(abs(dl)) == 0d0) then\n hgs(1:3) = rsize(1:3) \/ dble(num_rgrid(1:3))\n else\n hgs(1:3) = dl(1:3)\n end if\n call init_grid_whole(rsize,hgs,lg)\n system%hgs = hgs\n system%ngrid = lg%num(1) * lg%num(2) * lg%num(3)\n\n call init_lattice(system,stencil)\n call init_sym_sub( system%primitive_a, system%primitive_b )\n call init_kvector(num_kgrid,system)\n\n if(calc_mode=='RT') then\n system%if_real_orbital = .false.\n else if(calc_mode=='GS') then\n select case(iperiodic)\n case(0)\n system%if_real_orbital = .true.\n case(3)\n if(num_kgrid(1)*num_kgrid(2)*num_kgrid(3)==1 .and. stencil%if_orthogonal) then\n system%if_real_orbital = .true.\n else\n system%if_real_orbital = .false.\n end if\n if ( SPIN_ORBIT_ON ) system%if_real_orbital=.false.\n end select\n end if\n if ((.not. quiet) .and. comm_is_root(nproc_id_global)) then\n write(*,*) \" use of real value orbitals = \", system%if_real_orbital\n endif\n\n system%nion = natom\n\n if(spin=='unpolarized') then\n system%nspin=1\n else if(spin=='polarized') then\n system%nspin=2\n end if\n\n if(calc_mode=='RT'.and. temperature<-1.d-12)then\n if(projection_option=='no' .or. projection_option=='gx')then !'gx' is hidden option by AY\n if( SPIN_ORBIT_ON )then\n system%no = nelec\n else if(system%nspin==2.and.sum(nelec_spin(:))>0)then\n system%no = maxval(nelec_spin(:))\n else\n if(mod(nelec,2)==0)then\n system%no = nelec\/2\n else\n system%no = (nelec+1)\/2\n end if\n end if\n else if(projection_option=='gs')then\n system%no = nstate\n else\n stop 'wrong projection option'\n endif\n else\n system%no = nstate\n end if\n\n allocate(system%mass(1:nelem))\n if ( allocated(system%Rion) ) deallocate(system%Rion)\n if ( allocated(system%rocc) ) deallocate(system%rocc)\n if ( allocated(system%Velocity) ) deallocate(system%Velocity)\n if ( allocated(system%Force) ) deallocate(system%Force)\n allocate(system%Rion(3,system%nion),system%rocc(system%no,system%nk,system%nspin))\n allocate(system%Velocity(3,system%nion),system%Force(3,system%nion))\n system%Velocity(:,:) =0d0\n\n if(iflag_atom_coor==ntype_atom_coor_reduced) then\n Rion = matmul(system%primitive_a,Rion_red) ! [ a1, a2, a3 ] * R_ion\n end if\n system%Rion = Rion\n\n! initial value of occupation\n system%rocc = 0d0\n if ( SPIN_ORBIT_ON ) then\n call init_occupation_so( system%rocc, nelec )\n else\n select case(system%nspin)\n case(1)\n system%rocc(1:nelec\/2,:,1) = 2d0\n case(2)\n if ( nelec > 0 ) then\n if ( mod(nelec,2) == 0 ) then\n system%rocc(1:nelec\/2,:,1:2) = 1d0\n else\n system%rocc(1:(nelec-1)\/2,:,1:2) = 1d0\n system%rocc((nelec-1)\/2+1,:,1 ) = 1d0\n end if\n else if ( any(nelec_spin>0) ) then\n system%rocc(1:nelec_spin(1),:,1) = 1d0\n system%rocc(1:nelec_spin(2),:,2) = 1d0\n else\n write(*,*) \"nelect or nelec_spin should be specified in input\"\n end if\n end select\n end if\n\n call set_bn(bnmat)\n call set_cn(cnmat)\n if(stencil%if_orthogonal) then\n stencil%coef_lap0 = -0.5d0*cNmat(0,Nd)*(1.d0\/Hgs(1)**2+1.d0\/Hgs(2)**2+1.d0\/Hgs(3)**2)\n else\n if(nproc_rgrid(1)*nproc_rgrid(2)*nproc_rgrid(3)\/=1) &\n stop \"error: nonorthogonal lattice and r-space parallelization\"\n stencil%coef_lap0 = -0.5d0*cNmat(0,Nd)* &\n & ( stencil%coef_F(1)\/Hgs(1)**2 + stencil%coef_F(2)\/Hgs(2)**2 + stencil%coef_F(3)\/Hgs(3)**2 )\n end if\n do jj=1,3\n do ii=1,4\n stencil%coef_lap(ii,jj) = cnmat(ii,4)\/hgs(jj)**2\n stencil%coef_nab(ii,jj) = bnmat(ii,4)\/hgs(jj)\n end do\n end do\n\n call set_gridcoordinate(lg,system)\n\n system%vec_Ac = 0d0 ! initial value\n\n system%vec_Ac_ext = 0d0 ! initial value for output\n system%vec_E = 0d0 ! initial value for output\n system%vec_E_ext = 0d0 ! initial value for output\n\n return\nend subroutine init_dft_system\n\n!===================================================================================================================================\n\nsubroutine init_process_distribution(system,icomm1,info)\n use structures, only: s_parallel_info,s_dft_system\n use parallelization, only: nproc_id_global, nproc_group_global\n use salmon_global, only: theory\n use communication, only: comm_is_root,comm_bcast\n use set_numcpu\n implicit none\n type(s_dft_system),intent(in) :: system\n integer, intent(in) :: icomm1 ! Communicator for single DFT system.\n type(s_parallel_info),intent(inout) :: info\n logical :: if_stop\n\n if((info%nporbital + sum(info%nprgrid)) == 0) then\n ! Process distribution is automatically decided by SALMON.\n if (system%ngrid > 16**3) then\n call set_numcpu_general(iprefer_domain_distribution,system%nk,system%no,icomm1,info)\n else\n select case(theory)\n case('dft','dft_band','dft_md','dft2tddft')\n call set_numcpu_general(iprefer_k_distribution,system%nk,system%no,icomm1,info)\n case('tddft_response','tddft_pulse','single_scale_maxwell_tddft','multi_scale_maxwell_tddft')\n call set_numcpu_general(iprefer_orbital_distribution,system%nk,system%no,icomm1,info)\n case default\n stop 'invalid theory @ initialization'\n end select\n end if\n else\n ! Process distribution is explicitly specified by user.\n end if\n\n if (comm_is_root(nproc_id_global)) then\n if_stop = .not. check_numcpu(icomm1, info)\n end if\n call comm_bcast(if_stop, nproc_group_global)\n if (if_stop) stop 'fail: check_numcpu'\n\n#ifdef USE_SCALAPACK\n info%flag_blacs_gridinit = .false.\n#endif\n#ifdef USE_EIGENEXA\n info%flag_eigenexa_init = .false.\n#endif\nend subroutine init_process_distribution\n\n!===================================================================================================================================\n\nsubroutine init_parallel_dft(system,info)\n use structures\n implicit none\n type(s_dft_system),intent(in) :: system\n type(s_parallel_info) :: info\n !\n integer :: io,nproc_k,nproc_ob,nproc_domain_orbital(3),m,na\n\n nproc_k = info%npk\n nproc_ob = info%nporbital\n nproc_domain_orbital = info%nprgrid\n\n! for single-cell calculations\n info%im_s = 1\n info%im_e = 1\n info%numm = 1\n\n! # of k points\n info%ik_s = (info%id_k * system%nk) \/ nproc_k + 1\n info%ik_e = ((info%id_k+1) * system%nk) \/ nproc_k\n info%numk = info%ik_e - info%ik_s + 1\n\n! # of orbitals\n info%io_s = (info%id_o * system%no) \/ nproc_ob + 1\n info%io_e = ((info%id_o+1) * system%no) \/ nproc_ob\n info%numo = info%io_e - info%io_s + 1\n\n allocate(info%io_s_all(0:nproc_ob-1))\n allocate(info%io_e_all(0:nproc_ob-1))\n allocate(info%numo_all(0:nproc_ob-1))\n do m=0,nproc_ob-1\n info%io_s_all(m) = m * system%no \/ nproc_ob + 1\n info%io_e_all(m) = (m+1) * system%no \/ nproc_ob\n info%numo_all(m) = info%io_e_all(m) - info%io_s_all(m) + 1\n end do\n info%numo_max=maxval(info%numo_all(0:nproc_ob-1))\n\n! flags\n info%if_divide_rspace = nproc_domain_orbital(1)*nproc_domain_orbital(2)*nproc_domain_orbital(3).ne.1\n info%if_divide_orbit = nproc_ob.ne.1\n\n! process ID corresponding to the orbital index io\n if ( allocated(info%irank_io) ) deallocate(info%irank_io)\n allocate(info%irank_io(1:system%no))\n do io=1, system%no\n if(mod(io*nproc_ob,system%no)==0)then\n info%irank_io(io) = io*nproc_ob\/system%no - 1\n else\n info%irank_io(io) = io*nproc_ob\/system%no\n end if\n end do\n\n! #ia: atom index (communicator=info%icomm_ko)\n info%ia_s = int((system%nion * info%id_ko) \/ info%isize_ko) + 1\n info%ia_e = int((system%nion * (info%id_ko + 1)) \/ info%isize_ko)\n na = info%ia_e - info%ia_s + 1\n if (info%id_ko == info%isize_ko-1) info%ia_e = system%nion\n\nend subroutine init_parallel_dft\n\n!===================================================================================================================================\n\nsubroutine init_grid_whole(rsize,hgs,lg)\n use structures, only: s_rgrid\n use salmon_global, only: iperiodic,dl,num_rgrid,theory,al_em,dl_em\n implicit none\n real(8),intent(in) :: rsize(3),hgs(3)\n type(s_rgrid) :: lg\n !\n real(8),parameter :: epsilon=1.d-10\n integer :: j\n\n lg%ndir = 3 ! high symmetry nonorthogonal lattice is not implemented\n lg%nd = Nd\n\n select case(iperiodic)\n case(0)\n lg%ie(:)=int((rsize(:)+epsilon)\/2.d0\/Hgs(:))\n do j=1,3\n if(mod(int(rsize(j)\/Hgs(j)+1.d-12),2)==1)then\n lg%is(j)=-(int((rsize(j)+epsilon)\/2.d0\/Hgs(j)))\n else\n lg%is(j)=-(int((rsize(j)+epsilon)\/2.d0\/Hgs(j)))+1\n end if\n end do\n case(3)\n lg%is(:)=1\n lg%ie(:)=int((rsize(:)+epsilon)\/Hgs(:))\n end select\n lg%num(:)=lg%ie(:)-lg%is(:)+1\n\n lg%is_overlap(1:3) = lg%is(1:3) - Nd\n lg%ie_overlap(1:3) = lg%ie(1:3) + Nd\n lg%is_array(1:3) = lg%is_overlap(1:3)\n lg%ie_array(1:3) = lg%ie_overlap(1:3)\n\n if ( allocated(lg%idx) ) deallocate(lg%idx)\n if ( allocated(lg%idy) ) deallocate(lg%idy)\n if ( allocated(lg%idz) ) deallocate(lg%idz)\n allocate(lg%idx(lg%is_overlap(1):lg%ie_overlap(1)) &\n ,lg%idy(lg%is_overlap(2):lg%ie_overlap(2)) &\n ,lg%idz(lg%is_overlap(3):lg%ie_overlap(3)))\n\n do j=lg%is_overlap(1),lg%ie_overlap(1)\n lg%idx(j) = j\n end do\n do j=lg%is_overlap(2),lg%ie_overlap(2)\n lg%idy(j) = j\n end do\n do j=lg%is_overlap(3),lg%ie_overlap(3)\n lg%idz(j) = j\n end do\n\n select case(theory)\n case('maxwell')\n if( maxval(abs((al_em\/dl_em)-dble(lg%num))) > 1d-4 ) stop \"error: abs((al_em\/dl_em)-dble(lg%num)) is too large\"\n case default\n if(sum(abs(dl)) <= 1d-12) then\n if( maxval(abs(num_rgrid-lg%num)) > 0) stop \"error: num_rgrid \/= lg%num\"\n else\n if( maxval(abs((rsize\/dl)-dble(lg%num))) > 1d-4 ) stop \"error: abs((rsize\/dl)-dble(lg%num)) is too large\"\n end if\n end select\n\n return\nend subroutine init_grid_whole\n\n!===================================================================================================================================\n\nsubroutine check_ffte_condition(info,lg)\n use structures\n use salmon_global, only: yn_ffte\n implicit none\n type(s_parallel_info),intent(in) :: info\n type(s_rgrid), intent(in) :: lg\n integer :: mx,my,mz\n integer :: j,lg_num_tmp,ii\n\n if (yn_ffte == 'y') then\n mx = mod(lg%num(1), info%nprgrid(2))\n my = mod(lg%num(2), info%nprgrid(2))\n if (mx \/= 0 .or. my \/= 0) stop 'Both lg%num(1) and lg%num(2) must be divisible by nproc_domain_orbital(2)'\n\n my = mod(lg%num(2), info%nprgrid(3))\n mz = mod(lg%num(3), info%nprgrid(3))\n if (my \/= 0 .or. mz \/= 0) stop 'Both lg%num(2) and lg%num(3) must be divisible by nproc_domain_orbital(3)'\n\n ! this code treats the situation that lg%num(1:3) is less than or equal to 48,828,125\n do j=1,3\n lg_num_tmp=lg%num(j)\n do ii=1,26\n if(mod(lg_num_tmp,2)==0)then\n lg_num_tmp=lg_num_tmp\/2\n end if\n end do\n\n do ii=1,17\n if(mod(lg_num_tmp,3)==0)then\n lg_num_tmp=lg_num_tmp\/3\n end if\n end do\n\n do ii=1,11\n if(mod(lg_num_tmp,5)==0)then\n lg_num_tmp=lg_num_tmp\/5\n end if\n end do\n\n if(lg_num_tmp\/=1) stop \"When using FFTE, prime factors for number of grids must be combination of 2, 3 or 5.\"\n end do\n end if\nend subroutine check_ffte_condition\n\n!===================================================================================================================================\n\nsubroutine init_grid_parallel(info,lg,mg)\n use communication, only: comm_is_root\n use salmon_global, only: yn_periodic, quiet\n use structures, only: s_rgrid,s_parallel_info\n implicit none\n type(s_parallel_info),intent(in) :: info\n type(s_rgrid), intent(inout) :: lg\n type(s_rgrid), intent(inout) :: mg\n !\n integer :: myrank,nproc,nproc_domain_orbital(3),nproc_k,nproc_ob\n integer :: i1,i2,i3,i4,i5,ibox,j,nsize,npo(3)\n \n myrank = info%id_rko\n nproc = info%isize_rko\n\n nproc_k = info%npk\n nproc_ob = info%nporbital\n nproc_domain_orbital = info%nprgrid\n\n if ( allocated(mg%is_all) ) deallocate(mg%is_all)\n if ( allocated(mg%ie_all) ) deallocate(mg%ie_all)\n allocate(mg%is_all(3,0:nproc-1),mg%ie_all(3,0:nproc-1))\n\n! +-------------------------------+\n! | mg: r-space grid for orbitals |\n! +-------------------------------+\n\n mg%ndir = 3 ! high symmetry nonorthogonal lattice is not implemented\n mg%nd = Nd\n\n do i5=0,nproc_k-1\n do i4=0,nproc_ob-1\n do i3=0,nproc_domain_orbital(3)-1\n do i2=0,nproc_domain_orbital(2)-1\n do i1=0,nproc_domain_orbital(1)-1\n ibox = info%imap(i1,i2,i3,i4,i5)\n npo = [i1,i2,i3]\n do j=1,3\n nsize = (lg%num(j) + nproc_domain_orbital(j) - 1) \/ nproc_domain_orbital(j)\n mg%is_all(j,ibox) = lg%is(j) + nsize * npo(j)\n mg%ie_all(j,ibox) = mg%is_all(j,ibox) + nsize - 1\n if (mg%ie_all(j,ibox) > lg%ie(j)) then\n mg%ie_all(j,ibox) = lg%ie(j)\n end if\n end do\n end do\n end do\n end do\n end do\n end do\n\n mg%is(:) = mg%is_all(:,myrank)\n mg%ie(:) = mg%ie_all(:,myrank)\n\n mg%num(:) = mg%ie(:)-mg%is(:)+1\n\n mg%is_overlap(1:3) = mg%is(1:3)-nd\n mg%ie_overlap(1:3) = mg%ie(1:3)+nd\n\n if ( allocated(mg%idx) ) deallocate(mg%idx)\n if ( allocated(mg%idy) ) deallocate(mg%idy)\n if ( allocated(mg%idz) ) deallocate(mg%idz)\n allocate(mg%idx(mg%is_overlap(1):mg%ie_overlap(1)) &\n ,mg%idy(mg%is_overlap(2):mg%ie_overlap(2)) &\n ,mg%idz(mg%is_overlap(3):mg%ie_overlap(3)))\n\n if(yn_periodic=='y' .and. product(nproc_domain_orbital)==1) then\n if((.not. quiet) .and. comm_is_root(myrank)) &\n & write(*,*) \"r-space parallelization: off\"\n mg%is_array(1:3) = mg%is(1:3)\n mg%ie_array(1:3) = mg%ie(1:3)\n do j=mg%is_overlap(1),mg%ie_overlap(1)\n mg%idx(j) = mod(j+mg%num(1)-1,mg%num(1))+1\n end do\n do j=mg%is_overlap(2),mg%ie_overlap(2)\n mg%idy(j) = mod(j+mg%num(2)-1,mg%num(2))+1\n end do\n do j=mg%is_overlap(3),mg%ie_overlap(3)\n mg%idz(j) = mod(j+mg%num(3)-1,mg%num(3))+1\n end do\n else\n mg%is_array(1:3) = mg%is(1:3)-nd\n mg%ie_array(1:3) = mg%ie(1:3)+nd\n do j=mg%is_overlap(1),mg%ie_overlap(1)\n mg%idx(j) = j\n end do\n do j=mg%is_overlap(2),mg%ie_overlap(2)\n mg%idy(j) = j\n end do\n do j=mg%is_overlap(3),mg%ie_overlap(3)\n mg%idz(j) = j\n end do\n end if\n\n if(mg%num(1) 0d0 .and. G2 > cutoff_G2_emfield) fg%coef_gxgy0(ix,iy,iz) = 0d0\n fg%cos_cGdt(ix,iy,iz) = cos(cspeed_au*sqrt(G2)*dt)\n fg%sin_cGdt(ix,iy,iz) = sin(cspeed_au*sqrt(G2)*dt)\n end if\n\n enddo\n enddo\n enddo\n\n if(yn_ffte=='n') then\n ! discrete Fourier transform (general)\n\n allocate(fg%egx(lg%is(1):lg%ie(1),lg%is(1):lg%ie(1)))\n allocate(fg%egxc(lg%is(1):lg%ie(1),lg%is(1):lg%ie(1)))\n allocate(fg%egy(lg%is(2):lg%ie(2),lg%is(2):lg%ie(2)))\n allocate(fg%egyc(lg%is(2):lg%ie(2),lg%is(2):lg%ie(2)))\n allocate(fg%egz(lg%is(3):lg%ie(3),lg%is(3):lg%ie(3)))\n allocate(fg%egzc(lg%is(3):lg%ie(3),lg%is(3):lg%ie(3)))\n\n allocate(poisson%ff1x(lg%is(1):lg%ie(1),mg%is(2):mg%ie(2),mg%is(3):mg%ie(3)))\n allocate(poisson%ff1y(mg%is(1):mg%ie(1),lg%is(2):lg%ie(2),mg%is(3):mg%ie(3)))\n allocate(poisson%ff1z(mg%is(1):mg%ie(1),mg%is(2):mg%ie(2),lg%is(3):lg%ie(3)))\n allocate(poisson%ff2x(lg%is(1):lg%ie(1),mg%is(2):mg%ie(2),mg%is(3):mg%ie(3)))\n allocate(poisson%ff2y(mg%is(1):mg%ie(1),lg%is(2):lg%ie(2),mg%is(3):mg%ie(3)))\n allocate(poisson%ff2z(mg%is(1):mg%ie(1),mg%is(2):mg%ie(2),lg%is(3):lg%ie(3)))\n\n !$OMP parallel do private(ix,kx,tmp)\n do ix=lg%is(1),lg%ie(1)\n do kx=lg%is(1),lg%ie(1)\n tmp = exp(zI*(2.d0*Pi*dble((ix-1)*(kx-1))\/dble(lg%num(1))))\n fg%egx(kx,ix) = tmp\n fg%egxc(kx,ix) = conjg(tmp)\n end do\n end do\n !$OMP parallel do private(iy,ky,tmp)\n do iy=lg%is(2),lg%ie(2)\n do ky=lg%is(2),lg%ie(2)\n tmp = exp(zI*(2.d0*Pi*dble((iy-1)*(ky-1))\/dble(lg%num(2))))\n fg%egy(ky,iy) = tmp\n fg%egyc(ky,iy) = conjg(tmp)\n end do\n end do\n !$OMP parallel do private(iz,kz,tmp)\n do iz=lg%is(3),lg%ie(3)\n do kz=lg%is(3),lg%ie(3)\n tmp = exp(zI*(2.d0*Pi*dble((iz-1)*(kz-1))\/dble(lg%num(3))))\n fg%egz(kz,iz) = tmp\n fg%egzc(kz,iz) = conjg(tmp)\n end do\n end do\n\n else\n ! FFTE\n\n allocate(poisson%a_ffte(lg%num(1),mg%num(2),mg%num(3)))\n allocate(poisson%b_ffte(lg%num(1),mg%num(2),mg%num(3)))\n\n ! FFTE initialization step\n call PZFFT3DV_MOD(poisson%a_ffte,poisson%b_ffte,lg%num(1),lg%num(2),lg%num(3), &\n info%isize_y,info%isize_z,0, &\n info%icomm_y,info%icomm_z)\n\n end if\n\n allocate(poisson%zrhoG_ele(mg%is(1):mg%ie(1),mg%is(2):mg%ie(2),mg%is(3):mg%ie(3)))\n\n return\nend subroutine init_reciprocal_grid\n\n!===================================================================================================================================\n\nsubroutine set_gridcoordinate(lg,system)\n use structures, only: s_rgrid,s_dft_system\n use salmon_global, only: iperiodic\n implicit none\n type(s_rgrid), intent(inout) :: lg\n type(s_dft_system),intent(in) :: system\n integer :: ix,iy,iz\n\n allocate(lg%coordinate(minval(lg%is_overlap(1:3)):maxval(lg%ie_overlap(1:3)),3))\n\n select case(iperiodic)\n case(0)\n select case(mod(lg%num(1),2))\n case(1)\n!$OMP parallel do\n do ix=lg%is_overlap(1),lg%ie_overlap(1)\n lg%coordinate(ix,1)=dble(ix)*system%hgs(1)\n end do\n case(0)\n!$OMP parallel do\n do ix=lg%is_overlap(1),lg%ie_overlap(1)\n lg%coordinate(ix,1)=(dble(ix)-0.5d0)*system%hgs(1)\n end do\n end select\n\n select case(mod(lg%num(2),2))\n case(1)\n!$OMP parallel do\n do iy=lg%is_overlap(2),lg%ie_overlap(2)\n lg%coordinate(iy,2)=dble(iy)*system%hgs(2)\n end do\n case(0)\n!$OMP parallel do\n do iy=lg%is_overlap(2),lg%ie_overlap(2)\n lg%coordinate(iy,2)=(dble(iy)-0.5d0)*system%hgs(2)\n end do\n end select\n\n select case(mod(lg%num(3),2))\n case(1)\n!$OMP parallel do\n do iz=lg%is_overlap(3),lg%ie_overlap(3)\n lg%coordinate(iz,3)=dble(iz)*system%hgs(3)\n end do\n case(0)\n!$OMP parallel do\n do iz=lg%is_overlap(3),lg%ie_overlap(3)\n lg%coordinate(iz,3)=(dble(iz)-0.5d0)*system%hgs(3)\n end do\n end select\n case(3)\n!$OMP parallel do\n do ix=lg%is_overlap(1),lg%ie_overlap(1)\n lg%coordinate(ix,1)=dble(ix-1)*system%hgs(1)\n end do\n!$OMP parallel do\n do iy=lg%is_overlap(2),lg%ie_overlap(2)\n lg%coordinate(iy,2)=dble(iy-1)*system%hgs(2)\n end do\n!$OMP parallel do\n do iz=lg%is_overlap(3),lg%ie_overlap(3)\n lg%coordinate(iz,3)=dble(iz-1)*system%hgs(3)\n end do\n end select\n\nend subroutine set_gridcoordinate\n\n!===================================================================================================================================\n\nsubroutine init_nion_div(system,lg,mg,info)\n use structures, only: s_dft_system, s_reciprocal_grid, s_rgrid, s_parallel_info\n use communication, only: comm_summation, comm_get_groupinfo, comm_is_root\n !use parallelization, only: nproc_id_global\n implicit none\n type(s_dft_system),intent(in) :: system\n type(s_rgrid) ,intent(in) :: lg\n type(s_rgrid) ,intent(in) :: mg\n type(s_parallel_info) :: info\n !\n logical :: flag_cuboid\n !integer :: k,irank,nproc\n integer :: ia,j,nc,ix,iy,iz,iia,nion_total\n real(8) :: hgs(3), Rion_tmp(3,system%nion), al0(3,3)\n real(8) :: r_mg_min(3), r_mg_max(3), al_min(3), al_max(3), al_len(3)\n\n al0(:,:) = system%primitive_a(:,:)\n if( abs(al0(1,2)).ge.1d-10 .or. &\n abs(al0(1,3)).ge.1d-10 .or. &\n abs(al0(2,3)).ge.1d-10 ) then\n flag_cuboid=.false.\n else\n flag_cuboid = .true.\n endif\n\n\n if(flag_cuboid) then\n\n nc = 2\n hgs(:) = system%hgs(:)\n\n r_mg_min(:) = (mg%is(:)-1) * hgs(:)\n r_mg_max(:) = mg%ie(:) * hgs(:)\n\n al_min(:) = 0d0\n al_max(:) = system%hgs(:)*dble(lg%num(:))\n al_len(:) = al_max(:) - al_min(:)\n\n info%nion_mg = 0\n\n do ia = 1,system%nion\n j=1\n do ix = -nc, nc\n Rion_tmp(j,ia) = system%Rion(j,ia) + ix*al_len(j)\n if( Rion_tmp(j,ia) .ge. al_min(j) .and. Rion_tmp(j,ia) .lt. al_max(j) ) exit\n enddo\n j=2\n do iy = -nc, nc\n Rion_tmp(j,ia) = system%Rion(j,ia) + iy*al_len(j)\n if( Rion_tmp(j,ia) .ge. al_min(j) .and. Rion_tmp(j,ia) .lt. al_max(j) ) exit\n enddo\n j=3\n do iz = -nc, nc\n Rion_tmp(j,ia) = system%Rion(j,ia) + iz*al_len(j)\n if( Rion_tmp(j,ia) .ge. al_min(j) .and. Rion_tmp(j,ia) .lt. al_max(j) ) exit\n enddo\n\n if( (Rion_tmp(1,ia).ge.r_mg_min(1) .and. Rion_tmp(1,ia).lt.r_mg_max(1)) .and. &\n (Rion_tmp(2,ia).ge.r_mg_min(2) .and. Rion_tmp(2,ia).lt.r_mg_max(2)) .and. &\n (Rion_tmp(3,ia).ge.r_mg_min(3) .and. Rion_tmp(3,ia).lt.r_mg_max(3)) ) then\n info%nion_mg = info%nion_mg + 1\n endif\n enddo\n\n allocate( info%ia_mg(info%nion_mg) )\n\n iia = 0\n do ia = 1,system%nion\n if( (Rion_tmp(1,ia).ge.r_mg_min(1) .and. Rion_tmp(1,ia).lt.r_mg_max(1)) .and. &\n (Rion_tmp(2,ia).ge.r_mg_min(2) .and. Rion_tmp(2,ia).lt.r_mg_max(2)) .and. &\n (Rion_tmp(3,ia).ge.r_mg_min(3) .and. Rion_tmp(3,ia).lt.r_mg_max(3)) ) then\n iia = iia + 1\n info%ia_mg(iia) = ia\n endif\n enddo\n\n if( info%nion_mg .ne. iia ) stop \"Error1 in dividing atom in mg domain\"\n\n else !(flag_cuboid=.false.)\n\n ! assuming r-space parallelization is not available in nonorthogonal lattice cell\n info%nion_mg = system%nion\n allocate( info%ia_mg(info%nion_mg) )\n do ia=1,system%nion\n info%ia_mg(ia) = ia\n enddo\n\n endif\n\n !check\n call comm_summation(info%nion_mg, nion_total, info%icomm_r)\n if( nion_total .ne. system%nion ) stop \"Error2 in dividing atom in mg domain\"\n\n !write(*,*) \" #nion_mg=\", system%nion_mg\n !write(*,*) \" #check nion_total=\", nion_total\n\n\n !!(divide nion with all processes: not used now)\n !call comm_get_groupinfo(fg%icomm_G,irank,nproc)\n !\n !if(nproc .le. system%nion) then\n ! k = mod(system%nion,nproc)\n ! if(k==0) then\n ! system%nion_r = system%nion \/ nproc\n ! else\n ! system%nion_r = system%nion \/ nproc + 1\n ! endif\n ! system%nion_s = system%nion_r * irank + 1\n ! system%nion_e = system%nion_s + system%nion_r - 1\n ! if (irank == nproc-1) system%nion_e = system%nion\n ! if (system%nion_e .gt. system%nion) system%nion_e = -1\n ! if (system%nion_s .gt. system%nion) then\n ! system%nion_s = 0\n ! system%nion_e = -1\n ! endif\n !\n !else\n ! if(irank+1.le.system%nion) then\n ! system%nion_s = irank + 1\n ! system%nion_e = system%nion_s\n ! else\n ! system%nion_s = 0\n ! system%nion_e = -1\n ! endif\n !endif\n\nend subroutine init_nion_div\n\n!===================================================================================================================================\n\nsubroutine set_bN(bnmat)\n implicit none\n real(8) :: bnmat(4,4)\n\n bNmat(1,1)=1.d0\/2.d0\n\n bNmat(1,2)=2.d0\/3.d0\n bNmat(2,2)=-1.d0\/12.d0\n\n bNmat(1,3)=3.d0\/4.d0\n bNmat(2,3)=-3.d0\/20.d0\n bNmat(3,3)=1.d0\/60.d0\n\n bNmat(1,4)=4.d0\/5.d0\n bNmat(2,4)=-1.d0\/5.d0\n bNmat(3,4)=4.d0\/105.d0\n bNmat(4,4)=-1.d0\/280.d0\n\nend subroutine set_bN\n\nsubroutine set_cN(cnmat)\n implicit none\n real(8) :: cnmat(0:12,12)\n\n cNmat(0,1)=-2.d0\n cNmat(1,1)=1.d0\n\n cNmat(0,2)=-5.d0\/2.d0\n cNmat(1,2)=4.d0\/3.d0\n cNmat(2,2)=-1.d0\/12.d0\n\n cNmat(0,3)=-49.d0\/18.d0\n cNmat(1,3)=3.d0\/2.d0\n cNmat(2,3)=-3.d0\/20.d0\n cNmat(3,3)=1.d0\/90.d0\n\n cNmat(0,5)=-5269.d0\/1800.d0\n cNmat(1,5)=5.d0\/3.d0\n cNmat(2,5)=-5.d0\/21.d0\n cNmat(3,5)=5.d0\/126.d0\n cNmat(4,5)=-5.d0\/1008.d0\n cNmat(5,5)=1.d0\/3150.d0\n\n cNmat(0,4)=-205.d0\/72.d0\n cNmat(1,4)=8.d0\/5.d0\n cNmat(2,4)=-1.d0\/5.d0\n cNmat(3,4)=8.d0\/315.d0\n cNmat(4,4)=-1.d0\/560.d0\n\n cNmat(0,6)=-5369.d0\/1800.d0\n cNmat(1,6)=12.d0\/7.d0\n cNmat(2,6)=-15.d0\/56.d0\n cNmat(3,6)=10.d0\/189.d0\n cNmat(4,6)=-1.d0\/112.d0\n cNmat(5,6)=2.d0\/1925.d0\n cNmat(6,6)=-1.d0\/16632.d0\n\n cNmat(0,7)=-266681.d0\/88200.d0\n cNmat(1,7)=7.d0\/4.d0\n cNmat(2,7)=-7.d0\/24.d0\n cNmat(3,7)=7.d0\/108.d0\n cNmat(4,7)=-7.d0\/528.d0\n cNmat(5,7)=7.d0\/3300.d0\n cNmat(6,7)=-7.d0\/30888.d0\n cNmat(7,7)=1.d0\/84084.d0\n\n cNmat(0,8)=-1077749.d0\/352800.d0\n cNmat(1,8)=16.d0\/9.d0\n cNmat(2,8)=-14.d0\/45.d0\n cNmat(3,8)=112.d0\/1485.d0\n cNmat(4,8)=-7.d0\/396.d0\n cNmat(5,8)=112.d0\/32175.d0\n cNmat(6,8)=-2.d0\/3861.d0\n cNmat(7,8)=16.d0\/315315.d0\n cNmat(8,8)=-1.d0\/411840.d0\n\n cNmat(0,9)=-9778141.d0\/3175200.d0\n cNmat(1,9)=9.d0\/5.d0\n cNmat(2,9)=-18.d0\/55.d0\n cNmat(3,9)=14.d0\/165.d0\n cNmat(4,9)=-63.d0\/2860.d0\n cNmat(5,9)=18.d0\/3575.d0\n cNmat(6,9)=-2.d0\/2145.d0\n cNmat(7,9)=9.d0\/70070.d0\n cNmat(8,9)=-9.d0\/777920.d0\n cNmat(9,9)=1.d0\/1969110.d0\n\n cNmat(0,10)=-1968329.d0\/635040.d0\n cNmat(1,10)=20.d0\/11.d0\n cNmat(2,10)=-15.d0\/44.d0\n cNmat(3,10)=40.d0\/429.d0\n cNmat(4,10)=-15.d0\/572.d0\n cNmat(5,10)=24.d0\/3575.d0\n cNmat(6,10)=-5.d0\/3432.d0\n cNmat(7,10)=30.d0\/119119.d0\n cNmat(8,10)=-5.d0\/155584.d0\n cNmat(9,10)=10.d0\/3741309.d0\n cNmat(10,10)=-1.d0\/9237800.d0\n\n cNmat(0,11)=-239437889.d0\/76839840.d0\n cNmat(1,11)=11.d0\/6.d0\n cNmat(2,11)=-55.d0\/156.d0\n cNmat(3,11)=55.d0\/546.d0\n cNmat(4,11)=-11.d0\/364.d0\n cNmat(5,11)=11.d0\/1300.d0\n cNmat(6,11)=-11.d0\/5304.d0\n cNmat(7,11)=55.d0\/129948.d0\n cNmat(8,11)=-55.d0\/806208.d0\n cNmat(9,11)=11.d0\/1360476.d0\n cNmat(10,11)=-11.d0\/17635800.d0\n cNmat(11,11)=1.d0\/42678636.d0\n\n cNmat(0,12)=-240505109.d0\/76839840.d0\n cNmat(1,12)=24.d0\/13.d0\n cNmat(2,12)=-33.d0\/91.d0\n cNmat(3,12)=88.d0\/819.d0\n cNmat(4,12)=-99.d0\/2912.d0\n cNmat(5,12)=396.d0\/38675.d0\n cNmat(6,12)=-11.d0\/3978.d0\n cNmat(7,12)=132.d0\/205751.d0\n cNmat(8,12)=-33.d0\/268736.d0\n cNmat(9,12)=44.d0\/2380833.d0\n cNmat(10,12)=-3.d0\/1469650.d0\n cNmat(11,12)=12.d0\/81800719.d0\n cNmat(12,12)=-1.d0\/194699232.d0\n\nend subroutine set_cN\n\nend module initialization_sub\n","avg_line_length":31.5843543827,"max_line_length":132,"alphanum_fraction":0.6054728298} {"size":1296,"ext":"f","lang":"FORTRAN","max_stars_count":945.0,"content":" DOUBLE PRECISION FUNCTION DLAPY2( X, Y )\n*\n* -- LAPACK auxiliary routine (version 3.0) --\n* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,\n* Courant Institute, Argonne National Lab, and Rice University\n* October 31, 1992\n*\n* .. Scalar Arguments ..\n DOUBLE PRECISION X, Y\n* ..\n*\n* Purpose\n* =======\n*\n* DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary\n* overflow.\n*\n* Arguments\n* =========\n*\n* X (input) DOUBLE PRECISION\n* Y (input) DOUBLE PRECISION\n* X and Y specify the values x and y.\n*\n* =====================================================================\n*\n* .. Parameters ..\n DOUBLE PRECISION ZERO\n PARAMETER ( ZERO = 0.0D0 )\n DOUBLE PRECISION ONE\n PARAMETER ( ONE = 1.0D0 )\n* ..\n* .. Local Scalars ..\n DOUBLE PRECISION W, XABS, YABS, Z\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC ABS, MAX, MIN, SQRT\n* ..\n* .. Executable Statements ..\n*\n XABS = ABS( X )\n YABS = ABS( Y )\n W = MAX( XABS, YABS )\n Z = MIN( XABS, YABS )\n IF( Z.EQ.ZERO ) THEN\n DLAPY2 = W\n ELSE\n DLAPY2 = W*SQRT( ONE+( Z \/ W )**2 )\n END IF\n RETURN\n*\n* End of DLAPY2\n*\n END\n","avg_line_length":23.5636363636,"max_line_length":72,"alphanum_fraction":0.4861111111} {"size":15157,"ext":"for","lang":"FORTRAN","max_stars_count":25.0,"content":"C=====================================================================\r\nC WBAL, Subroutine, Gerrit Hoogenboom\r\nC Seasonally: Provides output Water balance. Prints file SoilWatBal.OUT\r\n! Data is obtained from WATBAL, SPAM and IRRIG modules daily. \r\n! Data from SPAM and IRRIG are sent via GETPUT routines.\r\nC-----------------------------------------------------------------------\r\nC REVISION HISTORY\r\nC 02\/20\/1996 GH Written\r\nC 09\/02\/1999 CHP Added daily soil water content check\r\nC 08\/20\/2002 GH Modified for Y2K\r\n! 02\/22\/2006 CHP Added tiledrain.\r\n! 03\/06\/2006 CHP Added mulch layer effects on evaporation and infiltration.\r\n! 01\/11\/2007 CHP Changed GETPUT calls to GET and PUT\r\n!-----------------------------------------------------------------------\r\n! Called by: WATBAL\r\nC=====================================================================\r\n SUBROUTINE Wbal(CONTROL, ISWITCH, \r\n & CRAIN, DLAYR, DRAIN, FLOODWAT, \r\n & IRRAMT, MULCH, NLAYR, RAIN, RUNOFF, SNOW, \r\n & SWDELTS, SWDELTT, SWDELTU, SWDELTX, SWDELTL,\r\n & TDFC, TDFD, TDRAIN, TRUNOF, TSW, TSWINI)\r\n! ------------------------------------------------------------------\r\n USE ModuleDefs \r\n USE ModuleData\r\n USE FloodModule\r\n IMPLICIT NONE\r\n SAVE\r\n\r\n CHARACTER*1 IDETL, IDETW, ISWWAT, MEINF\r\n CHARACTER*14, PARAMETER :: SWBAL = 'SoilWatBal.OUT'\r\n INTEGER DAS, DOY, DYNAMIC, INCDAT, LUNWBL\r\n INTEGER RUN, YEAR, YRSIM, YRDOY, NBUND\r\n INTEGER YR1, DY1, YR2, DY2\r\n\r\n REAL CEO, CEP, CES, CRAIN, EFFIRR\r\n REAL TDFC, TDFD\r\n REAL TDRAIN, TOTIR, TRUNOF, TSW, TSWINI\r\n REAL WBALAN\r\n\r\n! Temporary daily balance\r\n REAL, DIMENSION(NL) :: DLAYR, SWDELTS, SWDELTX, SWDELTU, SWDELTT\r\n REAL, DIMENSION(NL) :: SWDELTL\r\n REAL SWDELTSTOT, SWDELTUTOT, SWDELTXTOT, SWDELTTTOT, SWDELTLTOT\r\n REAL IRRAMT, ES, EF, RAIN, RUNOFF, TOTEFFIRR\r\n REAL DRAIN, EP, TSWY !, INFILT\r\n REAL CEF, FLOOD, FLOODI, TOTBUNDRO, FRUNOFF, FLOODY\r\n REAL SNOW, SNOWI, SNOWY, CUMWBAL\r\n REAL MULCHWAT, MWI, MWY\r\n REAL CUMRESWATADD, RESWATADD_T\r\n REAL CUMMULEVAP, MULCHEVAP\r\n INTEGER NLAYR, L\r\n\r\n LOGICAL FEXIST\r\n\r\n! The variable \"ISWITCH\" is of type \"SwitchType\".\r\n TYPE (ControlType) CONTROL\r\n TYPE (SwitchType) ISWITCH\r\n TYPE (FloodWatType) FLOODWAT\r\n TYPE (MulchType) MULCH\r\n\r\n! ------------------------------------------------------------------\r\n IDETW = ISWITCH % IDETW\r\n IDETL = ISWITCH % IDETL\r\n ISWWAT = ISWITCH % ISWWAT\r\n IF (IDETW .EQ. 'N' .OR. ISWWAT .EQ. 'N' .OR. IDETL == '0') RETURN\r\n! ------------------------------------------------------------------\r\n DYNAMIC = CONTROL % DYNAMIC\r\n YRDOY = CONTROL % YRDOY\r\n YRSIM = CONTROL % YRSIM\r\n DAS = CONTROL % DAS\r\n IDETW = ISWITCH % IDETW\r\n IDETL = ISWITCH % IDETL\r\n ISWWAT = ISWITCH % ISWWAT\r\n MEINF = ISWITCH % MEINF\r\n\r\n EF = FLOODWAT % EF \r\n CEF = FLOODWAT % CEF \r\n FLOOD = FLOODWAT % FLOOD \r\n NBUND = FLOODWAT % NBUND \r\n TOTBUNDRO = FLOODWAT % TOTBUNDRO\r\n FRUNOFF = FLOODWAT % FRUNOFF\r\n\r\n MULCHWAT = MULCH % MULCHWAT\r\n MULCHEVAP = MULCH % MULCHEVAP\r\n RESWATADD_T = MULCH % NEWMULCHWAT\r\n\r\n!***********************************************************************\r\n!***********************************************************************\r\n! Seasonal initialization - run once per season\r\n!***********************************************************************\r\n IF (DYNAMIC .EQ. SEASINIT) THEN\r\n!-----------------------------------------------------------------------\r\n RUN = CONTROL % RUN\r\n\r\n! Open output file\r\n CALL GETLUN('SWBAL', LUNWBL)\r\n INQUIRE (FILE = SWBAL, EXIST = FEXIST)\r\n IF (FEXIST) THEN\r\n OPEN (UNIT = LUNWBL, FILE = SWBAL, STATUS = 'OLD',\r\n & POSITION = 'APPEND')\r\n ELSE\r\n OPEN (UNIT = LUNWBL, FILE = SWBAL, STATUS = 'NEW')\r\n WRITE(LUNWBL,'(\"*WATER BALANCE OUTPUT FILE\")')\r\n ENDIF\r\n\r\n CALL HEADER(SEASINIT, LUNWBL, RUN)\r\n\r\n IF (INDEX('AD',IDETL) > 0) THEN\r\n !Write header for daily output\r\n WRITE (LUNWBL,1120)\r\n 1120 FORMAT('@YEAR DOY DAS',\r\n & ' SWTD FWTD SNTD MWTD', !State vars\r\n & ' IRRD PRED', !Inflows\r\n & ' RESAD', !Inflows\r\n & ' MEVAP', !Outflows\r\n & ' DRND ROFD FROD ESAD EPAD EFAD TDFD', !Outflows\r\n & ' WBAL CUMWBAL', !Balance\r\n & ' TOTS TOTU TOTX TOTT TOTL') !Changes to SW\r\n\r\n CALL YR_DOY(INCDAT(YRDOY,-1), YEAR, DOY) \r\n WRITE (LUNWBL,1300) YEAR, DOY, DAS, \r\n & (TSWINI * 10.), FLOOD, SNOW, MULCHWAT, !State variables\r\n & 0.0, 0.0, !Inflows\r\n & 0.0, !Inflows\r\n & MULCHEVAP, !Outflows\r\n! & INFILT, !Exchange between flood and soil water\r\n & 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, !Outflows\r\n & 0.0, 0.0 !Balance\r\n & ,0., 0., 0., 0.\r\n & ,0.\r\n\r\n ENDIF\r\n\r\n TSWY = TSWINI\r\n FLOODI = FLOOD\r\n FLOODY = FLOOD\r\n\r\n !CINF = 0.0\r\n SNOWI = SNOW\r\n SNOWY = SNOW\r\n MWI = MULCHWAT\r\n MWY = MULCHWAT\r\n\r\n CUMWBAL = 0.0\r\n CUMRESWATADD = 0.0\r\n CUMMULEVAP = 0.0\r\n\r\n!***********************************************************************\r\n!***********************************************************************\r\n! DAILY OUTPUT \r\n!***********************************************************************\r\n ELSEIF (DYNAMIC .EQ. OUTPUT) THEN\r\n!-----------------------------------------------------------------------\r\n IF (INDEX('AD',IDETL) > 0) THEN\r\n\r\n! Transfer data from constructed variable to local variables\r\n CALL Get('SPAM','CEO',CEO)\r\n CALL Get('SPAM','CEP',CEP)\r\n CALL Get('SPAM','CES',CES)\r\n CALL Get('SPAM','EP', EP)\r\n CALL Get('SPAM','ES', ES)\r\n CALL Get('MGMT','TOTIR', TOTIR)\r\n CALL Get('MGMT','EFFIRR',EFFIRR)\r\n CALL YR_DOY(YRDOY, YEAR, DOY) \r\n\r\n! Change in storage = Inflows - Outflows\r\n! Balance = Inflows - Outflows - Change in storage\r\n WBALAN = \r\n & + IRRAMT + RAIN !Inflows\r\n & + RESWATADD_T !Inflows\r\n & - MULCHEVAP !Outflows\r\n & - DRAIN - RUNOFF - FRUNOFF !Outflows\r\n & - ES - EP - EF - (TDFD*10.) !Outflows\r\n & - (TSW * 10.) + (TSWY * 10.) !Change in soil water \r\n & - FLOOD + FLOODY !Change in flood water \r\n & - SNOW + SNOWY !Change in snow accum.\r\n & - MULCHWAT + MWY !Change in mulch water\r\n\r\n CUMWBAL = CUMWBAL + WBALAN\r\n\r\n SWDELTSTOT = 0.0\r\n SWDELTUTOT = 0.0\r\n SWDELTTTOT = 0.0\r\n SWDELTXTOT = 0.0\r\n SWDELTLTOT = 0.0\r\n DO L = 1, NLAYR\r\n SWDELTSTOT = SWDELTSTOT + SWDELTS(L) * DLAYR(L)\r\n SWDELTUTOT = SWDELTUTOT + SWDELTU(L) * DLAYR(L)\r\n SWDELTTTOT = SWDELTTTOT + SWDELTT(L) * DLAYR(L)\r\n SWDELTXTOT = SWDELTXTOT + SWDELTX(L) * DLAYR(L)\r\n SWDELTLTOT = SWDELTLTOT + SWDELTL(L) * DLAYR(L)\r\n ENDDO\r\n\r\n WRITE (LUNWBL,1300) YEAR, DOY, DAS\r\n & ,(TSW * 10.), FLOOD, SNOW, MULCHWAT !State variables\r\n & ,IRRAMT, RAIN !Inflows\r\n & ,RESWATADD_T !Inflows\r\n & ,MULCHEVAP !Outflows\r\n!! & ,INFILT !Exchange between flood and soil water\r\n & ,DRAIN, RUNOFF, FRUNOFF, ES, EP, EF, TDFD*10. !Outflows\r\n & ,WBALAN, CUMWBAL !Balance\r\n & ,SWDELTSTOT*10., SWDELTUTOT*10.,SWDELTXTOT*10., SWDELTTTOT*10.\r\n & ,SWDELTLTOT*10.\r\n!1300 FORMAT(1X,I4,1X,I3.3,1X,I5,3F8.2, 12F7.2, F8.2, F10.2,4X,5F8.3)\r\n 1300 FORMAT(1X,I4,1X,I3.3,1X,I5\r\n & ,3F8.2,F7.2\r\n & ,3F7.2\r\n & ,8F7.2\r\n & ,F8.2,F10.2 !Balances\r\n & ,4X,5F8.2 !SWDELT's\r\n & )\r\n\r\n !Save values for comparison tomorrow\r\n TSWY = TSW\r\n FLOODY = FLOOD\r\n SNOWY = SNOW\r\n MWY = MULCHWAT\r\n ENDIF\r\n \r\n CUMMULEVAP = CUMMULEVAP + MULCHEVAP\r\n CUMRESWATADD = CUMRESWATADD + RESWATADD_T\r\n\r\n!***********************************************************************\r\n!***********************************************************************\r\n! SEASEND - Seasonal output\r\n!***********************************************************************\r\n ELSEIF (DYNAMIC .EQ. SEASEND) THEN\r\nC-----------------------------------------------------------------------\r\n YRSIM = CONTROL % YRSIM\r\n CALL YR_DOY(YRSIM, YR1, DY1)\r\n CALL YR_DOY(YRDOY, YR2, DY2)\r\n\r\n CALL Get('SPAM','CEO',CEO)\r\n CALL Get('SPAM','CEP',CEP)\r\n CALL Get('SPAM','CES',CES)\r\n CALL Get('SPAM','EP', EP)\r\n CALL Get('SPAM','ES', ES)\r\n\r\n! CALL Get('MGMT','DEPIR', DEPIR) !Total irrig amt today (mm) (includes losses)\r\n! CALL Get('MGMT','IRRAMT',IRRAMT) !Effective irrig amt today (mm)\r\n! CALL Get('MGMT','TOTIR', TOTIR) !Total applied irrigation (mm) (includes losses)\r\n CALL Get('MGMT','TOTEFFIRR',TOTEFFIRR) !Total effective irrigation\r\n\r\n! IF (EFFIRR .GT. 0.0) THEN\r\n! TOTEFFIRR = EFFIRR * TOTIR\r\n! ELSE\r\n! TOTEFFIRR = TOTIR\r\n! ENDIF\r\n\r\n WRITE (LUNWBL,320)\r\n 320 FORMAT(\/,'!',5X,'WATER BALANCE PARAMETERS',\r\n & \/,'!',5X,'========================',T48,'--mm--')\r\n WRITE (LUNWBL,400)\r\n & YR1, DY1, TSWINI*10,\r\n & YR2, DY2, TSW*10, \r\n & TOTEFFIRR,\r\n & CRAIN, CUMRESWATADD, \r\n & TDRAIN, TDFC*10., TRUNOF, CUMMULEVAP,\r\n & CES, CEP, CEO\r\n 400 FORMAT(\r\n & \/,'!',5X,'Soil H20 (start) on Year\/day',I5,'\/',I3.3,T44,F10.2,\r\n & \/,'!',5X,'Soil H20 (final) on Year\/day',I5,'\/',I3.3,T44,F10.2,\r\n & \/,'!',5X,'Effective Irrigation', T44,F10.2,\r\n & \/,'!',5X,'Precipitation', T44,F10.2,\r\n & \/,'!',5X,'Water added with new mulch', T44,F10.2,\r\n & \/,'!',5X,'Drainage', T44,F10.2,\r\n & \/,'!',5X,'Tiledrain flow', T44,F10.2,\r\n & \/,'!',5X,'Runoff', T44,F10.2,\r\n & \/,'!',5X,'Mulch evaporation', T44,F10.2,\r\n & \/,'!',5X,'Soil Evaporation', T44,F10.2,\r\n & \/,'!',5X,'Transpiration', T44,F10.2,\r\n & \/,'!',5X,'Potential ET', T44,F10.2)\r\n\r\n WBALAN = (TSWINI * 10.) - (TSW * 10.) !Change in water content\r\n & + TOTEFFIRR + CRAIN + CUMRESWATADD !Inflows\r\n & - CUMMULEVAP !Outflows\r\n & - TDRAIN - TRUNOF - CES - CEP - (TDFC*10.) !Outflows\r\n\r\n IF (SNOW > 0.0 .OR. SNOWI > 0.0) THEN\r\n WRITE(LUNWBL, 420) SNOWI, SNOW\r\n 420 FORMAT(\/,'!',5X,'Initial snow accumulation ', T44, F10.2,\r\n & \/,'!',5X,'Final snow accumulation ', T44, F10.2)\r\n WBALAN = WBALAN - SNOW + SNOWI\r\n ENDIF\r\n\r\n! IF (INDEX('RSN',MEINF) <= 0) THEN\r\n IF (INDEX('RSM',MEINF) > 0) THEN \r\n WRITE(LUNWBL, 430) MWI, MULCHWAT\r\n 430 FORMAT(\/,'!',5X,'Initial mulch water content ', T44, F10.2,\r\n & \/,'!',5X,'Final mulch water content ', T44, F10.2)\r\n WBALAN = WBALAN - MULCHWAT + MWI\r\n ENDIF\r\n\r\n IF (NBUND .GT. 0) THEN\r\n! WRITE (LUNWBL,450) FLOODI, FLOOD, CINF, CEF, TOTBUNDRO\r\n WRITE (LUNWBL,450) FLOODI, FLOOD, CEF, TOTBUNDRO\r\n 450 FORMAT(\r\n & \/,'!',5X,'Initial flood depth ',T44,F10.2,\r\n & \/,'!',5X,'Final flood depth ',T44,F10.2,\r\n! & \/,'!',5X,'Cumulative infiltration ',T44,F10.2,\r\n & \/,'!',5X,'Flood pool evaporation ',T44,F10.2,\r\n & \/,'!',5X,'Runoff over bund ',T44,F10.2)\r\n WBALAN = WBALAN - FLOOD + FLOODI - CEF - TOTBUNDRO\r\n ENDIF\r\n\r\n WRITE (LUNWBL,500) WBALAN\r\n 500 FORMAT(\/,'!',5X,'Final Balance ',T42,F12.3,\/)\r\n\r\n CLOSE(LUNWBL) \r\n\r\n!***********************************************************************\r\n!***********************************************************************\r\n! END OF DYNAMIC IF CONSTRUCT\r\n!***********************************************************************\r\n ENDIF\r\n!-----------------------------------------------------------------------\r\n RETURN\r\n END SUBROUTINE Wbal\r\nC=======================================================================\r\n\r\n\r\nC=====================================================================\r\n! WBAL VARIABLE DEFINITIONS:\r\n!-----------------------------------------------------------------------\r\n! CEO Cumulative potential evapotranspiration (mm)\r\n! CEP Cumulative transpiration (mm)\r\n! CES Cumulative evaporation (mm)\r\n! CRAIN Cumulative precipitation (mm)\r\n! DEFICIT Amount by which the allowable minimum soil water content in top \r\n! layer exceeds the actual calculated soil water content (cm3\/cm3)\r\n! DLAYR(L) Soil thickness in layer L (cm)\r\n! EFFIRR Irrigation application efficiency (cm\/cm)\r\n! ES Actual soil evaporation rate (mm\/d)\r\n! EXPER Experiment code (prefix of input files) \r\n! FIRST Indicates first call to subroutine (true or false)\r\n! LL(L) Volumetric soil water content in soil layer L at lower limit\r\n! (cm3\/cm3)\r\n! LUNWARN Logical unit number for Warning.OUT file \r\n! LUNWBL Logical unit number for WBAL.OUT file \r\n! NL Maximum number of soil layers = 20 \r\n! NLAYR Actual number of soil layers \r\n! SAT(L) Volumetric soil water content in layer L at saturation\r\n! (cm3 [water] \/ cm3 [soil])\r\n! SW(L) Volumetric soil water content in layer L\r\n! (cm3 [water] \/ cm3 [soil])\r\n! SWEF Soil water evaporation fraction; fraction of lower limit content \r\n! to which evaporation can reduce soil water content in top layer\r\n! (fraction)\r\n! TDRAIN Cumulative daily drainage from profile (mm)\r\n! TOTIR Total seasonal irrigation (mm)\r\n! TRUNOF Cumulative runoff (mm)\r\n! TSW Total soil water in profile (cm)\r\n! TSWINI Initial soil water content (cm)\r\n! WBALAN Seasonal water balance (should equal 0.0) (mm)\r\n! YRDOY Current day of simulation (YYDDD)\r\n! YRSIM Start of simulation date (YYDDD)\r\n!-----------------------------------------------------------------------\r\n! END SUBROUTINE WBAL\r\nC=======================================================================\r\n","avg_line_length":42.1027777778,"max_line_length":90,"alphanum_fraction":0.4485716171} {"size":55982,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"MODULE GLOB\n!!! traj: frame,num_part,dim\n\n INTEGER,DIMENSION(:),ALLOCATABLE::T_ind,T_start\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::T_tau\n INTEGER,DIMENSION(:,:),ALLOCATABLE::labels\n DOUBLE PRECISION,DIMENSION(:,:),ALLOCATABLE::labels_daux\n \n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::distrib,distrib_x\n \n \n TYPE array_pointer\n INTEGER,DIMENSION(:),POINTER::p1\n END TYPE array_pointer\n \n TYPE darray_pointer\n DOUBLE PRECISION,DIMENSION(:),POINTER::d1\n END TYPE darray_pointer\n \n\nCONTAINS\n\n SUBROUTINE free_memory_ts ()\n \n IF (ALLOCATED(T_ind)) DEALLOCATE(T_ind)\n IF (ALLOCATED(T_tau)) DEALLOCATE(T_tau)\n IF (ALLOCATED(T_start)) DEALLOCATE(T_start)\n IF (ALLOCATED(labels)) DEALLOCATE(labels)\n IF (ALLOCATED(labels_daux)) DEALLOCATE(labels_daux)\n \n END SUBROUTINE free_memory_ts\n \n SUBROUTINE traj2net(len_str,traj_full,ranges,num_frames,num_parts,dimensions,tray)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::len_str,num_parts,num_frames,dimensions\n INTEGER,DIMENSION(num_frames,num_parts,dimensions),INTENT(IN)::traj_full\n INTEGER,DIMENSION(dimensions,2),INTENT(IN)::ranges\n INTEGER,DIMENSION(num_frames,num_parts),INTENT(OUT)::tray\n \n INTEGER::N_nodes,Ktot\n INTEGER::index\n INTEGER::ii,jj,gg,kk,ll,hh,hhh,aa,bb\n INTEGER::llevamos,cajon,contador\n INTEGER::x,x2\n \n INTEGER,DIMENSION(:,:),ALLOCATABLE::indice\n LOGICAL,DIMENSION(:,:),ALLOCATABLE::ocupado\n INTEGER,DIMENSION(:),ALLOCATABLE::deantes,aux\n CHARACTER*40::f1,f2,f3\n \n INTEGER,DIMENSION(:),ALLOCATABLE::SL,W,K_out\n TYPE(array_pointer),DIMENSION(:),POINTER::C,WK_out\n INTEGER::Kmax\n INTEGER,DIMENSION(:),POINTER::aux_puntero,aux_puntero2\n LOGICAL::switch\n \n CALL free_memory_ts ()\n \n \n IF ((dimensions>999999).or.(len_str>999999)) THEN\n print*, 'ERROR in fortran traj2net'\n stop\n END IF\n \n \n DO cajon=1,dimensions\n \n IF (cajon==1) THEN\n llevamos=1\n tray=1\n ELSE\n CALL SYSTEM ('mv trad_aux.aux trad_aux_old.aux')\n END IF\n \n ALLOCATE(ocupado(llevamos,ranges(cajon,1):ranges(cajon,2)),indice(llevamos,ranges(cajon,1):ranges(cajon,2)))\n ocupado=.false.\n \n DO ii=1,num_parts\n DO jj=1,num_frames\n bb=tray(jj,ii)\n aa=traj_full(jj,ii,cajon)\n ocupado(bb,aa)=.true.\n END DO\n END DO\n \n contador=0\n \n WRITE(f1,'(I6)') cajon\n WRITE(f2,'(I6)') len_str\n f3=\"(I,\"\/\/TRIM(ADJUSTL(f1))\/\/\"I\"\/\/TRIM(ADJUSTL(f2))\/\/\")\"\n \n OPEN(21,FILE=\"trad_aux.aux\",status=\"REPLACE\",ACTION=\"WRITE\")\n IF (cajon==1) THEN\n DO ii=1,llevamos\n DO jj=ranges(1,1),ranges(1,2)\n IF (ocupado(ii,jj).eqv..true.) THEN\n contador=contador+1\n indice(ii,jj)=contador\n WRITE(21,f3) contador,jj\n END IF\n END DO\n END DO\n ELSE\n OPEN(61,FILE=\"trad_aux_old.aux\",status=\"OLD\",ACTION=\"READ\")\n ALLOCATE(deantes(cajon-1)) \n DO ii=1,llevamos\n READ(61,*) aa,deantes(:)\n DO jj=ranges(cajon,1),ranges(cajon,2)\n IF (ocupado(ii,jj).eqv..true.) THEN\n contador=contador+1\n WRITE(21,f3) contador,deantes(:),jj\n indice(ii,jj)=contador\n END IF\n END DO\n END DO\n DEALLOCATE(deantes)\n CLOSE(61)\n END IF\n \n CLOSE(21)\n \n DEALLOCATE(ocupado)\n \n DO ii=1,num_parts\n DO jj=1,num_frames\n bb=tray(jj,ii)\n aa=traj_full(jj,ii,cajon)\n tray(jj,ii)=indice(bb,aa)\n END DO\n END DO\n \n DEALLOCATE(indice)\n llevamos=contador\n \n IF (cajon\/=1) CALL SYSTEM('rm trad_aux_old.aux')\n \n !print*,'>>',cajon,llevamos\n END DO\n \n N_nodes=llevamos \n ALLOCATE(labels(N_nodes,dimensions),deantes(dimensions))\n OPEN(21,FILE=\"trad_aux.aux\",status=\"OLD\",ACTION=\"READ\")\n DO ii=1,N_nodes\n READ(21,*) llevamos,deantes(:)\n labels(ii,:)=deantes(:)\n END DO\n CLOSE(21)\n DEALLOCATE(deantes)\n CALL SYSTEM('rm trad_aux.aux')\n ALLOCATE(C(N_nodes),K_out(N_nodes))\n ALLOCATE(WK_out(N_nodes),SL(N_nodes),W(N_nodes))\n ALLOCATE(aux_puntero(25000),aux_puntero2(25000))\n \n DO ii=1,N_nodes\n ALLOCATE(C(ii)%p1(1),WK_out(ii)%p1(1))\n C(ii)%p1(:)=0\n WK_out(ii)%p1(:)=0\n END DO\n \n SL=0\n W=0\n K_out=0\n kk=0\n x=0\n x2=0\n aux_puntero(:)=0\n aux_puntero2(:)=0\n contador=0\n \n DO index=1,num_parts\n \n x=tray(1,index)\n contador=contador+1\n x2=tray(2,index)\n contador=contador+1\n \n DO ii=3,num_frames\n \n W(x)=W(x)+1\n \n switch=.true.\n DO gg=1,K_out(x)\n IF(C(x)%p1(gg)==x2) THEN\n WK_out(x)%p1(gg)=WK_out(x)%p1(gg)+1\n switch=.false.\n EXIT\n END IF\n END DO\n \n IF (switch.eqv..true.) THEN\n IF (K_out(x)>0) THEN\n gg=K_out(x)\n IF (gg>25000) THEN\n print*,'tenemos un problema'\n stop\n END IF\n aux_puntero(1:gg)=C(x)%p1(:)\n aux_puntero2(1:gg)=WK_out(x)%p1(:)\n DEALLOCATE(C(x)%p1,WK_out(x)%p1)\n ALLOCATE(C(x)%p1(gg+1),WK_out(x)%p1(gg+1))\n C(x)%p1(1:gg)=aux_puntero(:)\n WK_out(x)%p1(1:gg)=aux_puntero2(:)\n C(x)%p1(gg+1)=x2\n WK_out(x)%p1(gg+1)=1\n K_out(x)=K_out(x)+1\n ELSE\n WK_out(x)%p1(1)=1\n C(x)%p1(1)=x2\n K_out(x)=1\n END IF\n END IF\n \n x=x2 !!bin\n \n x2=tray(ii,index)\n contador=contador+1\n \n END DO\n \n W(x)=W(x)+1\n \n switch=.true.\n \n DO gg=1,K_out(x)\n IF(C(x)%p1(gg)==x2) THEN\n WK_out(x)%p1(gg)=WK_out(x)%p1(gg)+1\n switch=.false.\n EXIT\n END IF\n END DO\n \n IF (switch.eqv..true.) THEN\n IF (K_out(x)>0) THEN\n gg=K_out(x)\n IF (gg>25000) THEN\n print*,'tenemos un problema'\n stop\n END IF\n aux_puntero(1:gg)=C(x)%p1(:)\n aux_puntero2(1:gg)=WK_out(x)%p1(:)\n DEALLOCATE(C(x)%p1,WK_out(x)%p1)\n ALLOCATE(C(x)%p1(gg+1),WK_out(x)%p1(gg+1))\n C(x)%p1(1:gg)=aux_puntero(:)\n WK_out(x)%p1(1:gg)=aux_puntero2(:)\n C(x)%p1(gg+1)=x2\n WK_out(x)%p1(gg+1)=1\n K_out(x)=K_out(x)+1\n ELSE\n WK_out(x)%p1(1)=1\n C(x)%p1(1)=x2\n K_out(x)=1\n END IF\n END IF\n \n x=x2\n contador=contador+1\n \n W(x)=W(x)+1\n \n END DO\n \n Kmax=maxval(K_out(:))\n Ktot=sum(K_out(:))\n \n \n ALLOCATE(T_start(N_nodes+1),T_ind(Ktot),T_tau(Ktot))\n T_start=0\n T_ind=0\n T_tau=0\n \n ll=0\n DO ii=1,N_nodes\n \n hh=0\n switch=.false.\n DO gg=1,K_out(ii)\n IF (C(ii)%p1(gg)==ii) THEN\n switch=.true.\n exit\n END IF\n END DO\n \n T_start(ii)=ll\n IF (switch.eqv..true.) THEN\n ll=ll+1\n T_ind(ll)=ii\n hhh=WK_out(ii)%p1(gg)\n T_tau(ll)=hhh\n hh=hh+hhh\n DO jj=1,K_out(ii)\n IF (jj\/=gg) THEN\n ll=ll+1\n T_ind(ll)=C(ii)%p1(jj)\n hhh=WK_out(ii)%p1(jj)\n T_tau(ll)=hhh\n hh=hh+hhh\n END IF\n END DO\n ELSE\n DO jj=1,K_out(ii)\n ll=ll+1\n T_ind(ll)=C(ii)%p1(jj)\n hhh=WK_out(ii)%p1(jj)\n hh=hh+hhh\n T_tau(ll)=hhh\n END DO\n END IF\n \n END DO\n \n T_start(N_nodes+1)=ll\n \n tray=tray-1\n DEALLOCATE(C,K_out)\n DEALLOCATE(WK_out,SL,W)\n DEALLOCATE(aux_puntero,aux_puntero2)\n \n end subroutine traj2net\n \n SUBROUTINE trajbinning2net(len_str,traj_full,ranges,bins,num_frames,num_parts,dimensions,tray)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::len_str,num_parts,num_frames,dimensions\n DOUBLE PRECISION,DIMENSION(num_frames,num_parts,dimensions),INTENT(IN)::traj_full\n DOUBLE PRECISION,DIMENSION(dimensions,2),INTENT(IN)::ranges\n INTEGER,DIMENSION(dimensions),INTENT(IN)::bins\n INTEGER,DIMENSION(num_frames,num_parts),INTENT(OUT)::tray\n \n DOUBLE PRECISION,DIMENSION(dimensions)::delta_l\n\n INTEGER::N_nodes,Ktot\n INTEGER::index\n INTEGER::ii,jj,gg,kk,ll,hh,hhh,aa,bb\n INTEGER::llevamos,cajon,contador\n INTEGER::x,x2\n \n INTEGER,DIMENSION(:,:),ALLOCATABLE::indice\n LOGICAL,DIMENSION(:,:),ALLOCATABLE::ocupado\n INTEGER,DIMENSION(:),ALLOCATABLE::deantes,aux\n CHARACTER*40::f1,f2,f3\n \n INTEGER,DIMENSION(:),ALLOCATABLE::SL,W,K_out\n TYPE(array_pointer),DIMENSION(:),POINTER::C,WK_out\n INTEGER::Kmax\n INTEGER,DIMENSION(:),POINTER::aux_puntero,aux_puntero2\n LOGICAL::switch\n \n delta_l=0.0d0\n DO ii=1,dimensions\n delta_l(ii)=(ranges(ii,2)-ranges(ii,1))\/(1.0d0*bins(ii))\n END DO\n\n CALL free_memory_ts ()\n \n \n IF ((dimensions>999999).or.(len_str>999999)) THEN\n print*, 'ERROR in fortran traj2net'\n stop\n END IF\n \n \n DO cajon=1,dimensions\n \n IF (cajon==1) THEN\n llevamos=1\n tray=1\n ELSE\n CALL SYSTEM ('mv trad_aux.aux trad_aux_old.aux')\n END IF\n \n ALLOCATE(ocupado(llevamos,bins(cajon)),indice(llevamos,bins(cajon)))\n ocupado=.false.\n \n DO ii=1,num_parts\n DO jj=1,num_frames\n bb=tray(jj,ii)\n aa=traj_full(jj,ii,cajon)\n ocupado(bb,aa)=.true.\n END DO\n END DO\n \n contador=0\n \n WRITE(f1,'(I6)') cajon\n WRITE(f2,'(I6)') len_str\n f3=\"(I,\"\/\/TRIM(ADJUSTL(f1))\/\/\"I\"\/\/TRIM(ADJUSTL(f2))\/\/\")\"\n \n OPEN(21,FILE=\"trad_aux.aux\",status=\"REPLACE\",ACTION=\"WRITE\")\n IF (cajon==1) THEN\n DO ii=1,llevamos\n DO jj=ranges(1,1),ranges(1,2)\n IF (ocupado(ii,jj).eqv..true.) THEN\n contador=contador+1\n indice(ii,jj)=contador\n WRITE(21,f3) contador,jj\n END IF\n END DO\n END DO\n ELSE\n OPEN(61,FILE=\"trad_aux_old.aux\",status=\"OLD\",ACTION=\"READ\")\n ALLOCATE(deantes(cajon-1)) \n DO ii=1,llevamos\n READ(61,*) aa,deantes(:)\n DO jj=ranges(cajon,1),ranges(cajon,2)\n IF (ocupado(ii,jj).eqv..true.) THEN\n contador=contador+1\n WRITE(21,f3) contador,deantes(:),jj\n indice(ii,jj)=contador\n END IF\n END DO\n END DO\n DEALLOCATE(deantes)\n CLOSE(61)\n END IF\n \n CLOSE(21)\n \n DEALLOCATE(ocupado)\n \n DO ii=1,num_parts\n DO jj=1,num_frames\n bb=tray(jj,ii)\n aa=traj_full(jj,ii,cajon)\n tray(jj,ii)=indice(bb,aa)\n END DO\n END DO\n \n DEALLOCATE(indice)\n llevamos=contador\n \n IF (cajon\/=1) CALL SYSTEM('rm trad_aux_old.aux')\n \n !print*,'>>',cajon,llevamos\n END DO\n \n N_nodes=llevamos \n ALLOCATE(labels(N_nodes,dimensions),deantes(dimensions))\n OPEN(21,FILE=\"trad_aux.aux\",status=\"OLD\",ACTION=\"READ\")\n DO ii=1,N_nodes\n READ(21,*) llevamos,deantes(:)\n labels(ii,:)=deantes(:)\n END DO\n CLOSE(21)\n DEALLOCATE(deantes)\n CALL SYSTEM('rm trad_aux.aux')\n ALLOCATE(C(N_nodes),K_out(N_nodes))\n ALLOCATE(WK_out(N_nodes),SL(N_nodes),W(N_nodes))\n ALLOCATE(aux_puntero(25000),aux_puntero2(25000))\n \n DO ii=1,N_nodes\n ALLOCATE(C(ii)%p1(1),WK_out(ii)%p1(1))\n C(ii)%p1(:)=0\n WK_out(ii)%p1(:)=0\n END DO\n \n SL=0\n W=0\n K_out=0\n kk=0\n x=0\n x2=0\n aux_puntero(:)=0\n aux_puntero2(:)=0\n contador=0\n \n DO index=1,num_parts\n \n x=tray(1,index)\n contador=contador+1\n x2=tray(2,index)\n contador=contador+1\n \n DO ii=3,num_frames\n \n W(x)=W(x)+1\n \n switch=.true.\n DO gg=1,K_out(x)\n IF(C(x)%p1(gg)==x2) THEN\n WK_out(x)%p1(gg)=WK_out(x)%p1(gg)+1\n switch=.false.\n EXIT\n END IF\n END DO\n \n IF (switch.eqv..true.) THEN\n IF (K_out(x)>0) THEN\n gg=K_out(x)\n IF (gg>25000) THEN\n print*,'tenemos un problema'\n stop\n END IF\n aux_puntero(1:gg)=C(x)%p1(:)\n aux_puntero2(1:gg)=WK_out(x)%p1(:)\n DEALLOCATE(C(x)%p1,WK_out(x)%p1)\n ALLOCATE(C(x)%p1(gg+1),WK_out(x)%p1(gg+1))\n C(x)%p1(1:gg)=aux_puntero(:)\n WK_out(x)%p1(1:gg)=aux_puntero2(:)\n C(x)%p1(gg+1)=x2\n WK_out(x)%p1(gg+1)=1\n K_out(x)=K_out(x)+1\n ELSE\n WK_out(x)%p1(1)=1\n C(x)%p1(1)=x2\n K_out(x)=1\n END IF\n END IF\n \n x=x2 !!bin\n \n x2=tray(ii,index)\n contador=contador+1\n \n END DO\n \n W(x)=W(x)+1\n \n switch=.true.\n \n DO gg=1,K_out(x)\n IF(C(x)%p1(gg)==x2) THEN\n WK_out(x)%p1(gg)=WK_out(x)%p1(gg)+1\n switch=.false.\n EXIT\n END IF\n END DO\n \n IF (switch.eqv..true.) THEN\n IF (K_out(x)>0) THEN\n gg=K_out(x)\n IF (gg>25000) THEN\n print*,'tenemos un problema'\n stop\n END IF\n aux_puntero(1:gg)=C(x)%p1(:)\n aux_puntero2(1:gg)=WK_out(x)%p1(:)\n DEALLOCATE(C(x)%p1,WK_out(x)%p1)\n ALLOCATE(C(x)%p1(gg+1),WK_out(x)%p1(gg+1))\n C(x)%p1(1:gg)=aux_puntero(:)\n WK_out(x)%p1(1:gg)=aux_puntero2(:)\n C(x)%p1(gg+1)=x2\n WK_out(x)%p1(gg+1)=1\n K_out(x)=K_out(x)+1\n ELSE\n WK_out(x)%p1(1)=1\n C(x)%p1(1)=x2\n K_out(x)=1\n END IF\n END IF\n \n x=x2\n contador=contador+1\n \n W(x)=W(x)+1\n \n END DO\n \n Kmax=maxval(K_out(:))\n Ktot=sum(K_out(:))\n \n \n ALLOCATE(T_start(N_nodes+1),T_ind(Ktot),T_tau(Ktot))\n T_start=0\n T_ind=0\n T_tau=0\n \n ll=0\n DO ii=1,N_nodes\n \n hh=0\n switch=.false.\n DO gg=1,K_out(ii)\n IF (C(ii)%p1(gg)==ii) THEN\n switch=.true.\n exit\n END IF\n END DO\n \n T_start(ii)=ll\n IF (switch.eqv..true.) THEN\n ll=ll+1\n T_ind(ll)=ii\n hhh=WK_out(ii)%p1(gg)\n T_tau(ll)=hhh\n hh=hh+hhh\n DO jj=1,K_out(ii)\n IF (jj\/=gg) THEN\n ll=ll+1\n T_ind(ll)=C(ii)%p1(jj)\n hhh=WK_out(ii)%p1(jj)\n T_tau(ll)=hhh\n hh=hh+hhh\n END IF\n END DO\n ELSE\n DO jj=1,K_out(ii)\n ll=ll+1\n T_ind(ll)=C(ii)%p1(jj)\n hhh=WK_out(ii)%p1(jj)\n hh=hh+hhh\n T_tau(ll)=hhh\n END DO\n END IF\n \n END DO\n \n T_start(N_nodes+1)=ll\n \n tray=tray-1\n DEALLOCATE(C,K_out)\n DEALLOCATE(WK_out,SL,W)\n DEALLOCATE(aux_puntero,aux_puntero2)\n \n end subroutine trajbinning2net\n \n\n SUBROUTINE trajnodes2trajclusters (aux_list,trajnodes,num_nodes,frames,particles,trajout)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::frames,particles,num_nodes\n INTEGER,DIMENSION(frames,particles,1),INTENT(IN)::trajnodes\n INTEGER,DIMENSION(num_nodes),INTENT(IN)::aux_list\n INTEGER,DIMENSION(frames,particles,1),INTENT(OUT)::trajout\n \n INTEGER::ii,jj,kk,gg,ll\n \n DO ii=1,frames\n DO jj=1,particles\n ll=trajnodes(ii,jj,1)\n gg=aux_list(ll+1)\n trajout(ii,jj,1)=gg\n END DO\n END DO\n \n END SUBROUTINE trajnodes2trajclusters\n \n \n SUBROUTINE PCA (num_eigenvs,traj,frames,num_parts,dims,eigenvals,eigenvects)\n \n IMPLICIT NONE\n \n INTEGER,INTENT(IN)::frames,num_parts,dims,num_eigenvs\n DOUBLE PRECISION,DIMENSION(frames,num_parts,dims),INTENT(IN)::traj\n DOUBLE PRECISION,DIMENSION(num_eigenvs),INTENT(OUT)::eigenvals\n DOUBLE PRECISION,DIMENSION(num_eigenvs,num_parts,dims),INTENT(OUT)::eigenvects\n \n INTEGER::ii,jj,kk,gg,dim_mat\n INTEGER::xx,yy,jj1,kk1,jj2,kk2\n DOUBLE PRECISION::aux_coor,aver_xx\n DOUBLE PRECISION,DIMENSION(:,:),ALLOCATABLE::C,CC\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::vals,aver\n INTEGER,DIMENSION(:,:),ALLOCATABLE::aux_ind\n DOUBLE PRECISION,DIMENSION(:,:),ALLOCATABLE::vects\n \n !Para diagonalizar:\n INTEGER::num_val,info,eigenlimit,lwork\n INTEGER, DIMENSION(:), ALLOCATABLE::iwork,ifail\n DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE::work\n \n \n eigenvals=0.0d0\n eigenvects=0.0d0\n \n dim_mat=num_parts*dims\n\n ALLOCATE(C(dim_mat,dim_mat),aver(dim_mat),aux_ind(num_parts,dims))\n \n C=0.0d0\n aver=0.0d0\n aux_ind=0\n \n \n gg=0\n DO kk1=1,dims\n DO jj1=1,num_parts\n gg=gg+1\n aux_ind(jj1,kk1)=gg\n END DO\n END DO\n \n DO ii=1,frames\n \n DO jj1=1,num_parts\n DO kk1=1,dims\n xx=aux_ind(jj1,kk1)\n aux_coor=traj(ii,jj1,kk1)\n \n aver(xx)=aver(xx)+aux_coor\n \n DO jj2=jj1,num_parts\n DO kk2=kk1,dims\n yy=aux_ind(jj2,kk2)\n \n C(xx,yy)=C(xx,yy)+aux_coor*traj(ii,jj2,kk2)\n \n END DO\n END DO\n END DO\n END DO\n \n END DO\n \n aver=aver\/(frames*1.0d0)\n \n DO kk1=1,dims\n DO jj1=1,num_parts\n xx=aux_ind(jj1,kk1)\n aver_xx=aver(xx)\n DO jj2=jj1,num_parts\n DO kk2=kk1,dims\n yy=aux_ind(jj2,kk2)\n C(xx,yy)=C(xx,yy)\/(frames*1.0d0)-aver_xx*aver(yy)\n C(yy,xx)=C(xx,yy)\n END DO\n END DO\n END DO\n END DO\n \n eigenlimit=dim_mat-num_eigenvs+1\n lwork=8*dim_mat\n ALLOCATE(work(lwork),iwork(5*dim_mat),ifail(dim_mat))\n ALLOCATE(vects(num_eigenvs,dim_mat),vals(num_eigenvs))\n vects=0.0d0\n vals=0.0d0\n work=0.0d0\n iwork=0\n ifail=0\n \n CALL dsyevx ('V','I','U',dim_mat,C,dim_mat,0,0,eigenlimit,dim_mat,0.0d0,num_val&\n &,vals,vects,dim_mat,work,8*dim_mat,iwork,ifail,info)\n \n IF (info\/=0) THEN\n \n print*,'# Error diagonalising the covariance matrix.'\n print*,'the array \"work\" should have the dimension:', work(1)\n STOP\n \n END IF\n \n DO ii=1,num_eigenvs\n gg=num_eigenvs-ii+1\n eigenvals(ii)=vals(gg)\n END DO\n \n DO ii=1,num_eigenvs\n gg=num_eigenvs-ii+1\n DO jj1=1,num_parts\n DO kk1=1,dims\n xx=aux_ind(jj1,kk1)\n eigenvects(ii,jj1,kk1)=vects(gg,xx)\n END DO\n END DO\n END DO\n \n DEALLOCATE(aux_ind,aver)\n DEALLOCATE(C,work,iwork,ifail)\n DEALLOCATE(vals,vects)\n \n END SUBROUTINE PCA\n \n\n subroutine prada1 (ybins,bins,min,max,delta_x,rv_min,rv_max,traj,tw,num_parts,len_traj,traj_out)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::ybins,bins,tw,len_traj,num_parts,rv_min,rv_max\n DOUBLE PRECISION,INTENT(IN)::delta_x,min,max\n DOUBLE PRECISION,DIMENSION(len_traj,num_parts,1),INTENT(IN)::traj\n INTEGER,DIMENSION(len_traj-2*tw,num_parts,bins),INTENT(OUT)::traj_out\n \n INTEGER::Ltw,Ltw1\n INTEGER::nn,ii,tt,kk,gg\n DOUBLE PRECISION::delta_y\n LOGICAL::filt_min,filt_max\n \n traj_out=0\n Ltw=(2*tw+1)\n Ltw1=Ltw-1\n delta_y=(1.0d0*ybins)\/(1.0d0*Ltw)\n \n filt_min=.FALSE.\n filt_max=.FALSE.\n \n IF (rv_min==1) THEN\n filt_min=.TRUE.\n END IF\n IF (rv_max==1) THEN\n filt_max=.TRUE.\n END IF\n\n IF ((filt_min.eqv..TRUE.).OR.(filt_max.eqv..TRUE.)) THEN\n DO nn=1,num_parts\n DO ii=1,len_traj\n tt=INT((traj(ii,nn,1)-min)\/delta_x)+1\n IF (filt_min.eqv..TRUE.) THEN\n IF (tt<1) THEN\n tt=1\n ELSE\n tt=tt+1\n END IF\n END IF\n IF (tt>bins) tt=bins\n DO kk=ii-tw,ii+tw\n gg=kk-tw\n IF ((gg>0).and.(gg<=(len_traj-Ltw1))) THEN\n traj_out(gg,nn,tt)=traj_out(gg,nn,tt)+1\n END IF\n END DO\n END DO\n END DO\n ELSE\n DO nn=1,num_parts\n DO ii=1,len_traj\n tt=INT((traj(ii,nn,1)-min)\/delta_x)+1\n IF (tt>bins) THEN\n tt=bins\n END IF\n DO kk=ii-tw,ii+tw\n gg=kk-tw\n IF ((gg>0).and.(gg<=(len_traj-Ltw1))) THEN\n traj_out(gg,nn,tt)=traj_out(gg,nn,tt)+1\n END IF\n END DO\n END DO\n END DO\n END IF\n \n DO nn=1,num_parts\n DO ii=1,len_traj-Ltw1\n DO kk=1,bins\n tt=CEILING(delta_y*traj_out(ii,nn,kk))\n traj_out(ii,nn,kk)=tt\n END DO\n END DO\n END DO\n \n \n END SUBROUTINE prada1\n \n\n subroutine prada11 (ybins,bins,min,max,delta_x,rv_min,rv_max,traj,tw,num_parts,len_traj,traj_out)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::ybins,bins,tw,len_traj,num_parts,rv_min,rv_max\n DOUBLE PRECISION,INTENT(IN)::delta_x,min,max\n DOUBLE PRECISION,DIMENSION(len_traj,num_parts,1),INTENT(IN)::traj\n INTEGER,DIMENSION(len_traj-2*tw,num_parts,bins),INTENT(OUT)::traj_out\n \n INTEGER::Ltw,Ltw1\n INTEGER::nn,ii,tt,kk,gg,qq\n DOUBLE PRECISION::delta_y\n LOGICAL::filt_min,filt_max\n INTEGER,DIMENSION(:),ALLOCATABLE::histo_aux\n\n traj_out=0\n Ltw=(2*tw+1)\n Ltw1=Ltw-1\n delta_y=(1.0d0*ybins)\/(1.0d0*Ltw)\n \n filt_min=.FALSE.\n filt_max=.FALSE.\n \n IF (rv_min==1) THEN\n filt_min=.TRUE.\n END IF\n IF (rv_max==1) THEN\n filt_max=.TRUE.\n END IF\n\n ALLOCATE(histo_aux(bins))\n\n IF ((filt_min.eqv..TRUE.).OR.(filt_max.eqv..TRUE.)) THEN\n \n DO nn=1,num_parts\n histo_aux=0\n DO ii=1,Ltw\n tt=INT((traj(ii,nn,1)-min)\/delta_x)+1\n IF (filt_min.eqv..TRUE.) THEN\n IF (tt<1) THEN\n tt=1\n ELSE\n tt=tt+1\n END IF\n END IF\n IF (tt>bins) tt=bins\n histo_aux(tt)=histo_aux(tt)+1\n END DO\n DO ii=1,len_traj-Ltw\n traj_out(tw+ii,nn,:)=histo_aux(:)\n qq=INT((traj(Ltw+ii,nn,1)-min)\/delta_x)+1\n IF (filt_min.eqv..TRUE.) THEN\n IF (qq<1) THEN\n qq=1\n ELSE\n qq=qq+1\n END IF\n END IF\n IF (qq>bins) qq=bins\n tt=INT((traj(ii,nn,1)-min)\/delta_x)+1\n IF (filt_min.eqv..TRUE.) THEN\n IF (tt<1) THEN\n tt=1\n ELSE\n tt=tt+1\n END IF\n END IF\n IF (tt>bins) tt=bins\n histo_aux(qq)=histo_aux(qq)+1\n histo_aux(tt)=histo_aux(tt)-1\n END DO\n traj_out(len_traj-Ltw1,nn,:)=histo_aux(:)\n END DO\n \n \n ELSE\n\n DO nn=1,num_parts\n histo_aux=0\n DO ii=1,Ltw\n tt=INT((traj(ii,nn,1)-min)\/delta_x)+1\n IF (tt>bins) tt=bins\n histo_aux(tt)=histo_aux(tt)+1\n END DO\n DO ii=1,len_traj-Ltw\n traj_out(tw+ii,nn,:)=histo_aux(:)\n qq=INT((traj(Ltw+ii,nn,1)-min)\/delta_x)+1\n IF (qq>bins) qq=bins\n tt=INT((traj(ii,nn,1)-min)\/delta_x)+1\n IF (tt>bins) tt=bins\n histo_aux(qq)=histo_aux(qq)+1\n histo_aux(tt)=histo_aux(tt)-1\n END DO\n traj_out(len_traj-Ltw1,nn,:)=histo_aux(:)\n END DO\n\n END IF\n\n DO nn=1,num_parts\n DO ii=1,len_traj-Ltw1\n DO kk=1,bins\n tt=CEILING(delta_y*traj_out(ii,nn,kk))\n traj_out(ii,nn,kk)=tt\n END DO\n END DO\n END DO\n \n \n END SUBROUTINE prada11\n \n\n\n subroutine prada2 (ybins,sbins,bins,min,max,delta_x,traj,tw,num_parts,len_traj,traj_out)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::ybins,sbins,bins,tw,len_traj,num_parts\n DOUBLE PRECISION,INTENT(IN)::delta_x,min,max\n DOUBLE PRECISION,DIMENSION(len_traj,num_parts,1),INTENT(IN)::traj\n INTEGER,DIMENSION(len_traj-2*tw,num_parts,bins+1),INTENT(OUT)::traj_out\n \n INTEGER::Ltw,Ltw1\n INTEGER::nn,ii,tt,kk,gg\n DOUBLE PRECISION::delta_y,sigma\n \n traj_out=0\n Ltw=(2*tw+1)\n Ltw1=Ltw-1\n delta_y=(1.0d0*ybins)\/(1.0d0*Ltw)\n \n \n DO nn=1,num_parts\n DO ii=tw+1,len_traj-tw-1\n DO kk=ii-tw,ii+tw\n tt=CEILING((traj(kk,nn,1)-min)\/delta_x)\n IF (tt>bins) tt=bins\n traj_out(ii,nn,tt)=traj_out(ii,nn,tt)+1\n END DO\n sigma=0.0d0\n DO kk=ii-tw,ii+tw-1\n sigma=sigma+(traj(kk+1,nn,1)-traj(kk,nn,1))**2\n END DO\n traj_out(ii,nn,bins+1)=int((sigma\/(1.0d0*Ltw))*sbins)\n END DO\n END DO\n \n DO nn=1,num_parts\n DO ii=1,len_traj-Ltw1\n DO kk=1,bins\n tt=CEILING(delta_y*traj_out(ii,nn,kk))\n traj_out(ii,nn,kk)=tt\n END DO\n END DO\n END DO\n \n END SUBROUTINE prada2\n \n \n \n \n \n \n subroutine ganna (opt_range,opt,ibins,imin,imax,idelta_x,rv_min,rv_max,traj,ksi,tw,num_parts,len_traj,traj_out)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN)::opt_range,opt,ibins,tw,len_traj,num_parts,rv_min,rv_max\n DOUBLE PRECISION,INTENT(IN)::idelta_x,imin,imax\n DOUBLE PRECISION,INTENT(IN)::ksi\n DOUBLE PRECISION,DIMENSION(len_traj,num_parts,1),INTENT(IN)::traj\n INTEGER,DIMENSION(len_traj-2*tw,num_parts,1),INTENT(OUT)::traj_out\n \n INTEGER::bins\n DOUBLE PRECISION::delta_x,min,max,sobra\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::cumul\n INTEGER::Ltw,Ltw1,num_rep\n DOUBLE PRECISION::dsm\n DOUBLE PRECISION,DIMENSION(:,:),ALLOCATABLE::cumul_list,aux_list\n LOGICAL,DIMENSION(:),ALLOCATABLE::filter\n DOUBLE PRECISION::dist\n INTEGER::ii,jj,gg,kk,tt,lll,nn\n LOGICAL::switch,filt_min,filt_max\n \n filt_min=.FALSE.\n filt_max=.FALSE.\n \n!!! For histogram:\n \n bins=ibins\n max=imax\n min=imin\n delta_x=idelta_x\n \n IF (opt_range==0) THEN\n IF (opt==1) THEN\n bins=CEILING((max-min)\/delta_x)\n sobra=(bins*delta_x-(max-min))\/2.0d0\n bins=bins+1\n min=min-sobra\n max=max+sobra\n ELSE\n delta_x=(max-min)\/(bins*1.0d0)\n END IF\n ELSE\n IF (opt==1) THEN\n bins=CEILING((max-min)\/delta_x)\n ELSE\n delta_x=(max-min)\/(bins*1.0d0)\n END IF\n END IF\n \n IF (rv_min==1) THEN\n bins=bins+1\n filt_min=.TRUE.\n END IF\n IF (rv_max==1) THEN\n bins=bins+1\n filt_max=.TRUE.\n END IF\n \n !!\n ALLOCATE(cumul(bins))\n cumul=0.0d0\n \n Ltw=(2*tw+1)\n Ltw1=Ltw-1\n \n traj_out=0\n num_rep=0\n dsm=sqrt(2.0d0\/(1.0d0*Ltw))*ksi !Kolmogorov-Smirnov\n \n DO nn=1,num_parts\n DO ii=1,len_traj-2*tw\n cumul=0.0d0\n IF ((filt_min.eqv..TRUE.).OR.(filt_max.eqv..TRUE.)) THEN\n DO kk=ii,ii+Ltw1\n tt=CEILING((traj(kk,nn,1)-min)\/delta_x)\n IF (filt_min.eqv..TRUE.) THEN\n IF (tt<1) THEN\n tt=1\n ELSE\n tt=tt+1\n END IF\n END IF\n IF (tt>bins) tt=bins\n cumul(tt)=cumul(tt)+1.0d0\n END DO\n ELSE\n DO kk=ii,ii+Ltw1\n tt=CEILING((traj(kk,nn,1)-min)\/delta_x)\n IF (tt==0) tt=1\n cumul(tt)=cumul(tt)+1.0d0\n END DO\n END IF\n cumul=cumul\/(1.0d0*Ltw)\n DO kk=1,bins-1\n cumul(kk+1)=cumul(kk+1)+cumul(kk)\n END DO\n switch=.true.\n DO jj=ii-1,1,-1\n gg=traj_out(jj,nn,1)\n IF (filter(gg).eqv..true.) THEN\n dist=MAXVAL(abs(cumul_list(gg,:)-cumul(:)),DIM=1)\n IF (dist<=dsm) THEN\n traj_out(ii,nn,1)=gg\n switch=.false.\n EXIT\n END IF\n filter(gg)=.false.\n IF (COUNT(filter,DIM=1)==0) THEN\n EXIT\n END IF\n END IF\n END DO\n IF (switch.eqv..true.) THEN\n DO jj=num_rep,1,-1\n IF (COUNT(filter,DIM=1)==0) THEN\n EXIT\n END IF\n IF (filter(jj).eqv..true.) THEN\n dist=MAXVAL(abs(cumul_list(jj,:)-cumul(:)),DIM=1)\n IF (dist<=dsm) THEN\n traj_out(ii,nn,1)=jj\n switch=.false.\n EXIT\n END IF\n filter(jj)=.false.\n END IF\n END DO\n END IF\n \n IF (switch.eqv..true.) THEN\n IF (num_rep>0) THEN\n ALLOCATE(aux_list(num_rep,bins))\n aux_list=cumul_list\n DEALLOCATE(cumul_list,filter)\n num_rep=num_rep+1\n ALLOCATE(cumul_list(num_rep,bins),filter(num_rep))\n filter=.true.\n cumul_list(1:(num_rep-1),:)=aux_list\n DEALLOCATE(aux_list)\n cumul_list(num_rep,:)=cumul\n traj_out(ii,nn,1)=num_rep\n ELSE\n num_rep=1\n ALLOCATE(cumul_list(num_rep,bins),filter(num_rep))\n filter=.true.\n cumul_list(num_rep,:)=cumul\n traj_out(ii,nn,1)=num_rep\n END IF\n ELSE\n filter=.true.\n END IF\n END DO\n END DO\n \n traj_out=traj_out-1\n \n DEALLOCATE(cumul_list,filter,cumul)\n \n \n END subroutine ganna\n\n\n subroutine free_distrib ()\n \n IMPLICIT NONE\n \n if (ALLOCATED(distrib)) DEALLOCATE(distrib)\n if (ALLOCATED(distrib_x)) DEALLOCATE(distrib_x)\n \n end subroutine free_distrib\n \n subroutine life_time_dist (opt_norm,traj,state,num_frames,num_parts,dims,num_states,mean)\n \n IMPLICIT NONE\n INTEGER,INTENT(IN):: opt_norm,num_parts,dims,num_frames,num_states\n DOUBLE PRECISION,DIMENSION(num_frames,num_parts,dims),INTENT(IN):: traj\n DOUBLE PRECISION,DIMENSION(num_states),INTENT(IN):: state\n DOUBLE PRECISION,INTENT(OUT):: mean\n \n INTEGER:: ii,jj,kk,ll,gg,contador,kkk,lll\n LOGICAL::inside_old,inside\n INTEGER:: contador_total\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::distrib_aux\n \n gg=100\n contador=0\n contador_total=0\n mean=0.0d0\n \n IF (ALLOCATED(distrib)) DEALLOCATE(distrib)\n IF (ALLOCATED(distrib_x)) DEALLOCATE(distrib_x)\n \n ALLOCATE(distrib(gg))\n distrib=0.0d0\n \n DO kkk=1,num_parts\n DO lll=1,dims\n contador=0\n inside_old=.false.\n DO ii=1,num_frames\n inside=.false.\n DO jj=1,num_states\n IF (traj(ii,kkk,lll)==state(jj)) THEN\n inside=.true.\n contador=contador+1\n EXIT\n END IF\n END DO\n \n IF ((inside_old.eqv..true.).and.(inside.eqv..false.)) THEN\n IF (contador>gg) THEN\n ALLOCATE(distrib_aux(gg))\n distrib_aux(:)=distrib(:)\n DEALLOCATE(distrib)\n ALLOCATE(distrib(contador))\n distrib(:gg)=distrib_aux(:)\n distrib((gg+1):)=0.0d0\n gg=contador\n DEALLOCATE(distrib_aux)\n END IF\n distrib(contador)=distrib(contador)+1.0d0\n contador_total=contador_total+contador\n mean=mean+1.0d0\n contador=0\n END IF\n \n inside_old=inside\n \n END DO\n END DO\n END DO\n \n mean=(contador_total*1.0d0)\/mean\n \n IF (opt_norm==1) THEN\n distrib(:)=distrib(:)\/(contador_total*1.0d0)\n END IF\n \n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n END IF\n END DO\n \n ALLOCATE(distrib_aux(jj),distrib_x(jj))\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n distrib_aux(jj)=distrib(ii)\n distrib_x(jj)=ii\n END IF\n END DO\n DEALLOCATE(distrib)\n ALLOCATE(distrib(jj))\n distrib=distrib_aux\n DEALLOCATE(distrib_aux)\n \n end subroutine life_time_dist\n \n subroutine fpt_dist (opt_norm,opt_from_state,opt_from_segment,opt_to_state,opt_to_segment, &\n from_state,from_segment,to_state,to_segment,traj,num_frames,num_parts,dims,from_num_states,to_num_states,mean)\n \n \n IMPLICIT NONE\n INTEGER,INTENT(IN):: opt_norm,opt_from_state,opt_from_segment,opt_to_state,opt_to_segment\n INTEGER,INTENT(IN):: num_parts,dims,num_frames\n INTEGER,INTENT(IN):: from_num_states,to_num_states\n DOUBLE PRECISION,DIMENSION(num_frames,num_parts,dims),INTENT(IN):: traj\n DOUBLE PRECISION,DIMENSION(from_num_states),INTENT(IN):: from_state\n DOUBLE PRECISION,DIMENSION(to_num_states),INTENT(IN):: to_state\n DOUBLE PRECISION,DIMENSION(2),INTENT(IN)::from_segment,to_segment\n DOUBLE PRECISION,INTENT(OUT):: mean\n \n INTEGER:: ii,jj,kk,ll,gg,contador,kkk,lll\n LOGICAL::entro,inside_to,inside_from\n INTEGER(KIND=8):: contador_total\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::distrib_aux\n DOUBLE PRECISION::pos\n \n gg=100\n contador=0\n contador_total=0\n mean=0.0d0\n \n IF (ALLOCATED(distrib)) DEALLOCATE(distrib)\n IF (ALLOCATED(distrib_x)) DEALLOCATE(distrib_x)\n \n ALLOCATE(distrib(gg))\n distrib=0.0d0\n\n DO kkk=1,num_parts\n DO lll=1,dims\n entro=.false.\n contador=0\n DO ii=num_frames,1,-1\n pos=traj(ii,kkk,lll)\n \n inside_to=.false.\n IF (opt_to_segment==1) THEN\n IF ((to_segment(1)gg) THEN\n ALLOCATE(distrib_aux(gg))\n distrib_aux(:)=distrib(:)\n DEALLOCATE(distrib)\n ALLOCATE(distrib(contador))\n distrib(:gg)=distrib_aux(:)\n distrib((gg+1):)=0.0d0\n gg=contador\n DEALLOCATE(distrib_aux)\n END IF\n distrib(contador)=distrib(contador)+1.0d0\n contador_total=contador_total+contador\n mean=mean+1.0d0\n END IF\n \n END DO\n END DO\n END DO\n \n IF (mean>0.0d0) THEN\n mean=(contador_total*1.0d0)\/mean\n ELSE\n mean=0.0d0\n END IF\n \n IF (opt_norm==1) THEN\n IF (contador_total==0) THEN\n distrib=0.0d0\n ELSE\n distrib(:)=distrib(:)\/(contador_total*1.0d0)\n END IF\n END IF\n \n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n END IF\n END DO\n \n IF (jj\/=0) THEN\n ALLOCATE(distrib_aux(jj),distrib_x(jj))\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n distrib_aux(jj)=distrib(ii)\n distrib_x(jj)=ii\n END IF\n END DO\n DEALLOCATE(distrib)\n ALLOCATE(distrib(jj))\n distrib=distrib_aux\n DEALLOCATE(distrib_aux)\n ELSE\n DEALLOCATE(distrib)\n ALLOCATE(distrib(1),distrib_x(1))\n distrib=0.0d0\n distrib_x=0.0d0\n END IF\n \n end subroutine fpt_dist\n \n \n subroutine tt_dist (opt_norm,opt_noreturn,opt_from_state,opt_from_segment,opt_to_state,opt_to_segment, &\n from_state,from_segment,to_state,to_segment,traj,num_frames,num_parts,dims,from_num_states,to_num_states,mean)\n \n \n IMPLICIT NONE\n INTEGER,INTENT(IN):: opt_norm,opt_from_state,opt_from_segment,opt_to_state,opt_to_segment,opt_noreturn\n INTEGER,INTENT(IN):: num_parts,dims,num_frames\n INTEGER,INTENT(IN):: from_num_states,to_num_states\n DOUBLE PRECISION,DIMENSION(num_frames,num_parts,dims),INTENT(IN):: traj\n DOUBLE PRECISION,DIMENSION(from_num_states),INTENT(IN):: from_state\n DOUBLE PRECISION,DIMENSION(to_num_states),INTENT(IN):: to_state\n DOUBLE PRECISION,DIMENSION(2),INTENT(IN)::from_segment,to_segment\n DOUBLE PRECISION,INTENT(OUT):: mean\n\n INTEGER:: ii,jj,kk,ll,gg,contador,kkk,lll\n LOGICAL::entro,inside_to,inside_from,last_from\n INTEGER(KIND=8):: contador_total\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::distrib_aux\n DOUBLE PRECISION::pos\n \n gg=100\n contador=0\n contador_total=0\n mean=0.0d0\n \n IF (ALLOCATED(distrib)) DEALLOCATE(distrib)\n IF (ALLOCATED(distrib_x)) DEALLOCATE(distrib_x)\n \n ALLOCATE(distrib(gg))\n distrib=0.0d0\n \n DO kkk=1,num_parts\n DO lll=1,dims\n entro=.false.\n last_from=.false.\n contador=0\n DO ii=num_frames,1,-1\n pos=traj(ii,kkk,lll)\n \n inside_to=.false.\n IF (opt_to_segment==1) THEN\n IF ((to_segment(1)gg) THEN\n ALLOCATE(distrib_aux(gg))\n distrib_aux(:)=distrib(:)\n DEALLOCATE(distrib)\n ALLOCATE(distrib(contador))\n distrib(:gg)=distrib_aux(:)\n distrib((gg+1):)=0.0d0\n gg=contador\n DEALLOCATE(distrib_aux)\n END IF\n distrib(contador)=distrib(contador)+1.0d0\n contador_total=contador_total+contador\n mean=mean+1.0d0\n \n IF (opt_noreturn==1) THEN\n entro=.false.\n contador=0\n END IF\n \n END IF\n \n last_from=inside_from\n \n END DO\n END DO\n END DO\n \n IF (mean>0.0d0) THEN\n mean=(contador_total*1.0d0)\/mean\n ELSE\n mean=0.0d0\n END IF\n \n IF (opt_norm==1) THEN\n IF (contador_total==0) THEN\n distrib=0.0d0\n ELSE\n distrib(:)=distrib(:)\/(contador_total*1.0d0)\n END IF\n END IF\n \n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n END IF\n END DO\n \n IF (jj\/=0) THEN\n ALLOCATE(distrib_aux(jj),distrib_x(jj))\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n distrib_aux(jj)=distrib(ii)\n distrib_x(jj)=ii\n END IF\n END DO\n DEALLOCATE(distrib)\n ALLOCATE(distrib(jj))\n distrib=distrib_aux\n DEALLOCATE(distrib_aux)\n ELSE\n DEALLOCATE(distrib)\n ALLOCATE(distrib(1),distrib_x(1))\n distrib=0.0d0\n distrib_x=0.0d0\n END IF\n \n end subroutine tt_dist\n\n\nsubroutine fcpt_dist (opt_norm,opt_noreturn,opt_states,opt_segments, &\n states,segments,commitment,traj,num_frames,num_parts,dims,num_states,num_segments,num_commits,mean)\n\n\n IMPLICIT NONE\n INTEGER,INTENT(IN):: opt_norm,opt_states,opt_segments,opt_noreturn\n INTEGER,INTENT(IN):: num_parts,dims,num_frames\n INTEGER,INTENT(IN):: num_states,num_segments,num_commits\n DOUBLE PRECISION,DIMENSION(num_frames,num_parts,dims),INTENT(IN):: traj\n DOUBLE PRECISION,DIMENSION(num_states),INTENT(IN):: states\n DOUBLE PRECISION,DIMENSION(num_segments,2),INTENT(IN)::segments\n INTEGER,DIMENSION(num_commits),INTENT(IN)::commitment\n DOUBLE PRECISION,INTENT(OUT):: mean\n\n INTEGER:: ii,jj,kk,ll,gg,contador,kkk,lll,toca\n INTEGER,DIMENSION(num_commits)::visited\n LOGICAL::entro,inside_to,inside_false\n LOGICAL:: hecho,listo,touch\n INTEGER(KIND=8):: contador_total\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::distrib_aux\n DOUBLE PRECISION::pos\n\n gg=100\n contador=0\n contador_total=0\n mean=0.0d0\n visited=0\n toca=0\n\n IF (ALLOCATED(distrib)) DEALLOCATE(distrib)\n IF (ALLOCATED(distrib_x)) DEALLOCATE(distrib_x)\n\n ALLOCATE(distrib(gg))\n distrib=0.0d0\n\n DO kkk=1,num_parts\n DO lll=1,dims\n entro=.false.\n touch=.false.\n contador=0\n DO ii=num_frames,1,-1\n\n pos=traj(ii,kkk,lll)\n\n inside_to=.false.\n listo=.false.\n IF (opt_segments==1) THEN\n IF ((segments(num_segments,1)gg) THEN\n ALLOCATE(distrib_aux(gg))\n distrib_aux(:)=distrib(:)\n DEALLOCATE(distrib)\n ALLOCATE(distrib(contador))\n distrib(:gg)=distrib_aux(:)\n distrib((gg+1):)=0.0d0\n gg=contador\n DEALLOCATE(distrib_aux)\n END IF\n distrib(contador)=distrib(contador)+1.0d0\n contador_total=contador_total+contador\n mean=mean+1.0d0\n END IF\n END IF\n ELSE\n contador=0\n END IF\n\n END DO\n END DO\n END DO\n \n IF (mean>0.0d0) THEN\n mean=(contador_total*1.0d0)\/mean\n ELSE\n mean=0.0d0\n END IF\n\n IF (opt_norm==1) THEN\n IF (contador_total==0) THEN\n distrib=0.0d0\n ELSE\n distrib(:)=distrib(:)\/(contador_total*1.0d0)\n END IF\n END IF\n\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n END IF\n END DO\n\n IF (jj\/=0) THEN\n ALLOCATE(distrib_aux(jj),distrib_x(jj))\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n distrib_aux(jj)=distrib(ii)\n distrib_x(jj)=ii\n END IF\n END DO\n DEALLOCATE(distrib)\n ALLOCATE(distrib(jj))\n distrib=distrib_aux\n DEALLOCATE(distrib_aux)\n ELSE\n DEALLOCATE(distrib)\n ALLOCATE(distrib(1),distrib_x(1))\n distrib=0.0d0\n distrib_x=0.0d0\n END IF\n\n\nend subroutine fcpt_dist\n\n\nsubroutine ctt_dist (opt_norm,opt_noreturn,opt_states,opt_segments, &\n states,segments,commitment,traj,num_frames,num_parts,dims,num_states,num_segments,num_commits,mean)\n\n\n IMPLICIT NONE\n INTEGER,INTENT(IN):: opt_norm,opt_states,opt_segments,opt_noreturn\n INTEGER,INTENT(IN):: num_parts,dims,num_frames\n INTEGER,INTENT(IN):: num_states,num_segments,num_commits\n DOUBLE PRECISION,DIMENSION(num_frames,num_parts,dims),INTENT(IN):: traj\n DOUBLE PRECISION,DIMENSION(num_states),INTENT(IN):: states\n DOUBLE PRECISION,DIMENSION(num_segments,2),INTENT(IN)::segments\n INTEGER,DIMENSION(num_commits),INTENT(IN)::commitment\n DOUBLE PRECISION,INTENT(OUT):: mean\n\n INTEGER:: ii,jj,kk,ll,gg,contador,kkk,lll,toca\n INTEGER,DIMENSION(num_commits)::visited\n LOGICAL::entro,inside_to,inside_false\n LOGICAL:: hecho,listo,touch,last_in\n INTEGER(KIND=8):: contador_total\n DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::distrib_aux\n DOUBLE PRECISION::pos\n\n gg=100\n contador=0\n contador_total=0\n mean=0.0d0\n visited=0\n toca=0\n\n IF (ALLOCATED(distrib)) DEALLOCATE(distrib)\n IF (ALLOCATED(distrib_x)) DEALLOCATE(distrib_x)\n\n ALLOCATE(distrib(gg))\n distrib=0.0d0\n\n DO kkk=1,num_parts\n DO lll=1,dims\n entro=.false.\n touch=.false.\n contador=0\n last_in=.false.\n DO ii=num_frames,1,-1\n\n pos=traj(ii,kkk,lll)\n\n inside_to=.false.\n listo=.false.\n IF (opt_segments==1) THEN\n IF ((segments(num_segments,1)gg) THEN\n ALLOCATE(distrib_aux(gg))\n distrib_aux(:)=distrib(:)\n DEALLOCATE(distrib)\n ALLOCATE(distrib(contador))\n distrib(:gg)=distrib_aux(:)\n distrib((gg+1):)=0.0d0\n gg=contador\n DEALLOCATE(distrib_aux)\n END IF\n distrib(contador)=distrib(contador)+1.0d0\n contador_total=contador_total+contador\n mean=mean+1.0d0\n END IF\n END IF\n ELSE\n contador=0\n END IF\n \n last_in=touch\n\n END DO\n END DO\n END DO\n \n IF (mean>0.0d0) THEN\n mean=(contador_total*1.0d0)\/mean\n ELSE\n mean=0.0d0\n END IF\n\n IF (opt_norm==1) THEN\n IF (contador_total==0) THEN\n distrib=0.0d0\n ELSE\n distrib(:)=distrib(:)\/(contador_total*1.0d0)\n END IF\n END IF\n\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n END IF\n END DO\n\n IF (jj\/=0) THEN\n ALLOCATE(distrib_aux(jj),distrib_x(jj))\n jj=0\n DO ii=1,gg\n IF (distrib(ii)>0.0d0) THEN\n jj=jj+1\n distrib_aux(jj)=distrib(ii)\n distrib_x(jj)=ii\n END IF\n END DO\n DEALLOCATE(distrib)\n ALLOCATE(distrib(jj))\n distrib=distrib_aux\n DEALLOCATE(distrib_aux)\n ELSE\n DEALLOCATE(distrib)\n ALLOCATE(distrib(1),distrib_x(1))\n distrib=0.0d0\n distrib_x=0.0d0\n END IF\n\n\nend subroutine ctt_dist\n\nEND MODULE GLOB\n","avg_line_length":28.1599597586,"max_line_length":117,"alphanum_fraction":0.5014111679} {"size":55468,"ext":"f90","lang":"FORTRAN","max_stars_count":6.0,"content":"!\n! SEISMIC_CPML Version 1.1.3, July 2018.\n!\n! Copyright CNRS, France.\n! Contributor: Dimitri Komatitsch, komatitsch aT lma DOT cnrs-mrs DOT fr\n!\n! This software is a computer program whose purpose is to solve\n! the two-dimensional heterogeneous isotropic viscoelastic wave equation\n! using a finite-difference method with Convolutional Perfectly Matched\n! Layer (C-PML) conditions.\n!\n! This program is free software; you can redistribute it and\/or modify\n! it under the terms of the GNU General Public License as published by\n! the Free Software Foundation; either version 3 of the License, or\n! (at your option) any later version.\n!\n! This program is distributed in the hope that it will be useful,\n! but WITHOUT ANY WARRANTY; without even the implied warranty of\n! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n! GNU General Public License for more details.\n!\n! You should have received a copy of the GNU General Public License along\n! with this program; if not, write to the Free Software Foundation, Inc.,\n! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n!\n! The full text of the license is available in file \"LICENSE\".\n\n program seismic_CPML_2D_viscoelast_fourth\n\n! 2D finite-difference code in velocity and stress formulation\n! with Convolutional-PML (C-PML) absorbing conditions for an heterogeneous isotropic viscoelastic medium\n\n! Dimitri Komatitsch, CNRS, Marseille, July 2018.\n\n! A fourth-order spatially-staggered grid formulation is used:\n!\n! ^ y\n! |\n! |\n!\n! +-------------------+\n! | |\n! | |\n! | |\n! | |\n! | v_y |\n! sigma_xy +---------+ |\n! e13 | | |\n! (memory | | |\n! variable) | | |\n! | | |\n! | | |\n! +---------+---------+ ---> x\n! v_x sigma_xx\n! sigma_yy\n! e1 (viscoelastic memory variable)\n! e11 (viscoelastic memory variable)\n!\n\n! The C-PML implementation is based in part on formulas given in Roden and Gedney (2000).\n! If you use this code for your own research, please cite some (or all) of these\n! articles:\n!\n! @ARTICLE{MaKoEz08,\n! author = {Roland Martin and Dimitri Komatitsch and Abdela\\^aziz Ezziani},\n! title = {An unsplit convolutional perfectly matched layer improved at grazing\n! incidence for seismic wave equation in poroelastic media},\n! journal = {Geophysics},\n! year = {2008},\n! volume = {73},\n! pages = {T51-T61},\n! number = {4},\n! doi = {10.1190\/1.2939484}}\n!\n! @ARTICLE{MaKo09,\n! author = {Roland Martin and Dimitri Komatitsch},\n! title = {An unsplit convolutional perfectly matched layer technique improved\n! at grazing incidence for the viscoelastic wave equation},\n! journal = {Geophysical Journal International},\n! year = {2009},\n! volume = {179},\n! pages = {333-344},\n! number = {1},\n! doi = {10.1111\/j.1365-246X.2009.04278.x}}\n!\n! @ARTICLE{MaKoGe08,\n! author = {Roland Martin and Dimitri Komatitsch and Stephen D. Gedney},\n! title = {A variational formulation of a stabilized unsplit convolutional perfectly\n! matched layer for the isotropic or anisotropic seismic wave equation},\n! journal = {Computer Modeling in Engineering and Sciences},\n! year = {2008},\n! volume = {37},\n! pages = {274-304},\n! number = {3}}\n!\n! @ARTICLE{KoMa07,\n! author = {Dimitri Komatitsch and Roland Martin},\n! title = {An unsplit convolutional {P}erfectly {M}atched {L}ayer improved\n! at grazing incidence for the seismic wave equation},\n! journal = {Geophysics},\n! year = {2007},\n! volume = {72},\n! number = {5},\n! pages = {SM155-SM167},\n! doi = {10.1190\/1.2757586}}\n!\n! The original CPML technique for Maxwell's equations is described in:\n!\n! @ARTICLE{RoGe00,\n! author = {J. A. Roden and S. D. Gedney},\n! title = {Convolution {PML} ({CPML}): {A}n Efficient {FDTD} Implementation\n! of the {CFS}-{PML} for Arbitrary Media},\n! journal = {Microwave and Optical Technology Letters},\n! year = {2000},\n! volume = {27},\n! number = {5},\n! pages = {334-339},\n! doi = {10.1002\/1098-2760(20001205)27:5 < 334::AID-MOP14>3.0.CO;2-A}}\n\n!\n! To display the 2D results as color images, use:\n!\n! \" display image*.gif \" or \" gimp image*.gif \"\n!\n! or\n!\n! \" montage -geometry +0+3 -rotate 90 -tile 1x21 image*Vx*.gif allfiles_Vx.gif \"\n! \" montage -geometry +0+3 -rotate 90 -tile 1x21 image*Vy*.gif allfiles_Vy.gif \"\n! then \" display allfiles_Vx.gif \" or \" gimp allfiles_Vx.gif \"\n! then \" display allfiles_Vy.gif \" or \" gimp allfiles_Vy.gif \"\n!\n\n! IMPORTANT : all our CPML codes work fine in single precision as well (which is significantly faster).\n! If you want you can thus force automatic conversion to single precision at compile time\n! or change all the declarations and constants in the code from double precision to single.\n\n implicit none\n\n! include viscoelastic attenuation or not\n logical, parameter :: VISCOELASTIC_ATTENUATION = .true.\n\n! flags to add PML layers to the edges of the grid\n logical, parameter :: USE_PML_XMIN = .true.\n logical, parameter :: USE_PML_XMAX = .true.\n logical, parameter :: USE_PML_YMIN = .true.\n logical, parameter :: USE_PML_YMAX = .true.\n\n! total number of grid points in each direction of the grid\n integer, parameter :: NX = 2001\n integer, parameter :: NY = 2001\n\n! size of a grid cell\n double precision, parameter :: DELTAX = 1.5d0\n double precision, parameter :: DELTAY = DELTAX\n\n! thickness of the PML layer in grid points\n integer, parameter :: NPOINTS_PML = 10\n\n! P-velocity and density\n! the unrelaxed value is the value at frequency = 0 (the relaxed value would be the value at frequency = +infinity)\n double precision, parameter :: cp_unrelaxed = 2000.d0\n double precision, parameter :: cs_unrelaxed = cp_unrelaxed \/ 1.732d0\n double precision, parameter :: density = 2000.d0\n\n! Time step in seconds.\n! The CFL stability number for the O(2,2) algorithm is 1 \/ sqrt(2) = 0.707\n! i.e. one must choose cp * deltat \/ deltax < 0.707.\n! For the O(2,4) algorithm used here it is a bit more restrictive,\n! it is cp * deltat \/ deltax < 0.606 (see Levander 1988 eq (7)).\n! However this only ensures that the scheme is stable. To have a scheme that is both stable and accurate,\n! for O(2,4) some numerical tests show that one needs to take about half of that,\n! i.e. choose deltat so that cp * deltat \/ deltax is equal to about 0.30 or so. (or any value below; but not above).\n! Since the time scheme is only second order, this also depends on how many time steps are performed in total\n! (i.e. what the value of NSTEP below is); for large values of NSTEP, of course numerical errors will start to accumulate.\n double precision, parameter :: DELTAT = 2.2d-4\n\n! total number of time steps\n integer, parameter :: NSTEP = 5200\n\n! parameters for the source\n double precision, parameter :: f0 = 35.d0\n double precision, parameter :: t0 = 1.20d0 \/ f0\n double precision, parameter :: factor = 1.d0\n\n! source (force)\n double precision, parameter :: xsource = 1500.d0\n double precision, parameter :: ysource = 1500.d0\n integer, parameter :: ISOURCE = xsource \/ DELTAX + 1\n integer, parameter :: JSOURCE = ysource \/ DELTAY + 1\n! angle of source force in degrees and clockwise, with respect to the vertical (Y) axis\n double precision, parameter :: ANGLE_FORCE = 0.d0\n\n! receivers\n integer, parameter :: NREC = 1\n!! DK DK I use 2301 here instead of 2300 in order to fall exactly on a grid point\n double precision, parameter :: xdeb = 2301.d0 ! first receiver x in meters\n double precision, parameter :: ydeb = 2301.d0 ! first receiver y in meters\n double precision, parameter :: xfin = 2301.d0 ! last receiver x in meters\n double precision, parameter :: yfin = 2301.d0 ! last receiver y in meters\n\n! to compute energy curves for the whole medium (optional, but useful e.g. to produce\n! energy variation figures for articles); but expensive option, thus off by default\n logical, parameter :: COMPUTE_ENERGY = .false.\n\n! display information on the screen from time to time\n integer, parameter :: IT_DISPLAY = 200\n\n! compute some constants once and for all for the fourth-order spatial scheme\n! These coefficients are given for instance by Levander, Geophysics, vol. 53(11), p. 1436, equation (A-2)\n double precision, parameter :: NINE_OVER_8_DELTAX = 9.d0 \/ (8.d0*DELTAX)\n double precision, parameter :: NINE_OVER_8_DELTAY = 9.d0 \/ (8.d0*DELTAY)\n double precision, parameter :: ONE_OVER_24_DELTAX = 1.d0 \/ (24.d0*DELTAX)\n double precision, parameter :: ONE_OVER_24_DELTAY = 1.d0 \/ (24.d0*DELTAY)\n\n! value of PI\n double precision, parameter :: PI = 3.141592653589793238462643d0\n\n! conversion from degrees to radians\n double precision, parameter :: DEGREES_TO_RADIANS = PI \/ 180.d0\n\n! zero\n double precision, parameter :: ZERO = 0.d0\n\n double precision, parameter :: TWO_THIRDS = 2.d0 \/ 3.d0\n\n! large value for maximum\n double precision, parameter :: HUGEVAL = 1.d+30\n\n! threshold above which we consider that the code became unstable\n double precision, parameter :: STABILITY_THRESHOLD = 1.d+25\n\n! main arrays\n! in order to be able to use a fourth-order spatial operator on the edges of the model\n! here we define the arrays with size (0:NX+1,0:NY+1) instead of size (NX,NY) as in the second-order case\n double precision, dimension(0:NX+1,0:NY+1) :: vx,vy,sigma_xx,sigma_yy,sigma_xy,lambda_unrelaxed,mu_unrelaxed,rho\n\n! to interpolate material parameters or velocity at the right location in the staggered grid cell\n double precision :: lambda_half_x,mu_half_x,lambda_plus_mu_half_x,lambda_plus_two_mu_half_x,mu_half_y\n double precision :: rho_half_x_half_y,vy_interpolated\n\n! for evolution of total energy in the medium\n double precision :: epsilon_xx,epsilon_yy,epsilon_xy\n double precision, dimension(NSTEP) :: total_energy_kinetic,total_energy_potential\n\n! power to compute d0 profile\n double precision, parameter :: NPOWER = 2.d0\n\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-11\n double precision, parameter :: K_MAX_PML = 1.d0\n double precision, parameter :: ALPHA_MAX_PML = 2.d0*PI*(f0\/2.d0) ! from Festa and Vilotte\n\n! arrays for the memory variables\n! could declare these arrays in PML only to save a lot of memory, but proof of concept only here\n double precision, dimension(NX,NY) :: &\n memory_dvx_dx, &\n memory_dvx_dy, &\n memory_dvy_dx, &\n memory_dvy_dy, &\n memory_dsigma_xx_dx, &\n memory_dsigma_yy_dy, &\n memory_dsigma_xy_dx, &\n memory_dsigma_xy_dy\n\n double precision :: &\n value_dvx_dx, &\n value_dvx_dy, &\n value_dvy_dx, &\n value_dvy_dy, &\n value_dsigma_xx_dx, &\n value_dsigma_yy_dy, &\n value_dsigma_xy_dx, &\n value_dsigma_xy_dy\n\n! 1D arrays for the damping profiles\n double precision, dimension(NX) :: d_x,K_x,alpha_x,a_x,b_x,d_x_half,K_x_half,alpha_x_half,a_x_half,b_x_half, &\n one_over_K_x,one_over_K_x_half\n double precision, dimension(NY) :: d_y,K_y,alpha_y,a_y,b_y,d_y_half,K_y_half,alpha_y_half,a_y_half,b_y_half, &\n one_over_K_y,one_over_K_y_half\n\n double precision :: thickness_PML_x,thickness_PML_y,xoriginleft,xoriginright,yoriginbottom,yorigintop\n double precision :: Rcoef,d0_x,d0_y,xval,yval,abscissa_in_PML,abscissa_normalized\n\n! for the source\n double precision :: a,t,force_x,force_y,force_source_term\n\n! for receivers\n! Please note something important: the two components of the velocity vector are not defined at the same location,\n! Vy is half a grid cell away from Vx (see ASCII figure at the beginning of this program).\n! Thus this means there are \"two receivers\" rather than one, one recording Vx and another one, half a grid cell away, recording Vy.\n! If you need to use both components in real applications (and of course we will),\n! you will need to interpolate Vy to the location of Vx using:\n!\n! interpolate vy back at the location of vx, to be able to use both at the same location\n! vy_interpolated = 0.25d0 * (vy(i,j) + vy(i-1,j) + vy(i-1,j-1) + vy(i,j-1))\n!\n double precision xspacerec,yspacerec,distval,dist\n integer, dimension(NREC) :: ix_rec,iy_rec\n double precision, dimension(NREC) :: xrec,yrec\n integer :: myNREC\n\n! for seismograms\n double precision, dimension(NSTEP,NREC) :: sisvx,sisvy,sispressure\n\n integer :: i,j,it,irec\n\n double precision :: Courant_number,velocnorm\n\n! for attenuation (viscoelasticity)\n\n! attenuation quality factors Qp and Qs to use\n! BEWARE: we use Qp and Qs here, not QKappa and Qmu.\n! BEWARE: While Qmu is always equal to Qs, QKappa is not equal to Qp,\n! BEWARE: to convert from one to the other if your input data have Qkappa and Qmu you can use\n! BEWARE: the program conversion_between_Qp_Qs_and_Qkappa_Qmu_from_Dahlen_Tromp_959_960_in_3D_and_in_2D_plane_strain.f90\n! BEWARE: that is included in this software package.\n double precision, parameter :: Qp = 65.d0\n double precision, parameter :: Qs = 55.d0\n\n! number of Zener standard linear solids in parallel\n integer, parameter :: N_SLS = 3\n\n! attenuation constants\n double precision, dimension(N_SLS) :: tau_epsilon_nu1,tau_sigma_nu1,one_over_tau_sigma_nu1, &\n HALF_DELTAT_over_tau_sigma_nu1,multiplication_factor_tau_sigma_nu1,DELTAT_phi_nu1\n double precision, dimension(N_SLS) :: tau_epsilon_nu2,tau_sigma_nu2,one_over_tau_sigma_nu2, &\n HALF_DELTAT_over_tau_sigma_nu2,multiplication_factor_tau_sigma_nu2,DELTAT_phi_nu2\n\n! memory variable and other arrays for attenuation\n double precision, dimension(NX,NY,N_SLS) :: memory_variable_R_e1_dot,memory_variable_R_e1_dot_old\n double precision, dimension(NX,NY,N_SLS) :: memory_variable_R_e11_dot,memory_variable_R_e11_dot_old\n double precision, dimension(NX,NY,N_SLS) :: memory_variable_R_e13_dot,memory_variable_R_e13_dot_old\n integer :: i_sls\n double precision :: sum_of_memory_variables_e1,sum_of_memory_variables_e11,sum_of_memory_variables_e13\n\n! this defines the typical frequency range in which we use optimization to find the tau values that fit a given Q in that band\n double precision :: f_min_attenuation,f_max_attenuation\n\n!---\n!--- program starts here\n!---\n\n print *\n print *,'2D viscoelastic finite-difference code in velocity and stress formulation with C-PML'\n print *\n\n! display size of the model\n print *\n print *,'NX = ',NX\n print *,'NY = ',NY\n print *\n print *,'size of the model along X = ',(NX - 1) * DELTAX\n print *,'size of the model along Y = ',(NY - 1) * DELTAY\n print *\n print *,'Total number of grid points = ',NX * NY\n print *\n\n! for attenuation (viscoelasticity)\n if (VISCOELASTIC_ATTENUATION) then\n\n print *,'Qp quality factor used for attenuation = ',Qp\n print *,'Qs quality factor used for attenuation = ',Qs\n print *,'Number of Zener standard linear solids used to mimic the viscoelastic behavior (N_SLS) = ',N_SLS\n print *\n\n! this defines the typical frequency range in which we use optimization to find the tau values that fit a given Q in that band\n! f_min and f_max are computed as : f_max\/f_min=12 and (log(f_min)+log(f_max))\/2 = log(f0)\n f_min_attenuation = exp(log(f0)-log(12.d0)\/2.d0)\n f_max_attenuation = 12.d0 * f_min_attenuation\n\n! call the SolvOpt() nonlinear optimization routine to compute the tau_epsilon and tau_sigma values from a given Q factor\n print *,'Values for Qp:'\n print *\n call compute_attenuation_coeffs(N_SLS,Qp,f0,f_min_attenuation,f_max_attenuation,tau_epsilon_nu1,tau_sigma_nu1)\n print *,'Values for Qs:'\n print *\n call compute_attenuation_coeffs(N_SLS,Qs,f0,f_min_attenuation,f_max_attenuation,tau_epsilon_nu2,tau_sigma_nu2)\n\n else\n\n! dummy values in the non-dissipative case\n tau_epsilon_nu1(:) = 1.d0\n tau_sigma_nu1(:) = 1.d0\n\n tau_epsilon_nu2(:) = 1.d0\n tau_sigma_nu2(:) = 1.d0\n\n endif\n\n! precompute the inverse once and for all, to save computation time in the time loop below\n! (on computers, a multiplication is very significantly cheaper than a division)\n one_over_tau_sigma_nu1(:) = 1.d0 \/ tau_sigma_nu1(:)\n one_over_tau_sigma_nu2(:) = 1.d0 \/ tau_sigma_nu2(:)\n\n HALF_DELTAT_over_tau_sigma_nu1(:) = 0.5d0 * DELTAT \/ tau_sigma_nu1(:)\n HALF_DELTAT_over_tau_sigma_nu2(:) = 0.5d0 * DELTAT \/ tau_sigma_nu2(:)\n\n multiplication_factor_tau_sigma_nu1(:) = 1.d0 \/ (1.d0 + 0.5d0 * DELTAT * one_over_tau_sigma_nu1(:))\n multiplication_factor_tau_sigma_nu2(:) = 1.d0 \/ (1.d0 + 0.5d0 * DELTAT * one_over_tau_sigma_nu2(:))\n\n ! use the right formula with 1\/N included\n DELTAT_phi_nu1(:) = DELTAT * (1.d0 - tau_epsilon_nu1(:)\/tau_sigma_nu1(:)) \/ tau_sigma_nu1(:) \/ sum(tau_epsilon_nu1\/tau_sigma_nu1)\n DELTAT_phi_nu2(:) = DELTAT * (1.d0 - tau_epsilon_nu2(:)\/tau_sigma_nu2(:)) \/ tau_sigma_nu2(:) \/ sum(tau_epsilon_nu2\/tau_sigma_nu2)\n\n!--- define profile of absorption in PML region\n\n! thickness of the PML layer in meters\n thickness_PML_x = NPOINTS_PML * DELTAX\n thickness_PML_y = NPOINTS_PML * DELTAY\n\n! reflection coefficient (INRIA report section 6.1) http:\/\/hal.inria.fr\/docs\/00\/07\/32\/19\/PDF\/RR-3471.pdf\n Rcoef = 0.001d0\n\n! check that NPOWER is okay\n if (NPOWER < 1) stop 'NPOWER must be greater than 1'\n\n! compute d0 from INRIA report section 6.1 http:\/\/hal.inria.fr\/docs\/00\/07\/32\/19\/PDF\/RR-3471.pdf\n d0_x = - (NPOWER + 1) * cp_unrelaxed * log(Rcoef) \/ (2.d0 * thickness_PML_x)\n d0_y = - (NPOWER + 1) * cp_unrelaxed * log(Rcoef) \/ (2.d0 * thickness_PML_y)\n\n print *,'d0_x = ',d0_x\n print *,'d0_y = ',d0_y\n print *\n\n d_x(:) = ZERO\n d_x_half(:) = ZERO\n K_x(:) = 1.d0\n K_x_half(:) = 1.d0\n alpha_x(:) = ZERO\n alpha_x_half(:) = ZERO\n a_x(:) = ZERO\n a_x_half(:) = ZERO\n\n d_y(:) = ZERO\n d_y_half(:) = ZERO\n K_y(:) = 1.d0\n K_y_half(:) = 1.d0\n alpha_y(:) = ZERO\n alpha_y_half(:) = ZERO\n a_y(:) = ZERO\n a_y_half(:) = ZERO\n\n! damping in the X direction\n\n! origin of the PML layer (position of right edge minus thickness, in meters)\n xoriginleft = thickness_PML_x\n xoriginright = (NX-1)*DELTAX - thickness_PML_x\n\n do i = 1,NX\n\n! abscissa of current grid point along the damping profile\n xval = DELTAX * dble(i-1)\n\n!---------- left edge\n if (USE_PML_XMIN) then\n\n! define damping profile at the grid points\n abscissa_in_PML = xoriginleft - xval\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_x\n d_x(i) = d0_x * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_x(i) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_x(i) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n! define damping profile at half the grid points\n abscissa_in_PML = xoriginleft - (xval + DELTAX\/2.d0)\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_x\n d_x_half(i) = d0_x * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_x_half(i) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_x_half(i) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n endif\n\n!---------- right edge\n if (USE_PML_XMAX) then\n\n! define damping profile at the grid points\n abscissa_in_PML = xval - xoriginright\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_x\n d_x(i) = d0_x * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_x(i) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_x(i) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n! define damping profile at half the grid points\n abscissa_in_PML = xval + DELTAX\/2.d0 - xoriginright\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_x\n d_x_half(i) = d0_x * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_x_half(i) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_x_half(i) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n endif\n\n! just in case, for -5 at the end\n if (alpha_x(i) < ZERO) alpha_x(i) = ZERO\n if (alpha_x_half(i) < ZERO) alpha_x_half(i) = ZERO\n\n b_x(i) = exp(- (d_x(i) \/ K_x(i) + alpha_x(i)) * DELTAT)\n b_x_half(i) = exp(- (d_x_half(i) \/ K_x_half(i) + alpha_x_half(i)) * DELTAT)\n\n! this to avoid division by zero outside the PML\n if (abs(d_x(i)) > 1.d-6) a_x(i) = d_x(i) * (b_x(i) - 1.d0) \/ (K_x(i) * (d_x(i) + K_x(i) * alpha_x(i)))\n if (abs(d_x_half(i)) > 1.d-6) a_x_half(i) = d_x_half(i) * &\n (b_x_half(i) - 1.d0) \/ (K_x_half(i) * (d_x_half(i) + K_x_half(i) * alpha_x_half(i)))\n\n enddo\n\n! damping in the Y direction\n\n! origin of the PML layer (position of right edge minus thickness, in meters)\n yoriginbottom = thickness_PML_y\n yorigintop = (NY-1)*DELTAY - thickness_PML_y\n\n do j = 1,NY\n\n! abscissa of current grid point along the damping profile\n yval = DELTAY * dble(j-1)\n\n!---------- bottom edge\n if (USE_PML_YMIN) then\n\n! define damping profile at the grid points\n abscissa_in_PML = yoriginbottom - yval\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_y\n d_y(j) = d0_y * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_y(j) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_y(j) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n! define damping profile at half the grid points\n abscissa_in_PML = yoriginbottom - (yval + DELTAY\/2.d0)\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_y\n d_y_half(j) = d0_y * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_y_half(j) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_y_half(j) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n endif\n\n!---------- top edge\n if (USE_PML_YMAX) then\n\n! define damping profile at the grid points\n abscissa_in_PML = yval - yorigintop\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_y\n d_y(j) = d0_y * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_y(j) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_y(j) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n! define damping profile at half the grid points\n abscissa_in_PML = yval + DELTAY\/2.d0 - yorigintop\n if (abscissa_in_PML >= ZERO) then\n abscissa_normalized = abscissa_in_PML \/ thickness_PML_y\n d_y_half(j) = d0_y * abscissa_normalized**NPOWER\n! from Stephen Gedney's unpublished class notes for class EE699, lecture 8, slide 8-2\n K_y_half(j) = 1.d0 + (K_MAX_PML - 1.d0) * abscissa_normalized**NPOWER\n alpha_y_half(j) = ALPHA_MAX_PML * (1.d0 - abscissa_normalized)\n endif\n\n endif\n\n b_y(j) = exp(- (d_y(j) \/ K_y(j) + alpha_y(j)) * DELTAT)\n b_y_half(j) = exp(- (d_y_half(j) \/ K_y_half(j) + alpha_y_half(j)) * DELTAT)\n\n! this to avoid division by zero outside the PML\n if (abs(d_y(j)) > 1.d-6) a_y(j) = d_y(j) * (b_y(j) - 1.d0) \/ (K_y(j) * (d_y(j) + K_y(j) * alpha_y(j)))\n if (abs(d_y_half(j)) > 1.d-6) a_y_half(j) = d_y_half(j) * &\n (b_y_half(j) - 1.d0) \/ (K_y_half(j) * (d_y_half(j) + K_y_half(j) * alpha_y_half(j)))\n\n enddo\n\n! precompute the inverse once and for all, to save computation time in the time loop below\n! (on computers, a multiplication is very significantly cheaper than a division)\n one_over_K_x(:) = 1.d0 \/ K_x(:)\n one_over_K_x_half(:) = 1.d0 \/ K_x_half(:)\n one_over_K_y(:) = 1.d0 \/ K_y(:)\n one_over_K_y_half(:) = 1.d0 \/ K_y_half(:)\n\n! compute the Lame parameter and density\n do j = 1,NY\n do i = 1,NX\n rho(i,j) = density\n mu_unrelaxed(i,j) = density*cs_unrelaxed*cs_unrelaxed\n lambda_unrelaxed(i,j) = density*cp_unrelaxed*cp_unrelaxed - 2.d0*mu_unrelaxed(i,j)\n enddo\n enddo\n\n! print position of the source\n print *,'Position of the source:'\n print *\n print *,'x = ',xsource\n print *,'y = ',ysource\n print *\n\n! define location of receivers\n print *,'There are ',nrec,' receivers'\n print *\n if (NREC > 1) then\n! this is to avoid a warning with GNU gfortran at compile time about division by zero when NREC = 1\n myNREC = NREC\n xspacerec = (xfin-xdeb) \/ dble(myNREC-1)\n yspacerec = (yfin-ydeb) \/ dble(myNREC-1)\n else\n xspacerec = 0.d0\n yspacerec = 0.d0\n endif\n do irec=1,nrec\n xrec(irec) = xdeb + dble(irec-1)*xspacerec\n yrec(irec) = ydeb + dble(irec-1)*yspacerec\n enddo\n\n! find closest grid point for each receiver\n do irec=1,nrec\n dist = HUGEVAL\n do j = 1,NY\n do i = 1,NX\n distval = sqrt((DELTAX*dble(i-1) - xrec(irec))**2 + (DELTAY*dble(j-1) - yrec(irec))**2)\n if (distval < dist) then\n dist = distval\n ix_rec(irec) = i\n iy_rec(irec) = j\n endif\n enddo\n enddo\n print *,'receiver ',irec,' x_target,y_target = ',xrec(irec),yrec(irec)\n print *,'closest grid point found at distance ',dist,' in i,j = ',ix_rec(irec),iy_rec(irec)\n print *\n enddo\n\n! check the Courant stability condition for the explicit time scheme\n! R. Courant, K. O. Friedrichs and H. Lewy (1928)\n! For this O(2,4) scheme, when DELTAX == DELTAY the Courant number is given by Levander, Geophysics, vol. 53(11), p. 1427,\n! equation (7) and is equal to 0.606 (it is thus smaller than that of the O(2,2) scheme, which is 1\/sqrt(2) = 0.707,\n! i.e. when switching to a fourth-order spatial scheme one needs a time step that is about 0.707 \/ 0.606 = 1.167 times smaller.\n if (DELTAX == DELTAY) then\n Courant_number = cp_unrelaxed * DELTAT \/ DELTAX\n print *,'Courant number is ',Courant_number\n print *,' (the maximum possible value is 0.606; in practice for accuracy reasons a value not larger than 0.30 is recommended)'\n print *\n if (Courant_number > 0.606) stop 'time step is too large, simulation will be unstable'\n endif\n\n! suppress old files (can be commented out if \"call system\" is missing in your compiler)\n call system('rm -f Vx_file*.dat Vy_file*.dat image*.pnm image*.gif')\n\n! initialize arrays\n vx(:,:) = ZERO\n vy(:,:) = ZERO\n sigma_xx(:,:) = ZERO\n sigma_yy(:,:) = ZERO\n sigma_xy(:,:) = ZERO\n memory_variable_R_e1_dot(:,:,:) = ZERO\n memory_variable_R_e1_dot_old(:,:,:) = ZERO\n memory_variable_R_e11_dot(:,:,:) = ZERO\n memory_variable_R_e11_dot_old(:,:,:) = ZERO\n memory_variable_R_e13_dot(:,:,:) = ZERO\n memory_variable_R_e13_dot_old(:,:,:) = ZERO\n\n! PML\n memory_dvx_dx(:,:) = ZERO\n memory_dvx_dy(:,:) = ZERO\n memory_dvy_dx(:,:) = ZERO\n memory_dvy_dy(:,:) = ZERO\n memory_dsigma_xx_dx(:,:) = ZERO\n memory_dsigma_yy_dy(:,:) = ZERO\n memory_dsigma_xy_dx(:,:) = ZERO\n memory_dsigma_xy_dy(:,:) = ZERO\n\n! initialize seismograms\n sisvx(:,:) = ZERO\n sisvy(:,:) = ZERO\n sispressure(:,:) = ZERO\n\n! initialize total energy\n total_energy_kinetic(:) = ZERO\n total_energy_potential(:) = ZERO\n\n if (VISCOELASTIC_ATTENUATION) then\n print *,'adding VISCOELASTIC_ATTENUATION (i.e., running a viscoelastic simulation)'\n else\n print *,'not adding VISCOELASTIC_ATTENUATION (i.e., running a purely elastic simulation)'\n endif\n print *\n\n!---\n!--- beginning of time loop\n!---\n\n do it = 1,NSTEP\n\n!-----------------------------------------------------------------------\n! compute the stress tensor and update memory variables for C-PML\n! also update memory variables for viscoelastic attenuation if needed\n!-----------------------------------------------------------------------\n\n! we purposely leave this \"if\" test outside of the loops to make sure the compiler can optimize these loops;\n! with an \"if\" test inside most compilers cannot\n if (.not. VISCOELASTIC_ATTENUATION) then\n\n do j = 2,NY\n do i = 1,NX-1\n\n! interpolate material parameters at the right location in the staggered grid cell\n lambda_half_x = 0.5d0 * (lambda_unrelaxed(i+1,j) + lambda_unrelaxed(i,j))\n mu_half_x = 0.5d0 * (mu_unrelaxed(i+1,j) + mu_unrelaxed(i,j))\n lambda_plus_two_mu_half_x = lambda_half_x + 2.d0 * mu_half_x\n\n value_dvx_dx = (vx(i+1,j) - vx(i,j)) * NINE_OVER_8_DELTAX + (vx(i-1,j) - vx(i+2,j)) * ONE_OVER_24_DELTAX\n value_dvy_dy = (vy(i,j) - vy(i,j-1)) * NINE_OVER_8_DELTAY + (vy(i,j-2) - vy(i,j+1)) * ONE_OVER_24_DELTAY\n\n memory_dvx_dx(i,j) = b_x_half(i) * memory_dvx_dx(i,j) + a_x_half(i) * value_dvx_dx\n memory_dvy_dy(i,j) = b_y(j) * memory_dvy_dy(i,j) + a_y(j) * value_dvy_dy\n\n value_dvx_dx = value_dvx_dx \/ K_x_half(i) + memory_dvx_dx(i,j)\n value_dvy_dy = value_dvy_dy \/ K_y(j) + memory_dvy_dy(i,j)\n\n sigma_xx(i,j) = sigma_xx(i,j) + (lambda_plus_two_mu_half_x * value_dvx_dx + lambda_half_x * value_dvy_dy) * DELTAT\n\n sigma_yy(i,j) = sigma_yy(i,j) + (lambda_half_x * value_dvx_dx + lambda_plus_two_mu_half_x * value_dvy_dy) * DELTAT\n\n enddo\n enddo\n\n do j = 1,NY-1\n do i = 2,NX\n\n! interpolate material parameters at the right location in the staggered grid cell\n mu_half_y = 0.5d0 * (mu_unrelaxed(i,j+1) + mu_unrelaxed(i,j))\n\n value_dvy_dx = (vy(i,j) - vy(i-1,j)) * NINE_OVER_8_DELTAX + (vy(i-2,j) - vy(i+1,j)) * ONE_OVER_24_DELTAX\n value_dvx_dy = (vx(i,j+1) - vx(i,j)) * NINE_OVER_8_DELTAY + (vx(i,j-1) - vx(i,j+2)) * ONE_OVER_24_DELTAY\n\n memory_dvy_dx(i,j) = b_x(i) * memory_dvy_dx(i,j) + a_x(i) * value_dvy_dx\n memory_dvx_dy(i,j) = b_y_half(j) * memory_dvx_dy(i,j) + a_y_half(j) * value_dvx_dy\n\n value_dvy_dx = value_dvy_dx \/ K_x(i) + memory_dvy_dx(i,j)\n value_dvx_dy = value_dvx_dy \/ K_y_half(j) + memory_dvx_dy(i,j)\n\n sigma_xy(i,j) = sigma_xy(i,j) + mu_half_y * (value_dvy_dx + value_dvx_dy) * DELTAT\n\n enddo\n enddo\n\n else\n\n! the present becomes the past for the memory variables.\n! in C or C++ we could replace this with an exchange of pointers on the arrays\n! in order to avoid a memory copy of the whole array.\n memory_variable_R_e1_dot_old(:,:,:) = memory_variable_R_e1_dot(:,:,:)\n memory_variable_R_e11_dot_old(:,:,:) = memory_variable_R_e11_dot(:,:,:)\n memory_variable_R_e13_dot_old(:,:,:) = memory_variable_R_e13_dot(:,:,:)\n\n do j = 2,NY\n do i = 1,NX-1\n\n! interpolate material parameters at the right location in the staggered grid cell\n lambda_half_x = 0.5d0 * (lambda_unrelaxed(i+1,j) + lambda_unrelaxed(i,j))\n mu_half_x = 0.5d0 * (mu_unrelaxed(i+1,j) + mu_unrelaxed(i,j))\n lambda_plus_mu_half_x = lambda_half_x + mu_half_x\n lambda_plus_two_mu_half_x = lambda_half_x + 2.d0 * mu_half_x\n\n value_dvx_dx = (vx(i+1,j) - vx(i,j)) * NINE_OVER_8_DELTAX + (vx(i-1,j) - vx(i+2,j)) * ONE_OVER_24_DELTAX\n value_dvy_dy = (vy(i,j) - vy(i,j-1)) * NINE_OVER_8_DELTAY + (vy(i,j-2) - vy(i,j+1)) * ONE_OVER_24_DELTAY\n\n memory_dvx_dx(i,j) = b_x_half(i) * memory_dvx_dx(i,j) + a_x_half(i) * value_dvx_dx\n memory_dvy_dy(i,j) = b_y(j) * memory_dvy_dy(i,j) + a_y(j) * value_dvy_dy\n\n value_dvx_dx = value_dvx_dx \/ K_x_half(i) + memory_dvx_dx(i,j)\n value_dvy_dy = value_dvy_dy \/ K_y(j) + memory_dvy_dy(i,j)\n\n! use the Auxiliary Differential Equation form, which is second-order accurate in time if implemented following\n! eq (14) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994), which is what we do here\n sum_of_memory_variables_e1 = 0.d0\n sum_of_memory_variables_e11 = 0.d0\n do i_sls = 1,N_SLS\n! this average of the two terms comes from eq (14) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994)\n memory_variable_R_e1_dot(i,j,i_sls) = (memory_variable_R_e1_dot_old(i,j,i_sls) + &\n (value_dvx_dx + value_dvy_dy) * DELTAT_phi_nu1(i_sls) - &\n memory_variable_R_e1_dot_old(i,j,i_sls) * HALF_DELTAT_over_tau_sigma_nu1(i_sls)) &\n * multiplication_factor_tau_sigma_nu1(i_sls)\n\n memory_variable_R_e11_dot(i,j,i_sls) = (memory_variable_R_e11_dot_old(i,j,i_sls) + &\n 0.5d0 * (value_dvx_dx - value_dvy_dy) * DELTAT_phi_nu2(i_sls) - &\n memory_variable_R_e11_dot_old(i,j,i_sls) * HALF_DELTAT_over_tau_sigma_nu2(i_sls)) &\n * multiplication_factor_tau_sigma_nu2(i_sls)\n\n sum_of_memory_variables_e1 = sum_of_memory_variables_e1 + &\n memory_variable_R_e1_dot(i,j,i_sls) + memory_variable_R_e1_dot_old(i,j,i_sls)\n\n sum_of_memory_variables_e11 = sum_of_memory_variables_e11 + &\n memory_variable_R_e11_dot(i,j,i_sls) + memory_variable_R_e11_dot_old(i,j,i_sls)\n enddo\n\n sigma_xx(i,j) = sigma_xx(i,j) + &\n (lambda_plus_two_mu_half_x * value_dvx_dx + lambda_half_x * value_dvy_dy &\n! use the right formula with 1\/N included\n! i.e. use the unrelaxed moduli here (see Carcione's book, third edition, equation (3.189))\n! this average of the two terms comes from eq (13) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994)\n + (0.5d0 * lambda_plus_mu_half_x * sum_of_memory_variables_e1 + mu_half_x * sum_of_memory_variables_e11)) * DELTAT\n\n sigma_yy(i,j) = sigma_yy(i,j) + &\n (lambda_half_x * value_dvx_dx + lambda_plus_two_mu_half_x * value_dvy_dy &\n! use the right formula with 1\/N included\n! i.e. use the unrelaxed moduli here (see Carcione's book, third edition, equation (3.189))\n! this average of the two terms comes from eq (13) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994)\n + (0.5d0 * lambda_plus_mu_half_x * sum_of_memory_variables_e1 - mu_half_x * sum_of_memory_variables_e11)) * DELTAT\n\n enddo\n enddo\n\n do j = 1,NY-1\n do i = 2,NX\n\n! interpolate material parameters at the right location in the staggered grid cell\n mu_half_y = 0.5d0 * (mu_unrelaxed(i,j+1) + mu_unrelaxed(i,j))\n\n value_dvy_dx = (vy(i,j) - vy(i-1,j)) * NINE_OVER_8_DELTAX + (vy(i-2,j) - vy(i+1,j)) * ONE_OVER_24_DELTAX\n value_dvx_dy = (vx(i,j+1) - vx(i,j)) * NINE_OVER_8_DELTAY + (vx(i,j-1) - vx(i,j+2)) * ONE_OVER_24_DELTAY\n\n memory_dvy_dx(i,j) = b_x(i) * memory_dvy_dx(i,j) + a_x(i) * value_dvy_dx\n memory_dvx_dy(i,j) = b_y_half(j) * memory_dvx_dy(i,j) + a_y_half(j) * value_dvx_dy\n\n value_dvy_dx = value_dvy_dx \/ K_x(i) + memory_dvy_dx(i,j)\n value_dvx_dy = value_dvx_dy \/ K_y_half(j) + memory_dvx_dy(i,j)\n\n! use the Auxiliary Differential Equation form, which is second-order accurate in time if implemented following\n! eq (14) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994), which is what we do here\n sum_of_memory_variables_e13 = 0.d0\n do i_sls = 1,N_SLS\n! this average of the two terms comes from eq (14) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994)\n memory_variable_R_e13_dot(i,j,i_sls) = (memory_variable_R_e13_dot_old(i,j,i_sls) + &\n (value_dvy_dx + value_dvx_dy) * DELTAT_phi_nu2(i_sls) - &\n memory_variable_R_e13_dot_old(i,j,i_sls) * HALF_DELTAT_over_tau_sigma_nu2(i_sls)) &\n * multiplication_factor_tau_sigma_nu2(i_sls)\n\n sum_of_memory_variables_e13 = sum_of_memory_variables_e13 + &\n memory_variable_R_e13_dot(i,j,i_sls) + memory_variable_R_e13_dot_old(i,j,i_sls)\n enddo\n\n sigma_xy(i,j) = sigma_xy(i,j) + mu_half_y * (value_dvy_dx + value_dvx_dy &\n! use the right formula with 1\/N included\n! i.e. use the unrelaxed moduli here (see Carcione's book, third edition, equation (3.189))\n! this average of the two terms comes from eq (13) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994)\n + 0.5d0 * sum_of_memory_variables_e13) * DELTAT\n\n enddo\n enddo\n\n endif\n\n!--------------------------------------------------------\n! compute velocity and update memory variables for C-PML\n!--------------------------------------------------------\n\n do j = 2,NY\n do i = 2,NX\n\n value_dsigma_xx_dx = (sigma_xx(i,j) - sigma_xx(i-1,j)) * NINE_OVER_8_DELTAX + &\n (sigma_xx(i-2,j) - sigma_xx(i+1,j)) * ONE_OVER_24_DELTAX\n value_dsigma_xy_dy = (sigma_xy(i,j) - sigma_xy(i,j-1)) * NINE_OVER_8_DELTAY + &\n (sigma_xy(i,j-2) - sigma_xy(i,j+1)) * ONE_OVER_24_DELTAY\n\n memory_dsigma_xx_dx(i,j) = b_x(i) * memory_dsigma_xx_dx(i,j) + a_x(i) * value_dsigma_xx_dx\n memory_dsigma_xy_dy(i,j) = b_y(j) * memory_dsigma_xy_dy(i,j) + a_y(j) * value_dsigma_xy_dy\n\n value_dsigma_xx_dx = value_dsigma_xx_dx \/ K_x(i) + memory_dsigma_xx_dx(i,j)\n value_dsigma_xy_dy = value_dsigma_xy_dy \/ K_y(j) + memory_dsigma_xy_dy(i,j)\n\n vx(i,j) = vx(i,j) + (value_dsigma_xx_dx + value_dsigma_xy_dy) * DELTAT \/ rho(i,j)\n\n enddo\n enddo\n\n do j = 1,NY-1\n do i = 1,NX-1\n\n! interpolate density at the right location in the staggered grid cell\n rho_half_x_half_y = 0.25d0 * (rho(i,j) + rho(i+1,j) + rho(i+1,j+1) + rho(i,j+1))\n\n value_dsigma_xy_dx = (sigma_xy(i+1,j) - sigma_xy(i,j)) * NINE_OVER_8_DELTAX + &\n (sigma_xy(i-1,j) - sigma_xy(i+2,j)) * ONE_OVER_24_DELTAX\n\n value_dsigma_yy_dy = (sigma_yy(i,j+1) - sigma_yy(i,j)) * NINE_OVER_8_DELTAY + &\n (sigma_yy(i,j-1) - sigma_yy(i,j+2)) * ONE_OVER_24_DELTAY\n\n memory_dsigma_xy_dx(i,j) = b_x_half(i) * memory_dsigma_xy_dx(i,j) + a_x_half(i) * value_dsigma_xy_dx\n memory_dsigma_yy_dy(i,j) = b_y_half(j) * memory_dsigma_yy_dy(i,j) + a_y_half(j) * value_dsigma_yy_dy\n\n value_dsigma_xy_dx = value_dsigma_xy_dx \/ K_x_half(i) + memory_dsigma_xy_dx(i,j)\n value_dsigma_yy_dy = value_dsigma_yy_dy \/ K_y_half(j) + memory_dsigma_yy_dy(i,j)\n\n vy(i,j) = vy(i,j) + (value_dsigma_xy_dx + value_dsigma_yy_dy) * DELTAT \/ rho_half_x_half_y\n\n enddo\n enddo\n\n! add the source (force vector located at a given grid point)\n a = pi*pi*f0*f0\n t = dble(it-1)*DELTAT\n\n! Gaussian\n! force_source_term = - factor * exp(-a*(t-t0)**2) \/ (2.d0 * a)\n\n! first derivative of a Gaussian\n! force_source_term = factor * (t-t0)*exp(-a*(t-t0)**2)\n\n! Ricker source time function (second derivative of a Gaussian)\n force_source_term = factor * (1.d0 - 2.d0*a*(t-t0)**2)*exp(-a*(t-t0)**2)\n\n! to get the right amplitude of the force, we need to divide by the area of a grid cell\n! (we checked that against the analytical solution in a homogeneous medium for a force source)\n force_source_term = force_source_term \/ (DELTAX * DELTAY)\n\n! define location of the source\n i = ISOURCE\n j = JSOURCE\n\n force_x = sin(ANGLE_FORCE * DEGREES_TO_RADIANS) * force_source_term\n force_y = cos(ANGLE_FORCE * DEGREES_TO_RADIANS) * force_source_term\n\n! interpolate density at the right location in the staggered grid cell\n rho_half_x_half_y = 0.25d0 * (rho(i,j) + rho(i+1,j) + rho(i+1,j+1) + rho(i,j+1))\n\n! we want seismograms to be representing velocity, for the case of the seismic wave equation\n! representing displacement for a Ricker (i.e., second derivative of a Gaussian) source in displacement.\n! Since the force source is added to d(velocity)\/dt in this split velocity and stress scheme\n! we need to select the second derivative of a Gaussian as a source time wavelet\n! by analogy with a Ricker (i.e. a second derivative) added to d2(displacement)\/dt2\n! as in the unsplit equation written in displacement only.\n! Since the formula is d(velocity)\/dt = (velocity_new - velocity_old) \/ DELTAT = force_source_term\n! we also need to multiply by DELTAT here to avoid having an amplitude of the seismogram\n! that varies when one changes the time step, i.e. we write:\n! velocity_new = velocity_old + force_source_term * DELTAT at the source grid point\n vx(i,j) = vx(i,j) + force_x * DELTAT \/ rho(i,j)\n vy(i,j) = vy(i,j) + force_y * DELTAT \/ rho_half_x_half_y\n\n! Dirichlet conditions (rigid boundaries) on the edges or at the bottom of the PML layers\n vx(1,:) = ZERO\n vx(NX,:) = ZERO\n\n vx(:,1) = ZERO\n vx(:,NY) = ZERO\n\n vy(1,:) = ZERO\n vy(NX,:) = ZERO\n\n vy(:,1) = ZERO\n vy(:,NY) = ZERO\n\n! store seismograms\n do irec = 1,NREC\n\n! beware here that the two components of the velocity vector are not defined at the same point\n! in a staggered grid, and thus the two components of the velocity vector are recorded at slightly different locations,\n! vy is staggered by half a grid cell along X and along Y with respect to vx\n sisvx(it,irec) = vx(ix_rec(irec),iy_rec(irec))\n sisvy(it,irec) = vy(ix_rec(irec),iy_rec(irec))\n\n! from L. S. Bennethum, Compressibility Moduli for Porous Materials Incorporating Volume Fraction,\n! J. Engrg. Mech., vol. 132(11), p. 1205-1214 (2006), below equation (5):\n! for a 3D isotropic solid, pressure is defined in terms of the trace of the stress tensor as\n! p = -1\/3 (t11 + t22 + t33) where t is the Cauchy stress tensor.\n\n! to compute pressure in 3D in an elastic solid, one uses pressure = - trace(sigma) \/ 3\n! sigma_ij = lambda delta_ij trace(epsilon) + 2 mu epsilon_ij\n! = lambda (epsilon_xx + epsilon_yy + epsilon_zz) + 2 mu epsilon_ij\n! sigma_xx = lambda (epsilon_xx + epsilon_yy + epsilon_zz) + 2 mu epsilon_xx\n! sigma_yy = lambda (epsilon_xx + epsilon_yy + epsilon_zz) + 2 mu epsilon_yy\n! sigma_zz = lambda (epsilon_xx + epsilon_yy + epsilon_zz) + 2 mu epsilon_zz\n! pressure = - trace(sigma) \/ 3 = - (lambda + 2\/3 mu) trace(epsilon) = - kappa * trace(epsilon)\n!\n! to compute pressure in 2D in an elastic solid in the plane strain convention i.e. in the P-SV case,\n! one still uses pressure = - trace(sigma) \/ 3 but taking into account the fact\n! that the off-plane strain epsilon_zz is zero by definition of the plane strain convention\n! but thus the off-plane stress sigma_zz is not equal to zero,\n! one has instead: sigma_zz = lambda * (epsilon_xx + epsilon_yy), thus\n! sigma_ij = lambda delta_ij trace(epsilon) + 2 mu epsilon_ij\n! = lambda (epsilon_xx + epsilon_yy) + 2 mu epsilon_ij\n! sigma_xx = lambda (epsilon_xx + epsilon_yy) + 2 mu epsilon_xx\n! sigma_yy = lambda (epsilon_xx + epsilon_yy) + 2 mu epsilon_yy\n! sigma_zz = lambda * (epsilon_xx + epsilon_yy)\n! pressure = - trace(sigma) \/ 3 = - (lambda + 2*mu\/3) (epsilon_xx + epsilon_yy)\n\n i = ix_rec(irec)\n j = iy_rec(irec)\n\n! interpolate material parameters at the right location in the staggered grid cell\n lambda_half_x = 0.5d0 * (lambda_unrelaxed(i+1,j) + lambda_unrelaxed(i,j))\n mu_half_x = 0.5d0 * (mu_unrelaxed(i+1,j) + mu_unrelaxed(i,j))\n epsilon_xx = ((lambda_half_x + 2.d0*mu_half_x) * sigma_xx(i,j) - lambda_half_x * &\n sigma_yy(i,j)) \/ (4.d0 * mu_half_x * (lambda_half_x + mu_half_x))\n epsilon_yy = ((lambda_half_x + 2.d0*mu_half_x) * sigma_yy(i,j) - lambda_half_x * &\n sigma_xx(i,j)) \/ (4.d0 * mu_half_x * (lambda_half_x + mu_half_x))\n\n sispressure(it,irec) = - (lambda_half_x + TWO_THIRDS*mu_half_x) * (epsilon_xx + epsilon_yy)\n\n enddo\n\n! compute total energy in the medium (without the PML layers)\n if (COMPUTE_ENERGY) then\n\n! compute kinetic energy first, defined as 1\/2 rho ||v||^2\n total_energy_kinetic(it) = ZERO\n do j = NPOINTS_PML+1, NY-NPOINTS_PML\n do i = NPOINTS_PML+1, NX-NPOINTS_PML\n! interpolate vy back at the location of vx, to be able to use both at the same location\n vy_interpolated = 0.25d0 * (vy(i,j) + vy(i-1,j) + vy(i-1,j-1) + vy(i,j-1))\n total_energy_kinetic(it) = total_energy_kinetic(it) + 0.5d0 * rho(i,j) * (vx(i,j)**2 + vy_interpolated**2)\n enddo\n enddo\n\n! add potential energy, defined as 1\/2 epsilon_ij sigma_ij\n total_energy_potential(it) = ZERO\n do j = NPOINTS_PML+1, NY-NPOINTS_PML\n do i = NPOINTS_PML+1, NX-NPOINTS_PML\n! interpolate material parameters at the right location in the staggered grid cell\n lambda_half_x = 0.5d0 * (lambda_unrelaxed(i+1,j) + lambda_unrelaxed(i,j))\n mu_half_x = 0.5d0 * (mu_unrelaxed(i+1,j) + mu_unrelaxed(i,j))\n mu_half_y = 0.5d0 * (mu_unrelaxed(i,j+1) + mu_unrelaxed(i,j))\n epsilon_xx = ((lambda_half_x + 2.d0*mu_half_x) * sigma_xx(i,j) - lambda_half_x * &\n sigma_yy(i,j)) \/ (4.d0 * mu_half_x * (lambda_half_x + mu_half_x))\n epsilon_yy = ((lambda_half_x + 2.d0*mu_half_x) * sigma_yy(i,j) - lambda_half_x * &\n sigma_xx(i,j)) \/ (4.d0 * mu_half_x * (lambda_half_x + mu_half_x))\n epsilon_xy = sigma_xy(i,j) \/ (2.d0 * mu_half_y)\n total_energy_potential(it) = total_energy_potential(it) + &\n 0.5d0 * (epsilon_xx * sigma_xx(i,j) + epsilon_yy * sigma_yy(i,j) + 2.d0 * epsilon_xy * sigma_xy(i,j))\n enddo\n enddo\n\n endif\n\n! output information\n if (mod(it,IT_DISPLAY) == 0 .or. it == 5) then\n\n! print maximum of norm of velocity\n velocnorm = maxval(sqrt(vx**2 + vy**2))\n print *,'Time step # ',it,' out of ',NSTEP\n print *,'Time: ',sngl((it-1)*DELTAT),' seconds'\n print *,'Max norm velocity vector V (m\/s) = ',velocnorm\n if (COMPUTE_ENERGY) print *,'total energy = ',total_energy_kinetic(it) + total_energy_potential(it)\n print *\n! check stability of the code, exit if unstable\n if (velocnorm > STABILITY_THRESHOLD) stop 'code became unstable and blew up'\n\n call create_color_image(vx,NX,NY,it,ISOURCE,JSOURCE,ix_rec,iy_rec,nrec, &\n NPOINTS_PML,USE_PML_XMIN,USE_PML_XMAX,USE_PML_YMIN,USE_PML_YMAX,1)\n call create_color_image(vy,NX,NY,it,ISOURCE,JSOURCE,ix_rec,iy_rec,nrec, &\n NPOINTS_PML,USE_PML_XMIN,USE_PML_XMAX,USE_PML_YMIN,USE_PML_YMAX,2)\n\n! save the part of the seismograms that has been computed so far, so that users can monitor the progress of the simulation\n call write_seismograms(sisvx,sisvy,sispressure,NSTEP,NREC,DELTAT,t0)\n\n endif\n\n enddo ! end of time loop\n\n! save seismograms\n call write_seismograms(sisvx,sisvy,sispressure,NSTEP,NREC,DELTAT,t0)\n\n if (COMPUTE_ENERGY) then\n\n! save total energy\n open(unit=20,file='energy.dat',status='unknown')\n do it = 1,NSTEP\n write(20,*) sngl(dble(it-1)*DELTAT),sngl(total_energy_kinetic(it)), &\n sngl(total_energy_potential(it)),sngl(total_energy_kinetic(it) + total_energy_potential(it))\n enddo\n close(20)\n\n! create script for Gnuplot for total energy\n open(unit=20,file='plot_energy',status='unknown')\n write(20,*) '# set term x11'\n write(20,*) 'set term postscript landscape monochrome dashed \"Helvetica\" 22'\n write(20,*)\n write(20,*) 'set xlabel \"Time (s)\"'\n write(20,*) 'set ylabel \"Total energy\"'\n write(20,*)\n write(20,*) 'set output \"cpml_total_energy_semilog.eps\"'\n write(20,*) 'set logscale y'\n write(20,*) 'plot \"energy.dat\" us 1:2 t ''Ec'' w l lc 1, \"energy.dat\" us 1:3 &\n & t ''Ep'' w l lc 3, \"energy.dat\" us 1:4 t ''Total energy'' w l lc 4'\n write(20,*) 'pause -1 \"Hit any key...\"'\n write(20,*)\n close(20)\n\n endif\n\n! create script for Gnuplot\n open(unit=20,file='plotgnu',status='unknown')\n write(20,*) 'set term x11'\n write(20,*) '# set term postscript landscape monochrome dashed \"Helvetica\" 22'\n write(20,*)\n write(20,*) 'set xlabel \"Time (s)\"'\n write(20,*) 'set ylabel \"Amplitude (m \/ s)\"'\n write(20,*)\n\n write(20,*) 'set output \"v_sigma_Vx_receiver_001.eps\"'\n write(20,*) 'plot \"Vx_file_001.dat\" t ''Vx C-PML'' w l lc 1'\n write(20,*) 'pause -1 \"Hit any key...\"'\n write(20,*)\n\n write(20,*) 'set output \"v_sigma_Vy_receiver_001.eps\"'\n write(20,*) 'plot \"Vy_file_001.dat\" t ''Vy C-PML'' w l lc 1'\n write(20,*) 'pause -1 \"Hit any key...\"'\n write(20,*)\n\n write(20,*) 'set output \"v_sigma_Vx_receiver_002.eps\"'\n write(20,*) 'plot \"Vx_file_002.dat\" t ''Vx C-PML'' w l lc 1'\n write(20,*) 'pause -1 \"Hit any key...\"'\n write(20,*)\n\n write(20,*) 'set output \"v_sigma_Vy_receiver_002.eps\"'\n write(20,*) 'plot \"Vy_file_002.dat\" t ''Vy C-PML'' w l lc 1'\n write(20,*) 'pause -1 \"Hit any key...\"'\n write(20,*)\n\n close(20)\n\n print *\n print *,'End of the simulation'\n print *\n\n end program seismic_CPML_2D_viscoelast_fourth\n\n!----\n!---- save the seismograms in ASCII text format\n!----\n\n subroutine write_seismograms(sisvx,sisvy,sispressure,nt,nrec,DELTAT,t0)\n\n implicit none\n\n integer nt,nrec\n double precision DELTAT,t0\n\n double precision sisvx(nt,nrec)\n double precision sisvy(nt,nrec)\n double precision sispressure(nt,nrec)\n\n integer irec,it\n\n character(len=100) file_name\n\n! pressure\n do irec=1,nrec\n write(file_name,\"('pressure_file_',i3.3,'.dat')\") irec\n open(unit=11,file=file_name,status='unknown')\n do it=1,nt\n! in the scheme of eq (13) of Robertsson, Blanch and Symes, Geophysics, vol. 59(9), pp 1444-1456 (1994)\n! pressure is defined at time t + DELTAT\/2, i.e. staggered in time with respect to velocity.\n! Here we must thus take this shift of DELTAT\/2 into account to save the seismograms at the right time\n write(11,*) sngl(dble(it-1)*DELTAT - t0 + DELTAT\/2.d0),' ',sngl(sispressure(it,irec))\n enddo\n close(11)\n enddo\n\n! X component of velocity\n do irec=1,nrec\n write(file_name,\"('Vx_file_',i3.3,'.dat')\") irec\n open(unit=11,file=file_name,status='unknown')\n do it=1,nt\n write(11,*) sngl(dble(it-1)*DELTAT - t0),' ',sngl(sisvx(it,irec))\n enddo\n close(11)\n enddo\n\n! Y component of velocity\n do irec=1,nrec\n write(file_name,\"('Vy_file_half_a_grid_cell_away_from_Vx_',i3.3,'.dat')\") irec\n open(unit=11,file=file_name,status='unknown')\n do it=1,nt\n write(11,*) sngl(dble(it-1)*DELTAT - t0),' ',sngl(sisvy(it,irec))\n enddo\n close(11)\n enddo\n\n end subroutine write_seismograms\n\n!----\n!---- routine to create a color image of a given vector component\n!---- the image is created in PNM format and then converted to GIF\n!----\n\n subroutine create_color_image(image_data_2D,NX,NY,it,ISOURCE,JSOURCE,ix_rec,iy_rec,nrec, &\n NPOINTS_PML,USE_PML_XMIN,USE_PML_XMAX,USE_PML_YMIN,USE_PML_YMAX,field_number)\n\n implicit none\n\n! non linear display to enhance small amplitudes for graphics\n double precision, parameter :: POWER_DISPLAY = 0.30d0\n\n! amplitude threshold above which we draw the color point\n double precision, parameter :: cutvect = 0.01d0\n\n! use black or white background for points that are below the threshold\n logical, parameter :: WHITE_BACKGROUND = .true.\n\n! size of cross and square in pixels drawn to represent the source and the receivers\n integer, parameter :: width_cross = 5, thickness_cross = 1, size_square = 3\n\n integer NX,NY,it,field_number,ISOURCE,JSOURCE,NPOINTS_PML,nrec\n logical USE_PML_XMIN,USE_PML_XMAX,USE_PML_YMIN,USE_PML_YMAX\n\n! in order to be able to use a fourth-order spatial operator on the edges of the model\n! here we define the array with size (0:NX+1,0:NY+1) instead of size (NX,NY) as in the second-order case\n double precision, dimension(0:NX+1,0:NY+1) :: image_data_2D\n\n integer, dimension(nrec) :: ix_rec,iy_rec\n\n integer :: ix,iy,irec\n\n character(len=100) :: file_name,system_command\n\n integer :: R, G, B\n\n double precision :: normalized_value,max_amplitude\n\n! open image file and create system command to convert image to more convenient format\n! use the \"convert\" command from ImageMagick http:\/\/www.imagemagick.org\n if (field_number == 1) then\n write(file_name,\"('image',i6.6,'_Vx.pnm')\") it\n write(system_command,\"('convert image',i6.6,'_Vx.pnm image',i6.6,'_Vx.gif ; rm image',i6.6,'_Vx.pnm')\") it,it,it\n else if (field_number == 2) then\n write(file_name,\"('image',i6.6,'_Vy.pnm')\") it\n write(system_command,\"('convert image',i6.6,'_Vy.pnm image',i6.6,'_Vy.gif ; rm image',i6.6,'_Vy.pnm')\") it,it,it\n else if (field_number == 3) then\n write(file_name,\"('image',i6.6,'_pressure.pnm')\") it\n write(system_command,\"('convert image',i6.6,'_pressure.pnm image',i6.6,'_pressure.gif ; rm image',i6.6,'_pressure.pnm')\") &\n it,it,it\n endif\n\n open(unit=27, file=file_name, status='unknown')\n\n write(27,\"('P3')\") ! write image in PNM P3 format\n\n write(27,*) NX,NY ! write image size\n write(27,*) '255' ! maximum value of each pixel color\n\n! compute maximum amplitude\n max_amplitude = maxval(abs(image_data_2D))\n\n! image starts in upper-left corner in PNM format\n do iy=NY,1,-1\n do ix=1,NX\n\n! define data as vector component normalized to [-1:1] and rounded to nearest integer\n! keeping in mind that amplitude can be negative\n normalized_value = image_data_2D(ix,iy) \/ max_amplitude\n\n! suppress values that are outside [-1:+1] to avoid small edge effects\n if (normalized_value < -1.d0) normalized_value = -1.d0\n if (normalized_value > 1.d0) normalized_value = 1.d0\n\n! draw an orange cross to represent the source\n if ((ix >= ISOURCE - width_cross .and. ix <= ISOURCE + width_cross .and. &\n iy >= JSOURCE - thickness_cross .and. iy <= JSOURCE + thickness_cross) .or. &\n (ix >= ISOURCE - thickness_cross .and. ix <= ISOURCE + thickness_cross .and. &\n iy >= JSOURCE - width_cross .and. iy <= JSOURCE + width_cross)) then\n R = 255\n G = 157\n B = 0\n\n! display two-pixel-thick black frame around the image\n else if (ix <= 2 .or. ix >= NX-1 .or. iy <= 2 .or. iy >= NY-1) then\n R = 0\n G = 0\n B = 0\n\n! display edges of the PML layers\n else if ((USE_PML_XMIN .and. ix == NPOINTS_PML) .or. &\n (USE_PML_XMAX .and. ix == NX - NPOINTS_PML) .or. &\n (USE_PML_YMIN .and. iy == NPOINTS_PML) .or. &\n (USE_PML_YMAX .and. iy == NY - NPOINTS_PML)) then\n R = 255\n G = 150\n B = 0\n\n! suppress all the values that are below the threshold\n else if (abs(image_data_2D(ix,iy)) <= max_amplitude * cutvect) then\n\n! use a black or white background for points that are below the threshold\n if (WHITE_BACKGROUND) then\n R = 255\n G = 255\n B = 255\n else\n R = 0\n G = 0\n B = 0\n endif\n\n! represent regular image points using red if value is positive, blue if negative\n else if (normalized_value >= 0.d0) then\n R = nint(255.d0*normalized_value**POWER_DISPLAY)\n G = 0\n B = 0\n else\n R = 0\n G = 0\n B = nint(255.d0*abs(normalized_value)**POWER_DISPLAY)\n endif\n\n! draw a green square to represent the receivers\n do irec = 1,nrec\n if ((ix >= ix_rec(irec) - size_square .and. ix <= ix_rec(irec) + size_square .and. &\n iy >= iy_rec(irec) - size_square .and. iy <= iy_rec(irec) + size_square) .or. &\n (ix >= ix_rec(irec) - size_square .and. ix <= ix_rec(irec) + size_square .and. &\n iy >= iy_rec(irec) - size_square .and. iy <= iy_rec(irec) + size_square)) then\n! use dark green color\n R = 30\n G = 180\n B = 60\n endif\n enddo\n\n! write color pixel\n write(27,\"(i3,' ',i3,' ',i3)\") R,G,B\n\n enddo\n enddo\n\n! close file\n close(27)\n\n! call the system to convert image to Gif (can be commented out if \"call system\" is missing in your compiler)\n! call system(system_command)\n\n end subroutine create_color_image\n\n!\n!---- include the SolvOpt() routine that is used to compute the tau_epsilon and tau_sigma values from a given Q attenuation factor\n!\n\ninclude \"attenuation_model_with_SolvOpt.f90\"\n\n","avg_line_length":41.0266272189,"max_line_length":131,"alphanum_fraction":0.6786615706} {"size":16378,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"! Copyright 2014 College of William and Mary\n!\n! Licensed under the Apache License, Version 2.0 (the \"License\");\n! you may not use this file except in compliance with the License.\n! You may obtain a copy of the License at\n!\n! http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n!\n! Unless required by applicable law or agreed to in writing, software\n! distributed under the License is distributed on an \"AS IS\" BASIS,\n! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n! See the License for the specific language governing permissions and\n! limitations under the License.\n\n!\n!****************************************************************************************\n!\t\t\t\t\t\t\t\t\t\t\t*\n!\t(x,y) read in from station.bp (build pts), and output\n! results along a transect (defined below) for 3D variables. \n! Need to manually modify ntran etc. \n! Works for mixed tri\/quad outputs and node\/elem based vars.\n! Works for combined or uncombined nc outputs.\n! Will extrapolate above surface but not below bottom.\n\n! Inputs: screen; vgrid (in this dir or ..\/); station.bp (build pts; depths not used); nc\n! Outputs: transect.out & transect_grd.[zr]0 (ascii on struc'ed grid; \n! use plot_transect.m, but also consider using SCHISM_TRANSECT.m)\n! average_transect.out (averaged; in .bp with header for scalar and in\n! .xyuv for vector)\n\n! ifort -mcmodel=medium -assume byterecl -CB -O2 -o read_output9_transect.WW ..\/UtilLib\/extract_mod.f90 read_output9_transect.f90 ..\/UtilLib\/compute_zcor.f90 ..\/UtilLib\/pt_in_poly.f90 -I$NETCDF\/include -I$NETCDF_FORTRAN\/include -L$NETCDF_FORTRAN\/lib -L$NETCDF\/lib -L$NETCDF\/lib -lnetcdf -lnetcdff\n!\t\t\t\t\t\t\t\t\t\t\t*\n!****************************************************************************************\n!\n program read_out\n use netcdf\n use extract_mod\n\n! parameter(nbyte=4)\n character(len=30) :: file63,varname\n character(len=12) :: it_char\n allocatable :: sigma(:),cs(:),ztot(:)\n allocatable:: outvar(:,:,:,:),out(:,:,:,:),out2(:,:,:),icum(:,:,:),eta2(:,:),node3(:,:),arco(:,:)\n allocatable :: ztmp(:),x00(:),y00(:),iep(:),out3(:,:,:),out4(:,:),av_out3(:,:,:)\n allocatable :: nmxz(:,:),z0(:),r0(:),r00(:),z00(:)\n allocatable :: sigma_lcl(:,:),kbp(:),ztmp2(:,:),irank_read(:)\n integer :: nodel(3)\n real :: swild(3)\n real*8,allocatable :: timeout(:)\n \n print*, 'Do you work on uncombined (0) or combined (1) nc?'\n read(*,*)icomb\n if(icomb\/=0.and.icomb\/=1) stop 'Unknown icomb'\n\n!... Set max array size for system memory\n print*, 'Recommendation: for uncombined nc, specify max array size (e.g., <=2.e9);'\n print*, 'for combined nc, specify # of records to read each time.'\n print*, 'Do you want to specify max array size (1) or # of records (2)'\n read(*,*)ispec_max\n if(ispec_max==1) then\n print*, 'Input max array size (e.g., <=2.e9):'\n read(*,*)max_array_size\n print*, 'max_array_size read in=',max_array_size\n else\n print*, 'Input # of records:'\n read(*,*)nrec3\n endif\n\n print*, 'Input variable name to read from nc (e.g. salt):'\n read(*,'(a30)')varname\n varname=adjustl(varname); len_var=len_trim(varname)\n\n print*, 'Is the var node (1) or elem (2) based?'\n read(*,*) inode_elem\n \n print*, 'Input start and end file # to read:'\n read(*,*) iday1,iday2\n\n! print*, 'Input output interval in sec:'\n! read(*,*) dt_output\n\n! Input transect depths\n ntran=31\n allocate(z0(ntran))\n z0(1:ntran)=(\/(-30+i, i=0,ntran-1) \/)\n\n open(10,file='station.bp',status='old')\n read(10,*) \n read(10,*) nxy\n nxz=nxy*ntran\n nxz_e=(nxy-1)*(ntran-1)*2\n allocate(x00(nxy),y00(nxy),r0(nxy),r00(nxz),z00(nxz),nmxz(nxz_e,4),stat=istat)\n if(istat\/=0) stop 'Falied to allocate (1)'\n\n do i=1,nxy\n read(10,*)j,x00(i),y00(i)\n enddo !i\n !Along transect distance\n r0(1)=0\n do i=2,nxy\n r0(i)=r0(i-1)+sqrt((x00(i)-x00(i-1))**2+(y00(i)-y00(i-1))**2)\n enddo !i\n close(10)\n \n! Output transect grid\n open(22,file='transect_grd.z0',status='replace')\n open(23,file='transect_grd.r0',status='replace')\n write(22,'(f12.3)')z0\n write(23,'(e15.6)')r0\n close(22) \n close(23)\n\n! Compute connectivity\n do i=1,nxy\n do j=1,ntran\n nd=ntran*(i-1)+j\n r00(nd)=r0(i)\n z00(nd)=z0(j)\n enddo !j\n enddo !i\n\n do i=1,nxy-1\n do j=1,ntran-1\n ie=(ntran-1)*(i-1)+j\n n1=ntran*(i-1)+j\n n2=ntran*i+j\n nmxz(2*ie-1,1)=n1\n nmxz(2*ie-1,2)=n2\n nmxz(2*ie-1,3)=n2+1\n nmxz(2*ie,1)=n1\n nmxz(2*ie,2)=n2+1\n nmxz(2*ie,3)=n1+1\n enddo !j\n enddo !i\n\n open(21,file='transect.out',status='replace')\n \n!... Header\n !Returned vars: ne,np,ns,nrec,[x y dp](np),\n !elnode,i34,nvrt,h0,dtout\n !If icomb=0, additonal vars:\n !nproc,iegl_rank,iplg,ielg,islg,np_lcl(:),ne_lcl(:),ns_lcl(:)\n if(icomb==0) then !uncombined\n call get_global_geo\n else\n call readheader(iday1)\n endif\n\n print*, 'After header:',ne,np,ns,nrec,i34(ne), &\n &elnode(1:i34(ne),ne),nvrt,h0,x(np),y(np),dp(np),dtout\n\n! iskip=dt_output\/dtout\n! if(iskip<1) then\n! print*, 'Output interval too small; resetting to dtout=',dtout\n! iskip=1\n! endif\n !nstep=(iday2-iday1+1)*nrec\/iskip\n! if(nxz*ivs>6000) stop 'Increase output statement below!'\n \n allocate(out(nxy,3,nvrt,2), &\n &out2(nxy,nvrt,2),node3(nxy,3),arco(nxy,3),iep(nxy), &\n &out3(2,ntran,nxy),av_out3(2,ntran,nxy),out4(ntran,2),stat=istat)\n if(istat\/=0) stop 'Falied to allocate (5)'\n\n if(inode_elem==1) then !node based\n last_dim=np\n else !elem\n last_dim=ne\n endif\n\n !nrec specified if ispec_max=2\n if(ispec_max==1) nrec3=max_array_size\/(2*nvrt*last_dim)-1\n nrec3=min(nrec,max(nrec3,1))\n\n allocate(ztot(nvrt),sigma(nvrt),sigma_lcl(nvrt,np),kbp(np), &\n &timeout(nrec),outvar(2,nvrt,last_dim,nrec3),eta2(np,nrec3))\n outvar=-huge(1.0) !init\n\n! Read in vgrid.in\n call get_vgrid('vgrid.in',np,nvrt,ivcor,kz,h_s,h_c,theta_b,theta_f,ztot,sigma,sigma_lcl,kbp)\n\n allocate(ztmp(nvrt),ztmp2(nvrt,3))\n\n! Calculate kbp00\n if(ivcor==1) then\n kbp00=kbp\n else\n do i=1,np\n call zcor_SZ(dp(i),1.e8,h0,h_s,h_c,theta_b,theta_f,kz,nvrt,ztot,sigma, &\n &ztmp(:),idry2,kbp00(i))\n enddo !i\n endif !ivcor\n\n!... Find parent element for (x00,y00)\n iep=0\n do i=1,ne\n do l=1,nxy\n if(iep(l)\/=0) cycle\n\n call pt_in_poly(i34(i),x(elnode(1:i34(i),i)),y(elnode(1:i34(i),i)),x00(l),y00(l),inside,arco(l,1:3),nodel)\n if(inside==1) then\n iep(l)=i\n !print*, 'Found:',l,arco(l,1:3),nodel\n node3(l,1:3)=elnode(nodel(1:3),i)\n endif !inside\n enddo !l; build pts\n\n ifl=0 !flag\n do l=1,nxy\n if(iep(l)==0) then\n ifl=1\n exit\n endif\n enddo !l\n if(ifl==0) exit\n enddo !i=1,ne\n\n iabort=0\n do j=1,nxy\n if(iep(j)<=0) then\n print*, 'Cannot find a parent for pt:',j,x00(j),y00(j)\n iabort=1\n endif\n enddo !j\n if(iabort==1) stop 'check station points'\n\n !Mark ranks that need to be read in\n if(icomb==0) then\n allocate(irank_read(0:nproc-1))\n irank_read=0\n do j=1,nxy\n irank_read(iegl_rank(iep(j)))=1\n write(99,*)'reading from rank #:',iegl_rank(iep(j))\n enddo !j\n write(99,*)'Need to read from ',sum(irank_read),' ranks'\n endif !icomb\n\n if(varname(1:len_var).eq.'hvel') then\n rjunk=0 !invalid values\n else\n rjunk=-9999\n endif\n\n!... Time iteration\n!...\n av_out3=0\n nstep=0\n do iday=iday1,iday2\n!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n! write(it_char,'(i12)')iday\n! it_char=adjustl(it_char)\n! leng=len_trim(it_char)\n! file63='schout_'\/\/it_char(1:leng)\/\/'.nc'\n! iret=nf90_open(trim(adjustl(file63)),OR(NF90_NETCDF4,NF90_NOWRITE),ncid)\n! !time is double\n! iret=nf90_inq_varid(ncid,'time',itime_id)\n! iret=nf90_get_var(ncid,itime_id,timeout,(\/1\/),(\/nrec\/))\n if(icomb==0) then !uncombined\n call get_timeout(iday,nrec,timeout,icomb)\n else\n call get_timeout(iday,nrec,timeout)\n endif\n\n !print*, 'time(days)=',timeout\/86400\n\n !Get elev\n! start_2d(1)=1; start_2d(2)=irec\n! count_2d(1)=np; count_2d(2)=1\n! iret=nf90_get_var(ncid,ielev_id,eta2,start_2d,count_2d)\n!\n! iret=nf90_inq_varid(ncid,varname(1:len_var),ivarid1)\n! if(iret\/=nf90_NoErr) stop 'Var not found'\n! iret=nf90_Inquire_Variable(ncid,ivarid1,ndims=ndims,dimids=dimids)\n! if(ndims>100) stop 'increase dimension of dimids & idims'\n! do i=1,ndims\n! iret=nf90_Inquire_Dimension(ncid,dimids(i),len=idims(i))\n! enddo !i\n! npes=idims(ndims-1)\n! if(npes\/=np.and.npes\/=ne) stop 'can only handle node- or elem-based'\n!!'\n! if(idims(ndims)\/=nrec) stop 'last dim is not time'\n!\n! iret=nf90_get_att(ncid,ivarid1,'i23d',i23d)\n! if(i23d<=0.or.i23d>6) stop 'wrong i23d'\n! iret=nf90_get_att(ncid,ivarid1,'ivs',ivs)\n! print*, 'i23d:',i23d,ivs,idims(1:ndims)\n! if(ivs==1) then !scalar\n! if(mod(i23d-1,3)==0) then !2D\n! start_2d(1)=1; start_2d(2)=irec\n! count_2d(1)=npes; count_2d(2)=1\n! iret=nf90_get_var(ncid,ivarid1,outvar(1,1,1:npes),start_2d,count_2d)\n! else !3D\n! start_3d(1:2)=1; start_3d(3)=irec\n! count_3d(2)=npes; count_3d(1)=nvrt; count_3d(3)=1\n! iret=nf90_get_var(ncid,ivarid1,outvar(1,:,1:npes),start_3d,count_3d)\n! endif\n! else !vector\n! if(mod(i23d-1,3)==0) then !2D\n! start_3d(1:2)=1; start_3d(3)=irec\n! count_3d(2)=npes; count_3d(1)=2; count_3d(3)=1\n! iret=nf90_get_var(ncid,ivarid1,outvar(1:2,1,1:npes),start_3d,count_3d)\n! else if(ndims-1==3) then !3D vector\n! start_4d(1:3)=1; start_4d(4)=irec\n! count_4d(3)=npes; count_4d(2)=nvrt; count_4d(1)=2; count_4d(4)=1\n! iret=nf90_get_var(ncid,ivarid1,outvar(:,:,1:npes),start_4d,count_4d)\n! else\n! stop 'Unknown type(2)'\n! endif\n! endif !ivs\n\n irec1=1 !start record\n loop1: do\n irec2=min(nrec,irec1+nrec3-1)\n\n if(icomb==0) then !uncombined\n do irank=0,nproc-1\n if(irank_read(irank)>0) then\n call get_outvar_multirecord(1,iday,varname,irec1,irec2,np,last_dim,nvrt,nrec3,outvar,i23d,ivs,eta2,irank)\n endif\n enddo !irank\n else\n call get_outvar_multirecord(1,iday,varname,irec1,irec2,np,last_dim,nvrt,nrec3,outvar,i23d,ivs,eta2)\n endif\n if(inode_elem==1) then !node based\n if(i23d>3) stop 'U said it is node based'\n else !elem\n if(i23d<=3) stop 'U said it is elem based'\n endif\n\n !Available now:\n !outvar(2,nvrt,np|ne,irec2-irec1+1),i23d,ivs,eta2(np,irec2-irec1+1)\n\n do irec=1,irec2-irec1+1 !offeset record #\n!----------------------------------------------------------------------------\n irec_real=irec1+irec-1 !actual record #\n\n out2=0\n if(mod(i23d-1,3)==0) then !2D\n stop 'No 2D vars plz'\n else !i23d=3 \n if(i23d<=3) then !node\n do i=1,nxy\n do j=1,3 !nodes\n nd=node3(i,j)\n do k=max0(1,kbp00(nd)),nvrt\n do m=1,ivs\n out(i,j,k,m)=outvar(m,k,nd,irec)\n enddo !m\n enddo !k\n enddo !j\n enddo !i\n endif !node\n\n! Do interpolation\n do i=1,nxy\n etal=0; dep=0; idry=0\n do j=1,3\n nd=node3(i,j)\n if(eta2(nd,irec)+dp(nd)=ztmp(nvrt)) then !extrap above F.S.\n k0=nvrt-1; rat=1\n else !no extrap below bottom\n k0=0\n do k=kbpl,nvrt-1\n if(z0(kk)>=ztmp(k).and.z0(kk)<=ztmp(k+1)) then\n k0=k\n rat=(z0(kk)-ztmp(k))\/(ztmp(k+1)-ztmp(k))\n exit\n endif\n enddo !k\n endif \n\n if(k0==0) then !no extrap below bottom\n! write(12,*)'Warning: failed to find a vertical level:',it,i\n out4(kk,1:ivs)=rjunk\n else\n do m=1,ivs\n if(i23d<=3) then !node based\n out4(kk,m)=out2(i,k0,m)*(1-rat)+out2(i,k0+1,m)*rat\n else if(i23d<=6) then !elem\n out4(kk,m)=outvar(m,k0+1,iep(i),irec) !FV\n endif\n \n !Debug\n !if(mod(its,iskip)==0) write(99,*)time,i,kk,out4(kk,m)\n enddo !m\n endif\n enddo !kk\n endif !dry\/wet\n\n do kk=1,ntran\n !itmp=(i-1)*ntran+kk\n out3(1:ivs,kk,i)=out4(kk,1:ivs)\n enddo !kk\n enddo !i=1,nxy\n\n !Along all vertical levels of each build pt\n do i=1,nxy\n do kk=1,ntran\n write(21,'(e22.12,2(1x,f10.3))')timeout(irec_real),out3(1:ivs,kk,i)\n enddo !kk\n enddo !i\n\n av_out3=av_out3+out3\n nstep=nstep+1\n endif !i23d\n! enddo !irec=1,nrec\n!----------------------------------------------------------------------------\n enddo !irec\n\n if(irec2==nrec) exit loop1\n irec1=irec1+nrec3\n end do loop1\n\n!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n enddo !iday\n \n! Output average\n open(24,file='average_transect.out',status='replace')\n av_out3=av_out3\/nstep\n do i=1,nxy\n do kk=1,ntran\n if(ivs==2) then\n write(24,'(4(1x,e22.10))')r0(i),z0(kk),av_out3(1:ivs,kk,i)\n else\n j=(i-1)*ntran+kk\n write(24,'(i13,4(1x,e22.10))')j,r0(i),z0(kk),av_out3(1,kk,i)\n endif\n enddo !kk\n enddo !i\n close(24)\n\n print*, 'Finished!'\n\n stop\n end\n\n","avg_line_length":33.5614754098,"max_line_length":297,"alphanum_fraction":0.5124557333} {"size":3053,"ext":"f90","lang":"FORTRAN","max_stars_count":12.0,"content":"! { dg-do run }\n! Tests the patch to implement the array version of the TRANSFER\n! intrinsic (PR17298).\n! Contributed by Paul Thomas \n\n! Bigendian test posted by Perseus in comp.lang.fortran on 4 July 2005.\n! Original had parameter but this fails, at present, if is_gimple_var with -Ox, x>0\n\n LOGICAL :: bigend\n integer :: icheck = 1\n\n character(8) :: ch(2) = (\/\"lmnoPQRS\",\"LMNOpqrs\"\/)\n\n bigend = IACHAR(TRANSFER(icheck,\"a\")) == 0\n\n! tests numeric transfers other than original testscase.\n\n call test1 ()\n\n! tests numeric\/character transfers.\n\n call test2 ()\n\n! Test dummies, automatic objects and assumed character length.\n\n call test3 (ch, ch, ch, 8)\n\ncontains\n\n subroutine test1 ()\n real(4) :: a(4, 4)\n integer(2) :: it(4, 2, 4), jt(32)\n\n! Check multi-dimensional sources and that transfer works as an actual\n! argument of reshape.\n\n a = reshape ((\/(rand (), i = 1, 16)\/), (\/4,4\/))\n jt = transfer (a, it)\n it = reshape (jt, (\/4, 2, 4\/))\n if (any (reshape (transfer (it, a), (\/4,4\/)) .ne. a)) STOP 1\n\n end subroutine test1\n\n subroutine test2 ()\n integer(4) :: y(4), z(2)\n character(4) :: ch(4)\n\n! Allow for endian-ness\n if (bigend) then\n y = (\/(i + 3 + ishft (i + 2, 8) + ishft (i + 1, 16) &\n + ishft (i, 24), i = 65, 80 , 4)\/)\n else \n y = (\/(i + ishft (i + 1, 8) + ishft (i + 2, 16) &\n + ishft (i + 3, 24), i = 65, 80 , 4)\/)\n end if\n\n! Check source array sections in both directions.\n\n ch = \"wxyz\"\n ch(1:2) = transfer (y(2:4:2), ch)\n if (any (ch(1:2) .ne. (\/\"EFGH\",\"MNOP\"\/))) STOP 2\n ch = \"wxyz\"\n ch(1:2) = transfer (y(4:2:-2), ch)\n if (any (ch(1:2) .ne. (\/\"MNOP\",\"EFGH\"\/))) STOP 3\n\n! Check that a complete array transfers with size absent.\n\n ch = transfer (y, ch)\n if (any (ch .ne. (\/\"ABCD\",\"EFGH\",\"IJKL\",\"MNOP\"\/))) STOP 4\n\n! Check that a character array section is OK\n\n z = transfer (ch(2:3), y)\n if (any (z .ne. y(2:3))) STOP 5\n\n! Check dest array sections in both directions.\n\n ch = \"wxyz\"\n ch(3:4) = transfer (y, ch, 2)\n if (any (ch(3:4) .ne. (\/\"ABCD\",\"EFGH\"\/))) STOP 6\n ch = \"wxyz\"\n ch(3:2:-1) = transfer (y, ch, 2)\n if (any (ch(2:3) .ne. (\/\"EFGH\",\"ABCD\"\/))) STOP 7\n\n! Make sure that character to numeric is OK.\n\n ch = \"wxyz\"\n ch(1:2) = transfer (y, ch, 2)\n if (any (ch(1:2) .ne. (\/\"ABCD\",\"EFGH\"\/))) STOP 8\n\n z = transfer (ch, y, 2)\n if (any (y(1:2) .ne. z)) STOP 9\n\n end subroutine test2\n\n subroutine test3 (ch1, ch2, ch3, clen)\n integer clen\n character(8) :: ch1(:)\n character(*) :: ch2(2)\n character(clen) :: ch3(2)\n character(8) :: cntrl(2) = (\/\"lmnoPQRS\",\"LMNOpqrs\"\/)\n integer(8) :: ic(2)\n ic = transfer (cntrl, ic)\n\n! Check assumed shape.\n\n if (any (ic .ne. transfer (ch1, ic))) STOP 10\n\n! Check assumed character length.\n\n if (any (ic .ne. transfer (ch2, ic))) STOP 11\n\n! Check automatic character length.\n\n if (any (ic .ne. transfer (ch3, ic))) STOP 12\n\n end subroutine test3\n\nend\n","avg_line_length":25.4416666667,"max_line_length":83,"alphanum_fraction":0.561087455} {"size":1323,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"program chicharronera2\n! ------------------------------------------------------------------\n! en este programa se calculan las ra\u00edces de la ecuaci\u00f3n cuadr\u00e1tica ax**2+bx+c=0\n! ------------------------------------------------------------------\n! Declaraci\u00f3n de los tipos tipos\n! ------------------------------------------------------------------\nimplicit none\nreal :: a,b,c\n! coeficientes de la ecuaci\u00f3n\nreal :: discr\n! discriminante de la ecuaci\u00f3n\nreal :: x1,x2\n! variables para las posibles soluciones soluciones\nreal :: term, den\n\n\n! Entrada de datos\n\nwrite (*,*)\"Ingrese coeficientes a,b,c de una ecuacion cuadratica de la forma ax\u00b2+bx+c=0 con una coma entre ellos ejemplo: 4,9,6\"\nread(*,*) a,b,c\n if( a == 0 ) then\n write(*,*) \"La ecuaci\u00f3n no tiene t\u00e9rmino cuadr\u00e1tico\"\n stop\n endif\n\n! Bloque de procesamiento y salida\n\ndiscr = b**2 - 4.0*a*c\nden = 2.0*a\nterm = SQRT(ABS(discr))\nif (discr >= 0 ) then\n x1 = (-b+term)\/den\n x2 = (-b-term)\/den\n\n print*, \"a continuaci\u00f3n se muestran las raices de la ecuaci\u00f3n\"\n write(*,*) \"x1 = \", x1\n write(*,*) \"x2 = \", x2\nelse\n x1 = -b\/den\n x2 = term\/den\nprint*, \"a continuaci\u00f3n se muestran las raices con su parte real e imaginaria\"\n write(*,*) \"x1 = (\", x1, \" ,\", x2, \")\"\n write(*,*) \"x1 = (\", x1, \" ,\", -x2, \")\"\nendif\nstop\n\nend program chicharronera2\n","avg_line_length":27.5625,"max_line_length":129,"alphanum_fraction":0.5427059713} {"size":5296,"ext":"f90","lang":"FORTRAN","max_stars_count":5.0,"content":"! Copyright (c) 2015-2021, the ELSI team.\n! All rights reserved.\n!\n! This file is part of ELSI and is distributed under the BSD 3-clause license,\n! which may be found in the LICENSE file in the ELSI root directory.\n\n!>\n!! This is the public interface module of ELSI.\n!!\nmodule ELSI\n\n use ELSI_DATATYPE, only: elsi_handle,elsi_rw_handle\n use ELSI_GEO\n use ELSI_GET\n use ELSI_INPUT\n use ELSI_RW\n use ELSI_SET\n use ELSI_SETUP\n use ELSI_SOLVER\n use ELSI_UTIL, only: elsi_suggest_blacs_distribution\n\n implicit none\n\n private\n\n ! Data type\n public :: elsi_handle\n public :: elsi_rw_handle\n\n ! Setup\n public :: elsi_init\n public :: elsi_set_mpi\n public :: elsi_set_mpi_global\n public :: elsi_set_spin\n public :: elsi_set_kpoint\n public :: elsi_set_blacs\n public :: elsi_set_csc\n public :: elsi_set_csc_blk\n public :: elsi_set_coo\n public :: elsi_reinit\n public :: elsi_finalize\n\n ! Set\n public :: elsi_set_input_file\n public :: elsi_set_output\n public :: elsi_set_output_unit\n public :: elsi_set_output_log\n public :: elsi_set_save_ovlp\n public :: elsi_set_unit_ovlp\n public :: elsi_set_zero_def\n public :: elsi_set_sparsity_mask\n public :: elsi_set_illcond_check\n public :: elsi_set_illcond_tol\n public :: elsi_set_spin_degeneracy\n public :: elsi_set_energy_gap\n public :: elsi_set_spectrum_width\n public :: elsi_set_dimensionality\n public :: elsi_set_elpa_solver\n public :: elsi_set_elpa_n_single\n public :: elsi_set_elpa_gpu\n public :: elsi_set_elpa_autotune\n public :: elsi_set_occ_non_aufbau\n public :: elsi_set_omm_flavor\n public :: elsi_set_omm_n_elpa\n public :: elsi_set_omm_tol\n public :: elsi_set_pexsi_method\n public :: elsi_set_pexsi_n_mu\n public :: elsi_set_pexsi_n_pole\n public :: elsi_set_pexsi_np_per_pole\n public :: elsi_set_pexsi_np_symbo\n public :: elsi_set_pexsi_temp\n public :: elsi_set_pexsi_mu_min\n public :: elsi_set_pexsi_mu_max\n public :: elsi_set_pexsi_inertia_tol\n public :: elsi_set_eigenexa_method\n public :: elsi_set_sips_n_elpa\n public :: elsi_set_sips_n_slice\n public :: elsi_set_sips_inertia_tol\n public :: elsi_set_sips_ev_min\n public :: elsi_set_sips_ev_max\n public :: elsi_set_ntpoly_method\n public :: elsi_set_ntpoly_isr\n public :: elsi_set_ntpoly_tol\n public :: elsi_set_ntpoly_filter\n public :: elsi_set_ntpoly_max_iter\n public :: elsi_set_magma_solver\n public :: elsi_set_mu_broaden_scheme\n public :: elsi_set_mu_broaden_width\n public :: elsi_set_mu_tol\n public :: elsi_set_mu_mp_order\n public :: elsi_set_n_frozen\n public :: elsi_set_frozen_method\n public :: elsi_set_frozen_idx\n\n ! Get\n public :: elsi_get_version\n public :: elsi_get_datestamp\n public :: elsi_get_initialized\n public :: elsi_get_n_illcond\n public :: elsi_get_ovlp_ev_min\n public :: elsi_get_ovlp_ev_max\n public :: elsi_get_pexsi_mu_min\n public :: elsi_get_pexsi_mu_max\n public :: elsi_get_mu\n public :: elsi_get_entropy\n public :: elsi_get_edm_real\n public :: elsi_get_edm_complex\n public :: elsi_get_edm_real_sparse\n public :: elsi_get_edm_complex_sparse\n public :: elsi_get_eval\n public :: elsi_get_evec_real\n public :: elsi_get_evec_complex\n public :: elsi_get_occ\n\n ! Deprecated\n public :: elsi_set_write_unit\n public :: elsi_set_sing_check\n public :: elsi_set_sing_tol\n public :: elsi_set_elpa_gpu_kernels\n public :: elsi_set_pexsi_gap\n public :: elsi_set_pexsi_delta_e\n public :: elsi_set_sips_interval\n public :: elsi_set_mu_spin_degen\n public :: elsi_set_uuid\n public :: elsi_get_n_sing\n\n ! Solve\n public :: elsi_ev_real\n public :: elsi_ev_complex\n public :: elsi_ev_real_sparse\n public :: elsi_ev_complex_sparse\n public :: elsi_dm_real\n public :: elsi_dm_complex\n public :: elsi_dm_real_sparse\n public :: elsi_dm_complex_sparse\n public :: elsi_bse_real\n public :: elsi_bse_complex\n public :: elsi_inverse_cholesky_real\n public :: elsi_inverse_cholesky_complex\n\n ! Tool\n public :: elsi_orthonormalize_ev_real\n public :: elsi_orthonormalize_ev_complex\n public :: elsi_orthonormalize_ev_real_sparse\n public :: elsi_orthonormalize_ev_complex_sparse\n public :: elsi_extrapolate_dm_real\n public :: elsi_extrapolate_dm_complex\n public :: elsi_extrapolate_dm_real_sparse\n public :: elsi_extrapolate_dm_complex_sparse\n public :: elsi_compute_dm_real\n public :: elsi_compute_dm_complex\n public :: elsi_compute_edm_real\n public :: elsi_compute_edm_complex\n public :: elsi_compute_mu_and_occ\n public :: elsi_compute_entropy\n public :: elsi_suggest_blacs_distribution\n\n ! Read and write matrix\n public :: elsi_init_rw\n public :: elsi_finalize_rw\n public :: elsi_set_rw_mpi\n public :: elsi_set_rw_blacs\n public :: elsi_set_rw_csc\n public :: elsi_set_rw_zero_def\n public :: elsi_set_rw_header\n public :: elsi_get_rw_header\n public :: elsi_read_mat_dim\n public :: elsi_read_mat_dim_sparse\n public :: elsi_read_mat_real\n public :: elsi_read_mat_real_sparse\n public :: elsi_read_mat_complex\n public :: elsi_read_mat_complex_sparse\n public :: elsi_write_mat_real\n public :: elsi_write_mat_real_sparse\n public :: elsi_write_mat_complex\n public :: elsi_write_mat_complex_sparse\n\nend module ELSI\n","avg_line_length":29.5865921788,"max_line_length":78,"alphanum_fraction":0.7556646526} {"size":746,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"submodule (io:mag) mag_nc4\n\nuse timeutils, only: date_filename\nuse nc4fortran, only: netcdf_file\n\nimplicit none (type, external)\n\ncontains\n\nmodule procedure output_magfields_nc4\n!! WE ASSUME THE ROOT PROCESS HAS ALREADY REDUCED THE MAGNETIC FIELD DATA\n\ntype(netcdf_file) :: hout\n\ncharacter(:), allocatable :: filenamefull\n\nfilenamefull = date_filename(outdir \/\/ '\/magfields\/',ymd,UTsec) \/\/ '.nc'\nprint *, ' Output file name (magnetic fields): ',filenamefull\n\ncall hout%initialize(filenamefull, status='unknown',action='rw',comp_lvl=comp_lvl)\n\ncall hout%write('magfields\/Br', Br)\ncall hout%write('magfields\/Btheta', Btheta)\ncall hout%write('magfields\/Bphi', Bphi)\n\ncall hout%finalize()\n\nend procedure output_magfields_nc4\n\nend submodule mag_nc4\n","avg_line_length":24.064516129,"max_line_length":82,"alphanum_fraction":0.7694369973} {"size":2859,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"# Fletcher files\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/utils\/Utils.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/utils\/SimUtils.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/utils\/Ram1R1W.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/Buffers.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/interconnect\/Interconnect.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/Streams.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamArb.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamBuffer.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamFIFOCounter.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamFIFO.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamGearbox.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamNormalizer.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamParallelizer.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamSerializer.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamSlice.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/streams\/StreamSync.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayConfigParse.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayConfig.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/Arrays.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrow\/Arrow.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/BufferReaderCmdGenBusReq.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/BufferReaderCmd.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/BufferReaderPost.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/BufferReaderRespCtrl.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/BufferReaderResp.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/buffers\/BufferReader.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/interconnect\/BusReadArbiter.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/interconnect\/BusReadArbiterVec.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/interconnect\/BusReadBuffer.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderArb.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderLevel.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderList.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderListPrim.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderListSync.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderListSyncDecoder.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderNull.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderStruct.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReaderUnlockCombine.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/arrays\/ArrayReader.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/wrapper\/Wrapper.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/wrapper\/UserCoreController.vhd\r\n\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/axi\/axi.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/axi\/axi_mmio.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/axi\/axi_read_converter.vhd\r\n${FLETCHER_HARDWARE_DIR}\/vhdl\/axi\/axi_write_converter.vhd\r\n\r\n# Fletcher to AWS glue\r\n$FLETCHER_EXAMPLES_DIR\/sum-fast\/hardware\/fletcher_wrapper.vhd\r\n$FLETCHER_EXAMPLES_DIR\/sum-fast\/hardware\/axi_top.vhd\r\n\r\n# User provided hardware accelerated function\r\n$FLETCHER_EXAMPLES_DIR\/sum-fast\/hardware\/sum.vhd\r\n\r\n\r\n","avg_line_length":43.3181818182,"max_line_length":68,"alphanum_fraction":0.833158447} {"size":35655,"ext":"f","lang":"FORTRAN","max_stars_count":4.0,"content":"\n subroutine get_precip_inc(i4time_beg,i4time_end ! Input\n 1 ,imax,jmax,kmax ! Input\n 1 ,MAX_RADAR_FILES ! Input\n 1 ,lat,lon,topo ! Input\n 1 ,ilaps_cycle_time,grid_spacing_cen_m ! Input\n 1 ,radarext_3d_accum ! Input\n 1 ,snow_accum,precip_accum,frac_sum ! Outputs\n 1 ,istatus) ! Output\n\n! Calculate and return incremental precip for the analysis time cycle\n\n! Input\n real lat(imax,jmax)\n real lon(imax,jmax)\n real topo(imax,jmax)\n\n character*31 radarext_3d_accum\n\n! Output\n real snow_accum(imax,jmax) ! M\n real precip_accum(imax,jmax) ! M\n\n! Local\n real pcp_bkg_m(imax,jmax) ! background field for gauge analysis\n real closest_radar(imax,jmax) ! M\n\tcharacter var_req*4\n\n call get_precip_radar(i4time_beg,i4time_end ! Input\n 1 ,imax,jmax,kmax ! Input\n 1 ,MAX_RADAR_FILES ! Input\n 1 ,lat,lon,topo ! Input\n 1 ,ilaps_cycle_time,grid_spacing_cen_m ! Input\n 1 ,radarext_3d_accum ! Input\n 1 ,snow_accum,precip_accum,frac_sum ! Outputs\n 1 ,closest_radar ! Output\n 1 ,istatus) ! Output\n\n! Read precip first guess (LGB\/FSF). Try 'R01' variable\n var_req = 'R01'\n call get_modelfg_2d(i4time_end,var_req,imax,jmax,pcp_bkg_m\n 1 ,istat_bkg) \n\n! if(istat_bkg .ne. 1)then\n! var_req = 'PCP'\n! call get_modelfg_2d(i4time_end,var_req,imax,jmax,pcp_bkg_m \n! 1 ,istat_bkg) \n! endif\n\n! if(istat_bkg .ne. 1)then\n! write(6,*)' No model first guess precip, using zero field' \n! pcp_bkg_m = 0.\n! endif\n\n! Compare to gauge values\n if(ilaps_cycle_time .eq. 3600)then\n call get_maxstns(maxsta,istatus)\n if(istatus .ne. 1)return\n\n call get_r_missing_data(r_missing_data,istatus)\n if(istatus .ne. 1)return\n\n call blend_gauge_data( i4time_end,imax,jmax,maxsta ! I\n 1 ,r_missing_data ! I\n 1 ,lat,lon ! I\n 1 ,pcp_bkg_m ! I\n 1 ,ilaps_cycle_time ! I\n 1 ,closest_radar ! I\n 1 ,precip_accum) ! I\/O\n endif\n\n return\n end\n\n subroutine get_precip_radar(i4time_beg,i4time_end ! Input\n 1 ,imax,jmax,kmax ! Input\n 1 ,MAX_RADAR_FILES ! Input\n 1 ,lat,lon,topo ! Input\n 1 ,ilaps_cycle_time,grid_spacing_cen_m ! Input\n 1 ,radarext_3d_accum ! Input\n 1 ,snow_accum,precip_accum,frac_sum ! Outputs\n 1 ,closest_radar ! Output\n 1 ,istatus) ! Output\n\n! Steve Albers 1991\n! Steve Albers 1995 Dec Modify radar call to read_radar_ref\n! Returns Accumulated Snow and Liquid Precip\n! This routine uses 3D precip type (using temp data from the\n! closest cycle) as a cutoff for snow\/no snow. This is calculated and\n! applied every time we are leaving the valid time window for a\n! particular set of environmental data. Typically, the first half of the\n! cycle time comes from the previous cycle's temp data, the second half of\n! the period uses current data. A mask is also used so that the 3D\n! precip type calculations are performed only where there are accumulating\n! echoes. In other words, this code is more complex that it would\n! otherwise be so that real-time speed is optimized.\n\n! Input\n real lat(imax,jmax)\n real lon(imax,jmax)\n real topo(imax,jmax)\n\n! Output\n real snow_accum(imax,jmax) ! M\n real precip_accum(imax,jmax) ! M\n real closest_radar(imax,jmax) ! M\n\n! Local\n real precip_rateave(imax,jmax)\n real snow_rateave(imax,jmax)\n real snow_accum_pd(imax,jmax)\n real snow_rate(imax,jmax) ! M\/S\n real precip_rate(imax,jmax) ! M\/S\n real dbz_2d(imax,jmax)\n real t_sfc_k(imax,jmax)\n real td_sfc_k(imax,jmax)\n real pres_sfc_pa(imax,jmax)\n real tw_sfc_k(imax,jmax)\n real temp_3d(imax,jmax,kmax)\n real height_3d(imax,jmax,kmax)\n real temp_col_max(imax,jmax)\n real rh_3d(imax,jmax,kmax)\n real pres_3d(imax,jmax,kmax)\n logical l_mask_pcp(imax,jmax)\n logical l_mask_rdr(imax,jmax)\n integer i2_pcp_type_2d(imax,jmax)\n integer i2_cldpcp_type_3d(imax,jmax,kmax)\n integer ipcp_1d(kmax)\n\n real grid_ra_ref(imax,jmax,kmax)\n\n character*9 asc_tim_9,asc_tim_9_beg,asc_tim_9_end\n integer i4time_file(MAX_RADAR_FILES)\n real frac(MAX_RADAR_FILES)\n\n character*4 radar_name ! Local\n\n character*3 var_2d\n character*3 ext_local\n character*31 ext, radarext_3d_accum\n character*10 units_2d\n character*125 comment_2d\n\n integer iarg\n\n logical l_first_sfc_update_completed\n\n character*80 grid_fnam_common\n common \/ grid_fnam_cmn \/ grid_fnam_common\n\n data mode_radar\/1\/\n\n twet_snow = +1.3\n\n max_radar_gap = float(ilaps_cycle_time) + 1200. ! * 1.33334\n\n im = imax\/2 ! 15\n jm = jmax\/2 ! 56\n\n call make_fnam_lp(i4time_beg,asc_tim_9_beg,istatus)\n call make_fnam_lp(i4time_end,asc_tim_9_end,istatus)\n\n call get_r_missing_data(r_missing_data,istatus)\n if(istatus .ne. 1)return\n\n write(6,*)' Radar accumulation from ',asc_tim_9_beg,\n 1 ' to ',asc_tim_9_end\n\n! Get File Times and fractional time periods\n i4time_now = i4time_now_gg()\n i_wait = (i4time_end + (35*60) - i4time_now) \/ 60\n write(6,*)' Number of potential wait cycles = ',i_wait\n\n 50 continue\n\n if(radarext_3d_accum(1:3) .eq. 'xxx')then ! automatically select type(s)\n ext_local = 'vrc'\n call get_fracs(i4time_beg,i4time_end,max_radar_gap ! I\n 1 ,i_nbr_files_ret ! I\n 1 ,ext_local ! I\n 1 ,max_radar_files ! I\n 1 ,nscans_vrc ! O\n 1 ,i4time_file ! 0\n 1 ,frac,frac_sum,istatus) ! O\n\n write(6,*)' ext_local \/ nscans = ',ext_local,' ',nscans_vrc \n\n ext_local = 'vrz'\n call get_fracs(i4time_beg,i4time_end,max_radar_gap ! I\n 1 ,i_nbr_files_ret ! I\n 1 ,ext_local ! I\n 1 ,max_radar_files ! I\n 1 ,nscans_vrz ! O\n 1 ,i4time_file ! 0\n 1 ,frac,frac_sum,istatus) ! O\n\n write(6,*)' ext_local \/ nscans = ',ext_local,' ',nscans_vrz \n\n if(nscans_vrc .gt. nscans_vrz)then\n ext_local = 'vrc'\n elseif(nscans_vrc .lt. nscans_vrz)then\n ext_local = 'vrz'\n else ! equal case\n ext_local = 'vrc' ! or 'vrz'\n endif\n\n write(6,*)\n write(6,*)' auto select: nscans_vrc\/nscans_vrz\/ext_local:'\n 1 ,nscans_vrc,nscans_vrz,' ',ext_local \n write(6,*)\n\n else\n ext_local = radarext_3d_accum(1:3)\n\n endif\n\n call get_fracs(i4time_beg,i4time_end,max_radar_gap ! I\n 1 ,i_nbr_files_ret ! I\n 1 ,ext_local ! I\n 1 ,max_radar_files ! I\n 1 ,nscans ! O\n 1 ,i4time_file ! 0\n 1 ,frac,frac_sum,istatus) ! O\n\n write(6,*)' ext_local \/ nscans = ',ext_local,' ',nscans\n\n if(istatus .ne. 1)then\n if(i_wait .gt. 0 .and. frac_sum .ge. 0.30)then\n write(6,*)' Waiting 1 min for possible radar data'\n 1 ,frac_sum\n call snooze_gg(60.0,istat_snooze)\n i_wait = i_wait - 1\n goto50\n\n else ! Will not wait for radar data\n write(6,*)' WARNING: Insufficient data for accum'\n write(6,*)' No accum output being generated'\n return\n\n endif\n endif\n\n! Initialize both period and total precip\/snow\n\n! Snow is accumulated in \"periods\" corresponding to when the ancillary\n! LAPS data is read in. Each time new ancillary data is read in, the\n! \"period\" snow accumulation is added to the overall snow total for the\n! window.\n\n! This is done so that precip type (which determines snow\/no snow) only\n! has to be calculated only once for every time ancillary data is read in.\n! The precip type is calculated over a masked area corresponding to where\n! precip (potentially snow) has occurred over the \"period\".\n\n! This approximation may lead to slightly inaccurate accumulations\n! over the period if the precip type is changing over the period.\n! Note that precip type is a function of temperature, rh, and even\n! reflectivity - all of which can change in various ways over the\n! laps cycle. The approximation is there to increase the speed of\n! execution. When computers get better, it may be desirable to\n! redesign this so the precip type (and snow\/rain ratio) gets calculated\n! for each radar scan. Of course this can also be taken care of by\n! decreasing the overall LAPS analysis cycle time.\n\n do j = 1,jmax\n do i = 1,imax\n snow_rateave(i,j) = 0.\n snow_accum_pd(i,j) = 0.\n precip_rateave(i,j) = 0.\n l_mask_pcp(i,j) = .false.\n l_mask_rdr(i,j) = .false.\n enddo ! i\n enddo ! j\n\n i4_interval = (i4time_end - i4time_beg)\n i4time_mid = i4time_beg + i4_interval \/ 2\n i4_tol = max(float(ilaps_cycle_time) * 0.6,20.)\n i4time_temp = 0\n\n l_first_sfc_update_completed = .false.\n\n! Loop through all the radar scan times\n do ifile = 1,i_nbr_files_ret\n if(frac(ifile) .gt. 0.)then ! This scan is needed for the window at hand\n\n i4time_radar = i4time_file(ifile)\n\n call make_fnam_lp(i4time_radar,asc_tim_9,istatus)\n\n! write(6,101)asc_tim_9,frac(ifile)\n!101 format(' Time, Frac = ',a9,2x,f6.3)\n\n write(6,*)\n\n! Determine whether we need to update the sfc data to match the radar\n! and if we should add the period snow accum onto the total\n if(abs(i4time_radar - i4time_temp) .gt. ilaps_cycle_time\/2 \n 1 )then\n\n! Determine whether to add to snow accum total based on precip \n! type using ancillary LAPS data valid for the interval just \n! ended. Note that the first time around, we are just \n! initializing and don't need to add to the snow accum, we just \n! read in the initial ancillary LAPS data.\n\n if(l_first_sfc_update_completed)then\n do j = 1,jmax\n do i = 1,imax\n if(snow_accum_pd(i,j) .gt. 1e-10)then\n l_mask_pcp(i,j) = .true.\n endif\n enddo\n enddo\n\n\n write(6,*)' Compute 3D precip type over masked area'\n\n! Note that the reflectivities here are valid at the end\n! of the accumulating period. This means that the wb \n! threshold is calculated using reflectivities that may not \n! be representative for the entire accumulation subperiod\n! (typically one half of the laps cycle time).\n\n call cpt_pcp_type_3d(temp_3d,rh_3d,pres_3d\n 1 ,grid_ra_ref,l_mask_pcp,grid_spacing_cen_m\n 1 ,imax,jmax,kmax,twet_snow,i2_cldpcp_type_3d\n 1 ,istatus)\n if(istatus .ne. 1)then\n return\n endif\n\n I4_elapsed = ishow_timer()\n\n write(6,*)' Compute sfc precip type'\n call get_sfc_preciptype(pres_sfc_pa,t_sfc_k,td_sfc_k\n 1 ,i2_cldpcp_type_3d,twet_snow,dbz_2d\n 1 ,i2_pcp_type_2d,imax,jmax,kmax)\n\n I4_elapsed = ishow_timer()\n\n write(6,*)\n 1 ' Adding in accumulation for intervening period'\n\n n_pcp_pts = 0\n n_snw_pts = 0\n n_nopcp_pts = 0\n n_zr_pts = 0\n\n do j = 1,jmax\n do i = 1,imax\n\n if(l_mask_pcp(i,j))then\n n_pcp_pts = n_pcp_pts + 1\n iarg = i2_pcp_type_2d(i,j)\/16\n\n if(iarg .eq. 2)then ! precip type is snow\n r_pcp_type = iarg\n r_pcp_type_thresh = iarg\n\n if(.true.)then ! testcode\n call nowrad_virga_correction(\n 1 r_pcp_type,\n 1 r_pcp_type_thresh,\n 1 t_sfc_k(i,j),\n 1 td_sfc_k(i,j),\n 1 istatus_3dref)\n endif\n\n if(r_pcp_type_thresh .eq. 2.0)then\n snow_rateave(i,j) = \n 1 snow_rateave(i,j)+snow_accum_pd(i,j) \n n_snw_pts = n_snw_pts + 1\n else\n write(6,*)\n 1 ' Nowrad_virga thresh out #1',i,j \n endif\n\n elseif(iarg .eq. 0)then ! precip type is no precip\n n_nopcp_pts = n_nopcp_pts + 1\n if(n_nopcp_pts .le. 20)\n 1 write(6,*)' No2dPcpType pt at',i,j\n\n elseif(iarg .eq. 3)then ! precip type is freezing rain\n n_zr_pts = n_zr_pts + 1\n\n endif\n\n endif\n enddo ! i\n enddo ! j\n\n! This is useful for debugging\n do k = 1,kmax\n iarg = i2_cldpcp_type_3d(im,jm,k) \/ 16\n ipcp_1d(k) = iarg\n enddo ! k\n write(6,101)l_mask_pcp(im,jm),snow_accum_pd(im,jm)\n 1 ,snow_rateave(im,jm)\n 1 ,t_sfc_k(im,jm),td_sfc_k(im,jm)\n 1 ,i2_pcp_type_2d(im,jm)\n 1 ,(ipcp_1d(k),k=1,min(kmax,10))\n101 format(1x,'accum\/tw\/type2,3d',l2,2e11.3,2f6.1,i3,1x,\n 1 10i2)\n\n write(6,*)' # of Points Snow\/Precip\/ZR = '\n 1 ,n_snw_pts,n_pcp_pts,n_zr_pts\n\n if(n_nopcp_pts .gt. 0)\n 1 write(6,*)' WARNING: n_nopcp_pts = ',n_nopcp_pts\n\n endif ! l_first_sfc_update_completed\n\n! Initialize\n do j = 1,jmax\n do i = 1,imax\n snow_accum_pd(i,j) = 0.\n l_mask_pcp(i,j) = .false.\n enddo ! i\n enddo ! j\n\n! Read in surface data that is time matched to the radar data\n write(6,*)\n write(6,*)' Updating Surface and 3D Temp Information'\n\n! Read in surface temp data\n var_2d = 'T'\n ext = 'lsx'\n call get_laps_2dgrid(i4time_radar,i4_tol,i4time_temp\n 1 ,ext,var_2d,units_2d,comment_2d\n 1 ,imax,jmax,t_sfc_k,0,istatus)\n if(istatus .ne. 1)then\n write(6,*)' WARNING: LAPS Sfc Temp not available' \n frac_sum = -1.0 ! Turns off the wait loop for more radar\n return\n endif\n\n! Read in surface dewpoint data\n var_2d = 'TD'\n ext = 'lsx'\n call get_laps_2d(i4time_temp,ext,var_2d\n 1 ,units_2d,comment_2d,imax,jmax,td_sfc_k,istatus)\n if(istatus .ne. 1)then\n write(6,*)' WARNING: LAPS Sfc Dewpoint'\n 1 ,' not available' \n frac_sum = -1.0 ! Turns off the wait loop for more radar\n return\n endif\n\n! Read in surface pressure data\n var_2d = 'PS'\n ext = 'lsx'\n call get_laps_2d(i4time_temp,ext,var_2d\n 1 ,units_2d,comment_2d,imax,jmax,pres_sfc_pa,istatus)\n if(istatus .ne. 1)then\n write(6,*)' Warning: LAPS Sfc Pressure '\n 1 ,'not available' \n frac_sum = -1.0 ! Turns off the wait loop for more radar\n return\n endif\n\n I4_elapsed = ishow_timer()\n\n write(6,*)' Getting LT1 Height\/Temp' \n var_2d = 'HT' \n ext = 'lt1'\n\n call get_laps_3d(i4time_temp\n 1 ,imax,jmax,kmax,ext,var_2d\n 1 ,units_2d,comment_2d,height_3d,istatus)\n if(istatus .ne. 1)then\n write(6,*)' Warning: LAPS 3D Height not available' \n frac_sum = -1.0 ! Turns off the wait loop for more radar\n return\n endif\n\n var_2d = 'T3' \n ext = 'lt1'\n\n call get_laps_3d(i4time_temp\n 1 ,imax,jmax,kmax,ext,var_2d\n 1 ,units_2d,comment_2d,temp_3d,istatus)\n if(istatus .ne. 1)then\n write(6,*)' Warning: LAPS 3D Temp not available' \n frac_sum = -1.0 ! Turns off the wait loop for more radar\n return\n endif\n\n! Calculate column max temperatures\n do j = 1,jmax\n do i = 1,imax\n temp_col_max(i,j) = t_sfc_k(i,j)\n k_sfc = int(zcoord_of_pressure(pres_sfc_pa(i,j)))\n do k = k_sfc+1,kmax\n temp_col_max(i,j) =\n 1 max(temp_col_max(i,j),temp_3d(i,j,k))\n enddo ! k\n enddo ! i\n enddo ! j\n\n\n write(6,*)' Getting LH3 file (or equivalent)'\n var_2d = 'RHL'\n ext = 'lh3'\n call get_laps_3dgrid(i4time_temp,ilaps_cycle_time ! *2\n 1 ,i4time_rh\n 1 ,imax,jmax,kmax,ext,var_2d\n 1 ,units_2d,comment_2d,rh_3d,istatus) \n if(istatus .ne. 1)then\n write(6,*)' Warning: LAPS 3D RH not available'\n frac_sum = -1.0 ! Turns off the wait loop for more radar\n return\n endif\n\n l_first_sfc_update_completed = .true.\n\n write(6,*)' Ancillary LAPS data update completed'\n write(6,*)\n\n I4_elapsed = ishow_timer()\n\n else ! l_first_sfc_update_completed = .true.\n write(6,*)' No Ancillary LAPS data update needed'\n\n endif ! We need to update the LAPS information\n\n! Get LAPS reflectivities at the surface (or immediately above it)\n write(6,*)\n\n! Repeat read in radar data with low level reflectivities filled in\n call get_ref_base(ref_base,istatus)\n if(istatus .ne. 1)return\n\n i4_tol_radar = 1200\n \n ext = ' '\n ext(1:3) = ext_local\n call read_radar_3dref_new(i4time_radar, ! I\n 1 i4_tol_radar,i4_ret, ! I\/O\n 1 .true.,r_missing_data,imax,jmax,kmax, ! I\n 1 ext,lat,lon,topo,\n 1 .true.,.false.,\n 1 height_3d,\n 1 grid_ra_ref,\n 1 closest_radar, ! O\n 1 rlat_radar,rlon_radar,rheight_radar,radar_name,\n 1 n_ref,istatus_2dref,istatus_3dref)\n\n if(istatus_2dref .eq. 0)then\n write(6,*)' Error in reading radar data in PRECIP ACCUM'\n frac_sum = -1.0 ! Turns off the wait loop for more radar\n istatus = 0\n return\n endif\n\n! For now, we can change the 'r_missing_data' values to 'ref_base'\n do i = 1,imax\n do j = 1,jmax\n do k = 1,kmax\n if(grid_ra_ref(i,j,k) .eq. r_missing_data)then\n grid_ra_ref(i,j,k) = ref_base\n else\n l_mask_rdr(i,j) = .true.\n endif\n enddo ! k\n enddo ! j\n enddo ! i\n\n write(6,*)' Call get_low_ref'\n\n call get_low_ref(grid_ra_ref,pres_sfc_pa,imax,jmax,kmax\n 1 ,dbz_2d)\n\n write(6,*)' Incrementing Precip Accumulation '\n 1 ,'rate for this scan (call zr)'\n\n call zr(dbz_2d,imax,jmax,precip_rate)\n\n do j = 1,jmax\n do i = 1,imax\n if(precip_rate(i,j) .ne. r_missing_data .and.\n 1 l_mask_rdr(i,j) .and.\n 1 precip_rateave(i,j) .ne. r_missing_data )then\n precip_rateave(i,j) = precip_rateave(i,j)\n 1 + precip_rate(i,j) * frac(ifile) \n else\n precip_rateave(i,j) = r_missing_data\n endif\n enddo ! i\n enddo ! j\n\n\n write(6,*)' Incrementing Snow Accumulation_pd for this scan'\n\n call zs(precip_rate,temp_col_max,imax,jmax,snow_rate)\n\n do j = 1,jmax\n do i = 1,imax\n if(snow_rate(i,j) .ne. r_missing_data .and.\n 1 l_mask_rdr(i,j) .and.\n 1 snow_accum_pd(i,j) .ne. r_missing_data )then\n snow_accum_pd(i,j) = snow_accum_pd(i,j)\n 1 + snow_rate(i,j) * frac(ifile)\n else\n snow_accum_pd(i,j) = r_missing_data\n endif\n enddo ! i\n enddo ! j\n\n write(6,202)dbz_2d(im,jm),snow_rate(im,jm)\n 1 ,snow_accum_pd(im,jm)\n202 format(1x,'dbz\/rate\/accum_pd',3e12.4)\n\n endif ! Frac > 0 (This radar file is within the accumulating window\n\n! write(6,*)' Cycle to next file'\n\n enddo ! ifile (Loop through all radar file times)\n\n\n! Add in snow accumulation from final period; first define the mask\n do j = 1,jmax\n do i = 1,imax\n if(snow_accum_pd(i,j) .gt. 1e-10 .and. \n 1 snow_accum_pd(i,j) .ne. r_missing_data)then\n l_mask_pcp(i,j) = .true.\n endif\n enddo\n enddo\n\n\n write(6,*)' Compute 3D precip type over masked area'\n\n call cpt_pcp_type_3d(temp_3d,rh_3d,pres_3d,grid_ra_ref\n 1 ,l_mask_pcp,grid_spacing_cen_m\n 1 ,imax,jmax,kmax,twet_snow,i2_cldpcp_type_3d,istatus)\n if(istatus .ne. 1)then\n return\n endif\n\n write(6,*)' Compute sfc precip type'\n call get_sfc_preciptype(pres_sfc_pa,t_sfc_k,td_sfc_k\n 1 ,i2_cldpcp_type_3d,twet_snow,dbz_2d,i2_pcp_type_2d\n 1 ,imax,jmax,kmax)\n\n write(6,*)' Adding in accumulation for the last period'\n\n n_pcp_pts = 0\n n_snw_pts = 0\n n_nopcp_pts = 0\n n_zr_pts = 0\n\n do j = 1,jmax\n do i = 1,imax\n\n if(l_mask_pcp(i,j))then\n n_pcp_pts = n_pcp_pts + 1\n iarg = i2_pcp_type_2d(i,j) \/ 16\n\n if(iarg .eq. 2)then ! precip type is snow\n\n r_pcp_type = iarg\n r_pcp_type_thresh = iarg\n\n if(.true.)then ! testcode\n call nowrad_virga_correction(\n 1 r_pcp_type,\n 1 r_pcp_type_thresh,\n 1 t_sfc_k(i,j),\n 1 td_sfc_k(i,j),\n 1 istatus_3dref)\n else\n write(6,*)' Nowrad_virga thresh out #2',i,j\n endif\n\n if(r_pcp_type_thresh .eq. 2.0)then\n snow_rateave(i,j) = snow_rateave(i,j) \n 1 + snow_accum_pd(i,j)\n n_snw_pts = n_snw_pts + 1\n endif\n\n elseif(iarg .eq. 0)then ! precip type is no precip\n n_nopcp_pts = n_nopcp_pts + 1\n if(n_nopcp_pts .le. 20)write(6,*)\n 1 ' No2dPcpType pt at ',i,j \n elseif(iarg .eq. 3)then ! precip type is freezing rain\n n_zr_pts = n_zr_pts + 1\n endif\n\n endif\n\n enddo ! i\n enddo ! j\n\n\n! This is useful for debugging\n do k = 1,kmax\n iarg = i2_cldpcp_type_3d(im,jm,k) \/ 16\n ipcp_1d(k) = iarg\n enddo ! k\n write(6,101)l_mask_pcp(im,jm),snow_accum_pd(im,jm)\n 1 ,snow_rateave(im,jm)\n 1 ,t_sfc_k(im,jm),td_sfc_k(im,jm)\n 1 ,i2_pcp_type_2d(im,jm)\n 1 ,(ipcp_1d(k),k=1,min(kmax,10))\n\n write(6,*)' # of Points Snow\/Precip\/ZR = ',n_snw_pts,n_pcp_pts\n 1 ,n_zr_pts\n\n if(n_nopcp_pts .gt. 0)write(6,*)' WARNING: n_nopcp_pts = '\n 1 ,n_nopcp_pts\n\n write(6,*)' Converting from average rate to actual accumulation'\n\n! Convert from time averaged rate to accumulation\n do j = 1,jmax\n do i = 1,imax\n if(snow_rateave(i,j) .ne. r_missing_data)then\n snow_accum(i,j) = snow_rateave(i,j) * i4_interval\n else\n snow_accum(i,j) = r_missing_data\n endif\n\n if(precip_rateave(i,j) .ne. r_missing_data)then\n precip_accum(i,j) = precip_rateave(i,j) * i4_interval\n else\n precip_accum(i,j) = r_missing_data\n endif\n enddo ! i\n enddo ! j\n\n write(6,*)' Radar snow_accum(im,jm) = ',snow_accum(im,jm)\n write(6,*)' Radar precip_accum(im,jm) = ',precip_accum(im,jm)\n\n return\n end\n\n subroutine get_fracs(i4time_beg,i4time_end,max_radar_gap ! I\n 1 ,i_nbr_files_ret ! I\n 1 ,ext ! I\n 1 ,max_radar_files ! I\n 1 ,nscans ! O\n 1 ,i4time_file,frac,frac_sum,istatus) ! O\n\n! Steve Albers 1991 This routine calculates linear combination\n! coefficients for radar scans which can be used\n! to arrive at an integrated precipitation rate\n! over a specified time window\n\n integer MAX_RADAR_FILES\n\n character*255 c_filespec\n character*9 asc_tim_9\n character c_fnames(MAX_RADAR_FILES)*80\n character*3 ext\n\n real frac(MAX_RADAR_FILES)\n integer i4time_file(MAX_RADAR_FILES)\n\n nscans = 0 ! initialize\n\n call get_filespec(ext,2,c_filespec,istatus)\n\n call Get_file_names(c_filespec,\n 1 i_nbr_files_ret,\n 1 c_fnames,\n 1 max_radar_files,\n 1 i_status)\n\n if(i_nbr_files_ret .gt. 0)then\n call get_directory_length(c_fnames(1),lenf)\n else ! Error Condition\n write(6,*)' WARNING: No Radar Data Available for'\n 1 ,' Snow\/Precip Accumulation ',ext\n istatus = 0\n return\n endif\n\n do i=1,i_nbr_files_ret\n asc_tim_9 = c_fnames(i)(lenf+1:lenf+9)\n call i4time_fname_lp(asc_tim_9,I4time_file(i),istatus)\n if(istatus .ne. 1)then\n write(6,*)' Bad return from i4time_fname_lp,',\n 1 ' called from get_precip_accum: ',asc_tim_9\n return\n endif\n enddo\n\n i4_interval = i4time_end - i4time_beg\n nscans = 0\n\n do i = 1,i_nbr_files_ret\n! write(6,301)i4time_beg,i4time_file(i),i4time_end\n!301 format(1x,3i12)\n frac(i) = 0.\n\n if(i4time_file(i) .ge. i4time_beg .and.\n 1 i4time_file(i) .lt. i4time_end )then\n nscans = nscans + 1\n endif\n enddo\n\n do i = 1,i_nbr_files_ret-1\n ibeg = i\n iend = i+1\n\n interval_between_files = i4time_file(iend) \n 1 - i4time_file(ibeg)\n\n frac_between_files = float(interval_between_files)\n 1 \/ float(i4_interval)\n\n if(i4time_file(ibeg) .ge. i4time_beg .and.\n 1 i4time_file(iend) .le. i4time_end )then ! Fully Within Pd\n frac(ibeg) = frac(ibeg) + 0.5 * frac_between_files\n frac(iend) = frac(iend) + 0.5 * frac_between_files\n\n if(interval_between_files .gt. max_radar_gap)then\n write(6,*)' Warning: Gap in radar files (min) >'\n 1 ,max_radar_gap\/60\n istatus = 0\n return\n endif\n\n endif\n\n if(i4time_file(ibeg) .lt. i4time_beg .and.\n 1 i4time_file(iend) .gt. i4time_beg .and.\n 1 i4time_file(iend) .le. i4time_end )then ! Straddle Beginning\n a = i4time_beg - i4time_file(ibeg)\n b = i4time_file(iend) - i4time_beg\n partial_frac = b\/(a+b)\n frac(ibeg) = frac(ibeg) + ( 0.5 * partial_frac)\n 1 * frac_between_files * partial_frac\n frac(iend) = frac(iend) + (1.0 - 0.5 * partial_frac)\n 1 * frac_between_files * partial_frac\n\n if(interval_between_files .gt. max_radar_gap)then\n write(6,*)' Warning: Gap in radar files (min) >'\n 1 ,max_radar_gap\/60\n istatus = 0\n return\n endif\n\n endif\n\n if(i4time_file(ibeg) .lt. i4time_end .and.\n 1 i4time_file(ibeg) .ge. i4time_beg .and.\n 1 i4time_file(iend) .gt. i4time_end )then ! Straddle End\n a = i4time_end - i4time_file(ibeg)\n b = i4time_file(iend) - i4time_end\n partial_frac = a\/(a+b)\n frac(ibeg) = frac(ibeg) + (1.0 - 0.5 * partial_frac)\n 1 * frac_between_files * partial_frac\n frac(iend) = frac(iend) + ( 0.5 * partial_frac)\n 1 * frac_between_files * partial_frac\n\n if(interval_between_files .gt. max_radar_gap)then\n write(6,*)' Warning: Gap in radar files (min) >'\n 1 ,max_radar_gap\/60\n istatus = 0\n return\n endif\n\n endif\n\n if(i4time_file(ibeg) .lt. i4time_beg .and.\n 1 i4time_file(iend) .gt. i4time_end )then ! Brackets the Pd\n i4time_mid = i4time_beg + (i4time_end - i4time_beg) \/ 2\n frac_mid = float(i4time_mid - i4time_file(ibeg))\n 1 \/ float(i4time_file(iend) - i4time_file(ibeg))\n frac(ibeg) = 1.0 - frac_mid\n frac(iend) = frac_mid\n\n if(interval_between_files .gt. max_radar_gap)then\n write(6,*)' Warning: Gap in radar files (min) >'\n 1 ,max_radar_gap\/60\n istatus = 0\n return\n endif\n\n endif\n\n enddo ! i\n\n frac_sum = 0.\n do ifile = 1,i_nbr_files_ret\n if(frac(ifile) .gt. 0.)then\n call make_fnam_lp(i4time_file(ifile),asc_tim_9,istat_fnam)\n write(6,101)asc_tim_9,frac(ifile)\n 101 format(' FileTime, Frac = ',a9,2x,f8.5)\n frac_sum = frac_sum + frac(ifile)\n endif\n enddo\n\n if(abs(frac_sum - 1.0) .gt. 1e-5)then\n! Note: we can here potentially wait for more radar data in driver\n write(6,*)' Warning: Fractions do not add up to 1.0'\n 1 ,frac_sum\n istatus = 0\n endif\n\n if(i_nbr_files_ret .gt. 0)then\n if(i4time_file(1) .gt. i4time_beg)then\n write(6,*)\n 1 ' Radar files begin after start of accumulation window'\n frac_sum = -1.0 ! Turns off the wait loop for more radar\n endif\n endif\n\n999 if(istatus .ne. 1)then\n write(6,*)' Insufficient files within time window'\n return\n endif\n\n istatus = 1\n return\n end\n","avg_line_length":38.839869281,"max_line_length":82,"alphanum_fraction":0.471715047} {"size":9768,"ext":"f","lang":"FORTRAN","max_stars_count":4392.0,"content":"*> \\brief \\b CPBSTF\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download CPBSTF + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE CPBSTF( UPLO, N, KD, AB, LDAB, INFO )\n*\n* .. Scalar Arguments ..\n* CHARACTER UPLO\n* INTEGER INFO, KD, LDAB, N\n* ..\n* .. Array Arguments ..\n* COMPLEX AB( LDAB, * )\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> CPBSTF computes a split Cholesky factorization of a complex\n*> Hermitian positive definite band matrix A.\n*>\n*> This routine is designed to be used in conjunction with CHBGST.\n*>\n*> The factorization has the form A = S**H*S where S is a band matrix\n*> of the same bandwidth as A and the following structure:\n*>\n*> S = ( U )\n*> ( M L )\n*>\n*> where U is upper triangular of order m = (n+kd)\/2, and L is lower\n*> triangular of order n-m.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] UPLO\n*> \\verbatim\n*> UPLO is CHARACTER*1\n*> = 'U': Upper triangle of A is stored;\n*> = 'L': Lower triangle of A is stored.\n*> \\endverbatim\n*>\n*> \\param[in] N\n*> \\verbatim\n*> N is INTEGER\n*> The order of the matrix A. N >= 0.\n*> \\endverbatim\n*>\n*> \\param[in] KD\n*> \\verbatim\n*> KD is INTEGER\n*> The number of superdiagonals of the matrix A if UPLO = 'U',\n*> or the number of subdiagonals if UPLO = 'L'. KD >= 0.\n*> \\endverbatim\n*>\n*> \\param[in,out] AB\n*> \\verbatim\n*> AB is COMPLEX array, dimension (LDAB,N)\n*> On entry, the upper or lower triangle of the Hermitian band\n*> matrix A, stored in the first kd+1 rows of the array. The\n*> j-th column of A is stored in the j-th column of the array AB\n*> as follows:\n*> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;\n*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).\n*>\n*> On exit, if INFO = 0, the factor S from the split Cholesky\n*> factorization A = S**H*S. See Further Details.\n*> \\endverbatim\n*>\n*> \\param[in] LDAB\n*> \\verbatim\n*> LDAB is INTEGER\n*> The leading dimension of the array AB. LDAB >= KD+1.\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit\n*> < 0: if INFO = -i, the i-th argument had an illegal value\n*> > 0: if INFO = i, the factorization could not be completed,\n*> because the updated element a(i,i) was negative; the\n*> matrix A is not positive definite.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\date December 2016\n*\n*> \\ingroup complexOTHERcomputational\n*\n*> \\par Further Details:\n* =====================\n*>\n*> \\verbatim\n*>\n*> The band storage scheme is illustrated by the following example, when\n*> N = 7, KD = 2:\n*>\n*> S = ( s11 s12 s13 )\n*> ( s22 s23 s24 )\n*> ( s33 s34 )\n*> ( s44 )\n*> ( s53 s54 s55 )\n*> ( s64 s65 s66 )\n*> ( s75 s76 s77 )\n*>\n*> If UPLO = 'U', the array AB holds:\n*>\n*> on entry: on exit:\n*>\n*> * * a13 a24 a35 a46 a57 * * s13 s24 s53**H s64**H s75**H\n*> * a12 a23 a34 a45 a56 a67 * s12 s23 s34 s54**H s65**H s76**H\n*> a11 a22 a33 a44 a55 a66 a77 s11 s22 s33 s44 s55 s66 s77\n*>\n*> If UPLO = 'L', the array AB holds:\n*>\n*> on entry: on exit:\n*>\n*> a11 a22 a33 a44 a55 a66 a77 s11 s22 s33 s44 s55 s66 s77\n*> a21 a32 a43 a54 a65 a76 * s12**H s23**H s34**H s54 s65 s76 *\n*> a31 a42 a53 a64 a64 * * s13**H s24**H s53 s64 s75 * *\n*>\n*> Array elements marked * are not used by the routine; s12**H denotes\n*> conjg(s12); the diagonal elements of S are real.\n*> \\endverbatim\n*>\n* =====================================================================\n SUBROUTINE CPBSTF( UPLO, N, KD, AB, LDAB, INFO )\n*\n* -- LAPACK computational routine (version 3.7.0) --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* December 2016\n*\n* .. Scalar Arguments ..\n CHARACTER UPLO\n INTEGER INFO, KD, LDAB, N\n* ..\n* .. Array Arguments ..\n COMPLEX AB( LDAB, * )\n* ..\n*\n* =====================================================================\n*\n* .. Parameters ..\n REAL ONE, ZERO\n PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )\n* ..\n* .. Local Scalars ..\n LOGICAL UPPER\n INTEGER J, KLD, KM, M\n REAL AJJ\n* ..\n* .. External Functions ..\n LOGICAL LSAME\n EXTERNAL LSAME\n* ..\n* .. External Subroutines ..\n EXTERNAL CHER, CLACGV, CSSCAL, XERBLA\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC MAX, MIN, REAL, SQRT\n* ..\n* .. Executable Statements ..\n*\n* Test the input parameters.\n*\n INFO = 0\n UPPER = LSAME( UPLO, 'U' )\n IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN\n INFO = -1\n ELSE IF( N.LT.0 ) THEN\n INFO = -2\n ELSE IF( KD.LT.0 ) THEN\n INFO = -3\n ELSE IF( LDAB.LT.KD+1 ) THEN\n INFO = -5\n END IF\n IF( INFO.NE.0 ) THEN\n CALL XERBLA( 'CPBSTF', -INFO )\n RETURN\n END IF\n*\n* Quick return if possible\n*\n IF( N.EQ.0 )\n $ RETURN\n*\n KLD = MAX( 1, LDAB-1 )\n*\n* Set the splitting point m.\n*\n M = ( N+KD ) \/ 2\n*\n IF( UPPER ) THEN\n*\n* Factorize A(m+1:n,m+1:n) as L**H*L, and update A(1:m,1:m).\n*\n DO 10 J = N, M + 1, -1\n*\n* Compute s(j,j) and test for non-positive-definiteness.\n*\n AJJ = REAL( AB( KD+1, J ) )\n IF( AJJ.LE.ZERO ) THEN\n AB( KD+1, J ) = AJJ\n GO TO 50\n END IF\n AJJ = SQRT( AJJ )\n AB( KD+1, J ) = AJJ\n KM = MIN( J-1, KD )\n*\n* Compute elements j-km:j-1 of the j-th column and update the\n* the leading submatrix within the band.\n*\n CALL CSSCAL( KM, ONE \/ AJJ, AB( KD+1-KM, J ), 1 )\n CALL CHER( 'Upper', KM, -ONE, AB( KD+1-KM, J ), 1,\n $ AB( KD+1, J-KM ), KLD )\n 10 CONTINUE\n*\n* Factorize the updated submatrix A(1:m,1:m) as U**H*U.\n*\n DO 20 J = 1, M\n*\n* Compute s(j,j) and test for non-positive-definiteness.\n*\n AJJ = REAL( AB( KD+1, J ) )\n IF( AJJ.LE.ZERO ) THEN\n AB( KD+1, J ) = AJJ\n GO TO 50\n END IF\n AJJ = SQRT( AJJ )\n AB( KD+1, J ) = AJJ\n KM = MIN( KD, M-J )\n*\n* Compute elements j+1:j+km of the j-th row and update the\n* trailing submatrix within the band.\n*\n IF( KM.GT.0 ) THEN\n CALL CSSCAL( KM, ONE \/ AJJ, AB( KD, J+1 ), KLD )\n CALL CLACGV( KM, AB( KD, J+1 ), KLD )\n CALL CHER( 'Upper', KM, -ONE, AB( KD, J+1 ), KLD,\n $ AB( KD+1, J+1 ), KLD )\n CALL CLACGV( KM, AB( KD, J+1 ), KLD )\n END IF\n 20 CONTINUE\n ELSE\n*\n* Factorize A(m+1:n,m+1:n) as L**H*L, and update A(1:m,1:m).\n*\n DO 30 J = N, M + 1, -1\n*\n* Compute s(j,j) and test for non-positive-definiteness.\n*\n AJJ = REAL( AB( 1, J ) )\n IF( AJJ.LE.ZERO ) THEN\n AB( 1, J ) = AJJ\n GO TO 50\n END IF\n AJJ = SQRT( AJJ )\n AB( 1, J ) = AJJ\n KM = MIN( J-1, KD )\n*\n* Compute elements j-km:j-1 of the j-th row and update the\n* trailing submatrix within the band.\n*\n CALL CSSCAL( KM, ONE \/ AJJ, AB( KM+1, J-KM ), KLD )\n CALL CLACGV( KM, AB( KM+1, J-KM ), KLD )\n CALL CHER( 'Lower', KM, -ONE, AB( KM+1, J-KM ), KLD,\n $ AB( 1, J-KM ), KLD )\n CALL CLACGV( KM, AB( KM+1, J-KM ), KLD )\n 30 CONTINUE\n*\n* Factorize the updated submatrix A(1:m,1:m) as U**H*U.\n*\n DO 40 J = 1, M\n*\n* Compute s(j,j) and test for non-positive-definiteness.\n*\n AJJ = REAL( AB( 1, J ) )\n IF( AJJ.LE.ZERO ) THEN\n AB( 1, J ) = AJJ\n GO TO 50\n END IF\n AJJ = SQRT( AJJ )\n AB( 1, J ) = AJJ\n KM = MIN( KD, M-J )\n*\n* Compute elements j+1:j+km of the j-th column and update the\n* trailing submatrix within the band.\n*\n IF( KM.GT.0 ) THEN\n CALL CSSCAL( KM, ONE \/ AJJ, AB( 2, J ), 1 )\n CALL CHER( 'Lower', KM, -ONE, AB( 2, J ), 1,\n $ AB( 1, J+1 ), KLD )\n END IF\n 40 CONTINUE\n END IF\n RETURN\n*\n 50 CONTINUE\n INFO = J\n RETURN\n*\n* End of CPBSTF\n*\n END\n","avg_line_length":29.3333333333,"max_line_length":111,"alphanum_fraction":0.4730753481} {"size":6055,"ext":"f90","lang":"FORTRAN","max_stars_count":33.0,"content":"!*******************************************************************\n! *\n SUBROUTINE ONESCALAR(JA,JB,IA1,IA2,VSHELL)\n! *\n! The main program for evaluating the reduced matrix elements of *\n! a one particle operator for configurations in jj-coupling. *\n! *\n! Call(s) to: [LIB92]: CFP, FIXJ, GENSUM, ICHOP, IROW1, ISPAR, *\n! ITJPO, ITRIG, SETQNA, VIJOUT. *\n! [NJGRAF]: NJGRAF. *\n! *\n! Transform to fortran 90\/95 by G. Gaigalas December 2012 *\n! The last modification made by G. Gaigalas October 2017 *\n! *\n!*******************************************************************\n!\n!-----------------------------------------------\n! M o d u l e s\n!-----------------------------------------------\n USE vast_kind_param, ONLY: DOUBLE\n USE parameter_def, ONLY: NNNW\n USE CONS_C\n USE m_C\n USE orb_C, ONLY: NW, NAK\n USE dumx_C, ONLY: JLIS, JC1S, JC2S\n!-----------------------------------------------\n! I n t e r f a c e B l o c k s\n!-----------------------------------------------\n USE itrig_I\n USE ichkq1_I\n USE ichop_I\n USE ispar_I\n USE itjpo_I\n USE setqna_I\n USE onescalar1_I\n USE onescalar2_I\n IMPLICIT NONE\n!-----------------------------------------------\n! D u m m y A r g u m e n t s\n!-----------------------------------------------\n INTEGER, INTENT(IN) :: JA,JB\n INTEGER, INTENT(OUT) :: IA1,IA2\n REAL(DOUBLE), INTENT(OUT) :: VSHELL(NNNW)\n! DIMENSION VSHELL(NNNW)\n! DIMENSION IS(2),KS(2)\n!-----------------------------------------------\n! L o c a l V a r i a b l e s\n!-----------------------------------------------\n INTEGER :: KK,IOPAR,IJ,IDQ,JA1,JA2,NDQ,NS,ISH,I,II,I1,IM, &\n JW,KS1,KS2,NX,NPEELM\n INTEGER, DIMENSION(2) :: IS,KS\n REAL(DOUBLE) :: TCOEFF\n!-----------------------------------------------\n IA1 = 0\n KK = 1\n IOPAR = 1\n IF(ITRIG(ITJPO (JA),ITJPO (JB),KK).EQ.0)RETURN\n IF((IOPAR.NE.0).AND.(ISPAR(JA)*ISPAR(JB)*IOPAR.NE.1))RETURN\n IF(ICHKQ1(JA,JB).EQ.0)RETURN\n!\n CALL SETQNA (JA,JB)\n!\n DO IJ = 1,NW\n VSHELL(IJ) = ZERO\n END DO\n!\n! Analyse peel shell interactions\n IDQ = 0\n JA1 = 0\n JA2 = 0\n IF (NPEEL .NE. 0) THEN\n DO JW = 1,NPEEL\n IJ = JLIST(JW)\n NDQ = NQ1(IJ)-NQ2(IJ)\n IF (IABS (NDQ) .GT. 1) RETURN\n IF (NDQ .GT. 0) THEN\n JA1 = JW\n IDQ = IDQ+1\n ELSEIF (NDQ .LT. 0) THEN\n JA2 = JW\n IDQ = IDQ+1\n ENDIF\n END DO\n!\n IF (IDQ .GT. 2) RETURN\n!\n! Evaluate the array VSHELL\n!\n! Then there are two possibilities IDQ = 0 or IDQ = 2\n! if IDQ = 0, then loop over all shells by index ISH\n! if IDQ = 2, then one orbital fixed on each side\n NS = NPEEL\n ENDIF\n!\n IF (IDQ .EQ. 2) GOTO 19\n!\n! Loop over shells when IDQ = 0\n ISH = 0\n IF (NPEEL .EQ. 0) GOTO 9\n DO I = 1,NPEEL\n JLIS(I) = JLIST(I)\n END DO\n IF (NPEEL .EQ. 1) GOTO 9\n NPEELM = NPEEL-1\n DO I = 1,NPEELM\n JC1S(I) = JJC1(I)\n JC2S(I) = JJC2(I)\n END DO\n!\n! If ISH .GT. NW, then loop is over and return\n 9 ISH = ISH+1\n IF (ISH .GT. NW) RETURN\n IF (ICHOP (ISH,JA) .EQ. -1) GOTO 9\n IF (ICHOP (ISH,JA) .EQ. 0) GOTO 16\n!\n! Case one --- the ISH-th shell is in the core or in the peel and\n! closed for both sides\n I = 1\n IF (NPEEL.EQ.0) GOTO 15\n DO I = 1,NPEEL\n IJ = JLIST(I)\n IF (ISH .LT. IJ) GOTO 11\n END DO\n I = NPEEL+1\n GOTO 13\n 11 IM = NPEEL-I+1\n DO II = 1,IM\n JLIST(NPEEL+2-II) = JLIST(NPEEL+1-II)\n IF (NPEEL.EQ.II) GOTO 13\n JJC1(NPEEL+1-II) = JJC1(NPEEL-II)\n JJC2(NPEEL+1-II) = JJC2(NPEEL-II)\n END DO\n 13 CONTINUE\n IF (I .LT. 3) GOTO 14\n JJC1(I-1) = JJC1(I-2)\n JJC2(I-1) = JJC2(I-2)\n GOTO 15\n 14 I1 = JLIST(1)\n JJC1(1) = JJQ1(3,I1)\n JJC2(1) = JJQ2(3,I1)\n 15 JLIST(I) = ISH\n JA1 = I\n JA2 = I\n NS = NPEEL+1\n GOTO 19\n!\n! Case two --- the ISH-th shell is in the peel and open for either\n! side\n 16 NS = NPEEL\n DO JW = 1,NPEEL\n NX = ISH-JLIST(JW)\n IF (NX.EQ.0) GOTO 18\n END DO\n 18 JA1 = JW\n JA2 = JW\n!\n! Main computation\n!\n! JA1, JA2 are the indices of interacting shells in JLIST\n! IA1, IA2 are the indices of interacting shells in NW\n 19 IA1 = JLIST(JA1)\n IA2 = JLIST(JA2)\n KS1 = 2*IABS (NAK(IA1))\n KS2 = 2*IABS (NAK(IA2))\n!\n! Check triangular condition for the active shells\n IF (ITRIG (KS1,KS2,KK).EQ.1) GOTO 99\n IF (IDQ .EQ. 2) RETURN\n GOTO 100\n!\n! Set tables of quantum numbers of non-interacting spectator shells\n 99 CONTINUE\n\n IF (IDQ .EQ. 0) THEN\n!GG\n!GG Cia orginalioje programoje yra klaida\n!GG\n IF(JA .EQ. JB) THEN\n CALL ONESCALAR1(NS,JA,JB,JA1,JA2,TCOEFF)\n ELSE\n TCOEFF = ZERO\n END IF\n ELSE IF (IDQ .EQ. 2) THEN\n!\n! IDQ = 2 Case\n!\n! Permutation factor for IDQ = 2\n CALL ONESCALAR2(JA,JB,JA1,JA2,TCOEFF)\n VSHELL(1) = TCOEFF\n RETURN\n END IF\n!\n! End of loop over parent states\n!\n!\n! IDQ = 0 CASE\n VSHELL(ISH) = TCOEFF\n!\n! Loop over all shells when IDQ = 0\n100 CONTINUE\n IF (NPEEL .EQ. 0) GOTO 9\n DO I = 1,NPEEL\n JLIST(I) = JLIS(I)\n END DO\n IF (NPEEL .EQ. 1) GOTO 9\n NPEELM = NPEEL-1\n DO I = 1,NPEELM\n JJC1(I) = JC1S(I)\n JJC2(I) = JC2S(I)\n END DO\n GOTO 9\n RETURN\n END SUBROUTINE ONESCALAR\n","avg_line_length":28.2943925234,"max_line_length":69,"alphanum_fraction":0.4432700248} {"size":6905,"ext":"f","lang":"FORTRAN","max_stars_count":210.0,"content":" SUBROUTINE DLOCALMN(X,NI,NJ,XMSG,LWRAP,XI,YJ,NINJ,LOCMIN,\n + DELTA,NMIN,IER)\n DOUBLE PRECISION XVAL\n\nC input\n INTEGER LWRAP,NI,NJ,NINJ\nC input\n INTEGER XI(NINJ),YJ(NINJ)\nC input\n DOUBLE PRECISION X(NI,NJ),XMSG,DELTA\nC output\n INTEGER NMIN,IER\nC output\n DOUBLE PRECISION LOCMIN(NINJ)\nc***********************************************************************\nc\nc this routine looks at 9 points\nc\nc where the grid is:\nc\nc 1-------------8---------------7\nc | | |\nc | | |\nc | | |\nc | | |\nc 2-------------0---------------6\nc | | |\nc | | |\nc | | |\nc | | |\nc 3-------------4---------------5\nc\nc arguments :\nc .\nc . x - 2-d input\/output array\nc . ni - dimension size [\"x-axis\": eg longitude]\nc . nj - dimension size [\"y-axis\": eg latitude ]\nc . xmsg - value of missing points\nc . lwrap - flag to include wraparound points\nc . if lwrap = 1 , if data are cyclic in x\nc . if lwrap = 0 , data are not cyclic\nc . xi - x-axis coordinates [eg, longitudes]\nc . The fortran subscripts have been adjusted for NCL\nc . yj - y-axis coordinates [eg, latitudes ]\nc . The fortran subscripts have been adjusted for NCL\nc . ninj - max number of points (ni*nj is overkill but safe)\nc . locmin - 1D array dimensioned (ninj)\nc . delta - surrounding points must be different from the\nc . central value to be considered a local minimum\nc . Normally: delta = 0.0\nc . nmin - actual number of local minima detected\nc .\nc notes:\nc\nc 1) if a point or any of its neighbors is missing, check is\nc not implemented\nc 2) this routine does not check the edges, just the interior\nc except when \"lwrap\" is true.\nc 3) array has to have at least 3 points in each direction\nc\nc usage:\nc program main\nc implicit none\nc integer lwrap, ni, nj, ninj\nc parameter (ni=128, nj=64, ninj=ni*nj)\nc real z(ni,nj), zmsg, locmin(ninj)\nc integer xi(ni), yj(nj)\nc integer ier, n, m, nmin\nc\nc read () z\nc ier = 0\nc zmsg = -999.\nc lwrap = 1\nc delta = 0.0\nc call localmin (z,ni,nj,zmsg,lwrap,xi,yj\nc * ,ninj,locmin,delta,nmin,ier)\nc\nc if (nmin.gt.0) then\nc do n=1, nmin\nc write (*,\"(2i4,f10.2)\") xi(n),jy(n),locmin(n)\nc end do\nc else\nc write (*,\"('sub localmin: no local min found)\")\nc end if\nc end\nc***********************************************************************\n\nc determine if size of array is sufficient\n\n IER = 0\n IF (NI.LT.3 .OR. NJ.LT.3) THEN\n IER = 1\n WRITE (*,FMT='(\/,'' sub localmn: error'',2i5)') NI,NJ\n RETURN\n END IF\n\nc initialize to missing and zero\n\n NMIN = 0\n DO N = 1,NINJ\n LOCMIN(N) = XMSG\n XI(N) = -999\n YJ(N) = -999\n END DO\n\nc are endpoints to be included?\n\n IF (LWRAP.EQ.1) THEN\n NIB = 1\n NIE = NI\n ELSE\n NIB = 2\n NIE = NI - 1\n END IF\n NJB = 2\n NJE = NJ - 1\n\nc main loop\n\n DO J = NJB,NJE\n DO I = NIB,NIE\n JM1 = J - 1\n JP1 = J + 1\n IM1 = I - 1\n IP1 = I + 1\n IF (IM1.LT.1) IM1 = NI\n IF (IP1.GT.NI) IP1 = 1\n\n IF (X(I,J).NE.XMSG .AND. X(IM1,JP1).NE.XMSG .AND.\n + X(IM1,J).NE.XMSG .AND. X(IM1,JM1).NE.XMSG .AND.\n + X(I,JM1).NE.XMSG .AND. X(IP1,JM1).NE.XMSG .AND.\n + X(IP1,J).NE.XMSG .AND. X(IP1,JP1).NE.XMSG .AND.\n + X(I,JP1).NE.XMSG) THEN\n\n XVAL = X(I,J) + DELTA\n\n IF (X(IM1,JP1).GT.XVAL .AND. X(IM1,J).GT.XVAL .AND.\n + X(IM1,JM1).GT.XVAL .AND. X(I,JM1).GT.XVAL .AND.\n + X(IP1,JM1).GT.XVAL .AND. X(IP1,J).GT.XVAL .AND.\n + X(IP1,JP1).GT.XVAL .AND. X(I,JP1).GT.X(I,J)) THEN\n NMIN = NMIN + 1\nc subtract 1 for NCL subscripts\n XI(NMIN) = I - 1\n YJ(NMIN) = J - 1\n LOCMIN(NMIN) = X(I,J)\n END IF\n END IF\n END DO\n END DO\n\n RETURN\n END\nc ----------------------------------------------------------\n SUBROUTINE DLOCALMX(X,NI,NJ,XMSG,LWRAP,XI,YJ,NINJ,LOCMAX,\n + DELTA,NMAX,IER)\n DOUBLE PRECISION XVAL\n\nC input\n INTEGER LWRAP,NI,NJ,NINJ\nC input\n INTEGER XI(NINJ),YJ(NINJ)\nC input\n DOUBLE PRECISION X(NI,NJ),XMSG,DELTA\nC output\n INTEGER NMAX,IER\nC output\n DOUBLE PRECISION LOCMAX(NINJ)\nc***********************************************************************\nc see documentation for localmn\nc***********************************************************************\n\nc determine if size of array is sufficient\n\n IER = 0\n IF (NI.LT.3 .OR. NJ.LT.3) THEN\n IER = 1\n WRITE (*,FMT='(\/,'' sub localmx: error'',2i5)') NI,NJ\n RETURN\n END IF\n\nc initialize to missing and zero\n\n NMAX = 0\n DO N = 1,NINJ\n LOCMAX(N) = XMSG\n XI(N) = -999\n YJ(N) = -999\n END DO\n\n\nc are endpoints to be included?\n\n IF (LWRAP.EQ.1) THEN\n NIB = 1\n NIE = NI\n ELSE\n NIB = 2\n NIE = NI - 1\n END IF\n NJB = 2\n NJE = NJ - 1\n\nc main loop\n\n DO J = NJB,NJE\n DO I = NIB,NIE\n JM1 = J - 1\n JP1 = J + 1\n IM1 = I - 1\n IP1 = I + 1\n IF (IM1.LT.1) IM1 = NI\n IF (IP1.GT.NI) IP1 = 1\n\n IF (X(I,J).NE.XMSG .AND. X(IM1,JP1).NE.XMSG .AND.\n + X(IM1,J).NE.XMSG .AND. X(IM1,JM1).NE.XMSG .AND.\n + X(I,JM1).NE.XMSG .AND. X(IP1,JM1).NE.XMSG .AND.\n + X(IP1,J).NE.XMSG .AND. X(IP1,JP1).NE.XMSG .AND.\n + X(I,JP1).NE.XMSG) THEN\n\n XVAL = X(I,J) - DELTA\n\n IF (X(IM1,JP1).LT.XVAL .AND. X(IM1,J).LT.XVAL .AND.\n + X(IM1,JM1).LT.XVAL .AND. X(I,JM1).LT.XVAL .AND.\n + X(IP1,JM1).LT.XVAL .AND. X(IP1,J).LT.XVAL .AND.\n + X(IP1,JP1).LT.XVAL .AND. X(I,JP1).LT.X(I,J)) THEN\n NMAX = NMAX + 1\nc subtract 1 for NCL subscripts\n XI(NMAX) = I - 1\n YJ(NMAX) = J - 1\n LOCMAX(NMAX) = X(I,J)\n END IF\n END IF\n END DO\n END DO\n\n RETURN\n END\n","avg_line_length":29.012605042,"max_line_length":72,"alphanum_fraction":0.4299782766} {"size":979,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"mult(0,0,0).\nmult(0,1,0).\nmult(0,2,0).\nmult(0,3,0).\nmult(0,4,0).\nmult(0,5,0).\nmult(0,6,0).\nmult(0,7,0).\nmult(0,8,0).\nmult(0,9,0).\nmult(0,10,0).\nmult(1,1,1).\nmult(1,2,2).\nmult(1,3,3).\nmult(1,4,4).\nmult(1,5,5).\nmult(1,6,6).\nmult(1,7,7).\nmult(1,8,8).\nmult(1,9,9).\nmult(1,10,10).\nmult(2,2,4).\nmult(2,3,6).\nmult(2,4,8).\nmult(2,5,10).\nmult(2,6,12).\nmult(2,7,14).\nmult(2,8,16).\nmult(2,9,18).\nmult(2,10,20).\nmult(3,3,9).\nmult(3,4,12).\nmult(3,5,15).\nmult(3,6,18).\n\n% mult(0,0,0).\n% mult(1,0,0).\n% mult(2,0,0).\n% mult(3,0,0).\n% mult(4,0,0).\n% mult(5,0,0).\n% mult(6,0,0).\n% mult(7,0,0).\n% mult(8,0,0).\n% mult(9,0,0).\n% mult(10,0,0).\n% mult(1,1,1).\n% mult(2,1,2).\n% mult(3,1,3).\n% mult(4,1,4).\n% mult(5,1,5).\n% mult(6,1,6).\n% mult(7,1,7).\n% mult(8,1,8).\n% mult(9,1,9).\n% mult(10,1,10).\n% mult(2,2,4).\n% mult(3,2,6).\n% mult(4,2,8).\n% mult(5,2,10).\n% mult(6,2,12).\n% mult(7,2,14).\n% mult(8,2,16).\n% mult(9,2,18).\n% mult(10,2,20).\n% mult(3,3,9).\n% mult(4,3,12).\n% mult(5,3,15).\n% mult(6,3,18).\n","avg_line_length":13.9857142857,"max_line_length":16,"alphanum_fraction":0.5127681307} {"size":20115,"ext":"f","lang":"FORTRAN","max_stars_count":199.0,"content":"*> \\brief \\b CCHKPB\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at \n* http:\/\/www.netlib.org\/lapack\/explore-html\/ \n*\n* Definition:\n* ===========\n*\n* SUBROUTINE CCHKPB( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,\n* THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X,\n* XACT, WORK, RWORK, NOUT )\n* \n* .. Scalar Arguments ..\n* LOGICAL TSTERR\n* INTEGER NMAX, NN, NNB, NNS, NOUT\n* REAL THRESH\n* ..\n* .. Array Arguments ..\n* LOGICAL DOTYPE( * )\n* INTEGER NBVAL( * ), NSVAL( * ), NVAL( * )\n* REAL RWORK( * )\n* COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),\n* $ WORK( * ), X( * ), XACT( * )\n* ..\n* \n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> CCHKPB tests CPBTRF, -TRS, -RFS, and -CON.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] DOTYPE\n*> \\verbatim\n*> DOTYPE is LOGICAL array, dimension (NTYPES)\n*> The matrix types to be used for testing. Matrices of type j\n*> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =\n*> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.\n*> \\endverbatim\n*>\n*> \\param[in] NN\n*> \\verbatim\n*> NN is INTEGER\n*> The number of values of N contained in the vector NVAL.\n*> \\endverbatim\n*>\n*> \\param[in] NVAL\n*> \\verbatim\n*> NVAL is INTEGER array, dimension (NN)\n*> The values of the matrix dimension N.\n*> \\endverbatim\n*>\n*> \\param[in] NNB\n*> \\verbatim\n*> NNB is INTEGER\n*> The number of values of NB contained in the vector NBVAL.\n*> \\endverbatim\n*>\n*> \\param[in] NBVAL\n*> \\verbatim\n*> NBVAL is INTEGER array, dimension (NBVAL)\n*> The values of the blocksize NB.\n*> \\endverbatim\n*>\n*> \\param[in] NNS\n*> \\verbatim\n*> NNS is INTEGER\n*> The number of values of NRHS contained in the vector NSVAL.\n*> \\endverbatim\n*>\n*> \\param[in] NSVAL\n*> \\verbatim\n*> NSVAL is INTEGER array, dimension (NNS)\n*> The values of the number of right hand sides NRHS.\n*> \\endverbatim\n*>\n*> \\param[in] THRESH\n*> \\verbatim\n*> THRESH is REAL\n*> The threshold value for the test ratios. A result is\n*> included in the output file if RESULT >= THRESH. To have\n*> every test ratio printed, use THRESH = 0.\n*> \\endverbatim\n*>\n*> \\param[in] TSTERR\n*> \\verbatim\n*> TSTERR is LOGICAL\n*> Flag that indicates whether error exits are to be tested.\n*> \\endverbatim\n*>\n*> \\param[in] NMAX\n*> \\verbatim\n*> NMAX is INTEGER\n*> The maximum value permitted for N, used in dimensioning the\n*> work arrays.\n*> \\endverbatim\n*>\n*> \\param[out] A\n*> \\verbatim\n*> A is REAL array, dimension (NMAX*NMAX)\n*> \\endverbatim\n*>\n*> \\param[out] AFAC\n*> \\verbatim\n*> AFAC is REAL array, dimension (NMAX*NMAX)\n*> \\endverbatim\n*>\n*> \\param[out] AINV\n*> \\verbatim\n*> AINV is REAL array, dimension (NMAX*NMAX)\n*> \\endverbatim\n*>\n*> \\param[out] B\n*> \\verbatim\n*> B is REAL array, dimension (NMAX*NSMAX)\n*> where NSMAX is the largest entry in NSVAL.\n*> \\endverbatim\n*>\n*> \\param[out] X\n*> \\verbatim\n*> X is REAL array, dimension (NMAX*NSMAX)\n*> \\endverbatim\n*>\n*> \\param[out] XACT\n*> \\verbatim\n*> XACT is REAL array, dimension (NMAX*NSMAX)\n*> \\endverbatim\n*>\n*> \\param[out] WORK\n*> \\verbatim\n*> WORK is REAL array, dimension\n*> (NMAX*max(3,NSMAX))\n*> \\endverbatim\n*>\n*> \\param[out] RWORK\n*> \\verbatim\n*> RWORK is REAL array, dimension\n*> (max(NMAX,2*NSMAX))\n*> \\endverbatim\n*>\n*> \\param[in] NOUT\n*> \\verbatim\n*> NOUT is INTEGER\n*> The unit number for output.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee \n*> \\author Univ. of California Berkeley \n*> \\author Univ. of Colorado Denver \n*> \\author NAG Ltd. \n*\n*> \\date November 2011\n*\n*> \\ingroup complex_lin\n*\n* =====================================================================\n SUBROUTINE CCHKPB( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,\n $ THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X,\n $ XACT, WORK, RWORK, NOUT )\n*\n* -- LAPACK test routine (version 3.4.0) --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* November 2011\n*\n* .. Scalar Arguments ..\n LOGICAL TSTERR\n INTEGER NMAX, NN, NNB, NNS, NOUT\n REAL THRESH\n* ..\n* .. Array Arguments ..\n LOGICAL DOTYPE( * )\n INTEGER NBVAL( * ), NSVAL( * ), NVAL( * )\n REAL RWORK( * )\n COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),\n $ WORK( * ), X( * ), XACT( * )\n* ..\n*\n* =====================================================================\n*\n* .. Parameters ..\n REAL ONE, ZERO\n PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )\n INTEGER NTYPES, NTESTS\n PARAMETER ( NTYPES = 8, NTESTS = 7 )\n INTEGER NBW\n PARAMETER ( NBW = 4 )\n* ..\n* .. Local Scalars ..\n LOGICAL ZEROT\n CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE\n CHARACTER*3 PATH\n INTEGER I, I1, I2, IKD, IMAT, IN, INB, INFO, IOFF,\n $ IRHS, IUPLO, IW, IZERO, K, KD, KL, KOFF, KU,\n $ LDA, LDAB, MODE, N, NB, NERRS, NFAIL, NIMAT,\n $ NKD, NRHS, NRUN\n REAL AINVNM, ANORM, CNDNUM, RCOND, RCONDC\n* ..\n* .. Local Arrays ..\n INTEGER ISEED( 4 ), ISEEDY( 4 ), KDVAL( NBW )\n REAL RESULT( NTESTS )\n* ..\n* .. External Functions ..\n REAL CLANGE, CLANHB, SGET06\n EXTERNAL CLANGE, CLANHB, SGET06\n* ..\n* .. External Subroutines ..\n EXTERNAL ALAERH, ALAHD, ALASUM, CCOPY, CERRPO, CGET04,\n $ CLACPY, CLAIPD, CLARHS, CLASET, CLATB4, CLATMS,\n $ CPBCON, CPBRFS, CPBT01, CPBT02, CPBT05, CPBTRF,\n $ CPBTRS, CSWAP, XLAENV\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC CMPLX, MAX, MIN\n* ..\n* .. Scalars in Common ..\n LOGICAL LERR, OK\n CHARACTER*32 SRNAMT\n INTEGER INFOT, NUNIT\n* ..\n* .. Common blocks ..\n COMMON \/ INFOC \/ INFOT, NUNIT, OK, LERR\n COMMON \/ SRNAMC \/ SRNAMT\n* ..\n* .. Data statements ..\n DATA ISEEDY \/ 1988, 1989, 1990, 1991 \/\n* ..\n* .. Executable Statements ..\n*\n* Initialize constants and the random number seed.\n*\n PATH( 1: 1 ) = 'Complex precision'\n PATH( 2: 3 ) = 'PB'\n NRUN = 0\n NFAIL = 0\n NERRS = 0\n DO 10 I = 1, 4\n ISEED( I ) = ISEEDY( I )\n 10 CONTINUE\n*\n* Test the error exits\n*\n IF( TSTERR )\n $ CALL CERRPO( PATH, NOUT )\n INFOT = 0\n KDVAL( 1 ) = 0\n*\n* Do for each value of N in NVAL\n*\n DO 90 IN = 1, NN\n N = NVAL( IN )\n LDA = MAX( N, 1 )\n XTYPE = 'N'\n*\n* Set limits on the number of loop iterations.\n*\n NKD = MAX( 1, MIN( N, 4 ) )\n NIMAT = NTYPES\n IF( N.EQ.0 )\n $ NIMAT = 1\n*\n KDVAL( 2 ) = N + ( N+1 ) \/ 4\n KDVAL( 3 ) = ( 3*N-1 ) \/ 4\n KDVAL( 4 ) = ( N+1 ) \/ 4\n*\n DO 80 IKD = 1, NKD\n*\n* Do for KD = 0, (5*N+1)\/4, (3N-1)\/4, and (N+1)\/4. This order\n* makes it easier to skip redundant values for small values\n* of N.\n*\n KD = KDVAL( IKD )\n LDAB = KD + 1\n*\n* Do first for UPLO = 'U', then for UPLO = 'L'\n*\n DO 70 IUPLO = 1, 2\n KOFF = 1\n IF( IUPLO.EQ.1 ) THEN\n UPLO = 'U'\n KOFF = MAX( 1, KD+2-N )\n PACKIT = 'Q'\n ELSE\n UPLO = 'L'\n PACKIT = 'B'\n END IF\n*\n DO 60 IMAT = 1, NIMAT\n*\n* Do the tests only if DOTYPE( IMAT ) is true.\n*\n IF( .NOT.DOTYPE( IMAT ) )\n $ GO TO 60\n*\n* Skip types 2, 3, or 4 if the matrix size is too small.\n*\n ZEROT = IMAT.GE.2 .AND. IMAT.LE.4\n IF( ZEROT .AND. N.LT.IMAT-1 )\n $ GO TO 60\n*\n IF( .NOT.ZEROT .OR. .NOT.DOTYPE( 1 ) ) THEN\n*\n* Set up parameters with CLATB4 and generate a test\n* matrix with CLATMS.\n*\n CALL CLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM,\n $ MODE, CNDNUM, DIST )\n*\n SRNAMT = 'CLATMS'\n CALL CLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,\n $ CNDNUM, ANORM, KD, KD, PACKIT,\n $ A( KOFF ), LDAB, WORK, INFO )\n*\n* Check error code from CLATMS.\n*\n IF( INFO.NE.0 ) THEN\n CALL ALAERH( PATH, 'CLATMS', INFO, 0, UPLO, N,\n $ N, KD, KD, -1, IMAT, NFAIL, NERRS,\n $ NOUT )\n GO TO 60\n END IF\n ELSE IF( IZERO.GT.0 ) THEN\n*\n* Use the same matrix for types 3 and 4 as for type\n* 2 by copying back the zeroed out column,\n*\n IW = 2*LDA + 1\n IF( IUPLO.EQ.1 ) THEN\n IOFF = ( IZERO-1 )*LDAB + KD + 1\n CALL CCOPY( IZERO-I1, WORK( IW ), 1,\n $ A( IOFF-IZERO+I1 ), 1 )\n IW = IW + IZERO - I1\n CALL CCOPY( I2-IZERO+1, WORK( IW ), 1,\n $ A( IOFF ), MAX( LDAB-1, 1 ) )\n ELSE\n IOFF = ( I1-1 )*LDAB + 1\n CALL CCOPY( IZERO-I1, WORK( IW ), 1,\n $ A( IOFF+IZERO-I1 ),\n $ MAX( LDAB-1, 1 ) )\n IOFF = ( IZERO-1 )*LDAB + 1\n IW = IW + IZERO - I1\n CALL CCOPY( I2-IZERO+1, WORK( IW ), 1,\n $ A( IOFF ), 1 )\n END IF\n END IF\n*\n* For types 2-4, zero one row and column of the matrix\n* to test that INFO is returned correctly.\n*\n IZERO = 0\n IF( ZEROT ) THEN\n IF( IMAT.EQ.2 ) THEN\n IZERO = 1\n ELSE IF( IMAT.EQ.3 ) THEN\n IZERO = N\n ELSE\n IZERO = N \/ 2 + 1\n END IF\n*\n* Save the zeroed out row and column in WORK(*,3)\n*\n IW = 2*LDA\n DO 20 I = 1, MIN( 2*KD+1, N )\n WORK( IW+I ) = ZERO\n 20 CONTINUE\n IW = IW + 1\n I1 = MAX( IZERO-KD, 1 )\n I2 = MIN( IZERO+KD, N )\n*\n IF( IUPLO.EQ.1 ) THEN\n IOFF = ( IZERO-1 )*LDAB + KD + 1\n CALL CSWAP( IZERO-I1, A( IOFF-IZERO+I1 ), 1,\n $ WORK( IW ), 1 )\n IW = IW + IZERO - I1\n CALL CSWAP( I2-IZERO+1, A( IOFF ),\n $ MAX( LDAB-1, 1 ), WORK( IW ), 1 )\n ELSE\n IOFF = ( I1-1 )*LDAB + 1\n CALL CSWAP( IZERO-I1, A( IOFF+IZERO-I1 ),\n $ MAX( LDAB-1, 1 ), WORK( IW ), 1 )\n IOFF = ( IZERO-1 )*LDAB + 1\n IW = IW + IZERO - I1\n CALL CSWAP( I2-IZERO+1, A( IOFF ), 1,\n $ WORK( IW ), 1 )\n END IF\n END IF\n*\n* Set the imaginary part of the diagonals.\n*\n IF( IUPLO.EQ.1 ) THEN\n CALL CLAIPD( N, A( KD+1 ), LDAB, 0 )\n ELSE\n CALL CLAIPD( N, A( 1 ), LDAB, 0 )\n END IF\n*\n* Do for each value of NB in NBVAL\n*\n DO 50 INB = 1, NNB\n NB = NBVAL( INB )\n CALL XLAENV( 1, NB )\n*\n* Compute the L*L' or U'*U factorization of the band\n* matrix.\n*\n CALL CLACPY( 'Full', KD+1, N, A, LDAB, AFAC, LDAB )\n SRNAMT = 'CPBTRF'\n CALL CPBTRF( UPLO, N, KD, AFAC, LDAB, INFO )\n*\n* Check error code from CPBTRF.\n*\n IF( INFO.NE.IZERO ) THEN\n CALL ALAERH( PATH, 'CPBTRF', INFO, IZERO, UPLO,\n $ N, N, KD, KD, NB, IMAT, NFAIL,\n $ NERRS, NOUT )\n GO TO 50\n END IF\n*\n* Skip the tests if INFO is not 0.\n*\n IF( INFO.NE.0 )\n $ GO TO 50\n*\n*+ TEST 1\n* Reconstruct matrix from factors and compute\n* residual.\n*\n CALL CLACPY( 'Full', KD+1, N, AFAC, LDAB, AINV,\n $ LDAB )\n CALL CPBT01( UPLO, N, KD, A, LDAB, AINV, LDAB,\n $ RWORK, RESULT( 1 ) )\n*\n* Print the test ratio if it is .GE. THRESH.\n*\n IF( RESULT( 1 ).GE.THRESH ) THEN\n IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )\n $ CALL ALAHD( NOUT, PATH )\n WRITE( NOUT, FMT = 9999 )UPLO, N, KD, NB, IMAT,\n $ 1, RESULT( 1 )\n NFAIL = NFAIL + 1\n END IF\n NRUN = NRUN + 1\n*\n* Only do other tests if this is the first blocksize.\n*\n IF( INB.GT.1 )\n $ GO TO 50\n*\n* Form the inverse of A so we can get a good estimate\n* of RCONDC = 1\/(norm(A) * norm(inv(A))).\n*\n CALL CLASET( 'Full', N, N, CMPLX( ZERO ),\n $ CMPLX( ONE ), AINV, LDA )\n SRNAMT = 'CPBTRS'\n CALL CPBTRS( UPLO, N, KD, N, AFAC, LDAB, AINV, LDA,\n $ INFO )\n*\n* Compute RCONDC = 1\/(norm(A) * norm(inv(A))).\n*\n ANORM = CLANHB( '1', UPLO, N, KD, A, LDAB, RWORK )\n AINVNM = CLANGE( '1', N, N, AINV, LDA, RWORK )\n IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN\n RCONDC = ONE\n ELSE\n RCONDC = ( ONE \/ ANORM ) \/ AINVNM\n END IF\n*\n DO 40 IRHS = 1, NNS\n NRHS = NSVAL( IRHS )\n*\n*+ TEST 2\n* Solve and compute residual for A * X = B.\n*\n SRNAMT = 'CLARHS'\n CALL CLARHS( PATH, XTYPE, UPLO, ' ', N, N, KD,\n $ KD, NRHS, A, LDAB, XACT, LDA, B,\n $ LDA, ISEED, INFO )\n CALL CLACPY( 'Full', N, NRHS, B, LDA, X, LDA )\n*\n SRNAMT = 'CPBTRS'\n CALL CPBTRS( UPLO, N, KD, NRHS, AFAC, LDAB, X,\n $ LDA, INFO )\n*\n* Check error code from CPBTRS.\n*\n IF( INFO.NE.0 )\n $ CALL ALAERH( PATH, 'CPBTRS', INFO, 0, UPLO,\n $ N, N, KD, KD, NRHS, IMAT, NFAIL,\n $ NERRS, NOUT )\n*\n CALL CLACPY( 'Full', N, NRHS, B, LDA, WORK,\n $ LDA )\n CALL CPBT02( UPLO, N, KD, NRHS, A, LDAB, X, LDA,\n $ WORK, LDA, RWORK, RESULT( 2 ) )\n*\n*+ TEST 3\n* Check solution from generated exact solution.\n*\n CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,\n $ RESULT( 3 ) )\n*\n*+ TESTS 4, 5, and 6\n* Use iterative refinement to improve the solution.\n*\n SRNAMT = 'CPBRFS'\n CALL CPBRFS( UPLO, N, KD, NRHS, A, LDAB, AFAC,\n $ LDAB, B, LDA, X, LDA, RWORK,\n $ RWORK( NRHS+1 ), WORK,\n $ RWORK( 2*NRHS+1 ), INFO )\n*\n* Check error code from CPBRFS.\n*\n IF( INFO.NE.0 )\n $ CALL ALAERH( PATH, 'CPBRFS', INFO, 0, UPLO,\n $ N, N, KD, KD, NRHS, IMAT, NFAIL,\n $ NERRS, NOUT )\n*\n CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,\n $ RESULT( 4 ) )\n CALL CPBT05( UPLO, N, KD, NRHS, A, LDAB, B, LDA,\n $ X, LDA, XACT, LDA, RWORK,\n $ RWORK( NRHS+1 ), RESULT( 5 ) )\n*\n* Print information about the tests that did not\n* pass the threshold.\n*\n DO 30 K = 2, 6\n IF( RESULT( K ).GE.THRESH ) THEN\n IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )\n $ CALL ALAHD( NOUT, PATH )\n WRITE( NOUT, FMT = 9998 )UPLO, N, KD,\n $ NRHS, IMAT, K, RESULT( K )\n NFAIL = NFAIL + 1\n END IF\n 30 CONTINUE\n NRUN = NRUN + 5\n 40 CONTINUE\n*\n*+ TEST 7\n* Get an estimate of RCOND = 1\/CNDNUM.\n*\n SRNAMT = 'CPBCON'\n CALL CPBCON( UPLO, N, KD, AFAC, LDAB, ANORM, RCOND,\n $ WORK, RWORK, INFO )\n*\n* Check error code from CPBCON.\n*\n IF( INFO.NE.0 )\n $ CALL ALAERH( PATH, 'CPBCON', INFO, 0, UPLO, N,\n $ N, KD, KD, -1, IMAT, NFAIL, NERRS,\n $ NOUT )\n*\n RESULT( 7 ) = SGET06( RCOND, RCONDC )\n*\n* Print the test ratio if it is .GE. THRESH.\n*\n IF( RESULT( 7 ).GE.THRESH ) THEN\n IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )\n $ CALL ALAHD( NOUT, PATH )\n WRITE( NOUT, FMT = 9997 )UPLO, N, KD, IMAT, 7,\n $ RESULT( 7 )\n NFAIL = NFAIL + 1\n END IF\n NRUN = NRUN + 1\n 50 CONTINUE\n 60 CONTINUE\n 70 CONTINUE\n 80 CONTINUE\n 90 CONTINUE\n*\n* Print a summary of the results.\n*\n CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )\n*\n 9999 FORMAT( ' UPLO=''', A1, ''', N=', I5, ', KD=', I5, ', NB=', I4,\n $ ', type ', I2, ', test ', I2, ', ratio= ', G12.5 )\n 9998 FORMAT( ' UPLO=''', A1, ''', N=', I5, ', KD=', I5, ', NRHS=', I3,\n $ ', type ', I2, ', test(', I2, ') = ', G12.5 )\n 9997 FORMAT( ' UPLO=''', A1, ''', N=', I5, ', KD=', I5, ',', 10X,\n $ ' type ', I2, ', test(', I2, ') = ', G12.5 )\n RETURN\n*\n* End of CCHKPB\n*\n END\n","avg_line_length":33.8067226891,"max_line_length":76,"alphanum_fraction":0.3923440219} {"size":38673,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"!\n! CalculiX - A 3-dimensional finite element program\n! Copyright (C) 1998-2015 Guido Dhondt\n!\n! This program is free software; you can redistribute it and\/or\n! modify it under the terms of the GNU General Public License as\n! published by the Free Software Foundation(version 2);\n! \n!\n! This program is distributed in the hope that it will be useful,\n! but WITHOUT ANY WARRANTY; without even the implied warranty of \n! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n! GNU General Public License for more details.\n!\n! You should have received a copy of the GNU General Public License\n! along with this program; if not, write to the Free Software\n! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n!\n subroutine umat_aniso_creep(amat,iel,iint,kode,elconloc,emec,\n & emec0,beta,xokl,voj,xkl,vj,ithermal,t1l,dtime,time,ttime,\n & icmd,ielas,mi,nstate_,xstateini,xstate,stre,stiff,iorien,\n & pgauss,orab,nmethod,pnewdt)\n!\n! calculates stiffness and stresses for a user defined material\n! law\n!\n! icmd=3: calculates stress at mechanical strain\n! else: calculates stress at mechanical strain and the stiffness\n! matrix\n!\n! INPUT:\n!\n! amat material name\n! iel element number\n! iint integration point number\n!\n! kode material type (-100-#of constants entered\n! under *USER MATERIAL): can be used for materials\n! with varying number of constants\n!\n! elconloc(21) user defined constants defined by the keyword\n! card *USER MATERIAL (max. 21, actual # =\n! -kode-100), interpolated for the\n! actual temperature t1l\n!\n! emec(6) Lagrange mechanical strain tensor (component order:\n! 11,22,33,12,13,23) at the end of the increment\n! (thermal strains are subtracted)\n! emec0(6) Lagrange mechanical strain tensor at the start of the\n! increment (thermal strains are subtracted)\n! beta(6) residual stress tensor (the stress entered under\n! the keyword *INITIAL CONDITIONS,TYPE=STRESS)\n!\n! xokl(3,3) deformation gradient at the start of the increment\n! voj Jacobian at the start of the increment\n! xkl(3,3) deformation gradient at the end of the increment\n! vj Jacobian at the end of the increment\n!\n! ithermal 0: no thermal effects are taken into account: for\n! creep this does not make sense.\n! >0: thermal effects are taken into account (triggered\n! by the keyword *INITIAL CONDITIONS,TYPE=TEMPERATURE)\n! t1l temperature at the end of the increment\n! dtime time length of the increment\n! time step time at the end of the current increment\n! ttime total time at the start of the current step\n!\n! icmd not equal to 3: calculate stress and stiffness\n! 3: calculate only stress\n! ielas 0: no elastic iteration: irreversible effects\n! are allowed\n! 1: elastic iteration, i.e. no irreversible\n! deformation allowed\n!\n! mi(1) max. # of integration points per element in the\n! model\n! nstate_ max. # of state variables in the model\n!\n! xstateini(nstate_,mi(1),# of elements)\n! state variables at the start of the increment\n! xstate(nstate_,mi(1),# of elements)\n! state variables at the end of the increment\n!\n! stre(6) Piola-Kirchhoff stress of the second kind\n! at the start of the increment\n!\n! iorien number of the local coordinate axis system\n! in the integration point at stake (takes the value\n! 0 if no local system applies)\n! pgauss(3) global coordinates of the integration point\n! orab(7,*) description of all local coordinate systems.\n! If a local coordinate system applies the global \n! tensors can be obtained by premultiplying the local\n! tensors with skl(3,3). skl is determined by calling\n! the subroutine transformatrix: \n! call transformatrix(orab(1,iorien),pgauss,skl)\n!\n!\n! OUTPUT:\n!\n! xstate(nstate_,mi(1),# of elements)\n! updated state variables at the end of the increment\n! stre(6) Piola-Kirchhoff stress of the second kind at the\n! end of the increment\n! stiff(21): consistent tangent stiffness matrix in the material\n! frame of reference at the end of the increment. In\n! other words: the derivative of the PK2 stress with\n! respect to the Lagrangian strain tensor. The matrix\n! is supposed to be symmetric, only the upper half is\n! to be given in the same order as for a fully\n! anisotropic elastic material (*ELASTIC,TYPE=ANISO).\n! Notice that the matrix is an integral part of the \n! fourth order material tensor, i.e. the Voigt notation\n! is not used.\n!\n implicit none\n!\n integer exitcriterion\n!\n character*80 amat\n!\n integer ithermal,icmd,kode,ielas,iel,iint,nstate_,mi(*),iorien,\n & i,j,ipiv(6),info,neq,lda,ldb,j1,j2,j3,j4,j5,j6,j7,j8,\n & nrhs,iplas,kel(4,21),iloop,leximp,lend,layer,kspt,kstep,\n & kinc,ii,nmethod\n!\n real*8 ep0(6),epqini,ep(6),b,Pn(6),dg,ddg,c(21),x(21),cm1(21),\n & stri(6),htri,sg(6),r(13),ee(6),dd,gl(6,6),gr(6,6),c0,c1,c2,\n & skl(3,3),gcreep,gm1,ya(3,3,3,3),dsg,detc,strinv,\n & depq,svm,dsvm,dg1,dg2,fu,fu1,fu2,expon,ec(2),pnewdt,\n & timeabq(2),r1(13),ep1(6),gl1(6,6),sg1(6),ckl(3,3),\n & elconloc(21),stiff(21),emec(6),emec0(6),beta(6),stre(6),\n & vj,t1l,dtime,xkl(3,3),xokl(3,3),voj,pgauss(3),orab(7,*),\n & time,ttime,decra(5),deswa(5),serd,esw(2),p,predef(1),dpred(1),\n & dtemp,xstate(nstate_,mi(1),*),xstateini(nstate_,mi(1),*)\n!\n kel=reshape((\/1,1,1,1,1,1,2,2,2,2,2,2,1,1,3,3,2,2,3,3,3,3,3,3,\n & 1,1,1,2,2,2,1,2,3,3,1,2,1,2,1,2,1,1,1,3,2,2,1,3,\n & 3,3,1,3,1,2,1,3,1,3,1,3,1,1,2,3,2,2,2,3,3,3,2,3,\n & 1,2,2,3,1,3,2,3,2,3,2,3\/),(\/4,21\/))\n!\n leximp=1\n lend=3\n!\n if(ithermal.eq.0) then\n write(*,*)'*ERROR in umat_aniso_creep: no temperature defined;'\n write(*,*) ' a creep calculation without temperature'\n write(*,*) ' does not make sense'\n write(*,*)\n call exit(201)\n endif\n!\n iloop=0\n exitcriterion=0\n!\n c0=dsqrt(2.d0\/3.d0)\n c1=2.d0\/3.d0\n c2=-1.d0\/3.d0\n!\n! elastic constants\n!\n if(iorien.gt.0) then\n!\n call transformatrix(orab(1,iorien),pgauss,skl)\n!\n call orthotropic(elconloc,ya)\n!\n do j=1,21\n j1=kel(1,j)\n j2=kel(2,j)\n j3=kel(3,j)\n j4=kel(4,j)\n c(j)=0.d0\n do j5=1,3\n do j6=1,3\n do j7=1,3\n do j8=1,3\n c(j)=c(j)+ya(j5,j6,j7,j8)*\n & skl(j1,j5)*skl(j2,j6)*skl(j3,j7)*skl(j4,j8)\n enddo\n enddo\n enddo\n enddo\n enddo\n!\n else\n do i=1,9\n c(i)=elconloc(i)\n enddo\n endif\n!\n! state variables\n!\n! equivalent plastic strain\n!\n epqini=xstateini(1,iint,iel)\n!\n! plastic strain\n!\n do i=1,6\n ep0(i)=xstateini(1+i,iint,iel)\n enddo\n! elastic strains\n!\n do i=1,6\n ee(i)=emec(i)-ep0(i)\n enddo\n!\n! global trial stress tensor\n!\n if(iorien.gt.0) then\n stri(1)=c(1)*ee(1)+c(2)*ee(2)+c(4)*ee(3)+\n & 2.d0*(c(7)*ee(4)+c(11)*ee(5)+c(16)*ee(6))\n & -beta(1)\n stri(2)=c(2)*ee(1)+c(3)*ee(2)+c(5)*ee(3)+\n & 2.d0*(c(8)*ee(4)+c(12)*ee(5)+c(17)*ee(6))\n & -beta(2)\n stri(3)=c(4)*ee(1)+c(5)*ee(2)+c(6)*ee(3)+\n & 2.d0*(c(9)*ee(4)+c(13)*ee(5)+c(18)*ee(6))\n & -beta(3)\n stri(4)=c(7)*ee(1)+c(8)*ee(2)+c(9)*ee(3)+\n & 2.d0*(c(10)*ee(4)+c(14)*ee(5)+c(19)*ee(6))\n & -beta(4)\n stri(5)=c(11)*ee(1)+c(12)*ee(2)+c(13)*ee(3)+\n & 2.d0*(c(14)*ee(4)+c(15)*ee(5)+c(20)*ee(6))\n & -beta(5)\n stri(6)=c(16)*ee(1)+c(17)*ee(2)+c(18)*ee(3)+\n & 2.d0*(c(19)*ee(4)+c(20)*ee(5)+c(21)*ee(6))\n & -beta(6)\n else\n stri(1)=c(1)*ee(1)+c(2)*ee(2)+c(4)*ee(3)-beta(1)\n stri(2)=c(2)*ee(1)+c(3)*ee(2)+c(5)*ee(3)-beta(1)\n stri(3)=c(4)*ee(1)+c(5)*ee(2)+c(6)*ee(3)-beta(1)\n stri(4)=2.d0*c(7)*ee(4)-beta(4)\n stri(5)=2.d0*c(8)*ee(5)-beta(5)\n stri(6)=2.d0*c(9)*ee(6)-beta(6)\n endif\n!\n! stress radius (only deviatoric part of stress enters)\n!\n strinv=(stri(1)+stri(2)+stri(3))\/3.d0\n do i=1,3\n sg(i)=stri(i)-strinv\n enddo\n do i=4,6\n sg(i)=stri(i)\n enddo\n dsg=dsqrt(sg(1)*sg(1)+sg(2)*sg(2)+sg(3)*sg(3)+\n & 2.d0*(sg(4)*sg(4)+sg(5)*sg(5)+sg(6)*sg(6))) \n!\n! evaluation of the yield surface\n!\n ec(1)=epqini \n!\n htri=dsg\n!\n! check whether plasticity occurs\n!\n if(htri.gt.1.d-10) then\n iplas=1\n else\n iplas=0\n endif\n!\n if((iplas.eq.0).or.(ielas.eq.1).or.(dtime.lt.1.d-30).or.\n & ((nmethod.eq.1).and.(ithermal.ne.3))) then\n!\n! elastic stress\n!\n do i=1,6\n stre(i)=stri(i)\n enddo\n!\n! updating the state variables\n!\n xstate(1,iint,iel)=epqini\n do i=1,6\n xstate(1+i,iint,iel)=ep0(i)\n enddo\n!\n! elastic stiffness\n!\n if(icmd.ne.3) then\n if(iorien.gt.0) then\n do i=1,21\n stiff(i)=c(i)\n enddo\n else\n stiff(1)=c(1)\n stiff(2)=c(2)\n stiff(3)=c(3)\n stiff(4)=c(4)\n stiff(5)=c(5)\n stiff(6)=c(6)\n stiff(7)=0.d0\n stiff(8)=0.d0\n stiff(9)=0.d0\n stiff(10)=c(7)\n stiff(11)=0.d0\n stiff(12)=0.d0\n stiff(13)=0.d0\n stiff(14)=0.d0\n stiff(15)=c(8)\n stiff(16)=0.d0\n stiff(17)=0.d0\n stiff(18)=0.d0\n stiff(19)=0.d0\n stiff(20)=0.d0\n stiff(21)=c(9)\n endif\n endif\n!\n return\n endif\n!\n! plastic deformation\n!\n neq=6\n nrhs=1\n lda=6\n ldb=6\n!\n! initializing the state variables\n!\n do i=1,6\n ep(i)=ep0(i)\n enddo\n dg=0.d0\n!\n! determining the inverse of c\n!\n if(iorien.gt.0) then\n! \n! solve gl:C=gr\n!\n gl(1,1)=c(1) \n gl(1,2)=c(2) \n gl(2,2)=c(3) \n gl(1,3)=c(4) \n gl(2,3)=c(5) \n gl(3,3)=c(6) \n gl(1,4)=c(7) \n gl(2,4)=c(8) \n gl(3,4)=c(9) \n gl(4,4)=c(10)\n gl(1,5)=c(11)\n gl(2,5)=c(12)\n gl(3,5)=c(13)\n gl(4,5)=c(14)\n gl(5,5)=c(15)\n gl(1,6)=c(16)\n gl(2,6)=c(17)\n gl(3,6)=c(18)\n gl(4,6)=c(19)\n gl(5,6)=c(20)\n gl(6,6)=c(21)\n do i=1,6\n do j=1,i-1\n gl(i,j)=gl(j,i)\n enddo\n enddo\n do i=1,6\n do j=1,6\n gr(i,j)=0.d0\n enddo\n gr(i,i)=1.d0\n enddo\n nrhs=6\n call dgesv(neq,nrhs,gl,lda,ipiv,gr,ldb,info)\n if(info.ne.0) then\n write(*,*) '*ERROR in sc.f: linear equation solver'\n write(*,*) ' exited with error: info = ',info\n call exit(201)\n endif\n nrhs=1\n cm1(1)=gr(1,1)\n cm1(2)=gr(1,2)\n cm1(3)=gr(2,2)\n cm1(4)=gr(1,3)\n cm1(5)=gr(2,3)\n cm1(6)=gr(3,3)\n cm1(7)=gr(1,4)\/2.d0\n cm1(8)=gr(2,4)\/2.d0\n cm1(9)=gr(3,4)\/2.d0\n cm1(10)=gr(4,4)\/4.d0\n cm1(11)=gr(1,5)\/2.d0\n cm1(12)=gr(2,5)\/2.d0\n cm1(13)=gr(3,5)\/2.d0\n cm1(14)=gr(4,5)\/4.d0\n cm1(15)=gr(5,5)\/4.d0\n cm1(16)=gr(1,6)\/2.d0\n cm1(17)=gr(2,6)\/2.d0\n cm1(18)=gr(3,6)\/2.d0\n cm1(19)=gr(4,6)\/4.d0\n cm1(20)=gr(5,6)\/4.d0\n cm1(21)=gr(6,6)\/4.d0\n else\n detc=c(1)*(c(3)*c(6)-c(5)*c(5))-\n & c(2)*(c(2)*c(6)-c(4)*c(5))+\n & c(4)*(c(2)*c(5)-c(4)*c(3))\n cm1(1)=(c(3)*c(6)-c(5)*c(5))\/detc\n cm1(2)=(c(5)*c(4)-c(2)*c(6))\/detc\n cm1(3)=(c(1)*c(6)-c(4)*c(4))\/detc\n cm1(4)=(c(2)*c(5)-c(3)*c(4))\/detc\n cm1(5)=(c(2)*c(4)-c(1)*c(5))\/detc\n cm1(6)=(c(1)*c(3)-c(2)*c(2))\/detc\n cm1(7)=1.d0\/(4.d0*c(7))\n cm1(8)=1.d0\/(4.d0*c(8))\n cm1(9)=1.d0\/(4.d0*c(9))\n endif\n!\n! first attempt: root search with Newton-Raphson \n!\n loop: do\n!\n iloop=iloop+1\n!\n! elastic strains\n!\n do i=1,6\n ee(i)=emec(i)-ep(i)\n enddo\n! \n! global trial stress tensor\n! \n if(iorien.gt.0) then\n stri(1)=c(1)*ee(1)+c(2)*ee(2)+c(4)*ee(3)+\n & 2.d0*(c(7)*ee(4)+c(11)*ee(5)+c(16)*ee(6))\n & -beta(1)\n stri(2)=c(2)*ee(1)+c(3)*ee(2)+c(5)*ee(3)+\n & 2.d0*(c(8)*ee(4)+c(12)*ee(5)+c(17)*ee(6))\n & -beta(2)\n stri(3)=c(4)*ee(1)+c(5)*ee(2)+c(6)*ee(3)+\n & 2.d0*(c(9)*ee(4)+c(13)*ee(5)+c(18)*ee(6))\n & -beta(3)\n stri(4)=c(7)*ee(1)+c(8)*ee(2)+c(9)*ee(3)+\n & 2.d0*(c(10)*ee(4)+c(14)*ee(5)+c(19)*ee(6))\n & -beta(4)\n stri(5)=c(11)*ee(1)+c(12)*ee(2)+c(13)*ee(3)+\n & 2.d0*(c(14)*ee(4)+c(15)*ee(5)+c(20)*ee(6))\n & -beta(5)\n stri(6)=c(16)*ee(1)+c(17)*ee(2)+c(18)*ee(3)+\n & 2.d0*(c(19)*ee(4)+c(20)*ee(5)+c(21)*ee(6))\n & -beta(6)\n else\n stri(1)=c(1)*ee(1)+c(2)*ee(2)+c(4)*ee(3)-beta(1)\n stri(2)=c(2)*ee(1)+c(3)*ee(2)+c(5)*ee(3)-beta(1)\n stri(3)=c(4)*ee(1)+c(5)*ee(2)+c(6)*ee(3)-beta(1)\n stri(4)=2.d0*c(7)*ee(4)-beta(4)\n stri(5)=2.d0*c(8)*ee(5)-beta(5)\n stri(6)=2.d0*c(9)*ee(6)-beta(6)\n endif\n! \n! stress radius (only deviatoric part of stress enters)\n! \n strinv=(stri(1)+stri(2)+stri(3))\/3.d0\n do i=1,3\n sg(i)=stri(i)-strinv\n enddo\n do i=4,6\n sg(i)=stri(i)\n enddo\n dsg=dsqrt(sg(1)*sg(1)+sg(2)*sg(2)+sg(3)*sg(3)+\n & 2.d0*(sg(4)*sg(4)+sg(5)*sg(5)+sg(6)*sg(6))) \n! \n! evaluation of the yield surface\n! \n ec(1)=epqini \n decra(1)=c0*dg\n timeabq(1)=time\n timeabq(2)=ttime+time\n call creep(decra,deswa,xstateini(1,iint,iel),serd,ec,\n & esw,p,svm,t1l,dtemp,predef,dpred,timeabq,dtime,\n & amat,leximp,lend,pgauss,nstate_,iel,iint,layer,kspt,\n & kstep,kinc)\n!\n! if the creep routine returns an increased value of decra(1)\n! it means that there is a lower cut-off for decra(1);\n! if the routine stays in a range lower than this cut-off,\n! it will never leave it and the exit conditions are\n! assumed to be satisfied.\n!\n if(decra(1).gt.c0*dg) then\n dg=decra(1)\/c0\n if(iloop.gt.1) exitcriterion=1\n endif\n! \n htri=dsg-c0*svm\n! \n do i=1,6\n sg(i)=sg(i)\/dsg\n enddo\n! \n! determining the residual matrix\n! \n do i=1,6 \n r(i)=ep0(i)-ep(i)+dg*sg(i)\n enddo\n! \n! check convergence\n! \n if(exitcriterion.eq.1) exit\n if((dabs(htri).le.1.d-3).and.\n & ((iloop.gt.1).and.((dabs(ddg).lt.1.d-10).or.\n & (dabs(ddg).lt.1.d-3*dabs(dg))))) then\n dd=0.d0\n do i=1,6\n dd=dd+r(i)*r(i)\n enddo\n dd=sqrt(dd)\n if(dd.le.1.d-10) then\n exit\n endif\n endif\n! \n! determining b.x\n! \n b=dg\/dsg\n! \n x(1)=b*(c1-sg(1)*sg(1))\n x(2)=b*(c2-sg(1)*sg(2))\n x(3)=b*(c1-sg(2)*sg(2))\n x(4)=b*(c2-sg(1)*sg(3))\n x(5)=b*(c2-sg(2)*sg(3))\n x(6)=b*(c1-sg(3)*sg(3))\n x(7)=-b*sg(1)*sg(4)\n x(8)=-b*sg(2)*sg(4)\n x(9)=-b*sg(3)*sg(4)\n x(10)=b*(.5d0-sg(4)*sg(4))\n x(11)=-b*sg(1)*sg(5)\n x(12)=-b*sg(2)*sg(5)\n x(13)=-b*sg(3)*sg(5)\n x(14)=-b*sg(4)*sg(5)\n x(15)=b*(.5d0-sg(5)*sg(5))\n x(16)=-b*sg(1)*sg(6)\n x(17)=-b*sg(2)*sg(6)\n x(18)=-b*sg(3)*sg(6)\n x(19)=-b*sg(4)*sg(6)\n x(20)=-b*sg(5)*sg(6)\n x(21)=b*(.5d0-sg(6)*sg(6))\n! \n! filling the LHS\n! \n if(iorien.gt.0) then\n gl(1,1)=cm1(1)+x(1)\n gl(1,2)=cm1(2)+x(2)\n gl(2,2)=cm1(3)+x(3)\n gl(1,3)=cm1(4)+x(4)\n gl(2,3)=cm1(5)+x(5)\n gl(3,3)=cm1(6)+x(6)\n gl(1,4)=cm1(7)+x(7)\n gl(2,4)=cm1(8)+x(8)\n gl(3,4)=cm1(9)+x(9)\n gl(4,4)=cm1(10)+x(10)\n gl(1,5)=cm1(11)+x(11)\n gl(2,5)=cm1(12)+x(12)\n gl(3,5)=cm1(13)+x(13)\n gl(4,5)=cm1(14)+x(14)\n gl(5,5)=cm1(15)+x(15)\n gl(1,6)=cm1(16)+x(16)\n gl(2,6)=cm1(17)+x(17)\n gl(3,6)=cm1(18)+x(18)\n gl(4,6)=cm1(19)+x(19)\n gl(5,6)=cm1(20)+x(20)\n gl(6,6)=cm1(21)+x(21)\n do i=1,6\n do j=1,i-1\n gl(i,j)=gl(j,i)\n enddo\n enddo\n else\n gl(1,1)=cm1(1)+x(1)\n gl(1,2)=cm1(2)+x(2)\n gl(2,2)=cm1(3)+x(3)\n gl(1,3)=cm1(4)+x(4)\n gl(2,3)=cm1(5)+x(5)\n gl(3,3)=cm1(6)+x(6)\n gl(1,4)=x(7)\n gl(2,4)=x(8)\n gl(3,4)=x(9)\n gl(4,4)=cm1(7)+x(10)\n gl(1,5)=x(11)\n gl(2,5)=x(12)\n gl(3,5)=x(13)\n gl(4,5)=x(14)\n gl(5,5)=cm1(8)+x(15)\n gl(1,6)=x(16)\n gl(2,6)=x(17)\n gl(3,6)=x(18)\n gl(4,6)=x(19)\n gl(5,6)=x(20)\n gl(6,6)=cm1(9)+x(21)\n do i=1,6\n do j=1,i-1\n gl(i,j)=gl(j,i)\n enddo\n enddo\n endif\n!\n! filling the RHS\n!\n do i=1,6\n gr(i,1)=sg(i)\n enddo\n! \n! solve gl:(P:n)=gr\n!\n call dgesv(neq,nrhs,gl,lda,ipiv,gr,ldb,info)\n if(info.ne.0) then\n write(*,*) '*ERROR in sc.f: linear equation solver'\n write(*,*) ' exited with error: info = ',info\n call exit(201)\n endif\n!\n do i=1,6\n Pn(i)=gr(i,1)\n enddo\n!\n! calculating the creep contribution\n!\n gcreep=c1\/decra(5)\n!\n! calculating the correction to the consistency parameter\n!\n gm1=Pn(1)*sg(1)+Pn(2)*sg(2)+Pn(3)*sg(3)+\n & (Pn(4)*sg(4)+Pn(5)*sg(5)+Pn(6)*sg(6))\n gm1=1.d0\/(gm1+gcreep)\n ddg=gm1*(htri-(Pn(1)*r(1)+Pn(2)*r(2)+Pn(3)*r(3)+\n & (Pn(4)*r(4)+Pn(5)*r(5)+Pn(6)*r(6))))\n! \n! updating the residual matrix\n! \n do i=1,6\n r(i)=r(i)+ddg*sg(i)\n enddo\n! \n! update the plastic strain\n! \n gr(1,1)=r(1)\n gr(2,1)=r(2)\n gr(3,1)=r(3)\n gr(4,1)=r(4)\n gr(5,1)=r(5)\n gr(6,1)=r(6)\n!\n call dgetrs('No transpose',neq,nrhs,gl,lda,ipiv,gr,ldb,info)\n if(info.ne.0) then\n write(*,*) '*ERROR in sc.f: linear equation solver'\n write(*,*) ' exited with error: info = ',info\n call exit(201)\n endif\n!\n if(iorien.gt.0) then\n ep(1)=ep(1)+cm1(1)*gr(1,1)+cm1(2)*gr(2,1)+cm1(4)*gr(3,1)+\n & (cm1(7)*gr(4,1)+cm1(11)*gr(5,1)+cm1(16)*gr(6,1))\n ep(2)=ep(2)+cm1(2)*gr(1,1)+cm1(3)*gr(2,1)+cm1(5)*gr(3,1)+\n & (cm1(8)*gr(4,1)+cm1(12)*gr(5,1)+cm1(17)*gr(6,1))\n ep(3)=ep(3)+cm1(4)*gr(1,1)+cm1(5)*gr(2,1)+cm1(6)*gr(3,1)+\n & (cm1(9)*gr(4,1)+cm1(13)*gr(5,1)+cm1(18)*gr(6,1))\n ep(4)=ep(4)+cm1(7)*gr(1,1)+cm1(8)*gr(2,1)+cm1(9)*gr(3,1)+\n & (cm1(10)*gr(4,1)+cm1(14)*gr(5,1)+cm1(19)*gr(6,1))\n ep(5)=ep(5)+cm1(11)*gr(1,1)+cm1(12)*gr(2,1)+cm1(13)*gr(3,1)+\n & (cm1(14)*gr(4,1)+cm1(15)*gr(5,1)+cm1(20)*gr(6,1))\n ep(6)=ep(6)+cm1(16)*gr(1,1)+cm1(17)*gr(2,1)+cm1(18)*gr(3,1)+\n & (cm1(19)*gr(4,1)+cm1(20)*gr(5,1)+cm1(21)*gr(6,1))\n else\n ep(1)=ep(1)+cm1(1)*gr(1,1)+cm1(2)*gr(2,1)+cm1(4)*gr(3,1)\n ep(2)=ep(2)+cm1(2)*gr(1,1)+cm1(3)*gr(2,1)+cm1(5)*gr(3,1)\n ep(3)=ep(3)+cm1(4)*gr(1,1)+cm1(5)*gr(2,1)+cm1(6)*gr(3,1)\n ep(4)=ep(4)+cm1(7)*gr(4,1)\n ep(5)=ep(5)+cm1(8)*gr(5,1)\n ep(6)=ep(6)+cm1(9)*gr(6,1)\n endif\n!\n! update the consistency parameter\n!\n dg=dg+ddg\n!\n! end of major loop\n!\n if((iloop.gt.15).or.(dg.le.0.d0)) then\n iloop=1\n dg=0.d0\n do i=1,6\n ep(i)=ep0(i)\n enddo\n! \n! second attempt: root search through interval division\n! \n do\n if(iloop.gt.100) then\nc NOTE: write statements cause problems for\nc parallellized execution\nc write(*,*) \nc & '*WARNING in umat_aniso_creep: material loop'\nc write(*,*) ' did not converge in integration'\nc write(*,*) ' point',iint,'in element',iel,';'\nc write(*,*) ' the increment size is reduced'\nc write(*,*)\n pnewdt=0.25d0\n return\n endif\n! \n! elastic strains\n! \n do i=1,6\n ee(i)=emec(i)-ep(i)\n enddo\n! \n! global trial stress tensor\n! \n if(iorien.gt.0) then\n stri(1)=c(1)*ee(1)+c(2)*ee(2)+c(4)*ee(3)+\n & 2.d0*(c(7)*ee(4)+c(11)*ee(5)+c(16)*ee(6))\n & -beta(1)\n stri(2)=c(2)*ee(1)+c(3)*ee(2)+c(5)*ee(3)+\n & 2.d0*(c(8)*ee(4)+c(12)*ee(5)+c(17)*ee(6))\n & -beta(2)\n stri(3)=c(4)*ee(1)+c(5)*ee(2)+c(6)*ee(3)+\n & 2.d0*(c(9)*ee(4)+c(13)*ee(5)+c(18)*ee(6))\n & -beta(3)\n stri(4)=c(7)*ee(1)+c(8)*ee(2)+c(9)*ee(3)+\n & 2.d0*(c(10)*ee(4)+c(14)*ee(5)+c(19)*ee(6))\n & -beta(4)\n stri(5)=c(11)*ee(1)+c(12)*ee(2)+c(13)*ee(3)+\n & 2.d0*(c(14)*ee(4)+c(15)*ee(5)+c(20)*ee(6))\n & -beta(5)\n stri(6)=c(16)*ee(1)+c(17)*ee(2)+c(18)*ee(3)+\n & 2.d0*(c(19)*ee(4)+c(20)*ee(5)+c(21)*ee(6))\n & -beta(6)\n else\n stri(1)=c(1)*ee(1)+c(2)*ee(2)+c(4)*ee(3)-beta(1)\n stri(2)=c(2)*ee(1)+c(3)*ee(2)+c(5)*ee(3)-beta(1)\n stri(3)=c(4)*ee(1)+c(5)*ee(2)+c(6)*ee(3)-beta(1)\n stri(4)=2.d0*c(7)*ee(4)-beta(4)\n stri(5)=2.d0*c(8)*ee(5)-beta(5)\n stri(6)=2.d0*c(9)*ee(6)-beta(6)\n endif\n! \n! stress radius (only deviatoric part of stress enters)\n! \n strinv=(stri(1)+stri(2)+stri(3))\/3.d0\n do i=1,3\n sg(i)=stri(i)-strinv\n enddo\n do i=4,6\n sg(i)=stri(i)\n enddo\n dsg=dsqrt(sg(1)*sg(1)+sg(2)*sg(2)+sg(3)*sg(3)+\n & 2.d0*(sg(4)*sg(4)+sg(5)*sg(5)+sg(6)*sg(6))) \n! \n! evaluation of the yield surface\n! \n ec(1)=epqini \n decra(1)=c0*dg\n timeabq(1)=time\n timeabq(2)=ttime+time\n call creep(decra,deswa,xstateini(1,iint,iel),serd,ec,\n & esw,p,svm,t1l,dtemp,predef,dpred,timeabq,dtime,\n & amat,leximp,lend,pgauss,nstate_,iel,iint,layer,kspt,\n & kstep,kinc)\n if(decra(1).gt.c0*dg) then\n dg=decra(1)\/c0\n if(abs(iloop).gt.2) exitcriterion=1\n endif\n! \n! needed in case decra(1) was changed in subroutine creep,\n! for instance because it is too small\n! \n dg=decra(1)\/c0\n! \n htri=dsg-c0*svm\n! \n do i=1,6\n sg(i)=sg(i)\/dsg\n enddo\n! \n! determining the residual matrix\n! \n do i=1,6 \n r(i)=ep0(i)-ep(i)+dg*sg(i)\n enddo\n! \n! check convergence\n! \n if(exitcriterion.eq.1) exit loop\n if((dabs(htri).le.1.d-3).and.\n & ((iloop.gt.2).and.((dabs(ddg).lt.1.d-10).or.\n & (dabs(ddg).lt.1.d-3*dabs(dg))))) then\n dd=0.d0\n do i=1,6\n dd=dd+r(i)*r(i)\n enddo\n dd=sqrt(dd)\n if(dd.le.1.d-10) then\n exit loop\n endif\n endif\n if(iloop.gt.100) then\nc write(*,*) \nc & '*ERROR: no convergence in umat_aniso_creep'\nc write(*,*) ' iloop>100'\nc write(*,*) 'htri,dd ',htri,dd\n exit loop\n endif\n! \n! determining b.x\n! \n b=dg\/dsg\n! \n x(1)=b*(c1-sg(1)*sg(1))\n x(2)=b*(c2-sg(1)*sg(2))\n x(3)=b*(c1-sg(2)*sg(2))\n x(4)=b*(c2-sg(1)*sg(3))\n x(5)=b*(c2-sg(2)*sg(3))\n x(6)=b*(c1-sg(3)*sg(3))\n x(7)=-b*sg(1)*sg(4)\n x(8)=-b*sg(2)*sg(4)\n x(9)=-b*sg(3)*sg(4)\n x(10)=b*(.5d0-sg(4)*sg(4))\n x(11)=-b*sg(1)*sg(5)\n x(12)=-b*sg(2)*sg(5)\n x(13)=-b*sg(3)*sg(5)\n x(14)=-b*sg(4)*sg(5)\n x(15)=b*(.5d0-sg(5)*sg(5))\n x(16)=-b*sg(1)*sg(6)\n x(17)=-b*sg(2)*sg(6)\n x(18)=-b*sg(3)*sg(6)\n x(19)=-b*sg(4)*sg(6)\n x(20)=-b*sg(5)*sg(6)\n x(21)=b*(.5d0-sg(6)*sg(6))\n! \n! filling the LHS\n! \n if(iorien.gt.0) then\n gl(1,1)=cm1(1)+x(1)\n gl(1,2)=cm1(2)+x(2)\n gl(2,2)=cm1(3)+x(3)\n gl(1,3)=cm1(4)+x(4)\n gl(2,3)=cm1(5)+x(5)\n gl(3,3)=cm1(6)+x(6)\n gl(1,4)=cm1(7)+x(7)\n gl(2,4)=cm1(8)+x(8)\n gl(3,4)=cm1(9)+x(9)\n gl(4,4)=cm1(10)+x(10)\n gl(1,5)=cm1(11)+x(11)\n gl(2,5)=cm1(12)+x(12)\n gl(3,5)=cm1(13)+x(13)\n gl(4,5)=cm1(14)+x(14)\n gl(5,5)=cm1(15)+x(15)\n gl(1,6)=cm1(16)+x(16)\n gl(2,6)=cm1(17)+x(17)\n gl(3,6)=cm1(18)+x(18)\n gl(4,6)=cm1(19)+x(19)\n gl(5,6)=cm1(20)+x(20)\n gl(6,6)=cm1(21)+x(21)\n do i=1,6\n do j=1,i-1\n gl(i,j)=gl(j,i)\n enddo\n enddo\n else\n gl(1,1)=cm1(1)+x(1)\n gl(1,2)=cm1(2)+x(2)\n gl(2,2)=cm1(3)+x(3)\n gl(1,3)=cm1(4)+x(4)\n gl(2,3)=cm1(5)+x(5)\n gl(3,3)=cm1(6)+x(6)\n gl(1,4)=x(7)\n gl(2,4)=x(8)\n gl(3,4)=x(9)\n gl(4,4)=cm1(7)+x(10)\n gl(1,5)=x(11)\n gl(2,5)=x(12)\n gl(3,5)=x(13)\n gl(4,5)=x(14)\n gl(5,5)=cm1(8)+x(15)\n gl(1,6)=x(16)\n gl(2,6)=x(17)\n gl(3,6)=x(18)\n gl(4,6)=x(19)\n gl(5,6)=x(20)\n gl(6,6)=cm1(9)+x(21)\n do i=1,6\n do j=1,i-1\n gl(i,j)=gl(j,i)\n enddo\n enddo\n endif\n! \n! filling the RHS\n! \n do i=1,6\n gr(i,1)=sg(i)\n enddo\n! \n! solve gl:(P:n)=gr\n! \n call dgesv(neq,nrhs,gl,lda,ipiv,gr,ldb,info)\n if(info.ne.0) then\n write(*,*) '*ERROR in sc.f: linear equation solver'\n write(*,*) ' exited with error: info = ',info\n call exit(201)\n endif\n! \n do i=1,6\n Pn(i)=gr(i,1)\n enddo\n! \n! calculating the creep contribution\n! \n gcreep=c1\/decra(5)\n! \n! calculating the correction to the consistency parameter\n! \n gm1=Pn(1)*sg(1)+Pn(2)*sg(2)+Pn(3)*sg(3)+\n & (Pn(4)*sg(4)+Pn(5)*sg(5)+Pn(6)*sg(6))\n gm1=1.d0\/(gm1+gcreep)\n fu=(htri-(Pn(1)*r(1)+Pn(2)*r(2)+Pn(3)*r(3)+\n & (Pn(4)*r(4)+Pn(5)*r(5)+Pn(6)*r(6))))\n! \n if(iloop.eq.1) then\nc write(*,*) 'iloop,dg,fu ',iloop,dg,fu\n dg1=0.d0\n fu1=fu\n iloop=2\n dg=1.d-10\n ddg=dg\n do i=1,6\n ep1(i)=ep(i)\n r1(i)=r(i)\n sg1(i)=sg(i)\n do j=1,6\n gl1(i,j)=gl(i,j)\n enddo\n enddo\n elseif((iloop.eq.2).or.(iloop.lt.0)) then\n if(fu*fu1.lt.0.d0) then\nc write(*,*) 'iloop,dg,fu ',iloop,dg,fu\n if(iloop.eq.2) then\n iloop=3\n else\n iloop=-iloop+1\n endif\n fu2=fu\n dg2=dg\n dg=(dg1+dg2)\/2.d0\n ddg=(dg2-dg1)\/2.d0\n do i=1,6\n ep(i)=ep1(i)\n r(i)=r1(i)\n sg(i)=sg1(i)\n do j=1,6\n gl(i,j)=gl1(i,j)\n enddo\n enddo\n else\nc write(*,*) 'iloop,dg,fu ',iloop,dg,fu\nc dg1=dg\nc fu1=fu\n if(iloop.eq.2) then\n if(dabs(fu).gt.dabs(fu1)) exitcriterion=1\n dg1=dg\n fu1=fu\n ddg=dg*9.d0\n dg=dg*10.d0\n else\n dg1=dg\n fu1=fu\n dg=dg+ddg\n iloop=iloop-1\n endif\n if(dg.gt.10.1d0) then\n write(*,*) \n & '*ERROR: no convergence in umat_aniso_creep'\n write(*,*) ' dg>10.'\n call exit(201)\n endif\n do i=1,6\n ep1(i)=ep(i)\n r1(i)=r(i)\n sg1(i)=sg(i)\n do j=1,6\n gl1(i,j)=gl(i,j)\n enddo\n enddo\n endif\n else\nc write(*,*) 'iloop,dg,fu ',iloop,dg,fu\n if(fu*fu1.ge.0.d0) then\n dg1=dg\n fu1=fu\n dg=(dg1+dg2)\/2.d0\n ddg=(dg2-dg1)\/2.d0\n do i=1,6\n ep1(i)=ep(i)\n r1(i)=r(i)\n sg1(i)=sg(i)\n do j=1,6\n gl1(i,j)=gl(i,j)\n enddo\n enddo\n iloop=-iloop-1\n else\n dg2=dg\n fu2=fu\n dg=(dg1+dg2)\/2.d0\n ddg=(dg2-dg1)\/2.d0\n do i=1,6\n ep(i)=ep1(i)\n r(i)=r1(i)\n sg(i)=sg1(i)\n do j=1,6\n gl(i,j)=gl1(i,j)\n enddo\n enddo\n iloop=iloop+1\n endif\n endif\n! \n! updating the residual matrix\n! \n do i=1,6\n r(i)=r(i)+ddg*sg(i)\n enddo\n! \n! update the plastic strain\n! \n gr(1,1)=r(1)\n gr(2,1)=r(2)\n gr(3,1)=r(3)\n gr(4,1)=r(4)\n gr(5,1)=r(5)\n gr(6,1)=r(6)\n! \n call dgetrs('No transpose',neq,nrhs,gl,lda,ipiv,gr,ldb,\n & info)\n if(info.ne.0) then\n write(*,*) '*ERROR in sc.f: linear equation solver'\n write(*,*) ' exited with error: info = ',info\n call exit(201)\n endif\n! \n if(iorien.gt.0) then\n ep(1)=ep(1)+cm1(1)*gr(1,1)+cm1(2)*gr(2,1)+\n & cm1(4)*gr(3,1)+\n & (cm1(7)*gr(4,1)+cm1(11)*gr(5,1)+\n & cm1(16)*gr(6,1))\n ep(2)=ep(2)+cm1(2)*gr(1,1)+cm1(3)*gr(2,1)+\n & cm1(5)*gr(3,1)+\n & (cm1(8)*gr(4,1)+cm1(12)*gr(5,1)+\n & cm1(17)*gr(6,1))\n ep(3)=ep(3)+cm1(4)*gr(1,1)+cm1(5)*gr(2,1)\n & +cm1(6)*gr(3,1)+\n & (cm1(9)*gr(4,1)+cm1(13)*gr(5,1)+\n & cm1(18)*gr(6,1))\n ep(4)=ep(4)+cm1(7)*gr(1,1)+cm1(8)*gr(2,1)+\n & cm1(9)*gr(3,1)+\n & (cm1(10)*gr(4,1)+cm1(14)*gr(5,1)+\n & cm1(19)*gr(6,1))\n ep(5)=ep(5)+cm1(11)*gr(1,1)+cm1(12)*gr(2,1)+\n & cm1(13)*gr(3,1)+\n & (cm1(14)*gr(4,1)+cm1(15)*gr(5,1)+\n & cm1(20)*gr(6,1))\n ep(6)=ep(6)+cm1(16)*gr(1,1)+cm1(17)*gr(2,1)+\n & cm1(18)*gr(3,1)+\n & (cm1(19)*gr(4,1)+cm1(20)*gr(5,1)+\n & cm1(21)*gr(6,1))\n else\n ep(1)=ep(1)+cm1(1)*gr(1,1)+cm1(2)*gr(2,1)+\n & cm1(4)*gr(3,1)\n ep(2)=ep(2)+cm1(2)*gr(1,1)+cm1(3)*gr(2,1)+\n & cm1(5)*gr(3,1)\n ep(3)=ep(3)+cm1(4)*gr(1,1)+cm1(5)*gr(2,1)+\n & cm1(6)*gr(3,1)\n ep(4)=ep(4)+cm1(7)*gr(4,1)\n ep(5)=ep(5)+cm1(8)*gr(5,1)\n ep(6)=ep(6)+cm1(9)*gr(6,1)\n endif\n! \n! end of major loop\n! \n enddo\n! \n endif\n! \n enddo loop\n! \n! storing the stress\n! \n do i=1,6\n stre(i)=stri(i)\n enddo\n!\n! converting the stress into the material frame of\n! reference\n! \nc cauchy=1\nc call str2mat(stre,ckl,vj,cauchy)\n! \n! calculating the tangent stiffness matrix\n! \n if(icmd.ne.3) then\n! \n! determining p\n! \n gr(1,1)=1.d0 \n gr(1,2)=0. \n gr(2,2)=1.d0 \n gr(1,3)=0. \n gr(2,3)=0. \n gr(3,3)=1.d0 \n gr(1,4)=0. \n gr(2,4)=0. \n gr(3,4)=0. \n gr(4,4)=1.d0\n gr(1,5)=0.\n gr(2,5)=0.\n gr(3,5)=0.\n gr(4,5)=0.\n gr(5,5)=1.d0\n gr(1,6)=0.\n gr(2,6)=0.\n gr(3,6)=0.\n gr(4,6)=0.\n gr(5,6)=0.\n gr(6,6)=1.d0\n do i=1,6\n do j=1,i-1\n gr(i,j)=gr(j,i)\n enddo\n enddo\n nrhs=6\n!\n call dgetrs('No transpose',neq,nrhs,gl,lda,ipiv,gr,ldb,info)\n if(info.ne.0) then\n write(*,*) '*ERROR in sc.f: linear equation solver'\n write(*,*) ' exited with error: info = ',info\n call exit(201)\n endif\n!\n stiff(1)=gr(1,1)-gm1*Pn(1)*Pn(1)\n stiff(2)=gr(1,2)-gm1*Pn(1)*Pn(2)\n stiff(3)=gr(2,2)-gm1*Pn(2)*Pn(2)\n stiff(4)=gr(1,3)-gm1*Pn(1)*Pn(3)\n stiff(5)=gr(2,3)-gm1*Pn(2)*Pn(3)\n stiff(6)=gr(3,3)-gm1*Pn(3)*Pn(3)\n stiff(7)=(gr(1,4)-gm1*Pn(1)*Pn(4))\/2.d0\n stiff(8)=(gr(2,4)-gm1*Pn(2)*Pn(4))\/2.d0\n stiff(9)=(gr(3,4)-gm1*Pn(3)*Pn(4))\/2.d0\n stiff(10)=(gr(4,4)-gm1*Pn(4)*Pn(4))\/4.d0\n stiff(11)=(gr(1,5)-gm1*Pn(1)*Pn(5))\/2.d0\n stiff(12)=(gr(2,5)-gm1*Pn(2)*Pn(5))\/2.d0\n stiff(13)=(gr(3,5)-gm1*Pn(3)*Pn(5))\/2.d0\n stiff(14)=(gr(4,5)-gm1*Pn(4)*Pn(5))\/4.d0\n stiff(15)=(gr(5,5)-gm1*Pn(5)*Pn(5))\/4.d0\n stiff(16)=(gr(1,6)-gm1*Pn(1)*Pn(6))\/2.d0\n stiff(17)=(gr(2,6)-gm1*Pn(2)*Pn(6))\/2.d0\n stiff(18)=(gr(3,6)-gm1*Pn(3)*Pn(6))\/2.d0\n stiff(19)=(gr(4,6)-gm1*Pn(4)*Pn(6))\/4.d0\n stiff(20)=(gr(5,6)-gm1*Pn(5)*Pn(6))\/4.d0\n stiff(21)=(gr(6,6)-gm1*Pn(6)*Pn(6))\/4.d0\nc!start\nc! conversion of the stiffness matrix from spatial coordinates\nc! coordinates into material coordinates\nc! \nc call stiff2mat(stiff,ckl,vj,cauchy)\nc!end\n endif\n!\n! updating the state variables\n!\n xstate(1,iint,iel)=epqini+c0*dg\n do i=1,6\n xstate(1+i,iint,iel)=ep(i)\n enddo\n!\n return\n end\n","avg_line_length":32.7737288136,"max_line_length":78,"alphanum_fraction":0.3977969126} {"size":17260,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"! Copyright \u00a9 2022, UChicago Argonne, LLC, OPEN SOURCE LICENSE\n! See (root dir\/)LICENSE.TXT \n\n! PGAS-FMO Proxy Application \n! Written by Graham D. Fletcher, Computational Science Division, \n! Argonne National Laboratory \n\n! Improved version (0.1) \n! Models \n! - Fragments are He atoms\n! - The fragment basis is a contracted s-type GTO (used uncontracted) \n! - The density is just the product of the contraction weights \n! Assumptions \n! - The fragment basis sets and geometries are replicated \n! - The fragment densities are stored in a PGAS array \n! - The D*S factors for the intermediate coulomb approximation \n! are re-computed on-the-fly \n! Implementations \n! - 1 rank per compute process group\n! - Variable number of fragments per group \n! \n! References \n! The basic method-\n! [1] D.G. Fedorov, K. Kitaura, J. Chem. Phys. 120, 6832-6840(2004) \n! The electrostatic approximations (long-range and intermediate-range - \n! eqns. (12) and (13), respectively)- \n! [2] T. Nakano, et al, Chemical Physics Letters 351 (2002) 475\u2013480 \n\n module pgasfmo_params \n parameter ( pi = 3.1415926535897931d0 )\n real(8) sqrpi2\n parameter ( sqrpi2 = ( pi**( -0.5d0 ) )*2.0d0 )\n real(8) dtol, rcut \n parameter ( dtol= 1.0d-10, rcut= 1.0d-12 ) \n real(8) tobohrs \n parameter ( tobohrs = 1.889725987722d0 )\n end module pgasfmo_params \n\n\n\n module pgasfmo_info \n implicit none \n integer(4) num_proc, myrank, errcon \n integer(4) mpi_comm_compute \n integer num_comp \n integer, allocatable :: pgas_map( : ) \n end module pgasfmo_info \n\n\n\n program pgas_fmo \n use pgasfmo_params \n use pgasfmo_info \n implicit none \n integer nfrag,ngauss,myfrag,ifrag,jfrag,kfrag,nfrag_me, i,j,k,l \n real(8), allocatable :: xpnt( : )\n real(8), allocatable :: coef( : )\n real(8), allocatable :: geom( : , : )\n real(8), allocatable :: fock( : , : , : )\n real(8), allocatable :: dens( : , : )\n real(8) rmedium,rlong, eri,rsep,mullpop,sum,ovl,ptch,potev \n\n\n call pgasfmo_init \n\n if ( myrank == 0 ) read *, ngauss, nfrag \n\n call pgasfmo_bcast( 'i', nfrag, 1 ) \n call pgasfmo_bcast( 'i', ngauss, 1 ) \n\n allocate( xpnt( ngauss ) ) \n allocate( coef( ngauss ) ) \n allocate( geom( 3, nfrag ) ) \n\n if ( myrank == 0 ) then \n! read the GTO exponents and contraction coefficients \n read *, ( xpnt( i ), coef( i ), i = 1, ngauss ) \n\n! read intermediate and long-range inter-fragment separation cutoffs \n! and the (fake) Mulliken population charge \n read *, rmedium, rlong, mullpop\n\n! read the geometry \n do i = 1, nfrag \n read *, ( geom( j, i ), j = 1, 3 ) \n end do\n\n end if ! master input \n\n! broadcast input data to all compute ranks \n call pgasfmo_bcast( 'd', rmedium, 1 ) \n call pgasfmo_bcast( 'd', rlong, 1 ) \n call pgasfmo_bcast( 'd', mullpop, 1 ) \n call pgasfmo_bcast( 'd', xpnt, ngauss ) \n call pgasfmo_bcast( 'd', coef, ngauss ) \n call pgasfmo_bcast( 'd', geom, 3*nfrag ) \n\n! normalize the primitive GTO weights \n do i = 1, ngauss \n coef( i ) = coef( i )*( ( 2.0d0*xpnt( i ) )**0.75d0 )\n end do\n\n! scale the geometry to Bohrs for energy calculations in AU \n do i = 1, nfrag \n geom( 1, i ) = geom( 1, i )*tobohrs \n geom( 2, i ) = geom( 2, i )*tobohrs \n geom( 3, i ) = geom( 3, i )*tobohrs \n end do\n rmedium = rmedium * tobohrs \n rlong = rlong * tobohrs \n\n! create the PGAS array to hold the fragment densities \n call pgasfmo_create( ngauss**2, nfrag )\n\n nfrag_me = pgas_map( myrank+1 ) - pgas_map( myrank ) \n allocate( fock( ngauss, ngauss, nfrag_me ) ) \n\n do i = 1, nfrag_me \n do j = 1, ngauss \n do k = 1, ngauss \n fock( k, j, i ) = 0.0d0 \n end do\n end do\n end do\n\n! make the density - this could be input \n allocate( dens( ngauss, ngauss ) ) \n do i = 1, ngauss \n do j = 1, i \n dens( i, j ) = coef( i ) * coef( j ) !*2.0d0 \n dens( j, i ) = dens( i, j ) \n end do\n end do\n \n! fill the PGAS array from each group \n do myfrag = pgas_map( myrank ), pgas_map( myrank+1 ) - 1 \n call pgasfmo_put( myfrag, ngauss**2, dens ) ! local PUT \n end do \n\n! sync to ensure the array is filled before use \n call pgasfmo_sync() \n\n! Main loops over fragments, compute the e-e potential \n do ifrag = 1, nfrag_me \n myfrag = ifrag + pgas_map( myrank ) - 1 \n! The offset, below, prevents processors accessing the same fragment \n! density at the same time, thus avoiding a communication bottleneck \n do kfrag = 1, nfrag \n jfrag = kfrag + myrank \n if ( jfrag > nfrag ) jfrag = jfrag - nfrag \n\n! compute the inter-fragment separation \n! we would compute and store the fragment centers-of-mass, above \n! here, the fragments are He atoms so we just use their coordinates \n rsep = sqrt( ( geom( 1, jfrag ) - geom( 1, myfrag ) )**2 & \n + ( geom( 2, jfrag ) - geom( 2, myfrag ) )**2 & \n + ( geom( 3, jfrag ) - geom( 3, myfrag ) )**2 )\n\n! begin compute kernel \n! an obvious improvement is to replicate the i,j loops inside the rsep clauses \n! and move the GETs, below, outside of those loops \n do i = 1, ngauss\n do j = 1, ngauss \n! options for computing the potential \n if ( rsep > rlong ) then \n! first, the point-charge approximation (eq.13 of [2])\n fock( i, j, ifrag ) = fock( i, j, ifrag ) + mullpop*ptch( myfrag,jfrag, i,j, xpnt, geom ) \n else if ( rsep > rmedium ) then \n! intermediate, coulomb approximation (eq.12 of [2])\n call pgasfmo_get( jfrag, ngauss**2, dens ) \n do k = 1, ngauss\n! make (density * overlap)_kk for jfrag \n sum = 0.0d0 \n do l = 1, ngauss \n sum = sum + dens( k, l )*ovl( jfrag, l,k, xpnt, geom ) \n end do\n fock( i, j, ifrag ) = fock( i, j, ifrag ) + sum*eri( myfrag,jfrag, i,j,k,k, xpnt, geom ) \n end do \n else \n! full\/explicit calculation (2nd term in curly brackets, RHS, eq.5 of [1])\n call pgasfmo_get( jfrag, ngauss**2, dens ) \n do k = 1, ngauss\n do l = 1, ngauss \n fock( i, j, ifrag ) = fock( i, j, ifrag ) + dens( k, l )*eri( myfrag,jfrag, i,j,k,l, xpnt, geom ) \n end do ; end do \n end if \n end do ; end do ! fock matrix elements\n! end of compute kernel \n\n end do ! all fragments (monomers) \n end do ! my fragments \n\n\n! compute total interaction energy (eq.6 of [1]) - mainly for validation \n potev = 0.0d0 \n do ifrag = 1, nfrag_me \n myfrag = ifrag + pgas_map( myrank ) - 1 \n call pgasfmo_get( myfrag, ngauss**2, dens ) \n do i = 1, ngauss\n do j = 1, ngauss \n potev = potev + fock( i, j, ifrag )*dens( i, j ) \n end do ; end do \n end do \n call pgasfmo_gsumf( potev, 1 ) \n if ( myrank == 0 ) print *,'V= ', potev !*0.25d0 \n\n\n deallocate( dens ) \n deallocate( fock ) \n deallocate( geom ) \n deallocate( coef ) \n deallocate( xpnt ) \n call pgasfmo_end() \n end program pgas_fmo \n\n\n\n\n real(8) function eri( ifrag,jfrag, ib,jb,kb,lb, xpnt, geom )\n use pgasfmo_params \n implicit none \n integer ifrag,jfrag, i,j,k,l \n real(8) xpnt(*), geom(3,*) \n integer ib,jb,kb,lb \n real(8) aij,dij,xij,yij,zij, akl,dkl, aijkl,tt,f0t \n\n i = ifrag ! formula is left \n j = ifrag ! general for later \n k = jfrag ! extension, see also \n l = jfrag ! ptch() and ovl() \n eri = 0.0d0 \n aij = 1.0d0\/( xpnt( ib ) + xpnt( jb ) ) \n dij = exp( -xpnt( ib )*xpnt( jb )*aij* & \n ( ( geom( 1, i ) - geom( 1, j ) )**2 &\n + ( geom( 2, i ) - geom( 2, j ) )**2 &\n + ( geom( 3, i ) - geom( 3, j ) )**2 ) )*( aij**1.5d0 ) \n if ( abs( dij ) > dtol ) then \n xij = aij*( xpnt( ib )*geom( 1, i ) + xpnt( jb )*geom( 1, j ) ) \n yij = aij*( xpnt( ib )*geom( 2, i ) + xpnt( jb )*geom( 2, j ) ) \n zij = aij*( xpnt( ib )*geom( 3, i ) + xpnt( jb )*geom( 3, j ) ) \n akl = 1.0d0\/( xpnt( kb ) + xpnt( lb ) ) \n dkl = dij*exp( -xpnt( kb )*xpnt( lb )*akl* & \n ( ( geom( 1, k ) - geom( 1, l ) )**2 &\n + ( geom( 2, k ) - geom( 2, l ) )**2 &\n + ( geom( 3, k ) - geom( 3, l ) )**2 ) )*( akl**1.5d0 ) \n if ( abs( dkl ) > dtol ) then \n aijkl = ( xpnt( ib ) + xpnt( jb ) )*( xpnt( kb ) + xpnt( lb ) ) & \n \/ ( xpnt( ib ) + xpnt( jb ) + xpnt( kb ) + xpnt( lb ) ) \n tt = aijkl*( ( xij -akl*( xpnt( kb )*geom( 1, k ) + xpnt( lb )*geom( 1, l ) ) )**2 & \n + ( yij -akl*( xpnt( kb )*geom( 2, k ) + xpnt( lb )*geom( 2, l ) ) )**2 & \n + ( zij -akl*( xpnt( kb )*geom( 3, k ) + xpnt( lb )*geom( 3, l ) ) )**2 ) \n f0t = sqrpi2 \n if ( tt > rcut ) f0t = ( tt**( -0.5d0 ) )*erf( sqrt(tt) ) \n eri = dkl*f0t*sqrt(aijkl) \n end if \n end if \n end function eri \n\n\n\n\n real(8) function ptch( ifrag,jfrag, ib,jb, xpnt, geom )\n use pgasfmo_params \n implicit none \n integer ifrag,jfrag, i,j\n real(8) xpnt(*), geom(3,*) \n integer ib,jb \n real(8) eij,aij,ovl,xij,yij,zij, tt,f0t \n\n ptch = 0.0d0 \n i = ifrag \n j = ifrag \n eij = xpnt( ib ) + xpnt( jb ) \n aij = 1.0d0\/eij \n ovl = exp( -xpnt( ib )*xpnt( jb )*aij* & \n ( ( geom( 1, i ) - geom( 1, j ) )**2 &\n + ( geom( 2, i ) - geom( 2, j ) )**2 &\n + ( geom( 3, i ) - geom( 3, j ) )**2 ) )*( aij**1.5d0 ) \n if ( abs( ovl ) > dtol ) then \n xij = aij*( xpnt( ib )*geom( 1, i ) + xpnt( jb )*geom( 1, j ) ) \n yij = aij*( xpnt( ib )*geom( 2, i ) + xpnt( jb )*geom( 2, j ) ) \n zij = aij*( xpnt( ib )*geom( 3, i ) + xpnt( jb )*geom( 3, j ) ) \n tt = ( ( xij -geom( 1, jfrag ) )**2 & \n + ( yij -geom( 2, jfrag ) )**2 & \n + ( zij -geom( 3, jfrag ) )**2 )*eij \n f0t = sqrpi2 \n if ( tt > rcut ) f0t = ( tt**( -0.5d0 ) )*erf( sqrt(tt) ) \n ptch = ovl*f0t*sqrt( eij )\n end if \n end function ptch\n\n\n\n\n real(8) function ovl( jfrag, ib,jb, xpnt, geom )\n use pgasfmo_params \n implicit none \n integer jfrag, i,j\n real(8) xpnt(*), geom(3,*) \n integer ib,jb \n real(8) aij\n\n i = jfrag \n j = jfrag \n aij = 1.0d0\/( xpnt( ib ) + xpnt( jb ) ) \n ovl = exp( -xpnt( ib )*xpnt( jb )*aij* & \n ( ( geom( 1, i ) - geom( 1, j ) )**2 &\n + ( geom( 2, i ) - geom( 2, j ) )**2 &\n + ( geom( 3, i ) - geom( 3, j ) )**2 ) )*( aij**1.5d0 ) \n end function ovl\n\n\n\n\n subroutine pgasfmo_init\n use pgasfmo_info \n implicit none \n include 'mpif.h'\n integer i \n integer(4) group_world, group_comp \n integer(4), allocatable :: ranks( : ) \n call mpi_init( errcon )\n call mpi_comm_rank( mpi_comm_world, myrank, errcon )\n call mpi_comm_size( mpi_comm_world, num_proc, errcon ) \n if ( mod( num_proc, 2 ) .ne. 0 ) stop '!odd rank count!' \n num_comp = num_proc\/2 \n if ( myrank == 0 ) print *,'total (compute) ranks= ',num_comp \n! create compute process communicator to enable \n! collective communications between them \n allocate( ranks( 0 : num_comp - 1 ) ) \n do i = 0, num_comp - 1 \n ranks(i) = i\n end do\n call mpi_comm_group( mpi_comm_world, group_world, errcon )\n call mpi_group_incl( group_world, num_comp, ranks, & \n group_comp, errcon )\n call mpi_comm_create( mpi_comm_world, group_comp, & \n mpi_comm_compute, errcon )\n deallocate( ranks )\n if ( myrank >= num_comp ) then \n call pgasfmo_server() \n else\n allocate( pgas_map( 0 : num_comp ) ) \n call pgasfmo_sync() \n end if \n end subroutine pgasfmo_init \n\n\n\n\n subroutine pgasfmo_bcast( chtype, buff, len )\n use pgasfmo_info \n implicit none\n include 'mpif.h'\n character(1) chtype\n integer buff(*), len \n integer(4) type, from, len4 \n if ( chtype == 'i' ) then\n type = mpi_integer4\n else if ( chtype == 'd' ) then\n type = mpi_real8\n else\n! error\n end if\n len4 = len \n from = 0\n call mpi_bcast( buff, len4, type, from, mpi_comm_compute, errcon )\n end subroutine pgasfmo_bcast \n\n\n\n\n subroutine pgasfmo_gsumf( buff, datalen )\n use pgasfmo_info \n implicit none\n include 'mpif.h'\n real(8) buff(*)\n integer datalen \n integer(4) len4, type, oper \n integer maxrcv\n parameter (maxrcv = 16384 )\n real(8) rcv( maxrcv )\n integer i,j,loc,npass,len \n type = mpi_real8\n oper = mpi_sum\n npass = 1 + ( datalen - 1)\/maxrcv\n loc = 1\n len4 = maxrcv\n do i = 1, npass\n if ( i == npass ) len4 = datalen - maxrcv*(npass-1)\n call mpi_allreduce( buff( loc ), rcv, len4, type, &\n oper, mpi_comm_compute, errcon )\n do j = 1, len4 \n buff( loc + j - 1 ) = rcv( j )\n end do\n loc = loc + len4 \n end do\n end subroutine pgasfmo_gsumf \n\n\n\n\n subroutine pgasfmo_sync() \n use pgasfmo_info \n implicit none \n call mpi_barrier( mpi_comm_compute, errcon )\n end subroutine pgasfmo_sync \n\n\n\n\n subroutine pgasfmo_create( nrows, ncols ) \n use pgasfmo_info \n implicit none \n include 'mpif.h'\n integer nrows, ncols\n integer mincol,lftcol,icol,i \n integer(4) message(3) \n! create the domain decomposition (map columns to ranks) \n mincol = ncols\/num_comp \n lftcol = mod(ncols,num_comp) \n icol = 1\n do i = 0, num_comp \n pgas_map( i ) = icol\n icol = icol + mincol\n if ( i < lftcol ) icol = icol + 1\n end do \n message(1) = 0 ! = do a CREATE \n message(2) = pgas_map( myrank+1 ) - pgas_map( myrank ) \n message(3) = nrows \n call pgasfmo_send( message, 12, myrank + num_comp ) \n call mpi_barrier( mpi_comm_world, errcon )\n end subroutine pgasfmo_create \n\n\n\n\n subroutine pgasfmo_locate( pgas_addr, data_loc, item ) \n use pgasfmo_info \n implicit none\n integer pgas_addr, data_loc, item \n integer i\n\n! scan the PGAS mapping of the global address 'pgas_addr' to find the \n! corresponding data 'item' on rank 'data_loc' \n do i = 0, num_comp - 1 \n if ( pgas_addr >= pgas_map( i ) .and. pgas_addr <= pgas_map( i+1 ) -1 ) then \n data_loc = i \n item = pgas_addr - pgas_map( i ) + 1 \n end if \n end do \n end subroutine pgasfmo_locate\n\n\n\n\n subroutine pgasfmo_get( pgas_addr, len, buff )\n use pgasfmo_info \n implicit none\n integer pgas_addr, len, item, data_loc \n real(8) buff(*) \n integer(4) message(3) \n call pgasfmo_locate( pgas_addr, data_loc, item ) \n message(1) = 1 ! = do a GET\n message(2) = item \n message(3) = len \n call pgasfmo_send( message, 12, data_loc + num_comp ) \n call pgasfmo_recv( buff, len*8, data_loc + num_comp ) \n end subroutine pgasfmo_get\n\n\n\n\n subroutine pgasfmo_put( pgas_addr, len, buff )\n use pgasfmo_info \n implicit none\n integer pgas_addr, len, item, data_loc \n real(8) buff(*) \n integer(4) message(3) \n call pgasfmo_locate( pgas_addr, data_loc, item ) \n message(1) = 2 ! = do a PUT\n message(2) = item \n message(3) = len \n call pgasfmo_send( message, 12, data_loc + num_comp )\n call pgasfmo_send( buff, len*8, data_loc + num_comp ) \n end subroutine pgasfmo_put\n\n\n\n\n subroutine pgasfmo_send( sendbuff, len, to )\n implicit none\n include 'mpif.h'\n integer sendbuff(*) \n integer len, to \n integer(4) len4, mpityp, to4, msgtag, errcon \n msgtag = 270908 \n mpityp = mpi_byte\n len4 = len\n to4 = to\n call mpi_ssend( sendbuff, len4, mpityp, to4, msgtag, & \n mpi_comm_world, errcon )\n end subroutine pgasfmo_send\n\n\n\n\n subroutine pgasfmo_recv( recvbuff, len, from )\n implicit none\n include 'mpif.h'\n real(8) recvbuff(*) \n integer len, from \n integer(4) len4,mpityp,from4,msgtag,status(mpi_status_size),errcon \n msgtag = 270908 \n mpityp = mpi_byte\n len4 = len\n from4 = from\n call mpi_recv( recvbuff, len4, mpityp, from4, msgtag, & \n mpi_comm_world, status, errcon )\n end subroutine pgasfmo_recv\n\n\n\n\n subroutine pgasfmo_rcvany( recvbuff, len, from )\n implicit none\n include 'mpif.h'\n integer recvbuff(*) \n integer len, from \n integer(4) len4,mpityp,msgtag,status(mpi_status_size),errcon \n msgtag = 270908 \n mpityp = mpi_byte\n len4 = len\n call mpi_recv( recvbuff, len4, mpityp, mpi_any_source, msgtag, & \n mpi_comm_world, status, errcon )\n from = status(mpi_source)\n end subroutine pgasfmo_rcvany\n\n\n\n\n subroutine pgasfmo_server\n implicit none\n include 'mpif.h'\n logical serving \n integer(4) message(3), errcon \n integer from,task,item,len \n real(8), allocatable :: pgasfmo_data( : , : ) ! FMO1 density \n\n serving = .true.\n do while ( serving )\n call pgasfmo_rcvany( message, 12, from )\n task = message(1)\n item = message(2) \n len = message(3) \n if ( task == 0 ) THEN\n allocate( pgasfmo_data( len, item ) ) ! create local part of the PGAS \n call mpi_barrier( mpi_comm_world, errcon )\n else if ( task == 1 ) then ! GET \n call pgasfmo_send( pgasfmo_data(1,item), len*8, from )\n else if ( task == 2 ) then ! PUT \n call pgasfmo_recv( pgasfmo_data(1,item), len*8, from )\n else if ( task == 3 ) then\n serving = .false. ! done serving \n end if \n end do \n call mpi_barrier( mpi_comm_world, errcon )\n deallocate( pgasfmo_data ) \n call mpi_finalize( errcon )\n stop ! server does not return to the main program \n end subroutine pgasfmo_server\n\n\n\n\n subroutine pgasfmo_end ! called by compute ranks \n include 'mpif.h'\n integer(4) num_proc, myrank, errcon \n integer(4) message(3) \n call mpi_comm_rank( mpi_comm_world, myrank, errcon )\n call mpi_comm_size( mpi_comm_world, num_proc, errcon ) \n message(1) = 3 ! = terminate server \n call pgasfmo_send( message, 12, myrank + num_proc\/2 )\n call mpi_barrier( mpi_comm_world, errcon )\n call mpi_finalize( errcon )\n end subroutine pgasfmo_end \n\n\n\n\n","avg_line_length":29.2047377327,"max_line_length":101,"alphanum_fraction":0.6038238702} {"size":13221,"ext":"f","lang":"FORTRAN","max_stars_count":64.0,"content":" SUBROUTINE PCPOTRF( UPLO, N, A, IA, JA, DESCA, INFO )\n*\n* -- ScaLAPACK routine (version 1.7) --\n* University of Tennessee, Knoxville, Oak Ridge National Laboratory,\n* and University of California, Berkeley.\n* May 25, 2001\n*\n* .. Scalar Arguments ..\n CHARACTER UPLO\n INTEGER IA, INFO, JA, N\n* ..\n* .. Array Arguments ..\n INTEGER DESCA( * )\n COMPLEX A( * )\n* ..\n*\n* Purpose\n* =======\n*\n* PCPOTRF computes the Cholesky factorization of an N-by-N complex\n* hermitian positive definite distributed matrix sub( A ) denoting\n* A(IA:IA+N-1, JA:JA+N-1).\n*\n* The factorization has the form\n*\n* sub( A ) = U' * U , if UPLO = 'U', or\n*\n* sub( A ) = L * L', if UPLO = 'L',\n*\n* where U is an upper triangular matrix and L is lower triangular.\n*\n* Notes\n* =====\n*\n* Each global data object is described by an associated description\n* vector. This vector stores the information required to establish\n* the mapping between an object element and its corresponding process\n* and memory location.\n*\n* Let A be a generic term for any 2D block cyclicly distributed array.\n* Such a global array has an associated description vector DESCA.\n* In the following comments, the character _ should be read as\n* \"of the global array\".\n*\n* NOTATION STORED IN EXPLANATION\n* --------------- -------------- --------------------------------------\n* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,\n* DTYPE_A = 1.\n* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating\n* the BLACS process grid A is distribu-\n* ted over. The context itself is glo-\n* bal, but the handle (the integer\n* value) may vary.\n* M_A (global) DESCA( M_ ) The number of rows in the global\n* array A.\n* N_A (global) DESCA( N_ ) The number of columns in the global\n* array A.\n* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute\n* the rows of the array.\n* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute\n* the columns of the array.\n* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first\n* row of the array A is distributed.\n* CSRC_A (global) DESCA( CSRC_ ) The process column over which the\n* first column of the array A is\n* distributed.\n* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local\n* array. LLD_A >= MAX(1,LOCr(M_A)).\n*\n* Let K be the number of rows or columns of a distributed matrix,\n* and assume that its process grid has dimension p x q.\n* LOCr( K ) denotes the number of elements of K that a process\n* would receive if K were distributed over the p processes of its\n* process column.\n* Similarly, LOCc( K ) denotes the number of elements of K that a\n* process would receive if K were distributed over the q processes of\n* its process row.\n* The values of LOCr() and LOCc() may be determined via a call to the\n* ScaLAPACK tool function, NUMROC:\n* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),\n* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).\n* An upper bound for these quantities may be computed by:\n* LOCr( M ) <= ceil( ceil(M\/MB_A)\/NPROW )*MB_A\n* LOCc( N ) <= ceil( ceil(N\/NB_A)\/NPCOL )*NB_A\n*\n* This routine requires square block decomposition ( MB_A = NB_A ).\n*\n* Arguments\n* =========\n*\n* UPLO (global input) CHARACTER\n* = 'U': Upper triangle of sub( A ) is stored;\n* = 'L': Lower triangle of sub( A ) is stored.\n*\n* N (global input) INTEGER\n* The number of rows and columns to be operated on, i.e. the\n* order of the distributed submatrix sub( A ). N >= 0.\n*\n* A (local input\/local output) COMPLEX pointer into the\n* local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).\n* On entry, this array contains the local pieces of the\n* N-by-N Hermitian distributed matrix sub( A ) to be factored.\n* If UPLO = 'U', the leading N-by-N upper triangular part of\n* sub( A ) contains the upper triangular part of the matrix,\n* and its strictly lower triangular part is not referenced.\n* If UPLO = 'L', the leading N-by-N lower triangular part of\n* sub( A ) contains the lower triangular part of the distribu-\n* ted matrix, and its strictly upper triangular part is not\n* referenced. On exit, if UPLO = 'U', the upper triangular\n* part of the distributed matrix contains the Cholesky factor\n* U, if UPLO = 'L', the lower triangular part of the distribu-\n* ted matrix contains the Cholesky factor L.\n*\n* IA (global input) INTEGER\n* The row index in the global array A indicating the first\n* row of sub( A ).\n*\n* JA (global input) INTEGER\n* The column index in the global array A indicating the\n* first column of sub( A ).\n*\n* DESCA (global and local input) INTEGER array of dimension DLEN_.\n* The array descriptor for the distributed matrix A.\n*\n* INFO (global output) INTEGER\n* = 0: successful exit\n* < 0: If the i-th argument is an array and the j-entry had\n* an illegal value, then INFO = -(i*100+j), if the i-th\n* argument is a scalar and had an illegal value, then\n* INFO = -i.\n* > 0: If INFO = K, the leading minor of order K,\n* A(IA:IA+K-1,JA:JA+K-1) is not positive definite, and\n* the factorization could not be completed.\n*\n* =====================================================================\n*\n* .. Parameters ..\n INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,\n $ LLD_, MB_, M_, NB_, N_, RSRC_\n PARAMETER ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,\n $ CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,\n $ RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )\n REAL ONE\n PARAMETER ( ONE = 1.0E+0 )\n COMPLEX CONE\n PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )\n* ..\n* .. Local Scalars ..\n LOGICAL UPPER\n CHARACTER COLBTOP, ROWBTOP\n INTEGER I, ICOFF, ICTXT, IROFF, J, JB, JN, MYCOL,\n $ MYROW, NPCOL, NPROW\n* ..\n* .. Local Arrays ..\n INTEGER IDUM1( 1 ), IDUM2( 1 )\n* ..\n* .. External Subroutines ..\n EXTERNAL BLACS_GRIDINFO, CHK1MAT, PCHK1MAT, PB_TOPGET,\n $ PB_TOPSET, PCPOTF2, PCHERK, PCTRSM,\n $ PXERBLA\n* ..\n* .. External Functions ..\n LOGICAL LSAME\n INTEGER ICEIL\n EXTERNAL ICEIL, LSAME\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC ICHAR, MIN, MOD\n* ..\n* .. Executable Statements ..\n*\n* Get grid parameters\n*\n ICTXT = DESCA( CTXT_ )\n CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )\n*\n* Test the input parameters\n*\n INFO = 0\n IF( NPROW.EQ.-1 ) THEN\n INFO = -(600+CTXT_)\n ELSE\n CALL CHK1MAT( N, 2, N, 2, IA, JA, DESCA, 6, INFO )\n UPPER = LSAME( UPLO, 'U' )\n IF( INFO.EQ.0 ) THEN\n IROFF = MOD( IA-1, DESCA( MB_ ) )\n ICOFF = MOD( JA-1, DESCA( NB_ ) )\n IF ( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN\n INFO = -1\n ELSE IF( IROFF.NE.0 ) THEN\n INFO = -4\n ELSE IF( ICOFF.NE.0 ) THEN\n INFO = -5\n ELSE IF( DESCA( MB_ ).NE.DESCA( NB_ ) ) THEN\n INFO = -(600+NB_)\n END IF\n END IF\n IF( UPPER ) THEN\n IDUM1( 1 ) = ICHAR( 'U' )\n ELSE\n IDUM1( 1 ) = ICHAR( 'L' )\n END IF\n IDUM2( 1 ) = 1\n CALL PCHK1MAT( N, 2, N, 2, IA, JA, DESCA, 6, 1, IDUM1, IDUM2,\n $ INFO )\n END IF\n*\n IF( INFO.NE.0 ) THEN\n CALL PXERBLA( ICTXT, 'PCPOTRF', -INFO )\n RETURN\n END IF\n*\n* Quick return if possible\n*\n IF( N.EQ.0 )\n $ RETURN\n*\n CALL PB_TOPGET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP )\n CALL PB_TOPGET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP )\n*\n IF( UPPER ) THEN\n*\n* Split-ring topology for the communication along process\n* columns, 1-tree topology along process rows.\n*\n CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ' ' )\n CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', 'S-ring' )\n*\n* A is upper triangular, compute Cholesky factorization A = U'*U.\n*\n* Handle the first block of columns separately\n*\n JN = MIN( ICEIL( JA, DESCA( NB_ ) )*DESCA(NB_), JA+N-1 )\n JB = JN - JA + 1\n*\n* Perform unblocked Cholesky factorization on JB block\n*\n CALL PCPOTF2( UPLO, JB, A, IA, JA, DESCA, INFO )\n IF( INFO.NE.0 )\n $ GO TO 30\n*\n IF( JB+1.LE.N ) THEN\n*\n* Form the row panel of U using the triangular solver\n*\n CALL PCTRSM( 'Left', UPLO, 'Conjugate transpose',\n $ 'Non-Unit', JB, N-JB, CONE, A, IA, JA, DESCA,\n $ A, IA, JA+JB, DESCA )\n*\n* Update the trailing matrix, A = A - U'*U\n*\n CALL PCHERK( UPLO, 'Conjugate transpose', N-JB, JB, -ONE, A,\n $ IA, JA+JB, DESCA, ONE, A, IA+JB, JA+JB, DESCA )\n END IF\n*\n* Loop over remaining block of columns\n*\n DO 10 J = JN+1, JA+N-1, DESCA( NB_ )\n JB = MIN( N-J+JA, DESCA( NB_ ) )\n I = IA + J - JA\n*\n* Perform unblocked Cholesky factorization on JB block\n*\n CALL PCPOTF2( UPLO, JB, A, I, J, DESCA, INFO )\n IF( INFO.NE.0 ) THEN\n INFO = INFO + J - JA\n GO TO 30\n END IF\n*\n IF( J-JA+JB+1.LE.N ) THEN\n*\n* Form the row panel of U using the triangular solver\n*\n CALL PCTRSM( 'Left', UPLO, 'Conjugate transpose',\n $ 'Non-Unit', JB, N-J-JB+JA, CONE, A, I, J,\n $ DESCA, A, I, J+JB, DESCA )\n*\n* Update the trailing matrix, A = A - U'*U\n*\n CALL PCHERK( UPLO, 'Conjugate transpose', N-J-JB+JA, JB,\n $ -ONE, A, I, J+JB, DESCA, ONE, A, I+JB,\n $ J+JB, DESCA )\n END IF\n 10 CONTINUE\n*\n ELSE\n*\n* 1-tree topology for the communication along process columns,\n* Split-ring topology along process rows.\n*\n CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', 'S-ring' )\n CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', ' ' )\n*\n* A is lower triangular, compute Cholesky factorization A = L*L'\n* (right-looking)\n*\n* Handle the first block of columns separately\n*\n JN = MIN( ICEIL( JA, DESCA( NB_ ) )*DESCA( NB_ ), JA+N-1 )\n JB = JN - JA + 1\n*\n* Perform unblocked Cholesky factorization on JB block\n*\n CALL PCPOTF2( UPLO, JB, A, IA, JA, DESCA, INFO )\n IF( INFO.NE.0 )\n $ GO TO 30\n*\n IF( JB+1.LE.N ) THEN\n*\n* Form the column panel of L using the triangular solver\n*\n CALL PCTRSM( 'Right', UPLO, 'Conjugate transpose',\n $ 'Non-Unit', N-JB, JB, CONE, A, IA, JA, DESCA,\n $ A, IA+JB, JA, DESCA )\n*\n* Update the trailing matrix, A = A - L*L'\n*\n CALL PCHERK( UPLO, 'No Transpose', N-JB, JB, -ONE, A, IA+JB,\n $ JA, DESCA, ONE, A, IA+JB, JA+JB, DESCA )\n*\n END IF\n*\n DO 20 J = JN+1, JA+N-1, DESCA( NB_ )\n JB = MIN( N-J+JA, DESCA( NB_ ) )\n I = IA + J - JA\n*\n* Perform unblocked Cholesky factorization on JB block\n*\n CALL PCPOTF2( UPLO, JB, A, I, J, DESCA, INFO )\n IF( INFO.NE.0 ) THEN\n INFO = INFO + J - JA\n GO TO 30\n END IF\n*\n IF( J-JA+JB+1.LE.N ) THEN\n*\n* Form the column panel of L using the triangular solver\n*\n CALL PCTRSM( 'Right', UPLO, 'Conjugate transpose',\n $ 'Non-Unit', N-J-JB+JA, JB, CONE, A, I, J,\n $ DESCA, A, I+JB, J, DESCA )\n*\n* Update the trailing matrix, A = A - L*L'\n*\n CALL PCHERK( UPLO, 'No Transpose', N-J-JB+JA, JB, -ONE,\n $ A, I+JB, J, DESCA, ONE, A, I+JB, J+JB,\n $ DESCA )\n*\n END IF\n 20 CONTINUE\n*\n END IF\n*\n 30 CONTINUE\n*\n CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP )\n CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP )\n*\n RETURN\n*\n* End of PCPOTRF\n*\n END\n","avg_line_length":36.3214285714,"max_line_length":72,"alphanum_fraction":0.5149383556} {"size":362,"ext":"f","lang":"FORTRAN","max_stars_count":2.0,"content":"active(e10).\nactive(e14).\nactive(e15).\nactive(e9).\nactive(e12).\nactive(e22).\nactive(e4).\nactive(e8).\nactive(e23).\nactive(d189).\nactive(e16).\nactive(e21).\nactive(e6).\nactive(d193).\nactive(e20).\nactive(e25).\nactive(e11).\nactive(e7).\nactive(e24).\nactive(e17).\nactive(d192).\nactive(d196).\nactive(e3).\nactive(e18).\nactive(e19).\nactive(d195).\nactive(e26).\nactive(e5).\n","avg_line_length":12.4827586207,"max_line_length":13,"alphanum_fraction":0.6906077348} {"size":3209,"ext":"f90","lang":"FORTRAN","max_stars_count":3.0,"content":"module DofM\n use UtilitiesM\n\n implicit none\n\n private\n public :: DofDT, newDof\n\n type DofDT\n real(rkind) , pointer :: val\n real(rkind) , allocatable :: fixedVal\n character(:), pointer :: name\n logical :: isFixed\n contains\n procedure, public :: init\n procedure, public :: initWithName\n procedure, public :: fixDof\n procedure, public :: freeDof\n procedure, public :: assignVal\n procedure, public :: assignName\n procedure, public :: getVal\n procedure, public :: getName\n end type DofDT\n\n interface newDof\n procedure :: constructor\n procedure :: constructorWithName\n end interface newDof\n\ncontains\n\n type(DofDT) function constructor(dof, isFixed)\n implicit none\n real(rkind), target, intent(in) :: dof\n logical , intent(in) :: isFixed\n call constructor%init(dof, isFixed)\n end function constructor\n\n subroutine init(this, dof, isFixed)\n implicit none\n class(DofDT) , intent(inout) :: this\n real(rkind) , target, intent(in) :: dof\n logical , intent(in) :: isFixed\n this%val => dof\n this%name => null()\n this%isFixed = isFixed\n end subroutine init\n\n type(DofDT) function constructorWithName(dof, name, isFixed)\n implicit none\n real(rkind) , target, intent(in) :: dof\n character(*), target, intent(in) :: name\n logical , intent(in) :: isFixed\n call constructorWithName%initWithName(dof, name, isFixed)\n end function constructorWithName\n\n subroutine initWithName(this, dof, name, isFixed)\n implicit none\n class(DofDT) , intent(inout) :: this\n real(rkind) , target, intent(in) :: dof\n character(*), target, intent(in) :: name\n logical , intent(in) :: isFixed\n this%val => dof\n this%name => name\n this%isFixed = isFixed\n end subroutine initWithName\n\n subroutine assignVal(this, dof)\n implicit none\n class(DofDT) , intent(inout) :: this\n real(rkind) , target, intent(in) :: dof\n this%val => dof\n end subroutine assignVal\n\n subroutine assignName(this, name)\n implicit none\n class(DofDT) , intent(inout) :: this\n character(*), target, intent(in) :: name\n this%name => name\n end subroutine assignName\n\n subroutine fixDof(this, fixedVal)\n implicit none\n class(DofDT), intent(inout) :: this\n real(rkind) , intent(in) :: fixedVal\n this%isFixed = .true.\n if(allocated(this%fixedVal)) deallocate(this%fixedVal)\n allocate(this%fixedVal, source = fixedVal)\n end subroutine fixDof\n\n subroutine freeDof(this)\n implicit none\n class(DofDT), intent(inout) :: this\n this%isFixed = .false.\n if(allocated(this%fixedVal)) deallocate(this%fixedVal)\n end subroutine freeDof\n\n pure real(rkind) function getVal(this)\n implicit none\n class(DofDT), intent(in) :: this\n if(this%isFixed) then\n getVal = this%fixedVal\n else\n getVal = this%val\n end if\n end function getVal\n\n pure function getName(this)\n implicit none\n class(DofDT), intent(in) :: this\n character(:), allocatable :: getName\n getName = this%name\n end function getName\n \nend module DofM\n","avg_line_length":27.6637931034,"max_line_length":62,"alphanum_fraction":0.6388282954} {"size":181198,"ext":"f90","lang":"FORTRAN","max_stars_count":29.0,"content":"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n! Copyright (c) 2021 Advanced Micro Devices, Inc.\n!\n! Permission is hereby granted, free of charge, to any person obtaining a copy\n! of this software and associated documentation files (the \"Software\"), to deal\n! in the Software without restriction, including without limitation the rights\n! to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n! copies of the Software, and to permit persons to whom the Software is\n! furnished to do so, subject to the following conditions:\n!\n! The above copyright notice and this permission notice shall be included in\n! all copies or substantial portions of the Software.\n!\n! THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n! THE SOFTWARE.\n!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nmodule rocsparse\n use iso_c_binding\n\n! ===========================================================================\n! types SPARSE\n! ===========================================================================\n\n! rocsparse_operation\n enum, bind(c)\n enumerator :: rocsparse_operation_none = 111\n enumerator :: rocsparse_operation_transpose = 112\n enumerator :: rocsparse_operation_conjugate_transpose = 113\n end enum\n\n! rocsparse_index_base\n enum, bind(c)\n enumerator :: rocsparse_index_base_zero = 0\n enumerator :: rocsparse_index_base_one = 1\n end enum\n\n! rocsparse_matrix_type\n enum, bind(c)\n enumerator :: rocsparse_matrix_type_general = 0\n enumerator :: rocsparse_matrix_type_symmetric = 1\n enumerator :: rocsparse_matrix_type_hermitian = 2\n enumerator :: rocsparse_matrix_type_triangular = 3\n end enum\n\n! rocsparse_diag_type\n enum, bind(c)\n enumerator :: rocsparse_diag_type_non_unit = 0\n enumerator :: rocsparse_diag_type_unit = 1\n end enum\n\n! rocsparse_fill_mode\n enum, bind(c)\n enumerator :: rocsparse_fill_mode_lower = 0\n enumerator :: rocsparse_fill_mode_upper = 1\n end enum\n\n! rocsparse_action\n enum, bind(c)\n enumerator :: rocsparse_action_symbolic = 0\n enumerator :: rocsparse_action_numeric = 1\n end enum\n\n! rocsparse_direction\n enum, bind(c)\n enumerator :: rocsparse_direction_row = 0\n enumerator :: rocsparse_direction_column = 1\n end enum\n\n! rocsparse_hyb_partition\n enum, bind(c)\n enumerator :: rocsparse_hyb_partition_auto = 0\n enumerator :: rocsparse_hyb_partition_user = 1\n enumerator :: rocsparse_hyb_partition_max = 2\n end enum\n\n! rocsparse_analysis_policy\n enum, bind(c)\n enumerator :: rocsparse_analysis_policy_reuse = 0\n enumerator :: rocsparse_analysis_policy_force = 1\n end enum\n\n! rocsparse_solve_policy\n enum, bind(c)\n enumerator :: rocsparse_solve_policy_auto = 0\n end enum\n\n! rocsparse_pointer_mode\n enum, bind(c)\n enumerator :: rocsparse_pointer_mode_host = 0\n enumerator :: rocsparse_pointer_mode_device = 1\n end enum\n\n! rocsparse_layer_mode\n enum, bind(c)\n enumerator :: rocsparse_layer_mode_none = 0\n enumerator :: rocsparse_layer_mode_log_trace = 1\n enumerator :: rocsparse_layer_mode_log_bench = 2\n end enum\n\n! rocsparse_status\n enum, bind(c)\n enumerator :: rocsparse_status_success = 0\n enumerator :: rocsparse_status_invalid_handle = 1\n enumerator :: rocsparse_status_not_implemented = 2\n enumerator :: rocsparse_status_invalid_pointer = 3\n enumerator :: rocsparse_status_invalid_size = 4\n enumerator :: rocsparse_status_memory_error = 5\n enumerator :: rocsparse_status_internal_error = 6\n enumerator :: rocsparse_status_invalid_value = 7\n enumerator :: rocsparse_status_arch_mismatch = 8\n enumerator :: rocsparse_status_zero_pivot = 9\n end enum\n\n! ===========================================================================\n! auxiliary SPARSE\n! ===========================================================================\n\n interface\n\n! rocsparse_handle\n function rocsparse_create_handle(handle) &\n result(c_int) &\n bind(c, name = 'rocsparse_create_handle')\n use iso_c_binding\n implicit none\n type(c_ptr) :: handle\n end function rocsparse_create_handle\n\n function rocsparse_destroy_handle(handle) &\n result(c_int) &\n bind(c, name = 'rocsparse_destroy_handle')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n end function rocsparse_destroy_handle\n\n! rocsparse_stream\n function rocsparse_set_stream(handle, stream) &\n result(c_int) &\n bind(c, name = 'rocsparse_set_stream')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: stream\n end function rocsparse_set_stream\n\n function rocsparse_get_stream(handle, stream) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_stream')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr) :: stream\n end function\n\n! rocsparse_pointer_mode\n function rocsparse_set_pointer_mode(handle, pointer_mode) &\n result(c_int) &\n bind(c, name = 'rocsparse_set_pointer_mode')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: pointer_mode\n end function rocsparse_set_pointer_mode\n\n function rocsparse_get_pointer_mode(handle, pointer_mode) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_pointer_mode')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int) :: pointer_mode\n end function\n\n! rocsparse_version\n function rocsparse_get_version(handle, version) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_version')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int) :: version\n end function rocsparse_get_version\n\n function rocsparse_get_git_rev(handle, rev) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_git_rev')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n character(c_char) :: rev(*)\n end function rocsparse_get_git_rev\n\n! rocsparse_mat_descr\n function rocsparse_create_mat_descr(descr) &\n result(c_int) &\n bind(c, name = 'rocsparse_create_mat_descr')\n use iso_c_binding\n implicit none\n type(c_ptr) :: descr\n end function rocsparse_create_mat_descr\n\n function rocsparse_copy_mat_descr(dest, src) &\n result(c_int) &\n bind(c, name = 'rocsparse_copy_mat_descr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: dest\n type(c_ptr), intent(in), value :: src\n end function rocsparse_copy_mat_descr\n\n function rocsparse_destroy_mat_descr(descr) &\n result(c_int) &\n bind(c, name = 'rocsparse_destroy_mat_descr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: descr\n end function rocsparse_destroy_mat_descr\n\n! rocsparse_index_base\n function rocsparse_set_mat_index_base(descr, base) &\n result(c_int) &\n bind(c, name = 'rocsparse_set_mat_index_base')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: descr\n integer(c_int), value :: base\n end function rocsparse_set_mat_index_base\n\n function rocsparse_get_mat_index_base(descr) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_mat_index_base')\n use iso_c_binding\n implicit none\n type(c_ptr), intent(in), value :: descr\n end function rocsparse_get_mat_index_base\n\n! rocsparse_matrix_type\n function rocsparse_set_mat_type(descr, mat_type) &\n result(c_int) &\n bind(c, name = 'rocsparse_set_mat_type')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: descr\n integer(c_int), value :: mat_type\n end function rocsparse_set_mat_type\n\n function rocsparse_get_mat_type(descr) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_mat_type')\n use iso_c_binding\n implicit none\n type(c_ptr), intent(in), value :: descr\n end function rocsparse_get_mat_type\n\n! rocsparse_fill_mode\n function rocsparse_set_mat_fill_mode(descr, fill_mode) &\n result(c_int) &\n bind(c, name = 'rocsparse_set_mat_fill_mode')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: descr\n integer(c_int), value :: fill_mode\n end function rocsparse_set_mat_fill_mode\n\n function rocsparse_get_mat_fill_mode(descr) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_mat_fill_mode')\n use iso_c_binding\n implicit none\n type(c_ptr), intent(in), value :: descr\n end function rocsparse_get_mat_fill_mode\n\n! rocsparse_diag_type\n function rocsparse_set_mat_diag_type(descr, diag_type) &\n result(c_int) &\n bind(c, name = 'rocsparse_set_mat_diag_type')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: descr\n integer(c_int), value :: diag_type\n end function rocsparse_set_mat_diag_type\n\n function rocsparse_get_mat_diag_type(descr) &\n result(c_int) &\n bind(c, name = 'rocsparse_get_mat_diag_type')\n use iso_c_binding\n implicit none\n type(c_ptr), intent(in), value :: descr\n end function rocsparse_get_mat_diag_type\n\n! rocsparse_hyb_mat\n function rocsparse_create_hyb_mat(hyb) &\n result(c_int) &\n bind(c, name = 'rocsparse_create_hyb_mat')\n use iso_c_binding\n implicit none\n type(c_ptr) :: hyb\n end function rocsparse_create_hyb_mat\n\n function rocsparse_destroy_hyb_mat(hyb) &\n result(c_int) &\n bind(c, name = 'rocsparse_destroy_hyb_mat')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: hyb\n end function rocsparse_destroy_hyb_mat\n\n! rocsparse_mat_info\n function rocsparse_create_mat_info(info) &\n result(c_int) &\n bind(c, name = 'rocsparse_create_mat_info')\n use iso_c_binding\n implicit none\n type(c_ptr) :: info\n end function rocsparse_create_mat_info\n\n function rocsparse_destroy_mat_info(info) &\n result(c_int) &\n bind(c, name = 'rocsparse_destroy_mat_info')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: info\n end function rocsparse_destroy_mat_info\n\n! ===========================================================================\n! level 1 SPARSE\n! ===========================================================================\n\n! rocsparse_axpyi\n function rocsparse_saxpyi(handle, nnz, alpha, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_saxpyi')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_saxpyi\n\n function rocsparse_daxpyi(handle, nnz, alpha, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_daxpyi')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_daxpyi\n\n function rocsparse_caxpyi(handle, nnz, alpha, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_caxpyi')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_caxpyi\n\n function rocsparse_zaxpyi(handle, nnz, alpha, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_zaxpyi')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_zaxpyi\n\n! rocsparse_doti\n function rocsparse_sdoti(handle, nnz, x_val, x_ind, y, result, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_sdoti')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: result\n integer(c_int), value :: idx_base\n end function rocsparse_sdoti\n\n function rocsparse_ddoti(handle, nnz, x_val, x_ind, y, result, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_ddoti')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: result\n integer(c_int), value :: idx_base\n end function rocsparse_ddoti\n\n function rocsparse_cdoti(handle, nnz, x_val, x_ind, y, result, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_cdoti')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: result\n integer(c_int), value :: idx_base\n end function rocsparse_cdoti\n\n function rocsparse_zdoti(handle, nnz, x_val, x_ind, y, result, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_zdoti')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), intent(in), value :: y\n complex(c_double_complex) :: result\n integer(c_int), value :: idx_base\n end function rocsparse_zdoti\n\n! rocsparse_dotci\n function rocsparse_cdotci(handle, nnz, x_val, x_ind, y, result, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_cdotci')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: result\n integer(c_int), value :: idx_base\n end function rocsparse_cdotci\n\n function rocsparse_zdotci(handle, nnz, x_val, x_ind, y, result, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_zdotci')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: result\n integer(c_int), value :: idx_base\n end function rocsparse_zdotci\n\n! rocsparse_gthr\n function rocsparse_sgthr(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_sgthr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_sgthr\n\n function rocsparse_dgthr(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_dgthr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_dgthr\n\n function rocsparse_cgthr(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_cgthr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_cgthr\n\n function rocsparse_zgthr(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_zgthr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_zgthr\n\n! rocsparse_gthrz\n function rocsparse_sgthrz(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_sgthrz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_sgthrz\n\n function rocsparse_dgthrz(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_dgthrz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_dgthrz\n\n function rocsparse_cgthrz(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_cgthrz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_cgthrz\n\n function rocsparse_zgthrz(handle, nnz, y, x_val, x_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_zgthrz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: y\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n integer(c_int), value :: idx_base\n end function rocsparse_zgthrz\n\n! rocsparse_roti\n function rocsparse_sroti(handle, nnz, x_val, x_ind, y, c, s, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_sroti')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n type(c_ptr), intent(in), value :: c\n type(c_ptr), intent(in), value :: s\n integer(c_int), value :: idx_base\n end function rocsparse_sroti\n\n function rocsparse_droti(handle, nnz, x_val, x_ind, y, c, s, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_droti')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n type(c_ptr), intent(in), value :: c\n type(c_ptr), intent(in), value :: s\n integer(c_int), value :: idx_base\n end function rocsparse_droti\n\n! rocsparse_sctr\n function rocsparse_ssctr(handle, nnz, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_ssctr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_ssctr\n\n function rocsparse_dsctr(handle, nnz, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_dsctr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_dsctr\n\n function rocsparse_csctr(handle, nnz, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_csctr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_csctr\n\n function rocsparse_zsctr(handle, nnz, x_val, x_ind, y, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_zsctr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: x_val\n type(c_ptr), intent(in), value :: x_ind\n type(c_ptr), value :: y\n integer(c_int), value :: idx_base\n end function rocsparse_zsctr\n\n! ===========================================================================\n! level 2 SPARSE\n! ===========================================================================\n\n! rocsparse_bsrmv\n function rocsparse_sbsrmv(handle, dir, trans, mb, nb, nnzb, alpha, descr, &\n bsr_val, bsr_row_ptr, bsr_col_ind, bsr_dim, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_sbsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: trans\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n integer(c_int), value :: nnzb\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: bsr_dim\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_sbsrmv\n\n function rocsparse_dbsrmv(handle, dir, trans, mb, nb, nnzb, alpha, descr, &\n bsr_val, bsr_row_ptr, bsr_col_ind, bsr_dim, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_dbsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: trans\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n integer(c_int), value :: nnzb\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: bsr_dim\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_dbsrmv\n\n function rocsparse_cbsrmv(handle, dir, trans, mb, nb, nnzb, alpha, descr, &\n bsr_val, bsr_row_ptr, bsr_col_ind, bsr_dim, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_cbsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: trans\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n integer(c_int), value :: nnzb\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: bsr_dim\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_cbsrmv\n\n function rocsparse_zbsrmv(handle, dir, trans, mb, nb, nnzb, alpha, descr, &\n bsr_val, bsr_row_ptr, bsr_col_ind, bsr_dim, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_zbsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: trans\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n integer(c_int), value :: nnzb\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: bsr_dim\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_zbsrmv\n\n! rocsparse_coomv\n function rocsparse_scoomv(handle, trans, m, n, nnz, alpha, descr, coo_val, &\n coo_row_ind, coo_col_ind, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_scoomv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: coo_val\n type(c_ptr), intent(in), value :: coo_row_ind\n type(c_ptr), intent(in), value :: coo_col_ind\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_scoomv\n\n function rocsparse_dcoomv(handle, trans, m, n, nnz, alpha, descr, coo_val, &\n coo_row_ind, coo_col_ind, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcoomv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: coo_val\n type(c_ptr), intent(in), value :: coo_row_ind\n type(c_ptr), intent(in), value :: coo_col_ind\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_dcoomv\n\n function rocsparse_ccoomv(handle, trans, m, n, nnz, alpha, descr, coo_val, &\n coo_row_ind, coo_col_ind, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccoomv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: coo_val\n type(c_ptr), intent(in), value :: coo_row_ind\n type(c_ptr), intent(in), value :: coo_col_ind\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_ccoomv\n\n function rocsparse_zcoomv(handle, trans, m, n, nnz, alpha, descr, coo_val, &\n coo_row_ind, coo_col_ind, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcoomv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: coo_val\n type(c_ptr), intent(in), value :: coo_row_ind\n type(c_ptr), intent(in), value :: coo_col_ind\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_zcoomv\n\n! rocsparse_csrmv_analysis\n function rocsparse_scsrmv_analysis(handle, trans, m, n, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrmv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n end function rocsparse_scsrmv_analysis\n\n function rocsparse_dcsrmv_analysis(handle, trans, m, n, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrmv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n end function rocsparse_dcsrmv_analysis\n\n function rocsparse_ccsrmv_analysis(handle, trans, m, n, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrmv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), intent(in), value :: handle\n integer(c_int), intent(in), value :: trans\n integer(c_int), intent(in), value :: m\n integer(c_int), intent(in), value :: n\n integer(c_int), intent(in), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n end function rocsparse_ccsrmv_analysis\n\n function rocsparse_zcsrmv_analysis(handle, trans, m, n, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrmv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n end function rocsparse_zcsrmv_analysis\n\n! rocsparse_csrmv_clear\n function rocsparse_csrmv_clear(handle, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrmv_clear')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n end function rocsparse_csrmv_clear\n\n! rocsparse_csrmv\n function rocsparse_scsrmv(handle, trans, m, n, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_scsrmv\n\n function rocsparse_dcsrmv(handle, trans, m, n, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_dcsrmv\n\n function rocsparse_ccsrmv(handle, trans, m, n, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_ccsrmv\n\n function rocsparse_zcsrmv(handle, trans, m, n, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_zcsrmv\n\n! rocsparse_csrsv_zero_pivot\n function rocsparse_csrsv_zero_pivot(handle, descr, info, position) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrsv_zero_pivot')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), value :: info\n type(c_ptr), value :: position\n end function rocsparse_csrsv_zero_pivot\n\n! rocsparse_csrsv_buffer_size\n function rocsparse_scsrsv_buffer_size(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrsv_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_scsrsv_buffer_size\n\n function rocsparse_dcsrsv_buffer_size(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrsv_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_dcsrsv_buffer_size\n\n function rocsparse_ccsrsv_buffer_size(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrsv_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_ccsrsv_buffer_size\n\n function rocsparse_zcsrsv_buffer_size(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrsv_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_zcsrsv_buffer_size\n\n! rocsparse_csrsv_analysis\n function rocsparse_scsrsv_analysis(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrsv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrsv_analysis\n\n function rocsparse_dcsrsv_analysis(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrsv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrsv_analysis\n\n function rocsparse_ccsrsv_analysis(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrsv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrsv_analysis\n\n function rocsparse_zcsrsv_analysis(handle, trans, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrsv_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrsv_analysis\n\n! rocsparse_csrsv_clear\n function rocsparse_csrsv_clear(handle, descr, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrsv_clear')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), value :: info\n end function rocsparse_csrsv_clear\n\n! rocsparse_csrsv_solve\n function rocsparse_scsrsv_solve(handle, trans, m, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, y, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrsv_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), value :: y\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrsv_solve\n\n function rocsparse_dcsrsv_solve(handle, trans, m, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, y, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrsv_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), value :: y\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrsv_solve\n\n function rocsparse_ccsrsv_solve(handle, trans, m, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, y, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrsv_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), value :: y\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrsv_solve\n\n function rocsparse_zcsrsv_solve(handle, trans, m, nnz, alpha, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, x, y, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrsv_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n compleX(c_double_complex), intent(in) :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), intent(in), value :: x\n type(c_ptr), value :: y\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrsv_solve\n\n! rocsparse_ellmv\n function rocsparse_sellmv(handle, trans, m, n, alpha, descr, ell_val, &\n ell_col_ind, ell_width, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_sellmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_sellmv\n\n function rocsparse_dellmv(handle, trans, m, n, alpha, descr, ell_val, &\n ell_col_ind, ell_width, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_dellmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_dellmv\n\n function rocsparse_cellmv(handle, trans, m, n, alpha, descr, ell_val, &\n ell_col_ind, ell_width, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_cellmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_cellmv\n\n function rocsparse_zellmv(handle, trans, m, n, alpha, descr, ell_val, &\n ell_col_ind, ell_width, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_zellmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_zellmv\n\n! rocsparse_hybmv\n function rocsparse_shybmv(handle, trans, alpha, descr, hyb, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_shybmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_shybmv\n\n function rocsparse_dhybmv(handle, trans, alpha, descr, hyb, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_dhybmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_dhybmv\n\n function rocsparse_chybmv(handle, trans, alpha, descr, hyb, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_chybmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_chybmv\n\n function rocsparse_zhybmv(handle, trans, alpha, descr, hyb, x, beta, y) &\n result(c_int) &\n bind(c, name = 'rocsparse_zhybmv')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), intent(in), value :: x\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: y\n end function rocsparse_zhybmv\n\n! ===========================================================================\n! level 3 SPARSE\n! ===========================================================================\n\n! rocsparse_csrmm\n function rocsparse_scsrmm(handle, trans_A, trans_B, m, n, k, nnz, alpha, descr, &\n csr_val, csr_row_ptr, csr_col_ind, B, ldb, beta, C, ldc) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrmm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: C\n integer(c_int), value :: ldc\n end function rocsparse_scsrmm\n\n function rocsparse_dcsrmm(handle, trans_A, trans_B, m, n, k, nnz, alpha, descr, &\n csr_val, csr_row_ptr, csr_col_ind, B, ldb, beta, C, ldc) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrmm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: C\n integer(c_int), value :: ldc\n end function rocsparse_dcsrmm\n\n function rocsparse_ccsrmm(handle, trans_A, trans_B, m, n, k, nnz, alpha, descr, &\n csr_val, csr_row_ptr, csr_col_ind, B, ldb, beta, C, ldc) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrmm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: C\n integer(c_int), value :: ldc\n end function rocsparse_ccsrmm\n\n function rocsparse_zcsrmm(handle, trans_A, trans_B, m, n, k, nnz, alpha, descr, &\n csr_val, csr_row_ptr, csr_col_ind, B, ldb, beta, C, ldc) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrmm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), value :: C\n integer(c_int), value :: ldc\n end function rocsparse_zcsrmm\n\n! rocsparse_csrsm_zero_pivot\n function rocsparse_csrsm_zero_pivot(handle, info, position) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrsm_zero_pivot')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n type(c_ptr), value :: position\n end function rocsparse_csrsm_zero_pivot\n\n! rocsparse_csrsm_buffer_size\n function rocsparse_scsrsm_buffer_size(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrsm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: buffer_size\n end function rocsparse_scsrsm_buffer_size\n\n function rocsparse_dcsrsm_buffer_size(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrsm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: buffer_size\n end function rocsparse_dcsrsm_buffer_size\n\n function rocsparse_ccsrsm_buffer_size(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrsm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: buffer_size\n end function rocsparse_ccsrsm_buffer_size\n\n function rocsparse_zcsrsm_buffer_size(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrsm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: buffer_size\n end function rocsparse_zcsrsm_buffer_size\n\n! rocsparse_csrsm_analysis\n function rocsparse_scsrsm_analysis(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, &\n analysis, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrsm_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrsm_analysis\n\n function rocsparse_dcsrsm_analysis(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, &\n analysis, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrsm_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrsm_analysis\n\n function rocsparse_ccsrsm_analysis(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, &\n analysis, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrsm_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrsm_analysis\n\n function rocsparse_zcsrsm_analysis(handle, trans_A, trans_B, m, nrhs, nnz, &\n alpha, descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, &\n analysis, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrsm_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrsm_analysis\n\n! rocsparse_csrsm_clear\n function rocsparse_csrsm_clear(handle, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrsm_clear')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n end function rocsparse_csrsm_clear\n\n! rocsparse_csrsm_solve\n function rocsparse_scsrsm_solve(handle, trans_A, trans_B, m, nrhs, nnz, alpha, &\n descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrsm_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrsm_solve\n\n function rocsparse_dcsrsm_solve(handle, trans_A, trans_B, m, nrhs, nnz, alpha, &\n descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrsm_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrsm_solve\n\n function rocsparse_ccsrsm_solve(handle, trans_A, trans_B, m, nrhs, nnz, alpha, &\n descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrsm_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrsm_solve\n\n function rocsparse_zcsrsm_solve(handle, trans_A, trans_B, m, nrhs, nnz, alpha, &\n descr, csr_val, csr_row_ptr, csr_col_ind, B, ldb, info, policy, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrsm_solve')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: nrhs\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: B\n integer(c_int), value :: ldb\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrsm_solve\n\n! ===========================================================================\n! extra SPARSE\n! ===========================================================================\n\n! rocsparse_csrgeam_nnz\n function rocsparse_csrgeam_nnz(handle, m, n, descr_A, nnz_A, csr_row_ptr_A, &\n csr_col_ind_A, descr_B, nnz_B, csr_row_ptr_B, csr_col_ind_B, descr_C, &\n csr_row_ptr_C, nnz_C) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrgeam_nnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_row_ptr_C\n type(c_ptr), value :: nnz_C\n end function rocsparse_csrgeam_nnz\n\n! rocsparse_csrgeam\n function rocsparse_scsrgeam(handle, m, n, alpha, descr_A, nnz_A, csr_val_A, &\n csr_row_ptr_A, csr_col_ind_A, beta, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, descr_C, csr_val_C, csr_row_ptr_C, &\n csr_col_ind_C) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrgeam')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n end function rocsparse_scsrgeam\n\n function rocsparse_dcsrgeam(handle, m, n, alpha, descr_A, nnz_A, csr_val_A, &\n csr_row_ptr_A, csr_col_ind_A, beta, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, descr_C, csr_val_C, csr_row_ptr_C, &\n csr_col_ind_C) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrgeam')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n end function rocsparse_dcsrgeam\n\n function rocsparse_ccsrgeam(handle, m, n, alpha, descr_A, nnz_A, csr_val_A, &\n csr_row_ptr_A, csr_col_ind_A, beta, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, descr_C, csr_val_C, csr_row_ptr_C, &\n csr_col_ind_C) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrgeam')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n end function rocsparse_ccsrgeam\n\n function rocsparse_zcsrgeam(handle, m, n, alpha, descr_A, nnz_A, csr_val_A, &\n csr_row_ptr_A, csr_col_ind_A, beta, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, descr_C, csr_val_C, csr_row_ptr_C, &\n csr_col_ind_C) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrgeam')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n end function rocsparse_zcsrgeam\n\n! rocsparse_csrgemm_buffer_size\n function rocsparse_scsrgemm_buffer_size(handle, trans_A, trans_B, m, n, k, alpha, &\n descr_A, nnz_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_row_ptr_B, &\n csr_col_ind_B, beta, descr_D, nnz_D, csr_row_ptr_D, csr_col_ind_D, info_C, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrgemm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), value :: info_C\n type(c_ptr), value :: buffer_size\n end function rocsparse_scsrgemm_buffer_size\n\n function rocsparse_dcsrgemm_buffer_size(handle, trans_A, trans_B, m, n, k, alpha, &\n descr_A, nnz_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_row_ptr_B, &\n csr_col_ind_B, beta, descr_D, nnz_D, csr_row_ptr_D, csr_col_ind_D, info_C, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrgemm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), value :: info_C\n type(c_ptr), value :: buffer_size\n end function rocsparse_dcsrgemm_buffer_size\n\n function rocsparse_ccsrgemm_buffer_size(handle, trans_A, trans_B, m, n, k, alpha, &\n descr_A, nnz_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_row_ptr_B, &\n csr_col_ind_B, beta, descr_D, nnz_D, csr_row_ptr_D, csr_col_ind_D, info_C, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrgemm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), value :: info_C\n type(c_ptr), value :: buffer_size\n end function rocsparse_ccsrgemm_buffer_size\n\n function rocsparse_zcsrgemm_buffer_size(handle, trans_A, trans_B, m, n, k, alpha, &\n descr_A, nnz_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_row_ptr_B, &\n csr_col_ind_B, beta, descr_D, nnz_D, csr_row_ptr_D, csr_col_ind_D, info_C, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrgemm_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), value :: info_C\n type(c_ptr), value :: buffer_size\n end function rocsparse_zcsrgemm_buffer_size\n\n! rocsparse_csrgemm_nnz\n function rocsparse_csrgemm_nnz(handle, trans_A, trans_B, m, n, k, descr_A, &\n nnz_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_row_ptr_B, &\n csr_col_ind_B, descr_D, nnz_D, csr_row_ptr_D, csr_col_ind_D, descr_C, &\n csr_row_ptr_C, nnz_C, info_C, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrgemm_nnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_row_ptr_C\n type(c_ptr), value :: nnz_C\n type(c_ptr), intent(in), value :: info_C\n type(c_ptr), value :: temp_buffer\n end function rocsparse_csrgemm_nnz\n\n! rocsparse_csrgemm\n function rocsparse_scsrgemm(handle, trans_A, trans_B, m, n, k, alpha, descr_A, &\n nnz_A, csr_val_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, beta, descr_D, nnz_D, csr_val_D, csr_row_ptr_D, &\n csr_col_ind_D, descr_C, csr_val_C, csr_row_ptr_C, csr_col_ind_C, info_C, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrgemm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_val_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), intent(in), value :: info_C\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrgemm\n\n function rocsparse_dcsrgemm(handle, trans_A, trans_B, m, n, k, alpha, descr_A, &\n nnz_A, csr_val_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, beta, descr_D, nnz_D, csr_val_D, csr_row_ptr_D, &\n csr_col_ind_D, descr_C, csr_val_C, csr_row_ptr_C, csr_col_ind_C, info_C, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrgemm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_val_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), intent(in), value :: info_C\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrgemm\n\n function rocsparse_ccsrgemm(handle, trans_A, trans_B, m, n, k, alpha, descr_A, &\n nnz_A, csr_val_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, beta, descr_D, nnz_D, csr_val_D, csr_row_ptr_D, &\n csr_col_ind_D, descr_C, csr_val_C, csr_row_ptr_C, csr_col_ind_C, info_C, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrgemm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_val_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), intent(in), value :: info_C\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrgemm\n\n function rocsparse_zcsrgemm(handle, trans_A, trans_B, m, n, k, alpha, descr_A, &\n nnz_A, csr_val_A, csr_row_ptr_A, csr_col_ind_A, descr_B, nnz_B, csr_val_B, &\n csr_row_ptr_B, csr_col_ind_B, beta, descr_D, nnz_D, csr_val_D, csr_row_ptr_D, &\n csr_col_ind_D, descr_C, csr_val_C, csr_row_ptr_C, csr_col_ind_C, info_C, &\n temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrgemm')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: trans_A\n integer(c_int), value :: trans_B\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: k\n type(c_ptr), intent(in), value :: alpha\n type(c_ptr), intent(in), value :: descr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: descr_B\n integer(c_int), value :: nnz_B\n type(c_ptr), intent(in), value :: csr_val_B\n type(c_ptr), intent(in), value :: csr_row_ptr_B\n type(c_ptr), intent(in), value :: csr_col_ind_B\n type(c_ptr), intent(in), value :: beta\n type(c_ptr), intent(in), value :: descr_D\n integer(c_int), value :: nnz_D\n type(c_ptr), intent(in), value :: csr_val_D\n type(c_ptr), intent(in), value :: csr_row_ptr_D\n type(c_ptr), intent(in), value :: csr_col_ind_D\n type(c_ptr), intent(in), value :: descr_C\n type(c_ptr), value :: csr_val_C\n type(c_ptr), intent(in), value :: csr_row_ptr_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), intent(in), value :: info_C\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrgemm\n\n! ===========================================================================\n! preconditioner SPARSE\n! ===========================================================================\n\n! rocsparse_csric0_zero_pivot\n function rocsparse_csric0_zero_pivot(handle, info, position) &\n result(c_int) &\n bind(c, name = 'rocsparse_csric0_zero_pivot')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n type(c_ptr), value :: position\n end function rocsparse_csric0_zero_pivot\n\n! rocsparse_csric0_buffer_size\n function rocsparse_scsric0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsric0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_scsric0_buffer_size\n\n function rocsparse_dcsric0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsric0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_dcsric0_buffer_size\n\n function rocsparse_ccsric0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsric0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_ccsric0_buffer_size\n\n function rocsparse_zcsric0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsric0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_zcsric0_buffer_size\n\n! rocsparse_csric0_analysis\n function rocsparse_scsric0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsric0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsric0_analysis\n\n function rocsparse_dcsric0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsric0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsric0_analysis\n\n function rocsparse_ccsric0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsric0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsric0_analysis\n\n function rocsparse_zcsric0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsric0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsric0_analysis\n\n! rocsparse_csric0_clear\n function rocsparse_csric0_clear(handle, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_csric0_clear')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n end function rocsparse_csric0_clear\n\n! rocsparse_csric0\n function rocsparse_scsric0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsric0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsric0\n\n function rocsparse_dcsric0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsric0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsric0\n\n function rocsparse_ccsric0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsric0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsric0\n\n function rocsparse_zcsric0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsric0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsric0\n\n! rocsparse_csrilu0_zero_pivot\n function rocsparse_csrilu0_zero_pivot(handle, info, position) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrilu0_zero_pivot')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n type(c_ptr), value :: position\n end function rocsparse_csrilu0_zero_pivot\n\n! rocsparse_csrilu0_buffer_size\n function rocsparse_scsrilu0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrilu0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_scsrilu0_buffer_size\n\n function rocsparse_dcsrilu0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrilu0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_dcsrilu0_buffer_size\n\n function rocsparse_ccsrilu0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrilu0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_ccsrilu0_buffer_size\n\n function rocsparse_zcsrilu0_buffer_size(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrilu0_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n type(c_ptr), value :: buffer_size\n end function rocsparse_zcsrilu0_buffer_size\n\n! rocsparse_csrilu0_analysis\n function rocsparse_scsrilu0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrilu0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrilu0_analysis\n\n function rocsparse_dcsrilu0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrilu0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrilu0_analysis\n\n function rocsparse_ccsrilu0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrilu0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrilu0_analysis\n\n function rocsparse_zcsrilu0_analysis(handle, m, nnz, descr, csr_val, &\n csr_row_ptr, csr_col_ind, info, analysis, solve, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrilu0_analysis')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: analysis\n integer(c_int), value :: solve\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrilu0_analysis\n\n! rocsparse_csrilu0_clear\n function rocsparse_csrilu0_clear(handle, info) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrilu0_clear')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), value :: info\n end function rocsparse_csrilu0_clear\n\n! rocsparse_csrilu0\n function rocsparse_scsrilu0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsrilu0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsrilu0\n\n function rocsparse_dcsrilu0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsrilu0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsrilu0\n\n function rocsparse_ccsrilu0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsrilu0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsrilu0\n\n function rocsparse_zcsrilu0(handle, m, nnz, descr, csr_val, csr_row_ptr, &\n csr_col_ind, info, policy, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsrilu0')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: info\n integer(c_int), value :: policy\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsrilu0\n\n! ===========================================================================\n! conversion SPARSE\n! ===========================================================================\n\n! rocsparse_nnz\n function rocsparse_snnz(handle, dir, m, n, descr, A, ld, nnz_per_row_columns, &\n nnz_total_dev_host_ptr) &\n result(c_int) &\n bind(c, name = 'rocsparse_snnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), value :: nnz_per_row_columns\n type(c_ptr), value :: nnz_total_dev_host_ptr\n end function rocsparse_snnz\n\n function rocsparse_dnnz(handle, dir, m, n, descr, A, ld, nnz_per_row_columns, &\n nnz_total_dev_host_ptr) &\n result(c_int) &\n bind(c, name = 'rocsparse_dnnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), value :: nnz_per_row_columns\n type(c_ptr), value :: nnz_total_dev_host_ptr\n end function rocsparse_dnnz\n\n function rocsparse_cnnz(handle, dir, m, n, descr, A, ld, nnz_per_row_columns, &\n nnz_total_dev_host_ptr) &\n result(c_int) &\n bind(c, name = 'rocsparse_cnnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), value :: nnz_per_row_columns\n type(c_ptr), value :: nnz_total_dev_host_ptr\n end function rocsparse_cnnz\n\n function rocsparse_znnz(handle, dir, m, n, descr, A, ld, nnz_per_row_columns, &\n nnz_total_dev_host_ptr) &\n result(c_int) &\n bind(c, name = 'rocsparse_znnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), value :: nnz_per_row_columns\n type(c_ptr), value :: nnz_total_dev_host_ptr\n end function rocsparse_znnz\n\n! rocsparse_dense2csr\n function rocsparse_sdense2csr(handle, m, n, descr, A, ld, nnz_per_rows, csr_val, &\n csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_sdense2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_rows\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_sdense2csr\n\n function rocsparse_ddense2csr(handle, m, n, descr, A, ld, nnz_per_rows, csr_val, &\n csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_ddense2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_rows\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_ddense2csr\n\n function rocsparse_cdense2csr(handle, m, n, descr, A, ld, nnz_per_rows, csr_val, &\n csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_cdense2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_rows\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_cdense2csr\n\n function rocsparse_zdense2csr(handle, m, n, descr, A, ld, nnz_per_rows, csr_val, &\n csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_zdense2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_rows\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_zdense2csr\n\n! rocsparse_dense2csc\n function rocsparse_sdense2csc(handle, m, n, descr, A, ld, nnz_per_columns, &\n csc_val, csc_col_ptr, csc_row_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_sdense2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_columns\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_col_ptr\n type(c_ptr), value :: csc_row_ind\n end function rocsparse_sdense2csc\n\n function rocsparse_ddense2csc(handle, m, n, descr, A, ld, nnz_per_columns, &\n csc_val, csc_col_ptr, csc_row_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_ddense2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_columns\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_col_ptr\n type(c_ptr), value :: csc_row_ind\n end function rocsparse_ddense2csc\n\n function rocsparse_cdense2csc(handle, m, n, descr, A, ld, nnz_per_columns, &\n csc_val, csc_col_ptr, csc_row_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_cdense2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_columns\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_col_ptr\n type(c_ptr), value :: csc_row_ind\n end function rocsparse_cdense2csc\n\n function rocsparse_zdense2csc(handle, m, n, descr, A, ld, nnz_per_columns, &\n csc_val, csc_col_ptr, csc_row_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_zdense2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: A\n integer(c_int), value :: ld\n type(c_ptr), intent(in), value :: nnz_per_columns\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_col_ptr\n type(c_ptr), value :: csc_row_ind\n end function rocsparse_zdense2csc\n\n! rocsparse_csr2dense\n function rocsparse_scsr2dense(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsr2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_scsr2dense\n\n function rocsparse_dcsr2dense(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsr2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_dcsr2dense\n\n function rocsparse_ccsr2dense(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsr2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_ccsr2dense\n\n function rocsparse_zcsr2dense(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsr2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_zcsr2dense\n\n! rocsparse_csc2dense\n function rocsparse_scsc2dense(handle, m, n, descr, csc_val, csc_col_ptr, &\n csc_row_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsc2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csc_val\n type(c_ptr), intent(in), value :: csc_col_ptr\n type(c_ptr), intent(in), value :: csc_row_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_scsc2dense\n\n function rocsparse_dcsc2dense(handle, m, n, descr, csc_val, csc_col_ptr, &\n csc_row_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsc2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csc_val\n type(c_ptr), intent(in), value :: csc_col_ptr\n type(c_ptr), intent(in), value :: csc_row_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_dcsc2dense\n\n function rocsparse_ccsc2dense(handle, m, n, descr, csc_val, csc_col_ptr, &\n csc_row_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsc2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csc_val\n type(c_ptr), intent(in), value :: csc_col_ptr\n type(c_ptr), intent(in), value :: csc_row_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_ccsc2dense\n\n function rocsparse_zcsc2dense(handle, m, n, descr, csc_val, csc_col_ptr, &\n csc_row_ind, A, ld) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsc2dense')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csc_val\n type(c_ptr), intent(in), value :: csc_col_ptr\n type(c_ptr), intent(in), value :: csc_row_ind\n type(c_ptr), value :: A\n integer(c_int), value :: ld\n end function rocsparse_zcsc2dense\n\n! rocsparse_nnz_compress\n function rocsparse_snnz_compress(handle, m, descr_A, csr_val_A, csr_row_ptr_A, &\n nnz_per_row, nnz_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_snnz_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), value :: nnz_per_row\n type(c_ptr), value :: nnz_C\n real(c_float), value :: tol\n end function rocsparse_snnz_compress\n\n function rocsparse_dnnz_compress(handle, m, descr_A, csr_val_A, csr_row_ptr_A, &\n nnz_per_row, nnz_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_dnnz_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), value :: nnz_per_row\n type(c_ptr), value :: nnz_C\n real(c_double), value :: tol\n end function rocsparse_dnnz_compress\n\n function rocsparse_cnnz_compress(handle, m, descr_A, csr_val_A, csr_row_ptr_A, &\n nnz_per_row, nnz_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_cnnz_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), value :: nnz_per_row\n type(c_ptr), value :: nnz_C\n complex(c_float_complex), value :: tol\n end function rocsparse_cnnz_compress\n\n function rocsparse_znnz_compress(handle, m, descr_A, csr_val_A, csr_row_ptr_A, &\n nnz_per_row, nnz_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_znnz_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n type(c_ptr), value :: nnz_per_row\n type(c_ptr), value :: nnz_C\n complex(c_double_complex), value :: tol\n end function rocsparse_znnz_compress\n\n! rocsparse_csr2coo\n function rocsparse_csr2coo(handle, csr_row_ptr, nnz, m, coo_row_ind, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_csr2coo')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: csr_row_ptr\n integer(c_int), value :: nnz\n integer(c_int), value :: m\n type(c_ptr), value :: coo_row_ind\n integer(c_int), value :: idx_base\n end function rocsparse_csr2coo\n\n! rocsparse_csr2csc_buffer_size\n function rocsparse_csr2csc_buffer_size(handle, m, n, nnz, csr_row_ptr, &\n csr_col_ind, copy_values, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_csr2csc_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n integer(c_int), value :: copy_values\n type(c_ptr), value :: buffer_size\n end function rocsparse_csr2csc_buffer_size\n\n! rocsparse_csr2csc\n function rocsparse_scsr2csc(handle, m, n, nnz, csr_val, csr_row_ptr, &\n csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, &\n idx_base, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsr2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_row_ind\n type(c_ptr), value :: csc_col_ptr\n integer(c_int), value :: copy_values\n integer(c_int), value :: idx_base\n type(c_ptr), value :: temp_buffer\n end function rocsparse_scsr2csc\n\n function rocsparse_dcsr2csc(handle, m, n, nnz, csr_val, csr_row_ptr, &\n csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, &\n idx_base, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsr2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_row_ind\n type(c_ptr), value :: csc_col_ptr\n integer(c_int), value :: copy_values\n integer(c_int), value :: idx_base\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dcsr2csc\n\n function rocsparse_ccsr2csc(handle, m, n, nnz, csr_val, csr_row_ptr, &\n csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, &\n idx_base, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsr2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_row_ind\n type(c_ptr), value :: csc_col_ptr\n integer(c_int), value :: copy_values\n integer(c_int), value :: idx_base\n type(c_ptr), value :: temp_buffer\n end function rocsparse_ccsr2csc\n\n function rocsparse_zcsr2csc(handle, m, n, nnz, csr_val, csr_row_ptr, &\n csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, &\n idx_base, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsr2csc')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: csc_val\n type(c_ptr), value :: csc_row_ind\n type(c_ptr), value :: csc_col_ptr\n integer(c_int), value :: copy_values\n integer(c_int), value :: idx_base\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zcsr2csc\n\n! rocsparse_csr2ell_width\n function rocsparse_csr2ell_width(handle, m, csr_descr, csr_row_ptr, &\n ell_descr, ell_width) &\n result(c_int) &\n bind(c, name = 'rocsparse_csr2ell_width')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: ell_descr\n type(c_ptr), value :: ell_width\n end function rocsparse_csr2ell_width\n\n! rocsparse_csr2ell\n function rocsparse_scsr2ell(handle, m, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, ell_descr, ell_width, ell_val, ell_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsr2ell')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), value :: ell_val\n type(c_ptr), value :: ell_col_ind\n end function rocsparse_scsr2ell\n\n function rocsparse_dcsr2ell(handle, m, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, ell_descr, ell_width, ell_val, ell_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsr2ell')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), value :: ell_val\n type(c_ptr), value :: ell_col_ind\n end function rocsparse_dcsr2ell\n\n function rocsparse_ccsr2ell(handle, m, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, ell_descr, ell_width, ell_val, ell_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsr2ell')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), value :: ell_val\n type(c_ptr), value :: ell_col_ind\n end function rocsparse_ccsr2ell\n\n function rocsparse_zcsr2ell(handle, m, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, ell_descr, ell_width, ell_val, ell_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsr2ell')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), value :: ell_val\n type(c_ptr), value :: ell_col_ind\n end function rocsparse_zcsr2ell\n\n! rocsparse_csr2hyb\n function rocsparse_scsr2hyb(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, hyb, user_ell_width, partition_type) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsr2hyb')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: hyb\n integer(c_int), value :: user_ell_width\n integer(c_int), value :: partition_type\n end function rocsparse_scsr2hyb\n\n function rocsparse_dcsr2hyb(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, hyb, user_ell_width, partition_type) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsr2hyb')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: hyb\n integer(c_int), value :: user_ell_width\n integer(c_int), value :: partition_type\n end function rocsparse_dcsr2hyb\n\n function rocsparse_ccsr2hyb(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, hyb, user_ell_width, partition_type) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsr2hyb')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: hyb\n integer(c_int), value :: user_ell_width\n integer(c_int), value :: partition_type\n end function rocsparse_ccsr2hyb\n\n function rocsparse_zcsr2hyb(handle, m, n, descr, csr_val, csr_row_ptr, &\n csr_col_ind, hyb, user_ell_width, partition_type) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsr2hyb')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: hyb\n integer(c_int), value :: user_ell_width\n integer(c_int), value :: partition_type\n end function rocsparse_zcsr2hyb\n\n! rocsparse_csr2bsr_nnz\n function rocsparse_csr2bsr_nnz(handle, dir, m, n, csr_descr, csr_row_ptr, &\n csr_col_ind, block_dim, bsr_descr, bsr_row_ptr, bsr_nnz) &\n result(c_int) &\n bind(c, name = 'rocsparse_csr2bsr_nnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), value :: bsr_row_ptr\n type(c_ptr), value :: bsr_nnz\n end function rocsparse_csr2bsr_nnz\n\n! rocsparse_csr2bsr\n function rocsparse_scsr2bsr(handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsr2bsr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), value :: bsr_val\n type(c_ptr), value :: bsr_row_ptr\n type(c_ptr), value :: bsr_col_ind\n end function rocsparse_scsr2bsr\n\n function rocsparse_dcsr2bsr(handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsr2bsr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), value :: bsr_val\n type(c_ptr), value :: bsr_row_ptr\n type(c_ptr), value :: bsr_col_ind\n end function rocsparse_dcsr2bsr\n\n function rocsparse_ccsr2bsr(handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsr2bsr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), value :: bsr_val\n type(c_ptr), value :: bsr_row_ptr\n type(c_ptr), value :: bsr_col_ind\n end function rocsparse_ccsr2bsr\n\n function rocsparse_zcsr2bsr(handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, &\n csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsr2bsr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), intent(in), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), value :: bsr_val\n type(c_ptr), value :: bsr_row_ptr\n type(c_ptr), value :: bsr_col_ind\n end function rocsparse_zcsr2bsr\n\n! rocsparse_csr2csr_compress\n function rocsparse_scsr2csr_compress(handle, m, n, descr_A, csr_val_A, &\n csr_col_ind_A, csr_row_ptr_A, nnz_A, nnz_per_row, csr_val_C, &\n csr_col_ind_C, csr_row_ptr_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_scsr2csr_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: nnz_per_row\n type(c_ptr), value :: csr_val_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), value :: csr_row_ptr_C\n real(c_float), value :: tol\n end function rocsparse_scsr2csr_compress\n\n function rocsparse_dcsr2csr_compress(handle, m, n, descr_A, csr_val_A, &\n csr_col_ind_A, csr_row_ptr_A, nnz_A, nnz_per_row, csr_val_C, &\n csr_col_ind_C, csr_row_ptr_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_dcsr2csr_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: nnz_per_row\n type(c_ptr), value :: csr_val_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), value :: csr_row_ptr_C\n real(c_float), value :: tol\n end function rocsparse_dcsr2csr_compress\n\n function rocsparse_ccsr2csr_compress(handle, m, n, descr_A, csr_val_A, &\n csr_col_ind_A, csr_row_ptr_A, nnz_A, nnz_per_row, csr_val_C, &\n csr_col_ind_C, csr_row_ptr_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_ccsr2csr_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: nnz_per_row\n type(c_ptr), value :: csr_val_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), value :: csr_row_ptr_C\n real(c_float), value :: tol\n end function rocsparse_ccsr2csr_compress\n\n function rocsparse_zcsr2csr_compress(handle, m, n, descr_A, csr_val_A, &\n csr_col_ind_A, csr_row_ptr_A, nnz_A, nnz_per_row, csr_val_C, &\n csr_col_ind_C, csr_row_ptr_C, tol) &\n result(c_int) &\n bind(c, name = 'rocsparse_zcsr2csr_compress')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: descr_A\n type(c_ptr), intent(in), value :: csr_val_A\n type(c_ptr), intent(in), value :: csr_col_ind_A\n type(c_ptr), intent(in), value :: csr_row_ptr_A\n integer(c_int), value :: nnz_A\n type(c_ptr), intent(in), value :: nnz_per_row\n type(c_ptr), value :: csr_val_C\n type(c_ptr), value :: csr_col_ind_C\n type(c_ptr), value :: csr_row_ptr_C\n real(c_float), value :: tol\n end function rocsparse_zcsr2csr_compress\n\n! rocsparse_coo2csr\n function rocsparse_coo2csr(handle, coo_row_ind, nnz, m, csr_row_ptr, idx_base) &\n result(c_int) &\n bind(c, name = 'rocsparse_coo2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: coo_row_ind\n integer(c_int), value :: nnz\n integer(c_int), value :: m\n type(c_ptr), value :: csr_row_ptr\n integer(c_int), value :: idx_base\n end function rocsparse_coo2csr\n\n! rocsparse_ell2csr_nnz\n function rocsparse_ell2csr_nnz(handle, m, n, ell_descr, ell_width, ell_col_ind, &\n csr_descr, csr_row_ptr, csr_nnz) &\n result(c_int) &\n bind(c, name = 'rocsparse_ell2csr_nnz')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: ell_col_ind\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_nnz\n end function rocsparse_ell2csr_nnz\n\n! rocsparse_ell2csr\n function rocsparse_sell2csr(handle, m, n, ell_descr, ell_width, ell_val, &\n ell_col_ind, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_sell2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_sell2csr\n\n function rocsparse_dell2csr(handle, m, n, ell_descr, ell_width, ell_val, &\n ell_col_ind, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_dell2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_dell2csr\n\n function rocsparse_cell2csr(handle, m, n, ell_descr, ell_width, ell_val, &\n ell_col_ind, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_cell2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_cell2csr\n\n function rocsparse_zell2csr(handle, m, n, ell_descr, ell_width, ell_val, &\n ell_col_ind, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_zell2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n type(c_ptr), intent(in), value :: ell_descr\n integer(c_int), value :: ell_width\n type(c_ptr), intent(in), value :: ell_val\n type(c_ptr), intent(in), value :: ell_col_ind\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_zell2csr\n\n! rocsparse_hyb2csr_buffer_size\n function rocsparse_hyb2csr_buffer_size(handle, descr, hyb, csr_row_ptr, &\n buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_hyb2csr_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), value :: buffer_size\n end function rocsparse_hyb2csr_buffer_size\n\n! rocsparse_hyb2csr\n function rocsparse_shyb2csr(handle, descr, hyb, csr_val, csr_row_ptr, &\n csr_col_ind, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_shyb2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n type(c_ptr), value :: temp_buffer\n end function rocsparse_shyb2csr\n\n function rocsparse_dhyb2csr(handle, descr, hyb, csr_val, csr_row_ptr, &\n csr_col_ind, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_dhyb2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n type(c_ptr), value :: temp_buffer\n end function rocsparse_dhyb2csr\n\n function rocsparse_chyb2csr(handle, descr, hyb, csr_val, csr_row_ptr, &\n csr_col_ind, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_chyb2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n type(c_ptr), value :: temp_buffer\n end function rocsparse_chyb2csr\n\n function rocsparse_zhyb2csr(handle, descr, hyb, csr_val, csr_row_ptr, &\n csr_col_ind, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_zhyb2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n type(c_ptr), intent(in), value :: descr\n type(c_ptr), intent(in), value :: hyb\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n type(c_ptr), value :: temp_buffer\n end function rocsparse_zhyb2csr\n\n! rocsparse_create_identity_permutation\n function rocsparse_create_identity_permutation(handle, n, p) &\n result(c_int) &\n bind(c, name = 'rocsparse_create_identity_permutation')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: n\n type(c_ptr), value :: p\n end function rocsparse_create_identity_permutation\n\n! rocsparse_csrsort_buffer_size\n function rocsparse_csrsort_buffer_size(handle, m, n, nnz, csr_row_ptr, &\n csr_col_ind, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrsort_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), intent(in), value :: csr_col_ind\n type(c_ptr), value :: buffer_size\n end function rocsparse_csrsort_buffer_size\n\n! rocsparse_csrsort\n function rocsparse_csrsort(handle, m, n, nnz, csr_row_ptr, &\n csr_col_ind, perm, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_csrsort')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n type(c_ptr), value :: perm\n type(c_ptr), value :: temp_buffer\n end function rocsparse_csrsort\n\n! rocsparse_cscsort_buffer_size\n function rocsparse_cscsort_buffer_size(handle, m, n, nnz, csc_col_ptr, &\n csc_row_ind, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_cscsort_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csc_col_ptr\n type(c_ptr), intent(in), value :: csc_row_ind\n type(c_ptr), value :: buffer_size\n end function rocsparse_cscsort_buffer_size\n\n! rocsparse_cscsort\n function rocsparse_cscsort(handle, m, n, nnz, csc_col_ptr, &\n csc_row_ind, perm, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_cscsort')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: csc_col_ptr\n type(c_ptr), value :: csc_row_ind\n type(c_ptr), value :: perm\n type(c_ptr), value :: temp_buffer\n end function rocsparse_cscsort\n\n! rocsparse_coosort_buffer_size\n function rocsparse_coosort_buffer_size(handle, m, n, nnz, coo_row_ind, &\n coo_col_ind, buffer_size) &\n result(c_int) &\n bind(c, name = 'rocsparse_coosort_buffer_size')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), intent(in), value :: coo_row_ind\n type(c_ptr), intent(in), value :: coo_col_ind\n type(c_ptr), value :: buffer_size\n end function rocsparse_coosort_buffer_size\n\n! rocsparse_coosort_by_row\n function rocsparse_coosort_by_row(handle, m, n, nnz, coo_row_ind, &\n coo_col_ind, perm, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_coosort_by_row')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), value :: coo_row_ind\n type(c_ptr), value :: coo_col_ind\n type(c_ptr), value :: perm\n type(c_ptr), value :: temp_buffer\n end function rocsparse_coosort_by_row\n\n! rocsparse_coosort_by_column\n function rocsparse_coosort_by_column(handle, m, n, nnz, coo_row_ind, &\n coo_col_ind, perm, temp_buffer) &\n result(c_int) &\n bind(c, name = 'rocsparse_coosort_by_column')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: m\n integer(c_int), value :: n\n integer(c_int), value :: nnz\n type(c_ptr), value :: coo_row_ind\n type(c_ptr), value :: coo_col_ind\n type(c_ptr), value :: perm\n type(c_ptr), value :: temp_buffer\n end function rocsparse_coosort_by_column\n\n! rocsparse_bsr2csr\n function rocsparse_sbsr2csr(handle, dir, mb, nb, bsr_descr, bsr_val, bsr_row_ptr, &\n bsr_col_ind, block_dim, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_sbsr2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_sbsr2csr\n\n function rocsparse_dbsr2csr(handle, dir, mb, nb, bsr_descr, bsr_val, bsr_row_ptr, &\n bsr_col_ind, block_dim, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_dbsr2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_dbsr2csr\n\n function rocsparse_cbsr2csr(handle, dir, mb, nb, bsr_descr, bsr_val, bsr_row_ptr, &\n bsr_col_ind, block_dim, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_cbsr2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_cbsr2csr\n\n function rocsparse_zbsr2csr(handle, dir, mb, nb, bsr_descr, bsr_val, bsr_row_ptr, &\n bsr_col_ind, block_dim, csr_descr, csr_val, csr_row_ptr, csr_col_ind) &\n result(c_int) &\n bind(c, name = 'rocsparse_zbsr2csr')\n use iso_c_binding\n implicit none\n type(c_ptr), value :: handle\n integer(c_int), value :: dir\n integer(c_int), value :: mb\n integer(c_int), value :: nb\n type(c_ptr), intent(in), value :: bsr_descr\n type(c_ptr), intent(in), value :: bsr_val\n type(c_ptr), intent(in), value :: bsr_row_ptr\n type(c_ptr), intent(in), value :: bsr_col_ind\n integer(c_int), value :: block_dim\n type(c_ptr), intent(in), value :: csr_descr\n type(c_ptr), value :: csr_val\n type(c_ptr), value :: csr_row_ptr\n type(c_ptr), value :: csr_col_ind\n end function rocsparse_zbsr2csr\n\n end interface\n\n contains\n subroutine rocsparseCheck(rocsparseError_t)\n implicit none\n integer(kind(rocsparse_status_success)) :: rocsparseError_t\n if (rocsparseError_t \/= rocsparse_status_success) then\n write(*,*) \"ROCSPARSE ERROR: Error code = \", rocsparseError_t\n call exit(rocsparseError_t)\n end if\n end subroutine rocsparseCheck\n\nend module rocsparse\n","avg_line_length":43.9374393792,"max_line_length":95,"alphanum_fraction":0.548830561} {"size":1529,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":" SUBROUTINE RECEIV (STATEB,APPLY)\r\nC CALLS 'APPLY(STATEB,STATEZ,PRODZ)' FOR ALL REDUCTIONS 'PRODZ' IN\r\nC 'STATEZ' THAT RECEIVE THEIR LOOK-AHEAD SYMBOLS FROM 'STATEB'\r\nC GF 09.07.1980\r\nC\r\n INCLUDE 'PARS.f'\r\n INCLUDE 'PRES.f'\r\n INCLUDE 'PROS.f'\r\n INCLUDE 'STAS.f'\r\n INCLUDE 'SYMS.f'\r\n EXTERNAL APPLY\r\n INTEGER*2 I\r\n = ,PRED ! -> A PREDECESSOR OF 'STATEA'\r\n = ,PROD ! A PRODUCTION OF THE REACHING SYMBOL OF 'STATEB'\r\n = ,PRODZ ! MUST BE = 'PROD'\r\n = ,STATEA ! A PREDECESSOR OF 'STATEB'\r\n = ,STATEB ! THE STATE THAT EMITTS THE LOOK-AHEAD SYMBOLS\r\n = ,STATEZ ! THE STATE THAT HAS THE REDUCTION TO THE REACHING SYMB\r\nC\r\n PROD = SYMPRO(STASYM(STATEB))\r\n1 IF(PROD .GE. PROHIB) GOTO 2\r\n ! FOR ALL PRODUCTIONS OF THE REACHING SYMBOL OF 'STATEB'\r\n PRED = STAPRE(STATEB)\r\nCXML\r\nC XML3 (RECEIV, STATEB, PROD, PRED)\r\n CALL XML3 ('RECEIV', 1, 6, STATEB,PROD,PRED)\r\n3 IF(PRED .GE. PREHIB) GOTO 4\r\n STATEA = PRESTA(PRED)\r\n CALL ALONG(STATEA,PROMON(PROD),STATEZ,PRODZ)\r\n IF (PRODZ .NE. PROD)\r\n = CALL ASSERT(24,PROD,PRODZ)\r\n IF (STATEZ .GT. 0)\r\n = CALL APPLY(STATEB,STATEZ,PRODZ)\r\n ! ELSE\r\n ! 'LAGET' IS ISSUED WHEN REDUCTION IS INSERTED,'ITEINS'\r\n PRED = PRE(PRED)\r\n GOTO 3\r\n4 CONTINUE ! ALL PREDECESSORS\r\n PROD = PRO(PROD)\r\n GOTO 1\r\n2 CONTINUE ! ALL PRODUCTIONS\r\n RETURN! RECEIV\r\n END\r\n","avg_line_length":34.75,"max_line_length":73,"alphanum_fraction":0.566383257} {"size":2115,"ext":"f90","lang":"FORTRAN","max_stars_count":3.0,"content":"! -*- Mode: Fortran; -*-\n!\n! (C) 2014 by Argonne National Laboratory.\n! See COPYRIGHT in top-level directory.\n!\nsubroutine PMPIR_Rget_f08ts(origin_addr, origin_count, origin_datatype, target_rank, &\n target_disp, target_count, target_datatype, win, request, ierror)\n use, intrinsic :: iso_c_binding, only : c_int\n use :: mpi_f08, only : MPI_Datatype, MPI_Win, MPI_Request\n use :: mpi_f08_compile_constants, only : MPI_ADDRESS_KIND\n use :: mpi_c_interface, only : c_Datatype, c_Win, c_Request\n use :: mpi_c_interface, only : MPIR_Rget_cdesc\n\n implicit none\n\n type(*), dimension(..), asynchronous :: origin_addr\n integer, intent(in) :: origin_count\n integer, intent(in) :: target_rank\n integer, intent(in) :: target_count\n type(MPI_Datatype), intent(in) :: origin_datatype\n type(MPI_Datatype), intent(in) :: target_datatype\n integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp\n type(MPI_Win), intent(in) :: win\n type(MPI_Request), intent(out) :: request\n integer, optional, intent(out) :: ierror\n\n integer :: origin_count_c\n integer :: target_rank_c\n integer :: target_count_c\n integer(c_Datatype) :: origin_datatype_c\n integer(c_Datatype) :: target_datatype_c\n integer(c_Win) :: win_c\n integer(c_Request) :: request_c\n integer(c_int) :: ierror_c\n\n if (c_int == kind(0)) then\n ierror_c = MPIR_Rget_cdesc(origin_addr, origin_count, origin_datatype%MPI_VAL, target_rank, target_disp, &\n target_count, target_datatype%MPI_VAL, win%MPI_VAL, request%MPI_VAL)\n else\n origin_count_c = origin_count\n origin_datatype_c = origin_datatype%MPI_VAL\n target_rank_c = target_rank\n target_count_c = target_count\n target_datatype_c = target_datatype%MPI_VAL\n win_c = win%MPI_VAL\n ierror_c = MPIR_Rget_cdesc(origin_addr, origin_count_c, origin_datatype_c, target_rank_c, target_disp, &\n target_count_c, target_datatype_c, win_c, request_c)\n request%MPI_VAL = request_c\n end if\n\n if (present(ierror)) ierror = ierror_c\n\nend subroutine PMPIR_Rget_f08ts\n","avg_line_length":39.1666666667,"max_line_length":114,"alphanum_fraction":0.7073286052} {"size":3776,"ext":"f90","lang":"FORTRAN","max_stars_count":5.0,"content":"! -----------------------------------------------------------------\n! Programmer(s): Cody J. Balos @ LLNL\n! -----------------------------------------------------------------\n! SUNDIALS Copyright Start\n! Copyright (c) 2002-2019, Lawrence Livermore National Security\n! and Southern Methodist University.\n! All rights reserved.\n!\n! See the top-level LICENSE and NOTICE files for details.\n!\n! SPDX-License-Identifier: BSD-3-Clause\n! SUNDIALS Copyright End\n! -----------------------------------------------------------------\n! This file tests the Fortran 2003 interface to the SUNDIALS \n! sparse SUNMatrix implementation.\n! -----------------------------------------------------------------\n\n\nprogram main\n\n !======== Inclusions ==========\n use, intrinsic :: iso_c_binding\n use fsunmatrix_sparse_mod\n use fsunmatrix_dense_mod\n use fsunmatrix_band_mod\n use fnvector_serial_mod\n\n !======== Declarations ========\n implicit none\n\n ! constants\n real(c_double) :: ZERO = 0.d0\n real(c_double) :: ONE = 1.d0\n\n ! local variables\n integer(c_int) :: fails = 0 ! number of test fails\n integer(c_int) :: typ ! type of Sparse matrix\n integer(c_long) :: N ! dimensions of SUNMatrix\n integer(c_long) :: uband, lband ! bandwidth of band SUNMatrix\n type(c_ptr) :: A, B ! Sparse SUNMatrix\n type(c_ptr) :: D, E ! Dense and Banded SUNMatrix\n type(c_ptr) :: x, y ! NVectors\n type(c_ptr) :: matdata ! Matrix data pointer\n integer(c_long) :: lenrw, leniw ! matrix real and int work space size\n integer(c_long) :: val\n\n N = 100\n uband = 0\n lband = 0\n\n x = FN_VNew_Serial(N)\n y = FN_VNew_Serial(N)\n \n D = FSUNDenseMatrix(N, N)\n E = FSUNBandMatrix(N, uband, lband, uband)\n\n !======= Introduction =========\n print *,'Sparse matrix Fortran 2003 interface test'\n\n !===== Calls to interface =====\n \n ! constructors\n A = FSUNSparseMatrix(N, N, N, CSC_MAT)\n if (.not. c_associated(A)) then\n print *,'>>> FAILED - ERROR in FSUNSparseMatrix; halting'\n stop 1\n end if\n call FSUNMatDestroy_Sparse(A)\n \n A = FSUNSparseFromDenseMatrix(D, ZERO, CSR_MAT)\n if (.not. c_associated(A)) then\n print *,'>>> FAILED - ERROR in FSUNSparseFromDenseMatrix; halting'\n stop 1\n end if\n call FSUNMatDestroy_Sparse(A)\n \n A = FSUNSparseFromBandMatrix(E, ZERO, CSC_MAT)\n if (.not. c_associated(A)) then\n print *,'>>> FAILED - ERROR in FSUNSparseFromBandMatrix; halting'\n stop 1\n end if\n \n ! misc. matrix functions\n val = FSUNSparseMatrix_Rows(A)\n val = FSUNSparseMatrix_Columns(A)\n val = FSUNSparseMatrix_NNZ(A)\n val = FSUNSparseMatrix_NP(A)\n typ = FSUNSparseMatrix_SparseType(A)\n matdata = FSUNSparseMatrix_Data(A)\n matdata = FSUNSparseMatrix_IndexValues(A)\n matdata = FSUNSparseMatrix_IndexPointers(A)\n fails = fails + FSUNSparseMatrix_Realloc(A)\n fails = fails + FSUNSparseMatrix_Reallocate(A, N)\n \n ! matrix operations \n B = FSUNMatClone_Sparse(A)\n if (.not. c_associated(B)) then\n print *,'>>> FAILED - ERROR in FSUNMatClone_Sparse; halting'\n stop 1\n end if\n val = FSUNMatGetID_Sparse(A)\n fails = fails + FSUNMatZero_Sparse(A)\n fails = fails + FSUNMatCopy_Sparse(A,B)\n fails = fails + FSUNMatScaleAdd_Sparse(ONE, A, B)\n fails = fails + FSUNMatScaleAddI_Sparse(ONE, A)\n fails = fails + FSUNMatMatvec_Sparse(A, x, y)\n fails = fails + FSUNMatSpace_Sparse(A, lenrw, leniw)\n\n ! destructor\n call FSUNMatDestroy_Sparse(A)\n\n !======= Cleanup ===========\n call FSUNMatDestroy_Sparse(B)\n call FSUNMatDestroy_Dense(D)\n call FSUNMatDestroy_Band(E)\n call FN_VDestroy_Serial(x)\n call FN_VDestroy_Serial(y)\n\n if (fails == 0) then\n print *,' SUCCESS - all tests passed'\n else\n print *,' FAILURE - ', fails, ' tests failed'\n stop 1\n end if\n\nend program main\n\n","avg_line_length":29.5,"max_line_length":71,"alphanum_fraction":0.6263241525} {"size":26678,"ext":"f","lang":"FORTRAN","max_stars_count":1.0,"content":"c======================================================================= \n subroutine lddpraschpoi(ngrid,npred,nsubject,p,q,y,roffset,\n & grid,z,zpred, \n & murand,a0b0,b0,prec1,sb,mu0,prec2,smu,tinv, \n & acrate,cpo,\n & denspm,randsave,thetasave,densave, \n & ncluster,ss,beta,b,\n & alphaclus,sigmaclus,\n & alpha,mu,sigma,tau2, \n & mcmc,nsave,\n & iflagp,betac,xtx,xty,workmhp1,workvp1, \n & cstrt,ccluster,iflagq,\n & alphawork,densw,\n & prob,quadf,sigmainv, \n & workmhq1,workmhq2, \n & workvq1,workvq2, \n & ztz,zty, \n & seed) \nc======================================================================= \nc # 58 arguments\nc\nc Copyright: Alejandro Jara, 2007-2010.\nc\nc Version 1.0:\nc\nc Last modification: 25-09-2009.\nc\nc This program is free software; you can redistribute it and\/or modify\nc it under the terms of the GNU General Public License as published by\nc the Free Software Foundation; either version 2 of the License, or (at\nc your option) any later version.\nc\nc This program is distributed in the hope that it will be useful, but\nc WITHOUT ANY WARRANTY; without even the implied warranty of\nc MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nc General Public License for more details.\nc\nc You should have received a copy of the GNU General Public License\nc along with this program; if not, write to the Free Software\nc Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\nc\nc The author's contact information:\nc\nc Alejandro Jara\nc Department of Statistics\nc Facultad de Matematicas\nc Pontificia Universidad Catolica de Chile\nc Casilla 306, Correo 22 \nc Santiago\nc Chile\nc Voice: +56-2-3544506 URL : http:\/\/www.mat.puc.cl\/~ajara\nc Fax : +56-2-3547729 Email: atjara@uc.cl\nc\nc=======================================================================\n\n implicit none \n\nc+++++Data\n integer ngrid,npred,nsubject,p,q\n integer y(nsubject,p)\n real*8 roffset(nsubject,p)\n real*8 grid(ngrid),z(nsubject,q),zpred(npred,q)\n\nc+++++Prior\n integer murand\n real*8 a0b0(6)\n real*8 aa0,ab0\n real*8 b0(p-1)\n real*8 prec1(p-1,p-1)\n real*8 sb(p-1)\n real*8 mu0(q)\n real*8 prec2(q,q)\n real*8 smu(q)\n real*8 tau1\n real*8 taus1,taus2\n real*8 nu\n real*8 tinv(q,q) \n\nc+++++MCMC parameters\n integer mcmc(3),nburn,nskip,nsave,ndisplay\n\nc+++++Output\n real*8 acrate(2)\n real*8 cpo(nsubject,p)\n real*8 denspm(npred,ngrid)\n real*8 randsave(nsave,nsubject+npred)\n real*8 thetasave(nsave,p+q+(q*(q+1)\/2)+2)\n real*8 densave(nsave,npred*ngrid)\n\nc+++++Current values of the parameters\n integer ncluster,ss(nsubject) \n real*8 beta(p-1)\n real*8 b(nsubject)\n real*8 alphaclus(nsubject+100,q)\n real*8 sigmaclus(nsubject+100)\n real*8 alpha\n real*8 mu(q)\n real*8 sigma(q,q)\n real*8 tau2\n\nc+++++External Working space - Difficulty parameters\n integer iflagp(p-1)\n real*8 betac(p-1)\n real*8 xtx(p-1,p-1),xty(p-1)\n real*8 workmhp1((p-1)*p\/2)\n real*8 workvp1(p-1)\n\nc+++++External Working space - DDP part\n integer cstrt(nsubject,nsubject)\n integer ccluster(nsubject)\n integer iflagq(q)\n real*8 alphawork(q)\n real*8 densw(npred,ngrid)\n real*8 prob(nsubject+100)\n real*8 quadf(q,q)\n real*8 sigmainv(q,q)\n real*8 workmhq1(q*(q+1)\/2)\n real*8 workmhq2(q*(q+1)\/2)\n real*8 workvq1(q),workvq2(q)\n real*8 ztz(q,q),zty(q)\n\nc+++++External Working space - RNG\n integer seed(2),seed1,seed2\n\nc+++++Internal Working space\n integer counter\n integer dispcount\n integer evali\n integer i,ii\n integer iscan,isave,isample\n integer j,k,l\n integer ns,nscan\n integer ok\n integer since\n integer skipcount\n integer sprint\n integer yij\n real*8 acrate2\n real*8 dpoiss,detlog,dnrm\n real*8 eta,gprime\n real*8 logcgkn,logcgko\n real*8 loglikn,logliko\n real*8 logpriorn,logprioro\n real*8 mean\n real*8 muwork\n real*8 offset\n real*8 ratio,rgamma,rnorm,runif\n real*8 ssb\n real*8 thetac\n real*8 tmp1,tmp2,tmp3\n real*8 ytilde\n real*8 wtw,wtwinv,wty\n real*8 sigmawork\n\nc+++++CPU time\n real*8 sec00,sec0,sec1,sec\n\nc++++ DP (functional parameter)\n real*8 eps,rbeta,weight\n parameter(eps=0.01)\n\nc++++ parameters\n nburn=mcmc(1)\n nskip=mcmc(2)\n ndisplay=mcmc(3)\n\n aa0=a0b0(1)\n ab0=a0b0(2)\n tau1=a0b0(3)\n taus1=a0b0(4)\n taus2=a0b0(5)\n nu=a0b0(6)\n\nc++++ set random number generator\n seed1=seed(1)\n seed2=seed(2)\n \n call setall(seed1,seed2)\n\nc++++ cluster structure\n do i=1,nsubject\n ccluster(ss(i))=ccluster(ss(i))+1\n cstrt(ss(i),ccluster(ss(i)))=i\n end do\n \nc++++ inverse of sigma\n\n do i=1,q\n do j=1,q\n sigmainv(i,j)=sigma(i,j)\n end do\n end do\n call inverse(sigmainv,q,iflagq) \n\nc+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nc++++ start the MCMC algorithm\nc+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n isave=0\n skipcount=0\n dispcount=0\n nscan=nburn+(nskip+1)*(nsave)\n \n call cpu_time(sec0)\n sec00=0.d0\n\n do iscan=1,nscan\n\nc+++++++ check if the user has requested an interrupt\n call rchkusr()\n\nc+++++++ check if the user has requested an interrupt\n call rchkusr()\n\nc++++++++++++++++++++++++++++++++++\nc+++++++ difficulty parameters\nc++++++++++++++++++++++++++++++++++\n\n do i=1,p-1\n do j=1,p-1\n xtx(i,j)=prec1(i,j)\n end do\n xty(i)=sb(i)\n end do\n \n logliko=0.d0\n \n do i=1,nsubject\n do j=1,p-1\n yij=y(i,j+1)\n eta=b(i)-beta(j)+roffset(i,j+1) \n offset=b(i)+roffset(i,j+1)\n mean=exp(eta)\n gprime=exp(-eta)\n\n ytilde=eta+(dble(yij)-mean)*gprime-offset\n\n xtx(j,j)=xtx(j,j)+1.d0\/gprime\n xty(j)=xty(j)-ytilde\/gprime\n\n logliko=logliko+dpoiss(dble(yij),mean,1)\n end do\n end do\n\n call inverse(xtx,p-1,iflagp) \n\n do i=1,p-1\n tmp1=0.d0\n do j=1,p-1\n tmp1=tmp1+xtx(i,j)*xty(j) \n end do\n workvp1(i)=tmp1\n end do\n\n call rmvnorm(p-1,workvp1,xtx,workmhp1,xty,betac)\n\n call dmvnd(p-1,betac,workvp1,xtx,logcgko,iflagp)\n\nc+++++++ prior ratio\n\n tmp1=0.d0\n tmp2=0.d0\n \n do i=1,p-1\n do j=1,p-1\n tmp1=tmp1+(betac(i)-b0(i))* \n & prec1(i,j) *\n & (betac(j)-b0(j))\n\n tmp2=tmp2+(beta(i) -b0(i))* \n & prec1(i,j) *\n & (beta(j) -b0(j))\n end do\n end do\n\n logpriorn=-0.5d0*tmp1\n logprioro=-0.5d0*tmp2\n\n \nc+++++++ candidate generating kernel contribution\n\n do i=1,p-1\n do j=1,p-1\n xtx(i,j)=prec1(i,j)\n end do\n xty(i)=sb(i)\n end do\n\n loglikn=0.d0\n\n do i=1,nsubject\n do j=1,p-1\n yij=y(i,j+1)\n eta=b(i)-betac(j)+roffset(i,j+1) \n offset=b(i)+roffset(i,j+1)\n mean=exp(eta)\n gprime=exp(-eta)\n ytilde=eta+(dble(yij)-mean)*gprime-offset\n\n loglikn=loglikn+dpoiss(dble(yij),mean,1) \n\n xtx(j,j)=xtx(j,j)+1.d0\/gprime\n xty(j)=xty(j)-ytilde\/gprime\n end do\n end do\n\n call inverse(xtx,p-1,iflagp) \n do i=1,p-1\n tmp1=0.d0\n do j=1,p-1\n tmp1=tmp1+xtx(i,j)*xty(j) \n end do\n workvp1(i)=tmp1\n end do\n \n call dmvnd(p-1,beta,workvp1,xtx,logcgkn,iflagp)\n \nc+++++++ mh step\n\n ratio=loglikn-logliko+logcgkn-logcgko+\n & logpriorn-logprioro\n\n if(log(runif()).lt.ratio)then\n acrate(1)=acrate(1)+1.d0\n do i=1,p-1\n beta(i)=betac(i) \n end do\n end if\n\nc call dblepr(\"beta\",-1,beta,p-1)\n\nc++++++++++++++++++++++++++++++++++ \nc+++++++ random effects \nc++++++++++++++++++++++++++++++++++\n\nc+++++++ check if the user has requested an interrupt\n call rchkusr()\n\n acrate2=0.d0\n\n do i=1,nsubject\n\n tmp1=0.d0\n do j=1,q\n tmp1=tmp1+z(i,j)*alphaclus(ss(i),j)\n end do\n sigmawork=sigmaclus(ss(i))\n\n logprioro=dnrm(b(i),tmp1,sqrt(sigmawork),1)\n\n wtw=1.d0\/sigmawork\n wty=tmp1\/sigmawork\n\n logliko=0.d0\n \n do j=1,p\n if(j.eq.1)then\n eta=b(i)+roffset(i,j)\n offset=roffset(i,j)\n else\n eta=b(i)-beta(j-1)+roffset(i,j)\n offset=-beta(j-1)+roffset(i,j)\n end if\n \n yij=y(i,j)\n\n mean=exp(eta)\n gprime=exp(-eta)\n\n ytilde=eta+(dble(yij)-mean)*gprime-offset \n\n logliko=logliko+dpoiss(dble(yij),mean,1)\n \n wtw=wtw+1.d0\/gprime\n wty=wty+ytilde\/gprime\n end do\n\n wtwinv=1.d0\/wtw\n tmp1=wtwinv*wty\n \n thetac=rnorm(tmp1,sqrt(wtwinv))\n\n logcgko=dnrm(thetac,tmp1,sqrt(wtwinv),1)\n\nc++++++++++ candidate generating kernel contribution\n\n tmp1=0.d0\n do j=1,q\n tmp1=tmp1+z(i,j)*alphaclus(ss(i),j)\n end do\n sigmawork=sigmaclus(ss(i))\n\n logpriorn=dnrm(thetac,tmp1,sqrt(sigmawork),1)\n\n wtw=1.d0\/sigmawork\n wty=tmp1\/sigmawork\n\n loglikn=0.d0\n \n do j=1,p\n if(j.eq.1)then\n eta=thetac+roffset(i,j)\n offset=roffset(i,j)\n else\n eta=thetac-beta(j-1)+roffset(i,j)\n offset=-beta(j-1)+roffset(i,j)\n end if\n \n yij=y(i,j)\n \n mean=exp(eta)\n gprime=exp(-eta)\n \n ytilde=eta+(dble(yij)-mean)*gprime-offset \n\n loglikn=loglikn+dpoiss(dble(yij),mean,1)\n\n wtw=wtw+1.d0\/gprime\n wty=wty+ytilde\/gprime\n end do\n\n wtwinv=1.d0\/wtw\n tmp1=wtwinv*wty\n \n logcgkn=dnrm(b(i),tmp1,sqrt(wtwinv),1)\n\nc++++++++++ mh step\n ratio=loglikn-logliko+logcgkn-logcgko+\n & logpriorn-logprioro\n\n if(log(runif()).lt.ratio)then\n acrate2=acrate2+1.d0\n b(i)=thetac\n end if\n end do\n\n acrate(2)=acrate(2)+acrate2\/dble(nsubject)\n\nc call dblepr(\"b\",-1,b,nsubject)\n\nc++++++++++++++++++++++++++++++++++\nc+++++++ clustering structure +++\nc++++++++++++++++++++++++++++++++++\n\n do i=1,nsubject\n\nc++++++++++ check if the user has requested an interrupt\n call rchkusr()\n\n ns=ccluster(ss(i))\n \n if(ns.gt.1)then\n isample=1\n ccluster(ss(i))=ccluster(ss(i))-1 \n\n j=1\n ok=0\n do while(ok.eq.0.and.j.le.ns)\n if(cstrt(ss(i),j).eq.i)ok=j\n j=j+1\n end do\n\n do j=ok,ns-1\n cstrt(ss(i),j)=cstrt(ss(i),j+1)\n end do\n\n else\n isample=2\n since=ss(i)\n \n if(since.lt.ncluster)then\n call relabellddp(i,since,nsubject,q,ncluster,ccluster,\n & ss,cstrt,alphaclus,sigmaclus,\n & alphawork)\n end if\n ccluster(ncluster)=ccluster(ncluster)-1 \n ncluster=ncluster-1\n end if \n \n do j=1,ncluster\n\n tmp1=0.0\n do k=1,q\n tmp1=tmp1+z(i,k)*alphaclus(j,k)\n end do \n sigmawork=sigmaclus(j)\n\n tmp2=dnrm(b(i),tmp1,sqrt(sigmawork),1)\n \n prob(j)=dble(ccluster(j))*exp(tmp2)\n end do\n\n if(isample.eq.1)then\n sigmawork=1.d0\/rgamma(0.5*tau1,0.5*tau2)\n sigmaclus(ncluster+1)=sigmawork\n \n call rmvnorm(q,mu,sigma,workmhq1,workvq1,alphawork) \n do k=1,q\n alphaclus(ncluster+1,k)=alphawork(k)\n end do \n end if \n sigmawork=sigmaclus(ncluster+1)\n\n tmp1=0.0\n do k=1,q\n tmp1=tmp1+z(i,k)*alphaclus(ncluster+1,k)\n end do \n tmp2=dnrm(b(i),tmp1,sqrt(sigmawork),1)\n\n prob(ncluster+1)=alpha*exp(tmp2)\n\n call simdisc(prob,nsubject+100,ncluster+1,evali)\n\n ss(i)=evali\n ccluster(evali)=ccluster(evali)+1\n cstrt(evali,ccluster(evali))=i\n \n if(evali.gt.ncluster)then\n ncluster=ncluster+1\n end if\n \n end do\n \nc call intpr(\"ncluster\",-1,ncluster,1)\nc call intpr(\"ss\",-1,ss,nsubject)\n\nc+++++++++++++++++++++++++++++++++++\nc+++++++ regression coefficients +++\nc+++++++++++++++++++++++++++++++++++\n\n do i=1,ncluster\n\n do k=1,q\n tmp1=0.d0\n do l=1,q\n ztz(k,l)=sigmainv(k,l)\n tmp1=tmp1+sigmainv(k,l)*mu(l)\n end do\n zty(k)=tmp1\n end do \n\n ns=ccluster(i)\n do j=1,ns\n\nc+++++++++++++ check if the user has requested an interrupt\n call rchkusr()\n\n ii=cstrt(i,j)\n\n do k=1,q\n do l=1,q\n ztz(k,l)=ztz(k,l)+z(ii,k)*z(ii,l)\/sigmaclus(i)\n end do\n zty(k)=zty(k)+z(ii,k)*b(ii)\/sigmaclus(i)\n end do\n end do\n\n call inverse(ztz,q,iflagq)\n\n do k=1,q \n tmp1=0.d0\n do l=1,q\n tmp1=tmp1+ztz(k,l)*zty(l)\n end do\n workvq1(k)=tmp1\n end do \n \n call rmvnorm(q,workvq1,ztz,workmhq1,workvq2,alphawork)\n \n do j=1,q\n alphaclus(i,j)=alphawork(j)\n end do\n\nc call dblepr(\"alphawork\",-1,alphawork,q)\n\n end do\n\n\nc+++++++++++++++++++++++++++++++++++\nc+++++++ variances +++\nc+++++++++++++++++++++++++++++++++++\n\n do i=1,ncluster\n\nc++++++++++ check if the user has requested an interrupt\n call rchkusr()\n\n ns=ccluster(i)\n tmp2=0.0\n do j=1,ns\n\nc+++++++++++++ check if the user has requested an interrupt\n call rchkusr()\n\n ii=cstrt(i,j)\n tmp1=0.d0\n do k=1,q\n tmp1=tmp1+z(ii,k)*alphaclus(i,k)\n end do\n tmp1=b(ii)-tmp1\n tmp2=tmp2+tmp1*tmp1\n end do\n\n sigmaclus(i)=1.d0\/rgamma(0.5d0*(tau1+dble(ns)),\n & 0.5d0*(tau2+tmp2))\n end do\n\nc call dblepr(\"sigma\",-1,sigmaclus,ncluster)\n\nc++++++++++++++++++++++++++++++++++ \nc+++++++ Precision parameter\nc++++++++++++++++++++++++++++++++++\n if(aa0.gt.0.d0)then\n call samalph(alpha,aa0,ab0,ncluster,nsubject)\n end if \n\nc+++++++++++++++++++++++++++++++++++\nc+++++++ baseline mean +++\nc+++++++++++++++++++++++++++++++++++\n\n if(murand.eq.1)then\n do i=1,q\n do j=1,q\n ztz(i,j)=sigmainv(i,j)+dble(ncluster)*prec2(i,j)\n end do\n zty(i)=smu(i)\n end do\n call inverse(ztz,q,iflagq)\n\n do ii=1,ncluster \n do i=1,q\n alphawork(i)=alphaclus(ii,i)\n end do\n do i=1,q\n tmp1=0.d0\n do j=1,q\n tmp1=tmp1+sigmainv(i,j)*alphawork(j)\n end do \n zty(i)=zty(i)+tmp1\n end do\n end do\n\n do i=1,q\n tmp1=0.d0\n do j=1,q\n tmp1=tmp1+ztz(i,j)*zty(j)\n end do\n workvq1(i)=tmp1\n end do\n\n call rmvnorm(q,workvq1,ztz,workmhq1,workvq2,mu)\n\nc call dblepr(\"mu\",-1,mu,q)\n end if\n\nc++++++++++++++++++++++++++++++++++++++\nc+++++++ baseline covariance matrix +++\nc++++++++++++++++++++++++++++++++++++++\n\nc call dblepr(\"nu\",-1,nu,1)\n\n if(nu.gt.0)then\n do i=1,q\n do j=1,q\n ztz(i,j)=0.d0\n end do\n end do\n \n do ii=1,ncluster \n do i=1,q\n alphawork(i)=alphaclus(ii,i)-mu(i)\n end do\n \n do i=1,q\n do j=1,q\n ztz(i,j)=ztz(i,j)+alphawork(i)*alphawork(j)\n end do\n end do\n end do\n\n do i=1,q\t\n do j=1,q\n sigma(i,j)=ztz(i,j)+tinv(i,j)\n end do\n end do\n\n call riwishart(q,int(nu)+ncluster,sigma,sigmainv,\n & quadf,zty,workmhq1,workmhq2,iflagq)\n\nc call dblepr(\"sigma\",-1,sigma,q*q)\n\n end if\n\nc++++++++++++++++++++++++++++++++++++++\nc+++++++ baseline gamma parameter +++\nc++++++++++++++++++++++++++++++++++++++\n\n if(taus1.gt.0.d0)then\n tmp1=0.d0\n do i=1,ncluster\n tmp1=tmp1+1.d0\/sigmaclus(i)\n end do \n\n tau2=rgamma(0.5d0*(dble(ncluster)*tau1+taus1),\n & 0.5d0*(tmp1+taus2)) \n\nc call dblepr(\"tau2\",-1,tau2,1)\n end if\n\nc++++++++++++++++++++++++++++++++++ \nc+++++++ save samples\nc++++++++++++++++++++++++++++++++++ \n \n if(iscan.gt.nburn)then\n skipcount=skipcount+1\n if(skipcount.gt.nskip)then\n isave=isave+1\n dispcount=dispcount+1\n\nc+++++++++++++ difficulty parameters\n\n do i=1,p-1\n thetasave(isave,i)=beta(i)\n end do\n\nc+++++++++++++ random effects variance\n thetasave(isave,p)=tau2\n\nc+++++++++++++ baseline information\n \n do i=1,q\n thetasave(isave,p+i)=mu(i)\n end do \n \n counter=0\n do i=1,q\n do j=i,q\t\n counter=counter+1\n thetasave(isave,p+q+counter)=sigma(i,j)\n end do \n end do\n\nc+++++++++++++ cluster information\n\n thetasave(isave,p+q+counter+1)=ncluster\n thetasave(isave,p+q+counter+2)=alpha\n\nc+++++++++++++ random effects\n\n do i=1,nsubject\n randsave(isave,i)=b(i)\n end do\n\nc+++++++++++++ predictive information\n\n do i=1,npred\n\n call simdisc(prob,nsubject+100,ncluster+1,evali)\n\n if(evali.le.ncluster)then\n sigmawork=sigmaclus(evali)\n do k=1,q\n alphawork(k)=alphaclus(evali,k)\n end do\n end if\n if(evali.eq.ncluster+1)then \n sigmawork=1.0d0\/rgamma(0.5d0*tau1,0.5d0*tau2)\n sigmaclus(ncluster+1)=sigmawork\n \n call rmvnorm(q,mu,sigma,workmhq1,workvq1,alphawork) \n do k=1,q\n alphaclus(ncluster+1,k)=alphawork(k)\n end do \n end if\n\n tmp1=0.d0 \n do k=1,q\n tmp1=tmp1+zpred(i,k)*alphaclus(evali,k) \n end do\n sigmawork=sigmaclus(evali)\n thetac=rnorm(tmp1,sqrt(sigmawork))\n randsave(isave,nsubject+i)=thetac\n end do\n \nc+++++++++++++ Partially sampling the DP\n\n do i=1,ncluster\n prob(i)=real(ccluster(i))\/(alpha+real(nsubject))\n end do\n prob(ncluster+1)=alpha\/(alpha+dble(nsubject))\n call simdisc(prob,nsubject+100,ncluster+1,evali)\n\n if(evali.le.ncluster)then\n sigmawork=sigmaclus(evali)\n do k=1,q\n alphawork(k)=alphaclus(evali,k)\n end do\n end if\n if(evali.eq.ncluster+1)then \n sigmawork=1.0d0\/rgamma(0.5d0*tau1,0.5d0*tau2)\n sigmaclus(ncluster+1)=sigmawork\n \n call rmvnorm(q,mu,sigma,workmhq1,workvq1,alphawork) \n do k=1,q\n alphaclus(ncluster+1,k)=alphawork(k)\n end do \n end if\n\n tmp1=rbeta(1.d0,alpha+dble(nsubject))\n tmp2=tmp1\n weight=(1.d0-tmp1)\n \n do i=1,npred \n call rchkusr()\n \n muwork=0.0\n do j=1,q\n muwork=muwork+zpred(i,j)*alphawork(j)\n end do\n \n do j=1,ngrid \n densw(i,j)=tmp1*dnrm(grid(j),muwork,\n & sqrt(sigmawork),0)\n \n end do \n end do\n\n do while((1.0-tmp2).gt.eps)\n call rchkusr()\n\n tmp3=rbeta(1.d0,alpha+real(nsubject))\n tmp1=weight*tmp3\n weight=weight*(1.0-tmp3)\n\n call simdisc(prob,nsubject+100,ncluster+1,evali)\n\n if(evali.le.ncluster)then\n sigmawork=sigmaclus(evali)\n do k=1,q\n alphawork(k)=alphaclus(evali,k)\n end do\n end if\n\n if(evali.eq.ncluster+1)then \n sigmawork=1.0d0\/rgamma(0.5d0*tau1,0.5d0*tau2)\n sigmaclus(ncluster+1)=sigmawork\n \n call rmvnorm(q,mu,sigma,workmhq1,workvq1,alphawork) \n do k=1,q\n alphaclus(ncluster+1,k)=alphawork(k)\n end do \n end if\n\n do i=1,npred \n call rchkusr()\n\n muwork=0.0\n do j=1,q\n muwork=muwork+zpred(i,j)*alphawork(j)\n end do\n\n do j=1,ngrid \n densw(i,j)=densw(i,j)+tmp1*dnrm(grid(j),\n & muwork,sqrt(sigmawork),0)\n\n end do \n end do\n\n tmp2=tmp2+tmp1\n end do\n\n call simdisc(prob,nsubject+100,ncluster+1,evali)\n\n if(evali.le.ncluster)then\n sigmawork=sigmaclus(evali)\n do k=1,q\t\n alphawork(k)=alphaclus(evali,k)\n end do\n end if\n if(evali.eq.ncluster+1)then \n sigmawork=1.0d0\/rgamma(0.5d0*tau1,0.5d0*tau2)\n sigmaclus(ncluster+1)=sigmawork\n \n call rmvnorm(q,mu,sigma,workmhq1,workvq1,alphawork) \n do k=1,q\n alphaclus(ncluster+1,k)=alphawork(k)\n end do \n end if\n\n tmp1=weight\n do i=1,npred \n call rchkusr()\n \n muwork=0.0\n do j=1,q\n muwork=muwork+zpred(i,j)*alphawork(j)\n end do\n \n do j=1,ngrid \n densw(i,j)=densw(i,j)+tmp1*dnrm(grid(j),\n & muwork,sqrt(sigmawork),0)\n end do \n end do\n\n ii=0\n do i=1,npred\n call rchkusr()\n do j=1,ngrid\n denspm(i,j)=denspm(i,j)+densw(i,j)\n ii=ii+1\n densave(isave,ii)=densw(i,j)\n end do\n end do \n\nc+++++++++++++ cpo\n\n do i=1,nsubject\n do j=1,p\n yij=y(i,j)\n if(j.eq.1)then\n eta=b(i)+roffset(i,j)\n else\n eta=b(i)-beta(j-1)+roffset(i,j)\n end if\n mean=exp(eta)\n tmp1=dpoiss(dble(yij),mean,0)\n cpo(i,j)=cpo(i,j)+1.d0\/tmp1\n end do\n end do\n\nc+++++++++++++ print\n skipcount = 0\n if(dispcount.ge.ndisplay)then\n call cpu_time(sec1)\n sec00=sec00+(sec1-sec0)\n sec=sec00\n sec0=sec1\n tmp1=sprint(isave,nsave,sec)\n dispcount=0\n end if \n end if\n end if \n\n end do\n \n do i=1,2\n acrate(i)=acrate(i)\/dble(nscan) \n end do \n \n do i=1,nsubject\n do j=1,p\n cpo(i,j)=dble(nsave)\/cpo(i,j)\n end do \n end do\n\n do i=1,npred\n do j=1,ngrid\n denspm(i,j)=denspm(i,j)\/dble(nsave)\n end do \n end do\n\n return\n end\n\n","avg_line_length":27.6455958549,"max_line_length":94,"alphanum_fraction":0.4184721493} {"size":24108,"ext":"for","lang":"FORTRAN","max_stars_count":1.0,"content":" subroutine sedseg(dslost,jun,iyear,noout)\nc*******************************************************************\nc *\nc This subroutine is called from SR SEDOUT and breaks the *\nc hillslope profile into detachment or deposition segments. *\nc It calls SR SEDIST and SR SEDSTA. *\nc It builds abbrev.raw for OCP *\nc *\nc*******************************************************************\nc *\nc Arguments *\nc dslost - array containing the net soil loss\/gain at each *\nc of the 100 points on each OFE *\nc jun - unit number of file to write output to *\nc iyear - flag for printing out annual soil loss output *\nc noout - flag indicating printing of event by event *\nc summary files is desired (see SEDOUT) *\nc *\nc*******************************************************************\nc *\nc + + + ARGUMENT DECLARATIONS + + +\nc\n integer jun, iyear, noout\n real dslost\n include 'pmxcrp.inc'\n include 'pmxelm.inc'\n include 'pmxpln.inc'\nc include 'pmxres.inc'\n include 'pmxseg.inc'\n include 'pmxpts.inc'\nc include 'pmxprt.inc'\n include 'pmxhil.inc'\nc include 'pmxtil.inc'\nc include 'pmxtls.inc'\nc include 'pntype.inc'\nc\nc*****************************************************************\nc *\nc Common Blocks *\nc *\nc*****************************************************************\nc\n include 'cavloss.inc'\n include 'ccntour.inc'\nc include 'ccrpprm.inc'\nc include 'cenrpas.inc'\nc include 'ciravlo.inc'\nc include 'cirriga.inc'\nc include 'cpart.inc'\n include 'cseddet.inc'\nc\nc********************************************************************\nc *\nc seddet variables updated *\nc avedet, maxdet, ptdep, ptdet, avedep, maxdep *\nc *\nc********************************************************************\nc\n include 'csedld.inc'\nc\nc********************************************************************\nc *\nc sedld variables updated *\nc jflag(mxseg),ibegin,iend,lseg *\nc *\nc********************************************************************\nc\n include 'cslpopt.inc'\n include 'cstmflg.inc'\n include 'cstruc.inc'\n include 'csumout.inc'\nc\n include 'cunicon.inc'\nc read outopt, units\nc include 'csumirr.inc'\nc\nc*****************************************************************\nc *\nc Local variables *\nc deppt1 : distance where deposition section begins (m) *\nc deppt2 : distance where deposition section ends (m) *\nc dpavls : average deposition in section (kg\/m**2) *\nc detpt1 : distance where detachment section begins (m) *\nc detpt2 : distance where detachment section ends (m) *\nc dtavls : average detachment in section (kg\/m**2) *\nc detstd : standard deviation of detachment in sect.(kg\/m**2)*\nc detmax : maximum detachment in section (kg\/m**2) *\nc pdtmax : point of maximum detachment (m) *\nc detmin : minimum detachment in section (kg\/m**2) *\nc pdtmin : point of minimum detachment (m) *\nc depstd : standard deviation of deposition in sect.(kg\/m**2)*\nc depmax : maximum deposition in section (kg\/m**2) *\nc pdpmax : point of maximum deposition in section (m) *\nc depmin : minimum deposition in section (kg\/m**2) *\nc pdpmin : point of minimum deposition in section (m) *\nc *\nc*****************************************************************\nc\nc\n dimension dslost(mxplan,100)\nc\n dimension detstd(mxseg), detmax(mxseg), pdtmax(mxseg),\n 1 detmin(mxseg), pdtmin(mxseg)\nc\n dimension depstd(mxseg), depmax(mxseg), pdpmax(mxseg),\n 1 depmin(mxseg), pdpmin(mxseg)\nc\ncccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\nc\nc ADDED TOTFAL AND OFEFAL FOR NEW ABBREV.RAW\nc\ncccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\nc\n dimension detdis(mxseg), depdis(mxseg), idtsin(mxseg),\n 1 idpsin(mxseg),\n 1 detpt1(mxseg),detpt2(mxseg),dtavls(mxseg),\n 1 deppt1(mxseg),deppt2(mxseg),dpavls(mxseg)\nc\nc\nc + + + LOCAL VARIABLE DECLARATIONS + + +\nc\n integer jadet, jadep, jdet, jdep, itsin, ipsin, lend,\n 1 i, icnt, icont, idpsin, idtsin, iii, j, kbeg, kk,\n 1 lbeg\n real sum1, sum2, filoss, fidep, totmax, pdtmx, pdpmx,\n 1 depdis, depmax, depmin, deppt1,detdis,\n 1 deppt2, depstd, detmax, detmin, detpt1, detpt2, detstd,\n 1 dpavls, dtavls, pdpmax,\n 1 pdpmin, pdtmax, pdtmin, mtf, kgmtpa\n character*7 unit(9)\n data unit \/' mm', ' kg\/m2',' in.',' t\/a',' ft.'\n 1,' lbs\/ft',' lbs',' kg\/m',' m'\/\nc data unit\nc 1=mm\nc 2=kg\/m2\nc 3=in.\nc 4=t\/a\nc 5=ft.\nc 6=lbs\/ft\nc 7=lbs\nc 8=kg\/m\nc*******************************************************************\nc\n avedep = 0.0\n avedet = 0.0\n maxdep = 0.0\n maxdet = 0.0\n ptdep = 0.0\n ptdet = 0.0\n tdep(ihill) = 0.0\n tdet(ihill) = 0.0\nc\n if (noout.le.1) then\n write (jun,2500)\n icont = 0\n do 10 iplane = 1, nplane\n if (iyear.eq.1) then\n if (fail(1,iplane).gt.0) then\n write (jun,2000) fail(1,iplane), iplane\n totfal(iplane) = totfal(iplane) + fail(1,iplane)\n icont = 1\n end if\n if (fail(2,iplane).gt.0) then\n write (jun,2100) fail(2,iplane), iplane\n totfal(iplane) = totfal(iplane) + fail(2,iplane)\n icont = 1\n end if\n if (fail(3,iplane).gt.0) then\n write (jun,2200) fail(3,iplane), iplane\n totfal(iplane) = totfal(iplane) + fail(3,iplane)\n icont = 1\n end if\n end if\n 10 continue\n if (icont.eq.1) write (jun,1900)\n end if\nc\n call sedist(dslost)\nc\n lseg = 1\n jadep = 0\n jadet = 0\n sum1 = 0.0\n sum2 = 0.0\n jdet = 0\n jdep = 0\n itsin = 0\n ipsin = 0\n lend = nplane * 100\n kbeg = 0\n lbeg = 1\n icnt = 0\nc\n do 20 j = 1, lend\n if (dstot(j).ne.0.0) then\n if (kbeg.eq.0) then\n lbeg = j\n kbeg = 1\n end if\n icnt = j\n end if\n 20 continue\nc\n ibegin = lbeg\n if (icnt.lt.lend) then\n lend = icnt + 1\n end if\nc\n if (dstot(lbeg).gt.0.0) jflag(lseg) = 1\n if (dstot(lbeg).lt.0.0) jflag(lseg) = 0\nc\nc\nc Added by dcf 4\/16\/90 to cover possibility if dstot = 0\nc\n if (dstot(lbeg).eq.0.0) jflag(lseg) = 2\nc\n do 30 i = lbeg + 1, lend\n if ((jflag(lseg).eq.1.and.dstot(i).le.0.0).or.(i.eq.lend.and.\n 1 dstot(i).gt.0.0)) then\nc\n jadet = jadet + 1\n iend = i - 1\n if (i.eq.lend.and.dstot(i).gt.0.0) iend = i\nc\nc if the beginning of the detachment is the first point on the slope\nc set the point to zero otherwise average i with the point before it\nc\n if (ibegin.eq.1) then\n detpt1(jadet) = 0.0\n else\n detpt1(jadet) = stdist(ibegin-1)\n end if\nc\n detpt2(jadet) = stdist(iend)\nc\n detdis(jadet) = detpt2(jadet) - detpt1(jadet)\nc\n if (i.eq.lend.and.dstot(i).lt.0.0) then\n jadep = jadep + 1\n idpsin(jadep) = 1\n dpavls(jadep) = dstot(lend)\n depstd(jadep) = 0.0\n deppt1(jadep) = stdist(lend-1)\n deppt2(jadep) = stdist(lend)\n depdis(jadep) = deppt2(jadep) - deppt1(jadep)\n depmax(jadep) = dstot(lend)\n pdpmax(jadep) = stdist(lend)\n depmin(jadep) = dstot(lend)\n pdpmin(jadep) = stdist(lend)\n ipsin = 1\n jdep = 1\n end if\n if (ibegin.eq.iend) then\n idtsin(jadet) = 1\n detpt1(jadet) = stdist(ibegin-1)\n detpt2(jadet) = stdist(ibegin)\n detdis(jadet) = detpt2(jadet) - detpt1(jadet)\n dtavls(jadet) = dstot(ibegin)\n detstd(jadet) = 0.0\n detmax(jadet) = dstot(ibegin)\n pdtmax(jadet) = stdist(ibegin)\n detmin(jadet) = dstot(ibegin)\n pdtmin(jadet) = stdist(ibegin)\n itsin = 1\n jdet = 1\n else\n idtsin(jadet) = 0\n call sedsta(jadet,dtavls,detstd,detmax,pdtmax,detmin,pdtmin)\n jdet = 1\n end if\nc\n ibegin = iend + 1\n lseg = lseg + 1\n if (dstot(i).eq.0.0) jflag(lseg) = 2\n if (dstot(i).lt.0.0) jflag(lseg) = 0\nc\n else if ((jflag(lseg).eq.0.and.dstot(i).ge.0.0).or.(i.eq.lend\n 1 .and.dstot(i).lt.0.0)) then\nc\n jadep = jadep + 1\n iend = i - 1\n if (i.eq.lend.and.dstot(i).lt.0.0) iend = i\n if (ibegin.eq.1) then\n deppt1(jadep) = 0.0\n else\n deppt1(jadep) = stdist(ibegin-1)\n end if\nc\n deppt2(jadep) = stdist(iend)\n depdis(jadep) = deppt2(jadep) - deppt1(jadep)\nc\n if (i.eq.lend.and.dstot(i).gt.0.0) then\n jadet = jadet + 1\n idtsin(jadet) = 1\n dtavls(jadet) = dstot(lend)\n detstd(jadet) = 0.0\n detpt1(jadet) = stdist(lend-1)\n detpt2(jadet) = stdist(lend)\n detdis(jadet) = detpt2(jadet) - detpt1(jadet)\n detmax(jadet) = dstot(lend)\n detmin(jadet) = dstot(lend)\n pdtmax(jadet) = stdist(lend)\n pdtmin(jadet) = stdist(lend)\n itsin = 1\n jdet = 1\n end if\n if (ibegin.eq.iend) then\n idpsin(jadep) = 1\n deppt1(jadep) = stdist(ibegin-1)\n deppt2(jadep) = stdist(ibegin)\n depdis(jadep) = deppt2(jadep) - deppt1(jadep)\n dpavls(jadep) = dstot(ibegin)\n depmin(jadep) = dstot(ibegin)\n depmax(jadep) = dstot(ibegin)\n depstd(jadep) = 0.0\n pdpmax(jadep) = stdist(ibegin)\n pdpmin(jadep) = stdist(ibegin)\n ipsin = 1\n jdep = 1\n else\n idpsin(jadep) = 0\n call sedsta(jadep,dpavls,depstd,depmax,pdpmax,depmin,pdpmin)\n jdep = 1\n end if\nc\n ibegin = iend + 1\n lseg = lseg + 1\n if (dstot(i).eq.0.0) jflag(lseg) = 2\n if (dstot(i).gt.0.0) jflag(lseg) = 1\nc\n else if (jflag(lseg).eq.2.and.dstot(i).ne.0.0) then\n iend = i - 1\n if (i.eq.lend) then\n if (jflag(lseg).eq.1) then\n jadet = jadet + 1\n idtsin(jadet) = 1\n detpt1(jadet) = stdist(lend-1)\n detpt2(jadet) = stdist(lend)\n detdis(jadet) = detpt2(jadet) - detpt1(jadet)\n dtavls(jadet) = dstot(lend)\n detstd(jadet) = 0.0\n detmax(jadet) = dstot(lend)\n detmin(jadet) = dstot(lend)\n pdtmin(jadet) = stdist(lend)\n pdtmax(jadet) = stdist(lend)\n itsin = 1\n jdet = 1\n else if (jflag(lseg).eq.0) then\n jadep = jadep + 1\n idpsin(jadep) = 1\n deppt1(jadep) = lend\n deppt2(jadep) = lend\n depdis(jadep) = deppt2(jadep) - deppt1(jadep)\n dpavls(jadep) = dstot(lend)\n depstd(jadep) = 0.0\n depmax(jadep) = dstot(lend)\n depmin(jadep) = dstot(lend)\n pdpmin(jadep) = stdist(lend)\n pdpmax(jadep) = stdist(lend)\n ipsin = 1\n jdep = 1\n end if\n end if\n lseg = lseg + 1\n ibegin = iend + 1\n if (dstot(i).gt.0.0) jflag(lseg) = 1\n if (dstot(i).lt.0.0) jflag(lseg) = 0\n end if\nc\n 30 continue\nc\nc\n if (jadet.gt.0) then\n if (noout.le.1) write (jun,2600)\n if (jdet.gt.0) then\n totmax = detmax(1)\n pdtmx = pdtmax(1)\n do 40 kk = 1, jadet\n sum1 = sum1 + (dtavls(kk)*detdis(kk))\n sum2 = sum2 + detdis(kk)\nc\n if (detmax(kk).gt.totmax) then\n totmax = detmax(kk)\n pdtmx = pdtmax(kk)\n end if\nc\n 40 continue\nc\n if (sum2.ne.0.0) then\n filoss = sum1 \/ sum2\n tdet(ihill) = sum2*fwidth(iplane)*filoss\nc kg\/m2>t\/a\n kgmtpa=4.4605\nc m>ft\n mtf=3.2808\n if (noout.le.1) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n write (jun,2700) filoss*kgmtpa,unit(4)\n write (jun,2800) totmax*kgmtpa,unit(4),\n 1 pdtmx*mtf,unit(5)\n else\nc metric units\n write (jun,2750) filoss\n write (jun,2850) totmax, pdtmx\n end if\n if (imodel.eq.2.or.(imodel.eq.1.and.iyear.ne.1.and.ioutpt\n 1 .eq.1)) then\n do 50 iii = 1, nplane\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n write (jun,2900) irdgdx(iii)*kgmtpa,unit(4), iii\n else\n write (jun,2950) irdgdx(iii), iii\n end if\n 50 continue\n end if\n end if\n avedet = filoss\n maxdet = totmax\n ptdet = pdtmx\n end if\n if (noout.le.1) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n if (ioutss.ne.2) write (jun,3500)unit(5),unit(4),\n 1 unit(4),unit(4),unit(5),unit(4),unit(5)\n else\n if (ioutss.ne.2) write (jun,3550)\n end if\n end if\nc\n do 60 kk = 1, jadet\n if (ioutss.ne.2) then\n if (noout.le.1) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n write (jun,3300) detpt1(kk)*mtf,detpt2(kk)*mtf,\n 1 dtavls(kk)*kgmtpa,detstd(kk)*kgmtpa,\n 1 detmax(kk)*kgmtpa, pdtmax(kk)*mtf,\n 1 detmin(kk)*kgmtpa, pdtmin(kk)*mtf\n else\nc metric units\n write (jun,3350)detpt1(kk),detpt2(kk),\n 1 dtavls(kk),detstd(kk),detmax(kk), pdtmax(kk),\n 1 detmin(kk), pdtmin(kk)\n end if\n end if\n end if\nc\nc endif\nc\n 60 continue\n end if\nc\nc output summary of erosion and detatchment to abbrev.raw\nc\nc\n if (itsin.gt.0) then\n do 70 kk = 1, jadet\n if (idtsin(kk).eq.1) then\n if (ioutss.ne.2) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n if (noout.le.1) write (jun,3400)unit(5),unit(4)\n else\n if (noout.le.1) write (jun,3450)\n end if\n\n go to 80\n end if\n end if\nc\n 70 continue\nc\n 80 do 90 kk = 1, jadet\n if (idtsin(kk).eq.1) then\n if (ioutss.ne.2) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n if (noout.le.1) write (jun,3600) detpt2(kk)*mtf,\n 1 dtavls(kk)*kgmtpa\n else\n if (noout.le.1) write (jun,3650) detpt2(kk),\n 1 dtavls(kk)\n end if\n end if\n end if\n 90 continue\n end if\n end if\nc\nc\n if (jadep.gt.0) then\n if (noout.le.1) write (jun,3000)\n if (jdep.gt.0) then\n sum1 = 0.0\n sum2 = 0.0\n totmax = depmax(1)\n pdpmx = pdpmax(1)\nc\n do 100 kk = 1, jadep\n sum1 = sum1 + (dpavls(kk)*depdis(kk))\n sum2 = sum2 + depdis(kk)\n if (depmax(kk).lt.totmax) then\n totmax = depmax(kk)\n pdpmx = pdpmax(kk)\n end if\nc\n 100 continue\nc\n if (sum2.ne.0.0) then\n fidep = sum1 \/ sum2\n tdep(ihill)=sum2*fwidth(iplane)*fidep\n if (noout.le.1) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n write (jun,3100) fidep*kgmtpa,unit(4)\n write (jun,3200) totmax*kgmtpa,unit(4),pdpmx*mtf,unit(5)\n else\n write (jun,3150) fidep\n write (jun,3250) totmax, pdpmx\n end if\n end if\n avedep = fidep\n maxdep = totmax\n ptdep = pdpmx\n end if\n if (noout.le.1) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\n if (ioutss.ne.2) write (jun,3700)unit(5),unit(4),unit(4),\n 1 unit(4),unit(5),unit(4),unit(5)\n else\n if (ioutss.ne.2) write (jun,3750)\n end if\n end if\nc\n do 110 kk = 1, jadep\nc if(idpsin(kk).ne.1) then\n if (ioutss.ne.2) then\n if (noout.le.1) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\nc\n write (jun,3300) deppt1(kk)*mtf, deppt2(kk)*mtf,\n 1 dpavls(kk)*kgmtpa, depstd(kk)*kgmtpa,\n 1 depmax(kk)*kgmtpa, pdpmax(kk)*mtf,\n 1 depmin(kk)*kgmtpa, pdpmin(kk)*mtf\n else\n write (jun,3350) deppt1(kk), deppt2(kk), dpavls(kk),\n 1 depstd(kk), depmax(kk), pdpmax(kk), depmin(kk),\n 1 pdpmin(kk)\n end if\n end if\n end if\nc endif\n 110 continue\n end if\n if (ipsin.gt.0) then\n do 120 kk = 1, jadep\n if (idpsin(kk).eq.1) then\n if (ioutss.ne.2) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\nc\n if (noout.le.1) write (jun,3800)unit(5),unit(4)\n else\n if (noout.le.1) write (jun,3850)\n end if\n go to 130\n end if\n end if\n 120 continue\nc\n 130 do 140 kk = 1, jadep\n if (idpsin(kk).eq.1) then\n if (ioutss.ne.2) then\n if(outopt.eq.1.and.units.eq.1)then\nc abbreviated english units\nc\n if (noout.le.1) write (jun,3600) deppt2(kk)*mtf,\n 1 dpavls(kk)*kgmtpa\n else\n if (noout.le.1) write (jun,3650) deppt2(kk),\n 1 dpavls(kk)\n end if\n\n end if\n end if\n 140 continue\n end if\n end if\n return\n\n 1900 format (1x,\/,1x,\n 1 ' The WEPP Hillslope model has detected the failure of',\n 1 ' contours',\/,\n 1 ' during the simulation. The model has run the hillslope',\n 1 ' assuming',\/,\n 1 ' no failure. However the contour inputs should be ',\n 1 'reconfigured',\/,\n 1 ' so that the contours do not fail or the WEPP Watershed ',\n 1 'version',\/,' should be run with a concentrated flow channel.'\n 1 )\n 2000 format (1x,\/,1x,'Contours Failed in ',i3,' cases on OFE ',i3,\/,10\n 1 x,' - contour slope is > = average slope')\n 2100 format (1x,\/,1x,'Contours Failed in ',i3,' cases on OFE ',i3,\/,10\n 1 x,'- contour row sideslope is less than the hill slope')\n 2200 format (1x,\/,1x,'Contours Failed in ',i3,' cases on OFE ',i3,\/,10\n 1 x,' - contours under designed')\n 2500 format (\/\/'II. ON SITE EFFECTS ON SITE EFFECTS',\n 1 ' ON SITE EFFECTS',\/,5x,(3(15('-'),2x))\/)\n 2600 format (\/2x,'A. AREA OF NET SOIL LOSS')\nc data unit\nc 1=mm\nc 2=kg\/m2\nc 3=in.\nc 4=t\/a\nc 5=ft.\nc 6=lbs\/ft\nc 7=lbs\nc 8=kg\/m\n 2700 format (\/6x,'** Soil Loss (Avg. of Net Detachment',' Areas) = ',\n 1 f11.4,a,' **')\n 2750 format (\/6x,'** Soil Loss (Avg. of Net Detachment',' Areas) = ',f8\n 1 .3,' kg\/m2 **')\n 2800 format (6x,'** Maximum Soil Loss = ',f11.4,a,' at ',f7.1,\n 1 a,' **'\/)\n 2850 format (6x,'** Maximum Soil Loss = ',f8.3,' kg\/m2 at ',f7.2,\n 1 ' meters **'\/)\n 2900 format (6x,'** Interrill Contribution = ',f11.4,a,\n 1 ' for OFE #',i2)\n 2950 format (6x,'** Interrill Contribution = ',f8.3,' kg\/m2 ',\n 1 ' for OFE #',i2)\n 3000 format (\/2x,'B. AREA OF SOIL DEPOSITION')\n 3100 format (\/6x,'** Soil Deposition (Avg. of Net Deposition',\n 1 ' Areas) = ',f12.4,a,' **')\n 3150 format (\/6x,'** Soil Deposition (Avg. of Net Deposition',\n 1 ' Areas) = ',f9.3,' kg\/m2 **')\n 3200 format (6x,'** Maximum Soil Deposition = ',f12.4,a,' at ',f7\n 1 .1,a,' **'\/)\n 3250 format (6x,'** Maximum Soil Deposition = ',f9.3,' kg\/m2 at ',f7\n 1 .2,' meters **'\/)\n 3300 format (f7.1,'-',f7.1,1x,f8.1,2x,f8.1,2x,f9.1,1x,f7.1,2x,f8.1,2x,\n 1 f7.1)\n 3350 format (f7.2,'-',f7.2,1x,f8.3,2x,f8.3,2x,f9.3,1x,f7.2,2x,f8.3,2x,\n 1 f7.2)\n 3400 format (\/6x,'Single Point',5x,'Single Point',\/,7x,'Soil Area',10x,\n 1 'Loss',\/,9x,a,13x,a,\/,6x,30('-'))\n 3450 format (\/6x,'Single Point',5x,'Single Point',\/,7x,'Soil Area',10x,\n 1 'Loss',\/,9x,'(m)',13x,'(kg\/m2\/)',\/,6x,30('-'))\n 3500 format (\/,6x,'Area of',4x,'Soil Loss',3x,'Soil Loss',3x,'MAX',3x,\n 1 'MAX Loss',3x,'MIN',3x,'MIN Loss',\/,6x,'Net Loss',6x,'MEAN',6\n 1 x,'STDEV',6x,'Loss',4x,'Point',4x,'Loss',3x,'Point',\/,4x,\n 1 a,5x,a,4x,a,3x,a,2x,a,1x,a,1x,a,\/,72('-'))\n 3550 format (\/,6x,'Area of',4x,'Soil Loss',3x,'Soil Loss',3x,'MAX',3x,\n 1 'MAX Loss',3x,'MIN',3x,'MIN Loss',\/,6x,'Net Loss',6x,'MEAN',6\n 1 x,'STDEV',6x,'Loss',4x,'Point',4x,'Loss',3x,'Point',\/,8x,\n 1 '(m)',7x,'(kg\/m2)',5x,'(kg\/m2)',2x,'(kg\/m2)',4x,'(m)',4x,\n 1 '(kg\/m2)',2x,'(m)',\/,72('-'))\n 3600 format (6x,f7.1,9x,f9.1)\n 3650 format (6x,f7.2,9x,f9.3)\n 3700 format (6x,'Area of',4x,'Soil Dep',3x,'Soil Dep',5x,'MAX',4x,\n 1 'MAX Dep',3x,'MIN',3x,'MIN Dep',\/,6x,'Net Dep',7x,'MEAN',5x,\n 1 'STDEV',7x,'Dep',5x,'Point',4x,'Dep',4x,'Point',\/,4x,\n 1 a,5x,a,4x,a,3x,a,2x,a,1x,a,1x,a,\/,72('-'))\n 3750 format (6x,'Area of',4x,'Soil Dep',3x,'Soil Dep',5x,'MAX',4x,\n 1 'MAX Dep',3x,'MIN',3x,'MIN Dep',\/,6x,'Net Dep',7x,'MEAN',5x,\n 1 'STDEV',7x,'Dep',5x,'Point',4x,'Dep',4x,'Point',\/,8x,'(m)',7x,\n 1 '(kg\/m2)',4x,'(kg\/m2)',3x,'(kg\/m2)',4x,'(m)',4x,'(kg\/m2)',2x,\n 1 '(m)',\/,72('-'))\n 3800 format (\/6x,'Single Point',5x,'Single Point',\/,7x,'Soil Area',10x,\n 1 'Dep',\/,9x,a,13x,a,\/,6x,30('-'))\n 3850 format (\/6x,'Single Point',5x,'Single Point',\/,7x,'Soil Area',10x,\n 1 'Dep',\/,9x,'(m)',13x,'(kg\/m2\/)',\/,6x,30('-'))\n\n end\n","avg_line_length":35.5051546392,"max_line_length":76,"alphanum_fraction":0.4589347934} {"size":252,"ext":"f","lang":"FORTRAN","max_stars_count":2.0,"content":" module m\n integer::i=3\n contains\n subroutine s\n print '(a)','hello'\n end subroutine s\n end module m\n \n program t\n use m,only:s\n integer::i=77\n print '(i0)',i\n call s\n end program t\n","avg_line_length":16.8,"max_line_length":25,"alphanum_fraction":0.4801587302} {"size":4412,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"!\n! CalculiX - A 3-dimensional finite element program\n! Copyright (C) 1998-2021 Guido Dhondt\n!\n! This program is free software; you can redistribute it and\/or\n! modify it under the terms of the GNU General Public License as\n! published by the Free Software Foundation(version 2);\n! \n!\n! This program is distributed in the hope that it will be useful,\n! but WITHOUT ANY WARRANTY; without even the implied warranty of \n! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n! GNU General Public License for more details.\n!\n! You should have received a copy of the GNU General Public License\n! along with this program; if not, write to the Free Software\n! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n!\n subroutine complexfrequencys(inpc,textpart,nmethod,\n & mei,iperturb,istep,istat,n,iline,ipol,inl,\n & ipoinp,inp,ithermal,xboun,nboun,ipoinpc,mcs,cs,cyclicsymmetry,\n & ier)\n!\n! reading the input deck: *COMPLEX FREQUENCY\n!\n implicit none\n!\n character*1 inpc(*)\n character*132 textpart(16)\n!\n integer nmethod,mei(4),istep,istat,iperturb(*),i,nboun,\n & n,key,iline,ipol,inl,ipoinp(2,*),inp(3,*),nev,ithermal(*),\n & ipoinpc(0:*),mcs,cyclicsymmetry,ier\n!\n real*8 xboun(*),cs(17,*)\n!\n mei(4)=0\n!\n if(istep.lt.1) then\n write(*,*) '*ERROR reading *COMPLEX FREQUENCY:'\n write(*,*) ' *COMPLEX FREQUENCY can only be used'\n write(*,*) ' within a STEP'\n ier=1\n return\n endif\n!\n! no heat transfer analysis\n!\n if(ithermal(1).gt.1) then\n ithermal(1)=1\n endif\n!\n! check for cyclic symmetry\n!\n if((mcs.ne.0).and.(cs(2,1).ge.0.d0)) then\n cyclicsymmetry=1\n endif\n!\n nmethod=0\n do i=2,n\n if(textpart(i)(1:8).eq.'CORIOLIS') then\n nmethod=6\n elseif(textpart(i)(1:7).eq.'FLUTTER') then\n nmethod=7\n elseif(textpart(i)(1:11).eq.'STORAGE=YES') then\n write(*,*) '*WARNING reading *COMPLEX FREQUENCY:'\n write(*,*) ' for this keyword'\n write(*,*) ' STORAGE=YES is deactivated'\n write(*,*) ' in the CalculiX code'\n\nc mei(4)=1\n else\n write(*,*) \n & '*WARNING reading *COMPLEX FREQUENCY:'\n write(*,*) ' parameter not recognized:'\n write(*,*) ' ',\n & textpart(i)(1:index(textpart(i),' ')-1)\n call inputwarning(inpc,ipoinpc,iline,\n &\"*COMPLEX FREQUENCY%\")\n endif\n enddo\n if(nmethod.eq.0) then\n write(*,*) \n & '*ERROR reading *COMPLEX FREQUENCY:'\n write(*,*) ' either parameter CORIOLIS'\n write(*,*) ' or parameter FLUTTER is required'\n call inputerror(inpc,ipoinpc,iline,\n & \"*COMPLEX FREQUENCY%\",ier)\n return\n endif\n!\n if(iperturb(1).gt.1) iperturb(1)=0\n iperturb(2)=0\n!\n call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,\n & ipoinp,inp,ipoinpc)\n if((istat.lt.0).or.(key.eq.1)) then\n write(*,*) '*ERROR reading *COMPLEX FREQUENCY:'\n write(*,*) ' definition not complete'\n write(*,*) ' '\n call inputerror(inpc,ipoinpc,iline,\n & \"*COMPLEX FREQUENCY%\",ier)\n return\n endif\n read(textpart(1)(1:10),'(i10)',iostat=istat) nev\n if(istat.gt.0) then\n call inputerror(inpc,ipoinpc,iline,\n & \"*COMPLEX FREQUENCY%\",ier)\n return\n endif\n if(nev.le.0) then\n write(*,*) '*ERROR reading *COMPLEX FREQUENCY:'\n write(*,*) ' less than 1 eigenvalue requested'\n ier=1\n return\n endif\n!\n mei(1)=nev\n!\n! removing nonzero boundary conditions\n!\n do i=1,nboun\n xboun(i)=0.d0\n enddo\n!\n! correction for cyclic symmetric structures:\n! if the present step was not preceded by a frequency step\n! no nodal diameter has been selected. To make sure that\n! mastructcs is called instead of mastruct a fictitious\n! minimum nodal diameter is stored\n!\n if((cyclicsymmetry.eq.1).and.(mcs.ne.0).and.(cs(2,1)<0.d0)) \n & cs(2,1)=0.d0\n!\n call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,\n & ipoinp,inp,ipoinpc)\n!\n return\n end\n\n","avg_line_length":31.2907801418,"max_line_length":71,"alphanum_fraction":0.5682230281} {"size":4038,"ext":"f","lang":"FORTRAN","max_stars_count":1.0,"content":"C\nC @(#)std.f\t1.9 (BNP) 6\/3\/89\nC\n PROGRAM STD\nC\nC.... The example program uses LANDR to solve the standard eigenvalue\nC.... problem [A-lambda*I]x = 0.\nC....\nC.... For simplicity A here is the famous Wilkinson matrix W(N)+.\nC.... (pp.308 Wilkinson AEP) In this case, \/OPSTIF\/ SIMPLY stores\nC.... M := N\/2.\nC\n INTEGER M\n COMMON\/OPSTIF\/M\nC....\nC.... OP(N,P,Q,R) takes an N-vector Q and should return A*Q in Y.\nC.... OPM(N,X,Y) takes an N-vector X and should return X in Y.\nC\nC.... The common block \"GETPUT\" is used solely by the user-supplied\nC.... subroutine STORE and holds the Lanczos vectors.\nC\n DOUBLE PRECISION A\n COMMON\/GETPUT\/A(125000)\nC\nC.... See write-up for details on memory allocation for W and RITZ.\nC.... N <= LMTN, MAXPRS <= LMTPRS, LANMAX <= LMTLAN.\nC\n INTEGER LMTN,LMTPRS,LMTLAN,LMTNW\n PARAMETER (LMTN = 500,LMTPRS = 250,LMTLAN = LMTPRS)\n PARAMETER (LMTNW = 6*LMTN+4*LMTLAN+1+LMTLAN*LMTLAN)\n INTEGER I,EV,NW,N,LANMAX,MAXPRS,J,NEIG,IERR,MSGLVL\n DOUBLE PRECISION CONDM,ENDL,ENDR,KAPPA,\n * W(LMTNW),RITZ(LMTN),BND(LMTN)\n INTEGER NCELLS\n NCELLS(N,LANMAX,I) = 6*N+4*LANMAX+1+I*LANMAX*LANMAX\nC\nC.... NW is the size of the working array W\nC\n NW = LMTNW\nC\n READ(5,*)N,LANMAX,MAXPRS,ENDL,ENDR,EV,KAPPA,MSGLVL\nC\nC.... make N an odd number\nC\n M = N\/2\n N = M+M+1\n WRITE(11,2000)N,LANMAX,MAXPRS,ENDL,ENDR,EV.LE.0,KAPPA\n CONDM = 1.0D0\nC\nC.... Data validation\nC\n IF (ENDL.GE.ENDR) THEN\n WRITE(11,*)'ENDL must be strictly less than ENDR'\n STOP\n ELSE IF (MAXPRS.GT.LANMAX) THEN\n WRITE(11,*)'MAXPRS cannot exceed LANMAX',\n * '(MAXPRS =',MAXPRS,' LANMAX =',LANMAX,')'\n STOP\n ELSE IF (EV.LE.0.AND.NCELLS(N,LANMAX,0).GT.NW) THEN\n WRITE(11,*)'6*N+4*LANMAX+1 cannot exceed',\n * NW,'(N =',N,' LANMAX =',LANMAX,')'\n STOP\n ELSE IF (EV.GT.0.AND.NCELLS(N,LANMAX,1).GT.NW) THEN\n WRITE(11,*)'6*N+4*LANMAX+1+LANMAX*LANMAX cannot exceed',\n * NW,'(N =',N,' LANMAX =',LANMAX,')'\n STOP\n ENDIF\nC\nC.... To get a random starting vector, the first N cells\nC.... must be initialized to zero.\nC\n DO 17 I = 1,N\n W(I) = 0.0D0\n17 CONTINUE\nC\nC.... Make a Lanczos run; see LANDR for meanings of parameters.\nC\n CALL LANDR(N,LANMAX,MAXPRS,CONDM,ENDL,ENDR,EV,KAPPA,\nC CALL LANDR(...,J,NEIG,RITZ,BND,W,NW,IERR,MSGLVL)\n * J,NEIG,RITZ,BND,W,NW,IERR,MSGLVL)\n IF (IERR.NE.0) WRITE(11,2999)IERR\nC\nC.... If you permute eigenvalues, don't forget to permute the\nC.... eigenvectors with them.\nC\n WRITE(11,9999)J,NEIG,(I,RITZ(I),BND(I),I = 1,J)\n STOP\n9999 FORMAT(1X,'...... '\n * \/1X,'...... ',6X,' J =',I3,3X,' NEIG =',I3\n * \/1X,'...... '\n * \/1X,'...... ',3X,3X,' Computed Ritz values',2X,\n * '(','Error Bnds',')'\n * \/1X,'...... '\n * \/(1X,'...... ',I3,3X,1PD22.14,2X,'(',1PD10.2,')'))\n2000 FORMAT(\n * 1X,'... '\n * \/1X,'... solve the standard eigenproblem'\n * \/1X,'... no. of equations =',I4\n * \/1X,'... max. no. of Lanczos steps =',I4\n * \/1X,'... max. no. of eigenpairs =',I4\n * \/1X,'... left end of the interval =',1PD22.14\n * \/1X,'... right end of the interval =',1PD22.14\n * \/1X,'... eigenvalues only? [T\/F] =',L4\n * \/1X,'... kappa =',1PD22.14\n * \/1X,'... ')\n2999 FORMAT(1X,'... return flag =',I9,4(' '),'...')\n END\nC\n SUBROUTINE OP(N,P,Q,R)\n INTEGER N\n DOUBLE PRECISION P(N),Q(N),R(N)\nC\n INTEGER M\n COMMON\/OPSTIF\/M\nC\n INTEGER I\n DOUBLE PRECISION ALPHA\n ALPHA(I) = DBLE(IABS((M+1-I)))\nC\n R(1) = ALPHA(1)*Q(1)+Q(1+1)\n DO 100 I = 2,N-1\n R(I) = Q(I-1)+ALPHA(I)*Q(I)+Q(I+1)\n100 CONTINUE\n R(N) = Q(N-1)+ALPHA(N)*Q(N)\n RETURN\n END\nC\n SUBROUTINE OPM(N,A,B)\n INTEGER N\n DOUBLE PRECISION A(N),B(N)\n INTEGER I\nC\n DO 100 I = 1,N\n B(I) = A(I)\n100 CONTINUE\n RETURN\n END\n","avg_line_length":29.2608695652,"max_line_length":69,"alphanum_fraction":0.5482912333} {"size":4057,"ext":"f","lang":"FORTRAN","max_stars_count":9.0,"content":" subroutine intring(ngroups,nom,k1,k2,ik1k2\n . ,ic,matstore,nsign,nffinal0,nffinal1,\n . numat,natstore,nffinal,nbextra)\n\n implicit double precision(a-h,o-z)\n\n dimension nom(ngroups,ngroups),\nc . matstore(10*nffinal0,2),nsign(10*nffinal0)\n . matstore(nffinal0,2),nsign(nffinal0)\n\n\n dimension natstorek1(8),natstorek2(8),mata(8,8)\n dimension nk1(8),nk2(8)\n\n dimension numat(2*nffinal1),natstore(2*nffinal1,8)\n\nc this subroutine evaluates the L1--L1 interaction\nc where at least one fragment is a ring\n\nc rings cannot be broken without leading to closely\nc spaced caps. So if the L1..L1 interaction is fully\nc allowed, it is implemented in full\nc If totally disallowed, then no result\nc If partially allowed, we break the ring into groups\n\nc generate a local exclusion matrix\n\n numatk1=numat(k1)\n numatk2=numat(k2)\n do j=1,8\n natstorek1(j)=natstore(k1,j)\n natstorek2(j)=natstore(k2,j)\n enddo\n\n\nc write(6,*)numatk1,numatk2\nc stop\n ie=0\n id=0\n do n1=1,numatk1\n do n2=1,numatk2\n ie=ie+1\n mata(n1,n2)=nom(natstorek1(n1),natstorek2(n2))\n id=id+mata(n1,n2)\n enddo\n enddo\nc do n1=1,numatk1\nc write(6,*)(nom(natstorek1(n1),natstorek2(k)),k=1,numatk2)\nc enddo\nc stop\n\n if(id.eq.0)then\nc nothing is allowed, so nothing to do\n return\n endif\n\n if(id.eq.ie)then\nc all allowed\n if(ic.ge.10*nffinal0)then\n write(6,*)' ic too big'\n call cancelL1L1(10*nffinal0,ic,matstore,nsign)\n endif\n\n ic=ic+1\n matstore(ic,1)=k1\n matstore(ic,2)=k2\n nsign(ic)=ik1k2\n return\n endif\n\nc see if any full fragment calcs are possible\n\n if(numatk2.gt.numatk1)then\n\n do n1=1,numatk1\n nk1(n1)=0\n do n2=1,numatk2\n nk1(n1)=nk1(n1)+mata(n1,n2)\n enddo\n enddo\n\n do n1=1,numatk1\n if(nk1(n1).eq.numatk2)then\n if(ic.ge.10*nffinal0)then\n write(6,*)' ic too big'\n call cancelL1L1(10*nffinal0,ic,matstore,nsign)\n endif\n\n ic=ic+1\n matstore(ic,2)=k2\n mg=natstorek1(n1)\n call match_mg(2*nffinal1,mg,numat,natstore,nffinal,nbextra,match)\nc complete the interaction\n matstore(ic,1)=match\n nsign(ic)=ik1k2\nc wipe out these mata entries\n do n2=1,numatk2\n mata(n1,n2)=0\n enddo\nc end the if(nk1(n1).eq.numatk2)\n endif\n\nc end loop over n1\n enddo\n\nc else for if(numatk2.gt.numatk1)\n else\n\n do n2=1,numatk2\n nk2(n2)=0\n do n1=1,numatk1\n nk2(n2)=nk2(n2)+mata(n1,n2)\n enddo\n enddo\n\n do n2=1,numatk2\n\n if(nk2(n2).eq.numatk1)then\n\n if(ic.ge.10*nffinal0)then\n write(6,*)' ic too big'\n call cancelL1L1(10*nffinal0,ic,matstore,nsign)\n endif\n\n ic=ic+1\n matstore(ic,1)=k1\n mg=natstorek2(n2)\n call match_mg(2*nffinal1,mg,numat,natstore,nffinal,nbextra,match)\nc complete the interaction\n matstore(ic,2)=match\n nsign(ic)=ik1k2\nc wipe out these mata entries\n do n1=1,numatk1\n mata(n1,n2)=0\n enddo\nc end the if(nk2(n2).eq.numatk1)\n endif\n\nc end loop over n1\n enddo\n\nc end if(numatk2.gt.numatk1)\n endif\n\nc any remaining mata not zero are done by group\n\n do n1=1,numatk1\n do n2=1,numatk2\n if(mata(n1,n2).ne.0)then\n\n mg=natstorek1(n1)\n call match_mg(2*nffinal1,mg,numat,natstore,nffinal,nbextra,match)\nc save match\n match1=match\n\n mg=natstorek2(n2)\n call match_mg(2*nffinal1,mg,numat,natstore,nffinal,nbextra,match)\nc save match\n match2=match\nc record the fragment numbers and the net sign\n if(ic.ge.10*nffinal0)then\n write(6,*)' ic too big'\n call cancelL1L1(10*nffinal0,ic,matstore,nsign)\n endif\n\n ic=ic+1\n matstore(ic,1)=match1\n matstore(ic,2)=match2\n nsign(ic)=ik1k2\n endif\nc end the n1,n2 loops\n enddo\n enddo\n\n return\n end\n","avg_line_length":22.9209039548,"max_line_length":71,"alphanum_fraction":0.6058664037} {"size":2910,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"C Copyright(C) 2011 Sandia Corporation. Under the terms of Contract\nC DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains\nC certain rights in this software\nC \nC Redistribution and use in source and binary forms, with or without\nC modification, are permitted provided that the following conditions are\nC met:\nC \nC * Redistributions of source code must retain the above copyright\nC notice, this list of conditions and the following disclaimer.\nC \nC * Redistributions in binary form must reproduce the above\nC copyright notice, this list of conditions and the following\nC disclaimer in the documentation and\/or other materials provided\nC with the distribution.\nC \nC * Neither the name of Sandia Corporation nor the names of its\nC contributors may be used to endorse or promote products derived\nC from this software without specific prior written permission.\nC \nC THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\nC \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nC LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nC A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nC OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nC SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nC LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nC DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nC THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\nC (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nC OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\nC \n\nC $Id: dbmirr.f,v 1.2 1999\/02\/17 15:26:52 gdsjaar Exp $\nC=======================================================================\n SUBROUTINE DBMIRR (NELBS, NELBE, IDELB, NUMELB, NUMLNK, LINK)\nC=======================================================================\n\nC --*** DBMIRR *** (GEN3D) Fixup connectivity for reflections\nC -- Written by Greg Sjaardema - revised 02\/10\/89\nC -- Modified from DBOELB Written by Amy Gilkey\nC --\nC --Parameters:\nC -- NELBS, NELBE - IN - the number of first and last element blocks\nC -- IDELB - IN - the element block IDs for each block\nC -- NUMELB - IN - the number of elements in each block\nC -- NUMLNK - IN - the number of nodes per element in each block\nC -- LINK - IN\/OUT - the connectivity for each block\nC --\n\n INTEGER IDELB(*)\n INTEGER NUMELB(*)\n INTEGER NUMLNK(*)\n INTEGER LINK(*)\n\n IELNK = 0\n\n DO 10 NELB = NELBS, NELBE\n IELB = NELB-NELBS+1\n\n ISLNK = IELNK + 1\n IELNK = IELNK + NUMLNK(IELB) * NUMELB(IELB)\n\n CALL DBMIR1 (NELB, NUMELB(IELB), NUMLNK(IELB), LINK(ISLNK))\n 10 CONTINUE\n\n RETURN\n END\n","avg_line_length":42.1739130435,"max_line_length":72,"alphanum_fraction":0.6701030928} {"size":6242,"ext":"f","lang":"FORTRAN","max_stars_count":998.0,"content":"*> \\brief \\b ZGETRF\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download ZGETRF + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE ZGETRF( M, N, A, LDA, IPIV, INFO )\n*\n* .. Scalar Arguments ..\n* INTEGER INFO, LDA, M, N\n* ..\n* .. Array Arguments ..\n* INTEGER IPIV( * )\n* COMPLEX*16 A( LDA, * )\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> ZGETRF computes an LU factorization of a general M-by-N matrix A\n*> using partial pivoting with row interchanges.\n*>\n*> The factorization has the form\n*> A = P * L * U\n*> where P is a permutation matrix, L is lower triangular with unit\n*> diagonal elements (lower trapezoidal if m > n), and U is upper\n*> triangular (upper trapezoidal if m < n).\n*>\n*> This is the right-looking Level 3 BLAS version of the algorithm.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] M\n*> \\verbatim\n*> M is INTEGER\n*> The number of rows of the matrix A. M >= 0.\n*> \\endverbatim\n*>\n*> \\param[in] N\n*> \\verbatim\n*> N is INTEGER\n*> The number of columns of the matrix A. N >= 0.\n*> \\endverbatim\n*>\n*> \\param[in,out] A\n*> \\verbatim\n*> A is COMPLEX*16 array, dimension (LDA,N)\n*> On entry, the M-by-N matrix to be factored.\n*> On exit, the factors L and U from the factorization\n*> A = P*L*U; the unit diagonal elements of L are not stored.\n*> \\endverbatim\n*>\n*> \\param[in] LDA\n*> \\verbatim\n*> LDA is INTEGER\n*> The leading dimension of the array A. LDA >= max(1,M).\n*> \\endverbatim\n*>\n*> \\param[out] IPIV\n*> \\verbatim\n*> IPIV is INTEGER array, dimension (min(M,N))\n*> The pivot indices; for 1 <= i <= min(M,N), row i of the\n*> matrix was interchanged with row IPIV(i).\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit\n*> < 0: if INFO = -i, the i-th argument had an illegal value\n*> > 0: if INFO = i, U(i,i) is exactly zero. The factorization\n*> has been completed, but the factor U is exactly\n*> singular, and division by zero will occur if it is used\n*> to solve a system of equations.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\ingroup complex16GEcomputational\n*\n* =====================================================================\n SUBROUTINE ZGETRF( M, N, A, LDA, IPIV, INFO )\n*\n* -- LAPACK computational routine --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n*\n* .. Scalar Arguments ..\n INTEGER INFO, LDA, M, N\n* ..\n* .. Array Arguments ..\n INTEGER IPIV( * )\n COMPLEX*16 A( LDA, * )\n* ..\n*\n* =====================================================================\n*\n* .. Parameters ..\n COMPLEX*16 ONE\n PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )\n* ..\n* .. Local Scalars ..\n INTEGER I, IINFO, J, JB, NB\n* ..\n* .. External Subroutines ..\n EXTERNAL XERBLA, ZGEMM, ZGETRF2, ZLASWP, ZTRSM\n* ..\n* .. External Functions ..\n INTEGER ILAENV\n EXTERNAL ILAENV\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC MAX, MIN\n* ..\n* .. Executable Statements ..\n*\n* Test the input parameters.\n*\n INFO = 0\n IF( M.LT.0 ) THEN\n INFO = -1\n ELSE IF( N.LT.0 ) THEN\n INFO = -2\n ELSE IF( LDA.LT.MAX( 1, M ) ) THEN\n INFO = -4\n END IF\n IF( INFO.NE.0 ) THEN\n CALL XERBLA( 'ZGETRF', -INFO )\n RETURN\n END IF\n*\n* Quick return if possible\n*\n IF( M.EQ.0 .OR. N.EQ.0 )\n $ RETURN\n*\n* Determine the block size for this environment.\n*\n NB = ILAENV( 1, 'ZGETRF', ' ', M, N, -1, -1 )\n IF( NB.LE.1 .OR. NB.GE.MIN( M, N ) ) THEN\n*\n* Use unblocked code.\n*\n CALL ZGETRF2( M, N, A, LDA, IPIV, INFO )\n ELSE\n*\n* Use blocked code.\n*\n DO 20 J = 1, MIN( M, N ), NB\n JB = MIN( MIN( M, N )-J+1, NB )\n*\n* Factor diagonal and subdiagonal blocks and test for exact\n* singularity.\n*\n CALL ZGETRF2( M-J+1, JB, A( J, J ), LDA, IPIV( J ), IINFO )\n*\n* Adjust INFO and the pivot indices.\n*\n IF( INFO.EQ.0 .AND. IINFO.GT.0 )\n $ INFO = IINFO + J - 1\n DO 10 I = J, MIN( M, J+JB-1 )\n IPIV( I ) = J - 1 + IPIV( I )\n 10 CONTINUE\n*\n* Apply interchanges to columns 1:J-1.\n*\n CALL ZLASWP( J-1, A, LDA, J, J+JB-1, IPIV, 1 )\n*\n IF( J+JB.LE.N ) THEN\n*\n* Apply interchanges to columns J+JB:N.\n*\n CALL ZLASWP( N-J-JB+1, A( 1, J+JB ), LDA, J, J+JB-1,\n $ IPIV, 1 )\n*\n* Compute block row of U.\n*\n CALL ZTRSM( 'Left', 'Lower', 'No transpose', 'Unit', JB,\n $ N-J-JB+1, ONE, A( J, J ), LDA, A( J, J+JB ),\n $ LDA )\n IF( J+JB.LE.M ) THEN\n*\n* Update trailing submatrix.\n*\n CALL ZGEMM( 'No transpose', 'No transpose', M-J-JB+1,\n $ N-J-JB+1, JB, -ONE, A( J+JB, J ), LDA,\n $ A( J, J+JB ), LDA, ONE, A( J+JB, J+JB ),\n $ LDA )\n END IF\n END IF\n 20 CONTINUE\n END IF\n RETURN\n*\n* End of ZGETRF\n*\n END\n","avg_line_length":27.9910313901,"max_line_length":111,"alphanum_fraction":0.4939122076} {"size":46490,"ext":"f90","lang":"FORTRAN","max_stars_count":102.0,"content":"! Groundwater Transport (GWT) Model\n! The following are additional features\/checks to add\n! * Add check that discretization is the same between both models \n! * Program GWT-GWT exchange transport (awaiting implementation of interface model)\n! * Consider implementation of steady-state transport (affects MST, IST)\n! * Check and handle pore space discrepancy between flow and transport (porosity vs specific yield)\n! * UZT may not have the required porosity term\n \nmodule GwtModule\n\n use KindModule, only: DP, I4B\n use InputOutputModule, only: ParseLine, upcase\n use ConstantsModule, only: LENFTYPE, DZERO, LENPAKLOC\n use VersionModule, only: write_listfile_header\n use NumericalModelModule, only: NumericalModelType \n use BaseModelModule, only: BaseModelType\n use BndModule, only: BndType, AddBndToList, GetBndFromList\n use GwtIcModule, only: GwtIcType\n use GwtFmiModule, only: GwtFmiType\n use GwtAdvModule, only: GwtAdvType\n use GwtDspModule, only: GwtDspType\n use GwtSsmModule, only: GwtSsmType\n use GwtMvtModule, only: GwtMvtType\n use GwtMstModule, only: GwtMstType\n use GwtOcModule, only: GwtOcType\n use GwtObsModule, only: GwtObsType\n use BudgetModule, only: BudgetType\n \n implicit none\n\n private\n public :: gwt_cr\n public :: GwtModelType\n\n type, extends(NumericalModelType) :: GwtModelType\n \n type(GwtIcType), pointer :: ic => null() ! initial conditions package\n type(GwtFmiType), pointer :: fmi => null() ! flow model interface\n type(GwtMstType), pointer :: mst => null() ! mass storage and transfer package\n type(GwtAdvType), pointer :: adv => null() ! advection package\n type(GwtDspType), pointer :: dsp => null() ! dispersion package\n type(GwtSsmType), pointer :: ssm => null() ! source sink mixing package\n type(GwtMvtType), pointer :: mvt => null() ! mover transport package\n type(GwtOcType), pointer :: oc => null() ! output control package\n type(GwtObsType), pointer :: obs => null() ! observation package\n type(BudgetType), pointer :: budget => null() ! budget object\n integer(I4B), pointer :: inic => null() ! unit number IC\n integer(I4B), pointer :: infmi => null() ! unit number FMI\n integer(I4B), pointer :: inmvt => null() ! unit number MVT\n integer(I4B), pointer :: inmst => null() ! unit number MST\n integer(I4B), pointer :: inadv => null() ! unit number ADV\n integer(I4B), pointer :: indsp => null() ! unit number DSP\n integer(I4B), pointer :: inssm => null() ! unit number SSM\n integer(I4B), pointer :: inoc => null() ! unit number OC\n integer(I4B), pointer :: inobs => null() ! unit number OBS\n \n contains\n \n procedure :: model_df => gwt_df\n procedure :: model_ac => gwt_ac\n procedure :: model_mc => gwt_mc\n procedure :: model_ar => gwt_ar\n procedure :: model_rp => gwt_rp\n procedure :: model_ad => gwt_ad\n procedure :: model_cf => gwt_cf\n procedure :: model_fc => gwt_fc\n procedure :: model_cc => gwt_cc\n procedure :: model_cq => gwt_cq\n procedure :: model_bd => gwt_bd\n procedure :: model_ot => gwt_ot\n procedure :: model_da => gwt_da\n \n procedure :: allocate_scalars\n procedure, private :: package_create\n procedure, private :: ftype_check\n procedure :: get_iasym => gwt_get_iasym\n procedure, private :: gwt_ot_flow\n procedure, private :: gwt_ot_flowja\n procedure, private :: gwt_ot_dv\n procedure, private :: gwt_ot_bdsummary\n procedure, private :: gwt_ot_obs\n \n end type GwtModelType\n\n ! -- Module variables constant for simulation\n integer(I4B), parameter :: NIUNIT=100\n character(len=LENFTYPE), dimension(NIUNIT) :: cunit\n data cunit\/ 'DIS6 ', 'DISV6', 'DISU6', 'IC6 ', 'MST6 ', & ! 5\n 'ADV6 ', 'DSP6 ', 'SSM6 ', ' ', 'CNC6 ', & ! 10\n 'OC6 ', 'OBS6 ', 'FMI6 ', 'SRC6 ', 'IST6 ', & ! 15\n 'LKT6 ', 'SFT6 ', 'MWT6 ', 'UZT6 ', 'MVT6 ', & ! 20\n 'API6 ', ' ', ' ', ' ', ' ', & ! 25\n 75 * ' '\/\n \n contains\n \n subroutine gwt_cr(filename, id, modelname)\n! ******************************************************************************\n! gwt_cr -- Create a new groundwater transport model object\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use ListsModule, only: basemodellist\n use BaseModelModule, only: AddBaseModelToList\n use SimModule, only: store_error, count_errors\n use ConstantsModule, only: LINELENGTH, LENPACKAGENAME\n use CompilerVersion\n use MemoryManagerModule, only: mem_allocate\n use MemoryHelperModule, only: create_mem_path\n use GwfDisModule, only: dis_cr\n use GwfDisvModule, only: disv_cr\n use GwfDisuModule, only: disu_cr\n use GwtIcModule, only: ic_cr\n use GwtFmiModule, only: fmi_cr\n use GwtMstModule, only: mst_cr\n use GwtAdvModule, only: adv_cr\n use GwtDspModule, only: dsp_cr\n use GwtSsmModule, only: ssm_cr\n use GwtMvtModule, only: mvt_cr\n use GwtOcModule, only: oc_cr\n use GwtObsModule, only: gwt_obs_cr\n use BudgetModule, only: budget_cr\n use NameFileModule, only: NameFileType\n ! -- dummy\n character(len=*), intent(in) :: filename\n integer(I4B), intent(in) :: id\n character(len=*), intent(in) :: modelname\n ! -- local\n integer(I4B) :: indis, indis6, indisu6, indisv6\n integer(I4B) :: ipakid, i, j, iu, ipaknum\n character(len=LINELENGTH) :: errmsg\n character(len=LENPACKAGENAME) :: pakname\n type(NameFileType) :: namefile_obj\n type(GwtModelType), pointer :: this\n class(BaseModelType), pointer :: model\n integer(I4B) :: nwords\n character(len=LINELENGTH), allocatable, dimension(:) :: words\n! ------------------------------------------------------------------------------\n !\n ! -- Allocate a new GWT Model (this) and add it to basemodellist\n allocate(this)\n !\n ! -- Set this before any allocs in the memory manager can be done\n this%memoryPath = create_mem_path(modelname)\n !\n call this%allocate_scalars(modelname)\n model => this\n call AddBaseModelToList(basemodellist, model)\n !\n ! -- Assign values\n this%filename = filename\n this%name = modelname\n this%macronym = 'GWT'\n this%id = id\n !\n ! -- Open namefile and set iout\n call namefile_obj%init(this%filename, 0)\n call namefile_obj%add_cunit(niunit, cunit)\n call namefile_obj%openlistfile(this%iout)\n !\n ! -- Write header to model list file\n call write_listfile_header(this%iout, 'GROUNDWATER TRANSPORT MODEL (GWT)')\n !\n ! -- Open files\n call namefile_obj%openfiles(this%iout)\n !\n ! --\n if (size(namefile_obj%opts) > 0) then\n write(this%iout, '(1x,a)') 'NAMEFILE OPTIONS:'\n end if\n !\n ! -- parse options in the gwt name file\n do i = 1, size(namefile_obj%opts)\n call ParseLine(namefile_obj%opts(i), nwords, words)\n call upcase(words(1))\n select case(words(1))\n case ('PRINT_INPUT')\n this%iprpak = 1\n write(this%iout,'(4x,a)') 'STRESS PACKAGE INPUT WILL BE PRINTED '\/\/ &\n 'FOR ALL MODEL STRESS PACKAGES'\n case ('PRINT_FLOWS')\n this%iprflow = 1\n write(this%iout,'(4x,a)') 'PACKAGE FLOWS WILL BE PRINTED '\/\/ &\n 'FOR ALL MODEL PACKAGES'\n case ('SAVE_FLOWS')\n this%ipakcb = -1\n write(this%iout, '(4x,a)') &\n 'FLOWS WILL BE SAVED TO BUDGET FILE SPECIFIED IN OUTPUT CONTROL'\n case default\n write(errmsg,'(4x,a,a,a,a)') &\n 'UNKNOWN GWT NAMEFILE (', &\n trim(adjustl(this%filename)), ') OPTION: ', &\n trim(adjustl(namefile_obj%opts(i)))\n call store_error(errmsg, terminate=.TRUE.)\n end select\n end do\n !\n ! -- Assign unit numbers to attached modules, and remove\n ! -- from unitnumber (by specifying 1 for iremove)\n !\n indis = 0\n indis6 = 0\n indisu6 = 0\n indisv6 = 0\n call namefile_obj%get_unitnumber('DIS6', indis6, 1)\n if(indis6 > 0) indis = indis6\n if(indis <= 0) call namefile_obj%get_unitnumber('DISU6', indisu6, 1)\n if(indisu6 > 0) indis = indisu6\n if(indis <= 0) call namefile_obj%get_unitnumber('DISV6', indisv6, 1)\n if(indisv6 > 0) indis = indisv6\n call namefile_obj%get_unitnumber('IC6', this%inic, 1)\n call namefile_obj%get_unitnumber('FMI6', this%infmi, 1)\n call namefile_obj%get_unitnumber('MVT6', this%inmvt, 1)\n call namefile_obj%get_unitnumber('MST6', this%inmst, 1)\n call namefile_obj%get_unitnumber('ADV6', this%inadv, 1)\n call namefile_obj%get_unitnumber('DSP6', this%indsp, 1)\n call namefile_obj%get_unitnumber('SSM6', this%inssm, 1)\n call namefile_obj%get_unitnumber('OC6', this%inoc, 1)\n call namefile_obj%get_unitnumber('OBS6', this%inobs, 1)\n !\n ! -- Check to make sure that required ftype's have been specified\n call this%ftype_check(namefile_obj, indis)\n !\n ! -- Create discretization object\n if(indis6 > 0) then\n call dis_cr(this%dis, this%name, indis, this%iout)\n elseif(indisu6 > 0) then\n call disu_cr(this%dis, this%name, indis, this%iout)\n elseif(indisv6 > 0) then\n call disv_cr(this%dis, this%name, indis, this%iout)\n endif\n !\n ! -- Create utility objects\n call budget_cr(this%budget, this%name)\n !\n ! -- Create packages that are tied directly to model\n call ic_cr(this%ic, this%name, this%inic, this%iout, this%dis)\n call fmi_cr(this%fmi, this%name, this%infmi, this%iout)\n call mst_cr(this%mst, this%name, this%inmst, this%iout, this%fmi)\n call adv_cr(this%adv, this%name, this%inadv, this%iout, this%fmi)\n call dsp_cr(this%dsp, this%name, this%indsp, this%iout, this%fmi)\n call ssm_cr(this%ssm, this%name, this%inssm, this%iout, this%fmi)\n call mvt_cr(this%mvt, this%name, this%inmvt, this%iout, this%fmi)\n call oc_cr(this%oc, this%name, this%inoc, this%iout)\n call gwt_obs_cr(this%obs, this%inobs)\n !\n ! -- Create stress packages\n ipakid = 1\n do i = 1, niunit\n ipaknum = 1\n do j = 1, namefile_obj%get_nval_for_row(i)\n iu = namefile_obj%get_unitnumber_rowcol(i, j)\n call namefile_obj%get_pakname(i, j, pakname)\n call this%package_create(cunit(i), ipakid, ipaknum, pakname, iu, &\n this%iout)\n ipaknum = ipaknum + 1\n ipakid = ipakid + 1\n enddo\n enddo\n !\n ! -- return\n return\n end subroutine gwt_cr\n\n subroutine gwt_df(this)\n! ******************************************************************************\n! gwt_df -- Define packages of the model\n! Subroutine: (1) call df routines for each package\n! (2) set variables and pointers\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n ! -- dummy\n class(GwtModelType) :: this\n ! -- local\n integer(I4B) :: ip\n class(BndType), pointer :: packobj\n! ------------------------------------------------------------------------------\n !\n ! -- Define packages and utility objects\n call this%dis%dis_df()\n call this%fmi%fmi_df(this%dis, this%inssm)\n if (this%inmvt > 0) call this%mvt%mvt_df(this%dis)\n if (this%indsp > 0) call this%dsp%dsp_df(this%dis)\n if (this%inssm > 0) call this%ssm%ssm_df()\n call this%oc%oc_df()\n call this%budget%budget_df(niunit, 'MASS', 'M')\n !\n ! -- Assign or point model members to dis members\n this%neq = this%dis%nodes\n this%nja = this%dis%nja\n this%ia => this%dis%con%ia\n this%ja => this%dis%con%ja\n !\n ! -- Allocate model arrays, now that neq and nja are assigned\n call this%allocate_arrays()\n !\n ! -- Define packages and assign iout for time series managers\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_df(this%neq, this%dis)\n packobj%TsManager%iout = this%iout\n packobj%TasManager%iout = this%iout\n enddo\n !\n ! -- Store information needed for observations\n call this%obs%obs_df(this%iout, this%name, 'GWT', this%dis)\n !\n ! -- return\n return\n end subroutine gwt_df\n\n subroutine gwt_ac(this, sparse)\n! ******************************************************************************\n! gwt_ac -- Add the internal connections of this model to the sparse matrix\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use SparseModule, only: sparsematrix\n ! -- dummy\n class(GwtModelType) :: this\n type(sparsematrix), intent(inout) :: sparse\n ! -- local\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n! ------------------------------------------------------------------------------\n !\n ! -- Add the internal connections of this model to sparse\n call this%dis%dis_ac(this%moffset, sparse)\n if (this%indsp > 0) &\n call this%dsp%dsp_ac(this%moffset, sparse)\n !\n ! -- Add any package connections\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ac(this%moffset, sparse)\n enddo\n !\n ! -- return\n return\n end subroutine gwt_ac\n\n subroutine gwt_mc(this, iasln, jasln)\n! ******************************************************************************\n! gwt_mc -- Map the positions of this models connections in the\n! numerical solution coefficient matrix.\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B), dimension(:), intent(in) :: iasln\n integer(I4B), dimension(:), intent(in) :: jasln\n ! -- local\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n! ------------------------------------------------------------------------------\n !\n ! -- Find the position of each connection in the global ia, ja structure\n ! and store them in idxglo.\n call this%dis%dis_mc(this%moffset, this%idxglo, iasln, jasln)\n if (this%indsp > 0) call this%dsp%dsp_mc(this%moffset, iasln, jasln)\n !\n ! -- Map any package connections\n do ip=1,this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_mc(this%moffset, iasln, jasln)\n enddo\n !\n ! -- return\n return\n end subroutine gwt_mc\n\n subroutine gwt_ar(this)\n! ******************************************************************************\n! gwt_ar -- GroundWater Transport Model Allocate and Read\n! Subroutine: (1) allocates and reads packages part of this model,\n! (2) allocates memory for arrays part of this model object\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use ConstantsModule, only: DHNOFLO\n ! -- dummy\n class(GwtModelType) :: this\n ! -- locals\n integer(I4B) :: ip\n class(BndType), pointer :: packobj\n! ------------------------------------------------------------------------------\n !\n ! -- Allocate and read modules attached to model\n call this%fmi%fmi_ar(this%ibound)\n if (this%inmvt > 0) call this%mvt%mvt_ar()\n if (this%inic > 0) call this%ic%ic_ar(this%x)\n if (this%inmst > 0) call this%mst%mst_ar(this%dis, this%ibound)\n if (this%inadv > 0) call this%adv%adv_ar(this%dis, this%ibound)\n if (this%indsp > 0) call this%dsp%dsp_ar(this%ibound, this%mst%porosity)\n if (this%inssm > 0) call this%ssm%ssm_ar(this%dis, this%ibound, this%x)\n if (this%inobs > 0) call this%obs%gwt_obs_ar(this%ic, this%x, this%flowja)\n !\n ! -- Call dis_ar to write binary grid file\n !call this%dis%dis_ar(this%npf%icelltype)\n !\n ! -- set up output control\n call this%oc%oc_ar(this%x, this%dis, DHNOFLO)\n call this%budget%set_ibudcsv(this%oc%ibudcsv)\n !\n ! -- Package input files now open, so allocate and read\n do ip=1,this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%set_pointers(this%dis%nodes, this%ibound, this%x, &\n this%xold, this%flowja)\n ! -- Read and allocate package\n call packobj%bnd_ar()\n enddo\n !\n ! -- return\n return\n end subroutine gwt_ar\n\n subroutine gwt_rp(this)\n! ******************************************************************************\n! gwt_rp -- GroundWater Transport Model Read and Prepare\n! Subroutine: (1) calls package read and prepare routines\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use TdisModule, only: readnewdata\n ! -- dummy\n class(GwtModelType) :: this\n ! -- local\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n! ------------------------------------------------------------------------------\n !\n ! -- In fmi, check for mvt and mvrbudobj consistency\n call this%fmi%fmi_rp(this%inmvt)\n if (this%inmvt > 0) call this%mvt%mvt_rp()\n !\n ! -- Check with TDIS on whether or not it is time to RP\n if (.not. readnewdata) return\n !\n ! -- Read and prepare\n if(this%inoc > 0) call this%oc%oc_rp()\n if(this%inssm > 0) call this%ssm%ssm_rp()\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_rp()\n call packobj%bnd_rp_obs()\n enddo\n !\n ! -- Return\n return\n end subroutine gwt_rp\n \n subroutine gwt_ad(this)\n! ******************************************************************************\n! gwt_ad -- GroundWater Transport Model Time Step Advance\n! Subroutine: (1) calls package advance subroutines\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use SimVariablesModule, only: isimcheck, iFailedStepRetry\n ! -- dummy\n class(GwtModelType) :: this\n class(BndType), pointer :: packobj\n ! -- local\n integer(I4B) :: irestore\n integer(I4B) :: ip, n\n! ------------------------------------------------------------------------------\n !\n ! -- Reset state variable\n irestore = 0\n if (iFailedStepRetry > 0) irestore = 1\n if (irestore == 0) then\n !\n ! -- copy x into xold\n do n = 1, this%dis%nodes\n if (this%ibound(n) == 0) then\n this%xold(n) = DZERO\n else\n this%xold(n) = this%x(n)\n end if\n enddo\n else\n !\n ! -- copy xold into x if this time step is a redo\n do n = 1, this%dis%nodes\n this%x(n) = this%xold(n)\n enddo\n end if\n !\n ! -- Advance fmi\n call this%fmi%fmi_ad(this%x)\n !\n ! -- Advance\n !if(this%inmst > 0) call this%mst%mst_ad()\n if(this%indsp > 0) call this%dsp%dsp_ad()\n if(this%inssm > 0) call this%ssm%ssm_ad()\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ad()\n if (isimcheck > 0) then\n call packobj%bnd_ck()\n end if\n enddo\n !\n ! -- Push simulated values to preceding time\/subtime step\n call this%obs%obs_ad()\n !\n ! -- return\n return\n end subroutine gwt_ad\n\n subroutine gwt_cf(this, kiter)\n! ******************************************************************************\n! gwt_cf -- GroundWater Transport Model calculate coefficients\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B),intent(in) :: kiter\n ! -- local\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n! ------------------------------------------------------------------------------\n !\n ! -- Call package cf routines\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_cf()\n enddo\n !\n ! -- return\n return\n end subroutine gwt_cf\n\n subroutine gwt_fc(this, kiter, amatsln, njasln, inwtflag)\n! ******************************************************************************\n! gwt_fc -- GroundWater Transport Model fill coefficients\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B), intent(in) :: kiter\n integer(I4B), intent(in) :: njasln\n real(DP), dimension(njasln), intent(inout) :: amatsln\n integer(I4B), intent(in) :: inwtflag\n ! -- local\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n! ------------------------------------------------------------------------------\n !\n ! -- call fc routines\n call this%fmi%fmi_fc(this%dis%nodes, this%xold, this%nja, njasln, &\n amatsln, this%idxglo, this%rhs)\n if (this%inmvt > 0) then\n call this%mvt%mvt_fc(this%dis%nodes, this%xold, this%nja, njasln, &\n amatsln, this%idxglo, this%x, this%rhs)\n end if\n if(this%inmst > 0) then\n call this%mst%mst_fc(this%dis%nodes, this%xold, this%nja, njasln, &\n amatsln, this%idxglo, this%x, this%rhs, kiter)\n endif\n if(this%inadv > 0) then\n call this%adv%adv_fc(this%dis%nodes, amatsln, this%idxglo, this%x, &\n this%rhs)\n endif\n if(this%indsp > 0) then\n call this%dsp%dsp_fc(kiter, this%dis%nodes, this%nja, njasln, amatsln, &\n this%idxglo, this%rhs, this%x)\n endif\n if(this%inssm > 0) then\n call this%ssm%ssm_fc(amatsln, this%idxglo, this%rhs)\n endif\n !\n ! -- packages\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_fc(this%rhs, this%ia, this%idxglo, amatsln)\n enddo\n !\n ! -- return\n return\n end subroutine gwt_fc\n\n subroutine gwt_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)\n! ******************************************************************************\n! gwt_cc -- GroundWater Transport Model Final Convergence Check\n! Subroutine: (1) calls package cc routines\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B),intent(in) :: innertot\n integer(I4B),intent(in) :: kiter\n integer(I4B),intent(in) :: iend\n integer(I4B),intent(in) :: icnvgmod\n character(len=LENPAKLOC), intent(inout) :: cpak\n integer(I4B), intent(inout) :: ipak\n real(DP), intent(inout) :: dpak\n ! -- local\n !class(BndType), pointer :: packobj\n !integer(I4B) :: ip\n ! -- formats\n! ------------------------------------------------------------------------------\n !\n ! -- If mover is on, then at least 2 outers required\n if (this%inmvt > 0) call this%mvt%mvt_cc(kiter, iend, icnvgmod, cpak, dpak)\n !\n ! -- Call package cc routines\n !do ip = 1, this%bndlist%Count()\n ! packobj => GetBndFromList(this%bndlist, ip)\n ! call packobj%bnd_cc(iend, icnvg, hclose, rclose)\n !enddo\n !\n ! -- return\n return\n end subroutine gwt_cc\n \n subroutine gwt_cq(this, icnvg, isuppress_output)\n! ******************************************************************************\n! gwt_cq --Groundwater transport model calculate flow\n! Subroutine: (1) Calculate intercell flows (flowja)\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use SparseModule, only: csr_diagsum\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B), intent(in) :: icnvg\n integer(I4B), intent(in) :: isuppress_output\n ! -- local\n integer(I4B) :: i\n integer(I4B) :: ip\n class(BndType), pointer :: packobj\n! ------------------------------------------------------------------------------\n !\n ! -- Construct the flowja array. Flowja is calculated each time, even if\n ! output is suppressed. (flowja is positive into a cell.) The diagonal\n ! position of the flowja array will contain the flow residual after\n ! these routines are called, so each package is responsible for adding\n ! its flow to this diagonal position.\n do i = 1, this%nja\n this%flowja(i) = DZERO\n enddo\n if(this%inadv > 0) call this%adv%adv_cq(this%x, this%flowja)\n if(this%indsp > 0) call this%dsp%dsp_cq(this%x, this%flowja)\n if(this%inmst > 0) call this%mst%mst_cq(this%dis%nodes, this%x, this%xold, &\n this%flowja)\n if(this%inssm > 0) call this%ssm%ssm_cq(this%flowja)\n if(this%infmi > 0) call this%fmi%fmi_cq(this%x, this%flowja)\n !\n ! -- Go through packages and call cq routines. cf() routines are called\n ! first to regenerate non-linear terms to be consistent with the final\n ! conc solution.\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_cf(reset_mover=.false.)\n call packobj%bnd_cq(this%x, this%flowja)\n enddo\n !\n ! -- Finalize calculation of flowja by adding face flows to the diagonal.\n ! This results in the flow residual being stored in the diagonal\n ! position for each cell.\n call csr_diagsum(this%dis%con%ia, this%flowja)\n !\n ! -- Return\n return\n end subroutine gwt_cq\n\n subroutine gwt_bd(this, icnvg, isuppress_output)\n! ******************************************************************************\n! gwt_bd --GroundWater Transport Model Budget\n! Subroutine: (1) Calculate intercell flows (flowja)\n! (2) Calculate package contributions to model budget\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n use ConstantsModule, only: DZERO\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B), intent(in) :: icnvg\n integer(I4B), intent(in) :: isuppress_output\n ! -- local\n integer(I4B) :: ip\n class(BndType),pointer :: packobj\n! ------------------------------------------------------------------------------\n !\n ! -- Save the solution convergence flag\n this%icnvg = icnvg\n !\n ! -- Budget routines (start by resetting). Sole purpose of this section\n ! is to add in and outs to model budget. All ins and out for a model\n ! should be added here to this%budget. In a subsequent exchange call,\n ! exchange flows might also be added.\n call this%budget%reset()\n if(this%inmst > 0) call this%mst%mst_bd(isuppress_output, this%budget)\n if(this%inssm > 0) call this%ssm%ssm_bd(isuppress_output, this%budget)\n if(this%infmi > 0) call this%fmi%fmi_bd(isuppress_output, this%budget)\n if(this%inmvt > 0) call this%mvt%mvt_bd(this%x)\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_bd(this%budget)\n enddo\n\n !\n ! -- Return\n return\n end subroutine gwt_bd\n\n subroutine gwt_ot(this)\n! ******************************************************************************\n! gwt_ot -- GroundWater Transport Model Output\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use TdisModule, only: kstp, kper, tdis_ot, endofperiod\n ! -- dummy\n class(GwtModelType) :: this\n ! -- local\n integer(I4B) :: idvsave\n integer(I4B) :: idvprint\n integer(I4B) :: icbcfl\n integer(I4B) :: icbcun\n integer(I4B) :: ibudfl\n integer(I4B) :: ipflag\n ! -- formats\n character(len=*),parameter :: fmtnocnvg = &\n \"(1X,\/9X,'****FAILED TO MEET SOLVER CONVERGENCE CRITERIA IN TIME STEP ', &\n &I0,' OF STRESS PERIOD ',I0,'****')\"\n! ------------------------------------------------------------------------------\n !\n ! -- Set write and print flags\n idvsave = 0\n idvprint = 0\n icbcfl = 0\n ibudfl = 0\n if(this%oc%oc_save('CONCENTRATION')) idvsave = 1\n if(this%oc%oc_print('CONCENTRATION')) idvprint = 1\n if(this%oc%oc_save('BUDGET')) icbcfl = 1\n if(this%oc%oc_print('BUDGET')) ibudfl = 1\n icbcun = this%oc%oc_save_unit('BUDGET')\n !\n ! -- Override ibudfl and idvprint flags for nonconvergence\n ! and end of period\n ibudfl = this%oc%set_print_flag('BUDGET', this%icnvg, endofperiod)\n idvprint = this%oc%set_print_flag('CONCENTRATION', this%icnvg, endofperiod)\n !\n ! Calculate and save observations\n call this%gwt_ot_obs()\n ! \n ! Save and print flows\n call this%gwt_ot_flow(icbcfl, ibudfl, icbcun)\n ! \n ! Save and print dependent variables\n call this%gwt_ot_dv(idvsave, idvprint, ipflag)\n ! \n ! Print budget summaries\n call this%gwt_ot_bdsummary(ibudfl, ipflag)\n !\n ! -- Timing Output; if any dependendent variables or budgets\n ! are printed, then ipflag is set to 1.\n if(ipflag == 1) call tdis_ot(this%iout)\n !\n ! -- Write non-convergence message\n if(this%icnvg == 0) then\n write(this%iout, fmtnocnvg) kstp, kper\n endif\n !\n ! -- Return\n return\n end subroutine gwt_ot\n \n subroutine gwt_ot_obs(this)\n class(GwtModelType) :: this\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n \n ! -- Calculate and save observations\n call this%obs%obs_bd()\n call this%obs%obs_ot()\n \n ! -- Calculate and save package obserations\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_bd_obs()\n call packobj%bnd_ot_obs()\n end do\n \n end subroutine gwt_ot_obs\n \n subroutine gwt_ot_flow(this, icbcfl, ibudfl, icbcun)\n class(GwtModelType) :: this\n integer(I4B), intent(in) :: icbcfl\n integer(I4B), intent(in) :: ibudfl\n integer(I4B), intent(in) :: icbcun\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n\n ! -- Save GWT flows\n call this%gwt_ot_flowja(this%nja, this%flowja, icbcfl, icbcun)\n if(this%inmst > 0) call this%mst%mst_ot_flow(icbcfl, icbcun)\n if(this%infmi > 0) call this%fmi%fmi_ot_flow(icbcfl, icbcun)\n if(this%inssm > 0) call this%ssm%ssm_ot_flow(icbcfl=icbcfl, ibudfl=0, icbcun=icbcun)\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=0, icbcun=icbcun)\n end do\n \n ! -- Save advanced package flows\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ot_package_flows(icbcfl=icbcfl, ibudfl=0)\n end do\n if(this%inmvt > 0) then\n call this%mvt%mvt_ot_saveflow(icbcfl, ibudfl)\n end if\n\n ! -- Print GWF flows\n ! no need to print flowja\n ! no need to print mst\n ! no need to print fmi\n if(this%inssm > 0) call this%ssm%ssm_ot_flow(icbcfl=icbcfl, ibudfl=ibudfl, icbcun=0)\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=ibudfl, icbcun=0)\n end do\n \n ! -- Print advanced package flows\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ot_package_flows(icbcfl=0, ibudfl=ibudfl)\n end do\n if(this%inmvt > 0) then\n call this%mvt%mvt_ot_printflow(icbcfl, ibudfl)\n end if\n \n end subroutine gwt_ot_flow\n \n subroutine gwt_ot_flowja(this, nja, flowja, icbcfl, icbcun)\n! ******************************************************************************\n! gwt_ot_flowja -- Write intercell flows\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- dummy\n class(GwtModelType) :: this\n integer(I4B),intent(in) :: nja\n real(DP),dimension(nja),intent(in) :: flowja\n integer(I4B), intent(in) :: icbcfl\n integer(I4B), intent(in) :: icbcun\n ! -- local\n integer(I4B) :: ibinun\n ! -- formats\n! ------------------------------------------------------------------------------\n !\n ! -- Set unit number for binary output\n if(this%ipakcb < 0) then\n ibinun = icbcun\n elseif(this%ipakcb == 0) then\n ibinun = 0\n else\n ibinun = this%ipakcb\n endif\n if(icbcfl == 0) ibinun = 0\n !\n ! -- Write the face flows if requested\n if(ibinun \/= 0) then\n call this%dis%record_connection_array(flowja, ibinun, this%iout)\n endif\n !\n ! -- Return\n return\n end subroutine gwt_ot_flowja\n\n subroutine gwt_ot_dv(this, idvsave, idvprint, ipflag)\n class(GwtModelType) :: this\n integer(I4B), intent(in) :: idvsave\n integer(I4B), intent(in) :: idvprint\n integer(I4B), intent(inout) :: ipflag\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n \n ! -- Print advanced package dependent variables\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ot_dv(idvsave, idvprint)\n end do\n \n ! -- save head and print head\n call this%oc%oc_ot(ipflag)\n \n end subroutine gwt_ot_dv\n \n subroutine gwt_ot_bdsummary(this, ibudfl, ipflag)\n use TdisModule, only: kstp, kper, totim\n class(GwtModelType) :: this\n integer(I4B), intent(in) :: ibudfl\n integer(I4B), intent(inout) :: ipflag\n class(BndType), pointer :: packobj\n integer(I4B) :: ip\n\n !\n ! -- Package budget summary\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_ot_bdsummary(kstp, kper, this%iout, ibudfl)\n enddo\n \n ! -- mover budget summary\n if(this%inmvt > 0) then\n call this%mvt%mvt_ot_bdsummary(ibudfl)\n end if\n \n ! -- model budget summary\n if (ibudfl \/= 0) then\n ipflag = 1\n call this%budget%budget_ot(kstp, kper, this%iout)\n end if\n \n ! -- Write to budget csv\n call this%budget%writecsv(totim)\n \n end subroutine gwt_ot_bdsummary\n \n subroutine gwt_da(this)\n! ******************************************************************************\n! gwt_da -- Deallocate\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use MemoryManagerModule, only: mem_deallocate\n ! -- dummy\n class(GwtModelType) :: this\n ! -- local\n integer(I4B) :: ip\n class(BndType),pointer :: packobj\n! ------------------------------------------------------------------------------\n !\n ! -- Internal flow packages deallocate\n call this%dis%dis_da()\n call this%ic%ic_da()\n call this%fmi%fmi_da()\n call this%adv%adv_da()\n call this%dsp%dsp_da()\n call this%ssm%ssm_da()\n call this%mst%mst_da()\n call this%mvt%mvt_da()\n call this%budget%budget_da()\n call this%oc%oc_da()\n call this%obs%obs_da()\n !\n ! -- Internal package objects\n deallocate(this%dis)\n deallocate(this%ic)\n deallocate(this%fmi)\n deallocate(this%adv)\n deallocate(this%dsp)\n deallocate(this%ssm)\n deallocate(this%mst)\n deallocate(this%mvt)\n deallocate(this%budget)\n deallocate(this%oc)\n deallocate(this%obs)\n !\n ! -- Boundary packages\n do ip = 1, this%bndlist%Count()\n packobj => GetBndFromList(this%bndlist, ip)\n call packobj%bnd_da()\n deallocate(packobj)\n enddo\n !\n ! -- Scalars\n call mem_deallocate(this%inic)\n call mem_deallocate(this%infmi)\n call mem_deallocate(this%inadv)\n call mem_deallocate(this%indsp)\n call mem_deallocate(this%inssm)\n call mem_deallocate(this%inmst)\n call mem_deallocate(this%inmvt)\n call mem_deallocate(this%inoc)\n call mem_deallocate(this%inobs)\n !\n ! -- NumericalModelType\n call this%NumericalModelType%model_da()\n !\n ! -- return\n return\n end subroutine gwt_da\n\n function gwt_get_iasym(this) result (iasym)\n! ******************************************************************************\n! gwt_get_iasym -- return 1 if any package causes the matrix to be asymmetric.\n! Otherwise return 0.\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n class(GwtModelType) :: this\n ! -- local\n integer(I4B) :: iasym\n! ------------------------------------------------------------------------------\n !\n ! -- Start by setting iasym to zero\n iasym = 0\n !\n ! -- ADV\n if (this%inadv > 0) then\n if (this%adv%iasym \/= 0) iasym = 1\n endif\n !\n ! -- return\n return\n end function gwt_get_iasym\n\n subroutine allocate_scalars(this, modelname)\n! ******************************************************************************\n! allocate_scalars -- Allocate memory for non-allocatable members\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use MemoryManagerModule, only: mem_allocate\n ! -- dummy\n class(GwtModelType) :: this\n character(len=*), intent(in) :: modelname\n! ------------------------------------------------------------------------------\n !\n ! -- allocate members from parent class\n call this%NumericalModelType%allocate_scalars(modelname)\n !\n ! -- allocate members that are part of model class\n call mem_allocate(this%inic , 'INIC', this%memoryPath)\n call mem_allocate(this%infmi, 'INFMI', this%memoryPath)\n call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)\n call mem_allocate(this%inmst, 'INMST', this%memoryPath)\n call mem_allocate(this%inadv, 'INADV', this%memoryPath)\n call mem_allocate(this%indsp, 'INDSP', this%memoryPath)\n call mem_allocate(this%inssm, 'INSSM', this%memoryPath)\n call mem_allocate(this%inoc, 'INOC ', this%memoryPath)\n call mem_allocate(this%inobs, 'INOBS', this%memoryPath)\n !\n this%inic = 0\n this%infmi = 0\n this%inmvt = 0\n this%inmst = 0\n this%inadv = 0\n this%indsp = 0\n this%inssm = 0\n this%inoc = 0\n this%inobs = 0\n !\n ! -- return\n return\n end subroutine allocate_scalars\n\n subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, inunit, &\n iout)\n! ******************************************************************************\n! package_create -- Create boundary condition packages for this model\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use ConstantsModule, only: LINELENGTH\n use SimModule, only: store_error\n use GwtCncModule, only: cnc_create\n use GwtSrcModule, only: src_create\n use GwtIstModule, only: ist_create\n use GwtLktModule, only: lkt_create\n use GwtSftModule, only: sft_create\n use GwtMwtModule, only: mwt_create\n use GwtUztModule, only: uzt_create\n use ApiModule, only: api_create\n ! -- dummy\n class(GwtModelType) :: this\n character(len=*),intent(in) :: filtyp\n character(len=LINELENGTH) :: errmsg\n integer(I4B),intent(in) :: ipakid\n integer(I4B),intent(in) :: ipaknum\n character(len=*), intent(in) :: pakname\n integer(I4B),intent(in) :: inunit\n integer(I4B),intent(in) :: iout\n ! -- local\n class(BndType), pointer :: packobj\n class(BndType), pointer :: packobj2\n integer(I4B) :: ip\n! ------------------------------------------------------------------------------\n !\n ! -- This part creates the package object\n select case(filtyp)\n case('CNC6')\n call cnc_create(packobj, ipakid, ipaknum, inunit, iout, this%name, pakname)\n case('SRC6')\n call src_create(packobj, ipakid, ipaknum, inunit, iout, this%name, pakname)\n case('LKT6')\n call lkt_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &\n pakname, this%fmi)\n case('SFT6')\n call sft_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &\n pakname, this%fmi)\n case('MWT6')\n call mwt_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &\n pakname, this%fmi)\n case('UZT6')\n call uzt_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &\n pakname, this%fmi)\n case('IST6')\n call ist_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &\n pakname, this%fmi, this%mst)\n case('API6')\n call api_create(packobj, ipakid, ipaknum, inunit, iout, this%name, pakname)\n case default\n write(errmsg, *) 'Invalid package type: ', filtyp\n call store_error(errmsg, terminate=.TRUE.)\n end select\n !\n ! -- Packages is the bndlist that is associated with the parent model\n ! -- The following statement puts a pointer to this package in the ipakid\n ! -- position of packages.\n do ip = 1, this%bndlist%Count()\n packobj2 => GetBndFromList(this%bndlist, ip)\n if(packobj2%packName == pakname) then\n write(errmsg, '(a,a)') 'Cannot create package. Package name ' \/\/ &\n 'already exists: ', trim(pakname)\n call store_error(errmsg, terminate=.TRUE.)\n endif\n enddo\n call AddBndToList(this%bndlist, packobj)\n !\n ! -- return\n return\n end subroutine package_create\n\n subroutine ftype_check(this, namefile_obj, indis)\n! ******************************************************************************\n! ftype_check -- Check to make sure required input files have been specified\n! ******************************************************************************\n!\n! SPECIFICATIONS:\n! ------------------------------------------------------------------------------\n ! -- modules\n use ConstantsModule, only: LINELENGTH\n use SimModule, only: store_error, count_errors\n use NameFileModule, only: NameFileType\n ! -- dummy\n class(GwtModelType) :: this\n type(NameFileType), intent(in) :: namefile_obj\n integer(I4B), intent(in) :: indis\n ! -- local\n character(len=LINELENGTH) :: errmsg\n integer(I4B) :: i, iu\n character(len=LENFTYPE), dimension(10) :: nodupftype = &\n (\/'DIS6 ', 'DISU6', 'DISV6', 'IC6 ', 'MST6 ', 'ADV6 ', 'DSP6 ', &\n 'SSM6 ', 'OC6 ', 'OBS6 '\/)\n! ------------------------------------------------------------------------------\n !\n ! -- Check for IC6, DIS(u), and MST. Stop if not present.\n if(this%inic == 0) then\n write(errmsg, '(1x,a)') 'ERROR. INITIAL CONDITIONS (IC6) PACKAGE NOT SPECIFIED.'\n call store_error(errmsg)\n endif\n if(indis == 0) then\n write(errmsg, '(1x,a)') &\n 'ERROR. DISCRETIZATION (DIS6 or DISU6) PACKAGE NOT SPECIFIED.'\n call store_error(errmsg)\n endif\n if(this%inmst == 0) then\n write(errmsg, '(1x,a)') 'ERROR. MASS STORAGE AND TRANSFER (MST6) &\n &PACKAGE NOT SPECIFIED.'\n call store_error(errmsg)\n endif\n if(count_errors() > 0) then\n write(errmsg,'(1x,a)') 'ERROR. REQUIRED PACKAGE(S) NOT SPECIFIED.'\n call store_error(errmsg)\n endif\n !\n ! -- Check to make sure that some GWT packages are not specified more\n ! than once\n do i = 1, size(nodupftype)\n call namefile_obj%get_unitnumber(trim(nodupftype(i)), iu, 0)\n if (iu > 0) then\n write(errmsg,'(1x, a, a, a)') &\n 'DUPLICATE ENTRIES FOR FTYPE ', trim(nodupftype(i)), &\n ' NOT ALLOWED FOR GWT MODEL.'\n call store_error(errmsg)\n endif\n enddo\n !\n ! -- Stop if errors\n if(count_errors() > 0) then\n write(errmsg, '(a, a)') 'ERROR OCCURRED WHILE READING FILE: ', &\n trim(namefile_obj%filename)\n call store_error(errmsg, terminate=.TRUE.)\n endif\n !\n ! -- return\n return\n end subroutine ftype_check\n\n\n \nend module GwtModule\n","avg_line_length":37.6437246964,"max_line_length":115,"alphanum_fraction":0.529683803} {"size":13400,"ext":"f","lang":"FORTRAN","max_stars_count":2.0,"content":" program Game2048\n\n call main()\n stop\n end\n\n subroutine init_num()\n integer*8 :: ZF0F00F0F\n integer*8 :: ZFF00FF00\n integer*8 :: t8_1, t8_2\n integer*8 :: ROW_MASK, COL_MASK\n common \/MASK_NUM\/ ROW_MASK, COL_MASK\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n integer*8 :: ZF0F00F0FF0F00F0F, Z0000F0F00000F0F0,\n & Z0F0F00000F0F0000, ZFF00FF0000FF00FF\n integer*8 :: Z00FF00FF00000000, Z00000000FF00FF00,\n & Z3333333333333333, Z1111111111111111\n common \/LARGE_NUM1\/ ZF0F00F0FF0F00F0F, Z0000F0F00000F0F0,\n & Z0F0F00000F0F0000, ZFF00FF0000FF00FF\n common \/LARGE_NUM2\/ Z00FF00FF00000000, Z00000000FF00FF00,\n & Z3333333333333333, Z1111111111111111\n\n ROW_MASK = 65535\n t8_1 = 983055\n COL_MASK = ior(ishft(t8_1, 32), t8_1)\n\n Z000F = 15\n Z00F0 = 240\n Z0F00 = 3840\n\n t8_1 = 61680\n t8_2 = 3855\n ZF0F00F0F = ior(ishft(t8_1, 16), t8_2)\n t8_1 = 65280\n ZFF00FF00 = ior(ishft(t8_1, 16), t8_1) \n\n ZF0F00F0FF0F00F0F = ior(ishft(ZF0F00F0F, 32), ZF0F00F0F)\n t8_1 = 61680\n Z0000F0F00000F0F0 = ior(ishft(t8_1, 32), t8_1)\n t8_1 = 252641280\n Z0F0F00000F0F0000 = ior(ishft(t8_1, 32), t8_1)\n t8_1 = 16711935\n ZFF00FF0000FF00FF = ior(ishft(ZFF00FF00, 32), t8_1)\n t8_1 = 16711935\n Z00FF00FF00000000 = ishft(t8_1, 32)\n Z00000000FF00FF00 = ZFF00FF00\n t8_1 = 858993459\n Z3333333333333333 = ior(ishft(t8_1, 32), t8_1)\n t8_1 = 286331153\n Z1111111111111111 = ior(ishft(t8_1, 32), t8_1)\n end\n\n integer*4 function unif_random(n)\n integer*4 :: n\n external c_rand\n integer*4 :: c_rand\n\n unif_random = mod(c_rand(), n)\n end\n\n integer*8 function unpack_col(row)\n integer*2 :: row\n integer*8 :: t0, t1, t2, t3\n integer*8 :: ROW_MASK, COL_MASK\n common \/MASK_NUM\/ ROW_MASK, COL_MASK\n\n t0 = row\n t0 = iand(t0, ROW_MASK)\n t1 = ishft(t0, 12)\n t2 = ishft(t0, 24)\n t3 = ishft(t0, 36)\n\n unpack_col = iand(ior(ior(ior(t0, t1), t2), t3), COL_MASK)\n end\n\n integer*2 function reverse_row(row)\n integer*2 :: row\n integer*2 :: t0, t1, t2, t3\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n\n t0 = ishft(row, -12)\n t1 = iand(ishft(row, -4), Z00F0)\n t2 = iand(ishft(row, 4), Z0F00)\n t3 = ishft(row, 12)\n\n reverse_row = ior(ior(ior(t0, t1), t2), t3)\n end\n\n subroutine print_board(board)\n integer*8 :: board\n integer*8 :: board_, t_\n integer*4 :: i, j, power_val\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n\n board_ = board\n t_ = Z000F\n write(*, *) '-----------------------------'\n do i = 0, 3\n do j = 0, 3\n power_val = iand(board_, t_)\n if (power_val == 0) then\n write(*, '(a, \" \", $)') '|'\n else\n write(*, '(a, i6, $)')\n & '|', ishft(1, power_val)\n end if\n board_ = ishft(board_, -4)\n end do\n write(*, '(a)') '|'\n end do\n write(*, *) '-----------------------------'\n end\n\n integer*8 function transpose_board(x)\n integer*8 :: x\n integer*8 :: a1, a2, a3, a, b1, b2, b3\n integer*8 :: ZF0F00F0FF0F00F0F, Z0000F0F00000F0F0,\n & Z0F0F00000F0F0000, ZFF00FF0000FF00FF\n integer*8 :: Z00FF00FF00000000, Z00000000FF00FF00,\n & Z3333333333333333, Z1111111111111111\n common \/LARGE_NUM1\/ ZF0F00F0FF0F00F0F, Z0000F0F00000F0F0,\n & Z0F0F00000F0F0000, ZFF00FF0000FF00FF\n common \/LARGE_NUM2\/ Z00FF00FF00000000, Z00000000FF00FF00,\n & Z3333333333333333, Z1111111111111111\n\n a1 = iand(x, ZF0F00F0FF0F00F0F)\n a2 = iand(x, Z0000F0F00000F0F0)\n a3 = iand(x, Z0F0F00000F0F0000)\n a = ior(ior(a1, ishft(a2, 12)), ishft(a3, -12))\n b1 = iand(a, ZFF00FF0000FF00FF)\n b2 = iand(a, Z00FF00FF00000000)\n b3 = iand(a, Z00000000FF00FF00)\n\n transpose_board = ior(ior(b1, ishft(b2, -24)), ishft(b3, 24))\n end function transpose_board\n\n integer*4 function count_empty(x)\n integer*8 :: x\n integer*8 :: x_, t_\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n integer*8 :: Z00FF00FF00000000, Z00000000FF00FF00,\n & Z3333333333333333, Z1111111111111111\n common \/LARGE_NUM2\/ Z00FF00FF00000000, Z00000000FF00FF00,\n & Z3333333333333333, Z1111111111111111\n\n x_ = x\n x_ = ior(x_, iand(ishft(x_, -2), Z3333333333333333))\n x_ = ior(x_, ishft(x_, -1))\n x_ = iand(not(x_), Z1111111111111111)\n x_ = x_ + ishft(x_, -32)\n x_ = x_ + ishft(x_, -16)\n x_ = x_ + ishft(x_, -8)\n x_ = x_ + ishft(x_, -4)\n t_ = Z000F\n count_empty = iand(x_, t_)\n end\n\n integer*2 function execute_move_helper(row)\n integer*2 :: row\n integer*2 :: i, j, t0, t1, t2, t3\n integer*2 :: row_line(0:3)\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n\n row_line(0) = iand(row, Z000F)\n row_line(1) = iand(ishft(row, -4), Z000F)\n row_line(2) = iand(ishft(row, -8), Z000F)\n row_line(3) = iand(ishft(row, -12), Z000F)\n i = 0\n do while (i < 3)\n j = i + 1\n do while (j < 4)\n if (row_line(j) \/= 0) then\n exit\n end if\n j = j + 1\n end do\n if (j == 4) then\n exit\n end if\n if (row_line(i) == 0) then\n row_line(i) = row_line(j)\n row_line(j) = 0\n i = i - 1\n else if (row_line(i) == row_line(j)) then\n if (row_line(i) \/= 15) then\n row_line(i) = row_line(i) + 1\n end if\n row_line(j) = 0\n end if\n i = i + 1\n end do\n t0 = row_line(0)\n t1 = ishft(row_line(1), 4)\n t2 = ishft(row_line(2), 8)\n t3 = ishft(row_line(3), 12)\n execute_move_helper = ior(ior(ior(t0, t1), t2), t3)\n end\n\n integer*8 function execute_move(board, move)\n integer*8 :: board\n integer*4 :: move\n integer*8 :: ret, t\n integer*2 :: row, rev_row, i\n integer*8 :: transpose_board, unpack_col\n integer*2 :: reverse_row, execute_move_helper\n integer*8 :: ROW_MASK, COL_MASK\n common \/MASK_NUM\/ ROW_MASK, COL_MASK\n\n ret = board\n if ((move == 0) .or. (move == 1)) then\n t = transpose_board(board)\n else\n t = board\n end if\n do i = 0, 3\n row = iand(ishft(t, -ishft(i, 4)), ROW_MASK)\n if (move == 0) then\n ret = ieor(ret, ishft(unpack_col(ieor(row,\n & execute_move_helper(row))), ishft(i, 2)))\n else if (move == 1) then\n rev_row = reverse_row(row)\n ret = ieor(ret, ishft(unpack_col(ieor(row, reverse_row(\n & execute_move_helper(rev_row)))), ishft(i, 2)))\n else if (move == 2) then\n ret = ieor(ret, ishft(iand(ieor(row,\n & execute_move_helper(row)), ROW_MASK), ishft(i, 4)))\n else if (move == 3) then\n rev_row = reverse_row(row)\n ret = ieor(ret, ishft(iand(ieor(row, reverse_row(\n & execute_move_helper(rev_row))), ROW_MASK), ishft(i, 4)))\n end if\n end do\n execute_move = ret\n end\n\n integer*4 function score_helper(board)\n integer*8 :: board\n integer*4 :: score, i, j, rank\n integer*2 :: row\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n integer*8 :: ROW_MASK, COL_MASK\n common \/MASK_NUM\/ ROW_MASK, COL_MASK\n\n score = 0\n do j = 0, 3\n row = iand(ishft(board, -ishft(j, 4)), ROW_MASK)\n do i = 0, 3\n rank = iand(ishft(row, -ishft(i, 2)), Z000F)\n if (rank >= 2) then\n score = score + ((rank - 1) * ishft(1, rank))\n end if\n end do\n end do\n score_helper = score\n end\n\n integer*4 function score_board(board)\n integer*8 :: board\n integer*4 :: score_helper\n\n score_board = score_helper(board)\n end\n\n integer*8 function draw_tile()\n integer*4 :: ret\n integer*4 :: unif_random\n\n ret = unif_random(10)\n if (ret < 9) then\n ret = 1\n else\n ret = 2\n end if\n draw_tile = ret\n end\n\n integer*8 function insert_tile_rand(board, tile)\n integer*8 :: board\n integer*8 :: tile\n integer*8 :: tile_\n integer*8 :: tmp, t_\n integer*4 :: pos\n integer*4 :: unif_random, count_empty\n integer*2 :: Z000F, Z00F0, Z0F00\n common \/CONST_NUM\/ Z000F, Z00F0, Z0F00\n\n tile_ = tile\n pos = unif_random(count_empty(board))\n tmp = board\n t_ = Z000F\n do while (1>0)\n do while (iand(tmp, t_) \/= 0)\n tmp = ishft(tmp, -4)\n tile_ = ishft(tile_, 4)\n end do\n if (pos == 0) then\n exit\n end if\n pos = pos - 1\n tmp = ishft(tmp, -4)\n tile_ = ishft(tile_, 4)\n end do\n insert_tile_rand = ior(board, tile_)\n end\n\n integer*8 function initial_board()\n integer*8 :: board\n integer*4 :: rd\n integer*8 :: tile\n integer*4 :: unif_random\n integer*8 :: draw_tile, insert_tile_rand\n\n rd = unif_random(16)\n tile = draw_tile()\n board = ishft(tile, ishft(rd, 2))\n tile = draw_tile()\n initial_board = insert_tile_rand(board, tile)\n end\n\n integer*4 function ask_for_move(board)\n integer*8 :: board\n integer*4 :: ret\n character :: movechar\n integer :: pos\n character(len=9) :: allmoves = 'wsadkjhl'\n external c_getch\n integer :: c_getch\n\n call print_board(board)\n ret = -1\n do while (1 > 0)\n movechar = achar(c_getch())\n if (movechar == 'q') then\n ret = -1\n exit\n else if (movechar == 'r') then\n ret = 5\n exit\n end if\n pos = index(allmoves, movechar)\n if (pos \/= 0) then\n ret = mod(pos - 1, 4)\n exit\n end if\n end do\n ask_for_move = ret\n end\n\n subroutine play_game()\n integer*8 :: board, newboard, tile\n integer*4 :: scorepenalty, current_score, last_score, moveno\n integer*8 :: retract_vec(0:63)\n integer*1 :: retract_penalty_vec(0:63)\n integer*4 :: retract_pos, retract_num, move\n external c_clear_screen, c_print_move_score, c_print_final_score\n integer*8 :: initial_board, execute_move\n integer*8 :: draw_tile, insert_tile_rand\n integer*4 :: score_board, ask_for_move\n\n board = initial_board()\n scorepenalty = 0\n current_score = 0\n last_score = 0\n moveno = 0\n retract_pos = 0\n retract_num = 0\n\n do while (1 > 0)\n call c_clear_screen()\n move = 0\n do while (move < 4)\n if (execute_move(board, move) \/= board) then\n exit\n end if\n move = move + 1\n end do\n if (move == 4) then\n exit\n end if\n\n current_score = score_board(board) - scorepenalty\n moveno = moveno + 1\n call c_print_move_score(moveno, current_score, last_score)\n last_score = current_score\n\n move = ask_for_move(board)\n if (move < 0) then\n exit\n end if\n\n if (move == 5) then\n if ((moveno <= 1) .or. (retract_num <= 0)) then\n moveno = moveno - 1\n cycle\n end if\n moveno = moveno - 2\n if ((retract_pos == 0) .and. (retract_num > 0)) then\n retract_pos = 64\n end if\n retract_pos = retract_pos - 1\n board = retract_vec(retract_pos)\n scorepenalty = \n & scorepenalty - retract_penalty_vec(retract_pos)\n retract_num = retract_num - 1\n cycle\n end if\n\n newboard = execute_move(board, move)\n if (newboard == board) then\n moveno = moveno - 1\n cycle\n end if\n\n tile = draw_tile()\n if (tile == 2) then\n scorepenalty = scorepenalty + 4\n retract_penalty_vec(retract_pos) = 4\n else\n retract_penalty_vec(retract_pos) = 0\n end if\n retract_vec(retract_pos) = board\n retract_pos = retract_pos + 1\n if (retract_pos == 64) then\n retract_pos = 0\n end if\n if (retract_num < 64) then\n retract_num = retract_num + 1\n end if\n board = insert_tile_rand(newboard, tile)\n end do\n call print_board(board)\n call c_print_final_score(current_score)\n end\n\n subroutine main()\n call init_num()\n call play_game()\n end\n\n","avg_line_length":30.0448430493,"max_line_length":72,"alphanum_fraction":0.525} {"size":249,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"Describe Users\/Jerrica here.\n\n\nJerrica McDowell,\n\nI was content to leave Joes actions out of the eyes of Blockbuster, but seeing as how you had to drag it out I will be contacting Jim Woods the Blockbuster HR Rep. for the region about Joes actions.\n","avg_line_length":35.5714285714,"max_line_length":198,"alphanum_fraction":0.7871485944} {"size":1096,"ext":"f90","lang":"FORTRAN","max_stars_count":12.0,"content":"! { dg-do run }\n! { dg-options \"-ff2c\" }\n! Verifies that array results work with -ff2c\n! try all permutations of result clause in function yes\/no\n! and result clause in interface yes\/no\n! this is not possible in Fortran 77, but this exercises a previously\n! buggy codepath\nfunction c() result (r)\n complex :: r(5)\n r = 0.\nend function c\n\nfunction d()\n complex :: d(5)\n d = 1.\nend function d\n\nsubroutine test_without_result\ninterface\n function c ()\n complex :: c(5)\n end function c\nend interface\ninterface\n function d ()\n complex :: d(5)\n end function d\nend interface\ncomplex z(5)\nz = c()\nif (any(z \/= 0.)) STOP 1\nz = d()\nif (any(z \/= 1.)) STOP 2\nend subroutine test_without_result\n\nsubroutine test_with_result\ninterface\n function c () result(r)\n complex :: r(5)\n end function c\nend interface\ninterface\n function d () result(r)\n complex :: r(5)\n end function d\nend interface\ncomplex z(5)\nz = c()\nif (any(z \/= 0.)) STOP 3\nz = d()\nif (any(z \/= 1.)) STOP 4\nend subroutine test_with_result\n\ncall test_without_result\ncall test_with_result\nend\n \n","avg_line_length":18.8965517241,"max_line_length":69,"alphanum_fraction":0.6633211679} {"size":10099,"ext":"f","lang":"FORTRAN","max_stars_count":157.0,"content":"*> \\brief \\b DSTEGR\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download DSTEGR + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE DSTEGR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU,\n* ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,\n* LIWORK, INFO )\n*\n* .. Scalar Arguments ..\n* CHARACTER JOBZ, RANGE\n* INTEGER IL, INFO, IU, LDZ, LIWORK, LWORK, M, N\n* DOUBLE PRECISION ABSTOL, VL, VU\n* ..\n* .. Array Arguments ..\n* INTEGER ISUPPZ( * ), IWORK( * )\n* DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * )\n* DOUBLE PRECISION Z( LDZ, * )\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> DSTEGR computes selected eigenvalues and, optionally, eigenvectors\n*> of a real symmetric tridiagonal matrix T. Any such unreduced matrix has\n*> a well defined set of pairwise different real eigenvalues, the corresponding\n*> real eigenvectors are pairwise orthogonal.\n*>\n*> The spectrum may be computed either completely or partially by specifying\n*> either an interval (VL,VU] or a range of indices IL:IU for the desired\n*> eigenvalues.\n*>\n*> DSTEGR is a compatibility wrapper around the improved DSTEMR routine.\n*> See DSTEMR for further details.\n*>\n*> One important change is that the ABSTOL parameter no longer provides any\n*> benefit and hence is no longer used.\n*>\n*> Note : DSTEGR and DSTEMR work only on machines which follow\n*> IEEE-754 floating-point standard in their handling of infinities and\n*> NaNs. Normal execution may create these exceptiona values and hence\n*> may abort due to a floating point exception in environments which\n*> do not conform to the IEEE-754 standard.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] JOBZ\n*> \\verbatim\n*> JOBZ is CHARACTER*1\n*> = 'N': Compute eigenvalues only;\n*> = 'V': Compute eigenvalues and eigenvectors.\n*> \\endverbatim\n*>\n*> \\param[in] RANGE\n*> \\verbatim\n*> RANGE is CHARACTER*1\n*> = 'A': all eigenvalues will be found.\n*> = 'V': all eigenvalues in the half-open interval (VL,VU]\n*> will be found.\n*> = 'I': the IL-th through IU-th eigenvalues will be found.\n*> \\endverbatim\n*>\n*> \\param[in] N\n*> \\verbatim\n*> N is INTEGER\n*> The order of the matrix. N >= 0.\n*> \\endverbatim\n*>\n*> \\param[in,out] D\n*> \\verbatim\n*> D is DOUBLE PRECISION array, dimension (N)\n*> On entry, the N diagonal elements of the tridiagonal matrix\n*> T. On exit, D is overwritten.\n*> \\endverbatim\n*>\n*> \\param[in,out] E\n*> \\verbatim\n*> E is DOUBLE PRECISION array, dimension (N)\n*> On entry, the (N-1) subdiagonal elements of the tridiagonal\n*> matrix T in elements 1 to N-1 of E. E(N) need not be set on\n*> input, but is used internally as workspace.\n*> On exit, E is overwritten.\n*> \\endverbatim\n*>\n*> \\param[in] VL\n*> \\verbatim\n*> VL is DOUBLE PRECISION\n*>\n*> If RANGE='V', the lower bound of the interval to\n*> be searched for eigenvalues. VL < VU.\n*> Not referenced if RANGE = 'A' or 'I'.\n*> \\endverbatim\n*>\n*> \\param[in] VU\n*> \\verbatim\n*> VU is DOUBLE PRECISION\n*>\n*> If RANGE='V', the upper bound of the interval to\n*> be searched for eigenvalues. VL < VU.\n*> Not referenced if RANGE = 'A' or 'I'.\n*> \\endverbatim\n*>\n*> \\param[in] IL\n*> \\verbatim\n*> IL is INTEGER\n*>\n*> If RANGE='I', the index of the\n*> smallest eigenvalue to be returned.\n*> 1 <= IL <= IU <= N, if N > 0.\n*> Not referenced if RANGE = 'A' or 'V'.\n*> \\endverbatim\n*>\n*> \\param[in] IU\n*> \\verbatim\n*> IU is INTEGER\n*>\n*> If RANGE='I', the index of the\n*> largest eigenvalue to be returned.\n*> 1 <= IL <= IU <= N, if N > 0.\n*> Not referenced if RANGE = 'A' or 'V'.\n*> \\endverbatim\n*>\n*> \\param[in] ABSTOL\n*> \\verbatim\n*> ABSTOL is DOUBLE PRECISION\n*> Unused. Was the absolute error tolerance for the\n*> eigenvalues\/eigenvectors in previous versions.\n*> \\endverbatim\n*>\n*> \\param[out] M\n*> \\verbatim\n*> M is INTEGER\n*> The total number of eigenvalues found. 0 <= M <= N.\n*> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.\n*> \\endverbatim\n*>\n*> \\param[out] W\n*> \\verbatim\n*> W is DOUBLE PRECISION array, dimension (N)\n*> The first M elements contain the selected eigenvalues in\n*> ascending order.\n*> \\endverbatim\n*>\n*> \\param[out] Z\n*> \\verbatim\n*> Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M) )\n*> If JOBZ = 'V', and if INFO = 0, then the first M columns of Z\n*> contain the orthonormal eigenvectors of the matrix T\n*> corresponding to the selected eigenvalues, with the i-th\n*> column of Z holding the eigenvector associated with W(i).\n*> If JOBZ = 'N', then Z is not referenced.\n*> Note: the user must ensure that at least max(1,M) columns are\n*> supplied in the array Z; if RANGE = 'V', the exact value of M\n*> is not known in advance and an upper bound must be used.\n*> Supplying N columns is always safe.\n*> \\endverbatim\n*>\n*> \\param[in] LDZ\n*> \\verbatim\n*> LDZ is INTEGER\n*> The leading dimension of the array Z. LDZ >= 1, and if\n*> JOBZ = 'V', then LDZ >= max(1,N).\n*> \\endverbatim\n*>\n*> \\param[out] ISUPPZ\n*> \\verbatim\n*> ISUPPZ is INTEGER ARRAY, dimension ( 2*max(1,M) )\n*> The support of the eigenvectors in Z, i.e., the indices\n*> indicating the nonzero elements in Z. The i-th computed eigenvector\n*> is nonzero only in elements ISUPPZ( 2*i-1 ) through\n*> ISUPPZ( 2*i ). This is relevant in the case when the matrix\n*> is split. ISUPPZ is only accessed when JOBZ is 'V' and N > 0.\n*> \\endverbatim\n*>\n*> \\param[out] WORK\n*> \\verbatim\n*> WORK is DOUBLE PRECISION array, dimension (LWORK)\n*> On exit, if INFO = 0, WORK(1) returns the optimal\n*> (and minimal) LWORK.\n*> \\endverbatim\n*>\n*> \\param[in] LWORK\n*> \\verbatim\n*> LWORK is INTEGER\n*> The dimension of the array WORK. LWORK >= max(1,18*N)\n*> if JOBZ = 'V', and LWORK >= max(1,12*N) if JOBZ = 'N'.\n*> If LWORK = -1, then a workspace query is assumed; the routine\n*> only calculates the optimal size of the WORK array, returns\n*> this value as the first entry of the WORK array, and no error\n*> message related to LWORK is issued by XERBLA.\n*> \\endverbatim\n*>\n*> \\param[out] IWORK\n*> \\verbatim\n*> IWORK is INTEGER array, dimension (LIWORK)\n*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.\n*> \\endverbatim\n*>\n*> \\param[in] LIWORK\n*> \\verbatim\n*> LIWORK is INTEGER\n*> The dimension of the array IWORK. LIWORK >= max(1,10*N)\n*> if the eigenvectors are desired, and LIWORK >= max(1,8*N)\n*> if only the eigenvalues are to be computed.\n*> If LIWORK = -1, then a workspace query is assumed; the\n*> routine only calculates the optimal size of the IWORK array,\n*> returns this value as the first entry of the IWORK array, and\n*> no error message related to LIWORK is issued by XERBLA.\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> On exit, INFO\n*> = 0: successful exit\n*> < 0: if INFO = -i, the i-th argument had an illegal value\n*> > 0: if INFO = 1X, internal error in DLARRE,\n*> if INFO = 2X, internal error in DLARRV.\n*> Here, the digit X = ABS( IINFO ) < 10, where IINFO is\n*> the nonzero error code returned by DLARRE or\n*> DLARRV, respectively.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\date June 2016\n*\n*> \\ingroup doubleOTHERcomputational\n*\n*> \\par Contributors:\n* ==================\n*>\n*> Inderjit Dhillon, IBM Almaden, USA \\n\n*> Osni Marques, LBNL\/NERSC, USA \\n\n*> Christof Voemel, LBNL\/NERSC, USA \\n\n*\n* =====================================================================\n SUBROUTINE DSTEGR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU,\n $ ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,\n $ LIWORK, INFO )\n*\n* -- LAPACK computational routine (version 3.7.0) --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* June 2016\n*\n* .. Scalar Arguments ..\n CHARACTER JOBZ, RANGE\n INTEGER IL, INFO, IU, LDZ, LIWORK, LWORK, M, N\n DOUBLE PRECISION ABSTOL, VL, VU\n* ..\n* .. Array Arguments ..\n INTEGER ISUPPZ( * ), IWORK( * )\n DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * )\n DOUBLE PRECISION Z( LDZ, * )\n* ..\n*\n* =====================================================================\n*\n* .. Local Scalars ..\n LOGICAL TRYRAC\n* ..\n* .. External Subroutines ..\n EXTERNAL DSTEMR\n* ..\n* .. Executable Statements ..\n INFO = 0\n TRYRAC = .FALSE.\n\n CALL DSTEMR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU,\n $ M, W, Z, LDZ, N, ISUPPZ, TRYRAC, WORK, LWORK,\n $ IWORK, LIWORK, INFO )\n*\n* End of DSTEGR\n*\n END\n","avg_line_length":33.3300330033,"max_line_length":111,"alphanum_fraction":0.5701554609} {"size":1306,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"module repeat_test\n use ascii_string_and_integer_generator_m, only: &\n ASCII_STRING_AND_INTEGER_GENERATOR\n use iso_varying_string, only: char, repeat\n use string_and_integer_input_m, only: string_and_integer_input_t\n use veggies, only: &\n input_t, result_t, test_item_t, assert_equals, describe, fail, it\n\n implicit none\n private\n public :: test_repeat\ncontains\n function test_repeat() result(tests)\n type(test_item_t) :: tests\n\n tests = describe( &\n \"Sec. 3.4.13: REPEAT\", &\n [ it( &\n \"works the same for characters and strings\", &\n ASCII_STRING_AND_INTEGER_GENERATOR, &\n check_repeat) &\n ])\n end function\n\n pure function check_repeat(input) result(result_)\n class(input_t), intent(in) :: input\n type(result_t) :: result_\n\n select type (input)\n type is (string_and_integer_input_t)\n result_ = assert_equals( &\n repeat(char(input%string()), input%integer_()), &\n repeat(input%string(), input%integer_()))\n class default\n result_ = fail(\"Expected to get a string_and_integer_input_t\")\n end select\n end function\nend module\n","avg_line_length":33.4871794872,"max_line_length":77,"alphanum_fraction":0.595712098} {"size":8939,"ext":"f","lang":"FORTRAN","max_stars_count":1.0,"content":"C! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\nc calculation of the total cross-section integrad qq-> hh\nc In the UEHiggsY model or SM if the Wilson coefficients are set to zero\nC written by Lina Alasfar, HU Berlin 04.04.2019 c\n! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\n\nC-- qq > hh\n SUBROUTINE UPEVNT\nC...All real arithmetic in double precision.\n IMPLICIT DOUBLE PRECISION(A-H, O-Z)\nC...User process event common block.\n INTEGER MAXNUP, FLAV,RF, FLAV2, mod\n PARAMETER (MAXNUP=500)\n INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP\n DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP\n DOUBLE PRECISION MH,MW,MZ,lambdaEW,lambdaNP, gammah, m\n COMMON\/PYDAT2\/KCHG(500,4),PMAS(500,4),PARF(2000),VCKM(4,4)\n COMMON\/HEPEUP\/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP),\n &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP),\n &VTIMUP(MAXNUP),SPINUP(MAXNUP)\n SAVE \/HEPEUP\/\n\nC...The user's own transfer of information.\n COMMON\/MYCOMM\/ECM,PTMIN,INIT,mod\n SAVE\/MYCOMM\/\n COMMON\/KIN\/sh,uh,th,MH,M,MQ\n COMMON\/PARAM\/WILSON, WC, ghff,ghhff,gammah,ghhh, lambdanp,lambdaEW,xkl,xkf\nC common\/ flavour\/rf,fp1,fp2\nC...Local arrays and parameters.\n DIMENSION wc(6,6),fp1(-6:6),fp2(-6:6),xkf(6), xs(5,5)\n DOUBLE PRECISION, DIMENSION(6) :: MQ\n DATA PI\/3.141592653589793D0\/\n DATA CONV\/0.3894D9\/\nC----------------------------first: set up the parameters------------------------------------\nC...Default flag for event rejection.\n IREJ=0\nC-- initilise the kappa_f values w.r.t the beauty coupling\nC do 556, i = 1,4\nC xkf(i) = pmas(5,1)\/pmas(i,1)\nC556 continue\nC xkf(2)= 2000d00\n\n\n\n\n\nC-- Other parameters\nC xkl = 1d0 ! NP contibution to the trilinear cpupling\n gammah = PMAS(25,2) ! Higgs width\n gf = 1.166378D-05 ! Fermi's constant [GeV^-2]\n lambdaEW = (dSQRT(2D00)* GF)**(-0.5) ! the vev or electroweak scale [GeV]\n lambdaNP = 1300D00 ! new physics scale ~ TeV scale [GeV]\n MW =PMAS(24,1) ! W mass [GeV]\n mh=PMAS(25,1) ! Higgs mass\n g=sqrt(8*mw**2*gf\/sqrt(2d0)) ! weak coupling cnstant\n ghhh=(xkl)*(6d0*g*mh**2)\/(4d0*mw) ! Higgs trilinear coupling\n hwidth = cmplx(0d0,-gammah*mh)\nC...Default return value.\n XWGTUP=0D0 ! the event weight\n dsiggma =0d0 ! storing the total matrix element\n do 657, j = 1,5,1\n do 656 ,i =1,5,1\n xs(i,j) = 0d0 ! flavour matrix element\n656 continue\n657 continue\nC-- Setting up the Wilson coeffecients\n DO 15, ncol = 1,6\n DO 16, nrow = 1,6\n wc(ncol,nrow) = 0.0D00 ! off diagonal wilson , FCNC\n if( (ncol.eq.nrow).and.(ncol.lt.5) )then\n ! first one k is in terms of beauty couplings ratio\n wc(ncol,nrow) =\n . (lambdaNP\/lambdaEW)**2 *\n . (pmas(4,1)\/lambdaEW) * (xkf(nrow)-pmas(nrow,1)\/pmas(4,1))\n ! this one , k is in terms of ratio of yukawa to the SM\nC wc(ncol,nrow) =\nC . (lambdaNP\/lambdaEW)**2 *\nC . (pmas(nrow,1)\/lambdaEW) * (XKF(nrow)-1)\n endif\n16 CONTINUE\n15 CONTINUE\nC---------------------------Second: Phase space and mandalstam variables--------------------------------\n SHATMIN = (2D0*MH)**2! +PTMIN**2\n SHATMAX = ECM**2\n TAUM = SHATMIN\/ECM**2\n TAU= TAUM**PYR(0) !(2D0*HM)**2\/ECM**2 !4D0*PTMIN**2\/ECM**2\n X2 = TAU**PYR(0)\n X1= TAU\/X2\n s=tau*ECM**2\n sh = s\n\n T2=1.d0\/2.D0*(-s+dSqrt(s)*2d0*dSQRT(s\/4d0-mh**2))+mh**2\n T1=1.d0\/2.D0*(-s-dSqrt(s)*2d0*dSQRT(s\/4d0-mh**2))+mh**2\n\n T=T1+(T2-T1)*PYR(0)\n\n\nC...Derive other kinematical quantities.\n U=2D00*MH**2-S-T\n PT2=(T*U-S*mh**2)\/S\nC...Pick Q2 scale (which involves some arbitrariness)\n Q2= 0.25d0*S!PT2\n SCALUP=SQRT(Q2)\nC-- EVOLVE PDF'S\n call evolvePDF(x1,SCALUP,fp1)\n call evolvePDF(x2,SCALUP,fp2)\n\nC-- the jacobian\n PHSPV=(-dLOG(TAUM))*(-dLOG(TAU))*(T2-T1) !dlog(T2\/T1)*that\n\nC------------------------Third: compute the matrix elements ----------------------------------\nC SELECT FLAVOUR AT RANDOM\n RF = FLOOR( (5-1)*PYR(0)+1 ) ! just for generation asthetics\nC-- The flavour diagonal matrix elements\n do 666, i = 1,5,1\n80 ghff = (pmas(i,1)\/lambdaEW)!*xkf(i)\nC ghhff=m\/lambdaEW**2*(3d0\/2d0*(1d0-mq(5)\/(m)))\nC ghhff = 3*(pmas(i,1)\/lambdaEW**2)*(xkf(i)-1)\/2d0\n ghhff = (pmas(i,1)\/lambdaEW**2)*xkf(i)\n\n\nC-- t and u channels with their interference\n xs(i,i) =(ghff)**4*((2*mh**2*s)\/t**2 - (2*s*(mh**2 - t))\/t**2\n . + (2*mh**2*s)\/(t*u**2)\n . - (2*s*(mh**2 - u))\/(t*u**2)\n . + (s*(-2*mh**2 + s))\/(t**2*u)\n . - (mh**2 - t)**2\/(t**2*u) + (s*(-2*mh**2 + s))\/(t*u)\n . - (2*s*(mh**2 - t))\/(t*u)\n . + (mh**2 - t)**2\/(t*u) - (2*s*(mh**2 - u))\/(t**2*u)\n . + (mh**2 - u)**2\/(t**2*u)\n . - (mh**2 - u)**2\/(t*u))\nC-- s , with NP channels with their interference\n xs(i,i) = xs(i,i)+(2d0)*s*((ghff*ghhh \/ (-mh**2 + s)) +2d0* ghhff)**2\n xs(i,i) = xs(i,i)\/s**2\nC-- weight by the parton distibution functions\n xs(i,i) = xs(i,i)*fp1(i)*fp2(-i)\n . +xs(i,i)*fp2(i)*fp1(-i)\n666 CONTINUE\nC FCNC elements :\n do 777 i = 1,5,1\n do 778 j=1,5,1\n if(i.ne.j) then ! only off diagonal\n ghff=(lambdaEW \/ lambdaNP)**2 * wc(i,j) ! only NP part of Yukawa\n ghhff = -3d0* (lambdaEW \/ lambdaNP**2) * wc(i,j)\n ! t and u channels are not allowed with FCNC\n xs(i,j) = 2*s*((ghff*ghhh \/ (-mh**2 + s))+ ghhff)**2\nC xs(i,j) = xs(i,j)\/s**2\n xs(i,j) = 0d0!xs(i,j)*fp1(i)*fp2(-j)\nC . +xs(i,j)*fp2(j)*fp1(-i)\n end if\n778 continue\n777 continue\n\n\nC...The CONV factor converts from GeV**(-2) to pb.\n factor1 =1d0\/(16d0*PI) *(1d0\/24d0) ! prefactor\n dsiggma = abs(sum(xs)) ! the total matrix elemets\n XWGTUP= CONV*PHSPV*dsiggma*factor1 !the differential cross section\nC...Done when initializing for maximum cross section.\n IF(INIT.EQ.1) RETURN\nC...Store scale choice etc.\n\n\nC---------------------Fourth: setting up the event------------------------------\n\nC...The third step is to set up the partonic process that is selected.\n\nC...Define number of partons - two incoming and two outgoing.\n NUP=4\n\nC...Flavour codes for entries. Note that definition of t-hat\nC...means quark either is 1 and 3 or 2 and 4.\n IDUP(1)=1\n IDUP(2)=-1\n IDUP(3)=25\n IDUP(4)=35\n\nC...Status codes.\n ISTUP(1)=-1\n ISTUP(2)=-1\n ISTUP(3)=1\n ISTUP(4)=1\n\nC...Mother codes.\n MOTHUP(1,1)=0\n MOTHUP(2,1)=0\n MOTHUP(1,2)=0\n MOTHUP(2,2)=0\n MOTHUP(1,3)=1\n MOTHUP(2,3)=2\n MOTHUP(1,4)=1\n MOTHUP(2,4)=2\n\nC...Colour flow.\nC...Colour stretched from initial quark to antiquark\n ICOLUP(1,1) =501\n ICOLUP(2,1)=0\n ICOLUP(1,2)=0\n ICOLUP(2,2)=501\n ICOLUP(1,3) =0\n ICOLUP(2,3)=0\n ICOLUP(1,4)=0\n ICOLUP(2,4)=0\n\n\nC...Reset momenta to zero.\n DO 130 I=1,4\n DO 120 J=1,5\n PUP(J,I)=0D0\n120 CONTINUE\n130 CONTINUE\nCC\nC...Masses of final state entries; initial assumed massless.\n PUP(5,3)= PYMASS(IDUP(3))\n PUP(5,4)=PYMASS(IDUP(4))\nCC sqrt2 = dsqrt(2d00)\nC...Four-momenta of the incoming partons simple.\n PUP(4,1)=X1*ECM*0.50d00\n PUP(3,1)=PUP(4,1)\n PUP(4,2)=ECM*X2*0.50d00\n PUP(3,2)=-PUP(4,2)\n\nC...Energies and absolute momentum of the outgoing partons in\nC...the subsystem frame.\n RTSHAT=SQRT(X1*X2)*ECM\n PABS=0.5D0*SQRT(MAX(0D0,(RTSHAT**2-PUP(5,3)**2-\n &PUP(5,4)**2)**2-4D0*PUP(5,3)**2*PUP(5,4)**2))\/RTSHAT\n PE3=0.5D0*(RTSHAT**2+PUP(5,3)**2-PUP(5,4)**2)\/RTSHAT\n PE4=RTSHAT-PE3\nC...Subsystem scattering angle defined\n COSTHE=(t-u)\/s\n SINTHE=SQRT(MAX(0D0,1D0-COSTHE**2))\nC...Azimuthal angle at random.\n PHI=2D0*PI*PYR(0)\nC...Momenta of outgoing partons in the subsystem frame.\n PUP(1,3)=PABS*SINTHE*COS(PHI)\n PUP(2,3)=PABS*SINTHE*SIN(PHI)\n PZ3=PABS*COSTHE\n PUP(1,4)=-PUP(1,3)\n PUP(2,4)=-PUP(2,3)\n PZ4=-PZ3\nC...Longitudinal boost of outgoing partons to cm frame.\n BETA=(X1-X2)\/(X1+X2)\n GAMMA=0.5D0*(X1+X2)\/SQRT(X1*X2)\n PUP(3,3)=GAMMA*(PZ3+BETA*PE3)\n PUP(4,3)=GAMMA*(PE3+BETA*PZ3)\n PUP(3,4)=GAMMA*(PZ4+BETA*PE4)\n PUP(4,4)=GAMMA*(PE4+BETA*PZ4)\n RETURN\n END\nCC\n\n\n********************************************************************\n","avg_line_length":35.0549019608,"max_line_length":104,"alphanum_fraction":0.5393220718} {"size":6983,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"C\nC\nC Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.\nC\nC This program is free software; you can redistribute it and\/or modify it\nC under the terms of version 2.1 of the GNU Lesser General Public License \nC as published by the Free Software Foundation.\nC\nC This program is distributed in the hope that it would be useful, but\nC WITHOUT ANY WARRANTY; without even the implied warranty of\nC MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \nC\nC Further, this software is distributed without any warranty that it is\nC free of the rightful claim of any third person regarding infringement \nC or the like. Any license provided herein, whether implied or \nC otherwise, applies only to this software file. Patent licenses, if\nC any, provided herein do not apply to combinations of this program with \nC other software, or any other product whatsoever. \nC\nC You should have received a copy of the GNU Lesser General Public \nC License along with this program; if not, write the Free Software \nC Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, \nC USA.\nC\nC Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,\nC Mountain View, CA 94043, or:\nC\nC http:\/\/www.sgi.com\nC\nC For further information regarding this notice, see:\nC\nC http:\/\/oss.sgi.com\/projects\/GenInfo\/NoticeExplan\nC\nC\n\n\n SUBROUTINE OSRCHM( N,IARRAY,INC,ITARGET,\n & MASK,SHIFT,INDEX,IWHERE,\n & INUM )\n************************************************************************\n** **\n* Search an ordered integer array for integer target *\n** **\n* *\n* OSRCHM (N,IARRAY,INC,ITARGET,MASK,SHIFT,INDEX,IWHERE,INUM) is a *\n* subroutine that returns the index of the first location that *\n* is equal to the target. It also returns the index of where *\n* the target should fit into the array whether it finds a value *\n* equal to the target or not. Optionally it will find the *\n* total number of array elements equal to the target. *\n* *\n* *\n* Inputs: *\n* *\n* N Number of elements of the array to be searched. *\n* IARRAY The beginning address of the integer array *\n* to be searched. *\n* INC The skip increment distance between elements to be *\n* searched. INC should be 1 for contiguous elements *\n* of memory. INC should be -1 to find the last *\n* element with a true condition. *\n* A positive skip increment indicates an ascending *\n* array, while a negative skip increment indicates *\n* a descending array. *\n* *\n* ITARGET Integer target of the search. *\n* *\n* MASK A mask that is set from the right the side of the *\n* field of interest in the vector IARRAY *\n* *\n* SHIFT How much to shift right the IARRAY vector to position *\n* the field of interest at the right side of the word *\n* *\n* *\n* INUM If the number of elements of the array equal to the *\n* target is desired this parameter must be non-zero. *\n* *\n* Output: *\n* *\n* INDEX Is the index of the first location in the searched *\n* array where the target is equal to an element *\n* of that array. *\n* *\n* Exceptional cases: *\n* 1) if N is less than 1 then INDEX = 0 *\n* 2) if no equal array elements then INDEX = N+1 *\n* *\n* IWHERE Is the index of the first location in the searched *\n* array where the target would fit and keep the *\n* order of the array. If the target is found *\n* INDEX = IWHERE. *\n* *\n* Exceptional case: *\n* 1) if N is less than 1 then INDEX = 0 *\n* *\n* INUM Is the number of elements of the array equal to the *\n* target. This will return a value only if asked *\n* for and at least one target value is found in the *\n* array. Otherwise it will always be zero. *\n* *\n** **\n************************************************************************\n dimension iarray(n)\n integer shift\n*\n* -------------\n* USM What Line\n* -------------\nCDIR$ ID \"@(#) libu\/sci\/c2\/osrchm.f\t92.0\t10\/08\/98 14:57:41\"\n*\n if (n .lt. 0) go to 500\n j = 1\n if (inc .lt. 0) j = n * (-inc)\n do 100 i= 1, n\n if (and(mask,shiftr(iarray(j),shift)).gt.itarget) go to 200\n if (and(mask,shiftr(iarray(j),shift)).eq.itarget) go to 300\n j = j + inc\n 100 continue\n index = n + 1\n iwhere = n + 1\n inum = 0\n return\n 200 continue\n index = n + 1\n iwhere = i\n inum = 0\n return\n 300 continue\n index = i\n iwhere = i\n if (inum .eq. 0) return\n inum = 1\n do 400 i = i+1, n\n j = j + inc\n if (and(mask,shiftr(iarray(j),shift)).ne.itarget) return\n inum=inum+1\n 400 continue\n return\n 500 continue\n index = 0\n iwhere = 0\n return\n end\n","avg_line_length":48.4930555556,"max_line_length":75,"alphanum_fraction":0.4263210654} {"size":440,"ext":"f","lang":"FORTRAN","max_stars_count":34.0,"content":" subroutine clawpack46_src2(maxmx,maxmy,meqn,mbc,mx,my,\n & xlower,ylower,dx,dy,q,maux,aux,t,dt)\n implicit none\n\n integer maxmx, maxmy, meqn, mbc, mx, my, maux\n double precision xlower, ylower, dx, dy, t, dt\n double precision q(1-mbc:maxmx+mbc,1-mbc:maxmy+mbc, meqn)\n double precision aux(1-mbc:maxmx+mbc,1-mbc:maxmy+mbc, maux)\nc\nc # dummy source routine... does nothing\nc\n return\n end\n","avg_line_length":31.4285714286,"max_line_length":65,"alphanum_fraction":0.6409090909} {"size":491,"ext":"f","lang":"FORTRAN","max_stars_count":null,"content":"This editor can edit this entry and tell us a bit about themselves by clicking the Edit icon.\n\n\nHowdy, Mr. or Ms. Tang! I renamed the entry about the event to From Spoke to Sprocket, as it probably isnt the only bike related exhibition in the past and future of Davis. :) Seriously, though... I added a bunch of links out from the entry, but it would probably be a good idea to link to the entry from the various bike and art related entries. Users\/JabberWokky Evan JabberWokky Edwards\n","avg_line_length":98.2,"max_line_length":394,"alphanum_fraction":0.7718940937} {"size":234,"ext":"f90","lang":"FORTRAN","max_stars_count":2.0,"content":"program t\n implicit none\n!inquire stmt 'named' specifier\n logical::I1=.true.\ncharacter*7::a\n inquire (95, named=I1)\n print *,I1\n\n open (95, file='tmpfile')\n inquire (95, named=I1, name=a)\n print *,I1\n print *,a\n endprogram t\n\n","avg_line_length":15.6,"max_line_length":32,"alphanum_fraction":0.6581196581} {"size":945,"ext":"f","lang":"FORTRAN","max_stars_count":7.0,"content":"c =====================================================\n subroutine qinit(maxmx,maxmy,meqn,mbc,mx,my,xlower,ylower,\n & dx,dy,q,maux,aux)\nc =====================================================\nc\nc # Set initial conditions for q.\nc # Sample scalar equation with data that is piecewise constant with\nc # q = 1.0 if 0.1 < x < 0.6 and 0.1 < y < 0.6\nc # 0.1 otherwise\nc\n implicit double precision (a-h,o-z)\n dimension q(1-mbc:maxmx+mbc, 1-mbc:maxmy+mbc, meqn)\n\nc # set concentration profile\nc ---------------------------\n do 20 j=1,my\n yj = ylower + (j-0.5d0)*dy\n do 20 i=1,mx\n xi = xlower + (i-0.5d0)*dx\n if (xi.gt.0.1d0 .and. xi.lt.0.6d0 .and.\n & yj.gt.0.1d0 .and. yj.lt.0.6d0) then\n q(i,j,1) = 1.d0\n else\n q(i,j,1) = 0.1d0\n endif\n 20 continue\n\n\n return\n end\n","avg_line_length":30.4838709677,"max_line_length":72,"alphanum_fraction":0.4253968254} {"size":6367,"ext":"f90","lang":"FORTRAN","max_stars_count":null,"content":"!*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*!\n!* Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC.\n!* \n!* Produced at the Lawrence Livermore National Laboratory\n!* \n!* LLNL-CODE-666778\n!* \n!* All rights reserved.\n!* \n!* This file is part of Conduit. \n!* \n!* For details, see: http:\/\/software.llnl.gov\/conduit\/.\n!* \n!* Please also read conduit\/LICENSE\n!* \n!* Redistribution and use in source and binary forms, with or without \n!* modification, are permitted provided that the following conditions are met:\n!* \n!* * Redistributions of source code must retain the above copyright notice, \n!* this list of conditions and the disclaimer below.\n!* \n!* * Redistributions in binary form must reproduce the above copyright notice,\n!* this list of conditions and the disclaimer (as noted below) in the\n!* documentation and\/or other materials provided with the distribution.\n!* \n!* * Neither the name of the LLNS\/LLNL nor the names of its contributors may\n!* be used to endorse or promote products derived from this software without\n!* specific prior written permission.\n!* \n!* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n!* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n!* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n!* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,\n!* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY\n!* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL \n!* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n!* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n!* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, \n!* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n!* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n!* POSSIBILITY OF SUCH DAMAGE.\n!* \n!*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*!\n\n!------------------------------------------------------------------------------\n!\n! t_f_blueprint_mcarray.f\n!\n!------------------------------------------------------------------------------\n\n!------------------------------------------------------------------------------\nmodule t_f_blueprint_mcarray\n!------------------------------------------------------------------------------\n\n use iso_c_binding\n use fruit\n use conduit\n use conduit_blueprint\n use conduit_blueprint_mcarray\n implicit none\n\n!------------------------------------------------------------------------------\ncontains\n!------------------------------------------------------------------------------\n\n!------------------------------------------------------------------------------ \n! About test\n!------------------------------------------------------------------------------\n\n !--------------------------------------------------------------------------\n subroutine t_blueprint_mcarray_create_and_verify\n type(C_PTR) n\n type(C_PTR) nxform\n type(C_PTR) nempty\n type(C_PTR) info\n \n !----------------------------------------------------------------------\n call set_case_name(\"t_blueprint_mcarray_create_and_verify\")\n !----------------------------------------------------------------------\n \n n = conduit_node_create()\n nxform = conduit_node_create()\n nempty = conduit_node_create()\n info = conduit_node_create()\n \n call conduit_blueprint_mcarray_examples_xyz(\"interleaved\",10_8,n)\n call assert_true( conduit_blueprint_mcarray_verify(n,info) .eqv. .true. )\n call assert_true( conduit_blueprint_mcarray_is_interleaved(n) .eqv. .true. );\n\n call assert_true( conduit_blueprint_mcarray_to_contiguous(n,nxform) .eqv. .true. )\n call assert_true( conduit_blueprint_mcarray_is_interleaved(nxform) .eqv. .false. );\n call assert_true( conduit_node_is_contiguous(nxform) .eqv. .true. )\n\n call conduit_blueprint_mcarray_examples_xyz(\"separate\",10_8,n)\n call assert_true( conduit_blueprint_mcarray_verify(n,info) .eqv. .true. )\n call assert_true( conduit_blueprint_mcarray_verify(n,info) .eqv. .true. )\n\n\n call conduit_blueprint_mcarray_examples_xyz(\"contiguous\",10_8,n)\n call assert_true( conduit_blueprint_mcarray_verify(n,info) .eqv. .true. )\n call assert_true( conduit_node_is_contiguous(n) .eqv. .true. )\n call assert_true( conduit_blueprint_mcarray_is_interleaved(n) .eqv. .false. );\n\n\n call assert_true( conduit_blueprint_mcarray_to_interleaved(n,nxform) .eqv. .true. )\n call assert_true( conduit_blueprint_mcarray_is_interleaved(nxform) .eqv. .true. );\n\n call conduit_blueprint_mcarray_examples_xyz(\"interleaved_mixed\",10_8,n)\n call assert_true( conduit_blueprint_mcarray_verify(n,info) .eqv. .true. )\n call assert_true( conduit_blueprint_mcarray_verify_sub_protocol(\"sub\",nempty,info) .eqv. .false. )\n\n call assert_true( conduit_blueprint_mcarray_verify(nempty,info) .eqv. .false. )\n\n\n call conduit_node_destroy(n);\n call conduit_node_destroy(nxform);\n call conduit_node_destroy(nempty);\n call conduit_node_destroy(info);\n \n end subroutine t_blueprint_mcarray_create_and_verify\n\n!------------------------------------------------------------------------------\nend module t_f_blueprint_mcarray\n!------------------------------------------------------------------------------\n\n!------------------------------------------------------------------------------\nprogram fortran_test\n!------------------------------------------------------------------------------\n use fruit\n use t_f_blueprint_mcarray\n implicit none\n logical ok\n \n call init_fruit\n\n !----------------------------------------------------------------------------\n ! call our test routines\n !----------------------------------------------------------------------------\n call t_blueprint_mcarray_create_and_verify\n\n call fruit_summary\n call fruit_finalize\n call is_all_successful(ok)\n\n if (.not. ok) then\n call exit(1)\n endif\n\n!------------------------------------------------------------------------------\nend program fortran_test\n!------------------------------------------------------------------------------\n\n\n","avg_line_length":41.3441558442,"max_line_length":106,"alphanum_fraction":0.5423276268} {"size":4991,"ext":"f90","lang":"FORTRAN","max_stars_count":12.0,"content":"! { dg-do run }\n!\n! PR fortran\/37336\n!\n! Check the scalarizer\/array packing with strides\n! in the finalization wrapper\n!\nmodule m\n implicit none\n\n type t1\n integer :: i = 1\n contains\n final :: fini_elem\n end type t1\n\n type, extends(t1) :: t1e\n integer :: j = 11\n contains\n final :: fini_elem2\n end type t1e\n\n type t2\n integer :: i = 2\n contains\n final :: fini_shape\n end type t2\n\n type, extends(t2) :: t2e\n integer :: j = 22\n contains\n final :: fini_shape2\n end type t2e\n\n type t3\n integer :: i = 3\n contains\n final :: fini_explicit\n end type t3\n\n type, extends(t3) :: t3e\n integer :: j = 33\n contains\n final :: fini_explicit2\n end type t3e\n\n integer :: cnt1, cnt1e, cnt2, cnt2e, cnt3, cnt3e\n\ncontains\n\n impure elemental subroutine fini_elem(x)\n type(t1), intent(inout) :: x\n integer :: i, j, i2, j2\n\n if (cnt1e \/= 5*4) STOP 1\n j = mod (cnt1,5)+1\n i = cnt1\/5 + 1\n i2 = (i-1)*3 + 1\n j2 = (j-1)*2 + 1\n if (x%i \/= j2 + 100*i2) STOP 2\n x%i = x%i * (-13)\n cnt1 = cnt1 + 1\n end subroutine fini_elem\n\n impure elemental subroutine fini_elem2(x)\n type(t1e), intent(inout) :: x\n integer :: i, j, i2, j2\n\n j = mod (cnt1e,5)+1\n i = cnt1e\/5 + 1\n i2 = (i-1)*3 + 1\n j2 = (j-1)*2 + 1\n if (x%i \/= j2 + 100*i2) STOP 3\n if (x%j \/= (j2 + 100*i2)*100) STOP 4\n x%j = x%j * (-13)\n cnt1e = cnt1e + 1\n end subroutine fini_elem2\n\n subroutine fini_shape(x)\n type(t2) :: x(:,:)\n if (cnt2e \/= 1 .or. cnt2 \/= 0) STOP 5\n call check_var_sec(x%i, 1)\n x%i = x%i * (-13)\n cnt2 = cnt2 + 1\n end subroutine fini_shape\n\n subroutine fini_shape2(x)\n type(t2e) :: x(:,:)\n call check_var_sec(x%i, 1)\n call check_var_sec(x%j, 100)\n x%j = x%j * (-13)\n cnt2e = cnt2e + 1\n end subroutine fini_shape2\n\n subroutine fini_explicit(x)\n type(t3) :: x(5,4)\n if (cnt3e \/= 1 .or. cnt3 \/= 0) STOP 6\n call check_var_sec(x%i, 1)\n x%i = x%i * (-13)\n cnt3 = cnt3 + 1\n end subroutine fini_explicit\n\n subroutine fini_explicit2(x)\n type(t3e) :: x(5,4)\n call check_var_sec(x%i, 1)\n call check_var_sec(x%j, 100)\n x%j = x%j * (-13)\n cnt3e = cnt3e + 1\n end subroutine fini_explicit2\n\n subroutine fin_test_1(x)\n class(t1), intent(out) :: x(5,4)\n end subroutine fin_test_1\n\n subroutine fin_test_2(x)\n class(t2), intent(out) :: x(:,:)\n end subroutine fin_test_2\n\n subroutine fin_test_3(x)\n class(t3), intent(out) :: x(:,:)\n if (any (shape(x) \/= [5,4])) STOP 7\n end subroutine fin_test_3\n\n subroutine check_var_sec(x, factor)\n integer :: x(:,:)\n integer, value :: factor\n integer :: i, j, i2, j2\n\n do i = 1, 4\n i2 = (i-1)*3 + 1\n do j = 1, 5\n j2 = (j-1)*2 + 1\n if (x(j,i) \/= (j2 + 100*i2)*factor) STOP 8\n end do\n end do\n end subroutine check_var_sec\nend module m\n\n\nprogram test\n use m\n implicit none\n\n class(t1), allocatable :: x(:,:)\n class(t2), allocatable :: y(:,:)\n class(t3), allocatable :: z(:,:)\n integer :: i, j\n\n cnt1 = 0; cnt1e = 0; cnt2 = 0; cnt2e = 0; cnt3 = 0; cnt3e = 0\n\n allocate (t1e :: x(10,10))\n allocate (t2e :: y(10,10))\n allocate (t3e :: z(10,10))\n\n select type(x)\n type is (t1e)\n do i = 1, 10\n do j = 1, 10\n x(j,i)%i = j + 100*i\n x(j,i)%j = (j + 100*i)*100\n end do\n end do\n end select\n\n select type(y)\n type is (t2e)\n do i = 1, 10\n do j = 1, 10\n y(j,i)%i = j + 100*i\n y(j,i)%j = (j + 100*i)*100\n end do\n end do\n end select\n\n select type(z)\n type is (t3e)\n do i = 1, 10\n do j = 1, 10\n z(j,i)%i = j + 100*i\n z(j,i)%j = (j + 100*i)*100\n end do\n end do\n end select\n\n if (cnt1 + cnt1e + cnt2 + cnt2e + cnt3 + cnt3e \/= 0) STOP 9\n\n call fin_test_1(x(::2,::3))\n if (cnt1 \/= 5*4) STOP 10\n if (cnt1e \/= 5*4) STOP 11\n cnt1 = 0; cnt1e = 0\n if (cnt2 + cnt2e + cnt3 + cnt3e \/= 0) STOP 12\n\n call fin_test_2(y(::2,::3))\n if (cnt2 \/= 1) STOP 13\n if (cnt2e \/= 1) STOP 14\n cnt2 = 0; cnt2e = 0\n if (cnt1 + cnt1e + cnt3 + cnt3e \/= 0) STOP 15\n\n call fin_test_3(z(::2,::3))\n if (cnt3 \/= 1) STOP 16\n if (cnt3e \/= 1) STOP 17\n cnt3 = 0; cnt3e = 0\n if (cnt1 + cnt1e + cnt2 + cnt2e \/= 0) STOP 18\n\n select type(x)\n type is (t1e)\n call check_val(x%i, 1, 1)\n call check_val(x%j, 100, 11)\n end select\n\n select type(y)\n type is (t2e)\n call check_val(y%i, 1, 2)\n call check_val(y%j, 100, 22)\n end select\n\n select type(z)\n type is (t3e)\n call check_val(z%i, 1, 3)\n call check_val(z%j, 100, 33)\n end select\n\ncontains\n subroutine check_val(x, factor, val)\n integer :: x(:,:)\n integer, value :: factor, val\n integer :: i, j\n do i = 1, 10\n do j = 1, 10\n if (mod (j-1, 2) == 0 .and. mod (i-1, 3) == 0) then\n if (x(j,i) \/= val) STOP 19\n else\n if (x(j,i) \/= (j + 100*i)*factor) STOP 20\n end if\n end do\n end do\n end subroutine check_val\nend program test\n","avg_line_length":20.8828451883,"max_line_length":64,"alphanum_fraction":0.5403726708} {"size":17435,"ext":"f","lang":"FORTRAN","max_stars_count":624.0,"content":"*> \\brief \\b SLASD7 merges the two sets of singular values together into a single sorted set. Then it tries to deflate the size of the problem. Used by sbdsdc.\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at \n* http:\/\/www.netlib.org\/lapack\/explore-html\/ \n*\n*> \\htmlonly\n*> Download SLASD7 + dependencies \n*> \n*> [TGZ]<\/a> \n*> \n*> [ZIP]<\/a> \n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly \n*\n* Definition:\n* ===========\n*\n* SUBROUTINE SLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, VL,\n* VLW, ALPHA, BETA, DSIGMA, IDX, IDXP, IDXQ,\n* PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM,\n* C, S, INFO )\n* \n* .. Scalar Arguments ..\n* INTEGER GIVPTR, ICOMPQ, INFO, K, LDGCOL, LDGNUM, NL,\n* $ NR, SQRE\n* REAL ALPHA, BETA, C, S\n* ..\n* .. Array Arguments ..\n* INTEGER GIVCOL( LDGCOL, * ), IDX( * ), IDXP( * ),\n* $ IDXQ( * ), PERM( * )\n* REAL D( * ), DSIGMA( * ), GIVNUM( LDGNUM, * ),\n* $ VF( * ), VFW( * ), VL( * ), VLW( * ), Z( * ),\n* $ ZW( * )\n* ..\n* \n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> SLASD7 merges the two sets of singular values together into a single\n*> sorted set. Then it tries to deflate the size of the problem. There\n*> are two ways in which deflation can occur: when two or more singular\n*> values are close together or if there is a tiny entry in the Z\n*> vector. For each such occurrence the order of the related\n*> secular equation problem is reduced by one.\n*>\n*> SLASD7 is called from SLASD6.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] ICOMPQ\n*> \\verbatim\n*> ICOMPQ is INTEGER\n*> Specifies whether singular vectors are to be computed\n*> in compact form, as follows:\n*> = 0: Compute singular values only.\n*> = 1: Compute singular vectors of upper\n*> bidiagonal matrix in compact form.\n*> \\endverbatim\n*>\n*> \\param[in] NL\n*> \\verbatim\n*> NL is INTEGER\n*> The row dimension of the upper block. NL >= 1.\n*> \\endverbatim\n*>\n*> \\param[in] NR\n*> \\verbatim\n*> NR is INTEGER\n*> The row dimension of the lower block. NR >= 1.\n*> \\endverbatim\n*>\n*> \\param[in] SQRE\n*> \\verbatim\n*> SQRE is INTEGER\n*> = 0: the lower block is an NR-by-NR square matrix.\n*> = 1: the lower block is an NR-by-(NR+1) rectangular matrix.\n*>\n*> The bidiagonal matrix has\n*> N = NL + NR + 1 rows and\n*> M = N + SQRE >= N columns.\n*> \\endverbatim\n*>\n*> \\param[out] K\n*> \\verbatim\n*> K is INTEGER\n*> Contains the dimension of the non-deflated matrix, this is\n*> the order of the related secular equation. 1 <= K <=N.\n*> \\endverbatim\n*>\n*> \\param[in,out] D\n*> \\verbatim\n*> D is REAL array, dimension ( N )\n*> On entry D contains the singular values of the two submatrices\n*> to be combined. On exit D contains the trailing (N-K) updated\n*> singular values (those which were deflated) sorted into\n*> increasing order.\n*> \\endverbatim\n*>\n*> \\param[out] Z\n*> \\verbatim\n*> Z is REAL array, dimension ( M )\n*> On exit Z contains the updating row vector in the secular\n*> equation.\n*> \\endverbatim\n*>\n*> \\param[out] ZW\n*> \\verbatim\n*> ZW is REAL array, dimension ( M )\n*> Workspace for Z.\n*> \\endverbatim\n*>\n*> \\param[in,out] VF\n*> \\verbatim\n*> VF is REAL array, dimension ( M )\n*> On entry, VF(1:NL+1) contains the first components of all\n*> right singular vectors of the upper block; and VF(NL+2:M)\n*> contains the first components of all right singular vectors\n*> of the lower block. On exit, VF contains the first components\n*> of all right singular vectors of the bidiagonal matrix.\n*> \\endverbatim\n*>\n*> \\param[out] VFW\n*> \\verbatim\n*> VFW is REAL array, dimension ( M )\n*> Workspace for VF.\n*> \\endverbatim\n*>\n*> \\param[in,out] VL\n*> \\verbatim\n*> VL is REAL array, dimension ( M )\n*> On entry, VL(1:NL+1) contains the last components of all\n*> right singular vectors of the upper block; and VL(NL+2:M)\n*> contains the last components of all right singular vectors\n*> of the lower block. On exit, VL contains the last components\n*> of all right singular vectors of the bidiagonal matrix.\n*> \\endverbatim\n*>\n*> \\param[out] VLW\n*> \\verbatim\n*> VLW is REAL array, dimension ( M )\n*> Workspace for VL.\n*> \\endverbatim\n*>\n*> \\param[in] ALPHA\n*> \\verbatim\n*> ALPHA is REAL\n*> Contains the diagonal element associated with the added row.\n*> \\endverbatim\n*>\n*> \\param[in] BETA\n*> \\verbatim\n*> BETA is REAL\n*> Contains the off-diagonal element associated with the added\n*> row.\n*> \\endverbatim\n*>\n*> \\param[out] DSIGMA\n*> \\verbatim\n*> DSIGMA is REAL array, dimension ( N )\n*> Contains a copy of the diagonal elements (K-1 singular values\n*> and one zero) in the secular equation.\n*> \\endverbatim\n*>\n*> \\param[out] IDX\n*> \\verbatim\n*> IDX is INTEGER array, dimension ( N )\n*> This will contain the permutation used to sort the contents of\n*> D into ascending order.\n*> \\endverbatim\n*>\n*> \\param[out] IDXP\n*> \\verbatim\n*> IDXP is INTEGER array, dimension ( N )\n*> This will contain the permutation used to place deflated\n*> values of D at the end of the array. On output IDXP(2:K)\n*> points to the nondeflated D-values and IDXP(K+1:N)\n*> points to the deflated singular values.\n*> \\endverbatim\n*>\n*> \\param[in] IDXQ\n*> \\verbatim\n*> IDXQ is INTEGER array, dimension ( N )\n*> This contains the permutation which separately sorts the two\n*> sub-problems in D into ascending order. Note that entries in\n*> the first half of this permutation must first be moved one\n*> position backward; and entries in the second half\n*> must first have NL+1 added to their values.\n*> \\endverbatim\n*>\n*> \\param[out] PERM\n*> \\verbatim\n*> PERM is INTEGER array, dimension ( N )\n*> The permutations (from deflation and sorting) to be applied\n*> to each singular block. Not referenced if ICOMPQ = 0.\n*> \\endverbatim\n*>\n*> \\param[out] GIVPTR\n*> \\verbatim\n*> GIVPTR is INTEGER\n*> The number of Givens rotations which took place in this\n*> subproblem. Not referenced if ICOMPQ = 0.\n*> \\endverbatim\n*>\n*> \\param[out] GIVCOL\n*> \\verbatim\n*> GIVCOL is INTEGER array, dimension ( LDGCOL, 2 )\n*> Each pair of numbers indicates a pair of columns to take place\n*> in a Givens rotation. Not referenced if ICOMPQ = 0.\n*> \\endverbatim\n*>\n*> \\param[in] LDGCOL\n*> \\verbatim\n*> LDGCOL is INTEGER\n*> The leading dimension of GIVCOL, must be at least N.\n*> \\endverbatim\n*>\n*> \\param[out] GIVNUM\n*> \\verbatim\n*> GIVNUM is REAL array, dimension ( LDGNUM, 2 )\n*> Each number indicates the C or S value to be used in the\n*> corresponding Givens rotation. Not referenced if ICOMPQ = 0.\n*> \\endverbatim\n*>\n*> \\param[in] LDGNUM\n*> \\verbatim\n*> LDGNUM is INTEGER\n*> The leading dimension of GIVNUM, must be at least N.\n*> \\endverbatim\n*>\n*> \\param[out] C\n*> \\verbatim\n*> C is REAL\n*> C contains garbage if SQRE =0 and the C-value of a Givens\n*> rotation related to the right null space if SQRE = 1.\n*> \\endverbatim\n*>\n*> \\param[out] S\n*> \\verbatim\n*> S is REAL\n*> S contains garbage if SQRE =0 and the S-value of a Givens\n*> rotation related to the right null space if SQRE = 1.\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit.\n*> < 0: if INFO = -i, the i-th argument had an illegal value.\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee \n*> \\author Univ. of California Berkeley \n*> \\author Univ. of Colorado Denver \n*> \\author NAG Ltd. \n*\n*> \\date September 2012\n*\n*> \\ingroup auxOTHERauxiliary\n*\n*> \\par Contributors:\n* ==================\n*>\n*> Ming Gu and Huan Ren, Computer Science Division, University of\n*> California at Berkeley, USA\n*>\n* =====================================================================\n SUBROUTINE SLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, VL,\n $ VLW, ALPHA, BETA, DSIGMA, IDX, IDXP, IDXQ,\n $ PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM,\n $ C, S, INFO )\n*\n* -- LAPACK auxiliary routine (version 3.4.2) --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* September 2012\n*\n* .. Scalar Arguments ..\n INTEGER GIVPTR, ICOMPQ, INFO, K, LDGCOL, LDGNUM, NL,\n $ NR, SQRE\n REAL ALPHA, BETA, C, S\n* ..\n* .. Array Arguments ..\n INTEGER GIVCOL( LDGCOL, * ), IDX( * ), IDXP( * ),\n $ IDXQ( * ), PERM( * )\n REAL D( * ), DSIGMA( * ), GIVNUM( LDGNUM, * ),\n $ VF( * ), VFW( * ), VL( * ), VLW( * ), Z( * ),\n $ ZW( * )\n* ..\n*\n* =====================================================================\n*\n* .. Parameters ..\n REAL ZERO, ONE, TWO, EIGHT\n PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0,\n $ EIGHT = 8.0E+0 )\n* ..\n* .. Local Scalars ..\n*\n INTEGER I, IDXI, IDXJ, IDXJP, J, JP, JPREV, K2, M, N,\n $ NLP1, NLP2\n REAL EPS, HLFTOL, TAU, TOL, Z1\n* ..\n* .. External Subroutines ..\n EXTERNAL SCOPY, SLAMRG, SROT, XERBLA\n* ..\n* .. External Functions ..\n REAL SLAMCH, SLAPY2\n EXTERNAL SLAMCH, SLAPY2\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC ABS, MAX\n* ..\n* .. Executable Statements ..\n*\n* Test the input parameters.\n*\n INFO = 0\n N = NL + NR + 1\n M = N + SQRE\n*\n IF( ( ICOMPQ.LT.0 ) .OR. ( ICOMPQ.GT.1 ) ) THEN\n INFO = -1\n ELSE IF( NL.LT.1 ) THEN\n INFO = -2\n ELSE IF( NR.LT.1 ) THEN\n INFO = -3\n ELSE IF( ( SQRE.LT.0 ) .OR. ( SQRE.GT.1 ) ) THEN\n INFO = -4\n ELSE IF( LDGCOL.LT.N ) THEN\n INFO = -22\n ELSE IF( LDGNUM.LT.N ) THEN\n INFO = -24\n END IF\n IF( INFO.NE.0 ) THEN\n CALL XERBLA( 'SLASD7', -INFO )\n RETURN\n END IF\n*\n NLP1 = NL + 1\n NLP2 = NL + 2\n IF( ICOMPQ.EQ.1 ) THEN\n GIVPTR = 0\n END IF\n*\n* Generate the first part of the vector Z and move the singular\n* values in the first part of D one position backward.\n*\n Z1 = ALPHA*VL( NLP1 )\n VL( NLP1 ) = ZERO\n TAU = VF( NLP1 )\n DO 10 I = NL, 1, -1\n Z( I+1 ) = ALPHA*VL( I )\n VL( I ) = ZERO\n VF( I+1 ) = VF( I )\n D( I+1 ) = D( I )\n IDXQ( I+1 ) = IDXQ( I ) + 1\n 10 CONTINUE\n VF( 1 ) = TAU\n*\n* Generate the second part of the vector Z.\n*\n DO 20 I = NLP2, M\n Z( I ) = BETA*VF( I )\n VF( I ) = ZERO\n 20 CONTINUE\n*\n* Sort the singular values into increasing order\n*\n DO 30 I = NLP2, N\n IDXQ( I ) = IDXQ( I ) + NLP1\n 30 CONTINUE\n*\n* DSIGMA, IDXC, IDXC, and ZW are used as storage space.\n*\n DO 40 I = 2, N\n DSIGMA( I ) = D( IDXQ( I ) )\n ZW( I ) = Z( IDXQ( I ) )\n VFW( I ) = VF( IDXQ( I ) )\n VLW( I ) = VL( IDXQ( I ) )\n 40 CONTINUE\n*\n CALL SLAMRG( NL, NR, DSIGMA( 2 ), 1, 1, IDX( 2 ) )\n*\n DO 50 I = 2, N\n IDXI = 1 + IDX( I )\n D( I ) = DSIGMA( IDXI )\n Z( I ) = ZW( IDXI )\n VF( I ) = VFW( IDXI )\n VL( I ) = VLW( IDXI )\n 50 CONTINUE\n*\n* Calculate the allowable deflation tolerence\n*\n EPS = SLAMCH( 'Epsilon' )\n TOL = MAX( ABS( ALPHA ), ABS( BETA ) )\n TOL = EIGHT*EIGHT*EPS*MAX( ABS( D( N ) ), TOL )\n*\n* There are 2 kinds of deflation -- first a value in the z-vector\n* is small, second two (or more) singular values are very close\n* together (their difference is small).\n*\n* If the value in the z-vector is small, we simply permute the\n* array so that the corresponding singular value is moved to the\n* end.\n*\n* If two values in the D-vector are close, we perform a two-sided\n* rotation designed to make one of the corresponding z-vector\n* entries zero, and then permute the array so that the deflated\n* singular value is moved to the end.\n*\n* If there are multiple singular values then the problem deflates.\n* Here the number of equal singular values are found. As each equal\n* singular value is found, an elementary reflector is computed to\n* rotate the corresponding singular subspace so that the\n* corresponding components of Z are zero in this new basis.\n*\n K = 1\n K2 = N + 1\n DO 60 J = 2, N\n IF( ABS( Z( J ) ).LE.TOL ) THEN\n*\n* Deflate due to small z component.\n*\n K2 = K2 - 1\n IDXP( K2 ) = J\n IF( J.EQ.N )\n $ GO TO 100\n ELSE\n JPREV = J\n GO TO 70\n END IF\n 60 CONTINUE\n 70 CONTINUE\n J = JPREV\n 80 CONTINUE\n J = J + 1\n IF( J.GT.N )\n $ GO TO 90\n IF( ABS( Z( J ) ).LE.TOL ) THEN\n*\n* Deflate due to small z component.\n*\n K2 = K2 - 1\n IDXP( K2 ) = J\n ELSE\n*\n* Check if singular values are close enough to allow deflation.\n*\n IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN\n*\n* Deflation is possible.\n*\n S = Z( JPREV )\n C = Z( J )\n*\n* Find sqrt(a**2+b**2) without overflow or\n* destructive underflow.\n*\n TAU = SLAPY2( C, S )\n Z( J ) = TAU\n Z( JPREV ) = ZERO\n C = C \/ TAU\n S = -S \/ TAU\n*\n* Record the appropriate Givens rotation\n*\n IF( ICOMPQ.EQ.1 ) THEN\n GIVPTR = GIVPTR + 1\n IDXJP = IDXQ( IDX( JPREV )+1 )\n IDXJ = IDXQ( IDX( J )+1 )\n IF( IDXJP.LE.NLP1 ) THEN\n IDXJP = IDXJP - 1\n END IF\n IF( IDXJ.LE.NLP1 ) THEN\n IDXJ = IDXJ - 1\n END IF\n GIVCOL( GIVPTR, 2 ) = IDXJP\n GIVCOL( GIVPTR, 1 ) = IDXJ\n GIVNUM( GIVPTR, 2 ) = C\n GIVNUM( GIVPTR, 1 ) = S\n END IF\n CALL SROT( 1, VF( JPREV ), 1, VF( J ), 1, C, S )\n CALL SROT( 1, VL( JPREV ), 1, VL( J ), 1, C, S )\n K2 = K2 - 1\n IDXP( K2 ) = JPREV\n JPREV = J\n ELSE\n K = K + 1\n ZW( K ) = Z( JPREV )\n DSIGMA( K ) = D( JPREV )\n IDXP( K ) = JPREV\n JPREV = J\n END IF\n END IF\n GO TO 80\n 90 CONTINUE\n*\n* Record the last singular value.\n*\n K = K + 1\n ZW( K ) = Z( JPREV )\n DSIGMA( K ) = D( JPREV )\n IDXP( K ) = JPREV\n*\n 100 CONTINUE\n*\n* Sort the singular values into DSIGMA. The singular values which\n* were not deflated go into the first K slots of DSIGMA, except\n* that DSIGMA(1) is treated separately.\n*\n DO 110 J = 2, N\n JP = IDXP( J )\n DSIGMA( J ) = D( JP )\n VFW( J ) = VF( JP )\n VLW( J ) = VL( JP )\n 110 CONTINUE\n IF( ICOMPQ.EQ.1 ) THEN\n DO 120 J = 2, N\n JP = IDXP( J )\n PERM( J ) = IDXQ( IDX( JP )+1 )\n IF( PERM( J ).LE.NLP1 ) THEN\n PERM( J ) = PERM( J ) - 1\n END IF\n 120 CONTINUE\n END IF\n*\n* The deflated singular values go back into the last N - K slots of\n* D.\n*\n CALL SCOPY( N-K, DSIGMA( K+1 ), 1, D( K+1 ), 1 )\n*\n* Determine DSIGMA(1), DSIGMA(2), Z(1), VF(1), VL(1), VF(M), and\n* VL(M).\n*\n DSIGMA( 1 ) = ZERO\n HLFTOL = TOL \/ TWO\n IF( ABS( DSIGMA( 2 ) ).LE.HLFTOL )\n $ DSIGMA( 2 ) = HLFTOL\n IF( M.GT.N ) THEN\n Z( 1 ) = SLAPY2( Z1, Z( M ) )\n IF( Z( 1 ).LE.TOL ) THEN\n C = ONE\n S = ZERO\n Z( 1 ) = TOL\n ELSE\n C = Z1 \/ Z( 1 )\n S = -Z( M ) \/ Z( 1 )\n END IF\n CALL SROT( 1, VF( M ), 1, VF( 1 ), 1, C, S )\n CALL SROT( 1, VL( M ), 1, VL( 1 ), 1, C, S )\n ELSE\n IF( ABS( Z1 ).LE.TOL ) THEN\n Z( 1 ) = TOL\n ELSE\n Z( 1 ) = Z1\n END IF\n END IF\n*\n* Restore Z, VF, and VL.\n*\n CALL SCOPY( K-1, ZW( 2 ), 1, Z( 2 ), 1 )\n CALL SCOPY( N-1, VFW( 2 ), 1, VF( 2 ), 1 )\n CALL SCOPY( N-1, VLW( 2 ), 1, VL( 2 ), 1 )\n*\n RETURN\n*\n* End of SLASD7\n*\n END\n","avg_line_length":30.008605852,"max_line_length":159,"alphanum_fraction":0.5151706338} {"size":422,"ext":"f90","lang":"FORTRAN","max_stars_count":488.0,"content":"! { dg-do run }\n! { dg-options \"-fbounds-check\" }\n! { dg-shouldfail \"Incorrect size in SHIFT argument of EOSHIFT intrinsic: should not be zero-sized\" }\nprogram main\n real, dimension(1,0) :: a, b, c\n integer :: sp(3), i\n a = 4.0\n sp = 1\n i = 1\n b = eoshift (a,sp(1:i)) ! Invalid\nend program main\n! { dg-output \"Fortran runtime error: Incorrect size in SHIFT argument of EOSHIFT intrinsic: should not be zero-sized\" }\n","avg_line_length":32.4615384615,"max_line_length":120,"alphanum_fraction":0.6658767773} {"size":3766,"ext":"f","lang":"FORTRAN","max_stars_count":11.0,"content":"c\nc ----------------------------------------------------------\nc\n subroutine fluxsv(mptr,xfluxm,xfluxp,yfluxm,yfluxp,listbc,\n 1 ndimx,ndimy,nvar,maxsp,dtc,hx,hy)\nc\n use amr_module\n implicit double precision (a-h,o-z)\n\n\n dimension xfluxp(nvar,ndimx,ndimy), yfluxp(nvar,ndimx,ndimy)\n dimension xfluxm(nvar,ndimx,ndimy), yfluxm(nvar,ndimx,ndimy)\n dimension listbc(5,maxsp)\nc\nc :::::::::::::::::::: FLUXSV :::::::::::::::::::::::::\nc\nc coarse grids should save their fluxes in cells adjacent to\nc their nested fine grids, for later conservation fixing.\nc listbc holds info for where to save which fluxes.\nc xflux holds 'f' fluxes, yflux holds 'g' fluxes.\nc\nc :::::::::::::::::::::::::::::;:::::::::::::::::::::::\n \n \n ispot = 1\n level = node(nestlevel,mptr)\n\n 10 if (listbc(1,ispot).eq.0) go to 99 \nc\n mkid = listbc(4,ispot)\n intopl = listbc(5,ispot)\n nx = node(ndihi,mkid) - node(ndilo,mkid) + 1\n ny = node(ndjhi,mkid) - node(ndjlo,mkid) + 1\n kidlst = node(ffluxptr,mkid)\n i = listbc(1,ispot)\n j = listbc(2,ispot)\n inlist = kidlst + nvar*(intopl-1) - 1\nc\nc side k (listbc 3) has which side of coarse cell has interface\nc so can save appropriate fluxes. (dont know why we didnt have\nc which flux to save directly (i.e. put i+1,j to save that flux\nc rather than putting in cell center coords).\n\n if (listbc(3,ispot) .eq. 1) then\nc ::::: Cell i,j is on right side of a fine grid\n do 100 ivar = 1, nvar\n alloc(inlist + ivar) = -xfluxp(ivar,i,j)*dtc*hy\n100 continue\nc write(dbugunit,901) i,j,1,(xfluxp(ivar,i,j),ivar=1,nvar)\n endif\n\n if (listbc(3,ispot) .eq. 2) then\nc ::::: Cell i,j on bottom side of fine grid\n do 200 ivar = 1, nvar\n alloc(inlist + ivar) = -yfluxm(ivar,i,j+1)*dtc*hx\n200 continue\nc write(dbugunit,901) i,j,2,(yfluxm(ivar,i,j+1),ivar=1,nvar)\n endif\n\n if (listbc(3,ispot) .eq. 3) then\nc ::::: Cell i,j on left side of fine grid\n do 300 ivar = 1, nvar\n alloc(inlist + ivar) = -xfluxm(ivar,i+1,j)*dtc*hy\n300 continue\nc write(dbugunit,901) i,j,3,(xfluxm(ivar,i+1,j),ivar=1,nvar)\n endif\n\n if (listbc(3,ispot) .eq. 4) then\nc ::::: Cell i,j on top side of fine grid\n do 400 ivar = 1, nvar\n alloc(inlist + ivar) = -yfluxp(ivar,i,j)*dtc*hx\n400 continue\nc write(dbugunit,901) i,j,4,(yfluxp(ivar,i,j),ivar=1,nvar)\n endif\nc\nc ### new bcs 5 and 6 come from spherical mapping. note sign change:\nc ### previous fluxes stored negative flux, fine grids always add\nc ### their flux, then the delta is either added or subtracted as\nc ### appropriate for that side. New bc adds or subtracts BOTH fluxes.\nc\n if (listbc(3,ispot) .eq. 5) then\nc ::::: Cell i,j on top side of fine grid with spherical mapped bc\n do 500 ivar = 1, nvar\n alloc(inlist + ivar) = yfluxm(ivar,i,j+1)*dtc*hx\n500 continue\nc write(dbugunit,901) i,j,5,(yfluxm(ivar,i,j+1),ivar=1,nvar)\n 901 format(2i4,\" side\",i3,4e15.7)\n endif\nc\n if (listbc(3,ispot) .eq. 6) then\nc ::::: Cell i,j on bottom side of fine grid with spherical mapped bc\n do 600 ivar = 1, nvar\n alloc(inlist + ivar) = yfluxp(ivar,i,j)*dtc*hx\n600 continue\nc write(dbugunit,901) i,j,6,(yfluxp(ivar,i,j),ivar=1,nvar)\n endif\n\n ispot = ispot + 1\n if (ispot .gt. maxsp) go to 99\n go to 10\nc\n 99 return\n end\n","avg_line_length":36.2115384615,"max_line_length":79,"alphanum_fraction":0.5472650027} {"size":6230,"ext":"f","lang":"FORTRAN","max_stars_count":4392.0,"content":"*> \\brief \\b ZGTTRS\n*\n* =========== DOCUMENTATION ===========\n*\n* Online html documentation available at\n* http:\/\/www.netlib.org\/lapack\/explore-html\/\n*\n*> \\htmlonly\n*> Download ZGTTRS + dependencies\n*> \n*> [TGZ]<\/a>\n*> \n*> [ZIP]<\/a>\n*> \n*> [TXT]<\/a>\n*> \\endhtmlonly\n*\n* Definition:\n* ===========\n*\n* SUBROUTINE ZGTTRS( TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB,\n* INFO )\n*\n* .. Scalar Arguments ..\n* CHARACTER TRANS\n* INTEGER INFO, LDB, N, NRHS\n* ..\n* .. Array Arguments ..\n* INTEGER IPIV( * )\n* COMPLEX*16 B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )\n* ..\n*\n*\n*> \\par Purpose:\n* =============\n*>\n*> \\verbatim\n*>\n*> ZGTTRS solves one of the systems of equations\n*> A * X = B, A**T * X = B, or A**H * X = B,\n*> with a tridiagonal matrix A using the LU factorization computed\n*> by ZGTTRF.\n*> \\endverbatim\n*\n* Arguments:\n* ==========\n*\n*> \\param[in] TRANS\n*> \\verbatim\n*> TRANS is CHARACTER*1\n*> Specifies the form of the system of equations.\n*> = 'N': A * X = B (No transpose)\n*> = 'T': A**T * X = B (Transpose)\n*> = 'C': A**H * X = B (Conjugate transpose)\n*> \\endverbatim\n*>\n*> \\param[in] N\n*> \\verbatim\n*> N is INTEGER\n*> The order of the matrix A.\n*> \\endverbatim\n*>\n*> \\param[in] NRHS\n*> \\verbatim\n*> NRHS is INTEGER\n*> The number of right hand sides, i.e., the number of columns\n*> of the matrix B. NRHS >= 0.\n*> \\endverbatim\n*>\n*> \\param[in] DL\n*> \\verbatim\n*> DL is COMPLEX*16 array, dimension (N-1)\n*> The (n-1) multipliers that define the matrix L from the\n*> LU factorization of A.\n*> \\endverbatim\n*>\n*> \\param[in] D\n*> \\verbatim\n*> D is COMPLEX*16 array, dimension (N)\n*> The n diagonal elements of the upper triangular matrix U from\n*> the LU factorization of A.\n*> \\endverbatim\n*>\n*> \\param[in] DU\n*> \\verbatim\n*> DU is COMPLEX*16 array, dimension (N-1)\n*> The (n-1) elements of the first super-diagonal of U.\n*> \\endverbatim\n*>\n*> \\param[in] DU2\n*> \\verbatim\n*> DU2 is COMPLEX*16 array, dimension (N-2)\n*> The (n-2) elements of the second super-diagonal of U.\n*> \\endverbatim\n*>\n*> \\param[in] IPIV\n*> \\verbatim\n*> IPIV is INTEGER array, dimension (N)\n*> The pivot indices; for 1 <= i <= n, row i of the matrix was\n*> interchanged with row IPIV(i). IPIV(i) will always be either\n*> i or i+1; IPIV(i) = i indicates a row interchange was not\n*> required.\n*> \\endverbatim\n*>\n*> \\param[in,out] B\n*> \\verbatim\n*> B is COMPLEX*16 array, dimension (LDB,NRHS)\n*> On entry, the matrix of right hand side vectors B.\n*> On exit, B is overwritten by the solution vectors X.\n*> \\endverbatim\n*>\n*> \\param[in] LDB\n*> \\verbatim\n*> LDB is INTEGER\n*> The leading dimension of the array B. LDB >= max(1,N).\n*> \\endverbatim\n*>\n*> \\param[out] INFO\n*> \\verbatim\n*> INFO is INTEGER\n*> = 0: successful exit\n*> < 0: if INFO = -k, the k-th argument had an illegal value\n*> \\endverbatim\n*\n* Authors:\n* ========\n*\n*> \\author Univ. of Tennessee\n*> \\author Univ. of California Berkeley\n*> \\author Univ. of Colorado Denver\n*> \\author NAG Ltd.\n*\n*> \\date December 2016\n*\n*> \\ingroup complex16GTcomputational\n*\n* =====================================================================\n SUBROUTINE ZGTTRS( TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB,\n $ INFO )\n*\n* -- LAPACK computational routine (version 3.7.0) --\n* -- LAPACK is a software package provided by Univ. of Tennessee, --\n* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--\n* December 2016\n*\n* .. Scalar Arguments ..\n CHARACTER TRANS\n INTEGER INFO, LDB, N, NRHS\n* ..\n* .. Array Arguments ..\n INTEGER IPIV( * )\n COMPLEX*16 B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )\n* ..\n*\n* =====================================================================\n*\n* .. Local Scalars ..\n LOGICAL NOTRAN\n INTEGER ITRANS, J, JB, NB\n* ..\n* .. External Functions ..\n INTEGER ILAENV\n EXTERNAL ILAENV\n* ..\n* .. External Subroutines ..\n EXTERNAL XERBLA, ZGTTS2\n* ..\n* .. Intrinsic Functions ..\n INTRINSIC MAX, MIN\n* ..\n* .. Executable Statements ..\n*\n INFO = 0\n NOTRAN = ( TRANS.EQ.'N' .OR. TRANS.EQ.'n' )\n IF( .NOT.NOTRAN .AND. .NOT.( TRANS.EQ.'T' .OR. TRANS.EQ.\n $ 't' ) .AND. .NOT.( TRANS.EQ.'C' .OR. TRANS.EQ.'c' ) ) THEN\n INFO = -1\n ELSE IF( N.LT.0 ) THEN\n INFO = -2\n ELSE IF( NRHS.LT.0 ) THEN\n INFO = -3\n ELSE IF( LDB.LT.MAX( N, 1 ) ) THEN\n INFO = -10\n END IF\n IF( INFO.NE.0 ) THEN\n CALL XERBLA( 'ZGTTRS', -INFO )\n RETURN\n END IF\n*\n* Quick return if possible\n*\n IF( N.EQ.0 .OR. NRHS.EQ.0 )\n $ RETURN\n*\n* Decode TRANS\n*\n IF( NOTRAN ) THEN\n ITRANS = 0\n ELSE IF( TRANS.EQ.'T' .OR. TRANS.EQ.'t' ) THEN\n ITRANS = 1\n ELSE\n ITRANS = 2\n END IF\n*\n* Determine the number of right-hand sides to solve at a time.\n*\n IF( NRHS.EQ.1 ) THEN\n NB = 1\n ELSE\n NB = MAX( 1, ILAENV( 1, 'ZGTTRS', TRANS, N, NRHS, -1, -1 ) )\n END IF\n*\n IF( NB.GE.NRHS ) THEN\n CALL ZGTTS2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )\n ELSE\n DO 10 J = 1, NRHS, NB\n JB = MIN( NRHS-J+1, NB )\n CALL ZGTTS2( ITRANS, N, JB, DL, D, DU, DU2, IPIV, B( 1, J ),\n $ LDB )\n 10 CONTINUE\n END IF\n*\n* End of ZGTTRS\n*\n END\n","avg_line_length":27.5663716814,"max_line_length":111,"alphanum_fraction":0.5064205457} {"size":708,"ext":"f03","lang":"FORTRAN","max_stars_count":12.0,"content":"! { dg-do run }\n\n! Type-bound procedures\n! Check that calls work across module-boundaries.\n\nMODULE m\n IMPLICIT NONE\n\n TYPE trueOrFalse\n LOGICAL :: val\n CONTAINS\n PROCEDURE, PASS :: swap\n END TYPE trueOrFalse\n\nCONTAINS\n\n SUBROUTINE swap (me1, me2)\n IMPLICIT NONE\n CLASS(trueOrFalse), INTENT(INOUT) :: me1, me2\n\n IF (.NOT. me1%val .OR. me2%val) THEN\n STOP 1\n END IF\n \n me1%val = .FALSE.\n me2%val = .TRUE.\n END SUBROUTINE swap\n\nEND MODULE m\n\nPROGRAM main\n USE m, ONLY: trueOrFalse\n IMPLICIT NONE\n\n TYPE(trueOrFalse) :: t, f\n\n t%val = .TRUE.\n f%val = .FALSE.\n\n CALL t%swap (f)\n CALL f%swap (t)\n\n IF (.NOT. t%val .OR. f%val) THEN\n STOP 2\n END IF\nEND PROGRAM main\n","avg_line_length":15.0638297872,"max_line_length":49,"alphanum_fraction":0.6299435028} {"size":13967,"ext":"f","lang":"FORTRAN","max_stars_count":11.0,"content":" integer*8 function ktfmaloc(k,n,m,vec,trans,irtc)\n use tfstk\n implicit none\n type (sad_descriptor) ,intent(in):: k\n integer*8 ktfmalocp\n integer*4 ,intent(inout):: n,m,irtc\n logical*4 ,intent(in):: vec,trans\n ktfmaloc=ktfmalocp(k,n,m,vec,trans,.false.,.true.,irtc)\n return\n end\n\n integer*8 function ktfmalocp(k,n,m,vec,trans,map,err,irtc)\n use tfstk\n use tfshare\n use tmacro\n implicit none\n type (sad_descriptor) ,intent(in):: k\n type (sad_dlist), pointer :: kl,kl1,kli\n integer*8 kap,i0,ip0\n integer*4 ,intent(out):: n,m,irtc\n integer*4 i,itfmessage\n logical*4 ,intent(in):: vec,trans,map,err\nc\n ktfmalocp=-9999\nc\n if(.not. tflistq(k,kl))then\n go to 9100\n endif\n if(vec)then\n if(ktfreallistq(kl))then\n n=kl%nl\n m=0\n if(map .and. nparallel .gt. 1)then\n irtc=1\n kap=ktfallocshared(n)\nc kap=mapalloc8(rlist(0), n, 8, irtc)\n else\n kap=ktaloc(n)\n endif\n rlist(kap:kap+n-1)=kl%rbody(1:n)\nc call tmov(rlist(ka+1),rlist(kap),n)\n ktfmalocp=kap\n irtc=0\n return\n elseif(tfnumberq(kl%dbody(1)))then\n go to 9000\n endif\n elseif(ktfreallistq(kl)\n $ .or. tfnonlistq(kl%dbody(1),kl1))then\n go to 9000\n endif\n irtc=0\n n=kl%nl\n m=kl1%nl\n do i=1,n\n if(tfnonlistq(kl%dbody(i),kli))then\n go to 9000\n endif\n if(kli%nl .ne. m)then\n go to 9000\n endif\n if(ktfnonreallistqo(kli))then\n irtc=merge(itfmessage(9,'General::wrongtype','\"Real matrix\"'),\n $ -1,err)\n return\n endif\n enddo\n if(map .and. nparallel .gt. 1)then\n irtc=1\n kap=ktfallocshared(m*n)\nc kap=mapalloc8(rlist(0), m*n, 8, irtc)\n else\n kap=ktaloc(m*n)\n endif\n if(kap .lt. 0)then\n irtc=itfmessage(999,'General::memoryfull',' ')\n return\n endif\n if(trans)then\n do i=1,n\n i0=ktfaddr(kl%dbody(i)%k)\n ip0=kap+(i-1)*m-1\n rlist(ip0+1:ip0+m)=rlist(i0+1:i0+m)\n enddo\n else\n do i=1,n\n i0=ktfaddr(kl%dbody(i)%k)\n rlist(kap+i-1:kap+(m-1)*n+i-1:n)=rlist(i0+1:i0+m)\nc do j=1,m\nc ip=kap+(j-1)*n+i-1\nc rlist(ip)=rlist(i0+j)\nc enddo\n enddo\n endif\n irtc=0\n ktfmalocp=kap\n return\n 9000 irtc=merge(itfmessage(9,'General::wrongtype','\"Matrix\"'),\n $ -1,err)\n return\n 9100 irtc=merge(itfmessage(9,'General::wrongtype',\n $ '\"Numerical List or Matrix\"'),-1,err)\n return\n end\n\n subroutine tfl2m(kl,a,n,m,trans)\n use tfstk\n implicit none\n type (sad_dlist) ,intent(in):: kl\n type (sad_dlist), pointer :: kli\n integer*4 ,intent(in):: n,m\n integer*4 i\n real*8, intent(out):: a(n,m)\n logical*4 ,intent(in):: trans\n if(trans)then\n do i=1,m\n call loc_sad(ktfaddr(kl%dbody(i)%k),kli)\n a(:,i)=kli%rbody(1:n)\n enddo\n else\n do i=1,n\n call loc_sad(ktfaddr(kl%dbody(i)%k),kli)\n a(i,:)=kli%rbody(1:m)\n enddo\n endif\n return\n end\n\n subroutine tfl2cm(kl,c,n,m,trans,irtc)\n use tfstk\n implicit none\n type (sad_dlist) ,intent(in):: kl\n type (sad_dlist), pointer :: kli\n type (sad_complex), pointer :: cx\n integer*8 kij\n integer*4 ,intent(in)::n,m\n integer*4 ,intent(out)::irtc\n integer*4 i,j\n complex*16, intent(out):: c(n,max(m,1))\n real*8 x\n logical*4 trans\n if(m .eq. 0)then\n do j=1,n\n kij=kl%body(j)\n if(ktfrealq(kij,x))then\n c(j,1)=dcmplx(x,0.d0)\n elseif(tfcomplexq(kij,cx))then\n c(j,1)=cx%cx(1)\n else\n irtc=-1\n return\n endif\n enddo\n elseif(trans)then\n do i=1,m\n call loc_sad(ktfaddr(kl%dbody(i)%k),kli)\n do j=1,n\n kij=kli%dbody(j)%k\n if(ktfrealq(kij,x))then\n c(j,i)=x\n elseif(tfcomplexq(kij,cx))then\n c(j,i)=cx%cx(1)\n else\n irtc=-1\n return\n endif\n enddo\n enddo\n else\n do i=1,n\n call loc_sad(ktfaddr(kl%dbody(i)%k),kli)\n do j=1,m\n kij=kli%dbody(j)%k\n if(ktfrealq(kij,x))then\n c(i,j)=x\n elseif(tfcomplexq(kij,cx))then\n c(i,j)=cx%cx(1)\n else\n irtc=-1\n return\n endif\n enddo\n enddo\n endif\n irtc=0\n return\n end\n\n subroutine tfmsize(k,n,m,irtc)\n use tfstk\n implicit none\n type (sad_descriptor) ,intent(in):: k\n type (sad_dlist), pointer ::kl,kl1,kli\n integer*4 ,intent(inout):: n,m,irtc\n integer*4 i,itfmessage\n if(.not. tflistq(k,kl))then\n irtc=itfmessage(9,'General::wrongtype','\"List\"')\n return\n endif\n if(ktfreallistq(kl))then\n n=kl%nl\n m=-1\n irtc=0\n return\n endif\n if(tfnonlistq(kl%dbody(1),kl1))then\n go to 9000\n endif\n n=kl%nl\n m=kl1%nl\n do i=1,n\n if(tfnonlistq(kl%dbody(i),kli))then\n go to 9000\n endif\n if(kli%nl .ne. m)then\n go to 9000\n endif\n if(ktfnonreallistqo(kli))then\n irtc=itfmessage(9,'General::wrongtype','\"Real matrix\"')\n return\n endif\n enddo\n irtc=0\n return\n 9000 irtc=itfmessage(9,'General::wrongtype','\"Matrix\"')\n return\n end\n\n integer*8 function ktfcmaloc(k,n,m,vec,trans,err,irtc)\n use tfstk\n implicit none\n type (sad_descriptor) ,intent(in):: k\n type (sad_complex), pointer :: cxi\n type (sad_dlist), pointer :: kl,kl1,kli\n type (sad_rlist), pointer :: klj\n integer*8 kap,ki,ip0,kj,kaj\n integer*4 ,intent(out):: n,m,irtc\n integer*4 i,j,itfmessage\n logical*4 ,intent(in):: vec,trans,err\n ktfcmaloc=0\n if(.not. tflistq(k,kl))then\n go to 9100\n endif\n irtc=0\n if(vec)then\n n=kl%nl\n m=0\n if(ktfreallistq(kl))then\n kap=ktaloc(n*2)\n rlist(kap:kap+2*n-2:2)=kl%rbody(1:n)\n rlist(kap+1:kap+2*n-1:2)=0.d0\nc do i=1,n\nc rlist(kap+i*2-2)=kl%rbody(i)\nc rlist(kap+i*2-1)=0.d0\nc enddo\n ktfcmaloc=kap\n return\n elseif(tfnumberq(kl%dbody(1)))then\n kap=ktaloc(n*2)\n do i=1,n\n ki=kl%dbody(i)%k\n if(ktfrealq(ki))then\n klist(kap+i*2-2)=ki\n klist(kap+i*2-1)=0\n else\n if(tfcomplexq(ki,cxi))then\n rlist(kap+i*2-2)=cxi%re\n rlist(kap+i*2-1)=cxi%im\n else\n go to 8900\n endif\n endif\n enddo\n ktfcmaloc=kap\n return\n endif\n elseif(ktfreallistq(kl) .or. tfnumberq(kl%dbody(1)))then\n go to 9000\n endif\n if(tfnonlistq(kl%dbody(1),kl1))then\n ktfcmaloc=-1\n go to 9000\n endif\n irtc=0\n n=kl%nl\n m=kl1%nl\n do i=1,n\n if(tfnonlistq(kl%dbody(i)%k,kli))then\n ktfcmaloc=-1\n go to 9000\n endif\n if(kli%nl .ne. m)then\n ktfcmaloc=-1\n go to 9000\n endif\n enddo\n kap=ktaloc(m*n*2)\n if(trans)then\n do i=1,n\n call loc_sad(ktfaddr(kl%dbody(i)%k),kli)\n ip0=kap+(i-1)*2*m-2\n if(ktfreallistq(kli))then\n rlist(ip0+2:ip0+2*m:2)=kli%rbody(1:m)\n rlist(ip0+3:ip0+2*m+1:2)=0.d0\nc do j=1,m\nc rlist(ip0+j*2 )=kli%rbody(j)\nc rlist(ip0+j*2+1)=0.d0\nc enddo\n else\n do j=1,m\n kj=kli%dbody(j)%k\n if(ktfrealq(kj))then\n klist(ip0+j*2 )=kj\n klist(ip0+j*2+1)=0\n else\n kaj=ktfaddr(kj)\n if(ktfreallistq(kj,klj) .and.\n $ klj%head%k .eq. ktfoper+mtfcomplex\n $ .and. klj%nl .eq. 2)then\n rlist(ip0+j*2 )=klj%rbody(1)\n rlist(ip0+j*2+1)=klj%rbody(2)\n else\n call tfree(kap)\n ktfcmaloc=-1\n go to 9000\n endif\n endif\n enddo\n endif\n enddo\n else\n do i=1,n\n call loc_sad(ktfaddr(kl%dbody(i)%k),kli)\n if(ktfreallistq(kli))then\n rlist(kap+i*2-2:kap+2*((m-1)*n+i-1))=kli%rbody(1:m)\nc do j=1,m\nc ip0=kap+(j-1)*2*n+i*2-2\nc rlist(ip0 )=kli%rbody(j)\nc rlist(ip0+1)=0.d0\nc enddo\n else\n do j=1,m\n kj=kli%dbody(j)%k\n ip0=kap+(j-1)*2*n+i*2-2\n if(ktfrealq(kj))then\n klist(ip0 )=kj\n klist(ip0+1)=0\n else\n kaj=ktfaddr(kj)\n if(ktfreallistq(kj,klj) .and.\n $ klj%head%k .eq. ktfoper+mtfcomplex\n $ .and. klj%nl .eq. 2)then\n rlist(ip0 )=rlist(kaj+1)\n rlist(ip0+1)=rlist(kaj+2)\n else\n call tfree(kap)\n ktfcmaloc=-1\n go to 9000\n endif\n endif\n enddo\n endif\n enddo\n endif\n irtc=0\n ktfcmaloc=kap\n return\n 8900 call tfree(kap)\n ktfcmaloc=-1\n if(err)then\n irtc=itfmessage(9,'General::wrongtype',\n $ '\"Numeric vector\"')\n else\n irtc=-1\n endif\n return\n 9000 irtc=merge(itfmessage(9,'General::wrongtype','\"Matrix\"'),\n $ -1,err)\n return\n 9100 irtc=merge(itfmessage(9,'General::wrongtype','\"List\"'),\n $ -1,err)\n return\n end\n\n integer*8 function ktfc2l(cx,n)\n use tfstk\n implicit none\n integer*8 ktfcm2l\n integer*4 ,intent(in)::n\n complex*16 ,intent(in):: cx(n)\n ktfc2l=ktfcm2l(cx,0,n,1,.false.,.false.)\n return\n end\n\n subroutine nanchecka(a,n,m,ndim,tag,k)\n use tfstk, only:ktfenanq\n implicit none\n integer*4 n,m,ndim,i,j,k\n real*8, intent(in):: a(ndim,m)\n character*(*) tag\n do i=1,m\n do j=1,n\n if(ktfenanq(a(j,i)))then\n write(*,'(2a,3i6,Z18)')'nanchecka ',tag,k,j,i,a(j,i)\n return\n endif\n enddo\n enddo\n return\n end\n\n integer*8 function ktfcm2l(a,n,m,nd,trans,conj)\n use tfstk\n implicit none\n type (sad_dlist), pointer :: klx,klxi\n type (sad_rlist), pointer :: klj,kl\n integer*8 kax,kaxi,ktcalocm,kai,kc,kaj\n integer*4,intent(in):: n,m,nd\n integer*4 i,j\n logical*4 ,intent(in)::trans,conj\n logical*4 c\n real*8 imag_sign\n complex*16, intent(in):: a(nd,m)\n imag_sign=merge(-1.d0,1.d0,conj)\n kc=0\n if(n .eq. 0)then\n kax=ktaaloc(-1,m,klx)\n c=.false.\n do i=1,m\n if(imag(a(1,i)) .eq. 0.d0)then\n klx%rbody(i)=dble(a(1,i))\n if(kc .ne. 0)then\n kai=kc+(i-1)*6\n call tflocal1(kai)\n endif\n else\n if(kc .eq. 0)then\n kc=ktcalocm(m-i+1)-(i-1)*6\n endif\n kai=kc+(i-1)*6\n call loc_sad(kai,kl)\n kl%rbody(1)=dble(a(1,i))\n kl%rbody(2)=imag_sign*imag(a(1,i))\n klx%dbody(i)%k=ktflist+kai\nc klist(kax+i)=ktflist+ktcalocv(0,dble(a(1,i)),\nc $ imag_sign*imag(a(1,i)))\n c=.true.\n endif\n enddo\n klx%attr=merge(lconstlist+lnonreallist,lconstlist,c)\n else\n if(trans)then\n kax=ktadaloc(-1,m,klx)\n do i=1,m\n kaxi=ktaaloc(0,n,klxi)\n kc=0\n c=.false.\n do j=1,n\n if(imag(a(j,i)) .eq. 0.d0)then\n klxi%rbody(j)=dble(a(j,i))\n if(kc .ne. 0)then\n kaj=kc+(j-1)*6\n call tflocal1(kaj)\n endif\n else\n if(kc .eq. 0)then\n kc=ktcalocm(n-j+1)-(j-1)*6\n endif\n kaj=kc+(j-1)*6\n call loc_sad(kaj,klj)\n klj%rbody(1)=dble(a(j,i))\n klj%rbody(2)=imag_sign*imag(a(j,i))\n klxi%dbody(j)%k=ktflist+kaj\n c=.true.\n endif\n enddo\n klxi%attr=merge(lconstlist+lnonreallist,lconstlist,c)\n klx%dbody(i)%k=ktflist+kaxi\n enddo\n klxi%attr=ior(klxi%attr,lconstlist)\n else\n kax=ktadaloc(-1,n,klx)\n do i=1,n\n kaxi=ktaaloc(0,m,klxi)\n kc=0\n c=.false.\n do j=1,m\n if(imag(a(i,j)) .eq. 0.d0)then\n klxi%rbody(j)=dble(a(i,j))\n if(kc .ne. 0)then\n kaj=kc+(j-1)*6\n call tflocal1(kaj)\n endif\n else\n if(kc .eq. 0)then\n kc=ktcalocm(m-j+1)-(j-1)*6\n endif\n kaj=kc+(j-1)*6\n call loc_sad(kaj,klj)\n klj%rbody(1)=dble(a(i,j))\n klj%rbody(2)=imag_sign*imag(a(i,j))\n klxi%dbody(j)%k=ktflist+kaj\n c=.true.\n endif\n enddo\n klxi%attr=merge(lconstlist+lnonreallist,lconstlist,c)\n klx%dbody(i)%k=ktflist+kaxi\n enddo\n klxi%attr=ior(klxi%attr,lconstlist)\n endif\n endif\n ktfcm2l=kax\n return\n end\n","avg_line_length":27.1203883495,"max_line_length":72,"alphanum_fraction":0.4683181786} {"size":10176,"ext":"f","lang":"FORTRAN","max_stars_count":42.0,"content":"\tPROGRAM SFGRAM\nC************************************************************************\nC* PROGRAM SFGRAM\t\t\t\t\t\t\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* This program draws a meteorogram using reports in a surface file.\t*\nC**\t\t\t\t\t\t\t\t\t*\nC* Log:\t\t\t\t\t\t\t\t\t*\nC* G. Huffman\/USRA\t 6\/89\t\t\t\t\t\t*\nC* M. desJardins\/GSFC\t 5\/90\tGEMPAK 5 version\t\t\t*\nC* S. Schotz\/GSC\t 7\/90\tChange for call to IN_TAXS\t\t*\nC* S. Schotz\/GSC\t10\/90\tCall IN_LINE for border\t\t\t*\nC* J. Whistler\/SSAI\t 4\/91\tChanged taxis to *48 from *24\t\t*\nC* J. Whistler\/SSAI\t 5\/91\tChanged call to SFXGRF\t\t\t*\nC* J. Whistler\/SSAI\t 7\/91\tAdded PANEL and call to SFXPNL\t\t*\nC* K. Brill\/NMC\t\t10\/91\tPANEL*24 --> *48\t\t\t*\nC* K. Brill\/NMC\t\t 2\/92\tPass label & tic frequencies to SFXGRF\t*\nC* S. Jacobs\/EAI\t11\/92\tAdded call to GMESG and 'shrttl'\t*\nC* S. Jacobs\/EAI\t 6\/93\tAdded call to GSVIEW to reset view area\t*\nC* L. Williams\/EAI 3\/94\tClean up declarations of user input\t*\nC*\t\t\t\tvariables\t\t\t\t*\nC* S. Jacobs\/NMC\t 6\/94\tDEVICE*24 --> *72\t\t\t*\nC* S. Jacobs\/NMC\t 6\/94\tChanged the panel sizes for 2 plots\t*\nC* L. Williams\/EAI\t 7\/94\tRemoved call to SFXUPD\t\t\t*\nC* S. Jacobs\/NMC\t 9\/94\tMoved the title plotting to the end\t*\nC* D. Keiser\/GSC\t 8\/96\tAdded FL_MFIL to search for file type \t*\nC* K. Tyle\/GSC\t\t 8\/96\tAdded ER_WMSG call after FL_MFIL call,\t*\nC*\t\t\t\tuse filnam in call to SFXDSP\t\t*\nC* S. Maxwell\/GSC 7\/97 Increased input character length *\nC* S. Jacobs\/NCEP\t 9\/97\tChanged call to GQTEXT\t\t\t*\nC* S. Jacobs\/NCEP\t 1\/99\tChanged call to IN_LINE\t\t\t*\nC* S. Jacobs\/NCEP\t 5\/99\tChanged call to IN_LINE\t\t\t*\nC* S. Jacobs\/NCEP\t 9\/99\tAdded calls to GSTANM and GENANM\t*\nC* T. Lee\/GSC\t\t 5\/01\tRetrieved data from multiple files\t*\nC* T. Piper\/SAIC\t 4\/02\tFixed UMR; initialized icolor\t\t*\nC* A. Hardy\/NCEP\t12\/04 Increased 'witnes' 20 -> 100\t\t*\nC* C. Bailey\/HPC\t10\/06\tChanged call to IN_LINE\t\t\t*\nC* T. Piper\/SAIC 01\/08 Added GD_INIT; removed from IN_BDTA *\nC************************************************************************\n\tINCLUDE\t\t'GEMPRM.PRM'\nC*\n\tCHARACTER\tsffile*(LLMXLN), border*(LLMXLN),\n +\t\t\ttrace (5)*(LLMXLN), dattim*(LLMXLN),\n +\t\t\ttitle*(LLMXLN), taxis*(LLMXLN), statn*(LLMXLN),\n +\t\t\tdevice*(LLMXLN), marker*(LLMXLN), text*(LLMXLN),\n +\t\t\tntrace*(LLMXLN), panel*(LLMXLN), shrttl*(LLMXLN)\nC*\n\tCHARACTER\tparms (4,2,5)*12, prmtyp (4,2,5)*1,\n +\t\t\trange (2,5)*20, witnes (2,5)*100\n\tINTEGER\t\tntparm (2,5), icolor (4,2,5), iptprm (4,2,5)\nC*\n\tCHARACTER\tctlbl (50)*20, ctime*48, stns (10)*8,\n +\t\t\tstnold*8, sffcur*72, trcur (5)*48, datcur*40,\n +\t\t\tsss*48, ttlstr*72\n\tREAL\t\txtlbl (50), x (LLMXTM), view (4)\n\tLOGICAL\t\tnewfil, done, proces, plot, axflg, tmflg,\n +\t\t\trespnd, clear, contin, exit, scflag\n\tREAL\t\tdata (LLMXTM*MMPARM)\n\tCHARACTER\tcdata (LLMXTM*MMPARM)*8\n\tCHARACTER\ttimlst (LLMXTM)*20\n\tCHARACTER\ttimes (LLMXTM)*20\nC*\n\tCHARACTER\ttpanl (5,5)*24\n\tDATA\t\ttpanl \/ '0.;.25;1.;.75', 4 * ' ',\n +\t\t\t\t '0.;.525;1.;.95', '0.;.05;1.;.475', \n +\t\t\t\t 3 * ' ',\n +\t\t\t\t '0.;.70;1.;1.00', '0.;.35;1.;.65',\n +\t\t\t\t '0.;0.00;1.;.30', 2 * ' ',\n +\t\t\t\t '0.;.75;1.;1.', '0.;.50;1.;.75', \n +\t\t\t\t '0.;.25;1.;.50', '0.;0.;1.;.25',\n +\t\t\t\t ' ',\n +\t\t\t\t '0.;.776;1.;1.00', '0.;.582;1.;.806',\n +\t\t\t\t '0.;.388;1.;.612', '0.;.194;1.;.418',\n +\t\t\t\t '0.;0.00;1.;.2244' \/\nC*\n\tDATA\t\tsffcur, datcur, stnold, trcur \/ 8 * ' ' \/\n\tDATA\t\ticolor \/ 40 * 0 \/\nC------------------------------------------------------------------------\nC*\tInitialize TAE and GEMPLT.\nC\n\tkntt = 1\n\tCALL IP_INIT ( respnd, iperr )\n\tIF ( iperr .eq. 0 ) THEN\nC\nC* Initialize grid library common area grdcmn.cmn\nC \n CALL GD_INIT ( ier )\n\t CALL IP_IDNT ( 'SFGRAM', ier )\n\t CALL GG_INIT ( 2, iperr )\n\tEND IF\n\tIF ( iperr .eq. 0 ) THEN\n\t done = .false.\n\t ELSE\n\t done = .true.\n\tEND IF\nC\n\tvalues = 0.\nC\nC*\tMain loop to read in TAE parameters and draw profile.\nC\n\tnewfil = .true.\n\tDO WHILE ( .not. done )\nC\nC*\t Set flag to indicate processing will be done.\nC\n\t proces = .true.\nC\nC*\t Read in the variables from the TAE.\nC\n\t CALL SFXINP ( sffile, dattim, trace, statn, taxis, border, \n +\t\t\t marker, title, text, clear, device, ntrace,\n +\t\t\t panel, iperr )\nC\nC*\t Decode value for trace.\nC\n\t CALL ST_NUMB ( ntrace, mtrace, ier )\n\t IF ( ( mtrace .lt. 1 ) .or. ( mtrace .gt. 5 ) ) mtrace = 5\nC\nC*\t Exit if there is an error.\nC\n\t IF ( iperr .ne. 0 ) THEN\n\t done = .true.\n\t ELSE\nC\nC*\t Set up the graphics device.\nC\n\t CALL GG_SDEV ( device, iret )\n\t IF ( iret .ne. 0 ) proces = .false.\nC\nC*\t Get array of times based on the file name and data time. \nC\n\t IF ( proces ) THEN\n\t\tCALL SF_TLST ( sffile, dattim, sffcur, datcur, newfil,\n +\t\t\t\ttimlst, nts, iret )\n\t\tIF ( iret .ne. 0 ) THEN\n\t\t CALL ER_WMSG ( 'SF', iret, ' ', ier )\n\t\t iret = -17\n\t\t CALL ER_WMSG ( 'SFGRAM', iret, ' ', ier )\n\t\t proces = .false.\n\t\tEND IF\n\t END IF\nC\nC*\t Get input times to plot.\nC\n\t IF ( proces ) THEN\n\t\tCALL SFXDAT ( dattim, timlst, nts, newfil,\n +\t\t\t\tntime, times, ctime, iret )\n\t\tIF ( iret .ne. 0 ) proces = .false.\n\t END IF\nC\nC*\t Set the station list.\nC\n\t IF ( proces ) THEN\n\t\tIF ( statn (1:1) .eq. '@' ) THEN\n\t\t sss = statn (2: )\n\t\t ELSE\n\t\t sss = statn \n\t\tEND IF\n\t\tCALL ST_CLST ( sss, ';', ' ', 10, stns, nstn, ier )\n\t\tknt = 0\n\t\tDO i = 1, nstn\n\t\t CALL ST_LCUC ( stns (i), stns (i), ier )\n\t\t IF ( stns (i) .ne. ' ' ) knt = 1\n\t\tEND DO\n\t\tDO i = nstn + 1, 5\n\t\t IF ( i .gt. 1 ) stns (i) = stns (i-1)\n\t\tEND DO\n\t\tIF ( knt .eq. 0 ) THEN\n\t\t proces = .false.\n\t\t CALL ER_WMSG ( 'SFGRAM', -4, statn, ier )\n\t\tEND IF\n\t END IF\nC\nC*\t Parse the input for TEXT.\nC\n\t IF ( proces ) THEN\n\t\tCALL IN_TEXT ( text, ier )\n\t\tCALL GQTEXT ( itxfnt, itxhw, sztext, itxwid,\n +\t\t\t\tibrdr, irrotn, ijust, ier )\n\t\tIF ( itxhw .eq. 2 ) THEN\n\t\t iret = + 3\n\t\t CALL ER_WMSG ( 'SFGRAM', iret, ' ', ier )\n\t\tEND IF\n\t END IF\nC\nC*\t Set the current pixmap.\nC\n\t CALL GSTANM ( iret )\nC\nC*\t Set margin.\nC\n\t IF ( proces ) THEN\n\t\tCALL GSGMGN ( 7., 3., 7., 1., ier )\n\t END IF\nC\nC*\t Get the border and marker information.\nC\n\t IF ( proces ) THEN\n\t\tCALL IN_LINE ( border, values, 1, ibcolr, ibtyp, \n + ibwidt, iblab, smth, fltr, scflag, ier )\n\t\tCALL IN_MARK ( marker, mkcolr, ier )\n\t END IF\nC\nC*\t Set the panel information and store view coordinates.\nC\n\t IF ( proces ) THEN\n\t\tCALL GG_PANL ( panel, ier )\n\t\tCALL GQVIEW ( view (1), view (2), view (3), view (4),\n +\t\t\t ier ) \n\t END IF\nC\nC*\t Loop through the different traces.\nC\n\t sztmp = sztext\n\t IF ( proces ) THEN\nC\n\t stnold = ' '\n\t exit = .false.\n\t itrace = 1\n\t contin = .true.\n\t DO WHILE ( ( itrace .le. mtrace ) .and. contin )\nC\nC*\t\tSet variable showing there is something to plot.\nC\n\t\tIF ( stns (itrace) .eq. ' ' .or. exit ) THEN\n\t\t plot = .false.\n\t\t ELSE\n\t\t plot = .true.\nC\nC*\t\t Read the data if this is a new station.\nC\n\t\t IF ( stns (itrace) .ne. stnold ) THEN\n\t\t\tstnold = stns (itrace)\n\t\t\tCALL SFXDTA ( sffile, times, ntime, stnold, \n +\t\t\t\t\tstns, clear, ctime, itrace, \n +\t\t\t\t\tmtrace, trace, trcur, exit,\n +\t\t\t\t\tparms, ntparm, icolor, iptprm, \n +\t\t\t\t\tprmtyp, range, witnes, nparms,\n +\t\t\t\t\tdata, cdata, iret )\n\t\t\tIF ( iret .ne. 0 ) THEN\n\t\t\t plot = .false.\n\t\t\t stnold = ' '\n\t\t\tEND IF\n\t\t END IF\nC\nC*\t\t Continue when users opt to.\nC\n\t\t IF ( .not. exit ) THEN\nC\n\t\t\tIF ( plot .and. ( itrace .eq. 1 ) ) THEN\nC\nC*\t\t\t Get information about x axis.\nC\n\t\t\t CALL IN_TAXS ( taxis, 50, ntime, times, x, \n +\t\t\t\t\t xstrt, xstop, xtlbl, ctlbl, \n +\t\t\t\t\t nxlbl, xmndst, ilbfrq,\n +\t\t\t\t\t iglfrq, itmfrq, iret)\n\t\t\t xmndst = xmndst * 3.\n\t\t\t IF ( iret .ne. 0 ) THEN\n\t\t\t\tcontin = .false.\n\t\t\t\tplot = .false.\n\t\t\t END IF\n\t\t\tEND IF\nC\nC*\t\t\tSet the panel for plotting of traces.\nC\n\t\t\tIF ( plot ) THEN\n\t\t\t CALL SFXPNL ( view, tpanl (itrace, mtrace),\n +\t\t\t\t\t ier )\n\t\t\tEND IF\nC\nC*\t\t\tPlot on the left and then the right.\nC\n\t\t\tIF ( plot ) THEN\n\t\t\t axflg = .true.\n\t\t\t IF ( itrace .eq. mtrace ) THEN\n\t\t\t\ttmflg = .true.\n\t\t\t ELSE\n\t\t\t\ttmflg = .false.\n\t\t\t END IF\n\t\t\t DO j = 1, 2\nC\nC*\t\t\t Set up the graph coordinates.\nC\n\t\t\t IF ( ntparm ( j, itrace ) .gt. 0 ) THEN\n\t\t\t\tCALL GSCOLR ( ibcolr, ier )\n\t\t\t\tCALL GSLINE ( 0, 0, ibwidt, 0, ier )\n\t\t\t\tCALL SFXGRF ( j, itrace, ntime, data, \n +\t\t\t\t\t\tprmtyp (1,j,itrace),\n +\t\t\t\t\t \tiptprm (1,j,itrace),\n +\t\t\t\t\t\trange (j,itrace),\n +\t\t\t\t\t\taxflg, xstrt, xstop,\n +\t\t\t\t\t\txtlbl, ctlbl, nxlbl, \n +\t\t\t\t\t\ttmflg, ilbfrq,\n +\t\t\t\t\t\tiglfrq, itmfrq,\n +\t\t\t\t\t\twitnes (j,itrace),\n +\t\t\t\t\t\tparms (1,j,itrace),\n +\t\t\t\t\t\ticolor (1,j,itrace),\n +\t\t\t\t\t\tntparm, iret )\n\t\t\t\tIF ( iret .eq. 0 ) axflg = .false.\n\t\t\t ELSE\n\t\t\t\tiret = -1\n\t\t\t END IF\nC\nC*\t\t\t Plot the parameters on this side.\nC\n\t\t\t IF ( iret .eq. 0 ) THEN\n\t\t\t CALL SFXPLT ( j, parms (1,j,itrace),\n +\t\t\t\t\t\tprmtyp (1,j,itrace),\n +\t\t\t\t\t\ticolor (1,j,itrace),\n +\t\t\t\t\t\tdata, cdata, ntime,\n +\t\t\t\t\t\tiptprm (1,j,itrace), \n +\t\t\t\t\t\tmkcolr, xmndst, x, ier )\n\t\t\t END IF\n\t\t\t END DO\n\t\t END IF\n\t\t END IF\n\t\tEND IF\nC\n\t\titrace = itrace + 1\nC\n\t END DO\nC\nC*\t Reset view to initial settings.\nC\n\t IF ( plot .and. ( .not. exit ) ) THEN\n\t CALL GSVIEW ( view (1), view (2), view (3), view (4),\n +\t\t\t ier ) \nC\nC*\t Add title at bottom.\nC\n\t CALL SFXTTL ( title, stns, mtrace, ctime, icttl,\n +\t\t\t linttl, ttlstr, shrttl, ier )\n\t IF ( clear ) CALL GMESG ( shrttl, ier )\n\t IF ( icttl .gt. 0 ) THEN\n\t\t CALL GSCOLR ( icttl, ier )\n\t\t CALL GG_WSTR ( ttlstr, linttl, ier )\n\t END IF\n\t END IF\n\t END IF\nC\nC*\t End graphics mode.\nC\n\t IF ( proces .and. .not. exit ) CALL GEPLOT ( ier )\nC\nC*\t Prompt for next profile to be done.\nC\n\t CALL GENANM ( iret )\n\t CALL IP_DYNM ( done, ier )\n\t END IF\n\tEND DO\nC\nC*\tPrint general error messages if necessary.\nC\n\tIF (iperr .ne. 0) CALL ER_WMSG ( 'SFGRAM', iperr, ' ', ier )\nC\nC*\tExit from GEMPLT and the TAE.\nC\n\tCALL GENDP ( 0, iret )\n\tCALL IP_EXIT ( iret )\n\tEND\n","avg_line_length":28.188365651,"max_line_length":73,"alphanum_fraction":0.5309551887} {"size":2356,"ext":"for","lang":"FORTRAN","max_stars_count":1.0,"content":" subroutine strip(oldnam,newnam)\r\nc\r\nc + + + PURPOSE + + +\r\nc\r\nc SR STRIP strips all characters except the 8 character prefix to a\r\nc file name. Used for the creation of the initial condition name in\r\nc the initial condition file.\r\nc\r\nc Called from CONTIN.\r\nc Author(s): Whittemore\r\nc Reference in User Guide:\r\nc\r\nc Version: This module not yet recoded.\r\nc Date recoded:\r\nc Recoded by:\r\nc\r\nc + + + KEYWORDS + + +\r\nc\r\nc + + + PARAMETERS + + +\r\nc\r\nc + + + ARGUMENT DECLARATIONS + + +\r\nc\r\n character*51 oldnam\r\n character*8 newnam\r\nc\r\nc + + + ARGUMENT DEFINITIONS + + +\r\nc\r\nc newnam - name to be passed back to contin to be used as scenario\r\nc name in initial condition file.\r\nc oldnam - name read in from screen or shell file\r\nc\r\nc + + + COMMON BLOCKS + + +\r\nc\r\nc + + + LOCAL VARIABLES + + +\r\nc\r\n integer spos, filpos, tpos\r\nc\r\nc + + + LOCAL DEFINITIONS + + +\r\nc\r\nc spos - position counter\r\nc filpos - position in newnam for character from oldnam\r\nc tpos - position counter\r\nc\r\nc + + + SUBROUTINES CALLED + + +\r\nc\r\nc + + + DATA INITIALIZATIONS + + +\r\nc\r\nc\r\n newnam = ' '\r\nc\r\n if (len(oldnam).le.8) then\r\n newnam = oldnam(1:8)\r\n return\r\n end if\r\nc\r\n filpos = 8\r\nc\r\n do 10 spos = len(oldnam), 1, -1\r\nc\r\n if (oldnam(spos:spos).eq.'.') then\r\n tpos = spos - 1\r\nc\r\n do while (oldnam(tpos:tpos).ne.'\/'.and.oldnam(tpos:tpos).ne.\r\n 1 '\\\\')\r\n newnam(filpos:filpos) = oldnam(tpos:tpos)\r\n filpos = filpos - 1\r\n tpos = tpos - 1\r\n if (tpos.lt.1.or.filpos.lt.1) return\r\n end do\r\nc\r\n return\r\nc\r\n else if (oldnam(spos:spos).eq.'\/'.or.oldnam(spos:spos).eq.'\\\\')\r\n 1 then\r\n tpos = spos + 1\r\nc\r\n do while (oldnam(tpos:tpos).ne.'\/'.and.oldnam(tpos:tpos).ne.\r\n 1 '\\\\')\r\n newnam(filpos:filpos) = oldnam(tpos:tpos)\r\n filpos = filpos - 1\r\n tpos = tpos - 1\r\n if (tpos.lt.1.or.filpos.lt.1) return\r\n end do\r\nc\r\n return\r\nc\r\n end if\r\n 10 continue\r\nc\r\n newnam = oldnam(len(oldnam)-8:len(oldnam))\r\n if (newnam.eq.' ') newnam = oldnam(1:(len(oldnam)))\r\nc\r\n return\r\n end\r\n","avg_line_length":24.8,"max_line_length":72,"alphanum_fraction":0.5186757216}