repo_name
stringlengths
7
81
path
stringlengths
4
224
copies
stringclasses
221 values
size
stringlengths
4
7
content
stringlengths
975
1.04M
license
stringclasses
15 values
prool/ccx_prool
CalculiX/ccx_2.17/src/fcrit.f
1
1157
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine fcrit(time,t,a,b,ze,d,dd,h1,h2,h3,h4,func,funcp) ! implicit none ! real*8 time,t,a,b,ze,d,dd,h1,h2,h3,h4,fexp,func,funcp ! fexp=dexp(-h1*t) ! ! function ! func=((a+b*time)*(-t*h2-h3)-b*(-t*t*h2-2.d0*t*h3-2.d0*h4))*fexp ! ! derivative of the function ! funcp=((a+b*time)*t-b*(h3+t*h2+t*t))*fexp ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.8p2/src/plinterpol.f
2
2234
! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine plinterpol(plcon,nplcon,itemp,f,df,npmat_,ntmat_, & imat,nelem,epl) ! implicit none ! ! interpolation of isotropic or kinematic hardening data ! input: hardening data plcon and nplcon, temperature itemp, ! size parameters npmat_ and ntmat_, material number imat ! and equivalent plastic strain at which the coefficients ! are to be determined ! output: hardening coefficient and its local derivative f and df ! integer npmat_,ntmat_,nplcon(0:ntmat_,*),itemp,ndata,imat,j, & nelem ! real*8 plcon(0:2*npmat_,ntmat_,*),f,df,epl ! ndata=nplcon(itemp,imat) ! do j=1,ndata if(epl.lt.plcon(2*j,itemp,imat)) exit enddo ! if((j.eq.1).or.(j.gt.ndata)) then if(j.eq.1) then f=plcon(1,itemp,imat) df=0.d0 else f=plcon(2*ndata-1,itemp,imat) df=0.d0 endif write(*,*) '*WARNING in plinterpol: plastic strain ',epl write(*,*) ' outside material plastic strain range' write(*,*) ' in element ',nelem,' and material ',imat write(*,*) ' for temperature ',plcon(0,itemp,imat) else df=(plcon(2*j-1,itemp,imat)-plcon(2*j-3,itemp,imat))/ & (plcon(2*j,itemp,imat)-plcon(2*j-2,itemp,imat)) f=plcon(2*j-3,itemp,imat)+ & df*(epl-plcon(2*j-2,itemp,imat)) endif ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.9/src/ts_calc.f
4
2775
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine ts_calc(xflow,Tt,Pt,kappa,r,a,Ts,icase) ! ! this subroutine solves the implicit equation ! f=xflow*dsqrt(Tt)/(a*Pt)-C*(TtdT)**expon*(Ttdt-1)**0.5d0 ! ! author: Yannick Muller ! implicit none ! integer inv,icase,i ! real*8 xflow,Tt,Pt,Ts,kappa,r,f,df,a,expon,Ts_old,C,TtzTs, & deltaTs,TtzTs_crit, Qred_crit,Qred,h1,h2,h3 expon=-0.5d0*(kappa+1.d0)/(kappa-1.d0) ! C=dsqrt(2.d0/r*kappa/(kappa-1.d0)) ! ! f=xflow*dsqrt(Tt)/(a*Pt)-C*(TtdT)**expon*(Ttdt-1)**0.5d0 ! ! df=-C*Ttdt**expon*(expon/Ts*(TtdT-1)**0.5d0 ! & -0.5d0*TtdT/Ts*(TtdT-1.d0)**(-0.5d0)) ! Ts_old=Tt ! ! if(xflow.lt.0d0) then inv=-1 else inv=1 endif ! if(dabs(xflow).le.1e-9) then Ts=Tt return endif ! Qred=abs(xflow)*dsqrt(Tt)/(a*Pt) ! ! optimised estimate of T static ! Ts=Tt/(1+(Qred**2/C**2)) ! ! adiabatic ! if(icase.eq.0) then ! TtzTs_crit=(kappa+1.d0)/2.d0 ! ! isothermal ! else ! TtzTs_crit=(1d0+(kappa-1.d0)/(2.d0*kappa)) ! endif ! Qred_crit=C*(TtzTs_crit)**expon*(Ttzts_crit-1.d0)**0.5d0 ! ! xflow_crit=inv*Qred_crit/dsqrt(Tt)*A*Pt ! if(Qred.ge.Qred_crit) then ! Ts=Tt/TtzTs_crit ! return ! endif i=0 ! do i=i+1 Ttzts=Tt/Ts h1=Ttzts-1.d0 h2=dsqrt(h1) h3=Ttzts**expon ! f=C*h2*h3 ! df=f*(expon+0.5d0*Ttzts/h1)/Ts ! f=Qred-f deltaTs=-f/df ! Ts=Ts+deltaTs ! if( (((dabs(Ts-Ts_old)/ts_old).le.1.E-8)) & .or.((dabs(Ts-Ts_old)).le.1.E-10)) then exit else if(i.gt.20) then Ts=0.9*Tt exit endif Ts_old=Ts enddo ! return end
gpl-2.0
spthm/sphray
src/particle_system.F90
1
24884
!> \file particle_system.F90 !> \brief Particles, sources, and box, types and subroutines. !! !< module particle_system_mod use myf03_mod use atomic_rates_mod, only: calc_colion_eq_fits use mt19937_mod, only: genrand_real1 use m_mrgrnk, only: mrgrnk implicit none private public :: particle_type public :: particle_copy public :: particle_transform public :: particle_set_ye public :: particle_set_ci_eq public :: box_type public :: box_adjust public :: source_type public :: particle_system_type public :: particle_system_scale_comoving_to_physical public :: particle_system_scale_physical_to_comoving public :: particle_system_create_particle_random_access_list public :: particle_system_create_particle_density_access_list public :: particle_system_order_particles public :: particle_system_mean_xHII_number_weight public :: particle_system_mean_xHII_mass_weight public :: particle_system_mean_xHII_volume_weight public :: particle_system_set_ye public :: particle_system_set_ci_eq public :: particle_system_enforce_x_and_T_minmax public :: particle_system_print_lun public :: transformation_type public :: return_bytes_per_particle public :: return_bytes_per_source !> Particle type. !========================= type particle_type real(r4b) :: pos(3) !< x,y,z coordinates integer(i4b) :: id !< particle id real(r4b) :: mass !< particle mass real(r4b) :: T !< temperature in K real(r4b) :: rho !< density real(r4b) :: ye !< electron fraction real(r4b) :: xHI !< nHI/nH real(r4b) :: xHII !< nHII/nH real(r4b) :: hsml !< smoothing length integer(i8b) :: lasthit !< indx of last ray to cross this particle #ifdef incVel real(r4b) :: vel(3) !< x,y,z velocities #endif #ifdef incCloudy real(r4b) :: xHI_cloudy !< cloudy eq solutions #endif #ifdef incHmf real(r4b) :: Hmf !< Hydrogen mass fraction #endif #ifdef incHe real(r4b) :: xHeI !< nHeI/nHe real(r4b) :: xHeII !< nHeII/nHe real(r4b) :: xHeIII !< nHeIII/nHe #endif #ifdef incHemf real(r4b) :: Hemf !< Helium mass fraction #endif #ifdef outGammaHI real(r4b) :: gammaHI !< time averaged HI photoionization rate real(r4b) :: time !< elapsed time in seconds - reset at outputs #endif #ifdef incEOS real(r4b) :: eos !< equation of state variable #endif #ifdef incSFR real(r4b) :: sfr !< star formation rate #endif end type particle_type !> source type !================ type source_type real(r4b) :: pos(3) !< x,y,z coordinates #ifdef incVel real(r4b) :: vel(3) !< x,y,z velocities #endif real(r4b) :: L !< luminosity real(r4b) :: SpcType !< spectral type integer(i4b) :: EmisPrf !< emission profile real(r4b) :: Lcdf !< relates this luminosity to the other sources integer(i8b) :: lastemit !< last ray emitted from this source end type source_type !> simulation box and boundary conditions !========================================== type box_type real(r8b) :: tops(1:3) !< upper x,y,z coordinates [code] real(r8b) :: bots(1:3) !< lower x,y,z coordinates [code] real(r8b) :: lens(1:3) !< side lengths [code] (xf-xi,yf-yi,zf-zi) real(r8b) :: lens_cm(1:3) !< side lengths [cm] (xf-xi,yf-yi,zf-zi) real(r8b) :: vol !< box volume [code] (xlen*ylen*zlen) real(r8b) :: vol_cm !< box volume [cm^3] (xlen*ylen*zlen) integer(i8b) :: bbound(1:3) !< BCs for upper faces (0:vac 1:per -1:ref) integer(i8b) :: tbound(1:3) !< BCs for lower faces (0:vac 1:per -1:ref) end type box_type !> particles, sources, and box !========================================= type particle_system_type type(box_type) :: box !< the simulation box type(particle_type), allocatable :: par(:) !< all particles type(source_type), allocatable :: src(:) !< all sources integer(i4b), allocatable :: acc_list(:) !< access list end type particle_system_type !> transformation type !======================= type transformation_type integer(i8b) :: fac(1:3) !< newpos = fac * (oldpos - shift) real(i8b) :: shift(1:3) !< newpos = fac * (oldpos - shift) end type transformation_type contains !!============================================ !! !! BOX !! !!============================================ !> resets the box limits where the BCs are vacuum !================================================================== subroutine box_adjust(box,bot,top) type(box_type), intent(inout) :: box !< input box real(r4b), intent(in) :: bot(3) !< new bottoms real(r4b), intent(in) :: top(3) !< new tops where (box%bbound==0) box%bots = bot where (box%tbound==0) box%tops = top end subroutine box_adjust !!============================================ !! !! PARTICLE !! !!============================================ !> creates a copy of a particle !============================================================ function particle_copy(this) result(copy) type(particle_type), intent(in) :: this !< input particle type(particle_type) :: copy !< particle copy copy = this end function particle_copy !> transforms a particle !============================================================ subroutine particle_transform(this, transform) type(particle_type), intent(inout) :: this !< input particle type(transformation_type), intent(in) :: transform !< transformation this%pos = transform%fac * (this%pos - transform%shift) end subroutine particle_transform !> set electron fraction, ye=ne/nH from ionization fractions !============================================================== subroutine particle_set_ye(par, dfltH_mf, dfltHe_mf, ne_bckgnd) type(particle_type) :: par real(r8b), intent(in) :: dfltH_mf real(r8b), intent(in) :: dfltHe_mf real(r8b), intent(in) :: ne_bckgnd integer(i8b) :: i real(r8b) :: Hmf real(r8b) :: Hemf real(r8b) :: nHe_over_nH par%ye = par%xHII + ne_bckgnd #ifdef incHe #ifdef incHmf Hmf = par%Hmf #else Hmf = dfltH_mf #endif #ifdef incHemf Hemf = par%Hemf #else Hemf = dfltHe_mf #endif nHe_over_nH = 0.25d0 * Hemf / Hmf par%ye = par%ye + ( par%xHeII + 2.0d0 * par%xHeIII ) * nHe_over_nH #endif end subroutine particle_set_ye !> sets ionization fractions to their collisional equilibrium values !====================================================================== subroutine particle_set_ci_eq(par, caseA, DoH, DoHe, fit) type(particle_type) :: par logical, intent(in) :: caseA(2) !< 1st slot for H, 2nd for He logical, intent(in) :: DoH !< set Hydrogen? logical, intent(in) :: DoHe !< set Helium? character(*), intent(in) :: fit !< one of ['hui','cen'] real(r8b) :: T !< 8 byte temperature real(r8b) :: xvec(5) !< [xHI,xHII,xHeI,xHeII,xHeIII] T = par%T call calc_colion_eq_fits(fit, T, caseA, xvec) if (DoH) then par%xHI = xvec(1) par%xHII = xvec(2) endif if (DoHe) then #ifdef incHe par%xHeI = xvec(3) par%xHeII = xvec(4) par%xHeIII = xvec(5) #else write(*,*) write(*,*) 'In particle_set_ci_eq' write(*,*) 'DoHe = .true. but incHe macro not defined in Makefile' stop #endif endif end subroutine particle_set_ci_eq !> figures out how many bytes of RAM are needed per particle !======================================================================== function return_bytes_per_particle() result(bpp) integer(i4b) :: bpp !< bytes per particle bpp = 12 ! positions bpp = bpp + 4 ! ID bpp = bpp + 4 ! mass bpp = bpp + 4 ! temperature bpp = bpp + 4 ! rho bpp = bpp + 4 ! ye bpp = bpp + 8 ! H ionization fractions bpp = bpp + 4 ! hsml bpp = bpp + 8 ! last hit index #ifdef incVel bpp = bpp + 12 ! velocities #endif #ifdef incCloudy bpp = bpp + 4 ! cloudy table xHI #endif #ifdef incHmf bpp = bpp + 4 ! H mass fraction #endif #ifdef incHe bpp = bpp + 12 ! He ionization fractions #endif #ifdef incHemf bpp = bpp + 4 ! He mass fraction #endif #ifdef outGammaHI bpp = bpp + 4 ! GammaHI tracking bpp = bpp + 4 ! time var #endif #ifdef incEOS bpp = bpp + 4 ! Equation of State variable #endif #ifdef incSFR bpp = bpp + 4 ! Star formation rate #endif end function return_bytes_per_particle !> figures out how many bytes of RAM are needed per source !======================================================================== function return_bytes_per_source() result(bps) integer(i4b) :: bps !< bytes per source bps = 12 ! positions bps = bps + 4 ! luminosity bps = bps + 4 ! spectral type bps = bps + 4 ! emission profile bps = bps + 4 ! luminosity cumulative distribution function bps = bps + 8 ! last emit index #ifdef incVel bps = bps + 12 ! velocities #endif end function return_bytes_per_source !!============================================ !! !! PARTICLE SYSTEM !! !!============================================ !> scales particles, sources, and the box from comoving to physical values. ! velocity is taken from Gadget code value to peculiar. !========================================================================== subroutine particle_system_scale_comoving_to_physical(this, a, h) character(clen), parameter :: myname="scale_comoving_to_physical" integer, parameter :: verb=2 character(clen) :: str,fmt type(particle_system_type) :: this real(r8b), intent(in) :: a !< scale factor real(r8b), intent(in) :: h !< hubble parameter (little h) call mywrite(" scaling comoving to physical coordinates", verb) fmt = "(A,F12.5,T22,A,T25,F12.5)" write(str,fmt) " a = ", a, "h = ", h call mywrite(str,verb) ! particles !------------------------------------------------ this%par%pos(1) = this%par%pos(1) * a / h this%par%pos(2) = this%par%pos(2) * a / h this%par%pos(3) = this%par%pos(3) * a / h #ifdef incVel this%par%vel(1) = this%par%vel(1) * sqrt(a) this%par%vel(2) = this%par%vel(2) * sqrt(a) this%par%vel(3) = this%par%vel(3) * sqrt(a) #endif this%par%mass = this%par%mass / h this%par%hsml = this%par%hsml * a / h this%par%rho = ( this%par%rho / (a*a*a) ) * (h*h) ! sources !------------------------------------------------ this%src%pos(1) = this%src%pos(1) * a / h this%src%pos(2) = this%src%pos(2) * a / h this%src%pos(3) = this%src%pos(3) * a / h #ifdef incVel this%src%vel(1) = this%src%vel(1) * sqrt(a) this%src%vel(2) = this%src%vel(2) * sqrt(a) this%src%vel(3) = this%src%vel(3) * sqrt(a) #endif ! box !------------------------------------------------ this%box%tops = this%box%tops * a / h this%box%bots = this%box%bots * a / h this%box%lens = this%box%lens * a / h this%box%lens_cm = this%box%lens_cm * a / h this%box%vol = product( this%box%lens ) this%box%vol_cm = product( this%box%lens_cm ) end subroutine particle_system_scale_comoving_to_physical !> scales particles, sources, and the box from physical to comoving values. ! velocity is taken from peculiar to Gadget code value. !========================================================================== subroutine particle_system_scale_physical_to_comoving(this, a, h) character(clen), parameter :: myname="scale_physical_to_comoving" integer, parameter :: verb=2 character(clen) :: str,fmt type(particle_system_type) :: this real(r8b), intent(in) :: a !< scale factor real(r8b), intent(in) :: h !< hubble parameter (little h) call mywrite(" scaling physical to comoving coordinates", verb) fmt = "(A,F12.5,T22,A,T25,F12.5)" write(str,fmt) " a = ", a, "h = ", h call mywrite(str,verb) ! particles !------------------------------------------------ this%par%pos(1) = this%par%pos(1) / a * h this%par%pos(2) = this%par%pos(2) / a * h this%par%pos(3) = this%par%pos(3) / a * h #ifdef incVel this%par%vel(1) = this%par%vel(1) / sqrt(a) this%par%vel(2) = this%par%vel(2) / sqrt(a) this%par%vel(3) = this%par%vel(3) / sqrt(a) #endif this%par%mass = this%par%mass * h this%par%hsml = this%par%hsml / a * h this%par%rho = this%par%rho * (a*a*a) / (h*h) ! sources !------------------------------------------------ this%src%pos(1) = this%src%pos(1) / a * h this%src%pos(2) = this%src%pos(2) / a * h this%src%pos(3) = this%src%pos(3) / a * h #ifdef incVel this%src%vel(1) = this%src%vel(1) / sqrt(a) this%src%vel(2) = this%src%vel(2) / sqrt(a) this%src%vel(3) = this%src%vel(3) / sqrt(a) #endif ! box !------------------------------------------------ this%box%tops = this%box%tops / a * h this%box%bots = this%box%bots / a * h this%box%lens = this%box%lens / a * h this%box%lens_cm = this%box%lens_cm / a * h this%box%vol = product( this%box%lens ) this%box%vol_cm = product( this%box%lens_cm ) end subroutine particle_system_scale_physical_to_comoving !> allows for accessing the particles in a random order !------------------------------------------------------ subroutine particle_system_create_particle_random_access_list( psys ) type(particle_system_type) :: psys integer(i4b) :: i integer(i4b) :: n real(r4b), allocatable :: randoms(:) n = size( psys%par ) if (.not. allocated(psys%acc_list) ) allocate( psys%acc_list(n) ) allocate( randoms(n) ) do i = 1, size(randoms) randoms(i) = genrand_real1() end do call mrgrnk( randoms, psys%acc_list ) deallocate( randoms ) end subroutine particle_system_create_particle_random_access_list !> allows for accessing the particles from least to most dense !-------------------------------------------------------------- subroutine particle_system_create_particle_density_access_list( psys ) type(particle_system_type) :: psys integer(i4b) :: i integer(i4b) :: n real(r4b), allocatable :: rhos(:) n = size( psys%par ) if (.not. allocated(psys%acc_list) ) allocate( psys%acc_list(n) ) allocate( rhos(n) ) do i = 1,n rhos(i) = psys%par(i)%rho end do call mrgrnk( rhos, psys%acc_list ) deallocate( rhos ) end subroutine particle_system_create_particle_density_access_list ! this routine rearranges the particles in the particle system so that ! they are stored in the sequence given by the array order. For example ! order = [3,1,2] takes the third particle to the first position, the first ! particle to the second position, and the second particle to the third ! position. the array order is not preserved during the routine !> reorders the particles according to the array order !=========================================================================== subroutine particle_system_order_particles(this, order) type(particle_system_type), intent(inout) :: this !< input particle system integer(i4b), intent(inout) :: order(:) !< desired order type(particle_type) :: par integer(i8b) :: i integer(i8b) :: goal integer(i8b) :: npar if (size(this%par) /= size(order)) stop "size(this%par) /= size(order)" npar = size(this%par) do i=1,npar par=this%par(i) goal=order(i) do while(goal < i) goal=order(goal) order(i)=goal enddo this%par(i)=this%par(goal) this%par(goal)=par enddo do i=1,npar order(i)=i enddo end subroutine particle_system_order_particles !> calculates the number weighted mean value of xHII !======================================================================== function particle_system_mean_xHII_number_weight(this) result(numionfrac) type(particle_system_type), intent(in) :: this !< input particle system real(r8b) :: numionfrac !< number weighted global ionization fraction integer :: i numionfrac = 0.0d0 do i = 1,size(this%par) numionfrac = numionfrac + this%par(i)%xHII end do numionfrac = numionfrac / size(this%par) end function particle_system_mean_xHII_number_weight !> calculates the mass weighted mean value of xHII !======================================================== function particle_system_mean_xHII_mass_weight(this, DfltH_mf) result(massionfrac) type(particle_system_type), intent(in) :: this !< input particle system real(r8b) :: DfltH_mf !< H_mf if we dont have a value for each par real(r8b) :: massionfrac !< ion fraction m weighted real(r8b) :: masstot !< total volume real(r8b) :: Hmf !< Hydrogen mass fraction integer :: i massionfrac = 0.0d0 masstot = 0.0d0 do i = 1,size(this%par) #ifdef incHmf Hmf = this%par(i)%Hmf #else Hmf = dfltH_mf #endif massionfrac = massionfrac + this%par(i)%mass * Hmf * this%par(i)%xHII masstot = masstot + this%par(i)%mass * Hmf end do massionfrac = massionfrac / masstot end function particle_system_mean_xHII_mass_weight !> calculates the volume weighted mean of xHII !======================================================== function particle_system_mean_xHII_volume_weight(this) result(volionfrac) type(particle_system_type), intent(in) :: this !< input particle system real(r8b) :: volionfrac !< ion fraction v weighted real(r8b) :: voltot !< total volume real(r8b) :: h3 !< hsml^3 integer :: i volionfrac = 0.0d0 voltot = 0.0d0 do i = 1,size(this%par) h3 = this%par(i)%hsml * this%par(i)%hsml * this%par(i)%hsml volionfrac = volionfrac + h3 * this%par(i)%xHII voltot = voltot + h3 end do volionfrac = volionfrac / voltot end function particle_system_mean_xHII_volume_weight !> set electron fraction, ye=ne/nH from ionization fractions !============================================================== subroutine particle_system_set_ye(psys, dfltH_mf, dfltHe_mf, ne_bckgnd) type(particle_system_type) :: psys real(r8b), intent(in) :: dfltH_mf real(r8b), intent(in) :: dfltHe_mf real(r8b), intent(in) :: ne_bckgnd integer(i8b) :: i do i = 1,size(psys%par) call particle_set_ye( psys%par(i), dfltH_mf, dfltHe_mf, ne_bckgnd) end do end subroutine particle_system_set_ye !> sets ionization fractions to their collisional equilibrium values !====================================================================== subroutine particle_system_set_ci_eq(psys, caseA, DoH, DoHe, fit) type(particle_system_type) :: psys logical, intent(in) :: caseA(2) !< 1st slot for H, 2nd for He logical, intent(in) :: DoH !< set Hydrogen? logical, intent(in) :: DoHe !< set Helium? character(*), intent(in) :: fit !< one of ['hui','cen'] real(r8b) :: T !< 8 byte temperature real(r8b) :: xvec(5) !< [xHI,xHII,xHeI,xHeII,xHeIII] integer(i8b) :: i do i = 1, size(psys%par) call particle_set_ci_eq( psys%par(i), caseA, DoH, DoHe, fit ) end do end subroutine particle_system_set_ci_eq !> enforces a minimum and maximum value on the ionization fractions !! and temperatures !============================================================================= subroutine particle_system_enforce_x_and_T_minmax(psys,xmin,xmax,tmin,tmax) type(particle_system_type), intent(inout) :: psys !< inout particle system real(r8b), intent(in) :: xmin, xmax, tmin, tmax integer(i8b) :: i do i = 1,size(psys%par) if (psys%par(i)%xHI < xmin) psys%par(i)%xHI = xmin if (psys%par(i)%xHI > xmax) psys%par(i)%xHI = xmax if (psys%par(i)%xHII < xmin) psys%par(i)%xHII = xmin if (psys%par(i)%xHII > xmax) psys%par(i)%xHII = xmax #ifdef incHe if (psys%par(i)%xHeI < xmin) psys%par(i)%xHeI = xmin if (psys%par(i)%xHeII < xmin) psys%par(i)%xHeII = xmin if (psys%par(i)%xHeIII < xmin) psys%par(i)%xHeIII = xmin if (psys%par(i)%xHeI > xmax) psys%par(i)%xHeI = xmax if (psys%par(i)%xHeII > xmax) psys%par(i)%xHeII = xmax if (psys%par(i)%xHeIII > xmax) psys%par(i)%xHeIII = xmax #endif if (psys%par(i)%T < tmin) psys%par(i)%T = tmin if (psys%par(i)%T > tmax) psys%par(i)%T = tmax end do end subroutine particle_system_enforce_x_and_T_minmax !> outputs currently loaded particle data to the screen !================================================================= subroutine particle_system_print_lun(psys,str,lun) type(particle_system_type), intent(in) :: psys !< particle system character(*), optional, intent(in) :: str !< arbitrary string integer(i4b), optional, intent(in) :: lun !< if present goes to file integer(i4b) :: outlun outlun=stdout if (present(lun)) outlun=lun 99 format(72("-")) 100 format(A,T10,3ES15.5) 101 format(A,T10,2I15,ES15.5) 102 format(A,T10,2I15) 103 format(A,T10,3I15) write(outlun,99) if (present(str)) write(outlun,"(A)") trim(str) write(outlun,"(A,I15,A)") "particle data for ", size(psys%par), " particles" write(outlun,*) write(outlun,100) "xpos", minval(psys%par%pos(1)), & maxval(psys%par%pos(1)), meanval_real(psys%par%pos(1)) write(outlun,100) "ypos", minval(psys%par%pos(2)), & maxval(psys%par%pos(2)), meanval_real(psys%par%pos(2)) write(outlun,100) "zpos", minval(psys%par%pos(3)), & maxval(psys%par%pos(3)), meanval_real(psys%par%pos(3)) write(outlun,102) "id", minval(psys%par%id), & maxval(psys%par%id) write(outlun,100) "mass", minval(psys%par%mass), & maxval(psys%par%mass), meanval_real(psys%par%mass) write(outlun,100) "T", minval(psys%par(:)%T), & maxval(psys%par(:)%T), meanval_real(psys%par%T) write(outlun,100) "rho", minval(psys%par%rho), & maxval(psys%par%rho), meanval_real(psys%par%rho) write(outlun,100) "ye", minval(psys%par%ye), & maxval(psys%par%ye), meanval_real(psys%par%ye) write(outlun,100) "xHI", minval(psys%par%xHI), & maxval(psys%par%xHI), meanval_real(psys%par%xHI) write(outlun,100) "xHII", minval(psys%par%xHII), & maxval(psys%par%xHII), meanval_real(psys%par%xHII) write(outlun,100) "hsml", minval(psys%par%hsml), & maxval(psys%par%hsml), meanval_real(psys%par%hsml) write(outlun,101) "lasthit", minval(psys%par%lasthit), & maxval(psys%par%lasthit) #ifdef incVel write(outlun,100) "xvel", minval(psys%par%vel(1)), & maxval(psys%par%vel(1)), meanval_real(psys%par%vel(1)) write(outlun,100) "yvel", minval(psys%par%vel(2)), & maxval(psys%par%vel(2)), meanval_real(psys%par%vel(2)) write(outlun,100) "zvel", minval(psys%par%vel(3)), & maxval(psys%par%vel(3)), meanval_real(psys%par%vel(3)) #endif #ifdef incCloudy write(outlun,100) "xHI_cld", minval(psys%par%xHI_cloudy), & maxval(psys%par%xHI_cloudy), meanval_real(psys%par%xHI_cloudy) #endif #ifdef incHmf write(outlun,100) "Hmf", minval(psys%par%Hmf), & maxval(psys%par%Hmf), meanval_real(psys%par%Hmf) #endif #ifdef incHe write(outlun,100) "xHeI", minval(psys%par%xHeI), & maxval(psys%par%xHeI), meanval_real(psys%par%xHeI) write(outlun,100) "xHeII", minval(psys%par%xHeII), & maxval(psys%par%xHeII), meanval_real(psys%par%xHeII) write(outlun,100) "xHeIII", minval(psys%par%xHeIII), & maxval(psys%par%xHeIII), meanval_real(psys%par%xHeIII) #endif #ifdef incHemf write(outlun,100) "Hemf", minval(psys%par%Hemf), & maxval(psys%par%Hemf), meanval_real(psys%par%Hemf) #endif #ifdef outGammaHI write(outlun,100) "gammaHI", minval(psys%par%gammaHI), & maxval(psys%par%gammaHI), meanval_real(psys%par%gammaHI) write(outlun,100) "time(s)", minval(psys%par%time), & maxval(psys%par%time), meanval_real(psys%par%time) #endif #ifdef incEOS write(outlun,100) "eos", minval(psys%par%eos), & maxval(psys%par%eos), meanval_real(psys%par%eos) #endif #ifdef incSFR write(outlun,100) "sfr", minval(psys%par%sfr), & maxval(psys%par%sfr), meanval_real(psys%par%sfr) #endif write(outlun,*) write(outlun,100) "Box Uppers = ", psys%box%tops write(outlun,100) "Box Lowers = ", psys%box%bots write(outlun,103) "Upr BCs = ", psys%box%tbound write(outlun,103) "Lwr BCs = ", psys%box%bbound write(outlun,99) end subroutine particle_system_print_lun !> calculates the mean value w/o using the intrinsics !================================================================= function meanval_real(arr) result (mean) real(r4b), dimension(:), intent(in) :: arr !< array to average real(r8b) :: mean !< mean value to return integer(i8b) :: i mean = 0.0d0 do i = 1,size(arr) mean = mean + arr(i) end do mean = mean / size(arr) end function meanval_real end module particle_system_mod
gpl-3.0
prool/ccx_prool
CalculiX/ccx_2.15/src/calculated.f
1
2947
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2018 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine calculated(nktet,d,dmin,ipoed,iedg,cotet) ! ! determine the length of all edges in the actual mesh ! implicit none ! integer i,nktet,ipoed(*),iedg(3,*),index,n1,n2 ! real*8 d(*),dmin,cotet(3,*) ! intent(in) nktet,ipoed,iedg,cotet ! intent(inout) d,dmin ! ! determine the size of all edges ! dmin=1.d30 ! loop: do i=1,nktet index=ipoed(i) do if(index.eq.0) cycle loop ! n1=iedg(1,index) n2=iedg(2,index) ! d(index)=dsqrt((cotet(1,n1)-cotet(1,n2))**2+ & (cotet(2,n1)-cotet(2,n2))**2+ & (cotet(3,n1)-cotet(3,n2))**2) ! if(d(index).lt.dmin) dmin=d(index) ! index=iedg(3,index) enddo enddo loop c! c! calculating the desired edge size through interpolation c! c! initializing fields c! c nktri=integerglob(1) c netet=integerglob(2) c ne=integerglob(3) c nkon=integerglob(4) c nfaces=integerglob(5) c nfield=1 c nselect=1 c iselect(1)=1 c imastset=0 c! c do i=1,nktet c if(ipoeln(i).eq.0) cycle c! c! perform the interpolation for the internal node c! c do j=1,3 c coords(j)=cotet(j,i) c enddo c call basis(doubleglob(1),doubleglob(netet+1), c & doubleglob(2*netet+1), c & doubleglob(3*netet+1),doubleglob(4*netet+1), c & doubleglob(5*netet+1),integerglob(6), c & integerglob(netet+6), c & integerglob(2*netet+6),doubleglob(6*netet+1), c & integerglob(3*netet+6),nktri,netet, c & doubleglob(4*nfaces+6*netet+1),nfield, c & doubleglob(nktri+4*nfaces+6*netet+1), c & integerglob(7*netet+6),integerglob(ne+7*netet+6), c & integerglob(2*ne+7*netet+6), c & integerglob(nkon+2*ne+7*netet+6), c & coords(1),coords(2),coords(3),h(i),ratio,iselect, c & nselect,istartset,iendset,ialset,imastset, c & integerglob(nkon+2*ne+8*netet+6),nterms,konl,nelem) c! c enddo ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.9/src/genmodes.f
6
1982
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! c Bernhardi start subroutine genmodes(i,kon,ipkon,lakon,ne,nk,nk_,co) ! ! generate nodes for incompatible modes ! implicit none ! character*8 lakon(*) c real*8 co(3,*),coords(3) c integer i,kon(*),ipkon(*),ne,nope,nopeexp, & nk,nk_,j,indexe,k,nodeb(8,3) c indexe=ipkon(i) c if(lakon(i)(1:5).eq.'C3D8I')then nope=8 nopeexp=3 else write(*,*) "*ERROR in genmodes: wrong element type, element=", & lakon(i) call exit(201) endif ! ! generating additional nodes for the incompatible element. ! ! determining the mean value of the coordinates of the element ! do k=1,3 coords(k)=0.d0 do j=1,nope coords(k)=coords(k)+co(k,kon(indexe+j)) enddo coords(k)=coords(k)/8.d0 enddo ! do j=1,nopeexp nk=nk+1 if(nk.gt.nk_) then write(*,*) '*ERROR in genmodes: increase nk_' call exit(201) endif kon(indexe+nope+j)=nk do k=1,3 co(k,nk)=coords(k) enddo enddo ! return end c Bernhardi end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.12/src/genmodes.f
6
1982
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! c Bernhardi start subroutine genmodes(i,kon,ipkon,lakon,ne,nk,nk_,co) ! ! generate nodes for incompatible modes ! implicit none ! character*8 lakon(*) c real*8 co(3,*),coords(3) c integer i,kon(*),ipkon(*),ne,nope,nopeexp, & nk,nk_,j,indexe,k,nodeb(8,3) c indexe=ipkon(i) c if(lakon(i)(1:5).eq.'C3D8I')then nope=8 nopeexp=3 else write(*,*) "*ERROR in genmodes: wrong element type, element=", & lakon(i) call exit(201) endif ! ! generating additional nodes for the incompatible element. ! ! determining the mean value of the coordinates of the element ! do k=1,3 coords(k)=0.d0 do j=1,nope coords(k)=coords(k)+co(k,kon(indexe+j)) enddo coords(k)=coords(k)/8.d0 enddo ! do j=1,nopeexp nk=nk+1 if(nk.gt.nk_) then write(*,*) '*ERROR in genmodes: increase nk_' call exit(201) endif kon(indexe+nope+j)=nk do k=1,3 co(k,nk)=coords(k) enddo enddo ! return end c Bernhardi end
gpl-2.0
grlee77/scipy
scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/snconv.f
38
4001
c----------------------------------------------------------------------- c\BeginDoc c c\Name: snconv c c\Description: c Convergence testing for the nonsymmetric Arnoldi eigenvalue routine. c c\Usage: c call snconv c ( N, RITZR, RITZI, BOUNDS, TOL, NCONV ) c c\Arguments c N Integer. (INPUT) c Number of Ritz values to check for convergence. c c RITZR, Real arrays of length N. (INPUT) c RITZI Real and imaginary parts of the Ritz values to be checked c for convergence. c BOUNDS Real array of length N. (INPUT) c Ritz estimates for the Ritz values in RITZR and RITZI. c c TOL Real scalar. (INPUT) c Desired backward error for a Ritz value to be considered c "converged". c c NCONV Integer scalar. (OUTPUT) c Number of "converged" Ritz values. c c\EndDoc c c----------------------------------------------------------------------- c c\BeginLib c c\Local variables: c xxxxxx real c c\Routines called: c arscnd ARPACK utility routine for timing. c slamch LAPACK routine that determines machine constants. c slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. c c\Author c Danny Sorensen Phuong Vu c Richard Lehoucq CRPC / Rice University c Dept. of Computational & Houston, Texas c Applied Mathematics c Rice University c Houston, Texas c c\Revision history: c xx/xx/92: Version ' 2.1' c c\SCCS Information: @(#) c FILE: nconv.F SID: 2.3 DATE OF SID: 4/20/96 RELEASE: 2 c c\Remarks c 1. xxxx c c\EndLib c c----------------------------------------------------------------------- c subroutine snconv (n, ritzr, ritzi, bounds, tol, nconv) c c %----------------------------------------------------% c | Include files for debugging and timing information | c %----------------------------------------------------% c include 'debug.h' include 'stat.h' c c %------------------% c | Scalar Arguments | c %------------------% c integer n, nconv Real & tol c c %-----------------% c | Array Arguments | c %-----------------% Real & ritzr(n), ritzi(n), bounds(n) c c %---------------% c | Local Scalars | c %---------------% c integer i Real & temp, eps23 c c %--------------------% c | External Functions | c %--------------------% c Real & slapy2, slamch external slapy2, slamch c %-----------------------% c | Executable Statements | c %-----------------------% c c %-------------------------------------------------------------% c | Convergence test: unlike in the symmetric code, I am not | c | using things like refined error bounds and gap condition | c | because I don't know the exact equivalent concept. | c | | c | Instead the i-th Ritz value is considered "converged" when: | c | | c | bounds(i) .le. ( TOL * | ritz | ) | c | | c | for some appropriate choice of norm. | c %-------------------------------------------------------------% c call arscnd (t0) c c %---------------------------------% c | Get machine dependent constant. | c %---------------------------------% c eps23 = slamch('Epsilon-Machine') eps23 = eps23**(2.0E+0 / 3.0E+0) c nconv = 0 do 20 i = 1, n temp = max( eps23, slapy2( ritzr(i), ritzi(i) ) ) if (bounds(i) .le. tol*temp) nconv = nconv + 1 20 continue c call arscnd (t1) tnconv = tnconv + (t1 - t0) c return c c %---------------% c | End of snconv | c %---------------% c end
bsd-3-clause
freedesktop-unofficial-mirror/gstreamer-sdk__gcc
libgfortran/generated/_abs_c8.F90
22
1478
! Copyright 2002, 2007, 2009 Free Software Foundation, Inc. ! Contributed by Paul Brook <[email protected]> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. ! !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_COMPLEX_8) #ifdef HAVE_CABS elemental function _gfortran_specific__abs_c8 (parm) complex (kind=8), intent (in) :: parm real (kind=8) :: _gfortran_specific__abs_c8 _gfortran_specific__abs_c8 = abs (parm) end function #endif #endif
gpl-2.0
freedesktop-unofficial-mirror/gstreamer-sdk__gcc
gcc/testsuite/gfortran.dg/widechar_intrinsics_9.f90
174
2747
! { dg-do run } ! { dg-options "-fbackslash" } implicit none character(kind=1,len=3) :: s1, t1 character(kind=4,len=3) :: s4, t4 s1 = "foo" ; t1 = "bar" call check_minmax_1 ("foo", "bar", min("foo","bar"), max("foo","bar")) call check_minmax_1 ("bar", "foo", min("foo","bar"), max("foo","bar")) call check_minmax_1 (s1, t1, min(s1,t1), max(s1,t1)) call check_minmax_1 (t1, s1, min(s1,t1), max(s1,t1)) s1 = " " ; t1 = "bar" call check_minmax_1 (" ", "bar", min(" ","bar"), max(" ","bar")) call check_minmax_1 ("bar", " ", min(" ","bar"), max(" ","bar")) call check_minmax_1 (s1, t1, min(s1,t1), max(s1,t1)) call check_minmax_1 (t1, s1, min(s1,t1), max(s1,t1)) s1 = " " ; t1 = " " call check_minmax_1 (" ", " ", min(" "," "), max(" "," ")) call check_minmax_1 (" ", " ", min(" "," "), max(" "," ")) call check_minmax_1 (s1, t1, min(s1,t1), max(s1,t1)) call check_minmax_1 (t1, s1, min(s1,t1), max(s1,t1)) s1 = "d\xFF " ; t1 = "d " call check_minmax_1 ("d\xFF ", "d ", min("d\xFF ","d "), max("d\xFF ","d ")) call check_minmax_1 ("d ", "d\xFF ", min("d\xFF ","d "), max("d\xFF ","d ")) call check_minmax_1 (s1, t1, min(s1,t1), max(s1,t1)) call check_minmax_1 (t1, s1, min(s1,t1), max(s1,t1)) s4 = 4_" " ; t4 = 4_"xxx" call check_minmax_2 (4_" ", 4_"xxx", min(4_" ", 4_"xxx"), & max(4_" ", 4_"xxx")) call check_minmax_2 (4_"xxx", 4_" ", min(4_" ", 4_"xxx"), & max(4_" ", 4_"xxx")) call check_minmax_2 (s4, t4, min(s4,t4), max(s4,t4)) call check_minmax_2 (t4, s4, min(s4,t4), max(s4,t4)) s4 = 4_" \u1be3m" ; t4 = 4_"xxx" call check_minmax_2 (4_" \u1be3m", 4_"xxx", min(4_" \u1be3m", 4_"xxx"), & max(4_" \u1be3m", 4_"xxx")) call check_minmax_2 (4_"xxx", 4_" \u1be3m", min(4_" \u1be3m", 4_"xxx"), & max(4_" \u1be3m", 4_"xxx")) call check_minmax_2 (s4, t4, min(s4,t4), max(s4,t4)) call check_minmax_2 (t4, s4, min(s4,t4), max(s4,t4)) contains subroutine check_minmax_1 (s1, s2, smin, smax) implicit none character(kind=1,len=*), intent(in) :: s1, s2, smin, smax character(kind=4,len=len(s1)) :: w1, w2, wmin, wmax w1 = s1 ; w2 = s2 ; wmin = smin ; wmax = smax if (min (w1, w2) /= wmin) call abort if (max (w1, w2) /= wmax) call abort if (min (s1, s2) /= smin) call abort if (max (s1, s2) /= smax) call abort end subroutine check_minmax_1 subroutine check_minmax_2 (s1, s2, smin, smax) implicit none character(kind=4,len=*), intent(in) :: s1, s2, smin, smax if (min (s1, s2) /= smin) call abort if (max (s1, s2) /= smax) call abort end subroutine check_minmax_2 end
gpl-2.0
techno/gcc-mist32
libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90
74
1070
! { dg-do run } module e_54_6_mod contains subroutine init (v1, v2, N) integer :: i, N real, pointer, dimension(:) :: v1, v2 do i = 1, N v1(i) = i + 2.0 v2(i) = i - 3.0 end do end subroutine subroutine check (p, N) integer :: i, N real, parameter :: EPS = 0.00001 real, pointer, dimension(:) :: p real :: diff do i = 1, N diff = p(i) - (i + 2.0) * (i - 3.0) if (diff > EPS .or. -diff > EPS) call abort end do end subroutine subroutine vec_mult (p, v1, v2, N) real :: p(N), v1(N), v2(N) integer :: i, N !$omp target teams map(to: v1, v2) map(from: p) !$omp distribute parallel do simd do i = 1, N p(i) = v1(i) * v2(i) end do !$omp end target teams end subroutine end module program e_54_6 use e_54_6_mod, only : init, check, vec_mult real, pointer, dimension(:) :: p, v1, v2 integer :: n n = 1000 allocate (p(n), v1(n), v2(n)) call init (v1, v2, n) call vec_mult (p, v1, v2, n) call check (p, N) deallocate (p, v1, v2) end program
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/add_bo_st.f
1
1425
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine add_bo_st(au,jq,irow,i,j,value) ! ! stores the boundary stiffness coefficient (i,j) with value "value" ! in the stiffness matrix stored in spare matrix format ! implicit none ! integer jq(*),irow(*),i,j,ipointer,id ! real*8 au(*),value ! ! ! call nident(irow(jq(j)),i,jq(j+1)-jq(j),id) ! ipointer=jq(j)+id-1 ! if(irow(ipointer).ne.i) then c write(*,*) i,j,ipointer,irow(ipointer) write(*,*) '*ERROR in add_bo_st: coefficient should be 0' call exit(201) else au(ipointer)=au(ipointer)+value endif ! return end
gpl-2.0
jabbaqin/p3dfft
build/fcomm2.F90
3
8411
! This file is part of P3DFFT library ! ! P3DFFT ! ! Software Framework for Scalable Fourier Transforms in Three Dimensions ! ! Copyright (C) 2006-2014 Dmitry Pekurovsky ! Copyright (C) 2006-2014 University of California ! Copyright (C) 2010-2011 Jens Henrik Goebbert ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! ! !---------------------------------------------------------------------------- !======================================================== ! Transpose an array in Y=pencils into Z-pencils ! Uses MPI_Alltoall(v) ! subroutine fcomm2_many(source,dest,dim_out,nv,t,tc) !======================================================== implicit none real(r8) t,tc integer x,z,y,i,ierr,xs,ys,y2,z2,iy,iz,dny,nv,j,dim_out integer(i8) position,pos1,pos0 integer sndcnts(0:jproc-1) integer rcvcnts(0:jproc-1) integer sndstrt(0:jproc-1) integer rcvstrt(0:jproc-1) complex(mytype) source(iisize,ny_fft,kjsize,nv) complex(mytype) dest(dim_out,nv) ! Pack send buffers for exchanging y and z for all x at once call pack_fcomm2_many(buf1,source,nv) ! Exchange y-z buffers in columns of processors t = t - MPI_Wtime() #ifdef USE_EVEN ! Use MPI_Alltoall call mpi_alltoall(buf1,KfCntMax * nv, mpi_byte, & buf2,KfCntMax * nv, mpi_byte,mpi_comm_col,ierr) #else ! Use MPI_Alltoallv sndcnts = KfSndCnts * nv sndstrt = KfSndStrt * nv rcvcnts = KfRcvCnts * nv rcvstrt = KfRcvStrt * nv call mpi_alltoallv(buf1,SndCnts, SndStrt,mpi_byte, & buf2,RcvCnts, RcvStrt,mpi_byte,mpi_comm_col,ierr) #endif t = MPI_Wtime() + t tc = tc - MPI_Wtime() do j=1,nv call unpack_fcomm2(dest(1,j),j,nv) enddo tc = tc + MPI_Wtime() return end subroutine subroutine pack_fcomm2_many(sndbuf,source,nv) use fft_spec implicit none complex(mytype) source(iisize,ny_fft,kjsize,nv) complex(mytype) sndbuf(iisize*ny_fft*kjsize*nv) integer nv,j,i,position,pos0,pos1,x,y,z,dny dny = ny_fft-nyc position = 1 do j=1,nv do i=0,jproc-1 #ifdef USE_EVEN pos0 = (i * nv +(j-1))* KfCntMax/(mytype*2) + 1 #else pos0 = (nv * KfSndStrt(i) + (j-1)*KfSndCnts(i))/(mytype*2)+ 1 #endif ! If clearly in the first half of ny if(jjen(i) .le. nyhc) then do z=1,kjsize position = pos0 +(z-1)*jjsz(i)*iisize do y=jjst(i),jjen(i) do x=1,iisize sndbuf(position) = source(x,y,z,j) position = position+1 enddo enddo enddo ! If clearly in the second half of ny else if (jjst(i) .ge. nyhc+1) then do z=1,kjsize position = pos0 +(z-1)*jjsz(i)*iisize do y=jjst(i)+dny,jjen(i)+dny do x=1,iisize sndbuf(position) = source(x,y,z,j) position = position+1 enddo enddo enddo ! If spanning the first and second half of ny (e.g. iproc is odd) else do z=1,kjsize position = pos0 +(z-1)*jjsz(i)*iisize do y=jjst(i),nyhc do x=1,iisize sndbuf(position) = source(x,y,z,j) position = position+1 enddo enddo do y=ny_fft-nyhc+1,jjen(i)+dny do x=1,iisize sndbuf(position) = source(x,y,z,j) position = position+1 enddo enddo enddo endif enddo enddo end subroutine subroutine unpack_fcomm2(dest,j,nv) implicit none integer j,i,x,y,z,nv integer*8 position complex(mytype) dest(iisize,jjsize,nz_fft) do i=0,jproc-1 #ifdef USE_EVEN position = i*KfCntMax*nv/(mytype*2)+1 #else position = KfRcvStrt(i)*nv/(mytype*2)+1 #endif position = position + (j-1)*iisize*jjsize*kjsz(i) do z=kjst(i),kjen(i) do y=1,jjsize do x=1,iisize dest(x,y,z) = buf2(position) position = position +1 enddo enddo enddo enddo return end subroutine subroutine fcomm2(source,dest,t,tc) !======================================================== implicit none complex(mytype) source(iisize,ny_fft,kjsize) complex(mytype) dest(iisize,jjsize,nz_fft) real(r8) t,tc integer x,z,y,i,ierr,xs,ys,y2,z2,iy,iz,dny integer(i8) position,pos1,pos0 ! Pack send buffers for exchanging y and z for all x at once call pack_fcomm2(buf1,source) ! Exchange y-z buffers in columns of processors t = t - MPI_Wtime() #ifdef USE_EVEN ! Use MPI_Alltoall if(KfCntUneven) then call mpi_alltoall(buf1,KfCntMax, mpi_byte, & buf2,KfCntMax, mpi_byte,mpi_comm_col,ierr) t = MPI_Wtime() + t tc = tc - MPI_Wtime() position = 1 do i=0,jproc-1 do z=kjst(i),kjen(i) do y=1,jjsize do x=1,iisize dest(x,y,z) = buf2(position) position = position +1 enddo enddo enddo position = (i+1)*KfCntMax/(mytype*2)+1 enddo tc = tc + MPI_Wtime() else call mpi_alltoall(buf1,KfCntMax, mpi_byte, & dest,KfCntMax, mpi_byte,mpi_comm_col,ierr) t = MPI_Wtime() + t endif #else ! Use MPI_Alltoallv call mpi_alltoallv(buf1,KfSndCnts, KfSndStrt,mpi_byte, & dest,KfRcvCnts, KfRcvStrt,mpi_byte,mpi_comm_col,ierr) t = MPI_Wtime() + t #endif return end subroutine subroutine pack_fcomm2(buf1,source) complex(mytype) source(iisize,ny_fft,kjsize) complex(mytype) buf1(iisize*ny_fft*kjsize) integer i,dny,position,pos0,x,y,z dny = ny_fft-nyc position = 1 do i=0,jproc-1 #ifdef USE_EVEN pos0 = i*KfCntMax/(mytype*2) + 1 #else pos0 = KfSndStrt(i)/(mytype*2)+ 1 #endif ! If clearly in the first half of ny if(jjen(i) .le. nyhc) then do z=1,kjsize position = pos0 +(z-1)*jjsz(i)*iisize do y=jjst(i),jjen(i) do x=1,iisize buf1(position) = source(x,y,z) position = position+1 enddo enddo enddo ! If clearly in the second half of ny else if (jjst(i) .ge. nyhc+1) then do z=1,kjsize position = pos0 +(z-1)*jjsz(i)*iisize do y=jjst(i)+dny,jjen(i)+dny do x=1,iisize buf1(position) = source(x,y,z) position = position+1 enddo enddo enddo ! If spanning the first and second half of ny (e.g. iproc is odd) else do z=1,kjsize position = pos0 +(z-1)*jjsz(i)*iisize do y=jjst(i),nyhc do x=1,iisize buf1(position) = source(x,y,z) position = position+1 enddo enddo do y=ny_fft-nyhc+1,jjen(i)+dny do x=1,iisize buf1(position) = source(x,y,z) position = position+1 enddo enddo enddo endif enddo return end subroutine
gpl-3.0
prool/ccx_prool
CalculiX/ccx_2.10/src/plmix.f
4
7030
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine plmix(plcon,nplcon,plconloc,npmat_,ntmat_, & imat,j,temp,nelem,kin) ! ! interpolates the hardening data for material imat and temperature ! j and j-1 to obtain data for temperature temp. The data is taken ! from plcon and stored in plconloc. ! The Von Mises stress is interpolated for a given equivalent ! plastic strain. If the equivalent strain data points for ! temperature j and j-1 do not coincide, the union of both is ! taken. If this union exceeds 200 (ierror=1), the equivalent plastic ! strain range is divided into 199 intervals yielding 200 new ! equivalent strain data points, for which the Von Mises stress ! is interpolated. ! Attention: in plcon the odd storage spaces contain the Von ! Mises stress, the even ones the equivalent plastic ! strain. For plconloc, this order is reversed. ! implicit none ! integer imat,ndata,ntmat_,npmat_,nplcon(0:ntmat_,*),nelem, & kin,k,j,k1,k2,ierror,ndata1,ndata2,itemp ! real*8 eplmin,eplmax,depl,epla,plcon(0:2*npmat_,ntmat_,*), & plconloc(802),dummy,temp,ep1,ep2,t1,t2,s1,s2,ratio ! intent(in) plcon,nplcon,npmat_,ntmat_, & imat,j,temp,nelem,kin ! intent(inout) plconloc ! ndata=0 ierror=0 ! ndata1=nplcon(j-1,imat) ndata2=nplcon(j,imat) t1=plcon(0,j-1,imat) t2=plcon(0,j,imat) ratio=(temp-t1)/(t2-t1) ! ! the interval on which the stress interpolation is performed ! is the intersection of the domain of the two curves ! k1=1 k2=1 ep1=plcon(2,j-1,imat) ep2=plcon(2,j,imat) if(ep1.gt.ep2) then do k2=1,ndata2 ep2=plcon(2*k2,j,imat) if(ep2.gt.ep1) exit enddo if(k2.gt.ndata2) then write(*,*) '*ERROR in plmix: there exist two temperatures' write(*,*) ' for which the hardening curves are' write(*,*) ' disjunct' call exit(201) endif elseif(ep2.gt.ep1) then do k1=1,ndata1 ep1=plcon(2*k1,j-1,imat) if(ep1.gt.ep2) exit enddo if(k1.gt.ndata1) then write(*,*) '*ERROR in plmix: there exist two temperatures' write(*,*) ' for which the hardening curves are' write(*,*) ' disjunct' call exit(201) endif endif ! do s1=plcon(2*k1-1,j-1,imat) s2=plcon(2*k2-1,j,imat) ep1=plcon(2*k1,j-1,imat) ep2=plcon(2*k2,j,imat) ! if(dabs(ep1-ep2).lt.1.d-10) then if(k2.lt.ndata2) then k2=k2+1 elseif(k1.lt.ndata1) then k1=k1+1 else ndata=ndata+1 if(ndata.gt.200) then ierror=1 exit endif if(kin.eq.0) then plconloc(2*ndata-1)=ep1+ratio*(ep2-ep1) plconloc(2*ndata)=s1+ratio*(s2-s1) else plconloc(399+2*ndata)=ep1+ratio*(ep2-ep1) plconloc(400+2*ndata)=s1+ratio*(s2-s1) endif exit endif cycle endif if(ep1.lt.ep2) then ndata=ndata+1 if(ndata.gt.200) then ierror=1 exit endif call plinterpol(plcon,nplcon,j,s2,dummy,npmat_,ntmat_, & imat,nelem,ep1) if(kin.eq.0) then plconloc(2*ndata-1)=ep1 plconloc(2*ndata)=s1+ratio*(s2-s1) else plconloc(399+2*ndata)=ep1 plconloc(400+2*ndata)=s1+ratio*(s2-s1) endif if(k1.lt.ndata1) then k1=k1+1 cycle else exit endif else ndata=ndata+1 if(ndata.gt.200) then ierror=1 exit endif call plinterpol(plcon,nplcon,j-1,s1,dummy,npmat_,ntmat_, & imat,nelem,ep2) if(kin.eq.0) then plconloc(2*ndata-1)=ep2 plconloc(2*ndata)=s1+ratio*(s2-s1) else plconloc(399+2*ndata)=ep2 plconloc(400+2*ndata)=s1+ratio*(s2-s1) endif if(k2.lt.ndata2) then k2=k2+1 cycle else exit endif endif enddo ! ! if more than 200 data points result, the interval is divided into ! 199 equidistant intervals ! if(ierror.eq.0) then if(kin.eq.0) then plconloc(801)=real(ndata)+0.5d0 else plconloc(802)=real(ndata)+0.5d0 endif else if(kin.eq.0) then eplmin=max(plcon(2,j-1,imat),plcon(2,j,imat)) eplmax=min(plcon(2*ndata1,j-1,imat),plcon(2*ndata2,j,imat)) & -1.d-10 depl=(eplmax-eplmin)/199.d0 do k=1,200 epla=eplmin+(k-1)*depl itemp=j-1 call plinterpol(plcon,nplcon,itemp,s1, & dummy,npmat_,ntmat_,imat,nelem,epla) itemp=j call plinterpol(plcon,nplcon,itemp,s2, & dummy,npmat_,ntmat_,imat,nelem,epla) plconloc(2*k-1)=epla plconloc(2*k)=s1+ratio*(s2-s1) enddo plconloc(801)=200.5d0 else eplmin=max(plcon(2,j-1,imat),plcon(2,j,imat)) eplmax=min(plcon(2*ndata1,j-1,imat),plcon(2*ndata2,j,imat)) & -1.d-10 depl=(eplmax-eplmin)/199.d0 do k=1,200 epla=eplmin+(k-1)*depl itemp=j-1 call plinterpol(plcon,nplcon,itemp,s1, & dummy,npmat_,ntmat_,imat,nelem,epla) itemp=j call plinterpol(plcon,nplcon,itemp,s2, & dummy,npmat_,ntmat_,imat,nelem,epla) plconloc(399+2*k)=epla plconloc(400+2*k)=s1+ratio*(s2-s1) enddo plconloc(802)=200.5d0 endif endif ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.12/src/plmix.f
4
7030
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine plmix(plcon,nplcon,plconloc,npmat_,ntmat_, & imat,j,temp,nelem,kin) ! ! interpolates the hardening data for material imat and temperature ! j and j-1 to obtain data for temperature temp. The data is taken ! from plcon and stored in plconloc. ! The Von Mises stress is interpolated for a given equivalent ! plastic strain. If the equivalent strain data points for ! temperature j and j-1 do not coincide, the union of both is ! taken. If this union exceeds 200 (ierror=1), the equivalent plastic ! strain range is divided into 199 intervals yielding 200 new ! equivalent strain data points, for which the Von Mises stress ! is interpolated. ! Attention: in plcon the odd storage spaces contain the Von ! Mises stress, the even ones the equivalent plastic ! strain. For plconloc, this order is reversed. ! implicit none ! integer imat,ndata,ntmat_,npmat_,nplcon(0:ntmat_,*),nelem, & kin,k,j,k1,k2,ierror,ndata1,ndata2,itemp ! real*8 eplmin,eplmax,depl,epla,plcon(0:2*npmat_,ntmat_,*), & plconloc(802),dummy,temp,ep1,ep2,t1,t2,s1,s2,ratio ! intent(in) plcon,nplcon,npmat_,ntmat_, & imat,j,temp,nelem,kin ! intent(inout) plconloc ! ndata=0 ierror=0 ! ndata1=nplcon(j-1,imat) ndata2=nplcon(j,imat) t1=plcon(0,j-1,imat) t2=plcon(0,j,imat) ratio=(temp-t1)/(t2-t1) ! ! the interval on which the stress interpolation is performed ! is the intersection of the domain of the two curves ! k1=1 k2=1 ep1=plcon(2,j-1,imat) ep2=plcon(2,j,imat) if(ep1.gt.ep2) then do k2=1,ndata2 ep2=plcon(2*k2,j,imat) if(ep2.gt.ep1) exit enddo if(k2.gt.ndata2) then write(*,*) '*ERROR in plmix: there exist two temperatures' write(*,*) ' for which the hardening curves are' write(*,*) ' disjunct' call exit(201) endif elseif(ep2.gt.ep1) then do k1=1,ndata1 ep1=plcon(2*k1,j-1,imat) if(ep1.gt.ep2) exit enddo if(k1.gt.ndata1) then write(*,*) '*ERROR in plmix: there exist two temperatures' write(*,*) ' for which the hardening curves are' write(*,*) ' disjunct' call exit(201) endif endif ! do s1=plcon(2*k1-1,j-1,imat) s2=plcon(2*k2-1,j,imat) ep1=plcon(2*k1,j-1,imat) ep2=plcon(2*k2,j,imat) ! if(dabs(ep1-ep2).lt.1.d-10) then if(k2.lt.ndata2) then k2=k2+1 elseif(k1.lt.ndata1) then k1=k1+1 else ndata=ndata+1 if(ndata.gt.200) then ierror=1 exit endif if(kin.eq.0) then plconloc(2*ndata-1)=ep1+ratio*(ep2-ep1) plconloc(2*ndata)=s1+ratio*(s2-s1) else plconloc(399+2*ndata)=ep1+ratio*(ep2-ep1) plconloc(400+2*ndata)=s1+ratio*(s2-s1) endif exit endif cycle endif if(ep1.lt.ep2) then ndata=ndata+1 if(ndata.gt.200) then ierror=1 exit endif call plinterpol(plcon,nplcon,j,s2,dummy,npmat_,ntmat_, & imat,nelem,ep1) if(kin.eq.0) then plconloc(2*ndata-1)=ep1 plconloc(2*ndata)=s1+ratio*(s2-s1) else plconloc(399+2*ndata)=ep1 plconloc(400+2*ndata)=s1+ratio*(s2-s1) endif if(k1.lt.ndata1) then k1=k1+1 cycle else exit endif else ndata=ndata+1 if(ndata.gt.200) then ierror=1 exit endif call plinterpol(plcon,nplcon,j-1,s1,dummy,npmat_,ntmat_, & imat,nelem,ep2) if(kin.eq.0) then plconloc(2*ndata-1)=ep2 plconloc(2*ndata)=s1+ratio*(s2-s1) else plconloc(399+2*ndata)=ep2 plconloc(400+2*ndata)=s1+ratio*(s2-s1) endif if(k2.lt.ndata2) then k2=k2+1 cycle else exit endif endif enddo ! ! if more than 200 data points result, the interval is divided into ! 199 equidistant intervals ! if(ierror.eq.0) then if(kin.eq.0) then plconloc(801)=real(ndata)+0.5d0 else plconloc(802)=real(ndata)+0.5d0 endif else if(kin.eq.0) then eplmin=max(plcon(2,j-1,imat),plcon(2,j,imat)) eplmax=min(plcon(2*ndata1,j-1,imat),plcon(2*ndata2,j,imat)) & -1.d-10 depl=(eplmax-eplmin)/199.d0 do k=1,200 epla=eplmin+(k-1)*depl itemp=j-1 call plinterpol(plcon,nplcon,itemp,s1, & dummy,npmat_,ntmat_,imat,nelem,epla) itemp=j call plinterpol(plcon,nplcon,itemp,s2, & dummy,npmat_,ntmat_,imat,nelem,epla) plconloc(2*k-1)=epla plconloc(2*k)=s1+ratio*(s2-s1) enddo plconloc(801)=200.5d0 else eplmin=max(plcon(2,j-1,imat),plcon(2,j,imat)) eplmax=min(plcon(2*ndata1,j-1,imat),plcon(2*ndata2,j,imat)) & -1.d-10 depl=(eplmax-eplmin)/199.d0 do k=1,200 epla=eplmin+(k-1)*depl itemp=j-1 call plinterpol(plcon,nplcon,itemp,s1, & dummy,npmat_,ntmat_,imat,nelem,epla) itemp=j call plinterpol(plcon,nplcon,itemp,s2, & dummy,npmat_,ntmat_,imat,nelem,epla) plconloc(399+2*k)=epla plconloc(400+2*k)=s1+ratio*(s2-s1) enddo plconloc(802)=200.5d0 endif endif ! return end
gpl-2.0
dowoncha/COMP575
PA4/lib/eigen/blas/testing/dblat3.f
242
103029
PROGRAM DBLAT3 * * Test program for the DOUBLE PRECISION Level 3 Blas. * * The program must be driven by a short data file. The first 14 records * of the file are read using list-directed input, the last 6 records * are read using the format ( A6, L2 ). An annotated example of a data * file can be obtained by deleting the first 3 characters from the * following 20 lines: * 'DBLAT3.SUMM' NAME OF SUMMARY OUTPUT FILE * 6 UNIT NUMBER OF SUMMARY FILE * 'DBLAT3.SNAP' NAME OF SNAPSHOT OUTPUT FILE * -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0) * F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD. * F LOGICAL FLAG, T TO STOP ON FAILURES. * T LOGICAL FLAG, T TO TEST ERROR EXITS. * 16.0 THRESHOLD VALUE OF TEST RATIO * 6 NUMBER OF VALUES OF N * 0 1 2 3 5 9 VALUES OF N * 3 NUMBER OF VALUES OF ALPHA * 0.0 1.0 0.7 VALUES OF ALPHA * 3 NUMBER OF VALUES OF BETA * 0.0 1.0 1.3 VALUES OF BETA * DGEMM T PUT F FOR NO TEST. SAME COLUMNS. * DSYMM T PUT F FOR NO TEST. SAME COLUMNS. * DTRMM T PUT F FOR NO TEST. SAME COLUMNS. * DTRSM T PUT F FOR NO TEST. SAME COLUMNS. * DSYRK T PUT F FOR NO TEST. SAME COLUMNS. * DSYR2K T PUT F FOR NO TEST. SAME COLUMNS. * * See: * * Dongarra J. J., Du Croz J. J., Duff I. S. and Hammarling S. * A Set of Level 3 Basic Linear Algebra Subprograms. * * Technical Memorandum No.88 (Revision 1), Mathematics and * Computer Science Division, Argonne National Laboratory, 9700 * South Cass Avenue, Argonne, Illinois 60439, US. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. INTEGER NIN PARAMETER ( NIN = 5 ) INTEGER NSUBS PARAMETER ( NSUBS = 6 ) DOUBLE PRECISION ZERO, HALF, ONE PARAMETER ( ZERO = 0.0D0, HALF = 0.5D0, ONE = 1.0D0 ) INTEGER NMAX PARAMETER ( NMAX = 65 ) INTEGER NIDMAX, NALMAX, NBEMAX PARAMETER ( NIDMAX = 9, NALMAX = 7, NBEMAX = 7 ) * .. Local Scalars .. DOUBLE PRECISION EPS, ERR, THRESH INTEGER I, ISNUM, J, N, NALF, NBET, NIDIM, NOUT, NTRA LOGICAL FATAL, LTESTT, REWI, SAME, SFATAL, TRACE, $ TSTERR CHARACTER*1 TRANSA, TRANSB CHARACTER*6 SNAMET CHARACTER*32 SNAPS, SUMMRY * .. Local Arrays .. DOUBLE PRECISION AA( NMAX*NMAX ), AB( NMAX, 2*NMAX ), $ ALF( NALMAX ), AS( NMAX*NMAX ), $ BB( NMAX*NMAX ), BET( NBEMAX ), $ BS( NMAX*NMAX ), C( NMAX, NMAX ), $ CC( NMAX*NMAX ), CS( NMAX*NMAX ), CT( NMAX ), $ G( NMAX ), W( 2*NMAX ) INTEGER IDIM( NIDMAX ) LOGICAL LTEST( NSUBS ) CHARACTER*6 SNAMES( NSUBS ) * .. External Functions .. DOUBLE PRECISION DDIFF LOGICAL LDE EXTERNAL DDIFF, LDE * .. External Subroutines .. EXTERNAL DCHK1, DCHK2, DCHK3, DCHK4, DCHK5, DCHKE, DMMCH * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK CHARACTER*6 SRNAMT * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR COMMON /SRNAMC/SRNAMT * .. Data statements .. DATA SNAMES/'DGEMM ', 'DSYMM ', 'DTRMM ', 'DTRSM ', $ 'DSYRK ', 'DSYR2K'/ * .. Executable Statements .. * * Read name and unit number for summary output file and open file. * READ( NIN, FMT = * )SUMMRY READ( NIN, FMT = * )NOUT OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' ) NOUTC = NOUT * * Read name and unit number for snapshot output file and open file. * READ( NIN, FMT = * )SNAPS READ( NIN, FMT = * )NTRA TRACE = NTRA.GE.0 IF( TRACE )THEN OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' ) END IF * Read the flag that directs rewinding of the snapshot file. READ( NIN, FMT = * )REWI REWI = REWI.AND.TRACE * Read the flag that directs stopping on any failure. READ( NIN, FMT = * )SFATAL * Read the flag that indicates whether error exits are to be tested. READ( NIN, FMT = * )TSTERR * Read the threshold value of the test ratio READ( NIN, FMT = * )THRESH * * Read and check the parameter values for the tests. * * Values of N READ( NIN, FMT = * )NIDIM IF( NIDIM.LT.1.OR.NIDIM.GT.NIDMAX )THEN WRITE( NOUT, FMT = 9997 )'N', NIDMAX GO TO 220 END IF READ( NIN, FMT = * )( IDIM( I ), I = 1, NIDIM ) DO 10 I = 1, NIDIM IF( IDIM( I ).LT.0.OR.IDIM( I ).GT.NMAX )THEN WRITE( NOUT, FMT = 9996 )NMAX GO TO 220 END IF 10 CONTINUE * Values of ALPHA READ( NIN, FMT = * )NALF IF( NALF.LT.1.OR.NALF.GT.NALMAX )THEN WRITE( NOUT, FMT = 9997 )'ALPHA', NALMAX GO TO 220 END IF READ( NIN, FMT = * )( ALF( I ), I = 1, NALF ) * Values of BETA READ( NIN, FMT = * )NBET IF( NBET.LT.1.OR.NBET.GT.NBEMAX )THEN WRITE( NOUT, FMT = 9997 )'BETA', NBEMAX GO TO 220 END IF READ( NIN, FMT = * )( BET( I ), I = 1, NBET ) * * Report values of parameters. * WRITE( NOUT, FMT = 9995 ) WRITE( NOUT, FMT = 9994 )( IDIM( I ), I = 1, NIDIM ) WRITE( NOUT, FMT = 9993 )( ALF( I ), I = 1, NALF ) WRITE( NOUT, FMT = 9992 )( BET( I ), I = 1, NBET ) IF( .NOT.TSTERR )THEN WRITE( NOUT, FMT = * ) WRITE( NOUT, FMT = 9984 ) END IF WRITE( NOUT, FMT = * ) WRITE( NOUT, FMT = 9999 )THRESH WRITE( NOUT, FMT = * ) * * Read names of subroutines and flags which indicate * whether they are to be tested. * DO 20 I = 1, NSUBS LTEST( I ) = .FALSE. 20 CONTINUE 30 READ( NIN, FMT = 9988, END = 60 )SNAMET, LTESTT DO 40 I = 1, NSUBS IF( SNAMET.EQ.SNAMES( I ) ) $ GO TO 50 40 CONTINUE WRITE( NOUT, FMT = 9990 )SNAMET STOP 50 LTEST( I ) = LTESTT GO TO 30 * 60 CONTINUE CLOSE ( NIN ) * * Compute EPS (the machine precision). * EPS = ONE 70 CONTINUE IF( DDIFF( ONE + EPS, ONE ).EQ.ZERO ) $ GO TO 80 EPS = HALF*EPS GO TO 70 80 CONTINUE EPS = EPS + EPS WRITE( NOUT, FMT = 9998 )EPS * * Check the reliability of DMMCH using exact data. * N = MIN( 32, NMAX ) DO 100 J = 1, N DO 90 I = 1, N AB( I, J ) = MAX( I - J + 1, 0 ) 90 CONTINUE AB( J, NMAX + 1 ) = J AB( 1, NMAX + J ) = J C( J, 1 ) = ZERO 100 CONTINUE DO 110 J = 1, N CC( J ) = J*( ( J + 1 )*J )/2 - ( ( J + 1 )*J*( J - 1 ) )/3 110 CONTINUE * CC holds the exact result. On exit from DMMCH CT holds * the result computed by DMMCH. TRANSA = 'N' TRANSB = 'N' CALL DMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX, $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC, $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. ) SAME = LDE( CC, CT, N ) IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR STOP END IF TRANSB = 'T' CALL DMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX, $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC, $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. ) SAME = LDE( CC, CT, N ) IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR STOP END IF DO 120 J = 1, N AB( J, NMAX + 1 ) = N - J + 1 AB( 1, NMAX + J ) = N - J + 1 120 CONTINUE DO 130 J = 1, N CC( N - J + 1 ) = J*( ( J + 1 )*J )/2 - $ ( ( J + 1 )*J*( J - 1 ) )/3 130 CONTINUE TRANSA = 'T' TRANSB = 'N' CALL DMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX, $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC, $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. ) SAME = LDE( CC, CT, N ) IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR STOP END IF TRANSB = 'T' CALL DMMCH( TRANSA, TRANSB, N, 1, N, ONE, AB, NMAX, $ AB( 1, NMAX + 1 ), NMAX, ZERO, C, NMAX, CT, G, CC, $ NMAX, EPS, ERR, FATAL, NOUT, .TRUE. ) SAME = LDE( CC, CT, N ) IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN WRITE( NOUT, FMT = 9989 )TRANSA, TRANSB, SAME, ERR STOP END IF * * Test each subroutine in turn. * DO 200 ISNUM = 1, NSUBS WRITE( NOUT, FMT = * ) IF( .NOT.LTEST( ISNUM ) )THEN * Subprogram is not to be tested. WRITE( NOUT, FMT = 9987 )SNAMES( ISNUM ) ELSE SRNAMT = SNAMES( ISNUM ) * Test error exits. IF( TSTERR )THEN CALL DCHKE( ISNUM, SNAMES( ISNUM ), NOUT ) WRITE( NOUT, FMT = * ) END IF * Test computations. INFOT = 0 OK = .TRUE. FATAL = .FALSE. GO TO ( 140, 150, 160, 160, 170, 180 )ISNUM * Test DGEMM, 01. 140 CALL DCHK1( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, $ NMAX, AB, AA, AS, AB( 1, NMAX + 1 ), BB, BS, C, $ CC, CS, CT, G ) GO TO 190 * Test DSYMM, 02. 150 CALL DCHK2( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, $ NMAX, AB, AA, AS, AB( 1, NMAX + 1 ), BB, BS, C, $ CC, CS, CT, G ) GO TO 190 * Test DTRMM, 03, DTRSM, 04. 160 CALL DCHK3( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NMAX, AB, $ AA, AS, AB( 1, NMAX + 1 ), BB, BS, CT, G, C ) GO TO 190 * Test DSYRK, 05. 170 CALL DCHK4( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, $ NMAX, AB, AA, AS, AB( 1, NMAX + 1 ), BB, BS, C, $ CC, CS, CT, G ) GO TO 190 * Test DSYR2K, 06. 180 CALL DCHK5( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, $ NMAX, AB, AA, AS, BB, BS, C, CC, CS, CT, G, W ) GO TO 190 * 190 IF( FATAL.AND.SFATAL ) $ GO TO 210 END IF 200 CONTINUE WRITE( NOUT, FMT = 9986 ) GO TO 230 * 210 CONTINUE WRITE( NOUT, FMT = 9985 ) GO TO 230 * 220 CONTINUE WRITE( NOUT, FMT = 9991 ) * 230 CONTINUE IF( TRACE ) $ CLOSE ( NTRA ) CLOSE ( NOUT ) STOP * 9999 FORMAT( ' ROUTINES PASS COMPUTATIONAL TESTS IF TEST RATIO IS LES', $ 'S THAN', F8.2 ) 9998 FORMAT( ' RELATIVE MACHINE PRECISION IS TAKEN TO BE', 1P, D9.1 ) 9997 FORMAT( ' NUMBER OF VALUES OF ', A, ' IS LESS THAN 1 OR GREATER ', $ 'THAN ', I2 ) 9996 FORMAT( ' VALUE OF N IS LESS THAN 0 OR GREATER THAN ', I2 ) 9995 FORMAT( ' TESTS OF THE DOUBLE PRECISION LEVEL 3 BLAS', //' THE F', $ 'OLLOWING PARAMETER VALUES WILL BE USED:' ) 9994 FORMAT( ' FOR N ', 9I6 ) 9993 FORMAT( ' FOR ALPHA ', 7F6.1 ) 9992 FORMAT( ' FOR BETA ', 7F6.1 ) 9991 FORMAT( ' AMEND DATA FILE OR INCREASE ARRAY SIZES IN PROGRAM', $ /' ******* TESTS ABANDONED *******' ) 9990 FORMAT( ' SUBPROGRAM NAME ', A6, ' NOT RECOGNIZED', /' ******* T', $ 'ESTS ABANDONED *******' ) 9989 FORMAT( ' ERROR IN DMMCH - IN-LINE DOT PRODUCTS ARE BEING EVALU', $ 'ATED WRONGLY.', /' DMMCH WAS CALLED WITH TRANSA = ', A1, $ ' AND TRANSB = ', A1, /' AND RETURNED SAME = ', L1, ' AND ', $ 'ERR = ', F12.3, '.', /' THIS MAY BE DUE TO FAULTS IN THE ', $ 'ARITHMETIC OR THE COMPILER.', /' ******* TESTS ABANDONED ', $ '*******' ) 9988 FORMAT( A6, L2 ) 9987 FORMAT( 1X, A6, ' WAS NOT TESTED' ) 9986 FORMAT( /' END OF TESTS' ) 9985 FORMAT( /' ******* FATAL ERROR - TESTS ABANDONED *******' ) 9984 FORMAT( ' ERROR-EXITS WILL NOT BE TESTED' ) * * End of DBLAT3. * END SUBROUTINE DCHK1( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, NMAX, $ A, AA, AS, B, BB, BS, C, CC, CS, CT, G ) * * Tests DGEMM. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D0 ) * .. Scalar Arguments .. DOUBLE PRECISION EPS, THRESH INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. DOUBLE PRECISION A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), B( NMAX, NMAX ), $ BB( NMAX*NMAX ), BET( NBET ), BS( NMAX*NMAX ), $ C( NMAX, NMAX ), CC( NMAX*NMAX ), $ CS( NMAX*NMAX ), CT( NMAX ), G( NMAX ) INTEGER IDIM( NIDIM ) * .. Local Scalars .. DOUBLE PRECISION ALPHA, ALS, BETA, BLS, ERR, ERRMAX INTEGER I, IA, IB, ICA, ICB, IK, IM, IN, K, KS, LAA, $ LBB, LCC, LDA, LDAS, LDB, LDBS, LDC, LDCS, M, $ MA, MB, MS, N, NA, NARGS, NB, NC, NS LOGICAL NULL, RESET, SAME, TRANA, TRANB CHARACTER*1 TRANAS, TRANBS, TRANSA, TRANSB CHARACTER*3 ICH * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LDE, LDERES EXTERNAL LDE, LDERES * .. External Subroutines .. EXTERNAL DGEMM, DMAKE, DMMCH * .. Intrinsic Functions .. INTRINSIC MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICH/'NTC'/ * .. Executable Statements .. * NARGS = 13 NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 110 IM = 1, NIDIM M = IDIM( IM ) * DO 100 IN = 1, NIDIM N = IDIM( IN ) * Set LDC to 1 more than minimum value if room. LDC = M IF( LDC.LT.NMAX ) $ LDC = LDC + 1 * Skip tests if not enough room. IF( LDC.GT.NMAX ) $ GO TO 100 LCC = LDC*N NULL = N.LE.0.OR.M.LE.0 * DO 90 IK = 1, NIDIM K = IDIM( IK ) * DO 80 ICA = 1, 3 TRANSA = ICH( ICA: ICA ) TRANA = TRANSA.EQ.'T'.OR.TRANSA.EQ.'C' * IF( TRANA )THEN MA = K NA = M ELSE MA = M NA = K END IF * Set LDA to 1 more than minimum value if room. LDA = MA IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 80 LAA = LDA*NA * * Generate the matrix A. * CALL DMAKE( 'GE', ' ', ' ', MA, NA, A, NMAX, AA, LDA, $ RESET, ZERO ) * DO 70 ICB = 1, 3 TRANSB = ICH( ICB: ICB ) TRANB = TRANSB.EQ.'T'.OR.TRANSB.EQ.'C' * IF( TRANB )THEN MB = N NB = K ELSE MB = K NB = N END IF * Set LDB to 1 more than minimum value if room. LDB = MB IF( LDB.LT.NMAX ) $ LDB = LDB + 1 * Skip tests if not enough room. IF( LDB.GT.NMAX ) $ GO TO 70 LBB = LDB*NB * * Generate the matrix B. * CALL DMAKE( 'GE', ' ', ' ', MB, NB, B, NMAX, BB, $ LDB, RESET, ZERO ) * DO 60 IA = 1, NALF ALPHA = ALF( IA ) * DO 50 IB = 1, NBET BETA = BET( IB ) * * Generate the matrix C. * CALL DMAKE( 'GE', ' ', ' ', M, N, C, NMAX, $ CC, LDC, RESET, ZERO ) * NC = NC + 1 * * Save every datum before calling the * subroutine. * TRANAS = TRANSA TRANBS = TRANSB MS = M NS = N KS = K ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LBB BS( I ) = BB( I ) 20 CONTINUE LDBS = LDB BLS = BETA DO 30 I = 1, LCC CS( I ) = CC( I ) 30 CONTINUE LDCS = LDC * * Call the subroutine. * IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ TRANSA, TRANSB, M, N, K, ALPHA, LDA, LDB, $ BETA, LDC IF( REWI ) $ REWIND NTRA CALL DGEMM( TRANSA, TRANSB, M, N, K, ALPHA, $ AA, LDA, BB, LDB, BETA, CC, LDC ) * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9994 ) FATAL = .TRUE. GO TO 120 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = TRANSA.EQ.TRANAS ISAME( 2 ) = TRANSB.EQ.TRANBS ISAME( 3 ) = MS.EQ.M ISAME( 4 ) = NS.EQ.N ISAME( 5 ) = KS.EQ.K ISAME( 6 ) = ALS.EQ.ALPHA ISAME( 7 ) = LDE( AS, AA, LAA ) ISAME( 8 ) = LDAS.EQ.LDA ISAME( 9 ) = LDE( BS, BB, LBB ) ISAME( 10 ) = LDBS.EQ.LDB ISAME( 11 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 12 ) = LDE( CS, CC, LCC ) ELSE ISAME( 12 ) = LDERES( 'GE', ' ', M, N, CS, $ CC, LDC ) END IF ISAME( 13 ) = LDCS.EQ.LDC * * If data was incorrectly changed, report * and return. * SAME = .TRUE. DO 40 I = 1, NARGS SAME = SAME.AND.ISAME( I ) IF( .NOT.ISAME( I ) ) $ WRITE( NOUT, FMT = 9998 )I 40 CONTINUE IF( .NOT.SAME )THEN FATAL = .TRUE. GO TO 120 END IF * IF( .NOT.NULL )THEN * * Check the result. * CALL DMMCH( TRANSA, TRANSB, M, N, K, $ ALPHA, A, NMAX, B, NMAX, BETA, $ C, NMAX, CT, G, CC, LDC, EPS, $ ERR, FATAL, NOUT, .TRUE. ) ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 120 END IF * 50 CONTINUE * 60 CONTINUE * 70 CONTINUE * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * 110 CONTINUE * * Report result. * IF( ERRMAX.LT.THRESH )THEN WRITE( NOUT, FMT = 9999 )SNAME, NC ELSE WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX END IF GO TO 130 * 120 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME WRITE( NOUT, FMT = 9995 )NC, SNAME, TRANSA, TRANSB, M, N, K, $ ALPHA, LDA, LDB, BETA, LDC * 130 CONTINUE RETURN * 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL', $ 'S)' ) 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH', $ 'ANGED INCORRECTLY *******' ) 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C', $ 'ALLS)', /' ******* BUT WITH MAXIMUM TEST RATIO', F8.2, $ ' - SUSPECT *******' ) 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' ) 9995 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',''', A1, ''',', $ 3( I3, ',' ), F4.1, ', A,', I3, ', B,', I3, ',', F4.1, ', ', $ 'C,', I3, ').' ) 9994 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of DCHK1. * END SUBROUTINE DCHK2( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, NMAX, $ A, AA, AS, B, BB, BS, C, CC, CS, CT, G ) * * Tests DSYMM. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D0 ) * .. Scalar Arguments .. DOUBLE PRECISION EPS, THRESH INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. DOUBLE PRECISION A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), B( NMAX, NMAX ), $ BB( NMAX*NMAX ), BET( NBET ), BS( NMAX*NMAX ), $ C( NMAX, NMAX ), CC( NMAX*NMAX ), $ CS( NMAX*NMAX ), CT( NMAX ), G( NMAX ) INTEGER IDIM( NIDIM ) * .. Local Scalars .. DOUBLE PRECISION ALPHA, ALS, BETA, BLS, ERR, ERRMAX INTEGER I, IA, IB, ICS, ICU, IM, IN, LAA, LBB, LCC, $ LDA, LDAS, LDB, LDBS, LDC, LDCS, M, MS, N, NA, $ NARGS, NC, NS LOGICAL LEFT, NULL, RESET, SAME CHARACTER*1 SIDE, SIDES, UPLO, UPLOS CHARACTER*2 ICHS, ICHU * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LDE, LDERES EXTERNAL LDE, LDERES * .. External Subroutines .. EXTERNAL DMAKE, DMMCH, DSYMM * .. Intrinsic Functions .. INTRINSIC MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICHS/'LR'/, ICHU/'UL'/ * .. Executable Statements .. * NARGS = 12 NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 100 IM = 1, NIDIM M = IDIM( IM ) * DO 90 IN = 1, NIDIM N = IDIM( IN ) * Set LDC to 1 more than minimum value if room. LDC = M IF( LDC.LT.NMAX ) $ LDC = LDC + 1 * Skip tests if not enough room. IF( LDC.GT.NMAX ) $ GO TO 90 LCC = LDC*N NULL = N.LE.0.OR.M.LE.0 * * Set LDB to 1 more than minimum value if room. LDB = M IF( LDB.LT.NMAX ) $ LDB = LDB + 1 * Skip tests if not enough room. IF( LDB.GT.NMAX ) $ GO TO 90 LBB = LDB*N * * Generate the matrix B. * CALL DMAKE( 'GE', ' ', ' ', M, N, B, NMAX, BB, LDB, RESET, $ ZERO ) * DO 80 ICS = 1, 2 SIDE = ICHS( ICS: ICS ) LEFT = SIDE.EQ.'L' * IF( LEFT )THEN NA = M ELSE NA = N END IF * Set LDA to 1 more than minimum value if room. LDA = NA IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 80 LAA = LDA*NA * DO 70 ICU = 1, 2 UPLO = ICHU( ICU: ICU ) * * Generate the symmetric matrix A. * CALL DMAKE( 'SY', UPLO, ' ', NA, NA, A, NMAX, AA, LDA, $ RESET, ZERO ) * DO 60 IA = 1, NALF ALPHA = ALF( IA ) * DO 50 IB = 1, NBET BETA = BET( IB ) * * Generate the matrix C. * CALL DMAKE( 'GE', ' ', ' ', M, N, C, NMAX, CC, $ LDC, RESET, ZERO ) * NC = NC + 1 * * Save every datum before calling the * subroutine. * SIDES = SIDE UPLOS = UPLO MS = M NS = N ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LBB BS( I ) = BB( I ) 20 CONTINUE LDBS = LDB BLS = BETA DO 30 I = 1, LCC CS( I ) = CC( I ) 30 CONTINUE LDCS = LDC * * Call the subroutine. * IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, SIDE, $ UPLO, M, N, ALPHA, LDA, LDB, BETA, LDC IF( REWI ) $ REWIND NTRA CALL DSYMM( SIDE, UPLO, M, N, ALPHA, AA, LDA, $ BB, LDB, BETA, CC, LDC ) * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9994 ) FATAL = .TRUE. GO TO 110 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = SIDES.EQ.SIDE ISAME( 2 ) = UPLOS.EQ.UPLO ISAME( 3 ) = MS.EQ.M ISAME( 4 ) = NS.EQ.N ISAME( 5 ) = ALS.EQ.ALPHA ISAME( 6 ) = LDE( AS, AA, LAA ) ISAME( 7 ) = LDAS.EQ.LDA ISAME( 8 ) = LDE( BS, BB, LBB ) ISAME( 9 ) = LDBS.EQ.LDB ISAME( 10 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 11 ) = LDE( CS, CC, LCC ) ELSE ISAME( 11 ) = LDERES( 'GE', ' ', M, N, CS, $ CC, LDC ) END IF ISAME( 12 ) = LDCS.EQ.LDC * * If data was incorrectly changed, report and * return. * SAME = .TRUE. DO 40 I = 1, NARGS SAME = SAME.AND.ISAME( I ) IF( .NOT.ISAME( I ) ) $ WRITE( NOUT, FMT = 9998 )I 40 CONTINUE IF( .NOT.SAME )THEN FATAL = .TRUE. GO TO 110 END IF * IF( .NOT.NULL )THEN * * Check the result. * IF( LEFT )THEN CALL DMMCH( 'N', 'N', M, N, M, ALPHA, A, $ NMAX, B, NMAX, BETA, C, NMAX, $ CT, G, CC, LDC, EPS, ERR, $ FATAL, NOUT, .TRUE. ) ELSE CALL DMMCH( 'N', 'N', M, N, N, ALPHA, B, $ NMAX, A, NMAX, BETA, C, NMAX, $ CT, G, CC, LDC, EPS, ERR, $ FATAL, NOUT, .TRUE. ) END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 110 END IF * 50 CONTINUE * 60 CONTINUE * 70 CONTINUE * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * * Report result. * IF( ERRMAX.LT.THRESH )THEN WRITE( NOUT, FMT = 9999 )SNAME, NC ELSE WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX END IF GO TO 120 * 110 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME WRITE( NOUT, FMT = 9995 )NC, SNAME, SIDE, UPLO, M, N, ALPHA, LDA, $ LDB, BETA, LDC * 120 CONTINUE RETURN * 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL', $ 'S)' ) 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH', $ 'ANGED INCORRECTLY *******' ) 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C', $ 'ALLS)', /' ******* BUT WITH MAXIMUM TEST RATIO', F8.2, $ ' - SUSPECT *******' ) 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' ) 9995 FORMAT( 1X, I6, ': ', A6, '(', 2( '''', A1, ''',' ), 2( I3, ',' ), $ F4.1, ', A,', I3, ', B,', I3, ',', F4.1, ', C,', I3, ') ', $ ' .' ) 9994 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of DCHK2. * END SUBROUTINE DCHK3( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NMAX, A, AA, AS, $ B, BB, BS, CT, G, C ) * * Tests DTRMM and DTRSM. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) * .. Scalar Arguments .. DOUBLE PRECISION EPS, THRESH INTEGER NALF, NIDIM, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. DOUBLE PRECISION A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), B( NMAX, NMAX ), $ BB( NMAX*NMAX ), BS( NMAX*NMAX ), $ C( NMAX, NMAX ), CT( NMAX ), G( NMAX ) INTEGER IDIM( NIDIM ) * .. Local Scalars .. DOUBLE PRECISION ALPHA, ALS, ERR, ERRMAX INTEGER I, IA, ICD, ICS, ICT, ICU, IM, IN, J, LAA, LBB, $ LDA, LDAS, LDB, LDBS, M, MS, N, NA, NARGS, NC, $ NS LOGICAL LEFT, NULL, RESET, SAME CHARACTER*1 DIAG, DIAGS, SIDE, SIDES, TRANAS, TRANSA, UPLO, $ UPLOS CHARACTER*2 ICHD, ICHS, ICHU CHARACTER*3 ICHT * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LDE, LDERES EXTERNAL LDE, LDERES * .. External Subroutines .. EXTERNAL DMAKE, DMMCH, DTRMM, DTRSM * .. Intrinsic Functions .. INTRINSIC MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICHU/'UL'/, ICHT/'NTC'/, ICHD/'UN'/, ICHS/'LR'/ * .. Executable Statements .. * NARGS = 11 NC = 0 RESET = .TRUE. ERRMAX = ZERO * Set up zero matrix for DMMCH. DO 20 J = 1, NMAX DO 10 I = 1, NMAX C( I, J ) = ZERO 10 CONTINUE 20 CONTINUE * DO 140 IM = 1, NIDIM M = IDIM( IM ) * DO 130 IN = 1, NIDIM N = IDIM( IN ) * Set LDB to 1 more than minimum value if room. LDB = M IF( LDB.LT.NMAX ) $ LDB = LDB + 1 * Skip tests if not enough room. IF( LDB.GT.NMAX ) $ GO TO 130 LBB = LDB*N NULL = M.LE.0.OR.N.LE.0 * DO 120 ICS = 1, 2 SIDE = ICHS( ICS: ICS ) LEFT = SIDE.EQ.'L' IF( LEFT )THEN NA = M ELSE NA = N END IF * Set LDA to 1 more than minimum value if room. LDA = NA IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 130 LAA = LDA*NA * DO 110 ICU = 1, 2 UPLO = ICHU( ICU: ICU ) * DO 100 ICT = 1, 3 TRANSA = ICHT( ICT: ICT ) * DO 90 ICD = 1, 2 DIAG = ICHD( ICD: ICD ) * DO 80 IA = 1, NALF ALPHA = ALF( IA ) * * Generate the matrix A. * CALL DMAKE( 'TR', UPLO, DIAG, NA, NA, A, $ NMAX, AA, LDA, RESET, ZERO ) * * Generate the matrix B. * CALL DMAKE( 'GE', ' ', ' ', M, N, B, NMAX, $ BB, LDB, RESET, ZERO ) * NC = NC + 1 * * Save every datum before calling the * subroutine. * SIDES = SIDE UPLOS = UPLO TRANAS = TRANSA DIAGS = DIAG MS = M NS = N ALS = ALPHA DO 30 I = 1, LAA AS( I ) = AA( I ) 30 CONTINUE LDAS = LDA DO 40 I = 1, LBB BS( I ) = BB( I ) 40 CONTINUE LDBS = LDB * * Call the subroutine. * IF( SNAME( 4: 5 ).EQ.'MM' )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, $ LDA, LDB IF( REWI ) $ REWIND NTRA CALL DTRMM( SIDE, UPLO, TRANSA, DIAG, M, $ N, ALPHA, AA, LDA, BB, LDB ) ELSE IF( SNAME( 4: 5 ).EQ.'SM' )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, $ LDA, LDB IF( REWI ) $ REWIND NTRA CALL DTRSM( SIDE, UPLO, TRANSA, DIAG, M, $ N, ALPHA, AA, LDA, BB, LDB ) END IF * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9994 ) FATAL = .TRUE. GO TO 150 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = SIDES.EQ.SIDE ISAME( 2 ) = UPLOS.EQ.UPLO ISAME( 3 ) = TRANAS.EQ.TRANSA ISAME( 4 ) = DIAGS.EQ.DIAG ISAME( 5 ) = MS.EQ.M ISAME( 6 ) = NS.EQ.N ISAME( 7 ) = ALS.EQ.ALPHA ISAME( 8 ) = LDE( AS, AA, LAA ) ISAME( 9 ) = LDAS.EQ.LDA IF( NULL )THEN ISAME( 10 ) = LDE( BS, BB, LBB ) ELSE ISAME( 10 ) = LDERES( 'GE', ' ', M, N, BS, $ BB, LDB ) END IF ISAME( 11 ) = LDBS.EQ.LDB * * If data was incorrectly changed, report and * return. * SAME = .TRUE. DO 50 I = 1, NARGS SAME = SAME.AND.ISAME( I ) IF( .NOT.ISAME( I ) ) $ WRITE( NOUT, FMT = 9998 )I 50 CONTINUE IF( .NOT.SAME )THEN FATAL = .TRUE. GO TO 150 END IF * IF( .NOT.NULL )THEN IF( SNAME( 4: 5 ).EQ.'MM' )THEN * * Check the result. * IF( LEFT )THEN CALL DMMCH( TRANSA, 'N', M, N, M, $ ALPHA, A, NMAX, B, NMAX, $ ZERO, C, NMAX, CT, G, $ BB, LDB, EPS, ERR, $ FATAL, NOUT, .TRUE. ) ELSE CALL DMMCH( 'N', TRANSA, M, N, N, $ ALPHA, B, NMAX, A, NMAX, $ ZERO, C, NMAX, CT, G, $ BB, LDB, EPS, ERR, $ FATAL, NOUT, .TRUE. ) END IF ELSE IF( SNAME( 4: 5 ).EQ.'SM' )THEN * * Compute approximation to original * matrix. * DO 70 J = 1, N DO 60 I = 1, M C( I, J ) = BB( I + ( J - 1 )* $ LDB ) BB( I + ( J - 1 )*LDB ) = ALPHA* $ B( I, J ) 60 CONTINUE 70 CONTINUE * IF( LEFT )THEN CALL DMMCH( TRANSA, 'N', M, N, M, $ ONE, A, NMAX, C, NMAX, $ ZERO, B, NMAX, CT, G, $ BB, LDB, EPS, ERR, $ FATAL, NOUT, .FALSE. ) ELSE CALL DMMCH( 'N', TRANSA, M, N, N, $ ONE, C, NMAX, A, NMAX, $ ZERO, B, NMAX, CT, G, $ BB, LDB, EPS, ERR, $ FATAL, NOUT, .FALSE. ) END IF END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 150 END IF * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * 110 CONTINUE * 120 CONTINUE * 130 CONTINUE * 140 CONTINUE * * Report result. * IF( ERRMAX.LT.THRESH )THEN WRITE( NOUT, FMT = 9999 )SNAME, NC ELSE WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX END IF GO TO 160 * 150 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME WRITE( NOUT, FMT = 9995 )NC, SNAME, SIDE, UPLO, TRANSA, DIAG, M, $ N, ALPHA, LDA, LDB * 160 CONTINUE RETURN * 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL', $ 'S)' ) 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH', $ 'ANGED INCORRECTLY *******' ) 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C', $ 'ALLS)', /' ******* BUT WITH MAXIMUM TEST RATIO', F8.2, $ ' - SUSPECT *******' ) 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' ) 9995 FORMAT( 1X, I6, ': ', A6, '(', 4( '''', A1, ''',' ), 2( I3, ',' ), $ F4.1, ', A,', I3, ', B,', I3, ') .' ) 9994 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of DCHK3. * END SUBROUTINE DCHK4( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, NMAX, $ A, AA, AS, B, BB, BS, C, CC, CS, CT, G ) * * Tests DSYRK. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D0 ) * .. Scalar Arguments .. DOUBLE PRECISION EPS, THRESH INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. DOUBLE PRECISION A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), B( NMAX, NMAX ), $ BB( NMAX*NMAX ), BET( NBET ), BS( NMAX*NMAX ), $ C( NMAX, NMAX ), CC( NMAX*NMAX ), $ CS( NMAX*NMAX ), CT( NMAX ), G( NMAX ) INTEGER IDIM( NIDIM ) * .. Local Scalars .. DOUBLE PRECISION ALPHA, ALS, BETA, BETS, ERR, ERRMAX INTEGER I, IA, IB, ICT, ICU, IK, IN, J, JC, JJ, K, KS, $ LAA, LCC, LDA, LDAS, LDC, LDCS, LJ, MA, N, NA, $ NARGS, NC, NS LOGICAL NULL, RESET, SAME, TRAN, UPPER CHARACTER*1 TRANS, TRANSS, UPLO, UPLOS CHARACTER*2 ICHU CHARACTER*3 ICHT * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LDE, LDERES EXTERNAL LDE, LDERES * .. External Subroutines .. EXTERNAL DMAKE, DMMCH, DSYRK * .. Intrinsic Functions .. INTRINSIC MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICHT/'NTC'/, ICHU/'UL'/ * .. Executable Statements .. * NARGS = 10 NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 100 IN = 1, NIDIM N = IDIM( IN ) * Set LDC to 1 more than minimum value if room. LDC = N IF( LDC.LT.NMAX ) $ LDC = LDC + 1 * Skip tests if not enough room. IF( LDC.GT.NMAX ) $ GO TO 100 LCC = LDC*N NULL = N.LE.0 * DO 90 IK = 1, NIDIM K = IDIM( IK ) * DO 80 ICT = 1, 3 TRANS = ICHT( ICT: ICT ) TRAN = TRANS.EQ.'T'.OR.TRANS.EQ.'C' IF( TRAN )THEN MA = K NA = N ELSE MA = N NA = K END IF * Set LDA to 1 more than minimum value if room. LDA = MA IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 80 LAA = LDA*NA * * Generate the matrix A. * CALL DMAKE( 'GE', ' ', ' ', MA, NA, A, NMAX, AA, LDA, $ RESET, ZERO ) * DO 70 ICU = 1, 2 UPLO = ICHU( ICU: ICU ) UPPER = UPLO.EQ.'U' * DO 60 IA = 1, NALF ALPHA = ALF( IA ) * DO 50 IB = 1, NBET BETA = BET( IB ) * * Generate the matrix C. * CALL DMAKE( 'SY', UPLO, ' ', N, N, C, NMAX, CC, $ LDC, RESET, ZERO ) * NC = NC + 1 * * Save every datum before calling the subroutine. * UPLOS = UPLO TRANSS = TRANS NS = N KS = K ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA BETS = BETA DO 20 I = 1, LCC CS( I ) = CC( I ) 20 CONTINUE LDCS = LDC * * Call the subroutine. * IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, UPLO, $ TRANS, N, K, ALPHA, LDA, BETA, LDC IF( REWI ) $ REWIND NTRA CALL DSYRK( UPLO, TRANS, N, K, ALPHA, AA, LDA, $ BETA, CC, LDC ) * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9993 ) FATAL = .TRUE. GO TO 120 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = UPLOS.EQ.UPLO ISAME( 2 ) = TRANSS.EQ.TRANS ISAME( 3 ) = NS.EQ.N ISAME( 4 ) = KS.EQ.K ISAME( 5 ) = ALS.EQ.ALPHA ISAME( 6 ) = LDE( AS, AA, LAA ) ISAME( 7 ) = LDAS.EQ.LDA ISAME( 8 ) = BETS.EQ.BETA IF( NULL )THEN ISAME( 9 ) = LDE( CS, CC, LCC ) ELSE ISAME( 9 ) = LDERES( 'SY', UPLO, N, N, CS, $ CC, LDC ) END IF ISAME( 10 ) = LDCS.EQ.LDC * * If data was incorrectly changed, report and * return. * SAME = .TRUE. DO 30 I = 1, NARGS SAME = SAME.AND.ISAME( I ) IF( .NOT.ISAME( I ) ) $ WRITE( NOUT, FMT = 9998 )I 30 CONTINUE IF( .NOT.SAME )THEN FATAL = .TRUE. GO TO 120 END IF * IF( .NOT.NULL )THEN * * Check the result column by column. * JC = 1 DO 40 J = 1, N IF( UPPER )THEN JJ = 1 LJ = J ELSE JJ = J LJ = N - J + 1 END IF IF( TRAN )THEN CALL DMMCH( 'T', 'N', LJ, 1, K, ALPHA, $ A( 1, JJ ), NMAX, $ A( 1, J ), NMAX, BETA, $ C( JJ, J ), NMAX, CT, G, $ CC( JC ), LDC, EPS, ERR, $ FATAL, NOUT, .TRUE. ) ELSE CALL DMMCH( 'N', 'T', LJ, 1, K, ALPHA, $ A( JJ, 1 ), NMAX, $ A( J, 1 ), NMAX, BETA, $ C( JJ, J ), NMAX, CT, G, $ CC( JC ), LDC, EPS, ERR, $ FATAL, NOUT, .TRUE. ) END IF IF( UPPER )THEN JC = JC + LDC ELSE JC = JC + LDC + 1 END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 110 40 CONTINUE END IF * 50 CONTINUE * 60 CONTINUE * 70 CONTINUE * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * * Report result. * IF( ERRMAX.LT.THRESH )THEN WRITE( NOUT, FMT = 9999 )SNAME, NC ELSE WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX END IF GO TO 130 * 110 CONTINUE IF( N.GT.1 ) $ WRITE( NOUT, FMT = 9995 )J * 120 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, TRANS, N, K, ALPHA, $ LDA, BETA, LDC * 130 CONTINUE RETURN * 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL', $ 'S)' ) 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH', $ 'ANGED INCORRECTLY *******' ) 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C', $ 'ALLS)', /' ******* BUT WITH MAXIMUM TEST RATIO', F8.2, $ ' - SUSPECT *******' ) 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' ) 9995 FORMAT( ' THESE ARE THE RESULTS FOR COLUMN ', I3 ) 9994 FORMAT( 1X, I6, ': ', A6, '(', 2( '''', A1, ''',' ), 2( I3, ',' ), $ F4.1, ', A,', I3, ',', F4.1, ', C,', I3, ') .' ) 9993 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of DCHK4. * END SUBROUTINE DCHK5( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NBET, BET, NMAX, $ AB, AA, AS, BB, BS, C, CC, CS, CT, G, W ) * * Tests DSYR2K. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D0 ) * .. Scalar Arguments .. DOUBLE PRECISION EPS, THRESH INTEGER NALF, NBET, NIDIM, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. DOUBLE PRECISION AA( NMAX*NMAX ), AB( 2*NMAX*NMAX ), $ ALF( NALF ), AS( NMAX*NMAX ), BB( NMAX*NMAX ), $ BET( NBET ), BS( NMAX*NMAX ), C( NMAX, NMAX ), $ CC( NMAX*NMAX ), CS( NMAX*NMAX ), CT( NMAX ), $ G( NMAX ), W( 2*NMAX ) INTEGER IDIM( NIDIM ) * .. Local Scalars .. DOUBLE PRECISION ALPHA, ALS, BETA, BETS, ERR, ERRMAX INTEGER I, IA, IB, ICT, ICU, IK, IN, J, JC, JJ, JJAB, $ K, KS, LAA, LBB, LCC, LDA, LDAS, LDB, LDBS, $ LDC, LDCS, LJ, MA, N, NA, NARGS, NC, NS LOGICAL NULL, RESET, SAME, TRAN, UPPER CHARACTER*1 TRANS, TRANSS, UPLO, UPLOS CHARACTER*2 ICHU CHARACTER*3 ICHT * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LDE, LDERES EXTERNAL LDE, LDERES * .. External Subroutines .. EXTERNAL DMAKE, DMMCH, DSYR2K * .. Intrinsic Functions .. INTRINSIC MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICHT/'NTC'/, ICHU/'UL'/ * .. Executable Statements .. * NARGS = 12 NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 130 IN = 1, NIDIM N = IDIM( IN ) * Set LDC to 1 more than minimum value if room. LDC = N IF( LDC.LT.NMAX ) $ LDC = LDC + 1 * Skip tests if not enough room. IF( LDC.GT.NMAX ) $ GO TO 130 LCC = LDC*N NULL = N.LE.0 * DO 120 IK = 1, NIDIM K = IDIM( IK ) * DO 110 ICT = 1, 3 TRANS = ICHT( ICT: ICT ) TRAN = TRANS.EQ.'T'.OR.TRANS.EQ.'C' IF( TRAN )THEN MA = K NA = N ELSE MA = N NA = K END IF * Set LDA to 1 more than minimum value if room. LDA = MA IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 110 LAA = LDA*NA * * Generate the matrix A. * IF( TRAN )THEN CALL DMAKE( 'GE', ' ', ' ', MA, NA, AB, 2*NMAX, AA, $ LDA, RESET, ZERO ) ELSE CALL DMAKE( 'GE', ' ', ' ', MA, NA, AB, NMAX, AA, LDA, $ RESET, ZERO ) END IF * * Generate the matrix B. * LDB = LDA LBB = LAA IF( TRAN )THEN CALL DMAKE( 'GE', ' ', ' ', MA, NA, AB( K + 1 ), $ 2*NMAX, BB, LDB, RESET, ZERO ) ELSE CALL DMAKE( 'GE', ' ', ' ', MA, NA, AB( K*NMAX + 1 ), $ NMAX, BB, LDB, RESET, ZERO ) END IF * DO 100 ICU = 1, 2 UPLO = ICHU( ICU: ICU ) UPPER = UPLO.EQ.'U' * DO 90 IA = 1, NALF ALPHA = ALF( IA ) * DO 80 IB = 1, NBET BETA = BET( IB ) * * Generate the matrix C. * CALL DMAKE( 'SY', UPLO, ' ', N, N, C, NMAX, CC, $ LDC, RESET, ZERO ) * NC = NC + 1 * * Save every datum before calling the subroutine. * UPLOS = UPLO TRANSS = TRANS NS = N KS = K ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LBB BS( I ) = BB( I ) 20 CONTINUE LDBS = LDB BETS = BETA DO 30 I = 1, LCC CS( I ) = CC( I ) 30 CONTINUE LDCS = LDC * * Call the subroutine. * IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, UPLO, $ TRANS, N, K, ALPHA, LDA, LDB, BETA, LDC IF( REWI ) $ REWIND NTRA CALL DSYR2K( UPLO, TRANS, N, K, ALPHA, AA, LDA, $ BB, LDB, BETA, CC, LDC ) * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9993 ) FATAL = .TRUE. GO TO 150 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = UPLOS.EQ.UPLO ISAME( 2 ) = TRANSS.EQ.TRANS ISAME( 3 ) = NS.EQ.N ISAME( 4 ) = KS.EQ.K ISAME( 5 ) = ALS.EQ.ALPHA ISAME( 6 ) = LDE( AS, AA, LAA ) ISAME( 7 ) = LDAS.EQ.LDA ISAME( 8 ) = LDE( BS, BB, LBB ) ISAME( 9 ) = LDBS.EQ.LDB ISAME( 10 ) = BETS.EQ.BETA IF( NULL )THEN ISAME( 11 ) = LDE( CS, CC, LCC ) ELSE ISAME( 11 ) = LDERES( 'SY', UPLO, N, N, CS, $ CC, LDC ) END IF ISAME( 12 ) = LDCS.EQ.LDC * * If data was incorrectly changed, report and * return. * SAME = .TRUE. DO 40 I = 1, NARGS SAME = SAME.AND.ISAME( I ) IF( .NOT.ISAME( I ) ) $ WRITE( NOUT, FMT = 9998 )I 40 CONTINUE IF( .NOT.SAME )THEN FATAL = .TRUE. GO TO 150 END IF * IF( .NOT.NULL )THEN * * Check the result column by column. * JJAB = 1 JC = 1 DO 70 J = 1, N IF( UPPER )THEN JJ = 1 LJ = J ELSE JJ = J LJ = N - J + 1 END IF IF( TRAN )THEN DO 50 I = 1, K W( I ) = AB( ( J - 1 )*2*NMAX + K + $ I ) W( K + I ) = AB( ( J - 1 )*2*NMAX + $ I ) 50 CONTINUE CALL DMMCH( 'T', 'N', LJ, 1, 2*K, $ ALPHA, AB( JJAB ), 2*NMAX, $ W, 2*NMAX, BETA, $ C( JJ, J ), NMAX, CT, G, $ CC( JC ), LDC, EPS, ERR, $ FATAL, NOUT, .TRUE. ) ELSE DO 60 I = 1, K W( I ) = AB( ( K + I - 1 )*NMAX + $ J ) W( K + I ) = AB( ( I - 1 )*NMAX + $ J ) 60 CONTINUE CALL DMMCH( 'N', 'N', LJ, 1, 2*K, $ ALPHA, AB( JJ ), NMAX, W, $ 2*NMAX, BETA, C( JJ, J ), $ NMAX, CT, G, CC( JC ), LDC, $ EPS, ERR, FATAL, NOUT, $ .TRUE. ) END IF IF( UPPER )THEN JC = JC + LDC ELSE JC = JC + LDC + 1 IF( TRAN ) $ JJAB = JJAB + 2*NMAX END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 140 70 CONTINUE END IF * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * 110 CONTINUE * 120 CONTINUE * 130 CONTINUE * * Report result. * IF( ERRMAX.LT.THRESH )THEN WRITE( NOUT, FMT = 9999 )SNAME, NC ELSE WRITE( NOUT, FMT = 9997 )SNAME, NC, ERRMAX END IF GO TO 160 * 140 CONTINUE IF( N.GT.1 ) $ WRITE( NOUT, FMT = 9995 )J * 150 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, TRANS, N, K, ALPHA, $ LDA, LDB, BETA, LDC * 160 CONTINUE RETURN * 9999 FORMAT( ' ', A6, ' PASSED THE COMPUTATIONAL TESTS (', I6, ' CALL', $ 'S)' ) 9998 FORMAT( ' ******* FATAL ERROR - PARAMETER NUMBER ', I2, ' WAS CH', $ 'ANGED INCORRECTLY *******' ) 9997 FORMAT( ' ', A6, ' COMPLETED THE COMPUTATIONAL TESTS (', I6, ' C', $ 'ALLS)', /' ******* BUT WITH MAXIMUM TEST RATIO', F8.2, $ ' - SUSPECT *******' ) 9996 FORMAT( ' ******* ', A6, ' FAILED ON CALL NUMBER:' ) 9995 FORMAT( ' THESE ARE THE RESULTS FOR COLUMN ', I3 ) 9994 FORMAT( 1X, I6, ': ', A6, '(', 2( '''', A1, ''',' ), 2( I3, ',' ), $ F4.1, ', A,', I3, ', B,', I3, ',', F4.1, ', C,', I3, ') ', $ ' .' ) 9993 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of DCHK5. * END SUBROUTINE DCHKE( ISNUM, SRNAMT, NOUT ) * * Tests the error exits from the Level 3 Blas. * Requires a special version of the error-handling routine XERBLA. * ALPHA, BETA, A, B and C should not need to be defined. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. INTEGER ISNUM, NOUT CHARACTER*6 SRNAMT * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Local Scalars .. DOUBLE PRECISION ALPHA, BETA * .. Local Arrays .. DOUBLE PRECISION A( 2, 1 ), B( 2, 1 ), C( 2, 1 ) * .. External Subroutines .. EXTERNAL CHKXER, DGEMM, DSYMM, DSYR2K, DSYRK, DTRMM, $ DTRSM * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Executable Statements .. * OK is set to .FALSE. by the special version of XERBLA or by CHKXER * if anything is wrong. OK = .TRUE. * LERR is set to .TRUE. by the special version of XERBLA each time * it is called, and is then tested and re-set by CHKXER. LERR = .FALSE. GO TO ( 10, 20, 30, 40, 50, 60 )ISNUM 10 INFOT = 1 CALL DGEMM( '/', 'N', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 1 CALL DGEMM( '/', 'T', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DGEMM( 'N', '/', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DGEMM( 'T', '/', 0, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DGEMM( 'N', 'N', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DGEMM( 'N', 'T', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DGEMM( 'T', 'N', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DGEMM( 'T', 'T', -1, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DGEMM( 'N', 'N', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DGEMM( 'N', 'T', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DGEMM( 'T', 'N', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DGEMM( 'T', 'T', 0, -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DGEMM( 'N', 'N', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DGEMM( 'N', 'T', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DGEMM( 'T', 'N', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DGEMM( 'T', 'T', 0, 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL DGEMM( 'N', 'N', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL DGEMM( 'N', 'T', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL DGEMM( 'T', 'N', 0, 0, 2, ALPHA, A, 1, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL DGEMM( 'T', 'T', 0, 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DGEMM( 'N', 'N', 0, 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DGEMM( 'T', 'N', 0, 0, 2, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DGEMM( 'N', 'T', 0, 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DGEMM( 'T', 'T', 0, 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 13 CALL DGEMM( 'N', 'N', 2, 0, 0, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 13 CALL DGEMM( 'N', 'T', 2, 0, 0, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 13 CALL DGEMM( 'T', 'N', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 13 CALL DGEMM( 'T', 'T', 2, 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 70 20 INFOT = 1 CALL DSYMM( '/', 'U', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DSYMM( 'L', '/', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYMM( 'L', 'U', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYMM( 'R', 'U', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYMM( 'L', 'L', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYMM( 'R', 'L', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYMM( 'L', 'U', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYMM( 'R', 'U', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYMM( 'L', 'L', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYMM( 'R', 'L', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYMM( 'L', 'U', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYMM( 'R', 'U', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYMM( 'L', 'L', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYMM( 'R', 'L', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYMM( 'L', 'U', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYMM( 'R', 'U', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYMM( 'L', 'L', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYMM( 'R', 'L', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYMM( 'L', 'U', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYMM( 'R', 'U', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYMM( 'L', 'L', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYMM( 'R', 'L', 2, 0, ALPHA, A, 1, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 70 30 INFOT = 1 CALL DTRMM( '/', 'U', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DTRMM( 'L', '/', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DTRMM( 'L', 'U', '/', 'N', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DTRMM( 'L', 'U', 'N', '/', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'L', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'L', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'R', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'R', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'L', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'L', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'R', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRMM( 'R', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'L', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'L', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'R', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'R', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'L', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'L', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'R', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRMM( 'R', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'R', 'U', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'R', 'U', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'R', 'L', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRMM( 'R', 'L', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'R', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'R', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'R', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRMM( 'R', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 70 40 INFOT = 1 CALL DTRSM( '/', 'U', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DTRSM( 'L', '/', 'N', 'N', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DTRSM( 'L', 'U', '/', 'N', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DTRSM( 'L', 'U', 'N', '/', 0, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'L', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'L', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'R', 'U', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'R', 'U', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'L', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'L', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'R', 'L', 'N', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL DTRSM( 'R', 'L', 'T', 'N', -1, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'L', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'L', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'R', 'U', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'R', 'U', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'L', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'L', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'R', 'L', 'N', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL DTRSM( 'R', 'L', 'T', 'N', 0, -1, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'R', 'U', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'R', 'U', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'R', 'L', 'N', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DTRSM( 'R', 'L', 'T', 'N', 0, 2, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'L', 'U', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'L', 'U', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'R', 'U', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'R', 'U', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'L', 'L', 'N', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'L', 'L', 'T', 'N', 2, 0, ALPHA, A, 2, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'R', 'L', 'N', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL DTRSM( 'R', 'L', 'T', 'N', 2, 0, ALPHA, A, 1, B, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 70 50 INFOT = 1 CALL DSYRK( '/', 'N', 0, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DSYRK( 'U', '/', 0, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYRK( 'U', 'N', -1, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYRK( 'U', 'T', -1, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYRK( 'L', 'N', -1, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYRK( 'L', 'T', -1, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYRK( 'U', 'N', 0, -1, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYRK( 'U', 'T', 0, -1, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYRK( 'L', 'N', 0, -1, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYRK( 'L', 'T', 0, -1, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYRK( 'U', 'N', 2, 0, ALPHA, A, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYRK( 'U', 'T', 0, 2, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYRK( 'L', 'N', 2, 0, ALPHA, A, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYRK( 'L', 'T', 0, 2, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DSYRK( 'U', 'N', 2, 0, ALPHA, A, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DSYRK( 'U', 'T', 2, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DSYRK( 'L', 'N', 2, 0, ALPHA, A, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL DSYRK( 'L', 'T', 2, 0, ALPHA, A, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 70 60 INFOT = 1 CALL DSYR2K( '/', 'N', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL DSYR2K( 'U', '/', 0, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYR2K( 'U', 'N', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYR2K( 'U', 'T', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYR2K( 'L', 'N', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL DSYR2K( 'L', 'T', -1, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYR2K( 'U', 'N', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYR2K( 'U', 'T', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYR2K( 'L', 'N', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL DSYR2K( 'L', 'T', 0, -1, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYR2K( 'U', 'N', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYR2K( 'U', 'T', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYR2K( 'L', 'N', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL DSYR2K( 'L', 'T', 0, 2, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYR2K( 'U', 'N', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYR2K( 'U', 'T', 0, 2, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYR2K( 'L', 'N', 2, 0, ALPHA, A, 2, B, 1, BETA, C, 2 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL DSYR2K( 'L', 'T', 0, 2, ALPHA, A, 2, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYR2K( 'U', 'N', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYR2K( 'U', 'T', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYR2K( 'L', 'N', 2, 0, ALPHA, A, 2, B, 2, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 12 CALL DSYR2K( 'L', 'T', 2, 0, ALPHA, A, 1, B, 1, BETA, C, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) * 70 IF( OK )THEN WRITE( NOUT, FMT = 9999 )SRNAMT ELSE WRITE( NOUT, FMT = 9998 )SRNAMT END IF RETURN * 9999 FORMAT( ' ', A6, ' PASSED THE TESTS OF ERROR-EXITS' ) 9998 FORMAT( ' ******* ', A6, ' FAILED THE TESTS OF ERROR-EXITS *****', $ '**' ) * * End of DCHKE. * END SUBROUTINE DMAKE( TYPE, UPLO, DIAG, M, N, A, NMAX, AA, LDA, RESET, $ TRANSL ) * * Generates values for an M by N matrix A. * Stores the values in the array AA in the data structure required * by the routine, with unwanted elements set to rogue value. * * TYPE is 'GE', 'SY' or 'TR'. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) DOUBLE PRECISION ROGUE PARAMETER ( ROGUE = -1.0D10 ) * .. Scalar Arguments .. DOUBLE PRECISION TRANSL INTEGER LDA, M, N, NMAX LOGICAL RESET CHARACTER*1 DIAG, UPLO CHARACTER*2 TYPE * .. Array Arguments .. DOUBLE PRECISION A( NMAX, * ), AA( * ) * .. Local Scalars .. INTEGER I, IBEG, IEND, J LOGICAL GEN, LOWER, SYM, TRI, UNIT, UPPER * .. External Functions .. DOUBLE PRECISION DBEG EXTERNAL DBEG * .. Executable Statements .. GEN = TYPE.EQ.'GE' SYM = TYPE.EQ.'SY' TRI = TYPE.EQ.'TR' UPPER = ( SYM.OR.TRI ).AND.UPLO.EQ.'U' LOWER = ( SYM.OR.TRI ).AND.UPLO.EQ.'L' UNIT = TRI.AND.DIAG.EQ.'U' * * Generate data in array A. * DO 20 J = 1, N DO 10 I = 1, M IF( GEN.OR.( UPPER.AND.I.LE.J ).OR.( LOWER.AND.I.GE.J ) ) $ THEN A( I, J ) = DBEG( RESET ) + TRANSL IF( I.NE.J )THEN * Set some elements to zero IF( N.GT.3.AND.J.EQ.N/2 ) $ A( I, J ) = ZERO IF( SYM )THEN A( J, I ) = A( I, J ) ELSE IF( TRI )THEN A( J, I ) = ZERO END IF END IF END IF 10 CONTINUE IF( TRI ) $ A( J, J ) = A( J, J ) + ONE IF( UNIT ) $ A( J, J ) = ONE 20 CONTINUE * * Store elements in array AS in data structure required by routine. * IF( TYPE.EQ.'GE' )THEN DO 50 J = 1, N DO 30 I = 1, M AA( I + ( J - 1 )*LDA ) = A( I, J ) 30 CONTINUE DO 40 I = M + 1, LDA AA( I + ( J - 1 )*LDA ) = ROGUE 40 CONTINUE 50 CONTINUE ELSE IF( TYPE.EQ.'SY'.OR.TYPE.EQ.'TR' )THEN DO 90 J = 1, N IF( UPPER )THEN IBEG = 1 IF( UNIT )THEN IEND = J - 1 ELSE IEND = J END IF ELSE IF( UNIT )THEN IBEG = J + 1 ELSE IBEG = J END IF IEND = N END IF DO 60 I = 1, IBEG - 1 AA( I + ( J - 1 )*LDA ) = ROGUE 60 CONTINUE DO 70 I = IBEG, IEND AA( I + ( J - 1 )*LDA ) = A( I, J ) 70 CONTINUE DO 80 I = IEND + 1, LDA AA( I + ( J - 1 )*LDA ) = ROGUE 80 CONTINUE 90 CONTINUE END IF RETURN * * End of DMAKE. * END SUBROUTINE DMMCH( TRANSA, TRANSB, M, N, KK, ALPHA, A, LDA, B, LDB, $ BETA, C, LDC, CT, G, CC, LDCC, EPS, ERR, FATAL, $ NOUT, MV ) * * Checks the results of the computational tests. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) * .. Scalar Arguments .. DOUBLE PRECISION ALPHA, BETA, EPS, ERR INTEGER KK, LDA, LDB, LDC, LDCC, M, N, NOUT LOGICAL FATAL, MV CHARACTER*1 TRANSA, TRANSB * .. Array Arguments .. DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ), $ CC( LDCC, * ), CT( * ), G( * ) * .. Local Scalars .. DOUBLE PRECISION ERRI INTEGER I, J, K LOGICAL TRANA, TRANB * .. Intrinsic Functions .. INTRINSIC ABS, MAX, SQRT * .. Executable Statements .. TRANA = TRANSA.EQ.'T'.OR.TRANSA.EQ.'C' TRANB = TRANSB.EQ.'T'.OR.TRANSB.EQ.'C' * * Compute expected result, one column at a time, in CT using data * in A, B and C. * Compute gauges in G. * DO 120 J = 1, N * DO 10 I = 1, M CT( I ) = ZERO G( I ) = ZERO 10 CONTINUE IF( .NOT.TRANA.AND..NOT.TRANB )THEN DO 30 K = 1, KK DO 20 I = 1, M CT( I ) = CT( I ) + A( I, K )*B( K, J ) G( I ) = G( I ) + ABS( A( I, K ) )*ABS( B( K, J ) ) 20 CONTINUE 30 CONTINUE ELSE IF( TRANA.AND..NOT.TRANB )THEN DO 50 K = 1, KK DO 40 I = 1, M CT( I ) = CT( I ) + A( K, I )*B( K, J ) G( I ) = G( I ) + ABS( A( K, I ) )*ABS( B( K, J ) ) 40 CONTINUE 50 CONTINUE ELSE IF( .NOT.TRANA.AND.TRANB )THEN DO 70 K = 1, KK DO 60 I = 1, M CT( I ) = CT( I ) + A( I, K )*B( J, K ) G( I ) = G( I ) + ABS( A( I, K ) )*ABS( B( J, K ) ) 60 CONTINUE 70 CONTINUE ELSE IF( TRANA.AND.TRANB )THEN DO 90 K = 1, KK DO 80 I = 1, M CT( I ) = CT( I ) + A( K, I )*B( J, K ) G( I ) = G( I ) + ABS( A( K, I ) )*ABS( B( J, K ) ) 80 CONTINUE 90 CONTINUE END IF DO 100 I = 1, M CT( I ) = ALPHA*CT( I ) + BETA*C( I, J ) G( I ) = ABS( ALPHA )*G( I ) + ABS( BETA )*ABS( C( I, J ) ) 100 CONTINUE * * Compute the error ratio for this result. * ERR = ZERO DO 110 I = 1, M ERRI = ABS( CT( I ) - CC( I, J ) )/EPS IF( G( I ).NE.ZERO ) $ ERRI = ERRI/G( I ) ERR = MAX( ERR, ERRI ) IF( ERR*SQRT( EPS ).GE.ONE ) $ GO TO 130 110 CONTINUE * 120 CONTINUE * * If the loop completes, all results are at least half accurate. GO TO 150 * * Report fatal error. * 130 FATAL = .TRUE. WRITE( NOUT, FMT = 9999 ) DO 140 I = 1, M IF( MV )THEN WRITE( NOUT, FMT = 9998 )I, CT( I ), CC( I, J ) ELSE WRITE( NOUT, FMT = 9998 )I, CC( I, J ), CT( I ) END IF 140 CONTINUE IF( N.GT.1 ) $ WRITE( NOUT, FMT = 9997 )J * 150 CONTINUE RETURN * 9999 FORMAT( ' ******* FATAL ERROR - COMPUTED RESULT IS LESS THAN HAL', $ 'F ACCURATE *******', /' EXPECTED RESULT COMPU', $ 'TED RESULT' ) 9998 FORMAT( 1X, I7, 2G18.6 ) 9997 FORMAT( ' THESE ARE THE RESULTS FOR COLUMN ', I3 ) * * End of DMMCH. * END LOGICAL FUNCTION LDE( RI, RJ, LR ) * * Tests if two arrays are identical. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. INTEGER LR * .. Array Arguments .. DOUBLE PRECISION RI( * ), RJ( * ) * .. Local Scalars .. INTEGER I * .. Executable Statements .. DO 10 I = 1, LR IF( RI( I ).NE.RJ( I ) ) $ GO TO 20 10 CONTINUE LDE = .TRUE. GO TO 30 20 CONTINUE LDE = .FALSE. 30 RETURN * * End of LDE. * END LOGICAL FUNCTION LDERES( TYPE, UPLO, M, N, AA, AS, LDA ) * * Tests if selected elements in two arrays are equal. * * TYPE is 'GE' or 'SY'. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. INTEGER LDA, M, N CHARACTER*1 UPLO CHARACTER*2 TYPE * .. Array Arguments .. DOUBLE PRECISION AA( LDA, * ), AS( LDA, * ) * .. Local Scalars .. INTEGER I, IBEG, IEND, J LOGICAL UPPER * .. Executable Statements .. UPPER = UPLO.EQ.'U' IF( TYPE.EQ.'GE' )THEN DO 20 J = 1, N DO 10 I = M + 1, LDA IF( AA( I, J ).NE.AS( I, J ) ) $ GO TO 70 10 CONTINUE 20 CONTINUE ELSE IF( TYPE.EQ.'SY' )THEN DO 50 J = 1, N IF( UPPER )THEN IBEG = 1 IEND = J ELSE IBEG = J IEND = N END IF DO 30 I = 1, IBEG - 1 IF( AA( I, J ).NE.AS( I, J ) ) $ GO TO 70 30 CONTINUE DO 40 I = IEND + 1, LDA IF( AA( I, J ).NE.AS( I, J ) ) $ GO TO 70 40 CONTINUE 50 CONTINUE END IF * 60 CONTINUE LDERES = .TRUE. GO TO 80 70 CONTINUE LDERES = .FALSE. 80 RETURN * * End of LDERES. * END DOUBLE PRECISION FUNCTION DBEG( RESET ) * * Generates random numbers uniformly distributed between -0.5 and 0.5. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. LOGICAL RESET * .. Local Scalars .. INTEGER I, IC, MI * .. Save statement .. SAVE I, IC, MI * .. Executable Statements .. IF( RESET )THEN * Initialize local variables. MI = 891 I = 7 IC = 0 RESET = .FALSE. END IF * * The sequence of values of I is bounded between 1 and 999. * If initial I = 1,2,3,6,7 or 9, the period will be 50. * If initial I = 4 or 8, the period will be 25. * If initial I = 5, the period will be 10. * IC is used to break up the period by skipping 1 value of I in 6. * IC = IC + 1 10 I = I*MI I = I - 1000*( I/1000 ) IF( IC.GE.5 )THEN IC = 0 GO TO 10 END IF DBEG = ( I - 500 )/1001.0D0 RETURN * * End of DBEG. * END DOUBLE PRECISION FUNCTION DDIFF( X, Y ) * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. DOUBLE PRECISION X, Y * .. Executable Statements .. DDIFF = X - Y RETURN * * End of DDIFF. * END SUBROUTINE CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) * * Tests whether XERBLA has detected an error when it should. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. INTEGER INFOT, NOUT LOGICAL LERR, OK CHARACTER*6 SRNAMT * .. Executable Statements .. IF( .NOT.LERR )THEN WRITE( NOUT, FMT = 9999 )INFOT, SRNAMT OK = .FALSE. END IF LERR = .FALSE. RETURN * 9999 FORMAT( ' ***** ILLEGAL VALUE OF PARAMETER NUMBER ', I2, ' NOT D', $ 'ETECTED BY ', A6, ' *****' ) * * End of CHKXER. * END SUBROUTINE XERBLA( SRNAME, INFO ) * * This is a special version of XERBLA to be used only as part of * the test program for testing error exits from the Level 3 BLAS * routines. * * XERBLA is an error handler for the Level 3 BLAS routines. * * It is called by the Level 3 BLAS routines if an input parameter is * invalid. * * Auxiliary routine for test program for Level 3 Blas. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * .. Scalar Arguments .. INTEGER INFO CHARACTER*6 SRNAME * .. Scalars in Common .. INTEGER INFOT, NOUT LOGICAL LERR, OK CHARACTER*6 SRNAMT * .. Common blocks .. COMMON /INFOC/INFOT, NOUT, OK, LERR COMMON /SRNAMC/SRNAMT * .. Executable Statements .. LERR = .TRUE. IF( INFO.NE.INFOT )THEN IF( INFOT.NE.0 )THEN WRITE( NOUT, FMT = 9999 )INFO, INFOT ELSE WRITE( NOUT, FMT = 9997 )INFO END IF OK = .FALSE. END IF IF( SRNAME.NE.SRNAMT )THEN WRITE( NOUT, FMT = 9998 )SRNAME, SRNAMT OK = .FALSE. END IF RETURN * 9999 FORMAT( ' ******* XERBLA WAS CALLED WITH INFO = ', I6, ' INSTEAD', $ ' OF ', I2, ' *******' ) 9998 FORMAT( ' ******* XERBLA WAS CALLED WITH SRNAME = ', A6, ' INSTE', $ 'AD OF ', A6, ' *******' ) 9997 FORMAT( ' ******* XERBLA WAS CALLED WITH INFO = ', I6, $ ' *******' ) * * End of XERBLA * END
mit
prool/ccx_prool
CalculiX/ccx_2.16/src/cident.f
1
1271
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! ! identifies the position id of px in an ordered array ! x of integers; ! ! id is such that x(id).le.px and x(id+1).gt.px ! subroutine cident(x,px,n,id) implicit none character*81 x,px integer n,id,n2,m dimension x(n) id=0 if(n.eq.0) return n2=n+1 do m=(n2+id)/2 if(px.ge.x(m)) then id=m else n2=m endif if((n2-id).eq.1) return enddo end
gpl-2.0
prool/ccx_prool
ARPACK_i8/BLAS/strsm.f
16
12281
SUBROUTINE STRSM ( SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, $ B, LDB ) * .. Scalar Arguments .. CHARACTER*1 SIDE, UPLO, TRANSA, DIAG INTEGER M, N, LDA, LDB REAL ALPHA * .. Array Arguments .. REAL A( LDA, * ), B( LDB, * ) * .. * * Purpose * ======= * * STRSM solves one of the matrix equations * * op( A )*X = alpha*B, or X*op( A ) = alpha*B, * * where alpha is a scalar, X and B are m by n matrices, A is a unit, or * non-unit, upper or lower triangular matrix and op( A ) is one of * * op( A ) = A or op( A ) = A'. * * The matrix X is overwritten on B. * * Parameters * ========== * * SIDE - CHARACTER*1. * On entry, SIDE specifies whether op( A ) appears on the left * or right of X as follows: * * SIDE = 'L' or 'l' op( A )*X = alpha*B. * * SIDE = 'R' or 'r' X*op( A ) = alpha*B. * * Unchanged on exit. * * UPLO - CHARACTER*1. * On entry, UPLO specifies whether the matrix A is an upper or * lower triangular matrix as follows: * * UPLO = 'U' or 'u' A is an upper triangular matrix. * * UPLO = 'L' or 'l' A is a lower triangular matrix. * * Unchanged on exit. * * TRANSA - CHARACTER*1. * On entry, TRANSA specifies the form of op( A ) to be used in * the matrix multiplication as follows: * * TRANSA = 'N' or 'n' op( A ) = A. * * TRANSA = 'T' or 't' op( A ) = A'. * * TRANSA = 'C' or 'c' op( A ) = A'. * * Unchanged on exit. * * DIAG - CHARACTER*1. * On entry, DIAG specifies whether or not A is unit triangular * as follows: * * DIAG = 'U' or 'u' A is assumed to be unit triangular. * * DIAG = 'N' or 'n' A is not assumed to be unit * triangular. * * Unchanged on exit. * * M - INTEGER. * On entry, M specifies the number of rows of B. M must be at * least zero. * Unchanged on exit. * * N - INTEGER. * On entry, N specifies the number of columns of B. N must be * at least zero. * Unchanged on exit. * * ALPHA - REAL . * On entry, ALPHA specifies the scalar alpha. When alpha is * zero then A is not referenced and B need not be set before * entry. * Unchanged on exit. * * A - REAL array of DIMENSION ( LDA, k ), where k is m * when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'. * Before entry with UPLO = 'U' or 'u', the leading k by k * upper triangular part of the array A must contain the upper * triangular matrix and the strictly lower triangular part of * A is not referenced. * Before entry with UPLO = 'L' or 'l', the leading k by k * lower triangular part of the array A must contain the lower * triangular matrix and the strictly upper triangular part of * A is not referenced. * Note that when DIAG = 'U' or 'u', the diagonal elements of * A are not referenced either, but are assumed to be unity. * Unchanged on exit. * * LDA - INTEGER. * On entry, LDA specifies the first dimension of A as declared * in the calling (sub) program. When SIDE = 'L' or 'l' then * LDA must be at least max( 1, m ), when SIDE = 'R' or 'r' * then LDA must be at least max( 1, n ). * Unchanged on exit. * * B - REAL array of DIMENSION ( LDB, n ). * Before entry, the leading m by n part of the array B must * contain the right-hand side matrix B, and on exit is * overwritten by the solution matrix X. * * LDB - INTEGER. * On entry, LDB specifies the first dimension of B as declared * in the calling (sub) program. LDB must be at least * max( 1, m ). * Unchanged on exit. * * * Level 3 Blas routine. * * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. External Subroutines .. EXTERNAL XERBLA * .. Intrinsic Functions .. INTRINSIC MAX * .. Local Scalars .. LOGICAL LSIDE, NOUNIT, UPPER INTEGER I, INFO, J, K, NROWA REAL TEMP * .. Parameters .. REAL ONE , ZERO PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) * .. * .. Executable Statements .. * * Test the input parameters. * LSIDE = LSAME( SIDE , 'L' ) IF( LSIDE )THEN NROWA = M ELSE NROWA = N END IF NOUNIT = LSAME( DIAG , 'N' ) UPPER = LSAME( UPLO , 'U' ) * INFO = 0 IF( ( .NOT.LSIDE ).AND. $ ( .NOT.LSAME( SIDE , 'R' ) ) )THEN INFO = 1 ELSE IF( ( .NOT.UPPER ).AND. $ ( .NOT.LSAME( UPLO , 'L' ) ) )THEN INFO = 2 ELSE IF( ( .NOT.LSAME( TRANSA, 'N' ) ).AND. $ ( .NOT.LSAME( TRANSA, 'T' ) ).AND. $ ( .NOT.LSAME( TRANSA, 'C' ) ) )THEN INFO = 3 ELSE IF( ( .NOT.LSAME( DIAG , 'U' ) ).AND. $ ( .NOT.LSAME( DIAG , 'N' ) ) )THEN INFO = 4 ELSE IF( M .LT.0 )THEN INFO = 5 ELSE IF( N .LT.0 )THEN INFO = 6 ELSE IF( LDA.LT.MAX( 1, NROWA ) )THEN INFO = 9 ELSE IF( LDB.LT.MAX( 1, M ) )THEN INFO = 11 END IF IF( INFO.NE.0 )THEN CALL XERBLA( 'STRSM ', INFO ) RETURN END IF * * Quick return if possible. * IF( N.EQ.0 ) $ RETURN * * And when alpha.eq.zero. * IF( ALPHA.EQ.ZERO )THEN DO 20, J = 1, N DO 10, I = 1, M B( I, J ) = ZERO 10 CONTINUE 20 CONTINUE RETURN END IF * * Start the operations. * IF( LSIDE )THEN IF( LSAME( TRANSA, 'N' ) )THEN * * Form B := alpha*inv( A )*B. * IF( UPPER )THEN DO 60, J = 1, N IF( ALPHA.NE.ONE )THEN DO 30, I = 1, M B( I, J ) = ALPHA*B( I, J ) 30 CONTINUE END IF DO 50, K = M, 1, -1 IF( B( K, J ).NE.ZERO )THEN IF( NOUNIT ) $ B( K, J ) = B( K, J )/A( K, K ) DO 40, I = 1, K - 1 B( I, J ) = B( I, J ) - B( K, J )*A( I, K ) 40 CONTINUE END IF 50 CONTINUE 60 CONTINUE ELSE DO 100, J = 1, N IF( ALPHA.NE.ONE )THEN DO 70, I = 1, M B( I, J ) = ALPHA*B( I, J ) 70 CONTINUE END IF DO 90 K = 1, M IF( B( K, J ).NE.ZERO )THEN IF( NOUNIT ) $ B( K, J ) = B( K, J )/A( K, K ) DO 80, I = K + 1, M B( I, J ) = B( I, J ) - B( K, J )*A( I, K ) 80 CONTINUE END IF 90 CONTINUE 100 CONTINUE END IF ELSE * * Form B := alpha*inv( A' )*B. * IF( UPPER )THEN DO 130, J = 1, N DO 120, I = 1, M TEMP = ALPHA*B( I, J ) DO 110, K = 1, I - 1 TEMP = TEMP - A( K, I )*B( K, J ) 110 CONTINUE IF( NOUNIT ) $ TEMP = TEMP/A( I, I ) B( I, J ) = TEMP 120 CONTINUE 130 CONTINUE ELSE DO 160, J = 1, N DO 150, I = M, 1, -1 TEMP = ALPHA*B( I, J ) DO 140, K = I + 1, M TEMP = TEMP - A( K, I )*B( K, J ) 140 CONTINUE IF( NOUNIT ) $ TEMP = TEMP/A( I, I ) B( I, J ) = TEMP 150 CONTINUE 160 CONTINUE END IF END IF ELSE IF( LSAME( TRANSA, 'N' ) )THEN * * Form B := alpha*B*inv( A ). * IF( UPPER )THEN DO 210, J = 1, N IF( ALPHA.NE.ONE )THEN DO 170, I = 1, M B( I, J ) = ALPHA*B( I, J ) 170 CONTINUE END IF DO 190, K = 1, J - 1 IF( A( K, J ).NE.ZERO )THEN DO 180, I = 1, M B( I, J ) = B( I, J ) - A( K, J )*B( I, K ) 180 CONTINUE END IF 190 CONTINUE IF( NOUNIT )THEN TEMP = ONE/A( J, J ) DO 200, I = 1, M B( I, J ) = TEMP*B( I, J ) 200 CONTINUE END IF 210 CONTINUE ELSE DO 260, J = N, 1, -1 IF( ALPHA.NE.ONE )THEN DO 220, I = 1, M B( I, J ) = ALPHA*B( I, J ) 220 CONTINUE END IF DO 240, K = J + 1, N IF( A( K, J ).NE.ZERO )THEN DO 230, I = 1, M B( I, J ) = B( I, J ) - A( K, J )*B( I, K ) 230 CONTINUE END IF 240 CONTINUE IF( NOUNIT )THEN TEMP = ONE/A( J, J ) DO 250, I = 1, M B( I, J ) = TEMP*B( I, J ) 250 CONTINUE END IF 260 CONTINUE END IF ELSE * * Form B := alpha*B*inv( A' ). * IF( UPPER )THEN DO 310, K = N, 1, -1 IF( NOUNIT )THEN TEMP = ONE/A( K, K ) DO 270, I = 1, M B( I, K ) = TEMP*B( I, K ) 270 CONTINUE END IF DO 290, J = 1, K - 1 IF( A( J, K ).NE.ZERO )THEN TEMP = A( J, K ) DO 280, I = 1, M B( I, J ) = B( I, J ) - TEMP*B( I, K ) 280 CONTINUE END IF 290 CONTINUE IF( ALPHA.NE.ONE )THEN DO 300, I = 1, M B( I, K ) = ALPHA*B( I, K ) 300 CONTINUE END IF 310 CONTINUE ELSE DO 360, K = 1, N IF( NOUNIT )THEN TEMP = ONE/A( K, K ) DO 320, I = 1, M B( I, K ) = TEMP*B( I, K ) 320 CONTINUE END IF DO 340, J = K + 1, N IF( A( J, K ).NE.ZERO )THEN TEMP = A( J, K ) DO 330, I = 1, M B( I, J ) = B( I, J ) - TEMP*B( I, K ) 330 CONTINUE END IF 340 CONTINUE IF( ALPHA.NE.ONE )THEN DO 350, I = 1, M B( I, K ) = ALPHA*B( I, K ) 350 CONTINUE END IF 360 CONTINUE END IF END IF END IF * RETURN * * End of STRSM . * END
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.10/src/calc_residual_cross_split.f
5
4983
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2007 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! author: Yannick Muller ! real*8 function calc_residual_cross_split(pt1,Tt1,xflow1,xflow2, &pt2,Tt2,ichan_num,A1,A2,A_s,dh1,dh2,alpha,zeta_fac, &kappa,R,ider,iflag) ! implicit none ! integer icase,ichan_num,ider,icrit1,icrit2,iflag,ier ! real*8 ! In- and Output &f, &R, ! ! Kappa stuff &kappa, &km1, &kp1, ! &pt1, &pt2, &Tt1, &Tt2, &xflow1, &xflow2, ! &pt2_lim, ! &zeta, ! &A1, &A2, ! &Ts0, &Ts1, &Ts2, &dh1, &dh2, &alpha, &Q_crit, &pspt_crit, &Q0, &Q1, &Q2, &pspt0, &pspt1, &pspt2, &w1, &w2, &w1w2, &w2w1, &pi, &z2d390, &z1p090, &z60, &z90, &hq, &M1, &M2, &zeta_fac, &xflow_s, &Q_s, &Ts_s, &pspt_s, &w_s, &wsw1, &A_s, &AsA1, &VsV1 ! real*8 Table_zeta(2,10) ! ! pi=4.d0*datan(1.d0) ! icrit1 = 0 icrit2 = 0 ! ! setting icase (always adiabatic) ! icase=0; ! km1=kappa-1.d0 kp1=kappa+1.d0 Q_crit = dsqrt(kappa/R)* & (1+0.5d0*(kappa-1))**(-0.5d0*(kappa+1)/(kappa-1)) pspt_crit = (2./(KAPPA+1.)) ** (KAPPA/(KAPPA-1.)) ! Q0 = xflow1*dsqrt(Tt1)/pt1/A1 Q1 = xflow2*dsqrt(Tt1)/pt1/A2 if(Q1.ge.Q_crit) then Q1 = Q_crit icrit1 = 1 write(*,*)'*WARNING in Cross Split:' write(*,*)'Critical conditions at 1' endif Q2 = xflow2*dsqrt(Tt1)/pt2/A2 if(Q2.ge.Q_crit) then Q2 = Q_crit icrit2 = 1 write(*,*)'*WARNING in Cross Split:' write(*,*)'Critical conditions at 2' endif ! ! Flow velocity at inlet call ts_calc(xflow1,Tt1,pt1,kappa,r,A1,Ts0,icase) pspt0 = (Ts0/Tt1)**(kappa/(kappa-1)) call wpi(w1, pspt0, Q0, & dsqrt(Tt1),kappa,R) ! ! Flow velocity at outlet call ts_calc(xflow2,Tt1,pt1,kappa,r,A2,Ts1,icase) pspt1 = (Ts1/Tt1)**(kappa/(kappa-1)) call wpi(w2, pspt1, Q1, & dsqrt(Tt2),kappa,R) ! w2w1=w2/w1 w1w2=w1/w2 ! ! Main branch if(ichan_num.eq.1) then ! ! Zeta as in Calculix zeta=0.4d0*(1-W2W1)**2 ! zeta=zeta*(W1W2)**2 ! ! First branch elseif((ichan_num.eq.2).or.(ichan_num.eq.3)) then hq=dh2/dh1 if(alpha.le.60.or.hq.le.2.d0/3.d0) then zeta=0.95d0*((W2W1-2d0*dcos(alpha*pi/180)) & *W2W1+1.d0) zeta=zeta*(W1W2)**2 else z2d390=0.95d0*((W2W1-2d0*dcos(90.d0*pi/180)) & *W2W1+1.d0) z1p090=0.95*(0.34d0+W2W1**2) z90=z2d390+(3*hq-2.d0)*(z1p090-z2d390) Z60=0.95d0*((W2W1-2d0*dcos(60.d0*pi/180)) & *W2W1+1.d0) zeta=z60+(alpha/30.d0-2.d0)*(z90-z60) zeta=zeta*(W1W2)**2 endif ! endif ! ! zeta_fac for side branches are all =1 ! main branch can be set by the user in ACC Designer zeta = zeta*zeta_fac ! if(icrit2.ne.1) then if(icrit1.ne.1) then f = pt2 - pt1*pspt1**zeta else f = xflow2*dsqrt(Tt1)/pt1/A2-Q_crit endif else f = xflow2*dsqrt(Tt1)/pt2/A2-Q_crit endif ! if(iflag.eq.3) then ! write(1,57)' zeta= ',zeta 57 format(1x,a,f9.4) ! else if (iflag.eq.4) then ! ! Calculate Mach numbers call machpi(M1,pspt0,kappa,R) call ts_calc(xflow2,Tt2,pt2,kappa,r,A2,Ts2,icase) ! Pressure ratio pspt2 = (Ts2/Tt2)**(kappa/(kappa-1)) call machpi(M2,pspt2,kappa,R) write(1,80)'Inlet: Tt1= ',Tt1, & ', pt1= ',pt1,', M1= ',M1 write(1,77)'mass flow = ',xflow2,', kappa = ',kappa, & ', zeta= ',zeta write(1,80)'Outlet: Tt2= ',Tt2, & ', pt2= ',pt2,', M2= ',M2 80 format(3x,a,f10.6,a,f10.2,a,f10.6) 77 format(3x,a,f10.6,a,f10.2,a,f10.6) endif ! calc_residual_cross_split=f ! return end
gpl-2.0
epfl-cosmo/q-e
PW/src/compute_qdipol.f90
9
3631
! ! Copyright (C) 2001-2004 PWSCF group ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http://www.gnu.org/copyleft/gpl.txt . ! SUBROUTINE compute_qdipol(dpqq) ! ! This routine computes the term dpqq, i.e. the dipole moment of the ! augmentation charge. The output is given on cartesian coordinates ! USE kinds, only: DP USE constants, ONLY: fpi USE atom, ONLY: rgrid USE ions_base, ONLY: ntyp => nsp USE uspp, only: nhtol, nhtolm, indv, nlx, ap USE uspp_param, only: upf, nbetam, nh, nhm implicit none REAL(DP) :: dpqq( nhm, nhm, 3, ntyp) real(DP), allocatable :: qrad2(:,:,:), qtot(:,:,:), aux(:) real(DP) :: fact integer :: nt, l, ir, nb, mb, ijv, ilast, ipol, ih, ivl, jh, jvl, lp, ndm call start_clock('cmpt_qdipol') ndm = MAXVAL ( upf(1:ntyp)%kkbeta ) allocate (qrad2( nbetam , nbetam, ntyp)) allocate (aux( ndm)) allocate (qtot( ndm, nbetam, nbetam)) qrad2(:,:,:)=0.d0 dpqq=0.d0 do nt = 1, ntyp if ( upf(nt)%tvanp ) then l=1 ! ! Only l=1 terms enter in the dipole of Q ! do nb = 1, upf(nt)%nbeta do mb = nb, upf(nt)%nbeta ijv = mb * (mb-1) /2 + nb if ( ( l >= abs(upf(nt)%lll(nb) - upf(nt)%lll(mb)) ) .and. & ( l <= upf(nt)%lll(nb) + upf(nt)%lll(mb) ) .and. & (mod (l+upf(nt)%lll(nb)+upf(nt)%lll(mb), 2) == 0) ) then qtot(1:upf(nt)%kkbeta,nb,mb) = upf(nt)%qfuncl(1:upf(nt)%kkbeta,ijv,l) endif enddo enddo do nb=1, upf(nt)%nbeta ! ! the Q are symmetric with respect to indices ! do mb=nb, upf(nt)%nbeta if ( ( l >= abs(upf(nt)%lll(nb) - upf(nt)%lll(mb)) ) .and. & ( l <= upf(nt)%lll(nb) + upf(nt)%lll(mb) ) .and. & (mod (l+upf(nt)%lll(nb)+upf(nt)%lll(mb), 2) == 0) ) then do ir = 1, upf(nt)%kkbeta aux(ir)=rgrid(nt)%r(ir)*qtot(ir, nb, mb) enddo call simpson ( upf(nt)%kkbeta, aux, rgrid(nt)%rab, & qrad2(nb,mb,nt) ) endif enddo enddo endif ! ntyp enddo do ipol = 1,3 fact=-sqrt(fpi/3.d0) if (ipol.eq.1) lp=3 if (ipol.eq.2) lp=4 if (ipol.eq.3) then lp=2 fact=-fact endif do nt = 1,ntyp if ( upf(nt)%tvanp ) then do ih = 1, nh(nt) ivl = nhtolm(ih, nt) mb = indv(ih, nt) do jh = ih, nh (nt) jvl = nhtolm(jh, nt) nb=indv(jh,nt) if (ivl > nlx) call errore('compute_qdipol',' ivl > nlx', ivl) if (jvl > nlx) call errore('compute_qdipol',' jvl > nlx', jvl) if (nb > nbetam) & call errore('compute_qdipol',' nb out of bounds', nb) if (mb > nbetam) & call errore('compute_qdipol',' mb out of bounds', mb) if (mb > nb) call errore('compute_qdipol',' mb > nb', 1) dpqq(ih,jh,ipol,nt)=fact*ap(lp,ivl,jvl)*qrad2(mb,nb,nt) dpqq(jh,ih,ipol,nt)=dpqq(ih,jh,ipol,nt) ! WRITE( stdout,'(3i5,2f15.9)') ih,jh,ipol,dpqq(ih,jh,ipol,nt) enddo enddo endif enddo enddo deallocate(qtot) deallocate(aux) deallocate(qrad2) call stop_clock('cmpt_qdipol') return end subroutine compute_qdipol
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.10/src/resultsprint.f
1
15202
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine resultsprint(co,nk,kon,ipkon,lakon,ne,v,stn,inum, & stx,ielorien,norien,orab,t1,ithermal,filab,een,iperturb,fn, & nactdof,iout,vold,nodeboun,ndirboun,nboun,nmethod,ttime,xstate, & epn,mi,nstate_,ener,enern,xstaten,eei,set,nset,istartset, & iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, & nelemload,nload,ikin,ielmat,thicke,eme,emn,rhcon,nrhcon,shcon, & nshcon,cocon,ncocon,ntmat_,sideload,icfd,inomat,pslavsurf, & islavact,cdn,mortar,islavnode,nslavnode,ntie,islavsurf,time, & ielprop,prop,veold,ne0,nmpc,ipompc,nodempc,labmpc,energyini, & energy) ! ! - stores the results in the .dat file, if requested ! - nodal quantities at the nodes ! - element quantities at the integration points ! - calculates the extrapolation of element quantities to ! the nodes (if requested for .frd output) ! - calculates 1d/2d results for 1d/2d elements by ! interpolation ! implicit none ! logical force,rfprint ! character*1 cflag character*6 prlab(*) character*8 lakon(*) character*20 sideload(*),labmpc(*) character*81 set(*),prset(*) character*87 filab(*) ! integer kon(*),inum(*),iperm(20),mi(*),ielorien(mi(3),*), & ipkon(*),icfdout,nactdof(0:mi(2),*),nodeboun(*),icompressible, & nelemload(2,*),ndirboun(*),ielmat(mi(3),*),nrhcon(*), & inotr(2,*),iorienloc,iflag,nload,mt,nk,ne,ithermal(2),i, & norien,iperturb(*),iout,nboun,nmethod,node,nshcon(*), & nfield,ndim,nstate_,nset,istartset(*),iendset(*),ialset(*), & nprint,ntrans,ikin,ncocon(2,*),ntmat_,icfd,inomat(*),mortar, & islavact(*),islavnode(*),nslavnode(*),ntie,islavsurf(2,*), & ielprop(*),ne0,index,nmpc,ipompc(*),nodempc(3,*) ! real*8 co(3,*),v(0:mi(2),*),stx(6,mi(1),*),stn(6,*),cdn(6,*), & qfx(3,mi(1),*),qfn(3,*),orab(7,*),fn(0:mi(2),*),pslavsurf(3,*), & t1(*),een(6,*),vold(0:mi(2),*),epn(*),thicke(mi(3),*),time, & ener(mi(1),*),enern(*),eei(6,mi(1),*),rhcon(0:1,ntmat_,*), & ttime,xstate(nstate_,mi(1),*),trab(7,*),xstaten(nstate_,*), & eme(6,mi(1),*),emn(6,*),shcon(0:3,ntmat_,*),cocon(0:6,ntmat_,*), & prop(*),veold(0:mi(2),*),energy(*),energyini(*) ! data iflag /3/ data iperm /5,6,7,8,1,2,3,4,13,14,15,16,9,10,11,12,17,18,19,20/ ! mt=mi(2)+1 ! ! no print requests ! if(iout.le.0) then ! ! 2d basic dof results (displacements, temperature) are ! calculated in each iteration, so that they are available ! in the user subroutines ! if(filab(1)(5:5).ne.' ') then nfield=mt call map3dto1d2d_v(v,ipkon,inum,kon,lakon,nfield,nk, & ne,nactdof) endif ! ! the total energy should not be calculated: ! - for non-dynamical calculations (nmethod!=4) ! - for modal dynamics (iperturb(1)<=1) ! - for thermal and thermomechanical calculations (ithermal(1)>1) ! - for electromagnetic calculations (mi(2)=5) ! if((nmethod.eq.4).and.(iperturb(1).gt.1).and. & (ithermal(1).le.1).and.(mi(2).ne.5)) then call calcenergy(ipkon,lakon,kon,co,ener,mi,ne,thicke, & ielmat,energyini,energy,ielprop,prop) endif ! return endif ! ! output in dat file (with *NODE PRINT or *EL PRINT) ! call printout(set,nset,istartset,iendset,ialset,nprint, & prlab,prset,v,t1,fn,ipkon,lakon,stx,eei,xstate,ener, & mi(1),nstate_,ithermal,co,kon,qfx,ttime,trab,inotr,ntrans, & orab,ielorien,norien,nk,ne,inum,filab,vold,ikin,ielmat,thicke, & eme,islavsurf,mortar,time,ielprop,prop,veold) ! icompressible=0 call printoutface(co,rhcon,nrhcon,ntmat_,vold,shcon,nshcon, & cocon,ncocon,icompressible,istartset,iendset,ipkon,lakon,kon, & ialset,prset,ttime,nset,set,nprint,prlab,ielmat,mi,time) ! ! interpolation in the original nodes of 1d and 2d elements ! this operation has to be performed in any case since ! the interpolated values may be needed as boundary conditions ! in the next step (e.g. the temperature in a heat transfer ! calculation as boundary condition in a subsequent static ! step) ! if(filab(1)(5:5).ne.' ') then nfield=mt cflag=filab(1)(5:5) force=.false. call map3dto1d2d(v,ipkon,inum,kon,lakon,nfield,nk, & ne,cflag,co,vold,force,mi) endif ! if((filab(2)(1:4).eq.'NT ').and.(ithermal(1).le.1)) then if(filab(2)(5:5).eq.'I') then nfield=1 cflag=filab(2)(5:5) force=.false. call map3dto1d2d(t1,ipkon,inum,kon,lakon,nfield,nk, & ne,cflag,co,vold,force,mi) endif endif ! ! check whether forces are requested in the frd-file. If so, but ! none are requested in the .dat file, and output=2d, ! map3dto1d2d has to be called ! if(filab(5)(1:2).eq.'RF') then if(filab(5)(5:5).eq.'I') then rfprint=.false. do i=1,nprint if(prlab(i)(1:2).eq.'RF') then rfprint=.true. exit endif enddo if(.not.rfprint) then nfield=mt cflag=' ' force=.true. call map3dto1d2d(fn,ipkon,inum,kon,lakon,nfield,nk, & ne,cflag,co,vold,force,mi) endif endif endif ! ! in this routine no 3d-fluid results are stored ! icfdout=0 ! ! for composites: ! interpolation of the displacements and temperatures ! from the expanded nodes to the layer nodes ! if(mi(3).gt.1) then if((filab(1)(1:3).eq.'U ').or. & ((filab(2)(1:4).eq.'NT ').and.(ithermal(1).gt.1))) then nfield=mt call map3dtolayer(v,ipkon,kon,lakon,nfield, & ne,co,ielmat,mi) endif if((filab(2)(1:4).eq.'NT ').and.(ithermal(1).le.1)) then nfield=1 call map3dtolayer(t1,ipkon,kon,lakon,nfield, & ne,co,ielmat,mi) endif endif ! ! determining the contact differential displacements and stresses ! in the contact nodes for output in frd format (only for face- ! to-face penalty; for node-to-face penalty these quantities are ! determined in the slave nodes and no extrapolation is necessary) ! ! This block must precede all calls to extrapolate, since the ! field inum from extrapolatecontact.f is not correct; by a ! subsequent call to extrapolate inum is corrected. ! if((filab(26)(1:4).eq.'CONT').or.(filab(46)(1:4).eq.'PCON')) then if(mortar.eq.1) then nfield=6 ndim=6 cflag=filab(3)(5:5) force=.false. call extrapolatecontact(stx,cdn,ipkon,inum,kon,lakon,nfield, & nk,ne,mi(1),ndim,co,cflag,vold,force,pslavsurf, & islavact,islavnode,nslavnode,ntie,islavsurf,ielprop,prop, & ielmat,ne0) endif endif ! ! determining the stresses in the nodes for output in frd format ! if((filab(3)(1:4).eq.'S ').or.(filab(18)(1:4).eq.'PHS ').or. & (filab(20)(1:4).eq.'MAXS').or. & (((filab(44)(1:4).eq.'EMFE').or.(filab(45)(1:4).eq.'EMFB')) & .and.(ithermal(1).ne.2))) then nfield=6 ndim=6 if((norien.gt.0).and.(filab(3)(6:6).eq.'L')) then iorienloc=1 else iorienloc=0 endif cflag=filab(3)(5:5) force=.false. ! call extrapolate(stx,stn,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) ! endif ! ! determining the total strains in the nodes for output in frd format ! if((filab(4)(1:4).eq.'E ').or.(filab(30)(1:4).eq.'MAXE')) then nfield=6 ndim=6 if((norien.gt.0).and.(filab(4)(6:6).eq.'L')) then iorienloc=1 else iorienloc=0 endif cflag=filab(4)(5:5) force=.false. call extrapolate(eei,een,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) endif ! ! determining the mechanical strains in the nodes for output in ! frd format ! if(filab(32)(1:4).eq.'ME ') then nfield=6 ndim=6 if((norien.gt.0).and.(filab(4)(6:6).eq.'L')) then iorienloc=1 else iorienloc=0 endif cflag=filab(4)(5:5) force=.false. call extrapolate(eme,emn,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) endif ! ! determining the plastic equivalent strain in the nodes ! for output in frd format ! if(filab(6)(1:4).eq.'PEEQ') then nfield=1 ndim=nstate_ iorienloc=0 cflag=filab(6)(5:5) force=.false. call extrapolate(xstate,epn,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) endif ! ! determining the total energy in the nodes ! for output in frd format ! if(filab(7)(1:4).eq.'ENER') then nfield=1 ndim=1 iorienloc=0 cflag=filab(7)(5:5) force=.false. call extrapolate(ener,enern,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) endif ! ! determining the internal state variables in the nodes ! for output in frd format ! if(filab(8)(1:4).eq.'SDV ') then nfield=nstate_ ndim=nstate_ if((norien.gt.0).and.(filab(9)(6:6).eq.'L')) then write(*,*) '*WARNING in results: SDV variables cannot' write(*,*) ' be stored in a local frame;' write(*,*) ' the global frame will be used' endif iorienloc=0 cflag=filab(8)(5:5) force=.false. call extrapolate(xstate,xstaten,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) endif ! ! determining the heat flux in the nodes for output in frd format ! if(((filab(9)(1:4).eq.'HFL ').and.(ithermal(1).gt.1)).or. & ((filab(42)(1:3).eq.'ECD').and.(ithermal(1).eq.2))) then nfield=3 ndim=3 if((norien.gt.0).and.(filab(9)(6:6).eq.'L')) then iorienloc=1 else iorienloc=0 endif cflag=filab(9)(5:5) force=.false. call extrapolate(qfx,qfn,ipkon,inum,kon,lakon,nfield,nk, & ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop) endif ! ! if no element quantities requested in the nodes: calculate ! inum if nodal quantities are requested: used in subroutine frd ! to determine which nodes are active in the model ! if((filab(3)(1:4).ne.'S ').and.(filab(4)(1:4).ne.'E ').and. & (filab(6)(1:4).ne.'PEEQ').and.(filab(7)(1:4).ne.'ENER').and. & (filab(8)(1:4).ne.'SDV ').and.(filab(9)(1:4).ne.'HFL ').and. & (filab(42)(1:3).ne.'ECD').and.(filab(32)(1:4).ne.'ME ').and. & ((nmethod.ne.4).or.(iperturb(1).ge.2))) then ! nfield=0 ndim=0 iorienloc=0 cflag=filab(1)(5:5) call createinum(ipkon,inum,kon,lakon,nk,ne,cflag,nelemload, & nload,nodeboun,nboun,ndirboun,ithermal,co,vold,mi,ielmat) endif ! c if(ithermal(1).gt.1) then if(ithermal(2).gt.1) then ! ! next section is executed if at least one step is thermal ! or thermomechanical ! ! extrapolation for the network ! -interpolation for the total pressure and temperature ! in the middle nodes ! -extrapolation for the mass flow in the end nodes ! call networkextrapolate(v,ipkon,inum,kon,lakon,ne,mi) ! ! printing values for environmental film and ! pressure nodes (these nodes are considered to be network ! nodes) ! do i=1,nload if((sideload(i)(3:4).ne.'FC').and. & (sideload(i)(3:4).ne.'NP')) cycle node=nelemload(2,i) if(icfd.eq.1) then if(node.gt.0) then if(inomat(node).ne.0) cycle endif endif if((node.gt.0).and.(sideload(i)(1:1).ne.' ')) then if(inum(node).lt.0) cycle inum(node)=-1 endif enddo ! ! printing values radiation ! (these nodes are considered to be network nodes, unless ! they were already assigned to the structure) ! do i=1,nload if((sideload(i)(3:4).ne.'CR')) cycle node=nelemload(2,i) if(icfd.eq.1) then if(node.gt.0) then if(inomat(node).ne.0) cycle endif endif if((node.gt.0).and.(sideload(i)(1:1).ne.' ')) then if(inum(node).ne.0) cycle inum(node)=-1 endif enddo ! ! printing values for nodes belonging to network MPC's ! (these nodes are considered to be network nodes) ! do i=1,nmpc if(labmpc(i)(1:7).eq.'NETWORK') then index=ipompc(i) do node=nodempc(1,index) if(inum(node).ge.0) inum(node)=-1 index=nodempc(3,index) if(index.eq.0) exit enddo endif enddo ! ! printing values of prescribed boundary conditions (these ! nodes are considered to be network nodes) ! do i=1,nboun node=nodeboun(i) if(inum(node).ne.0) cycle if(icfd.eq.1) then if(inomat(node).ne.0) cycle endif if((cflag.ne.' ').and.(ndirboun(i).eq.3)) cycle inum(node)=-1 enddo endif ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.16/src/umatht.f
1
5417
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine umatht(u,dudt,dudg,flux,dfdt,dfdg, & statev,temp,dtemp,dtemdx,time,dtime,predef,dpred, & cmname,ntgrd,nstatv,props,nprops,coords,pnewdt, & noel,npt,layer,kspt,kstep,kinc,vold,co,lakonl,konl, & ipompc,nodempc,coefmpc,nmpc,ikmpc,ilmpc,mi) ! ! heat transfer material subroutine ! ! INPUT: ! ! statev(nstatv) internal state variables at the start ! of the increment ! temp temperature at the start of the increment ! dtemp increment of temperature ! dtemdx(ntgrd) current values of the spatial gradients of the ! temperature ! time(1) step time at the beginning of the increment ! time(2) total time at the beginning of the increment ! dtime time increment ! predef not used ! dpred not used ! cmname material name ! ntgrd number of spatial gradients of temperature ! nstatv number of internal state variables as defined ! on the *DEPVAR card ! props(nprops) user defined constants defined by the keyword ! card *USER MATERIAL,TYPE=THERMAL ! nprops number of user defined constants, as specified ! on the *USER MATERIAL,TYPE=THERMAL card ! coords global coordinates of the integration point ! pnewd not used ! noel element number ! npt integration point number ! layer not used ! kspt not used ! kstep not used ! kinc not used ! vold(0..4,1..nk) solution field in all nodes ! 0: temperature ! 1: displacement in global x-direction ! 2: displacement in global y-direction ! 3: displacement in global z-direction ! 4: static pressure ! co(3,1..nk) coordinates of all nodes ! 1: coordinate in global x-direction ! 2: coordinate in global y-direction ! 3: coordinate in global z-direction ! lakonl element label ! konl(1..20) nodes belonging to the element ! ipompc(1..nmpc)) ipompc(i) points to the first term of ! MPC i in field nodempc ! nodempc(1,*) node number of a MPC term ! nodempc(2,*) coordinate direction of a MPC term ! nodempc(3,*) if not 0: points towards the next term ! of the MPC in field nodempc ! if 0: MPC definition is finished ! coefmpc(*) coefficient of a MPC term ! nmpc number of MPC's ! ikmpc(1..nmpc) ordered global degrees of freedom of the MPC's ! the global degree of freedom is ! 8*(node-1)+direction of the dependent term of ! the MPC (direction = 0: temperature; ! 1-3: displacements; 4: static pressure; ! 5-7: rotations) ! ilmpc(1..nmpc) ilmpc(i) is the MPC number corresponding ! to the reference number in ikmpc(i) ! mi(1) max # of integration points per element (max ! over all elements) ! mi(2) max degree of freedomm per node (max over all ! nodes) in fields like v(0:mi(2))... ! ! OUTPUT: ! ! u not used ! dudt not used ! dudg(ntgrd) not used ! flux(ntgrd) heat flux at the end of the increment ! dfdt(ntgrd) not used ! dfdg(ntgrd,ntgrd) variation of the heat flux with respect to the ! spatial temperature gradient ! statev(nstatv) internal state variables at the end of the ! increment ! implicit none ! character*8 lakonl character*80 cmname ! integer ntgrd,nstatv,nprops,noel,npt,layer,kspt,kstep,kinc, & konl(20),ipompc(*),nodempc(3,*),nmpc,ikmpc(*),ilmpc(*),mi(*) ! real*8 u,dudt,dudg(ntgrd),flux(ntgrd),dfdt(ntgrd), & statev(nstatv),pnewdt,temp,dtemp,dtemdx(ntgrd),time(2),dtime, & predef,dpred,props(nprops),coords(3),dfdg(ntgrd,ntgrd), & vold(0:mi(2),*),co(3,*),coefmpc(*) ! ! insert here your code ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.15/src/writestadiv.f
2
1429
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2018 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine writestadiv(istep,j,icutb,l,ttime,time,dtime) ! implicit none ! ! writes increment statistics in the .sta file ! the close and open guarantees that the computer buffer is ! emptied each time a new line is written. That way the file ! is always up to data (also during the calculation) ! ! this version of writesummary is meant for increments which did ! not converge ! integer istep,j,icutb,l real*8 ttime,time,dtime ! write(8,100) istep,j,icutb+1,l,ttime+time-dtime,time-dtime,dtime flush(8) ! 100 format(1x,i5,1x,i10,1x,i5,'U',1x,i4,3(1x,e13.6)) ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.8p2/src/rs.f
10
19128
c c EISPACK -> SLATEC: public domain (cf. gams.nist.gov) c real*8 function pythag(a,b) implicit none real*8 a,b c c finds dsqrt(a**2+b**2) without overflow or destructive underflow c real*8 p,r,s,t,u p = dmax1(dabs(a),dabs(b)) if (p .eq. 0.0d0) go to 20 r = (dmin1(dabs(a),dabs(b))/p)**2 10 continue t = 4.0d0 + r if (t .eq. 4.0d0) go to 20 s = r/t u = 1.0d0 + 2.0d0*s p = u*p r = (s/u)**2 * r go to 10 20 pythag = p return end c subroutine rs(nm,n,a,w,matz,z,fv1,fv2,ierr) c implicit none integer n,nm,ierr,matz real*8 a(nm,n),w(n),z(nm,n),fv1(n),fv2(n) c c this subroutine calls the recommended sequence of c subroutines from the eigensystem subroutine package (eispack) c to find the eigenvalues and eigenvectors (if desired) c of a real symmetric matrix. c c on input c c nm must be set to the row dimension of the two-dimensional c array parameters as declared in the calling program c dimension statement. c c n is the order of the matrix a. c c a contains the real symmetric matrix. c c matz is an integer variable set equal to zero if c only eigenvalues are desired. otherwise it is set to c any non-zero integer for both eigenvalues and eigenvectors. c c on output c c w contains the eigenvalues in ascending order. c c z contains the eigenvectors if matz is not zero. c c ierr is an integer output variable set equal to an error c completion code described in the documentation for tqlrat c and tql2. the normal completion code is zero. c c fv1 and fv2 are temporary storage arrays. c c questions and comments should be directed to burton s. garbow, c mathematics and computer science div, argonne national laboratory c c this version dated august 1983. c c ------------------------------------------------------------------ c if (n .le. nm) go to 10 ierr = 10 * n go to 50 c 10 if (matz .ne. 0) go to 20 c .......... find eigenvalues only .......... call tred1(nm,n,a,w,fv1,fv2) * tqlrat encounters catastrophic underflow on the Vax * call tqlrat(n,w,fv2,ierr) call tql1(n,w,fv1,ierr) go to 50 c .......... find both eigenvalues and eigenvectors .......... 20 call tred2(nm,n,a,w,fv1,z) call tql2(nm,n,w,fv1,z,ierr) 50 return end c subroutine tql1(n,d,e,ierr) c implicit none integer i,j,l,m,n,ii,l1,l2,mml,ierr real*8 d(n),e(n) real*8 c,c2,c3,dl1,el1,f,g,h,p,r,s,s2,tst1,tst2,pythag c c this subroutine is a translation of the algol procedure tql1, c num. math. 11, 293-306(1968) by bowdler, martin, reinsch, and c wilkinson. c handbook for auto. comp., vol.ii-linear algebra, 227-240(1971). c c this subroutine finds the eigenvalues of a symmetric c tridiagonal matrix by the ql method. c c on input c c n is the order of the matrix. c c d contains the diagonal elements of the input matrix. c c e contains the subdiagonal elements of the input matrix c in its last n-1 positions. e(1) is arbitrary. c c on output c c d contains the eigenvalues in ascending order. if an c error exit is made, the eigenvalues are correct and c ordered for indices 1,2,...ierr-1, but may not be c the smallest eigenvalues. c c e has been destroyed. c c ierr is set to c zero for normal return, c j if the j-th eigenvalue has not been c determined after 30 iterations. c c calls pythag for dsqrt(a*a + b*b) . c c questions and comments should be directed to burton s. garbow, c mathematics and computer science div, argonne national laboratory c c this version dated august 1983. c c ------------------------------------------------------------------ c ierr = 0 if (n .eq. 1) go to 1001 c do 100 i = 2, n 100 e(i-1) = e(i) c f = 0.0d0 tst1 = 0.0d0 e(n) = 0.0d0 c do 290 l = 1, n j = 0 h = dabs(d(l)) + dabs(e(l)) if (tst1 .lt. h) tst1 = h c .......... look for small sub-diagonal element .......... do 110 m = l, n tst2 = tst1 + dabs(e(m)) if (tst2 .eq. tst1) go to 120 c .......... e(n) is always zero, so there is no exit c through the bottom of the loop .......... 110 continue c 120 if (m .eq. l) go to 210 130 if (j .eq. 30) go to 1000 j = j + 1 c .......... form shift .......... l1 = l + 1 l2 = l1 + 1 g = d(l) p = (d(l1) - g) / (2.0d0 * e(l)) r = pythag(p,1.0d0) d(l) = e(l) / (p + dsign(r,p)) d(l1) = e(l) * (p + dsign(r,p)) dl1 = d(l1) h = g - d(l) if (l2 .gt. n) go to 145 c do 140 i = l2, n 140 d(i) = d(i) - h c 145 f = f + h c .......... ql transformation .......... p = d(m) c = 1.0d0 c2 = c el1 = e(l1) s = 0.0d0 mml = m - l c .......... for i=m-1 step -1 until l do -- .......... do 200 ii = 1, mml c3 = c2 c2 = c s2 = s i = m - ii g = c * e(i) h = c * p r = pythag(p,e(i)) e(i+1) = s * r s = e(i) / r c = p / r p = c * d(i) - s * g d(i+1) = h + s * (c * g + s * d(i)) 200 continue c p = -s * s2 * c3 * el1 * e(l) / dl1 e(l) = s * p d(l) = c * p tst2 = tst1 + dabs(e(l)) if (tst2 .gt. tst1) go to 130 210 p = d(l) + f c .......... order eigenvalues .......... if (l .eq. 1) go to 250 c .......... for i=l step -1 until 2 do -- .......... do 230 ii = 2, l i = l + 2 - ii if (p .ge. d(i-1)) go to 270 d(i) = d(i-1) 230 continue c 250 i = 1 270 d(i) = p 290 continue c go to 1001 c .......... set error -- no convergence to an c eigenvalue after 30 iterations .......... 1000 ierr = l 1001 return end c subroutine tql2(nm,n,d,e,z,ierr) c implicit none integer i,j,k,l,m,n,ii,l1,l2,nm,mml,ierr real*8 d(n),e(n),z(nm,n) real*8 c,c2,c3,dl1,el1,f,g,h,p,r,s,s2,tst1,tst2,pythag c c this subroutine is a translation of the algol procedure tql2, c num. math. 11, 293-306(1968) by bowdler, martin, reinsch, and c wilkinson. c handbook for auto. comp., vol.ii-linear algebra, 227-240(1971). c c this subroutine finds the eigenvalues and eigenvectors c of a symmetric tridiagonal matrix by the ql method. c the eigenvectors of a full symmetric matrix can also c be found if tred2 has been used to reduce this c full matrix to tridiagonal form. c c on input c c nm must be set to the row dimension of two-dimensional c array parameters as declared in the calling program c dimension statement. c c n is the order of the matrix. c c d contains the diagonal elements of the input matrix. c c e contains the subdiagonal elements of the input matrix c in its last n-1 positions. e(1) is arbitrary. c c z contains the transformation matrix produced in the c reduction by tred2, if performed. if the eigenvectors c of the tridiagonal matrix are desired, z must contain c the identity matrix. c c on output c c d contains the eigenvalues in ascending order. if an c error exit is made, the eigenvalues are correct but c unordered for indices 1,2,...,ierr-1. c c e has been destroyed. c c z contains orthonormal eigenvectors of the symmetric c tridiagonal (or full) matrix. if an error exit is made, c z contains the eigenvectors associated with the stored c eigenvalues. c c ierr is set to c zero for normal return, c j if the j-th eigenvalue has not been c determined after 30 iterations. c c calls pythag for dsqrt(a*a + b*b) . c c questions and comments should be directed to burton s. garbow, c mathematics and computer science div, argonne national laboratory c c this version dated august 1983. c c ------------------------------------------------------------------ c ierr = 0 if (n .eq. 1) go to 1001 c do 100 i = 2, n 100 e(i-1) = e(i) c f = 0.0d0 tst1 = 0.0d0 e(n) = 0.0d0 c do 240 l = 1, n j = 0 h = dabs(d(l)) + dabs(e(l)) if (tst1 .lt. h) tst1 = h c .......... look for small sub-diagonal element .......... do 110 m = l, n tst2 = tst1 + dabs(e(m)) if (tst2 .eq. tst1) go to 120 c .......... e(n) is always zero, so there is no exit c through the bottom of the loop .......... 110 continue c 120 if (m .eq. l) go to 220 130 if (j .eq. 30) go to 1000 j = j + 1 c .......... form shift .......... l1 = l + 1 l2 = l1 + 1 g = d(l) p = (d(l1) - g) / (2.0d0 * e(l)) r = pythag(p,1.0d0) d(l) = e(l) / (p + dsign(r,p)) d(l1) = e(l) * (p + dsign(r,p)) dl1 = d(l1) h = g - d(l) if (l2 .gt. n) go to 145 c do 140 i = l2, n 140 d(i) = d(i) - h c 145 f = f + h c .......... ql transformation .......... p = d(m) c = 1.0d0 c2 = c el1 = e(l1) s = 0.0d0 mml = m - l c .......... for i=m-1 step -1 until l do -- .......... do 200 ii = 1, mml c3 = c2 c2 = c s2 = s i = m - ii g = c * e(i) h = c * p r = pythag(p,e(i)) e(i+1) = s * r s = e(i) / r c = p / r p = c * d(i) - s * g d(i+1) = h + s * (c * g + s * d(i)) c .......... form vector .......... do 180 k = 1, n h = z(k,i+1) z(k,i+1) = s * z(k,i) + c * h z(k,i) = c * z(k,i) - s * h 180 continue c 200 continue c p = -s * s2 * c3 * el1 * e(l) / dl1 e(l) = s * p d(l) = c * p tst2 = tst1 + dabs(e(l)) if (tst2 .gt. tst1) go to 130 220 d(l) = d(l) + f 240 continue c .......... order eigenvalues and eigenvectors .......... do 300 ii = 2, n i = ii - 1 k = i p = d(i) c do 260 j = ii, n if (d(j) .ge. p) go to 260 k = j p = d(j) 260 continue c if (k .eq. i) go to 300 d(k) = d(i) d(i) = p c do 280 j = 1, n p = z(j,i) z(j,i) = z(j,k) z(j,k) = p 280 continue c 300 continue c go to 1001 c .......... set error -- no convergence to an c eigenvalue after 30 iterations .......... 1000 ierr = l 1001 return end c subroutine tred1(nm,n,a,d,e,e2) c implicit none integer i,j,k,l,n,ii,nm,jp1 real*8 a(nm,n),d(n),e(n),e2(n) real*8 f,g,h,scale c c this subroutine is a translation of the algol procedure tred1, c num. math. 11, 181-195(1968) by martin, reinsch, and wilkinson. c handbook for auto. comp., vol.ii-linear algebra, 212-226(1971). c c this subroutine reduces a real symmetric matrix c to a symmetric tridiagonal matrix using c orthogonal similarity transformations. c c on input c c nm must be set to the row dimension of two-dimensional c array parameters as declared in the calling program c dimension statement. c c n is the order of the matrix. c c a contains the real symmetric input matrix. only the c lower triangle of the matrix need be supplied. c c on output c c a contains information about the orthogonal trans- c formations used in the reduction in its strict lower c triangle. the full upper triangle of a is unaltered. c c d contains the diagonal elements of the tridiagonal matrix. c c e contains the subdiagonal elements of the tridiagonal c matrix in its last n-1 positions. e(1) is set to zero. c c e2 contains the squares of the corresponding elements of e. c e2 may coincide with e if the squares are not needed. c c questions and comments should be directed to burton s. garbow, c mathematics and computer science div, argonne national laboratory c c this version dated august 1983. c c ------------------------------------------------------------------ c do 100 i = 1, n d(i) = a(n,i) a(n,i) = a(i,i) 100 continue c .......... for i=n step -1 until 1 do -- .......... do 300 ii = 1, n i = n + 1 - ii l = i - 1 h = 0.0d0 scale = 0.0d0 if (l .lt. 1) go to 130 c .......... scale row (algol tol then not needed) .......... do 120 k = 1, l 120 scale = scale + dabs(d(k)) c if (scale .ne. 0.0d0) go to 140 c do 125 j = 1, l d(j) = a(l,j) a(l,j) = a(i,j) a(i,j) = 0.0d0 125 continue c 130 e(i) = 0.0d0 e2(i) = 0.0d0 go to 300 c 140 do 150 k = 1, l d(k) = d(k) / scale h = h + d(k) * d(k) 150 continue c e2(i) = scale * scale * h f = d(l) g = -dsign(dsqrt(h),f) e(i) = scale * g h = h - f * g d(l) = f - g if (l .eq. 1) go to 285 c .......... form a*u .......... do 170 j = 1, l 170 e(j) = 0.0d0 c do 240 j = 1, l f = d(j) g = e(j) + a(j,j) * f jp1 = j + 1 if (l .lt. jp1) go to 220 c do 200 k = jp1, l g = g + a(k,j) * d(k) e(k) = e(k) + a(k,j) * f 200 continue c 220 e(j) = g 240 continue c .......... form p .......... f = 0.0d0 c do 245 j = 1, l e(j) = e(j) / h f = f + e(j) * d(j) 245 continue c h = f / (h + h) c .......... form q .......... do 250 j = 1, l 250 e(j) = e(j) - h * d(j) c .......... form reduced a .......... do 280 j = 1, l f = d(j) g = e(j) c do 260 k = j, l 260 a(k,j) = a(k,j) - f * e(k) - g * d(k) c 280 continue c 285 do 290 j = 1, l f = d(j) d(j) = a(l,j) a(l,j) = a(i,j) a(i,j) = f * scale 290 continue c 300 continue c return end c subroutine tred2(nm,n,a,d,e,z) c implicit none integer i,j,k,l,n,ii,nm,jp1 real*8 a(nm,n),d(n),e(n),z(nm,n) real*8 f,g,h,hh,scale c c this subroutine is a translation of the algol procedure tred2, c num. math. 11, 181-195(1968) by martin, reinsch, and wilkinson. c handbook for auto. comp., vol.ii-linear algebra, 212-226(1971). c c this subroutine reduces a real symmetric matrix to a c symmetric tridiagonal matrix using and accumulating c orthogonal similarity transformations. c c on input c c nm must be set to the row dimension of two-dimensional c array parameters as declared in the calling program c dimension statement. c c n is the order of the matrix. c c a contains the real symmetric input matrix. only the c lower triangle of the matrix need be supplied. c c on output c c d contains the diagonal elements of the tridiagonal matrix. c c e contains the subdiagonal elements of the tridiagonal c matrix in its last n-1 positions. e(1) is set to zero. c c z contains the orthogonal transformation matrix c produced in the reduction. c c a and z may coincide. if distinct, a is unaltered. c c questions and comments should be directed to burton s. garbow, c mathematics and computer science div, argonne national laboratory c c this version dated august 1983. c c ------------------------------------------------------------------ c do 100 i = 1, n c do 80 j = i, n 80 z(j,i) = a(j,i) c d(i) = a(n,i) 100 continue c if (n .eq. 1) go to 510 c .......... for i=n step -1 until 2 do -- .......... do 300 ii = 2, n i = n + 2 - ii l = i - 1 h = 0.0d0 scale = 0.0d0 if (l .lt. 2) go to 130 c .......... scale row (algol tol then not needed) .......... do 120 k = 1, l 120 scale = scale + dabs(d(k)) c if (scale .ne. 0.0d0) go to 140 130 e(i) = d(l) c do 135 j = 1, l d(j) = z(l,j) z(i,j) = 0.0d0 z(j,i) = 0.0d0 135 continue c go to 290 c 140 do 150 k = 1, l d(k) = d(k) / scale h = h + d(k) * d(k) 150 continue c f = d(l) g = -dsign(dsqrt(h),f) e(i) = scale * g h = h - f * g d(l) = f - g c .......... form a*u .......... do 170 j = 1, l 170 e(j) = 0.0d0 c do 240 j = 1, l f = d(j) z(j,i) = f g = e(j) + z(j,j) * f jp1 = j + 1 if (l .lt. jp1) go to 220 c do 200 k = jp1, l g = g + z(k,j) * d(k) e(k) = e(k) + z(k,j) * f 200 continue c 220 e(j) = g 240 continue c .......... form p .......... f = 0.0d0 c do 245 j = 1, l e(j) = e(j) / h f = f + e(j) * d(j) 245 continue c hh = f / (h + h) c .......... form q .......... do 250 j = 1, l 250 e(j) = e(j) - hh * d(j) c .......... form reduced a .......... do 280 j = 1, l f = d(j) g = e(j) c do 260 k = j, l 260 z(k,j) = z(k,j) - f * e(k) - g * d(k) c d(j) = z(l,j) z(i,j) = 0.0d0 280 continue c 290 d(i) = h 300 continue c .......... accumulation of transformation matrices .......... do 500 i = 2, n l = i - 1 z(n,l) = z(l,l) z(l,l) = 1.0d0 h = d(i) if (h .eq. 0.0d0) go to 380 c do 330 k = 1, l 330 d(k) = z(k,i) / h c do 360 j = 1, l g = 0.0d0 c do 340 k = 1, l 340 g = g + z(k,i) * z(k,j) c do 360 k = 1, l z(k,j) = z(k,j) - g * d(k) 360 continue c 380 do 400 k = 1, l 400 z(k,i) = 0.0d0 c 500 continue c 510 do 520 i = 1, n d(i) = z(n,i) z(n,i) = 0.0d0 520 continue c z(n,n) = 1.0d0 e(1) = 0.0d0 return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.16/src/frictionheating.f
1
11032
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine frictionheating(ne0,ne,ipkon,lakon,ielmat,mi,elcon, & ncmat_,ntmat_,kon,islavsurf,pmastsurf,springarea,co,vold, & veold,pslavsurf,xloadact,nload,nload_,nelemload,iamload, & idefload,sideload,stx,nam,time,ttime,matname,istep,iinc) ! ! determines the effect of friction heating ! implicit none ! character*8 lakon(*),lakonl character*20 label,sideload(*) character*80 matname(*) ! integer i,j,k,ne0,ne,indexe,ipkon(*),imat,mi(*),ielmat(mi(3),*), & ncmat_,ntmat_,kon(*),nope,igauss,jfaces,ifaces,nelems,ifacem, & nelemm,jfacem,islavsurf(2,*),nopes,nopem,konl(20),iflag, & mint2d,iamplitude,isector,nload,nload_,nelemload(2,*),nam, & iamload(2,*),idefload(*),istep,iinc ! real*8 elcon(0:ncmat_,ntmat_,*),pressure,stx(6,mi(1),*), & pmastsurf(6,*),area,springarea(2,*),pl(3,20),co(3,*), & vold(0:mi(2),*),areaslav,xi,et,vels(3),veold(0:mi(2),*), & xsj2m(3),xs2m(3,7),shp2m(7,9),xsj2s(3),xs2s(3,7),shp2s(7,9), & areamast,pslavsurf(3,*),value,velm(3),um,xloadact(2,*),weight, & shear,vnorm,f,eta,timeend(2),time,ttime,coords(3),xl(3,20) ! intent(in) ne0,ne,ipkon,lakon,ielmat,mi,elcon, & ncmat_,ntmat_,kon,islavsurf,pmastsurf,springarea,co,vold, & veold,pslavsurf,nload_,stx,nam,time,ttime,matname,istep,iinc ! intent(inout) iamload,xloadact,sideload,idefload,nelemload,nload ! include "gauss.f" ! ! mortar=1 is assumed (face-to-face penalty contact) ! ithermal=3 is assumed ! iamplitude=0 isector=0 ! do i=ne0+1,ne imat=ielmat(1,i) ! ! heat conversion factor ! eta=elcon(9,1,imat) ! ! surface weighting factor ! f=elcon(10,1,imat) ! ! velocity ! vnorm=elcon(11,1,imat) ! ! friction coefficient ! um=elcon(6,1,imat) ! pressure=stx(4,1,i) if(pressure.lt.0.d0) cycle ! shear=dsqrt(stx(5,1,i)**2+stx(6,1,i)**2) if(vnorm.lt.-0.5d0) then ! ! if ||v||<0 => take differential velocity from the results ! no heat generation if no slip ! if(shear.lt.um*pressure*0.95d0) cycle endif ! indexe=ipkon(i) lakonl=lakon(i) ! nope=kon(ipkon(i)) nopem=ichar(lakonl(8:8))-48 nopes=nope-nopem ! igauss=kon(indexe+nope+1) jfaces=kon(indexe+nope+2) ! ! slave face ! ifaces=islavsurf(1,jfaces) nelems=int(ifaces/10.d0) jfaces=ifaces-10*nelems ! ! master face ! ifacem=int(pmastsurf(3,igauss)) nelemm=int(ifacem/10.d0) jfacem=ifacem-10*nelemm ! ! contact area ! area=springarea(1,igauss) ! ! slave and master nodes ! do j=1,nope konl(j)=kon(indexe+j) do k=1,3 pl(k,j)=co(k,konl(j))+vold(k,konl(j)) enddo enddo ! ! user subroutine called if vnorm=-0.01d0 ! if((vnorm.lt.0.d0).and.(vnorm.gt.-0.5d0)) then ! xi=pslavsurf(1,igauss) et=pslavsurf(2,igauss) ! do j=nopem+1,nopem+nopes konl(j)=kon(indexe+j) do k=1,3 xl(k,j)=co(k,konl(j)) enddo enddo ! ! determining the jacobian vector on the surface ! iflag=1 if(nopes.eq.8) then call shape8q(xi,et,xl(1,nopem+1),xsj2s,xs2s,shp2s,iflag) elseif(nopes.eq.4) then call shape4q(xi,et,xl(1,nopem+1),xsj2s,xs2s,shp2s,iflag) elseif(nopes.eq.6) then call shape6tri(xi,et,xl(1,nopem+1),xsj2s,xs2s,shp2s, & iflag) else call shape3tri(xi,et,xl(1,nopem+1),xsj2s,xs2s,shp2s, & iflag) endif ! ! position of the slave integration point ! do j=1,3 coords(j)=0.d0 do k=1,nopes coords(j)=coords(j)+shp2s(4,k)*xl(j,nopem+k) enddo enddo ! timeend(1)=time timeend(2)=ttime+time call fricheat(eta,f,vnorm,timeend,matname(imat),i, & nelems,jfaces,nelemm,jfacem,um, & istep,iinc,area,pressure,coords) endif ! ! heat flux into the slave face ! if(nopes.eq.8) then mint2d=9 elseif(nopes.eq.6) then mint2d=3 elseif(nopes.eq.4) then mint2d=4 else mint2d=1 endif ! ! calculating the area of the slave face ! areaslav=0.d0 ! do j=1,mint2d if(nopes.eq.8) then xi=gauss2d3(1,j) et=gauss2d3(2,j) weight=weight2d3(j) elseif(nopes.eq.6) then xi=gauss2d5(1,j) et=gauss2d5(2,j) weight=weight2d5(j) elseif(nopes.eq.4) then xi=gauss2d2(1,j) et=gauss2d2(2,j) weight=weight2d2(j) else xi=gauss2d4(1,j) et=gauss2d4(2,j) weight=weight2d4(j) endif ! iflag=2 if(nopes.eq.8) then call shape8q(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s,iflag) elseif(nopes.eq.4) then call shape4q(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s,iflag) elseif(nopes.eq.6) then call shape6tri(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s, &iflag) else call shape3tri(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s, &iflag) endif ! areaslav=areaslav+dsqrt(xsj2s(1)**2+ & xsj2s(2)**2+ & xsj2s(3)**2) enddo ! label(1:20)='S ' write(label(2:2),'(i1)') jfaces ! if(vnorm.gt.0.d0) then value=um*pressure*vnorm*eta*f*area/areaslav call loadadd(nelems,label,value,nelemload,sideload,xloadact, & nload,nload_,iamload,iamplitude,nam,isector, & idefload) elseif(vnorm.lt.-0.5d0) then ! ! calculate the differential velocity ! ! determining the slave velocity ! xi=pslavsurf(1,igauss) et=pslavsurf(2,igauss) iflag=1 if(nopes.eq.8) then call shape8q(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s,iflag) elseif(nopes.eq.4) then call shape4q(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s,iflag) elseif(nopes.eq.6) then call shape6tri(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s, & iflag) else call shape3tri(xi,et,pl(1,nopem+1),xsj2s,xs2s,shp2s, & iflag) endif ! do k=1,3 vels(k)=0.d0 do j=1,nopes vels(k)=vels(k)+shp2s(4,j)* & veold(k,konl(nopem+j)) enddo enddo ! ! determining the master velocity ! xi=pmastsurf(1,igauss) et=pmastsurf(2,igauss) iflag=1 if(nopem.eq.8) then call shape8q(xi,et,pl,xsj2m,xs2m,shp2m,iflag) elseif(nopem.eq.4) then call shape4q(xi,et,pl,xsj2m,xs2m,shp2m,iflag) elseif(nopem.eq.6) then call shape6tri(xi,et,pl,xsj2m,xs2m,shp2m,iflag) else call shape3tri(xi,et,pl,xsj2m,xs2m,shp2m,iflag) endif ! do k=1,3 velm(k)=0.d0 do j=1,nopem velm(k)=velm(k)+shp2m(4,j)* & veold(k,konl(j)) enddo enddo ! vnorm=dsqrt((vels(1)-velm(1))**2+ & (vels(2)-velm(2))**2+ & (vels(3)-velm(3))**2) value=um*pressure*vnorm*eta*f*area/areaslav call loadadd(nelems,label,value,nelemload,sideload,xloadact, & nload,nload_,iamload,iamplitude,nam,isector, & idefload) endif ! ! heat flux into the master face ! if(nopem.eq.8) then mint2d=9 elseif(nopem.eq.6) then mint2d=3 elseif(nopem.eq.4) then mint2d=4 else mint2d=1 endif ! ! calculating the area of the slave face ! areamast=0.d0 ! do j=1,mint2d if(nopem.eq.8) then xi=gauss2d3(1,j) et=gauss2d3(2,j) weight=weight2d3(j) elseif(nopem.eq.6) then xi=gauss2d5(1,j) et=gauss2d5(2,j) weight=weight2d5(j) elseif(nopem.eq.4) then xi=gauss2d2(1,j) et=gauss2d2(2,j) weight=weight2d2(j) else xi=gauss2d4(1,j) et=gauss2d4(2,j) weight=weight2d4(j) endif ! iflag=2 if(nopem.eq.8) then call shape8q(xi,et,pl,xsj2m,xs2m,shp2m,iflag) elseif(nopem.eq.4) then call shape4q(xi,et,pl,xsj2m,xs2m,shp2m,iflag) elseif(nopem.eq.6) then call shape6tri(xi,et,pl,xsj2m,xs2m,shp2m,iflag) else call shape3tri(xi,et,pl,xsj2m,xs2m,shp2m,iflag) endif ! areamast=areamast+dsqrt(xsj2m(1)**2+ & xsj2m(2)**2+ & xsj2m(3)**2) enddo ! label(1:20)='S ' write(label(2:2),'(i1)') jfacem ! ! at this point vnorm was either given by the user or ! calculated for the slave surface (differential velocity) ! value=um*pressure*vnorm*eta*(1.d0-f)*area/areamast call loadadd(nelemm,label,value,nelemload,sideload,xloadact, & nload,nload_,iamload,iamplitude,nam,isector, & idefload) enddo ! return end
gpl-2.0
patrickanderson1/XNLO
UPPE/eigen_3_2/blas/drotmg.f
174
4889
SUBROUTINE DROTMG(DD1,DD2,DX1,DY1,DPARAM) * .. Scalar Arguments .. DOUBLE PRECISION DD1,DD2,DX1,DY1 * .. * .. Array Arguments .. DOUBLE PRECISION DPARAM(5) * .. * * Purpose * ======= * * CONSTRUCT THE MODIFIED GIVENS TRANSFORMATION MATRIX H WHICH ZEROS * THE SECOND COMPONENT OF THE 2-VECTOR (DSQRT(DD1)*DX1,DSQRT(DD2)* * DY2)**T. * WITH DPARAM(1)=DFLAG, H HAS ONE OF THE FOLLOWING FORMS.. * * DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 * * (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) * H=( ) ( ) ( ) ( ) * (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). * LOCATIONS 2-4 OF DPARAM CONTAIN DH11, DH21, DH12, AND DH22 * RESPECTIVELY. (VALUES OF 1.D0, -1.D0, OR 0.D0 IMPLIED BY THE * VALUE OF DPARAM(1) ARE NOT STORED IN DPARAM.) * * THE VALUES OF GAMSQ AND RGAMSQ SET IN THE DATA STATEMENT MAY BE * INEXACT. THIS IS OK AS THEY ARE ONLY USED FOR TESTING THE SIZE * OF DD1 AND DD2. ALL ACTUAL SCALING OF DATA IS DONE USING GAM. * * * Arguments * ========= * * DD1 (input/output) DOUBLE PRECISION * * DD2 (input/output) DOUBLE PRECISION * * DX1 (input/output) DOUBLE PRECISION * * DY1 (input) DOUBLE PRECISION * * DPARAM (input/output) DOUBLE PRECISION array, dimension 5 * DPARAM(1)=DFLAG * DPARAM(2)=DH11 * DPARAM(3)=DH21 * DPARAM(4)=DH12 * DPARAM(5)=DH22 * * ===================================================================== * * .. Local Scalars .. DOUBLE PRECISION DFLAG,DH11,DH12,DH21,DH22,DP1,DP2,DQ1,DQ2,DTEMP, + DU,GAM,GAMSQ,ONE,RGAMSQ,TWO,ZERO INTEGER IGO * .. * .. Intrinsic Functions .. INTRINSIC DABS * .. * .. Data statements .. * DATA ZERO,ONE,TWO/0.D0,1.D0,2.D0/ DATA GAM,GAMSQ,RGAMSQ/4096.D0,16777216.D0,5.9604645D-8/ * .. IF (.NOT.DD1.LT.ZERO) GO TO 10 * GO ZERO-H-D-AND-DX1.. GO TO 60 10 CONTINUE * CASE-DD1-NONNEGATIVE DP2 = DD2*DY1 IF (.NOT.DP2.EQ.ZERO) GO TO 20 DFLAG = -TWO GO TO 260 * REGULAR-CASE.. 20 CONTINUE DP1 = DD1*DX1 DQ2 = DP2*DY1 DQ1 = DP1*DX1 * IF (.NOT.DABS(DQ1).GT.DABS(DQ2)) GO TO 40 DH21 = -DY1/DX1 DH12 = DP2/DP1 * DU = ONE - DH12*DH21 * IF (.NOT.DU.LE.ZERO) GO TO 30 * GO ZERO-H-D-AND-DX1.. GO TO 60 30 CONTINUE DFLAG = ZERO DD1 = DD1/DU DD2 = DD2/DU DX1 = DX1*DU * GO SCALE-CHECK.. GO TO 100 40 CONTINUE IF (.NOT.DQ2.LT.ZERO) GO TO 50 * GO ZERO-H-D-AND-DX1.. GO TO 60 50 CONTINUE DFLAG = ONE DH11 = DP1/DP2 DH22 = DX1/DY1 DU = ONE + DH11*DH22 DTEMP = DD2/DU DD2 = DD1/DU DD1 = DTEMP DX1 = DY1*DU * GO SCALE-CHECK GO TO 100 * PROCEDURE..ZERO-H-D-AND-DX1.. 60 CONTINUE DFLAG = -ONE DH11 = ZERO DH12 = ZERO DH21 = ZERO DH22 = ZERO * DD1 = ZERO DD2 = ZERO DX1 = ZERO * RETURN.. GO TO 220 * PROCEDURE..FIX-H.. 70 CONTINUE IF (.NOT.DFLAG.GE.ZERO) GO TO 90 * IF (.NOT.DFLAG.EQ.ZERO) GO TO 80 DH11 = ONE DH22 = ONE DFLAG = -ONE GO TO 90 80 CONTINUE DH21 = -ONE DH12 = ONE DFLAG = -ONE 90 CONTINUE GO TO IGO(120,150,180,210) * PROCEDURE..SCALE-CHECK 100 CONTINUE 110 CONTINUE IF (.NOT.DD1.LE.RGAMSQ) GO TO 130 IF (DD1.EQ.ZERO) GO TO 160 ASSIGN 120 TO IGO * FIX-H.. GO TO 70 120 CONTINUE DD1 = DD1*GAM**2 DX1 = DX1/GAM DH11 = DH11/GAM DH12 = DH12/GAM GO TO 110 130 CONTINUE 140 CONTINUE IF (.NOT.DD1.GE.GAMSQ) GO TO 160 ASSIGN 150 TO IGO * FIX-H.. GO TO 70 150 CONTINUE DD1 = DD1/GAM**2 DX1 = DX1*GAM DH11 = DH11*GAM DH12 = DH12*GAM GO TO 140 160 CONTINUE 170 CONTINUE IF (.NOT.DABS(DD2).LE.RGAMSQ) GO TO 190 IF (DD2.EQ.ZERO) GO TO 220 ASSIGN 180 TO IGO * FIX-H.. GO TO 70 180 CONTINUE DD2 = DD2*GAM**2 DH21 = DH21/GAM DH22 = DH22/GAM GO TO 170 190 CONTINUE 200 CONTINUE IF (.NOT.DABS(DD2).GE.GAMSQ) GO TO 220 ASSIGN 210 TO IGO * FIX-H.. GO TO 70 210 CONTINUE DD2 = DD2/GAM**2 DH21 = DH21*GAM DH22 = DH22*GAM GO TO 200 220 CONTINUE IF (DFLAG) 250,230,240 230 CONTINUE DPARAM(3) = DH21 DPARAM(4) = DH12 GO TO 260 240 CONTINUE DPARAM(2) = DH11 DPARAM(5) = DH22 GO TO 260 250 CONTINUE DPARAM(2) = DH11 DPARAM(3) = DH21 DPARAM(4) = DH12 DPARAM(5) = DH22 260 CONTINUE DPARAM(1) = DFLAG RETURN END
mit
epfl-cosmo/q-e
GWW/minpack/dpmpar.f
155
5790
double precision function dpmpar(i) integer i c ********** c c Function dpmpar c c This function provides double precision machine parameters c when the appropriate set of data statements is activated (by c removing the c from column 1) and all other data statements are c rendered inactive. Most of the parameter values were obtained c from the corresponding Bell Laboratories Port Library function. c c The function statement is c c double precision function dpmpar(i) c c where c c i is an integer input variable set to 1, 2, or 3 which c selects the desired machine parameter. If the machine has c t base b digits and its smallest and largest exponents are c emin and emax, respectively, then these parameters are c c dpmpar(1) = b**(1 - t), the machine precision, c c dpmpar(2) = b**(emin - 1), the smallest magnitude, c c dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. c c Argonne National Laboratory. MINPACK Project. November 1996. c Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' c c ********** integer mcheps(4) integer minmag(4) integer maxmag(4) double precision dmach(3) equivalence (dmach(1),mcheps(1)) equivalence (dmach(2),minmag(1)) equivalence (dmach(3),maxmag(1)) c c Machine constants for the IBM 360/370 series, c the Amdahl 470/V6, the ICL 2900, the Itel AS/6, c the Xerox Sigma 5/7/9 and the Sel systems 85/86. c c data mcheps(1),mcheps(2) / z34100000, z00000000 / c data minmag(1),minmag(2) / z00100000, z00000000 / c data maxmag(1),maxmag(2) / z7fffffff, zffffffff / c c Machine constants for the Honeywell 600/6000 series. c c data mcheps(1),mcheps(2) / o606400000000, o000000000000 / c data minmag(1),minmag(2) / o402400000000, o000000000000 / c data maxmag(1),maxmag(2) / o376777777777, o777777777777 / c c Machine constants for the CDC 6000/7000 series. c c data mcheps(1) / 15614000000000000000b / c data mcheps(2) / 15010000000000000000b / c c data minmag(1) / 00604000000000000000b / c data minmag(2) / 00000000000000000000b / c c data maxmag(1) / 37767777777777777777b / c data maxmag(2) / 37167777777777777777b / c c Machine constants for the PDP-10 (KA processor). c c data mcheps(1),mcheps(2) / "114400000000, "000000000000 / c data minmag(1),minmag(2) / "033400000000, "000000000000 / c data maxmag(1),maxmag(2) / "377777777777, "344777777777 / c c Machine constants for the PDP-10 (KI processor). c c data mcheps(1),mcheps(2) / "104400000000, "000000000000 / c data minmag(1),minmag(2) / "000400000000, "000000000000 / c data maxmag(1),maxmag(2) / "377777777777, "377777777777 / c c Machine constants for the PDP-11. c c data mcheps(1),mcheps(2) / 9472, 0 / c data mcheps(3),mcheps(4) / 0, 0 / c c data minmag(1),minmag(2) / 128, 0 / c data minmag(3),minmag(4) / 0, 0 / c c data maxmag(1),maxmag(2) / 32767, -1 / c data maxmag(3),maxmag(4) / -1, -1 / c c Machine constants for the Burroughs 6700/7700 systems. c c data mcheps(1) / o1451000000000000 / c data mcheps(2) / o0000000000000000 / c c data minmag(1) / o1771000000000000 / c data minmag(2) / o7770000000000000 / c c data maxmag(1) / o0777777777777777 / c data maxmag(2) / o7777777777777777 / c c Machine constants for the Burroughs 5700 system. c c data mcheps(1) / o1451000000000000 / c data mcheps(2) / o0000000000000000 / c c data minmag(1) / o1771000000000000 / c data minmag(2) / o0000000000000000 / c c data maxmag(1) / o0777777777777777 / c data maxmag(2) / o0007777777777777 / c c Machine constants for the Burroughs 1700 system. c c data mcheps(1) / zcc6800000 / c data mcheps(2) / z000000000 / c c data minmag(1) / zc00800000 / c data minmag(2) / z000000000 / c c data maxmag(1) / zdffffffff / c data maxmag(2) / zfffffffff / c c Machine constants for the Univac 1100 series. c c data mcheps(1),mcheps(2) / o170640000000, o000000000000 / c data minmag(1),minmag(2) / o000040000000, o000000000000 / c data maxmag(1),maxmag(2) / o377777777777, o777777777777 / c c Machine constants for the Data General Eclipse S/200. c c Note - it may be appropriate to include the following card - c static dmach(3) c c data minmag/20k,3*0/,maxmag/77777k,3*177777k/ c data mcheps/32020k,3*0/ c c Machine constants for the Harris 220. c c data mcheps(1),mcheps(2) / '20000000, '00000334 / c data minmag(1),minmag(2) / '20000000, '00000201 / c data maxmag(1),maxmag(2) / '37777777, '37777577 / c c Machine constants for the Cray-1. c c data mcheps(1) / 0376424000000000000000b / c data mcheps(2) / 0000000000000000000000b / c c data minmag(1) / 0200034000000000000000b / c data minmag(2) / 0000000000000000000000b / c c data maxmag(1) / 0577777777777777777777b / c data maxmag(2) / 0000007777777777777776b / c c Machine constants for the Prime 400. c c data mcheps(1),mcheps(2) / :10000000000, :00000000123 / c data minmag(1),minmag(2) / :10000000000, :00000100000 / c data maxmag(1),maxmag(2) / :17777777777, :37777677776 / c c Machine constants for the VAX-11. c c data mcheps(1),mcheps(2) / 9472, 0 / c data minmag(1),minmag(2) / 128, 0 / c data maxmag(1),maxmag(2) / -32769, -1 / c c Machine constants for IEEE machines. c data dmach(1) /2.22044604926d-16/ data dmach(2) /2.22507385852d-308/ data dmach(3) /1.79769313485d+308/ c dpmpar = dmach(i) return c c Last card of function dpmpar. c end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.9/src/extrapolatefluid.f
3
3324
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine extrapolatefluid(nk,iponofa,inofa,inum,vfa,v,ielfa, & ithermal,imach,ikappa,xmach,xkappa,shcon,nshcon,ntmat_,ielmat, & physcon,mi) ! ! extrapolates the field values at the center of the faces to ! the nodes ! implicit none ! integer nk,iponofa(*),inofa(2,*),inum(*),ielfa(4,*),i,l,indexf, & iface,ithermal,imach,ikappa,imat,nshcon(*),ntmat_,mi(*), & ielmat(mi(3),*) ! real*8 vfa(0:5,*),v(0:4,*),cp,r,xk,xmach(*),xkappa(*),t1l, & shcon(0:3,ntmat_,*),physcon(*) ! do i=1,nk if(ithermal.eq.0) then do l=1,4 v(l,i)=0.d0 enddo inum(i)=0 indexf=iponofa(i) do if(indexf.eq.0) exit iface=inofa(1,indexf) do l=1,4 v(l,i)=v(l,i)+vfa(l,iface) enddo inum(i)=inum(i)+1 indexf=inofa(2,indexf) enddo if(inum(i).gt.0) then do l=1,4 v(l,i)=v(l,i)/inum(i) enddo endif else do l=0,4 v(l,i)=0.d0 enddo inum(i)=0 indexf=iponofa(i) do if(indexf.eq.0) exit iface=inofa(1,indexf) c write(*,*) 'extrapolatefluid ',i,iface, c & ielfa(1,iface),ielfa(4,iface),vfa(0,iface) do l=0,4 v(l,i)=v(l,i)+vfa(l,iface) enddo if(imach.eq.1) then t1l=vfa(0,iface) imat=ielmat(1,ielfa(1,iface)) r=shcon(3,1,imat) call materialdata_cp_sec(imat,ntmat_,t1l, & shcon,nshcon,cp,physcon) xk=cp/(cp-r) xmach(i)=xmach(i)+dsqrt((vfa(1,iface)**2+ & vfa(2,iface)**2+vfa(3,iface)**2)/(xk*r*t1l)) c write(*,*) 'extrapolatefluid ',i,xk,r,t1l,xmach(i) endif if(ikappa.eq.1) then xkappa(i)=xkappa(i)+xk endif ! inum(i)=inum(i)+1 indexf=inofa(2,indexf) enddo if(inum(i).gt.0) then do l=0,4 v(l,i)=v(l,i)/inum(i) enddo if(imach.eq.1) xmach(i)=xmach(i)/inum(i) if(ikappa.eq.1) xkappa(i)=xkappa(i)/inum(i) endif endif enddo ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/materialdata_cp.f
1
1580
! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine materialdata_cp(imat,ntmat_,t1l,shcon,nshcon,cp) ! implicit none ! ! determines the specific heat ! integer imat,ntmat_,id,nshcon(*),four ! real*8 t1l,shcon(0:3,ntmat_,*),cp ! four=4 ! ! calculating the specific heat ! call ident2(shcon(0,1,imat),t1l,nshcon(imat),four,id) if(nshcon(imat).eq.0) then continue elseif(nshcon(imat).eq.1) then cp=shcon(1,1,imat) elseif(id.eq.0) then cp=shcon(1,1,imat) elseif(id.eq.nshcon(imat)) then cp=shcon(1,id,imat) else cp=shcon(1,id,imat)+ & (shcon(1,id+1,imat)-shcon(1,id,imat))* & (t1l-shcon(0,id,imat))/ & (shcon(0,id+1,imat)-shcon(0,id,imat)) endif ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.9/src/shape9q.f
4
7115
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine shape9q(xi,et,xl,xsj,xs,shp,iflag) ! ! shape functions and derivatives for a 9-node quadratic ! isoparametric quadrilateral element. -1<=xi,et<=1 ! ! iflag=1: calculate only the value of the shape functions ! iflag=2: calculate the value of the shape functions, ! their derivatives w.r.t. the local coordinates ! and the Jacobian vector (local normal to the ! surface) ! iflag=3: calculate the value of the shape functions, the ! value of their derivatives w.r.t. the global ! coordinates and the Jacobian vector (local normal ! to the surface) ! iflag=4: calculate the value of the shape functions, the ! value of their 1st and 2nd order derivatives ! w.r.t. the local coordinates, the Jacobian vector ! (local normal to the surface) ! implicit none ! integer i,j,k,iflag ! real*8 shp(7,9),xs(3,7),xsi(2,3),xl(3,9),sh(3),xsj(3),xi,et, & fxi1,fxi2,fxi3,fet1,fet2,fet3,dfxi1,dfxi2,dfxi3,dfet1,dfet2, & dfet3,ddfxi1,ddfxi2,ddfxi3,ddfet1,ddfet2,ddfet3 ! intent(in) xi,et,xl,iflag ! intent(out) shp,xs,xsj ! ! shape functions and their glocal derivatives for an element ! described with two local parameters and three global ones. ! ! shape functions in one dimension ! fxi1=xi*(xi-1.d0)/2.d0 fxi2=(1.d0-xi)*(1.d0+xi) fxi3=xi*(xi+1.d0)/2.d0 ! fet1=et*(et-1.d0)/2.d0 fet2=(1.d0-et)*(1.d0+et) fet3=et*(et+1.d0)/2.d0 ! ! shape functions ! shp(4,1)=fxi1*fet1 shp(4,2)=fxi3*fet1 shp(4,3)=fxi3*fet3 shp(4,4)=fxi1*fet3 shp(4,5)=fxi2*fet1 shp(4,6)=fxi3*fet2 shp(4,7)=fxi2*fet3 shp(4,8)=fxi1*fet2 shp(4,9)=fxi2*fet2 ! if(iflag.eq.1) return ! ! derivative of the shape functions in one dimension ! dfxi1=(2.d0*xi-1.d0)/2.d0 dfxi2=-2.d0*xi dfxi3=(2.d0*xi+1.d0)/2.d0 ! dfet1=(2.d0*et-1.d0)/2.d0 dfet2=-2.d0*et dfet3=(2.d0*et+1.d0)/2.d0 ! ! local derivatives of the shape functions: xi-derivative ! shp(1,1)=dfxi1*fet1 shp(1,2)=dfxi3*fet1 shp(1,3)=dfxi3*fet3 shp(1,4)=dfxi1*fet3 shp(1,5)=dfxi2*fet1 shp(1,6)=dfxi3*fet2 shp(1,7)=dfxi2*fet3 shp(1,8)=dfxi1*fet2 shp(1,9)=dfxi2*fet2 ! ! local derivatives of the shape functions: eta-derivative ! shp(2,1)=fxi1*dfet1 shp(2,2)=fxi3*dfet1 shp(2,3)=fxi3*dfet3 shp(2,4)=fxi1*dfet3 shp(2,5)=fxi2*dfet1 shp(2,6)=fxi3*dfet2 shp(2,7)=fxi2*dfet3 shp(2,8)=fxi1*dfet2 shp(2,9)=fxi2*dfet2 ! ! computation of the local derivative of the global coordinates ! (xs) ! do i=1,3 do j=1,2 xs(i,j)=0.d0 do k=1,9 xs(i,j)=xs(i,j)+xl(i,k)*shp(j,k) enddo enddo enddo ! ! computation of the jacobian vector ! xsj(1)=xs(2,1)*xs(3,2)-xs(3,1)*xs(2,2) xsj(2)=xs(1,2)*xs(3,1)-xs(3,2)*xs(1,1) xsj(3)=xs(1,1)*xs(2,2)-xs(2,1)*xs(1,2) ! if(iflag.eq.3) then ! ! computation of the global derivative of the local coordinates ! (xsi) (inversion of xs) ! if(dabs(xsj(3)).gt.1.d-10) then xsi(1,1)=xs(2,2)/xsj(3) xsi(2,2)=xs(1,1)/xsj(3) xsi(1,2)=-xs(1,2)/xsj(3) xsi(2,1)=-xs(2,1)/xsj(3) if(dabs(xsj(2)).gt.1.d-10) then xsi(2,3)=xs(1,1)/(-xsj(2)) xsi(1,3)=-xs(1,2)/(-xsj(2)) elseif(dabs(xsj(1)).gt.1.d-10) then xsi(2,3)=xs(2,1)/xsj(1) xsi(1,3)=-xs(2,2)/xsj(1) else xsi(2,3)=0.d0 xsi(1,3)=0.d0 endif elseif(dabs(xsj(2)).gt.1.d-10) then xsi(1,1)=xs(3,2)/(-xsj(2)) xsi(2,3)=xs(1,1)/(-xsj(2)) xsi(1,3)=-xs(1,2)/(-xsj(2)) xsi(2,1)=-xs(3,1)/(-xsj(2)) if(dabs(xsj(1)).gt.1.d-10) then xsi(1,2)=xs(3,2)/xsj(1) xsi(2,2)=-xs(3,1)/xsj(1) else xsi(1,2)=0.d0 xsi(2,2)=0.d0 endif else xsi(1,2)=xs(3,2)/xsj(1) xsi(2,3)=xs(2,1)/xsj(1) xsi(1,3)=-xs(2,2)/xsj(1) xsi(2,2)=-xs(3,1)/xsj(1) xsi(1,1)=0.d0 xsi(2,1)=0.d0 endif ! ! computation of the global derivatives of the shape functions ! do k=1,9 do j=1,3 sh(j)=shp(1,k)*xsi(1,j)+shp(2,k)*xsi(2,j) enddo do j=1,3 shp(j,k)=sh(j) enddo enddo ! elseif(iflag.eq.4) then ! ! second derivative of the shape functions in one dimension ! ddfxi1=1.d0 ddfxi2=-2.d0 ddfxi3=1.d0 ! ddfet1=1.d0 ddfet2=-2.d0 ddfet3=1.d0 ! ! local 2nd order derivatives of the shape functions: xi,xi-derivative ! shp(5,1)=ddfxi1*fet1 shp(5,2)=ddfxi3*fet1 shp(5,3)=ddfxi3*fet3 shp(5,4)=ddfxi1*fet3 shp(5,5)=ddfxi2*fet1 shp(5,6)=ddfxi3*fet2 shp(5,7)=ddfxi2*fet3 shp(5,8)=ddfxi1*fet2 shp(5,9)=ddfxi2*fet2 ! ! local 2nd order derivatives of the shape functions: xi,eta-derivative ! shp(6,1)=dfxi1*dfet1 shp(6,2)=dfxi3*dfet1 shp(6,3)=dfxi3*dfet3 shp(6,4)=dfxi1*dfet3 shp(6,5)=dfxi2*dfet1 shp(6,6)=dfxi3*dfet2 shp(6,7)=dfxi2*dfet3 shp(6,8)=dfxi1*dfet2 shp(6,9)=dfxi2*dfet2 ! ! local 2nd order derivatives of the shape functions: eta,eta-derivative ! shp(7,1)=fxi1*ddfet1 shp(7,2)=fxi3*ddfet1 shp(7,3)=fxi3*ddfet3 shp(7,4)=fxi1*ddfet3 shp(7,5)=fxi2*ddfet1 shp(7,6)=fxi3*ddfet2 shp(7,7)=fxi2*ddfet3 shp(7,8)=fxi1*ddfet2 shp(7,9)=fxi2*ddfet2 ! ! computation of the local 2nd derivatives of the global coordinates ! (xs) ! do i=1,3 do j=5,7 xs(i,j)=0.d0 do k=1,9 xs(i,j)=xs(i,j)+xl(i,k)*shp(j,k) enddo enddo enddo endif ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.10/src/shape9q.f
4
7115
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine shape9q(xi,et,xl,xsj,xs,shp,iflag) ! ! shape functions and derivatives for a 9-node quadratic ! isoparametric quadrilateral element. -1<=xi,et<=1 ! ! iflag=1: calculate only the value of the shape functions ! iflag=2: calculate the value of the shape functions, ! their derivatives w.r.t. the local coordinates ! and the Jacobian vector (local normal to the ! surface) ! iflag=3: calculate the value of the shape functions, the ! value of their derivatives w.r.t. the global ! coordinates and the Jacobian vector (local normal ! to the surface) ! iflag=4: calculate the value of the shape functions, the ! value of their 1st and 2nd order derivatives ! w.r.t. the local coordinates, the Jacobian vector ! (local normal to the surface) ! implicit none ! integer i,j,k,iflag ! real*8 shp(7,9),xs(3,7),xsi(2,3),xl(3,9),sh(3),xsj(3),xi,et, & fxi1,fxi2,fxi3,fet1,fet2,fet3,dfxi1,dfxi2,dfxi3,dfet1,dfet2, & dfet3,ddfxi1,ddfxi2,ddfxi3,ddfet1,ddfet2,ddfet3 ! intent(in) xi,et,xl,iflag ! intent(out) shp,xs,xsj ! ! shape functions and their glocal derivatives for an element ! described with two local parameters and three global ones. ! ! shape functions in one dimension ! fxi1=xi*(xi-1.d0)/2.d0 fxi2=(1.d0-xi)*(1.d0+xi) fxi3=xi*(xi+1.d0)/2.d0 ! fet1=et*(et-1.d0)/2.d0 fet2=(1.d0-et)*(1.d0+et) fet3=et*(et+1.d0)/2.d0 ! ! shape functions ! shp(4,1)=fxi1*fet1 shp(4,2)=fxi3*fet1 shp(4,3)=fxi3*fet3 shp(4,4)=fxi1*fet3 shp(4,5)=fxi2*fet1 shp(4,6)=fxi3*fet2 shp(4,7)=fxi2*fet3 shp(4,8)=fxi1*fet2 shp(4,9)=fxi2*fet2 ! if(iflag.eq.1) return ! ! derivative of the shape functions in one dimension ! dfxi1=(2.d0*xi-1.d0)/2.d0 dfxi2=-2.d0*xi dfxi3=(2.d0*xi+1.d0)/2.d0 ! dfet1=(2.d0*et-1.d0)/2.d0 dfet2=-2.d0*et dfet3=(2.d0*et+1.d0)/2.d0 ! ! local derivatives of the shape functions: xi-derivative ! shp(1,1)=dfxi1*fet1 shp(1,2)=dfxi3*fet1 shp(1,3)=dfxi3*fet3 shp(1,4)=dfxi1*fet3 shp(1,5)=dfxi2*fet1 shp(1,6)=dfxi3*fet2 shp(1,7)=dfxi2*fet3 shp(1,8)=dfxi1*fet2 shp(1,9)=dfxi2*fet2 ! ! local derivatives of the shape functions: eta-derivative ! shp(2,1)=fxi1*dfet1 shp(2,2)=fxi3*dfet1 shp(2,3)=fxi3*dfet3 shp(2,4)=fxi1*dfet3 shp(2,5)=fxi2*dfet1 shp(2,6)=fxi3*dfet2 shp(2,7)=fxi2*dfet3 shp(2,8)=fxi1*dfet2 shp(2,9)=fxi2*dfet2 ! ! computation of the local derivative of the global coordinates ! (xs) ! do i=1,3 do j=1,2 xs(i,j)=0.d0 do k=1,9 xs(i,j)=xs(i,j)+xl(i,k)*shp(j,k) enddo enddo enddo ! ! computation of the jacobian vector ! xsj(1)=xs(2,1)*xs(3,2)-xs(3,1)*xs(2,2) xsj(2)=xs(1,2)*xs(3,1)-xs(3,2)*xs(1,1) xsj(3)=xs(1,1)*xs(2,2)-xs(2,1)*xs(1,2) ! if(iflag.eq.3) then ! ! computation of the global derivative of the local coordinates ! (xsi) (inversion of xs) ! if(dabs(xsj(3)).gt.1.d-10) then xsi(1,1)=xs(2,2)/xsj(3) xsi(2,2)=xs(1,1)/xsj(3) xsi(1,2)=-xs(1,2)/xsj(3) xsi(2,1)=-xs(2,1)/xsj(3) if(dabs(xsj(2)).gt.1.d-10) then xsi(2,3)=xs(1,1)/(-xsj(2)) xsi(1,3)=-xs(1,2)/(-xsj(2)) elseif(dabs(xsj(1)).gt.1.d-10) then xsi(2,3)=xs(2,1)/xsj(1) xsi(1,3)=-xs(2,2)/xsj(1) else xsi(2,3)=0.d0 xsi(1,3)=0.d0 endif elseif(dabs(xsj(2)).gt.1.d-10) then xsi(1,1)=xs(3,2)/(-xsj(2)) xsi(2,3)=xs(1,1)/(-xsj(2)) xsi(1,3)=-xs(1,2)/(-xsj(2)) xsi(2,1)=-xs(3,1)/(-xsj(2)) if(dabs(xsj(1)).gt.1.d-10) then xsi(1,2)=xs(3,2)/xsj(1) xsi(2,2)=-xs(3,1)/xsj(1) else xsi(1,2)=0.d0 xsi(2,2)=0.d0 endif else xsi(1,2)=xs(3,2)/xsj(1) xsi(2,3)=xs(2,1)/xsj(1) xsi(1,3)=-xs(2,2)/xsj(1) xsi(2,2)=-xs(3,1)/xsj(1) xsi(1,1)=0.d0 xsi(2,1)=0.d0 endif ! ! computation of the global derivatives of the shape functions ! do k=1,9 do j=1,3 sh(j)=shp(1,k)*xsi(1,j)+shp(2,k)*xsi(2,j) enddo do j=1,3 shp(j,k)=sh(j) enddo enddo ! elseif(iflag.eq.4) then ! ! second derivative of the shape functions in one dimension ! ddfxi1=1.d0 ddfxi2=-2.d0 ddfxi3=1.d0 ! ddfet1=1.d0 ddfet2=-2.d0 ddfet3=1.d0 ! ! local 2nd order derivatives of the shape functions: xi,xi-derivative ! shp(5,1)=ddfxi1*fet1 shp(5,2)=ddfxi3*fet1 shp(5,3)=ddfxi3*fet3 shp(5,4)=ddfxi1*fet3 shp(5,5)=ddfxi2*fet1 shp(5,6)=ddfxi3*fet2 shp(5,7)=ddfxi2*fet3 shp(5,8)=ddfxi1*fet2 shp(5,9)=ddfxi2*fet2 ! ! local 2nd order derivatives of the shape functions: xi,eta-derivative ! shp(6,1)=dfxi1*dfet1 shp(6,2)=dfxi3*dfet1 shp(6,3)=dfxi3*dfet3 shp(6,4)=dfxi1*dfet3 shp(6,5)=dfxi2*dfet1 shp(6,6)=dfxi3*dfet2 shp(6,7)=dfxi2*dfet3 shp(6,8)=dfxi1*dfet2 shp(6,9)=dfxi2*dfet2 ! ! local 2nd order derivatives of the shape functions: eta,eta-derivative ! shp(7,1)=fxi1*ddfet1 shp(7,2)=fxi3*ddfet1 shp(7,3)=fxi3*ddfet3 shp(7,4)=fxi1*ddfet3 shp(7,5)=fxi2*ddfet1 shp(7,6)=fxi3*ddfet2 shp(7,7)=fxi2*ddfet3 shp(7,8)=fxi1*ddfet2 shp(7,9)=fxi2*ddfet2 ! ! computation of the local 2nd derivatives of the global coordinates ! (xs) ! do i=1,3 do j=5,7 xs(i,j)=0.d0 do k=1,9 xs(i,j)=xs(i,j)+xl(i,k)*shp(j,k) enddo enddo enddo endif ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.9/src/shape26h.f
4
9751
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine shape26h(xi,et,ze,xl,xsj,shp,iflag,konl) ! ! shape functions and derivatives for a 26-node quadratic ! isoparametric brick element. -1<=xi,et,ze<=1 ! ! iflag=1: calculate only the value of the shape functions ! iflag=2: calculate the value of the shape functions and ! the Jacobian determinant ! iflag=3: calculate the value of the shape functions, the ! value of their derivatives w.r.t. the global ! coordinates and the Jacobian determinant ! implicit none ! integer i,j,k,iflag,konl(26),jf(3,6),ifaceq(8,6) ! real*8 shp(4,26),xs(3,3),xsi(3,3),xl(3,26),shpe(4,26),dd, & dd1,dd2,dd3,xi,et,ze,xsj,omg,omh,omr,opg,oph,opr, & tpgphpr,tmgphpr,tmgmhpr,tpgmhpr,tpgphmr,tmgphmr,tmgmhmr,tpgmhmr, & omgopg,omhoph,omropr,omgmopg,omhmoph,omrmopr,fxi(3),fet(3), & fze(3),dfxi(3),dfet(3),dfze(3) ! intent(in) xi,et,ze,xl,iflag,konl ! intent(out) shp,xsj ! jf=reshape((/2,2,1,2,2,3,2,1,2,3,2,2,2,3,2,1,2,2/),(/3,6/)) ! ifaceq=reshape(( /4,3,2,1,11,10,9,12, & 5,6,7,8,13,14,15,16, & 1,2,6,5,9,18,13,17, & 2,3,7,6,10,19,14,18, & 3,4,8,7,11,20,15,19, & 4,1,5,8,12,17,16,20/),(/8,6/)) ! ! shape functions in one dimension ! fxi(1)=xi*(xi-1.d0)/2.d0 fxi(2)=(1.d0-xi)*(1.d0+xi) fxi(3)=xi*(xi+1.d0)/2.d0 ! fet(1)=et*(et-1.d0)/2.d0 fet(2)=(1.d0-et)*(1.d0+et) fet(3)=et*(et+1.d0)/2.d0 ! fze(1)=ze*(ze-1.d0)/2.d0 fze(2)=(1.d0-ze)*(1.d0+ze) fze(3)=ze*(ze+1.d0)/2.d0 ! ! shape functions and their glocal derivatives ! omg=1.d0-xi omh=1.d0-et omr=1.d0-ze opg=1.d0+xi oph=1.d0+et opr=1.d0+ze tpgphpr=opg+oph+ze tmgphpr=omg+oph+ze tmgmhpr=omg+omh+ze tpgmhpr=opg+omh+ze tpgphmr=opg+oph-ze tmgphmr=omg+oph-ze tmgmhmr=omg+omh-ze tpgmhmr=opg+omh-ze omgopg=omg*opg/4.d0 omhoph=omh*oph/4.d0 omropr=omr*opr/4.d0 omgmopg=(omg-opg)/4.d0 omhmoph=(omh-oph)/4.d0 omrmopr=(omr-opr)/4.d0 ! ! shape functions ! shp(4, 1)=-omg*omh*omr*tpgphpr/8.d0 shp(4, 2)=-opg*omh*omr*tmgphpr/8.d0 shp(4, 3)=-opg*oph*omr*tmgmhpr/8.d0 shp(4, 4)=-omg*oph*omr*tpgmhpr/8.d0 shp(4, 5)=-omg*omh*opr*tpgphmr/8.d0 shp(4, 6)=-opg*omh*opr*tmgphmr/8.d0 shp(4, 7)=-opg*oph*opr*tmgmhmr/8.d0 shp(4, 8)=-omg*oph*opr*tpgmhmr/8.d0 shp(4, 9)=omgopg*omh*omr shp(4,10)=omhoph*opg*omr shp(4,11)=omgopg*oph*omr shp(4,12)=omhoph*omg*omr shp(4,13)=omgopg*omh*opr shp(4,14)=omhoph*opg*opr shp(4,15)=omgopg*oph*opr shp(4,16)=omhoph*omg*opr shp(4,17)=omropr*omg*omh shp(4,18)=omropr*opg*omh shp(4,19)=omropr*opg*oph shp(4,20)=omropr*omg*oph ! ! correction for the extra nodes in the middle of the faces ! do i=1,6 if(konl(20+i).eq.konl(20)) then ! ! no extra node in this face ! shp(4,20+i)=0.d0 else shp(4,20+i)=fxi(jf(1,i))*fet(jf(2,i))*fze(jf(3,i)) do j=1,4 shp(4,ifaceq(j,i))=shp(4,ifaceq(j,i))+shp(4,20+i)/4.d0 enddo do j=5,8 shp(4,ifaceq(j,i))=shp(4,ifaceq(j,i))-shp(4,20+i)/2.d0 enddo endif enddo ! if(iflag.eq.1) return ! ! derivative of the shape functions in one dimension ! dfxi(1)=(2.d0*xi-1.d0)/2.d0 dfxi(2)=-2.d0*xi dfxi(3)=(2.d0*xi+1.d0)/2.d0 ! dfet(1)=(2.d0*et-1.d0)/2.d0 dfet(2)=-2.d0*et dfet(3)=(2.d0*et+1.d0)/2.d0 ! dfze(1)=(2.d0*ze-1.d0)/2.d0 dfze(2)=-2.d0*ze dfze(3)=(2.d0*ze+1.d0)/2.d0 ! ! local derivatives of the shape functions: xi-derivative ! shpe(1, 1)=omh*omr*(tpgphpr-omg)/8.d0 shpe(1, 2)=(opg-tmgphpr)*omh*omr/8.d0 shpe(1, 3)=(opg-tmgmhpr)*oph*omr/8.d0 shpe(1, 4)=oph*omr*(tpgmhpr-omg)/8.d0 shpe(1, 5)=omh*opr*(tpgphmr-omg)/8.d0 shpe(1, 6)=(opg-tmgphmr)*omh*opr/8.d0 shpe(1, 7)=(opg-tmgmhmr)*oph*opr/8.d0 shpe(1, 8)=oph*opr*(tpgmhmr-omg)/8.d0 shpe(1, 9)=omgmopg*omh*omr shpe(1,10)=omhoph*omr shpe(1,11)=omgmopg*oph*omr shpe(1,12)=-omhoph*omr shpe(1,13)=omgmopg*omh*opr shpe(1,14)=omhoph*opr shpe(1,15)=omgmopg*oph*opr shpe(1,16)=-omhoph*opr shpe(1,17)=-omropr*omh shpe(1,18)=omropr*omh shpe(1,19)=omropr*oph shpe(1,20)=-omropr*oph ! ! correction for the extra nodes in the middle of the faces ! do i=1,6 if(konl(20+i).eq.konl(20)) then ! ! no extra node in this face ! shpe(1,20+i)=0.d0 else shpe(1,20+i)=dfxi(jf(1,i))*fet(jf(2,i))*fze(jf(3,i)) do j=1,4 shpe(1,ifaceq(j,i))=shpe(1,ifaceq(j,i))+shpe(1,20+i)/4.d0 enddo do j=5,8 shpe(1,ifaceq(j,i))=shpe(1,ifaceq(j,i))-shpe(1,20+i)/2.d0 enddo endif enddo ! ! local derivatives of the shape functions: eta-derivative ! shpe(2, 1)=omg*omr*(tpgphpr-omh)/8.d0 shpe(2, 2)=opg*omr*(tmgphpr-omh)/8.d0 shpe(2, 3)=opg*(oph-tmgmhpr)*omr/8.d0 shpe(2, 4)=omg*(oph-tpgmhpr)*omr/8.d0 shpe(2, 5)=omg*opr*(tpgphmr-omh)/8.d0 shpe(2, 6)=opg*opr*(tmgphmr-omh)/8.d0 shpe(2, 7)=opg*(oph-tmgmhmr)*opr/8.d0 shpe(2, 8)=omg*(oph-tpgmhmr)*opr/8.d0 shpe(2, 9)=-omgopg*omr shpe(2,10)=omhmoph*opg*omr shpe(2,11)=omgopg*omr shpe(2,12)=omhmoph*omg*omr shpe(2,13)=-omgopg*opr shpe(2,14)=omhmoph*opg*opr shpe(2,15)=omgopg*opr shpe(2,16)=omhmoph*omg*opr shpe(2,17)=-omropr*omg shpe(2,18)=-omropr*opg shpe(2,19)=omropr*opg shpe(2,20)=omropr*omg ! ! correction for the extra nodes in the middle of the faces ! do i=1,6 if(konl(20+i).eq.konl(20)) then ! ! no extra node in this face ! shpe(2,20+i)=0.d0 else shpe(2,20+i)=fxi(jf(1,i))*dfet(jf(2,i))*fze(jf(3,i)) do j=1,4 shpe(2,ifaceq(j,i))=shpe(2,ifaceq(j,i))+shpe(2,20+i)/4.d0 enddo do j=5,8 shpe(2,ifaceq(j,i))=shpe(2,ifaceq(j,i))-shpe(2,20+i)/2.d0 enddo endif enddo ! ! local derivatives of the shape functions: zeta-derivative ! shpe(3, 1)=omg*omh*(tpgphpr-omr)/8.d0 shpe(3, 2)=opg*omh*(tmgphpr-omr)/8.d0 shpe(3, 3)=opg*oph*(tmgmhpr-omr)/8.d0 shpe(3, 4)=omg*oph*(tpgmhpr-omr)/8.d0 shpe(3, 5)=omg*omh*(opr-tpgphmr)/8.d0 shpe(3, 6)=opg*omh*(opr-tmgphmr)/8.d0 shpe(3, 7)=opg*oph*(opr-tmgmhmr)/8.d0 shpe(3, 8)=omg*oph*(opr-tpgmhmr)/8.d0 shpe(3, 9)=-omgopg*omh shpe(3,10)=-omhoph*opg shpe(3,11)=-omgopg*oph shpe(3,12)=-omhoph*omg shpe(3,13)=omgopg*omh shpe(3,14)=omhoph*opg shpe(3,15)=omgopg*oph shpe(3,16)=omhoph*omg shpe(3,17)=omrmopr*omg*omh shpe(3,18)=omrmopr*opg*omh shpe(3,19)=omrmopr*opg*oph shpe(3,20)=omrmopr*omg*oph ! ! correction for the extra nodes in the middle of the faces ! do i=1,6 if(konl(20+i).eq.konl(20)) then ! ! no extra node in this face ! shpe(3,20+i)=0.d0 else shpe(3,20+i)=fxi(jf(1,i))*fet(jf(2,i))*dfze(jf(3,i)) do j=1,4 shpe(3,ifaceq(j,i))=shpe(3,ifaceq(j,i))+shpe(3,20+i)/4.d0 enddo do j=5,8 shpe(3,ifaceq(j,i))=shpe(3,ifaceq(j,i))-shpe(3,20+i)/2.d0 enddo endif enddo ! ! computation of the local derivative of the global coordinates ! (xs) ! do i=1,3 do j=1,3 xs(i,j)=0.d0 do k=1,26 xs(i,j)=xs(i,j)+xl(i,k)*shpe(j,k) enddo enddo enddo ! ! computation of the jacobian determinant ! dd1=xs(2,2)*xs(3,3)-xs(2,3)*xs(3,2) dd2=xs(2,3)*xs(3,1)-xs(2,1)*xs(3,3) dd3=xs(2,1)*xs(3,2)-xs(2,2)*xs(3,1) xsj=xs(1,1)*dd1+xs(1,2)*dd2+xs(1,3)*dd3 ! if(iflag.eq.2) return ! dd=1.d0/xsj ! ! computation of the global derivative of the local coordinates ! (xsi) (inversion of xs) ! xsi(1,1)=dd1*dd xsi(1,2)=(xs(1,3)*xs(3,2)-xs(1,2)*xs(3,3))*dd xsi(1,3)=(xs(1,2)*xs(2,3)-xs(2,2)*xs(1,3))*dd xsi(2,1)=dd2*dd xsi(2,2)=(xs(1,1)*xs(3,3)-xs(3,1)*xs(1,3))*dd xsi(2,3)=(xs(1,3)*xs(2,1)-xs(1,1)*xs(2,3))*dd xsi(3,1)=dd3*dd xsi(3,2)=(xs(1,2)*xs(3,1)-xs(1,1)*xs(3,2))*dd xsi(3,3)=(xs(1,1)*xs(2,2)-xs(2,1)*xs(1,2))*dd ! ! computation of the global derivatives of the shape functions ! do k=1,26 do j=1,3 shp(j,k)=shpe(1,k)*xsi(1,j)+shpe(2,k)*xsi(2,j) & +shpe(3,k)*xsi(3,j) enddo enddo ! return end
gpl-2.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/elemental_subroutine_10.f90
72
2245
! { dg-do run } ! ! PR fortran/60066 ! ! Contributed by F Martinez Fadrique <[email protected]> ! ! Fixed by the patch for PR59906 but adds another, different test. ! module m_assertion_character implicit none type :: t_assertion_character character(len=8) :: name contains procedure :: assertion_character procedure :: write => assertion_array_write end type t_assertion_character contains impure elemental subroutine assertion_character( ast, name ) class(t_assertion_character), intent(out) :: ast character(len=*), intent(in) :: name ast%name = name end subroutine assertion_character subroutine assertion_array_write( ast, unit ) class(t_assertion_character), intent(in) :: ast character(*), intent(inOUT) :: unit write(unit,*) trim (unit(2:len(unit)))//trim (ast%name) end subroutine assertion_array_write end module m_assertion_character module m_assertion_array_character use m_assertion_character implicit none type :: t_assertion_array_character type(t_assertion_character), dimension(:), allocatable :: rast contains procedure :: assertion_array_character procedure :: write => assertion_array_character_write end type t_assertion_array_character contains subroutine assertion_array_character( ast, name, nast ) class(t_assertion_array_character), intent(out) :: ast character(len=*), intent(in) :: name integer, intent(in) :: nast integer :: i allocate ( ast%rast(nast) ) call ast%rast%assertion_character ( name ) end subroutine assertion_array_character subroutine assertion_array_character_write( ast, unit ) class(t_assertion_array_character), intent(in) :: ast CHARACTER(*), intent(inOUT) :: unit integer :: i do i = 1, size (ast%rast) call ast%rast(i)%write (unit) end do end subroutine assertion_array_character_write end module m_assertion_array_character program main use m_assertion_array_character implicit none type(t_assertion_array_character) :: ast character(len=8) :: name character (26) :: line = '' name = 'test' call ast%assertion_array_character ( name, 5 ) call ast%write (line) if (line(2:len (line)) .ne. "testtesttesttesttest") call abort end program main
gpl-2.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/assumed_charlen_function_5.f90
185
1073
! { dg-do compile } ! Tests the patch for PR28890, in which a reference to a legal reference ! to an assumed character length function, passed as a dummy, would ! cause an ICE. ! ! Contributed by Paul Thomas <[email protected]> ! character(*) function charrext (n) ! { dg-warning "Obsolescent feature" } character(26) :: alpha ="abcdefghijklmnopqrstuvwxyz" charrext = alpha (1:n) end function charrext character(26), external :: charrext interface integer(4) function test(charr, i) ! { dg-warning "Obsolescent feature" } character(*), external :: charr integer :: i end function test end interface do j = 1 , 26 m = test (charrext, j) m = ctest (charrext, 27 - j) end do contains integer(4) function ctest(charr, i) ! { dg-warning "Obsolescent feature" } character(*) :: charr integer :: i print *, charr(i) ctest = 1 end function ctest end integer(4) function test(charr, i) ! { dg-warning "Obsolescent feature" } character(*) :: charr integer :: i print *, charr(i) test = 1 end function test
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.15/src/extrapol_oel5.f
1
1721
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2018 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine extrapol_oel5(ielfa,ipnei,vel,xlet,gradofa,xxj, & nef,nfacea,nfaceb) ! ! correct the facial turbulent frequency gradients: ! Moukalled et al. p 289 ! implicit none ! integer ielfa(4,*),ipnei(*),nef,nfacea,nfaceb,i,k,iel1,iel2, & indexf ! real*8 vel(nef,0:7),xlet(*),gradofa(3,*),xxj(3,*),dd ! intent(in) ielfa,ipnei,vel,xlet,xxj, & nef,nfacea,nfaceb ! intent(inout) gradofa ! do i=nfacea,nfaceb iel2=ielfa(2,i) if(iel2.gt.0) then iel1=ielfa(1,i) indexf=ipnei(iel1)+ielfa(4,i) dd=(vel(iel2,7)-vel(iel1,7))/xlet(indexf) & -gradofa(1,i)*xxj(1,indexf) & -gradofa(2,i)*xxj(2,indexf) & -gradofa(3,i)*xxj(3,indexf) do k=1,3 gradofa(k,i)=gradofa(k,i)+dd*xxj(k,indexf) enddo endif enddo ! return end
gpl-2.0
ccilab/binutils
gdb/testsuite/gdb.fortran/subarray.f
13
1159
c Copyright 2005-2016 Free Software Foundation, Inc. c This program is free software; you can redistribute it and/or modify c it under the terms of the GNU General Public License as published by c the Free Software Foundation; either version 3 of the License, or c (at your option) any later version. c c This program is distributed in the hope that it will be useful, c but WITHOUT ANY WARRANTY; without even the implied warranty of c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the c GNU General Public License for more details. c c You should have received a copy of the GNU General Public License c along with this program. If not, see <http://www.gnu.org/licenses/>. c Ihis file is the Fortran source file for subarray.exp. It was written c by Wu Zhou. ([email protected]) PROGRAM subarray character *7 str integer array(7) c Initialize character array "str" and integer array "array". str = 'abcdefg' do i = 1, 7 array(i) = i end do write (*, *) str(2:4) write (*, *) str(:3) write (*, *) str(5:) write (*, *) str(:) END PROGRAM
gpl-3.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/integer_exponentiation_3.F90
136
4468
! { dg-do run { xfail spu-*-* } } ! FAILs on SPU because of wrong compile-time rounding mode ! { dg-options "" } ! { dg-options "-ffloat-store" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } ! ! module mod_check implicit none interface check module procedure check_i8 module procedure check_i4 module procedure check_r8 module procedure check_r4 module procedure check_c8 module procedure check_c4 end interface check interface acheck module procedure acheck_c8 module procedure acheck_c4 end interface acheck contains subroutine check_i8 (a, b) integer(kind=8), intent(in) :: a, b if (a /= b) call abort() end subroutine check_i8 subroutine check_i4 (a, b) integer(kind=4), intent(in) :: a, b if (a /= b) call abort() end subroutine check_i4 subroutine check_r8 (a, b) real(kind=8), intent(in) :: a, b if (a /= b) call abort() end subroutine check_r8 subroutine check_r4 (a, b) real(kind=4), intent(in) :: a, b if (a /= b) call abort() end subroutine check_r4 subroutine check_c8 (a, b) complex(kind=8), intent(in) :: a, b if (a /= b) call abort() end subroutine check_c8 subroutine check_c4 (a, b) complex(kind=4), intent(in) :: a, b if (a /= b) call abort() end subroutine check_c4 subroutine acheck_c8 (a, b) complex(kind=8), intent(in) :: a, b if (abs(a-b) > 1.d-9 * min(abs(a),abs(b))) call abort() end subroutine acheck_c8 subroutine acheck_c4 (a, b) complex(kind=4), intent(in) :: a, b if (abs(a-b) > 1.e-5 * min(abs(a),abs(b))) call abort() end subroutine acheck_c4 end module mod_check program test use mod_check implicit none integer(kind=4) :: i4 integer(kind=8) :: i8 real(kind=4) :: r4 real(kind=8) :: r8 complex(kind=4) :: c4 complex(kind=8) :: c8 #define TEST(base,exp,var) var = base; call check((var)**(exp),(base)**(exp)) #define ATEST(base,exp,var) var = base; call acheck((var)**(exp),(base)**(exp)) !!!!! INTEGER BASE !!!!! TEST(0,0,i4) TEST(0_8,0_8,i8) TEST(1,0,i4) TEST(1_8,0_8,i8) TEST(-1,0,i4) TEST(-1_8,0_8,i8) TEST(huge(0_4),0,i4) TEST(huge(0_8),0_8,i8) TEST(-huge(0_4)-1,0,i4) TEST(-huge(0_8)-1_8,0_8,i8) TEST(1,1,i4) TEST(1_8,1_8,i8) TEST(1,2,i4) TEST(1_8,2_8,i8) TEST(1,-1,i4) TEST(1_8,-1_8,i8) TEST(1,-2,i4) TEST(1_8,-2_8,i8) TEST(1,huge(0),i4) TEST(1_8,huge(0_8),i8) TEST(1,-huge(0)-1,i4) TEST(1_8,-huge(0_8)-1_8,i8) TEST(-1,1,i4) TEST(-1_8,1_8,i8) TEST(-1,2,i4) TEST(-1_8,2_8,i8) TEST(-1,-1,i4) TEST(-1_8,-1_8,i8) TEST(-1,-2,i4) TEST(-1_8,-2_8,i8) TEST(-1,huge(0),i4) TEST(-1_8,huge(0_8),i8) TEST(-1,-huge(0)-1,i4) TEST(-1_8,-huge(0_8)-1_8,i8) TEST(2,9,i4) TEST(2_8,9_8,i8) TEST(-2,9,i4) TEST(-2_8,9_8,i8) TEST(2,-9,i4) TEST(2_8,-9_8,i8) TEST(-2,-9,i4) TEST(-2_8,-9_8,i8) !!!!! REAL BASE !!!!! TEST(0.0,0,r4) TEST(0.0,1,r4) TEST(0.0,huge(0),r4) TEST(0.0,0_8,r4) TEST(0.0,1_8,r4) TEST(0.0,huge(0_8),r4) TEST(1.0,0,r4) TEST(1.0,1,r4) TEST(1.0,-1,r4) TEST(1.0,huge(0),r4) TEST(1.0,-huge(0)-1,r4) TEST(1.0,0_8,r4) TEST(1.0,1_8,r4) TEST(1.0,-1_8,r4) TEST(1.0,huge(0_8),r4) TEST(1.0,-huge(0_8)-1_8,r4) TEST(-1.0,0,r4) TEST(-1.0,1,r4) TEST(-1.0,-1,r4) TEST(-1.0,huge(0),r4) TEST(-1.0,-huge(0)-1,r4) TEST(-1.0,0_8,r4) TEST(-1.0,1_8,r4) TEST(-1.0,-1_8,r4) TEST(-1.0,huge(0_8),r4) TEST(-1.0,-huge(0_8)-1_8,r4) TEST(2.0,0,r4) TEST(2.0,1,r4) TEST(2.0,-1,r4) TEST(2.0,3,r4) TEST(2.0,-3,r4) TEST(2.0,0_8,r4) TEST(2.0,1_8,r4) TEST(2.0,-1_8,r4) TEST(2.0,3_8,r4) TEST(2.0,-3_8,r4) TEST(nearest(1.0,-1.0),0,r4) TEST(nearest(1.0,-1.0),huge(0_4),r4) ! { dg-warning "Arithmetic underflow" } TEST(nearest(1.0,-1.0),0_8,r4) TEST(nearest(1.0_8,-1.0),huge(0_8),r8) ! { dg-warning "Arithmetic underflow" } TEST(nearest(1.0,-1.0),107,r4) TEST(nearest(1.0,1.0),107,r4) !!!!! COMPLEX BASE !!!!! TEST((1.0,0.2),0,c4) TEST((1.0,0.2),1,c4) TEST((1.0,0.2),2,c4) ATEST((1.0,0.2),9,c4) ATEST((1.0,0.2),-1,c4) ATEST((1.0,0.2),-2,c4) ATEST((1.0,0.2),-9,c4) TEST((0.0,0.2),0,c4) TEST((0.0,0.2),1,c4) TEST((0.0,0.2),2,c4) ATEST((0.0,0.2),9,c4) ATEST((0.0,0.2),-1,c4) ATEST((0.0,0.2),-2,c4) ATEST((0.0,0.2),-9,c4) TEST((1.0,0.),0,c4) TEST((1.0,0.),1,c4) TEST((1.0,0.),2,c4) TEST((1.0,0.),9,c4) ATEST((1.0,0.),-1,c4) ATEST((1.0,0.),-2,c4) ATEST((1.0,0.),-9,c4) end program test
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.12/src/cd_own_albers.f
6
1222
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! author: Yannick Muller ! subroutine cd_own_albers(p1,p2,xl,d,cd,u,T1,R,kappa) ! implicit none ! real*8 d,xl,p1,p2,cd,T1,R,kappa,u ! p1=p1 p2=p2 xl=xl d=d u=u T1=T1 R=R kappa=Kappa cd=1.d0 write(*,*) '*WARNING while using subroutine cd_own_albers.f' write(*,*) 'cd implicitely taken equal to 1' ! return ! end
gpl-2.0
prool/ccx_prool
ARPACK/LAPACK/dgttrs.f
5
5299
SUBROUTINE DGTTRS( TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB, $ INFO ) * * -- LAPACK routine (version 2.0) -- * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., * Courant Institute, Argonne National Lab, and Rice University * September 30, 1994 * * .. Scalar Arguments .. CHARACTER TRANS INTEGER INFO, LDB, N, NRHS * .. * .. Array Arguments .. INTEGER IPIV( * ) DOUBLE PRECISION B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * ) * .. * * Purpose * ======= * * DGTTRS solves one of the systems of equations * A*X = B or A'*X = B, * with a tridiagonal matrix A using the LU factorization computed * by DGTTRF. * * Arguments * ========= * * TRANS (input) CHARACTER * Specifies the form of the system of equations: * = 'N': A * X = B (No transpose) * = 'T': A'* X = B (Transpose) * = 'C': A'* X = B (Conjugate transpose = Transpose) * * N (input) INTEGER * The order of the matrix A. N >= 0. * * NRHS (input) INTEGER * The number of right hand sides, i.e., the number of columns * of the matrix B. NRHS >= 0. * * DL (input) DOUBLE PRECISION array, dimension (N-1) * The (n-1) multipliers that define the matrix L from the * LU factorization of A. * * D (input) DOUBLE PRECISION array, dimension (N) * The n diagonal elements of the upper triangular matrix U from * the LU factorization of A. * * DU (input) DOUBLE PRECISION array, dimension (N-1) * The (n-1) elements of the first superdiagonal of U. * * DU2 (input) DOUBLE PRECISION array, dimension (N-2) * The (n-2) elements of the second superdiagonal of U. * * IPIV (input) INTEGER array, dimension (N) * The pivot indices; for 1 <= i <= n, row i of the matrix was * interchanged with row IPIV(i). IPIV(i) will always be either * i or i+1; IPIV(i) = i indicates a row interchange was not * required. * * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) * On entry, the right hand side matrix B. * On exit, B is overwritten by the solution matrix X. * * LDB (input) INTEGER * The leading dimension of the array B. LDB >= max(1,N). * * INFO (output) INTEGER * = 0: successful exit * < 0: if INFO = -i, the i-th argument had an illegal value * * ===================================================================== * * .. Local Scalars .. LOGICAL NOTRAN INTEGER I, J DOUBLE PRECISION TEMP * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * .. Executable Statements .. * INFO = 0 NOTRAN = LSAME( TRANS, 'N' ) IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT. $ LSAME( TRANS, 'C' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( NRHS.LT.0 ) THEN INFO = -3 ELSE IF( LDB.LT.MAX( N, 1 ) ) THEN INFO = -10 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DGTTRS', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 .OR. NRHS.EQ.0 ) $ RETURN * IF( NOTRAN ) THEN * * Solve A*X = B using the LU factorization of A, * overwriting each right hand side vector with its solution. * DO 30 J = 1, NRHS * * Solve L*x = b. * DO 10 I = 1, N - 1 IF( IPIV( I ).EQ.I ) THEN B( I+1, J ) = B( I+1, J ) - DL( I )*B( I, J ) ELSE TEMP = B( I, J ) B( I, J ) = B( I+1, J ) B( I+1, J ) = TEMP - DL( I )*B( I, J ) END IF 10 CONTINUE * * Solve U*x = b. * B( N, J ) = B( N, J ) / D( N ) IF( N.GT.1 ) $ B( N-1, J ) = ( B( N-1, J )-DU( N-1 )*B( N, J ) ) / $ D( N-1 ) DO 20 I = N - 2, 1, -1 B( I, J ) = ( B( I, J )-DU( I )*B( I+1, J )-DU2( I )* $ B( I+2, J ) ) / D( I ) 20 CONTINUE 30 CONTINUE ELSE * * Solve A' * X = B. * DO 60 J = 1, NRHS * * Solve U'*x = b. * B( 1, J ) = B( 1, J ) / D( 1 ) IF( N.GT.1 ) $ B( 2, J ) = ( B( 2, J )-DU( 1 )*B( 1, J ) ) / D( 2 ) DO 40 I = 3, N B( I, J ) = ( B( I, J )-DU( I-1 )*B( I-1, J )-DU2( I-2 )* $ B( I-2, J ) ) / D( I ) 40 CONTINUE * * Solve L'*x = b. * DO 50 I = N - 1, 1, -1 IF( IPIV( I ).EQ.I ) THEN B( I, J ) = B( I, J ) - DL( I )*B( I+1, J ) ELSE TEMP = B( I+1, J ) B( I+1, J ) = B( I, J ) - DL( I )*TEMP B( I, J ) = TEMP END IF 50 CONTINUE 60 CONTINUE END IF * * End of DGTTRS * END
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.16/src/createelemneigh.f
1
2010
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine createelemneigh(nk,iponoel,inoel,istartnneigh, & ialnneigh,icheckelems,istarteneigh,ialeneigh) ! implicit none ! integer nk,iponoel(*),inoel(2,*),istartnneigh(*),ialnneigh(*), & ifree,index,i,j,ipos,na,nb,node,istarteneigh(*),ialeneigh(*), & icheckelems(*) ! ! determining all the elements to which the objective ! nodes of the neighboring elements of a node i belong ! They are stored in ialeneigh(istarteneigh(i)).. ! ...up to..... ialeneigh(istarteneigh(i+1)-1) ! ifree=1 do i=1,nk ! istarteneigh(i)=ifree index=iponoel(i) if(index.eq.0) cycle na=istartnneigh(i) nb=istartnneigh(i+1)-1 ! do j=na,nb ! node=ialnneigh(j) index=iponoel(node) ! do if(index.eq.0) exit ipos=inoel(1,index) if(icheckelems(ipos).ne.i) then ialeneigh(ifree)=inoel(1,index) ifree=ifree+1 icheckelems(ipos)=i endif index=inoel(2,index) enddo enddo enddo istarteneigh(nk+1)=ifree ! return end
gpl-2.0
prool/ccx_prool
ARPACK/SRC/zgetv0.f
3
12987
c\BeginDoc c c\Name: zgetv0 c c\Description: c Generate a random initial residual vector for the Arnoldi process. c Force the residual vector to be in the range of the operator OP. c c\Usage: c call zgetv0 c ( IDO, BMAT, ITRY, INITV, N, J, V, LDV, RESID, RNORM, c IPNTR, WORKD, IERR ) c c\Arguments c IDO Integer. (INPUT/OUTPUT) c Reverse communication flag. IDO must be zero on the first c call to zgetv0. c ------------------------------------------------------------- c IDO = 0: first call to the reverse communication interface c IDO = -1: compute Y = OP * X where c IPNTR(1) is the pointer into WORKD for X, c IPNTR(2) is the pointer into WORKD for Y. c This is for the initialization phase to force the c starting vector into the range of OP. c IDO = 2: compute Y = B * X where c IPNTR(1) is the pointer into WORKD for X, c IPNTR(2) is the pointer into WORKD for Y. c IDO = 99: done c ------------------------------------------------------------- c c BMAT Character*1. (INPUT) c BMAT specifies the type of the matrix B in the (generalized) c eigenvalue problem A*x = lambda*B*x. c B = 'I' -> standard eigenvalue problem A*x = lambda*x c B = 'G' -> generalized eigenvalue problem A*x = lambda*B*x c c ITRY Integer. (INPUT) c ITRY counts the number of times that zgetv0 is called. c It should be set to 1 on the initial call to zgetv0. c c INITV Logical variable. (INPUT) c .TRUE. => the initial residual vector is given in RESID. c .FALSE. => generate a random initial residual vector. c c N Integer. (INPUT) c Dimension of the problem. c c J Integer. (INPUT) c Index of the residual vector to be generated, with respect to c the Arnoldi process. J > 1 in case of a "restart". c c V Complex*16 N by J array. (INPUT) c The first J-1 columns of V contain the current Arnoldi basis c if this is a "restart". c c LDV Integer. (INPUT) c Leading dimension of V exactly as declared in the calling c program. c c RESID Complex*16 array of length N. (INPUT/OUTPUT) c Initial residual vector to be generated. If RESID is c provided, force RESID into the range of the operator OP. c c RNORM Double precision scalar. (OUTPUT) c B-norm of the generated residual. c c IPNTR Integer array of length 3. (OUTPUT) c c WORKD Complex*16 work array of length 2*N. (REVERSE COMMUNICATION). c On exit, WORK(1:N) = B*RESID to be used in SSAITR. c c IERR Integer. (OUTPUT) c = 0: Normal exit. c = -1: Cannot generate a nontrivial restarted residual vector c in the range of the operator OP. c c\EndDoc c c----------------------------------------------------------------------- c c\BeginLib c c\Local variables: c xxxxxx Complex*16 c c\References: c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), c pp 357-385. c c\Routines called: c second ARPACK utility routine for timing. c zvout ARPACK utility routine that prints vectors. c zlarnv LAPACK routine for generating a random vector. c zgemv Level 2 BLAS routine for matrix vector multiplication. c zcopy Level 1 BLAS that copies one vector to another. c zdotc Level 1 BLAS that computes the scalar product of two vectors. c dznrm2 Level 1 BLAS that computes the norm of a vector. c c\Author c Danny Sorensen Phuong Vu c Richard Lehoucq CRPC / Rice University c Dept. of Computational & Houston, Texas c Applied Mathematics c Rice University c Houston, Texas c c\SCCS Information: @(#) c FILE: getv0.F SID: 2.3 DATE OF SID: 8/27/96 RELEASE: 2 c c\EndLib c c----------------------------------------------------------------------- c subroutine zgetv0 & ( ido, bmat, itry, initv, n, j, v, ldv, resid, rnorm, & ipntr, workd, ierr ) c c %----------------------------------------------------% c | Include files for debugging and timing information | c %----------------------------------------------------% c include 'debug.h' include 'stat.h' c c %------------------% c | Scalar Arguments | c %------------------% c character bmat*1 logical initv integer ido, ierr, itry, j, ldv, n Double precision & rnorm c c %-----------------% c | Array Arguments | c %-----------------% c integer ipntr(3) Complex*16 & resid(n), v(ldv,j), workd(2*n) c c %------------% c | Parameters | c %------------% c Complex*16 & one, zero Double precision & rzero parameter (one = (1.0D+0, 0.0D+0), zero = (0.0D+0, 0.0D+0), & rzero = 0.0D+0) c c %------------------------% c | Local Scalars & Arrays | c %------------------------% c logical first, inits, orth integer idist, iseed(4), iter, msglvl, jj Double precision & rnorm0 Complex*16 & cnorm save first, iseed, inits, iter, msglvl, orth, rnorm0 c c %----------------------% c | External Subroutines | c %----------------------% c external zcopy, zgemv, zlarnv, zvout, second c c %--------------------% c | External Functions | c %--------------------% c Double precision & dznrm2, dlapy2 Complex*16 & zdotc external zdotc, dznrm2, dlapy2 c c %-----------------% c | Data Statements | c %-----------------% c data inits /.true./ c c %-----------------------% c | Executable Statements | c %-----------------------% c c c %-----------------------------------% c | Initialize the seed of the LAPACK | c | random number generator | c %-----------------------------------% c if (inits) then iseed(1) = 1 iseed(2) = 3 iseed(3) = 5 iseed(4) = 7 inits = .false. end if c if (ido .eq. 0) then c c %-------------------------------% c | Initialize timing statistics | c | & message level for debugging | c %-------------------------------% c call second (t0) msglvl = mgetv0 c ierr = 0 iter = 0 first = .FALSE. orth = .FALSE. c c %-----------------------------------------------------% c | Possibly generate a random starting vector in RESID | c | Use a LAPACK random number generator used by the | c | matrix generation routines. | c | idist = 1: uniform (0,1) distribution; | c | idist = 2: uniform (-1,1) distribution; | c | idist = 3: normal (0,1) distribution; | c %-----------------------------------------------------% c if (.not.initv) then idist = 2 call zlarnv (idist, iseed, n, resid) end if c c %----------------------------------------------------------% c | Force the starting vector into the range of OP to handle | c | the generalized problem when B is possibly (singular). | c %----------------------------------------------------------% c call second (t2) if (bmat .eq. 'G') then nopx = nopx + 1 ipntr(1) = 1 ipntr(2) = n + 1 call zcopy (n, resid, 1, workd, 1) ido = -1 go to 9000 end if end if c c %----------------------------------------% c | Back from computing B*(initial-vector) | c %----------------------------------------% c if (first) go to 20 c c %-----------------------------------------------% c | Back from computing B*(orthogonalized-vector) | c %-----------------------------------------------% c if (orth) go to 40 c call second (t3) tmvopx = tmvopx + (t3 - t2) c c %------------------------------------------------------% c | Starting vector is now in the range of OP; r = OP*r; | c | Compute B-norm of starting vector. | c %------------------------------------------------------% c call second (t2) first = .TRUE. if (bmat .eq. 'G') then nbx = nbx + 1 call zcopy (n, workd(n+1), 1, resid, 1) ipntr(1) = n + 1 ipntr(2) = 1 ido = 2 go to 9000 else if (bmat .eq. 'I') then call zcopy (n, resid, 1, workd, 1) end if c 20 continue c if (bmat .eq. 'G') then call second (t3) tmvbx = tmvbx + (t3 - t2) end if c first = .FALSE. if (bmat .eq. 'G') then cnorm = zdotc (n, resid, 1, workd, 1) rnorm0 = sqrt(dlapy2(dble(cnorm),dimag(cnorm))) else if (bmat .eq. 'I') then rnorm0 = dznrm2(n, resid, 1) end if rnorm = rnorm0 c c %---------------------------------------------% c | Exit if this is the very first Arnoldi step | c %---------------------------------------------% c if (j .eq. 1) go to 50 c c %---------------------------------------------------------------- c | Otherwise need to B-orthogonalize the starting vector against | c | the current Arnoldi basis using Gram-Schmidt with iter. ref. | c | This is the case where an invariant subspace is encountered | c | in the middle of the Arnoldi factorization. | c | | c | s = V^{T}*B*r; r = r - V*s; | c | | c | Stopping criteria used for iter. ref. is discussed in | c | Parlett's book, page 107 and in Gragg & Reichel TOMS paper. | c %---------------------------------------------------------------% c orth = .TRUE. 30 continue c call zgemv ('C', n, j-1, one, v, ldv, workd, 1, & zero, workd(n+1), 1) call zgemv ('N', n, j-1, -one, v, ldv, workd(n+1), 1, & one, resid, 1) c c %----------------------------------------------------------% c | Compute the B-norm of the orthogonalized starting vector | c %----------------------------------------------------------% c call second (t2) if (bmat .eq. 'G') then nbx = nbx + 1 call zcopy (n, resid, 1, workd(n+1), 1) ipntr(1) = n + 1 ipntr(2) = 1 ido = 2 go to 9000 else if (bmat .eq. 'I') then call zcopy (n, resid, 1, workd, 1) end if c 40 continue c if (bmat .eq. 'G') then call second (t3) tmvbx = tmvbx + (t3 - t2) end if c if (bmat .eq. 'G') then cnorm = zdotc (n, resid, 1, workd, 1) rnorm = sqrt(dlapy2(dble(cnorm),dimag(cnorm))) else if (bmat .eq. 'I') then rnorm = dznrm2(n, resid, 1) end if c c %--------------------------------------% c | Check for further orthogonalization. | c %--------------------------------------% c if (msglvl .gt. 2) then call dvout (logfil, 1, rnorm0, ndigit, & '_getv0: re-orthonalization ; rnorm0 is') call dvout (logfil, 1, rnorm, ndigit, & '_getv0: re-orthonalization ; rnorm is') end if c if (rnorm .gt. 0.717*rnorm0) go to 50 c iter = iter + 1 if (iter .le. 1) then c c %-----------------------------------% c | Perform iterative refinement step | c %-----------------------------------% c rnorm0 = rnorm go to 30 else c c %------------------------------------% c | Iterative refinement step "failed" | c %------------------------------------% c do 45 jj = 1, n resid(jj) = zero 45 continue rnorm = rzero ierr = -1 end if c 50 continue c if (msglvl .gt. 0) then call dvout (logfil, 1, rnorm, ndigit, & '_getv0: B-norm of initial / restarted starting vector') end if if (msglvl .gt. 2) then call zvout (logfil, n, resid, ndigit, & '_getv0: initial / restarted starting vector') end if ido = 99 c call second (t1) tgetv0 = tgetv0 + (t1 - t0) c 9000 continue return c c %---------------% c | End of zgetv0 | c %---------------% c end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.16/src/restartshort.f
1
9579
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine restartshort(nset,nload,nbody,nforc,nboun,nk,ne, & nmpc,nalset,nmat,ntmat,npmat,norien,nam,nprint,mi, & ntrans,ncs,namtot,ncmat,memmpc,ne1d,ne2d,nflow, & set,meminset,rmeminset,jobnamec,irestartstep,icntrl,ithermal, & nener,nstate_,ntie,nslavs,nkon,mcs,nprop,mortar,ifacecount, & nintpoint,infree,nef) ! ! istartset := meminset ! iendset := rmeminset ! implicit none ! character*80 version character*81 set(*) character*132 fnrstrt,jobnamec(*) ! integer istep,nset,nload,nforc,nboun,nk,ne,nmpc,nalset,nmat, & ntmat,npmat,norien,nam,nprint,mi(*),ntrans,ncs,nprop, & namtot,ncmat,memmpc,ne1d,ne2d,nflow,infree(4),mortar, & nmethod,iperturb(2),meminset(*),rmeminset(*),nintpoint, & i,j,k,ipos,icntrl,nener,irestartstep,im0,im1,im2,mem,iact, & istat,nkon,nlabel,iplas,ithermal,nstate_,iprestr,maxlenmpc, & mcs,ntie,nbody,nslavs,ifacecount,iversion,nef ! if(icntrl.eq.0) then ! ! this branch is called from readinput.c ! its purpose is to read the value of nset ! ! determining the name of the restart file ! ipos=index(jobnamec(1),char(0)) fnrstrt(1:ipos-1)=jobnamec(1)(1:ipos-1) fnrstrt(ipos:ipos+3)=".rin" do i=ipos+4,132 fnrstrt(i:i)=' ' enddo ! ! opening the restart file ! open(15,file=fnrstrt,ACCESS='SEQUENTIAL',FORM='UNFORMATTED', & err=15) ! iversion=0 ! do ! read(15,iostat=istat) version if(istat.lt.0) then if(irestartstep.eq.0) then ! ! reading the last step ! irestartstep=istep close(15) open(15,file=fnrstrt,ACCESS='SEQUENTIAL', & FORM='UNFORMATTED',err=15) read(15) version else write(*,*) '*ERROR in restartshort: requested step' write(*,*) ' is not in the restart file' call exit(201) endif endif ! if(iversion.eq.0) then write(*,*) write(*,*) '*INFO: restart file ',fnrstrt write(*,*) ' has been opened for reading.' write(*,*) ' it was created with CalculiX ',version iversion=1 endif ! read(15)istep ! ! reading the number of sets ! read(15)nset ! if(istep.eq.irestartstep) exit ! read(15)nalset ! ! load size ! read(15)nload read(15)nbody read(15)nforc read(15)nboun read(15)nflow ! ! mesh size ! read(15)nk read(15)ne read(15)nef read(15)nkon read(15)(mi(i),i=1,3) ! ! constraint size ! read(15)nmpc read(15)memmpc read(15)maxlenmpc ! ! material size ! read(15)nmat read(15)ntmat read(15)npmat read(15)ncmat ! ! property info ! read(15)nprop ! ! transformation size ! read(15)norien read(15)ntrans ! ! amplitude size ! read(15)nam read(15)namtot ! ! print size ! read(15)nprint read(15)nlabel ! ! tie size ! read(15)ntie ! ! cyclic symmetry size ! read(15)ncs read(15)mcs ! ! 1d and 2d element size ! read(15)ne1d read(15)ne2d read(15)(infree(i),i=1,4) ! ! procedure info ! read(15)nmethod read(15)(iperturb(i),i=1,2) read(15)nener read(15)iplas read(15)ithermal read(15)nstate_ read(15)nslavs read(15)iprestr read(15)mortar if(mortar.eq.1) then read(15)ifacecount read(15)nintpoint endif ! ! skipping the next entries ! call skip(nset,nalset,nload,nbody, & nforc,nboun,nk,ne,nkon, & mi,nmpc,memmpc,nmat,ntmat,npmat,ncmat,norien, & ntrans,nam,nprint,nlabel,ncs,ne1d,ne2d,infree, & nmethod,iperturb,nener,ithermal,nstate_,iprestr, & mcs,ntie,nslavs,nprop,mortar,ifacecount,nintpoint, & nef) ! enddo ! close(15) ! return endif ! ! determining the name of the restart file ! ipos=index(jobnamec(1),char(0)) fnrstrt(1:ipos-1)=jobnamec(1)(1:ipos-1) fnrstrt(ipos:ipos+3)=".rin" do i=ipos+4,132 fnrstrt(i:i)=' ' enddo ! ! opening the restart file ! open(15,file=fnrstrt,ACCESS='SEQUENTIAL',FORM='UNFORMATTED', & err=15) ! do ! read(15,iostat=istat) version if(istat.lt.0) then if(irestartstep.eq.0) then ! ! reading the last step ! irestartstep=istep close(15) open(15,file=fnrstrt,ACCESS='SEQUENTIAL', & FORM='UNFORMATTED',err=15) read(15) version else write(*,*) '*ERROR in restartshort: requested step' write(*,*) ' is not in the restart file' call exit(201) endif endif read(15)istep ! ! set size ! read(15)nset read(15)nalset ! ! load size ! read(15)nload read(15)nbody read(15)nforc read(15)nboun read(15)nflow ! ! mesh size ! read(15)nk read(15)ne read(15)nef read(15)nkon read(15)(mi(i),i=1,3) ! ! constraint size ! read(15)nmpc read(15)memmpc read(15)maxlenmpc ! ! material size ! read(15)nmat read(15)ntmat read(15)npmat read(15)ncmat ! ! property info ! read(15)nprop ! ! transformation size ! read(15)norien read(15)ntrans ! ! amplitude size ! read(15)nam read(15)namtot ! ! print size ! read(15)nprint read(15)nlabel ! ! tie size ! read(15)ntie ! ! cyclic symmetry size ! read(15)ncs read(15)mcs ! ! 1d and 2d element size ! read(15)ne1d read(15)ne2d read(15)(infree(i),i=1,4) ! ! procedure info ! read(15)nmethod read(15)(iperturb(i),i=1,2) read(15)nener read(15)iplas read(15)ithermal read(15)nstate_ read(15)nslavs read(15)iprestr read(15)mortar if(mortar.eq.1) then read(15)ifacecount read(15)nintpoint endif ! if(istep.eq.irestartstep) exit ! ! skipping the next entries ! call skip(nset,nalset,nload,nbody,nforc,nboun,nk,ne,nkon, & mi,nmpc,memmpc,nmat,ntmat,npmat,ncmat,norien,ntrans, & nam,nprint,nlabel,ncs,ne1d,ne2d,infree,nmethod, & iperturb,nener,ithermal,nstate_,iprestr,mcs,ntie, & nslavs,nprop,mortar,ifacecount,nintpoint,nef) ! enddo ! ! sets ! read(15)(set(i),i=1,nset) ! ! the contents of istartset is temporarily stored in meminset ! read(15)(meminset(i),i=1,nset) ! ! the contents of iendset is temporarily stored in rmeminset ! read(15)(rmeminset(i),i=1,nset) ! ! reordering the information of istartset, iendset and ialset ! into meminset and rmeminset ! iact=0 do j=1,nalset if(iact.eq.0) then do k=1,nset if(meminset(k).eq.j) then meminset(k)=0 mem=0 iact=1 exit endif enddo if(k.gt.nset) cycle endif mem=mem+1 im2=im1 im1=im0 read(15) im0 if(im0.gt.0) then meminset(k)=meminset(k)+1 else ! ! im0<0 and two elements are already stored ! meminset(k)=meminset(k)+(im2-im1)/im0-1 endif if(rmeminset(k).eq.j) then iact=0 rmeminset(k)=mem ! ! make set k ineligible in further iterations ! meminset(k)=-meminset(k) endif enddo ! ! restore the sign of meminset ! do k=1,nset meminset(k)=-meminset(k) enddo ! close(15) ! return ! 15 write(*,*) '*ERROR in restartshort: could not open file ',fnrstrt call exit(201) end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.10/src/depvars.f
6
2603
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine depvars(inpc,textpart,nelcon,nmat, & nstate_,irstrt,istep,istat,n,iline,ipol,inl,ipoinp,inp, & ncocon,ipoinpc) ! ! reading the input deck: *DEPVAR ! implicit none ! character*1 inpc(*) character*132 textpart(16) ! integer nelcon(2,*),nmat,istep,nstate_,ncocon(2,*),ipoinpc(0:*), & n,key,istat,nstate,irstrt,iline,ipol,inl,ipoinp(2,*),inp(3,*),i ! if((istep.gt.0).and.(irstrt.ge.0)) then write(*,*) '*ERROR in depvars: *DEPVAR should be placed' write(*,*) ' before all step definitions' call exit(201) endif ! if(nmat.eq.0) then write(*,*) '*ERROR in depvars: *DEPVAR should be preceded' write(*,*) ' by a *MATERIAL card' call exit(201) endif ! c if((nelcon(1,nmat).gt.-100).and.(ncocon(1,nmat).gt.-100)) then c write(*,*) '*ERROR in depvars: *DEPVAR should be preceded' c write(*,*) ' by an *USER MATERIAL card' c call exit(201) c endif ! do i=2,n write(*,*) & '*WARNING in depvars: parameter not recognized:' write(*,*) ' ', & textpart(i)(1:index(textpart(i),' ')-1) call inputwarning(inpc,ipoinpc,iline, &"*DEPVAR%") enddo ! call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) if((istat.lt.0).or.(key.eq.1)) then write(*,*) '*ERROR in depvars: incomplete definition' call exit(201) endif read(textpart(1)(1:10),'(i10)',iostat=istat) nstate if(istat.gt.0) call inputerror(inpc,ipoinpc,iline, &"*DEPVAR%") nstate_=max(nstate_,nstate) ! call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) ! return end
gpl-2.0
dowoncha/COMP575
PA4/lib/eigen/blas/testing/cblat1.f
245
31188
PROGRAM CBLAT1 * Test program for the COMPLEX Level 1 BLAS. * Based upon the original BLAS test routine together with: * F06GAF Example Program Text * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, MODE, N LOGICAL PASS * .. Local Scalars .. REAL SFAC INTEGER IC * .. External Subroutines .. EXTERNAL CHECK1, CHECK2, HEADER * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS * .. Data statements .. DATA SFAC/9.765625E-4/ * .. Executable Statements .. WRITE (NOUT,99999) DO 20 IC = 1, 10 ICASE = IC CALL HEADER * * Initialize PASS, INCX, INCY, and MODE for a new case. * The value 9999 for INCX, INCY or MODE will appear in the * detailed output, if any, for cases that do not involve * these parameters. * PASS = .TRUE. INCX = 9999 INCY = 9999 MODE = 9999 IF (ICASE.LE.5) THEN CALL CHECK2(SFAC) ELSE IF (ICASE.GE.6) THEN CALL CHECK1(SFAC) END IF * -- Print IF (PASS) WRITE (NOUT,99998) 20 CONTINUE STOP * 99999 FORMAT (' Complex BLAS Test Program Results',/1X) 99998 FORMAT (' ----- PASS -----') END SUBROUTINE HEADER * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, MODE, N LOGICAL PASS * .. Local Arrays .. CHARACTER*6 L(10) * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS * .. Data statements .. DATA L(1)/'CDOTC '/ DATA L(2)/'CDOTU '/ DATA L(3)/'CAXPY '/ DATA L(4)/'CCOPY '/ DATA L(5)/'CSWAP '/ DATA L(6)/'SCNRM2'/ DATA L(7)/'SCASUM'/ DATA L(8)/'CSCAL '/ DATA L(9)/'CSSCAL'/ DATA L(10)/'ICAMAX'/ * .. Executable Statements .. WRITE (NOUT,99999) ICASE, L(ICASE) RETURN * 99999 FORMAT (/' Test of subprogram number',I3,12X,A6) END SUBROUTINE CHECK1(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, MODE, N LOGICAL PASS * .. Local Scalars .. COMPLEX CA REAL SA INTEGER I, J, LEN, NP1 * .. Local Arrays .. COMPLEX CTRUE5(8,5,2), CTRUE6(8,5,2), CV(8,5,2), CX(8), + MWPCS(5), MWPCT(5) REAL STRUE2(5), STRUE4(5) INTEGER ITRUE3(5) * .. External Functions .. REAL SCASUM, SCNRM2 INTEGER ICAMAX EXTERNAL SCASUM, SCNRM2, ICAMAX * .. External Subroutines .. EXTERNAL CSCAL, CSSCAL, CTEST, ITEST1, STEST1 * .. Intrinsic Functions .. INTRINSIC MAX * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS * .. Data statements .. DATA SA, CA/0.3E0, (0.4E0,-0.7E0)/ DATA ((CV(I,J,1),I=1,8),J=1,5)/(0.1E0,0.1E0), + (1.0E0,2.0E0), (1.0E0,2.0E0), (1.0E0,2.0E0), + (1.0E0,2.0E0), (1.0E0,2.0E0), (1.0E0,2.0E0), + (1.0E0,2.0E0), (0.3E0,-0.4E0), (3.0E0,4.0E0), + (3.0E0,4.0E0), (3.0E0,4.0E0), (3.0E0,4.0E0), + (3.0E0,4.0E0), (3.0E0,4.0E0), (3.0E0,4.0E0), + (0.1E0,-0.3E0), (0.5E0,-0.1E0), (5.0E0,6.0E0), + (5.0E0,6.0E0), (5.0E0,6.0E0), (5.0E0,6.0E0), + (5.0E0,6.0E0), (5.0E0,6.0E0), (0.1E0,0.1E0), + (-0.6E0,0.1E0), (0.1E0,-0.3E0), (7.0E0,8.0E0), + (7.0E0,8.0E0), (7.0E0,8.0E0), (7.0E0,8.0E0), + (7.0E0,8.0E0), (0.3E0,0.1E0), (0.1E0,0.4E0), + (0.4E0,0.1E0), (0.1E0,0.2E0), (2.0E0,3.0E0), + (2.0E0,3.0E0), (2.0E0,3.0E0), (2.0E0,3.0E0)/ DATA ((CV(I,J,2),I=1,8),J=1,5)/(0.1E0,0.1E0), + (4.0E0,5.0E0), (4.0E0,5.0E0), (4.0E0,5.0E0), + (4.0E0,5.0E0), (4.0E0,5.0E0), (4.0E0,5.0E0), + (4.0E0,5.0E0), (0.3E0,-0.4E0), (6.0E0,7.0E0), + (6.0E0,7.0E0), (6.0E0,7.0E0), (6.0E0,7.0E0), + (6.0E0,7.0E0), (6.0E0,7.0E0), (6.0E0,7.0E0), + (0.1E0,-0.3E0), (8.0E0,9.0E0), (0.5E0,-0.1E0), + (2.0E0,5.0E0), (2.0E0,5.0E0), (2.0E0,5.0E0), + (2.0E0,5.0E0), (2.0E0,5.0E0), (0.1E0,0.1E0), + (3.0E0,6.0E0), (-0.6E0,0.1E0), (4.0E0,7.0E0), + (0.1E0,-0.3E0), (7.0E0,2.0E0), (7.0E0,2.0E0), + (7.0E0,2.0E0), (0.3E0,0.1E0), (5.0E0,8.0E0), + (0.1E0,0.4E0), (6.0E0,9.0E0), (0.4E0,0.1E0), + (8.0E0,3.0E0), (0.1E0,0.2E0), (9.0E0,4.0E0)/ DATA STRUE2/0.0E0, 0.5E0, 0.6E0, 0.7E0, 0.7E0/ DATA STRUE4/0.0E0, 0.7E0, 1.0E0, 1.3E0, 1.7E0/ DATA ((CTRUE5(I,J,1),I=1,8),J=1,5)/(0.1E0,0.1E0), + (1.0E0,2.0E0), (1.0E0,2.0E0), (1.0E0,2.0E0), + (1.0E0,2.0E0), (1.0E0,2.0E0), (1.0E0,2.0E0), + (1.0E0,2.0E0), (-0.16E0,-0.37E0), (3.0E0,4.0E0), + (3.0E0,4.0E0), (3.0E0,4.0E0), (3.0E0,4.0E0), + (3.0E0,4.0E0), (3.0E0,4.0E0), (3.0E0,4.0E0), + (-0.17E0,-0.19E0), (0.13E0,-0.39E0), + (5.0E0,6.0E0), (5.0E0,6.0E0), (5.0E0,6.0E0), + (5.0E0,6.0E0), (5.0E0,6.0E0), (5.0E0,6.0E0), + (0.11E0,-0.03E0), (-0.17E0,0.46E0), + (-0.17E0,-0.19E0), (7.0E0,8.0E0), (7.0E0,8.0E0), + (7.0E0,8.0E0), (7.0E0,8.0E0), (7.0E0,8.0E0), + (0.19E0,-0.17E0), (0.32E0,0.09E0), + (0.23E0,-0.24E0), (0.18E0,0.01E0), + (2.0E0,3.0E0), (2.0E0,3.0E0), (2.0E0,3.0E0), + (2.0E0,3.0E0)/ DATA ((CTRUE5(I,J,2),I=1,8),J=1,5)/(0.1E0,0.1E0), + (4.0E0,5.0E0), (4.0E0,5.0E0), (4.0E0,5.0E0), + (4.0E0,5.0E0), (4.0E0,5.0E0), (4.0E0,5.0E0), + (4.0E0,5.0E0), (-0.16E0,-0.37E0), (6.0E0,7.0E0), + (6.0E0,7.0E0), (6.0E0,7.0E0), (6.0E0,7.0E0), + (6.0E0,7.0E0), (6.0E0,7.0E0), (6.0E0,7.0E0), + (-0.17E0,-0.19E0), (8.0E0,9.0E0), + (0.13E0,-0.39E0), (2.0E0,5.0E0), (2.0E0,5.0E0), + (2.0E0,5.0E0), (2.0E0,5.0E0), (2.0E0,5.0E0), + (0.11E0,-0.03E0), (3.0E0,6.0E0), + (-0.17E0,0.46E0), (4.0E0,7.0E0), + (-0.17E0,-0.19E0), (7.0E0,2.0E0), (7.0E0,2.0E0), + (7.0E0,2.0E0), (0.19E0,-0.17E0), (5.0E0,8.0E0), + (0.32E0,0.09E0), (6.0E0,9.0E0), + (0.23E0,-0.24E0), (8.0E0,3.0E0), + (0.18E0,0.01E0), (9.0E0,4.0E0)/ DATA ((CTRUE6(I,J,1),I=1,8),J=1,5)/(0.1E0,0.1E0), + (1.0E0,2.0E0), (1.0E0,2.0E0), (1.0E0,2.0E0), + (1.0E0,2.0E0), (1.0E0,2.0E0), (1.0E0,2.0E0), + (1.0E0,2.0E0), (0.09E0,-0.12E0), (3.0E0,4.0E0), + (3.0E0,4.0E0), (3.0E0,4.0E0), (3.0E0,4.0E0), + (3.0E0,4.0E0), (3.0E0,4.0E0), (3.0E0,4.0E0), + (0.03E0,-0.09E0), (0.15E0,-0.03E0), + (5.0E0,6.0E0), (5.0E0,6.0E0), (5.0E0,6.0E0), + (5.0E0,6.0E0), (5.0E0,6.0E0), (5.0E0,6.0E0), + (0.03E0,0.03E0), (-0.18E0,0.03E0), + (0.03E0,-0.09E0), (7.0E0,8.0E0), (7.0E0,8.0E0), + (7.0E0,8.0E0), (7.0E0,8.0E0), (7.0E0,8.0E0), + (0.09E0,0.03E0), (0.03E0,0.12E0), + (0.12E0,0.03E0), (0.03E0,0.06E0), (2.0E0,3.0E0), + (2.0E0,3.0E0), (2.0E0,3.0E0), (2.0E0,3.0E0)/ DATA ((CTRUE6(I,J,2),I=1,8),J=1,5)/(0.1E0,0.1E0), + (4.0E0,5.0E0), (4.0E0,5.0E0), (4.0E0,5.0E0), + (4.0E0,5.0E0), (4.0E0,5.0E0), (4.0E0,5.0E0), + (4.0E0,5.0E0), (0.09E0,-0.12E0), (6.0E0,7.0E0), + (6.0E0,7.0E0), (6.0E0,7.0E0), (6.0E0,7.0E0), + (6.0E0,7.0E0), (6.0E0,7.0E0), (6.0E0,7.0E0), + (0.03E0,-0.09E0), (8.0E0,9.0E0), + (0.15E0,-0.03E0), (2.0E0,5.0E0), (2.0E0,5.0E0), + (2.0E0,5.0E0), (2.0E0,5.0E0), (2.0E0,5.0E0), + (0.03E0,0.03E0), (3.0E0,6.0E0), + (-0.18E0,0.03E0), (4.0E0,7.0E0), + (0.03E0,-0.09E0), (7.0E0,2.0E0), (7.0E0,2.0E0), + (7.0E0,2.0E0), (0.09E0,0.03E0), (5.0E0,8.0E0), + (0.03E0,0.12E0), (6.0E0,9.0E0), (0.12E0,0.03E0), + (8.0E0,3.0E0), (0.03E0,0.06E0), (9.0E0,4.0E0)/ DATA ITRUE3/0, 1, 2, 2, 2/ * .. Executable Statements .. DO 60 INCX = 1, 2 DO 40 NP1 = 1, 5 N = NP1 - 1 LEN = 2*MAX(N,1) * .. Set vector arguments .. DO 20 I = 1, LEN CX(I) = CV(I,NP1,INCX) 20 CONTINUE IF (ICASE.EQ.6) THEN * .. SCNRM2 .. CALL STEST1(SCNRM2(N,CX,INCX),STRUE2(NP1),STRUE2(NP1), + SFAC) ELSE IF (ICASE.EQ.7) THEN * .. SCASUM .. CALL STEST1(SCASUM(N,CX,INCX),STRUE4(NP1),STRUE4(NP1), + SFAC) ELSE IF (ICASE.EQ.8) THEN * .. CSCAL .. CALL CSCAL(N,CA,CX,INCX) CALL CTEST(LEN,CX,CTRUE5(1,NP1,INCX),CTRUE5(1,NP1,INCX), + SFAC) ELSE IF (ICASE.EQ.9) THEN * .. CSSCAL .. CALL CSSCAL(N,SA,CX,INCX) CALL CTEST(LEN,CX,CTRUE6(1,NP1,INCX),CTRUE6(1,NP1,INCX), + SFAC) ELSE IF (ICASE.EQ.10) THEN * .. ICAMAX .. CALL ITEST1(ICAMAX(N,CX,INCX),ITRUE3(NP1)) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK1' STOP END IF * 40 CONTINUE 60 CONTINUE * INCX = 1 IF (ICASE.EQ.8) THEN * CSCAL * Add a test for alpha equal to zero. CA = (0.0E0,0.0E0) DO 80 I = 1, 5 MWPCT(I) = (0.0E0,0.0E0) MWPCS(I) = (1.0E0,1.0E0) 80 CONTINUE CALL CSCAL(5,CA,CX,INCX) CALL CTEST(5,CX,MWPCT,MWPCS,SFAC) ELSE IF (ICASE.EQ.9) THEN * CSSCAL * Add a test for alpha equal to zero. SA = 0.0E0 DO 100 I = 1, 5 MWPCT(I) = (0.0E0,0.0E0) MWPCS(I) = (1.0E0,1.0E0) 100 CONTINUE CALL CSSCAL(5,SA,CX,INCX) CALL CTEST(5,CX,MWPCT,MWPCS,SFAC) * Add a test for alpha equal to one. SA = 1.0E0 DO 120 I = 1, 5 MWPCT(I) = CX(I) MWPCS(I) = CX(I) 120 CONTINUE CALL CSSCAL(5,SA,CX,INCX) CALL CTEST(5,CX,MWPCT,MWPCS,SFAC) * Add a test for alpha equal to minus one. SA = -1.0E0 DO 140 I = 1, 5 MWPCT(I) = -CX(I) MWPCS(I) = -CX(I) 140 CONTINUE CALL CSSCAL(5,SA,CX,INCX) CALL CTEST(5,CX,MWPCT,MWPCS,SFAC) END IF RETURN END SUBROUTINE CHECK2(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, MODE, N LOGICAL PASS * .. Local Scalars .. COMPLEX CA INTEGER I, J, KI, KN, KSIZE, LENX, LENY, MX, MY * .. Local Arrays .. COMPLEX CDOT(1), CSIZE1(4), CSIZE2(7,2), CSIZE3(14), + CT10X(7,4,4), CT10Y(7,4,4), CT6(4,4), CT7(4,4), + CT8(7,4,4), CX(7), CX1(7), CY(7), CY1(7) INTEGER INCXS(4), INCYS(4), LENS(4,2), NS(4) * .. External Functions .. COMPLEX CDOTC, CDOTU EXTERNAL CDOTC, CDOTU * .. External Subroutines .. EXTERNAL CAXPY, CCOPY, CSWAP, CTEST * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS * .. Data statements .. DATA CA/(0.4E0,-0.7E0)/ DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA CX1/(0.7E0,-0.8E0), (-0.4E0,-0.7E0), + (-0.1E0,-0.9E0), (0.2E0,-0.8E0), + (-0.9E0,-0.4E0), (0.1E0,0.4E0), (-0.6E0,0.6E0)/ DATA CY1/(0.6E0,-0.6E0), (-0.9E0,0.5E0), + (0.7E0,-0.6E0), (0.1E0,-0.5E0), (-0.1E0,-0.2E0), + (-0.5E0,-0.3E0), (0.8E0,-0.7E0)/ DATA ((CT8(I,J,1),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.32E0,-1.41E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.32E0,-1.41E0), + (-1.55E0,0.5E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.32E0,-1.41E0), (-1.55E0,0.5E0), + (0.03E0,-0.89E0), (-0.38E0,-0.96E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0)/ DATA ((CT8(I,J,2),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.32E0,-1.41E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (-0.07E0,-0.89E0), + (-0.9E0,0.5E0), (0.42E0,-1.41E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.78E0,0.06E0), (-0.9E0,0.5E0), + (0.06E0,-0.13E0), (0.1E0,-0.5E0), + (-0.77E0,-0.49E0), (-0.5E0,-0.3E0), + (0.52E0,-1.51E0)/ DATA ((CT8(I,J,3),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.32E0,-1.41E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (-0.07E0,-0.89E0), + (-1.18E0,-0.31E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.78E0,0.06E0), (-1.54E0,0.97E0), + (0.03E0,-0.89E0), (-0.18E0,-1.31E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0)/ DATA ((CT8(I,J,4),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.32E0,-1.41E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.32E0,-1.41E0), (-0.9E0,0.5E0), + (0.05E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.32E0,-1.41E0), + (-0.9E0,0.5E0), (0.05E0,-0.6E0), (0.1E0,-0.5E0), + (-0.77E0,-0.49E0), (-0.5E0,-0.3E0), + (0.32E0,-1.16E0)/ DATA CT7/(0.0E0,0.0E0), (-0.06E0,-0.90E0), + (0.65E0,-0.47E0), (-0.34E0,-1.22E0), + (0.0E0,0.0E0), (-0.06E0,-0.90E0), + (-0.59E0,-1.46E0), (-1.04E0,-0.04E0), + (0.0E0,0.0E0), (-0.06E0,-0.90E0), + (-0.83E0,0.59E0), (0.07E0,-0.37E0), + (0.0E0,0.0E0), (-0.06E0,-0.90E0), + (-0.76E0,-1.15E0), (-1.33E0,-1.82E0)/ DATA CT6/(0.0E0,0.0E0), (0.90E0,0.06E0), + (0.91E0,-0.77E0), (1.80E0,-0.10E0), + (0.0E0,0.0E0), (0.90E0,0.06E0), (1.45E0,0.74E0), + (0.20E0,0.90E0), (0.0E0,0.0E0), (0.90E0,0.06E0), + (-0.55E0,0.23E0), (0.83E0,-0.39E0), + (0.0E0,0.0E0), (0.90E0,0.06E0), (1.04E0,0.79E0), + (1.95E0,1.22E0)/ DATA ((CT10X(I,J,1),I=1,7),J=1,4)/(0.7E0,-0.8E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.6E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.6E0,-0.6E0), (-0.9E0,0.5E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.6E0,-0.6E0), + (-0.9E0,0.5E0), (0.7E0,-0.6E0), (0.1E0,-0.5E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0)/ DATA ((CT10X(I,J,2),I=1,7),J=1,4)/(0.7E0,-0.8E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.6E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.7E0,-0.6E0), (-0.4E0,-0.7E0), + (0.6E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.8E0,-0.7E0), + (-0.4E0,-0.7E0), (-0.1E0,-0.2E0), + (0.2E0,-0.8E0), (0.7E0,-0.6E0), (0.1E0,0.4E0), + (0.6E0,-0.6E0)/ DATA ((CT10X(I,J,3),I=1,7),J=1,4)/(0.7E0,-0.8E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.6E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (-0.9E0,0.5E0), (-0.4E0,-0.7E0), + (0.6E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.1E0,-0.5E0), + (-0.4E0,-0.7E0), (0.7E0,-0.6E0), (0.2E0,-0.8E0), + (-0.9E0,0.5E0), (0.1E0,0.4E0), (0.6E0,-0.6E0)/ DATA ((CT10X(I,J,4),I=1,7),J=1,4)/(0.7E0,-0.8E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.6E0,-0.6E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.6E0,-0.6E0), (0.7E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.6E0,-0.6E0), + (0.7E0,-0.6E0), (-0.1E0,-0.2E0), (0.8E0,-0.7E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0)/ DATA ((CT10Y(I,J,1),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.7E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.7E0,-0.8E0), (-0.4E0,-0.7E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.7E0,-0.8E0), + (-0.4E0,-0.7E0), (-0.1E0,-0.9E0), + (0.2E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0)/ DATA ((CT10Y(I,J,2),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.7E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (-0.1E0,-0.9E0), (-0.9E0,0.5E0), + (0.7E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (-0.6E0,0.6E0), + (-0.9E0,0.5E0), (-0.9E0,-0.4E0), (0.1E0,-0.5E0), + (-0.1E0,-0.9E0), (-0.5E0,-0.3E0), + (0.7E0,-0.8E0)/ DATA ((CT10Y(I,J,3),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.7E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (-0.1E0,-0.9E0), (0.7E0,-0.8E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (-0.6E0,0.6E0), + (-0.9E0,-0.4E0), (-0.1E0,-0.9E0), + (0.7E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0)/ DATA ((CT10Y(I,J,4),I=1,7),J=1,4)/(0.6E0,-0.6E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.7E0,-0.8E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.7E0,-0.8E0), (-0.9E0,0.5E0), + (-0.4E0,-0.7E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.7E0,-0.8E0), + (-0.9E0,0.5E0), (-0.4E0,-0.7E0), (0.1E0,-0.5E0), + (-0.1E0,-0.9E0), (-0.5E0,-0.3E0), + (0.2E0,-0.8E0)/ DATA CSIZE1/(0.0E0,0.0E0), (0.9E0,0.9E0), + (1.63E0,1.73E0), (2.90E0,2.78E0)/ DATA CSIZE3/(0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (1.17E0,1.17E0), + (1.17E0,1.17E0), (1.17E0,1.17E0), + (1.17E0,1.17E0), (1.17E0,1.17E0), + (1.17E0,1.17E0), (1.17E0,1.17E0)/ DATA CSIZE2/(0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0), + (0.0E0,0.0E0), (0.0E0,0.0E0), (1.54E0,1.54E0), + (1.54E0,1.54E0), (1.54E0,1.54E0), + (1.54E0,1.54E0), (1.54E0,1.54E0), + (1.54E0,1.54E0), (1.54E0,1.54E0)/ * .. Executable Statements .. DO 60 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 40 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * .. initialize all argument arrays .. DO 20 I = 1, 7 CX(I) = CX1(I) CY(I) = CY1(I) 20 CONTINUE IF (ICASE.EQ.1) THEN * .. CDOTC .. CDOT(1) = CDOTC(N,CX,INCX,CY,INCY) CALL CTEST(1,CDOT,CT6(KN,KI),CSIZE1(KN),SFAC) ELSE IF (ICASE.EQ.2) THEN * .. CDOTU .. CDOT(1) = CDOTU(N,CX,INCX,CY,INCY) CALL CTEST(1,CDOT,CT7(KN,KI),CSIZE1(KN),SFAC) ELSE IF (ICASE.EQ.3) THEN * .. CAXPY .. CALL CAXPY(N,CA,CX,INCX,CY,INCY) CALL CTEST(LENY,CY,CT8(1,KN,KI),CSIZE2(1,KSIZE),SFAC) ELSE IF (ICASE.EQ.4) THEN * .. CCOPY .. CALL CCOPY(N,CX,INCX,CY,INCY) CALL CTEST(LENY,CY,CT10Y(1,KN,KI),CSIZE3,1.0E0) ELSE IF (ICASE.EQ.5) THEN * .. CSWAP .. CALL CSWAP(N,CX,INCX,CY,INCY) CALL CTEST(LENX,CX,CT10X(1,KN,KI),CSIZE3,1.0E0) CALL CTEST(LENY,CY,CT10Y(1,KN,KI),CSIZE3,1.0E0) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK2' STOP END IF * 40 CONTINUE 60 CONTINUE RETURN END SUBROUTINE STEST(LEN,SCOMP,STRUE,SSIZE,SFAC) * ********************************* STEST ************************** * * THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO * SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE * NEGLIGIBLE. * * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC INTEGER LEN * .. Array Arguments .. REAL SCOMP(LEN), SSIZE(LEN), STRUE(LEN) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, MODE, N LOGICAL PASS * .. Local Scalars .. REAL SD INTEGER I * .. External Functions .. REAL SDIFF EXTERNAL SDIFF * .. Intrinsic Functions .. INTRINSIC ABS * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS * .. Executable Statements .. * DO 40 I = 1, LEN SD = SCOMP(I) - STRUE(I) IF (SDIFF(ABS(SSIZE(I))+ABS(SFAC*SD),ABS(SSIZE(I))).EQ.0.0E0) + GO TO 40 * * HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, MODE, I, SCOMP(I), + STRUE(I), SD, SSIZE(I) 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY MODE I ', + ' COMP(I) TRUE(I) DIFFERENCE', + ' SIZE(I)',/1X) 99997 FORMAT (1X,I4,I3,3I5,I3,2E36.8,2E12.4) END SUBROUTINE STEST1(SCOMP1,STRUE1,SSIZE,SFAC) * ************************* STEST1 ***************************** * * THIS IS AN INTERFACE SUBROUTINE TO ACCOMODATE THE FORTRAN * REQUIREMENT THAT WHEN A DUMMY ARGUMENT IS AN ARRAY, THE * ACTUAL ARGUMENT MUST ALSO BE AN ARRAY OR AN ARRAY ELEMENT. * * C.L. LAWSON, JPL, 1978 DEC 6 * * .. Scalar Arguments .. REAL SCOMP1, SFAC, STRUE1 * .. Array Arguments .. REAL SSIZE(*) * .. Local Arrays .. REAL SCOMP(1), STRUE(1) * .. External Subroutines .. EXTERNAL STEST * .. Executable Statements .. * SCOMP(1) = SCOMP1 STRUE(1) = STRUE1 CALL STEST(1,SCOMP,STRUE,SSIZE,SFAC) * RETURN END REAL FUNCTION SDIFF(SA,SB) * ********************************* SDIFF ************************** * COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15 * * .. Scalar Arguments .. REAL SA, SB * .. Executable Statements .. SDIFF = SA - SB RETURN END SUBROUTINE CTEST(LEN,CCOMP,CTRUE,CSIZE,SFAC) * **************************** CTEST ***************************** * * C.L. LAWSON, JPL, 1978 DEC 6 * * .. Scalar Arguments .. REAL SFAC INTEGER LEN * .. Array Arguments .. COMPLEX CCOMP(LEN), CSIZE(LEN), CTRUE(LEN) * .. Local Scalars .. INTEGER I * .. Local Arrays .. REAL SCOMP(20), SSIZE(20), STRUE(20) * .. External Subroutines .. EXTERNAL STEST * .. Intrinsic Functions .. INTRINSIC AIMAG, REAL * .. Executable Statements .. DO 20 I = 1, LEN SCOMP(2*I-1) = REAL(CCOMP(I)) SCOMP(2*I) = AIMAG(CCOMP(I)) STRUE(2*I-1) = REAL(CTRUE(I)) STRUE(2*I) = AIMAG(CTRUE(I)) SSIZE(2*I-1) = REAL(CSIZE(I)) SSIZE(2*I) = AIMAG(CSIZE(I)) 20 CONTINUE * CALL STEST(2*LEN,SCOMP,STRUE,SSIZE,SFAC) RETURN END SUBROUTINE ITEST1(ICOMP,ITRUE) * ********************************* ITEST1 ************************* * * THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR * EQUALITY. * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. INTEGER ICOMP, ITRUE * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, MODE, N LOGICAL PASS * .. Local Scalars .. INTEGER ID * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS * .. Executable Statements .. IF (ICOMP.EQ.ITRUE) GO TO 40 * * HERE ICOMP IS NOT EQUAL TO ITRUE. * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 ID = ICOMP - ITRUE WRITE (NOUT,99997) ICASE, N, INCX, INCY, MODE, ICOMP, ITRUE, ID 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY MODE ', + ' COMP TRUE DIFFERENCE', + /1X) 99997 FORMAT (1X,I4,I3,3I5,2I36,I12) END
mit
prool/ccx_prool
CalculiX/ccx_2.9/src/advecstiff.f
2
6670
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2007 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine advecstiff(nope,voldl,ithermal,xl,nelemload,nelemadvec, & nload,lakon,xload,istep,time,ttime,dtime,sideload,vold,mi, & xloadold,reltime,nmethod,s,iinc) ! ! calculates the stiffness of an advective element. ! An advective element consists of a face with a forced convection ! film condition and a network node ! implicit none ! character*8 lakonl,lakon(*) character*20 sideload(*),sideloadl ! integer nope,i,ithermal(2),j,nelemload(2,*),nelemadvec,nload,id, & nelem,ig,mint2d,iflag,istep,jltyp,nfield,mi(*),nmethod,k,iinc, & node,nopes ! real*8 tl2(9),voldl(0:mi(2),9),xl(3,9),sinktemp,xi,et,weight, & xl2(3,8),xsj2(3),shp2(7,9),coords(3),xs2(3,7),dxsj2,areaj, & temp,xload(2,*),timeend(2),time,ttime,dtime,field,reltime, & vold(0:mi(2),*),xloadold(2,*),s(100,100),sref,sref2 ! intent(in) nope,voldl,ithermal,xl,nelemload,nelemadvec, & nload,lakon,istep,time,ttime,dtime,sideload,vold,mi, & xloadold,reltime,nmethod,iinc ! intent(inout) s,xload ! include "gauss.f" ! iflag=2 ! timeend(1)=time timeend(2)=ttime+time ! ! number of nodes in the advective face ! nopes=nope-1 ! ! temperature and displacements in the element's nodes ! do i=1,nope tl2(i)=voldl(0,i) enddo do i=1,nopes if(ithermal(2).eq.2) then do j=1,3 xl2(j,i)=xl(j,i) enddo else do j=1,3 xl2(j,i)=xl(j,i)+voldl(j,i) enddo endif enddo ! call nident2(nelemload,nelemadvec,nload,id) ! ! the second entry in nelemload points to the original ! film loading ! id=nelemload(2,id) ! ! number of the original element ! nelem=nelemload(1,id) lakonl=lakon(nelem) read(sideload(id)(2:2),'(i1)') ig ! ! number of integration points ! if(lakonl(4:5).eq.'8R') then mint2d=1 elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) then if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'E')) then mint2d=2 else mint2d=4 endif elseif(lakonl(4:4).eq.'2') then mint2d=9 elseif(lakonl(4:5).eq.'10') then mint2d=3 elseif(lakonl(4:4).eq.'4') then mint2d=1 elseif(lakonl(4:5).eq.'15') then if(ig.le.2) then mint2d=3 else mint2d=4 endif elseif(lakonl(4:4).eq.'6') then mint2d=1 endif ! do i=1,mint2d ! ! copying the sink temperature to ensure the same ! value in each integration point (sinktemp can be ! changed in subroutine film: requirement from the ! thermal people) ! sinktemp=tl2(nope) ! if((lakonl(4:5).eq.'8R').or. & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then xi=gauss2d1(1,i) et=gauss2d1(2,i) weight=weight2d1(i) elseif((lakonl(4:4).eq.'8').or. & (lakonl(4:6).eq.'20R').or. & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then xi=gauss2d2(1,i) et=gauss2d2(2,i) weight=weight2d2(i) elseif(lakonl(4:4).eq.'2') then xi=gauss2d3(1,i) et=gauss2d3(2,i) weight=weight2d3(i) elseif((lakonl(4:5).eq.'10').or. & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then xi=gauss2d5(1,i) et=gauss2d5(2,i) weight=weight2d5(i) elseif((lakonl(4:4).eq.'4').or. & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then xi=gauss2d4(1,i) et=gauss2d4(2,i) weight=weight2d4(i) endif ! if(nopes.eq.8) then call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) elseif(nopes.eq.4) then call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) elseif(nopes.eq.6) then call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) else call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) endif ! dxsj2=dsqrt(xsj2(1)*xsj2(1)+xsj2(2)*xsj2(2)+ & xsj2(3)*xsj2(3)) areaj=dxsj2*weight ! temp=0.d0 do j=1,nopes temp=temp+tl2(j)*shp2(4,j) enddo ! ! for nonuniform load: determine the coordinates of the ! point (transferred into the user subroutine) ! if((sideload(id)(3:4).eq.'NU').or. & (sideload(id)(5:6).eq.'NU')) then do k=1,3 coords(k)=0.d0 do j=1,nopes coords(k)=coords(k)+xl2(k,j)*shp2(4,j) enddo enddo read(sideload(id)(2:2),'(i1)') jltyp jltyp=jltyp+10 node=nelemload(2,id) sideloadl=sideload(id) sideloadl(1:1)='F' call film(xload(1,id),sinktemp,temp,istep, & iinc,timeend,nelem,i,coords,jltyp,field,nfield, & sideloadl,node,areaj,vold,mi) if(nmethod.eq.1) xload(1,id)=xloadold(1,id)+ & (xload(1,id)-xloadold(1,id))*reltime endif ! sref=xload(1,id)*areaj shp2(4,nope)=-1.d0 ! do j=1,nope sref2=sref*shp2(4,j) s(nope,j)=s(nope,j)-sref2 do k=1,nopes s(k,j)=s(k,j)+sref2*shp2(4,k) enddo enddo enddo ! ! for some axisymmetric and plane strain elements only half the ! number of integration points was used ! if(((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')).and. & ((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'E'))) then do i=1,nope do j=1,nope s(i,j)=2.d0*s(i,j) enddo enddo endif ! return end
gpl-2.0
LucHermitte/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/complex16/ztrsyl.f
39
11621
SUBROUTINE ZTRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C, $ LDC, SCALE, INFO ) * * -- LAPACK routine (version 3.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2006 * * .. Scalar Arguments .. CHARACTER TRANA, TRANB INTEGER INFO, ISGN, LDA, LDB, LDC, M, N DOUBLE PRECISION SCALE * .. * .. Array Arguments .. COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ) * .. * * Purpose * ======= * * ZTRSYL solves the complex Sylvester matrix equation: * * op(A)*X + X*op(B) = scale*C or * op(A)*X - X*op(B) = scale*C, * * where op(A) = A or A**H, and A and B are both upper triangular. A is * M-by-M and B is N-by-N; the right hand side C and the solution X are * M-by-N; and scale is an output scale factor, set <= 1 to avoid * overflow in X. * * Arguments * ========= * * TRANA (input) CHARACTER*1 * Specifies the option op(A): * = 'N': op(A) = A (No transpose) * = 'C': op(A) = A**H (Conjugate transpose) * * TRANB (input) CHARACTER*1 * Specifies the option op(B): * = 'N': op(B) = B (No transpose) * = 'C': op(B) = B**H (Conjugate transpose) * * ISGN (input) INTEGER * Specifies the sign in the equation: * = +1: solve op(A)*X + X*op(B) = scale*C * = -1: solve op(A)*X - X*op(B) = scale*C * * M (input) INTEGER * The order of the matrix A, and the number of rows in the * matrices X and C. M >= 0. * * N (input) INTEGER * The order of the matrix B, and the number of columns in the * matrices X and C. N >= 0. * * A (input) COMPLEX*16 array, dimension (LDA,M) * The upper triangular matrix A. * * LDA (input) INTEGER * The leading dimension of the array A. LDA >= max(1,M). * * B (input) COMPLEX*16 array, dimension (LDB,N) * The upper triangular matrix B. * * LDB (input) INTEGER * The leading dimension of the array B. LDB >= max(1,N). * * C (input/output) COMPLEX*16 array, dimension (LDC,N) * On entry, the M-by-N right hand side matrix C. * On exit, C is overwritten by the solution matrix X. * * LDC (input) INTEGER * The leading dimension of the array C. LDC >= max(1,M) * * SCALE (output) DOUBLE PRECISION * The scale factor, scale, set <= 1 to avoid overflow in X. * * INFO (output) INTEGER * = 0: successful exit * < 0: if INFO = -i, the i-th argument had an illegal value * = 1: A and B have common or very close eigenvalues; perturbed * values were used to solve the equation (but the matrices * A and B are unchanged). * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE PARAMETER ( ONE = 1.0D+0 ) * .. * .. Local Scalars .. LOGICAL NOTRNA, NOTRNB INTEGER J, K, L DOUBLE PRECISION BIGNUM, DA11, DB, EPS, SCALOC, SGN, SMIN, $ SMLNUM COMPLEX*16 A11, SUML, SUMR, VEC, X11 * .. * .. Local Arrays .. DOUBLE PRECISION DUM( 1 ) * .. * .. External Functions .. LOGICAL LSAME DOUBLE PRECISION DLAMCH, ZLANGE COMPLEX*16 ZDOTC, ZDOTU, ZLADIV EXTERNAL LSAME, DLAMCH, ZLANGE, ZDOTC, ZDOTU, ZLADIV * .. * .. External Subroutines .. EXTERNAL DLABAD, XERBLA, ZDSCAL * .. * .. Intrinsic Functions .. INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX, MIN * .. * .. Executable Statements .. * * Decode and Test input parameters * NOTRNA = LSAME( TRANA, 'N' ) NOTRNB = LSAME( TRANB, 'N' ) * INFO = 0 IF( .NOT.NOTRNA .AND. .NOT.LSAME( TRANA, 'C' ) ) THEN INFO = -1 ELSE IF( .NOT.NOTRNB .AND. .NOT.LSAME( TRANB, 'C' ) ) THEN INFO = -2 ELSE IF( ISGN.NE.1 .AND. ISGN.NE.-1 ) THEN INFO = -3 ELSE IF( M.LT.0 ) THEN INFO = -4 ELSE IF( N.LT.0 ) THEN INFO = -5 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN INFO = -7 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN INFO = -9 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN INFO = -11 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'ZTRSYL', -INFO ) RETURN END IF * * Quick return if possible * SCALE = ONE IF( M.EQ.0 .OR. N.EQ.0 ) $ RETURN * * Set constants to control overflow * EPS = DLAMCH( 'P' ) SMLNUM = DLAMCH( 'S' ) BIGNUM = ONE / SMLNUM CALL DLABAD( SMLNUM, BIGNUM ) SMLNUM = SMLNUM*DBLE( M*N ) / EPS BIGNUM = ONE / SMLNUM SMIN = MAX( SMLNUM, EPS*ZLANGE( 'M', M, M, A, LDA, DUM ), $ EPS*ZLANGE( 'M', N, N, B, LDB, DUM ) ) SGN = ISGN * IF( NOTRNA .AND. NOTRNB ) THEN * * Solve A*X + ISGN*X*B = scale*C. * * The (K,L)th block of X is determined starting from * bottom-left corner column by column by * * A(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L) * * Where * M L-1 * R(K,L) = SUM [A(K,I)*X(I,L)] +ISGN*SUM [X(K,J)*B(J,L)]. * I=K+1 J=1 * DO 30 L = 1, N DO 20 K = M, 1, -1 * SUML = ZDOTU( M-K, A( K, MIN( K+1, M ) ), LDA, $ C( MIN( K+1, M ), L ), 1 ) SUMR = ZDOTU( L-1, C( K, 1 ), LDC, B( 1, L ), 1 ) VEC = C( K, L ) - ( SUML+SGN*SUMR ) * SCALOC = ONE A11 = A( K, K ) + SGN*B( L, L ) DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) ) IF( DA11.LE.SMIN ) THEN A11 = SMIN DA11 = SMIN INFO = 1 END IF DB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) ) IF( DA11.LT.ONE .AND. DB.GT.ONE ) THEN IF( DB.GT.BIGNUM*DA11 ) $ SCALOC = ONE / DB END IF X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 ) * IF( SCALOC.NE.ONE ) THEN DO 10 J = 1, N CALL ZDSCAL( M, SCALOC, C( 1, J ), 1 ) 10 CONTINUE SCALE = SCALE*SCALOC END IF C( K, L ) = X11 * 20 CONTINUE 30 CONTINUE * ELSE IF( .NOT.NOTRNA .AND. NOTRNB ) THEN * * Solve A' *X + ISGN*X*B = scale*C. * * The (K,L)th block of X is determined starting from * upper-left corner column by column by * * A'(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L) * * Where * K-1 L-1 * R(K,L) = SUM [A'(I,K)*X(I,L)] + ISGN*SUM [X(K,J)*B(J,L)] * I=1 J=1 * DO 60 L = 1, N DO 50 K = 1, M * SUML = ZDOTC( K-1, A( 1, K ), 1, C( 1, L ), 1 ) SUMR = ZDOTU( L-1, C( K, 1 ), LDC, B( 1, L ), 1 ) VEC = C( K, L ) - ( SUML+SGN*SUMR ) * SCALOC = ONE A11 = DCONJG( A( K, K ) ) + SGN*B( L, L ) DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) ) IF( DA11.LE.SMIN ) THEN A11 = SMIN DA11 = SMIN INFO = 1 END IF DB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) ) IF( DA11.LT.ONE .AND. DB.GT.ONE ) THEN IF( DB.GT.BIGNUM*DA11 ) $ SCALOC = ONE / DB END IF * X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 ) * IF( SCALOC.NE.ONE ) THEN DO 40 J = 1, N CALL ZDSCAL( M, SCALOC, C( 1, J ), 1 ) 40 CONTINUE SCALE = SCALE*SCALOC END IF C( K, L ) = X11 * 50 CONTINUE 60 CONTINUE * ELSE IF( .NOT.NOTRNA .AND. .NOT.NOTRNB ) THEN * * Solve A'*X + ISGN*X*B' = C. * * The (K,L)th block of X is determined starting from * upper-right corner column by column by * * A'(K,K)*X(K,L) + ISGN*X(K,L)*B'(L,L) = C(K,L) - R(K,L) * * Where * K-1 * R(K,L) = SUM [A'(I,K)*X(I,L)] + * I=1 * N * ISGN*SUM [X(K,J)*B'(L,J)]. * J=L+1 * DO 90 L = N, 1, -1 DO 80 K = 1, M * SUML = ZDOTC( K-1, A( 1, K ), 1, C( 1, L ), 1 ) SUMR = ZDOTC( N-L, C( K, MIN( L+1, N ) ), LDC, $ B( L, MIN( L+1, N ) ), LDB ) VEC = C( K, L ) - ( SUML+SGN*DCONJG( SUMR ) ) * SCALOC = ONE A11 = DCONJG( A( K, K )+SGN*B( L, L ) ) DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) ) IF( DA11.LE.SMIN ) THEN A11 = SMIN DA11 = SMIN INFO = 1 END IF DB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) ) IF( DA11.LT.ONE .AND. DB.GT.ONE ) THEN IF( DB.GT.BIGNUM*DA11 ) $ SCALOC = ONE / DB END IF * X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 ) * IF( SCALOC.NE.ONE ) THEN DO 70 J = 1, N CALL ZDSCAL( M, SCALOC, C( 1, J ), 1 ) 70 CONTINUE SCALE = SCALE*SCALOC END IF C( K, L ) = X11 * 80 CONTINUE 90 CONTINUE * ELSE IF( NOTRNA .AND. .NOT.NOTRNB ) THEN * * Solve A*X + ISGN*X*B' = C. * * The (K,L)th block of X is determined starting from * bottom-left corner column by column by * * A(K,K)*X(K,L) + ISGN*X(K,L)*B'(L,L) = C(K,L) - R(K,L) * * Where * M N * R(K,L) = SUM [A(K,I)*X(I,L)] + ISGN*SUM [X(K,J)*B'(L,J)] * I=K+1 J=L+1 * DO 120 L = N, 1, -1 DO 110 K = M, 1, -1 * SUML = ZDOTU( M-K, A( K, MIN( K+1, M ) ), LDA, $ C( MIN( K+1, M ), L ), 1 ) SUMR = ZDOTC( N-L, C( K, MIN( L+1, N ) ), LDC, $ B( L, MIN( L+1, N ) ), LDB ) VEC = C( K, L ) - ( SUML+SGN*DCONJG( SUMR ) ) * SCALOC = ONE A11 = A( K, K ) + SGN*DCONJG( B( L, L ) ) DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) ) IF( DA11.LE.SMIN ) THEN A11 = SMIN DA11 = SMIN INFO = 1 END IF DB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) ) IF( DA11.LT.ONE .AND. DB.GT.ONE ) THEN IF( DB.GT.BIGNUM*DA11 ) $ SCALOC = ONE / DB END IF * X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 ) * IF( SCALOC.NE.ONE ) THEN DO 100 J = 1, N CALL ZDSCAL( M, SCALOC, C( 1, J ), 1 ) 100 CONTINUE SCALE = SCALE*SCALOC END IF C( K, L ) = X11 * 110 CONTINUE 120 CONTINUE * END IF * RETURN * * End of ZTRSYL * END
apache-2.0
epfl-cosmo/q-e
EPW/src/poolgather.f90
2
7058
! ! Copyright (C) 2010-2016 Samuel Ponce', Roxana Margine, Carla Verdi, Feliciano Giustino ! Copyright (C) 2007-2009 Jesse Noffsinger, Brad Malone, Feliciano Giustino ! ! This file is distributed under the terms of the GNU General Public ! License. See the file `LICENSE' in the root directory of the ! present distribution, or http://www.gnu.org/copyleft.gpl.txt . ! ! Adapted from the subroutine poolscatter in PW/para - Quantum-ESPRESSO group ! !-------------------------------------------------------------------- subroutine poolgather (nsize, nkstot, nks, f_in, f_out) !-------------------------------------------------------------------- !! !! gather the kpoints and the electronic eigenvalues !! across the pools !! doesn't work with the double grid (k and k+q) !! !-------------------------------------------------------------------- USE kinds, only : DP USE mp_global, ONLY : my_pool_id, & inter_pool_comm, kunit,npool, my_pool_id USE mp, ONLY : mp_barrier, mp_bcast,mp_sum ! implicit none ! INTEGER, INTENT (in) :: nsize !! first dimension of vectors f_in and f_out INTEGER, INTENT (in) :: nks !! number of k-points per pool INTEGER, INTENT (in) :: nkstot !! total number of k-points REAL (KIND=DP), INTENT (in) :: f_in(nsize,nks) !! input ( only for k-points of mypool ) REAL (KIND=DP), INTENT (out) :: f_out(nsize,nkstot) !! output ( contains values for all k-point ) ! #ifdef __MPI INTEGER :: rest, nbase ! the rest of the integer division nkstot / npo ! the position in the original list ! rest = nkstot / kunit - ( nkstot / kunit / npool ) * npool ! nbase = nks * my_pool_id ! IF ( ( my_pool_id + 1 ) > rest ) nbase = nbase + rest * kunit f_out = 0.d0 f_out(:,(nbase+1):(nbase+nks)) = f_in(:,1:nks) ! ! ... reduce across the pools ! CALL mp_sum(f_out,inter_pool_comm) ! #else f_out(:,:) = f_in(:,:) ! #endif ! end subroutine poolgather ! !-------------------------------------------------------------------- subroutine poolgather2 (nsize, nkstot, nks, f_in, f_out) !-------------------------------------------------------------------- !! !! gather the kpoints and the electronic eigenvalues !! across the pools !! works with the double grid (k and k+q) !! define rest and nbase as in loadkmesh_para subroutine !! !-------------------------------------------------------------------- USE kinds, ONLY : DP USE mp_global, ONLY : my_pool_id, & inter_pool_comm, npool, my_pool_id USE mp, ONLY : mp_barrier, mp_bcast,mp_sum implicit none ! INTEGER, INTENT (in) :: nsize !! first dimension of vectors f_in and f_out INTEGER, INTENT (in) :: nks !! number of k-points per pool INTEGER, INTENT (in) :: nkstot !! total number of k-points REAL (KIND=DP), INTENT (in) :: f_in(nsize,nks) ! input ( only for k-points of mypool ) REAL (KIND=DP), INTENT (out) :: f_out(nsize,nkstot) ! output ( contains values for all k-point ) ! #ifdef __MPI INTEGER :: rest, nbase, nkst ! the rest of the integer division nkstot / npo ! the position in the original list ! nkst = 2 * ( nkstot / 2 / npool ) rest = ( nkstot - nkst * npool ) / 2 IF (my_pool_id < rest ) THEN nkst = nkst + 2 nbase = my_pool_id*nkst ELSE nbase = rest*(nkst+2)+(my_pool_id-rest)*nkst ENDIF f_out = 0.d0 f_out(:,(nbase+1):(nbase+nks)) = f_in(:,1:nks) ! ! ... reduce across the pools ! CALL mp_sum(f_out,inter_pool_comm) ! #else f_out(:,:) = f_in(:,:) ! #endif ! end subroutine poolgather2 ! !---------------- subroutine poolgather_int1 ( nkstot, nks, f_in, f_out) !-------------------------------------------------------------------- !! !! gather the kpoints and the electronic eigenvalues !! across the pools !! works with the double grid (k and k+q) !! define rest and nbase as in loadkmesh_para subroutine !! !-------------------------------------------------------------------- USE kinds, ONLY : DP USE mp_global, ONLY : my_pool_id, & inter_pool_comm, kunit,npool, my_pool_id USE mp, ONLY : mp_barrier, mp_bcast,mp_sum implicit none ! INTEGER, INTENT (in) :: nks !! number of k-points per pool INTEGER, INTENT (in) :: nkstot !! total number of k-points INTEGER, INTENT (in) :: f_in(nks) !! input ( only for k-points of mypool ) INTEGER, INTENT (out) :: f_out(nkstot) !! output ( contains values for all k-point ) ! #ifdef __MPI INTEGER :: rest, nbase ! the rest of the integer division nkstot / npo ! the position in the original list ! rest = nkstot / kunit - ( nkstot / kunit / npool ) * npool ! nbase = nks * my_pool_id ! IF ( ( my_pool_id + 1 ) > rest ) nbase = nbase + rest * kunit f_out = 0 f_out((nbase+1):(nbase+nks)) = f_in(1:nks) ! ! ... reduce across the pools ! CALL mp_sum(f_out,inter_pool_comm) ! #else f_out(:) = f_in(:) ! #endif ! end subroutine poolgather_int1 ! !-------------------------------------------------------------------- subroutine poolgather_int (nsize, nkstot, nks, f_in, f_out) !-------------------------------------------------------------------- !! !! gather the kpoints and the electronic eigenvalues !! across the pools !! works with the double grid (k and k+q) !! define rest and nbase as in loadkmesh_para subroutine !! !-------------------------------------------------------------------- USE kinds, ONLY : DP USE mp_global, ONLY : my_pool_id, & inter_pool_comm, kunit,npool, my_pool_id USE mp, ONLY : mp_barrier, mp_bcast,mp_sum implicit none ! INTEGER, INTENT (in) :: nsize !! first dimension of vectors f_in and f_out INTEGER, INTENT (in) :: nks !! number of k-points per pool INTEGER, INTENT (in) :: nkstot !! total number of k-points INTEGER, INTENT (in) :: f_in(nsize,nks) !! input ( only for k-points of mypool ) INTEGER, INTENT (out) :: f_out(nsize,nkstot) !! output ( contains values for all k-point ) ! #ifdef __MPI INTEGER :: rest, nbase ! the rest of the integer division nkstot / npo ! the position in the original list ! rest = nkstot / kunit - ( nkstot / kunit / npool ) * npool ! nbase = nks * my_pool_id ! IF ( ( my_pool_id + 1 ) > rest ) nbase = nbase + rest * kunit f_out = 0 f_out(:,(nbase+1):(nbase+nks)) = f_in(:,1:nks) ! ! ... reduce across the pools ! CALL mp_sum(f_out,inter_pool_comm) ! #else f_out(:,:) = f_in(:,:) ! #endif ! end subroutine poolgather_int
gpl-2.0
freedesktop-unofficial-mirror/gstreamer-sdk__gcc
gcc/testsuite/gfortran.dg/complex_intrinsic_8.f90
185
2536
! { dg-do link } ! ! PR fortran/33197 ! ! Fortran complex trigonometric functions: acos, asin, atan, acosh, asinh, atanh ! ! Compile-time simplifications ! implicit none real(4), parameter :: pi = 2*acos(0.0_4) real(8), parameter :: pi8 = 2*acos(0.0_8) real(4), parameter :: eps = 10*epsilon(0.0_4) real(8), parameter :: eps8 = 10*epsilon(0.0_8) complex(4), parameter :: z0_0 = cmplx(0.0_4, 0.0_4, kind=4) complex(4), parameter :: z1_1 = cmplx(1.0_4, 1.0_4, kind=4) complex(8), parameter :: z80_0 = cmplx(0.0_8, 0.0_8, kind=8) complex(8), parameter :: z81_1 = cmplx(1.0_8, 1.0_8, kind=8) if (abs(acos(z0_0) - cmplx(pi/2,-0.0,4)) > eps) call link_error() if (abs(acos(z1_1) - cmplx(0.904556894, -1.06127506,4)) > eps) call link_error() if (abs(acos(z80_0) - cmplx(pi8/2,-0.0_8,8)) > eps8) call link_error() if (abs(acos(z81_1) - cmplx(0.90455689430238140_8, -1.0612750619050357_8,8)) > eps8) call link_error() if (abs(asin(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(asin(z1_1) - cmplx(0.66623943, 1.06127506,4)) > eps) call link_error() if (abs(asin(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(asin(z81_1) - cmplx(0.66623943249251527_8, 1.0612750619050357_8,8)) > eps8) call link_error() if (abs(atan(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(atan(z1_1) - cmplx(1.01722196, 0.40235947,4)) > eps) call link_error() if (abs(atan(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(atan(z81_1) - cmplx(1.0172219678978514_8, 0.40235947810852507_8,8)) > eps8) call link_error() if (abs(acosh(z0_0) - cmplx(0.0,pi/2,4)) > eps) call link_error() if (abs(acosh(z1_1) - cmplx(1.06127506, 0.90455689,4)) > eps) call link_error() if (abs(acosh(z80_0) - cmplx(0.0_8,pi8/2,8)) > eps8) call link_error() if (abs(acosh(z81_1) - cmplx(1.0612750619050357_8, 0.90455689430238140_8,8)) > eps8) call link_error() if (abs(asinh(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(asinh(z1_1) - cmplx(1.06127506, 0.66623943,4)) > eps) call link_error() if (abs(asinh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(asinh(z81_1) - cmplx(1.0612750619050357_8, 0.66623943249251527_8,8)) > eps8) call link_error() if (abs(atanh(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(atanh(z1_1) - cmplx(0.40235947, 1.01722196,4)) > eps) call link_error() if (abs(atanh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(atanh(z81_1) - cmplx(0.40235947810852507_8, 1.0172219678978514_8,8)) > eps8) call link_error() end
gpl-2.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/complex_intrinsic_8.f90
185
2536
! { dg-do link } ! ! PR fortran/33197 ! ! Fortran complex trigonometric functions: acos, asin, atan, acosh, asinh, atanh ! ! Compile-time simplifications ! implicit none real(4), parameter :: pi = 2*acos(0.0_4) real(8), parameter :: pi8 = 2*acos(0.0_8) real(4), parameter :: eps = 10*epsilon(0.0_4) real(8), parameter :: eps8 = 10*epsilon(0.0_8) complex(4), parameter :: z0_0 = cmplx(0.0_4, 0.0_4, kind=4) complex(4), parameter :: z1_1 = cmplx(1.0_4, 1.0_4, kind=4) complex(8), parameter :: z80_0 = cmplx(0.0_8, 0.0_8, kind=8) complex(8), parameter :: z81_1 = cmplx(1.0_8, 1.0_8, kind=8) if (abs(acos(z0_0) - cmplx(pi/2,-0.0,4)) > eps) call link_error() if (abs(acos(z1_1) - cmplx(0.904556894, -1.06127506,4)) > eps) call link_error() if (abs(acos(z80_0) - cmplx(pi8/2,-0.0_8,8)) > eps8) call link_error() if (abs(acos(z81_1) - cmplx(0.90455689430238140_8, -1.0612750619050357_8,8)) > eps8) call link_error() if (abs(asin(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(asin(z1_1) - cmplx(0.66623943, 1.06127506,4)) > eps) call link_error() if (abs(asin(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(asin(z81_1) - cmplx(0.66623943249251527_8, 1.0612750619050357_8,8)) > eps8) call link_error() if (abs(atan(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(atan(z1_1) - cmplx(1.01722196, 0.40235947,4)) > eps) call link_error() if (abs(atan(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(atan(z81_1) - cmplx(1.0172219678978514_8, 0.40235947810852507_8,8)) > eps8) call link_error() if (abs(acosh(z0_0) - cmplx(0.0,pi/2,4)) > eps) call link_error() if (abs(acosh(z1_1) - cmplx(1.06127506, 0.90455689,4)) > eps) call link_error() if (abs(acosh(z80_0) - cmplx(0.0_8,pi8/2,8)) > eps8) call link_error() if (abs(acosh(z81_1) - cmplx(1.0612750619050357_8, 0.90455689430238140_8,8)) > eps8) call link_error() if (abs(asinh(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(asinh(z1_1) - cmplx(1.06127506, 0.66623943,4)) > eps) call link_error() if (abs(asinh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(asinh(z81_1) - cmplx(1.0612750619050357_8, 0.66623943249251527_8,8)) > eps8) call link_error() if (abs(atanh(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error() if (abs(atanh(z1_1) - cmplx(0.40235947, 1.01722196,4)) > eps) call link_error() if (abs(atanh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error() if (abs(atanh(z81_1) - cmplx(0.40235947810852507_8, 1.0172219678978514_8,8)) > eps8) call link_error() end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/calcmach.f
1
2390
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine calcmach(vold,vcon,v,nk, & ielmat,ntmat_,shcon,nshcon,rhcon,nrhcon,iout, & nmethod,convergence,physcon,iponoel,inoel,ithermal, & nactdoh,iit,compressible,ismooth,vcontu,vtu,turbulent, & inomat,nodeboun,ndirboun,nboun,mi,co,factor) ! ! calculates ! vold (temperature,velocity and pressure) ! vcon (volumetric energy density, volumetric momentum ! density and density) ! at the nodes ! ! prints if iout=1 ! implicit none ! integer convergence,compressible, & nrhcon(*),ntmat_,nactdoh(0:4,*),iit,turbulent,mi(*), & nshcon(*),ielmat(mi(3),*),nk,ithermal(*),i,j,k,index,iout, & nmethod,imat,nelem,iponoel(*),inoel(3,*),ismooth, & inomat(*),node,nodeboun(*),ndirboun(*),nboun ! real*8 v(0:mi(2),*),vold(0:mi(2),*),vcon(0:4,*), & rhcon(0:1,ntmat_,*),rho,c1,vmax(0:4),dummy,press, & voldmax(0:4),cp,r,temp,temp0,c2,c3,tempnew,vel2, & shcon(0:3,ntmat_,*),drho,dtemp,physcon(*),dpress, & vcontu(2,*),vtu(2,*),co(3,*),factor ! ! calculate kappa (cp/cv) and store it in v(0,*) ! calculate the Mach number and store it in v(1,*) ! do i=1,nk imat=inomat(i) temp=vold(0,i) call materialdata_cp_sec(imat,ntmat_,temp,shcon, & nshcon,cp,physcon) r=shcon(3,1,imat) vel2=vold(1,i)**2+vold(2,i)**2+vold(3,i)**2 v(0,i)=cp/(cp-r) v(1,i)=dsqrt((vold(1,i)**2+vold(2,i)**2+vold(3,i)**2) & /(v(0,i)*r*(temp-physcon(1)))) enddo ! return end
gpl-2.0
ajanson/SCIRun
src/Externals/eigen/blas/testing/sblat1.f
291
43388
*> \brief \b SBLAT1 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * PROGRAM SBLAT1 * * *> \par Purpose: * ============= *> *> \verbatim *> *> Test program for the REAL Level 1 BLAS. *> *> Based upon the original BLAS test routine together with: *> F06EAF Example Program Text *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date April 2012 * *> \ingroup single_blas_testing * * ===================================================================== PROGRAM SBLAT1 * * -- Reference BLAS test routine (version 3.4.1) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * April 2012 * * ===================================================================== * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL SFAC INTEGER IC * .. External Subroutines .. EXTERNAL CHECK0, CHECK1, CHECK2, CHECK3, HEADER * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA SFAC/9.765625E-4/ * .. Executable Statements .. WRITE (NOUT,99999) DO 20 IC = 1, 13 ICASE = IC CALL HEADER * * .. Initialize PASS, INCX, and INCY for a new case. .. * .. the value 9999 for INCX or INCY will appear in the .. * .. detailed output, if any, for cases that do not involve .. * .. these parameters .. * PASS = .TRUE. INCX = 9999 INCY = 9999 IF (ICASE.EQ.3 .OR. ICASE.EQ.11) THEN CALL CHECK0(SFAC) ELSE IF (ICASE.EQ.7 .OR. ICASE.EQ.8 .OR. ICASE.EQ.9 .OR. + ICASE.EQ.10) THEN CALL CHECK1(SFAC) ELSE IF (ICASE.EQ.1 .OR. ICASE.EQ.2 .OR. ICASE.EQ.5 .OR. + ICASE.EQ.6 .OR. ICASE.EQ.12 .OR. ICASE.EQ.13) THEN CALL CHECK2(SFAC) ELSE IF (ICASE.EQ.4) THEN CALL CHECK3(SFAC) END IF * -- Print IF (PASS) WRITE (NOUT,99998) 20 CONTINUE STOP * 99999 FORMAT (' Real BLAS Test Program Results',/1X) 99998 FORMAT (' ----- PASS -----') END SUBROUTINE HEADER * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Arrays .. CHARACTER*6 L(13) * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA L(1)/' SDOT '/ DATA L(2)/'SAXPY '/ DATA L(3)/'SROTG '/ DATA L(4)/' SROT '/ DATA L(5)/'SCOPY '/ DATA L(6)/'SSWAP '/ DATA L(7)/'SNRM2 '/ DATA L(8)/'SASUM '/ DATA L(9)/'SSCAL '/ DATA L(10)/'ISAMAX'/ DATA L(11)/'SROTMG'/ DATA L(12)/'SROTM '/ DATA L(13)/'SDSDOT'/ * .. Executable Statements .. WRITE (NOUT,99999) ICASE, L(ICASE) RETURN * 99999 FORMAT (/' Test of subprogram number',I3,12X,A6) END SUBROUTINE CHECK0(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL D12, SA, SB, SC, SS INTEGER I, K * .. Local Arrays .. REAL DA1(8), DATRUE(8), DB1(8), DBTRUE(8), DC1(8), + DS1(8), DAB(4,9), DTEMP(9), DTRUE(9,9) * .. External Subroutines .. EXTERNAL SROTG, SROTMG, STEST1 * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA DA1/0.3E0, 0.4E0, -0.3E0, -0.4E0, -0.3E0, 0.0E0, + 0.0E0, 1.0E0/ DATA DB1/0.4E0, 0.3E0, 0.4E0, 0.3E0, -0.4E0, 0.0E0, + 1.0E0, 0.0E0/ DATA DC1/0.6E0, 0.8E0, -0.6E0, 0.8E0, 0.6E0, 1.0E0, + 0.0E0, 1.0E0/ DATA DS1/0.8E0, 0.6E0, 0.8E0, -0.6E0, 0.8E0, 0.0E0, + 1.0E0, 0.0E0/ DATA DATRUE/0.5E0, 0.5E0, 0.5E0, -0.5E0, -0.5E0, + 0.0E0, 1.0E0, 1.0E0/ DATA DBTRUE/0.0E0, 0.6E0, 0.0E0, -0.6E0, 0.0E0, + 0.0E0, 1.0E0, 0.0E0/ * INPUT FOR MODIFIED GIVENS DATA DAB/ .1E0,.3E0,1.2E0,.2E0, A .7E0, .2E0, .6E0, 4.2E0, B 0.E0,0.E0,0.E0,0.E0, C 4.E0, -1.E0, 2.E0, 4.E0, D 6.E-10, 2.E-2, 1.E5, 10.E0, E 4.E10, 2.E-2, 1.E-5, 10.E0, F 2.E-10, 4.E-2, 1.E5, 10.E0, G 2.E10, 4.E-2, 1.E-5, 10.E0, H 4.E0, -2.E0, 8.E0, 4.E0 / * TRUE RESULTS FOR MODIFIED GIVENS DATA DTRUE/0.E0,0.E0, 1.3E0, .2E0, 0.E0,0.E0,0.E0, .5E0, 0.E0, A 0.E0,0.E0, 4.5E0, 4.2E0, 1.E0, .5E0, 0.E0,0.E0,0.E0, B 0.E0,0.E0,0.E0,0.E0, -2.E0, 0.E0,0.E0,0.E0,0.E0, C 0.E0,0.E0,0.E0, 4.E0, -1.E0, 0.E0,0.E0,0.E0,0.E0, D 0.E0, 15.E-3, 0.E0, 10.E0, -1.E0, 0.E0, -1.E-4, E 0.E0, 1.E0, F 0.E0,0.E0, 6144.E-5, 10.E0, -1.E0, 4096.E0, -1.E6, G 0.E0, 1.E0, H 0.E0,0.E0,15.E0,10.E0,-1.E0, 5.E-5, 0.E0,1.E0,0.E0, I 0.E0,0.E0, 15.E0, 10.E0, -1. E0, 5.E5, -4096.E0, J 1.E0, 4096.E-6, K 0.E0,0.E0, 7.E0, 4.E0, 0.E0,0.E0, -.5E0, -.25E0, 0.E0/ * 4096 = 2 ** 12 DATA D12 /4096.E0/ DTRUE(1,1) = 12.E0 / 130.E0 DTRUE(2,1) = 36.E0 / 130.E0 DTRUE(7,1) = -1.E0 / 6.E0 DTRUE(1,2) = 14.E0 / 75.E0 DTRUE(2,2) = 49.E0 / 75.E0 DTRUE(9,2) = 1.E0 / 7.E0 DTRUE(1,5) = 45.E-11 * (D12 * D12) DTRUE(3,5) = 4.E5 / (3.E0 * D12) DTRUE(6,5) = 1.E0 / D12 DTRUE(8,5) = 1.E4 / (3.E0 * D12) DTRUE(1,6) = 4.E10 / (1.5E0 * D12 * D12) DTRUE(2,6) = 2.E-2 / 1.5E0 DTRUE(8,6) = 5.E-7 * D12 DTRUE(1,7) = 4.E0 / 150.E0 DTRUE(2,7) = (2.E-10 / 1.5E0) * (D12 * D12) DTRUE(7,7) = -DTRUE(6,5) DTRUE(9,7) = 1.E4 / D12 DTRUE(1,8) = DTRUE(1,7) DTRUE(2,8) = 2.E10 / (1.5E0 * D12 * D12) DTRUE(1,9) = 32.E0 / 7.E0 DTRUE(2,9) = -16.E0 / 7.E0 * .. Executable Statements .. * * Compute true values which cannot be prestored * in decimal notation * DBTRUE(1) = 1.0E0/0.6E0 DBTRUE(3) = -1.0E0/0.6E0 DBTRUE(5) = 1.0E0/0.6E0 * DO 20 K = 1, 8 * .. Set N=K for identification in output if any .. N = K IF (ICASE.EQ.3) THEN * .. SROTG .. IF (K.GT.8) GO TO 40 SA = DA1(K) SB = DB1(K) CALL SROTG(SA,SB,SC,SS) CALL STEST1(SA,DATRUE(K),DATRUE(K),SFAC) CALL STEST1(SB,DBTRUE(K),DBTRUE(K),SFAC) CALL STEST1(SC,DC1(K),DC1(K),SFAC) CALL STEST1(SS,DS1(K),DS1(K),SFAC) ELSEIF (ICASE.EQ.11) THEN * .. SROTMG .. DO I=1,4 DTEMP(I)= DAB(I,K) DTEMP(I+4) = 0.0 END DO DTEMP(9) = 0.0 CALL SROTMG(DTEMP(1),DTEMP(2),DTEMP(3),DTEMP(4),DTEMP(5)) CALL STEST(9,DTEMP,DTRUE(1,K),DTRUE(1,K),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK0' STOP END IF 20 CONTINUE 40 RETURN END SUBROUTINE CHECK1(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. INTEGER I, LEN, NP1 * .. Local Arrays .. REAL DTRUE1(5), DTRUE3(5), DTRUE5(8,5,2), DV(8,5,2), + SA(10), STEMP(1), STRUE(8), SX(8) INTEGER ITRUE2(5) * .. External Functions .. REAL SASUM, SNRM2 INTEGER ISAMAX EXTERNAL SASUM, SNRM2, ISAMAX * .. External Subroutines .. EXTERNAL ITEST1, SSCAL, STEST, STEST1 * .. Intrinsic Functions .. INTRINSIC MAX * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA SA/0.3E0, -1.0E0, 0.0E0, 1.0E0, 0.3E0, 0.3E0, + 0.3E0, 0.3E0, 0.3E0, 0.3E0/ DATA DV/0.1E0, 2.0E0, 2.0E0, 2.0E0, 2.0E0, 2.0E0, + 2.0E0, 2.0E0, 0.3E0, 3.0E0, 3.0E0, 3.0E0, 3.0E0, + 3.0E0, 3.0E0, 3.0E0, 0.3E0, -0.4E0, 4.0E0, + 4.0E0, 4.0E0, 4.0E0, 4.0E0, 4.0E0, 0.2E0, + -0.6E0, 0.3E0, 5.0E0, 5.0E0, 5.0E0, 5.0E0, + 5.0E0, 0.1E0, -0.3E0, 0.5E0, -0.1E0, 6.0E0, + 6.0E0, 6.0E0, 6.0E0, 0.1E0, 8.0E0, 8.0E0, 8.0E0, + 8.0E0, 8.0E0, 8.0E0, 8.0E0, 0.3E0, 9.0E0, 9.0E0, + 9.0E0, 9.0E0, 9.0E0, 9.0E0, 9.0E0, 0.3E0, 2.0E0, + -0.4E0, 2.0E0, 2.0E0, 2.0E0, 2.0E0, 2.0E0, + 0.2E0, 3.0E0, -0.6E0, 5.0E0, 0.3E0, 2.0E0, + 2.0E0, 2.0E0, 0.1E0, 4.0E0, -0.3E0, 6.0E0, + -0.5E0, 7.0E0, -0.1E0, 3.0E0/ DATA DTRUE1/0.0E0, 0.3E0, 0.5E0, 0.7E0, 0.6E0/ DATA DTRUE3/0.0E0, 0.3E0, 0.7E0, 1.1E0, 1.0E0/ DATA DTRUE5/0.10E0, 2.0E0, 2.0E0, 2.0E0, 2.0E0, + 2.0E0, 2.0E0, 2.0E0, -0.3E0, 3.0E0, 3.0E0, + 3.0E0, 3.0E0, 3.0E0, 3.0E0, 3.0E0, 0.0E0, 0.0E0, + 4.0E0, 4.0E0, 4.0E0, 4.0E0, 4.0E0, 4.0E0, + 0.20E0, -0.60E0, 0.30E0, 5.0E0, 5.0E0, 5.0E0, + 5.0E0, 5.0E0, 0.03E0, -0.09E0, 0.15E0, -0.03E0, + 6.0E0, 6.0E0, 6.0E0, 6.0E0, 0.10E0, 8.0E0, + 8.0E0, 8.0E0, 8.0E0, 8.0E0, 8.0E0, 8.0E0, + 0.09E0, 9.0E0, 9.0E0, 9.0E0, 9.0E0, 9.0E0, + 9.0E0, 9.0E0, 0.09E0, 2.0E0, -0.12E0, 2.0E0, + 2.0E0, 2.0E0, 2.0E0, 2.0E0, 0.06E0, 3.0E0, + -0.18E0, 5.0E0, 0.09E0, 2.0E0, 2.0E0, 2.0E0, + 0.03E0, 4.0E0, -0.09E0, 6.0E0, -0.15E0, 7.0E0, + -0.03E0, 3.0E0/ DATA ITRUE2/0, 1, 2, 2, 3/ * .. Executable Statements .. DO 80 INCX = 1, 2 DO 60 NP1 = 1, 5 N = NP1 - 1 LEN = 2*MAX(N,1) * .. Set vector arguments .. DO 20 I = 1, LEN SX(I) = DV(I,NP1,INCX) 20 CONTINUE * IF (ICASE.EQ.7) THEN * .. SNRM2 .. STEMP(1) = DTRUE1(NP1) CALL STEST1(SNRM2(N,SX,INCX),STEMP(1),STEMP,SFAC) ELSE IF (ICASE.EQ.8) THEN * .. SASUM .. STEMP(1) = DTRUE3(NP1) CALL STEST1(SASUM(N,SX,INCX),STEMP(1),STEMP,SFAC) ELSE IF (ICASE.EQ.9) THEN * .. SSCAL .. CALL SSCAL(N,SA((INCX-1)*5+NP1),SX,INCX) DO 40 I = 1, LEN STRUE(I) = DTRUE5(I,NP1,INCX) 40 CONTINUE CALL STEST(LEN,SX,STRUE,STRUE,SFAC) ELSE IF (ICASE.EQ.10) THEN * .. ISAMAX .. CALL ITEST1(ISAMAX(N,SX,INCX),ITRUE2(NP1)) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK1' STOP END IF 60 CONTINUE 80 CONTINUE RETURN END SUBROUTINE CHECK2(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL SA INTEGER I, J, KI, KN, KNI, KPAR, KSIZE, LENX, LENY, $ MX, MY * .. Local Arrays .. REAL DT10X(7,4,4), DT10Y(7,4,4), DT7(4,4), $ DT8(7,4,4), DX1(7), $ DY1(7), SSIZE1(4), SSIZE2(14,2), SSIZE3(4), $ SSIZE(7), STX(7), STY(7), SX(7), SY(7), $ DPAR(5,4), DT19X(7,4,16),DT19XA(7,4,4), $ DT19XB(7,4,4), DT19XC(7,4,4),DT19XD(7,4,4), $ DT19Y(7,4,16), DT19YA(7,4,4),DT19YB(7,4,4), $ DT19YC(7,4,4), DT19YD(7,4,4), DTEMP(5), $ ST7B(4,4) INTEGER INCXS(4), INCYS(4), LENS(4,2), NS(4) * .. External Functions .. REAL SDOT, SDSDOT EXTERNAL SDOT, SDSDOT * .. External Subroutines .. EXTERNAL SAXPY, SCOPY, SROTM, SSWAP, STEST, STEST1 * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. EQUIVALENCE (DT19X(1,1,1),DT19XA(1,1,1)),(DT19X(1,1,5), A DT19XB(1,1,1)),(DT19X(1,1,9),DT19XC(1,1,1)), B (DT19X(1,1,13),DT19XD(1,1,1)) EQUIVALENCE (DT19Y(1,1,1),DT19YA(1,1,1)),(DT19Y(1,1,5), A DT19YB(1,1,1)),(DT19Y(1,1,9),DT19YC(1,1,1)), B (DT19Y(1,1,13),DT19YD(1,1,1)) DATA SA/0.3E0/ DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA DX1/0.6E0, 0.1E0, -0.5E0, 0.8E0, 0.9E0, -0.3E0, + -0.4E0/ DATA DY1/0.5E0, -0.9E0, 0.3E0, 0.7E0, -0.6E0, 0.2E0, + 0.8E0/ DATA DT7/0.0E0, 0.30E0, 0.21E0, 0.62E0, 0.0E0, + 0.30E0, -0.07E0, 0.85E0, 0.0E0, 0.30E0, -0.79E0, + -0.74E0, 0.0E0, 0.30E0, 0.33E0, 1.27E0/ DATA ST7B/ .1, .4, .31, .72, .1, .4, .03, .95, + .1, .4, -.69, -.64, .1, .4, .43, 1.37/ DATA DT8/0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.68E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.68E0, -0.87E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.68E0, -0.87E0, 0.15E0, + 0.94E0, 0.0E0, 0.0E0, 0.0E0, 0.5E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.68E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.35E0, -0.9E0, 0.48E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.38E0, -0.9E0, 0.57E0, 0.7E0, -0.75E0, + 0.2E0, 0.98E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.68E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.35E0, -0.72E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.38E0, + -0.63E0, 0.15E0, 0.88E0, 0.0E0, 0.0E0, 0.0E0, + 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.68E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.68E0, -0.9E0, 0.33E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.68E0, -0.9E0, 0.33E0, 0.7E0, + -0.75E0, 0.2E0, 1.04E0/ DATA DT10X/0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.5E0, -0.9E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.5E0, -0.9E0, 0.3E0, 0.7E0, + 0.0E0, 0.0E0, 0.0E0, 0.6E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.3E0, 0.1E0, 0.5E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.8E0, 0.1E0, -0.6E0, + 0.8E0, 0.3E0, -0.3E0, 0.5E0, 0.6E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.5E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, -0.9E0, + 0.1E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.7E0, + 0.1E0, 0.3E0, 0.8E0, -0.9E0, -0.3E0, 0.5E0, + 0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.5E0, 0.3E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.5E0, 0.3E0, -0.6E0, 0.8E0, 0.0E0, 0.0E0, + 0.0E0/ DATA DT10Y/0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.6E0, 0.1E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.6E0, 0.1E0, -0.5E0, 0.8E0, 0.0E0, + 0.0E0, 0.0E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, -0.5E0, -0.9E0, 0.6E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, -0.4E0, -0.9E0, 0.9E0, + 0.7E0, -0.5E0, 0.2E0, 0.6E0, 0.5E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.6E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, -0.5E0, + 0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + -0.4E0, 0.9E0, -0.5E0, 0.6E0, 0.0E0, 0.0E0, + 0.0E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.6E0, -0.9E0, 0.1E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.6E0, -0.9E0, 0.1E0, 0.7E0, + -0.5E0, 0.2E0, 0.8E0/ DATA SSIZE1/0.0E0, 0.3E0, 1.6E0, 3.2E0/ DATA SSIZE2/0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, + 1.17E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, + 1.17E0, 1.17E0, 1.17E0/ DATA SSIZE3/ .1, .4, 1.7, 3.3 / * * FOR DROTM * DATA DPAR/-2.E0, 0.E0,0.E0,0.E0,0.E0, A -1.E0, 2.E0, -3.E0, -4.E0, 5.E0, B 0.E0, 0.E0, 2.E0, -3.E0, 0.E0, C 1.E0, 5.E0, 2.E0, 0.E0, -4.E0/ * TRUE X RESULTS F0R ROTATIONS DROTM DATA DT19XA/.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E -.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F -.9E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G 3.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .6E0, .1E0, 0.E0,0.E0,0.E0,0.E0,0.E0, I -.8E0, 3.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0, J -.9E0, 2.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0, K 3.5E0, -.4E0, 0.E0,0.E0,0.E0,0.E0,0.E0, L .6E0, .1E0, -.5E0, .8E0, 0.E0,0.E0,0.E0, M -.8E0, 3.8E0, -2.2E0, -1.2E0, 0.E0,0.E0,0.E0, N -.9E0, 2.8E0, -1.4E0, -1.3E0, 0.E0,0.E0,0.E0, O 3.5E0, -.4E0, -2.2E0, 4.7E0, 0.E0,0.E0,0.E0/ * DATA DT19XB/.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E -.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F -.9E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G 3.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .6E0, .1E0, -.5E0, 0.E0,0.E0,0.E0,0.E0, I 0.E0, .1E0, -3.0E0, 0.E0,0.E0,0.E0,0.E0, J -.3E0, .1E0, -2.0E0, 0.E0,0.E0,0.E0,0.E0, K 3.3E0, .1E0, -2.0E0, 0.E0,0.E0,0.E0,0.E0, L .6E0, .1E0, -.5E0, .8E0, .9E0, -.3E0, -.4E0, M -2.0E0, .1E0, 1.4E0, .8E0, .6E0, -.3E0, -2.8E0, N -1.8E0, .1E0, 1.3E0, .8E0, 0.E0, -.3E0, -1.9E0, O 3.8E0, .1E0, -3.1E0, .8E0, 4.8E0, -.3E0, -1.5E0 / * DATA DT19XC/.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E -.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F -.9E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G 3.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .6E0, .1E0, -.5E0, 0.E0,0.E0,0.E0,0.E0, I 4.8E0, .1E0, -3.0E0, 0.E0,0.E0,0.E0,0.E0, J 3.3E0, .1E0, -2.0E0, 0.E0,0.E0,0.E0,0.E0, K 2.1E0, .1E0, -2.0E0, 0.E0,0.E0,0.E0,0.E0, L .6E0, .1E0, -.5E0, .8E0, .9E0, -.3E0, -.4E0, M -1.6E0, .1E0, -2.2E0, .8E0, 5.4E0, -.3E0, -2.8E0, N -1.5E0, .1E0, -1.4E0, .8E0, 3.6E0, -.3E0, -1.9E0, O 3.7E0, .1E0, -2.2E0, .8E0, 3.6E0, -.3E0, -1.5E0 / * DATA DT19XD/.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E -.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F -.9E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G 3.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .6E0, .1E0, 0.E0,0.E0,0.E0,0.E0,0.E0, I -.8E0, -1.0E0, 0.E0,0.E0,0.E0,0.E0,0.E0, J -.9E0, -.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0, K 3.5E0, .8E0, 0.E0,0.E0,0.E0,0.E0,0.E0, L .6E0, .1E0, -.5E0, .8E0, 0.E0,0.E0,0.E0, M -.8E0, -1.0E0, 1.4E0, -1.6E0, 0.E0,0.E0,0.E0, N -.9E0, -.8E0, 1.3E0, -1.6E0, 0.E0,0.E0,0.E0, O 3.5E0, .8E0, -3.1E0, 4.8E0, 0.E0,0.E0,0.E0/ * TRUE Y RESULTS FOR ROTATIONS DROTM DATA DT19YA/.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E .7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F 1.7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G -2.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .5E0, -.9E0, 0.E0,0.E0,0.E0,0.E0,0.E0, I .7E0, -4.8E0, 0.E0,0.E0,0.E0,0.E0,0.E0, J 1.7E0, -.7E0, 0.E0,0.E0,0.E0,0.E0,0.E0, K -2.6E0, 3.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0, L .5E0, -.9E0, .3E0, .7E0, 0.E0,0.E0,0.E0, M .7E0, -4.8E0, 3.0E0, 1.1E0, 0.E0,0.E0,0.E0, N 1.7E0, -.7E0, -.7E0, 2.3E0, 0.E0,0.E0,0.E0, O -2.6E0, 3.5E0, -.7E0, -3.6E0, 0.E0,0.E0,0.E0/ * DATA DT19YB/.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E .7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F 1.7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G -2.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .5E0, -.9E0, .3E0, 0.E0,0.E0,0.E0,0.E0, I 4.0E0, -.9E0, -.3E0, 0.E0,0.E0,0.E0,0.E0, J -.5E0, -.9E0, 1.5E0, 0.E0,0.E0,0.E0,0.E0, K -1.5E0, -.9E0, -1.8E0, 0.E0,0.E0,0.E0,0.E0, L .5E0, -.9E0, .3E0, .7E0, -.6E0, .2E0, .8E0, M 3.7E0, -.9E0, -1.2E0, .7E0, -1.5E0, .2E0, 2.2E0, N -.3E0, -.9E0, 2.1E0, .7E0, -1.6E0, .2E0, 2.0E0, O -1.6E0, -.9E0, -2.1E0, .7E0, 2.9E0, .2E0, -3.8E0 / * DATA DT19YC/.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E .7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F 1.7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G -2.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .5E0, -.9E0, 0.E0,0.E0,0.E0,0.E0,0.E0, I 4.0E0, -6.3E0, 0.E0,0.E0,0.E0,0.E0,0.E0, J -.5E0, .3E0, 0.E0,0.E0,0.E0,0.E0,0.E0, K -1.5E0, 3.0E0, 0.E0,0.E0,0.E0,0.E0,0.E0, L .5E0, -.9E0, .3E0, .7E0, 0.E0,0.E0,0.E0, M 3.7E0, -7.2E0, 3.0E0, 1.7E0, 0.E0,0.E0,0.E0, N -.3E0, .9E0, -.7E0, 1.9E0, 0.E0,0.E0,0.E0, O -1.6E0, 2.7E0, -.7E0, -3.4E0, 0.E0,0.E0,0.E0/ * DATA DT19YD/.5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, A .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, B .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, C .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, D .5E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, E .7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, F 1.7E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, G -2.6E0, 0.E0,0.E0,0.E0,0.E0,0.E0,0.E0, H .5E0, -.9E0, .3E0, 0.E0,0.E0,0.E0,0.E0, I .7E0, -.9E0, 1.2E0, 0.E0,0.E0,0.E0,0.E0, J 1.7E0, -.9E0, .5E0, 0.E0,0.E0,0.E0,0.E0, K -2.6E0, -.9E0, -1.3E0, 0.E0,0.E0,0.E0,0.E0, L .5E0, -.9E0, .3E0, .7E0, -.6E0, .2E0, .8E0, M .7E0, -.9E0, 1.2E0, .7E0, -1.5E0, .2E0, 1.6E0, N 1.7E0, -.9E0, .5E0, .7E0, -1.6E0, .2E0, 2.4E0, O -2.6E0, -.9E0, -1.3E0, .7E0, 2.9E0, .2E0, -4.0E0 / * * .. Executable Statements .. * DO 120 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 100 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * .. Initialize all argument arrays .. DO 20 I = 1, 7 SX(I) = DX1(I) SY(I) = DY1(I) 20 CONTINUE * IF (ICASE.EQ.1) THEN * .. SDOT .. CALL STEST1(SDOT(N,SX,INCX,SY,INCY),DT7(KN,KI),SSIZE1(KN) + ,SFAC) ELSE IF (ICASE.EQ.2) THEN * .. SAXPY .. CALL SAXPY(N,SA,SX,INCX,SY,INCY) DO 40 J = 1, LENY STY(J) = DT8(J,KN,KI) 40 CONTINUE CALL STEST(LENY,SY,STY,SSIZE2(1,KSIZE),SFAC) ELSE IF (ICASE.EQ.5) THEN * .. SCOPY .. DO 60 I = 1, 7 STY(I) = DT10Y(I,KN,KI) 60 CONTINUE CALL SCOPY(N,SX,INCX,SY,INCY) CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0E0) ELSE IF (ICASE.EQ.6) THEN * .. SSWAP .. CALL SSWAP(N,SX,INCX,SY,INCY) DO 80 I = 1, 7 STX(I) = DT10X(I,KN,KI) STY(I) = DT10Y(I,KN,KI) 80 CONTINUE CALL STEST(LENX,SX,STX,SSIZE2(1,1),1.0E0) CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0E0) ELSEIF (ICASE.EQ.12) THEN * .. SROTM .. KNI=KN+4*(KI-1) DO KPAR=1,4 DO I=1,7 SX(I) = DX1(I) SY(I) = DY1(I) STX(I)= DT19X(I,KPAR,KNI) STY(I)= DT19Y(I,KPAR,KNI) END DO * DO I=1,5 DTEMP(I) = DPAR(I,KPAR) END DO * DO I=1,LENX SSIZE(I)=STX(I) END DO * SEE REMARK ABOVE ABOUT DT11X(1,2,7) * AND DT11X(5,3,8). IF ((KPAR .EQ. 2) .AND. (KNI .EQ. 7)) $ SSIZE(1) = 2.4E0 IF ((KPAR .EQ. 3) .AND. (KNI .EQ. 8)) $ SSIZE(5) = 1.8E0 * CALL SROTM(N,SX,INCX,SY,INCY,DTEMP) CALL STEST(LENX,SX,STX,SSIZE,SFAC) CALL STEST(LENY,SY,STY,STY,SFAC) END DO ELSEIF (ICASE.EQ.13) THEN * .. SDSROT .. CALL STEST1 (SDSDOT(N,.1,SX,INCX,SY,INCY), $ ST7B(KN,KI),SSIZE3(KN),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK2' STOP END IF 100 CONTINUE 120 CONTINUE RETURN END SUBROUTINE CHECK3(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. REAL SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL SC, SS INTEGER I, K, KI, KN, KSIZE, LENX, LENY, MX, MY * .. Local Arrays .. REAL COPYX(5), COPYY(5), DT9X(7,4,4), DT9Y(7,4,4), + DX1(7), DY1(7), MWPC(11), MWPS(11), MWPSTX(5), + MWPSTY(5), MWPTX(11,5), MWPTY(11,5), MWPX(5), + MWPY(5), SSIZE2(14,2), STX(7), STY(7), SX(7), + SY(7) INTEGER INCXS(4), INCYS(4), LENS(4,2), MWPINX(11), + MWPINY(11), MWPN(11), NS(4) * .. External Subroutines .. EXTERNAL SROT, STEST * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA DX1/0.6E0, 0.1E0, -0.5E0, 0.8E0, 0.9E0, -0.3E0, + -0.4E0/ DATA DY1/0.5E0, -0.9E0, 0.3E0, 0.7E0, -0.6E0, 0.2E0, + 0.8E0/ DATA SC, SS/0.8E0, 0.6E0/ DATA DT9X/0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.78E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.78E0, -0.46E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.78E0, -0.46E0, -0.22E0, + 1.06E0, 0.0E0, 0.0E0, 0.0E0, 0.6E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.78E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.66E0, 0.1E0, -0.1E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.96E0, 0.1E0, -0.76E0, 0.8E0, 0.90E0, + -0.3E0, -0.02E0, 0.6E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.78E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, -0.06E0, 0.1E0, + -0.1E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.90E0, + 0.1E0, -0.22E0, 0.8E0, 0.18E0, -0.3E0, -0.02E0, + 0.6E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.78E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.78E0, 0.26E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.78E0, 0.26E0, -0.76E0, 1.12E0, + 0.0E0, 0.0E0, 0.0E0/ DATA DT9Y/0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.04E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.04E0, -0.78E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.04E0, -0.78E0, 0.54E0, + 0.08E0, 0.0E0, 0.0E0, 0.0E0, 0.5E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.04E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.7E0, + -0.9E0, -0.12E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.64E0, -0.9E0, -0.30E0, 0.7E0, -0.18E0, 0.2E0, + 0.28E0, 0.5E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.04E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.7E0, -1.08E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.64E0, -1.26E0, + 0.54E0, 0.20E0, 0.0E0, 0.0E0, 0.0E0, 0.5E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.04E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.04E0, -0.9E0, 0.18E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.04E0, -0.9E0, 0.18E0, 0.7E0, + -0.18E0, 0.2E0, 0.16E0/ DATA SSIZE2/0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, 0.0E0, + 0.0E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, + 1.17E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, 1.17E0, + 1.17E0, 1.17E0, 1.17E0/ * .. Executable Statements .. * DO 60 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 40 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * IF (ICASE.EQ.4) THEN * .. SROT .. DO 20 I = 1, 7 SX(I) = DX1(I) SY(I) = DY1(I) STX(I) = DT9X(I,KN,KI) STY(I) = DT9Y(I,KN,KI) 20 CONTINUE CALL SROT(N,SX,INCX,SY,INCY,SC,SS) CALL STEST(LENX,SX,STX,SSIZE2(1,KSIZE),SFAC) CALL STEST(LENY,SY,STY,SSIZE2(1,KSIZE),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK3' STOP END IF 40 CONTINUE 60 CONTINUE * MWPC(1) = 1 DO 80 I = 2, 11 MWPC(I) = 0 80 CONTINUE MWPS(1) = 0 DO 100 I = 2, 6 MWPS(I) = 1 100 CONTINUE DO 120 I = 7, 11 MWPS(I) = -1 120 CONTINUE MWPINX(1) = 1 MWPINX(2) = 1 MWPINX(3) = 1 MWPINX(4) = -1 MWPINX(5) = 1 MWPINX(6) = -1 MWPINX(7) = 1 MWPINX(8) = 1 MWPINX(9) = -1 MWPINX(10) = 1 MWPINX(11) = -1 MWPINY(1) = 1 MWPINY(2) = 1 MWPINY(3) = -1 MWPINY(4) = -1 MWPINY(5) = 2 MWPINY(6) = 1 MWPINY(7) = 1 MWPINY(8) = -1 MWPINY(9) = -1 MWPINY(10) = 2 MWPINY(11) = 1 DO 140 I = 1, 11 MWPN(I) = 5 140 CONTINUE MWPN(5) = 3 MWPN(10) = 3 DO 160 I = 1, 5 MWPX(I) = I MWPY(I) = I MWPTX(1,I) = I MWPTY(1,I) = I MWPTX(2,I) = I MWPTY(2,I) = -I MWPTX(3,I) = 6 - I MWPTY(3,I) = I - 6 MWPTX(4,I) = I MWPTY(4,I) = -I MWPTX(6,I) = 6 - I MWPTY(6,I) = I - 6 MWPTX(7,I) = -I MWPTY(7,I) = I MWPTX(8,I) = I - 6 MWPTY(8,I) = 6 - I MWPTX(9,I) = -I MWPTY(9,I) = I MWPTX(11,I) = I - 6 MWPTY(11,I) = 6 - I 160 CONTINUE MWPTX(5,1) = 1 MWPTX(5,2) = 3 MWPTX(5,3) = 5 MWPTX(5,4) = 4 MWPTX(5,5) = 5 MWPTY(5,1) = -1 MWPTY(5,2) = 2 MWPTY(5,3) = -2 MWPTY(5,4) = 4 MWPTY(5,5) = -3 MWPTX(10,1) = -1 MWPTX(10,2) = -3 MWPTX(10,3) = -5 MWPTX(10,4) = 4 MWPTX(10,5) = 5 MWPTY(10,1) = 1 MWPTY(10,2) = 2 MWPTY(10,3) = 2 MWPTY(10,4) = 4 MWPTY(10,5) = 3 DO 200 I = 1, 11 INCX = MWPINX(I) INCY = MWPINY(I) DO 180 K = 1, 5 COPYX(K) = MWPX(K) COPYY(K) = MWPY(K) MWPSTX(K) = MWPTX(I,K) MWPSTY(K) = MWPTY(I,K) 180 CONTINUE CALL SROT(MWPN(I),COPYX,INCX,COPYY,INCY,MWPC(I),MWPS(I)) CALL STEST(5,COPYX,MWPSTX,MWPSTX,SFAC) CALL STEST(5,COPYY,MWPSTY,MWPSTY,SFAC) 200 CONTINUE RETURN END SUBROUTINE STEST(LEN,SCOMP,STRUE,SSIZE,SFAC) * ********************************* STEST ************************** * * THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO * SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE * NEGLIGIBLE. * * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT REAL ZERO PARAMETER (NOUT=6, ZERO=0.0E0) * .. Scalar Arguments .. REAL SFAC INTEGER LEN * .. Array Arguments .. REAL SCOMP(LEN), SSIZE(LEN), STRUE(LEN) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL SD INTEGER I * .. External Functions .. REAL SDIFF EXTERNAL SDIFF * .. Intrinsic Functions .. INTRINSIC ABS * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * DO 40 I = 1, LEN SD = SCOMP(I) - STRUE(I) IF (ABS(SFAC*SD) .LE. ABS(SSIZE(I))*EPSILON(ZERO)) + GO TO 40 * * HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, I, SCOMP(I), + STRUE(I), SD, SSIZE(I) 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY I ', + ' COMP(I) TRUE(I) DIFFERENCE', + ' SIZE(I)',/1X) 99997 FORMAT (1X,I4,I3,2I5,I3,2E36.8,2E12.4) END SUBROUTINE STEST1(SCOMP1,STRUE1,SSIZE,SFAC) * ************************* STEST1 ***************************** * * THIS IS AN INTERFACE SUBROUTINE TO ACCOMODATE THE FORTRAN * REQUIREMENT THAT WHEN A DUMMY ARGUMENT IS AN ARRAY, THE * ACTUAL ARGUMENT MUST ALSO BE AN ARRAY OR AN ARRAY ELEMENT. * * C.L. LAWSON, JPL, 1978 DEC 6 * * .. Scalar Arguments .. REAL SCOMP1, SFAC, STRUE1 * .. Array Arguments .. REAL SSIZE(*) * .. Local Arrays .. REAL SCOMP(1), STRUE(1) * .. External Subroutines .. EXTERNAL STEST * .. Executable Statements .. * SCOMP(1) = SCOMP1 STRUE(1) = STRUE1 CALL STEST(1,SCOMP,STRUE,SSIZE,SFAC) * RETURN END REAL FUNCTION SDIFF(SA,SB) * ********************************* SDIFF ************************** * COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15 * * .. Scalar Arguments .. REAL SA, SB * .. Executable Statements .. SDIFF = SA - SB RETURN END SUBROUTINE ITEST1(ICOMP,ITRUE) * ********************************* ITEST1 ************************* * * THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR * EQUALITY. * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. INTEGER ICOMP, ITRUE * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. INTEGER ID * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * IF (ICOMP.EQ.ITRUE) GO TO 40 * * HERE ICOMP IS NOT EQUAL TO ITRUE. * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 ID = ICOMP - ITRUE WRITE (NOUT,99997) ICASE, N, INCX, INCY, ICOMP, ITRUE, ID 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY ', + ' COMP TRUE DIFFERENCE', + /1X) 99997 FORMAT (1X,I4,I3,2I5,2I36,I12) END
mit
prool/ccx_prool
CalculiX/ccx_2.9/src/dashpots.f
4
6738
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine dashpots(inpc,textpart,nelcon,nmat,ntmat_,npmat_, & plicon,nplicon, & ncmat_,elcon,matname,irstrt,istep,istat,n,iline,ipol, & inl,ipoinp,inp,nmat_,set,istartset,iendset,ialset, & nset,ielmat,ielorien,ipoinpc,mi) ! ! reading the input deck: *DASHPOT ! implicit none ! logical frequency ! character*1 inpc(*) character*80 matname(*) character*81 set(*),elset character*132 textpart(16) ! integer nelcon(2,*),nmat,ntmat_,ntmat,npmat_,npmat,istep,mi(*), & n,key,i,nplicon(0:ntmat_,*),ncmat_,istat,istartset(*), & iendset(*),irstrt,iline,ipol,inl,ipoinp(2,*),inp(3,*),nmat_, & ialset(*),ipos,nset,j,k,ielmat(mi(3),*),ielorien(mi(3),*), & ipoinpc(0:*) ! real*8 plicon(0:2*npmat_,ntmat_,*),xfreq,temperature, & elcon(0:ncmat_,ntmat_,*) ! frequency=.false. ! ntmat=0 npmat=0 ! if((istep.gt.0).and.(irstrt.ge.0)) then write(*,*) '*ERROR reading *DASHPOT: *DASHPOT should be placed' write(*,*) ' before all step definitions' call exit(201) endif ! nmat=nmat+1 if(nmat.gt.nmat_) then write(*,*) '*ERROR reading *DASHPOT: increase nmat_' call exit(201) endif matname(nmat)(1:7)='DASHPOT' do i=8,80 matname(nmat)(i:i)=' ' enddo ! do i=2,n if(textpart(i)(1:6).eq.'ELSET=') then elset=textpart(i)(7:86) elset(81:81)=' ' ipos=index(elset,' ') elset(ipos:ipos)='E' else write(*,*) & '*WARNING reading *DASHPOT: parameter not recognized:' write(*,*) ' ', & textpart(i)(1:index(textpart(i),' ')-1) call inputwarning(inpc,ipoinpc,iline, &"*DASHPOT%") endif enddo ! ! check for frequency dependency (for steady state dynamics ! calculations) ! call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) if((istat.lt.0).or.(key.eq.1)) return read(textpart(2)(1:20),'(f20.0)',iostat=istat) & xfreq if(istat.gt.0) call inputerror(inpc,ipoinpc,iline, &"*DASHPOT%") if(xfreq.gt.0.d0) frequency=.true. iline=iline-1 ! if(.not.frequency) then nelcon(1,nmat)=2 ! ! linear dashpot ! do call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) if((istat.lt.0).or.(key.eq.1)) exit ntmat=ntmat+1 nelcon(2,nmat)=ntmat if(ntmat.gt.ntmat_) then write(*,*) '*ERROR reading *DASHPOT: increase ntmat_' call exit(201) endif do i=1,2 read(textpart(i)(1:20),'(f20.0)',iostat=istat) & elcon(i,ntmat,nmat) if(istat.gt.0) call inputerror(inpc,ipoinpc,iline, &"*DASHPOT%") enddo if(textpart(3)(1:1).ne.' ') then read(textpart(3)(1:20),'(f20.0)',iostat=istat) & elcon(0,ntmat,nmat) if(istat.gt.0) call inputerror(inpc,ipoinpc,iline, &"*DASHPOT%") else elcon(0,ntmat,nmat)=0.d0 endif enddo else nelcon(1,nmat)=-51 ! ! kinematic hardening coefficients ! do call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) if((istat.lt.0).or.(key.eq.1)) exit read(textpart(3)(1:20),'(f20.0)',iostat=istat) temperature if(istat.gt.0) call inputerror(inpc,ipoinpc,iline, &"*DASHPOT%") ! ! first temperature ! if(ntmat.eq.0) then npmat=0 ntmat=ntmat+1 if(ntmat.gt.ntmat_) then write(*,*) '*ERROR reading *DASHPOT: increase ntmat_' call exit(201) endif nplicon(0,nmat)=ntmat plicon(0,ntmat,nmat)=temperature ! ! new temperature ! elseif(plicon(0,ntmat,nmat).ne.temperature) then npmat=0 ntmat=ntmat+1 if(ntmat.gt.ntmat_) then write(*,*) '*ERROR reading *DASHPOT: increase ntmat_' call exit(201) endif nplicon(0,nmat)=ntmat plicon(0,ntmat,nmat)=temperature endif do i=1,2 read(textpart(i)(1:20),'(f20.0)',iostat=istat) & plicon(2*npmat+i,ntmat,nmat) if(istat.gt.0) call inputerror(inpc,ipoinpc,iline, &"*DASHPOT%") enddo npmat=npmat+1 if(npmat.gt.npmat_) then write(*,*) '*ERROR reading *DASHPOT: increase npmat_' call exit(201) endif nplicon(ntmat,nmat)=npmat enddo endif ! if(ntmat.eq.0) then write(*,*)'*ERROR reading *DASHPOT: *DASHPOT card without data' call exit(201) endif do i=1,nset if(set(i).eq.elset) exit enddo if(i.gt.nset) then elset(ipos:ipos)=' ' write(*,*) '*ERROR reading *DASHPOT: element set ',elset write(*,*) ' has not yet been defined. ' call inputerror(inpc,ipoinpc,iline, &"*DASHPOT%") call exit(201) endif ! ! assigning the elements of the set the appropriate material ! do j=istartset(i),iendset(i) if(ialset(j).gt.0) then ielmat(1,ialset(j))=nmat ielorien(1,ialset(j))=0 else k=ialset(j-2) do k=k-ialset(j) if(k.ge.ialset(j-1)) exit ielmat(1,k)=nmat ielorien(1,k)=0 enddo endif enddo ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.11/src/distattachline.f
6
3367
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine distattachline(xig,etg,pneigh,pnode,a,p, & ratio,nterms,xn) ! ! calculates the distance between a straight line through the node ! with coordinates in "pnode" and direction vector "xn" and ! the node with local coordinates xig and etg ! in a face described by "nterms" nodes with coordinates ! in "pneigh" ! implicit none ! integer nterms,i,j ! real*8 ratio(8),pneigh(3,*),pnode(3),a,xi,et,xig,etg,p(3), & dummy,xn(3),coeff ! if(nterms.eq.3) then xi=(xig+1.d0)/2.d0 et=(etg+1.d0)/2.d0 if(xi+et.gt.1.d0) then dummy=xi xi=1.d0-et et=1.d0-dummy endif ratio(1)=1.d0-xi-et ratio(2)=xi ratio(3)=et elseif(nterms.eq.4) then xi=xig et=etg ratio(1)=(1.d0-xi)*(1.d0-et)/4.d0 ratio(2)=(1.d0+xi)*(1.d0-et)/4.d0 ratio(3)=(1.d0+xi)*(1.d0+et)/4.d0 ratio(4)=(1.d0-xi)*(1.d0+et)/4.d0 elseif(nterms.eq.6) then xi=(xig+1.d0)/2.d0 et=(etg+1.d0)/2.d0 if(xi+et.gt.1.d0) then dummy=xi xi=1.d0-et et=1.d0-dummy endif ratio(1)=2.d0*(0.5d0-xi-et)*(1.d0-xi-et) ratio(2)=xi*(2.d0*xi-1.d0) ratio(3)=et*(2.d0*et-1.d0) ratio(4)=4.d0*xi*(1.d0-xi-et) ratio(5)=4.d0*xi*et ratio(6)=4.d0*et*(1.d0-xi-et) elseif(nterms.eq.8) then xi=xig et=etg ratio(1)=(1.d0-xi)*(1.d0-et)*(-xi-et-1.d0)/4.d0 ratio(2)=(1.d0+xi)*(1.d0-et)*(xi-et-1.d0)/4.d0 ratio(3)=(1.d0+xi)*(1.d0+et)*(xi+et-1.d0)/4.d0 ratio(4)=(1.d0-xi)*(1.d0+et)*(-xi+et-1.d0)/4.d0 ratio(5)=(1.d0-xi*xi)*(1.d0-et)/2.d0 ratio(6)=(1.d0+xi)*(1.d0-et*et)/2.d0 ratio(7)=(1.d0-xi*xi)*(1.d0+et)/2.d0 ratio(8)=(1.d0-xi)*(1.d0-et*et)/2.d0 else write(*,*) '*ERROR in distattach: case with ',nterms write(*,*) ' terms is not covered' call exit(201) endif ! ! calculating the position in the face ! do i=1,3 p(i)=0.d0 do j=1,nterms p(i)=p(i)+ratio(j)*pneigh(i,j) enddo enddo ! ! calculating the distance ! c a=(pnode(1)-p(1))**2+(pnode(2)-p(2))**2+(pnode(3)-p(3))**2 coeff=0.0 do i=1,3 coeff=coeff+xn(i)*(p(i)-pnode(i)) enddo a=(p(1)-pnode(1)-coeff*xn(1))**2+(p(2)-pnode(2)- & coeff*xn(2))**2+(p(3)-pnode(3)-coeff*xn(3))**2 ! return end
gpl-2.0
freedesktop-unofficial-mirror/gstreamer-sdk__gcc
libgomp/testsuite/libgomp.fortran/allocatable2.f90
182
1472
! { dg-do run } ! { dg-require-effective-target tls_runtime } !$ use omp_lib integer, save, allocatable :: a(:, :) integer, allocatable :: b(:, :) integer :: n logical :: l !$omp threadprivate (a) if (allocated (a)) call abort call omp_set_dynamic (.false.) l = .false. !$omp parallel num_threads (4) reduction(.or.:l) allocate (a(-1:1, 7:10)) a(:, :) = omp_get_thread_num () + 6 l = l.or..not.allocated (a) l = l.or.size(a).ne.12.or.size(a,1).ne.3.or.size(a,2).ne.4 !$omp end parallel if (l.or.any(a.ne.6)) call abort () !$omp parallel num_threads (4) copyin (a) reduction(.or.:l) private (b) l = l.or.allocated (b) l = l.or..not.allocated (a) l = l.or.size(a).ne.12.or.size(a,1).ne.3.or.size(a,2).ne.4 l = l.or.any(a.ne.6) allocate (b(1, 3)) a(:, :) = omp_get_thread_num () + 36 b(:, :) = omp_get_thread_num () + 66 !$omp single n = omp_get_thread_num () !$omp end single copyprivate (a, b) l = l.or..not.allocated (a) l = l.or.size(a).ne.12.or.size(a,1).ne.3.or.size(a,2).ne.4 l = l.or.any(a.ne.(n + 36)) l = l.or..not.allocated (b) l = l.or.size(b).ne.3.or.size(b,1).ne.1.or.size(b,2).ne.3 l = l.or.any(b.ne.(n + 66)) deallocate (b) l = l.or.allocated (b) !$omp end parallel if (n.lt.0 .or. n.ge.4) call abort if (l.or.any(a.ne.(n + 36))) call abort !$omp parallel num_threads (4) reduction(.or.:l) deallocate (a) l = l.or.allocated (a) !$omp end parallel if (l.or.allocated (a)) call abort end
gpl-2.0
kaliveda-dev/kaliveda
KVIndra/INDRA2ROOT/kali_lecture_dst_camp1.f
2
118981
c************************************************************************ c Eric Bonnet 04/2010 c Derniere compilation sous SL5 64 bits c g77 -w -I/afs/in2p3.fr/home/throng/indra/veda1/for fortran.f -c c************************************************************************ c * c KALI : ou (K)artouches (A) (L)ire pour (I)ndra ... * c * c************************************************************************ c * c Ce programme lit: * c - les cartouches DST_95 creees avec la version IBM(VM) de VEDA * c - les cartouches DST_96 creees avec la version Anastasie de VEDA * c - les cartouches DST_96 "reduites" * c * c Version : 3 Juin 1996 (J-L. Charvet) * c************************************************************************ c c--------------------------------------------------------------------- c c Ce programme a ete modifiee pour gerer l'ecriture de DST "reduites". c Il permet apres selection des evts de les re-ecrire sur une DST c dans la meme structure que les bandes DST originelles c c Il necessite le fichier ANALYSE FORTRAN pour fonctionner; c celui-ci contient les routines propres a l'utilisateur comme c INI_HBOOK, INI_RUN, TRAITEMENT, FIN_RUN et CLOSE_HB. c c Variable logique a utiliser dans TRAITEMENT pour ecrire des evts selectionnes c c copy_event = .true. c c--------------------------------------------------------------------- c c 3/3/00 Ce programme a ete modifie pour gerer la nouvelle calibration c ------ et identification des couronnes 10-17 (N. Le Neindre) c c Si on veut l'utiliser il suffit de mettre dans INI_HBOOK c c new_calib_c1017=.true. c c Quand une nouvelle calib. et ident. a lieu un parametre "new_cali" c prend la valeur "1" sinon new_cali=0 c c les anciennes valeurs sont dans les tableaux: c kz_old(i) ---- > z(i) c ka_old(i) ---- > a(i) c z_indra_old(i) ---- > z_indra(i) c a_indra_old(i) ---- > a_indra(i) c ener_old(i) ---- > ener(i) c code_vieux(i) ---- > code(i) c avec i=1,npart_traite c c Toutes ces variables et tableaux sont dans 'veda_rel.incl' c c les nouvelles sont dans les tableaux standards de 'veda_6.incl': c z(i), a(i), .... c c c--------------------------------------------------------------------- c En cas de problemes, contactez les personnes suivantes : c c - O. Lopez, LPC Caen, (LOPEZO@FRCPN11) c - J. L. Charvet, Saclay, (CHARVET@FRCPN11) c - D. Cussol, LPC Caen, (CUSSOL@FRCPN11) c c c-------------------------------------------------------------------- c D.Cussol & JDF: 27/09/2007 Version qui copie les fichiers c HPSS sur le repertoire courant (RFIO n'existe plus) program Kali c logical end_of_file,end_of_program integer*2 ibuff(8192),itab(8),ktab(100) integer*1 clinux(16392),clin(16392) Character*1 char1 character*8 typebloc character*80 filein,fileout,namefil real*4 time Character*6 cart_dst c - JDF 27092007 c Character*6 cartou c need 9 characters to hold 'campagne1' Character*9 cartou c for 'rfcp' command character*160 commande character*80 hpssdir c - JDF 27092007 Character*8 datj,hj Integer*4 ifin,iq,jq integer*4 lun,irc,numruni,new_run Integer*4 iascii(256) Integer*4 nsito,nsito1,nsico integer*4 nblocecr_tot,nevtecr_tot,nevtcor logical*1 time_max,linux Character*70 critere,dst_file integer*4 long_critere Character*6 op_system Common /SYST/op_system Common /RED1/new_run,long_critere,critere Common /ASKI/iascii common /CORESIL/nsito,nsito1,nsico character*8 tywrbloc(4) data tywrbloc/'VEDARED1','BLOCDATA','ETAT_IND',' SCALER '/ c c --- Definition des variables indispensables c include 'veda_rel.incl' include 'veda_wri.incl' include 'veda_5.incl' include 'veda_6.incl' include 'veda_11.incl' include 'veda_12.incl' include 'veda_logic.incl' call INITC c ---- PATH des fichiers data de VEDA ---------------------------------- linux=.true. call VAR_ENVIRONNEMENT namefil=nomjob(1:long_job)//'.sortie' print*,'INFO namefil=',namefil,' iout=',iout open (i_out,file=namefil) iwt=-1 call DATIMH (datj,hj) write(i_out,'(//,'' Date debut : '',a8,'' '',a8)')datj,hj iwf=i_out call INI_ASCII correction_piedestal_SiPG=3. lfiltre=.false. lsimulation=.false. dst_reduite=.false. new_calib_c1017=.false. call INI_HBOOK c call CPUTIME(t1,irc) long_critere=70 time_max=.false. char_ascii=.false. end_of_program=.false. end_of_file=.false. fin_lect_run=.false. copy_event=.false. nblocecr_tot=0 nevtecr_tot=0 nsito=0. nsito1=0. nsico=0. nevt_dump=100 ! Nbre d'evts a "DUMPER" c --- Lecture du drapeau d'ecriture sur cartouche DST ecrit_dst=.False. write(i_out,100) write(*,100) 100 format(/,' **** TRAITEMENT des bandes DST 1ere Camp. INDRA **** ', & 'version: 14 Novembre 1995',/, & ' ------------------------------------------ ') c --- Boucle sur le nbre de fichiers a lire print*,'INFO end_of_program ', end_of_program !do while (.not.end_of_program) print*,'INFO boucle while ', end_of_program filein=nomjob(1:long_job)//'.dst' call OPEN_FILE(filein,lun) end_of_file=.False. if(lun.eq.-100) then print *,'Probleme a l''ouverture du fichier : ',filein(1:8) print *,'On passe au fichier suivant...' end_of_file=.True. endif nbloclus=0 nevtlus=0 nb_scaler=0 nkbyta=0 nkbyte=0 c --- Boucle sur la lecture des blocs du fichier ll=0 do while(.not.end_of_file) ll=ll+1 c --- Controle du temps restant (batch) call TIMEL(time) if(time.lt.5.) then ! Temps limite atteint, c'est fini... write(i_out,*) write(i_out,*) '**** Temps limite atteint ' write(6,*) '**** Temps limite atteint **** ' end_of_file=.True. time_max=.true. else call READ_BUFFER (lun,nbloclus,ibuff,istatus) c --- Swap de ibuff (LINUX seulement) if(linux)then do i=1,8192 ibuf=ibuff(i) ibuf1=jbyt(ibuf,1,8) ibuf2=jbyt(ibuf,9,8) ibuff(i)=ibuf1*256+ibuf2 ! buffer swappe end do endif if(nbloclus.le.5)then c write(*,'(8i6)')(ibuff(k),k=1,256) c write(*,'(15(1x,z4))')(ibuff(k),k=1,256) endif if(istatus.eq.-1) then end_of_file=.True. call CFCLOS (lun,0) elseif(istatus.gt.0) then ! pb de lecture du bloc write(*,'('' On passe au run suivant ! '')') c nbloc_tot=nbloc_tot+1 ! on passe au bloc suivant end_of_file=.True. call CFCLOS (lun,0) else ! istatus=0 Bon bloc nbloc_tot=nbloc_tot+1 nkbyta=nkbyta+16384 if(ibuff(2).le.127)then ! en ASCII typebloc=' ' do i=1,8 char1=CHAR(ibuff(i)) typebloc(i:i)=char1 enddo char_ascii=.true. else ! en EBCDIC if(ibuff(1).eq.229)typebloc='VEDADST3' if(ibuff(1).eq.194)typebloc='BLOCDATA' if(ibuff(1).eq.197)typebloc='ETAT_IND' if(ibuff(3).eq.195)typebloc=' SCALER ' endif c --- Aiguillage suivant le type de bloc if(typebloc.eq.'VEDADST3'.or.typebloc.eq.'VEDADST4'. & or.typebloc.eq.'VEDADST5'.or.typebloc.eq.'VEDARED1' )then if(typebloc.eq.'VEDARED1')then dst_reduite=.true. write(i_out,104) 104 format(/,' ** TRAITEMENT des bandes DST <reduite> ** ') endif call DEC_BLOC_HEAD (ibuff,iversion,irc) if(irc.ne.0) then write(i_out,*) ' Erreur lecture du fichier : ' & ,filein write(6,*) ' Erreur lecture du fichier : ',filein end_of_program=.true. goto 999 end if print *,' *** RUN = ',numerun if(new_calib_c1017)then call INIT_CALIB_C1017 (numerun) endif if(.not.dst_reduite)then ! correction seulement en lecture DST physique c $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ c --- appel a des routines d'initialisation de calibration (JLC 25/6/97) c pour correction de la calibration silicium (voir coresi.f) c-----> Silicium : IPN Orsay icode=-10 call INITSI (iannee,imois,numerun,icode) print *,'Initialisation Calibration Siliciums: icode = ',icode if(icode.eq.0)then write(iwf,'('' *** Calibration Silicium (Orsay) : OK ***'')') else write(iwf,'('' *** ATTENTION : Calib. Silicium INOPERANT ***'')') write(iwf,'('' date ou run non traite INITSI... icode = '', & i2)')icode write(*,'('' Prob. a l initialisation INITSI... icode = '', & i2)')icode endif c-----> CsI (fragments) - LPC (couronnes 2-9 en Argon) icode=-10 call INICALF (numerun,imois,iannee,icode) print *,'Initialisation Calibration Csi (fragments)' if(icode.eq.0)then write(iwf,'('' *** Cali. CsI fragm. cour. 2-9 : OK ***'')') elseif(icode.eq.-1)then write(iwf,'('' *** ATTENTION : Calibration CsI fragment ***'')') write(iwf,'('' init. INICALF... icode = '', & i2,'' : Signaux SiPG et GG utilises'')')icode write(*,'('' init. INICALF... icode = '', & i2,'' : Signaux SiPG et GG utilises'')')icode else write(iwf,'('' *** ATTENTION : Cali. CsI frag. INOPERANT ***'')') write(iwf,'('' Prob. a l initialisation INICALF.. icode = '', & i2)')icode write(*,'('' Prob. a l initialisation INICALF.. icode = '', & i2)')icode endif c $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ endif call INI_RUN elseif(typebloc.eq.'BLOCDATA') then if(iversion.eq.3)then call DEC_BLOC_DST_3 (ibuff) elseif(iversion.eq.4)then call DEC_BLOC_DST_4 (ibuff) elseif(iversion.eq.5)then call DEC_BLOC_DST (ibuff) else STOP 'BLOCDATA impossible a lire' endif if(fin_lect_run)then end_of_file=.true. time_max=.true. endif elseif(typebloc.eq.' SCALER ') then nb_echelle_a_imprimer=16 imp_all=1 nb_scaler=nb_scaler+1 write(*,*) ' ' write(*,*) ' DERNIER bloc = bloc Scaler du run' write(*,*) ' bloc Scaler = ',nbloclus Call DECODE_SCALER & (ibuff,echelle,nb_echelle_a_imprimer,Iwt) call PRINT_SCALER(i_out) elseif(typebloc.eq.'ETAT_IND') then call DEC_BLOC_ETAT(ibuff,irc) if(irc.ne.0) then write(i_out,*) ' Erreur a la lecture du bloc ETAT_IND ' write(6,*) ' Erreur a la lecture du bloc ETAT_IND ' end if else write(6,25) nbloclus,typebloc 25 format(1x,' Type du bloc #',i6,' : ',a8,' inconnu !') c do i=1,8 c itab(i)=ibuff(i) c print *,i,itab(i) c end do end if c --- Pointeur de bloc iloop=mod(nbloclus,250) iwoop=mod(nblocecr,250) if(iloop.eq.0.and.nbloclus.ne.1) then write(6,'('' ## Blocs lus = '',i5,'' Evts lus = '',i8, & '' Temps restant ='',f10.2,'' sec.'')') & nbloclus,nevtlus,time end if endif ! fin du test sur istatus endif end do c --- Fin de la lecture, qq rappels... write(i_out,*) ' ' write(i_out,*) 'Fin de lecture du fichier DST : ',filein write(i_out,*) 'Nombre de blocs lus :',nbloclus write(i_out,*) 'Nombre de blocs SCALER :',nb_scaler write(i_out,*) 'Nombre d''evts lus :',nevtlus write(i_out,*) 'Numero du dernier evt lu :',num_evt_brut write(i_out,*)'-----------------------------------------------' write(6,*) ' ' write(6,*) ' ---- Fin de lecture fichier : ',filein write(6,*) 'Nombre de blocs lus :',nbloclus write(6,*) 'Nombre d''evts lus :',nevtlus write(6,*) ' --------------------------------------------' write(6,*) ' ' call FIN_RUN write(i_out,*) ' ' if(time_max)end_of_program=.true. c --- Fermeture 999 write(i_out,*) ' ' write(i_out,*) ' -- Cumul du nb de blocs lus : ',nbloc_tot write(i_out,*) ' -- Cumul du nb d''evts lus : ',nevt_tot write(i_out,*) ' ' write(6,*) ' ' write(6,*) ' -- Cumul du nb de blocs lus : ',nbloc_tot write(6,*) ' -- Cumul du nb d''evts lus : ',nevt_tot write(6,*) ' ' if(.not.dst_reduite)then ! correction seulement en lecture DST physique write(6,*) ' Bilan correction en energie des SiPG cour. 2->9 :' write(6,*) ' -------------------------------------------------' write(6,*) ' Correction si variation de piedestal SiPG >= ', & correction_piedestal_SiPG write(6,*) ' ' write(6,*) ' -- Nb LCP & IMF total ....... = ',nsito write(6,*) ' -- Nb LCP & IMF (SiGG > 3800) = ',nsito1 write(6,*) ' -- Nb LCP & IMF (E. corrigee) = ',nsico write(6,*) ' ' endif 200 call CLOSE_HB write(i_out,*) ' ' write(i_out,*) ' ---- FIN DE LECTURE ----' call DATIMH (datj,hj) write(i_out,'(//,'' Date fin : '',a8,'' '',a8)')datj,hj end c---------------------------------------------------------------------- c --- Routine de decodage des blocs evts (VEDA iversion=5) c---------------------------------------------------------------------- subroutine DEC_BLOC_DST(ibuff) integer*2 ibuff(8192),code2 integer*4 ivalz(300),jvalz integer*4 nsito,nsito1,nsico integer*2 nevt_low,nevt_high integer*4 code16,code4(4),ien logical evt_a_lire,prt integer*2 kbyt(2) Real*4 tab_pw(12),hit_pw(12) common /TABPW/tab_pw,hit_pw include 'veda_rel.incl' include 'veda_wri.incl' include 'veda_5.incl' include 'veda_6.incl' common /VEDADUMP/ivalz common /CORESIL/nsito,nsito1,nsico c Equivalence (ien,kbyt) ipt=9 evt_a_lire=.True. prt=.False. c --- Boucle sur le nombre d'evt a decoder dans le bloc c nbloc=nbloc+1 nbuffevt=0 c print *,' nbloc = ',nbloclus if(prt) then write(10,*) 'Impression Bloc #',nbloc do i=1,8192,8 write(10,1) (ibuff(i+k),k=0,7) end do 1 format(1x,8(i5,1x)) end if do while(evt_a_lire) ilong=ibuff(ipt) nkbyte=nkbyte+ilong*2 c --- Fin de lecture du bloc courant if(ilong.eq.0.or.ipt.ge.8192) then ! JLC 06/02/04 c if(ilong.eq.0) then evt_a_lire=.False. else c --- Decodage de l'evt NEVTLUS nbuffevt=nbuffevt+1 nevtlus=nevtlus+1 nevt_tot=nevt_tot+1 nevt_low=ibuff(ipt+1) nevt_high=ibuff(ipt+2) npart_traite=ibuff(ipt+3) code_evt=ibuff(ipt+4) mrejet=ibuff(ipt+5) iztot=ibuff(ipt+6) ztot=float(iztot) mcha=ibuff(ipt+7) c --- Reconstitution de NEVT... iflag=0 if(nevt_high.lt.0) iflag=1 if(iflag.eq.0) then num_evt_brut=nevt_low*2**16+nevt_high else num_evt_brut=nevt_low*2**16+nevt_high+65536 end if nevt=nevt+1 c --- Remplissage du buffer d'ecriture "ievt" pour l'evenement if(ilong.gt.wmax)then print *,' -------------------------------------------' print *,' ATTENTION DANGER ... dans le bloc = ',nbloclus print *,' ilong = ',ilong,' > wmax = ',wmax print *,' risque de violation de memoire ! (veda_wri.incl)' print *,' evt = ',nevtlus,' evt brut = ',num_evt_brut print *,' npart_traite, iztot , mcha = ', & npart_traite,iztot,mcha print *,' On se repositionne sur le bloc suivant' c print *,' Avant: dump de cet evt: ' c do k=1,ilong c print *,' k,ibuff = ',k,ibuff(ipt+k-1) c enddo print *,' -------------------------------------------' c write(*,'(8i6)')(ibuff(k),k=1,8193) c print * c write(*,'(15(1x,z4))')(ibuff(k),k=1,8193) c stop 'DEC_BLOC_DST' return endif if(ilong.gt.1200)then print *,' -------------------------------------------' print *,' ATTENTION EVENEMENT BIZARRE ...' print *,' Longueur evt un peu grande: = ',ilong,' > 1200' print *,' evt = ',nevtlus,' evt brut = ',num_evt_brut print *,' npart_traite, Ztot , Mult.(code>=2) = ', & npart_traite,iztot,mcha print *,' *** Danger s''ils sont trop nombreux ! ***' print *,' -------------------------------------------' endif do k=1,ilong ievt(k)=ibuff(ipt+k-1) enddo do k=ilong+1,wmax ievt(k)=0 enddo c --- tableau jbuff donne pour chaque constituant i de l'evt c l'adresse (ou pointeur) ou il commence dans l'evt jbuff(1)=9 do i=2,npart_traite ik=jbuff(i-1) jbuff(i)=ik+ievt(ik) enddo c --- Positionnement du pointeur de lecture ipt=ipt+i_entete c --- Decodage caracteristiques des particules... do i=1,npart_traite de1(i)=0. de2(i)=0. de3(i)=0. de4(i)=0. de5(i)=0. de_mylar(i)=0. code_cali(i)=0. ener(i)=0. ecode(i)=0 do k=1,4 code_energie(k,i)=0 enddo canal(i,1)=0 canal(i,2)=0 canal(i,4)=0 canal(i,5)=0 canal(i,7)=0 canal(i,8)=0 ilongevt=ibuff(ipt) module=ibuff(ipt+1) icou(i)=module/100 imod(i)=mod(module,100) c --- Si Gamma ( Code = 0 ) if(ilongevt.eq.i_long1) then z(i)=0 a(i)=0 z_indra(i)=0. a_indra(i)=0. code_part(i)=11*16 ! code gamma=11 dans IDENLCP code16=code_part(i) call DECODE_PART(icou(i),code16,code4) code(i)=code4(1) do k=1,4 code_idf(k,i)=code4(k) enddo if(icou(i).eq.1)then de1(i)=ibuff(ipt+2) else de3(i)=ibuff(ipt+2) endif mt(i)=ibuff(ipt+3) else ib=ibuff(ipt+2) z_indra(i)=float(ib)/100. z(i)=nint(z_indra(i)) ib=ibuff(ipt+3) a_indra(i)=float(ib)/100. a(i)=nint(a_indra(i)) code_part(i)=ibuff(ipt+4) code16=code_part(i) call DECODE_PART(icou(i),code16,code4) code(i)=code4(1) do k=1,4 code_idf(k,i)=code4(k) enddo c --- Correction des cartouches 38KDC creees entre le 19 et 25/6/95 --- c Pb du code=9 trop souvent present, corrige ensuite dans VEDA 3.2 if((kjour.ge.19.and.kjour.le.25).and. & kmois.eq.6.and.kanne.eq.95)then if(icou(i).ge.10)call CORRECT_BACK (num_evt_brut,i) endif c ----- code_cali(i)=ibuff(ipt+5) code16=code_cali(i) code_energie(1,i)=jbyt(code16,1,4) code_energie(2,i)=jbyt(code16,5,4) code_energie(3,i)=jbyt(code16,9,4) code_energie(4,i)=jbyt(code16,13,4) ecode(i)=code_energie(1,i) mt(i)=ibuff(ipt+6) c --- Cas des Phoswichs (couronne = 1) if(ilongevt.eq.i_long2) then kbyt(1)=ibuff(ipt+7) kbyt(2)=ibuff(ipt+8) ien=kbyt(1)*(2**16)+kbyt(2) if(kbyt(2).lt.0)ien=ien+2**16 de1(i)=float(ien) de1(i)=de1(i)/10. c if(nevt.le.100)then c write(*,'(z4,1x,z4,1x,z8,2x,3i8)')ibuff(ipt+7),ibuff(ipt+8),ien, c & ibuff(ipt+7),ibuff(ipt+8),ien c endif c --- Cas des couronnes 2 a 9 elseif(ilongevt.eq.i_long3) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. kbyt(1)=ibuff(ipt+9) kbyt(2)=ibuff(ipt+10) ien=kbyt(1)*(2**16)+kbyt(2) if(kbyt(2).lt.0)ien=ien+2**16 de2(i)=float(ien) de2(i)=de2(i)/10. kbyt(1)=ibuff(ipt+11) kbyt(2)=ibuff(ipt+12) ien=kbyt(1)*(2**16)+kbyt(2) if(kbyt(2).lt.0)ien=ien+2**16 de3(i)=float(ien) de3(i)=de3(i)/10. canal(i,1)=ibuff(ipt+13) ! canal ChIo GG canal(i,2)=ibuff(ipt+14) ! canal ChIo PG canal(i,4)=ibuff(ipt+15) ! canal SI GG canal(i,5)=ibuff(ipt+16) ! canal SI PG canal(i,7)=ibuff(ipt+17) ! canal CsI R canal(i,8)=ibuff(ipt+18) ! canal CsI L if(.not.dst_reduite)then ! la correction a ete faite lors ! de la gen. de la DST reduite c --- Correction de de2(i) et de3(i) du fait de la correction en energie c du silicium PG (voir coresi.f - MFR,JLC 25/6/97) nsito=nsito+1. ! compteur (LCP & IMF: cou.2-9) if(canal(i,4) .gt. 3800) then nsito1=nsito1+1 call cor_can(i) endif endif c --- Cas des couronnes 10 a 17 (sans Etalons) elseif(ilongevt.eq.i_long4) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. kbyt(1)=ibuff(ipt+9) kbyt(2)=ibuff(ipt+10) ien=kbyt(1)*(2**16)+kbyt(2) if(kbyt(2).lt.0)ien=ien+2**16 de3(i)=float(ien) de3(i)=de3(i)/10. canal(i,1)=ibuff(ipt+11) ! canal ChIo GG canal(i,2)=ibuff(ipt+12) ! canal ChIo PG canal(i,7)=ibuff(ipt+13) ! canal CsI R canal(i,8)=ibuff(ipt+14) ! canal CsI L c --- Correction des ecode(i)=3 --- JLC 20/10/97 if(z(i).ge.1.and.z(i).le.2)then ico=0 call COR_ECSI_LIMIT (icou(i),imod(i),z(i),a(i), & de3(i),ico) if(ico.eq.7)then ! E > E_max (sinon ico=1) ecode(i)=3 code_energie(2,i)=7 else if(ecode(i).eq.3)ecode(i)=1 code_energie(2,i)=1 endif code_energie(1,i)=ecode(i) do k=1,4 code4(k)=code_energie(k,i) enddo call CODAGE (code4,code2) ievt(jbuff(i)+5)=code2 endif c --- Cas des couronnes 10 a 17 (avec Etalons) elseif(ilongevt.eq.i_long5) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. de4(i)=(ibuff(ipt+9))/10. kbyt(1)=ibuff(ipt+10) kbyt(2)=ibuff(ipt+11) ien=kbyt(1)*(2**16)+kbyt(2) if(kbyt(2).lt.0)ien=ien+2**16 de5(i)=float(ien) de5(i)=de5(i)/10. kbyt(1)=ibuff(ipt+12) kbyt(2)=ibuff(ipt+13) ien=kbyt(1)*(2**16)+kbyt(2) if(kbyt(2).lt.0)ien=ien+2**16 de3(i)=float(ien) de3(i)=de3(i)/10. canal(i,1)=ibuff(ipt+14) ! canal ChIo GG canal(i,2)=ibuff(ipt+15) ! canal ChIo PG canal(i,7)=ibuff(ipt+16) ! canal CsI R canal(i,8)=ibuff(ipt+17) ! canal CsI L c --- Correction des ecode(i)=3 --- JLC 20/10/97 if(z(i).ge.1.and.z(i).le.2)then ico=0 call COR_ECSI_LIMIT (icou(i),imod(i),z(i),a(i), & de3(i),ico) if(ico.eq.7)then ! E > E_max (sinon ico=1) ecode(i)=3 code_energie(2,i)=7 else if(ecode(i).eq.3)ecode(i)=1 code_energie(2,i)=1 endif code_energie(1,i)=ecode(i) do k=1,4 code4(k)=code_energie(k,i) enddo call CODAGE (code4,code2) ievt(jbuff(i)+5)=code2 endif else write(6,*) 'Bloc=',nbloclus,' Evt:',nevt,'bizarre!' write(6,*) 'En effet, ilongevt =',ilongevt,' !?' write(6,*) 'On passe au bloc suivant !!!?' return end if dde1=de1(i) dde2=de2(i) dde3=de3(i) dde4=de4(i) dde5=de5(i) if(dde1.lt.0)dde1=0. if(dde2.lt.0)dde2=0. if(dde3.lt.0)dde3=0. if(dde4.lt.0)dde4=0. if(dde5.lt.0)dde5=0. ener(i)=(dde1+dde2+dde3+dde4+dde5)+de_mylar(i) endif ipt=ipt+abs(ilongevt) end do c --- Routine de correction des Identifications Etalons (L. Tassan-Got) call PROPNET c --- Nouvelle calibration couronne 10-17 (JLC: 25/2/00) new_cali=0 if(new_calib_c1017)then do i=1,npart_traite kz_old(i)=z(i) ka_old(i)=a(i) z_indra_old(i)=z_indra(i) a_indra_old(i)=a_indra(i) ener_old(i)=ener(i) code_vieux(i)=code(i) enddo call NOUVELLE_CALIBRATION_IDENTIFICATION_C10_17 c --- le remplissage des nouvelles valeurs z(i),a(i), .... est fait c dans la routine "NOUVELLE_CALIBRATION_IDENTIFICATION_C10_17" c A noter: code(i) est en fait inchange endif c --- Routine utilisateurs pour le traitement evt/evt copy_event=.false. call TRAITEMENT if(fin_lect_run)evt_a_lire=.false. 101 format(1x,5(i6,2x)) end if end do return end c-------------------------------------------------------------------- c --- Routine de decodage du bloc Entete du fichier DST c-------------------------------------------------------------------- subroutine DEC_BLOC_HEAD (ibuff,iversion,irc) integer*2 ibuff(8192),ktab(100) character*8 day,hour,nom character*5 type integer*4 irc,iversion integer*4 kheure,kminut,ksecon Integer*4 iascii(256) Character*70 critere integer*4 new_run,long_critere Common /RED1/new_run,long_critere,critere Common/ASKI/iascii include 'veda_rel.incl' include 'veda_wri.incl' include 'veda_5.incl' ipt=8 irc=0 numerun=ibuff(ipt+1) ijour=ibuff(ipt+2) imois=ibuff(ipt+3) iannee=ibuff(ipt+4) zproj=ibuff(ipt+5) aproj=ibuff(ipt+6) zcib=ibuff(ipt+7) acib=ibuff(ipt+8) esura=ibuff(ipt+9) iversion=ibuff(ipt+10) ipt=ipt+10 write(i_out,'(/,'' *** Lecture Run numero '',i4)')numerun write(i_out,1) ijour,imois,iannee 1 format(/,' Date de creation du run : ',i2,'/',i2,'/',i4) if(char_ascii)then do i=1,8 ilettre=ibuff(ipt+i) c print *,' DAY : i,ilettre = ',i,ilettre day(i:i)=CHAR(ilettre) end do kjour=(ibuff(ipt+1)-48)*10+ibuff(ipt+2)-48 kmois=ibuff(ipt+4)*10+ibuff(ipt+5)-528 kanne=ibuff(ipt+7)*10+ibuff(ipt+8)-528 c print *,' ASCII : jour,mois,annee = ',kjour,kmois,kanne if(iversion.eq.3.and.(kmois.ge.5.and.kanne.eq.96))then c print *,' changement de version .....' iversion=4 endif ipt=ipt+8 do i=1,8 ilettre=ibuff(ipt+i) c print *,' HOUR : i,ilettre = ',i,ilettre hour(i:i)=CHAR(ilettre) end do write(i_out,4) day,hour 4 format(' Fichier DST cree le : ',a8,' a ',a8) else kjour=(ibuff(ipt+1)-240)*10+ibuff(ipt+2)-240 kmois=ibuff(ipt+4)*10+ibuff(ipt+5)-2640 kanne=ibuff(ipt+7)*10+ibuff(ipt+8)-2640 do l=1,8 ibuff(ipt+l)=iascii(ibuff(ipt+l)) enddo ipt=ipt+8 kheure=(ibuff(ipt+1)-240)*10+ibuff(ipt+2)-240 kminut=(ibuff(ipt+4)-240)*10+ibuff(ipt+5)-240 ksecon=(ibuff(ipt+7)-240)*10+ibuff(ipt+8)-240 write(i_out,7)kjour,kmois,kanne,kheure,kminut,ksecon 7 format(' Fichier DST cree le : ',i2,'/',i2,'/19',i2,' a ', & i2,'h.',i2,'m.',i2,'s.') do l=1,8 ibuff(ipt+l)=iascii(ibuff(ipt+l)) enddo endif write(i_out,2) zproj,aproj,esura 2 format(/,1x,'Projectile ==> Z=',f4.0,' A=',f4.0, & ' E/A=',f5.1) write(i_out,3) zcib,acib 3 format(1x,'Cible ==> Z=',f4.0,' A=',f4.0) ipt=ipt+9 numbytes=ibuff(ipt) c do i=1,5 c idummy=ibuff(ipt+i) c print *,' TYPE : i,idummy = ',i,idummy c type(i:i)=CHAR(idummy) c end do type(1:5)='INT*2' ipt=ipt+6 i_entete=ibuff(ipt) i_long1=ibuff(ipt+1) i_long2=ibuff(ipt+2) i_long3=ibuff(ipt+3) i_long4=ibuff(ipt+4) i_long5=ibuff(ipt+5) nkbyte=nkbyte+ipt*2 if(dst_reduite)then ipt=ipt+6 new_run=ibuff(ipt) ipt=ipt+1 long_critere=ibuff(ipt) do l=1,long_critere ktab(l)=ibuff(ipt+l) enddo call ATOC (ktab,long_critere,critere) endif write(*,5) iversion 5 format(/,' Version du programme VEDA/DST :',i4) write(*,*) ' Longueurs (mots) suivant l''identification :' write(*,*) ' - Gamma :',i_long1 write(*,*) ' - Phoswich :',i_long2 write(*,*) ' - Cour. 2 a 9 :',i_long3 write(*,*) ' - Cour 10 a 17 (sans si_etal):',i_long4 write(*,*) ' - Cour 10 a 17 (avec si_etal):',i_long5 write(*,*) ' ' write(*,*) 'Longueur des blocs :',numbytes,' octets' write(*,6) type 6 format(1x,'Type des mots : ',a5) return end c---------------------------------------------------------------------- c --- Routine de decodage des blocs evts (VEDA Version 4) c---------------------------------------------------------------------- subroutine DEC_BLOC_DST_4(ibuff) integer*2 ibuff(8192) integer*4 ivalz(300),jvalz integer*2 nevt_low,nevt_high integer*4 code16,code4(4),ien logical evt_a_lire,prt integer*2 kbyt(2) Real*4 tab_pw(12),hit_pw(12) common /TABPW/tab_pw,hit_pw include 'veda_rel.incl' include 'veda_wri.incl' include 'veda_5.incl' include 'veda_6.incl' common /VEDADUMP/ivalz Equivalence (ien,kbyt) ipt=9 evt_a_lire=.True. prt=.False. c --- Boucle sur le nombre d'evt a decoder dans le bloc nbloc=nbloc+1 nbuffevt=0 if(prt) then write(10,*) 'Impression Bloc #',nbloc do i=1,8192,8 write(10,1) (ibuff(i+k),k=0,7) end do 1 format(1x,8(i5,1x)) end if do while(evt_a_lire) ilong=ibuff(ipt) nkbyte=nkbyte+ilong*2 c --- Fin de lecture du bloc courant if(ilong.eq.0.or.ipt.ge.8192) then ! JLC 06/02/04 c if(ilong.eq.0) then evt_a_lire=.False. else c --- Decodage de l'evt NEVTLUS nbuffevt=nbuffevt+1 nevtlus=nevtlus+1 nevt_tot=nevt_tot+1 nevt_low=ibuff(ipt+1) nevt_high=ibuff(ipt+2) npart_traite=ibuff(ipt+3) code_evt=ibuff(ipt+4) mrejet=ibuff(ipt+5) iztot=ibuff(ipt+6) ztot=float(iztot) mcha=ibuff(ipt+7) c --- Reconstitution de NEVT... iflag=0 if(nevt_high.lt.0) iflag=1 if(iflag.eq.0) then num_evt_brut=nevt_low*2**16+nevt_high else num_evt_brut=nevt_low*2**16+nevt_high+65535 end if nevt=nevt+1 c --- Remplissage du buffer d'ecriture "ievt" pour l'evenement if(ilong.gt.wmax)then print *,' -------------------------------------------' print *,' ATTENTION DANGER ...' print *,' ilong = ',ilong,' > wmax = ',wmax print *,' voir veda_wri.incl ! violation de memoire ! ' print *,' evt = ',nevtlus,' evt brut = ',num_evt_brut print *,' npart_traite, iztot , mcha = ', & npart_traite,iztot,mcha print *,' dump de cet evt: ' do k=1,ilong print *,' k,ibuff = ',k,ibuff(ipt+k-1) enddo print *,' -------------------------------------------' c stop 'DEC_BLOC_DST' return endif do k=1,ilong ievt(k)=ibuff(ipt+k-1) enddo do k=ilong+1,wmax ievt(k)=0 enddo c --- Positionnement du pointeur de lecture ipt=ipt+i_entete c --- Decodage caracteristiques des particules... do i=1,npart_traite de1(i)=0. de2(i)=0. de3(i)=0. de4(i)=0. de5(i)=0. de_mylar(i)=0. code_cali(i)=0. ener(i)=0. ecode(i)=0 do k=1,4 code_energie(k,i)=0 enddo canal(i,4)=-1 canal(i,7)=-1 canal(i,8)=-1 ilongevt=ibuff(ipt) module=ibuff(ipt+1) icou(i)=module/100 imod(i)=mod(module,100) c --- Si Gamma ( Code = 0 ) if(ilongevt.eq.i_long1) then z(i)=0 a(i)=0 z_indra(i)=0. a_indra(i)=0. code_part(i)=11*16 ! code gamma=11 dans IDENLCP code16=code_part(i) call DECODE_PART(icou(i),code16,code4) code(i)=code4(1) do k=1,4 code_idf(k,i)=code4(k) enddo if(icou(i).eq.1)then de1(i)=ibuff(ipt+2) else de3(i)=ibuff(ipt+2) endif mt(i)=ibuff(ipt+3) else ib=ibuff(ipt+2) z_indra(i)=float(ib)/100. z(i)=nint(z_indra(i)) ib=ibuff(ipt+3) a_indra(i)=float(ib)/100. a(i)=nint(a_indra(i)) code_part(i)=ibuff(ipt+4) code16=code_part(i) call DECODE_PART(icou(i),code16,code4) code(i)=code4(1) do k=1,4 code_idf(k,i)=code4(k) enddo c --- Correction des cartouches 38KDC creees entre le 19 et 25/6/95 --- c Pb du code=9 trop souvent present, corrige ensuite dans VEDA 3.2 if((kjour.ge.19.and.kjour.le.25).and. & kmois.eq.6.and.kanne.eq.95)then if(icou(i).ge.10)call CORRECT_BACK (num_evt_brut,i) endif c ----- code_cali(i)=ibuff(ipt+5) code16=code_cali(i) code_energie(1,i)=jbyt(code16,1,4) code_energie(2,i)=jbyt(code16,5,4) code_energie(3,i)=jbyt(code16,9,4) code_energie(4,i)=jbyt(code16,13,4) ecode(i)=code_energie(1,i) mt(i)=ibuff(ipt+6) c --- Cas des Phoswichs (couronne = 1) if(ilongevt.eq.i_long2) then kbyt(1)=ibuff(ipt+7) kbyt(2)=ibuff(ipt+8) de1(i)=float(ien) de1(i)=de1(i)/10. c --- Cas des couronnes 2 a 9 elseif(ilongevt.eq.i_long3) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. kbyt(1)=ibuff(ipt+9) kbyt(2)=ibuff(ipt+10) de2(i)=float(ien) de2(i)=de2(i)/10. kbyt(1)=ibuff(ipt+11) kbyt(2)=ibuff(ipt+12) de3(i)=float(ien) de3(i)=de3(i)/10. canal(i,4)=ibuff(ipt+13) ! canal SI GG canal(i,7)=ibuff(ipt+14) ! canal CsI R canal(i,8)=ibuff(ipt+15) ! canal CsI L c --- Cas des couronnes 10 a 17 (sans Etalons) elseif(ilongevt.eq.i_long4) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. kbyt(1)=ibuff(ipt+9) kbyt(2)=ibuff(ipt+10) de3(i)=float(ien) de3(i)=de3(i)/10. canal(i,7)=ibuff(ipt+11) ! canal CsI R canal(i,8)=ibuff(ipt+12) ! canal CsI L c --- Cas des couronnes 10 a 17 (avec Etalons) elseif(ilongevt.eq.i_long5) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. de4(i)=(ibuff(ipt+9))/10. kbyt(1)=ibuff(ipt+10) kbyt(2)=ibuff(ipt+11) de5(i)=float(ien) de5(i)=de5(i)/10. kbyt(1)=ibuff(ipt+12) kbyt(2)=ibuff(ipt+13) de3(i)=float(ien) de3(i)=de3(i)/10. canal(i,7)=ibuff(ipt+14) ! canal CsI R canal(i,8)=ibuff(ipt+15) ! canal CsI L else write(6,*) 'Bloc=',nbloclus,' Evt:',nevt,'bizarre!' write(6,*) 'En effet, ilongevt =',ilongevt,' !?' write(6,*) 'On passe au bloc suivant !!!?' return end if dde1=de1(i) dde2=de2(i) dde3=de3(i) dde4=de4(i) dde5=de5(i) if(dde1.lt.0)dde1=0. if(dde2.lt.0)dde2=0. if(dde3.lt.0)dde3=0. if(dde4.lt.0)dde4=0. if(dde5.lt.0)dde5=0. ener(i)=(dde1+dde2+dde3+dde4+dde5)+de_mylar(i) endif ipt=ipt+abs(ilongevt) end do c --- Routine de correction des Identifications Etalons (L. Tassan-Got) call PROPNET c --- Routine utilisateurs pour le traitement evt/evt copy_event=.false. call TRAITEMENT if(fin_lect_run)evt_a_lire=.false. 101 format(1x,5(i6,2x)) end if end do return end c---------------------------------------------------------------------- c --- Routine de decodage des blocs evts (VEDA Version 3) c---------------------------------------------------------------------- subroutine DEC_BLOC_DST_3(ibuff) integer*2 ibuff(8192) integer*4 ivalz(300),jvalz integer*2 nevt_low,nevt_high integer*4 code16,code4(4),ien logical evt_a_lire,prt integer*2 kbyt(2) Real*4 tab_pw(12),hit_pw(12) common /TABPW/tab_pw,hit_pw include 'veda_rel.incl' include 'veda_wri.incl' include 'veda_5.incl' include 'veda_6.incl' common /VEDADUMP/ivalz Equivalence (ien,kbyt) ipt=9 evt_a_lire=.True. prt=.False. c --- Boucle sur le nombre d'evt a decoder dans le bloc nbloc=nbloc+1 nbuffevt=0 if(prt) then write(10,*) 'Impression Bloc #',nbloc do i=1,8192,8 write(10,1) (ibuff(i+k),k=0,7) end do 1 format(1x,8(i5,1x)) end if do while(evt_a_lire) ilong=ibuff(ipt) nkbyte=nkbyte+ilong*2 c --- Fin de lecture du bloc courant if(ilong.eq.0.or.ipt.ge.8192) then ! JLC 06/02/04 0 c if(ilong.eq.0) then evt_a_lire=.False. else c --- Decodage de l'evt NEVTLUS nbuffevt=nbuffevt+1 nevtlus=nevtlus+1 nevt_tot=nevt_tot+1 nevt_low=ibuff(ipt+1) nevt_high=ibuff(ipt+2) npart_traite=ibuff(ipt+3) code_evt=ibuff(ipt+4) mrejet=ibuff(ipt+5) iztot=ibuff(ipt+6) ztot=float(iztot) mcha=ibuff(ipt+7) c --- Reconstitution de NEVT... iflag=0 if(nevt_high.lt.0) iflag=1 if(iflag.eq.0) then num_evt_brut=nevt_low*2**16+nevt_high else num_evt_brut=nevt_low*2**16+nevt_high+65535 end if nevt=nevt+1 c --- Remplissage du buffer d'ecriture "ievt" pour l'evenement if(ilong.gt.wmax)then print *,' -------------------------------------------' print *,' ATTENTION DANGER ...' print *,' ilong = ',ilong,' > wmax = ',wmax print *,' voir veda_wri.incl ! violation de memoire ! ' print *,' evt = ',nevtlus,' evt brut = ',num_evt_brut print *,' npart_traite, iztot , mcha = ', & npart_traite,iztot,mcha print *,' dump de cet evt: ' do k=1,ilong print *,' k,ibuff = ',k,ibuff(ipt+k-1) enddo print *,' -------------------------------------------' c stop 'DEC_BLOC_DST' return endif do k=1,ilong ievt(k)=ibuff(ipt+k-1) enddo do k=ilong+1,wmax ievt(k)=0 enddo c --- Positionnement du pointeur de lecture ipt=ipt+i_entete c --- Decodage caracteristiques des particules... do i=1,npart_traite de1(i)=0. de2(i)=0. de3(i)=0. de4(i)=0. de5(i)=0. de_mylar(i)=0. code_cali(i)=0. ener(i)=0. ecode(i)=0 do k=1,4 code_energie(k,i)=0 enddo ilongevt=ibuff(ipt) module=ibuff(ipt+1) icou(i)=module/100 imod(i)=mod(module,100) c --- Si Gamma ( Code = 0 ) if(ilongevt.eq.i_long1) then z(i)=0 a(i)=0 z_indra(i)=0. a_indra(i)=0. code_part(i)=11*16 ! code gamma=11 dans IDENLCP code16=code_part(i) call DECODE_PART(icou(i),code16,code4) code(i)=code4(1) do k=1,4 code_idf(k,i)=code4(k) enddo if(icou(i).eq.1)then de1(i)=ibuff(ipt+2) else de3(i)=ibuff(ipt+2) endif mt(i)=ibuff(ipt+3) else ib=ibuff(ipt+2) z_indra(i)=float(ib)/100. z(i)=nint(z_indra(i)) ib=ibuff(ipt+3) a_indra(i)=float(ib)/100. a(i)=nint(a_indra(i)) code_part(i)=ibuff(ipt+4) code16=code_part(i) call DECODE_PART(icou(i),code16,code4) code(i)=code4(1) do k=1,4 code_idf(k,i)=code4(k) enddo c --- Correction des cartouches 38KDC creees entre le 19 et 25/6/95 --- c Pb du code=9 trop souvent present, corrige ensuite dans VEDA 3.2 if((kjour.ge.19.and.kjour.le.25).and. & kmois.eq.6.and.kanne.eq.95)then if(icou(i).ge.10)call CORRECT_BACK (num_evt_brut,i) endif c ----- code_cali(i)=ibuff(ipt+5) code16=code_cali(i) code_energie(1,i)=jbyt(code16,1,4) code_energie(2,i)=jbyt(code16,5,4) code_energie(3,i)=jbyt(code16,9,4) code_energie(4,i)=jbyt(code16,13,4) ecode(i)=code_energie(1,i) mt(i)=ibuff(ipt+6) c --- Cas des Phoswichs (couronne = 1) if(ilongevt.eq.i_long2) then kbyt(1)=ibuff(ipt+7) kbyt(2)=ibuff(ipt+8) de1(i)=float(ien) de1(i)=de1(i)/10. c --- Cas des couronnes 2 a 9 elseif(ilongevt.eq.i_long3) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. kbyt(1)=ibuff(ipt+9) kbyt(2)=ibuff(ipt+10) de2(i)=float(ien) de2(i)=de2(i)/10. kbyt(1)=ibuff(ipt+11) kbyt(2)=ibuff(ipt+12) de3(i)=float(ien) de3(i)=de3(i)/10. c --- Cas des couronnes 10 a 17 (sans Etalons) elseif(ilongevt.eq.i_long4) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. kbyt(1)=ibuff(ipt+9) kbyt(2)=ibuff(ipt+10) de3(i)=float(ien) de3(i)=de3(i)/10. c --- Cas des couronnes 10 a 17 (avec Etalons) elseif(ilongevt.eq.i_long5) then de_mylar(i)=(ibuff(ipt+7))/100. de1(i)=(ibuff(ipt+8))/10. de4(i)=(ibuff(ipt+9))/10. kbyt(1)=ibuff(ipt+10) kbyt(2)=ibuff(ipt+11) de5(i)=float(ien) de5(i)=de5(i)/10. kbyt(1)=ibuff(ipt+12) kbyt(2)=ibuff(ipt+13) de3(i)=float(ien) de3(i)=de3(i)/10. else write(i_out,*) 'Evt #',nevt,',Part. non repertoriee :',i write(i_out,*) 'En effet, Longpart =',ilongevt,' !?' end if dde1=de1(i) dde2=de2(i) dde3=de3(i) dde4=de4(i) dde5=de5(i) if(dde1.lt.0)dde1=0. if(dde2.lt.0)dde2=0. if(dde3.lt.0)dde3=0. if(dde4.lt.0)dde4=0. if(dde5.lt.0)dde5=0. ener(i)=(dde1+dde2+dde3+dde4+dde5)+de_mylar(i) endif ipt=ipt+ilongevt end do c --- Routine de correction des Identifications Etalons (L. Tassan-Got) call PROPNET c --- Routine utilisateurs pour le traitement evt/evt copy_event=.false. call TRAITEMENT if(fin_lect_run)evt_a_lire=.false. 101 format(1x,5(i6,2x)) end if end do return end c---------------------------------------------------------------------- c-------------------------------------------------------------------- c Routine de travail, dumpe un evt c-------------------------------------------------------------------- subroutine DUMP_EVT(iout) include 'veda_rel.incl' include 'veda_6.incl' integer*4 ivalz(300) common /VEDADUMP/ivalz write(iout,3) write(iout,2) nevtlus,npart_traite write(iout,4) do i=1,npart_traite write(iout,1) icou(i),imod(i),z_indra(i),a_indra(i),code(i), & z(i),a(i),code_part(i),(code_idf(k,i),k=1,4) end do write(iout,3) write(iout,*) ' ' 1 format(1x,i2,':',i2,3x,f6.2,1x,f6.2,1x,i4,2i5,4x,z4,2x,4i5) 2 format(1x,'Evt numero ',i8,' : ',i4,' particules') 3 format(60('-')) 4 format(1x,' Cour Z A Code Z A code_part', & ' code_idf') return end c---------------------------------------------------------------------- c Routine de decodeage des codes d'identification 16 bits DST c c Elle fournit sous forme d'un tableau de 4 entiers*4 les differents c codes ORIGINAUX d'identification ainsi que le code general defini c dans le fichier VEDA_6 INCL sur le disque INDRA 200 . c------------------------------------------------------------------- Subroutine DECODE_PART (jcou,icode,code4) Integer*4 code4(4) Integer*4 icode,jcou,ik,icodg integer*2 codganil(0:15),codlpc(0:15) data codganil/10,15,12,16,30,35,32,-200,20,22,-200,11, & -99,-999,-200,-111/ data codlpc/0,100,1,101,2,102,3,4,-300,-300,-300,-300,-300, & 997,998,999/ code4(1)=jbyt(icode,1,4) code4(2)=jbyt(icode,5,4) code4(3)=jbyt(icode,9,4) code4(4)=jbyt(icode,13,4) icodg=code4(1) if(jcou.eq.1)then ik=code4(2) if(ik.eq.4)code4(2)=-1 elseif (jcou.le.9)then if(icodg.eq.0)then ik=11 code4(2)=codganil(ik) endif if(icodg.eq.1.or.icodg.eq.2.or.icodg.eq.9.or.icodg.eq.10)then ik=code4(2) code4(2)=codganil(ik) elseif(icodg.eq.3)then code4(2)=codganil(1) ik=code4(3) code4(3)=codlpc(ik) endif endif c write(*,'(2x,i6,2x,z4,4x,4i4)')jcou,icode,(code4(i),i=4,1,-1) return end c--------------------------------------------------------------------- subroutine ATOC(itab,long,chaine) integer*2 itab(*) integer*4 long character*(*) chaine do i=1,long ic=itab(i) chaine(i:i)=CHAR(ic) end do return end c--------------------------------------------------------------------- subroutine ATOC_EBCDIC (itab,long,chaine) integer*2 itab(*) integer*4 long character*(*) chaine Integer*4 iascii(256) Common/ASKI/iascii do i=1,long ic=itab(i) ic=iascii(ic) ! transformation code EBCDIC en code ASCII chaine(i:i)=CHAR(ic) end do return end c---------------------------------------------------------------- c Cette routine realise la conversion Caractere --> Integer*2 en c code ASCII ( contenu dans le tableau Ich) c---------------------------------------------------------------- subroutine CTOA(chaine,long,ich) character*(*) chaine integer*4 long,icha integer*2 ich(*) do i=1,long icha=ICHAR(chaine(i:i)) ich(i)=icha end do return end c------------------------------------------------------------------ Subroutine DECODE_SCALER & (buffer,contenu,nb_echelle_a_imprimer,iwt) c *** Routine qui decode le bloc SCALER et remplit le tableau "contenu" c --- 25-01-94 --- Auteur: J-L Charvet (Charvet@FRCPN11) c iwt = 0 : pas d'impression de tous les blocs "SCALER" c iwt <>0 : imp. sur file associe au num. logique iwt c iwt =-1 : retour qui signifie un pb dans le decodage c ---------------------------------------------------------------------- Parameter (nb_echelle_max=255) Integer*2 buffer(8192),ibuf1,ibuf2 Integer*4 buffer_Scaler(4096),ibuf4 Integer*4 iwt Integer*4 nb_echelle_a_imprimer Integer*4 Icount_bloc Integer*4 Long_scaler Integer*4 Nb_channel Integer*4 Status_fix Integer*4 Reserv_fix1,Reserv_fix2 Integer*4 Label(nb_echelle_max) Integer*4 Status(nb_echelle_max) Integer*4 Contenu(nb_echelle_max) Integer*4 Frequence(nb_echelle_max) Integer*4 Tics(nb_echelle_max) Integer*4 Reserve(nb_echelle_max,3) c Common ibuf2,ibuf1 c Equivalence (ibuf4,ibuf2) do i=1,4096 k=2*i-1 ibuf1=buffer(k) ibuf2=buffer(k+1) ibuf4=ibuf2*(2**16)+ibuf1 if(ibuf1.lt.0)ibuf4=ibuf4+2**16 buffer_scaler(i)=ibuf4 enddo k=0 Icount_bloc=buffer_scaler(3) Long_scaler=buffer_scaler(4) Nb_Channel =buffer_scaler(5) Status_fix =buffer_scaler(6) Reserv_fix1=buffer_scaler(7) Reserv_fix2=buffer_scaler(8) do i=9,2048,8 k=k+1 if(k.gt.nb_echelle_max)then write & (*,'('' DECODE_SCALER: nb_echelle > '',i4)')nb_echelle_max iwt=-1 return endif Label(k)=buffer_scaler(i) Status(k)=buffer_scaler(i+1) Contenu(k)=buffer_scaler(i+2) Frequence(k)=buffer_scaler(i+3) Tics (k)=buffer_scaler(i+4) Reserve(k,1)=buffer_scaler(i+5) Reserve(k,2)=buffer_scaler(i+6) Reserve(k,3)=buffer_scaler(i+7) enddo nb_echelle_lu=k if(iwt.gt.0)then write(iwt,100)icount_bloc,nb_echelle_lu 100 format(/,' Compteur bloc = ',i8,/, & ' Nb_echelle lu = ',i8) write(iwt,101)long_scaler,nb_channel,status_fix, &reserv_fix1,reserve_fix2 101 format(/,' Long_scaler = ',i8,/, & ' Nb_channel = ',i8,/, & ' Status_fixe = ',i8,/, & ' Reserve_1 & 2 = ',2i8) write(iwt,102) 102 format(/,80('-'),/, &' Numero Label Status Contenu Frequence', &' Tics(*10ms) Reserve(3)',/, &80('-')) do k=1,nb_echelle_a_imprimer write(iwt,103)k,Label(k),Status(k),Contenu(k),Frequence(k), &Tics(k),(Reserve(k,j),j=1,3) 103 format(i4,2i10,2x,i10,1x,i7,6x,i10,1x,3i5) enddo endif c write(iwt,'(/,'' Bloc_scaler: '',i5)') nbloc_scaler c write(iwt,'(10(1x,z4))')(buffer(i),i=1,512) c write(iwt,'(/)') c write(iwt,'(5(1x,z8))')(buffer_scaler(i),i=1,256) c write(iwt,'(/)') return end c ********************************************************************** Subroutine PRINT_SCALER (iwt) c *** Routine qui imprime le contenu des "echelles" sur iwt c --- 25-01-94 --- Auteur: J-L Charvet (Charvet@FRCPN11) c iwt = 0 : impression sur console (par defaut) c iwt > 0 : impression sur fichier associe au num. logique iwt c ---------------------------------------------------------------------- Include 'veda_rel.incl' Character*18 Nom_echelle(nb_echelle_max) c nom_echelle(1)='Faraday 1' nom_echelle(2)='Faraday 2' nom_echelle(3)='DEC' nom_echelle(4)='FC' nom_echelle(5)='OK' nom_echelle(6)='FT' nom_echelle(7)='AVL' nom_echelle(8)='OCD' nom_echelle(9)='Gene LASER' nom_echelle(10)='Gene ELECT' nom_echelle(11)='Gene TEST' nom_echelle(12)='Gene DIRECT' nom_echelle(13)='Gene TM' nom_echelle(14)='Gene MARQ' nom_echelle(15)='OA' nom_echelle(16)='RAZ' do i=17,nb_echelle_max Nom_echelle(i)=' ' enddo if(iwt.eq.0)iwt=6 write(iwt,100) 100 format(//,10x,' *** IMPRESSION DES ECHELLES ***',/, &11x,31('*')) write(iwt,102) 102 format(/,7x,40('-'),/,7x, &' Echelle Nom Contenu ',/,7x,40('-')) do k=1,nb_echelle_a_imprimer write(iwt,103)k,Nom_echelle(k),echelle(k) 103 format(7x,i5,5x,a,i10) enddo return end c-------------------------------------------------------------------- c --- Routine de decodage du bloc ETAT d'INDRA c-------------------------------------------------------------------- subroutine DEC_BLOC_ETAT(ibuff,irc) integer*2 ibuff(8192) character*80 message,msg(0:100) integer*4 lon_msg,nb_msg,code_msg(0:100) integer*2 itab(80) integer*4 ierr(4) include 'veda_rel.incl' include 'veda_wri.incl' include 'veda_6.incl' c --- Initialisation de Module_panne (=0 : tout OK) do i=1,17 do j=1,24 do k=1,5 Module_panne(i,j,k)=0 enddo enddo enddo c --- irc=0 iwf=i_out c write(iwf,100) write(*,100) 100 format(/,' ETAT D INDRA PENDANT LE RUN ',/,28('-'),/) c print *,'DECODAGE DU Bloc ETAT ' c write(*,'(20i4)')(ibuff(i),i=1,256) i1=1 ipt=8 c --- signification des codes panne lon_msg=ibuff(ipt+1) nb_msg=ibuff(ipt+2) ipt=ipt+2 do i=1,nb_msg code_msg(i)=ibuff(ipt+1) ii=code_msg(i) ipt=ipt+1 do j=1,lon_msg itab(j)=ibuff(ipt+j) enddo if(char_ascii)then call ATOC (itab,lon_msg,message) else call ATOC_EBCDIC (itab,lon_msg,message) endif msg(ii)=message ipt=ipt+lon_msg enddo irc=ibuff(ipt+1)+1 if(irc.ne.0)return ipt=ipt+1 c --- do while (i1.ne.0) i1=ibuff(ipt+1) i2=ibuff(ipt+2) if(i1.ne.0)then ierr(1)=i1/100 ierr(2)=mod(i1,100) ierr(3)=i2/100 ierr(4)=mod(i2,100) message=msg(ierr(4)) call WARNING_INDRA(iwf,ierr,message,lon_msg) if(ierr(2).eq.0)then do j=1,24 Module_panne(ierr(1),j,ierr(3))=ierr(4) enddo else Module_panne(ierr(1),ierr(2),ierr(3))=ierr(4) endif ipt=ipt+2 endif enddo c do i=1,17 c do j=1,24 c do k=1,5 c ico=Module_panne(i,j,k) c if(ico.ne.0)then c print *,' c = ',i,' m = ',j,' Det = ',k,' cod = ',ico,msg(ico) c endif c enddo c enddo c enddo c --- return end c ---------------------------------------------------------------------- subroutine WARNING_INDRA (iwf,ierr,msg,lon_msg) character*80 msg character*10 tip(5), tipo integer*4 iwf,ierr(4),lon_msg data tip /'CHIO','SI','CsI','SI75','SILI'/ if(ierr(1).eq.1)then tipo = 'PHOSWICH' else tipo = tip(ierr(3)) endif if(ierr(2).eq.0)then c write(iwf,10)ierr(1),tipo,ierr(4),msg(1:lon_msg) write(*,10)ierr(1),tipo,ierr(4),msg(1:lon_msg) else c write(iwf,20)ierr(1),ierr(2),tipo,ierr(4),msg(1:lon_msg) write(*,20)ierr(1),ierr(2),tipo,ierr(4),msg(1:lon_msg) endif 10 format(' Cour. ',i3,' Tous modules ',a5,2x,'(',i2,') : ',a) 20 format(' Cour. ',i3,' Module : ',i3,2x,a5,2x,'(',i2,') : ',a) return end c------------------------------------------------------------------- Subroutine CORRECT_BACK (nevt,i) integer*4 nevt,i,cod Include 'veda_6.incl' cod=code_idf(1,i) if(cod.eq.9)then if(code_idf(2,i).eq.7)cod=2 endif if(cod.eq.10)then if(code_idf(2,i).eq.1.or.code_idf(2,i).eq.2)cod=3 if(code_idf(4,i).eq.2)cod=4 endif code_idf(1,i)=cod code(i)=cod return end c ---------------------------------------------------------------------- Subroutine READ_BUFFER(lun,nbloc,buffer,istatus) Parameter (lr=8192) integer*2 buffer(lr) integer*4 lun,irc,nwrec,nwtak,istatus nwrec=4096 nwtak=nwrec istatus=0 c --- lecture d'un bloc call cfget (lun,0,nwrec,nwtak,buffer,irc) istatus=irc ! irc=-1 : fin de fichier detecte nbloc=nbloc+1 if(irc.gt.0)then print *,' !!!! Error cfget : irc = ',irc,' nbloc = ',nbloc c stop 'READ_BUFFER' endif return end c ---------------------------------------------------------------------- Subroutine OPEN_FILE(filein,lun) Character*80 filein integer*4 lun,irc,nwrec,nwtak nwrec=4096 nwtak=nwrec call cfopen (lun,0,nwrec,'r',0,filein,irc) if(irc.ne.0)then print *, ' !!!! Error cfopen : irc = ',irc,' file : ',filein lun=-100 return endif return end c ---------------------------------------------------------------------- Subroutine WRITE_BUFFER(lun,nbloc,buffer,istatus) Parameter (lr=8192) integer*2 buffer(lr) integer*4 lun,istatus istatus=0 c --- ecriture d'un bloc write(lun)buffer nbloc=nbloc+1 return end c ---------------------------------------------------------------------- Subroutine VAR_ENVIRONNEMENT include 'veda_11.incl' call GETENVF ('VEDA_DATA',vedafil) i=0 long_path=0 do while (long_path.eq.0) i=i+1 if(vedafil(i:i).eq.' ')long_path=i-1 enddo if(long_path.gt.3)then write(*,'(/,'' Chemin des fichiers DATA = '',a)') & vedafil(1:long_path) endif ! call GETENVF ('VEDA_REFE',vedafil2) ! i=0 ! long_path2=0 ! do while (long_path2.eq.0) ! i=i+1 ! if(vedafil2(i:i).eq.' ')long_path2=i-1 ! enddo ! if(long_path2.gt.3)then ! write(*,'('' Chemin des fichiers REFERENCE = '',a)') ! & vedafil2(1:long_path2) ! endif ! call GETENVF ('VEDA_PNIA',vedapnia) ! i=0 ! long_dap=0 ! do while (long_dap.eq.0) ! i=i+1 ! if(vedapnia(i:i).eq.' ')long_dap=i-1 ! enddo ! if(long_dap.gt.3)then ! write(*,'('' Chemin des fichiers DAPNIA = '',a)') ! & vedapnia(1:long_dap) ! endif ! call GETENVF ('VEDA_OUT',vedaout) ! i=0 ! long_out=0 ! do while (long_out.eq.0) ! i=i+1 ! if(vedaout(i:i).eq.' ')long_out=i-1 ! enddo ! if(long_out.gt.3)then ! write(*,'('' Chemin des fichiers OUT (HBK) = '',a)') ! & vedaout(1:long_out) ! endif call GETENVF ('RUN_PREFIX',nomjob) i=0 long_job=0 do while (long_job.eq.0) i=i+1 if(nomjob(i:i).eq.' ')long_job=i-1 enddo if(long_job.gt.3)then write(*,'('' Nom du Prefix ='',a)') & nomjob(1:long_job) endif write(*,*) return end c ---------------------------------------------------------------------- c ---------------------------------------------------------------------- c c ********************************************************* c * ROUTINE DE CORRECTION RELATIVE AUX IDENT. DES ETALONS * c ********************************************************* c L. Tassan-Got c c Modification du 27/7/95: c Des particules etaient creees dans la Chio (couronnes 10 a 17) c quand seules des particules atteignant le Csi a travers un etalon c etaient presentes : la fourchette de coherence restait a 0. c c Modification du 18/10/95 pour affecter le code=3 (entre les lignes) c aux Z=1 et Z=2 identifies dans des etalons et ayant des masses hors c gamme. c ---------------------------------------------------------------------- subroutine propnet implicit none c include 'veda_6.incl' include 'veda_rel.incl' c integer i, j, jp, ic, im, ic2, im2, icch, imch, nte, ncs integer izz, iaa, kan integer*4 mn_cou, mx_cou parameter (mn_cou=10, mx_cou=17) integer*4 n_cou(mn_cou:mx_cou), m_etl(mn_cou:mx_cou) integer*4 mch_etl(mn_cou:mx_cou) integer*4 nucou_ch(mn_cou:mx_cou) logical bcl, okc, oks, mdf1, mdf2 integer iabs, mod c data n_cou/ 2,1,1,1,2,1,2,1 / data m_etl/ 2,2,2,4,3,3,2,2 / data mch_etl/ 1,1,1,4,3,3,2,2 / data nucou_ch/ 10,10,12,13,14,14,16,16/ c kan = mod(kanne,100) c --- Suppression des part. crees dans la Chio apres passage etalon --- mdf1 = kan.le.95 .and. kmois.le.7 .and. kjour.le.27 c --- Affectation code entre lignes pour A aberrant sur Z=1 ou 2 --- mdf2 = kan.le.95 .and. kmois.le.10 .and. kjour.le.18 c if(.not.mdf2)return i = 1 do while (i.le.npart_traite) ic = icou(i) im = imod(i) if(mdf2 .and. ic.ge.10 .and. ic.le.17 .and. code(i).eq.3) then izz = z(i) iaa = iabs(a(i)) oks = izz.eq.1 .and. (iaa.lt.1 .or. iaa.gt.3) oks = oks .or. (izz.eq.2 .and. (iaa.lt.3 .or. iaa.gt.6)) if(oks) then code(i) = 10 code_idf(1,i) = 10 endif endif if(mdf1 .and. ic.ge.10 .and. ic.le.17 .and. code(i).eq.7) then oks = im.eq.mch_etl(ic) .and. z(i).eq.1 okc = im.eq.1 .and. ic.le.14 if(oks.or.okc) then nte = 0 ncs = 0 do jp = -1,1,2 j = i+jp bcl = .true. do while (bcl .and. j.ge.1 .and. j.le.npart_traite) ic2 = icou(j) im2 = imod(j) icch = nucou_ch(ic2) if(icch.eq.13) then imch = ((im2-1)/3)*3+1 else if(icch.eq.16) then imch = im2 else imch = ((im2-1)/2)*2+1 endif bcl = icch.eq.ic .and. imch.eq.im if(bcl) then if(code(j).eq.3) then nte = nte+1 else ncs = ncs+1 endif endif j = j+jp enddo enddo if(nte.ge.1 .and. ncs.eq.0 .and. oks) then mcha = mcha-1 ztot = ztot-z(i) npart_traite = npart_traite-1 do j = i,npart_traite ic = j+1 z(j) = z(ic) a(j) = a(ic) z_indra(j) = z_indra(ic) a_indra(j) = a_indra(ic) icou(j) = icou(ic) imod(j) = imod(ic) code_part(j) = code_part(ic) code_cali(j) = code_cali(ic) code(j) = code(ic) ecode(j) = ecode(ic) do jp = 1,4 code_idf(jp,j) = code_idf(jp,ic) enddo do jp = 1,4 code_energie(jp,j) = code_energie(jp,ic) enddo do jp = 1,15 canal(j,jp) = canal(ic,jp) enddo ener(j) = ener(ic) de1(j) = de1(ic) de2(j) = de2(ic) de3(j) = de3(ic) de4(j) = de4(ic) de5(j) = de5(ic) de_mylar(j) = de_mylar(ic) mt(j) = mt(ic) enddo i = i-1 else if(nte.eq.0 .and. ncs.eq.0 .and. okc) then code(i) = 5 code_idf(1,i) = 5 code_part(i) = code_part(i)-2 endif endif endif i = i+1 enddo return end c ---------------------------------------------------------------------------- Subroutine ECRIT_EVT_SELECT include 'veda_rel.incl' include 'veda_wri.incl' integer*2 itab(8) if(wpointeur.eq.0)then call CTOA ('BLOCDATA',8,itab) do i=1,8 wbuffer(i)=itab(i) enddo do i=9,8192 wbuffer(i)=0 enddo wpointeur=8 else ifin=wpointeur + ievt(1) if(ifin.ge.8192)then call WRITE_BUFFER (lunw,nblocecr,wbuffer,istatus) call CTOA ('BLOCDATA',8,itab) do i=1,8 wbuffer(i)=itab(i) enddo do i=9,8192 wbuffer(i)=0 enddo wpointeur=8 endif endif do i=1,ievt(1) k=wpointeur+i wbuffer(k)=ievt(i) enddo wpointeur=wpointeur+ievt(1) nevtecr=nevtecr+1 return end c ------------------------------------------------------------------------- Subroutine INI_ASCII c Routine construisant le tableau iascci : code ASCII = iascii (code EBCDIC) Integer*4 iascii(256) Common/ASKI/iascii do i=1,256 iascii(i)=0 enddo c ---- 0 -> 9 do i=240,249 l=i-192 iascii(i)=l enddo c ---- A -> Z do i=193,202 ! A -> I l=i-128 iascii(i)=l enddo do i=209,217 ! J -> R l=i-135 iascii(i)=l enddo do i=226,233 ! S -> Z l=i-143 iascii(i)=l enddo c ---- a -> z do i=129,137 l=i-32 iascii(i)=l enddo do i=145,153 l=i-39 iascii(i)=l enddo do i=162,169 l=i-47 iascii(i)=l enddo c ---- Divers iascii(64)=32 ! space iascii(90)=33 ! ! iascii(127)=34 ! " iascii(123)=35 ! # iascii(91)=36 ! $ iascii(108)=37 ! % iascii(80)=38 ! & iascii(125)=39 ! ' iascii(77)=40 ! ( iascii(93)=41 ! ) iascii(92)=42 ! * iascii(78)=43 ! + iascii(107)=44 ! , iascii(96)=45 ! - iascii(75)=46 ! . iascii(97)=47 ! / iascii(122)=58 ! : iascii(94)=59 ! ; iascii(76)=60 ! < iascii(126)=61 ! = iascii(110)=62 ! > iascii(111)=63 ! ? iascii(124)=64 ! @ iascii(224)=92 ! \ iascii(109)=95 ! _ iascii(121)=96 ! ` iascii(192)=123 ! { iascii(79)=124 ! | iascii(208)=125 ! } iascii(161)=126 ! ~ return end c---------------------------------------------------------------------------- c --- Routine ecriture de l'entete du fichier c------------------------------------------------------------------- subroutine ECRIT_HEADER_REDUITE (iout,numerun,ibuff) character*8 day,hour,nom character*5 type integer*2 itab(8) integer*2 ibuff(8192),ktab(100) integer*4 i_long1,i_long2,i_long3,i_long4,i_long5 integer*4 iout Character*70 critere integer*4 new_run,long_critere Common /RED1/new_run,long_critere,critere include 'veda_5.incl' character*8 typebloc(4) data typebloc/'VEDARED1','BLOCDATA','ETAT_IND',' SCALER '/ iversion=5 ! Numero de version de l'ecriture VEDA (1ere campagne) c --- Structure du fichier DST, longueurs des evts... i_entete=8 ! Nombre de mots pour entete EVT i_long1=4 ! Nombre de mots pour les Gammas i_long2=9 ! Nombre de mots pour les Phoswichs i_long3=19 ! Nbre de mots pour les Cour. 2 a 9 i_long4=15 ! Nbre de mots pour les Cour. 10 a 17 (sans Etalons) i_long5=18 ! Nbre de mots pour les Cour. 10 a 17 (avec Etalons) c --- Qq messages d'informations write(6,*) ' ' write(6,*) ' Ecriture Bloc HEADER_REDUITE :' write(6,*) ' ' call DATIMH(day,hour) ipt=0 c --- Ecriture du mot d'entete de bloc call CTOA(typebloc(1),8,itab) do i=1,8 ibuff(ipt+i)=Itab(i) end do ipt=ipt+8 ibuff(ipt+1)=numerun ibuff(ipt+2)=ijour ibuff(ipt+3)=imois ibuff(ipt+4)=iannee ibuff(ipt+5)=nint(zproj) ibuff(ipt+6)=nint(aproj) ibuff(ipt+7)=nint(zcib) ibuff(ipt+8)=nint(acib) ibuff(ipt+9)=nint(esura) ibuff(ipt+10)=iversion ipt=ipt+10 c call CTOA(day,8,itab) ! on garde la date de creation DST c do i=1,8 ! a cause des corrections "propnet" c ibuff(ipt+i)=Itab(i) c end do ipt=ipt+8 c call CTOA(hour,8,itab) c do i=1,8 c ibuff(ipt+i)=Itab(i) c end do ipt=ipt+8 c --- taille des blocs enregistres ibuff(ipt+1)=16384 c --- format des mots type='INT*2' ipt=ipt+1 call CTOA(type,5,itab) do i=1,5 ibuff(ipt+i)=Itab(i) end do ipt=ipt+6 ibuff(ipt)=i_entete ibuff(ipt+1)=i_long1 ibuff(ipt+2)=i_long2 ibuff(ipt+3)=i_long3 ibuff(ipt+4)=i_long4 ibuff(ipt+5)=i_long5 ipt=ipt+6 ibuff(ipt)=new_run ipt=ipt+1 ibuff(ipt)=long_critere call CTOA (critere,long_critere,ktab) do l=1,long_critere ibuff(ipt+l)=ktab(l) enddo ipt=ipt+long_critere+1 do i=ipt,8192 ibuff(i)=0 end do c write(6,'(15(1x,z2))')(ibuff(i),i=1,ipt) c --- Ecriture des caracteristiques du run sur fichier #Iout write(iout,100) 100 format(/,' Ecriture Bloc HEADER sur DST Reduite',/,1x,36('-')) write(iout,4) numerun,day,hour 4 format(/,' Run = ',i4,' : DST_Reduite creee le : ',a8,' a ',a8) return end c------------------------------------------------------------------- ************************************************************************ c c Correction apportee aux code energie des Csi couronnes: 10-17 c c Lors de la generation des DST si E_csi > E. limite que peut mesurer c le CsI , la routine CSICALOR retourne le code: code_energie (2,i)=7 c Ce code donne ensuite dans VEDA un code general : ecode(i)=3 c c Il y avait une erreur sur ce test lors de la generation des DST c c Le test sur l'energie limite fonction de la longueur du CsI est c donc refait par cette routine a la lecture des DST. c c JLC 8/7/97 c ************************************************************************ subroutine COR_ECSI_LIMIT (icou,imod,iz,ia,e_csi,iret) implicit none integer mindet, maxdet PARAMETER (MINDET =193, MAXDET = 336) integer icou,imod,iz,ia,iret integer i, nudet, nmod(17)/2*12, 11*24, 2*16, 2*8/ real a,e_csi,emax_a,pre/0.4318/ real emax(mindet:maxdet,2) # /48*166.,24*126.,24*144.,48*129., # 48*664.,24*504.,24*577.,48*517./ nudet = 0 do i = 1,icou-1 nudet = nudet + nmod(i) enddo nudet = nudet + imod iret=1 a=ia * calcul de l'energie max arretee dans le CsI pour Z=1 et 2 et test: * E(A,e) = E(A0,e) * (A/A0)**0.4318 -- base sur R = C E**1.76 et * E(A,e) = (A/A0)* E(A0,e*a0/A) pour un Z donne if(iz.eq.1) then emax_a = emax(nudet,1) * a**pre if(e_csi .gt. emax_a) iret = 7 elseif(iz.eq.2) then emax_a = emax(nudet,2) * (a/4.)**pre if(e_csi .gt. emax_a) iret = 7 endif return end c-------------------------------------------------------------------
gpl-3.0
LucHermitte/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/eispack/tred2.f
41
4123
subroutine tred2(nm,n,a,d,e,z) c integer i,j,k,l,n,ii,nm,jp1 double precision a(nm,n),d(n),e(n),z(nm,n) double precision f,g,h,hh,scale c c this subroutine is a translation of the algol procedure tred2, c num. math. 11, 181-195(1968) by martin, reinsch, and wilkinson. c handbook for auto. comp., vol.ii-linear algebra, 212-226(1971). c c this subroutine reduces a real symmetric matrix to a c symmetric tridiagonal matrix using and accumulating c orthogonal similarity transformations. c c on input c c nm must be set to the row dimension of two-dimensional c array parameters as declared in the calling program c dimension statement. c c n is the order of the matrix. c c a contains the real symmetric input matrix. only the c lower triangle of the matrix need be supplied. c c on output c c d contains the diagonal elements of the tridiagonal matrix. c c e contains the subdiagonal elements of the tridiagonal c matrix in its last n-1 positions. e(1) is set to zero. c c z contains the orthogonal transformation matrix c produced in the reduction. c c a and z may coincide. if distinct, a is unaltered. c c questions and comments should be directed to burton s. garbow, c mathematics and computer science div, argonne national laboratory c c this version dated august 1983. c c ------------------------------------------------------------------ c do 100 i = 1, n c do 80 j = i, n 80 z(j,i) = a(j,i) c d(i) = a(n,i) 100 continue c if (n .eq. 1) go to 510 c .......... for i=n step -1 until 2 do -- .......... do 300 ii = 2, n i = n + 2 - ii l = i - 1 h = 0.0d0 scale = 0.0d0 if (l .lt. 2) go to 130 c .......... scale row (algol tol then not needed) .......... do 120 k = 1, l 120 scale = scale + dabs(d(k)) c if (scale .ne. 0.0d0) go to 140 130 e(i) = d(l) c do 135 j = 1, l d(j) = z(l,j) z(i,j) = 0.0d0 z(j,i) = 0.0d0 135 continue c go to 290 c 140 do 150 k = 1, l d(k) = d(k) / scale h = h + d(k) * d(k) 150 continue c f = d(l) g = -dsign(dsqrt(h),f) e(i) = scale * g h = h - f * g d(l) = f - g c .......... form a*u .......... do 170 j = 1, l 170 e(j) = 0.0d0 c do 240 j = 1, l f = d(j) z(j,i) = f g = e(j) + z(j,j) * f jp1 = j + 1 if (l .lt. jp1) go to 220 c do 200 k = jp1, l g = g + z(k,j) * d(k) e(k) = e(k) + z(k,j) * f 200 continue c 220 e(j) = g 240 continue c .......... form p .......... f = 0.0d0 c do 245 j = 1, l e(j) = e(j) / h f = f + e(j) * d(j) 245 continue c hh = f / (h + h) c .......... form q .......... do 250 j = 1, l 250 e(j) = e(j) - hh * d(j) c .......... form reduced a .......... do 280 j = 1, l f = d(j) g = e(j) c do 260 k = j, l 260 z(k,j) = z(k,j) - f * e(k) - g * d(k) c d(j) = z(l,j) z(i,j) = 0.0d0 280 continue c 290 d(i) = h 300 continue c .......... accumulation of transformation matrices .......... do 500 i = 2, n l = i - 1 z(n,l) = z(l,l) z(l,l) = 1.0d0 h = d(i) if (h .eq. 0.0d0) go to 380 c do 330 k = 1, l 330 d(k) = z(k,i) / h c do 360 j = 1, l g = 0.0d0 c do 340 k = 1, l 340 g = g + z(k,i) * z(k,j) c do 360 k = 1, l z(k,j) = z(k,j) - g * d(k) 360 continue c 380 do 400 k = 1, l 400 z(k,i) = 0.0d0 c 500 continue c 510 do 520 i = 1, n d(i) = z(n,i) z(n,i) = 0.0d0 520 continue c z(n,n) = 1.0d0 e(1) = 0.0d0 return end
apache-2.0
techno/gcc-mist32
libgfortran/intrinsics/f2c_specifics.F90
47
4852
! Copyright (C) 2002-2015 Free Software Foundation, Inc. ! Contributed by Tobias Schl"uter ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. ! !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! Specifics for the intrinsics whose calling conventions change if ! -ff2c is used. ! ! There are two annoyances WRT the preprocessor: ! - we're using -traditional-cpp, so we can't use the ## operator. ! - macros expand to a single line, and Fortran lines can't be wider ! than 132 characters, therefore we use two macros to split the lines ! ! The cases we need to implement are functions returning default REAL ! or COMPLEX. The former need to return DOUBLE PRECISION instead of REAL, ! the latter become subroutines returning via a hidden first argument. ! one argument functions #define REAL_HEAD(NAME) \ elemental function _gfortran_f2c_specific__/**/NAME/**/_r4 (parm) result(res); #define REAL_BODY(NAME) \ REAL, intent (in) :: parm; \ DOUBLE PRECISION :: res; \ res = NAME (parm); \ end function #define COMPLEX_HEAD(NAME) \ subroutine _gfortran_f2c_specific__/**/NAME/**/_c4 (res, parm); #define COMPLEX_BODY(NAME) \ COMPLEX, intent (in) :: parm; \ COMPLEX, intent (out) :: res; \ res = NAME (parm); \ end subroutine #define DCOMPLEX_HEAD(NAME) \ subroutine _gfortran_f2c_specific__/**/NAME/**/_c8 (res, parm); #define DCOMPLEX_BODY(NAME) \ DOUBLE COMPLEX, intent (in) :: parm; \ DOUBLE COMPLEX, intent (out) :: res; \ res = NAME (parm); \ end subroutine REAL_HEAD(abs) REAL_BODY(abs) ! abs is special in that the result is real elemental function _gfortran_f2c_specific__abs_c4 (parm) result (res) COMPLEX, intent(in) :: parm DOUBLE PRECISION :: res res = abs(parm) end function ! aimag is special in that the result is real elemental function _gfortran_f2c_specific__aimag_c4 (parm) complex(kind=4), intent(in) :: parm double precision :: _gfortran_f2c_specific__aimag_c4 _gfortran_f2c_specific__aimag_c4 = aimag(parm) end function elemental function _gfortran_f2c_specific__aimag_c8 (parm) complex(kind=8), intent(in) :: parm double precision :: _gfortran_f2c_specific__aimag_c8 _gfortran_f2c_specific__aimag_c8 = aimag(parm) end function REAL_HEAD(exp) REAL_BODY(exp) COMPLEX_HEAD(exp) COMPLEX_BODY(exp) DCOMPLEX_HEAD(exp) DCOMPLEX_BODY(exp) REAL_HEAD(log) REAL_BODY(log) COMPLEX_HEAD(log) COMPLEX_BODY(log) DCOMPLEX_HEAD(log) DCOMPLEX_BODY(log) REAL_HEAD(log10) REAL_BODY(log10) REAL_HEAD(sqrt) REAL_BODY(sqrt) COMPLEX_HEAD(sqrt) COMPLEX_BODY(sqrt) DCOMPLEX_HEAD(sqrt) DCOMPLEX_BODY(sqrt) REAL_HEAD(asin) REAL_BODY(asin) REAL_HEAD(acos) REAL_BODY(acos) REAL_HEAD(atan) REAL_BODY(atan) REAL_HEAD(asinh) REAL_BODY(asinh) REAL_HEAD(acosh) REAL_BODY(acosh) REAL_HEAD(atanh) REAL_BODY(atanh) REAL_HEAD(sin) REAL_BODY(sin) COMPLEX_HEAD(sin) COMPLEX_BODY(sin) DCOMPLEX_HEAD(sin) DCOMPLEX_BODY(sin) REAL_HEAD(cos) REAL_BODY(cos) COMPLEX_HEAD(cos) COMPLEX_BODY(cos) DCOMPLEX_HEAD(cos) DCOMPLEX_BODY(cos) REAL_HEAD(tan) REAL_BODY(tan) REAL_HEAD(sinh) REAL_BODY(sinh) REAL_HEAD(cosh) REAL_BODY(cosh) REAL_HEAD(tanh) REAL_BODY(tanh) REAL_HEAD(aint) REAL_BODY(aint) REAL_HEAD(anint) REAL_BODY(anint) ! two argument functions #define REAL2_HEAD(NAME) \ elemental function _gfortran_f2c_specific__/**/NAME/**/_r4 (p1, p2) result(res); #define REAL2_BODY(NAME) \ REAL, intent (in) :: p1, p2; \ DOUBLE PRECISION :: res; \ res = NAME (p1, p2); \ end function REAL2_HEAD(sign) REAL2_BODY(sign) REAL2_HEAD(dim) REAL2_BODY(dim) REAL2_HEAD(atan2) REAL2_BODY(atan2) REAL2_HEAD(mod) REAL2_BODY(mod) ! conjg is special-cased because it is not suffixed _c4 but _4 subroutine _gfortran_f2c_specific__conjg_4 (res, parm) COMPLEX, intent (in) :: parm COMPLEX, intent (out) :: res res = conjg (parm) end subroutine subroutine _gfortran_f2c_specific__conjg_8 (res, parm) DOUBLE COMPLEX, intent (in) :: parm DOUBLE COMPLEX, intent (out) :: res res = conjg (parm) end subroutine
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.16/src/dynamics.f
1
7746
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine dynamics(inpc,textpart,nmethod,iperturb,tinc,tper, & tmin,tmax,idrct,alpha,iexpl,isolver,istep,istat,n,iline, & ipol,inl,ipoinp,inp,ithermal,ipoinpc,nef,ctrl,tincf,nener, & ier) ! ! reading the input deck: *DYNAMIC ! ! isolver=0: SPOOLES ! 2: iterative solver with diagonal scaling ! 3: iterative solver with Cholesky preconditioning ! 4: sgi solver ! 5: TAUCS ! 7: pardiso ! ! iexpl==0: structure:implicit, fluid:incompressible ! iexpl==2: structure:explicit, fluid:incompressible ! implicit none ! character*1 inpc(*) character*20 solver character*132 textpart(16) ! integer nmethod,istep,istat,n,key,i,iperturb,idrct,iexpl, & isolver,iline,ipol,inl,ipoinp(2,*),inp(3,*),ithermal, & ipoinpc(0:*),nef,nener,ier ! real*8 tinc,tper,tmin,tmax,alpha(*),ctrl(*),tincf ! if(istep.lt.1) then write(*,*) '*ERROR reading *DYNAMIC: *DYNAMIC can only' write(*,*) ' be used within a STEP' ier=1 return endif ! ! default is implicit ! iexpl=0 ! ! no heat transfer analysis ! if(ithermal.gt.1) then ithermal=1 endif ! ! only nonlinear analysis allowed for this procedure ! if(iperturb.lt.2) iperturb=2 ! ! default values ! idrct=0 alpha(1)=-0.05d0 alpha(2)=0.5d0 tmin=0.d0 tmax=0.d0 tincf=1.d-2 ! ! default solver ! solver=' ' if(isolver.eq.0) then solver(1:7)='SPOOLES' elseif(isolver.eq.2) then solver(1:16)='ITERATIVESCALING' elseif(isolver.eq.3) then solver(1:17)='ITERATIVECHOLESKY' elseif(isolver.eq.4) then solver(1:3)='SGI' elseif(isolver.eq.5) then solver(1:5)='TAUCS' elseif(isolver.eq.7) then solver(1:7)='PARDISO' endif ! do i=2,n if(textpart(i)(1:6).eq.'ALPHA=') then read(textpart(i)(7:26),'(f20.0)',iostat=istat) alpha(1) if(istat.gt.0) then call inputerror(inpc,ipoinpc,iline, & "*DYNAMIC%",ier) return endif if(alpha(1).lt.-1.d0/3.d0) then write(*,*) '*WARNING reading *DYNAMIC: alpha is smaller' write(*,*) ' than -1/3 and is reset to -1/3' alpha(1)=-1.d0/3.d0 elseif(alpha(1).gt.0.d0) then write(*,*) '*WARNING reading *DYNAMIC: alpha is greater' write(*,*) ' than 0 and is reset to 0' alpha(1)=0.d0 endif elseif(textpart(i)(1:8).eq.'EXPLICIT') then iexpl=2 elseif((textpart(i)(1:6).eq.'DIRECT').and. & (textpart(i)(1:9).ne.'DIRECT=NO')) then idrct=1 elseif(textpart(i)(1:7).eq.'SOLVER=') then read(textpart(i)(8:27),'(a20)') solver elseif(textpart(i)(1:18).eq.'RELATIVETOABSOLUTE') then alpha(2)=1.5 else write(*,*) & '*WARNING reading *DYNAMIC: parameter not recognized:' write(*,*) ' ', & textpart(i)(1:index(textpart(i),' ')-1) call inputwarning(inpc,ipoinpc,iline, &"*DYNAMIC%") endif enddo ! if(solver(1:7).eq.'SPOOLES') then isolver=0 elseif(solver(1:16).eq.'ITERATIVESCALING') then isolver=2 elseif(solver(1:17).eq.'ITERATIVECHOLESKY') then isolver=3 elseif(solver(1:3).eq.'SGI') then isolver=4 elseif(solver(1:5).eq.'TAUCS') then isolver=5 elseif(solver(1:7).eq.'PARDISO') then isolver=7 else write(*,*) '*WARNING reading *DYNAMIC: unknown solver;' write(*,*) ' the default solver is used' endif ! call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) if((istat.lt.0).or.(key.eq.1)) then if((iperturb.ge.2).or.(nef.gt.0)) then write(*,*)'*WARNING reading *DYNAMIC: a nonlinear analysis i &s requested' write(*,*) ' but no time increment nor step is speci &fied' write(*,*) ' the defaults (1,1) are used' tinc=1.d0 tper=1.d0 tmin=1.d-5 tmax=1.d+30 tincf=1.d-2 endif nmethod=4 return endif ! read(textpart(1)(1:20),'(f20.0)',iostat=istat) tinc if(istat.gt.0) then call inputerror(inpc,ipoinpc,iline, & "*DYNAMIC%",ier) return endif read(textpart(2)(1:20),'(f20.0)',iostat=istat) tper if(istat.gt.0) then call inputerror(inpc,ipoinpc,iline, & "*DYNAMIC%",ier) return endif read(textpart(3)(1:20),'(f20.0)',iostat=istat) tmin if(istat.gt.0) then call inputerror(inpc,ipoinpc,iline, & "*DYNAMIC%",ier) return endif read(textpart(4)(1:20),'(f20.0)',iostat=istat) tmax if(istat.gt.0) then call inputerror(inpc,ipoinpc,iline, & "*DYNAMIC%",ier) return endif read(textpart(4)(1:20),'(f20.0)',iostat=istat) tincf if(istat.gt.0) then call inputerror(inpc,ipoinpc,iline, & "*DYNAMIC%",ier) return endif ! if(tinc.le.0.d0) then write(*,*)'*ERROR reading *DYNAMIC: initial increment size is n &egative' endif if(tper.le.0.d0) then write(*,*) '*ERROR reading *DYNAMIC: step size is negative' endif if(tinc.gt.tper) then write(*,*)'*ERROR reading *DYNAMIC: initial increment size exce &eds step size' endif if((nef.gt.0).and.(tincf.le.0.d0)) then write(*,*) '*WARNING reading *DYNAMIC: initial CFD increment si &ze is zero or negative; the default of 0.01 is taken' tincf=1.d-2 endif ! if(idrct.ne.1) then if(dabs(tmin).lt.1.d-10*tper) then tmin=min(tinc,1.e-10*tper) endif if(dabs(tmax).lt.1.d-10) then tmax=1.d+30 endif if(dabs(tmax).gt.tper) then tmax=tper endif if(tinc.gt.dabs(tmax)) then write(*,*) '*WARNING reading *DYNAMIC:' write(*,*) ' the initial increment ',tinc write(*,*) ' exceeds the maximum increment ', & tmax write(*,*) ' the initial increment is reduced' write(*,*) ' to the maximum value' tinc=dabs(tmax) endif endif ! ! 10 cutbacks allowed for dynamics (because of contact) ! ctrl(8)=10.5d0 ! nmethod=4 nener=1 ! call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/cident80.f
1
1273
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! ! identifies the position id of px in an ordered array ! x of integers; ! ! id is such that x(id).le.px and x(id+1).gt.px ! subroutine cident80(x,px,n,id) implicit none character*80 x,px integer n,id,n2,m dimension x(n) id=0 if(n.eq.0) return n2=n+1 do m=(n2+id)/2 if(px.ge.x(m)) then id=m else n2=m endif if((n2-id).eq.1) return enddo end
gpl-2.0
prool/ccx_prool
ARPACK_i8/SRC/dstats.f
170
1166
c c\SCCS Information: @(#) c FILE: stats.F SID: 2.1 DATE OF SID: 4/19/96 RELEASE: 2 c %---------------------------------------------% c | Initialize statistic and timing information | c | for symmetric Arnoldi code. | c %---------------------------------------------% subroutine dstats c %--------------------------------% c | See stat.doc for documentation | c %--------------------------------% include 'stat.h' c %-----------------------% c | Executable Statements | c %-----------------------% nopx = 0 nbx = 0 nrorth = 0 nitref = 0 nrstrt = 0 tsaupd = 0.0D+0 tsaup2 = 0.0D+0 tsaitr = 0.0D+0 tseigt = 0.0D+0 tsgets = 0.0D+0 tsapps = 0.0D+0 tsconv = 0.0D+0 titref = 0.0D+0 tgetv0 = 0.0D+0 trvec = 0.0D+0 c %----------------------------------------------------% c | User time including reverse communication overhead | c %----------------------------------------------------% tmvopx = 0.0D+0 tmvbx = 0.0D+0 return c c End of dstats c end
gpl-2.0
val-github/lammps-dev
examples/comb/elastic.f90
15
4827
! This program calculates elastic constants ! Must be used with in.comb-elastic script, and reads output log.lammps ! Written by T-R Shan, MSE, UF, Feb 2010 program main implicit none integer :: i,j,k,l real*8 :: box(6,11),force(6,11),vol(11),eps(11),strbox(6,11) real*8 :: sumx,sumx2,sumy,sumxy,c11,c12,c13,c14,c15,c16,c33,c44,c66,bulk,shear character*7 :: header1 open(5,status='old',file='log.lammps') do i=1,500 read(5,'(a7)') header1 if(header1.eq.'Step Lx')then do j=1,11 read(5,*) k,(box(l,j),l=1,6),(force(l,j),l=1,6) vol(j)=box(1,j)*box(2,j)*box(3,j)*dsqrt(1-(box(4,j)/box(1,j))*(box(4,j)/box(1,j))-(box(6,j)/box(3,j))*(box(6,j)/box(3,j)-(box(5,j)/box(3,j))*(box(5,j)/box(3,j)))) eps(j)=(box(1,j)-box(1,1))/box(1,1) do l=1,6 strbox(l,j)=force(l,j)/vol(j)/1.0d4 enddo enddo exit endif enddo !! C11 sumx = 0.0; sumx2 = 0.0; sumy = 0.0; sumxy = 0.0 do j=2,11 sumx = sumx + eps(j) sumx2= sumx2+ eps(j)*eps(j) sumy = sumy + strbox(1,j) sumxy= sumxy+ strbox(1,j)*eps(j) enddo c11 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C12 sumy = 0.0; sumxy = 0.0 do j=2,11 sumy = sumy + strbox(2,j) sumxy= sumxy+ strbox(2,j)*eps(j) enddo c12 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C13 sumy = 0.0; sumxy = 0.0 do j=2,11 sumy = sumy + strbox(3,j) sumxy= sumxy+ strbox(3,j)*eps(j) enddo c13 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C14 sumy = 0.0; sumxy = 0.0 do j=2,11 sumy = sumy + strbox(4,j) sumxy= sumxy+ strbox(4,j)*eps(j) enddo c14 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C15 sumy = 0.0; sumxy = 0.0 do j=2,11 sumy = sumy + strbox(5,j) sumxy= sumxy+ strbox(5,j)*eps(j) enddo c15 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C16 sumy = 0.0; sumxy = 0.0 do j=2,11 sumy = sumy + strbox(6,j) sumxy= sumxy+ strbox(6,j)*eps(j) enddo c16 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C33 do i=1,500 read(5,'(a7)') header1 if(header1.eq.'Step Lx')then do j=1,11 read(5,*) k,(box(l,j),l=1,6),(force(l,j),l=1,6) vol(j)=box(1,j)*box(2,j)*box(3,j)*dsqrt(1-(box(4,j)/box(1,j))*(box(4,j)/box(1,j))-(box(6,j)/box(3,j))*(box(6,j)/box(3,j)-(box(5,j)/box(3,j))*(box(5,j)/box(3,j)))) eps(j)=(box(3,j)-box(3,1))/box(3,1) do l=1,6 strbox(l,j)=force(l,j)/vol(j)/1.0d4 enddo enddo exit endif enddo sumx = 0.0; sumx2 = 0.0; sumy = 0.0; sumxy = 0.0 do j=2,11 sumx = sumx + eps(j) sumx2= sumx2+ eps(j)*eps(j) sumy = sumy + strbox(3,j) sumxy= sumxy+ strbox(3,j)*eps(j) enddo c33 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C44 do i=1,500 read(5,'(a7)') header1 if(header1.eq.'Step Lx')then do j=1,11 read(5,*) k,(box(l,j),l=1,6),(force(l,j),l=1,6) vol(j)=box(1,j)*box(2,j)*box(3,j)*dsqrt(1.0-(box(4,j)/box(1,j))*(box(4,j)/box(1,j))-(box(6,j)/box(3,j))*(box(6,j)/box(3,j)-(box(5,j)/box(3,j))*(box(5,j)/box(3,j)))) do l=1,6 strbox(l,j)=force(l,j)/vol(j)/1.0d4 enddo enddo exit endif enddo sumx = 0.0; sumx2 = 0.0; sumy = 0.0; sumxy = 0.0 do j=2,11 eps(j)=asin(box(6,j)/box(3,j)) sumx = sumx + eps(j) sumx2= sumx2+ eps(j)*eps(j) sumy = sumy + strbox(6,j) sumxy= sumxy+ strbox(6,j)*eps(j) enddo c44 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) !! C66 do i=1,500 read(5,'(a7)') header1 if(header1.eq.'Step Lx')then do j=1,11 read(5,*) k,(box(l,j),l=1,6),(force(l,j),l=1,6) vol(j)=box(1,j)*box(2,j)*box(3,j)*dsqrt(1.0-(box(4,j)/box(1,j))*(box(4,j)/box(1,j))-(box(6,j)/box(3,j))*(box(6,j)/box(3,j)-(box(5,j)/box(3,j))*(box(5,j)/box(3,j)))) do l=1,6 strbox(l,j)=force(l,j)/vol(j)/1.0d4 enddo enddo exit endif enddo sumx = 0.0; sumx2 = 0.0; sumy = 0.0; sumxy = 0.0 do j=2,11 eps(j)=asin(box(4,j)/box(1,j)) sumx = sumx + eps(j) sumx2= sumx2+ eps(j)*eps(j) sumy = sumy + strbox(4,j) sumxy= sumxy+ strbox(4,j)*eps(j) enddo c66 = (sumxy-sumx*sumy/10.0)/(sumx2-sumx*sumx/10.0) bulk=(c11*2.0+c33)/9.0+2.0*(c12+c13*2.0)/9.0 shear=(2.*c11+c33-c12-2.*c13)/15.+(2.*c44+c66)/5. write(*,*) write(*,*)'Elastic constants (GPa):' write(*,101) 'C11 = ',c11 write(*,101) 'C12 = ',c12 write(*,101) 'C13 = ',c13 write(*,101) 'C14 = ',c14 write(*,101) 'C15 = ',c15 write(*,101) 'C16 = ',c16 write(*,101) 'C33 = ',c33 write(*,101) 'C44 = ',c44 write(*,101) 'C66 = ',c66 write(*,101) 'B = ',bulk write(*,101) 'G = ',shear write(5,*) write(5,*)'Elastic constants (GPa):' write(5,101) 'C11 = ',c11 write(5,101) 'C12 = ',c12 write(5,101) 'C13 = ',c13 write(5,101) 'C14 = ',c14 write(5,101) 'C15 = ',c15 write(5,101) 'C16 = ',c16 write(5,101) 'C33 = ',c33 write(5,101) 'C44 = ',c44 write(5,101) 'C66 = ',c66 write(5,101) 'B = ',bulk write(5,101) 'G = ',shear 101 format(a6,f11.3) stop end
gpl-2.0
techno/gcc-mist32
libgfortran/generated/_acosh_r10.F90
47
1484
! Copyright (C) 2002-2015 Free Software Foundation, Inc. ! Contributed by Paul Brook <[email protected]> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_10) #ifdef HAVE_ACOSHL elemental function _gfortran_specific__acosh_r10 (parm) real (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__acosh_r10 _gfortran_specific__acosh_r10 = acosh (parm) end function #endif #endif
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.15/src/extrapolate_u.f
2
1650
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2018 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine extrapolate_u(yi,yn,ipkon,inum,kon,lakon,nfield,nk, & ne,mi,ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop,i) ! ! extrapolates nfield values at the integration points to the ! nodes for user element i ! implicit none ! logical force ! character*1 cflag character*8 lakon(*) ! integer ipkon(*),inum(*),kon(*),mi(*),ne,nfield,nk,i,ndim, & iorienloc,ielorien(mi(3),*),ielmat(mi(3),*),ielprop(*) ! real*8 yi(ndim,mi(1),*),yn(nfield,*),orab(7,*),co(3,*),prop(*), & vold(0:mi(2),*),thicke(mi(3),*) ! if(lakon(i)(2:3).eq.'1 ') then call extrapolate_u1(yi,yn,ipkon,inum,kon,lakon,nfield,nk, & ne,mi,ndim,orab,ielorien,co,iorienloc,cflag, & vold,force,ielmat,thicke,ielprop,prop,i) endif ! return end
gpl-2.0
alexfrolov/grappa
applications/NPB/OMP/SP/txinvr.f
4
1835
c--------------------------------------------------------------------- c--------------------------------------------------------------------- subroutine txinvr c--------------------------------------------------------------------- c--------------------------------------------------------------------- c--------------------------------------------------------------------- c block-diagonal matrix-vector multiplication c--------------------------------------------------------------------- include 'header.h' integer i, j, k double precision t1, t2, t3, ac, ru1, uu, vv, ww, r1, r2, r3, > r4, r5, ac2inv if (timeron) call timer_start(t_txinvr) !$omp parallel do default(shared) !$omp& private(i,j,k,t1,t2,t3,ac,ru1,uu,vv,ww,r1,r2,r3,r4,r5,ac2inv) do k = 1, nz2 do j = 1, ny2 do i = 1, nx2 ru1 = rho_i(i,j,k) uu = us(i,j,k) vv = vs(i,j,k) ww = ws(i,j,k) ac = speed(i,j,k) ac2inv = ac*ac r1 = rhs(1,i,j,k) r2 = rhs(2,i,j,k) r3 = rhs(3,i,j,k) r4 = rhs(4,i,j,k) r5 = rhs(5,i,j,k) t1 = c2 / ac2inv * ( qs(i,j,k)*r1 - uu*r2 - > vv*r3 - ww*r4 + r5 ) t2 = bt * ru1 * ( uu * r1 - r2 ) t3 = ( bt * ru1 * ac ) * t1 rhs(1,i,j,k) = r1 - t1 rhs(2,i,j,k) = - ru1 * ( ww*r1 - r4 ) rhs(3,i,j,k) = ru1 * ( vv*r1 - r3 ) rhs(4,i,j,k) = - t2 + t3 rhs(5,i,j,k) = t2 + t3 end do end do end do if (timeron) call timer_stop(t_txinvr) return end
bsd-3-clause
epfl-cosmo/q-e
atomic/src/elsdps_paw.f90
15
3050
! ! Copyright (C) 2007 Quantum ESPRESSO group ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http://www.gnu.org/copyleft/gpl.txt . ! ! !--------------------------------------------------------------- subroutine elsdps_paw( ) !--------------------------------------------------------------- ! ! total paw energy in the local-spin-density scheme ! use kinds, only: DP use constants, only: fpi use radial_grids, only : ndmx use ld1_parameters, only : nwfsx use ld1inc, only : nlcc, grid, nspin, rhoc, lsd, & encl, ehrt, ecxc, evxt, ekin, ecc, epseu, & nwfts, enlts, octs, paw_energy use funct, only : dft_is_gradient implicit none real(DP) :: & excc, vxcc(2), & ! exch-corr energy from core charge int_0_inf_dr, & ! the integral function rh0(2), & ! the charge in a given point rhc, & ! core charge in a given point edcts ! auxiliary energy real(DP),allocatable :: & vgc(:,:), & ! the gga potential egc(:), & ! the gga energy rho_aux(:,:), & ! auxiliary space exccc(:) ! the exchange and correlation energy of the core REAL(dp) :: & ! compatibility with metaGGA - not yet used tau(ndmx) = 0.0_dp, vtau(ndmx) = 0.0_dp integer :: & i,ns,ierr ! ! If there is NLCC we calculate here also the exchange and correlation ! energy of the pseudo core charge. ! This quantity is printed but not added to the total energy ! ecc=0.0_DP if (nlcc) then allocate(exccc(ndmx), stat=ierr) exccc=0.0_DP rh0(1)=0.0_DP rh0(2)=0.0_DP do i=1,grid%mesh rhc= rhoc(i)/grid%r2(i)/fpi call vxc_t(lsd,rh0,rhc,excc,vxcc) exccc(i) = excc*rhoc(i) enddo if (dft_is_gradient()) then allocate(rho_aux(ndmx,2), stat=ierr) allocate(vgc(ndmx,2),stat=ierr) allocate(egc(ndmx),stat=ierr) vgc=0.0_DP egc=0.0_DP rho_aux=0.0_DP call vxcgc ( ndmx, grid%mesh, nspin, grid%r, grid%r2, rho_aux, & rhoc, vgc, egc, tau, vtau, 1) do i=1,grid%mesh exccc(i) = exccc(i) + egc(i)*fpi*grid%r2(i) enddo deallocate(egc) deallocate(vgc) deallocate(rho_aux) endif ecc= int_0_inf_dr(exccc,grid,grid%mesh,2) deallocate(exccc) endif ! ! Add the three contributions for each energy ! encl= paw_energy(5,1)+paw_energy(5,2)-paw_energy(5,3) ehrt= paw_energy(2,1)+paw_energy(2,2)-paw_energy(2,3) ecxc= paw_energy(3,1)+paw_energy(3,2)-paw_energy(3,3) edcts= paw_energy(4,1)+paw_energy(4,2)-paw_energy(4,3) ! ! The nonlocal pseudopotential energy is not computed. ! epseu=0.0_DP ! ! Now compute the kinetic energy ! ekin = -encl-edcts do ns=1,nwfts if (octs(ns) > 0.0_DP) then ekin=ekin+octs(ns)*enlts(ns) endif end do return end subroutine elsdps_paw
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.15/src/materials.f
2
2499
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2018 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine materials(inpc,textpart,matname,nmat,nmat_, & irstrt,istep,istat,n,iline,ipol,inl,ipoinp,inp,ipoinpc, & imat,ier) ! ! reading the input deck: *MATERIAL ! implicit none ! character*1 inpc(*) character*80 matname(*) character*132 textpart(16) ! integer nmat,nmat_,istep,istat,n,key,i,irstrt(*),iline,ipol,inl, & ipoinp(2,*),inp(3,*),ipoinpc(0:*),imat,ier ! if((istep.gt.0).and.(irstrt(1).ge.0)) then write(*,*) & '*ERROR reading *MATERIAL: *MATERIAL should be placed' write(*,*) ' before all step definitions' ier=1 return endif ! nmat=nmat+1 if(nmat.gt.nmat_) then write(*,*) '*ERROR reading *MATERIAL: increase nmat_' ier=1 return endif ! imat=nmat ! do i=2,n if(textpart(i)(1:5).eq.'NAME=') then matname(nmat)=textpart(i)(6:85) if(textpart(i)(86:86).ne.' ') then write(*,*) & '*ERROR reading *MATERIAL: material name too long' write(*,*) ' (more than 80 characters)' write(*,*) ' material name:',textpart(i)(1:132) ier=1 return endif exit else write(*,*) & '*WARNING reading *MATERIAL: parameter not recognized:' write(*,*) ' ', & textpart(i)(1:index(textpart(i),' ')-1) call inputwarning(inpc,ipoinpc,iline, &"*MATERIAL%") endif enddo ! call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl, & ipoinp,inp,ipoinpc) ! return end
gpl-2.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/allocate_error_2.f90
181
1104
! { dg-do compile } program main type t1 integer, allocatable :: x(:) integer, allocatable :: y(:) end type t1 type(t1), allocatable :: v(:) allocate (v(3), v(4)) ! { dg-error "Allocate-object at \\(1\\) also appears at \\(2\\)" } allocate (v(1), v(1)%x(2)) ! { dg-error "Allocate-object at \\(1\\) is subobject of object at \\(2\\)" } allocate (v(1)%x(2), v(1)) ! { dg-error "Allocate-object at \\(1\\) is subobject of object at \\(2\\)" } allocate (v(1)%y(2), v(1)%x(1)) allocate (v(2)%x(3), v(2)%x(3)) ! { dg-error "Allocate-object at \\(1\\) also appears at \\(2\\)" } allocate (v(1)%x(3), v(2)%x(3)) deallocate (v, v) ! { dg-error "Allocate-object at \\(1\\) also appears at \\(2\\)" } deallocate (v, v(1)%x) ! { dg-error "Allocate-object at \\(1\\) is subobject of object at \\(2\\)" } deallocate (v(1)%x, v) ! { dg-error "Allocate-object at \\(1\\) is subobject of object at \\(2\\)" } deallocate (v(1)%y, v(1)%x) deallocate (v(2)%x, v(2)%x) ! { dg-error "Allocate-object at \\(1\\) also appears at \\(2\\)" } deallocate (v(1)%x, v(2)%x) end program main
gpl-2.0
LucHermitte/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/blas/dasum.f
71
1063
double precision function dasum(n,dx,incx) c c takes the sum of the absolute values. c jack dongarra, linpack, 3/11/78. c modified 3/93 to return if incx .le. 0. c modified 12/3/93, array(1) declarations changed to array(*) c double precision dx(*),dtemp integer i,incx,m,mp1,n,nincx c dasum = 0.0d0 dtemp = 0.0d0 if( n.le.0 .or. incx.le.0 )return if(incx.eq.1)go to 20 c c code for increment not equal to 1 c nincx = n*incx do 10 i = 1,nincx,incx dtemp = dtemp + dabs(dx(i)) 10 continue dasum = dtemp return c c code for increment equal to 1 c c c clean-up loop c 20 m = mod(n,6) if( m .eq. 0 ) go to 40 do 30 i = 1,m dtemp = dtemp + dabs(dx(i)) 30 continue if( n .lt. 6 ) go to 60 40 mp1 = m + 1 do 50 i = mp1,n,6 dtemp = dtemp + dabs(dx(i)) + dabs(dx(i + 1)) + dabs(dx(i + 2)) * + dabs(dx(i + 3)) + dabs(dx(i + 4)) + dabs(dx(i + 5)) 50 continue 60 dasum = dtemp return end
apache-2.0
prool/ccx_prool
ARPACK_i8/EXAMPLES/NONSYM/sndrv4.f
3
19591
program sndrv4 c c Simple program to illustrate the idea of reverse communication c in shift-invert mode for a generalized nonsymmetric eigenvalue c problem. c c We implement example four of ex-nonsym.doc in DOCUMENTS directory c c\Example-4 c ... Suppose we want to solve A*x = lambda*B*x in inverse mode, c where A and B are derived from the finite element discretization c of the 1-dimensional convection-diffusion operator c (d^2u / dx^2) + rho*(du/dx) c on the interval [0,1] with zero Dirichlet boundary condition c using linear elements. c c ... The shift sigma is a real number. c c ... OP = inv[A-SIGMA*M]*M and B = M. c c ... Use mode 3 of SNAUPD. c c\BeginLib c c\Routines called: c snaupd ARPACK reverse communication interface routine. c sneupd ARPACK routine that returns Ritz values and (optionally) c Ritz vectors. c sgttrf LAPACK tridiagonal factorization routine. c sgttrs LAPACK tridiagonal linear system solve routine. c slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. c saxpy Level 1 BLAS that computes y <- alpha*x+y. c scopy Level 1 BLAS that copies one vector to another. c sdot Level 1 BLAS that computes the dot product of two vectors. c snrm2 Level 1 BLAS that computes the norm of a vector. c av Matrix vector multiplication routine that computes A*x. c mv Matrix vector multiplication routine that computes M*x. c c\Author c Richard Lehoucq c Danny Sorensen c Chao Yang c Dept. of Computational & c Applied Mathematics c Rice University c Houston, Texas c c\SCCS Information: @(#) c FILE: ndrv4.F SID: 2.4 DATE OF SID: 4/22/96 RELEASE: 2 c c\Remarks c 1. None c c\EndLib c----------------------------------------------------------------------- c c %-----------------------------% c | Define leading dimensions | c | for all arrays. | c | MAXN: Maximum dimension | c | of the A allowed. | c | MAXNEV: Maximum NEV allowed | c | MAXNCV: Maximum NCV allowed | c %-----------------------------% c integer maxn, maxnev, maxncv, ldv parameter (maxn=256, maxnev=10, maxncv=25, & ldv=maxn ) c c %--------------% c | Local Arrays | c %--------------% c integer iparam(11), ipntr(14), ipiv(maxn) logical select(maxnev) Real & ax(maxn), mx(maxn), d(maxncv,3), resid(maxn), & v(ldv,maxncv), workd(3*maxn), workev(3*maxncv), & workl(3*maxncv*maxncv+6*maxncv), & dd(maxn), dl(maxn), du(maxn), & du2(maxn) c c %---------------% c | Local Scalars | c %---------------% c character bmat*1, which*2 integer ido, n, nev, ncv, lworkl, info, ierr, j, & nconv, maxitr, ishfts, mode Real & tol, h, s, & sigmar, sigmai, s1, s2, s3 logical first, rvec c c %-----------------------------% c | BLAS & LAPACK routines used | c %-----------------------------% c Real & sdot, snrm2, slapy2 external sdot, snrm2, slapy2, sgttrf, sgttrs c c %--------------------% c | Intrinsic function | c %--------------------% c intrinsic abs c c %------------% c | Parameters | c %------------% c Real & one, zero, two, rho common /convct/ rho parameter (one = 1.0E+0, zero = 0.0E+0, & two = 2.0E+0) c c %-----------------------% c | Executable statements | c %-----------------------% c c %----------------------------------------------------% c | The number N is the dimension of the matrix. A | c | generalized eigenvalue problem is solved (BMAT = | c | 'G'). NEV is the number of eigenvalues (closest | c | to SIGMAR) to be approximated. Since the | c | shift-invert mode is used, WHICH is set to 'LM'. | c | The user can modify NEV, NCV, SIGMAR to solve | c | problems of different sizes, and to get different | c | parts of the spectrum. However, The following | c | conditions must be satisfied: | c | N <= MAXN, | c | NEV <= MAXNEV, | c | NEV + 2 <= NCV <= MAXNCV | c %----------------------------------------------------% c n = 100 nev = 4 ncv = 10 if ( n .gt. maxn ) then print *, ' ERROR with _NDRV4: N is greater than MAXN ' go to 9000 else if ( nev .gt. maxnev ) then print *, ' ERROR with _NDRV4: NEV is greater than MAXNEV ' go to 9000 else if ( ncv .gt. maxncv ) then print *, ' ERROR with _NDRV4: NCV is greater than MAXNCV ' go to 9000 end if bmat = 'G' which = 'LM' sigmar = one sigmai = zero c c %--------------------------------------------------% c | Construct C = A - SIGMA*M in real arithmetic, | c | and factor C in real arithmetic (using LAPACK | c | subroutine sgttrf). The matrix A is chosen to be | c | the tridiagonal matrix derived from the standard | c | central difference discretization of the 1-d | c | convection-diffusion operator u" + rho*u' on the | c | interval [0, 1] with zero Dirichlet boundary | c | condition. The matrix M is the mass matrix | c | formed by using piecewise linear elements on | c | [0,1]. | c %--------------------------------------------------% c rho = 1.0E+1 h = one / real(n+1) s = rho / two c s1 = -one/h - s - sigmar*h s2 = two/h - 4.0E+0*sigmar*h s3 = -one/h + s - sigmar*h c do 10 j = 1, n-1 dl(j) = s1 dd(j) = s2 du(j) = s3 10 continue dd(n) = s2 c call sgttrf(n, dl, dd, du, du2, ipiv, ierr) if ( ierr .ne. 0 ) then print*, ' ' print*, ' ERROR with _gttrf in _NDRV4.' print*, ' ' go to 9000 end if c c %-----------------------------------------------------% c | The work array WORKL is used in SNAUPD as | c | workspace. Its dimension LWORKL is set as | c | illustrated below. The parameter TOL determines | c | the stopping criterion. If TOL<=0, machine | c | precision is used. The variable IDO is used for | c | reverse communication, and is initially set to 0. | c | Setting INFO=0 indicates that a random vector is | c | generated in SNAUPD to start the Arnoldi iteration. | c %-----------------------------------------------------% c lworkl = 3*ncv**2+6*ncv tol = zero ido = 0 info = 0 c c %---------------------------------------------------% c | This program uses exact shifts with respect to | c | the current Hessenberg matrix (IPARAM(1) = 1). | c | IPARAM(3) specifies the maximum number of Arnoldi | c | iterations allowed. Mode 3 of SNAUPD is used | c | (IPARAM(7) = 3). All these options can be | c | changed by the user. For details, see the | c | documentation in SNAUPD. | c %---------------------------------------------------% c ishfts = 1 maxitr = 300 mode = 3 c iparam(1) = ishfts iparam(3) = maxitr iparam(7) = mode c c %------------------------------------------% c | M A I N L O O P(Reverse communication) | c %------------------------------------------% c 20 continue c c %---------------------------------------------% c | Repeatedly call the routine SNAUPD and take | c | actions indicated by parameter IDO until | c | either convergence is indicated or maxitr | c | has been exceeded. | c %---------------------------------------------% c call snaupd ( ido, bmat, n, which, nev, tol, resid, & ncv, v, ldv, iparam, ipntr, workd, & workl, lworkl, info ) c if (ido .eq. -1) then c c %-------------------------------------------% c | Perform y <--- OP*x = inv[A-SIGMA*M]*M*x | c | to force starting vector into the range | c | of OP. The user should supply his/her | c | own matrix vector multiplication routine | c | and a linear system solver. The matrix | c | vector multiplication routine should take | c | workd(ipntr(1)) as the input. The final | c | result should be returned to | c | workd(ipntr(2)). | c %-------------------------------------------% c call mv (n, workd(ipntr(1)), workd(ipntr(2))) call sgttrs('N', n, 1, dl, dd, du, du2, ipiv, & workd(ipntr(2)), n, ierr) if ( ierr .ne. 0 ) then print*, ' ' print*, ' ERROR with _gttrs in _NDRV4.' print*, ' ' go to 9000 end if c c %-----------------------------------------% c | L O O P B A C K to call SNAUPD again. | c %-----------------------------------------% c go to 20 c else if ( ido .eq. 1) then c c %-----------------------------------------% c | Perform y <-- OP*x = inv[A-sigma*M]*M*x | c | M*x has been saved in workd(ipntr(3)). | c | The user only need the linear system | c | solver here that takes workd(ipntr(3)) | c | as input, and returns the result to | c | workd(ipntr(2)). | c %-----------------------------------------% c call scopy( n, workd(ipntr(3)), 1, workd(ipntr(2)), 1) call sgttrs ('N', n, 1, dl, dd, du, du2, ipiv, & workd(ipntr(2)), n, ierr) if ( ierr .ne. 0 ) then print*, ' ' print*, ' ERROR with _gttrs in _NDRV4.' print*, ' ' go to 9000 end if c c %-----------------------------------------% c | L O O P B A C K to call SNAUPD again. | c %-----------------------------------------% c go to 20 c else if ( ido .eq. 2) then c c %---------------------------------------------% c | Perform y <--- M*x | c | Need matrix vector multiplication routine | c | here that takes workd(ipntr(1)) as input | c | and returns the result to workd(ipntr(2)). | c %---------------------------------------------% c call mv (n, workd(ipntr(1)), workd(ipntr(2))) c c %-----------------------------------------% c | L O O P B A C K to call SNAUPD again. | c %-----------------------------------------% c go to 20 c end if c c c %-----------------------------------------% c | Either we have convergence, or there is | c | an error. | c %-----------------------------------------% c if ( info .lt. 0 ) then c c %--------------------------% c | Error message, check the | c | documentation in SNAUPD. | c %--------------------------% c print *, ' ' print *, ' Error with _naupd, info = ', info print *, ' Check the documentation in _naupd.' print *, ' ' c else c c %-------------------------------------------% c | No fatal errors occurred. | c | Post-Process using SNEUPD. | c | | c | Computed eigenvalues may be extracted. | c | | c | Eigenvectors may also be computed now if | c | desired. (indicated by rvec = .true.) | c %-------------------------------------------% c rvec = .true. call sneupd ( rvec, 'A', select, d, d(1,2), v, ldv, & sigmar, sigmai, workev, bmat, n, which, nev, tol, & resid, ncv, v, ldv, iparam, ipntr, workd, & workl, lworkl, ierr ) c c %-----------------------------------------------% c | The real part of the eigenvalue is returned | c | in the first column of the two dimensional | c | array D, and the IMAGINARY part is returned | c | in the second column of D. The corresponding | c | eigenvectors are returned in the first NEV | c | columns of the two dimensional array V if | c | requested. Otherwise, an orthogonal basis | c | for the invariant subspace corresponding to | c | the eigenvalues in D is returned in V. | c %-----------------------------------------------% c if ( ierr .ne. 0) then c c %------------------------------------% c | Error condition: | c | Check the documentation of SNEUPD. | c %------------------------------------% c print *, ' ' print *, ' Error with _neupd, info = ', ierr print *, ' Check the documentation of _neupd. ' print *, ' ' c else c first = .true. nconv = iparam(5) do 30 j=1, nconv c c %---------------------------% c | Compute the residual norm | c | | c | || A*x - lambda*x || | c | | c | for the NCONV accurately | c | computed eigenvalues and | c | eigenvectors. (iparam(5) | c | indicates how many are | c | accurate to the requested | c | tolerance) | c %---------------------------% c if (d(j,2) .eq. zero) then c c %--------------------% c | Ritz value is real | c %--------------------% c call av(n, v(1,j), ax) call mv(n, v(1,j), mx) call saxpy(n, -d(j,1), mx, 1, ax, 1) d(j,3) = snrm2(n, ax, 1) d(j,3) = d(j,3) / abs(d(j,1)) c else if (first) then c c %------------------------% c | Ritz value is complex. | c | Residual of one Ritz | c | value of the conjugate | c | pair is computed. | c %------------------------% c call av(n, v(1,j), ax) call mv(n, v(1,j), mx) call saxpy(n, -d(j,1), mx, 1, ax, 1) call mv(n, v(1,j+1), mx) call saxpy(n, d(j,2), mx, 1, ax, 1) d(j,3) = snrm2(n, ax, 1) call av(n, v(1,j+1), ax) call mv(n, v(1,j+1), mx) call saxpy(n, -d(j,1), mx, 1, ax, 1) call mv(n, v(1,j), mx) call saxpy(n, -d(j,2), mx, 1, ax, 1) d(j,3) = slapy2( d(j,3), snrm2(n, ax, 1) ) d(j,3) = d(j,3) / slapy2(d(j,1),d(j,2)) d(j+1,3) = d(j,3) first = .false. else first = .true. end if c 30 continue c c %-----------------------------% c | Display computed residuals. | c %-----------------------------% c call smout(6, nconv, 3, d, maxncv, -6, & 'Ritz values (Real,Imag) and relative residuals') c end if c c %-------------------------------------------% c | Print additional convergence information. | c %-------------------------------------------% c if ( info .eq. 1) then print *, ' ' print *, ' Maximum number of iterations reached.' print *, ' ' else if ( info .eq. 3) then print *, ' ' print *, ' No shifts could be applied during implicit & Arnoldi update, try increasing NCV.' print *, ' ' end if c print *, ' ' print *, ' _NDRV4 ' print *, ' ====== ' print *, ' ' print *, ' Size of the matrix is ', n print *, ' The number of Ritz values requested is ', nev print *, ' The number of Arnoldi vectors generated', & ' (NCV) is ', ncv print *, ' What portion of the spectrum: ', which print *, ' The number of converged Ritz values is ', & nconv print *, ' The number of Implicit Arnoldi update', & ' iterations taken is ', iparam(3) print *, ' The number of OP*x is ', iparam(9) print *, ' The convergence criterion is ', tol print *, ' ' c end if c c %---------------------------% c | Done with program sndrv4. | c %---------------------------% c 9000 continue c end c c========================================================================== c c matrix vector multiplication subroutine c subroutine mv (n, v, w) integer n, j Real & v(n), w(n), one, four, h parameter (one = 1.0E+0, four = 4.0E+0) c c Compute the matrix vector multiplication y<---M*x c where M is mass matrix formed by using piecewise linear elements c on [0,1]. c w(1) = four*v(1) + one*v(2) do 10 j = 2,n-1 w(j) = one*v(j-1) + four*v(j) + one*v(j+1) 10 continue w(n) = one*v(n-1) + four*v(n) c h = one / real(n+1) call sscal(n, h, w, 1) return end c------------------------------------------------------------------ subroutine av (n, v, w) integer n, j Real & v(n), w(n), one, two, dd, dl, du, s, h, rho common /convct/ rho parameter (one = 1.0E+0, two = 2.0E+0) c c Compute the matrix vector multiplication y<---A*x c where A is obtained from the finite element discretization of the c 1-dimensional convection diffusion operator c d^u/dx^2 + rho*(du/dx) c on the interval [0,1] with zero Dirichlet boundary condition c using linear elements. c This routine is only used in residual calculation. c h = one / real(n+1) s = rho / two dd = two / h dl = -one/h - s du = -one/h + s c w(1) = dd*v(1) + du*v(2) do 10 j = 2,n-1 w(j) = dl*v(j-1) + dd*v(j) + du*v(j+1) 10 continue w(n) = dl*v(n-1) + dd*v(n) return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.11/src/generateeminterfaces.f
3
7020
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2015 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine generateeminterfaces(istartset,iendset, & ialset,iactive,ipkon,lakon,kon,ikmpc,nmpc,nafaces) ! ! determines the interfaces in between the phi-domain and any ! other domain, i.e. ! ! faces belonging to the phi domain and adjacent to the A- or ! A-V-domain ! faces belonging to the A-domain adjacent to the phi-domain ! faces belonging to the A-V-domain adjacent to the phi-domain ! implicit none ! character*8 lakon(*) ! integer istartset(*),iendset(*),ialset(*),iactive(3), & ipkon(*),kon(*),iset,ntotal,nope,nopes,indexe,nodef(9), & ifaceq(8,6),ifacet(6,4),ifacew1(4,5),ifacew2(8,5),m, & node,idof,jdof(3),idummy,nlength,kflag,ikmpc(*),nmpc,id, & iface,nelem,jface,i,j,k,nafaces ! data kflag /1/ ! ! nodes per face for hex elements ! data ifaceq /4,3,2,1,11,10,9,12, & 5,6,7,8,13,14,15,16, & 1,2,6,5,9,18,13,17, & 2,3,7,6,10,19,14,18, & 3,4,8,7,11,20,15,19, & 4,1,5,8,12,17,16,20/ ! ! nodes per face for tet elements ! data ifacet /1,3,2,7,6,5, & 1,2,4,5,9,8, & 2,3,4,6,10,9, & 1,4,3,8,10,7/ ! ! nodes per face for linear wedge elements ! data ifacew1 /1,3,2,0, & 4,5,6,0, & 1,2,5,4, & 2,3,6,5, & 3,1,4,6/ ! ! nodes per face for quadratic wedge elements ! data ifacew2 /1,3,2,9,8,7,0,0, & 4,5,6,10,11,12,0,0, & 1,2,5,4,7,14,10,13, & 2,3,6,5,8,15,11,14, & 3,1,4,6,9,13,12,15/ ! ! The sets iactive(1),iactive(2) and iactive(3) contain all ! external surfaces of the phi-domain, the A-V-domain and the ! A-domain, respectively. In what follows these surfaces are ! shrunk to those faces in common between the phi-domain and the ! others, i.e. iactive(1) contains the faces of the phi-domain ! adjacent to the A-V-domain and A-domain, iactive(2) contains the ! faces of the A-V-domain adjacent to the phi-domain and iactive(3) ! contains the faces of the A-domain adjacent to the phi-domain ! ! 1) determining the faces of the phi-domain in all nodes of which a ! MPC for the x-component of A exists. ! 2) determining the faces of the A-V-domain in all nodes of which ! a MPC for phi exists (dof 5) ! 3) determining the faces of the A-domain in all nodes of which ! a MPC for phi exists (dof 5) ! jdof(1)=1 jdof(2)=5 jdof(3)=5 ! do m=1,3 if(iactive(m).gt.0) then iset=iactive(m) ntotal=0 loop1: do j=istartset(iset),iendset(iset) iface=ialset(j) nelem=int(iface/10.d0) jface=iface-10*nelem ! ! nodes belonging to the element (nope) and to the ! face (nopes) ! if(lakon(nelem)(4:5).eq.'8R') then nopes=4 nope=8 elseif(lakon(nelem)(4:4).eq.'8') then nopes=4 nope=8 elseif(lakon(nelem)(4:6).eq.'20R') then nopes=8 nope=20 elseif(lakon(nelem)(4:5).eq.'20') then nopes=8 nope=20 elseif(lakon(nelem)(4:5).eq.'10') then nopes=6 nope=10 elseif(lakon(nelem)(4:4).eq.'4') then nopes=3 nope=4 ! ! treatment of wedge faces ! elseif(lakon(nelem)(4:4).eq.'6') then nope=6 if(jface.le.2) then nopes=3 else nopes=4 endif elseif(lakon(nelem)(4:5).eq.'15') then nope=15 if(jface.le.2) then nopes=6 else nopes=8 endif endif ! ! nodes belonging to the face ! indexe=ipkon(nelem) if((nope.eq.20).or.(nope.eq.8)) then do k=1,nopes nodef(k)=kon(indexe+ifaceq(k,jface)) enddo elseif((nope.eq.10).or.(nope.eq.4)) then do k=1,nopes nodef(k)=kon(indexe+ifacet(k,jface)) enddo elseif(nope.eq.15) then do k=1,nopes nodef(k)=kon(indexe+ifacew2(k,jface)) enddo else do k=1,nopes nodef(k)=kon(indexe+ifacew1(k,jface)) enddo endif ! do i=1,nopes node=nodef(i) idof=8*(node-1)+jdof(m) call nident(ikmpc,idof,nmpc,id) if(id.gt.0) then if(ikmpc(id).eq.idof) cycle endif cycle loop1 enddo ! ialset(istartset(iset)+ntotal)=iface ntotal=ntotal+1 cycle enddo loop1 iendset(iset)=istartset(iset)+ntotal-1 endif enddo ! ! sorting the sets ! do m=1,3 if(iactive(m).eq.0) cycle nlength=iendset(iactive(m))-istartset(iactive(m))+1 call isortii(ialset(istartset(iactive(m))),idummy, & nlength,kflag) enddo ! ! nafaces is the total number of faces belonging to the A-V-domain ! or A-domain and adjacent to the phi-domain. The nodes on these ! faces are subject to A.n=0 ! if((iactive(2).eq.0).and.(iactive(3).eq.0)) then nafaces=0 elseif(iactive(2).eq.0) then nafaces=iendset(iactive(3))-istartset(iactive(3))+1 elseif(iactive(3).eq.0) then nafaces=iendset(iactive(2))-istartset(iactive(2))+1 else nafaces=iendset(iactive(2))-istartset(iactive(2))+1 & +iendset(iactive(3))-istartset(iactive(3))+1 endif ! return end
gpl-2.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/bessel_6.f90
123
1476
! { dg-do run { xfail spu-*-* } } ! { dg-add-options ieee } ! ! PR fortran/36158 ! PR fortran/33197 ! ! XFAILed for SPU targets since we don't have an accurate library ! implementation of the single-precision Bessel functions. ! ! Run-time tests for transformations BESSEL_JN ! implicit none real,parameter :: values(*) = [0.0, 0.5, 1.0, 0.9, 1.8,2.0,3.0,4.0,4.25,8.0,34.53, 475.78] real,parameter :: myeps(size(values)) = epsilon(0.0) & * [2, 7, 5, 6, 9, 12, 12, 7, 7, 8, 92, 15 ] ! The following is sufficient for me - the values above are a bit ! more tolerant ! * [0, 5, 3, 4, 6, 7, 7, 5, 5, 6, 66, 4 ] integer,parameter :: mymax(size(values)) = & [100, 17, 23, 21, 27, 28, 32, 35, 31, 41, 47, 37 ] integer, parameter :: Nmax = 100 real :: rec(0:Nmax), lib(0:Nmax) integer :: i do i = 1, ubound(values,dim=1) call compare(mymax(i), values(i), myeps(i)) end do contains subroutine compare(mymax, X, myeps) integer :: i, nit, mymax real X, myeps, myeps2 rec(0:mymax) = BESSEL_JN(0, mymax, X) lib(0:mymax) = [ (BESSEL_JN(i, X), i=0,mymax) ] !print *, 'YN for X = ', X, ' -- Epsilon = ',epsilon(x) do i = 0, mymax ! print '(i2,2e17.9,e12.2,f18.10,2l3)', i, rec(i), lib(i), & ! rec(i)-lib(i), ((rec(i)-lib(i))/rec(i))/epsilon(x), & ! rec(i) == lib(i), abs((rec(i)-lib(i))/rec(i)) < myeps if (rec(i) == lib(i)) CYCLE if (abs((rec(i)-lib(i))/rec(i)) > myeps) & call abort() end do end end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/genfirstactif.f
1
10840
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! ! subroutine generating the first actice set ! and calculating the areas for all faces on slaveside ! ! [in] imastop (l,i) for edge l in triagle i neightbouring triangle ! [in] islavsurf islavsurf(1,i) slaveface i islavsurf(2,i) pointer into imastsurf and pmastsurf ! [in] itiefac pointer into field islavsurf: (1,i) beginning slave_i (2,i) end of slave_i ! [out] areaslav (i)area of face i, ONLY HELP FIELD ! [in,out] ifree in=0 out=# active nodes ! subroutine genfirstactif(tieset,ntie,itietri,ipkon,kon,lakon,cg, & straight,co,vold,xo,yo,zo,x,y,z,nx,ny,nz,istep,iinc,iit, & mi,imastop,nslavnode,islavnode,islavsurf,itiefac,areaslav, & set,nset,istartset,iendset,ialset,islavact,ifree,tietol) ! ! Initialization of the Active slave nodes set ! ! Author: Samoela Rakotonanahary, Saskia Sitzmann ! ! guido: areaslav not needed?? ! implicit none ! character*8 lakon(*) character*81 tieset(3,*),slavset,set(*),noset ! integer ntie, & itietri(2,ntie),ipkon(*),kon(*),node,neigh(1),iflag,kneigh, & i,j,k,l,isol,iset,idummy,itri,ll,kflag,n,nx(*),ny(*),istep, & iinc,mi(*),nz(*),nstart,iit,nope,iteller,ifaces,jfaces, & imastop(3,*), itriangle(100),ntriangle,ntriangle_,itriold, & itrinew,id,nslavnode(*),islavnode(*),islavsurf(2,*), & itiefac(2,*),konl(20),nelems,m,mint2d,nopes, & ipos,nset,istartset(*),iendset(*), & ialset(*),islavact(*),ifree,ifac,getlocno ! real*8 cg(3,*),straight(16,*),co(3,*),vold(0:mi(2),*),p(3), & dist,xo(*),yo(*),zo(*),x(*),y(*),z(*),c0,weight, & areaslav(*),xl2(3,8),area,xi,et,shp2(7,8), & xs2(3,2),xsj2(3),tietol(3,*),adjust ! ! ! ! flag for shape functions ! data iflag /2/ ! data iteller /0/ save iteller ! include "gauss.f" ! do i=1,ntie if(tieset(1,i)(81:81).ne.'C') cycle kneigh=1 slavset=tieset(2,i) ! ! check whether an adjust node set has been defined ! only checked in the first increment of the first step ! if((istep.eq.1).and.(iinc.eq.1).and.(iit.le.1)) then iset=0 if(tieset(1,i)(1:1).ne.' ') then noset(1:80)=tieset(1,i)(1:80) noset(81:81)=' ' ipos=index(noset,' ') noset(ipos:ipos)='N' do iset=1,nset if(set(iset).eq.noset) exit enddo kflag=1 call isortii(ialset(istartset(iset)),idummy, & iendset(iset)-istartset(iset)+1,kflag) endif endif ! ! determine the area of the slave surfaces ! do l=itiefac(1,i),itiefac(2,i) ifaces=islavsurf(1,l) nelems=int(ifaces/10) jfaces=ifaces-nelems*10 ! ! Decide on the max integration points number, just consider 2D situation ! call getnumberofnodes(nelems,jfaces,lakon,nope,nopes,mint2d) ! ! actual position of the nodes belonging to the ! slave surface ! do j=1,nope konl(j)=kon(ipkon(nelems)+j) enddo do m=1,nopes ifac=getlocno(m,jfaces,nope) do j=1,3 xl2(j,m)=co(j,konl(ifac))+ & vold(j,konl(ifac)) enddo enddo ! ! calculating the area of the slave face ! area=0.d0 do m=1,mint2d if((lakon(nelems)(4:5).eq.'8R').or. & ((lakon(nelems)(4:4).eq.'6').and.(nopes.eq.4))) then xi=gauss2d1(1,m) et=gauss2d1(2,m) weight=weight2d1(m) elseif((lakon(nelems)(4:4).eq.'8').or. & (lakon(nelems)(4:6).eq.'20R').or. & ((lakon(nelems)(4:5).eq.'15').and. & (nopes.eq.8))) then xi=gauss2d2(1,m) et=gauss2d2(2,m) weight=weight2d2(m) elseif(lakon(nelems)(4:4).eq.'2') then xi=gauss2d3(1,m) et=gauss2d3(2,m) weight=weight2d3(m) elseif((lakon(nelems)(4:5).eq.'10').or. & ((lakon(nelems)(4:5).eq.'15').and. & (nopes.eq.6))) then xi=gauss2d5(1,m) et=gauss2d5(2,m) weight=weight2d5(m) elseif((lakon(nelems)(4:4).eq.'4').or. & ((lakon(nelems)(4:4).eq.'6').and. & (nopes.eq.3))) then xi=gauss2d4(1,m) et=gauss2d4(2,m) weight=weight2d4(m) endif ! if(nopes.eq.8) then call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) elseif(nopes.eq.4) then call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) elseif(nopes.eq.6) then call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) else call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) endif area=area+weight*dsqrt(xsj2(1)**2+xsj2(2)**2+ & xsj2(3)**2) enddo areaslav(l)=area enddo ! ! search a master face for each slave node and generate a contact ! spring element if successful ! nstart=itietri(1,i)-1 n=itietri(2,i)-nstart if(n.lt.kneigh) kneigh=n do j=1,n xo(j)=cg(1,nstart+j) x(j)=xo(j) nx(j)=j yo(j)=cg(2,nstart+j) y(j)=yo(j) ny(j)=j zo(j)=cg(3,nstart+j) z(j)=zo(j) nz(j)=j enddo kflag=2 call dsort(x,nx,n,kflag) call dsort(y,ny,n,kflag) call dsort(z,nz,n,kflag) ! do j=nslavnode(i)+1,nslavnode(i+1) node=islavnode(j) ! do k=1,3 p(k)=co(k,node)+vold(k,node) enddo ! ! determining the kneigh neighboring master contact ! triangle centers of gravity ! call near3d(xo,yo,zo,x,y,z,nx,ny,nz,p(1),p(2),p(3), & n,neigh,kneigh) ! isol=0 ! itriold=0 itri=neigh(1)+itietri(1,i)-1 ntriangle=0 ntriangle_=100 ! loop1: do do l=1,3 ll=4*l-3 dist=straight(ll,itri)*p(1)+ & straight(ll+1,itri)*p(2)+ & straight(ll+2,itri)*p(3)+ & straight(ll+3,itri) if(dist.gt.1.d-6) then itrinew=imastop(l,itri) if(itrinew.eq.0) then c write(*,*) '**border reached' exit loop1 elseif((itrinew.lt.itietri(1,i)).or. & (itrinew.gt.itietri(2,i))) then c write(*,*) '**border reached' exit loop1 elseif(itrinew.eq.itriold) then c write(*,*) '**solution in between triangles' isol=itri exit loop1 else call nident(itriangle,itrinew,ntriangle,id) if(id.gt.0) then if(itriangle(id).eq.itrinew) then c write(*,*) '**circular path; no solution' exit loop1 endif endif ntriangle=ntriangle+1 if(ntriangle.gt.ntriangle_) then c write(*,*) '**too many iterations' exit loop1 endif do k=ntriangle,id+2,-1 itriangle(k)=itriangle(k-1) enddo itriangle(id+1)=itrinew itriold=itri itri=itrinew cycle loop1 endif elseif(l.eq.3) then c write(*,*) '**regular solution' isol=itri exit loop1 endif enddo enddo loop1 ! ! check whether distance is larger than c0: ! no element is generated ! if(isol.ne.0) then dist=straight(13,itri)*p(1)+ & straight(14,itri)*p(2)+ & straight(15,itri)*p(3)+ & straight(16,itri) ! ! check for an adjust parameter (only in the first ! increment of the first step) ! if((istep.eq.1).and.(iinc.eq.1).and.(iit.le.1)) then if(iset.ne.0) then ! ! check whether node belongs to the adjust node ! set ! call nident(ialset(istartset(iset)),node, & iendset(iset)-istartset(iset)+1,id) if(id.gt.0) then if(ialset(istartset(iset)+id-1).eq.node) then do k=1,3 co(k,node)=co(k,node)- & dist*straight(12+k,itri) enddo dist=0.d0 endif endif elseif(dabs(tietol(1,i)).ge.2.d0) then ! ! adjust parameter ! adjust=dabs(tietol(1,i))-2.d0 if(dist.le.adjust) then do k=1,3 co(k,node)=co(k,node)- & dist*straight(12+k,itri) enddo dist=0.d0 endif endif endif ! c0=1.d-10 if(dabs(tietol(1,i)).ge.2.d0) then c0=dabs(tietol(1,i))-2.d0 endif if(dist.gt.c0) then isol=0 ! ! adjusting the bodies at the start of the ! calculation such that they touch ! endif endif ! if(isol.ne.0) then ! ! Active node islavact(j)=2 ifree=ifree+1 else islavact(j)=-1 ! endif ! enddo enddo ! return end
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/interpolsubmodel.f
1
5037
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine interpolsubmodel(integerglob,doubleglob,value, & coo,iselect,nselect,nodeface,tieset,istartset,iendset, & ialset,ntie,entity) ! ! interpolates for a node with coordinates in "coo" the ! "nselect" values with relative positions in "iselect" within the ! global mesh stored in integerglob and doubleglob. The fields ! integerglob and doubleglob are created and filled in ! getglobalresults.c. ! The domain of the global model within which ! the interpolation takes place can be limited to an element ! subset. To this end the submodel to which node "node" belongs is ! determined. The submodels are stored in tieset(1..3,i), i=1..ntie. ! tieset(1,i)(81:81)='S' if the tie is a submodel. In that case the ! set number corresponding to the submodel boundary is stored in ! tieset(2,i) and the set number corresponding to the global element ! model in tieset(3,i). Notice that the submodel boundary can be ! a nodal set or an element face set (the actual node and the actual ! element face are stored in nodeface, respecively). ! implicit none ! character*1 entity character*81 tieset(3,*) ! integer integerglob(*),nselect,iselect(nselect),nodeface, & istartset(*),iendset(*),ialset(*),ntie,i,islavset,iset, & nlength,id,jfaces,nelems,nktet,netet,ne,nkon,nfaces,nfield, & imastset,nterms,konl(20),nelem,loopa ! real*8 doubleglob(*),value(*),coo(3),ratio(20),dist,coords(3) ! ! ! ! if no global file was read, set results to zero ! if(integerglob(1).eq.0) then do i=1,nselect value(i)=0.d0 enddo return endif ! ! determining the submodel to which the entity "nodeface" belongs ! islavset=0 do i=1,ntie if(tieset(1,i)(81:81).ne.'S') cycle ! ! check whether submodel is of the right kind (nodal or ! element face) ! if(tieset(2,i)(11:11).ne.entity) cycle read(tieset(2,i)(1:10),'(i10)') iset nlength=iendset(iset)-istartset(iset)+1 call nident(ialset(istartset(iset)),nodeface,nlength,id) if(id.le.0) cycle if(ialset(istartset(iset)+id-1).ne.nodeface) cycle ! ! check whether slave set is of the right ! islavset=iset exit enddo ! ! check whether a submodel was found ! if(islavset.eq.0) then if(entity.eq.'N') then write(*,*) '*ERROR in interpolsubmodel: node',nodeface write(*,*) ' does not belong to any submodel' call exit(201) else nelems=int(nodeface/10) jfaces=nodeface-nelems*10 write(*,*) '*ERROR in interpolsubmodel: face',jfaces write(*,*) ' of element',nelems write(*,*) ' does not belong to any submodel' call exit(201) endif endif ! ! determining the global element set (if zero: all global elements ! are taken) ! read(tieset(3,i)(1:10),'(i10)') imastset ! ! reading the number of nodes, tetrahedral interpolation elements, ! global elements, connectivity size and number of faces ! nktet=integerglob(1) netet=integerglob(2) ne=integerglob(3) nkon=integerglob(4) nfaces=integerglob(5) nfield=13 ! ! perform the interpolation ! coords(1)=coo(1) coords(2)=coo(2) coords(3)=coo(3) loopa=8 call basis(doubleglob(1),doubleglob(netet+1), & doubleglob(2*netet+1), & doubleglob(3*netet+1),doubleglob(4*netet+1), & doubleglob(5*netet+1),integerglob(6),integerglob(netet+6), & integerglob(2*netet+6),doubleglob(6*netet+1), & integerglob(3*netet+6),nktet,netet, & doubleglob(4*nfaces+6*netet+1),nfield, & doubleglob(13*nktet+4*nfaces+6*netet+1), & integerglob(7*netet+6),integerglob(ne+7*netet+6), & integerglob(2*ne+7*netet+6),integerglob(nkon+2*ne+7*netet+6), & coords(1),coords(2),coords(3),value,ratio,iselect,nselect, & istartset,iendset,ialset,imastset, & integerglob(nkon+2*ne+8*netet+6),nterms,konl,nelem,loopa, & dist) ! return end
gpl-2.0
techno/gcc-mist32
gcc/testsuite/gfortran.dg/widechar_select_1.f90
174
1479
! { dg-do run } ! { dg-options "-fbackslash" } call testme(test("foo"), test4(4_"foo"), 1) call testme(test(""), test4(4_""), 1) call testme(test("gee"), test4(4_"gee"), 4) call testme(test("bar"), test4(4_"bar"), 1) call testme(test("magi"), test4(4_"magi"), 4) call testme(test("magic"), test4(4_"magic"), 2) call testme(test("magic "), test4(4_"magic "), 2) call testme(test("magica"), test4(4_"magica"), 4) call testme(test("freeze"), test4(4_"freeze"), 3) call testme(test("freeze "), test4(4_"freeze "), 3) call testme(test("frugal"), test4(4_"frugal"), 3) call testme(test("frugal "), test4(4_"frugal "), 3) call testme(test("frugal \x01"), test4(4_"frugal \x01"), 3) call testme(test("frugal \xFF"), test4(4_"frugal \xFF"), 4) contains integer function test(s) character(len=*) :: s select case (s) case ("":"foo") test = 1 case ("magic") test = 2 case ("freeze":"frugal") test = 3 case default test = 4 end select end function test integer function test4(s) character(kind=4,len=*) :: s select case (s) case (4_"":4_"foo") test4 = 1 case (4_"magic") test4 = 2 case (4_"freeze":4_"frugal") test4 = 3 case default test4 = 4 end select end function test4 subroutine testme(x,y,z) integer :: x, y, z if (x /= y) call abort if (x /= z) call abort end subroutine testme end
gpl-2.0
epfl-cosmo/q-e
PHonon/PH/d2ionq_mm.f90
8
6082
! ! Copyright (C) 2016 Quantum ESPRESSO Foundation ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http://www.gnu.org/copyleft/gpl.txt . ! ! Calculation of Grimme D2 contribution to the dyamical matrix ! See module "london_module" in Modules/mm_dispersion.f90 ! Written by Fabrizio Masullo for his M.Sc. in Mathematic at UniUD ! under the supervision of Paolo Giannozzi !------------------------------------------------------------------------------ ! ! SUBROUTINE d2ionq_mm ( alat , nat , ityp , at , bg , tau, q, deriv2_london ) ! USE london_module USE constants, ONLY : tpi, eps8 USE mp_images, ONLY : me_image , nproc_image , intra_image_comm USE mp, ONLY : mp_sum ! IMPLICIT NONE ! INTEGER , INTENT ( in ) :: nat , ityp ( nat ) ! input: ! nat : number of atoms ! ityp : type of each atom ! REAL ( DP ) , INTENT ( in ) :: alat, tau(3, nat), at(3 , 3), bg(3 , 3), q(3) ! input: ! alat : the cell parameter ! tau : atomic positions in alat units ! at : direct lattice vectors ! bg : reciprocal lattice vectors ! q : wave-vector (in 2pi/alat units) ! COMPLEX ( DP ), INTENT(OUT) :: deriv2_london ( 3, nat, 3, nat ) ! INTEGER :: ata , atb , nrm , nr , ipol, jpol ! locals : ! ata , atb : atom counters ! nrm : actual number of vectors computed by rgen ! nr : counter on neighbours shells ! ipol, jpol: counters on coords ! INTEGER :: first , last , resto, divid ! locals : ! first : lower bound on processor ! last : upper ! REAL ( DP ) :: dist , f_damp , dtau ( 3 ) , & exparg , expval, par , par2, fac , facF, add, addF, auxr COMPLEX ( DP ) :: eiqr ! locals : ! dist : distance R_ij between the current pair of atoms ! f_damp : damping function ! dtau : \vec R_ij ! ... and many other temporary variables, plus some buffers: ! REAL ( DP ) :: aux (3, 3, nat) COMPLEX ( DP ) :: aux2(3, 3, nat) ! ! deriv2_london ( : , : , : , :) = 0.d0 ! #if defined __MPI ! ! parallelization: divide atoms across processors of this image ! (different images have different atomic positions) ! resto = mod ( nat , nproc_image ) divid = nat / nproc_image ! IF ( me_image + 1 <= resto ) THEN ! first = ( divid + 1 ) * me_image + 1 last = ( divid + 1 ) * ( me_image + 1 ) ! ELSE ! first = ( ( divid + 1 ) * resto ) + ( divid ) * ( me_image-resto ) + 1 last = ( divid + 1 ) * resto + ( divid ) * ( me_image - resto + 1 ) ! ENDIF ! #else ! first = 1 last = nat #endif ! DO ata = first , last ! aux(:,:,:) = 0.d0 aux2(:,:,:) = 0.d0 ! DO atb = 1 , nat ! dtau ( : ) = tau ( : , ata ) - tau ( : , atb ) ! ! generate neighbours shells CALL rgen ( dtau, r_cut, mxr, at, bg, r, dist2, nrm ) ! ! compute forces ! par = beta / ( R_sum ( ityp ( atb ) , ityp ( ata ) ) ) ! par2 = par**2 ! #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1600) !$omp parallel do private(nr,dist,exparg,expval,fac,add,eiqr,facF,addF,auxr,ipol,jpol) default(shared), reduction(+:aux), reduction(+:aux2) #endif DO nr = 1 , nrm ! dist = alat * sqrt ( dist2 ( nr ) ) IF ( dist > eps8 ) THEN ! exparg = - beta * ( dist / ( R_sum ( ityp(atb) , ityp(ata) ) ) - 1.0_dp ) expval = exp ( exparg ) ! fac = C6_ij ( ityp ( atb ) , ityp ( ata ) ) / dist**8 add = 48.d0 / dist**2 ! eiqr = exp ((0_dp,1_dp)*(q(1)*(r(1,nr)+dtau(1))+& q(2)*(r(2,nr)+dtau(2))+& q(3)*(r(3,nr)+dtau(3)) ) * tpi ) ! facF = C6_ij ( ityp ( atb ) , ityp ( ata ) ) / dist**6 addF = 6.d0 / dist ! DO ipol = 1 , 3 DO jpol = 1 , 3 IF (ipol /= jpol) THEN auxr = ( scal6 / ( 1.d0 + expval ) * fac * & ( add - par*(13.d0*expval/((1.d0+expval)*dist))-& par2 *expval*(1.0_dp - expval)/ & ( (1.d0 + expval) * (1.d0 + expval) ) ) * & r ( ipol, nr ) * alat * r(jpol,nr) * alat ) ELSE auxr = ( scal6 / ( 1.d0 + expval ) * fac * & ( add - par*(13.d0*expval/((1.d0+expval)*dist))-& par2 *expval*(1.0_dp - expval)/ & ( (1.d0 + expval) * (1.d0 + expval) ) ) * & r ( ipol, nr ) * alat * r(jpol,nr) * alat )- & ( scal6 / ( 1.0_dp + expval ) * facF * & ( - par * expval / ( 1.d0 + expval ) + addF ) * & 1.d0/ dist ) ENDIF ! aux (ipol,jpol,atb) = aux (ipol,jpol,atb) + auxr aux2(ipol,jpol,atb) = aux2(ipol,jpol,atb) + auxr*eiqr ! ENDDO ! ENDDO ! ENDIF ! ENDDO #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1600) !$omp end parallel do #endif DO ipol =1,3 DO jpol = 1,3 deriv2_london (ipol, ata, jpol, atb) = aux2(ipol,jpol,atb) ENDDO ENDDO ENDDO ! DO atb = 1, nat DO ipol =1,3 DO jpol = 1,3 deriv2_london (ipol, ata, jpol, ata) = & deriv2_london (ipol, ata, jpol, ata) - aux(ipol,jpol,atb) ENDDO ENDDO ENDDO ! ENDDO CALL mp_sum ( deriv2_london , intra_image_comm ) ! RETURN ! END SUBROUTINE d2ionq_mm
gpl-2.0
prool/ccx_prool
CalculiX/ccx_2.17/src/cd_pk_albers.f
1
1342
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2020 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! author: Yannick Muller ! subroutine cd_pk_albers(rad,d,xl,reynolds,p2,p1,beta,kappa,cd,u, & T1,R) ! implicit none ! real*8 rad,d,xl,reynolds,p2,p1,beta,kappa, & cd,R,u,T1 ! rad=rad d=d xl=xl reynolds=reynolds p2=p2 p1=p1 beta=beta kappa=kappa R=R u=u T1=T1 cd=1.d0 write(*,*) '*WARNING while using subroutine cd_pk_albers.f' write(*,*) 'cd implicitely taken equal to 1' ! return end
gpl-2.0
freedesktop-unofficial-mirror/gstreamer-sdk__gcc
gcc/testsuite/gfortran.dg/whole_file_9.f90
169
1069
! { dg-do compile } ! { dg-options "-fwhole-file" } ! Test the fix for the fourth problem in PR40011, where the ! entries were not resolved, resulting in a segfault. ! ! Contributed by Dominique d'Humieres <[email protected]> ! program test interface function bad_stuff(n) integer :: bad_stuff (2) integer :: n(2) end function bad_stuff recursive function rec_stuff(n) result (tmp) integer :: n(2), tmp(2) end function rec_stuff end interface integer :: res(2) res = bad_stuff((/-19,-30/)) end program test recursive function bad_stuff(n) integer :: bad_stuff (2) integer :: n(2), tmp(2), ent = 0, sent = 0 save ent, sent ent = -1 entry rec_stuff(n) result (tmp) if (ent == -1) then sent = ent ent = 0 end if ent = ent + 1 tmp = 1 if(maxval (n) < 5) then tmp = tmp + rec_stuff (n+1) ent = ent - 1 endif if (ent == 1) then if (sent == -1) then bad_stuff = tmp + bad_stuff (1) end if ent = 0 sent = 0 end if end function bad_stuff
gpl-2.0
epfl-cosmo/q-e
CPV/src/ortho.f90
9
15766
! ! Copyright (C) 2002-2011 Quantum ESPRESSO group ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http://www.gnu.org/copyleft/gpl.txt . ! !=----------------------------------------------------------------------------=! SUBROUTINE ortho_gamma_x( iopt, cp, ngwx, phi, becp_dist, qbecp, nkbx, bephi, qbephi, & x0, nx0, descla, diff, iter, n, nss, istart ) !=----------------------------------------------------------------------------=! ! USE kinds, ONLY: DP USE orthogonalize_base, ONLY: rhoset, sigset, tauset, ortho_iterate, & ortho_alt_iterate, use_parallel_diag USE dspev_module, ONLY: diagonalize_serial, diagonalize_parallel USE descriptors, ONLY: la_descriptor USE mp_global, ONLY: nproc_bgrp, me_bgrp, intra_bgrp_comm, my_bgrp_id, inter_bgrp_comm, nbgrp USE mp, ONLY: mp_sum, mp_bcast IMPLICIT NONE ! ... Arguments INTEGER, INTENT(IN) :: iopt INTEGER, INTENT(IN) :: ngwx, nkbx, nx0 INTEGER, INTENT(IN) :: n, nss, istart COMPLEX(DP) :: phi( ngwx, n ), cp( ngwx, n ) REAL(DP) :: bephi( :, : ) REAL(DP) :: becp_dist( :, : ) REAL(DP) :: qbephi( :, : ), qbecp( :, : ) REAL(DP) :: x0( nx0, nx0 ) TYPE(la_descriptor), INTENT(IN) :: descla INTEGER, INTENT(OUT) :: iter REAL(DP), INTENT(OUT) :: diff ! ... Locals REAL(DP), ALLOCATABLE :: s(:,:), sig(:,:), tau(:,:), rhot(:,:) REAL(DP), ALLOCATABLE :: wrk(:,:), rhoa(:,:), rhos(:,:), rhod(:) INTEGER :: i, j, info, nr, nc, ir, ic ! ! ... Subroutine body ! IF( descla%active_node > 0 ) THEN ! IF( nx0 /= descla%nrcx ) & CALL errore( ' ortho_gamma ', ' inconsistent dimensions nx0 ' , nx0 ) ! nr = descla%nr nc = descla%nc ! ir = descla%ir ic = descla%ic ! ELSE ! nr = 1 nc = 1 ! IF( nx0 /= 1 ) & CALL errore( ' ortho_gamma ', ' inconsistent dimensions nx0, should be 1 ' , nx0 ) ! END IF ! ALLOCATE( rhos( nx0, nx0 ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating rhos ', ABS( info ) ) ALLOCATE( rhoa( nx0, nx0 ), STAT = info ) ! antisymmetric part of rho IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating rhoa ', ABS( info ) ) ALLOCATE( s( nx0, nx0 ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating s ', ABS( info ) ) ALLOCATE( sig( nx0, nx0 ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating sig ', ABS( info ) ) ALLOCATE( tau( nx0, nx0 ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating tau ', ABS( info ) ) ! ALLOCATE( rhod( nss ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating tau ', ABS( rhod ) ) ! ! rho = <s'c0|s|cp> ! CALL start_clock( 'rhoset' ) ! CALL rhoset( cp, ngwx, phi, bephi, nkbx, qbecp, n, nss, istart, rhos, nx0, descla ) ! IF( descla%active_node > 0 ) THEN ! ALLOCATE( rhot( nx0, nx0 ), STAT = info ) ! transpose of rho IF( info /= 0 ) & CALL errore( ' ortho_gamma ', ' allocating rhot ', ABS( rhod ) ) ! ! distributed array rhos contains "rho", ! now transpose rhos and store the result in distributed array rhot ! CALL sqr_tr_cannon( nss, rhos, nx0, rhot, nx0, descla ) ! ! Compute the symmetric part of rho ! DO j = 1, nc DO i = 1, nr rhos( i, j ) = 0.5d0 * ( rhos( i, j ) + rhot( i, j ) ) END DO END DO ! ! distributed array rhos now contains symmetric part of "rho", ! CALL consistency_check( rhos ) ! ! Antisymmetric part of rho, alredy distributed across ortho procs. ! DO j = 1, nc DO i = 1, nr rhoa( i, j ) = rhos( i, j ) - rhot( i, j ) END DO END DO ! DEALLOCATE( rhot ) ! END IF CALL stop_clock( 'rhoset' ) CALL start_clock( 'rsg' ) ! ! ... Diagonalize symmetric part of rho (rhos) ! ... "s" is the matrix of eigenvectors, "rhod" is the array of eigenvalues ! IF( use_parallel_diag ) THEN ! CALL diagonalize_parallel( nss, rhos, rhod, s, descla ) ! ELSE ! IF( descla%active_node > 0 ) THEN ! ALLOCATE( wrk( nss, nss ), STAT = info ) IF( info /= 0 ) CALL errore( ' ortho_gamma ', ' allocating wrk ', 1 ) ! CALL collect_matrix( wrk, rhos ) ! CALL diagonalize_serial( nss, wrk, rhod ) ! CALL distribute_matrix( wrk, s ) ! DEALLOCATE( wrk ) ! END IF ! END IF ! CALL stop_clock( 'rsg' ) ! ! sig = 1-<cp|s|cp> ! CALL start_clock( 'sigset' ) CALL sigset( cp, ngwx, becp_dist, nkbx, qbecp, n, nss, istart, sig, nx0, descla ) CALL stop_clock( 'sigset' ) ! ! tau = <s'c0|s|s'c0> ! CALL start_clock( 'tauset' ) CALL tauset( phi, ngwx, bephi, nkbx, qbephi, n, nss, istart, tau, nx0, descla ) CALL stop_clock( 'tauset' ) ! CALL start_clock( 'ortho_iter' ) ! IF( my_bgrp_id == 0 ) THEN ! ! Matrices and orthogonalization are replicated on all band groups, there is no ! need to keep all processors busy with this task. The processors of the first ! group are enough. Moreover replicating the computation across groups could leads ! to small numerical differences and weird numerical effects. ! IF( iopt == 0 ) THEN ! CALL ortho_iterate( iter, diff, s, nx0, rhod, x0, nx0, sig, rhoa, rhos, tau, nss, descla) ! ELSE ! CALL ortho_alt_iterate( iter, diff, s, nx0, rhod, x0, nx0, sig, rhoa, tau, nss, descla) ! END IF ! END IF ! IF( nbgrp > 1 ) THEN ! ! All groups must have the same lambda matrix, in order to avoid weird ! numerical side effects. ! CALL mp_bcast( x0, 0, inter_bgrp_comm ) CALL mp_bcast( iter, 0, inter_bgrp_comm ) CALL mp_bcast( diff, 0, inter_bgrp_comm ) ! END IF ! CALL stop_clock( 'ortho_iter' ) ! DEALLOCATE( rhoa, rhos, rhod, s, sig, tau ) ! IF( descla%active_node > 0 ) CALL consistency_check( x0 ) RETURN CONTAINS SUBROUTINE distribute_matrix( a, b ) REAL(DP) :: a(:,:), b(:,:) INTEGER :: i, j IF( descla%active_node > 0 ) THEN DO j = 1, nc DO i = 1, nr b( i, j ) = a( i + ir - 1, j + ic - 1 ) END DO END DO END IF RETURN END SUBROUTINE SUBROUTINE collect_matrix( a, b ) REAL(DP) :: a(:,:), b(:,:) INTEGER :: i, j a = 0.0d0 IF( descla%active_node > 0 ) THEN DO j = 1, nc DO i = 1, nr a( ir + i - 1, ic + j - 1 ) = b( i, j ) END DO END DO END IF CALL mp_sum( a, descla%comm ) RETURN END SUBROUTINE SUBROUTINE consistency_check( a ) REAL(DP) :: a(:,:) INTEGER :: i, j ! ! on some machines (IBM RS/6000 for instance) the following test allows ! to distinguish between Numbers and Sodium Nitride (NaN, Not a Number). ! If a matrix of Not-Numbers is passed to rs, the most likely outcome is ! that the program goes on forever doing nothing and writing nothing. ! DO j = 1, nc DO i = 1, nr IF (a(i,j) /= a(i,j)) CALL errore(' ortho ',' ortho went bananas ',1) END DO END DO RETURN END SUBROUTINE END SUBROUTINE ortho_gamma_x !=----------------------------------------------------------------------------=! SUBROUTINE ortho_x( eigr, cp_bgrp, phi_bgrp, x0, descla, diff, iter, ccc, bephi, becp_bgrp ) !=----------------------------------------------------------------------------=! ! ! input = cp (non-orthonormal), beta ! input = phi |phi>=s'|c0> ! output= cp (orthonormal with s( r(t+dt) ) ) ! output= bephi, becp ! the method used is similar to the version in les houches 1988 ! 'simple molecular systems at..' p. 462-463 (18-22) ! xcx + b x + b^t x^t + a = 1 ! where c = <s'c0|s|s'c0> b = <s'c0|s cp> a = <cp|s|cp> ! where s=s(r(t+dt)) and s'=s(r(t)) ! for vanderbilt pseudo pot - kl & ap ! USE kinds, ONLY: DP USE ions_base, ONLY: na, nat USE uspp, ONLY: nkb, qq USE uspp_param, ONLY: nh, ish, nvb USE electrons_base, ONLY: f, nbsp_bgrp, iupdwn_bgrp, nupdwn_bgrp, i2gupdwn_bgrp, nbsp, nspin, nupdwn, iupdwn USE gvecw, ONLY: ngw USE control_flags, ONLY: iprint, iverbosity, ortho_max USE control_flags, ONLY: force_pairing USE io_global, ONLY: stdout, ionode USE cp_interfaces, ONLY: ortho_gamma, c_bgrp_expand, c_bgrp_pack, nlsm1, collect_bec USE descriptors, ONLY: la_descriptor USE mp_global, ONLY: nproc_bgrp, me_bgrp, intra_bgrp_comm, inter_bgrp_comm ! DEBUG USE orthogonalize_base, ONLY: bec_bgrp2ortho USE mp, ONLY : mp_sum ! IMPLICIT NONE ! TYPE(la_descriptor), INTENT(IN) :: descla(:) COMPLEX(DP) :: eigr(:,:) COMPLEX(DP) :: cp_bgrp(:,:), phi_bgrp(:,:) REAL(DP) :: x0(:,:,:), diff, ccc INTEGER :: iter REAL(DP) :: bephi(:,:) REAL(DP) :: becp_bgrp(:,:) ! REAL(DP), ALLOCATABLE :: xloc(:,:), becp_dist(:,:) REAL(DP), ALLOCATABLE :: qbephi(:,:,:), qbecp(:,:,:), bec_col(:,:) INTEGER :: nkbx INTEGER :: info, i, j, iss, iv, jv, ia, is, inl, jnl INTEGER :: n1, n2, m1, m2 INTEGER :: nspin_sub, nx0, ngwx, nrcx REAL(DP) :: qqf, dum ! nkbx = nkb ngwx = SIZE( cp_bgrp, 1 ) ! nx0 = SIZE( x0, 1 ) ! ! calculation of becp and bephi ! CALL start_clock( 'ortho' ) nrcx = MAXVAL( descla( : )%nrcx ) ALLOCATE( becp_dist( nkbx, nrcx*nspin ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho ', ' allocating becp_dist ', ABS( info ) ) IF( nvb > 0 ) THEN ! becp_bgrp = 0.0d0 ! CALL nlsm1 ( nbsp_bgrp, 1, nvb, eigr, phi_bgrp, becp_bgrp ) CALL bec_bgrp2ortho( becp_bgrp, bephi, nrcx, descla ) ! becp_bgrp = 0.0d0 ! CALL nlsm1 ( nbsp_bgrp, 1, nvb, eigr, cp_bgrp, becp_bgrp ) CALL bec_bgrp2ortho( becp_bgrp, becp_dist, nrcx, descla ) ! END IF ! ! calculation of qbephi and qbecp ! ALLOCATE( qbephi( nkbx, nx0, nspin ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho ', ' allocating qbephi ', ABS( info ) ) ! IF( nvb > 0 ) THEN ALLOCATE( bec_col ( nkbx, nrcx*nspin ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho ', ' allocating bec_col ', ABS( info ) ) CALL redist_row2col( nupdwn(1), bephi, bec_col, nkbx, nrcx, descla(1) ) IF( nspin == 2 ) THEN CALL redist_row2col( nupdwn(2), bephi(1,nrcx+1), bec_col(1,nrcx+1), nkbx, nrcx, descla(2) ) END IF END IF ! qbephi = 0.d0 ! DO is=1,nvb DO iv=1,nh(is) inl = ish(is)+(iv-1)*na(is) DO jv=1,nh(is) jnl = ish(is)+(jv-1)*na(is) qqf = qq(iv,jv,is) IF( ABS( qqf ) > 1.D-5 ) THEN DO iss = 1, nspin IF( descla( iss )%active_node > 0 ) THEN DO i = 1, descla( iss )%nc CALL daxpy( na(is), qqf, bec_col(jnl+1,i+(iss-1)*nrcx),1,qbephi(inl+1,i,iss), 1 ) END DO END IF END DO ENDIF END DO END DO END DO ! ALLOCATE( qbecp ( nkbx, nx0, nspin ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho ', ' allocating qbecp ', ABS( info ) ) qbecp = 0.d0 IF( nvb > 0 ) THEN CALL redist_row2col( nupdwn(1), becp_dist, bec_col, nkbx, nrcx, descla(1) ) IF( nspin == 2 ) THEN CALL redist_row2col( nupdwn(2), becp_dist(1,nrcx+1), bec_col(1,nrcx+1), nkbx, nrcx, descla(2) ) END IF END IF DO is=1,nvb DO iv=1,nh(is) inl = ish(is)+(iv-1)*na(is) DO jv=1,nh(is) jnl = ish(is)+(jv-1)*na(is) qqf = qq(iv,jv,is) IF( ABS( qqf ) > 1.D-5 ) THEN DO iss = 1, nspin IF( descla( iss )%active_node > 0 ) THEN DO i = 1, descla( iss )%nc CALL daxpy( na(is), qqf, bec_col(jnl+1,i+(iss-1)*nrcx),1, qbecp(inl+1,i,iss), 1 ) END DO END IF END DO ENDIF END DO END DO END DO ! IF( nvb > 0 ) DEALLOCATE( bec_col ) ! ! Expand cp and phi to contain all electronic band ! CALL c_bgrp_expand( cp_bgrp ) CALL c_bgrp_expand( phi_bgrp ) ! ALLOCATE( xloc( nx0, nx0 ), STAT = info ) IF( info /= 0 ) & CALL errore( ' ortho ', ' allocating xloc ', ABS( info ) ) ! nspin_sub = nspin if( force_pairing ) nspin_sub = 1 ! DO iss = 1, nspin_sub IF( descla( iss )%active_node > 0 ) xloc = x0(:,:,iss) * ccc CALL ortho_gamma( 0, cp_bgrp, ngwx, phi_bgrp, becp_dist(:,(iss-1)*nrcx+1:iss*nrcx), qbecp(:,:,iss), nkbx, & bephi(:,((iss-1)*nrcx+1):iss*nrcx), & qbephi(:,:,iss), xloc, nx0, descla(iss), diff, iter, nbsp, nupdwn(iss), iupdwn(iss) ) IF( iter > ortho_max ) THEN WRITE( stdout, 100 ) diff, iter CALL errore('ortho','max number of iterations exceeded',iter) END IF IF( iverbosity > 1 ) THEN WRITE( stdout, 100 ) diff, iter ENDIF ! IF( descla( iss )%active_node > 0 ) x0( :, :, iss ) = xloc / ccc ! END DO IF( force_pairing ) cp_bgrp(:, iupdwn(2):iupdwn(2)+nupdwn(2)-1 ) = cp_bgrp(:,1:nupdwn(2)) ! DEALLOCATE( xloc ) DEALLOCATE( qbecp ) DEALLOCATE( qbephi ) DEALLOCATE( becp_dist ) ! ! pack cp so that it contains only the bands in the band subgroup ! CALL c_bgrp_pack( cp_bgrp ) ! CALL stop_clock( 'ortho' ) ! RETURN ! 100 FORMAT(3X,'diff = ',D18.10,' iter = ', I5 ) ! END SUBROUTINE ortho_x
gpl-2.0
techno/gcc-mist32
libgomp/testsuite/libgomp.fortran/allocatable11.f90
102
2814
! { dg-do run } ! { dg-require-effective-target tls_runtime } use omp_lib integer, allocatable, save :: a, b(:), c(:,:) integer :: p !$omp threadprivate (a, b, c) if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort call omp_set_dynamic (.false.) call omp_set_num_threads (4) !$omp parallel num_threads (4) if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort !$omp end parallel allocate (a, b(6:9), c(3, 8:9)) a = 4 b = 5 c = 6 if (.not.allocated (a)) call abort if (.not.allocated (b) .or. size (b) /= 4) call abort if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort if (.not.allocated (c) .or. size (c) /= 6) call abort if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort !$omp parallel num_threads (4) copyin (a, b, c) private (p) p = omp_get_thread_num () if (.not.allocated (a)) call abort if (.not.allocated (b) .or. size (b) /= 4) call abort if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort if (.not.allocated (c) .or. size (c) /= 6) call abort if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort if (a /= 4 .or. any (b /= 5) .or. any (c /= 6)) call abort deallocate (a, b, c) if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort allocate (a, b(p:9), c(3, p:7)) a = p b = p c = p if (.not.allocated (a)) call abort if (.not.allocated (b) .or. size (b) /= (10 - p)) call abort if (lbound (b, 1) /= p .or. ubound (b, 1) /= 9) call abort if (.not.allocated (c) .or. size (c) /= (3 * (8 - p))) call abort if (size (c, 1) /= 3 .or. size (c, 2) /= (8 - p)) call abort if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort if (lbound (c, 2) /= p .or. ubound (c, 2) /= 7) call abort if (a /= p .or. any (b /= p) .or. any (c /= p)) call abort !$omp end parallel !$omp parallel num_threads (4) copyin (a, b, c) if (.not.allocated (a)) call abort if (.not.allocated (b) .or. size (b) /= 10) call abort if (lbound (b, 1) /= 0 .or. ubound (b, 1) /= 9) call abort if (.not.allocated (c) .or. size (c) /= 24) call abort if (size (c, 1) /= 3 .or. size (c, 2) /= 8) call abort if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort if (lbound (c, 2) /= 0 .or. ubound (c, 2) /= 7) call abort if (a /= 0 .or. any (b /= 0) .or. any (c /= 0)) call abort !$omp end parallel deallocate (a, b, c) if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort !$omp parallel num_threads (4) copyin (a, b, c) if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort !$omp end parallel end
gpl-2.0
sonnyhu/scipy
scipy/sparse/linalg/eigen/arpack/ARPACK/UTIL/iswap.f
168
1227
subroutine iswap (n,sx,incx,sy,incy) c c interchanges two vectors. c uses unrolled loops for increments equal to 1. c jack dongarra, linpack, 3/11/78. c integer sx(1),sy(1),stemp integer i,incx,incy,ix,iy,m,mp1,n c if(n.le.0)return if(incx.eq.1.and.incy.eq.1)go to 20 c c code for unequal increments or equal increments not equal c to 1 c ix = 1 iy = 1 if(incx.lt.0)ix = (-n+1)*incx + 1 if(incy.lt.0)iy = (-n+1)*incy + 1 do 10 i = 1,n stemp = sx(ix) sx(ix) = sy(iy) sy(iy) = stemp ix = ix + incx iy = iy + incy 10 continue return c c code for both increments equal to 1 c c c clean-up loop c 20 m = mod(n,3) if( m .eq. 0 ) go to 40 do 30 i = 1,m stemp = sx(i) sx(i) = sy(i) sy(i) = stemp 30 continue if( n .lt. 3 ) return 40 mp1 = m + 1 do 50 i = mp1,n,3 stemp = sx(i) sx(i) = sy(i) sy(i) = stemp stemp = sx(i + 1) sx(i + 1) = sy(i + 1) sy(i + 1) = stemp stemp = sx(i + 2) sx(i + 2) = sy(i + 2) sy(i + 2) = stemp 50 continue return end
bsd-3-clause
foss-for-synopsys-dwc-arc-processors/gcc
libgfortran/intrinsics/selected_int_kind.f90
4
1592
! Copyright (C) 2003-2021 Free Software Foundation, Inc. ! Contributed by Kejia Zhao <[email protected]> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !Libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. ! !Libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. function _gfortran_selected_int_kind (r) implicit none integer, intent (in) :: r integer :: _gfortran_selected_int_kind integer :: i ! Integer kind_range table type :: int_info integer :: kind integer :: range end type int_info include "selected_int_kind.inc" do i = 1, c if (r <= int_infos (i) % range) then _gfortran_selected_int_kind = int_infos (i) % kind return end if end do _gfortran_selected_int_kind = -1 return end function
gpl-2.0
zwizwa/staapl
pic18/p18f1220.f
1
1187
\ chip constants load p18f1220-const.f staapl pic18/pic18-serial macro : serial-div 16 ; \ High baud rate with 8 bit counter. \ chip config macros for core code \ FIXME: should i set chip pins to output? according to johannes \ inputs shouldn't hurt. : init-chip -1 LATB ! \ prevent TX pin glitch \ 2-output \ 2 ports, all output #x70 OSCCON ! ; \ internal oscillator at 8MHz \ Detect the presence of a serial cable by detecting an IDLE state \ (high) on RX (RB4). Tie the pin low using 100k to default to BREAK \ with no cable connected, or jumper it. \ On a Power-on Reset, RB4:RB0 are configured as analog inputs by \ default and read as 0; RB7:RB5 are configured as digital \ inputs. This means we need to set ADCON1 to check the debug state. \ This macro is then only valid AFTER initializing the serial port, \ which sets the inputs to digital. : debug-serial? PORTB 4 high? ; : init-serial | baud fosc | ADCON1 5 high ADCON1 6 high \ pins TRISB 4 high TRISB 1 high \ init-serial-baud-8 \ baud rate baud fosc async.init-brg-8 ; : boot-size #x200 ; \ size of code-protect region forth
gpl-2.0
sonnyhu/scipy
scipy/integrate/quadpack/dqawce.f
143
12260
subroutine dqawce(f,a,b,c,epsabs,epsrel,limit,result,abserr,neval, * ier,alist,blist,rlist,elist,iord,last) c***begin prologue dqawce c***date written 800101 (yymmdd) c***revision date 830518 (yymmdd) c***category no. h2a2a1,j4 c***keywords automatic integrator, special-purpose, c cauchy principal value, clenshaw-curtis method c***author piessens,robert,appl. math. & progr. div. - k.u.leuven c de doncker,elise,appl. math. & progr. div. - k.u.leuven c*** purpose the routine calculates an approximation result to a c cauchy principal value i = integral of f*w over (a,b) c (w(x) = 1/(x-c), (c.ne.a, c.ne.b), hopefully satisfying c following claim for accuracy c abs(i-result).le.max(epsabs,epsrel*abs(i)) c***description c c computation of a cauchy principal value c standard fortran subroutine c double precision version c c parameters c on entry c f - double precision c function subprogram defining the integrand c function f(x). the actual name for f needs to be c declared e x t e r n a l in the driver program. c c a - double precision c lower limit of integration c c b - double precision c upper limit of integration c c c - double precision c parameter in the weight function, c.ne.a, c.ne.b c if c = a or c = b, the routine will end with c ier = 6. c c epsabs - double precision c absolute accuracy requested c epsrel - double precision c relative accuracy requested c if epsabs.le.0 c and epsrel.lt.max(50*rel.mach.acc.,0.5d-28), c the routine will end with ier = 6. c c limit - integer c gives an upper bound on the number of subintervals c in the partition of (a,b), limit.ge.1 c c on return c result - double precision c approximation to the integral c c abserr - double precision c estimate of the modulus of the absolute error, c which should equal or exceed abs(i-result) c c neval - integer c number of integrand evaluations c c ier - integer c ier = 0 normal and reliable termination of the c routine. it is assumed that the requested c accuracy has been achieved. c ier.gt.0 abnormal termination of the routine c the estimates for integral and error are c less reliable. it is assumed that the c requested accuracy has not been achieved. c error messages c ier = 1 maximum number of subdivisions allowed c has been achieved. one can allow more sub- c divisions by increasing the value of c limit. however, if this yields no c improvement it is advised to analyze the c the integrand, in order to determine the c the integration difficulties. if the c position of a local difficulty can be c determined (e.g. singularity, c discontinuity within the interval) one c will probably gain from splitting up the c interval at this point and calling c appropriate integrators on the subranges. c = 2 the occurrence of roundoff error is detec- c ted, which prevents the requested c tolerance from being achieved. c = 3 extremely bad integrand behaviour c occurs at some interior points of c the integration interval. c = 6 the input is invalid, because c c = a or c = b or c (epsabs.le.0 and c epsrel.lt.max(50*rel.mach.acc.,0.5d-28)) c or limit.lt.1. c result, abserr, neval, rlist(1), elist(1), c iord(1) and last are set to zero. alist(1) c and blist(1) are set to a and b c respectively. c c alist - double precision c vector of dimension at least limit, the first c last elements of which are the left c end points of the subintervals in the partition c of the given integration range (a,b) c c blist - double precision c vector of dimension at least limit, the first c last elements of which are the right c end points of the subintervals in the partition c of the given integration range (a,b) c c rlist - double precision c vector of dimension at least limit, the first c last elements of which are the integral c approximations on the subintervals c c elist - double precision c vector of dimension limit, the first last c elements of which are the moduli of the absolute c error estimates on the subintervals c c iord - integer c vector of dimension at least limit, the first k c elements of which are pointers to the error c estimates over the subintervals, so that c elist(iord(1)), ..., elist(iord(k)) with k = last c if last.le.(limit/2+2), and k = limit+1-last c otherwise, form a decreasing sequence c c last - integer c number of subintervals actually produced in c the subdivision process c c***references (none) c***routines called d1mach,dqc25c,dqpsrt c***end prologue dqawce c double precision a,aa,abserr,alist,area,area1,area12,area2,a1,a2, * b,bb,blist,b1,b2,c,dabs,dmax1,d1mach,elist,epmach,epsabs,epsrel, * errbnd,errmax,error1,erro12,error2,errsum,f,result,rlist,uflow integer ier,iord,iroff1,iroff2,k,krule,last,limit,maxerr,nev, * neval,nrmax c dimension alist(limit),blist(limit),rlist(limit),elist(limit), * iord(limit) c external f c c list of major variables c ----------------------- c c alist - list of left end points of all subintervals c considered up to now c blist - list of right end points of all subintervals c considered up to now c rlist(i) - approximation to the integral over c (alist(i),blist(i)) c elist(i) - error estimate applying to rlist(i) c maxerr - pointer to the interval with largest c error estimate c errmax - elist(maxerr) c area - sum of the integrals over the subintervals c errsum - sum of the errors over the subintervals c errbnd - requested accuracy max(epsabs,epsrel* c abs(result)) c *****1 - variable for the left subinterval c *****2 - variable for the right subinterval c last - index for subdivision c c c machine dependent constants c --------------------------- c c epmach is the largest relative spacing. c uflow is the smallest positive magnitude. c c***first executable statement dqawce epmach = d1mach(4) uflow = d1mach(1) c c c test on validity of parameters c ------------------------------ c ier = 6 neval = 0 last = 0 alist(1) = a blist(1) = b rlist(1) = 0.0d+00 elist(1) = 0.0d+00 iord(1) = 0 result = 0.0d+00 abserr = 0.0d+00 if(c.eq.a.or.c.eq.b.or.(epsabs.le.0.0d+00.and * .epsrel.lt.dmax1(0.5d+02*epmach,0.5d-28))) go to 999 c c first approximation to the integral c ----------------------------------- c aa=a bb=b if (a.le.b) go to 10 aa=b bb=a 10 ier=0 krule = 1 call dqc25c(f,aa,bb,c,result,abserr,krule,neval) last = 1 rlist(1) = result elist(1) = abserr iord(1) = 1 alist(1) = a blist(1) = b c c test on accuracy c errbnd = dmax1(epsabs,epsrel*dabs(result)) if(limit.eq.1) ier = 1 if(abserr.lt.dmin1(0.1d-01*dabs(result),errbnd) * .or.ier.eq.1) go to 70 c c initialization c -------------- c alist(1) = aa blist(1) = bb rlist(1) = result errmax = abserr maxerr = 1 area = result errsum = abserr nrmax = 1 iroff1 = 0 iroff2 = 0 c c main do-loop c ------------ c do 40 last = 2,limit c c bisect the subinterval with nrmax-th largest c error estimate. c a1 = alist(maxerr) b1 = 0.5d+00*(alist(maxerr)+blist(maxerr)) b2 = blist(maxerr) if(c.le.b1.and.c.gt.a1) b1 = 0.5d+00*(c+b2) if(c.gt.b1.and.c.lt.b2) b1 = 0.5d+00*(a1+c) a2 = b1 krule = 2 call dqc25c(f,a1,b1,c,area1,error1,krule,nev) neval = neval+nev call dqc25c(f,a2,b2,c,area2,error2,krule,nev) neval = neval+nev c c improve previous approximations to integral c and error and test for accuracy. c area12 = area1+area2 erro12 = error1+error2 errsum = errsum+erro12-errmax area = area+area12-rlist(maxerr) if(dabs(rlist(maxerr)-area12).lt.0.1d-04*dabs(area12) * .and.erro12.ge.0.99d+00*errmax.and.krule.eq.0) * iroff1 = iroff1+1 if(last.gt.10.and.erro12.gt.errmax.and.krule.eq.0) * iroff2 = iroff2+1 rlist(maxerr) = area1 rlist(last) = area2 errbnd = dmax1(epsabs,epsrel*dabs(area)) if(errsum.le.errbnd) go to 15 c c test for roundoff error and eventually set error flag. c if(iroff1.ge.6.and.iroff2.gt.20) ier = 2 c c set error flag in the case that number of interval c bisections exceeds limit. c if(last.eq.limit) ier = 1 c c set error flag in the case of bad integrand behaviour c at a point of the integration range. c if(dmax1(dabs(a1),dabs(b2)).le.(0.1d+01+0.1d+03*epmach) * *(dabs(a2)+0.1d+04*uflow)) ier = 3 c c append the newly-created intervals to the list. c 15 if(error2.gt.error1) go to 20 alist(last) = a2 blist(maxerr) = b1 blist(last) = b2 elist(maxerr) = error1 elist(last) = error2 go to 30 20 alist(maxerr) = a2 alist(last) = a1 blist(last) = b1 rlist(maxerr) = area2 rlist(last) = area1 elist(maxerr) = error2 elist(last) = error1 c c call subroutine dqpsrt to maintain the descending ordering c in the list of error estimates and select the subinterval c with nrmax-th largest error estimate (to be bisected next). c 30 call dqpsrt(limit,last,maxerr,errmax,elist,iord,nrmax) c ***jump out of do-loop if(ier.ne.0.or.errsum.le.errbnd) go to 50 40 continue c c compute final result. c --------------------- c 50 result = 0.0d+00 do 60 k=1,last result = result+rlist(k) 60 continue abserr = errsum 70 if (aa.eq.b) result=-result 999 return end
bsd-3-clause
wavebitscientific/wavy
src/lib/mod_linear_wave_theory.f90
2
5980
! ! wavy - A spectral ocean wave modeling and development framework ! Copyright (c) 2017, Wavebit Scientific LLC ! All rights reserved. ! ! Licensed under the BSD-3 clause license. See LICENSE for details. ! !=============================================================================== module mod_linear_wave_theory use mod_precision,only:intkind,realkind implicit none private public :: elevation public :: pressure public :: horizontalAcceleration public :: horizontalVelocity public :: verticalAcceleration public :: verticalVelocity !=============================================================================== contains !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function elevation(x,t,a,k,omega) !! Returns the elevation [m] of a sinusoid wave given its amplitude [m], !! wavenumber [rad/m], and frequency [Hz]. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] elevation = a*sin(k*x-omega*t) endfunction elevation !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function pressure(x,z,t,a,k,omega,rho,grav) !! Returns the pressure [Pa] at depth z (negative downward) for a sinusoid !! wave given its amplitude [m], wavenumber [rad/m], and frequency [Hz]. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical displacement [m] from the surface, negative downward real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] real(kind=realkind),intent(in) :: rho !! Water density [kg/m^3] real(kind=realkind),intent(in) :: grav !! Gravitational acceleration [m/s^2] pressure = -rho*grav*(elevation(x,t,a,k,omega)-z) endfunction pressure !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function horizontalAcceleration(x,z,t,a,k,omega) !! Returns the horizontal acceleration of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] horizontalAcceleration = -a*omega**2*cos(k*x-omega*t)*exp(k*z) endfunction horizontalAcceleration !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function horizontalVelocity(x,z,t,a,k,omega) !! Returns the horizontal velocity of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] horizontalVelocity = a*omega*sin(k*x-omega*t)*exp(k*z) endfunction horizontalVelocity !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind)& function verticalAcceleration(x,z,t,a,k,omega) !! Returns the vertical acceleration of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] verticalAcceleration = -a*omega**2*sin(k*x-omega*t)*exp(k*z) endfunction verticalAcceleration !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function verticalVelocity(x,z,t,a,k,omega) !! Returns the vertical velocity of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] verticalVelocity = -a*omega*cos(k*x-omega*t)*exp(k*z) endfunction verticalVelocity !------------------------------------------------------------------------------- endmodule mod_linear_wave_theory
bsd-3-clause
wavebitscientific/wavy
docs/src/mod_linear_wave_theory.f90
2
5980
! ! wavy - A spectral ocean wave modeling and development framework ! Copyright (c) 2017, Wavebit Scientific LLC ! All rights reserved. ! ! Licensed under the BSD-3 clause license. See LICENSE for details. ! !=============================================================================== module mod_linear_wave_theory use mod_precision,only:intkind,realkind implicit none private public :: elevation public :: pressure public :: horizontalAcceleration public :: horizontalVelocity public :: verticalAcceleration public :: verticalVelocity !=============================================================================== contains !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function elevation(x,t,a,k,omega) !! Returns the elevation [m] of a sinusoid wave given its amplitude [m], !! wavenumber [rad/m], and frequency [Hz]. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] elevation = a*sin(k*x-omega*t) endfunction elevation !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function pressure(x,z,t,a,k,omega,rho,grav) !! Returns the pressure [Pa] at depth z (negative downward) for a sinusoid !! wave given its amplitude [m], wavenumber [rad/m], and frequency [Hz]. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical displacement [m] from the surface, negative downward real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] real(kind=realkind),intent(in) :: rho !! Water density [kg/m^3] real(kind=realkind),intent(in) :: grav !! Gravitational acceleration [m/s^2] pressure = -rho*grav*(elevation(x,t,a,k,omega)-z) endfunction pressure !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function horizontalAcceleration(x,z,t,a,k,omega) !! Returns the horizontal acceleration of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] horizontalAcceleration = -a*omega**2*cos(k*x-omega*t)*exp(k*z) endfunction horizontalAcceleration !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function horizontalVelocity(x,z,t,a,k,omega) !! Returns the horizontal velocity of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] horizontalVelocity = a*omega*sin(k*x-omega*t)*exp(k*z) endfunction horizontalVelocity !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind)& function verticalAcceleration(x,z,t,a,k,omega) !! Returns the vertical acceleration of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] verticalAcceleration = -a*omega**2*sin(k*x-omega*t)*exp(k*z) endfunction verticalAcceleration !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- pure elemental real(kind=realkind) function verticalVelocity(x,z,t,a,k,omega) !! Returns the vertical velocity of a water particle under a sinusoid wave, !! given its amplitude, wavenumber, and frequency. real(kind=realkind),intent(in) :: x !! Horizontal space [m] real(kind=realkind),intent(in) :: z !! Vertical space, negative downward [m] real(kind=realkind),intent(in) :: t !! Time [s] real(kind=realkind),intent(in) :: a !! Wave amplitude [m] real(kind=realkind),intent(in) :: k !! Wavenumber [rad/m] real(kind=realkind),intent(in) :: omega !! Angular frequency [rad] verticalVelocity = -a*omega*cos(k*x-omega*t)*exp(k*z) endfunction verticalVelocity !------------------------------------------------------------------------------- endmodule mod_linear_wave_theory
bsd-3-clause
Pakketeretet2/lammps
lib/linalg/dlaev2.f
21
6202
*> \brief \b DLAEV2 computes the eigenvalues and eigenvectors of a 2-by-2 symmetric/Hermitian matrix. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLAEV2 + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaev2.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaev2.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaev2.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLAEV2( A, B, C, RT1, RT2, CS1, SN1 ) * * .. Scalar Arguments .. * DOUBLE PRECISION A, B, C, CS1, RT1, RT2, SN1 * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLAEV2 computes the eigendecomposition of a 2-by-2 symmetric matrix *> [ A B ] *> [ B C ]. *> On return, RT1 is the eigenvalue of larger absolute value, RT2 is the *> eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right *> eigenvector for RT1, giving the decomposition *> *> [ CS1 SN1 ] [ A B ] [ CS1 -SN1 ] = [ RT1 0 ] *> [-SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ]. *> \endverbatim * * Arguments: * ========== * *> \param[in] A *> \verbatim *> A is DOUBLE PRECISION *> The (1,1) element of the 2-by-2 matrix. *> \endverbatim *> *> \param[in] B *> \verbatim *> B is DOUBLE PRECISION *> The (1,2) element and the conjugate of the (2,1) element of *> the 2-by-2 matrix. *> \endverbatim *> *> \param[in] C *> \verbatim *> C is DOUBLE PRECISION *> The (2,2) element of the 2-by-2 matrix. *> \endverbatim *> *> \param[out] RT1 *> \verbatim *> RT1 is DOUBLE PRECISION *> The eigenvalue of larger absolute value. *> \endverbatim *> *> \param[out] RT2 *> \verbatim *> RT2 is DOUBLE PRECISION *> The eigenvalue of smaller absolute value. *> \endverbatim *> *> \param[out] CS1 *> \verbatim *> CS1 is DOUBLE PRECISION *> \endverbatim *> *> \param[out] SN1 *> \verbatim *> SN1 is DOUBLE PRECISION *> The vector (CS1, SN1) is a unit right eigenvector for RT1. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date December 2016 * *> \ingroup OTHERauxiliary * *> \par Further Details: * ===================== *> *> \verbatim *> *> RT1 is accurate to a few ulps barring over/underflow. *> *> RT2 may be inaccurate if there is massive cancellation in the *> determinant A*C-B*B; higher precision or correctly rounded or *> correctly truncated arithmetic would be needed to compute RT2 *> accurately in all cases. *> *> CS1 and SN1 are accurate to a few ulps barring over/underflow. *> *> Overflow is possible only if RT1 is within a factor of 5 of overflow. *> Underflow is harmless if the input data is 0 or exceeds *> underflow_threshold / macheps. *> \endverbatim *> * ===================================================================== SUBROUTINE DLAEV2( A, B, C, RT1, RT2, CS1, SN1 ) * * -- LAPACK auxiliary routine (version 3.7.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * December 2016 * * .. Scalar Arguments .. DOUBLE PRECISION A, B, C, CS1, RT1, RT2, SN1 * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE PARAMETER ( ONE = 1.0D0 ) DOUBLE PRECISION TWO PARAMETER ( TWO = 2.0D0 ) DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D0 ) DOUBLE PRECISION HALF PARAMETER ( HALF = 0.5D0 ) * .. * .. Local Scalars .. INTEGER SGN1, SGN2 DOUBLE PRECISION AB, ACMN, ACMX, ACS, ADF, CS, CT, DF, RT, SM, $ TB, TN * .. * .. Intrinsic Functions .. INTRINSIC ABS, SQRT * .. * .. Executable Statements .. * * Compute the eigenvalues * SM = A + C DF = A - C ADF = ABS( DF ) TB = B + B AB = ABS( TB ) IF( ABS( A ).GT.ABS( C ) ) THEN ACMX = A ACMN = C ELSE ACMX = C ACMN = A END IF IF( ADF.GT.AB ) THEN RT = ADF*SQRT( ONE+( AB / ADF )**2 ) ELSE IF( ADF.LT.AB ) THEN RT = AB*SQRT( ONE+( ADF / AB )**2 ) ELSE * * Includes case AB=ADF=0 * RT = AB*SQRT( TWO ) END IF IF( SM.LT.ZERO ) THEN RT1 = HALF*( SM-RT ) SGN1 = -1 * * Order of execution important. * To get fully accurate smaller eigenvalue, * next line needs to be executed in higher precision. * RT2 = ( ACMX / RT1 )*ACMN - ( B / RT1 )*B ELSE IF( SM.GT.ZERO ) THEN RT1 = HALF*( SM+RT ) SGN1 = 1 * * Order of execution important. * To get fully accurate smaller eigenvalue, * next line needs to be executed in higher precision. * RT2 = ( ACMX / RT1 )*ACMN - ( B / RT1 )*B ELSE * * Includes case RT1 = RT2 = 0 * RT1 = HALF*RT RT2 = -HALF*RT SGN1 = 1 END IF * * Compute the eigenvector * IF( DF.GE.ZERO ) THEN CS = DF + RT SGN2 = 1 ELSE CS = DF - RT SGN2 = -1 END IF ACS = ABS( CS ) IF( ACS.GT.AB ) THEN CT = -TB / CS SN1 = ONE / SQRT( ONE+CT*CT ) CS1 = CT*SN1 ELSE IF( AB.EQ.ZERO ) THEN CS1 = ONE SN1 = ZERO ELSE TN = -CS / TB CS1 = ONE / SQRT( ONE+TN*TN ) SN1 = TN*CS1 END IF END IF IF( SGN1.EQ.SGN2 ) THEN TN = CS1 CS1 = -SN1 SN1 = TN END IF RETURN * * End of DLAEV2 * END
gpl-2.0
buaabyl/lm8-gcc
gcc-4.4.3/gcc/testsuite/gfortran.dg/argument_checking_11.f90
181
10346
! { dg-do compile } ! { dg-options "-std=f95 -fmax-errors=100" } ! ! PR fortran/34665 ! ! Test argument checking ! ! TODO: Check also expressions, e.g. "(a(1))" instead of "a(1) ! for strings; check also "string" and [ "string" ] ! implicit none CONTAINS SUBROUTINE test1(a,b,c,d,e) integer, dimension(:) :: a integer, pointer, dimension(:) :: b integer, dimension(*) :: c integer, dimension(5) :: d integer :: e call as_size(a) call as_size(b) call as_size(c) call as_size(d) call as_size(e) ! { dg-error "Rank mismatch" } call as_size(1) ! { dg-error "Rank mismatch" } call as_size( (/ 1 /) ) call as_size( (a) ) call as_size( (b) ) call as_size( (c) ) ! { dg-error "The upper bound in the last dimension must appear in the reference to the assumed size array" } call as_size( (d) ) call as_size( (e) ) ! { dg-error "Rank mismatch" } call as_size(a(1)) ! { dg-error "Element of assumed-shaped" } call as_size(b(1)) ! { dg-error "Element of assumed-shaped" } call as_size(c(1)) call as_size(d(1)) call as_size( (a(1)) ) ! { dg-error "Rank mismatch" } call as_size( (b(1)) ) ! { dg-error "Rank mismatch" } call as_size( (c(1)) ) ! { dg-error "Rank mismatch" } call as_size( (d(1)) ) ! { dg-error "Rank mismatch" } call as_size(a(1:2)) call as_size(b(1:2)) call as_size(c(1:2)) call as_size(d(1:2)) call as_size( (a(1:2)) ) call as_size( (b(1:2)) ) call as_size( (c(1:2)) ) call as_size( (d(1:2)) ) call as_shape(a) call as_shape(b) call as_shape(c) ! { dg-error "cannot be an assumed-size array" } call as_shape(d) call as_shape(e) ! { dg-error "Rank mismatch" } call as_shape( 1 ) ! { dg-error "Rank mismatch" } call as_shape( (/ 1 /) ) call as_shape( (a) ) call as_shape( (b) ) call as_shape( (c) ) ! { dg-error "The upper bound in the last dimension must appear in the reference to the assumed size array" } call as_shape( (d) ) call as_shape( (e) ) ! { dg-error "Rank mismatch" } call as_shape( (1) ) ! { dg-error "Rank mismatch" } call as_shape( ((/ 1 /)) ) call as_shape(a(1)) ! { dg-error "Rank mismatch" } call as_shape(b(1)) ! { dg-error "Rank mismatch" } call as_shape(c(1)) ! { dg-error "Rank mismatch" } call as_shape(d(1)) ! { dg-error "Rank mismatch" } call as_shape( (a(1)) ) ! { dg-error "Rank mismatch" } call as_shape( (b(1)) ) ! { dg-error "Rank mismatch" } call as_shape( (c(1)) ) ! { dg-error "Rank mismatch" } call as_shape( (d(1)) ) ! { dg-error "Rank mismatch" } call as_shape(a(1:2)) call as_shape(b(1:2)) call as_shape(c(1:2)) call as_shape(d(1:2)) call as_shape( (a(1:2)) ) call as_shape( (b(1:2)) ) call as_shape( (c(1:2)) ) call as_shape( (d(1:2)) ) call as_expl(a) call as_expl(b) call as_expl(c) call as_expl(d) call as_expl(e) ! { dg-error "Rank mismatch" } call as_expl( 1 ) ! { dg-error "Rank mismatch" } call as_expl( (/ 1, 2, 3 /) ) call as_expl( (a) ) call as_expl( (b) ) call as_expl( (c) ) ! { dg-error "The upper bound in the last dimension must appear in the reference to the assumed size array" } call as_expl( (d) ) call as_expl( (e) ) ! { dg-error "Rank mismatch" } call as_expl(a(1)) ! { dg-error "Element of assumed-shaped" } call as_expl(b(1)) ! { dg-error "Element of assumed-shaped" } call as_expl(c(1)) call as_expl(d(1)) call as_expl( (a(1)) ) ! { dg-error "Rank mismatch" } call as_expl( (b(1)) ) ! { dg-error "Rank mismatch" } call as_expl( (c(1)) ) ! { dg-error "Rank mismatch" } call as_expl( (d(1)) ) ! { dg-error "Rank mismatch" } call as_expl(a(1:3)) call as_expl(b(1:3)) call as_expl(c(1:3)) call as_expl(d(1:3)) call as_expl( (a(1:3)) ) call as_expl( (b(1:3)) ) call as_expl( (c(1:3)) ) call as_expl( (d(1:3)) ) END SUBROUTINE test1 SUBROUTINE as_size(a) integer, dimension(*) :: a END SUBROUTINE as_size SUBROUTINE as_shape(a) integer, dimension(:) :: a END SUBROUTINE as_shape SUBROUTINE as_expl(a) integer, dimension(3) :: a END SUBROUTINE as_expl SUBROUTINE test2(a,b,c,d,e) character(len=*), dimension(:) :: a character(len=*), pointer, dimension(:) :: b character(len=*), dimension(*) :: c character(len=*), dimension(5) :: d character(len=*) :: e call cas_size(a) call cas_size(b) call cas_size(c) call cas_size(d) call cas_size(e) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size("abc") ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size( (/"abc"/) ) call cas_size(a//"a") call cas_size(b//"a") call cas_size(c//"a") ! { dg-error "The upper bound in the last dimension must appear in the reference to the assumed size array" } call cas_size(d//"a") call cas_size(e//"a") ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size(("abc")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size( ((/"abc"/)) ) call cas_size(a(1)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size(b(1)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size(c(1)) ! OK in F95 call cas_size(d(1)) ! OK in F95 call cas_size((a(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size((b(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size((c(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size((d(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size(a(1:2)) call cas_size(b(1:2)) call cas_size(c(1:2)) call cas_size(d(1:2)) call cas_size((a(1:2)//"a")) call cas_size((b(1:2)//"a")) call cas_size((c(1:2)//"a")) call cas_size((d(1:2)//"a")) call cas_size(a(:)(1:3)) call cas_size(b(:)(1:3)) call cas_size(d(:)(1:3)) call cas_size((a(:)(1:3)//"a")) call cas_size((b(:)(1:3)//"a")) call cas_size((d(:)(1:3)//"a")) call cas_size(a(1:2)(1:3)) call cas_size(b(1:2)(1:3)) call cas_size(c(1:2)(1:3)) call cas_size(d(1:2)(1:3)) call cas_size((a(1:2)(1:3)//"a")) call cas_size((b(1:2)(1:3)//"a")) call cas_size((c(1:2)(1:3)//"a")) call cas_size((d(1:2)(1:3)//"a")) call cas_size(e(1:3)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size("abcd"(1:3)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size((e(1:3))) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size(("abcd"(1:3)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_shape(a) call cas_shape(b) call cas_shape(c) ! { dg-error "cannot be an assumed-size array" } call cas_shape(d) call cas_shape(e) ! { dg-error "Rank mismatch" } call cas_shape("abc") ! { dg-error "Rank mismatch" } call cas_shape( (/"abc"/) ) call cas_shape(a//"c") call cas_shape(b//"c") call cas_shape(c//"c") ! { dg-error "The upper bound in the last dimension must appear in the reference to the assumed size array" } call cas_shape(d//"c") call cas_shape(e//"c") ! { dg-error "Rank mismatch" } call cas_shape(("abc")) ! { dg-error "Rank mismatch" } call cas_shape( ((/"abc"/)) ) call cas_shape(a(1)) ! { dg-error "Rank mismatch" } call cas_shape(b(1)) ! { dg-error "Rank mismatch" } call cas_shape(c(1)) ! { dg-error "Rank mismatch" } call cas_shape(d(1)) ! { dg-error "Rank mismatch" } call cas_shape(a(1:2)) call cas_shape(b(1:2)) call cas_shape(c(1:2)) call cas_shape(d(1:2)) call cas_shape((a(1:2)//"a")) call cas_shape((b(1:2)//"a")) call cas_shape((c(1:2)//"a")) call cas_shape((d(1:2)//"a")) call cas_shape(a(:)(1:3)) call cas_shape(b(:)(1:3)) call cas_shape(d(:)(1:3)) call cas_shape((a(:)(1:3)//"a")) call cas_shape((b(:)(1:3)//"a")) call cas_shape((d(:)(1:3)//"a")) call cas_shape(a(1:2)(1:3)) call cas_shape(b(1:2)(1:3)) call cas_shape(c(1:2)(1:3)) call cas_shape(d(1:2)(1:3)) call cas_shape((a(1:2)(1:3)//"a")) call cas_shape((b(1:2)(1:3)//"a")) call cas_shape((c(1:2)(1:3)//"a")) call cas_shape((d(1:2)(1:3)//"a")) call cas_size(e(1:3)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size("abcd"(1:3)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size((e(1:3))) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_size(("abcd"(1:3)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(a) call cas_expl(b) call cas_expl(c) call cas_expl(d) call cas_expl(e) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl("abc") ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl((/"a","b","c"/)) call cas_expl(a//"a") call cas_expl(b//"a") call cas_expl(c//"a") ! { dg-error "The upper bound in the last dimension must appear in the reference to the assumed size array" } call cas_expl(d//"a") call cas_expl(e//"a") ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(("abc")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(((/"a","b","c"/))) call cas_expl(a(1)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(b(1)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(c(1)) ! OK in F95 call cas_expl(d(1)) ! OK in F95 call cas_expl((a(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl((b(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl((c(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl((d(1)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(a(1:3)) call cas_expl(b(1:3)) call cas_expl(c(1:3)) call cas_expl(d(1:3)) call cas_expl((a(1:3)//"a")) call cas_expl((b(1:3)//"a")) call cas_expl((c(1:3)//"a")) call cas_expl((d(1:3)//"a")) call cas_expl(a(:)(1:3)) call cas_expl(b(:)(1:3)) call cas_expl(d(:)(1:3)) call cas_expl((a(:)(1:3))) call cas_expl((b(:)(1:3))) call cas_expl((d(:)(1:3))) call cas_expl(a(1:2)(1:3)) call cas_expl(b(1:2)(1:3)) call cas_expl(c(1:2)(1:3)) call cas_expl(d(1:2)(1:3)) call cas_expl((a(1:2)(1:3)//"a")) call cas_expl((b(1:2)(1:3)//"a")) call cas_expl((c(1:2)(1:3)//"a")) call cas_expl((d(1:2)(1:3)//"a")) call cas_expl(e(1:3)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl("abcd"(1:3)) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl((e(1:3))) ! { dg-error "Fortran 2003: Scalar CHARACTER" } call cas_expl(("abcd"(1:3)//"a")) ! { dg-error "Fortran 2003: Scalar CHARACTER" } END SUBROUTINE test2 SUBROUTINE cas_size(a) character(len=*), dimension(*) :: a END SUBROUTINE cas_size SUBROUTINE cas_shape(a) character(len=*), dimension(:) :: a END SUBROUTINE cas_shape SUBROUTINE cas_expl(a) character(len=*), dimension(3) :: a END SUBROUTINE cas_expl END
gpl-2.0
hisashiyashiro/nicam_dckernel_2016
dckernel_communication/src/mod_process.f90
1
7652
!------------------------------------------------------------------------------- !> module PROCESS !! !! @par Description !! MPI/non-MPI management module !! Imported from SCALE library !! !! @author Team SCALE !! !< module mod_process !----------------------------------------------------------------------------- ! !++ used modules ! use mpi use mod_precision use mod_stdio !----------------------------------------------------------------------------- implicit none private !----------------------------------------------------------------------------- ! !++ Public procedures ! public :: PRC_MPIstart public :: PRC_LOCAL_setup public :: PRC_MPIstop public :: PRC_MPIfinish public :: PRC_MPIbarrier public :: PRC_MPItime public :: PRC_MPItimestat !----------------------------------------------------------------------------- ! !++ Public parameters & variables ! !----------------------------------------------------------------------------- ! [ communicator system ] ! MPI_COMM_WORLD ! | ! PRC_LOCAL_COMM_WORLD --split--> BULK_COMM_WORLD ! | ! PRC_GLOBAL_COMM_WORLD --split--> PRC_LOCAL_COMM_WORLD !----------------------------------------------------------------------------- integer, public, parameter :: PRC_masterrank = 0 !< master process in each communicator ! local world integer, public :: PRC_LOCAL_COMM_WORLD = -1 !< local communicator integer, public :: PRC_nprocs = 1 !< myrank in local communicator integer, public :: PRC_myrank = 0 !< process num in local communicator logical, public :: PRC_IsMaster = .false. !< master process in local communicator? logical, public :: PRC_mpi_alive = .false. !< MPI is alive? !----------------------------------------------------------------------------- ! !++ Private procedures ! !----------------------------------------------------------------------------- ! !++ Private parameters & variables ! !----------------------------------------------------------------------------- contains !----------------------------------------------------------------------------- !> Start MPI subroutine PRC_MPIstart( & comm ) implicit none integer, intent(out) :: comm ! communicator integer :: ierr !--------------------------------------------------------------------------- call MPI_Init(ierr) PRC_mpi_alive = .true. comm = MPI_COMM_WORLD return end subroutine PRC_MPIstart !----------------------------------------------------------------------------- !> Setup MPI subroutine PRC_LOCAL_setup( & comm, & myrank, & ismaster ) implicit none integer, intent(in) :: comm ! communicator integer, intent(out) :: myrank ! myrank in this communicator logical, intent(out) :: ismaster ! master process in this communicator? integer :: ierr !--------------------------------------------------------------------------- PRC_LOCAL_COMM_WORLD = comm call MPI_COMM_RANK(PRC_LOCAL_COMM_WORLD,PRC_myrank,ierr) call MPI_COMM_SIZE(PRC_LOCAL_COMM_WORLD,PRC_nprocs,ierr) if ( PRC_myrank == PRC_masterrank ) then PRC_IsMaster = .true. else PRC_IsMaster = .false. endif myrank = PRC_myrank ismaster = PRC_IsMaster return end subroutine PRC_LOCAL_setup !----------------------------------------------------------------------------- !> Abort MPI subroutine PRC_MPIstop implicit none integer :: ierr !--------------------------------------------------------------------------- ! flush 1kbyte write(IO_FID_LOG,'(32A32)') ' ' write(IO_FID_LOG,*) '+++ Abort MPI' if( PRC_IsMaster ) write(*,*) '+++ Abort MPI' if ( IO_L ) then if( IO_FID_LOG /= IO_FID_STDOUT ) close(IO_FID_LOG) endif close(IO_FID_CONF) if ( PRC_mpi_alive ) then ! Abort MPI call MPI_Abort(PRC_LOCAL_COMM_WORLD, 1, ierr) endif stop end subroutine PRC_MPIstop !----------------------------------------------------------------------------- !> Stop MPI peacefully subroutine PRC_MPIfinish implicit none integer :: ierr !--------------------------------------------------------------------------- ! Stop MPI if ( PRC_mpi_alive ) then if ( IO_L ) then write(IO_FID_LOG,*) write(IO_FID_LOG,*) '++++++ Stop MPI' write(IO_FID_LOG,*) endif call MPI_Barrier(PRC_LOCAL_COMM_WORLD,ierr) call MPI_Finalize(ierr) write(IO_FID_LOG,*) '*** MPI is peacefully finalized' endif ! Close logfile, configfile if ( IO_L ) then if( IO_FID_LOG /= IO_FID_STDOUT ) close(IO_FID_LOG) endif close(IO_FID_CONF) ! Stop program stop end subroutine PRC_MPIfinish !----------------------------------------------------------------------------- !> Barrier MPI subroutine PRC_MPIbarrier implicit none integer :: ierr !--------------------------------------------------------------------------- if ( PRC_mpi_alive ) then call MPI_barrier(PRC_LOCAL_COMM_WORLD,ierr) endif end subroutine PRC_MPIbarrier !----------------------------------------------------------------------------- !> Get MPI time !> @return time function PRC_MPItime() result(time) implicit none real(DP) :: time !--------------------------------------------------------------------------- if ( PRC_mpi_alive ) then time = real(MPI_WTIME(), kind=DP) else call CPU_TIME(time) endif end function PRC_MPItime !----------------------------------------------------------------------------- !> Calc global statistics for timer subroutine PRC_MPItimestat( & avgvar, & maxvar, & minvar, & maxidx, & minidx, & var ) implicit none real(DP), intent(out) :: avgvar(:) !< average real(DP), intent(out) :: maxvar(:) !< maximum real(DP), intent(out) :: minvar(:) !< minimum integer, intent(out) :: maxidx(:) !< index of maximum integer, intent(out) :: minidx(:) !< index of minimum real(DP), intent(in) :: var(:) !< values for statistics real(DP), allocatable :: statval(:,:) integer :: vsize real(DP) :: totalvar integer :: ierr integer :: v, p !--------------------------------------------------------------------------- vsize = size(var(:)) allocate( statval(vsize,0:PRC_nprocs-1) ) statval(:,:) = 0.0_DP do v = 1, vsize statval(v,PRC_myrank) = var(v) enddo ! MPI broadcast do p = 0, PRC_nprocs-1 call MPI_Bcast( statval(1,p), & vsize, & MPI_DOUBLE_PRECISION, & p, & PRC_LOCAL_COMM_WORLD, & ierr ) enddo do v = 1, vsize totalvar = 0.0_DP do p = 0, PRC_nprocs-1 totalvar = totalvar + statval(v,p) enddo avgvar(v) = totalvar / PRC_nprocs maxvar(v) = maxval(statval(v,:)) minvar(v) = minval(statval(v,:)) maxidx(v:v) = maxloc(statval(v,:)) minidx(v:v) = minloc(statval(v,:)) enddo deallocate( statval ) return end subroutine PRC_MPItimestat end module mod_process
bsd-2-clause
OpenFAST/OpenFAST
modules/aerodyn/src/AeroAcoustics.f90
1
162024
!********************************************************************************************************************************** ! File last committed: 2020-02-12 !********************************************************************************************************************************** module AeroAcoustics use NWTC_Library use AeroAcoustics_Types use AeroAcoustics_IO use NWTC_LAPACK USE NWTC_FFTPACK implicit none private ! ..... Public Subroutines ................................................................................................... public :: AA_Init ! Initialization routine public :: AA_End ! Ending routine (includes clean up) public :: AA_UpdateStates ! Loose coupling routine for solving for constraint states, integrating ! continuous states, and updating discrete states public :: AA_CalcOutput ! Routine for computing outputs contains !---------------------------------------------------------------------------------------------------------------------------------- !> This routine is called at the start of the simulation to perform initialization steps. !! The parameters are set here and not changed during the simulation. !! The initial states and initial guess for the input are defined. subroutine AA_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut, ErrStat, ErrMsg ) type(AA_InitInputType), intent(in ) :: InitInp !< Input data for initialization routine type(AA_InputType), intent( out) :: u !< An initial guess for the input; input mesh must be defined type(AA_ParameterType), intent( out) :: p !< Parameters type(AA_ContinuousStateType), intent( out) :: x !< Initial continuous states type(AA_DiscreteStateType), intent( out) :: xd !< Initial discrete states type(AA_ConstraintStateType), intent( out) :: z !< Initial guess of the constraint states type(AA_OtherStateType), intent( out) :: OtherState !< Initial other states type(AA_OutputType), intent( out) :: y !< Initial system outputs (outputs are not calculated; !! only the output mesh is initialized) type(AA_MiscVarType), intent( out) :: m !< Initial misc/optimization variables real(DbKi), intent(inout) :: interval !< Coupling interval in seconds: the rate that !! (1) AA_UpdateStates() is called in loose coupling & !! (2) AA_UpdateDiscState() is called in tight coupling. !! Input is the suggested time from the glue code; !! Output is the actual coupling interval that will be used !! by the glue code. type(AA_InitOutputType), intent( out) :: InitOut !< Output for initialization routine integer(IntKi), intent( out) :: errStat !< Error status of the operation character(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables integer(IntKi) :: i ! loop counter integer(IntKi) :: errStat2 ! temporary error status of the operation character(ErrMsgLen) :: errMsg2 ! temporary error message type(AA_InputFile) :: InputFileData ! Data stored in the module's input file integer(IntKi) :: UnEcho ! Unit number for the echo file character(*), parameter :: RoutineName = 'AA_Init' ! Initialize variables for this routine errStat = ErrID_None errMsg = "" UnEcho = -1 ! Initialize the NWTC Subroutine Library call NWTC_Init( EchoLibVer=.FALSE. ) ! Display the module information call DispNVD( AA_Ver ) ! To get rid of a compiler warning. x%DummyContState = 0.0_SiKi z%DummyConstrState = 0.0_SiKi OtherState%DummyOtherState = 0.0_SiKi !bjj: note that we haven't validated p%NumBlades before using it below! p%NumBlades = InitInp%NumBlades ! need this before reading the AD input file so that we know how many blade files to read p%RootName = TRIM(InitInp%RootName)//'.NN' ! Read the primary AeroAcoustics input file in AeroAcoustics_IO call ReadInputFiles( InitInp%InputFile, InitInp%AFInfo%BL_file, InputFileData, interval, p%RootName, p%NumBlades, UnEcho, ErrStat2, ErrMsg2 ) if (Failed()) return ! Validate the inputs call ValidateInputData(InputFileData, p%NumBlades, ErrStat2, ErrMsg2); if (Failed()) return ! Validate Initialization Input data ( not found in the AeroAcoustics input file ) if (InitInp%AirDens <= 0.0) call SetErrStat ( ErrID_Fatal, 'The air density (AirDens) must be greater than zero.', ErrStat, ErrMsg, RoutineName ) if (InitInp%KinVisc <= 0.0) call SetErrStat ( ErrID_Fatal, 'The kinesmatic viscosity (KinVisc) must be greater than zero.', ErrStat, ErrMsg, RoutineName ) if (InitInp%SpdSound <= 0.0) call SetErrStat ( ErrID_Fatal, 'The speed of sound (SpdSound) must be greater than zero.', ErrStat, ErrMsg, RoutineName ) if (Failed()) return ! Define parameters call SetParameters( InitInp, InputFileData, p, ErrStat2, ErrMsg2 ); if(Failed()) return ! Define and initialize inputs call Init_u( u, p, InputFileData, InitInp, errStat2, errMsg2 ); if(Failed()) return ! Define outputs here call Init_y(y, u, p, errStat2, errMsg2); if(Failed()) return ! Initialize states and misc vars call Init_MiscVars(m, p, u, y, errStat2, errMsg2); if(Failed()) return call Init_States(xd, p, errStat2, errMsg2); if(Failed()) return ! Define initialization output here call AA_SetInitOut(p, InputFileData, InitOut, errStat2, errMsg2); if(Failed()) return call AA_InitializeOutputFile(p, InputFileData,InitOut,errStat2, errMsg2); if(Failed()) return call Cleanup() contains logical function Failed() call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) Failed = ErrStat >= AbortErrLev if (Failed) call Cleanup() end function Failed subroutine Cleanup() CALL AA_DestroyInputFile( InputFileData, ErrStat2, ErrMsg2 ) IF ( UnEcho > 0 ) CLOSE( UnEcho ) end subroutine Cleanup end subroutine AA_Init !---------------------------------------------------------------------------------------------------------------------------------- !> This routine sets AeroAcoustics parameters for use during the simulation; these variables are not changed after AA_Init. subroutine SetParameters( InitInp, InputFileData, p, ErrStat, ErrMsg ) TYPE(AA_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine, out is needed because of copy below TYPE(AA_InputFile), INTENT(IN ) :: InputFileData !< Data stored in the module's input file -- intent(out) only for move_alloc statements TYPE(AA_ParameterType), INTENT(INOUT) :: p !< Parameters INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None ! Local variables CHARACTER(ErrMsgLen) :: ErrMsg2 ! temporary Error message if ErrStat / = ErrID_None INTEGER(IntKi) :: ErrStat2 ! temporary Error status of the operation INTEGER(IntKi) :: simcou,coun ! simple loop counter INTEGER(IntKi) :: I,J,whichairfoil,K,i1_1,i10_1,i1_2,i10_2,iLE character(*), parameter :: RoutineName = 'SetParameters' LOGICAL :: tr,tri,exist,LE_flag REAL(ReKi) :: val1,val10,f2,f4,lefttip,rightip,jumpreg, dist1, dist10 ! Initialize variables for this routine ErrStat = ErrID_None ErrMsg = "" !!Assign input fiel data to parameters p%DT = InputFileData%DT_AA ! seconds p%AA_Bl_Prcntge = InputFileData%AA_Bl_Prcntge ! % p%fsample = 1/p%DT ! Hz p%total_sample = 2**( ceiling(log(1*p%fsample)/log(2.0d0)))! 1 stands for the 1 seconds. Every 1 second Vrel spectra will be calculated for the dissipation calculation (change if more needed & recompile ) p%total_sampleTI = 5/p%DT ! 10 seconds for TI sampling p%AAStart = InputFileData%AAStart p%IBLUNT = InputFileData%IBLUNT p%ILAM = InputFileData%ILAM p%ITIP = InputFileData%ITIP p%ITRIP = InputFileData%ITRIP p%ITURB = InputFileData%ITURB p%IInflow = InputFileData%IInflow p%X_BLMethod = InputFileData%X_BLMethod p%TICalcMeth = InputFileData%TICalcMeth p%AweightFlag = InputFileData%AweightFlag p%ROUND = InputFileData%ROUND p%alprat = InputFileData%ALPRAT p%NrOutFile = InputFileData%NrOutFile p%delim = Tab p%outFmt = "ES15.6E3" p%NumBlNds = InitInp%NumBlNds p%AirDens = InitInp%AirDens p%KinVisc = InitInp%KinVisc p%SpdSound = InitInp%SpdSound p%HubHeight = InitInp%HubHeight p%Lturb = InputFileData%Lturb p%dy_turb_in = InputFileData%dy_turb_in p%dz_turb_in = InputFileData%dz_turb_in p%NrObsLoc = InputFileData%NrObsLoc p%FTitle = InputFileData%FTitle IF ((InputFileData%TICalcMeth==1)) THEN call AllocAry(p%TI_Grid_In,size(InputFileData%TI_Grid_In,1), size(InputFileData%TI_Grid_In,2), 'p%TI_Grid_In', errStat2, errMsg2); if(Failed()) return p%TI_Grid_In=InputFileData%TI_Grid_In ENDIF p%AvgV=InputFileData%AvgV ! Copy AFInfo into AA module ! TODO Allocate AFInfo and AFindx variables (DONE AND DONE) ALLOCATE(p%AFInfo( size(InitInp%AFInfo) ), STAT=ErrStat2) IF ( ErrStat2 /= 0 ) THEN CALL SetErrStat(ErrID_Fatal, 'Error allocating memory for the InitInp%AFInfo array.', ErrStat2, ErrMsg2, RoutineName) RETURN ENDIF do i=1,size(InitInp%AFInfo) call AFI_CopyParam(InitInp%AFInfo(i), p%AFInfo(i), MESH_NEWCOPY, errStat2, errMsg2); if(Failed()) return end do ! Check 1 tri=.true. IF( (p%ITURB.eq.2) .or. (p%IInflow.gt.1) )then ! if tno is on or one of the guidati models is on, check if we have airfoil coordinates DO k=1,size(p%AFInfo) ! if any of the airfoil coordinates are missing change calculation method IF( (size(p%AFInfo(k)%X_Coord) .lt. 5) .or. (size(p%AFInfo(k)%Y_Coord).lt.5) )then IF (tri) then ! Print the message for once only print*, 'Airfoil coordinates are missing: If Full or Simplified Guidati or Bl Calculation is on coordinates are needed ' print*, 'Calculation methods enforced as BPM for TBLTE and only Amiet for inflow ' p%ITURB = 1 p%IInflow = 1 tri=.false. ENDIF ENDIF ENDDO ENDIF ! Check 2 ! if passed the first check and if tno, turn on boundary layer calculation IF( (p%ITURB.eq.2)) then p%X_BLMethod=2 ENDIF ! Check 3 ! if boundary layer is tripped then laminar b.l. vortex shedding mechanism is turned off IF( p%ITRIP.gt.0 )then p%ILAM=0 ENDIF ! set 1/3 octave band frequency as parameter and A weighting. CALL AllocAry( p%FreqList, 34, 'FreqList', ErrStat2, ErrMsg2); if(Failed()) return p%FreqList = (/10.,12.5,16.,20.,25.,31.5,40.,50.,63.,80., & 100.,125.,160.,200.,250.,315.,400.,500.,630.,800., & 1000.,1250.,1600.,2000.,2500.,3150.,4000.,5000.,6300.,8000., & 10000.,12500.,16000.,20000./) ! TODO this should be fortran parameter CALL AllocAry(p%Aweight, size(p%Freqlist), 'Aweight', ErrStat2, ErrMsg2); if(Failed()) return Do I=1,size(p%Freqlist) f2 = p%Freqlist(I)**2; f4 = p%Freqlist(I)**4; p%Aweight(I)= 10 * log(1.562339 * f4 / ((f2 + 107.65265**2) & * (f2 + 737.86223 **2))) / log(10.0_Reki) & + 10 * log(2.242881E+16 * f4 / ((f2 + 20.598997**2)**2 & * (f2 + 12194.22**2)**2)) / log(10.0_Reki) enddo ! Observer Locations call AllocAry(p%ObsX, p%NrObsLoc, 'p%ObsX', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(p%ObsY, p%NrObsLoc, 'p%ObsY', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(p%ObsZ, p%NrObsLoc, 'p%ObsZ', ErrStat2, ErrMsg2); if(Failed()) return p%ObsX = InputFileData%ObsX p%ObsY = InputFileData%ObsY p%ObsZ = InputFileData%ObsZ ! call AllocAry(p%BlAFID, p%NumBlNds, p%numBlades, 'p%BlAFID' , ErrStat2, ErrMsg2); if(Failed()) return p%BlAFID=InitInp%BlAFID ! Blade Characteristics chord,span,trailing edge angle and thickness,airfoil ID for each segment call AllocAry(p%TEThick ,p%NumBlNds,p%NumBlades,'p%TEThick' ,ErrStat2,ErrMsg2); if(Failed()) return call AllocAry(p%TEAngle ,p%NumBlNds,p%NumBlades,'p%TEAngle' ,ErrStat2,ErrMsg2); if(Failed()) return call AllocAry(p%StallStart,p%NumBlNds,p%NumBlades,'p%StallStart',ErrStat2,ErrMsg2); if(Failed()) return p%StallStart(:,:) = 0.0_ReKi do i=1,p%NumBlades do j=1,p%NumBlNds whichairfoil = p%BlAFID(j,i) p%TEThick(j,i) = InputFileData%BladeProps(whichairfoil)%TEThick p%TEAngle(j,i) = InputFileData%BladeProps(whichairfoil)%TEAngle if(p%AFInfo(whichairfoil)%NumTabs /=1 ) then call SetErrStat(ErrID_Fatal, 'Number of airfoil tables within airfoil file different than 1, which is not supported.', ErrStat2, ErrMsg2, RoutineName ) if(Failed()) return endif p%StallStart(j,i) = p%AFInfo(whichairfoil)%Table(1)%UA_BL%alpha1*180/PI ! approximate stall angle of attack [deg] (alpha1 in [rad]) enddo enddo call AllocAry(p%BlSpn, p%NumBlNds, p%NumBlades, 'p%BlSpn' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(p%BlChord, p%NumBlNds, p%NumBlades, 'p%BlChord', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(p%AerCent, 2, p%NumBlNds, p%NumBlades, 'p%AerCent', ErrStat2, ErrMsg2); if(Failed()) return p%BlSpn = InitInp%BlSpn p%BlChord = InitInp%BlChord do j=p%NumBlNds,2,-1 IF ( p%BlSpn(j,1) .lt. p%BlSpn(p%NumBlNds,1)*(100-p%AA_Bl_Prcntge)/100 )THEN ! assuming p%startnode=j exit ! exit the loop endif enddo IF (p%startnode.lt.2) THEN p%startnode=2 ENDIF !print*, 'AeroAcoustics Module is using the blade nodes starting from ' ,p%startnode,' Radius in meter ',p%BlSpn(p%startnode,1) !AerodYnamic center extraction for each segment do i=1,p%numBlades do j=1,p%NumBlNds whichairfoil = p%BlAFID(j,i) ! just a temporary variable for clear coding ! airfoil coordinates read by AeroDyn. First value is the aerodynamic center p%AerCent(1,J,I) = p%AFInfo(whichairfoil)%X_Coord(1) ! assigned here corresponding airfoil. p%AerCent(2,J,I) = p%AFInfo(whichairfoil)%Y_Coord(1) ! assigned here corresponding airfoil. enddo enddo ! Dimensionalize Leading and trailing edge coordinates for later usage call AllocAry( p%AFTeCo, 3, p%NumBlNds,p%numBlades, 'p%AFTeCo', errStat2, errMsg2 ); if(Failed())return call AllocAry( p%AFLeCo, 3, p%NumBlNds,p%numBlades, 'p%AFLeCo', errStat2, errMsg2 ); if(Failed())return p%AFTeCo=0.0_Reki p%AFLeCo=0.0_Reki ! Normalized Leading edge coordinates (0,0,0) ! Normalized Trailing edge coordinates (1,0,0) -- > changed to 0,1,0 DO i=1,p%numBlades DO j=1,p%NumBlNds p%AFLeCo(1,j,i) = ( 0.0_Reki - p%AerCent(2,J,I) ) * p%BlChord(j,i) ! (y_LE - y_AC) *Chord p%AFLeCo(2,j,i) = ( 0.0_Reki - p%AerCent(1,J,I) ) * p%BlChord(j,i) ! (x_LE - x_AC) *Chord p%AFLeCo(3,j,i) = ( 0.0_Reki - 0.0_Reki ) * p%BlChord(j,i) ! this is always zero at the moment ( kept for 3d consistency ) p%AFTeCo(1,j,i) = ( 0.0_Reki - p%AerCent(2,J,I) ) * p%BlChord(j,i) ! (y_TE - y_AC) *Chord p%AFTeCo(2,j,i) = ( 1.0_Reki - p%AerCent(1,J,I) ) * p%BlChord(j,i) ! (x_TE - x_AC) *Chord p%AFTeCo(3,j,i) = ( 0.0_Reki - 0.0_Reki ) * p%BlChord(j,i) ! this is always zero at the moment ( kept for 3d consistency ) ENDDO ENDDO if (p%X_BLMethod.eq.2) then ! Copying inputdata list of AOA and Reynolds to parameters call AllocAry( p%AOAListBL, size(InputFileData%AOAListBL), 'p%AOAListBL', errStat2, errMsg2); if(Failed()) return call AllocAry( p%ReListBL, size(InputFileData%ReListBL) , 'p%ReListBL' , errStat2, errMsg2); if(Failed()) return p%AOAListBL=InputFileData%AOAListBL p%ReListBL=InputFileData%ReListBL ! Allocate the suction and pressure side boundary layer parameters for output - will be used as tabulated data call AllocAry(p%dstarall1 ,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%dstarall1' , errStat2, errMsg2); if(Failed()) return call AllocAry(p%dstarall2 ,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%dstarall2' , errStat2, errMsg2); if(Failed()) return call AllocAry(p%d99all1 ,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%d99all1' , errStat2, errMsg2); if(Failed()) return call AllocAry(p%d99all2 ,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%d99all2' , errStat2, errMsg2); if(Failed()) return call AllocAry(p%Cfall1 ,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%Cfall1' , errStat2, errMsg2); if(Failed()) return call AllocAry(p%Cfall2 ,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%Cfall2' , errStat2, errMsg2); if(Failed()) return call AllocAry(p%EdgeVelRat1,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%EdgeVelRat1', errStat2, errMsg2); if(Failed()) return call AllocAry(p%EdgeVelRat2,size(p%AOAListBL), size(p%ReListBL),size(p%AFInfo),'p%EdgeVelRat2', errStat2, errMsg2); if(Failed()) return p%dstarall1 =0.0_ReKi p%dstarall2 =0.0_ReKi p%d99all1 =0.0_ReKi p%d99all2 =0.0_ReKi p%Cfall1 =0.0_ReKi p%Cfall2 =0.0_ReKi p%EdgeVelRat1 =0.0_ReKi p%EdgeVelRat2 =0.0_ReKi ! --- BL data are read from files and just copy what was read from the files p%dstarall1 = InputFileData%Suct_DispThick p%dstarall2 = InputFileData%Pres_DispThick p%d99all1 = InputFileData%Suct_BLThick p%d99all2 = InputFileData%Pres_BLThick p%Cfall1 = InputFileData%Suct_Cf p%Cfall2 = InputFileData%Pres_Cf p%EdgeVelRat1 = InputFileData%Suct_EdgeVelRat p%EdgeVelRat2 = InputFileData%Pres_EdgeVelRat if(Failed()) return endif ! If simplified guidati is on, calculate the airfoil thickness at 1% and at 10% chord from input airfoil coordinates IF (p%IInflow .EQ. 2) THEN call AllocAry(p%AFThickGuida,2,size(p%AFInfo), 'p%AFThickGuida', errStat2, errMsg2); if(Failed()) return p%AFThickGuida=0.0_Reki DO k=1,size(p%AFInfo) ! for each airfoil interpolation ! IF ((MIN(p%AFInfo(k)%X_Coord) < 0.) .or. (MAX(p%AFInfo(k)%X_Coord) > 0.)) THEN ! call SetErrStat ( ErrID_Fatal,'The coordinates of airfoil '//trim(num2lstr(k))//' are mot defined between x=0 and x=1. Code stops.' ,ErrStat, ErrMsg, RoutineName ) ! ENDIF ! Flip the flag when LE is found and find index LE_flag = .False. DO i=3,size(p%AFInfo(k)%X_Coord) IF (LE_flag .eqv. .False.) THEN IF (p%AFInfo(k)%X_Coord(i) - p%AFInfo(k)%X_Coord(i-1) > 0.) THEN LE_flag = .TRUE. iLE = i ENDIF ENDIF ENDDO ! From LE toward TE dist1 = ABS( p%AFInfo(k)%X_Coord(iLE) - 0.01) dist10 = ABS( p%AFInfo(k)%X_Coord(iLE) - 0.10) DO i=iLE+1,size(p%AFInfo(k)%X_Coord) IF (ABS(p%AFInfo(k)%X_Coord(i) - 0.01) < dist1) THEN i1_1 = i dist1 = ABS(p%AFInfo(k)%X_Coord(i) - 0.01) ENDIF IF (ABS(p%AFInfo(k)%X_Coord(i) - 0.1) < dist10) THEN i10_1 = i dist10 = ABS(p%AFInfo(k)%X_Coord(i) - 0.1) ENDIF ENDDO ! From TE to LE dist1 = 0.99 dist10 = 0.90 DO i=1,iLE-1 IF (ABS(p%AFInfo(k)%X_Coord(i) - 0.01) < dist1) THEN i1_2 = i dist1 = ABS(p%AFInfo(k)%X_Coord(i) - 0.01) ENDIF IF (ABS(p%AFInfo(k)%X_Coord(i) - 0.1) < dist10) THEN i10_2 = i dist10 = ABS(p%AFInfo(k)%X_Coord(i) - 0.1) ENDIF ENDDO val1 = p%AFInfo(k)%Y_Coord(i1_1) - p%AFInfo(k)%Y_Coord(i1_2) val10 = p%AFInfo(k)%Y_Coord(i10_1) - p%AFInfo(k)%Y_Coord(i10_2) p%AFThickGuida(1,k)=val1 ! 1 % chord thickness p%AFThickGuida(2,k)=val10 ! 10 % chord thickness ENDDO ENDIF !! for turbulence intensity calculations on the fly every 5 meter the whole rotor area is divided vertically to store flow fields in each region jumpreg=7 p%toptip = CEILING(p%HubHeight+maxval(p%BlSpn(:,1)))+2 !Top Tip Height = Hub height plus radius p%bottip = FLOOR(p%HubHeight-maxval(p%BlSpn(:,1)))-2 !Bottom Tip Height = Hub height minus radius call AllocAry(p%rotorregionlimitsVert,ceiling(((p%toptip)-(p%bottip))/jumpreg), 'p%rotorregionlimitsVert', errStat2, errMsg2); if(Failed()) return do i=0,size(p%rotorregionlimitsVert)-1 p%rotorregionlimitsVert(i+1)=(p%bottip)+jumpreg*i enddo !! for turbulence intensity calculations on the fly every 5 meter the whole rotor area is divided horizontally to store flow fields in each region jumpreg=7 lefttip = 2*maxval(p%BlSpn(:,1))+5 ! rightip = 0 ! call AllocAry( p%rotorregionlimitsHorz,ceiling(((lefttip)-(rightip))/jumpreg), 'p%rotorregionlimitsHorz', errStat2, errMsg2); if(Failed()) return do i=0,size(p%rotorregionlimitsHorz)-1 p%rotorregionlimitsHorz(i+1)=rightip+jumpreg*i enddo jumpreg=60 ! 10 ! must be divisable to 360 call AllocAry(p%rotorregionlimitsalph,INT((360/jumpreg)+1), 'p%rotorregionlimitsalph', errStat2, errMsg2); if(Failed()) return do i=0,size(p%rotorregionlimitsalph)-1 p%rotorregionlimitsalph(i+1)=jumpreg*i enddo jumpreg=5 call AllocAry( p%rotorregionlimitsrad, (CEILING( maxval(p%BlSpn(:,1))/jumpreg )+2), 'p%rotorregionlimitsrad', errStat2, errMsg2); if(Failed()) return do i=1,size(p%rotorregionlimitsrad)-1 p%rotorregionlimitsrad(i+1)=jumpreg*i enddo p%rotorregionlimitsrad(1)=0.0_reki p%rotorregionlimitsrad(size(p%rotorregionlimitsrad)-1)=p%rotorregionlimitsrad(size(p%rotorregionlimitsrad)-1)+3 contains logical function Failed() call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) Failed = ErrStat >= AbortErrLev end function Failed end subroutine SetParameters !---------------------------------------------------------------------------------------------------------------------------------- !> This routine initializes AeroAcoustics module input array variables for use during the simulation. subroutine Init_u( u, p, InputFileData, InitInp, errStat, errMsg ) type(AA_InputType), intent( out) :: u !< Input data type(AA_ParameterType), intent(in ) :: p !< Parameters type(AA_InputFile), intent(in ) :: InputFileData !< Data stored in the module's input file type(AA_InitInputType), intent(in ) :: InitInp !< Input data for AD initialization routine integer(IntKi), intent( out) :: errStat !< Error status of the operation character(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None !local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'Init_u' call AllocAry(u%AoANoise , p%NumBlNds, p%numBlades, 'u%AoANoise', errStat2 , errMsg2); if(Failed()) return call AllocAry(u%Vrel , p%NumBlNds, p%numBlades, 'u%Vrel' , errStat2 , errMsg2); if(Failed()) return call AllocAry(u%AeroCent_G, 3 , p%NumBlNds , p%numBlades , 'u%AeroCent_G', errStat2 , errMsg2); if(Failed()) return call AllocAry(u%Inflow , 3_IntKi , p%NumBlNds , p%numBlades , 'u%Inflow' , ErrStat2 , ErrMsg2); if(Failed()) return call AllocAry(u%RotGtoL , 3 , 3 , p%NumBlNds , p%numBlades , 'u%RotGtoL' , errStat2 , errMsg2); if(Failed()) return u%AoANoise = 0.0_Reki u%Vrel = 0.0_Reki u%RotGtoL = 0.0_Reki u%AeroCent_G = 0.0_Reki u%Inflow = 0.0_Reki contains logical function Failed() call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) Failed = ErrStat >= AbortErrLev end function Failed end subroutine Init_u !---------------------------------------------------------------------------------------------------------------------------------- !> This routine initializes AeroAcoustics output array variables for use during the simulation. subroutine Init_y(y, u, p, errStat, errMsg) type(AA_OutputType), intent( out) :: y !< Module outputs type(AA_InputType), intent(inout) :: u !< Module inputs -- intent(out) because of mesh sibling copy type(AA_ParameterType), intent(inout) :: p !< Parameters integer(IntKi), intent( out) :: errStat !< Error status of the operation character(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables integer(intKi) :: k ! loop counter for blades integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'Init_y' integer(intKi) :: nNoiseMechanism ! loop counter for blades ! Initialize variables for this routine errStat = ErrID_None errMsg = "" nNoiseMechanism = 7! 7 noise mechanisms p%numOuts = p%NrObsLoc p%NumOutsForSep = p%NrObsLoc*size(p%FreqList)*nNoiseMechanism p%NumOutsForPE = p%NrObsLoc*size(p%Freqlist) p%NumOutsForNodes = p%NrObsLoc*p%NumBlNds*p%NumBlades call AllocAry(y%WriteOutput , p%numOuts , 'y%WriteOutput' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%WriteOutputSep , p%NumOutsForSep , 'y%WriteOutputSep' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%WriteOutputForPE , p%numOutsForPE , 'y%WriteOutputForPE' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%DirectiviOutput , p%NrObsLoc , 'y%DirectiviOutput' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%WriteOutputNode , p%NumOutsForNodes , 'y%WriteOutputSepFreq' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%OASPL , p%NrObsLoc , p%NumBlNds , p%NumBlades , 'y%OASPL' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%SumSpecNoise , size(p%FreqList) , p%NrObsLoc , p%NumBlades , 'y%SumSpecNoise' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%SumSpecNoiseSep , 7 , p%NrObsLoc , size(p%FreqList) , 'y%SumSpecNoiseSep' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%OASPL_Mech , nNoiseMechanism , p%NrObsLoc , p%NumBlNds , p%NumBlades , 'y%OASPL_Mech' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%OutLECoords , 3 , size(p%FreqList) , p%NrObsLoc , p%NumBlades , 'y%OutLECoords' , errStat2 , errMsg2); if(Failed()) return call AllocAry(y%PtotalFreq , p%NrObsLoc , size(p%FreqList) , 'y%PtotalFreq' , errStat2 , errMsg2); if(Failed()) return y%WriteOutput = 0.0_reki y%WriteOutputSep = 0.0_reki y%WriteOutputForPE = 0.0_reki y%DirectiviOutput = 0.0_reki y%WriteOutputNode = 0.0_reki y%OASPL = 0.0_reki y%OASPL_Mech = 0.0_reki y%SumSpecNoise = 0.0_reki y%SumSpecNoiseSep = 0.0_reki y%OutLECoords = 0.0_reki y%PtotalFreq = 0.0_reki contains logical function Failed() call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) Failed = ErrStat >= AbortErrLev end function Failed end subroutine Init_y !---------------------------------------------------------------------------------------------------------------------------------- !> This routine initializes (allocates) the misc variables for use during the simulation. subroutine Init_MiscVars(m, p, u, y, errStat, errMsg) type(AA_MiscVarType), intent(inout) :: m !< misc/optimization data (not defined in submodules) type(AA_ParameterType), intent(in ) :: p !< Parameters type(AA_InputType), intent(inout) :: u !< input for HubMotion mesh (create sibling mesh here) type(AA_OutputType), intent(in ) :: y !< output (create mapping between output and otherstate mesh here) integer(IntKi), intent( out) :: errStat !< Error status of the operation character(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables integer(intKi) :: k integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'Init_MiscVars' ! Initialize variables for this routine errStat = ErrID_None errMsg = "" call AllocAry(m%ChordAngleLE, p%NrObsLoc, p%NumBlNds, p%numBlades, 'ChordAngleLE', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(m%SpanAngleLE , p%NrObsLoc, p%NumBlNds, p%numBlades, 'SpanAngleLE' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(m%ChordAngleTE, p%NrObsLoc, p%NumBlNds, p%numBlades, 'ChordAngleTE', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(m%SpanAngleTE , p%NrObsLoc, p%NumBlNds, p%numBlades, 'SpanAngleTE' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(m%rTEtoObserve, p%NrObsLoc, p%NumBlNds, p%numBlades, 'rTEtoObserve', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(m%rLEtoObserve, p%NrObsLoc, p%NumBlNds, p%numBlades, 'rLEtoObserve', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(m%SPLLBL , size(p%FreqList), 'SPLLBL' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLP , size(p%FreqList), 'SPLP' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLS , size(p%FreqList), 'SPLS' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLALPH , size(p%FreqList), 'SPLALPH' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLTBL , size(p%FreqList), 'SPLTBL' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLBLUNT , size(p%FreqList), 'SPLBLUNT' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLTIP , size(p%FreqList), 'SPLTIP' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLTI , size(p%FreqList), 'SPLTI' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%SPLTIGui , size(p%FreqList), 'SPLTIGui' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%CfVar , 2 , 'CfVar' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%d99Var , 2 , 'd99Var' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%dstarVar , 2 , 'dstarVar' , errStat2, errMsg2); if(Failed()) return call AllocAry(m%EdgeVelVar , 2 , 'EdgeVelVar', errStat2, errMsg2); if(Failed()) return call AllocAry(m%LE_Location, 3, p%NumBlNds, p%numBlades, 'LE_Location', ErrStat2, ErrMsg2); if(Failed()) return m%ChordAngleLE = 0.0_ReKi m%SpanAngleLE = 0.0_ReKi m%ChordAngleTE = 0.0_ReKi m%SpanAngleTE = 0.0_ReKi m%rTEtoObserve = 0.0_ReKi m%rLEtoObserve = 0.0_ReKi m%SPLLBL = 0.0_ReKi m%SPLP = 0.0_ReKi m%SPLS = 0.0_ReKi m%SPLALPH = 0.0_ReKi m%SPLTBL = 0.0_ReKi m%SPLBLUNT = 0.0_ReKi m%SPLTIP = 0.0_ReKi m%SPLTI = 0.0_ReKi m%SPLTIGui = 0.0_ReKi m%CfVar = 0.0_ReKi m%d99Var = 0.0_ReKi m%dstarVar = 0.0_ReKi m%EdgeVelVar = 0.0_ReKi m%LE_Location = 0.0_ReKi m%speccou = 0 m%filesopen = 0 contains logical function Failed() call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) Failed = ErrStat >= AbortErrLev end function Failed end subroutine Init_MiscVars !---------------------------------------------------------------------------------------------------------------------------------- !> This routine initializes (allocates) the misc variables for use during the simulation. subroutine Init_states(xd, p, errStat, errMsg) type(AA_DiscreteStateType), intent(inout) :: xd ! type(AA_ParameterType), intent(in ) :: p !< Parameters integer(IntKi), intent( out) :: errStat !< Error status of the operation character(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables integer(intKi) :: k,ji integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'Init_DiscrStates' ! Initialize variables for this routine errStat = ErrID_None errMsg = "" call AllocAry(xd%MeanVrel, p%NumBlNds, p%numBlades, 'xd%MeanVrel' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(xd%VrelSq, p%NumBlNds, p%numBlades, 'xd%VrelSq' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(xd%TIVrel, p%NumBlNds, p%numBlades, 'xd%TIVrel' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(xd%MeanVxVyVz, p%NumBlNds, p%numBlades, 'xd%MeanVxVyVz', ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(xd%TIVx, p%NumBlNds, p%numBlades, 'xd%TIVx' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(xd%VxSq, p%NumBlNds, p%numBlades, 'xd%VxSq' , ErrStat2, ErrMsg2); if(Failed()) return call AllocAry(xd%VrelStore, p%total_sample+1, p%NumBlNds, p%numBlades,'xd%VrelStore', ErrStat2, ErrMsg2) ! plus one just in case if(Failed()) return DO ji=1,size(xd%MeanVrel,2) DO k=1,size(xd%MeanVrel,1) xd%VrelSq (k,ji) = 0.0_ReKi ! Relative Velocity Squared for TI calculation (on the fly) xd%MeanVrel (k,ji) = 0.0_ReKi ! Relative Velocity Mean calculation (on the fly) xd%TIVrel(k,ji) = 0.0_ReKi ! Turbulence Intensity (for on the fly calculation) xd%MeanVxVyVz (k,ji) = 0.0_ReKi ! xd%TIVx (k,ji) = 0.0_ReKi ! xd%VxSq (k,ji) = 0.0_ReKi ! xd%VrelStore (1:size(xd%VrelStore,1),k,ji) = 0.0_ReKi ! ENDDO ENDDO call AllocAry(xd%RegVxStor,p%total_sampleTI,size(p%rotorregionlimitsrad)-1,size(p%rotorregionlimitsalph)-1,'xd%Vxst',ErrStat2,ErrMsg2) if(Failed()) return call AllocAry(xd%allregcounter ,size(p%rotorregionlimitsrad)-1,size(p%rotorregionlimitsalph)-1,'xd%allregcounter',ErrStat2,ErrMsg2 ) if(Failed()) return call AllocAry(xd%VxSqRegion ,size(p%rotorregionlimitsrad)-1,size(p%rotorregionlimitsalph)-1,'xd%VxSqRegion' , ErrStat2, ErrMsg2) if(Failed()) return call AllocAry(xd%RegionTIDelete,size(p%rotorregionlimitsrad)-1,size(p%rotorregionlimitsalph)-1,'xd%RegionTIDelete', ErrStat2, ErrMsg2) do ji=1,size(xd%allregcounter,2) do k=1,size(xd%allregcounter,1) xd%allregcounter(k,ji) = 2.0_Reki ! xd%VxSqRegion(k,ji) = 0.0_ReKi ! xd%RegionTIDelete(k,ji) = 0.0_ReKi ! xd%RegVxStor(1:size(xd%RegVxStor,1),k,ji)=0.0_reki enddo enddo contains logical function Failed() call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) Failed = ErrStat >= AbortErrLev end function Failed end subroutine Init_states !---------------------------------------------------------------------------------------------------------------------------------- subroutine AA_UpdateStates( t, n, m, u, p, xd, errStat, errMsg ) real(DbKi), intent(in ) :: t !< Current simulation time in seconds integer(IntKi), intent(in ) :: n !< Current simulation time step n = 0,1,... type(AA_InputType), intent(in ) :: u !< Inputs at utimes (out only for mesh record-keeping in ExtrapInterp routine) TYPE(AA_ParameterType), INTENT(IN ) :: p !< Parameters type(AA_DiscreteStateType), intent(inout) :: xd !< Input: Discrete states at t; type(AA_MiscVarType), intent(inout) :: m !< misc/optimization data integer(IntKi), intent( out) :: errStat !< Error status of the operation character(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None ! local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'AA_UpdateStates' REAL(ReKi),DIMENSION(p%NumBlNds,p%numBlades) :: TEMPSTD ! temporary standard deviation variable REAL(ReKi) :: tempsingle,tempmean,angletemp,abs_le_x,ti_vx,U1,U2 ! temporary standard deviation variable integer(intKi) :: i,j,k,rco, y0_a,y1_a,z0_a,z1_a logical :: exist REAL(ReKi) :: yi_a,zi_a,yd_a,zd_a,c00_a,c10_a ErrStat = ErrID_None ErrMsg = "" ! Cumulative mean and standard deviation, states are updated as Vx Vy Vz changes at each time step TEMPSTD = sqrt( u%Inflow(1,:,:)**2+u%Inflow(2,:,:)**2+u%Inflow(3,:,:)**2 ) xd%MeanVxVyVz = (TEMPSTD + xd%MeanVxVyVz*n) / (n+1) ! xd%VxSq = TEMPSTD**2 + xd%VxSq ! TEMPSTD = sqrt( (xd%VxSq/(n+1)) - (xd%MeanVxVyVz**2) ) ! xd%TIVx = (TEMPSTD / xd%MeanVxVyVz ) ! check inflow noise input for multiplication with 100 or not m%speccou= m%speccou+1 IF( (p%TICalcMeth.eq.2) ) THEN do i=1,p%NumBlades do j=1,p%NumBlNds abs_le_x=m%LE_Location(3,j,i)-p%hubheight IF ((abs_le_x.lt.0).and.(m%LE_Location(2,j,i).lt.0)) THEN angletemp=180+ATAN( ABS( m%LE_Location(2,j,i)/abs_le_x ) ) * R2D_D ELSEIF ((abs_le_x.lt.0).and.(m%LE_Location(2,j,i).gt.0)) THEN angletemp=180-ATAN( ABS( m%LE_Location(2,j,i)/abs_le_x ) ) * R2D_D ELSEIF ((abs_le_x.gt.0).and.(m%LE_Location(2,j,i).lt.0)) THEN angletemp=360-ATAN( ABS( m%LE_Location(2,j,i)/abs_le_x ) ) * R2D_D ELSEIF ((abs_le_x.gt.0).and.(m%LE_Location(2,j,i).gt.0)) THEN angletemp=ATAN( m%LE_Location(2,j,i)/abs_le_x ) * R2D_D ELSE print*, 'problem in angletemp Aeroacoustics module' ENDIF !abs_le_x=ABS(abs_le_x) do k=1,size(p%rotorregionlimitsrad) IF (p%BlSpn(j,i)-p%rotorregionlimitsrad(k).lt.0) THEN ! it means location is in the k-1 region !print*, abs_le_x,p%rotorregionlimitsrad(k),k-1 GOTO 4758 ENDIF enddo 4758 do rco=1,size(p%rotorregionlimitsalph) IF (angletemp-p%rotorregionlimitsalph(rco).lt.0) THEN ! it means location is in the k-1 region GOTO 9815 ENDIF enddo 9815 xd%allregcounter(k-1,rco-1)=CEILING(xd%allregcounter(k-1,rco-1)+1.0_Reki) ! increase the sample amount in that specific 5 meter height vertical region tempsingle = sqrt( u%Inflow(1,j,i)**2+u%Inflow(2,j,i)**2+u%Inflow(3,j,i)**2 ) ! ! with storage region dependent moving average and TI IF (INT(xd%allregcounter(k-1,rco-1)) .lt. (size(xd%RegVxStor,1)+1)) THEN xd%RegVxStor(INT(xd%allregcounter(k-1,rco-1)),k-1,rco-1)=tempsingle xd%TIVx(j,i) = 0 xd%RegionTIDelete(k-1,rco-1)=0 ELSE xd%RegVxStor((mod(INT(xd%allregcounter(k-1,rco-1))-size(xd%RegVxStor,1),size(xd%RegVxStor,1)))+1,k-1,rco-1)=tempsingle tempmean=SUM(xd%RegVxStor(:,k-1,rco-1)) tempmean=tempmean/size(xd%RegVxStor,1) xd%RegionTIDelete(k-1,rco-1)=SQRT((SUM((xd%RegVxStor(:,k-1,rco-1)-tempmean)**2)) / size(xd%RegVxStor,1) ) xd%TIVx(j,i) = xd%RegionTIDelete(k-1,rco-1) ! only the fluctuation ENDIF enddo enddo ELSE! interpolate from the user given ti values do i=1,p%NumBlades do j=1,p%NumBlNds zi_a=ABS(m%LE_Location(3,j,i) - (FLOOR(p%HubHeight-maxval(p%BlSpn(:,1)))) ) /p%dz_turb_in z0_a=floor(zi_a) z1_a=ceiling(zi_a) zd_a=zi_a-z0_a yi_a=ABS(m%LE_Location(2,j,i) + maxval(p%BlSpn(:,1)) ) /p%dy_turb_in y0_a=floor(yi_a) y1_a=ceiling(yi_a) yd_a=yi_a-y0_a c00_a=(1.0_ReKi-yd_a)*p%TI_Grid_In(z0_a+1,y0_a+1)+yd_a*p%TI_Grid_In(z0_a+1,y1_a+1) c10_a=(1.0_ReKi-yd_a)*p%TI_Grid_In(z1_a+1,y0_a+1)+yd_a*p%TI_Grid_In(z1_a+1,y1_a+1) ! This is the turbulence intensity of the wind at the location of the blade i at node j ti_vx = (1.0_ReKi-zd_a)*c00_a+zd_a*c10_a ! With some velocity triangles, we convert it into the incident turbulence intensity, i.e. the TI used by the Amiet model U1 = u%Vrel(J,I) U2 = SQRT((p%AvgV*(1.+ti_vx))**2. + U1**2. - p%AvgV**2.) ! xd%TIVx(j,i)=(U2-U1)/U1 xd%TIVx(j,i)=p%AvgV*ti_vx/U1 if (i.eq.p%NumBlades) then if (j.eq.p%NumBlNds) then endif endif enddo enddo endif end subroutine AA_UpdateStates !---------------------------------------------------------------------------------------------------------------------------------- !> This routine is called at the end of the simulation. subroutine AA_End( u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg ) TYPE(AA_InputType), INTENT(INOUT) :: u !< System inputs TYPE(AA_ParameterType), INTENT(INOUT) :: p !< Parameters TYPE(AA_ContinuousStateType), INTENT(INOUT) :: x !< Continuous states TYPE(AA_DiscreteStateType), INTENT(INOUT) :: xd !< Discrete states TYPE(AA_ConstraintStateType), INTENT(INOUT) :: z !< Constraint states TYPE(AA_OtherStateType), INTENT(INOUT) :: OtherState !< Other states TYPE(AA_OutputType), INTENT(INOUT) :: y !< System outputs TYPE(AA_MiscVarType), INTENT(INOUT) :: m !< Misc/optimization variables INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None ! Initialize ErrStat ErrStat = ErrID_None ErrMsg = "" ! Destroy the input data: CALL AA_DestroyInput( u, ErrStat, ErrMsg ) ! Destroy the parameter data: CALL AA_DestroyParam( p, ErrStat, ErrMsg ) ! Destroy the state data: CALL AA_DestroyContState( x, ErrStat, ErrMsg ) CALL AA_DestroyDiscState( xd, ErrStat, ErrMsg ) CALL AA_DestroyConstrState( z, ErrStat, ErrMsg ) CALL AA_DestroyOtherState( OtherState, ErrStat, ErrMsg ) CALL AA_DestroyMisc( m, ErrStat, ErrMsg ) ! Destroy the output data: CALL AA_DestroyOutput( y, ErrStat, ErrMsg ) END SUBROUTINE AA_End !> Routine for computing outputs, used in both loose and tight coupling. !! This subroutine is used to compute the output channels (motions and loads) and place them in the WriteOutput() array. !! The descriptions of the output channels are not given here. Please see the included OutListParameters.xlsx sheet for !! for a complete description of each output parameter. subroutine AA_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg) ! NOTE: no matter how many channels are selected for output, all of the outputs are calcalated ! All of the calculated output channels are placed into the m%AllOuts(:), while the channels selected for outputs are ! placed in the y%WriteOutput(:) array. !.................................................................................................................................. REAL(DbKi), INTENT(IN ) :: t !< Current simulation time in seconds TYPE(AA_InputType), INTENT(IN ) :: u !< Inputs at Time t TYPE(AA_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(AA_ContinuousStateType), INTENT(IN ) :: x !< Continuous states at t TYPE(AA_DiscreteStateType), INTENT(IN ) :: xd !< Discrete states at t TYPE(AA_ConstraintStateType), INTENT(IN ) :: z !< Constraint states at t TYPE(AA_OtherStateType), INTENT(IN ) :: OtherState !< Other states at t TYPE(AA_OutputType), INTENT(INOUT) :: y !< Outputs computed at t (Input only so that mesh con- type(AA_MiscVarType), INTENT(INOUT) :: m !< Misc/optimization variables INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None ! Local variables integer, parameter :: indx = 1 ! m%BEMT_u(1) is at t; m%BEMT_u(2) is t+dt integer(intKi) :: i integer(intKi) :: ErrStat2 character(ErrMsgLen) :: ErrMsg2 character(*), parameter :: RoutineName = 'AA_CalcOutput' ErrStat = ErrID_None ErrMsg = "" ! assume integer divide is possible call CalcObserve(t,p,m,u,xd,errStat2, errMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) IF (t >= p%AAStart) THEN IF (mod(t + 1E-10,p%DT) .lt. 1E-6) THEN call CalcAeroAcousticsOutput(u,p,m,xd,y,errStat2,errMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) call Calc_WriteOutput( p, u, m, y, ErrStat2, ErrMsg2 ) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) call AA_WriteOutputLine(y, t, p, ErrStat2, ErrMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) ENDIF ENDIF end subroutine AA_CalcOutput !---------------------------------------------------------------------------------------------------------------------------------- !----------------------------------------------------------------------------------------------------------------------------------! SUBROUTINE CalcObserve(t,p,m,u,xd,errStat,errMsg) REAL(DbKi), INTENT(IN ) :: t !< Current simulation time in seconds TYPE(AA_DiscreteStateType), INTENT(IN ) :: xd !< discrete state type TYPE(AA_ParameterType), intent(in ) :: p !< Parameters TYPE(AA_InputType), intent(in ) :: u !< NN Inputs at Time TYPE(AA_MiscVarType), intent(inout) :: m !< misc/optimization data (not defined in submodules) INTEGER(IntKi), intent( out) :: errStat !< Error status of the operation CHARACTER(*), intent( out) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables. REAL(ReKi) :: RLEObserve (3) ! Position vector from leading edge to observer in trailing edge coordinate system REAL(ReKi) :: RTEObserve (3) ! Position vector from trailing edge to observer in trailing edge coordinate system REAL(ReKi) :: RTEObserveG (3) ! Position vector from trailing edge to observer in the coordinate system located at the trailing edge and rotated as the global REAL(ReKi) :: RLEObserveG (3) ! Position vector from leading edge to observer in the coordinate system located at the leading edge and rotated as the global REAL(ReKi) :: RTEObservereal (3) ! Location of trailing edge in global coordinate system REAL(ReKi) :: RLEObservereal (3) ! Location of leading edge in global coordinate system REAL(ReKi) :: LocalToGlobal(3,3) ! Transformation matrix REAL(ReKi) :: timeLE ! Time of sound propagation from leading edge to observer REAL(ReKi) :: timeTE ! Time of sound propagation from trailing edge to observer REAL(ReKi) :: phi_e ! Spanwise directivity angle REAL(ReKi) :: theta_e ! Chordwise directivity angle INTEGER(intKi) :: I ! I A generic index for DO loops. INTEGER(intKi) :: J ! J A generic index for DO loops. INTEGER(intKi) :: K ! K A generic index for DO loops. INTEGER(intKi) :: ErrStat2 CHARACTER(ErrMsgLen) :: ErrMsg2 CHARACTER(*), parameter :: RoutineName = 'CalcObserveDist' LOGICAL :: exist ErrStat = ErrID_None ErrMsg = "" ! Loop through the blades DO I = 1,p%numBlades ! Loop through the nodes along blade span DO J = 1,p%NumBlNds ! Transpose the rotational vector GlobalToLocal to obtain the rotation LocalToGlobal LocalToGlobal = TRANSPOSE(u%RotGtoL(:,:,J,I)) ! Rotate the coordinates of leading and trailing edge from the local reference system to the global. Then add the coordinates of the aerodynamic center in the global coordinate system ! The global coordinate system is located on the ground, has x pointing downwind, y pointing laterally, and z pointing vertically upwards RTEObservereal = MATMUL(LocalToGlobal, p%AFTeCo(:,J,I)) + u%AeroCent_G(:,J,I) RLEObservereal = MATMUL(LocalToGlobal, p%AFLeCo(:,J,I)) + u%AeroCent_G(:,J,I) ! Compute the coordinates of the leading edge in the global coordinate system m%LE_Location(1,J,I) = RLEObservereal(1) m%LE_Location(2,J,I) = RLEObservereal(2) m%LE_Location(3,J,I) = RLEObservereal(3) ! If the time step is set to generate AA outputs IF (t >= p%AAStart) THEN IF ( mod(t + 1E-10,p%DT) .lt. 1E-6) THEN ! Loop through the observers DO K = 1,p%NrObsLoc ! Calculate the position of the observer K in a reference system located at the trailing edge and oriented as the global reference system RTEObserveG(1)=p%Obsx(K)-RTEObservereal(1) RTEObserveG(2)=p%Obsy(K)-RTEObservereal(2) RTEObserveG(3)=p%Obsz(K)-RTEObservereal(3) ! Calculate the position of the observer K in a reference system located at the leading edge and oriented as the global reference system RLEObserveG(1)=p%Obsx(K)-RLEObservereal(1) RLEObserveG(2)=p%Obsy(K)-RLEObservereal(2) RLEObserveG(3)=p%Obsz(K)-RLEObservereal(3) ! Rotate back the two reference systems from global to local. RTEObserve = MATMUL(u%RotGtoL(:,:,J,I), RTEObserveG) RLEObserve = MATMUL(u%RotGtoL(:,:,J,I), RLEObserveG) ! Calculate absolute distance between node and observer m%rTEtoObserve(K,J,I) = SQRT (RTEObserve(1)**2+RTEObserve(2)**2+RTEObserve(3)**2) m%rLEtoObserve(K,J,I) = SQRT (RLEObserve(1)**2+RLEObserve(2)**2+RLEObserve(3)**2) ! Calculate time of noise propagation to observer timeTE = m%rTEtoObserve(K,J,I) / p%SpdSound timeLE = m%rLEtoObserve(K,J,I) / p%SpdSound ! The local system has y alinged with the chord, x pointing towards the airfoil suction side, and z aligned with blade span from root towards tip ! x ---> z_e ! y ---> x_e ! z ---> y_e ! Compute spanwise directivity angle phi for the trailing edge phi_e = ATAN2 (RTEObserve(1) , RTEObserve(3)) m%SpanAngleTE(K,J,I) = phi_e * R2D ! Compute chordwise directivity angle theta for the trailing edge theta_e = ATAN2 ((RTEObserve(3) * COS (phi_e) + RTEObserve(1) * SIN (phi_e) ) , RTEObserve(2)) m%ChordAngleTE(K,J,I) = theta_e * R2D ! Compute spanwise directivity angle phi for the leading edge (it's the same angle for the trailing edge) phi_e = ATAN2 (RLEObserve(1) , RLEObserve(3)) m%SpanAngleLE(K,J,I) = phi_e * R2D ! Compute chordwise directivity angle theta for the leading edge theta_e = ATAN2 ((RLEObserve(3) * COS (phi_e) + RLEObserve(1) * SIN (phi_e) ) , RLEObserve(2)) m%ChordAngleLE(K,J,I) = theta_e * R2D ENDDO !K, observers ENDIF ! every Xth time step or so.. ENDIF ! only if the time step is more than user input value run this part ENDDO !J, blade nodes ENDDO !I , number of blades END SUBROUTINE CalcObserve !----------------------------------------------------------------------------------------------------------------------------------! SUBROUTINE CalcAeroAcousticsOutput(u,p,m,xd,y,errStat,errMsg) TYPE(AA_InputType), INTENT(IN ) :: u !< Inputs at Time t TYPE(AA_OutputType), INTENT(INOUT) :: y !< TYPE(AA_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(AA_MiscVarType), INTENT(INOUT) :: m !< misc/optimization data (not defined in submodules) TYPE(AA_DiscreteStateType), INTENT(IN ) :: xd !< discrete state type integer(IntKi), INTENT( OUT) :: errStat !< Error status of the operation character(*), INTENT( OUT) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables. integer(intKi) :: III !III A generic index for DO loops. integer(intKi) :: I !I A generic index for DO loops. integer(intKi) :: J !J A generic index for DO loops. integer(intKi) :: K,liop,cou ,JTEMP !K A generic index for DO loops. integer(intKi) :: oi !K A generic index for DO loops. REAL(ReKi) :: AlphaNoise ! REAL(ReKi) :: UNoise ! REAL(ReKi) :: elementspan ! REAL(ReKi),DIMENSION(p%NumBlNds) ::tempdel REAL(ReKi),DIMENSION(p%NrObsLoc,p%NumBlNds,p%numBlades) ::OASPLTBLAll REAL(ReKi),DIMENSION(p%NrObsLoc,p%NumBlNds,p%numBlades,size(p%FreqList)) ::ForMaxLoc REAL(ReKi),DIMENSION(size(y%OASPL_Mech,1),size(p%FreqList),p%NrObsLoc,p%NumBlNds,p%numBlades) :: ForMaxLoc3 REAL(ReKi),DIMENSION(size(p%FreqList),p%NrObsLoc,p%numBlades) ::SPL_Out REAL(ReKi),DIMENSION(p%NumBlNds,p%numBlades) ::temp_dispthick REAL(ReKi),DIMENSION(p%NumBlNds,p%numBlades) ::temp_dispthickchord real(ReKi) :: Ptotal real(ReKi) :: PtotalLBL real(ReKi) :: PtotalTBLP real(ReKi) :: PtotalTBLS real(ReKi) :: PtotalSep real(ReKi) :: PtotalTBLAll real(ReKi) :: PtotalBlunt real(ReKi) :: PtotalTip real(ReKi) :: PtotalInflow real(ReKi) :: PLBL real(ReKi) :: PTBLP real(ReKi) :: PTBLS real(ReKi) :: PTBLALH real(ReKi) :: PTip real(ReKi) :: PTI real(ReKi) :: PBLNT,adforma REAL(ReKi),DIMENSION(2) :: Cf ,d99, d_star TYPE(FFT_DataType) :: FFT_Data !< the instance of the FFT module we're using REAL(ReKi),DIMENSION(p%total_sample) :: spect_signal REAL(ReKi),DIMENSION(p%total_sample/2) :: spectra real(ReKi),ALLOCATABLE :: fft_freq(:) integer(intKi) :: ErrStat2 character(ErrMsgLen) :: ErrMsg2 character(*), parameter :: RoutineName = 'CalcAeroAcousticsOutput' logical :: exist ErrStat = ErrID_None ErrMsg = "" !------------------- Fill with zeros -------------------------! DO I = 1,p%numBlades;DO J = 1,p%NumBlNds;DO K = 1,p%NrObsLoc; y%OASPL(k,j,i) = 0.0_Reki DO oi=1,size(y%OASPL_Mech,1) y%OASPL_Mech(oi,k,j,i)= 0.0_Reki ENDDO; ENDDO;ENDDO;ENDDO DO K = 1,p%NrObsLoc; y%DirectiviOutput(K) = 0.0_Reki DO I=1,p%NumBlades;DO III=1,size(p%FreqList); y%SumSpecNoise(III,K,I) = 0.0_Reki ForMaxLoc(K,1:p%NumBlNds,I,III)=0.0_Reki DO oi=1,size(y%OASPL_Mech,1) y%SumSpecNoiseSep(oi,K,III) = 0.0_Reki ForMaxLoc3(oi,III,K,1:p%NumBlNds,I)=0.0_Reki m%SPLLBL(III)=0.0_Reki m%SPLP(III)=0.0_Reki m%SPLS(III)=0.0_Reki m%SPLALPH(III)=0.0_Reki m%SPLBLUNT(III)=0.0_Reki m%SPLTIP(III)=0.0_Reki m%SPLti(III)=0.0_Reki ENDDO ENDDO;ENDDO ENDDO DO K = 1,p%NrObsLoc; DO III = 1,size(p%FreqList); y%PtotalFreq(K,III) = 0.0_ReKi ENDDO ENDDO !------------------- initialize FFT -------------------------! !!!IF (m%speccou .eq. p%total_sample)THEN !!!CALL InitFFT ( p%total_sample, FFT_Data, ErrStat=ErrStat2 ) !!! CALL SetErrStat(ErrStat2, 'Error in InitFFT', ErrStat, ErrMsg, 'CalcAeroAcousticsOutput' ) !!!CALL AllocAry( fft_freq, size(spect_signal)/2-1, 'fft_freq', ErrStat2, ErrMsg2 ) !!! CALL SetErrStat( errStat2, errMsg2, errStat, errMsg, RoutineName ) !!!do liop=1,size(fft_freq) !!! fft_freq(liop)=p%fsample*liop ! fRequncy x axis !!! fft_freq(liop)=fft_freq(liop)/size(spect_signal) !!!enddo !!!ENDIF DO I = 1,p%numBlades DO J = p%startnode,p%NumBlNds ! starts loop from startnode. !------------------------------!!------------------------------!!------------------------------!!------------------------------! !------------------------------!!------------------------------!!------------------------------!!------------------------------! !------------------------------!!------------------------------!!------------------------------!!------------------------------! !--------Calculate Spectrum for dissipation calculation-------------------------! !IF (m%speccou .eq. p%total_sample)THEN !spect_signal=xd%VrelStore( 1:p%total_sample,J,I ) ! CALL ApplyFFT_f( spect_signal, FFT_Data, ErrStat2 ) ! IF (ErrStat2 /= ErrID_None ) THEN ! CALL SetErrStat(ErrStat2, 'Error in ApplyFFT .', ErrStat, ErrMsg, 'CalcAeroAcousticsOutput' ) ! ENDIF !cou=1 !O liop=2,size(spect_signal)-1,2 !cou=cou+1 !spectra(cou) = spect_signal(liop)*spect_signal(liop) + spect_signal(1+liop)*spect_signal(1+liop) !ENDDO !spectra(1)=spect_signal(1)*spect_signal(1) !spectra=spectra/(size(spectra)*2) ! m%speccou=0 !ENDIF Unoise = u%Vrel(J,I) IF (EqualRealNos(Unoise,0.0_ReKi)) then Unoise = 0.1 ! TODO TODO a value consistent with the test above should be used ENDIF IF (J .EQ. p%NumBlNds) THEN elementspan = (p%BlSpn(J,I)-p%BlSpn(J-1,I))/2 ELSE elementspan = (p%BlSpn(J,I)-p%BlSpn(J-1,I))/2 + (p%BlSpn(J+1,I)-p%BlSpn(J,I))/2 ENDIF AlphaNoise= u%AoANoise(J,I) * R2D_D !--------Read in Boundary Layer Data-------------------------! IF (p%X_BLMethod .EQ. 2) THEN call BL_Param_Interp(p,m,Unoise,AlphaNoise,p%BlChord(J,I),p%BlAFID(J,I), errStat2, errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) temp_dispthick(J,I) = m%d99Var(1) m%d99Var = m%d99Var*p%BlChord(J,I) m%dstarVar = m%dstarVar*p%BlChord(J,I) temp_dispthickchord(J,I)=m%d99Var(1) ENDIF !------------------------------!!------------------------------!!------------------------------!!------------------------------! !------------------------------!!------------------------------!!------------------------------!!------------------------------! !------------------------------!!------------------------------!!------------------------------!!------------------------------! DO K = 1,p%NrObsLoc !--------Laminar Boundary Layer Vortex Shedding Noise----------------------------! IF ( (p%ILAM .EQ. 1) .AND. (p%ITRIP .EQ. 0) ) THEN CALL LBLVS(AlphaNoise,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & elementspan,m%rTEtoObserve(K,J,I), & p,m%d99Var(2),m%dstarVar(1),m%dstarVar(2),m%SPLLBL,p%StallStart(J,I),errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF !--------Turbulent Boundary Layer Trailing Edge Noise----------------------------! IF ( (p%ITURB .EQ. 1) .or. (p%ITURB .EQ. 2) ) THEN CALL TBLTE(AlphaNoise,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & elementspan,m%rTEtoObserve(K,J,I), p, j,i,k,m%d99Var(2),m%dstarVar(1),m%dstarVar(2),p%StallStart(J,I), & m%SPLP,m%SPLS,m%SPLALPH,m%SPLTBL,errStat2,errMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (p%ITURB .EQ. 2) THEN m%SPLP=0.0_ReKi;m%SPLS=0.0_ReKi;m%SPLTBL=0.0_ReKi; m%EdgeVelVar(1)=1.000d0;m%EdgeVelVar(2)=m%EdgeVelVar(1); CALL TBLTE_TNO(AlphaNoise,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & elementspan,m%rTEtoObserve(K,J,I),m%CfVar,m%d99var,m%EdgeVelVar ,p, & m%SPLP,m%SPLS,m%SPLALPH,m%SPLTBL,errStat2 ,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF ENDIF !--------Blunt Trailing Edge Noise----------------------------------------------! IF ( p%IBLUNT .EQ. 1 ) THEN CALL BLUNT(AlphaNoise,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & elementspan,m%rTEtoObserve(K,J,I),p%TEThick(J,I),p%TEAngle(J,I), & p, m%d99Var(2),m%dstarVar(1),m%dstarVar(2),m%SPLBLUNT,p%StallStart(J,I),errStat2,errMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF !--------Tip Noise--------------------------------------------------------------! IF ( (p%ITIP .EQ. 1) .AND. (J .EQ. p%NumBlNds) ) THEN CALL TIPNOIS(AlphaNoise,p%ALpRAT,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & m%rTEtoObserve(K,J,I), p, m%SPLTIP,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF !--------Inflow Turbulence Noise ------------------------------------------------! ! important checks to be done inflow tubulence inputs IF (p%IInflow.gt.0) then ! Amiet's Inflow Noise Model is Calculated as long as InflowNoise is On CALL InflowNoise(AlphaNoise,p%BlChord(J,I),Unoise,m%ChordAngleLE(K,J,I),m%SpanAngleLE(K,J,I),& elementspan,m%rLEtoObserve(K,J,I),xd%MeanVxVyVz(J,I),xd%TIVx(J,I),m%LE_Location(3,J,I),0.050,p,m%SPLti,errStat2,errMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ! If Guidati model (simplified or full version) is also on then the 'SPL correction' to Amiet's model will be added IF ( p%IInflow .EQ. 2 ) THEN CALL Simple_Guidati(UNoise,p%BlChord(J,I),p%AFThickGuida(2,p%BlAFID(J,I)), & p%AFThickGuida(1,p%BlAFID(J,I)),p,m%SPLTIGui,errStat2,errMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) m%SPLti=m%SPLti+m%SPLTIGui + 10. ! +10 is fudge factor to match NLR data ELSEIF ( p%IInflow .EQ. 3 ) THEN print*,'Full Guidati removed' STOP ENDIF ENDIF !----------------------------------------------------------------------------------------------------------------------------------! ! ADD IN THIS SEGMENT'S CONTRIBUTION ON A MEAN-SQUARE ! PRESSURE BASIS !----------------------------------------------------------------------------------------------------------------------------------! Ptotal = 0.0_ReKi ! Total Sound Pressure - All (7) mechanisms, All Frequencies PtotalLBL= 0.0_ReKi ! Total Sound Pressure - Laminar Boundary Layer, All Frequencies PtotalTBLP= 0.0_ReKi ! Total Sound Pressure - Turbulent Boundary Layer, Pressure Contribution, All Frequencies PtotalTBLS= 0.0_ReKi ! Total Sound Pressure - Turbulent Boundary Layer, Suction Contribution, All Frequencies PtotalSep= 0.0_ReKi ! Total Sound Pressure - Separation, All Frequencies PtotalTBLAll = 0.0_ReKi ! Total Sound Pressure - Turbulent Boundary Layer, All Frequencies PtotalBlunt= 0.0_ReKi ! Total Sound Pressure - Blunt Trailing Edge, All Frequencies PtotalTip= 0.0_ReKi ! Total Sound Pressure - Tip Noise, All Frequencies PtotalInflow= 0.0_ReKi ! Total Sound Pressure - Turbulent Inflow, All Frequencies PLBL= 0.0_ReKi ! Laminar Boundary Layer - Current Iteration PTBLP= 0.0_ReKi ! Turbulent Boundary Layer, Pressure Contribution - Current Iteration PTBLS= 0.0_ReKi ! Turbulent Boundary Layer, Suction Contribution - Current Iteration PTBLALH= 0.0_ReKi ! Turbulent Boundary Layer, Angle of Attack Contribution - Current Iteration (Feeds into PTotalSep. Consider renaming.) PTip= 0.0_ReKi ! Tip Noise - Current Iteration PTI= 0.0_ReKi ! Turbulent Inflow - Current Iteration PBLNT= 0.0_ReKi ! Blunt Trailing Edge - Current Iteration DO III=1,size(p%FreqList) ! Loops through each 1/3rd octave center frequency ! If flag for LBL is ON and Boundary Layer Trip is OFF, then compute LBL IF ( (p%ILAM .EQ. 1) .AND. (p%ITRIP .EQ. 0) ) THEN IF (p%AweightFlag .eqv. .TRUE.) THEN m%SPLLBL(III) = m%SPLLBL(III) + p%Aweight(III) ! A-weighting ENDIF PLBL = 10.0_ReKi**(m%SPLLBL(III)/10.0_ReKi) ! SPL to Sound Pressure (P) Conversion for III Frequency PtotalLBL = PtotalLBL + PLBL ! Sum of Current LBL with LBL Running Total Ptotal = Ptotal + PLBL ! Sum of Current LBL with Overall Running Total y%PtotalFreq(K,III) = y%PtotalFreq(K,III) + PLBL ! Running sum of observer and frequency dependent sound pressure y%SumSpecNoiseSep(1,K,III) = PLBL + y%SumSpecNoiseSep(1,K,III) ! Assigns Current LBL to Appropriate Mechanism (1), Observer (K), and Frequency (III) ENDIF ! If flag for TBL is ON, compute Pressure, Suction, and AoA contributions IF ( p%ITURB .GT. 0 ) THEN IF (p%AweightFlag .eqv. .TRUE.) THEN m%SPLP(III) = m%SPLP(III) + p%Aweight(III) ! A-weighting m%SPLS(III) = m%SPLS(III) + p%Aweight(III) ! A-weighting m%SPLALPH(III) = m%SPLALPH(III) + p%Aweight(III) ! A-weighting ENDIF PTBLP = 10.0_ReKi**(m%SPLP(III)/10.0_ReKi) ! SPL to P Conversion for III Frequency PTBLS = 10.0_ReKi**(m%SPLS(III)/10.0_ReKi) ! SPL to P Conversion for III Frequency PTBLALH = 10.0_ReKi**(m%SPLALPH(III)/10.0_ReKi) ! SPL to P Conversion for III Frequency PtotalTBLP = PtotalTBLP + PTBLP ! Sum of Current TBLP with TBLP Running Total PtotalTBLS = PtotalTBLS + PTBLS ! Sum of Current TBLS with TBLS Running Total PtotalSep = PtotalSep + PTBLALH ! Sum of Current TBLALH with TBLALH Running Total Ptotal = Ptotal + PTBLP + PTBLS + PTBLALH ! Sum of Current TBL with Overall Running Total y%PtotalFreq(K,III) = y%PtotalFreq(K,III) + PTBLP + PTBLS + PTBLALH ! Running sum of observer and frequency dependent sound pressure PtotalTBLAll = PtotalTBLAll + 10.0_ReKi**(m%SPLTBL(III)/10.0_ReKi) ! SPLTBL from comment on line 1794 is the mean-square sum of SPLP, SPLS, and SPLALPH. ! So this should be equal to PTBLP+PTBLS+TBLALH y%SumSpecNoiseSep(2,K,III) = PTBLP + y%SumSpecNoiseSep(2,K,III) ! Assigns Current TBLP to Appropriate Mechanism (2), Observer (K), and Frequency (III) y%SumSpecNoiseSep(3,K,III) = PTBLS + y%SumSpecNoiseSep(3,K,III) ! Assigns Current TBLS to Appropriate Mechanism (2), Observer (K), and Frequency (III) y%SumSpecNoiseSep(4,K,III) = PTBLALH + y%SumSpecNoiseSep(4,K,III) ! Assigns Current TBLALH to Appropriate Mechanism (2), Observer (K), and Frequency (III) ENDIF ! If flag for Blunt TE is ON, compute Blunt contribution IF ( p%IBLUNT .GT. 0 ) THEN ! NOTE: .EQ. 1 would be more accurate since only options are 0 and 1 IF (p%AweightFlag .eqv. .TRUE.) THEN m%SPLBLUNT(III) = m%SPLBLUNT(III) + p%Aweight(III) ! A-weighting ENDIF PBLNT = 10.0_ReKi**(m%SPLBLUNT(III)/10.0_ReKi) ! SPL to P Conversion for III Frequency PtotalBlunt = PtotalBlunt + PBLNT ! Sum of Current Blunt with Blunt Running Total Ptotal = Ptotal + PBLNT ! Sum of Current Blunt with Overall Running Total y%PtotalFreq(K,III) = y%PtotalFreq(K,III) + PBLNT ! Running sum of observer and frequency dependent sound pressure y%SumSpecNoiseSep(5,K,III) = PBLNT + y%SumSpecNoiseSep(5,K,III) ! Assigns Current Blunt to Appropriate Mechanism (5), Observer (K), and Frequency (III) ENDIF ! If flag for Tip is ON and the current blade node (J) is the last node (tip), compute Tip contribution IF ( (p%ITIP .GT. 0) .AND. (J .EQ. p%NumBlNds) ) THEN ! NOTE: .EQ. 1 would again be more accurate IF (p%AweightFlag .eqv. .TRUE.) THEN m%SPLTIP(III) = m%SPLTIP(III) + p%Aweight(III) ! A-weighting ENDIF PTip = 10.0_ReKi**(m%SPLTIP(III)/10.0_ReKi) ! SPL to P Conversion for III Frequency PtotalTip = PtotalTip + PTip ! Sum of Current Tip with Tip Running Total Ptotal = Ptotal + PTip ! Sum of Current Tip with Overall Running Total y%PtotalFreq(K,III) = y%PtotalFreq(K,III) + PTip ! Running sum of observer and frequency dependent sound pressure y%SumSpecNoiseSep(6,K,III) = PTip + y%SumSpecNoiseSep(6,K,III) ! Assigns Current Tip to Appropriate Mechanism (6), Observer (K), and Frequency (III) ENDIF ! If flag for TI is ON, compute Turbulent Inflow contribution IF ( (p%IInflow .GT. 0) ) THEN IF (p%AweightFlag .eqv. .TRUE.) THEN m%SPLti(III) = m%SPLti(III) + p%Aweight(III) ! A-weighting ENDIF PTI = 10.0_ReKi**(m%SPLti(III)/10.0_ReKi) ! SPL to P Conversion for III Frequency PtotalInflow = PtotalInflow + PTI ! Sum of Current TI with TI Running Total Ptotal = Ptotal + PTI ! Sum of Current TI with Overall Running Total y%PtotalFreq(K,III) = y%PtotalFreq(K,III) + PTI ! Running sum of observer and frequency dependent sound pressure y%SumSpecNoiseSep(7,K,III) = PTI + y%SumSpecNoiseSep(7,K,III) ! Assigns Current TI to Appropriate Mechanism (7), Observer (K), and Frequency (III) ENDIF ENDDO ! III = 1, size(p%FreqList) y%DirectiviOutput(K) = Ptotal + y%DirectiviOutput(K) ! Assigns Overall Pressure to Appropriate Observer for Directivity IF (y%DirectiviOutput(K) .EQ. 0.) y%DirectiviOutput(K) = 1 ! Since these will all be converted via LOG10, they will produce an error if .EQ. 0. ! Set .EQ. to 1 instead (LOG10(1)=0) y%OASPL(K,J,I) = Ptotal + y%OASPL(K,J,I) ! Assigns Overall Pressure to Appropriate Observer/Blade/Node for Directivity ENDDO ! Loop on observers ENDDO ! Loop on blade nodes ENDDO ! Loop on blades ! If any Output file is wanted, convert DirectiviOutput from Directivity Factor to Directivity Index ! Ref: Fundamentals of Acoustics by Colin Hansen (1951) y%DirectiviOutput = 10.*LOG10(y%DirectiviOutput) !! DirectiviOutput is used as total observer OASPL for Output File 1 ! Since these will all be converted via LOG10, they will produce an error if .EQ. 0., Set .EQ. to 1 instead (LOG10(1)=0) DO I = 1,p%numBlades DO J = 1,p%NumBlNds DO K = 1,p%NrObsLoc IF (y%OASPL(K,J,I) .EQ. 0.) y%OASPL(K,J,I) = 1 ENDDO ENDDO ENDDO IF (p%NrOutFile .gt. 0) y%OASPL = 10.*LOG10(y%OASPL) !! OASPL is used as observer/blade/node OASPL for Output File 4 ! Procedure for Output file 2 IF (p%NrOutFile .gt. 1) THEN DO K = 1,p%NrObsLoc DO III=1,size(p%FreqList) IF (y%PtotalFreq(K,III) .EQ. 0.) y%PtotalFreq(K,III) = 1 y%PtotalFreq(K,III) = 10.*LOG10(y%PtotalFreq(K,III)) ! P to SPL conversion ENDDO ENDDO ENDIF ! If 3rd Output file is needed, these will need to be converted via LOG10. Change to equal 1 to avoid error. DO K = 1,p%NrObsLoc DO III = 1,size(p%FreqList) DO oi = 1,7 IF (y%SumSpecNoiseSep(oi,K,III) .EQ. 0.) y%SumSpecNoiseSep(oi,K,III) = 1 ENDDO ENDDO ENDDO ! Procedure for Output file 3 IF (p%NrOutFile .gt. 2) THEN y%SumSpecNoiseSep = 10.*LOG10(y%SumSpecNoiseSep) ! P to SPL Conversion ENDIF END SUBROUTINE CalcAeroAcousticsOutput !==================================================================================================================================! SUBROUTINE LBLVS(ALPSTAR,C,U,THETA,PHI,L,R,p,d99Var2,dstarVar1,dstarVar2,SPLLAM,StallVal,errStat,errMsg) REAL(ReKi), INTENT(IN ) :: ALPSTAR ! AOA REAL(ReKi), INTENT(IN ) :: C ! Chord Length REAL(ReKi), INTENT(IN ) :: U ! Unoise FREESTREAM VELOCITY METERS/SEC REAL(ReKi), INTENT(IN ) :: THETA ! DIRECTIVITY ANGLE DEGREES REAL(ReKi), INTENT(IN ) :: PHI ! DIRECTIVITY ANGLE DEGREES REAL(ReKi), INTENT(IN ) :: L ! SPAN METERS REAL(ReKi), INTENT(IN ) :: R ! OBSERVER DISTANCE FROM SEGMENT METERS REAL(ReKi), INTENT(IN ) :: d99Var2 ! REAL(ReKi), INTENT(IN ) :: dstarVar1 ! REAL(ReKi), INTENT(IN ) :: dstarVar2 ! REAL(ReKi), INTENT(IN ) :: StallVal ! TYPE(AA_ParameterType), INTENT(IN ) :: p ! Noise module Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLLAM ! INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'LBLVS' ! Local variables real(ReKi) :: STPRIM ! STROUHAL NUMBER BASED ON PRESSURE SIDE BOUNDARY LAYER THICKNESS --- real(ReKi) :: M ! MACH NUMBER real(ReKi) :: RC ! REYNOLDS NUMBER BASED ON CHORD real(ReKi) :: DELTAP ! PRESSURE SIDE BOUNDARY LAYER THICKNESS METERS real(ReKi) :: DSTRS ! SUCTION SIDE BOUNDARY LAYER DISPLACEMENT THICKNESS METERS real(ReKi) :: DSTRP ! PRESSURE SIDE BOUNDARY LAYER DISPLACEMENT THICKNESS METERS real(ReKi) :: DBARH ! HIGH FREQUENCY DIRECTIVITY --- real(ReKi) :: ST1PRIM ! REFERENCE STROUHAL NUMBER --- real(ReKi) :: STPKPRM ! PEAK STROUHAL NUMBER --- real(ReKi) :: RC0 ! REFERENCE REYNOLDS NUMBER --- real(ReKi) :: D ! REYNOLDS NUMBER RATIO --- real(ReKi) :: G1 ! SOUND PRESSURE LEVEL FUNCTION DB real(ReKi) :: G2 ! OVERALL SOUND PRESSURE LEVEL FUNCTION DB real(ReKi) :: G3 ! OVERALL SOUND PRESSURE LEVEL FUNCTION DB real(ReKi) :: E ! STROUHAL NUMBER RATIO --- real(ReKi) :: SCALE ! GEOMETRIC SCALING TERM integer(intKi) :: I ! I A generic index for DO loops. ErrStat = ErrID_None ErrMsg = "" !compute reynolds number and mach number M = U / p%SpdSound ! MACH NUMBER RC = U * C/p%KinVisc ! REYNOLDS NUMBER BASED ON CHORD ! compute boundary layer thicknesses IF (p%X_BLMethod .eq. 2) THEN DELTAP = d99Var2 DSTRS = dstarVar1 DSTRP = dstarVar2 ELSE CALL THICK(C,M,RC,ALPSTAR,p,DELTAP,DSTRS,DSTRP,StallVal,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF ! compute directivity function CALL DIRECTH_TE(M,THETA,PHI,DBARH,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (DBARH <= 0) THEN SPLLAM = 0. RETURN ENDIF ! compute reference strouhal number ! Eq 55 from BPM Airfoil Self-noise and Prediction paper IF (RC .LE. 1.3E+05) ST1PRIM = .18 IF((RC .GT. 1.3E+05).AND.(RC.LE.4.0E+05))ST1PRIM=.001756*RC**.3931 IF (RC .GT. 4.0E+05) ST1PRIM = .28 STPKPRM = 10.**(-.04*ALPSTAR) * ST1PRIM ! Eq 56 from BPM Airfoil Self-noise and Prediction paper ! compute reference reynolds number ! Eq 59 from BPM Airfoil Self-noise and Prediction paper IF (ALPSTAR .LE. 3.0) RC0=10.**(.215*ALPSTAR+4.978) IF (ALPSTAR .GT. 3.0) RC0=10.**(.120*ALPSTAR+5.263) ! compute peak scaled spectrum level D = RC / RC0 ! Used in Eq 58 from BPM Airfoil Self-noise and Prediction paper IF (D .LE. .3237) G2 =77.852*LOG10(D)+15.328 ! Begin Eq 58 from BPM Airfoil Self-noise and Prediction paper IF ((D .GT. .3237).AND.(D .LE. .5689)) G2 = 65.188*LOG10(D) + 9.125 IF ((D .GT. .5689).AND.(D .LE. 1.7579)) G2 = -114.052 * LOG10(D)**2. IF ((D .GT. 1.7579).AND.(D .LE. 3.0889)) G2 = -65.188*LOG10(D)+9.125 IF (D .GT. 3.0889) G2 =-77.852*LOG10(D)+15.328 ! end ! compute angle-dependent level for shape curve G3 = 171.04 - 3.03 * ALPSTAR ! Eq 60 from BPM Airfoil Self-noise and Prediction paper SCALE = 10. * LOG10(DELTAP*M**5*DBARH*L/R**2) ! From Eq 53 from BPM Airfoil Self-noise and Prediction paper ! Compute scaled sound pressure levels for each strouhal number DO I=1,SIZE(p%FreqList) STPRIM = p%FreqList(I) * DELTAP / U ! Eq 54 from BPM Airfoil Self-noise and Prediction paper E = STPRIM / STPKPRM ! Used in Eq 57 from BPM Airfoil Self-noise and Prediction paper IF (E .LE. .5974) G1 = 39.8*LOG10(E)-11.12 ! Begin Eq 57 from BPM Airfoil Self-noise and Prediction paper IF ((E .GT. .5974).AND.(E .LE. .8545)) G1 = 98.409 * LOG10(E) + 2.0 IF ((E .GT. .8545).AND.(E .LE. 1.17)) G1 = -5.076+SQRT(2.484-506.25*(LOG10(E))**2.) IF ((E .GT. 1.17).AND.(E .LE. 1.674)) G1 = -98.409 * LOG10(E) + 2.0 IF (E .GT. 1.674) G1 = -39.80*LOG10(E)-11.12 ! end SPLLAM(I) = G1 + G2 + G3 + SCALE ! Eq 53 from BPM Airfoil Self-noise and Prediction paper ENDDO END SUBROUTINE LBLVS !==================================================================================================================================! SUBROUTINE TBLTE(ALPSTAR,C,U,THETA,PHI,L,R,p,jj,ii,kk,d99Var2,dstarVar1,dstarVar2,StallVal,SPLP,SPLS,SPLALPH,SPLTBL,errStat,errMsg) REAL(ReKi), INTENT(IN ) :: ALPSTAR ! AOA(deg) REAL(ReKi), INTENT(IN ) :: C ! Chord Length (m) ! REAL(ReKi), INTENT(IN ) :: U ! Unoise(m/s) ! REAL(ReKi), INTENT(IN ) :: THETA ! DIRECTIVITY ANGLE (deg) ! REAL(ReKi), INTENT(IN ) :: PHI ! DIRECTIVITY ANGLE (deg) REAL(ReKi), INTENT(IN ) :: L ! SPAN(m) REAL(ReKi), INTENT(IN ) :: R ! SOURCE TO OBSERVER DISTANCE (m) ! REAL(ReKi) :: ALPSTAR ! AOA(deg) ! REAL(ReKi) :: C ! Chord Length (m) REAL(ReKi) :: U ! Unoise(m/s) REAL(ReKi) :: THETA ! DIRECTIVITY ANGLE (deg) REAL(ReKi) :: PHI ! DIRECTIVITY ANGLE (deg) ! REAL(ReKi) :: L ! SPAN(m) ! REAL(ReKi) :: R ! SOURCE TO OBSERVER DISTANCE (m) REAL(ReKi), INTENT(IN ) :: d99Var2 ! REAL(ReKi), INTENT(IN ) :: dstarVar1 ! REAL(ReKi), INTENT(IN ) :: dstarVar2 ! REAL(ReKi), INTENT(IN ) :: StallVal ! INTEGER(IntKi), INTENT( IN) :: jj ! Error status of the operation INTEGER(IntKi), INTENT( IN) :: ii ! Error status of the operation INTEGER(IntKi), INTENT( IN) :: kk ! Error status of the operation TYPE(AA_ParameterType), INTENT(IN ) :: p ! Noise Module Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLP ! SOUND PRESSURE LEVEL DUE TO PRESSURE SIDE OF AIRFOIL (db) REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLS ! SOUND PRESSURE LEVEL DUE TO SUCTION SIDE OF AIRFOIL (db) REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLTBL ! TOTAL SOUND PRESSURE LEVEL DUE TO TBLTE MECHANISM (db) REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLALPH ! SOUND PRESSURE LEVEL DUE TO ANGLE OF ATTACK CONTRIBUTION (db) INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'TBLTE' ! Local variables real(ReKi) :: STP ! PRESSURE SIDE STROUHAL NUMBER --- real(ReKi) :: STS ! SUCTION SIDE STROUHAL NUMBER --- real(ReKi) :: DSTRS ! SUCTION SIDE DISPLACEMENT THICKNESS METERS real(ReKi) :: DSTRP ! PRESSURE SIDE DISPLACEMENT THICKNESS METERS real(ReKi) :: RDSTRS ! REYNOLDS NUMBER BASED ON SUCTION SIDE DISPLACEMENT THICKNESS real(ReKi) :: RDSTRP ! REYNOLDS NUMBER BASED ON PRESSURE SIDE DISPLACEMENT THICKNESS real(ReKi) :: ST1 ! PEAK STROUHAL NUMBER --- real(ReKi) :: ST2 ! PEAK STROUHAL NUMBER --- real(ReKi) :: ST1PRIM ! PEAK STROUHAL NUMBER --- real(ReKi) :: A0 ! FUNCTION USED IN 'A' CALCULATION real(ReKi) :: A02 ! FUNCTION USED IN 'A' CALCULATION real(ReKi) :: ARA0 ! INTERPOLATION FACTOR real(ReKi) :: ARA02 ! INTERPOLATION FACTOR real(ReKi) :: B0 ! FUNCTION USED IN 'B' CALCULATION real(ReKi) :: BMINB0 ! MINIMUM 'B' EVALUATED AT B0 DB real(ReKi) :: BMINB ! MINIMUM 'B' EVALUATED AT B DB real(ReKi) :: BMAXB0 ! MAXIMUM 'B' EVALUATED AT B0 DB real(ReKi) :: BMAXB ! MAXIMUM 'B' EVALUATED AT B DB real(ReKi) :: BRB0 ! INTERPOLATION FACTOR DB real(ReKi) :: STPEAK ! PEAK STROUHAL NUMBER --- real(ReKi) :: AMINA ! MINIMUM 'A' CURVE EVALUATED AT STROUHAL NUMBER RATIO DB real(ReKi) :: AMINB ! MINIMUM 'A' CURVE EVALUATED AT B DB real(ReKi) :: AMAXA ! MAXIMUM 'A' CURVE EVALUATED AT STROUHAL NUMBER RATIO (DB) real(ReKi) :: AMAXB ! MAXIMUM 'A' CURVE EVALUATED AT B DB real(ReKi) :: AMINA0 ! MAXIMUM 'B' EVALUATED AT B0 DB real(ReKi) :: AMINA02 ! MINIMUM 'A' CURVE EVALUATED AT A02 DB real(ReKi) :: AMAXA0 ! MAXIMUM 'A' CURVE EVALUATED AT A0 DB real(ReKi) :: AMAXA02 ! MAXIMUM 'A' CURVE EVALUATED AT A02 DB real(ReKi) :: A ! STROUHAL NUMBER RATIO --- real(ReKi) :: B ! STROUHAL NUMBER RATIO --- real(ReKi) :: AA ! 'A' SPECTRUM SHAPE EVALUATED AT STROUHAL NUMBER RATIO DB real(ReKi) :: BB ! 'B' SPECTRUM SHAPE EVALUATED AT STROUHAL NUMBER RATIO DB real(ReKi) :: DELK1 ! CORRECTION TO AMPLITUDE FUNCTION DB real(ReKi) :: GAMMA ! USED IN 'B' COMPUTATION --- real(ReKi) :: BETA ! USED IN 'B' COMPUTATION --- real(ReKi) :: GAMMA0 ! USED IN 'B' COMPUTATION --- real(ReKi) :: BETA0 ! USED IN 'B' COMPUTATION --- real(ReKi) :: K1 ! AMPLITUDE FUNCTION (DB) real(ReKi) :: K2 ! AMPLITUDE FUNCTION (DB) real(ReKi) :: P1 ! PRESSURE SIDE PRESSURE (NT/M2) real(ReKi) :: P2 ! SUCTION SIDE PRESSURE (NT/M2) real(ReKi) :: P4 ! PRESSURE FROM ANGLE OF ATTACK CONTRIBUTION (NT/M2) real(ReKi) :: M ! MACH NUMBER real(ReKi) :: RC ! REYNOLDS NUMBER BASED ON CHORD real(ReKi) :: DELTAP ! PRESSURE SIDE BOUNDARY LAYER THICKNESS METERS real(ReKi) :: XCHECK ! USED TO CHECK FOR ANGLE OF ATTACK CONTRIBUTION real(ReKi) :: DBARH ! HIGH FREQUENCY DIRECTIVITY --- real(ReKi) :: DBARL ! LOW FREQUENCY DIRECTIVITY --- integer(intKi) :: I ! I A generic index for DO loops. LOGICAL :: SWITCH !!LOGICAL FOR COMPUTATION OF ANGLE OF ATTACK CONTRIBUTION ErrStat = ErrID_None ErrMsg = "" ! Compute reynolds number and mach number M = U / p%SpdSound RC = U * C/p%KinVisc ! Compute boundary layer thicknesses IF (p%X_BLMethod .eq. 2) THEN DELTAP = d99Var2 DSTRS = dstarVar1 DSTRP = dstarVar2 ELSE CALL THICK(C,M,RC,ALPSTAR,p,DELTAP,DSTRS,DSTRP,StallVal,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF ! Compute directivity function CALL DIRECTL(M,THETA,PHI,DBARL,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) CALL DIRECTH_TE(M,THETA,PHI,DBARH,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ! IF (DBARH <= 0) THEN ! SPLP = 0. ! SPLS = 0. ! SPLALPH = 0. ! RETURN ! ENDIF ! Calculate the reynolds numbers based on pressure and suction displacement thickness RDSTRS = DSTRS * U / p%KinVisc RDSTRP = DSTRP * U / p%KinVisc ! Determine peak strouhal numbers to be used for 'a' and 'b' curve calculations ST1 = .02 * M ** (-.6) ! Eq 32 from BPM Airfoil Self-noise and Prediction paper ! Eq 34 from BPM Airfoil Self-noise and Prediction paper IF (ALPSTAR .LE. 1.333) ST2 = ST1 IF ((ALPSTAR .GT. 1.333).AND.(ALPSTAR .LE. StallVal)) ST2 = ST1*10.**(.0054*(ALPSTAR-1.333)**2.) IF (ALPSTAR .GT. StallVal) ST2 = 4.72 * ST1 ST1PRIM = (ST1+ST2)/2. ! Eq 33 from BPM Airfoil Self-noise and Prediction paper CALL A0COMP(RC,A0) ! compute -20 dB dropout (returns A0) CALL A0COMP(3.*RC,A02) ! compute -20 dB dropout for AoA > AoA_0 (returns A02) ! Evaluate minimum and maximum 'a' curves at a0 CALL AMIN(A0,AMINA0) CALL AMAX(A0,AMAXA0) CALL AMIN(A02,AMINA02) CALL AMAX(A02,AMAXA02) ! Compute 'a' max/min ratio ! Eq 39 from BPM Airfoil Self-noise and Prediction paper ARA0 = (20. + AMINA0) / (AMINA0 - AMAXA0) ARA02 = (20. + AMINA02)/ (AMINA02- AMAXA02) ! Compute b0 to be used in 'b' curve calculations ! Eq 44 from BPM Airfoil Self-noise and Prediction paper IF (RC .LT. 9.52E+04) B0 = .30 IF ((RC .GE. 9.52E+04).AND.(RC .LT. 8.57E+05)) & B0 = (-4.48E-13)*(RC-8.57E+05)**2. + .56 IF (RC .GE. 8.57E+05) B0 = .56 ! Evaluate minimum and maximum 'b' curves at b0 CALL BMIN(B0,BMINB0) CALL BMAX(B0,BMAXB0) ! Compute 'b' max/min ratio BRB0 = (20. + BMINB0) / (BMINB0 - BMAXB0) ! For each center frequency, compute an 'a' prediction for the pressure side STPEAK = ST1 IF (RC .LT. 2.47E+05) K1 = -4.31 * LOG10(RC) + 156.3 ! Begin Eq 47 from BPM Airfoil Self-noise and Prediction paper IF((RC .GE. 2.47E+05).AND.(RC .LE. 8.0E+05)) K1 = -9.0 * LOG10(RC) + 181.6 IF (RC .GT. 8.0E+05) K1 = 128.5 ! end IF (RDSTRP .LE. 5000.) DELK1 = -ALPSTAR*(5.29-1.43*LOG10(RDSTRP)) ! Begin Eq 48 from BPM Airfoil Self-noise and Prediction paper IF (RDSTRP .GT. 5000.) DELK1 = 0.0 ! end GAMMA = 27.094 * M + 3.31 ! Begin Eq 49 from BPM Airfoil Self-noise and Prediction paper BETA = 72.650 * M + 10.74 GAMMA0 = 23.430 * M + 4.651 BETA0 =-34.190 * M - 13.820 ! end IF (ALPSTAR .LE. (GAMMA0-GAMMA)) K2 = -1000.0 ! Begin Eq 49 from BPM Airfoil Self-noise and Prediction paper IF ((ALPSTAR.GT.(GAMMA0-GAMMA)).AND.(ALPSTAR.LE.(GAMMA0+GAMMA))) & K2=SQRT(BETA**2.-(BETA/GAMMA)**2.*(ALPSTAR-GAMMA0)**2.)+BETA0 IF (ALPSTAR .GT. (GAMMA0+GAMMA)) K2 = -12.0 K2 = K2 + K1 ! end ! Check for 'a' computation for suction side XCHECK = GAMMA0 SWITCH = .FALSE. !older version: ! IF ((ALPSTAR .GE. XCHECK).OR.(ALPSTAR .GT. 12.5))SWITCH=.TRUE. ! newer version IF ((ALPSTAR .GE. XCHECK).OR.(ALPSTAR .GT. StallVal))SWITCH=.TRUE. DO I=1,size(p%FreqList) STP= p%FreqList(I) * DSTRP / U ! Eq 31 from BPM Airfoil Self-noise and Prediction paper A = LOG10( STP / STPEAK ) ! Eq 37 from BPM Airfoil Self-noise and Prediction paper CALL AMIN(A,AMINA) CALL AMAX(A,AMAXA) AA = AMINA + ARA0 * (AMAXA - AMINA) ! Eq 40 from BPM Airfoil Self-noise and Prediction paper SPLP(I)=AA+K1-3.+10.*LOG10(DSTRP*M**5.*DBARH*L/R**2.)+DELK1 ! Eq 25 from BPM Airfoil Self-noise and Prediction paper STS = p%FreqList(I) * DSTRS / U ! Eq 31 from BPM Airfoil Self-noise and Prediction paper IF (.NOT. SWITCH) THEN A = LOG10( STS / ST1PRIM ) CALL AMIN(A,AMINA) CALL AMAX(A,AMAXA) AA = AMINA + ARA0 * (AMAXA - AMINA) SPLS(I) = AA+K1-3.+10.*LOG10(DSTRS*M**5.*DBARH* L/R**2.) ! Eq 26 from BPM Airfoil Self-noise and Prediction paper ! 'B' CURVE COMPUTATION ! B = ABS(LOG10(STS / ST2)) B = LOG10(STS / ST2) ! abs not needed absolute taken in the AMAX,AMIN ! Eq 43 from BPM Airfoil Self-noise and Prediction paper CALL BMIN(B,BMINB) CALL BMAX(B,BMAXB) BB = BMINB + BRB0 * (BMAXB-BMINB) ! Eq 46 from BPM Airfoil Self-noise and Prediction paper SPLALPH(I)=BB+K2+10.*LOG10(DSTRS*M**5.*DBARH*L/R**2.) ! Eq 27 from BPM Airfoil Self-noise and Prediction paper ELSE ! The 'a' computation is dropped if 'switch' is true SPLS(I) = 10.*LOG10(DSTRS*M**5.*DBARL*L/R**2.) ! SPLP(I) = 0.0 + 10.*LOG10(DSTRS*M**5.*DBARL*L/R**2.) ! changed the line below because the SPLP should be calculatd with DSTRP not with DSTRS SPLP(I) = 10.*LOG10(DSTRP*M**5.*DBARL*L/R**2.) ! this is correct ! B = ABS(LOG10(STS / ST2)) B = LOG10(STS / ST2) ! abs not needed absolute taken in the AMAX,AMIN CALL AMIN(B,AMINB) CALL AMAX(B,AMAXB) BB = AMINB + ARA02 * (AMAXB-AMINB) SPLALPH(I)=BB+K2+10.*LOG10(DSTRS*M**5.*DBARL*L/R**2.) ENDIF ! Sum all contributions from 'a' and 'b' on both pressure and suction side on a mean-square pressure basis IF (SPLP(I) .LT. -100.) SPLP(I) = -100. ! Similar to Eq 28 of BPM Airfoil Self-noise and Prediction paper IF (SPLS(I) .LT. -100.) SPLS(I) = -100. ! Similar to Eq 29 of BPM Airfoil Self-noise and Prediction paper IF (SPLALPH(I) .LT. -100.) SPLALPH(I) = -100. ! Eq 30 of BPM Airfoil Self-noise and Prediction paper recommends SPLALPH = 10log(stuff) + A' + K2, where A' is calculated same as A but with x3 Rc P1 = 10.**(SPLP(I) / 10.) ! SPL_Pressure P2 = 10.**(SPLS(I) / 10.) ! SPL_Suction P4 = 10.**(SPLALPH(I) / 10.) ! SPL_AoA SPLTBL(I) = 10. * LOG10(P1 + P2 + P4) ! Eq 24 from BPM Airfoil Self-noise and Prediction paper ENDDO END SUBROUTINE TBLTE !==================================================================================================================================! SUBROUTINE TIPNOIS(ALPHTIP,ALPRAT2,C,U ,THETA,PHI, R,p,SPLTIP, errStat, errMsg) REAL(ReKi), INTENT(IN ) :: ALPHTIP !< AOA REAL(ReKi), INTENT(IN ) :: ALPRAT2 !< TIP LIFT CURVE SLOPE --- REAL(ReKi), INTENT(IN ) :: C !< Chord Length REAL(ReKi), INTENT(IN ) :: U !< FREESTREAM VELOCITY METERS/SEC REAL(ReKi), INTENT(IN ) :: THETA !< DIRECTIVITY ANGLE DEGREES REAL(ReKi), INTENT(IN ) :: PHI !< DIRECTIVITY ANGLE DEGREES REAL(ReKi), INTENT(IN ) :: R !< SOURCE TO OBSERVER DISTANCE METERS TYPE(AA_ParameterType) , INTENT(IN ) :: p !< Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLTIP !< INTEGER(IntKi), INTENT( OUT) :: errStat !< Error status of the operation character(*), INTENT( OUT) :: errMsg !< Error message if ErrStat /= ErrID_None ! local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'tipnoise' REAL(ReKi) :: M ! MACH NUMBER --- REAL(ReKi) :: MM ! MAXIMUM MACH NUMBER --- REAL(ReKi) :: ALPTIPP ! CORRECTED TIP ANGLE OF ATTACK DEGREES REAL(ReKi) :: DBARH ! DIRECTIVITY --- REAL(ReKi) :: SCALE ! SCALING TERM --- REAL(ReKi) :: STPP ! STROUHAL NUMBER --- REAL(ReKi) :: UM ! MAXIMUM VELOCITY METERS/SEC REAL(ReKi) :: L ! CHARACTERISTIC LENGTH FOR TIP METERS REAL(ReKi) :: TERM ! SCALING TERM --- integer(intKi) :: I !I A generic index for DO loops. ErrStat = ErrID_None ErrMsg = "" IF (alphtip.eq.0.) THEN SPLTIP= 0 RETURN ELSEIF (alphtip.lt.0.) THEN ! alphtip = ABS (alphtip) ! (EB_DTU) NOT possible to change inten(in) variable, INSTEAD ! ALPTIPP is equal to abs(alphtip) - see next equation ENDIF !! used to be ALPTIPP = ALPHTIP * ALPRAT2 ALPTIPP = ABS(ALPHTIP) * ALPRAT2 M = U / p%SpdSound ! MACH NUMBER ! Compute directivity function CALL DIRECTH_TE(M,THETA,PHI,DBARH,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (p%ROUND) THEN L = .008 * ALPTIPP * C ! Eq 63 from BPM Airfoil Self-noise and Prediction paper ELSE IF (ABS(ALPTIPP) .LE. 2.) THEN ! not sure where this comes from L = (.023 + .0169*ALPTIPP) * C ELSE L = (.0378 + .0095*ALPTIPP) * C ENDIF ENDIF MM = (1. + .036*ALPTIPP) * M ! Eq 64 from BPM Airfoil Self-noise and Prediction paper UM = MM * p%SpdSound ! Eq 65 from BPM Airfoil Self-noise and Prediction paper TERM = M*M*MM**3.*L**2.*DBARH/R**2. ! TERM = M^2 * M_max^5 *l^2 *D / r^2 according to Semi-Empirical Aeroacoustic Noise Prediction Code for Wind Turbines paper ! Term is correct according to Eq 61 from BPM Airfoil self-noise and Prediction paper IF (TERM .NE. 0.0) THEN SCALE = 10.*LOG10(TERM) ELSE SCALE = 0.0 ENDIF DO I=1,size(p%FreqList) STPP = p%FreqList(I) * L / UM ! Eq 62 from BPM Airfoil Self-noise and Prediction paper SPLTIP(I) = 126.-30.5*(LOG10(STPP)+.3)**2. + SCALE ! Eq 61 from BPM Airfoil Self-noise and Prediction paper ENDDO END SUBROUTINE TipNois !==================================================================================================================================! SUBROUTINE InflowNoise(AlphaNoise,Chord,U,THETA,PHI,d,RObs,MeanVNoise,TINoise,LE_Location,dissip,p,SPLti,errStat,errMsg) ! REAL(ReKi), INTENT(IN ) :: AlphaNoise ! AOA ! REAL(ReKi), INTENT(IN ) :: Chord ! Chord Length ! REAL(ReKi), INTENT(IN ) :: U ! ! REAL(ReKi), INTENT(IN ) :: d ! element span ! REAL(ReKi), INTENT(IN ) :: RObs ! distance to observer ! REAL(ReKi), INTENT(IN ) :: THETA ! ! REAL(ReKi), INTENT(IN ) :: PHI ! Spanwise directivity angle ! REAL(ReKi), INTENT(IN ) :: MeanVNoise ! ! REAL(ReKi), INTENT(IN ) :: TINoise ! ! REAL(ReKi), INTENT(IN ) :: LE_Location ! REAL(ReKi) :: AlphaNoise ! AOA REAL(ReKi) :: Chord ! Chord Length REAL(ReKi) :: U ! REAL(ReKi) :: d ! element span REAL(ReKi) :: RObs ! distance to observer REAL(ReKi) :: THETA ! REAL(ReKi) :: PHI ! Spanwise directivity angle REAL(ReKi) :: MeanVNoise ! REAL(ReKi) :: TINoise ! REAL(ReKi) :: LE_Location ! REAL(ReKi), INTENT(IN ) :: dissip ! TYPE(AA_ParameterType), INTENT(IN ) :: p ! Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLti ! INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'InflowNoise' ! local variables REAL(ReKi) :: Beta2 ! Prandtl-Glauert correction factor REAL(ReKi) :: DBARH ! High-frequency directivity correction factor REAL(ReKi) :: DBARL ! Low-frequency directivity correction factor REAL(ReKi) :: Directivity ! Directivity correction factor REAL(ReKi) :: Frequency_cutoff ! Cutoff frequency between REAL(ReKi) :: LFC ! low-frequency correction factor REAL(ReKi) :: Mach ! local mach number REAL(ReKi) :: Sears ! Sears function REAL(ReKi) :: SPLhigh ! predicted high frequency sound pressure level REAL(ReKi) :: Ums ! mean square turbulence level REAL(ReKi) :: WaveNumber ! wave number - non-dimensional frequency REAL(ReKi) :: Kbar ! nafnoise REAL(ReKi) :: khat,Kh ! nafnoise REAL(ReKi) :: ke ! nafnoise REAL(ReKi) :: alpstar ! nafnoise REAL(ReKi) :: mu ! nafnoise REAL(ReKi) :: tinooisess ! nafnoise ! REAL(ReKi) :: L_Gammas ! nafnoise INTEGER(intKi) :: I !I A generic index for DO loops. ErrStat = ErrID_None ErrMsg = "" !!!--- NAF NOISE IDENTICAL Mach = U/p%SpdSound ! This part is recently added for height and surface roughness dependent estimation of turbulence intensity and turbulence scales !%Lturb=300*(Z/300)^(0.46+0.074*log(p%z0_aa)); !% Gives larger length scale ! Lturb=25.d0*LE_Location**(0.35)*p%z0_aa**(-0.063) !% Gives smaller length scale ! Wei Jun Zhu, Modeling of Aerodynamically generated Noise From Wind Turbines ! L_Gammas=0.24+0.096*log10(p%z0_aa)+0.016*(log10(p%z0_aa))**2; !% Can be computed or just give it a value. ! Wei Jun Zhu, Modeling of Aerodynamically generated Noise From Wind Turbines !tinooisess=L_Gammas*log(30.d0/p%z0_aa)/log(LE_Location/p%z0_aa) !% F.E. 16% is 0.16 which is the correct input for SPLhIgh, no need to divide 100 ! ! Wei Jun Zhu, Modeling of Aerodynamically generated Noise From Wind Turbines tinooisess=TINoise !tinooisess=0.1 !Ums = (tinooisess*U)**2 !Ums = (tinooisess*8)**2 CALL DIRECTL(Mach,THETA,PHI,DBARL,errStat2,errMsg2) ! assume that noise is low-freq in nature because turbulence length scale is large CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) CALL DIRECTH_LE(Mach,THETA,PHI,DBARH,errStat2,errMsg2) ! Directivity for the leading edge at high frequencies CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (DBARH <= 0) THEN SPLti = 0. RETURN ENDIF ! In the following lines, bibliography will be referenced as: a) Moriarty, Guidati, Migliore, Recent Improvement of a Semi-Empirical Aeroacoustic ! Prediction Code for Wind Turbines ! ref b) Lowson, Assessment and Prediction of Wind Turbine Noise !*********************************************** Model 1: !!! Nafnoise source code version see below Frequency_cutoff = 10*U/PI/Chord Ke = 3.0/(4.0*p%Lturb) Beta2 = 1-Mach*Mach ALPSTAR = AlphaNoise*PI/180. DO I=1,size(p%FreqList) IF (p%FreqList(I) <= Frequency_cutoff) THEN Directivity = DBARL ELSE Directivity = DBARH ENDIF WaveNumber = 2.0*PI*p%FreqList(I)/U Kbar = WaveNumber*Chord/2.0 Khat = WaveNumber/Ke ! mu = Mach*WaveNumber*Chord/2.0/Beta2 SPLhigh = 10.*LOG10(p%AirDens*p%AirDens*p%SpdSound**4*p%Lturb*(d/2.)/ & (RObs*RObs)*(Mach**5)*tinooisess*tinooisess*(Khat**3)* & (1+Khat**2)**(-7./3.)*Directivity) + 78.4 ! ref a) !!! SPLhigh = 10.*LOG10(p%Lturb*(d/2.)/ & !!! (RObs*RObs)*(Mach**5)*tinooisess*tinooisess*(WaveNumber**3) & !!! *(1+WaveNumber**2)**(-7./3.)*Directivity) + 181.3 SPLhigh = SPLhigh + 10.*LOG10(1+ 9.0*ALPSTAR*ALPSTAR) ! Component due to angles of attack, ref a) Sears = 1/(2.*PI*Kbar/Beta2+1/(1+2.4*Kbar/Beta2)) ! ref a) !!! Sears = 1/(2.*PI*WaveNumber/Beta2+1/(1+2.4*WaveNumber/Beta2)) ! ref b) LFC = 10*Sears*Mach*Kbar*Kbar/Beta2 ! ref a) !!! LFC = 10*Sears*Mach*WaveNumber*WaveNumber/Beta2 ! ref b) !!! IF (mu<(PI/4.0)) THEN ! ref b) !!! SPLti(I) = SPLhigh + 10.*ALOG10(LFC) ! ref b) !!! ELSE ! ref b) !!! SPLti(I) = SPLhigh ! ref b) !!!ENDIF SPLti(I) = SPLhigh + 10.*LOG10(LFC/(1+LFC)) ENDDO !!!*********************************************** end of Model 1 ! ! ********************************* Model 2: ! !Wei Jun Zhu et al - !Modeling of Aerodynamically Generated Noise From Wind Turbines 2005 paper ! Beta2 = 1.d0-Mach**2; ! corresponding line: Bsq = 1.d0 - Ma**2; ! DO I=1,size(p%FreqList) ! WaveNumber = PI*p%FreqList(I)*p%SpdSound/U !corresponding line: K = pi*Freq(i)*c/Vrel; ! CarloS: This is a Mistake, c in this case is the Local Chord ! Sears = (2.d0*PI*WaveNumber/Beta2 + (1.d0+2.4d0*WaveNumber/Beta2)**(-1))**(-1); ! ! corresponding line: Ssq = (2.d0*pi*K/Bsq + (1.d0+2.4d0*K/Bsq)**(-1))**(-1); ! LFC = 10.d0 * Sears*Mach*WaveNumber**2*Beta2**(-1); ! ! corresponding line: LFC = 10.d0 * Ssq*Ma*K**2*Bsq**(-1); ! SPLti(I)=(p%AirDens*p%AirDens*p%SpdSound*p%SpdSound*p%Lturb*d)/(2*RObs*RObs) ! ! SPLti(I)=SPLti(I)*(Mach**3)*(MeanVnoise**2)*(tinooisess**2) ! SPLti(I)=SPLti(I)*(Mach**3)*(tinooisess**2) ! ! SPLti(I)=SPLti(I)*(Mach**3)*ufluct**2 ! SPLti(I)=(SPLti(I)*(WaveNumber**3)) / ((1+WaveNumber**2)**(7/3)) ! SPLti(I)=SPLti(I)*DBARH ! SPLti(I)=10*log10(SPLti(I))+58.4 ! SPLti(I) = SPLti(I) + 10.*LOG10(LFC/(1+LFC)) ! ! SPLti(I)=10.d0*log10(DBARH*p%AirDens**2*p%SpdSound**2*p%Lturb*d/2.0*Mach**3*tinooisess**2* & ! !WaveNumber**3*(1.d0+WaveNumber**2)**(-7.d0/3.d0)/RObs**2)+58.4d0 + 10.d0*log10(LFC/(1+LFC)) ! ! corresponding line: SPLti(i)=10.d0*log10(Di_hi_fr*Density**2*co**2*Tbscale*L/2.0*Ma ! ! & **3*Tbinten**2*K**3*(1.d0+K**2)**(-7.d0/3.d0)/Distance**2)+58.4d0 ! ! & + 10.d0*log10(LFC/(1+LFC)); ! ! !% ver2.! ! ! Kh = 8.d0*pi*p%FreqList(i)*p%Lturb/(3.d0*U); ! ! SPLti(i) = 10*log10(DBARH*p%Lturb*0.5*d*Mach**5*tinooisess**2*Kh**3*(1+Kh**2)**(-7/3)/RObs**2) +& ! ! 10*log10(10**18.13) + 10*log10(DBARH*LFC/(1+LFC)); ! ! ENDDO ! ! ********************************* End of Model 2/ CarloSucameli: I think this model is wrong !!!! ! ********************************* Model 3: !!!! ! ref b) Lowson, Assessment and Prediction of Wind Turbine Noise !!!! Beta2 = 1.d0-Mach**2; ! corresponding line: Bsq = 1.d0 - Ma**2; !!!! DO I=1,size(p%FreqList) !!!! WaveNumber = PI*p%FreqList(I)*Chord/U !corresponding line: K = pi*Freq(i)*c/Vrel; !!!! Sears = (2.d0*PI*WaveNumber/Beta2 + (1.d0+2.4d0*WaveNumber/Beta2)**(-1))**(-1); !!!! ! corresponding line: Ssq = (2.d0*pi*K/Bsq + (1.d0+2.4d0*K/Bsq)**(-1))**(-1); !!!! LFC = 10.d0 * Sears*Mach*WaveNumber**2*Beta2**(-1); !!!! ! corresponding line: LFC = 10.d0 * Ssq*Ma*K**2*Bsq**(-1); !!!! SPLti(I)=(p%AirDens*p%AirDens*p%SpdSound*p%SpdSound*p%Lturb*d)/(2*RObs*RObs) !!!! SPLti(I)=SPLti(I)*(Mach**3)*(MeanVnoise**2)*(tinooisess**2) !!!! SPLti(I)=(SPLti(I)*(WaveNumber**3)) / ((1+WaveNumber**2)**(7./3.)) !!!! SPLti(I)=SPLti(I)*DBARH !!!! SPLti(I)=10*log10(SPLti(I))+58.4 !!!! SPLti(I) = SPLti(I) + 10.*LOG10(LFC/(1+LFC)) !!!! !!!! !!!! ENDDO !!!! ! ********************************* End of Model 3 !!Buck&Oerlamans&Palo - !Experimental validation of a wind turbine turbulent inflow noise prediction code 2016 paper !DO I=1,size(p%FreqList) ! IF (p%FreqList(I) <= Frequency_cutoff) THEN ! Directivity = DBARL ! ELSE ! Directivity = DBARH ! ENDIF ! WaveNumber = 2.0*PI*p%FreqList(I)/U ! (K) ! Kbar = WaveNumber*Chord/2.0 ! Khat = WaveNumber/Ke ! SPLhigh = ( (p%AirDens**2) * (p%SpdSound**2) *d ) / (2*RObs*RObs) ! SPLhigh = SPLhigh * (Mach**3) * (dissip**(2/3)) * (WaveNumber**(-5/3)) * Directivity ! SPLhigh = 10.*LOG10(SPLhigh) + 77.6 ! Sears = 1/(2.*PI*Kbar/Beta2+1/(1+2.4*Kbar/Beta2)) ! LFC = 10*Sears*(1+9.0*ALPSTAR*ALPSTAR)*Mach*Kbar*Kbar/Beta2 ! SPLti(I) = SPLhigh + 10.*LOG10(LFC/(1+LFC)) !ENDDO ! double commented lines are from FAST v4.0 aeroacoustics module. But Nafnoise version is used see above !! Mach = U/p%SpdSound !! !!IF (TINoise > 0) THEN !! Ums = (TINoise*MeanVNoise/100.)**2 ! mean square turbulence level !!ELSE !! SPLti = 0. !! RETURN !!ENDIF !! !! LTurb=60 !! LTurb=0.06 !!! temporarily commented !!! IF (FASTHH < 30.0) THEN !!! LTurb = 3.5*0.7*FASTHH ! Prediction sensitive to this parameter! !!! ELSE !!! LTurb = 3.5*21. !!! ENDIF !! !!!LTurb = LTurb/100 !! !!! Calculate directivity...? !!!!! ---------------------------- !! CALL DIRECTL(Mach,THETA,PHI,DBARL,errStat2,errMsg2) !yes, assume that noise is low-freq in nature because turbulence length scale is large !! CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) !! CALL DIRECTH_LE(Mach,THETA,PHI,DBARH,errStat2,errMsg2) !! CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) !! IF (DBARH <= 0) THEN !! SPLti = 0. !! RETURN !! ENDIF !! !! Frequency_cutoff = 10*U/PI/Chord !! !! IF (DBARL <= 0.) THEN !! SPLti = 0. !! RETURN !! ENDIF !! !!DO I=1,size(p%FreqList) !! IF (p%FreqList(I) <= Frequency_cutoff) THEN !! Directivity = DBARL !! ELSE !! Directivity = DBARH !! ENDIF !! WaveNumber = PI*p%FreqList(I)*Chord/U !! Beta2 = 1-Mach*Mach !! SPLhigh = 10.*LOG10(p%AirDens*p%AirDens*p%SpdSound*p%SpdSound*p%Lturb*(d/2.)/(RObs*RObs)*(Mach**3)*Ums* & !! (WaveNumber**3)*(1+WaveNumber**2)**(-7./3.)*Directivity) + 58.4 !! Sears = 1/(2*PI*WaveNumber/Beta2+1/(1+2.4*WaveNumber/Beta2)) !! LFC = 10*Sears*Mach*WaveNumber*WaveNumber/Beta2 !! SPLti(I) = SPLhigh + 10.*LOG10(LFC/(1+LFC)) !! !!ENDDO END SUBROUTINE InflowNoise !==================================================================================================== SUBROUTINE BLUNT(ALPSTAR,C,U ,THETA,PHI,L,R,H,PSI,p,d99Var2,dstarVar1,dstarVar2,SPLBLUNT,StallVal,errStat,errMsg) REAL(ReKi), INTENT(IN ) :: ALPSTAR ! AOA REAL(ReKi), INTENT(IN ) :: C ! Chord Length REAL(ReKi), INTENT(IN ) :: U ! Unoise REAL(ReKi), INTENT(IN ) :: THETA ! DIRECTIVITY ANGLE --- REAL(ReKi), INTENT(IN ) :: PHI ! DIRECTIVITY ANGLE --- REAL(ReKi), INTENT(IN ) :: L ! SPAN METERS REAL(ReKi), INTENT(IN ) :: R ! SOURCE TO OBSERVER DISTANCE METERS REAL(ReKi), INTENT(IN ) :: H ! TRAILING EDGE BLUNTNESS METERS REAL(ReKi), INTENT(IN ) :: PSI ! TRAILING EDGE ANGLE DEGREES REAL(ReKi), INTENT(IN ) :: d99Var2 ! REAL(ReKi), INTENT(IN ) :: dstarVar1 ! REAL(ReKi), INTENT(IN ) :: dstarVar2 ! REAL(ReKi), INTENT(IN ) :: StallVal !< Stall angle at station i TYPE(AA_ParameterType), INTENT(IN ) :: p ! Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLBLUNT ! INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None ! Local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'BLUNT' real(ReKi) :: STPPP ! STROUHAL NUMBER --- real(ReKi) :: M ! MACH NUMBER --- real(ReKi) :: RC ! REYNOLDS NUMBER BASED ON CHORD --- integer(intKi) :: I ! I A generic index for DO loops. real(ReKi) :: DELTAP ! PRESSURE SIDE BOUNDARY LAYER THICKNESS METERS real(ReKi) :: DSTRS ! SUCTION SIDE DISPLACEMENT THICKNESS METERS real(ReKi) :: DSTRP ! PRESSURE SIDE DISPLACEMENT THICKNESS METERS real(ReKi) :: DBARH ! HIGH FREQUENCY DIRECTIVITY --- real(ReKi) :: DSTRAVG ! AVERAGE DISPLACEMENT THICKNESS METERS real(ReKi) :: HDSTAR ! BLUNTNESS OVER AVERAGE DISPLACEMENT THICKNESS --- real(ReKi) :: DSTARH ! AVERAGE DISPLACEMENT THICKNESS OVER TRAILING EDGE BLUNTNESS --- real(ReKi) :: ATERM ! USED TO COMPUTE PEAK STROUHAL NO. --- real(ReKi) :: STPEAK ! PEAK STROUHAL NUMBER --- real(ReKi) :: ETA ! RATIO OF STROUHAL NUMBERS --- real(ReKi) :: HDSTARL ! MINIMUM ALLOWED VALUE OF HDSTAR --- real(ReKi) :: G514 ! G5 EVALUATED AT PSI=14.0 DB real(ReKi) :: HDSTARP ! MODIFIED VALUE OF HDSTAR --- real(ReKi) :: G50 ! G5 EVALUATED AT PSI=0.0 DB real(ReKi) :: G4 ! SCALED SPECTRUM LEVEL DB ! real(ReKi) :: G5 ! SPECTRUM SHAPE FUNCTION DB REAL(ReKi),DIMENSION(size(p%FreqList)) :: G5 ! SPECTRUM SHAPE FUNCTION DB ! corrected (EB_DTU) real(ReKi) :: G5Sum ! SPECTRUM SHAPE FUNCTION DB real(ReKi) :: F4TEMP ! G5 EVALUATED AT MINIMUM HDSTARP DB real(ReKi) :: SCALE ! SCALING FACTOR --- ErrStat = ErrID_None ErrMsg = "" ! Reynolds number and mach number M = U / p%SpdSound RC = U * C/p%KinVisc ! Compute boundary layer thicknesses IF (p%X_BLMethod .eq. 2) THEN DELTAP = d99Var2 DSTRS = dstarVar1 DSTRP = dstarVar2 ELSE CALL THICK(C,M,RC,ALPSTAR,p,DELTAP,DSTRS,DSTRP,StallVal,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) ENDIF ! Compute average displacement thickness DSTRAVG = (DSTRS + DSTRP) / 2. HDSTAR = H / DSTRAVG DSTARH = 1. /HDSTAR ! Compute directivity function CALL DIRECTH_TE(M,THETA,PHI,DBARH,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (DBARH <= 0) THEN SPLBLUNT = 0. RETURN ENDIF ! Compute peak strouhal number eq 72 in BPM Airfoil Self-noise and Prediction paper ATERM = .212 - .0045 * PSI IF (HDSTAR .GE. .2) & STPEAK = ATERM / (1.+.235*DSTARH-.0132*DSTARH**2.) ! this is what it used to be in nafnoise and fast noise module !! STPEAK = ATERM / (1+0.235*(DSTARH)**(-1)-0.0132*DSTARH**(-2)) ! check if this one is correct (EB_DTU) IF (HDSTAR .LT. .2) & STPEAK = .1 * HDSTAR + .095 - .00243 * PSI ! Compute scaled spectrum level eq 74 of BPM Airfoil Self-noise and Prediction paper IF (HDSTAR .LE. 5.) G4=17.5*LOG10(HDSTAR)+157.5-1.114*PSI IF (HDSTAR .GT. 5.) G4=169.7 - 1.114 * PSI ! For each frequency, compute spectrum shape referenced to 0 db SCALE = 10. * LOG10(M**5.5*H*DBARH*L/R**2.) G5Sum=0.0_Reki DO I=1,SIZE(p%FreqList) STPPP = p%FreqList(I) * H / U ETA = LOG10(STPPP/STPEAK) HDSTARL = HDSTAR CALL G5COMP(HDSTARL,ETA,G514,errStat2,errMsg2 ) ! compute G5 for Phi=14deg CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) HDSTARP = 6.724 * HDSTAR **2.-4.019*HDSTAR+1.107 ! eq 82 from BPM Airfoil Self-noise and Prediction paper CALL G5COMP(HDSTARP,ETA,G50,errStat2,errMsg2 ) ! recompute G5 for Phi=0deg CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) G5(I) = G50 + .0714 * PSI * (G514-G50) ! interpolate G5 from G50 and G514 IF (G5(I) .GT. 0.) G5(I) = 0. G5Sum = 10**(G5(I)/10)+G5Sum ! to be subtracted SPLBLUNT(I) = G4 + G5(I) + SCALE - 10*log10(1/G5Sum) ! equation mentioned there is plus but it is stated subtract, thus ''- 10*log10(1/G5Sum)'' end do END SUBROUTINE Blunt !==================================================================================================== SUBROUTINE G5COMP(HDSTAR,ETA,G5,errStat,errMsg) REAL(ReKi), INTENT(IN ) :: HDSTAR !< REAL(ReKi), INTENT(IN ) :: ETA !< REAL(ReKi), INTENT( OUT) :: G5 !< INTEGER(IntKi), INTENT( OUT) :: errStat !< Error status of the operation CHARACTER(*), INTENT( OUT) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables INTEGER(intKi) :: ErrStat2 ! temporary Error status CHARACTER(ErrMsgLen) :: ErrMsg2 ! temporary Error message CHARACTER(*), parameter :: RoutineName = 'BLUNT' real(ReKi) :: K real(ReKi) :: M real(ReKi) :: MU real(ReKi) :: ETALIMIT real(ReKi) :: ETA0 ErrStat = ErrID_None ErrMsg = "" IF ( HDSTAR .LT. .25) MU = .1211 ! begin eq 78 from BPM Airfoil Self-noise and Prediction paper IF ((HDSTAR .GT. .25).AND.(HDSTAR .LE. .62)) MU =-.2175*HDSTAR + .1755 IF ((HDSTAR .GT. .62).AND.(HDSTAR .LT. 1.15)) MU =-.0308*HDSTAR + .0596 IF ( HDSTAR .GE. 1.15) MU = .0242 ! end IF ( HDSTAR .LE. .02 ) M = 0.0 ! begin eq 79 from BPM Airfoil Self-noise and Prediction paper IF ((HDSTAR .GE. .02 ).AND.(HDSTAR .LT. .5)) M = 68.724*HDSTAR - 1.35 IF ((HDSTAR .GT. .5 ).AND.(HDSTAR .LE. .62)) M = 308.475*HDSTAR - 121.23 IF ((HDSTAR .GT. .62 ).AND.(HDSTAR .LE. 1.15)) M = 224.811*HDSTAR - 69.354 IF ((HDSTAR .GT. 1.15).AND.(HDSTAR .LT. 1.2)) M = 1583.28*HDSTAR - 1631.592 IF ( HDSTAR .GT. 1.2 ) M = 268.344 IF ( M .LT. 0.0 ) M = 0.0 ! end ETA0 = -SQRT((M*M*MU**4)/(6.25+M*M*MU*MU)) ! eq 80 from BPM Airfoil Self-noise and Prediction paper K = 2.5*SQRT(1.-(ETA0/MU)**2.)-2.5-M*ETA0 ! eq 81 from BPM Airfoil Self-noise and Prediction paper ETALIMIT = 0.03615995 ! one of the bounds given in eq 76 of BPM Airfoil Self-noise and Prediction paper IF (ETA .LE. ETA0) G5 = M * ETA + K ! begin eq 76 from BPM Airfoil Self-noise and Prediction paper IF((ETA.GT.ETA0).AND.(ETA .LE. 0.)) G5 = 2.5*SQRT(1.-(ETA/MU)**2.)-2.5 IF((ETA.GT.0. ).AND.(ETA.LE.ETALIMIT)) G5 = SQRT(1.5625-1194.99*ETA**2.)-1.25 IF (ETA.GT.ETALIMIT) G5 = -155.543 * ETA + 4.375 ! end END SUBROUTINE G5Comp !==================================================================================================== !> This subroutine defines the curve fit corresponding to the a-curve for the minimum allowed reynolds number. SUBROUTINE AMIN(A,AMINA) REAL(ReKi), INTENT(IN ) :: A REAL(ReKi), INTENT(OUT ) :: AMINA REAL(ReKi) :: X1 X1 = ABS(A) IF (X1 .LE. .204) AMINA=SQRT(67.552-886.788*X1**2.)-8.219 IF((X1 .GT. .204).AND.(X1 .LE. .244))AMINA=-32.665*X1+3.981 IF (X1 .GT. .244)AMINA=-142.795*X1**3.+103.656*X1**2.-57.757*X1+6.006 END SUBROUTINE AMIN !==================================================================================================== !> This subroutine defines the curve fit corresponding to the a-curve for the maximum allowed reynolds number. SUBROUTINE AMAX(A,AMAXA) REAL(ReKi), INTENT(IN ) :: A REAL(ReKi), INTENT(OUT ) :: AMAXA REAL(ReKi) :: X1 X1 = ABS(A) IF (X1 .LE. .13)AMAXA=SQRT(67.552-886.788*X1**2.)-8.219 IF((X1 .GT. .13).AND.(X1 .LE. .321))AMAXA=-15.901*X1+1.098 IF (X1 .GT. .321)AMAXA=-4.669*X1**3.+3.491*X1**2.-16.699*X1+1.149 END SUBROUTINE AMAX !==================================================================================================== !> This subroutine defines the curve fit corresponding to the b-curve for the minimum allowed reynolds number. SUBROUTINE BMIN(B,BMINB) REAL(ReKi), INTENT(IN ) :: B REAL(ReKi), INTENT(OUT ) :: BMINB REAL(ReKi) :: X1 X1 = ABS(B) IF (X1 .LE. .13)BMINB=SQRT(16.888-886.788*X1**2.)-4.109 IF((X1 .GT. .13).AND.(X1 .LE. .145))BMINB=-83.607*X1+8.138 IF (X1.GT..145)BMINB=-817.81*X1**3.+355.21*X1**2.-135.024*X1+10.619 END SUBROUTINE BMin !==================================================================================================== !> Define the curve fit corresponding to the b-curve for the maximum allowed reynolds number. SUBROUTINE BMAX(B,BMAXB) REAL(ReKi), INTENT(IN ) :: B REAL(ReKi), INTENT(OUT ) :: BMAXB REAL(ReKi) :: X1 X1 = ABS(B) IF (X1 .LE. .1) BMAXB=SQRT(16.888-886.788*X1**2.)-4.109 IF((X1 .GT. .1).AND.(X1 .LE. .187))BMAXB=-31.313*X1+1.854 IF (X1.GT..187)BMAXB=-80.541*X1**3.+44.174*X1**2.-39.381*X1+2.344 END SUBROUTINE BMax !==================================================================================================== !> Determine where the a-curve takes on a value of -20 db. SUBROUTINE A0COMP(RC,A0) REAL(ReKi), INTENT(IN ) :: RC REAL(ReKi), INTENT(OUT ) :: A0 IF (RC .LT. 9.52E+04) A0 = .57 IF ((RC .GE. 9.52E+04).AND.(RC .LT. 8.57E+05)) & A0 = (-9.57E-13)*(RC-8.57E+05)**2. + 1.13 IF (RC .GE. 8.57E+05) A0 = 1.13 END SUBROUTINE A0COMP !==================================================================================================== !> Compute zero angle of attack boundary layer thickness (meters) and reynolds number SUBROUTINE THICK(C,M,RC,ALPSTAR,p,DELTAP,DSTRS,DSTRP,StallVal,errStat,errMsg) !! VARIABLE NAME DEFINITION UNITS !! ------------- ---------- ----- !! ALPSTAR ANGLE OF ATTACK DEGREES !! C CHORD LENGTH METERS !! C0 SPEED OF SOUND METERS/SEC !! DELTA0 BOUNDARY LAYER THICKNESS AT !! ZERO ANGLE OF ATTACK METERS !! DELTAP PRESSURE SIDE BOUNDARY LAYER !! THICKNESS METERS !! DSTR0 DISPLACEMENT THICKNESS AT ZERO !! ANGLE OF ATTACK METERS !! DSTRP PRESSURE SIDE DISPLACEMENT !! THICKNESS METERS !! DSTRS SUCTION SIDE DISPLACEMENT !! THICKNESS METERS !! ITRIP TRIGGER FOR BOUNDARY LAYER TRIPPING --- !! M MACH NUMBER --- !! RC REYNOLDS NUMBER BASED ON CHORD --- !! U FREESTREAM VELOCITY METERS/SEC !! KinViscosity KINEMATIC VISCOSITY M2/SEC REAL(ReKi), INTENT(IN ) :: ALPSTAR !< AOA REAL(ReKi), INTENT(IN ) :: C !< Chord Length REAL(ReKi), INTENT(IN ) :: RC !< RC= U*C/KinViscosity REAL(ReKi), INTENT(IN ) :: M !< M = U/C0 TYPE(AA_ParameterType), INTENT(IN ) :: p !< Parameters REAL(ReKi), INTENT( OUT) :: DELTAP !< REAL(ReKi), INTENT( OUT) :: DSTRS !< REAL(ReKi), INTENT( OUT) :: DSTRP !< REAL(ReKi), INTENT(IN ) :: StallVal !< Stall angle at station i INTEGER(IntKi), INTENT( OUT) :: errStat !< Error status of the operation character(*), INTENT( OUT) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'Thick' real(ReKi) :: DELTA0 ! BOUNDARY LAYER THICKNESS AT ZERO ANGLE OF ATTACK METERS real(ReKi) :: DSTR0 ! DISPLACEMENT THICKNESS AT ZERO ANGLE OF ATTACK METERS ErrStat = ErrID_None ErrMsg = "" ! DELTA0 = 10.**(1.6569-.9045*LOG10(RC)+.0596*LOG10(RC)**2.)*C IF (p%ITRIP .GT. 0) DELTA0 = 10.**(1.892-0.9045*LOG(RC)+0.0596*LOG(RC)**2.)*C IF (p%ITRIP .EQ. 2) DELTA0=.6*DELTA0 ! Pressure side boundary layer thickness DELTAP = 10.**(-.04175*ALPSTAR+.00106*ALPSTAR**2.)*DELTA0 ! Compute zero angle of attack displacement thickness IF ((p%ITRIP .EQ. 1) .OR. (p%ITRIP .EQ. 2)) THEN IF (RC .LE. .3E+06) DSTR0 = .0601 * RC **(-.114)*C IF (RC .GT. .3E+06) & DSTR0=10.**(3.411-1.5397*LOG10(RC)+.1059*LOG10(RC)**2.)*C IF (p%ITRIP .EQ. 2) DSTR0 = DSTR0 * .6 ELSE DSTR0=10.**(3.0187-1.5397*LOG10(RC)+.1059*LOG10(RC)**2.)*C ENDIF ! Pressure side displacement thickness DSTRP = 10.**(-.0432*ALPSTAR+.00113*ALPSTAR**2.)*DSTR0 ! IF (p%ITRIP .EQ. 3) DSTRP = DSTRP * 1.48 ! commented since itrip is never 3 check if meant 2.(EB_DTU) ! Suction side displacement thickness IF (p%ITRIP .EQ. 1) THEN IF (ALPSTAR .LE. 5.) DSTRS=10.**(.0679*ALPSTAR)*DSTR0 IF((ALPSTAR .GT. 5.).AND.(ALPSTAR .LE. StallVal)) & DSTRS = .381*10.**(.1516*ALPSTAR)*DSTR0 IF (ALPSTAR .GT. StallVal)DSTRS=14.296*10.**(.0258*ALPSTAR)*DSTR0 ELSE IF (ALPSTAR .LE. 7.5)DSTRS =10.**(.0679*ALPSTAR)*DSTR0 IF((ALPSTAR .GT. 7.5).AND.(ALPSTAR .LE. StallVal)) & DSTRS = .0162*10.**(.3066*ALPSTAR)*DSTR0 IF (ALPSTAR .GT. StallVal) DSTRS = 52.42*10.**(.0258*ALPSTAR)*DSTR0 ENDIF END SUBROUTINE Thick !==================================================================================================== !> This subroutine computes the high frequency directivity function for the trailing edge SUBROUTINE DIRECTH_TE(M,THETA,PHI,DBAR, errStat, errMsg) REAL(ReKi), INTENT(IN ) :: THETA ! REAL(ReKi), INTENT(IN ) :: PHI ! REAL(ReKi), INTENT(IN ) :: M ! REAL(ReKi), INTENT( OUT) :: DBAR ! INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None ! Local variables character(*), parameter :: RoutineName = 'Directh_te' real(ReKi) :: MC real(ReKi) :: DEGRAD real(ReKi) :: PHIR real(ReKi) :: THETAR ErrStat = ErrID_None ErrMsg = "" DEGRAD = .017453 MC = .8 * M THETAR = THETA * DEGRAD PHIR = PHI * DEGRAD DBAR = 2.*SIN(THETAR/2.)**2.*SIN(PHIR)**2./((1.+M*COS(THETAR))* (1.+(M-MC)*COS(THETAR))**2.) ! eq B1 in BPM Airfoil Self-noise and Prediction paper END SUBROUTINE DIRECTH_TE !==================================================================================================== !> This subroutine computes the high frequency directivity function for the leading edge SUBROUTINE DIRECTH_LE(M,THETA,PHI,DBAR, errStat, errMsg) REAL(ReKi), INTENT(IN ) :: THETA ! REAL(ReKi), INTENT(IN ) :: PHI ! REAL(ReKi), INTENT(IN ) :: M ! REAL(ReKi), INTENT( OUT) :: DBAR ! INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None ! Local variables character(*), parameter :: RoutineName = 'Directh_le' real(ReKi) :: DEGRAD real(ReKi) :: PHIR real(ReKi) :: THETAR ErrStat = ErrID_None ErrMsg = "" DEGRAD = .017453 THETAR = THETA * DEGRAD PHIR = PHI * DEGRAD DBAR = 2.*COS(THETAR/2.)**2.*SIN(PHIR)**2./(1.+M*COS(THETAR))**3. END SUBROUTINE DIRECTH_LE !==================================================================================================== !> This subroutine computes the high frequency directivity function for the input observer location ! Paper: SUBROUTINE DIRECTL(M,THETA,PHI,DBAR, errStat, errMsg) REAL(ReKi), INTENT(IN ) :: THETA !< REAL(ReKi), INTENT(IN ) :: PHI !< REAL(ReKi), INTENT(IN ) :: M !< REAL(ReKi), INTENT( OUT) :: DBAR !< INTEGER(IntKi), INTENT( OUT) :: errStat !< Error status of the operation character(*), INTENT( OUT) :: errMsg !< Error message if ErrStat /= ErrID_None ! Local variables character(*), parameter :: RoutineName = 'DirectL' real(ReKi) :: MC real(ReKi) :: DEGRAD real(ReKi) :: PHIR real(ReKi) :: THETAR ErrStat = ErrID_None ErrMsg = "" ! This subroutine computes the low frequency directivity function for the input observer location DEGRAD = .017453 MC = .8 * M THETAR = THETA * DEGRAD PHIR = PHI * DEGRAD DBAR = (SIN(THETAR)*SIN(PHIR))**2/(1.+M*COS(THETAR))**4 ! eq B2 in BPM Airfoil Self-noise and Prediction paper END SUBROUTINE DIRECTL !==================================================================================================================================! !=============================== Simplified Guidati Inflow Turbulence Noise Addition =============================================! !==================================================================================================================================! ! Uses simple correction for turbulent inflow noise from Moriarty et. al 2005 ! Paper: Prediction of Turbulent Inflow and Trailing-Edge Noise for Wind Turbines, by Moriarty, Guidati, and Migliore SUBROUTINE Simple_Guidati(U,Chord,thick_10p,thick_1p,p,SPLti,errStat,errMsg) REAL(ReKi), INTENT(IN ) :: U ! Vrel REAL(ReKi), INTENT(IN ) :: Chord ! Chord Length REAL(ReKi), INTENT(IN ) :: thick_10p ! REAL(ReKi), INTENT(IN ) :: thick_1p ! TYPE(AA_ParameterType), INTENT(IN ) :: p ! Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLti ! INTEGER(IntKi), INTENT( OUT) :: errStat ! Error status of the operation character(*), INTENT( OUT) :: errMsg ! Error message if ErrStat /= ErrID_None ! local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'Simple_Guidati' INTEGER(intKi) :: loop1 ! temporary REAL(ReKi) :: TI_Param ! Temporary variable thickness ratio dependent REAL(ReKi) :: slope ! Temporary variable thickness ratio dependent ErrStat = ErrID_None ErrMsg = "" TI_Param = thick_1p + thick_10p ! Eq 2 slope = 1.123*TI_Param + 5.317*TI_Param*TI_Param ! Eq 3 do loop1 =1,size(p%FreqList) SPLti(loop1) = -slope*(2*PI*p%FreqList(loop1)*chord/U + 5.0d0) ! Eq 4 enddo ! Outputs Delta_SPL, the difference in SPL between the airfoil and a flat plate. END SUBROUTINE Simple_Guidati !==================================================================================================================================! !================================ Turbulent Boundary Layer Trailing Edge Noise ====================================================! !=================================================== TNO START ====================================================================! SUBROUTINE TBLTE_TNO(ALPSTAR,C,U,THETA,PHI,D,R,Cfall,d99all,EdgeVelAll,p,SPLP,SPLS,SPLALPH,SPLTBL,errStat,errMsgn) USE TNO, only: SPL_integrate REAL(ReKi), INTENT(IN ) :: ALPSTAR !< AOA (deg) REAL(ReKi), INTENT(IN ) :: C !< Chord Length (m) REAL(ReKi), INTENT(IN ) :: U !< Unoise (m/s) REAL(ReKi), INTENT(IN ) :: THETA !< DIRECTIVITY ANGLE (deg) REAL(ReKi), INTENT(IN ) :: PHI !< DIRECTIVITY ANGLE (deg) REAL(ReKi), INTENT(IN ) :: D !< SPAN (m) REAL(ReKi), INTENT(IN ) :: R !< SOURCE TO OBSERVER DISTANCE (m) REAL(ReKi),DIMENSION(2), INTENT(IN ) :: Cfall !< Skin friction coefficient (-) REAL(ReKi),DIMENSION(2), INTENT(IN ) :: d99all !< REAL(ReKi),DIMENSION(2), INTENT(IN ) :: EdgeVelAll !< TYPE(AA_ParameterType), INTENT(IN ) :: p !< Noise Module Parameters REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT(IN ) :: SPLALPH !< SOUND PRESSURE LEVEL DUE TO ANGLE OF ATTACK CONTRIBUTION (db) REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLP !< SOUND PRESSURE LEVEL DUE TO PRESSURE SIDE OF AIRFOIL (db) REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLS !< SOUND PRESSURE LEVEL DUE TO SUCTION SIDE OF AIRFOIL (db) REAL(ReKi),DIMENSION(size(p%FreqList)), INTENT( OUT) :: SPLTBL !< TOTAL SOUND PRESSURE LEVEL DUE TO TBLTE MECHANISM (db) INTEGER(IntKi), INTENT( OUT) :: errStat !< Error status of the operation character(*), INTENT( OUT) :: errMsgn !< Error message if ErrStat /= ErrID_None ! Local variables integer(intKi) :: ErrStat2 ! temporary Error status character(ErrMsgLen) :: ErrMsg2 ! temporary Error message character(*), parameter :: RoutineName = 'TBLTE_TNO' REAL(ReKi) :: answer REAL(ReKi) :: Spectrum REAL(ReKi) :: freq(size(p%FreqList)) REAL(ReKi) :: SPL_press,SPL_suction REAL(ReKi) :: band_width,band_ratio REAL(ReKi) :: DBARH REAL(ReKi) :: P1,P2,P4 INTEGER (4) :: n_freq INTEGER (4) :: i_omega ! Variables passed to integration routine real(ReKi) :: int_limits(2) !< Lower and upper integration limits real(ReKi) :: Mach !< Mach number real(ReKi) :: omega ! Init n_freq = size(p%FreqList) freq = p%FreqList ErrStat = ErrID_None ErrMsgn = "" ! Body of TNO band_ratio = 2.**(1./3.) ! Mach number Mach = U / p%SpdSound ! Directivity function CALL DIRECTH_TE(REAL(Mach),THETA,PHI,DBARH,errStat2,errMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsgn, RoutineName ) do i_omega = 1,n_freq omega = 2.*pi*freq(i_omega) !integration limits int_limits(1) = 0.0e0 int_limits(2) = 10*omega/(Mach*p%SpdSound) ! Convert to third octave band_width = freq(i_omega)*(sqrt(band_ratio)-1./sqrt(band_ratio)) * 4. * pi IF (Cfall(1) .GT. 0.) THEN answer = SPL_integrate(omega=omega,limits=int_limits,ISSUCTION=.true., & Mach=Mach,SpdSound=p%SpdSound,AirDens=p%AirDens,KinVisc=p%KinVisc, & Cfall=Cfall,d99all=d99all,EdgeVelAll=EdgeVelAll) Spectrum = D/(4.*pi*R**2.)*answer SPL_suction = 10.*log10(Spectrum*DBARH/2.e-5/2.e-5) SPLS(i_omega) = SPL_suction + 10.*log10(band_width) ENDIF IF (Cfall(2) .GT. 0.) THEN answer = SPL_integrate(omega=omega,limits=int_limits,ISSUCTION=.FALSE., & Mach=Mach,SpdSound=p%SpdSound,AirDens=p%AirDens,KinVisc=p%KinVisc, & Cfall=Cfall,d99all=d99all,EdgeVelAll=EdgeVelAll) Spectrum = D/(4.*pi*R**2.)*answer SPL_press = 10.*log10(Spectrum*DBARH/2.e-5/2.e-5) SPLP(i_omega) = SPL_press + 10.*log10(band_width) ENDIF ! Sum the noise sources SPLALPH is BPM value IF (SPLP(i_omega) .LT. -100.) SPLP(i_omega) = -100. IF (SPLS(i_omega) .LT. -100.) SPLS(i_omega) = -100. P1 = 10.**(SPLP(i_omega) / 10.) P2 = 10.**(SPLS(i_omega) / 10.) P4 = 10.**(SPLALPH(i_omega) / 10.) SPLTBL(i_omega) = 10. * LOG10(P1 + P2 + P4) enddo END SUBROUTINE TBLTE_TNO !==================================================================================================== SUBROUTINE BL_Param_Interp(p,m,U,AlphaNoise,C,whichairfoil, errStat, errMsg) TYPE(AA_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(AA_MiscVarType), INTENT(INOUT) :: m !< misc/optimization data (not defined in submodules) REAL(ReKi), INTENT(IN ) :: U !< METERS/SEC REAL(ReKi), INTENT(IN ) :: AlphaNoise !< Angle of Attack DEG REAL(ReKi), INTENT(IN ) :: C !< Chord METERS integer(intKi), INTENT(IN ) :: whichairfoil !< whichairfoil integer(IntKi), intent( out) :: ErrStat !< Error status of the operation character(*), intent( out) :: ErrMsg !< Error message if ErrStat /= ErrID_None character(*), parameter :: RoutineName = 'BL_Param_Interp' REAL(ReKi) :: redif1,redif2,aoadif1,aoadif2,xx1,xx2,RC INTEGER(intKi) :: loop1,loop2 logical :: re_flag ErrStat = ErrID_None ErrMsg = "" !!!! this if is not used but if necessary two sets of tables can be populated for tripped and untripped cases RC = U * C/p%KinVisc ! REYNOLDS NUMBER BASED ON CHORD re_flag = .FALSE. DO loop1=1,size(p%ReListBL)-1 IF ( (RC.le.p%ReListBL(loop1+1)) .and. (RC.gt.p%ReListBL(loop1)) ) then re_flag = .TRUE. redif1=abs(RC-p%ReListBL(loop1+1)) redif2=abs(RC-p%ReListBL(loop1)) DO loop2=1,size(p%AOAListBL)-1 if ( (AlphaNoise.le.p%AOAListBL(loop2+1)) .and. (AlphaNoise.gt.p%AOAListBL(loop2)) ) then aoadif1=abs(AlphaNoise-p%AOAListBL(loop2+1)) aoadif2=abs(AlphaNoise-p%AOAListBL(loop2)) xx1=( p%dstarall1(loop2,loop1+1,whichairfoil)*redif2+p%dstarall1(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%dstarall1(loop2+1,loop1+1,whichairfoil)*redif2+p%dstarall1(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%dstarVar(1)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%dstarall2(loop2,loop1+1,whichairfoil)*redif2+p%dstarall2(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%dstarall2(loop2+1,loop1+1,whichairfoil)*redif2+p%dstarall2(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%dstarVar(2)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%d99all1(loop2,loop1+1,whichairfoil)*redif2+p%d99all1(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%d99all1(loop2+1,loop1+1,whichairfoil)*redif2+p%d99all1(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%d99Var(1)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%d99all2(loop2,loop1+1,whichairfoil)*redif2+p%d99all2(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%d99all2(loop2+1,loop1+1,whichairfoil)*redif2+p%d99all2(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%d99Var(2)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%Cfall1(loop2,loop1+1,whichairfoil)*redif2+p%Cfall1(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%Cfall1(loop2+1,loop1+1,whichairfoil)*redif2+p%Cfall1(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%CfVar(1)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%Cfall2(loop2,loop1+1,whichairfoil)*redif2+p%Cfall2(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%Cfall2(loop2+1,loop1+1,whichairfoil)*redif2+p%Cfall2(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%CfVar(2)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%EdgeVelRat1(loop2,loop1+1,whichairfoil)*redif2+p%EdgeVelRat1(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%EdgeVelRat1(loop2+1,loop1+1,whichairfoil)*redif2+p%EdgeVelRat1(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%EdgeVelVar(1)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) xx1=( p%EdgeVelRat2(loop2,loop1+1,whichairfoil)*redif2+p%EdgeVelRat2(loop2,loop1,whichairfoil)*redif1 ) / (redif1+redif2) xx2=( p%EdgeVelRat2(loop2+1,loop1+1,whichairfoil)*redif2+p%EdgeVelRat2(loop2+1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%EdgeVelVar(2)=(xx1*aoadif1+xx2*aoadif2) / (aoadif1+aoadif2) return ! We exit the routine ! endif if (loop2 .eq. (size(p%AOAListBL)-1) ) then if (AlphaNoise .gt. p%AOAListBL(size(p%AOAListBL))) then print*, 'Warning AeroAcoustics Module - Angle of attack (AoA) range is not in the range provided by the user' print*, 'Station ',whichairfoil print*, 'Airfoil AoA ',AlphaNoise,' Using the closest AoA ',p%AOAListBL(loop2+1) m%dStarVar (1) = ( p%dstarall1 (loop2+1,loop1+1,whichairfoil)*redif2 + p%dstarall1 (loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%dStarVar (2) = ( p%dstarall2 (loop2+1,loop1+1,whichairfoil)*redif2 + p%dstarall2 (loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%d99Var (1) = ( p%d99all1 (loop2+1,loop1+1,whichairfoil)*redif2 + p%d99all1 (loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%d99Var (2) = ( p%d99all2 (loop2+1,loop1+1,whichairfoil)*redif2 + p%d99all2 (loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%CfVar (1) = ( p%Cfall1 (loop2+1,loop1+1,whichairfoil)*redif2 + p%Cfall1 (loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%CfVar (2) = ( p%Cfall2 (loop2+1,loop1+1,whichairfoil)*redif2 + p%Cfall2 (loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%EdgeVelVar(1) = ( p%EdgeVelRat1(loop2+1,loop1+1,whichairfoil)*redif2 + p%EdgeVelRat1(loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) m%EdgeVelVar(2) = ( p%EdgeVelRat2(loop2+1,loop1+1,whichairfoil)*redif2 + p%EdgeVelRat2(loop2+1,loop1,whichairfoil)*redif1 )/(redif1+redif2) elseif (AlphaNoise .lt. p%AOAListBL(1)) then print*, 'Warning AeroAcoustics Module - Angle of attack (AoA) range is not in the range provided by the user' print*, 'Station ',whichairfoil print*, 'Airfoil AoA ',AlphaNoise,' Using the closest AoA ',p%AOAListBL(1) m%dStarVar(1) = ( p%dstarall1 (1,loop1+1,whichairfoil)*redif2 + p%dstarall1 (1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%dStarVar(2) = ( p%dstarall2 (1,loop1+1,whichairfoil)*redif2 + p%dstarall2 (1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%d99Var(1) = ( p%d99all1 (1,loop1+1,whichairfoil)*redif2 + p%d99all1 (1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%d99Var(2) = ( p%d99all2 (1,loop1+1,whichairfoil)*redif2 + p%d99all2 (1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%CfVar(1) = ( p%Cfall1 (1,loop1+1,whichairfoil)*redif2 + p%Cfall1 (1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%CfVar(2) = ( p%Cfall2 (1,loop1+1,whichairfoil)*redif2 + p%Cfall2 (1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%EdgeVelVar(1) = ( p%EdgeVelRat1(1,loop1+1,whichairfoil)*redif2 + p%EdgeVelRat1(1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) m%EdgeVelVar(2) = ( p%EdgeVelRat2(1,loop1+1,whichairfoil)*redif2 + p%EdgeVelRat2(1,loop1,whichairfoil)*redif1 ) / (redif1+redif2) endif endif enddo endif enddo if (.not. re_flag) then call SetErrStat( ErrID_Fatal, 'Warning AeroAcoustics Module - the Reynolds number is not in the range provided by the user. Code stopping.', ErrStat, ErrMsg, RoutineName ) stop endif END SUBROUTINE BL_Param_Interp SUBROUTINE Aero_Tests() !--------Laminar Boundary Layer Vortex Shedding Noise----------------------------! !CALL LBLVS(AlphaNoise,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & ! elementspan,m%rTEtoObserve(K,J,I), & ! p,m%d99Var(2),m%dstarVar(1),m%dstarVar(2),m%SPLLBL,ErrStat2,errMsg2) !--------Turbulent Boundary Layer Trailing Edge Noise----------------------------! !CALL TBLTE(3.0d0,0.22860d0,63.920d0,90.0d0,90.0d0,0.5090d0,1.220d0, & ! p, m%d99Var(2),m%dstarVar(1),m%dstarVar(2),p%StallStart(J,I),m%SPLP,m%SPLS,m%SPLALPH,m%SPLTBL,ErrStat2,errMsg2 ) !m%SPLP=0.0_ReKi;m%SPLS=0.0_ReKi;m%SPLTBL=0.0_ReKi; !m%EdgeVelVar(1)=1.000d0;m%EdgeVelVar(2)=m%EdgeVelVar(1); !m%CfVar(1) = 0.0003785760d0;m%CfVar(2) = 0.001984380d0;m%d99var(1)= 0.01105860d0; m%d99var(2)= 0.007465830d0;m%EdgeVelVar(1)=1.000d0;m%EdgeVelVar(2)=m%EdgeVelVar(1); !CALL TBLTE_TNO(3.0_Reki,0.22860_Reki,63.9200_Reki,90.00_Reki,90.0_Reki,0.5090_Reki,1.220_Reki, & ! m%CfVar,m%d99var,m%EdgeVelVar, p, m%SPLP,m%SPLS,m%SPLALPH,m%SPLTBL,ErrStat2 ,errMsg2) !--------Blunt Trailing Edge Noise----------------------------------------------! !CALL BLUNT(3.0d0,0.22860d0,63.920d0,90.0d0,90.0d0,0.5090d0,1.220d0,& ! p%TEThick(J,I),p%TEAngle(J,I),p, m%d99Var(2),m%dstarVar(1),m%dstarVar(2),m%SPLBLUNT,ErrStat2,errMsg2 ) !--------Tip Noise--------------------------------------------------------------! !CALL TIPNOIS(AlphaNoise,p%ALpRAT,p%BlChord(J,I),UNoise,m%ChordAngleTE(K,J,I),m%SpanAngleTE(K,J,I), & ! m%rTEtoObserve(K,J,I), p, m%SPLTIP,ErrStat2,errMsg2) !--------Inflow Turbulence Noise ------------------------------------------------! !CALL InflowNoise(3.0d0,0.22860d0,63.920d0,90.0d0,90.0d0,0.5090d0,1.220d0, & ! xd%MeanVrel(J,I),0.050d0,0.050d0,p,m%SPLti,ErrStat2,errMsg2 ) !CALL FullGuidati(3.0d0,63.920d0,0.22860d0,0.5090d0,1.220d0,90.0d0,90.0d0,xd%MeanVrel(J,I),xd%TIVrel(J,I), & ! p,p%BlAFID(J,I),m%SPLTIGui,ErrStat2 ) !CALL Simple_Guidati(UNoise,0.22860d0,0.120d0,0.020d0,p,m%SPLTIGui,ErrStat2,errMsg2 ) END SUBROUTINE END MODULE AeroAcoustics
apache-2.0
sonnyhu/scipy
scipy/integrate/quadpack/dqk51.f
145
9707
subroutine dqk51(f,a,b,result,abserr,resabs,resasc) c***begin prologue dqk51 c***date written 800101 (yymmdd) c***revision date 830518 (yymmdd) c***category no. h2a1a2 c***keywords 51-point gauss-kronrod rules c***author piessens,robert,appl. math. & progr. div. - k.u.leuven c de doncker,elise,appl. math & progr. div. - k.u.leuven c***purpose to compute i = integral of f over (a,b) with error c estimate c j = integral of abs(f) over (a,b) c***description c c integration rules c standard fortran subroutine c double precision version c c parameters c on entry c f - double precision c function subroutine defining the integrand c function f(x). the actual name for f needs to be c declared e x t e r n a l in the calling program. c c a - double precision c lower limit of integration c c b - double precision c upper limit of integration c c on return c result - double precision c approximation to the integral i c result is computed by applying the 51-point c kronrod rule (resk) obtained by optimal addition c of abscissae to the 25-point gauss rule (resg). c c abserr - double precision c estimate of the modulus of the absolute error, c which should not exceed abs(i-result) c c resabs - double precision c approximation to the integral j c c resasc - double precision c approximation to the integral of abs(f-i/(b-a)) c over (a,b) c c***references (none) c***routines called d1mach c***end prologue dqk51 c double precision a,absc,abserr,b,centr,dabs,dhlgth,dmax1,dmin1, * d1mach,epmach,f,fc,fsum,fval1,fval2,fv1,fv2,hlgth,resabs,resasc, * resg,resk,reskh,result,uflow,wg,wgk,xgk integer j,jtw,jtwm1 external f c dimension fv1(25),fv2(25),xgk(26),wgk(26),wg(13) c c the abscissae and weights are given for the interval (-1,1). c because of symmetry only the positive abscissae and their c corresponding weights are given. c c xgk - abscissae of the 51-point kronrod rule c xgk(2), xgk(4), ... abscissae of the 25-point c gauss rule c xgk(1), xgk(3), ... abscissae which are optimally c added to the 25-point gauss rule c c wgk - weights of the 51-point kronrod rule c c wg - weights of the 25-point gauss rule c c c gauss quadrature weights and kronron quadrature abscissae and weights c as evaluated with 80 decimal digit arithmetic by l. w. fullerton, c bell labs, nov. 1981. c data wg ( 1) / 0.0113937985 0102628794 7902964113 235 d0 / data wg ( 2) / 0.0263549866 1503213726 1901815295 299 d0 / data wg ( 3) / 0.0409391567 0130631265 5623487711 646 d0 / data wg ( 4) / 0.0549046959 7583519192 5936891540 473 d0 / data wg ( 5) / 0.0680383338 1235691720 7187185656 708 d0 / data wg ( 6) / 0.0801407003 3500101801 3234959669 111 d0 / data wg ( 7) / 0.0910282619 8296364981 1497220702 892 d0 / data wg ( 8) / 0.1005359490 6705064420 2206890392 686 d0 / data wg ( 9) / 0.1085196244 7426365311 6093957050 117 d0 / data wg ( 10) / 0.1148582591 4571164833 9325545869 556 d0 / data wg ( 11) / 0.1194557635 3578477222 8178126512 901 d0 / data wg ( 12) / 0.1222424429 9031004168 8959518945 852 d0 / data wg ( 13) / 0.1231760537 2671545120 3902873079 050 d0 / c data xgk ( 1) / 0.9992621049 9260983419 3457486540 341 d0 / data xgk ( 2) / 0.9955569697 9049809790 8784946893 902 d0 / data xgk ( 3) / 0.9880357945 3407724763 7331014577 406 d0 / data xgk ( 4) / 0.9766639214 5951751149 8315386479 594 d0 / data xgk ( 5) / 0.9616149864 2584251241 8130033660 167 d0 / data xgk ( 6) / 0.9429745712 2897433941 4011169658 471 d0 / data xgk ( 7) / 0.9207471152 8170156174 6346084546 331 d0 / data xgk ( 8) / 0.8949919978 7827536885 1042006782 805 d0 / data xgk ( 9) / 0.8658470652 9327559544 8996969588 340 d0 / data xgk ( 10) / 0.8334426287 6083400142 1021108693 570 d0 / data xgk ( 11) / 0.7978737979 9850005941 0410904994 307 d0 / data xgk ( 12) / 0.7592592630 3735763057 7282865204 361 d0 / data xgk ( 13) / 0.7177664068 1308438818 6654079773 298 d0 / data xgk ( 14) / 0.6735663684 7346836448 5120633247 622 d0 / data xgk ( 15) / 0.6268100990 1031741278 8122681624 518 d0 / data xgk ( 16) / 0.5776629302 4122296772 3689841612 654 d0 / data xgk ( 17) / 0.5263252843 3471918259 9623778158 010 d0 / data xgk ( 18) / 0.4730027314 4571496052 2182115009 192 d0 / data xgk ( 19) / 0.4178853821 9303774885 1814394594 572 d0 / data xgk ( 20) / 0.3611723058 0938783773 5821730127 641 d0 / data xgk ( 21) / 0.3030895389 3110783016 7478909980 339 d0 / data xgk ( 22) / 0.2438668837 2098843204 5190362797 452 d0 / data xgk ( 23) / 0.1837189394 2104889201 5969888759 528 d0 / data xgk ( 24) / 0.1228646926 1071039638 7359818808 037 d0 / data xgk ( 25) / 0.0615444830 0568507888 6546392366 797 d0 / data xgk ( 26) / 0.0000000000 0000000000 0000000000 000 d0 / c data wgk ( 1) / 0.0019873838 9233031592 6507851882 843 d0 / data wgk ( 2) / 0.0055619321 3535671375 8040236901 066 d0 / data wgk ( 3) / 0.0094739733 8617415160 7207710523 655 d0 / data wgk ( 4) / 0.0132362291 9557167481 3656405846 976 d0 / data wgk ( 5) / 0.0168478177 0912829823 1516667536 336 d0 / data wgk ( 6) / 0.0204353711 4588283545 6568292235 939 d0 / data wgk ( 7) / 0.0240099456 0695321622 0092489164 881 d0 / data wgk ( 8) / 0.0274753175 8785173780 2948455517 811 d0 / data wgk ( 9) / 0.0307923001 6738748889 1109020215 229 d0 / data wgk ( 10) / 0.0340021302 7432933783 6748795229 551 d0 / data wgk ( 11) / 0.0371162714 8341554356 0330625367 620 d0 / data wgk ( 12) / 0.0400838255 0403238207 4839284467 076 d0 / data wgk ( 13) / 0.0428728450 2017004947 6895792439 495 d0 / data wgk ( 14) / 0.0455029130 4992178890 9870584752 660 d0 / data wgk ( 15) / 0.0479825371 3883671390 6392255756 915 d0 / data wgk ( 16) / 0.0502776790 8071567196 3325259433 440 d0 / data wgk ( 17) / 0.0523628858 0640747586 4366712137 873 d0 / data wgk ( 18) / 0.0542511298 8854549014 4543370459 876 d0 / data wgk ( 19) / 0.0559508112 2041231730 8240686382 747 d0 / data wgk ( 20) / 0.0574371163 6156783285 3582693939 506 d0 / data wgk ( 21) / 0.0586896800 2239420796 1974175856 788 d0 / data wgk ( 22) / 0.0597203403 2417405997 9099291932 562 d0 / data wgk ( 23) / 0.0605394553 7604586294 5360267517 565 d0 / data wgk ( 24) / 0.0611285097 1705304830 5859030416 293 d0 / data wgk ( 25) / 0.0614711898 7142531666 1544131965 264 d0 / c note: wgk (26) was calculated from the values of wgk(1..25) data wgk ( 26) / 0.0615808180 6783293507 8759824240 066 d0 / c c c list of major variables c ----------------------- c c centr - mid point of the interval c hlgth - half-length of the interval c absc - abscissa c fval* - function value c resg - result of the 25-point gauss formula c resk - result of the 51-point kronrod formula c reskh - approximation to the mean value of f over (a,b), c i.e. to i/(b-a) c c machine dependent constants c --------------------------- c c epmach is the largest relative spacing. c uflow is the smallest positive magnitude. c c***first executable statement dqk51 epmach = d1mach(4) uflow = d1mach(1) c centr = 0.5d+00*(a+b) hlgth = 0.5d+00*(b-a) dhlgth = dabs(hlgth) c c compute the 51-point kronrod approximation to c the integral, and estimate the absolute error. c fc = f(centr) resg = wg(13)*fc resk = wgk(26)*fc resabs = dabs(resk) do 10 j=1,12 jtw = j*2 absc = hlgth*xgk(jtw) fval1 = f(centr-absc) fval2 = f(centr+absc) fv1(jtw) = fval1 fv2(jtw) = fval2 fsum = fval1+fval2 resg = resg+wg(j)*fsum resk = resk+wgk(jtw)*fsum resabs = resabs+wgk(jtw)*(dabs(fval1)+dabs(fval2)) 10 continue do 15 j = 1,13 jtwm1 = j*2-1 absc = hlgth*xgk(jtwm1) fval1 = f(centr-absc) fval2 = f(centr+absc) fv1(jtwm1) = fval1 fv2(jtwm1) = fval2 fsum = fval1+fval2 resk = resk+wgk(jtwm1)*fsum resabs = resabs+wgk(jtwm1)*(dabs(fval1)+dabs(fval2)) 15 continue reskh = resk*0.5d+00 resasc = wgk(26)*dabs(fc-reskh) do 20 j=1,25 resasc = resasc+wgk(j)*(dabs(fv1(j)-reskh)+dabs(fv2(j)-reskh)) 20 continue result = resk*hlgth resabs = resabs*dhlgth resasc = resasc*dhlgth abserr = dabs((resk-resg)*hlgth) if(resasc.ne.0.0d+00.and.abserr.ne.0.0d+00) * abserr = resasc*dmin1(0.1d+01,(0.2d+03*abserr/resasc)**1.5d+00) if(resabs.gt.uflow/(0.5d+02*epmach)) abserr = dmax1 * ((epmach*0.5d+02)*resabs,abserr) return end
bsd-3-clause
ensemblr/llvm-project-boilerplate
include/llvm/projects/test-suite/MultiSource/Benchmarks/ASC_Sequoia/sphot/rdinput.f
4
6793
subroutine rdinput( NRuns ) C---------------------------------------------------------------------- C The input deck is read by MPI task=0 as a derived datatype. It C is then sent to all other MPI tasks. This replaces the original C routine, which redirected stdin to every task, for portability C reasons. BMB 4/12/2001 C---------------------------------------------------------------------- include 'params.inc' include 'geomz.inc' include 'globals.inc' include 'mpif.h' character*24 dt character*127 mach INTEGER MPIid, ierr, InputFileType, basetypes(2), offsets(2), + blockcounts(2), extent, numMPItasks, + stat(MPI_STATUS_SIZE), + Nruns, matb1, mate1, matb2, mate2, i, filler20 C.....Define the structure InputFile and declare a variable of that C.....type. These will be used to create an MPI derived data type C.....so that the input file can be sent to each task from task=0. C.....Note that the i20 variable exists only for data alignment and C.....is not used elsewhere. TYPE InputFile SEQUENCE INTEGER i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13, + i14,i15,i16,i17,i18,i19,i20 DOUBLE PRECISION d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11, + d12,d13,d14 END TYPE InputFile TYPE (InputFile) Infile INTEGER nout parameter (nout=10) OPEN (4, FILE="input.dat") c open(nout,FILE='out_setup.txt',STATUS='UNKNOWN', c | ACCESS='SEQUENTIAL',FORM='FORMATTED') read(4,*) Nruns read (4,100) title 100 format(20a4) c write (nout,200) title 200 format(////1x,20a4) c write(nout,13) 13 format(/1x,' SPHOT') read (4,626) ilib, illib 626 format(2i10) c write (nout,627) ilib, illib 627 format(/ | /'ilib ', 8x,i2,3x,'library (0=binary, 1=formatted)', | / 18x, 'for ixopec=2, put ilib=1' | /'illib', 8x,i2,3x,'0=use old bin.lib,1=form new bin.lib') read (4,101) npart, igroup, ixopec, isorst, irr, ithom, icross 101 format(7i10) c write (nout,201) npart, igroup, ixopec, isorst, c | irr, ithom, icross 201 format( | /'npart ',i9,3x,'# of particles (different if plankian used)' | /'igroup',i9,3x,'energy bins (0=12, 1-12=1, 13=ross.mean)' | /'ixopec',i9,3x,'opacity (0=library, 1=input,2=data)' | /'isorst',i9,3x,'source (1=uniform in sphere, 2=plankian)' | /'irr ',i9,3x,'r-roulette/split (0=none, 1=impt, 2=size)' | /'ithom ',i9,3x,'thomson scattering (0=not used, 1=used)' | /'icross',i9,3x,'print cross sections (0= no, 1= yes)') read (4,102) naxl, nradl, nreg 102 format(3i10) c write (nout,202) naxl, nradl, nreg 202 format('naxl ',i10,3x,'number of axial meshes' | /'nradl',i10,3x,'number of radial meshes' | /'nreg ',i10,3x,'number of material regions') read (4,103) dtol, wcut, tcen, xmult 103 format(4e10.2) c write (nout,203) dtol, wcut, tcen, xmult 203 format( | /'dtol =',2x,e10.3,3x,'tolerance to cell boundaries (cm)' | /'wcut =',2x,e10.3,3x,'low weight cutoff' | /'tcen =',2x,e10.3,3x,'time to census (sec)' | /'xmult=',2x,e10.3,3x,'weight mult. for russian roulette') read (4,103) axl, radl, opec, bwgt c write (nout,204) axl, radl, opec, bwgt 204 format( | /'axl =',2x,e10.3,3x,'portion of sphere analyzed (degrees)' | /'radl =',2x,e10.3,3x,'sphere radius (cm)' | /'opec =',2x,e10.3,3x,'input opacity (1/cm)' | /'bwgt =',2x,e10.3,3x,'bundle weight (kev)') C.......For the purposes of the ASCI Purple Benchmark, it is mandatory C.......that nreg = 2. This is hardcoded into the derived datatype C.......and replaces the code below which permits an arbitrary number C.......of regions. C do 151 i = 1,nreg C read (4,104) matb, mate C104 format(2i10) C do 151 j = matb,mate C ng_mid(j) = i C151 continue nreg = 2 read (4,104) matb1, mate1 read (4,104) matb2, mate2 104 format(2i10) do 151 j = matb1, mate1 ng_mid(j) = 1 151 continue do 152 j = matb2, mate2 ng_mid(j) = 2 152 continue read (4,105) (mtl(i), atrat(i), dns(i), tmp(i), i=1,nreg) 105 format(i10,3e10.3) c write (nout,205) 205 format(//' region',5x,'material',5x,'atomic ratio',5x, | 'density(g/cc)',5x,'temperature(ev)'/) c write (nout,206) (i,mtl(i), atrat(i), dns(i), c | tmp(i), i=1,nreg) 206 format(i5,10x,i1,9x,e10.3,8x,e10.3,10x,e10.3) read (4,400) print_flag 400 format(i10) c write (nout,401) print_flag 401 format(//'print_flag ',i10) C........Be sure to close unit as it will be used in rdopac routine CLOSE (4) C........Transfer data to derived data type variable Infile = InputFile (Nruns, ilib, illib, npart, igroup, + ixopec, isorst, irr, ithom, icross, naxl, + nradl, nreg, matb1, mate1, matb2, mate2, + mtl(1), mtl(2), filler20, + dtol, wcut, tcen, xmult, axl, radl, opec, bwgt, + atrat(1), atrat(2), dns(1), dns(2), tmp(1), + tmp(2) ) c close(nout) Nruns = Infile%i1 ilib = Infile%i2 illib = Infile%i3 npart = Infile%i4 igroup = Infile%i5 ixopec = Infile%i6 isorst = Infile%i7 irr = Infile%i8 ithom = Infile%i9 icross = Infile%i10 naxl = Infile%i11 nradl = Infile%i12 nreg = Infile%i13 matb1 = Infile%i14 mate1 = Infile%i15 matb2 = Infile%i16 mate2 = Infile%i17 mtl(1) = Infile%i18 mtl(2) = Infile%i19 dtol = Infile%d1 wcut = Infile%d2 tcen = Infile%d3 xmult = Infile%d4 axl = Infile%d5 radl = Infile%d6 opec = Infile%d7 bwgt = Infile%d8 atrat(1) = Infile%d9 atrat(2) = Infile%d10 dns(1) = Infile%d11 dns(2) = Infile%d12 tmp(1) = Infile%d13 tmp(2) = Infile%d14 nreg = 2 do 351 j = matb1, mate1 ng_mid(j) = 1 351 continue do 352 j = matb2, mate2 ng_mid(j) = 2 352 continue C.....ALL TASKS DO THIS C.....Read in LLNL library opacities. The original IF condition C.....has been commented out for the purposes of the ASCI Purple C.....benchmark which MUST use the opacity library. C if (ixopec .eq. 0) then C CALL rdopac (ilib,illib) C endif ixopec = 0 CALL rdopac (ilib, illib) return end
mit
rofirrim/gcc-tiny
gcc/testsuite/gfortran.dg/list_read_4.f90
182
1552
! { dg-do run } ! Test of gfortran list directed read> check delimiters are correctly ! treated. Written in f77 so that g77 will run for comparison. ! ! f , e and i edit reads are terminated separately by read_real.c ! ! PThomas Jan 2005 ! BDavis program list_read_4 integer i(10),l(10),k,j real x(10),y(10) ! expected results data y / 1.0,2.0,3.0,-1.0,-1.0,-1.0,4.0,4.0,99.0,99.0 / data l /1,2,3,-1,-1,-1,4,4,99,99/ ! put them in a file open (10,status="scratch") write (10,*) " 1.0, 2.0 , 3.0,, 2* , 2*4.0 , 5*99.0" write (10,*) " 1.0e0, 2.0e0 , 3.0e0,, 2* , 2*4.0e0 , 5*99.0e0" write (10,*) " 1, 2 , 3,, 2* , 2*4 , 5*99" write (10,*) " 1, 2 , 3,, 2* , 2*4 , 5*99" rewind (10) ! do k = 1,10 x(k) = -1.0 enddo read (10,*,iostat=ier) x if (ier.ne.0) call abort do k = 1,10 if (x(k).ne.y(k)) call abort x(k) = -1 end do READ(10,*,iostat=ier) x if (ier.ne.0) call abort do k = 1,10 if (x(k).ne.y(k)) call abort x(k) = -1 end do READ(10,*,iostat=ier) x if (ier.ne.0) call abort do k = 1,10 if (x(k).ne.y(k)) call abort x(k) = -1 end do ! integer do k = 1,10 i(k) = -1 end do READ(10,*,iostat=ier) (i(j),j=1,10) if (ier.ne.0) call abort do k = 1,10 if (i(k).ne.y(k)) call abort i(k) = -1 end do end
gpl-2.0
foss-for-synopsys-dwc-arc-processors/gcc
gcc/testsuite/gfortran.dg/typebound_operator_11.f90
155
1035
! { dg-do compile } ! ! PR fortran/46328 ! ! Contributed by Damian Rouson ! module foo_module type ,abstract :: foo contains procedure(t_interface) ,deferred :: t procedure(assign_interface) ,deferred :: assign procedure(multiply_interface) ,deferred :: multiply generic :: operator(*) => multiply generic :: assignment(=) => assign end type abstract interface function t_interface(this) import :: foo class(foo) :: this class(foo), allocatable ::t_interface end function function multiply_interface(lhs,rhs) import :: foo class(foo), allocatable :: multiply_interface class(foo), intent(in) :: lhs real, intent(in) :: rhs end function subroutine assign_interface(lhs,rhs) import :: foo class(foo), intent(in) :: rhs class(foo), intent(inout) :: lhs end subroutine end interface contains subroutine bar(x,dt) class(foo) :: x real, intent(in) :: dt x = x%t()*dt end subroutine end module
gpl-2.0
rofirrim/gcc-tiny
gcc/testsuite/gfortran.dg/typebound_operator_11.f90
155
1035
! { dg-do compile } ! ! PR fortran/46328 ! ! Contributed by Damian Rouson ! module foo_module type ,abstract :: foo contains procedure(t_interface) ,deferred :: t procedure(assign_interface) ,deferred :: assign procedure(multiply_interface) ,deferred :: multiply generic :: operator(*) => multiply generic :: assignment(=) => assign end type abstract interface function t_interface(this) import :: foo class(foo) :: this class(foo), allocatable ::t_interface end function function multiply_interface(lhs,rhs) import :: foo class(foo), allocatable :: multiply_interface class(foo), intent(in) :: lhs real, intent(in) :: rhs end function subroutine assign_interface(lhs,rhs) import :: foo class(foo), intent(in) :: rhs class(foo), intent(inout) :: lhs end subroutine end interface contains subroutine bar(x,dt) class(foo) :: x real, intent(in) :: dt x = x%t()*dt end subroutine end module
gpl-2.0
buaabyl/lm8-gcc
gcc-4.4.3/gcc/testsuite/gfortran.dg/nan_3.f90
8
1151
! { dg-do run } ! { dg-options "-fno-range-check" } ! { dg-options "-fno-range-check -mieee" { target alpha*-*-* sh*-*-* } } ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } } ! ! PR fortran/34319 ! ! Check support of INF/NaN for I/O. ! program main implicit none real :: r complex :: z character(len=30) :: str str = "nan" read(str,*) r if (.not.isnan(r)) call abort() str = "(nan,4.0)" read(str,*) z if (.not.isnan(real(z)) .or. aimag(z) /= 4.0) call abort() str = "(7.0,nan)" read(str,*) z if (.not.isnan(aimag(z)) .or. real(z) /= 7.0) call abort() str = "inFinity" read(str,*) r if (r <= huge(r)) call abort() str = "(+inFinity,4.0)" read(str,*) z if ((real(z) <= huge(r)) .or. aimag(z) /= 4.0) call abort() str = "(7.0,-inFinity)" read(str,*) z if ((aimag(z) >= -huge(r)) .or. real(z) /= 7.0) call abort() str = "inf" read(str,*) r if (r <= huge(r)) call abort() str = "(+inf,4.0)" read(str,*) z if ((real(z) <= huge(r)) .or. aimag(z) /= 4.0) call abort() str = "(7.0,-inf)" read(str,*) z if ((aimag(z) >= -huge(r)) .or. real(z) /= 7.0) call abort() end program main
gpl-2.0
rofirrim/gcc-tiny
gcc/testsuite/gfortran.dg/class_optional_2.f90
133
21203
! { dg-do run } ! { dg-options "-fcoarray=single" } ! ! PR fortran/50981 ! PR fortran/54618 ! PR fortran/55978 implicit none type t integer, allocatable :: i end type t type, extends (t):: t2 integer, allocatable :: j end type t2 call s1a1() call s1a() call s1ac1() call s1ac() call s2() call s2p(psnt=.false.) call s2caf() call s2elem() call s2elem_t() call s2elem_t2() call s2t() call s2tp(psnt=.false.) call s2t2() call s2t2p(psnt=.false.) call a1a1() call a1a() call a1ac1() call a1ac() call a2() call a2p(psnt=.false.) call a2caf() call a3a1() call a3a() call a3ac1() call a3ac() call a4() call a4p(psnt=.false.) call a4caf() call ar1a1() call ar1a() call ar1ac1() call ar1ac() call ar() call art() call arp(psnt=.false.) call artp(psnt=.false.) contains subroutine s1a1(z, z2, z3, z4, z5) type(t), optional :: z, z4[*] type(t), pointer, optional :: z2 type(t), allocatable, optional :: z3, z5[:] type(t), allocatable :: x type(t), pointer :: y y => null() call s2(x) call s2(y) call s2(z) call s2(z2) call s2(z3) call s2(z4) call s2(z5) call s2p(y,psnt=.true.) call s2p(z2,psnt=.false.) call s2elem(x) call s2elem(y) call s2elem(z) call s2elem(z2) call s2elem(z3) call s2elem(z4) call s2elem(z5) call s2elem_t(x) call s2elem_t(y) call s2elem_t(z) ! call s2elem_t(z2) ! FIXME: Segfault ! call s2elem_t(z3) ! FIXME: Segfault ! call s2elem_t(z4) ! FIXME: Segfault ! call s2elem_t(z5) ! FIXME: Segfault call s2caf(z4) call s2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) call s2t(x) call s2t(y) call s2t(z) ! call s2t(z2) ! FIXME: Segfault ! call s2t(z3) ! FIXME: Segfault ! call s2t(z4) ! FIXME: Segfault ! call s2t(z5) ! FIXME: Segfault call s2tp(y,psnt=.true.) call s2tp(z2,psnt=.false.) end subroutine s1a1 subroutine s1a(z, z2, z3, z4, z5) type(t2), optional :: z, z4[*] type(t2), optional, pointer :: z2 type(t2), optional, allocatable :: z3, z5[:] type(t2), allocatable :: x type(t2), pointer :: y y => null() call s2(x) call s2(y) call s2(z) call s2(z2) call s2(z3) call s2(z4) call s2(z5) call s2p(y,psnt=.true.) call s2p(z2,psnt=.false.) call s2elem(x) call s2elem(y) call s2elem(z) call s2elem(z2) call s2elem(z3) call s2elem(z4) call s2elem(z5) call s2elem_t2(x) call s2elem_t2(y) call s2elem_t2(z) ! call s2elem_t2(z2) ! FIXME: Segfault ! call s2elem_t2(z3) ! FIXME: Segfault ! call s2elem_t2(z4) ! FIXME: Segfault ! call s2elem_t2(z5) ! FIXME: Segfault call s2caf(z4) call s2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) call s2t2(x) call s2t2(y) call s2t2(z) ! call s2t2(z2) ! FIXME: Segfault ! call s2t2(z3) ! FIXME: Segfault call s2t2(z4) ! call s2t2(z5) ! FIXME: Segfault call s2t2p(y,psnt=.true.) call s2t2p(z2,psnt=.false.) end subroutine s1a subroutine s1ac1(z, z2, z3, z4, z5) class(t), optional :: z, z4[*] class(t), optional, pointer :: z2 class(t), optional, allocatable :: z3, z5[:] class(t), allocatable :: x class(t), pointer :: y y => null() call s2(x) call s2(y) call s2(z) call s2(z2) call s2(z3) call s2(z4) call s2(z5) call s2p(y,psnt=.true.) call s2p(z2,psnt=.false.) call s2elem(x) call s2elem(y) call s2elem(z) call s2elem(z2) call s2elem(z3) call s2elem(z4) call s2elem(z5) call s2elem_t(x) call s2elem_t(y) ! call s2elem_t(z) ! FIXME: Segfault ! call s2elem_t(z2) ! FIXME: Segfault ! call s2elem_t(z3) ! FIXME: Segfault ! call s2elem_t(z4) ! FIXME: Segfault ! call s2elem_t(z5) ! FIXME: Segfault call s2caf(z4) call s2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) call s2t(x) call s2t(y) ! call s2t(z) ! FIXME: Segfault ! call s2t(z2) ! FIXME: Segfault ! call s2t(z3) ! FIXME: Segfault ! call s2t(z4) ! FIXME: Segfault ! call s2t(z5) ! FIXME: Segfault call s2tp(y,psnt=.true.) call s2tp(z2,psnt=.false.) end subroutine s1ac1 subroutine s1ac(z, z2, z3, z4, z5) class(t2), optional :: z, z4[*] class(t2), optional, pointer :: z2 class(t2), optional, allocatable :: z3, z5[:] class(t2), allocatable :: x class(t2), pointer :: y y => null() call s2(x) call s2(y) call s2(z) call s2(z2) call s2(z3) call s2(z4) call s2(z5) call s2p(y,psnt=.true.) call s2p(z2,psnt=.false.) call s2elem(x) call s2elem(y) call s2elem(z) call s2elem(z2) call s2elem(z3) call s2elem(z4) call s2elem(z5) call s2elem_t2(x) ! call s2elem_t2(y) ! FIXME: Segfault ! call s2elem_t2(z) ! FIXME: Segfault ! call s2elem_t2(z2) ! FIXME: Segfault ! call s2elem_t2(z3) ! FIXME: Segfault ! call s2elem_t2(z4) ! FIXME: Segfault ! call s2elem_t2(z5) ! FIXME: Segfault call s2caf(z4) call s2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) call s2t2(x) call s2t2(y) ! call s2t2(z) ! FIXME: Segfault ! call s2t2(z2) ! FIXME: Segfault ! call s2t2(z3) ! FIXME: Segfault ! call s2t2(z4) ! FIXME: Segfault ! call s2t2(z5) ! FIXME: Segfault call s2t2p(y,psnt=.true.) call s2t2p(z2,psnt=.false.) end subroutine s1ac subroutine s2(x) class(t), intent(in), optional :: x if (present (x)) call abort () !print *, present(x) end subroutine s2 subroutine s2p(x,psnt) class(t), intent(in), pointer, optional :: x logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine s2p subroutine s2caf(x) class(t), intent(in), optional :: x[*] if (present (x)) call abort () !print *, present(x) end subroutine s2caf subroutine s2t(x) type(t), intent(in), optional :: x if (present (x)) call abort () !print *, present(x) end subroutine s2t subroutine s2t2(x) type(t2), intent(in), optional :: x if (present (x)) call abort () !print *, present(x) end subroutine s2t2 subroutine s2tp(x, psnt) type(t), pointer, intent(in), optional :: x logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine s2tp subroutine s2t2p(x, psnt) type(t2), pointer, intent(in), optional :: x logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine s2t2p impure elemental subroutine s2elem(x) class(t), intent(in), optional :: x if (present (x)) call abort () !print *, present(x) end subroutine s2elem impure elemental subroutine s2elem_t(x) type(t), intent(in), optional :: x if (present (x)) call abort () !print *, present(x) end subroutine s2elem_t impure elemental subroutine s2elem_t2(x) type(t2), intent(in), optional :: x if (present (x)) call abort () !print *, present(x) end subroutine s2elem_t2 subroutine a1a1(z, z2, z3, z4, z5) type(t), optional :: z(:), z4(:)[*] type(t), optional, pointer :: z2(:) type(t), optional, allocatable :: z3(:), z5(:)[:] type(t), allocatable :: x(:) type(t), pointer :: y(:) y => null() call a2(x) call a2(y) call a2(z) call a2(z2) call a2(z3) call a2(z4) call a2(z5) call a2p(y,psnt=.true.) call a2p(z2,psnt=.false.) call a2caf(z4) call a2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Segfault ! call s2elem(y) ! FIXME: Segfault ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t(x) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t(y) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t(z) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t(z2) ! FIXME: Segfault ! call s2elem_t(z3) ! FIXME: Segfault ! call s2elem_t(z4) ! FIXME: Segfault ! call s2elem_t(z5) ! FIXME: Segfault end subroutine a1a1 subroutine a1a(z, z2, z3, z4, z5) type(t2), optional :: z(:), z4(:)[*] type(t2), optional, pointer :: z2(:) type(t2), optional, allocatable :: z3(:), z5(:)[:] type(t2), allocatable :: x(:) type(t2), pointer :: y(:) y => null() call a2(x) call a2(y) call a2(z) call a2(z2) call a2(z3) call a2(z4) call a2(z5) call a2p(y,psnt=.true.) call a2p(z2,psnt=.false.) call a2caf(z4) call a2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Segfault ! call s2elem(y) ! FIXME: Segfault ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t2(x) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t2(y) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t2(z) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t2(z2) ! FIXME: Segfault ! call s2elem_t2(z3) ! FIXME: Segfault ! call s2elem_t2(z4) ! FIXME: Segfault ! call s2elem_t2(z5) ! FIXME: Segfault end subroutine a1a subroutine a1ac1(z, z2, z3, z4, z5) class(t), optional :: z(:), z4(:)[*] class(t), optional, pointer :: z2(:) class(t), optional, allocatable :: z3(:), z5(:)[:] class(t), allocatable :: x(:) class(t), pointer :: y(:) y => null() call a2(x) call a2(y) call a2(z) call a2(z2) call a2(z3) call a2(z4) call a2(z5) call a2p(y,psnt=.true.) call a2p(z2,psnt=.false.) call a2caf(z4) call a2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Segfault ! call s2elem(y) ! FIXME: Segfault ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t(x) ! FIXME: Segfault ! call s2elem_t(y) ! FIXME: Segfault ! call s2elem_t(z) ! FIXME: Segfault ! call s2elem_t(z2) ! FIXME: Segfault ! call s2elem_t(z3) ! FIXME: Segfault ! call s2elem_t(z4) ! FIXME: Segfault ! call s2elem_t(z5) ! FIXME: Segfault end subroutine a1ac1 subroutine a1ac(z, z2, z3, z4, z5) class(t2), optional :: z(:), z4(:)[*] class(t2), optional, pointer :: z2(:) class(t2), optional, allocatable :: z3(:), z5(:)[:] class(t2), allocatable :: x(:) class(t2), pointer :: y(:) y => null() call a2(x) call a2(y) call a2(z) call a2(z2) call a2(z3) call a2(z4) call a2(z5) call a2p(y,psnt=.true.) call a2p(z2,psnt=.false.) call a2caf(z4) call a2caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Segfault ! call s2elem(y) ! FIXME: Segfault ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t2(x) ! FIXME: Segfault ! call s2elem_t2(y) ! FIXME: Segfault ! call s2elem_t2(z) ! FIXME: Segfault ! call s2elem_t2(z2) ! FIXME: Segfault ! call s2elem_t2(z3) ! FIXME: Segfault ! call s2elem_t2(z4) ! FIXME: Segfault ! call s2elem_t2(z5) ! FIXME: Segfault end subroutine a1ac subroutine a2(x) class(t), intent(in), optional :: x(:) if (present (x)) call abort () ! print *, present(x) end subroutine a2 subroutine a2p(x, psnt) class(t), pointer, intent(in), optional :: x(:) logical psnt if (present (x).neqv. psnt) call abort () ! print *, present(x) end subroutine a2p subroutine a2caf(x) class(t), intent(in), optional :: x(:)[*] if (present (x)) call abort () ! print *, present(x) end subroutine a2caf subroutine a3a1(z, z2, z3, z4, z5) type(t), optional :: z(4), z4(4)[*] type(t), optional, pointer :: z2(:) type(t), optional, allocatable :: z3(:), z5(:)[:] type(t), allocatable :: x(:) type(t), pointer :: y(:) y => null() call a4(x) call a4(y) call a4(z) call a4(z2) call a4(z3) call a4(z4) call a4(z5) call a4p(y,psnt=.true.) call a4p(z2,psnt=.false.) call a4t(x) call a4t(y) call a4t(z) ! call a4t(z2) ! FIXME: Segfault ! call a4t(z3) ! FIXME: Segfault ! call a4t(z4) ! FIXME: Segfault ! call a4t(z5) ! FIXME: Segfault call a4tp(y,psnt=.true.) call a4tp(z2,psnt=.false.) call a4caf(z4) call a4caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Segfault ! call s2elem(y) ! FIXME: Segfault ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t(x) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t(y) ! FIXME: Conditional jump or move depends on uninitialised value call s2elem_t(z) ! call s2elem_t(z2) ! FIXME: Segfault ! call s2elem_t(z3) ! FIXME: Segfault ! call s2elem_t(z4) ! FIXME: Segfault ! call s2elem_t(z5) ! FIXME: Segfault end subroutine a3a1 subroutine a3a(z, z2, z3) type(t2), optional :: z(4) type(t2), optional, pointer :: z2(:) type(t2), optional, allocatable :: z3(:) type(t2), allocatable :: x(:) type(t2), pointer :: y(:) y => null() call a4(x) call a4(y) call a4(z) call a4(z2) call a4(z3) call a4p(y,psnt=.true.) call a4p(z2,psnt=.false.) call a4t2(x) call a4t2(y) call a4t2(z) ! call a4t2(z2) ! FIXME: Segfault ! call a4t2(z3) ! FIXME: Segfault call a4t2p(y,psnt=.true.) call a4t2p(z2,psnt=.false.) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Segfault ! call s2elem(y) ! FIXME: Segfault ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t2(x) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t2(y) ! FIXME: Conditional jump or move depends on uninitialised value call s2elem_t2(z) ! call s2elem_t2(z2) ! FIXME: Segfault ! call s2elem_t2(z3) ! FIXME: Segfault ! call s2elem_t2(z4) ! FIXME: Segfault ! call s2elem_t2(z5) ! FIXME: Segfault end subroutine a3a subroutine a3ac1(z, z2, z3, z4, z5) class(t), optional :: z(4), z4(4)[*] class(t), optional, pointer :: z2(:) class(t), optional, allocatable :: z3(:), z5(:)[:] class(t), allocatable :: x(:) class(t), pointer :: y(:) y => null() call a4(x) call a4(y) call a4(z) call a4(z2) call a4(z3) call a4(z4) call a4(z5) call a4p(y,psnt=.true.) call a4p(z2,psnt=.false.) ! call a4t(x) ! FIXME: Segfault ! call a4t(y) ! FIXME: Segfault ! call a4t(z) ! FIXME: Segfault ! call a4t(z2) ! FIXME: Segfault ! call a4t(z3) ! FIXME: Segfault ! call a4t(z4) ! FIXME: Segfault ! call a4t(z5) ! FIXME: Segfault ! call a4tp(y,psnt=.true.) ! FIXME: Segfault ! call a4tp(z2,psnt=.false.) ! FIXME: Segfault call a4caf(z4) call a4caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) ! call s2elem(x) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem(y) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem(z) ! FIXME: Segfault ! call s2elem(z2) ! FIXME: Segfault ! call s2elem(z3) ! FIXME: Segfault ! call s2elem(z4) ! FIXME: Segfault ! call s2elem(z5) ! FIXME: Segfault ! call s2elem_t(x) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t(y) ! FIXME: Conditional jump or move depends on uninitialised value ! call s2elem_t(z) ! FIXME: Segfault ! call s2elem_t(z2) ! FIXME: Segfault ! call s2elem_t(z3) ! FIXME: Segfault ! call s2elem_t(z4) ! FIXME: Segfault ! call s2elem_t(z5) ! FIXME: Segfault end subroutine a3ac1 subroutine a3ac(z, z2, z3, z4, z5) class(t2), optional :: z(4), z4(4)[*] class(t2), optional, pointer :: z2(:) class(t2), optional, allocatable :: z3(:), z5(:)[:] class(t2), allocatable :: x(:) class(t2), pointer :: y(:) y => null() call a4(x) call a4(y) call a4(z) call a4(z2) call a4(z3) call a4(z4) call a4(z5) call a4p(y,psnt=.true.) call a4p(z2,psnt=.false.) ! call a4t2(x) ! FIXME: Segfault ! call a4t2(y) ! FIXME: Segfault ! call a4t2(z) ! FIXME: Segfault ! call a4t2(z2) ! FIXME: Segfault ! call a4t2(z3) ! FIXME: Segfault ! call a4t2(z4) ! FIXME: Segfault ! call a4t2(z5) ! FIXME: Segfault ! call a4t2p(y,psnt=.true.) ! FIXME: Segfault ! call a4t2p(z2,psnt=.false.) ! FIXME: Segfault call a4caf(z4) call a4caf(z5) call ar(x) call ar(y) call ar(z) call ar(z2) call ar(z3) call ar(z4) call ar(z5) call arp(y,psnt=.true.) call arp(z2,psnt=.false.) end subroutine a3ac subroutine a4(x) class(t), intent(in), optional :: x(4) if (present (x)) call abort () !print *, present(x) end subroutine a4 subroutine a4p(x, psnt) class(t), pointer, intent(in), optional :: x(:) logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine a4p subroutine a4caf(x) class(t), intent(in), optional :: x(4)[*] if (present (x)) call abort () !print *, present(x) end subroutine a4caf subroutine a4t(x) type(t), intent(in), optional :: x(4) if (present (x)) call abort () !print *, present(x) end subroutine a4t subroutine a4t2(x) type(t2), intent(in), optional :: x(4) if (present (x)) call abort () !print *, present(x) end subroutine a4t2 subroutine a4tp(x, psnt) type(t), pointer, intent(in), optional :: x(:) logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine a4tp subroutine a4t2p(x, psnt) type(t2), pointer, intent(in), optional :: x(:) logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine a4t2p subroutine ar(x) class(t), intent(in), optional :: x(..) if (present (x)) call abort () !print *, present(x) end subroutine ar subroutine art(x) type(t), intent(in), optional :: x(..) if (present (x)) call abort () !print *, present(x) end subroutine art subroutine arp(x, psnt) class(t), pointer, intent(in), optional :: x(..) logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine arp subroutine artp(x, psnt) type(t), intent(in), pointer, optional :: x(..) logical psnt if (present (x).neqv. psnt) call abort () !print *, present(x) end subroutine artp subroutine ar1a1(z, z2, z3) type(t), optional :: z(..) type(t), pointer, optional :: z2(..) type(t), allocatable, optional :: z3(..) call ar(z) call ar(z2) call ar(z3) call art(z) call art(z2) call art(z3) call arp(z2, .false.) call artp(z2, .false.) end subroutine ar1a1 subroutine ar1a(z, z2, z3) type(t2), optional :: z(..) type(t2), optional, pointer :: z2(..) type(t2), optional, allocatable :: z3(..) call ar(z) call ar(z2) call ar(z3) call arp(z2, .false.) end subroutine ar1a subroutine ar1ac1(z, z2, z3) class(t), optional :: z(..) class(t), optional, pointer :: z2(..) class(t), optional, allocatable :: z3(..) call ar(z) call ar(z2) call ar(z3) ! call art(z) ! FIXME: ICE - This requires packing support for assumed-rank ! call art(z2)! FIXME: ICE - This requires packing support for assumed-rank ! call art(z3)! FIXME: ICE - This requires packing support for assumed-rank call arp(z2, .false.) ! call artp(z2, .false.) ! FIXME: ICE end subroutine ar1ac1 subroutine ar1ac(z, z2, z3) class(t2), optional :: z(..) class(t2), optional, pointer :: z2(..) class(t2), optional, allocatable :: z3(..) call ar(z) call ar(z2) call ar(z3) call arp(z2, .false.) end subroutine ar1ac end
gpl-2.0
rofirrim/gcc-tiny
gcc/testsuite/gfortran.dg/iso_fortran_env_1.f90
136
1193
! { dg-do run } module iso_fortran_env real :: x end module iso_fortran_env subroutine bar use , intrinsic :: iso_fortran_env implicit none if (file_storage_size /= 8) call abort if (character_storage_size /= 8) call abort if (all (numeric_storage_size /= [ 8, 16, 32, 64, 128])) call abort if (input_unit /= 5) call abort if (output_unit /= 6) call abort if (error_unit /= 0) call abort if (iostat_end /= -1) call abort if (iostat_eor /= -2) call abort end subroutine bar2 use , intrinsic :: iso_fortran_env, only : file_storage_size, & character_storage_size, numeric_storage_size, input_unit, output_unit, & error_unit, iostat_end, iostat_eor implicit none if (file_storage_size /= 8) call abort if (character_storage_size /= 8) call abort if (all (numeric_storage_size /= [ 8, 16, 32, 64, 128])) call abort if (input_unit /= 5) call abort if (output_unit /= 6) call abort if (error_unit /= 0) call abort if (iostat_end /= -1) call abort if (iostat_eor /= -2) call abort end program test use , intrinsic :: iso_fortran_env, uu => output_unit implicit none if (input_unit /= 5 .or. uu /= 6) call abort call bar call bar2 end
gpl-2.0
rofirrim/gcc-tiny
gcc/testsuite/gfortran.dg/goacc/routine-5.f90
3
1956
! Test invalid intra-routine parallellism. module param integer, parameter :: N = 32 end module param subroutine gang (a) !$acc routine gang integer, intent (inout) :: a(N) integer :: i !$acc loop do i = 1, N a(i) = a(i) - a(i) end do !$acc loop gang do i = 1, N a(i) = a(i) - a(i) end do !$acc loop worker do i = 1, N a(i) = a(i) - a(i) end do !$acc loop vector do i = 1, N a(i) = a(i) - a(i) end do end subroutine gang subroutine worker (a) !$acc routine worker integer, intent (inout) :: a(N) integer :: i !$acc loop do i = 1, N a(i) = a(i) - a(i) end do !$acc loop gang ! { dg-error "disallowed by containing routine" } do i = 1, N a(i) = a(i) - a(i) end do !$acc loop worker do i = 1, N a(i) = a(i) - a(i) end do !$acc loop vector do i = 1, N a(i) = a(i) - a(i) end do end subroutine worker subroutine vector (a) !$acc routine vector integer, intent (inout) :: a(N) integer :: i !$acc loop do i = 1, N a(i) = a(i) - a(i) end do !$acc loop gang ! { dg-error "disallowed by containing routine" } do i = 1, N a(i) = a(i) - a(i) end do !$acc loop worker ! { dg-error "disallowed by containing routine" } do i = 1, N a(i) = a(i) - a(i) end do !$acc loop vector do i = 1, N a(i) = a(i) - a(i) end do end subroutine vector subroutine seq (a) !$acc routine seq integer, intent (inout) :: a(N) integer :: i !$acc loop ! { dg-warning "insufficient partitioning" } do i = 1, N a(i) = a(i) - a(i) end do !$acc loop gang ! { dg-error "disallowed by containing routine" } do i = 1, N a(i) = a(i) - a(i) end do !$acc loop worker ! { dg-error "disallowed by containing routine" } do i = 1, N a(i) = a(i) - a(i) end do !$acc loop vector ! { dg-error "disallowed by containing routine" } do i = 1, N a(i) = a(i) - a(i) end do end subroutine seq
gpl-2.0
foss-for-synopsys-dwc-arc-processors/gcc
libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90
12
1422
! { dg-do run } module e_52_1_mod contains subroutine init (v1, v2, N) integer :: i, N real :: v1(N), v2(N) do i = 1, N v1(i) = i + 2.0 v2(i) = i - 3.0 end do end subroutine subroutine init_again (v1, v2, N) integer :: i, N real :: v1(N), v2(N) do i = 1, N v1(i) = i - 3.0 v2(i) = i + 2.0 end do end subroutine subroutine check (p, N) integer :: i, N real, parameter :: EPS = 0.00001 real :: diff, p(N) do i = 1, N diff = p(i) - 2 * (i + 2.0) * (i - 3.0) if (diff > EPS .or. -diff > EPS) stop 1 end do end subroutine subroutine vec_mult (p, v1, v2, N) real :: p(N), v1(N), v2(N) integer :: i, N call init (v1, v2, N) !$omp target data map(to: v1, v2) map(from: p) !$omp target !$omp parallel do do i = 1, N p(i) = v1(i) * v2(i) end do !$omp end target call init_again (v1, v2, N) !$omp target update to(v1, v2) !$omp target !$omp parallel do do i = 1, N p(i) = p(i) + v1(i) * v2(i) end do !$omp end target !$omp end target data call check (p, N) end subroutine end module program e_52_1 use e_52_1_mod, only : vec_mult integer :: n real, pointer :: p(:), v1(:), v2(:) n = 1000 allocate (p(n), v1(n), v2(n)) call vec_mult (p, v1, v2, n) deallocate (p, v1, v2) end program
gpl-2.0
unofficial-opensource-apple/gcc_os
gcc/testsuite/g77.dg/20010216-1.f
10
1404
C Test for bug in reg-stack handling conditional moves. C Reported by Tim Prince <[email protected]> C C { dg-do run { target "i[6789]86-*-*" } } C { dg-options "-ffast-math -march=pentiumpro" } double precision function foo(x, y) implicit none double precision x, y double precision a, b, c, d if (x /= y) then if (x * y >= 0) then a = abs(x) b = abs(y) c = max(a, b) d = min(a, b) foo = 1 - d/c else foo = 1 end if else foo = 0 end if end program test implicit none integer ntests parameter (ntests=7) double precision tolerance parameter (tolerance=1.0D-6) C Each column is a pair of values to feed to foo, C and its expected return value. double precision a(ntests) /1, -23, -1, 1, 9, 10, -9/ double precision b(ntests) /1, -23, 12, -12, 10, 9, -10/ double precision x(ntests) /0, 0, 1, 1, 0.1, 0.1, 0.1/ double precision foo double precision result integer i do i = 1, ntests result = foo(a(i), b(i)) if (abs(result - x(i)) > tolerance) then print *, i, a(i), b(i), x(i), result call abort end if end do end
gpl-2.0